agent-office-studio 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +0 -1
- package/dist/assets/index-Cdivbl1d.css +1 -0
- package/dist/assets/{index-S_6NhxZ0.js → index-CfqwI0KM.js} +260 -255
- package/dist/index.html +10 -23
- package/docs/README.md +0 -1
- package/docs/claude-access.md +1 -2
- package/docs/configuration.md +1 -5
- package/docs/getting-started.md +0 -1
- package/docs/guides/troubleshooting.md +0 -10
- package/docs/guides/updating.md +0 -2
- package/docs/how-it-works.md +0 -2
- package/docs/linked-offices.md +1 -1
- package/docs/packaging.md +3 -4
- package/docs/phone.md +1 -2
- package/docs/security.md +1 -7
- package/docs/using-the-office.md +1 -1
- package/package.json +1 -6
- package/server/icons.js +82 -0
- package/server/index.js +11 -25
- package/dist/assets/_commonjsHelpers-CqkleIqs.js +0 -1
- package/dist/assets/addon-fit-BwprjgOP.js +0 -1
- package/dist/assets/index-CiEWLydu.css +0 -32
- package/dist/assets/xterm-C7kOH91j.js +0 -9
- package/docs/terminal.md +0 -46
- package/server/terminal.js +0 -255
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/xterm-C7kOH91j.js","assets/_commonjsHelpers-CqkleIqs.js","assets/addon-fit-BwprjgOP.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var Vp=Object.defineProperty;var Gp=(i,t,e)=>t in i?Vp(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var _e=(i,t,e)=>Gp(i,typeof t!="symbol"?t+"":t,e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))n(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&n(a)}).observe(document,{childList:!0,subtree:!0});function e(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function n(s){if(s.ep)return;s.ep=!0;const r=e(s);fetch(s.href,r)}})();"serviceWorker"in navigator&&addEventListener("load",()=>navigator.serviceWorker.register("/sw.js").catch(()=>{}));const ef=[{id:"paper",name:"Paper"},{id:"ocean",name:"Ocean"},{id:"forest",name:"Forest"},{id:"sunset",name:"Sunset"},{id:"lavender",name:"Lavender"}],nh=[{id:"light",name:"Light"},{id:"dark",name:"Dark"},{id:"auto",name:"Auto"}],qo=document.documentElement,nf=matchMedia("(prefers-color-scheme: dark)"),sf=(i,t,e)=>{try{const n=localStorage.getItem(i);return e.some(s=>s.id===n)?n:t}catch{return t}},nu=(i,t)=>{try{localStorage.setItem(i,t)}catch{}};try{if(localStorage.getItem("office.appearance")===null){const i=localStorage.getItem("office.mode");nh.some(t=>t.id===i)&&(localStorage.setItem("office.appearance",i),localStorage.removeItem("office.mode"))}}catch{}let Zl=sf("office.theme","paper",ef),ia=sf("office.appearance","auto",nh);const Xr=document.getElementById("themeBtn"),Rn=document.getElementById("themePop");function mo(){const i=ia==="dark"||ia==="auto"&&nf.matches?"dark":"light";qo.dataset.theme=Zl,qo.dataset.mode=i;const t=document.querySelector('meta[name="theme-color"]');t&&(t.content=getComputedStyle(qo).getPropertyValue("--paper").trim()||t.content),$p()}function $p(){if(!Rn)return;Rn.replaceChildren();const i=e=>Object.assign(document.createElement("p"),{className:"theme-k",textContent:e}),t=(e,n,s,r)=>{const a=document.createElement("div");a.className=r,a.setAttribute("role","radiogroup");for(const o of e){const l=document.createElement("button");l.type="button",l.dataset.t=o.id,l.setAttribute("role","radio"),l.setAttribute("aria-checked",String(o.id===n)),l.innerHTML=r==="theme-swatches"?"<i></i><span></span>":"<span></span>",l.querySelector("span").textContent=o.name,l.addEventListener("click",()=>s(o.id)),a.appendChild(l)}return a};Rn.append(i("Theme"),t(ef,Zl,e=>{Zl=e,nu("office.theme",e),mo()},"theme-swatches"),i("Mode"),t(nh,ia,e=>{ia=e,nu("office.appearance",e),mo()},"theme-modes"))}function ih(i){var t;Rn.hidden=!i,Xr.setAttribute("aria-expanded",String(i)),i&&((t=Rn.querySelector('[aria-checked="true"]'))==null||t.focus())}Xr==null||Xr.addEventListener("click",i=>{i.stopPropagation(),ih(Rn.hidden)});Rn==null||Rn.addEventListener("click",i=>i.stopPropagation());document.addEventListener("click",()=>{Rn&&!Rn.hidden&&ih(!1)});document.addEventListener("keydown",i=>{i.key==="Escape"&&Rn&&!Rn.hidden&&(ih(!1),Xr.focus())});nf.addEventListener("change",()=>{ia==="auto"&&mo()});mo();const lr=document.getElementById("acctBtn"),Pe=document.getElementById("acctPop"),Wp=[{id:"login",name:"Claude Code login"},{id:"apikey",name:"API key"}];let Tn=null,go=null,Ss=!1,Kn="",Yi=null;const We=(i,t={})=>Object.assign(document.createElement(i),t);function Ii(){if(!Pe)return;if(!Tn){Pe.replaceChildren(We("p",{className:"theme-k",textContent:"Claude access"}),We("p",{className:"acct-note",textContent:Kn||"Checking…"}));return}const i=go||Tn.mode;Pe.replaceChildren();const t=We("div",{className:"theme-modes acct-modes"});t.setAttribute("role","radiogroup");for(const n of Wp){const s=We("button",{type:"button"});s.setAttribute("role","radio"),s.setAttribute("aria-checked",String(n.id===i)),s.append(We("span",{textContent:n.name})),s.addEventListener("click",()=>{go=n.id,Kn="",n.id==="login"||Tn.keySet?Ko({mode:n.id}):Ii()}),t.append(s)}Pe.append(We("p",{className:"theme-k",textContent:"Claude access"}),t);const e=(n,s="acct-note")=>Pe.append(We("p",{className:s,textContent:n}));if(i==="login")e("Jobs run on your Claude plan, using the login Claude Code keeps on this machine. If it isn’t signed in yet, run claude once in a terminal.");else{Tn.keySet&&Tn.mode==="apikey"?e(`Using the key ending ${Tn.keyHint}${Tn.keyFrom==="env"?", from ANTHROPIC_API_KEY":""}. Jobs are billed to that API account.`):e("Jobs are billed to the API account the key belongs to. It is kept on this machine only.");const n=We("form",{className:"acct-form"}),s=We("input",{type:"password",placeholder:Tn.keySet?"Replace with another key":"sk-ant-…",autocomplete:"off",spellcheck:!1});s.setAttribute("aria-label","Anthropic API key");const r=We("button",{type:"submit",className:"primary small",textContent:Ss?"Checking…":"Save",disabled:Ss});if(n.append(s,r),n.addEventListener("submit",a=>{a.preventDefault(),s.value.trim()&&Ko({mode:"apikey",key:s.value})}),Pe.append(n),Tn.keyFrom==="office"){const a=We("button",{type:"button",className:"acct-forget",textContent:"Forget this key"});a.addEventListener("click",()=>Ko(null)),Pe.append(a)}Ss||queueMicrotask(()=>{Tn.keySet||s.focus()})}Kn&&e(Kn,"acct-note acct-err"),Pe.append(We("p",{className:"acct-note acct-fine",textContent:"Jobs already running finish the way they started."})),Xp()}function Xp(){if(!Yi)return;Pe.append(We("p",{className:"theme-k",textContent:"Context limit"}));const i=We("form",{className:"acct-form"}),t=We("input",{type:"number",min:0,step:1e4,value:Yi.tokens,required:!0});t.setAttribute("aria-label","Context limit in tokens");const e=We("button",{type:"submit",className:"primary small",textContent:"Save"});if(i.append(t,e),i.addEventListener("submit",n=>{n.preventDefault();const s=Number(t.value);Number.isInteger(s)&&s>=0?iu(s):(Kn="Use a whole number of tokens, or 0 to turn it off.",Ii())}),Pe.append(i,We("p",{className:"acct-note acct-fine",textContent:Yi.tokens?`Agents are nudged to clear their context past ${Yi.tokens.toLocaleString()} tokens.`:"Off: agents are never nudged to clear their context."})),Yi.custom){const n=We("button",{type:"button",className:"acct-forget",textContent:`Back to the default (${Yi.default.toLocaleString()})`});n.addEventListener("click",()=>iu(null)),Pe.append(n)}}async function iu(i){Kn="";try{const t=await fetch("/api/context-limit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tokens:i})}),e=await t.json();if(!t.ok)throw new Error(e.error||"That didn’t save.");Yi=e}catch(t){Kn=t.message}Ii()}function Yo(i){i&&(Yi=i,!Ss&&Pe&&!Pe.hidden&&Ii())}async function Ko(i){Ss=!0,Kn="",Ii();try{const t=await fetch("/api/auth",i?{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i)}:{method:"DELETE"}),e=await t.json();if(!t.ok)throw new Error(e.error||"That didn’t save.");Tn=e,go=null}catch(t){Kn=t.message}Ss=!1,Ii()}function Jl(i){i&&(Tn=i,Ss||Ii())}function Lo(i){var t;Pe.hidden=!i,lr.setAttribute("aria-expanded",String(i)),i||(go=null,Kn=""),Ii(),i&&((t=Pe.querySelector('[aria-checked="true"]'))==null||t.focus()),i&&!Tn&&fetch("/api/auth").then(e=>e.ok?e.json():Promise.reject()).then(Jl,()=>{Kn="Restart the office server to choose this.",Ii()})}lr==null||lr.addEventListener("click",()=>Lo(Pe.hidden));var Jd;(Jd=document.getElementById("themeBtn"))==null||Jd.addEventListener("click",()=>{Pe.hidden||Lo(!1)});document.addEventListener("click",i=>{Pe&&!Pe.hidden&&!Pe.contains(i.target)&&!lr.contains(i.target)&&Lo(!1)});document.addEventListener("keydown",i=>{i.key==="Escape"&&Pe&&!Pe.hidden&&(Lo(!1),lr.focus())});const cr=document.getElementById("linkBtn"),Ue=document.getElementById("linkPop"),Zo=document.getElementById("app"),sh=[{id:"plan",name:"Plan only"},{id:"edit",name:"Edit files"},{id:"auto",name:"Full autonomy"}],sa={plan:0,edit:1,auto:2},jp=2e6,qp=/^[0-9A-HJKMNP-TV-Z]{8}$/;let Zn=null,Gr={},Pi=null,ns=null,Li=null,hr=null,hn="",fi="",vo=!1;const Pt=(i,t={},...e)=>{const n=Object.assign(document.createElement(i),t);return n.append(...e.filter(s=>s!=null&&s!==!1)),n},Fn=(i,t="acct-note")=>Pt("p",{className:t,textContent:i});async function ki(i,t,e){const n=t===void 0?{method:e||"GET"}:{method:e||"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)},s=await fetch(i,n),r=await s.json().catch(()=>({}));if(!s.ok)throw new Error(r.error||(s.status===404?"Restart the office server to use links.":"That didn’t work."));return r}function Yp(i){const t=String(i||"").toUpperCase().replace(/[\s-]+/g,"").replace(/[IL]/g,"1").replace(/O/g,"0");return qp.test(t)?t:null}const Kp=i=>{const t=String(i).toUpperCase().replace(/-/g,"");return`${t.slice(0,4)}-${t.slice(4)}`};function Ql(i){return i>=1e6?`${+(i/1e6).toFixed(1)}M`:i>=1e3?`${Math.round(i/1e3)}k`:String(i)}function Zp(i){const t=typeof i=="number"?i:Date.parse(i);if(!t)return"";const e=t-Date.now();if(e<=0)return"Expired. Make a new one.";const n=Math.ceil(e/6e4),s=Math.floor(n/60),r=n%60,a=new Date(t).toLocaleString([],{weekday:"short",hour:"numeric",minute:"2-digit"});return`Works once. Expires in ${s?`${s} h ${r} min`:`${r} min`} (${a}).`}function Jp(i){var n,s;const t=((n=i.repos)==null?void 0:n.length)||0,e=((s=sh.find(r=>r.id===i.clearance))==null?void 0:s.name)||i.clearance;return`${t===1?i.repos[0]:`${t} projects`} · ${e} · ${Ql(i.tokensPerDay||0)} tokens a day`}function Qp(i){return i.kind!=="guest"?"Linked office":i.role==="guest"?"Guest · you visit them":"Guest · they visit you"}function sn(){if(!Ue||Ue.hidden)return;const i=Gr.handle||(Pi==null?void 0:Pi.handle);Ue.replaceChildren(Pt("p",{className:"theme-k",textContent:"Linked offices"})),i?(Ue.append(Pt("p",{className:"lb-me"},"This office is ",Pt("strong",{textContent:`@${i}`}))),Ue.append(em()),ns&&Ue.append(nm()),Li&&Ue.append(sm())):Ue.append(...tm()),fi&&Ue.append(Fn(fi,"acct-note acct-err")),Gr.error?Ue.append(Fn(`Link service: ${Gr.error}`,"acct-note acct-err")):Zn!=null&&Zn.length&&Gr.connected===!1&&Ue.append(Fn("Connecting to the link service…","acct-note acct-fine")),Ue.append(rm())}function tm(){const i=[Fn("Linked offices see each other’s agents walk in as visitors, and a guest can run jobs here within the limits you set. First, pick a handle for this office.")];if(Pi&&!Pi.configured)return[...i,Fn("This office has no link service set up.","acct-note acct-err")];const t=Pt("form",{className:"acct-form"}),e=Pt("input",{type:"text",placeholder:"Pick a handle",autocomplete:"off",spellcheck:!1,maxLength:20});return e.setAttribute("aria-label","Handle"),t.append(e,Pt("button",{type:"submit",className:"primary small",textContent:hn==="claim"?"Claiming…":"Claim",disabled:!!hn})),t.addEventListener("submit",async n=>{n.preventDefault(),e.value.trim()&&await Do("claim",async()=>{om(await ki("/api/leaderboard/handle",{handle:e.value.trim()}),!0),_r(await ki("/api/links"))})}),[...i,t,Fn("Claiming a handle doesn’t put you on the leaderboard. Sharing your counters there is a separate choice.","acct-note acct-fine")]}function em(){const i=Pt("div",{className:"link-actions"}),t=Pt("button",{type:"button",className:"ghost small",textContent:hn==="link"?"Making a code…":"Invite an office",disabled:!!hn});t.addEventListener("click",()=>{Li=null,rf("link")});const e=Pt("button",{type:"button",className:"ghost small",textContent:"Invite a guest",disabled:!!hn});e.setAttribute("aria-expanded",String(!!Li)),e.addEventListener("click",im);const n=Pt("form",{className:"acct-form link-redeem"}),s=Pt("input",{type:"text",placeholder:"Enter a code, e.g. K7QX-M2PD",autocomplete:"off",spellcheck:!1,maxLength:12});return s.setAttribute("aria-label","Invite code"),n.append(s,Pt("button",{type:"submit",className:"primary small",textContent:hn==="redeem"?"Linking…":"Link",disabled:!!hn})),n.addEventListener("submit",r=>{r.preventDefault();const a=Yp(s.value);if(!a){fi="A code is 8 letters and numbers, like K7QX-M2PD.",sn();return}Do("redeem",async()=>{_r(await ki("/api/links/redeem",{code:a})),ns=null})}),i.append(Pt("div",{className:"link-row"},t,e),n),i}function nm(){const i=Pt("div",{className:"link-code"}),t=Kp(ns.code),e=Pt("button",{type:"button",className:"ghost small",textContent:vo?"Copied":"Copy"});return e.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(t),vo=!0}catch{fi="Couldn’t copy. Select the code and copy it by hand."}sn()}),i.append(Pt("p",{className:"theme-k",textContent:ns.kind==="guest"?"Guest code":"Office code"}),Pt("div",{className:"link-code-row"},Pt("output",{className:"link-code-v",textContent:t}),e),Fn(`${ns.kind==="guest"?"Give this to your guest. They enter it in their own office.":"Give this to the other office. They enter it under Linked offices."} ${Zp(ns.expiresAt)}`,"acct-note acct-fine")),i}async function im(){if(Li){Li=null,sn();return}if(Li={repos:new Set,clearance:"edit",full:!1,tokensPerDay:jp},ns=null,sn(),!hr){try{hr=(await ki("/api/repos")).repos||[]}catch(i){hr=[],fi=i.message}sn()}}function sm(){const i=Li,t=Pt("form",{className:"link-guest"});t.append(Pt("p",{className:"theme-k",textContent:"Invite a guest"}),Fn("A guest can start jobs with your agents in the projects you pick, at or below the clearance you set. Their jobs run on your Claude account.","acct-note acct-fine"));const e=Pt("fieldset",{className:"link-repos"},Pt("legend",{textContent:`Projects they can use (${i.repos.size} picked)`}));hr?hr.length||e.append(Fn("No projects found.","acct-note acct-fine")):e.append(Fn("Loading…","acct-note acct-fine"));for(const c of hr||[]){const h=Pt("input",{type:"checkbox",checked:i.repos.has(c)});h.addEventListener("change",()=>{h.checked?i.repos.add(c):i.repos.delete(c),sn()}),e.append(Pt("label",{},h,Pt("span",{textContent:c})))}const n=Pt("div",{className:"theme-modes acct-modes link-cap"});n.setAttribute("role","radiogroup"),n.setAttribute("aria-label","Clearance cap");for(const c of sh.slice(0,2)){const h=Pt("button",{type:"button",textContent:c.name,disabled:i.full});h.setAttribute("role","radio"),h.setAttribute("aria-checked",String(!i.full&&i.clearance===c.id)),h.addEventListener("click",()=>{i.clearance=c.id,sn()}),n.append(h)}const s=Pt("input",{type:"checkbox",checked:i.full});s.addEventListener("change",()=>{i.full=s.checked,sn()});const r=Pt("div",{className:"link-warn"},Pt("p",{textContent:"Full autonomy lets the guest run any command on this machine, with your files and your logins. Only allow it for someone you’d hand your laptop to."}),Pt("label",{},s,Pt("span",{textContent:"Allow full autonomy anyway"}))),a=Pt("input",{type:"number",min:1e5,step:1e5,value:i.tokensPerDay,required:!0});a.setAttribute("aria-label","Tokens per day");const o=Pt("span",{className:"acct-fine",textContent:Ql(i.tokensPerDay)});a.addEventListener("input",()=>{i.tokensPerDay=Math.floor(Number(a.value))||0,o.textContent=Ql(i.tokensPerDay)});const l=i.repos.size>0&&!hn;return t.append(e,Pt("p",{className:"link-k",textContent:"Clearance cap"}),n,r,Pt("label",{className:"link-k link-tokens"},Pt("span",{textContent:"Tokens per day"}),a,o),Pt("div",{className:"link-row"},Pt("button",{type:"submit",className:"primary small",textContent:hn==="guest"?"Making a code…":"Make guest code",disabled:!l}),i.repos.size?null:Pt("span",{className:"acct-fine",textContent:"Pick at least one project."}))),t.addEventListener("submit",c=>{if(c.preventDefault(),!i.repos.size||i.tokensPerDay<1e5){fi=i.repos.size?"Allow at least 100,000 tokens a day.":"Pick at least one project.",sn();return}rf("guest",{repos:[...i.repos],clearance:i.full?"auto":i.clearance,tokensPerDay:i.tokensPerDay})}),t}function rm(){const i=Pt("div",{className:"lb-board"});if(!Zn)return i.append(Fn("Loading links…","acct-note acct-fine")),i;if(!Zn.length)return i.append(Fn("No links yet.","acct-note acct-fine")),i;const t=Pt("ul",{className:"lb-list link-list"});for(const e of Zn){const n=Pt("li",{className:"link-item"},Pt("span",{className:"link-who"},Pt("strong",{textContent:`@${e.peer}`}),Pt("span",{className:"acct-fine",textContent:Qp(e)}),e.guest?Pt("span",{className:"acct-fine",textContent:Jp(e.guest)}):null)),s=Pt("span",{className:"link-row"});if(e.kind==="guest"&&e.role==="guest"){const a=Pt("button",{type:"button",className:"primary small",textContent:`Visit @${e.peer}`});a.addEventListener("click",()=>{location.search=`?visit=${encodeURIComponent(e.id)}`}),s.append(a)}const r=Pt("button",{type:"button",className:"acct-forget",textContent:hn===e.id?"Unlinking…":"Unlink",disabled:!!hn});r.addEventListener("click",()=>am(e)),s.append(r),n.append(s),t.append(n)}return i.append(t),i}async function Do(i,t){hn=i,fi="",sn();try{await t()}catch(e){fi=e.message}hn="",sn()}function rf(i,t){return vo=!1,Do(i,async()=>{const e=await ki("/api/links/invite",t?{kind:i,guest:t}:{kind:i});ns={kind:e.kind||i,code:e.code,expiresAt:e.expiresAt},Li=null})}function am(i){const t=i.kind!=="guest"?"You stop seeing each other’s agents.":i.role==="host"?"Their running jobs stop and they lose access right away.":"You can’t visit their office again without a new code.";confirm(`Unlink @${i.peer}? ${t}`)&&Do(i.id,async()=>{_r(await ki(`/api/links/${encodeURIComponent(i.id)}`,void 0,"DELETE"))})}function om(i,t=!1){Pi=i,t&&document.dispatchEvent(new CustomEvent("office:leaderboard",{detail:i}))}function _r(i){!i||!Array.isArray(i.links)||(Zn=i.links,Gr={handle:i.handle||null,connected:i.connected,error:i.error||null},ko(),hn||sn())}document.addEventListener("office:leaderboard",i=>{Pi=i.detail,hn||sn()});function Io(i){if(Ue.hidden=!i,cr.setAttribute("aria-expanded",String(i)),!i){fi="",Li=null,vo=!1;return}sn(),ki("/api/links").then(_r,t=>{Zn||(Zn=[]),fi=t.message,sn()}),Pi||ki("/api/leaderboard").then(t=>{Pi=t,sn()},()=>{})}cr==null||cr.addEventListener("click",()=>Io(Ue.hidden));var Qd;for(const i of["themeBtn","acctBtn"])(Qd=document.getElementById(i))==null||Qd.addEventListener("click",()=>{Ue.hidden||Io(!1)});document.addEventListener("click",i=>{Ue&&!Ue.hidden&&i.target.isConnected&&!Ue.contains(i.target)&&!cr.contains(i.target)&&Io(!1)});document.addEventListener("keydown",i=>{i.key==="Escape"&&Ue&&!Ue.hidden&&(Io(!1),cr.focus())});const Gt={on:!1,link:null,host:"",repos:null,clearance:"edit",tokensPerDay:0};{const i=new URLSearchParams(location.search).get("visit");i&&Object.assign(Gt,{on:!0,link:i})}function lm(i){i&&(ws="",Object.assign(Gt,{on:!0,link:i.link??Gt.link,host:i.host??Gt.host,repos:Array.isArray(i.repos)?i.repos:Gt.repos,clearance:sa[i.clearance]!=null?i.clearance:Gt.clearance,tokensPerDay:i.tokensPerDay??Gt.tokensPerDay}),ko())}function Ns(i,t=""){return i=encodeURIComponent(i),Gt.on?`/api/visit/${encodeURIComponent(Gt.link)}/jobs/${i}${t}`:`/api/jobs/${i}${t}`}function Jo(i,t,e){return Gt.on?{text:i,mode:t}:{message:i,mode:t,files:e}}const Qo=i=>`#${i.replace(/\s+/g,"-")}`.toLowerCase();async function cm({text:i,mode:t,model:e}){const n=(i.match(/(^|\s)#[\w.-]+/g)||[]).map(c=>c.trim().toLowerCase()),s=Gt.repos||[],r=s.filter(c=>n.includes(Qo(c)));if(r.length!==1){const c=s.map(Qo).join(", ")||"none yet";throw new Error(r.length?"Name just one project per job.":`Name the project with a # tag. You can use: ${c}.`)}const a=r[0],o=i.replace(new RegExp(`(^|\\s)${Qo(a).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?=\\s|$)`,"i")," ").replace(/\s+/g," ").trim();if(!o)throw new Error("Say what the job is, as well as the project.");const{job:l}=await ki(`/api/visit/${encodeURIComponent(Gt.link)}/jobs`,{repo:a,prompt:o,mode:t,model:e});return l}function hm(i){return!Gt.on||!i?i:Object.fromEntries(Object.entries(i).filter(([t])=>(sa[t]??9)<=sa[Gt.clearance]))}function su(i){return!Gt.on||!Array.isArray(i)?i:i.filter(t=>{var e;return(e=Gt.repos)==null?void 0:e.includes(t)})}let ws="",to=!1;function um(i){if(!Gt.on)return null;if(i===4404)ws="The host ended this link. You can’t visit any more.";else if(i===4502)ws="Can’t reach the host’s office right now. Trying again…";else return ws="",null;return to=i===4404,ko(),i===4404?0:1e4}function ko(){var r,a,o,l;if(!Gt.on)return;const i=Gt.host||((r=Zn==null?void 0:Zn.find(c=>c.id===Gt.link))==null?void 0:r.peer)||"";i&&(Gt.host=i),Zo.classList.add("visiting"),Zo.dataset.visiting=i,Zo.classList.toggle("visit-ended",!!to);const t=document.getElementById("input");if(t){t.placeholder=to?"This link has ended.":`Start a job${i?` at @${i}`:""} · #project`;for(const c of document.querySelectorAll("#composer textarea, #composer select, #composer button"))c.disabled=!!to}const e=document.getElementById("mode");if(e){for(const c of e.options)c.hidden=c.disabled=sa[c.value]>sa[Gt.clearance];(a=e.selectedOptions[0])!=null&&a.disabled&&(e.value=Gt.clearance)}let n=document.getElementById("visitBar");n||(n=Pt("div",{className:"visit-bar",id:"visitBar"}),n.setAttribute("role","status"),(o=document.querySelector(".brand"))==null||o.after(n));const s=Pt("a",{href:location.pathname,textContent:"Back to my office"});n.replaceChildren(Pt("span",{},"Visiting ",Pt("strong",{textContent:i?`@${i}`:"a linked office"}),Gt.repos?` · ${Gt.repos.length} ${Gt.repos.length===1?"project":"projects"}, up to ${(l=sh.find(c=>c.id===Gt.clearance))==null?void 0:l.name.toLowerCase()}`:""),s),n.classList.toggle("visit-off",!!ws),ws&&n.append(Pt("p",{className:"visit-note",textContent:ws}))}ko();const nr=document.getElementById("setBtn"),Ie=document.getElementById("settings");let Es=null,Je={},ur=!1,as="",af=()=>{};const Ce=(i,t={})=>Object.assign(document.createElement(i),t);Ce.kids=(i,t)=>(i.append(...t),i);const eo=i=>i.key in Je?Je[i.key]:i.value,ru=(i,t)=>i.kind==="bool"?t?"on":"off":i.kind==="time"?t||"off":i.kind==="text"?t||"the account name":i.kind==="number"?`${Number(t).toLocaleString()}${i.unit?` ${i.unit}`:""}`:String(t),of=(i,t)=>Number.isInteger(t)&&t>=i.min&&t<=i.max,lf=()=>Object.keys(Je);function dm(i){const t=eo(i),e=`set-${i.key}`,n=r=>{Object.is(r,i.value)?delete Je[i.key]:Je[i.key]=r,rh(),cf(i)};if(i.kind==="bool"){const r=Ce("button",{type:"button",id:e,className:"set-switch"});return r.setAttribute("role","switch"),r.setAttribute("aria-checked",String(!!t)),r.addEventListener("click",()=>{n(!eo(i)),r.setAttribute("aria-checked",String(!!eo(i)))}),r}if(i.kind==="choice"){const r=Ce("div",{className:"theme-modes set-choice"});r.setAttribute("role","radiogroup"),r.setAttribute("aria-label",i.label),r.style.gridTemplateColumns=`repeat(${i.options.length}, 1fr)`;for(const a of i.options){const o=Ce("button",{type:"button",textContent:a});o.setAttribute("role","radio"),o.setAttribute("aria-checked",String(a===t)),o.addEventListener("click",()=>{n(a);for(const l of r.children)l.setAttribute("aria-checked",String(l.textContent===a))}),r.append(o)}return r}const s=Ce("input",{id:e,className:"set-input"});return s.spellcheck=!1,s.autocomplete="off",i.kind==="number"?Object.assign(s,{type:"number",min:i.min,max:i.max,step:i.step||1,value:t,inputMode:"numeric"}):i.kind==="time"?Object.assign(s,{type:"time",value:t}):Object.assign(s,{type:"text",value:t,maxLength:i.max,placeholder:i.default||"Your first name"}),s.addEventListener("input",()=>{const r=s.value;n(i.kind==="number"?r===""?NaN:Number(r):r)}),s}const tc=new Map;function cf(i){const t=tc.get(i.key);if(!t)return;t.classList.toggle("set-changed",i.key in Je);const e=t.querySelector(".set-fine");e.replaceChildren();const n=eo(i);if(i.kind==="number"&&!of(i,n)){e.textContent=`Use a whole number from ${i.min.toLocaleString()} to ${i.max.toLocaleString()}.`,e.classList.add("acct-err");return}if(e.classList.remove("acct-err"),i.hint&&e.append(i.hint," "),i.custom&&!(i.key in Je)){const s=Ce("button",{type:"button",className:"acct-forget set-reset",textContent:`Use the default (${ru(i,i.default)})`});s.addEventListener("click",()=>ec({[i.key]:null})),e.append(s)}else i.custom||e.append(`Default: ${ru(i,i.default)}.`)}function rh(){const i=lf().length,t=Ie.querySelector(".set-save"),e=Ie.querySelector(".set-undo"),n=Ie.querySelector(".set-msg");if(!t)return;const s=Es.some(r=>r.key in Je&&r.kind==="number"&&!of(r,Je[r.key]));t.disabled=ur||!i||s,t.textContent=ur?"Saving…":i>1?`Save ${i} changes`:"Save",e.hidden=!i||ur,n.textContent=as||(i?"Unsaved changes":""),n.classList.toggle("acct-err",!!as)}function dr(){tc.clear();const i=Ie.querySelector(".set-body");if(i.replaceChildren(),!Es){i.append(Ce("p",{className:"acct-note",textContent:as||"Loading…"}));return}const t=[...new Set(Es.map(e=>e.group))];for(const e of t){const n=Ce("section",{className:"set-group"});n.append(Ce("h3",{className:"theme-k",textContent:e}));for(const s of Es.filter(r=>r.group===e)){const r=Ce("div",{className:"set-row"}),a=Ce("div",{className:"set-text"}),o=Ce("label",{className:"set-label",textContent:s.label});o.htmlFor=`set-${s.key}`,a.append(o,Ce("p",{className:"acct-note acct-fine set-fine"})),r.append(a,dm(s)),tc.set(s.key,r),n.append(r),cf(s)}i.append(n)}rh()}async function ec(i){ur=!0,as="",rh();try{const t=await fetch("/api/settings",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i)}),e=await t.json();if(!t.ok)throw new Error(e.error||"That didn’t save.");for(const n of Object.keys(i))delete Je[n];ah(e),af("Settings saved","good")}catch(t){as=t.message}ur=!1,dr()}let hf=()=>{};function ah(i){Es=i.settings;for(const t of Es)t.key in Je&&Object.is(Je[t.key],t.value)&&delete Je[t.key];i.owner!==void 0&&hf(i.owner)}function au(i){i!=null&&i.settings&&(ah(i),Ie!=null&&Ie.open&&!ur&&dr())}function fm(){var i;as="",Ie.showModal(),nr.setAttribute("aria-expanded","true"),dr(),Es||fetch("/api/settings").then(t=>t.ok?t.json():Promise.reject()).then(t=>{ah(t),dr()},()=>{as="Restart the office server to use Settings.",dr()}),(i=Ie.querySelector("input, button.set-switch, [role=radio]"))==null||i.focus()}function tl(){return lf().length&&!confirm("Discard your unsaved changes?")?!1:(Je={},Ie.close(),!0)}function pm({toast:i,renderOwner:t}){if(af=i,hf=t,!(!nr||!Ie)){if(Gt.on){nr.hidden=!0;return}Ie.append(Ce.kids(Ce("header",{className:"set-head"}),[Ce("h2",{textContent:"Settings"}),Object.assign(Ce("button",{type:"button",className:"theme-btn set-x"}),{innerHTML:'<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 6l12 12M18 6 6 18"/></svg>',ariaLabel:"Close settings"})]),Ce("div",{className:"set-body"}),Ce.kids(Ce("footer",{className:"set-foot"}),[Ce("span",{className:"set-msg",role:"status"}),Ce("button",{type:"button",className:"set-undo acct-forget",textContent:"Discard",hidden:!0}),Ce("button",{type:"button",className:"primary small set-save",textContent:"Save",disabled:!0})])),Ie.querySelector(".set-x").addEventListener("click",tl),Ie.querySelector(".set-undo").addEventListener("click",()=>{Je={},as="",dr()}),Ie.querySelector(".set-save").addEventListener("click",()=>ec({...Je})),nr.addEventListener("click",fm),Ie.addEventListener("cancel",e=>{e.preventDefault(),tl()}),Ie.addEventListener("click",e=>{e.target===Ie&&tl()}),Ie.addEventListener("close",()=>{nr.setAttribute("aria-expanded","false"),nr.focus()}),Ie.addEventListener("keydown",e=>{e.key==="Enter"&&e.target.matches("input")&&!Ie.querySelector(".set-save").disabled&&(e.preventDefault(),ec({...Je}))})}}const fr=document.getElementById("lbBtn"),Te=document.getElementById("lbPop"),uf=[{id:"jobs",name:"Jobs",value:i=>String(i.jobs)},{id:"tokens",name:"Tokens",value:i=>oh(i.tokens)},{id:"time",name:"Time",value:i=>lh(i.seconds)}],mm=[{id:"week",name:"This week"},{id:"all",name:"All time"}];let jt=null,nc="week",jr="jobs",Zi=null,ic=!1,Ai=!1,kn="",sc="";const Kt=(i,t={})=>Object.assign(document.createElement(i),t);function oh(i){return i>=1e9?`${(i/1e9).toFixed(1)}B`:i>=1e6?`${(i/1e6).toFixed(1)}M`:i>=1e3?`${(i/1e3).toFixed(i>=1e5?0:1)}k`:String(i)}function lh(i){const t=Math.round(i/60);return t<1?i>0?"<1m":"0m":t<60?`${t}m`:`${Math.floor(t/60)}h ${String(t%60).padStart(2,"0")}m`}function df(i){const t=Math.max(0,Math.round((Date.now()-i)/1e3));return t<90?"just now":t<5400?`${Math.round(t/60)} min ago`:t<129600?`${Math.round(t/3600)} h ago`:`${Math.round(t/86400)} days ago`}function ou(i,t,e,n,s=""){const r=Kt("div",{className:`theme-modes lb-tabs ${s}`});r.setAttribute("role","radiogroup"),r.setAttribute("aria-label",e);for(const a of i){const o=Kt("button",{type:"button"});o.setAttribute("role","radio"),o.setAttribute("aria-checked",String(a.id===t)),o.append(Kt("span",{textContent:a.name})),o.addEventListener("click",()=>n(a.id)),r.append(o)}return r}function Jn(){if(!Te)return;Te.replaceChildren(Kt("p",{className:"theme-k",textContent:"Leaderboard"}));const i=(t,e="acct-note")=>Te.append(Kt("p",{className:e,textContent:t}));if(!jt){i(kn||"Checking…");return}if(!jt.configured){i("No leaderboard is set up for this office. Whoever hosts one gives you its address: set it as OFFICE_LEADERBOARD_URL and restart the office.");return}if(lu())gm();else if(jt.joined){const t=jt.week,e=Kt("p",{className:"lb-me"});Te.append(e),e.append(Kt("strong",{textContent:jt.handle}),Kt("span",{textContent:` · ${t.jobs} ${t.jobs===1?"job":"jobs"}, ${oh(t.tokens)} tokens, ${lh(t.seconds)} this week`}));const n=jt.error?`Not shared yet: ${jt.error}`:jt.lastSync?`Shared ${df(jt.lastSync)}.`:"Sharing…";i(n,jt.error?"acct-note acct-err":"acct-note acct-fine")}else{i("Compete on jobs finished, tokens used and time your agents spend working. Joining shares exactly these counters per day, for the last two weeks and from now on, under the handle you claim. Never prompts, projects, files, chat or cost.");const t=Kt("form",{className:"acct-form"}),e=Kt("input",{type:"text",placeholder:"Pick a handle",autocomplete:"off",spellcheck:!1,maxLength:20});e.setAttribute("aria-label","Handle"),t.append(e,Kt("button",{type:"submit",className:"primary small",textContent:Ai?"Joining…":"Join",disabled:Ai})),t.addEventListener("submit",n=>{n.preventDefault(),e.value.trim()&&xo("POST",{handle:e.value})}),Te.append(t),kn&&i(kn,"acct-note acct-err")}if(Te.append(ou(mm,nc,"Period",t=>{nc=t,_o()},"lb-period"),ou(uf,jr,"Ranked by",t=>{jr=t,Jn()},"lb-metric")),Te.append(vm()),jt.joined&&!lu()){const t=Kt("button",{type:"button",className:"acct-forget",textContent:Ai?"Working…":"Leave and delete my data",disabled:Ai});t.addEventListener("click",()=>{confirm("Leave the leaderboard? Your handle is released and your counters are deleted from the service.")&&xo("DELETE")}),Te.append(t),kn&&i(kn,"acct-note acct-err")}}const lu=()=>!!jt&&"sharing"in jt&&!!jt.handle;function gm(){const i=(s,r="acct-note")=>Te.append(Kt("p",{className:r,textContent:s})),t=Kt("p",{className:"lb-me"});if(t.append(Kt("strong",{textContent:jt.handle})),jt.sharing&&jt.week){const s=jt.week;t.append(Kt("span",{textContent:` · ${s.jobs} ${s.jobs===1?"job":"jobs"}, ${oh(s.tokens)} tokens, ${lh(s.seconds)} this week`}))}Te.append(t);const e=Kt("input",{type:"checkbox",checked:!!jt.sharing,disabled:Ai});e.addEventListener("change",()=>{if(e.checked){xo("POST",{handle:jt.handle});return}confirm("Stop sharing? Your counters are deleted from the board. You keep your handle while you have linked offices; with none, the handle is released too.")?xo("DELETE"):e.checked=!0});const n=Kt("label",{className:"lb-share"});if(n.append(e,Kt("span",{textContent:"Share my counters on the board"})),Te.append(n),jt.sharing){const s=jt.error?`Not shared yet: ${jt.error}`:jt.lastSync?`Shared ${df(jt.lastSync)}.`:"Sharing…";i(s,jt.error?"acct-note acct-err":"acct-note acct-fine")}else i("Sharing sends jobs finished, tokens and agent time per day, for the last two weeks and from now on. Never prompts, projects, files, chat or cost.","acct-note acct-fine");kn&&i(kn,"acct-note acct-err")}function vm(){var r;const i=Kt("div",{className:"lb-board"});if(!Zi)return i.append(Kt("p",{className:"acct-note",textContent:ic?"Loading…":sc||"No board yet."})),i;const e=Zi[jr==="time"?"time":jr]||[];if(!e.length)return i.append(Kt("p",{className:"acct-note",textContent:"Nobody on the board yet."})),i;const n=uf.find(a=>a.id===jr),s=Kt("ol",{className:"lb-list"});for(const a of e){const o=Kt("li",{className:a.handle.toLowerCase()===((r=jt.handle)==null?void 0:r.toLowerCase())?"lb-row lb-you":"lb-row"});o.append(Kt("span",{className:"lb-rank",textContent:String(a.rank)}),Kt("span",{className:"lb-name",textContent:a.handle}),Kt("span",{className:"lb-val",textContent:n.value(a)})),s.append(o)}return i.append(s),Zi.players>e.length&&i.append(Kt("p",{className:"acct-note acct-fine",textContent:`Top ${e.length} of ${Zi.players}.`})),Zi.since&&i.append(Kt("p",{className:"acct-note acct-fine",textContent:"Weeks start Monday, UTC."})),i}async function _o(){if(jt!=null&&jt.configured){ic=!0,sc="",Jn();try{const i=await fetch(`/api/leaderboard/board?period=${nc}`),t=await i.json();if(!i.ok)throw new Error(t.error||"Couldn’t load the board.");Zi=t}catch(i){Zi=null,sc=i.message}ic=!1,Te.hidden||Jn()}}async function xo(i,t){Ai=!0,kn="",Jn();try{const e=await fetch("/api/leaderboard",i==="POST"?{method:i,headers:{"content-type":"application/json"},body:JSON.stringify(t)}:{method:i}),n=await e.json();if(!e.ok)throw new Error(n.error||"That didn’t work.");oa(n),Zi=null}catch(e){kn=e.message}Ai=!1,Jn(),kn||_o()}function cu(i){i&&(oa(i),!Ai&&!Te.hidden&&Jn())}function oa(i){jt=i,document.dispatchEvent(new CustomEvent("office:leaderboard",{detail:i}))}document.addEventListener("office:leaderboard",i=>{i.detail!==jt&&(jt=i.detail,!Ai&&Te&&!Te.hidden&&Jn())});function No(i){if(Te.hidden=!i,fr.setAttribute("aria-expanded",String(i)),!i){kn="";return}Jn(),jt?_o():fetch("/api/leaderboard").then(t=>t.ok?t.json():Promise.reject()).then(t=>{oa(t),Jn(),_o()},()=>{kn="Restart the office server to use this.",Jn()})}fr==null||fr.addEventListener("click",()=>No(Te.hidden));var tf;for(const i of["themeBtn","acctBtn"])(tf=document.getElementById(i))==null||tf.addEventListener("click",()=>{Te.hidden||No(!1)});document.addEventListener("click",i=>{const t=i.composedPath();Te&&!Te.hidden&&!t.includes(Te)&&!t.includes(fr)&&No(!1)});document.addEventListener("keydown",i=>{i.key==="Escape"&&Te&&!Te.hidden&&(No(!1),fr.focus())});const rc="office.nameAsked",_m="office.name",xm=i=>i.trim().replace(/\s+/g,"_").replace(/[^A-Za-z0-9_-]/g,"").slice(0,20);function ym(){const i=Kt("dialog",{className:"name-ask"}),t=Kt("form",{method:"dialog"}),e=Kt("input",{type:"text",placeholder:"Your name",autocomplete:"off",spellcheck:!1,maxLength:40});e.setAttribute("aria-label","Your name");const n=Kt("p",{className:"acct-note acct-err",hidden:!0}),s=Kt("button",{type:"submit",className:"primary small",textContent:"Continue"}),r=Kt("button",{type:"button",className:"acct-forget",textContent:"Not now"}),a=Kt("div",{className:"acct-form"});a.append(e,s),t.append(Kt("h2",{textContent:"Welcome to the office"}),Kt("p",{className:"acct-note",textContent:jt!=null&&jt.configured?"What should we call you? Your name becomes your handle on the leaderboard. Nothing is shared until you join it.":"What should we call you?"}),a,n,r),i.append(t);const o=()=>{try{localStorage.setItem(rc,"1")}catch{}i.close(),i.remove()};r.addEventListener("click",o),i.addEventListener("cancel",o),t.addEventListener("submit",async l=>{l.preventDefault();const c=e.value.trim(),h=xm(c);if(c){n.hidden=!0,s.disabled=!0;try{if(jt!=null&&jt.configured){if(h.length<3)throw new Error("Use at least 3 letters or numbers.");const u=await fetch("/api/leaderboard/handle",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({handle:h})}),d=await u.json();if(!u.ok)throw new Error(d.error||"That handle didn’t work.");oa(d),Te.hidden||Jn()}try{localStorage.setItem(_m,c)}catch{}o()}catch(u){n.textContent=u.message,n.hidden=!1,s.disabled=!1,e.focus()}}}),document.body.append(i),i.showModal(),e.focus()}try{!localStorage.getItem(rc)&&!new URLSearchParams(location.search).has("visit")&&fetch("/api/leaderboard").then(i=>i.ok?i.json():null).catch(()=>null).then(i=>{if(i&&oa(i),i!=null&&i.handle){try{localStorage.setItem(rc,"1")}catch{}return}ym()})}catch{}/**
|
|
1
|
+
var zp=Object.defineProperty;var Bp=(i,t,e)=>t in i?zp(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var _e=(i,t,e)=>Bp(i,typeof t!="symbol"?t+"":t,e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))n(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&n(a)}).observe(document,{childList:!0,subtree:!0});function e(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function n(s){if(s.ep)return;s.ep=!0;const r=e(s);fetch(s.href,r)}})();"serviceWorker"in navigator&&addEventListener("load",()=>navigator.serviceWorker.register("/sw.js").catch(()=>{}));const Qd=[{id:"paper",name:"Paper"},{id:"ocean",name:"Ocean"},{id:"forest",name:"Forest"},{id:"sunset",name:"Sunset"},{id:"lavender",name:"Lavender"}],eh=[{id:"light",name:"Light"},{id:"dark",name:"Dark"},{id:"auto",name:"Auto"}],Xo=document.documentElement,tf=matchMedia("(prefers-color-scheme: dark)"),ef=(i,t,e)=>{try{const n=localStorage.getItem(i);return e.some(s=>s.id===n)?n:t}catch{return t}},iu=(i,t)=>{try{localStorage.setItem(i,t)}catch{}};try{if(localStorage.getItem("office.appearance")===null){const i=localStorage.getItem("office.mode");eh.some(t=>t.id===i)&&(localStorage.setItem("office.appearance",i),localStorage.removeItem("office.mode"))}}catch{}let Yl=ef("office.theme","paper",Qd),na=ef("office.appearance","auto",eh);const Xr=document.getElementById("themeBtn"),Cn=document.getElementById("themePop");function fo(){const i=na==="dark"||na==="auto"&&tf.matches?"dark":"light";Xo.dataset.theme=Yl,Xo.dataset.mode=i;const t=document.querySelector('meta[name="theme-color"]');t&&(t.content=getComputedStyle(Xo).getPropertyValue("--paper").trim()||t.content),Hp()}function Hp(){if(!Cn)return;Cn.replaceChildren();const i=e=>Object.assign(document.createElement("p"),{className:"theme-k",textContent:e}),t=(e,n,s,r)=>{const a=document.createElement("div");a.className=r,a.setAttribute("role","radiogroup");for(const o of e){const l=document.createElement("button");l.type="button",l.dataset.t=o.id,l.setAttribute("role","radio"),l.setAttribute("aria-checked",String(o.id===n)),l.innerHTML=r==="theme-swatches"?"<i></i><span></span>":"<span></span>",l.querySelector("span").textContent=o.name,l.addEventListener("click",()=>s(o.id)),a.appendChild(l)}return a};Cn.append(i("Theme"),t(Qd,Yl,e=>{Yl=e,iu("office.theme",e),fo()},"theme-swatches"),i("Mode"),t(eh,na,e=>{na=e,iu("office.appearance",e),fo()},"theme-modes"))}function nh(i){var t;Cn.hidden=!i,Xr.setAttribute("aria-expanded",String(i)),i&&((t=Cn.querySelector('[aria-checked="true"]'))==null||t.focus())}Xr==null||Xr.addEventListener("click",i=>{i.stopPropagation(),nh(Cn.hidden)});Cn==null||Cn.addEventListener("click",i=>i.stopPropagation());document.addEventListener("click",()=>{Cn&&!Cn.hidden&&nh(!1)});document.addEventListener("keydown",i=>{i.key==="Escape"&&Cn&&!Cn.hidden&&(nh(!1),Xr.focus())});tf.addEventListener("change",()=>{na==="auto"&&fo()});fo();const or=document.getElementById("acctBtn"),Ce=document.getElementById("acctPop"),Vp=[{id:"login",name:"Claude Code login"},{id:"apikey",name:"API key"}];let En=null,po=null,xs=!1,Yn="",ji=null;const Ge=(i,t={})=>Object.assign(document.createElement(i),t);function Di(){if(!Ce)return;if(!En){Ce.replaceChildren(Ge("p",{className:"theme-k",textContent:"Claude access"}),Ge("p",{className:"acct-note",textContent:Yn||"Checking…"}));return}const i=po||En.mode;Ce.replaceChildren();const t=Ge("div",{className:"theme-modes acct-modes"});t.setAttribute("role","radiogroup");for(const n of Vp){const s=Ge("button",{type:"button"});s.setAttribute("role","radio"),s.setAttribute("aria-checked",String(n.id===i)),s.append(Ge("span",{textContent:n.name})),s.addEventListener("click",()=>{po=n.id,Yn="",n.id==="login"||En.keySet?qo({mode:n.id}):Di()}),t.append(s)}Ce.append(Ge("p",{className:"theme-k",textContent:"Claude access"}),t);const e=(n,s="acct-note")=>Ce.append(Ge("p",{className:s,textContent:n}));if(i==="login")e("Jobs run on your Claude plan, using the login Claude Code keeps on this machine. If it isn’t signed in yet, run claude once in a terminal.");else{En.keySet&&En.mode==="apikey"?e(`Using the key ending ${En.keyHint}${En.keyFrom==="env"?", from ANTHROPIC_API_KEY":""}. Jobs are billed to that API account.`):e("Jobs are billed to the API account the key belongs to. It is kept on this machine only.");const n=Ge("form",{className:"acct-form"}),s=Ge("input",{type:"password",placeholder:En.keySet?"Replace with another key":"sk-ant-…",autocomplete:"off",spellcheck:!1});s.setAttribute("aria-label","Anthropic API key");const r=Ge("button",{type:"submit",className:"primary small",textContent:xs?"Checking…":"Save",disabled:xs});if(n.append(s,r),n.addEventListener("submit",a=>{a.preventDefault(),s.value.trim()&&qo({mode:"apikey",key:s.value})}),Ce.append(n),En.keyFrom==="office"){const a=Ge("button",{type:"button",className:"acct-forget",textContent:"Forget this key"});a.addEventListener("click",()=>qo(null)),Ce.append(a)}xs||queueMicrotask(()=>{En.keySet||s.focus()})}Yn&&e(Yn,"acct-note acct-err"),Ce.append(Ge("p",{className:"acct-note acct-fine",textContent:"Jobs already running finish the way they started."})),Gp()}function Gp(){if(!ji)return;Ce.append(Ge("p",{className:"theme-k",textContent:"Context limit"}));const i=Ge("form",{className:"acct-form"}),t=Ge("input",{type:"number",min:0,step:1e4,value:ji.tokens,required:!0});t.setAttribute("aria-label","Context limit in tokens");const e=Ge("button",{type:"submit",className:"primary small",textContent:"Save"});if(i.append(t,e),i.addEventListener("submit",n=>{n.preventDefault();const s=Number(t.value);Number.isInteger(s)&&s>=0?su(s):(Yn="Use a whole number of tokens, or 0 to turn it off.",Di())}),Ce.append(i,Ge("p",{className:"acct-note acct-fine",textContent:ji.tokens?`Agents are nudged to clear their context past ${ji.tokens.toLocaleString()} tokens.`:"Off: agents are never nudged to clear their context."})),ji.custom){const n=Ge("button",{type:"button",className:"acct-forget",textContent:`Back to the default (${ji.default.toLocaleString()})`});n.addEventListener("click",()=>su(null)),Ce.append(n)}}async function su(i){Yn="";try{const t=await fetch("/api/context-limit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tokens:i})}),e=await t.json();if(!t.ok)throw new Error(e.error||"That didn’t save.");ji=e}catch(t){Yn=t.message}Di()}function jo(i){i&&(ji=i,!xs&&Ce&&!Ce.hidden&&Di())}async function qo(i){xs=!0,Yn="",Di();try{const t=await fetch("/api/auth",i?{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i)}:{method:"DELETE"}),e=await t.json();if(!t.ok)throw new Error(e.error||"That didn’t save.");En=e,po=null}catch(t){Yn=t.message}xs=!1,Di()}function Kl(i){i&&(En=i,xs||Di())}function Ro(i){var t;Ce.hidden=!i,or.setAttribute("aria-expanded",String(i)),i||(po=null,Yn=""),Di(),i&&((t=Ce.querySelector('[aria-checked="true"]'))==null||t.focus()),i&&!En&&fetch("/api/auth").then(e=>e.ok?e.json():Promise.reject()).then(Kl,()=>{Yn="Restart the office server to choose this.",Di()})}or==null||or.addEventListener("click",()=>Ro(Ce.hidden));var Kd;(Kd=document.getElementById("themeBtn"))==null||Kd.addEventListener("click",()=>{Ce.hidden||Ro(!1)});document.addEventListener("click",i=>{Ce&&!Ce.hidden&&!Ce.contains(i.target)&&!or.contains(i.target)&&Ro(!1)});document.addEventListener("keydown",i=>{i.key==="Escape"&&Ce&&!Ce.hidden&&(Ro(!1),or.focus())});const lr=document.getElementById("linkBtn"),ke=document.getElementById("linkPop"),Yo=document.getElementById("app"),ih=[{id:"plan",name:"Plan only"},{id:"edit",name:"Edit files"},{id:"auto",name:"Full autonomy"}],ia={plan:0,edit:1,auto:2},$p=2e6,Wp=/^[0-9A-HJKMNP-TV-Z]{8}$/;let Kn=null,Gr={},Ri=null,ts=null,Pi=null,cr=null,cn="",ui="",mo=!1;const Pt=(i,t={},...e)=>{const n=Object.assign(document.createElement(i),t);return n.append(...e.filter(s=>s!=null&&s!==!1)),n},On=(i,t="acct-note")=>Pt("p",{className:t,textContent:i});async function Ii(i,t,e){const n=t===void 0?{method:e||"GET"}:{method:e||"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)},s=await fetch(i,n),r=await s.json().catch(()=>({}));if(!s.ok)throw new Error(r.error||(s.status===404?"Restart the office server to use links.":"That didn’t work."));return r}function Xp(i){const t=String(i||"").toUpperCase().replace(/[\s-]+/g,"").replace(/[IL]/g,"1").replace(/O/g,"0");return Wp.test(t)?t:null}const jp=i=>{const t=String(i).toUpperCase().replace(/-/g,"");return`${t.slice(0,4)}-${t.slice(4)}`};function Zl(i){return i>=1e6?`${+(i/1e6).toFixed(1)}M`:i>=1e3?`${Math.round(i/1e3)}k`:String(i)}function qp(i){const t=typeof i=="number"?i:Date.parse(i);if(!t)return"";const e=t-Date.now();if(e<=0)return"Expired. Make a new one.";const n=Math.ceil(e/6e4),s=Math.floor(n/60),r=n%60,a=new Date(t).toLocaleString([],{weekday:"short",hour:"numeric",minute:"2-digit"});return`Works once. Expires in ${s?`${s} h ${r} min`:`${r} min`} (${a}).`}function Yp(i){var n,s;const t=((n=i.repos)==null?void 0:n.length)||0,e=((s=ih.find(r=>r.id===i.clearance))==null?void 0:s.name)||i.clearance;return`${t===1?i.repos[0]:`${t} projects`} · ${e} · ${Zl(i.tokensPerDay||0)} tokens a day`}function Kp(i){return i.kind!=="guest"?"Linked office":i.role==="guest"?"Guest · you visit them":"Guest · they visit you"}function nn(){if(!ke||ke.hidden)return;const i=Gr.handle||(Ri==null?void 0:Ri.handle);ke.replaceChildren(Pt("p",{className:"theme-k",textContent:"Linked offices"})),i?(ke.append(Pt("p",{className:"lb-me"},"This office is ",Pt("strong",{textContent:`@${i}`}))),ke.append(Jp()),ts&&ke.append(Qp()),Pi&&ke.append(em())):ke.append(...Zp()),ui&&ke.append(On(ui,"acct-note acct-err")),Gr.error?ke.append(On(`Link service: ${Gr.error}`,"acct-note acct-err")):Kn!=null&&Kn.length&&Gr.connected===!1&&ke.append(On("Connecting to the link service…","acct-note acct-fine")),ke.append(nm())}function Zp(){const i=[On("Linked offices see each other’s agents walk in as visitors, and a guest can run jobs here within the limits you set. First, pick a handle for this office.")];if(Ri&&!Ri.configured)return[...i,On("This office has no link service set up.","acct-note acct-err")];const t=Pt("form",{className:"acct-form"}),e=Pt("input",{type:"text",placeholder:"Pick a handle",autocomplete:"off",spellcheck:!1,maxLength:20});return e.setAttribute("aria-label","Handle"),t.append(e,Pt("button",{type:"submit",className:"primary small",textContent:cn==="claim"?"Claiming…":"Claim",disabled:!!cn})),t.addEventListener("submit",async n=>{n.preventDefault(),e.value.trim()&&await Po("claim",async()=>{sm(await Ii("/api/leaderboard/handle",{handle:e.value.trim()}),!0),_r(await Ii("/api/links"))})}),[...i,t,On("Claiming a handle doesn’t put you on the leaderboard. Sharing your counters there is a separate choice.","acct-note acct-fine")]}function Jp(){const i=Pt("div",{className:"link-actions"}),t=Pt("button",{type:"button",className:"ghost small",textContent:cn==="link"?"Making a code…":"Invite an office",disabled:!!cn});t.addEventListener("click",()=>{Pi=null,nf("link")});const e=Pt("button",{type:"button",className:"ghost small",textContent:"Invite a guest",disabled:!!cn});e.setAttribute("aria-expanded",String(!!Pi)),e.addEventListener("click",tm);const n=Pt("form",{className:"acct-form link-redeem"}),s=Pt("input",{type:"text",placeholder:"Enter a code, e.g. K7QX-M2PD",autocomplete:"off",spellcheck:!1,maxLength:12});return s.setAttribute("aria-label","Invite code"),n.append(s,Pt("button",{type:"submit",className:"primary small",textContent:cn==="redeem"?"Linking…":"Link",disabled:!!cn})),n.addEventListener("submit",r=>{r.preventDefault();const a=Xp(s.value);if(!a){ui="A code is 8 letters and numbers, like K7QX-M2PD.",nn();return}Po("redeem",async()=>{_r(await Ii("/api/links/redeem",{code:a})),ts=null})}),i.append(Pt("div",{className:"link-row"},t,e),n),i}function Qp(){const i=Pt("div",{className:"link-code"}),t=jp(ts.code),e=Pt("button",{type:"button",className:"ghost small",textContent:mo?"Copied":"Copy"});return e.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(t),mo=!0}catch{ui="Couldn’t copy. Select the code and copy it by hand."}nn()}),i.append(Pt("p",{className:"theme-k",textContent:ts.kind==="guest"?"Guest code":"Office code"}),Pt("div",{className:"link-code-row"},Pt("output",{className:"link-code-v",textContent:t}),e),On(`${ts.kind==="guest"?"Give this to your guest. They enter it in their own office.":"Give this to the other office. They enter it under Linked offices."} ${qp(ts.expiresAt)}`,"acct-note acct-fine")),i}async function tm(){if(Pi){Pi=null,nn();return}if(Pi={repos:new Set,clearance:"edit",full:!1,tokensPerDay:$p},ts=null,nn(),!cr){try{cr=(await Ii("/api/repos")).repos||[]}catch(i){cr=[],ui=i.message}nn()}}function em(){const i=Pi,t=Pt("form",{className:"link-guest"});t.append(Pt("p",{className:"theme-k",textContent:"Invite a guest"}),On("A guest can start jobs with your agents in the projects you pick, at or below the clearance you set. Their jobs run on your Claude account.","acct-note acct-fine"));const e=Pt("fieldset",{className:"link-repos"},Pt("legend",{textContent:`Projects they can use (${i.repos.size} picked)`}));cr?cr.length||e.append(On("No projects found.","acct-note acct-fine")):e.append(On("Loading…","acct-note acct-fine"));for(const c of cr||[]){const h=Pt("input",{type:"checkbox",checked:i.repos.has(c)});h.addEventListener("change",()=>{h.checked?i.repos.add(c):i.repos.delete(c),nn()}),e.append(Pt("label",{},h,Pt("span",{textContent:c})))}const n=Pt("div",{className:"theme-modes acct-modes link-cap"});n.setAttribute("role","radiogroup"),n.setAttribute("aria-label","Clearance cap");for(const c of ih.slice(0,2)){const h=Pt("button",{type:"button",textContent:c.name,disabled:i.full});h.setAttribute("role","radio"),h.setAttribute("aria-checked",String(!i.full&&i.clearance===c.id)),h.addEventListener("click",()=>{i.clearance=c.id,nn()}),n.append(h)}const s=Pt("input",{type:"checkbox",checked:i.full});s.addEventListener("change",()=>{i.full=s.checked,nn()});const r=Pt("div",{className:"link-warn"},Pt("p",{textContent:"Full autonomy lets the guest run any command on this machine, with your files and your logins. Only allow it for someone you’d hand your laptop to."}),Pt("label",{},s,Pt("span",{textContent:"Allow full autonomy anyway"}))),a=Pt("input",{type:"number",min:1e5,step:1e5,value:i.tokensPerDay,required:!0});a.setAttribute("aria-label","Tokens per day");const o=Pt("span",{className:"acct-fine",textContent:Zl(i.tokensPerDay)});a.addEventListener("input",()=>{i.tokensPerDay=Math.floor(Number(a.value))||0,o.textContent=Zl(i.tokensPerDay)});const l=i.repos.size>0&&!cn;return t.append(e,Pt("p",{className:"link-k",textContent:"Clearance cap"}),n,r,Pt("label",{className:"link-k link-tokens"},Pt("span",{textContent:"Tokens per day"}),a,o),Pt("div",{className:"link-row"},Pt("button",{type:"submit",className:"primary small",textContent:cn==="guest"?"Making a code…":"Make guest code",disabled:!l}),i.repos.size?null:Pt("span",{className:"acct-fine",textContent:"Pick at least one project."}))),t.addEventListener("submit",c=>{if(c.preventDefault(),!i.repos.size||i.tokensPerDay<1e5){ui=i.repos.size?"Allow at least 100,000 tokens a day.":"Pick at least one project.",nn();return}nf("guest",{repos:[...i.repos],clearance:i.full?"auto":i.clearance,tokensPerDay:i.tokensPerDay})}),t}function nm(){const i=Pt("div",{className:"lb-board"});if(!Kn)return i.append(On("Loading links…","acct-note acct-fine")),i;if(!Kn.length)return i.append(On("No links yet.","acct-note acct-fine")),i;const t=Pt("ul",{className:"lb-list link-list"});for(const e of Kn){const n=Pt("li",{className:"link-item"},Pt("span",{className:"link-who"},Pt("strong",{textContent:`@${e.peer}`}),Pt("span",{className:"acct-fine",textContent:Kp(e)}),e.guest?Pt("span",{className:"acct-fine",textContent:Yp(e.guest)}):null)),s=Pt("span",{className:"link-row"});if(e.kind==="guest"&&e.role==="guest"){const a=Pt("button",{type:"button",className:"primary small",textContent:`Visit @${e.peer}`});a.addEventListener("click",()=>{location.search=`?visit=${encodeURIComponent(e.id)}`}),s.append(a)}const r=Pt("button",{type:"button",className:"acct-forget",textContent:cn===e.id?"Unlinking…":"Unlink",disabled:!!cn});r.addEventListener("click",()=>im(e)),s.append(r),n.append(s),t.append(n)}return i.append(t),i}async function Po(i,t){cn=i,ui="",nn();try{await t()}catch(e){ui=e.message}cn="",nn()}function nf(i,t){return mo=!1,Po(i,async()=>{const e=await Ii("/api/links/invite",t?{kind:i,guest:t}:{kind:i});ts={kind:e.kind||i,code:e.code,expiresAt:e.expiresAt},Pi=null})}function im(i){const t=i.kind!=="guest"?"You stop seeing each other’s agents.":i.role==="host"?"Their running jobs stop and they lose access right away.":"You can’t visit their office again without a new code.";confirm(`Unlink @${i.peer}? ${t}`)&&Po(i.id,async()=>{_r(await Ii(`/api/links/${encodeURIComponent(i.id)}`,void 0,"DELETE"))})}function sm(i,t=!1){Ri=i,t&&document.dispatchEvent(new CustomEvent("office:leaderboard",{detail:i}))}function _r(i){!i||!Array.isArray(i.links)||(Kn=i.links,Gr={handle:i.handle||null,connected:i.connected,error:i.error||null},Do(),cn||nn())}document.addEventListener("office:leaderboard",i=>{Ri=i.detail,cn||nn()});function Lo(i){if(ke.hidden=!i,lr.setAttribute("aria-expanded",String(i)),!i){ui="",Pi=null,mo=!1;return}nn(),Ii("/api/links").then(_r,t=>{Kn||(Kn=[]),ui=t.message,nn()}),Ri||Ii("/api/leaderboard").then(t=>{Ri=t,nn()},()=>{})}lr==null||lr.addEventListener("click",()=>Lo(ke.hidden));var Zd;for(const i of["themeBtn","acctBtn"])(Zd=document.getElementById(i))==null||Zd.addEventListener("click",()=>{ke.hidden||Lo(!1)});document.addEventListener("click",i=>{ke&&!ke.hidden&&i.target.isConnected&&!ke.contains(i.target)&&!lr.contains(i.target)&&Lo(!1)});document.addEventListener("keydown",i=>{i.key==="Escape"&&ke&&!ke.hidden&&(Lo(!1),lr.focus())});const Gt={on:!1,link:null,host:"",repos:null,clearance:"edit",tokensPerDay:0};{const i=new URLSearchParams(location.search).get("visit");i&&Object.assign(Gt,{on:!0,link:i})}function rm(i){i&&(ys="",Object.assign(Gt,{on:!0,link:i.link??Gt.link,host:i.host??Gt.host,repos:Array.isArray(i.repos)?i.repos:Gt.repos,clearance:ia[i.clearance]!=null?i.clearance:Gt.clearance,tokensPerDay:i.tokensPerDay??Gt.tokensPerDay}),Do())}function Ls(i,t=""){return i=encodeURIComponent(i),Gt.on?`/api/visit/${encodeURIComponent(Gt.link)}/jobs/${i}${t}`:`/api/jobs/${i}${t}`}function Ko(i,t,e){return Gt.on?{text:i,mode:t}:{message:i,mode:t,files:e}}const Zo=i=>`#${i.replace(/\s+/g,"-")}`.toLowerCase();async function am({text:i,mode:t,model:e}){const n=(i.match(/(^|\s)#[\w.-]+/g)||[]).map(c=>c.trim().toLowerCase()),s=Gt.repos||[],r=s.filter(c=>n.includes(Zo(c)));if(r.length!==1){const c=s.map(Zo).join(", ")||"none yet";throw new Error(r.length?"Name just one project per job.":`Name the project with a # tag. You can use: ${c}.`)}const a=r[0],o=i.replace(new RegExp(`(^|\\s)${Zo(a).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?=\\s|$)`,"i")," ").replace(/\s+/g," ").trim();if(!o)throw new Error("Say what the job is, as well as the project.");const{job:l}=await Ii(`/api/visit/${encodeURIComponent(Gt.link)}/jobs`,{repo:a,prompt:o,mode:t,model:e});return l}function om(i){return!Gt.on||!i?i:Object.fromEntries(Object.entries(i).filter(([t])=>(ia[t]??9)<=ia[Gt.clearance]))}function ru(i){return!Gt.on||!Array.isArray(i)?i:i.filter(t=>{var e;return(e=Gt.repos)==null?void 0:e.includes(t)})}let ys="",Ja=!1;function lm(i){if(!Gt.on)return null;if(i===4404)ys="The host ended this link. You can’t visit any more.";else if(i===4502)ys="Can’t reach the host’s office right now. Trying again…";else return ys="",null;return Ja=i===4404,Do(),i===4404?0:1e4}function Do(){var r,a,o,l;if(!Gt.on)return;const i=Gt.host||((r=Kn==null?void 0:Kn.find(c=>c.id===Gt.link))==null?void 0:r.peer)||"";i&&(Gt.host=i),Yo.classList.add("visiting"),Yo.dataset.visiting=i,Yo.classList.toggle("visit-ended",!!Ja);const t=document.getElementById("input");if(t){t.placeholder=Ja?"This link has ended.":`Start a job${i?` at @${i}`:""} · #project`;for(const c of document.querySelectorAll("#composer textarea, #composer select, #composer button"))c.disabled=!!Ja}const e=document.getElementById("mode");if(e){for(const c of e.options)c.hidden=c.disabled=ia[c.value]>ia[Gt.clearance];(a=e.selectedOptions[0])!=null&&a.disabled&&(e.value=Gt.clearance)}let n=document.getElementById("visitBar");n||(n=Pt("div",{className:"visit-bar",id:"visitBar"}),n.setAttribute("role","status"),(o=document.querySelector(".brand"))==null||o.after(n));const s=Pt("a",{href:location.pathname,textContent:"Back to my office"});n.replaceChildren(Pt("span",{},"Visiting ",Pt("strong",{textContent:i?`@${i}`:"a linked office"}),Gt.repos?` · ${Gt.repos.length} ${Gt.repos.length===1?"project":"projects"}, up to ${(l=ih.find(c=>c.id===Gt.clearance))==null?void 0:l.name.toLowerCase()}`:""),s),n.classList.toggle("visit-off",!!ys),ys&&n.append(Pt("p",{className:"visit-note",textContent:ys}))}Do();const Js=document.getElementById("setBtn"),Le=document.getElementById("settings");let Ms=null,Ze={},hr=!1,ss="",sf=()=>{};const Te=(i,t={})=>Object.assign(document.createElement(i),t);Te.kids=(i,t)=>(i.append(...t),i);const Qa=i=>i.key in Ze?Ze[i.key]:i.value,au=(i,t)=>i.kind==="bool"?t?"on":"off":i.kind==="time"?t||"off":i.kind==="text"?t||"the account name":i.kind==="number"?`${Number(t).toLocaleString()}${i.unit?` ${i.unit}`:""}`:String(t),rf=(i,t)=>Number.isInteger(t)&&t>=i.min&&t<=i.max,af=()=>Object.keys(Ze);function cm(i){const t=Qa(i),e=`set-${i.key}`,n=r=>{Object.is(r,i.value)?delete Ze[i.key]:Ze[i.key]=r,sh(),of(i)};if(i.kind==="bool"){const r=Te("button",{type:"button",id:e,className:"set-switch"});return r.setAttribute("role","switch"),r.setAttribute("aria-checked",String(!!t)),r.addEventListener("click",()=>{n(!Qa(i)),r.setAttribute("aria-checked",String(!!Qa(i)))}),r}if(i.kind==="choice"){const r=Te("div",{className:"theme-modes set-choice"});r.setAttribute("role","radiogroup"),r.setAttribute("aria-label",i.label),r.style.gridTemplateColumns=`repeat(${i.options.length}, 1fr)`;for(const a of i.options){const o=Te("button",{type:"button",textContent:a});o.setAttribute("role","radio"),o.setAttribute("aria-checked",String(a===t)),o.addEventListener("click",()=>{n(a);for(const l of r.children)l.setAttribute("aria-checked",String(l.textContent===a))}),r.append(o)}return r}const s=Te("input",{id:e,className:"set-input"});return s.spellcheck=!1,s.autocomplete="off",i.kind==="number"?Object.assign(s,{type:"number",min:i.min,max:i.max,step:i.step||1,value:t,inputMode:"numeric"}):i.kind==="time"?Object.assign(s,{type:"time",value:t}):Object.assign(s,{type:"text",value:t,maxLength:i.max,placeholder:i.default||"Your first name"}),s.addEventListener("input",()=>{const r=s.value;n(i.kind==="number"?r===""?NaN:Number(r):r)}),s}const Jl=new Map;function of(i){const t=Jl.get(i.key);if(!t)return;t.classList.toggle("set-changed",i.key in Ze);const e=t.querySelector(".set-fine");e.replaceChildren();const n=Qa(i);if(i.kind==="number"&&!rf(i,n)){e.textContent=`Use a whole number from ${i.min.toLocaleString()} to ${i.max.toLocaleString()}.`,e.classList.add("acct-err");return}if(e.classList.remove("acct-err"),i.hint&&e.append(i.hint," "),i.custom&&!(i.key in Ze)){const s=Te("button",{type:"button",className:"acct-forget set-reset",textContent:`Use the default (${au(i,i.default)})`});s.addEventListener("click",()=>Ql({[i.key]:null})),e.append(s)}else i.custom||e.append(`Default: ${au(i,i.default)}.`)}function sh(){const i=af().length,t=Le.querySelector(".set-save"),e=Le.querySelector(".set-undo"),n=Le.querySelector(".set-msg");if(!t)return;const s=Ms.some(r=>r.key in Ze&&r.kind==="number"&&!rf(r,Ze[r.key]));t.disabled=hr||!i||s,t.textContent=hr?"Saving…":i>1?`Save ${i} changes`:"Save",e.hidden=!i||hr,n.textContent=ss||(i?"Unsaved changes":""),n.classList.toggle("acct-err",!!ss)}function ur(){Jl.clear();const i=Le.querySelector(".set-body");if(i.replaceChildren(),!Ms){i.append(Te("p",{className:"acct-note",textContent:ss||"Loading…"}));return}const t=[...new Set(Ms.map(e=>e.group))];for(const e of t){const n=Te("section",{className:"set-group"});n.append(Te("h3",{className:"theme-k",textContent:e}));for(const s of Ms.filter(r=>r.group===e)){const r=Te("div",{className:"set-row"}),a=Te("div",{className:"set-text"}),o=Te("label",{className:"set-label",textContent:s.label});o.htmlFor=`set-${s.key}`,a.append(o,Te("p",{className:"acct-note acct-fine set-fine"})),r.append(a,cm(s)),Jl.set(s.key,r),n.append(r),of(s)}i.append(n)}sh()}async function Ql(i){hr=!0,ss="",sh();try{const t=await fetch("/api/settings",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i)}),e=await t.json();if(!t.ok)throw new Error(e.error||"That didn’t save.");for(const n of Object.keys(i))delete Ze[n];rh(e),sf("Settings saved","good")}catch(t){ss=t.message}hr=!1,ur()}let lf=()=>{};function rh(i){Ms=i.settings;for(const t of Ms)t.key in Ze&&Object.is(Ze[t.key],t.value)&&delete Ze[t.key];i.owner!==void 0&&lf(i.owner)}function ou(i){i!=null&&i.settings&&(rh(i),Le!=null&&Le.open&&!hr&&ur())}function hm(){var i;ss="",Le.showModal(),Js.setAttribute("aria-expanded","true"),ur(),Ms||fetch("/api/settings").then(t=>t.ok?t.json():Promise.reject()).then(t=>{rh(t),ur()},()=>{ss="Restart the office server to use Settings.",ur()}),(i=Le.querySelector("input, button.set-switch, [role=radio]"))==null||i.focus()}function Jo(){return af().length&&!confirm("Discard your unsaved changes?")?!1:(Ze={},Le.close(),!0)}function um({toast:i,renderOwner:t}){if(sf=i,lf=t,!(!Js||!Le)){if(Gt.on){Js.hidden=!0;return}Le.append(Te.kids(Te("header",{className:"set-head"}),[Te("h2",{textContent:"Settings"}),Object.assign(Te("button",{type:"button",className:"theme-btn set-x"}),{innerHTML:'<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 6l12 12M18 6 6 18"/></svg>',ariaLabel:"Close settings"})]),Te("div",{className:"set-body"}),Te.kids(Te("footer",{className:"set-foot"}),[Te("span",{className:"set-msg",role:"status"}),Te("button",{type:"button",className:"set-undo acct-forget",textContent:"Discard",hidden:!0}),Te("button",{type:"button",className:"primary small set-save",textContent:"Save",disabled:!0})])),Le.querySelector(".set-x").addEventListener("click",Jo),Le.querySelector(".set-undo").addEventListener("click",()=>{Ze={},ss="",ur()}),Le.querySelector(".set-save").addEventListener("click",()=>Ql({...Ze})),Js.addEventListener("click",hm),Le.addEventListener("cancel",e=>{e.preventDefault(),Jo()}),Le.addEventListener("click",e=>{e.target===Le&&Jo()}),Le.addEventListener("close",()=>{Js.setAttribute("aria-expanded","false"),Js.focus()}),Le.addEventListener("keydown",e=>{e.key==="Enter"&&e.target.matches("input")&&!Le.querySelector(".set-save").disabled&&(e.preventDefault(),Ql({...Ze}))})}}const dr=document.getElementById("lbBtn"),we=document.getElementById("lbPop"),cf=[{id:"jobs",name:"Jobs",value:i=>String(i.jobs)},{id:"tokens",name:"Tokens",value:i=>ah(i.tokens)},{id:"time",name:"Time",value:i=>oh(i.seconds)}],dm=[{id:"week",name:"This week"},{id:"all",name:"All time"}];let jt=null,tc="week",jr="jobs",Yi=null,ec=!1,Ti=!1,In="",nc="";const Kt=(i,t={})=>Object.assign(document.createElement(i),t);function ah(i){return i>=1e9?`${(i/1e9).toFixed(1)}B`:i>=1e6?`${(i/1e6).toFixed(1)}M`:i>=1e3?`${(i/1e3).toFixed(i>=1e5?0:1)}k`:String(i)}function oh(i){const t=Math.round(i/60);return t<1?i>0?"<1m":"0m":t<60?`${t}m`:`${Math.floor(t/60)}h ${String(t%60).padStart(2,"0")}m`}function hf(i){const t=Math.max(0,Math.round((Date.now()-i)/1e3));return t<90?"just now":t<5400?`${Math.round(t/60)} min ago`:t<129600?`${Math.round(t/3600)} h ago`:`${Math.round(t/86400)} days ago`}function lu(i,t,e,n,s=""){const r=Kt("div",{className:`theme-modes lb-tabs ${s}`});r.setAttribute("role","radiogroup"),r.setAttribute("aria-label",e);for(const a of i){const o=Kt("button",{type:"button"});o.setAttribute("role","radio"),o.setAttribute("aria-checked",String(a.id===t)),o.append(Kt("span",{textContent:a.name})),o.addEventListener("click",()=>n(a.id)),r.append(o)}return r}function Zn(){if(!we)return;we.replaceChildren(Kt("p",{className:"theme-k",textContent:"Leaderboard"}));const i=(t,e="acct-note")=>we.append(Kt("p",{className:e,textContent:t}));if(!jt){i(In||"Checking…");return}if(!jt.configured){i("No leaderboard is set up for this office. Whoever hosts one gives you its address: set it as OFFICE_LEADERBOARD_URL and restart the office.");return}if(cu())fm();else if(jt.joined){const t=jt.week,e=Kt("p",{className:"lb-me"});we.append(e),e.append(Kt("strong",{textContent:jt.handle}),Kt("span",{textContent:` · ${t.jobs} ${t.jobs===1?"job":"jobs"}, ${ah(t.tokens)} tokens, ${oh(t.seconds)} this week`}));const n=jt.error?`Not shared yet: ${jt.error}`:jt.lastSync?`Shared ${hf(jt.lastSync)}.`:"Sharing…";i(n,jt.error?"acct-note acct-err":"acct-note acct-fine")}else{i("Compete on jobs finished, tokens used and time your agents spend working. Joining shares exactly these counters per day, for the last two weeks and from now on, under the handle you claim. Never prompts, projects, files, chat or cost.");const t=Kt("form",{className:"acct-form"}),e=Kt("input",{type:"text",placeholder:"Pick a handle",autocomplete:"off",spellcheck:!1,maxLength:20});e.setAttribute("aria-label","Handle"),t.append(e,Kt("button",{type:"submit",className:"primary small",textContent:Ti?"Joining…":"Join",disabled:Ti})),t.addEventListener("submit",n=>{n.preventDefault(),e.value.trim()&&vo("POST",{handle:e.value})}),we.append(t),In&&i(In,"acct-note acct-err")}if(we.append(lu(dm,tc,"Period",t=>{tc=t,go()},"lb-period"),lu(cf,jr,"Ranked by",t=>{jr=t,Zn()},"lb-metric")),we.append(pm()),jt.joined&&!cu()){const t=Kt("button",{type:"button",className:"acct-forget",textContent:Ti?"Working…":"Leave and delete my data",disabled:Ti});t.addEventListener("click",()=>{confirm("Leave the leaderboard? Your handle is released and your counters are deleted from the service.")&&vo("DELETE")}),we.append(t),In&&i(In,"acct-note acct-err")}}const cu=()=>!!jt&&"sharing"in jt&&!!jt.handle;function fm(){const i=(s,r="acct-note")=>we.append(Kt("p",{className:r,textContent:s})),t=Kt("p",{className:"lb-me"});if(t.append(Kt("strong",{textContent:jt.handle})),jt.sharing&&jt.week){const s=jt.week;t.append(Kt("span",{textContent:` · ${s.jobs} ${s.jobs===1?"job":"jobs"}, ${ah(s.tokens)} tokens, ${oh(s.seconds)} this week`}))}we.append(t);const e=Kt("input",{type:"checkbox",checked:!!jt.sharing,disabled:Ti});e.addEventListener("change",()=>{if(e.checked){vo("POST",{handle:jt.handle});return}confirm("Stop sharing? Your counters are deleted from the board. You keep your handle while you have linked offices; with none, the handle is released too.")?vo("DELETE"):e.checked=!0});const n=Kt("label",{className:"lb-share"});if(n.append(e,Kt("span",{textContent:"Share my counters on the board"})),we.append(n),jt.sharing){const s=jt.error?`Not shared yet: ${jt.error}`:jt.lastSync?`Shared ${hf(jt.lastSync)}.`:"Sharing…";i(s,jt.error?"acct-note acct-err":"acct-note acct-fine")}else i("Sharing sends jobs finished, tokens and agent time per day, for the last two weeks and from now on. Never prompts, projects, files, chat or cost.","acct-note acct-fine");In&&i(In,"acct-note acct-err")}function pm(){var r;const i=Kt("div",{className:"lb-board"});if(!Yi)return i.append(Kt("p",{className:"acct-note",textContent:ec?"Loading…":nc||"No board yet."})),i;const e=Yi[jr==="time"?"time":jr]||[];if(!e.length)return i.append(Kt("p",{className:"acct-note",textContent:"Nobody on the board yet."})),i;const n=cf.find(a=>a.id===jr),s=Kt("ol",{className:"lb-list"});for(const a of e){const o=Kt("li",{className:a.handle.toLowerCase()===((r=jt.handle)==null?void 0:r.toLowerCase())?"lb-row lb-you":"lb-row"});o.append(Kt("span",{className:"lb-rank",textContent:String(a.rank)}),Kt("span",{className:"lb-name",textContent:a.handle}),Kt("span",{className:"lb-val",textContent:n.value(a)})),s.append(o)}return i.append(s),Yi.players>e.length&&i.append(Kt("p",{className:"acct-note acct-fine",textContent:`Top ${e.length} of ${Yi.players}.`})),Yi.since&&i.append(Kt("p",{className:"acct-note acct-fine",textContent:"Weeks start Monday, UTC."})),i}async function go(){if(jt!=null&&jt.configured){ec=!0,nc="",Zn();try{const i=await fetch(`/api/leaderboard/board?period=${tc}`),t=await i.json();if(!i.ok)throw new Error(t.error||"Couldn’t load the board.");Yi=t}catch(i){Yi=null,nc=i.message}ec=!1,we.hidden||Zn()}}async function vo(i,t){Ti=!0,In="",Zn();try{const e=await fetch("/api/leaderboard",i==="POST"?{method:i,headers:{"content-type":"application/json"},body:JSON.stringify(t)}:{method:i}),n=await e.json();if(!e.ok)throw new Error(n.error||"That didn’t work.");aa(n),Yi=null}catch(e){In=e.message}Ti=!1,Zn(),In||go()}function hu(i){i&&(aa(i),!Ti&&!we.hidden&&Zn())}function aa(i){jt=i,document.dispatchEvent(new CustomEvent("office:leaderboard",{detail:i}))}document.addEventListener("office:leaderboard",i=>{i.detail!==jt&&(jt=i.detail,!Ti&&we&&!we.hidden&&Zn())});function Io(i){if(we.hidden=!i,dr.setAttribute("aria-expanded",String(i)),!i){In="";return}Zn(),jt?go():fetch("/api/leaderboard").then(t=>t.ok?t.json():Promise.reject()).then(t=>{aa(t),Zn(),go()},()=>{In="Restart the office server to use this.",Zn()})}dr==null||dr.addEventListener("click",()=>Io(we.hidden));var Jd;for(const i of["themeBtn","acctBtn"])(Jd=document.getElementById(i))==null||Jd.addEventListener("click",()=>{we.hidden||Io(!1)});document.addEventListener("click",i=>{const t=i.composedPath();we&&!we.hidden&&!t.includes(we)&&!t.includes(dr)&&Io(!1)});document.addEventListener("keydown",i=>{i.key==="Escape"&&we&&!we.hidden&&(Io(!1),dr.focus())});const ic="office.nameAsked",mm="office.name",gm=i=>i.trim().replace(/\s+/g,"_").replace(/[^A-Za-z0-9_-]/g,"").slice(0,20);function vm(){const i=Kt("dialog",{className:"name-ask"}),t=Kt("form",{method:"dialog"}),e=Kt("input",{type:"text",placeholder:"Your name",autocomplete:"off",spellcheck:!1,maxLength:40});e.setAttribute("aria-label","Your name");const n=Kt("p",{className:"acct-note acct-err",hidden:!0}),s=Kt("button",{type:"submit",className:"primary small",textContent:"Continue"}),r=Kt("button",{type:"button",className:"acct-forget",textContent:"Not now"}),a=Kt("div",{className:"acct-form"});a.append(e,s),t.append(Kt("h2",{textContent:"Welcome to the office"}),Kt("p",{className:"acct-note",textContent:jt!=null&&jt.configured?"What should we call you? Your name becomes your handle on the leaderboard. Nothing is shared until you join it.":"What should we call you?"}),a,n,r),i.append(t);const o=()=>{try{localStorage.setItem(ic,"1")}catch{}i.close(),i.remove()};r.addEventListener("click",o),i.addEventListener("cancel",o),t.addEventListener("submit",async l=>{l.preventDefault();const c=e.value.trim(),h=gm(c);if(c){n.hidden=!0,s.disabled=!0;try{if(jt!=null&&jt.configured){if(h.length<3)throw new Error("Use at least 3 letters or numbers.");const u=await fetch("/api/leaderboard/handle",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({handle:h})}),d=await u.json();if(!u.ok)throw new Error(d.error||"That handle didn’t work.");aa(d),we.hidden||Zn()}try{localStorage.setItem(mm,c)}catch{}o()}catch(u){n.textContent=u.message,n.hidden=!1,s.disabled=!1,e.focus()}}}),document.body.append(i),i.showModal(),e.focus()}try{!localStorage.getItem(ic)&&!new URLSearchParams(location.search).has("visit")&&fetch("/api/leaderboard").then(i=>i.ok?i.json():null).catch(()=>null).then(i=>{if(i&&aa(i),i!=null&&i.handle){try{localStorage.setItem(ic,"1")}catch{}return}vm()})}catch{}/**
|
|
3
2
|
* @license
|
|
4
3
|
* Copyright 2010-2024 Three.js Authors
|
|
5
4
|
* SPDX-License-Identifier: MIT
|
|
6
|
-
*/const ch="169",Di={ROTATE:0,DOLLY:1,PAN:2},is={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Mm=0,hu=1,bm=2,ff=1,pf=2,Ei=3,os=0,un=1,li=2,Ye=0,pr=1,ac=2,uu=3,du=4,mf=5,jn=100,Sm=101,wm=102,Em=103,Tm=104,$r=200,Am=201,Cm=202,Rm=203,oc=204,lc=205,cc=206,Pm=207,hc=208,Lm=209,Dm=210,Im=211,km=212,Nm=213,Um=214,uc=0,dc=1,fc=2,xr=3,pc=4,mc=5,gc=6,vc=7,gf=0,Om=1,Fm=2,ss=0,vf=1,_f=2,xf=3,yf=4,zm=5,Mf=6,hh=7,bf=300,yr=301,Mr=302,_c=303,xc=304,Uo=306,Ni=1e3,Ms=1001,yc=1002,rn=1003,Bm=1004,pa=1005,qn=1006,el=1007,bs=1008,pi=1009,Sf=1010,wf=1011,ra=1012,uh=1013,Ts=1014,Ci=1015,Ui=1016,dh=1017,fh=1018,As=1020,Ef=35902,Tf=1021,Af=1022,Nn=1023,Cf=1024,Rf=1025,mr=1026,Cs=1027,Pf=1028,ph=1029,Lf=1030,mh=1031,gh=1033,no=33776,io=33777,so=33778,ro=33779,Mc=35840,bc=35841,Sc=35842,wc=35843,Ec=36196,Tc=37492,Ac=37496,Cc=37808,Rc=37809,Pc=37810,Lc=37811,Dc=37812,Ic=37813,kc=37814,Nc=37815,Uc=37816,Oc=37817,Fc=37818,zc=37819,Bc=37820,Hc=37821,ao=36492,Vc=36494,Gc=36495,Df=36283,$c=36284,Wc=36285,Xc=36286,Hm=3200,Vm=3201,vh=0,Gm=1,Ji="",Ke="srgb",cs="srgb-linear",_h="display-p3",Oo="display-p3-linear",yo="linear",ye="srgb",Mo="rec709",bo="p3",Us=7680,fu=519,$m=512,Wm=513,Xm=514,If=515,jm=516,qm=517,Ym=518,Km=519,pu=35044,mu="300 es",Ri=2e3,So=2001;class Ps{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const n=this._listeners;return n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const s=this._listeners[t];if(s!==void 0){const r=s.indexOf(e);r!==-1&&s.splice(r,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const n=this._listeners[t.type];if(n!==void 0){t.target=this;const s=n.slice(0);for(let r=0,a=s.length;r<a;r++)s[r].call(this,t);t.target=null}}}const tn=["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 gu=1234567;const qr=Math.PI/180,aa=180/Math.PI;function Tr(){const i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(tn[i&255]+tn[i>>8&255]+tn[i>>16&255]+tn[i>>24&255]+"-"+tn[t&255]+tn[t>>8&255]+"-"+tn[t>>16&15|64]+tn[t>>24&255]+"-"+tn[e&63|128]+tn[e>>8&255]+"-"+tn[e>>16&255]+tn[e>>24&255]+tn[n&255]+tn[n>>8&255]+tn[n>>16&255]+tn[n>>24&255]).toLowerCase()}function ze(i,t,e){return Math.max(t,Math.min(e,i))}function xh(i,t){return(i%t+t)%t}function Zm(i,t,e,n,s){return n+(i-t)*(s-n)/(e-t)}function Jm(i,t,e){return i!==t?(e-i)/(t-i):0}function Yr(i,t,e){return(1-e)*i+e*t}function Qm(i,t,e,n){return Yr(i,t,1-Math.exp(-e*n))}function t0(i,t=1){return t-Math.abs(xh(i,t*2)-t)}function e0(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function n0(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function i0(i,t){return i+Math.floor(Math.random()*(t-i+1))}function s0(i,t){return i+Math.random()*(t-i)}function r0(i){return i*(.5-Math.random())}function a0(i){i!==void 0&&(gu=i);let t=gu+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function o0(i){return i*qr}function l0(i){return i*aa}function c0(i){return(i&i-1)===0&&i!==0}function h0(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function u0(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function d0(i,t,e,n,s){const r=Math.cos,a=Math.sin,o=r(e/2),l=a(e/2),c=r((t+n)/2),h=a((t+n)/2),u=r((t-n)/2),d=a((t-n)/2),f=r((n-t)/2),g=a((n-t)/2);switch(s){case"XYX":i.set(o*h,l*u,l*d,o*c);break;case"YZY":i.set(l*d,o*h,l*u,o*c);break;case"ZXZ":i.set(l*u,l*d,o*h,o*c);break;case"XZX":i.set(o*h,l*g,l*f,o*c);break;case"YXY":i.set(l*f,o*h,l*g,o*c);break;case"ZYZ":i.set(l*g,l*f,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function ir(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function on(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const xs={DEG2RAD:qr,RAD2DEG:aa,generateUUID:Tr,clamp:ze,euclideanModulo:xh,mapLinear:Zm,inverseLerp:Jm,lerp:Yr,damp:Qm,pingpong:t0,smoothstep:e0,smootherstep:n0,randInt:i0,randFloat:s0,randFloatSpread:r0,seededRandom:a0,degToRad:o0,radToDeg:l0,isPowerOfTwo:c0,ceilPowerOfTwo:h0,floorPowerOfTwo:u0,setQuaternionFromProperEuler:d0,normalize:on,denormalize:ir};class rt{constructor(t=0,e=0){rt.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6],this.y=s[1]*e+s[4]*n+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,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(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(ze(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),s=Math.sin(e),r=this.x-t.x,a=this.y-t.y;return this.x=r*n-a*s+t.x,this.y=r*s+a*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Xt{constructor(t,e,n,s,r,a,o,l,c){Xt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,a,o,l,c)}set(t,e,n,s,r,a,o,l,c){const h=this.elements;return h[0]=t,h[1]=s,h[2]=o,h[3]=e,h[4]=r,h[5]=l,h[6]=n,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,s=e.elements,r=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],h=n[4],u=n[7],d=n[2],f=n[5],g=n[8],_=s[0],m=s[3],p=s[6],y=s[1],x=s[4],S=s[7],L=s[2],T=s[5],E=s[8];return r[0]=a*_+o*y+l*L,r[3]=a*m+o*x+l*T,r[6]=a*p+o*S+l*E,r[1]=c*_+h*y+u*L,r[4]=c*m+h*x+u*T,r[7]=c*p+h*S+u*E,r[2]=d*_+f*y+g*L,r[5]=d*m+f*x+g*T,r[8]=d*p+f*S+g*E,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8];return e*a*h-e*o*c-n*r*h+n*o*l+s*r*c-s*a*l}invert(){const t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8],u=h*a-o*c,d=o*l-h*r,f=c*r-a*l,g=e*u+n*d+s*f;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/g;return t[0]=u*_,t[1]=(s*c-h*n)*_,t[2]=(o*n-s*a)*_,t[3]=d*_,t[4]=(h*e-s*l)*_,t[5]=(s*r-o*e)*_,t[6]=f*_,t[7]=(n*l-c*e)*_,t[8]=(a*e-n*r)*_,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,s,r,a,o){const l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*a+c*o)+a+t,-s*c,s*l,-s*(-c*a+l*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(nl.makeScale(t,e)),this}rotate(t){return this.premultiply(nl.makeRotation(-t)),this}translate(t,e){return this.premultiply(nl.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let s=0;s<9;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const nl=new Xt;function kf(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function wo(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function f0(){const i=wo("canvas");return i.style.display="block",i}const vu={};function oo(i){i in vu||(vu[i]=!0,console.warn(i))}function p0(i,t,e){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(t,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,e);break;default:n()}}setTimeout(r,e)})}function m0(i){const t=i.elements;t[2]=.5*t[2]+.5*t[3],t[6]=.5*t[6]+.5*t[7],t[10]=.5*t[10]+.5*t[11],t[14]=.5*t[14]+.5*t[15]}function g0(i){const t=i.elements;t[11]===-1?(t[10]=-t[10]-1,t[14]=-t[14]):(t[10]=-t[10],t[14]=-t[14]+1)}const _u=new Xt().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),xu=new Xt().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Rr={[cs]:{transfer:yo,primaries:Mo,luminanceCoefficients:[.2126,.7152,.0722],toReference:i=>i,fromReference:i=>i},[Ke]:{transfer:ye,primaries:Mo,luminanceCoefficients:[.2126,.7152,.0722],toReference:i=>i.convertSRGBToLinear(),fromReference:i=>i.convertLinearToSRGB()},[Oo]:{transfer:yo,primaries:bo,luminanceCoefficients:[.2289,.6917,.0793],toReference:i=>i.applyMatrix3(xu),fromReference:i=>i.applyMatrix3(_u)},[_h]:{transfer:ye,primaries:bo,luminanceCoefficients:[.2289,.6917,.0793],toReference:i=>i.convertSRGBToLinear().applyMatrix3(xu),fromReference:i=>i.applyMatrix3(_u).convertLinearToSRGB()}},v0=new Set([cs,Oo]),oe={enabled:!0,_workingColorSpace:cs,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(i){if(!v0.has(i))throw new Error(`Unsupported working color space, "${i}".`);this._workingColorSpace=i},convert:function(i,t,e){if(this.enabled===!1||t===e||!t||!e)return i;const n=Rr[t].toReference,s=Rr[e].fromReference;return s(n(i))},fromWorkingColorSpace:function(i,t){return this.convert(i,this._workingColorSpace,t)},toWorkingColorSpace:function(i,t){return this.convert(i,t,this._workingColorSpace)},getPrimaries:function(i){return Rr[i].primaries},getTransfer:function(i){return i===Ji?yo:Rr[i].transfer},getLuminanceCoefficients:function(i,t=this._workingColorSpace){return i.fromArray(Rr[t].luminanceCoefficients)}};function gr(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function il(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let Os;class _0{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{Os===void 0&&(Os=wo("canvas")),Os.width=t.width,Os.height=t.height;const n=Os.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=Os}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=wo("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const s=n.getImageData(0,0,t.width,t.height),r=s.data;for(let a=0;a<r.length;a++)r[a]=gr(r[a]/255)*255;return n.putImageData(s,0,0),e}else if(t.data){const e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(gr(e[n]/255)*255):e[n]=gr(e[n]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let x0=0;class Nf{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:x0++}),this.uuid=Tr(),this.data=t,this.dataReady=!0,this.version=0}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const n={uuid:this.uuid,url:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let a=0,o=s.length;a<o;a++)s[a].isDataTexture?r.push(sl(s[a].image)):r.push(sl(s[a]))}else r=sl(s);n.url=r}return e||(t.images[this.uuid]=n),n}}function sl(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?_0.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let y0=0;class an extends Ps{constructor(t=an.DEFAULT_IMAGE,e=an.DEFAULT_MAPPING,n=Ms,s=Ms,r=qn,a=bs,o=Nn,l=pi,c=an.DEFAULT_ANISOTROPY,h=Ji){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:y0++}),this.uuid=Tr(),this.name="",this.source=new Nf(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new rt(0,0),this.repeat=new rt(1,1),this.center=new rt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Xt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(t=null){this.source.data=t}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(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).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),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==bf)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Ni:t.x=t.x-Math.floor(t.x);break;case Ms:t.x=t.x<0?0:1;break;case yc:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Ni:t.y=t.y-Math.floor(t.y);break;case Ms:t.y=t.y<0?0:1;break;case yc:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}an.DEFAULT_IMAGE=null;an.DEFAULT_MAPPING=bf;an.DEFAULT_ANISOTROPY=1;class me{constructor(t=0,e=0,n=0,s=1){me.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=s}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,s){return this.x=t,this.y=e,this.z=n,this.w=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,s=this.z,r=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*s+a[12]*r,this.y=a[1]*e+a[5]*n+a[9]*s+a[13]*r,this.z=a[2]*e+a[6]*n+a[10]*s+a[14]*r,this.w=a[3]*e+a[7]*n+a[11]*s+a[15]*r,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,s,r;const l=t.elements,c=l[0],h=l[4],u=l[8],d=l[1],f=l[5],g=l[9],_=l[2],m=l[6],p=l[10];if(Math.abs(h-d)<.01&&Math.abs(u-_)<.01&&Math.abs(g-m)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+_)<.1&&Math.abs(g+m)<.1&&Math.abs(c+f+p-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const x=(c+1)/2,S=(f+1)/2,L=(p+1)/2,T=(h+d)/4,E=(u+_)/4,P=(g+m)/4;return x>S&&x>L?x<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(x),s=T/n,r=E/n):S>L?S<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(S),n=T/s,r=P/s):L<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(L),n=E/r,s=P/r),this.set(n,s,r,e),this}let y=Math.sqrt((m-g)*(m-g)+(u-_)*(u-_)+(d-h)*(d-h));return Math.abs(y)<.001&&(y=1),this.x=(m-g)/y,this.y=(u-_)/y,this.z=(d-h)/y,this.w=Math.acos((c+f+p-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,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(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class M0 extends Ps{constructor(t=1,e=1,n={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new me(0,0,t,e),this.scissorTest=!1,this.viewport=new me(0,0,t,e);const s={width:t,height:e,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:qn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const r=new an(s,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 a=n.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].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(t){this.textures[0]=t}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=t,this.textures[s].image.height=e,this.textures[s].image.depth=n;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let n=0,s=t.textures.length;n<s;n++)this.textures[n]=t.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0;const e=Object.assign({},t.texture.image);return this.texture.source=new Nf(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Qn extends M0{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class Uf extends an{constructor(t=null,e=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=rn,this.minFilter=rn,this.wrapR=Ms,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class b0 extends an{constructor(t=null,e=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=rn,this.minFilter=rn,this.wrapR=Ms,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class ls{constructor(t=0,e=0,n=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=s}static slerpFlat(t,e,n,s,r,a,o){let l=n[s+0],c=n[s+1],h=n[s+2],u=n[s+3];const d=r[a+0],f=r[a+1],g=r[a+2],_=r[a+3];if(o===0){t[e+0]=l,t[e+1]=c,t[e+2]=h,t[e+3]=u;return}if(o===1){t[e+0]=d,t[e+1]=f,t[e+2]=g,t[e+3]=_;return}if(u!==_||l!==d||c!==f||h!==g){let m=1-o;const p=l*d+c*f+h*g+u*_,y=p>=0?1:-1,x=1-p*p;if(x>Number.EPSILON){const L=Math.sqrt(x),T=Math.atan2(L,p*y);m=Math.sin(m*T)/L,o=Math.sin(o*T)/L}const S=o*y;if(l=l*m+d*S,c=c*m+f*S,h=h*m+g*S,u=u*m+_*S,m===1-o){const L=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=L,c*=L,h*=L,u*=L}}t[e]=l,t[e+1]=c,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,s,r,a){const o=n[s],l=n[s+1],c=n[s+2],h=n[s+3],u=r[a],d=r[a+1],f=r[a+2],g=r[a+3];return t[e]=o*g+h*u+l*f-c*d,t[e+1]=l*g+h*d+c*u-o*f,t[e+2]=c*g+h*f+o*d-l*u,t[e+3]=h*g-o*u-l*d-c*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,s){return this._x=t,this._y=e,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,s=t._y,r=t._z,a=t._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(s/2),u=o(r/2),d=l(n/2),f=l(s/2),g=l(r/2);switch(a){case"XYZ":this._x=d*h*u+c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u-d*f*g;break;case"YXZ":this._x=d*h*u+c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u+d*f*g;break;case"ZXY":this._x=d*h*u-c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u-d*f*g;break;case"ZYX":this._x=d*h*u-c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u+d*f*g;break;case"YZX":this._x=d*h*u+c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u-d*f*g;break;case"XZY":this._x=d*h*u-c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u+d*f*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,s=Math.sin(n);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],s=e[4],r=e[8],a=e[1],o=e[5],l=e[9],c=e[2],h=e[6],u=e[10],d=n+o+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-l)*f,this._y=(r-c)*f,this._z=(a-s)*f}else if(n>o&&n>u){const f=2*Math.sqrt(1+n-o-u);this._w=(h-l)/f,this._x=.25*f,this._y=(s+a)/f,this._z=(r+c)/f}else if(o>u){const f=2*Math.sqrt(1+o-n-u);this._w=(r-c)/f,this._x=(s+a)/f,this._y=.25*f,this._z=(l+h)/f}else{const f=2*Math.sqrt(1+u-n-o);this._w=(a-s)/f,this._x=(r+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<Number.EPSILON?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(ze(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const s=Math.min(1,e/n);return this.slerp(t,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,s=t._y,r=t._z,a=t._w,o=e._x,l=e._y,c=e._z,h=e._w;return this._x=n*h+a*o+s*c-r*l,this._y=s*h+a*l+r*o-n*c,this._z=r*h+a*c+n*l-s*o,this._w=a*h-n*o-s*l-r*c,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const n=this._x,s=this._y,r=this._z,a=this._w;let o=a*t._w+n*t._x+s*t._y+r*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=n,this._y=s,this._z=r,this;const l=1-o*o;if(l<=Number.EPSILON){const f=1-e;return this._w=f*a+e*this._w,this._x=f*n+e*this._x,this._y=f*s+e*this._y,this._z=f*r+e*this._z,this.normalize(),this}const c=Math.sqrt(l),h=Math.atan2(c,o),u=Math.sin((1-e)*h)/c,d=Math.sin(e*h)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=s*u+this._y*d,this._z=r*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(t),s*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class R{constructor(t=0,e=0,n=0){R.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(yu.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(yu.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*s,this.y=r[1]*e+r[4]*n+r[7]*s,this.z=r[2]*e+r[5]*n+r[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,s=this.z,r=t.elements,a=1/(r[3]*e+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*s+r[12])*a,this.y=(r[1]*e+r[5]*n+r[9]*s+r[13])*a,this.z=(r[2]*e+r[6]*n+r[10]*s+r[14])*a,this}applyQuaternion(t){const e=this.x,n=this.y,s=this.z,r=t.x,a=t.y,o=t.z,l=t.w,c=2*(a*s-o*n),h=2*(o*e-r*s),u=2*(r*n-a*e);return this.x=e+l*c+a*u-o*h,this.y=n+l*h+o*c-r*u,this.z=s+l*u+r*h-a*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*s,this.y=r[1]*e+r[5]*n+r[9]*s,this.z=r[2]*e+r[6]*n+r[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,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(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,s=t.y,r=t.z,a=e.x,o=e.y,l=e.z;return this.x=s*l-r*o,this.y=r*a-n*l,this.z=n*o-s*a,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return rl.copy(this).projectOnVector(t),this.sub(rl)}reflect(t){return this.sub(rl.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(ze(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,s=this.z-t.z;return e*e+n*n+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const s=Math.sin(e)*t;return this.x=s*Math.sin(n),this.y=Math.cos(e)*t,this.z=s*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=s,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const rl=new R,yu=new ls;class la{constructor(t=new R(1/0,1/0,1/0),e=new R(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(Vn.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(Vn.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=Vn.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.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(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(n!==void 0){const r=n.getAttribute("position");if(e===!0&&r!==void 0&&t.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)t.isMesh===!0?t.getVertexPosition(a,Vn):Vn.fromBufferAttribute(r,a),Vn.applyMatrix4(t.matrixWorld),this.expandByPoint(Vn);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),ma.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),ma.copy(n.boundingBox)),ma.applyMatrix4(t.matrixWorld),this.union(ma)}const s=t.children;for(let r=0,a=s.length;r<a;r++)this.expandByObject(s[r],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,Vn),Vn.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Pr),ga.subVectors(this.max,Pr),Fs.subVectors(t.a,Pr),zs.subVectors(t.b,Pr),Bs.subVectors(t.c,Pr),Hi.subVectors(zs,Fs),Vi.subVectors(Bs,zs),us.subVectors(Fs,Bs);let e=[0,-Hi.z,Hi.y,0,-Vi.z,Vi.y,0,-us.z,us.y,Hi.z,0,-Hi.x,Vi.z,0,-Vi.x,us.z,0,-us.x,-Hi.y,Hi.x,0,-Vi.y,Vi.x,0,-us.y,us.x,0];return!al(e,Fs,zs,Bs,ga)||(e=[1,0,0,0,1,0,0,0,1],!al(e,Fs,zs,Bs,ga))?!1:(va.crossVectors(Hi,Vi),e=[va.x,va.y,va.z],al(e,Fs,zs,Bs,ga))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Vn).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Vn).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(xi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),xi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),xi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),xi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),xi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),xi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),xi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),xi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(xi),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const xi=[new R,new R,new R,new R,new R,new R,new R,new R],Vn=new R,ma=new la,Fs=new R,zs=new R,Bs=new R,Hi=new R,Vi=new R,us=new R,Pr=new R,ga=new R,va=new R,ds=new R;function al(i,t,e,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){ds.fromArray(i,r);const o=s.x*Math.abs(ds.x)+s.y*Math.abs(ds.y)+s.z*Math.abs(ds.z),l=t.dot(ds),c=e.dot(ds),h=n.dot(ds);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const S0=new la,Lr=new R,ol=new R;class yh{constructor(t=new R,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;e!==void 0?n.copy(e):S0.setFromPoints(t).getCenter(n);let s=0;for(let r=0,a=t.length;r<a;r++)s=Math.max(s,n.distanceToSquared(t[r]));return this.radius=Math.sqrt(s),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Lr.subVectors(t,this.center);const e=Lr.lengthSq();if(e>this.radius*this.radius){const n=Math.sqrt(e),s=(n-this.radius)*.5;this.center.addScaledVector(Lr,s/n),this.radius+=s}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(ol.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Lr.copy(t.center).add(ol)),this.expandByPoint(Lr.copy(t.center).sub(ol))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}const yi=new R,ll=new R,_a=new R,Gi=new R,cl=new R,xa=new R,hl=new R;class Mh{constructor(t=new R,e=new R(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,yi)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=yi.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(yi.copy(this.origin).addScaledVector(this.direction,e),yi.distanceToSquared(t))}distanceSqToSegment(t,e,n,s){ll.copy(t).add(e).multiplyScalar(.5),_a.copy(e).sub(t).normalize(),Gi.copy(this.origin).sub(ll);const r=t.distanceTo(e)*.5,a=-this.direction.dot(_a),o=Gi.dot(this.direction),l=-Gi.dot(_a),c=Gi.lengthSq(),h=Math.abs(1-a*a);let u,d,f,g;if(h>0)if(u=a*l-o,d=a*o-l,g=r*h,u>=0)if(d>=-g)if(d<=g){const _=1/h;u*=_,d*=_,f=u*(u+a*d+2*o)+d*(a*u+d+2*l)+c}else d=r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;else d=-r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;else d<=-g?(u=Math.max(0,-(-a*r+o)),d=u>0?-r:Math.min(Math.max(-r,-l),r),f=-u*u+d*(d+2*l)+c):d<=g?(u=0,d=Math.min(Math.max(-r,-l),r),f=d*(d+2*l)+c):(u=Math.max(0,-(a*r+o)),d=u>0?r:Math.min(Math.max(-r,-l),r),f=-u*u+d*(d+2*l)+c);else d=a>0?-r:r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),s&&s.copy(ll).addScaledVector(_a,d),f}intersectSphere(t,e){yi.subVectors(t.center,this.origin);const n=yi.dot(this.direction),s=yi.dot(yi)-n*n,r=t.radius*t.radius;if(s>r)return null;const a=Math.sqrt(r-s),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,e):this.at(o,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,s,r,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(t.min.x-d.x)*c,s=(t.max.x-d.x)*c):(n=(t.max.x-d.x)*c,s=(t.min.x-d.x)*c),h>=0?(r=(t.min.y-d.y)*h,a=(t.max.y-d.y)*h):(r=(t.max.y-d.y)*h,a=(t.min.y-d.y)*h),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a<s||isNaN(s))&&(s=a),u>=0?(o=(t.min.z-d.z)*u,l=(t.max.z-d.z)*u):(o=(t.max.z-d.z)*u,l=(t.min.z-d.z)*u),n>l||o>s)||((o>n||n!==n)&&(n=o),(l<s||s!==s)&&(s=l),s<0)?null:this.at(n>=0?n:s,e)}intersectsBox(t){return this.intersectBox(t,yi)!==null}intersectTriangle(t,e,n,s,r){cl.subVectors(e,t),xa.subVectors(n,t),hl.crossVectors(cl,xa);let a=this.direction.dot(hl),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Gi.subVectors(this.origin,t);const l=o*this.direction.dot(xa.crossVectors(Gi,xa));if(l<0)return null;const c=o*this.direction.dot(cl.cross(Gi));if(c<0||l+c>a)return null;const h=-o*Gi.dot(hl);return h<0?null:this.at(h/a,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class fe{constructor(t,e,n,s,r,a,o,l,c,h,u,d,f,g,_,m){fe.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,a,o,l,c,h,u,d,f,g,_,m)}set(t,e,n,s,r,a,o,l,c,h,u,d,f,g,_,m){const p=this.elements;return p[0]=t,p[4]=e,p[8]=n,p[12]=s,p[1]=r,p[5]=a,p[9]=o,p[13]=l,p[2]=c,p[6]=h,p[10]=u,p[14]=d,p[3]=f,p[7]=g,p[11]=_,p[15]=m,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 fe().fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,s=1/Hs.setFromMatrixColumn(t,0).length(),r=1/Hs.setFromMatrixColumn(t,1).length(),a=1/Hs.setFromMatrixColumn(t,2).length();return e[0]=n[0]*s,e[1]=n[1]*s,e[2]=n[2]*s,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,s=t.y,r=t.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(s),c=Math.sin(s),h=Math.cos(r),u=Math.sin(r);if(t.order==="XYZ"){const d=a*h,f=a*u,g=o*h,_=o*u;e[0]=l*h,e[4]=-l*u,e[8]=c,e[1]=f+g*c,e[5]=d-_*c,e[9]=-o*l,e[2]=_-d*c,e[6]=g+f*c,e[10]=a*l}else if(t.order==="YXZ"){const d=l*h,f=l*u,g=c*h,_=c*u;e[0]=d+_*o,e[4]=g*o-f,e[8]=a*c,e[1]=a*u,e[5]=a*h,e[9]=-o,e[2]=f*o-g,e[6]=_+d*o,e[10]=a*l}else if(t.order==="ZXY"){const d=l*h,f=l*u,g=c*h,_=c*u;e[0]=d-_*o,e[4]=-a*u,e[8]=g+f*o,e[1]=f+g*o,e[5]=a*h,e[9]=_-d*o,e[2]=-a*c,e[6]=o,e[10]=a*l}else if(t.order==="ZYX"){const d=a*h,f=a*u,g=o*h,_=o*u;e[0]=l*h,e[4]=g*c-f,e[8]=d*c+_,e[1]=l*u,e[5]=_*c+d,e[9]=f*c-g,e[2]=-c,e[6]=o*l,e[10]=a*l}else if(t.order==="YZX"){const d=a*l,f=a*c,g=o*l,_=o*c;e[0]=l*h,e[4]=_-d*u,e[8]=g*u+f,e[1]=u,e[5]=a*h,e[9]=-o*h,e[2]=-c*h,e[6]=f*u+g,e[10]=d-_*u}else if(t.order==="XZY"){const d=a*l,f=a*c,g=o*l,_=o*c;e[0]=l*h,e[4]=-u,e[8]=c*h,e[1]=d*u+_,e[5]=a*h,e[9]=f*u-g,e[2]=g*u-f,e[6]=o*h,e[10]=_*u+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(w0,t,E0)}lookAt(t,e,n){const s=this.elements;return wn.subVectors(t,e),wn.lengthSq()===0&&(wn.z=1),wn.normalize(),$i.crossVectors(n,wn),$i.lengthSq()===0&&(Math.abs(n.z)===1?wn.x+=1e-4:wn.z+=1e-4,wn.normalize(),$i.crossVectors(n,wn)),$i.normalize(),ya.crossVectors(wn,$i),s[0]=$i.x,s[4]=ya.x,s[8]=wn.x,s[1]=$i.y,s[5]=ya.y,s[9]=wn.y,s[2]=$i.z,s[6]=ya.z,s[10]=wn.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,s=e.elements,r=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],h=n[1],u=n[5],d=n[9],f=n[13],g=n[2],_=n[6],m=n[10],p=n[14],y=n[3],x=n[7],S=n[11],L=n[15],T=s[0],E=s[4],P=s[8],U=s[12],v=s[1],b=s[5],I=s[9],O=s[13],$=s[2],K=s[6],z=s[10],Z=s[14],V=s[3],at=s[7],ct=s[11],_t=s[15];return r[0]=a*T+o*v+l*$+c*V,r[4]=a*E+o*b+l*K+c*at,r[8]=a*P+o*I+l*z+c*ct,r[12]=a*U+o*O+l*Z+c*_t,r[1]=h*T+u*v+d*$+f*V,r[5]=h*E+u*b+d*K+f*at,r[9]=h*P+u*I+d*z+f*ct,r[13]=h*U+u*O+d*Z+f*_t,r[2]=g*T+_*v+m*$+p*V,r[6]=g*E+_*b+m*K+p*at,r[10]=g*P+_*I+m*z+p*ct,r[14]=g*U+_*O+m*Z+p*_t,r[3]=y*T+x*v+S*$+L*V,r[7]=y*E+x*b+S*K+L*at,r[11]=y*P+x*I+S*z+L*ct,r[15]=y*U+x*O+S*Z+L*_t,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],s=t[8],r=t[12],a=t[1],o=t[5],l=t[9],c=t[13],h=t[2],u=t[6],d=t[10],f=t[14],g=t[3],_=t[7],m=t[11],p=t[15];return g*(+r*l*u-s*c*u-r*o*d+n*c*d+s*o*f-n*l*f)+_*(+e*l*f-e*c*d+r*a*d-s*a*f+s*c*h-r*l*h)+m*(+e*c*u-e*o*f-r*a*u+n*a*f+r*o*h-n*c*h)+p*(-s*o*h-e*l*u+e*o*d+s*a*u-n*a*d+n*l*h)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],f=t[11],g=t[12],_=t[13],m=t[14],p=t[15],y=u*m*c-_*d*c+_*l*f-o*m*f-u*l*p+o*d*p,x=g*d*c-h*m*c-g*l*f+a*m*f+h*l*p-a*d*p,S=h*_*c-g*u*c+g*o*f-a*_*f-h*o*p+a*u*p,L=g*u*l-h*_*l-g*o*d+a*_*d+h*o*m-a*u*m,T=e*y+n*x+s*S+r*L;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const E=1/T;return t[0]=y*E,t[1]=(_*d*r-u*m*r-_*s*f+n*m*f+u*s*p-n*d*p)*E,t[2]=(o*m*r-_*l*r+_*s*c-n*m*c-o*s*p+n*l*p)*E,t[3]=(u*l*r-o*d*r-u*s*c+n*d*c+o*s*f-n*l*f)*E,t[4]=x*E,t[5]=(h*m*r-g*d*r+g*s*f-e*m*f-h*s*p+e*d*p)*E,t[6]=(g*l*r-a*m*r-g*s*c+e*m*c+a*s*p-e*l*p)*E,t[7]=(a*d*r-h*l*r+h*s*c-e*d*c-a*s*f+e*l*f)*E,t[8]=S*E,t[9]=(g*u*r-h*_*r-g*n*f+e*_*f+h*n*p-e*u*p)*E,t[10]=(a*_*r-g*o*r+g*n*c-e*_*c-a*n*p+e*o*p)*E,t[11]=(h*o*r-a*u*r-h*n*c+e*u*c+a*n*f-e*o*f)*E,t[12]=L*E,t[13]=(h*_*s-g*u*s+g*n*d-e*_*d-h*n*m+e*u*m)*E,t[14]=(g*o*s-a*_*s-g*n*l+e*_*l+a*n*m-e*o*m)*E,t[15]=(a*u*s-h*o*s+h*n*l-e*u*l-a*n*d+e*o*d)*E,this}scale(t){const e=this.elements,n=t.x,s=t.y,r=t.z;return e[0]*=n,e[4]*=s,e[8]*=r,e[1]*=n,e[5]*=s,e[9]*=r,e[2]*=n,e[6]*=s,e[10]*=r,e[3]*=n,e[7]*=s,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,s))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),s=Math.sin(e),r=1-n,a=t.x,o=t.y,l=t.z,c=r*a,h=r*o;return this.set(c*a+n,c*o-s*l,c*l+s*o,0,c*o+s*l,h*o+n,h*l-s*a,0,c*l-s*o,h*l+s*a,r*l*l+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,s,r,a){return this.set(1,n,r,0,t,1,a,0,e,s,1,0,0,0,0,1),this}compose(t,e,n){const s=this.elements,r=e._x,a=e._y,o=e._z,l=e._w,c=r+r,h=a+a,u=o+o,d=r*c,f=r*h,g=r*u,_=a*h,m=a*u,p=o*u,y=l*c,x=l*h,S=l*u,L=n.x,T=n.y,E=n.z;return s[0]=(1-(_+p))*L,s[1]=(f+S)*L,s[2]=(g-x)*L,s[3]=0,s[4]=(f-S)*T,s[5]=(1-(d+p))*T,s[6]=(m+y)*T,s[7]=0,s[8]=(g+x)*E,s[9]=(m-y)*E,s[10]=(1-(d+_))*E,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,n){const s=this.elements;let r=Hs.set(s[0],s[1],s[2]).length();const a=Hs.set(s[4],s[5],s[6]).length(),o=Hs.set(s[8],s[9],s[10]).length();this.determinant()<0&&(r=-r),t.x=s[12],t.y=s[13],t.z=s[14],Gn.copy(this);const c=1/r,h=1/a,u=1/o;return Gn.elements[0]*=c,Gn.elements[1]*=c,Gn.elements[2]*=c,Gn.elements[4]*=h,Gn.elements[5]*=h,Gn.elements[6]*=h,Gn.elements[8]*=u,Gn.elements[9]*=u,Gn.elements[10]*=u,e.setFromRotationMatrix(Gn),n.x=r,n.y=a,n.z=o,this}makePerspective(t,e,n,s,r,a,o=Ri){const l=this.elements,c=2*r/(e-t),h=2*r/(n-s),u=(e+t)/(e-t),d=(n+s)/(n-s);let f,g;if(o===Ri)f=-(a+r)/(a-r),g=-2*a*r/(a-r);else if(o===So)f=-a/(a-r),g=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=h,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(t,e,n,s,r,a,o=Ri){const l=this.elements,c=1/(e-t),h=1/(n-s),u=1/(a-r),d=(e+t)*c,f=(n+s)*h;let g,_;if(o===Ri)g=(a+r)*u,_=-2*u;else if(o===So)g=r*u,_=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*h,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(t){const e=this.elements,n=t.elements;for(let s=0;s<16;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const Hs=new R,Gn=new fe,w0=new R(0,0,0),E0=new R(1,1,1),$i=new R,ya=new R,wn=new R,Mu=new fe,bu=new ls;class mi{constructor(t=0,e=0,n=0,s=mi.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,s=this._order){return this._x=t,this._y=e,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const s=t.elements,r=s[0],a=s[4],o=s[8],l=s[1],c=s[5],h=s[9],u=s[2],d=s[6],f=s[10];switch(e){case"XYZ":this._y=Math.asin(ze(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-ze(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(ze(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-ze(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(ze(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-ze(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Mu.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Mu,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return bu.setFromEuler(this),this.setFromQuaternion(bu,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}mi.DEFAULT_ORDER="XYZ";class bh{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let T0=0;const Su=new R,Vs=new ls,Mi=new fe,Ma=new R,Dr=new R,A0=new R,C0=new ls,wu=new R(1,0,0),Eu=new R(0,1,0),Tu=new R(0,0,1),Au={type:"added"},R0={type:"removed"},Gs={type:"childadded",child:null},ul={type:"childremoved",child:null};class Qe extends Ps{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:T0++}),this.uuid=Tr(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Qe.DEFAULT_UP.clone();const t=new R,e=new mi,n=new ls,s=new R(1,1,1);function r(){n.setFromEuler(e,!1)}function a(){e.setFromQuaternion(n,void 0,!1)}e._onChange(r),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new fe},normalMatrix:{value:new Xt}}),this.matrix=new fe,this.matrixWorld=new fe,this.matrixAutoUpdate=Qe.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Qe.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new bh,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Vs.setFromAxisAngle(t,e),this.quaternion.multiply(Vs),this}rotateOnWorldAxis(t,e){return Vs.setFromAxisAngle(t,e),this.quaternion.premultiply(Vs),this}rotateX(t){return this.rotateOnAxis(wu,t)}rotateY(t){return this.rotateOnAxis(Eu,t)}rotateZ(t){return this.rotateOnAxis(Tu,t)}translateOnAxis(t,e){return Su.copy(t).applyQuaternion(this.quaternion),this.position.add(Su.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(wu,t)}translateY(t){return this.translateOnAxis(Eu,t)}translateZ(t){return this.translateOnAxis(Tu,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Mi.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?Ma.copy(t):Ma.set(t,e,n);const s=this.parent;this.updateWorldMatrix(!0,!1),Dr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Mi.lookAt(Dr,Ma,this.up):Mi.lookAt(Ma,Dr,this.up),this.quaternion.setFromRotationMatrix(Mi),s&&(Mi.extractRotation(s.matrixWorld),Vs.setFromRotationMatrix(Mi),this.quaternion.premultiply(Vs.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Au),Gs.child=t,this.dispatchEvent(Gs),Gs.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(R0),ul.child=t,this.dispatchEvent(ul),ul.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),Mi.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),Mi.multiply(t.parent.matrixWorld)),t.applyMatrix4(Mi),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Au),Gs.child=t,this.dispatchEvent(Gs),Gs.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,s=this.children.length;n<s;n++){const a=this.children[n].getObjectByProperty(t,e);if(a!==void 0)return a}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Dr,t,A0),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Dr,C0,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e){const n=this.parent;if(t===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){const s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.visibility=this._visibility,s.active=this._active,s.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.geometryCount=this._geometryCount,s.matricesTexture=this._matricesTexture.toJSON(t),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(s.boundingSphere={center:s.boundingSphere.center.toArray(),radius:s.boundingSphere.radius}),this.boundingBox!==null&&(s.boundingBox={min:s.boundingBox.min.toArray(),max:s.boundingBox.max.toArray()}));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(t.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const u=l[c];r(t.shapes,u)}else r(t.shapes,l)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(t.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(r(t.materials,this.material[l]));s.material=o}else s.material=r(t.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];s.animations.push(r(t.animations,l))}}if(e){const o=a(t.geometries),l=a(t.materials),c=a(t.textures),h=a(t.images),u=a(t.shapes),d=a(t.skeletons),f=a(t.animations),g=a(t.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),g.length>0&&(n.nodes=g)}return n.object=s,n;function a(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){const s=t.children[n];this.add(s.clone())}return this}}Qe.DEFAULT_UP=new R(0,1,0);Qe.DEFAULT_MATRIX_AUTO_UPDATE=!0;Qe.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const $n=new R,bi=new R,dl=new R,Si=new R,$s=new R,Ws=new R,Cu=new R,fl=new R,pl=new R,ml=new R,gl=new me,vl=new me,_l=new me;class Yn{constructor(t=new R,e=new R,n=new R){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,s){s.subVectors(n,e),$n.subVectors(t,e),s.cross($n);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(t,e,n,s,r){$n.subVectors(s,e),bi.subVectors(n,e),dl.subVectors(t,e);const a=$n.dot($n),o=$n.dot(bi),l=$n.dot(dl),c=bi.dot(bi),h=bi.dot(dl),u=a*c-o*o;if(u===0)return r.set(0,0,0),null;const d=1/u,f=(c*l-o*h)*d,g=(a*h-o*l)*d;return r.set(1-f-g,g,f)}static containsPoint(t,e,n,s){return this.getBarycoord(t,e,n,s,Si)===null?!1:Si.x>=0&&Si.y>=0&&Si.x+Si.y<=1}static getInterpolation(t,e,n,s,r,a,o,l){return this.getBarycoord(t,e,n,s,Si)===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,Si.x),l.addScaledVector(a,Si.y),l.addScaledVector(o,Si.z),l)}static getInterpolatedAttribute(t,e,n,s,r,a){return gl.setScalar(0),vl.setScalar(0),_l.setScalar(0),gl.fromBufferAttribute(t,e),vl.fromBufferAttribute(t,n),_l.fromBufferAttribute(t,s),a.setScalar(0),a.addScaledVector(gl,r.x),a.addScaledVector(vl,r.y),a.addScaledVector(_l,r.z),a}static isFrontFacing(t,e,n,s){return $n.subVectors(n,e),bi.subVectors(t,e),$n.cross(bi).dot(s)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,s){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,e,n,s){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,s),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return $n.subVectors(this.c,this.b),bi.subVectors(this.a,this.b),$n.cross(bi).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Yn.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Yn.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,s,r){return Yn.getInterpolation(t,this.a,this.b,this.c,e,n,s,r)}containsPoint(t){return Yn.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Yn.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,s=this.b,r=this.c;let a,o;$s.subVectors(s,n),Ws.subVectors(r,n),fl.subVectors(t,n);const l=$s.dot(fl),c=Ws.dot(fl);if(l<=0&&c<=0)return e.copy(n);pl.subVectors(t,s);const h=$s.dot(pl),u=Ws.dot(pl);if(h>=0&&u<=h)return e.copy(s);const d=l*u-h*c;if(d<=0&&l>=0&&h<=0)return a=l/(l-h),e.copy(n).addScaledVector($s,a);ml.subVectors(t,r);const f=$s.dot(ml),g=Ws.dot(ml);if(g>=0&&f<=g)return e.copy(r);const _=f*c-l*g;if(_<=0&&c>=0&&g<=0)return o=c/(c-g),e.copy(n).addScaledVector(Ws,o);const m=h*g-f*u;if(m<=0&&u-h>=0&&f-g>=0)return Cu.subVectors(r,s),o=(u-h)/(u-h+(f-g)),e.copy(s).addScaledVector(Cu,o);const p=1/(m+_+d);return a=_*p,o=d*p,e.copy(n).addScaledVector($s,a).addScaledVector(Ws,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Of={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Wi={h:0,s:0,l:0},ba={h:0,s:0,l:0};function xl(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+(t-i)*6*e:e<1/2?t:e<2/3?i+(t-i)*6*(2/3-e):i}class Zt{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){const s=t;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Ke){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,oe.toWorkingColorSpace(this,e),this}setRGB(t,e,n,s=oe.workingColorSpace){return this.r=t,this.g=e,this.b=n,oe.toWorkingColorSpace(this,s),this}setHSL(t,e,n,s=oe.workingColorSpace){if(t=xh(t,1),e=ze(e,0,1),n=ze(n,0,1),e===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+e):n+e-n*e,a=2*n-r;this.r=xl(a,r,t+1/3),this.g=xl(a,r,t),this.b=xl(a,r,t-1/3)}return oe.toWorkingColorSpace(this,s),this}setStyle(t,e=Ke){function n(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))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,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))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,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){const r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(r,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Ke){const n=Of[t.toLowerCase()];return n!==void 0?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=gr(t.r),this.g=gr(t.g),this.b=gr(t.b),this}copyLinearToSRGB(t){return this.r=il(t.r),this.g=il(t.g),this.b=il(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Ke){return oe.fromWorkingColorSpace(en.copy(this),t),Math.round(ze(en.r*255,0,255))*65536+Math.round(ze(en.g*255,0,255))*256+Math.round(ze(en.b*255,0,255))}getHexString(t=Ke){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=oe.workingColorSpace){oe.fromWorkingColorSpace(en.copy(this),e);const n=en.r,s=en.g,r=en.b,a=Math.max(n,s,r),o=Math.min(n,s,r);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const u=a-o;switch(c=h<=.5?u/(a+o):u/(2-a-o),a){case n:l=(s-r)/u+(s<r?6:0);break;case s:l=(r-n)/u+2;break;case r:l=(n-s)/u+4;break}l/=6}return t.h=l,t.s=c,t.l=h,t}getRGB(t,e=oe.workingColorSpace){return oe.fromWorkingColorSpace(en.copy(this),e),t.r=en.r,t.g=en.g,t.b=en.b,t}getStyle(t=Ke){oe.fromWorkingColorSpace(en.copy(this),t);const e=en.r,n=en.g,s=en.b;return t!==Ke?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(t,e,n){return this.getHSL(Wi),this.setHSL(Wi.h+t,Wi.s+e,Wi.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(Wi),t.getHSL(ba);const n=Yr(Wi.h,ba.h,e),s=Yr(Wi.s,ba.s,e),r=Yr(Wi.l,ba.l,e);return this.setHSL(n,s,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,s=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*s,this.g=r[1]*e+r[4]*n+r[7]*s,this.b=r[2]*e+r[5]*n+r[8]*s,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const en=new Zt;Zt.NAMES=Of;let P0=0;class Fi extends Ps{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:P0++}),this.uuid=Tr(),this.name="",this.type="Material",this.blending=pr,this.side=os,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=oc,this.blendDst=lc,this.blendEquation=jn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Zt(0,0,0),this.blendAlpha=0,this.depthFunc=xr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=fu,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Us,this.stencilZFail=Us,this.stencilZPass=Us,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const n=t[e];if(n===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const s=this[e];if(s===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={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(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).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(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).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(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).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(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).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!==pr&&(n.blending=this.blending),this.side!==os&&(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!==oc&&(n.blendSrc=this.blendSrc),this.blendDst!==lc&&(n.blendDst=this.blendDst),this.blendEquation!==jn&&(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!==xr&&(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!==fu&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Us&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Us&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Us&&(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 s(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(e){const r=s(t.textures),a=s(t.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(e!==null){const s=e.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class dn extends Fi{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Zt(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 mi,this.combine=gf,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const Ne=new R,Sa=new rt;class ui{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=pu,this.updateRanges=[],this.gpuType=Ci,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let s=0,r=this.itemSize;s<r;s++)this.array[t+s]=e.array[n+s];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)Sa.fromBufferAttribute(this,e),Sa.applyMatrix3(t),this.setXY(e,Sa.x,Sa.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)Ne.fromBufferAttribute(this,e),Ne.applyMatrix3(t),this.setXYZ(e,Ne.x,Ne.y,Ne.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)Ne.fromBufferAttribute(this,e),Ne.applyMatrix4(t),this.setXYZ(e,Ne.x,Ne.y,Ne.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Ne.fromBufferAttribute(this,e),Ne.applyNormalMatrix(t),this.setXYZ(e,Ne.x,Ne.y,Ne.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Ne.fromBufferAttribute(this,e),Ne.transformDirection(t),this.setXYZ(e,Ne.x,Ne.y,Ne.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=ir(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=on(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=ir(e,this.array)),e}setX(t,e){return this.normalized&&(e=on(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=ir(e,this.array)),e}setY(t,e){return this.normalized&&(e=on(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=ir(e,this.array)),e}setZ(t,e){return this.normalized&&(e=on(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=ir(e,this.array)),e}setW(t,e){return this.normalized&&(e=on(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=on(e,this.array),n=on(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,s){return t*=this.itemSize,this.normalized&&(e=on(e,this.array),n=on(n,this.array),s=on(s,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=s,this}setXYZW(t,e,n,s,r){return t*=this.itemSize,this.normalized&&(e=on(e,this.array),n=on(n,this.array),s=on(s,this.array),r=on(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=s,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==pu&&(t.usage=this.usage),t}}class Ff extends ui{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class zf extends ui{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class he extends ui{constructor(t,e,n){super(new Float32Array(t),e,n)}}let L0=0;const Ln=new fe,yl=new Qe,Xs=new R,En=new la,Ir=new la,Ge=new R;class fn extends Ps{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:L0++}),this.uuid=Tr(),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(t){return Array.isArray(t)?this.index=new(kf(t)?zf:Ff)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new Xt().getNormalMatrix(t);n.applyNormalMatrix(r),n.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(t),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return Ln.makeRotationFromQuaternion(t),this.applyMatrix4(Ln),this}rotateX(t){return Ln.makeRotationX(t),this.applyMatrix4(Ln),this}rotateY(t){return Ln.makeRotationY(t),this.applyMatrix4(Ln),this}rotateZ(t){return Ln.makeRotationZ(t),this.applyMatrix4(Ln),this}translate(t,e,n){return Ln.makeTranslation(t,e,n),this.applyMatrix4(Ln),this}scale(t,e,n){return Ln.makeScale(t,e,n),this.applyMatrix4(Ln),this}lookAt(t){return yl.lookAt(t),yl.updateMatrix(),this.applyMatrix4(yl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Xs).negate(),this.translate(Xs.x,Xs.y,Xs.z),this}setFromPoints(t){const e=[];for(let n=0,s=t.length;n<s;n++){const r=t[n];e.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new he(e,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new la);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new R(-1/0,-1/0,-1/0),new R(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,s=e.length;n<s;n++){const r=e[n];En.setFromBufferAttribute(r),this.morphTargetsRelative?(Ge.addVectors(this.boundingBox.min,En.min),this.boundingBox.expandByPoint(Ge),Ge.addVectors(this.boundingBox.max,En.max),this.boundingBox.expandByPoint(Ge)):(this.boundingBox.expandByPoint(En.min),this.boundingBox.expandByPoint(En.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 yh);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new R,1/0);return}if(t){const n=this.boundingSphere.center;if(En.setFromBufferAttribute(t),e)for(let r=0,a=e.length;r<a;r++){const o=e[r];Ir.setFromBufferAttribute(o),this.morphTargetsRelative?(Ge.addVectors(En.min,Ir.min),En.expandByPoint(Ge),Ge.addVectors(En.max,Ir.max),En.expandByPoint(Ge)):(En.expandByPoint(Ir.min),En.expandByPoint(Ir.max))}En.getCenter(n);let s=0;for(let r=0,a=t.count;r<a;r++)Ge.fromBufferAttribute(t,r),s=Math.max(s,n.distanceToSquared(Ge));if(e)for(let r=0,a=e.length;r<a;r++){const o=e[r],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)Ge.fromBufferAttribute(o,c),l&&(Xs.fromBufferAttribute(t,c),Ge.add(Xs)),s=Math.max(s,n.distanceToSquared(Ge))}this.boundingSphere.radius=Math.sqrt(s),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 t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.position,s=e.normal,r=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new ui(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let P=0;P<n.count;P++)o[P]=new R,l[P]=new R;const c=new R,h=new R,u=new R,d=new rt,f=new rt,g=new rt,_=new R,m=new R;function p(P,U,v){c.fromBufferAttribute(n,P),h.fromBufferAttribute(n,U),u.fromBufferAttribute(n,v),d.fromBufferAttribute(r,P),f.fromBufferAttribute(r,U),g.fromBufferAttribute(r,v),h.sub(c),u.sub(c),f.sub(d),g.sub(d);const b=1/(f.x*g.y-g.x*f.y);isFinite(b)&&(_.copy(h).multiplyScalar(g.y).addScaledVector(u,-f.y).multiplyScalar(b),m.copy(u).multiplyScalar(f.x).addScaledVector(h,-g.x).multiplyScalar(b),o[P].add(_),o[U].add(_),o[v].add(_),l[P].add(m),l[U].add(m),l[v].add(m))}let y=this.groups;y.length===0&&(y=[{start:0,count:t.count}]);for(let P=0,U=y.length;P<U;++P){const v=y[P],b=v.start,I=v.count;for(let O=b,$=b+I;O<$;O+=3)p(t.getX(O+0),t.getX(O+1),t.getX(O+2))}const x=new R,S=new R,L=new R,T=new R;function E(P){L.fromBufferAttribute(s,P),T.copy(L);const U=o[P];x.copy(U),x.sub(L.multiplyScalar(L.dot(U))).normalize(),S.crossVectors(T,U);const b=S.dot(l[P])<0?-1:1;a.setXYZW(P,x.x,x.y,x.z,b)}for(let P=0,U=y.length;P<U;++P){const v=y[P],b=v.start,I=v.count;for(let O=b,$=b+I;O<$;O+=3)E(t.getX(O+0)),E(t.getX(O+1)),E(t.getX(O+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new ui(new Float32Array(e.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 s=new R,r=new R,a=new R,o=new R,l=new R,c=new R,h=new R,u=new R;if(t)for(let d=0,f=t.count;d<f;d+=3){const g=t.getX(d+0),_=t.getX(d+1),m=t.getX(d+2);s.fromBufferAttribute(e,g),r.fromBufferAttribute(e,_),a.fromBufferAttribute(e,m),h.subVectors(a,r),u.subVectors(s,r),h.cross(u),o.fromBufferAttribute(n,g),l.fromBufferAttribute(n,_),c.fromBufferAttribute(n,m),o.add(h),l.add(h),c.add(h),n.setXYZ(g,o.x,o.y,o.z),n.setXYZ(_,l.x,l.y,l.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let d=0,f=e.count;d<f;d+=3)s.fromBufferAttribute(e,d+0),r.fromBufferAttribute(e,d+1),a.fromBufferAttribute(e,d+2),h.subVectors(a,r),u.subVectors(s,r),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)Ge.fromBufferAttribute(t,e),Ge.normalize(),t.setXYZ(e,Ge.x,Ge.y,Ge.z)}toNonIndexed(){function t(o,l){const c=o.array,h=o.itemSize,u=o.normalized,d=new c.constructor(l.length*h);let f=0,g=0;for(let _=0,m=l.length;_<m;_++){o.isInterleavedBufferAttribute?f=l[_]*o.data.stride+o.offset:f=l[_]*h;for(let p=0;p<h;p++)d[g++]=c[f++]}return new ui(d,h,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new fn,n=this.index.array,s=this.attributes;for(const o in s){const l=s[o],c=t(l,n);e.setAttribute(o,c)}const r=this.morphAttributes;for(const o in r){const l=[],c=r[o];for(let h=0,u=c.length;h<u;h++){const d=c[h],f=t(d,n);l.push(f)}e.morphAttributes[o]=l}e.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];e.addGroup(c.start,c.count,c.materialIndex)}return e}toJSON(){const t={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(t[c]=l[c]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const l in n){const c=n[l];t.data.attributes[l]=c.toJSON(t.data)}const s={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let u=0,d=c.length;u<d;u++){const f=c[u];h.push(f.toJSON(t.data))}h.length>0&&(s[l]=h,r=!0)}r&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(t.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;n!==null&&this.setIndex(n.clone(e));const s=t.attributes;for(const c in s){const h=s[c];this.setAttribute(c,h.clone(e))}const r=t.morphAttributes;for(const c in r){const h=[],u=r[c];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(e));this.morphAttributes[c]=h}this.morphTargetsRelative=t.morphTargetsRelative;const a=t.groups;for(let c=0,h=a.length;c<h;c++){const u=a[c];this.addGroup(u.start,u.count,u.materialIndex)}const o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=t.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Ru=new fe,fs=new Mh,wa=new yh,Pu=new R,Ea=new R,Ta=new R,Aa=new R,Ml=new R,Ca=new R,Lu=new R,Ra=new R;class yt extends Qe{constructor(t=new fn,e=new dn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){const o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(t,e){const n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;e.fromBufferAttribute(s,t);const o=this.morphTargetInfluences;if(r&&o){Ca.set(0,0,0);for(let l=0,c=r.length;l<c;l++){const h=o[l],u=r[l];h!==0&&(Ml.fromBufferAttribute(u,t),a?Ca.addScaledVector(Ml,h):Ca.addScaledVector(Ml.sub(e),h))}e.add(Ca)}return e}raycast(t,e){const n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),wa.copy(n.boundingSphere),wa.applyMatrix4(r),fs.copy(t.ray).recast(t.near),!(wa.containsPoint(fs.origin)===!1&&(fs.intersectSphere(wa,Pu)===null||fs.origin.distanceToSquared(Pu)>(t.far-t.near)**2))&&(Ru.copy(r).invert(),fs.copy(t.ray).applyMatrix4(Ru),!(n.boundingBox!==null&&fs.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,fs)))}_computeIntersections(t,e,n){let s;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,u=r.attributes.normal,d=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,_=d.length;g<_;g++){const m=d[g],p=a[m.materialIndex],y=Math.max(m.start,f.start),x=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let S=y,L=x;S<L;S+=3){const T=o.getX(S),E=o.getX(S+1),P=o.getX(S+2);s=Pa(this,p,t,n,c,h,u,T,E,P),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=m.materialIndex,e.push(s))}}else{const g=Math.max(0,f.start),_=Math.min(o.count,f.start+f.count);for(let m=g,p=_;m<p;m+=3){const y=o.getX(m),x=o.getX(m+1),S=o.getX(m+2);s=Pa(this,a,t,n,c,h,u,y,x,S),s&&(s.faceIndex=Math.floor(m/3),e.push(s))}}else if(l!==void 0)if(Array.isArray(a))for(let g=0,_=d.length;g<_;g++){const m=d[g],p=a[m.materialIndex],y=Math.max(m.start,f.start),x=Math.min(l.count,Math.min(m.start+m.count,f.start+f.count));for(let S=y,L=x;S<L;S+=3){const T=S,E=S+1,P=S+2;s=Pa(this,p,t,n,c,h,u,T,E,P),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=m.materialIndex,e.push(s))}}else{const g=Math.max(0,f.start),_=Math.min(l.count,f.start+f.count);for(let m=g,p=_;m<p;m+=3){const y=m,x=m+1,S=m+2;s=Pa(this,a,t,n,c,h,u,y,x,S),s&&(s.faceIndex=Math.floor(m/3),e.push(s))}}}}function D0(i,t,e,n,s,r,a,o){let l;if(t.side===un?l=n.intersectTriangle(a,r,s,!0,o):l=n.intersectTriangle(s,r,a,t.side===os,o),l===null)return null;Ra.copy(o),Ra.applyMatrix4(i.matrixWorld);const c=e.ray.origin.distanceTo(Ra);return c<e.near||c>e.far?null:{distance:c,point:Ra.clone(),object:i}}function Pa(i,t,e,n,s,r,a,o,l,c){i.getVertexPosition(o,Ea),i.getVertexPosition(l,Ta),i.getVertexPosition(c,Aa);const h=D0(i,t,e,n,Ea,Ta,Aa,Lu);if(h){const u=new R;Yn.getBarycoord(Lu,Ea,Ta,Aa,u),s&&(h.uv=Yn.getInterpolatedAttribute(s,o,l,c,u,new rt)),r&&(h.uv1=Yn.getInterpolatedAttribute(r,o,l,c,u,new rt)),a&&(h.normal=Yn.getInterpolatedAttribute(a,o,l,c,u,new R),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:l,c,normal:new R,materialIndex:0};Yn.getNormal(Ea,Ta,Aa,d.normal),h.face=d,h.barycoord=u}return h}class Ze extends fn{constructor(t=1,e=1,n=1,s=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:s,heightSegments:r,depthSegments:a};const o=this;s=Math.floor(s),r=Math.floor(r),a=Math.floor(a);const l=[],c=[],h=[],u=[];let d=0,f=0;g("z","y","x",-1,-1,n,e,t,a,r,0),g("z","y","x",1,-1,n,e,-t,a,r,1),g("x","z","y",1,1,t,n,e,s,a,2),g("x","z","y",1,-1,t,n,-e,s,a,3),g("x","y","z",1,-1,t,e,n,s,r,4),g("x","y","z",-1,-1,t,e,-n,s,r,5),this.setIndex(l),this.setAttribute("position",new he(c,3)),this.setAttribute("normal",new he(h,3)),this.setAttribute("uv",new he(u,2));function g(_,m,p,y,x,S,L,T,E,P,U){const v=S/E,b=L/P,I=S/2,O=L/2,$=T/2,K=E+1,z=P+1;let Z=0,V=0;const at=new R;for(let ct=0;ct<z;ct++){const _t=ct*b-O;for(let $t=0;$t<K;$t++){const Jt=$t*v-I;at[_]=Jt*y,at[m]=_t*x,at[p]=$,c.push(at.x,at.y,at.z),at[_]=0,at[m]=0,at[p]=T>0?1:-1,h.push(at.x,at.y,at.z),u.push($t/E),u.push(1-ct/P),Z+=1}}for(let ct=0;ct<P;ct++)for(let _t=0;_t<E;_t++){const $t=d+_t+K*ct,Jt=d+_t+K*(ct+1),X=d+(_t+1)+K*(ct+1),et=d+(_t+1)+K*ct;l.push($t,Jt,et),l.push(Jt,X,et),V+=6}o.addGroup(f,V,U),f+=V,d+=Z}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ze(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function br(i){const t={};for(const e in i){t[e]={};for(const n in i[e]){const s=i[e][n];s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)?s.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=s.clone():Array.isArray(s)?t[e][n]=s.slice():t[e][n]=s}}return t}function ln(i){const t={};for(let e=0;e<i.length;e++){const n=br(i[e]);for(const s in n)t[s]=n[s]}return t}function I0(i){const t=[];for(let e=0;e<i.length;e++)t.push(i[e].clone());return t}function Bf(i){const t=i.getRenderTarget();return t===null?i.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:oe.workingColorSpace}const Qi={clone:br,merge:ln};var k0=`void main() {
|
|
5
|
+
*/const lh="169",Li={ROTATE:0,DOLLY:1,PAN:2},es={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},_m=0,uu=1,xm=2,uf=1,df=2,Si=3,rs=0,hn=1,ai=2,qe=0,fr=1,sc=2,du=3,fu=4,ff=5,Xn=100,ym=101,Mm=102,bm=103,Sm=104,$r=200,wm=201,Em=202,Tm=203,rc=204,ac=205,oc=206,Am=207,lc=208,Cm=209,Rm=210,Pm=211,Lm=212,Dm=213,Im=214,cc=0,hc=1,uc=2,xr=3,dc=4,fc=5,pc=6,mc=7,pf=0,km=1,Nm=2,ns=0,mf=1,gf=2,vf=3,_f=4,Um=5,xf=6,ch=7,yf=300,yr=301,Mr=302,gc=303,vc=304,ko=306,ki=1e3,vs=1001,_c=1002,sn=1003,Om=1004,fa=1005,jn=1006,Qo=1007,_s=1008,di=1009,Mf=1010,bf=1011,sa=1012,hh=1013,bs=1014,Ai=1015,Ni=1016,uh=1017,dh=1018,Ss=1020,Sf=35902,wf=1021,Ef=1022,kn=1023,Tf=1024,Af=1025,pr=1026,ws=1027,Cf=1028,fh=1029,Rf=1030,ph=1031,mh=1033,to=33776,eo=33777,no=33778,io=33779,xc=35840,yc=35841,Mc=35842,bc=35843,Sc=36196,wc=37492,Ec=37496,Tc=37808,Ac=37809,Cc=37810,Rc=37811,Pc=37812,Lc=37813,Dc=37814,Ic=37815,kc=37816,Nc=37817,Uc=37818,Oc=37819,Fc=37820,zc=37821,so=36492,Bc=36494,Hc=36495,Pf=36283,Vc=36284,Gc=36285,$c=36286,Fm=3200,zm=3201,gh=0,Bm=1,Ki="",Ye="srgb",os="srgb-linear",vh="display-p3",No="display-p3-linear",_o="linear",ye="srgb",xo="rec709",yo="p3",Ds=7680,pu=519,Hm=512,Vm=513,Gm=514,Lf=515,$m=516,Wm=517,Xm=518,jm=519,mu=35044,gu="300 es",Ci=2e3,Mo=2001;class Ts{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const n=this._listeners;return n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const s=this._listeners[t];if(s!==void 0){const r=s.indexOf(e);r!==-1&&s.splice(r,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const n=this._listeners[t.type];if(n!==void 0){t.target=this;const s=n.slice(0);for(let r=0,a=s.length;r<a;r++)s[r].call(this,t);t.target=null}}}const Qe=["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 vu=1234567;const qr=Math.PI/180,ra=180/Math.PI;function Tr(){const i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Qe[i&255]+Qe[i>>8&255]+Qe[i>>16&255]+Qe[i>>24&255]+"-"+Qe[t&255]+Qe[t>>8&255]+"-"+Qe[t>>16&15|64]+Qe[t>>24&255]+"-"+Qe[e&63|128]+Qe[e>>8&255]+"-"+Qe[e>>16&255]+Qe[e>>24&255]+Qe[n&255]+Qe[n>>8&255]+Qe[n>>16&255]+Qe[n>>24&255]).toLowerCase()}function Fe(i,t,e){return Math.max(t,Math.min(e,i))}function _h(i,t){return(i%t+t)%t}function qm(i,t,e,n,s){return n+(i-t)*(s-n)/(e-t)}function Ym(i,t,e){return i!==t?(e-i)/(t-i):0}function Yr(i,t,e){return(1-e)*i+e*t}function Km(i,t,e,n){return Yr(i,t,1-Math.exp(-e*n))}function Zm(i,t=1){return t-Math.abs(_h(i,t*2)-t)}function Jm(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function Qm(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function t0(i,t){return i+Math.floor(Math.random()*(t-i+1))}function e0(i,t){return i+Math.random()*(t-i)}function n0(i){return i*(.5-Math.random())}function i0(i){i!==void 0&&(vu=i);let t=vu+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function s0(i){return i*qr}function r0(i){return i*ra}function a0(i){return(i&i-1)===0&&i!==0}function o0(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function l0(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function c0(i,t,e,n,s){const r=Math.cos,a=Math.sin,o=r(e/2),l=a(e/2),c=r((t+n)/2),h=a((t+n)/2),u=r((t-n)/2),d=a((t-n)/2),f=r((n-t)/2),g=a((n-t)/2);switch(s){case"XYX":i.set(o*h,l*u,l*d,o*c);break;case"YZY":i.set(l*d,o*h,l*u,o*c);break;case"ZXZ":i.set(l*u,l*d,o*h,o*c);break;case"XZX":i.set(o*h,l*g,l*f,o*c);break;case"YXY":i.set(l*f,o*h,l*g,o*c);break;case"ZYZ":i.set(l*g,l*f,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function Qs(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function an(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const tr={DEG2RAD:qr,RAD2DEG:ra,generateUUID:Tr,clamp:Fe,euclideanModulo:_h,mapLinear:qm,inverseLerp:Ym,lerp:Yr,damp:Km,pingpong:Zm,smoothstep:Jm,smootherstep:Qm,randInt:t0,randFloat:e0,randFloatSpread:n0,seededRandom:i0,degToRad:s0,radToDeg:r0,isPowerOfTwo:a0,ceilPowerOfTwo:o0,floorPowerOfTwo:l0,setQuaternionFromProperEuler:c0,normalize:an,denormalize:Qs};class at{constructor(t=0,e=0){at.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6],this.y=s[1]*e+s[4]*n+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,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(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Fe(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),s=Math.sin(e),r=this.x-t.x,a=this.y-t.y;return this.x=r*n-a*s+t.x,this.y=r*s+a*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Xt{constructor(t,e,n,s,r,a,o,l,c){Xt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,a,o,l,c)}set(t,e,n,s,r,a,o,l,c){const h=this.elements;return h[0]=t,h[1]=s,h[2]=o,h[3]=e,h[4]=r,h[5]=l,h[6]=n,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,s=e.elements,r=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],h=n[4],u=n[7],d=n[2],f=n[5],g=n[8],_=s[0],m=s[3],p=s[6],y=s[1],x=s[4],S=s[7],L=s[2],T=s[5],E=s[8];return r[0]=a*_+o*y+l*L,r[3]=a*m+o*x+l*T,r[6]=a*p+o*S+l*E,r[1]=c*_+h*y+u*L,r[4]=c*m+h*x+u*T,r[7]=c*p+h*S+u*E,r[2]=d*_+f*y+g*L,r[5]=d*m+f*x+g*T,r[8]=d*p+f*S+g*E,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8];return e*a*h-e*o*c-n*r*h+n*o*l+s*r*c-s*a*l}invert(){const t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8],u=h*a-o*c,d=o*l-h*r,f=c*r-a*l,g=e*u+n*d+s*f;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/g;return t[0]=u*_,t[1]=(s*c-h*n)*_,t[2]=(o*n-s*a)*_,t[3]=d*_,t[4]=(h*e-s*l)*_,t[5]=(s*r-o*e)*_,t[6]=f*_,t[7]=(n*l-c*e)*_,t[8]=(a*e-n*r)*_,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,s,r,a,o){const l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*a+c*o)+a+t,-s*c,s*l,-s*(-c*a+l*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(tl.makeScale(t,e)),this}rotate(t){return this.premultiply(tl.makeRotation(-t)),this}translate(t,e){return this.premultiply(tl.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let s=0;s<9;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const tl=new Xt;function Df(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function bo(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function h0(){const i=bo("canvas");return i.style.display="block",i}const _u={};function ro(i){i in _u||(_u[i]=!0,console.warn(i))}function u0(i,t,e){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(t,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,e);break;default:n()}}setTimeout(r,e)})}function d0(i){const t=i.elements;t[2]=.5*t[2]+.5*t[3],t[6]=.5*t[6]+.5*t[7],t[10]=.5*t[10]+.5*t[11],t[14]=.5*t[14]+.5*t[15]}function f0(i){const t=i.elements;t[11]===-1?(t[10]=-t[10]-1,t[14]=-t[14]):(t[10]=-t[10],t[14]=-t[14]+1)}const xu=new Xt().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),yu=new Xt().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Rr={[os]:{transfer:_o,primaries:xo,luminanceCoefficients:[.2126,.7152,.0722],toReference:i=>i,fromReference:i=>i},[Ye]:{transfer:ye,primaries:xo,luminanceCoefficients:[.2126,.7152,.0722],toReference:i=>i.convertSRGBToLinear(),fromReference:i=>i.convertLinearToSRGB()},[No]:{transfer:_o,primaries:yo,luminanceCoefficients:[.2289,.6917,.0793],toReference:i=>i.applyMatrix3(yu),fromReference:i=>i.applyMatrix3(xu)},[vh]:{transfer:ye,primaries:yo,luminanceCoefficients:[.2289,.6917,.0793],toReference:i=>i.convertSRGBToLinear().applyMatrix3(yu),fromReference:i=>i.applyMatrix3(xu).convertLinearToSRGB()}},p0=new Set([os,No]),oe={enabled:!0,_workingColorSpace:os,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(i){if(!p0.has(i))throw new Error(`Unsupported working color space, "${i}".`);this._workingColorSpace=i},convert:function(i,t,e){if(this.enabled===!1||t===e||!t||!e)return i;const n=Rr[t].toReference,s=Rr[e].fromReference;return s(n(i))},fromWorkingColorSpace:function(i,t){return this.convert(i,this._workingColorSpace,t)},toWorkingColorSpace:function(i,t){return this.convert(i,t,this._workingColorSpace)},getPrimaries:function(i){return Rr[i].primaries},getTransfer:function(i){return i===Ki?_o:Rr[i].transfer},getLuminanceCoefficients:function(i,t=this._workingColorSpace){return i.fromArray(Rr[t].luminanceCoefficients)}};function mr(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function el(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let Is;class m0{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{Is===void 0&&(Is=bo("canvas")),Is.width=t.width,Is.height=t.height;const n=Is.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=Is}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=bo("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const s=n.getImageData(0,0,t.width,t.height),r=s.data;for(let a=0;a<r.length;a++)r[a]=mr(r[a]/255)*255;return n.putImageData(s,0,0),e}else if(t.data){const e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(mr(e[n]/255)*255):e[n]=mr(e[n]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let g0=0;class If{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:g0++}),this.uuid=Tr(),this.data=t,this.dataReady=!0,this.version=0}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const n={uuid:this.uuid,url:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let a=0,o=s.length;a<o;a++)s[a].isDataTexture?r.push(nl(s[a].image)):r.push(nl(s[a]))}else r=nl(s);n.url=r}return e||(t.images[this.uuid]=n),n}}function nl(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?m0.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let v0=0;class rn extends Ts{constructor(t=rn.DEFAULT_IMAGE,e=rn.DEFAULT_MAPPING,n=vs,s=vs,r=jn,a=_s,o=kn,l=di,c=rn.DEFAULT_ANISOTROPY,h=Ki){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:v0++}),this.uuid=Tr(),this.name="",this.source=new If(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new at(0,0),this.repeat=new at(1,1),this.center=new at(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Xt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(t=null){this.source.data=t}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(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).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),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==yf)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case ki:t.x=t.x-Math.floor(t.x);break;case vs:t.x=t.x<0?0:1;break;case _c:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case ki:t.y=t.y-Math.floor(t.y);break;case vs:t.y=t.y<0?0:1;break;case _c:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}rn.DEFAULT_IMAGE=null;rn.DEFAULT_MAPPING=yf;rn.DEFAULT_ANISOTROPY=1;class me{constructor(t=0,e=0,n=0,s=1){me.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=s}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,s){return this.x=t,this.y=e,this.z=n,this.w=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,s=this.z,r=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*s+a[12]*r,this.y=a[1]*e+a[5]*n+a[9]*s+a[13]*r,this.z=a[2]*e+a[6]*n+a[10]*s+a[14]*r,this.w=a[3]*e+a[7]*n+a[11]*s+a[15]*r,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,s,r;const l=t.elements,c=l[0],h=l[4],u=l[8],d=l[1],f=l[5],g=l[9],_=l[2],m=l[6],p=l[10];if(Math.abs(h-d)<.01&&Math.abs(u-_)<.01&&Math.abs(g-m)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+_)<.1&&Math.abs(g+m)<.1&&Math.abs(c+f+p-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const x=(c+1)/2,S=(f+1)/2,L=(p+1)/2,T=(h+d)/4,E=(u+_)/4,P=(g+m)/4;return x>S&&x>L?x<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(x),s=T/n,r=E/n):S>L?S<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(S),n=T/s,r=P/s):L<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(L),n=E/r,s=P/r),this.set(n,s,r,e),this}let y=Math.sqrt((m-g)*(m-g)+(u-_)*(u-_)+(d-h)*(d-h));return Math.abs(y)<.001&&(y=1),this.x=(m-g)/y,this.y=(u-_)/y,this.z=(d-h)/y,this.w=Math.acos((c+f+p-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,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(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class _0 extends Ts{constructor(t=1,e=1,n={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new me(0,0,t,e),this.scissorTest=!1,this.viewport=new me(0,0,t,e);const s={width:t,height:e,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:jn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const r=new rn(s,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 a=n.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].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(t){this.textures[0]=t}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=t,this.textures[s].image.height=e,this.textures[s].image.depth=n;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let n=0,s=t.textures.length;n<s;n++)this.textures[n]=t.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0;const e=Object.assign({},t.texture.image);return this.texture.source=new If(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Jn extends _0{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class kf extends rn{constructor(t=null,e=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=sn,this.minFilter=sn,this.wrapR=vs,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class x0 extends rn{constructor(t=null,e=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=sn,this.minFilter=sn,this.wrapR=vs,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class as{constructor(t=0,e=0,n=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=s}static slerpFlat(t,e,n,s,r,a,o){let l=n[s+0],c=n[s+1],h=n[s+2],u=n[s+3];const d=r[a+0],f=r[a+1],g=r[a+2],_=r[a+3];if(o===0){t[e+0]=l,t[e+1]=c,t[e+2]=h,t[e+3]=u;return}if(o===1){t[e+0]=d,t[e+1]=f,t[e+2]=g,t[e+3]=_;return}if(u!==_||l!==d||c!==f||h!==g){let m=1-o;const p=l*d+c*f+h*g+u*_,y=p>=0?1:-1,x=1-p*p;if(x>Number.EPSILON){const L=Math.sqrt(x),T=Math.atan2(L,p*y);m=Math.sin(m*T)/L,o=Math.sin(o*T)/L}const S=o*y;if(l=l*m+d*S,c=c*m+f*S,h=h*m+g*S,u=u*m+_*S,m===1-o){const L=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=L,c*=L,h*=L,u*=L}}t[e]=l,t[e+1]=c,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,s,r,a){const o=n[s],l=n[s+1],c=n[s+2],h=n[s+3],u=r[a],d=r[a+1],f=r[a+2],g=r[a+3];return t[e]=o*g+h*u+l*f-c*d,t[e+1]=l*g+h*d+c*u-o*f,t[e+2]=c*g+h*f+o*d-l*u,t[e+3]=h*g-o*u-l*d-c*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,s){return this._x=t,this._y=e,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,s=t._y,r=t._z,a=t._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(s/2),u=o(r/2),d=l(n/2),f=l(s/2),g=l(r/2);switch(a){case"XYZ":this._x=d*h*u+c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u-d*f*g;break;case"YXZ":this._x=d*h*u+c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u+d*f*g;break;case"ZXY":this._x=d*h*u-c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u-d*f*g;break;case"ZYX":this._x=d*h*u-c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u+d*f*g;break;case"YZX":this._x=d*h*u+c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u-d*f*g;break;case"XZY":this._x=d*h*u-c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u+d*f*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,s=Math.sin(n);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],s=e[4],r=e[8],a=e[1],o=e[5],l=e[9],c=e[2],h=e[6],u=e[10],d=n+o+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-l)*f,this._y=(r-c)*f,this._z=(a-s)*f}else if(n>o&&n>u){const f=2*Math.sqrt(1+n-o-u);this._w=(h-l)/f,this._x=.25*f,this._y=(s+a)/f,this._z=(r+c)/f}else if(o>u){const f=2*Math.sqrt(1+o-n-u);this._w=(r-c)/f,this._x=(s+a)/f,this._y=.25*f,this._z=(l+h)/f}else{const f=2*Math.sqrt(1+u-n-o);this._w=(a-s)/f,this._x=(r+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<Number.EPSILON?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Fe(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const s=Math.min(1,e/n);return this.slerp(t,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,s=t._y,r=t._z,a=t._w,o=e._x,l=e._y,c=e._z,h=e._w;return this._x=n*h+a*o+s*c-r*l,this._y=s*h+a*l+r*o-n*c,this._z=r*h+a*c+n*l-s*o,this._w=a*h-n*o-s*l-r*c,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const n=this._x,s=this._y,r=this._z,a=this._w;let o=a*t._w+n*t._x+s*t._y+r*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=n,this._y=s,this._z=r,this;const l=1-o*o;if(l<=Number.EPSILON){const f=1-e;return this._w=f*a+e*this._w,this._x=f*n+e*this._x,this._y=f*s+e*this._y,this._z=f*r+e*this._z,this.normalize(),this}const c=Math.sqrt(l),h=Math.atan2(c,o),u=Math.sin((1-e)*h)/c,d=Math.sin(e*h)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=s*u+this._y*d,this._z=r*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(t),s*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class R{constructor(t=0,e=0,n=0){R.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Mu.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Mu.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*s,this.y=r[1]*e+r[4]*n+r[7]*s,this.z=r[2]*e+r[5]*n+r[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,s=this.z,r=t.elements,a=1/(r[3]*e+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*s+r[12])*a,this.y=(r[1]*e+r[5]*n+r[9]*s+r[13])*a,this.z=(r[2]*e+r[6]*n+r[10]*s+r[14])*a,this}applyQuaternion(t){const e=this.x,n=this.y,s=this.z,r=t.x,a=t.y,o=t.z,l=t.w,c=2*(a*s-o*n),h=2*(o*e-r*s),u=2*(r*n-a*e);return this.x=e+l*c+a*u-o*h,this.y=n+l*h+o*c-r*u,this.z=s+l*u+r*h-a*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*s,this.y=r[1]*e+r[5]*n+r[9]*s,this.z=r[2]*e+r[6]*n+r[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,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(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,s=t.y,r=t.z,a=e.x,o=e.y,l=e.z;return this.x=s*l-r*o,this.y=r*a-n*l,this.z=n*o-s*a,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return il.copy(this).projectOnVector(t),this.sub(il)}reflect(t){return this.sub(il.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Fe(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,s=this.z-t.z;return e*e+n*n+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const s=Math.sin(e)*t;return this.x=s*Math.sin(n),this.y=Math.cos(e)*t,this.z=s*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=s,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const il=new R,Mu=new as;class oa{constructor(t=new R(1/0,1/0,1/0),e=new R(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(Hn.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(Hn.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=Hn.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.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(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(n!==void 0){const r=n.getAttribute("position");if(e===!0&&r!==void 0&&t.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)t.isMesh===!0?t.getVertexPosition(a,Hn):Hn.fromBufferAttribute(r,a),Hn.applyMatrix4(t.matrixWorld),this.expandByPoint(Hn);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),pa.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),pa.copy(n.boundingBox)),pa.applyMatrix4(t.matrixWorld),this.union(pa)}const s=t.children;for(let r=0,a=s.length;r<a;r++)this.expandByObject(s[r],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,Hn),Hn.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Pr),ma.subVectors(this.max,Pr),ks.subVectors(t.a,Pr),Ns.subVectors(t.b,Pr),Us.subVectors(t.c,Pr),Bi.subVectors(Ns,ks),Hi.subVectors(Us,Ns),cs.subVectors(ks,Us);let e=[0,-Bi.z,Bi.y,0,-Hi.z,Hi.y,0,-cs.z,cs.y,Bi.z,0,-Bi.x,Hi.z,0,-Hi.x,cs.z,0,-cs.x,-Bi.y,Bi.x,0,-Hi.y,Hi.x,0,-cs.y,cs.x,0];return!sl(e,ks,Ns,Us,ma)||(e=[1,0,0,0,1,0,0,0,1],!sl(e,ks,Ns,Us,ma))?!1:(ga.crossVectors(Bi,Hi),e=[ga.x,ga.y,ga.z],sl(e,ks,Ns,Us,ma))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Hn).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Hn).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(vi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),vi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),vi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),vi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),vi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),vi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),vi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),vi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(vi),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const vi=[new R,new R,new R,new R,new R,new R,new R,new R],Hn=new R,pa=new oa,ks=new R,Ns=new R,Us=new R,Bi=new R,Hi=new R,cs=new R,Pr=new R,ma=new R,ga=new R,hs=new R;function sl(i,t,e,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){hs.fromArray(i,r);const o=s.x*Math.abs(hs.x)+s.y*Math.abs(hs.y)+s.z*Math.abs(hs.z),l=t.dot(hs),c=e.dot(hs),h=n.dot(hs);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const y0=new oa,Lr=new R,rl=new R;class xh{constructor(t=new R,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;e!==void 0?n.copy(e):y0.setFromPoints(t).getCenter(n);let s=0;for(let r=0,a=t.length;r<a;r++)s=Math.max(s,n.distanceToSquared(t[r]));return this.radius=Math.sqrt(s),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Lr.subVectors(t,this.center);const e=Lr.lengthSq();if(e>this.radius*this.radius){const n=Math.sqrt(e),s=(n-this.radius)*.5;this.center.addScaledVector(Lr,s/n),this.radius+=s}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(rl.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Lr.copy(t.center).add(rl)),this.expandByPoint(Lr.copy(t.center).sub(rl))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}const _i=new R,al=new R,va=new R,Vi=new R,ol=new R,_a=new R,ll=new R;class yh{constructor(t=new R,e=new R(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,_i)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=_i.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(_i.copy(this.origin).addScaledVector(this.direction,e),_i.distanceToSquared(t))}distanceSqToSegment(t,e,n,s){al.copy(t).add(e).multiplyScalar(.5),va.copy(e).sub(t).normalize(),Vi.copy(this.origin).sub(al);const r=t.distanceTo(e)*.5,a=-this.direction.dot(va),o=Vi.dot(this.direction),l=-Vi.dot(va),c=Vi.lengthSq(),h=Math.abs(1-a*a);let u,d,f,g;if(h>0)if(u=a*l-o,d=a*o-l,g=r*h,u>=0)if(d>=-g)if(d<=g){const _=1/h;u*=_,d*=_,f=u*(u+a*d+2*o)+d*(a*u+d+2*l)+c}else d=r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;else d=-r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;else d<=-g?(u=Math.max(0,-(-a*r+o)),d=u>0?-r:Math.min(Math.max(-r,-l),r),f=-u*u+d*(d+2*l)+c):d<=g?(u=0,d=Math.min(Math.max(-r,-l),r),f=d*(d+2*l)+c):(u=Math.max(0,-(a*r+o)),d=u>0?r:Math.min(Math.max(-r,-l),r),f=-u*u+d*(d+2*l)+c);else d=a>0?-r:r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),s&&s.copy(al).addScaledVector(va,d),f}intersectSphere(t,e){_i.subVectors(t.center,this.origin);const n=_i.dot(this.direction),s=_i.dot(_i)-n*n,r=t.radius*t.radius;if(s>r)return null;const a=Math.sqrt(r-s),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,e):this.at(o,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,s,r,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(t.min.x-d.x)*c,s=(t.max.x-d.x)*c):(n=(t.max.x-d.x)*c,s=(t.min.x-d.x)*c),h>=0?(r=(t.min.y-d.y)*h,a=(t.max.y-d.y)*h):(r=(t.max.y-d.y)*h,a=(t.min.y-d.y)*h),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a<s||isNaN(s))&&(s=a),u>=0?(o=(t.min.z-d.z)*u,l=(t.max.z-d.z)*u):(o=(t.max.z-d.z)*u,l=(t.min.z-d.z)*u),n>l||o>s)||((o>n||n!==n)&&(n=o),(l<s||s!==s)&&(s=l),s<0)?null:this.at(n>=0?n:s,e)}intersectsBox(t){return this.intersectBox(t,_i)!==null}intersectTriangle(t,e,n,s,r){ol.subVectors(e,t),_a.subVectors(n,t),ll.crossVectors(ol,_a);let a=this.direction.dot(ll),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Vi.subVectors(this.origin,t);const l=o*this.direction.dot(_a.crossVectors(Vi,_a));if(l<0)return null;const c=o*this.direction.dot(ol.cross(Vi));if(c<0||l+c>a)return null;const h=-o*Vi.dot(ll);return h<0?null:this.at(h/a,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class fe{constructor(t,e,n,s,r,a,o,l,c,h,u,d,f,g,_,m){fe.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,a,o,l,c,h,u,d,f,g,_,m)}set(t,e,n,s,r,a,o,l,c,h,u,d,f,g,_,m){const p=this.elements;return p[0]=t,p[4]=e,p[8]=n,p[12]=s,p[1]=r,p[5]=a,p[9]=o,p[13]=l,p[2]=c,p[6]=h,p[10]=u,p[14]=d,p[3]=f,p[7]=g,p[11]=_,p[15]=m,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 fe().fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,s=1/Os.setFromMatrixColumn(t,0).length(),r=1/Os.setFromMatrixColumn(t,1).length(),a=1/Os.setFromMatrixColumn(t,2).length();return e[0]=n[0]*s,e[1]=n[1]*s,e[2]=n[2]*s,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,s=t.y,r=t.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(s),c=Math.sin(s),h=Math.cos(r),u=Math.sin(r);if(t.order==="XYZ"){const d=a*h,f=a*u,g=o*h,_=o*u;e[0]=l*h,e[4]=-l*u,e[8]=c,e[1]=f+g*c,e[5]=d-_*c,e[9]=-o*l,e[2]=_-d*c,e[6]=g+f*c,e[10]=a*l}else if(t.order==="YXZ"){const d=l*h,f=l*u,g=c*h,_=c*u;e[0]=d+_*o,e[4]=g*o-f,e[8]=a*c,e[1]=a*u,e[5]=a*h,e[9]=-o,e[2]=f*o-g,e[6]=_+d*o,e[10]=a*l}else if(t.order==="ZXY"){const d=l*h,f=l*u,g=c*h,_=c*u;e[0]=d-_*o,e[4]=-a*u,e[8]=g+f*o,e[1]=f+g*o,e[5]=a*h,e[9]=_-d*o,e[2]=-a*c,e[6]=o,e[10]=a*l}else if(t.order==="ZYX"){const d=a*h,f=a*u,g=o*h,_=o*u;e[0]=l*h,e[4]=g*c-f,e[8]=d*c+_,e[1]=l*u,e[5]=_*c+d,e[9]=f*c-g,e[2]=-c,e[6]=o*l,e[10]=a*l}else if(t.order==="YZX"){const d=a*l,f=a*c,g=o*l,_=o*c;e[0]=l*h,e[4]=_-d*u,e[8]=g*u+f,e[1]=u,e[5]=a*h,e[9]=-o*h,e[2]=-c*h,e[6]=f*u+g,e[10]=d-_*u}else if(t.order==="XZY"){const d=a*l,f=a*c,g=o*l,_=o*c;e[0]=l*h,e[4]=-u,e[8]=c*h,e[1]=d*u+_,e[5]=a*h,e[9]=f*u-g,e[2]=g*u-f,e[6]=o*h,e[10]=_*u+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(M0,t,b0)}lookAt(t,e,n){const s=this.elements;return Sn.subVectors(t,e),Sn.lengthSq()===0&&(Sn.z=1),Sn.normalize(),Gi.crossVectors(n,Sn),Gi.lengthSq()===0&&(Math.abs(n.z)===1?Sn.x+=1e-4:Sn.z+=1e-4,Sn.normalize(),Gi.crossVectors(n,Sn)),Gi.normalize(),xa.crossVectors(Sn,Gi),s[0]=Gi.x,s[4]=xa.x,s[8]=Sn.x,s[1]=Gi.y,s[5]=xa.y,s[9]=Sn.y,s[2]=Gi.z,s[6]=xa.z,s[10]=Sn.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,s=e.elements,r=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],h=n[1],u=n[5],d=n[9],f=n[13],g=n[2],_=n[6],m=n[10],p=n[14],y=n[3],x=n[7],S=n[11],L=n[15],T=s[0],E=s[4],P=s[8],U=s[12],v=s[1],b=s[5],I=s[9],O=s[13],$=s[2],K=s[6],z=s[10],Z=s[14],V=s[3],ot=s[7],ct=s[11],_t=s[15];return r[0]=a*T+o*v+l*$+c*V,r[4]=a*E+o*b+l*K+c*ot,r[8]=a*P+o*I+l*z+c*ct,r[12]=a*U+o*O+l*Z+c*_t,r[1]=h*T+u*v+d*$+f*V,r[5]=h*E+u*b+d*K+f*ot,r[9]=h*P+u*I+d*z+f*ct,r[13]=h*U+u*O+d*Z+f*_t,r[2]=g*T+_*v+m*$+p*V,r[6]=g*E+_*b+m*K+p*ot,r[10]=g*P+_*I+m*z+p*ct,r[14]=g*U+_*O+m*Z+p*_t,r[3]=y*T+x*v+S*$+L*V,r[7]=y*E+x*b+S*K+L*ot,r[11]=y*P+x*I+S*z+L*ct,r[15]=y*U+x*O+S*Z+L*_t,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],s=t[8],r=t[12],a=t[1],o=t[5],l=t[9],c=t[13],h=t[2],u=t[6],d=t[10],f=t[14],g=t[3],_=t[7],m=t[11],p=t[15];return g*(+r*l*u-s*c*u-r*o*d+n*c*d+s*o*f-n*l*f)+_*(+e*l*f-e*c*d+r*a*d-s*a*f+s*c*h-r*l*h)+m*(+e*c*u-e*o*f-r*a*u+n*a*f+r*o*h-n*c*h)+p*(-s*o*h-e*l*u+e*o*d+s*a*u-n*a*d+n*l*h)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],f=t[11],g=t[12],_=t[13],m=t[14],p=t[15],y=u*m*c-_*d*c+_*l*f-o*m*f-u*l*p+o*d*p,x=g*d*c-h*m*c-g*l*f+a*m*f+h*l*p-a*d*p,S=h*_*c-g*u*c+g*o*f-a*_*f-h*o*p+a*u*p,L=g*u*l-h*_*l-g*o*d+a*_*d+h*o*m-a*u*m,T=e*y+n*x+s*S+r*L;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const E=1/T;return t[0]=y*E,t[1]=(_*d*r-u*m*r-_*s*f+n*m*f+u*s*p-n*d*p)*E,t[2]=(o*m*r-_*l*r+_*s*c-n*m*c-o*s*p+n*l*p)*E,t[3]=(u*l*r-o*d*r-u*s*c+n*d*c+o*s*f-n*l*f)*E,t[4]=x*E,t[5]=(h*m*r-g*d*r+g*s*f-e*m*f-h*s*p+e*d*p)*E,t[6]=(g*l*r-a*m*r-g*s*c+e*m*c+a*s*p-e*l*p)*E,t[7]=(a*d*r-h*l*r+h*s*c-e*d*c-a*s*f+e*l*f)*E,t[8]=S*E,t[9]=(g*u*r-h*_*r-g*n*f+e*_*f+h*n*p-e*u*p)*E,t[10]=(a*_*r-g*o*r+g*n*c-e*_*c-a*n*p+e*o*p)*E,t[11]=(h*o*r-a*u*r-h*n*c+e*u*c+a*n*f-e*o*f)*E,t[12]=L*E,t[13]=(h*_*s-g*u*s+g*n*d-e*_*d-h*n*m+e*u*m)*E,t[14]=(g*o*s-a*_*s-g*n*l+e*_*l+a*n*m-e*o*m)*E,t[15]=(a*u*s-h*o*s+h*n*l-e*u*l-a*n*d+e*o*d)*E,this}scale(t){const e=this.elements,n=t.x,s=t.y,r=t.z;return e[0]*=n,e[4]*=s,e[8]*=r,e[1]*=n,e[5]*=s,e[9]*=r,e[2]*=n,e[6]*=s,e[10]*=r,e[3]*=n,e[7]*=s,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,s))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),s=Math.sin(e),r=1-n,a=t.x,o=t.y,l=t.z,c=r*a,h=r*o;return this.set(c*a+n,c*o-s*l,c*l+s*o,0,c*o+s*l,h*o+n,h*l-s*a,0,c*l-s*o,h*l+s*a,r*l*l+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,s,r,a){return this.set(1,n,r,0,t,1,a,0,e,s,1,0,0,0,0,1),this}compose(t,e,n){const s=this.elements,r=e._x,a=e._y,o=e._z,l=e._w,c=r+r,h=a+a,u=o+o,d=r*c,f=r*h,g=r*u,_=a*h,m=a*u,p=o*u,y=l*c,x=l*h,S=l*u,L=n.x,T=n.y,E=n.z;return s[0]=(1-(_+p))*L,s[1]=(f+S)*L,s[2]=(g-x)*L,s[3]=0,s[4]=(f-S)*T,s[5]=(1-(d+p))*T,s[6]=(m+y)*T,s[7]=0,s[8]=(g+x)*E,s[9]=(m-y)*E,s[10]=(1-(d+_))*E,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,n){const s=this.elements;let r=Os.set(s[0],s[1],s[2]).length();const a=Os.set(s[4],s[5],s[6]).length(),o=Os.set(s[8],s[9],s[10]).length();this.determinant()<0&&(r=-r),t.x=s[12],t.y=s[13],t.z=s[14],Vn.copy(this);const c=1/r,h=1/a,u=1/o;return Vn.elements[0]*=c,Vn.elements[1]*=c,Vn.elements[2]*=c,Vn.elements[4]*=h,Vn.elements[5]*=h,Vn.elements[6]*=h,Vn.elements[8]*=u,Vn.elements[9]*=u,Vn.elements[10]*=u,e.setFromRotationMatrix(Vn),n.x=r,n.y=a,n.z=o,this}makePerspective(t,e,n,s,r,a,o=Ci){const l=this.elements,c=2*r/(e-t),h=2*r/(n-s),u=(e+t)/(e-t),d=(n+s)/(n-s);let f,g;if(o===Ci)f=-(a+r)/(a-r),g=-2*a*r/(a-r);else if(o===Mo)f=-a/(a-r),g=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=h,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(t,e,n,s,r,a,o=Ci){const l=this.elements,c=1/(e-t),h=1/(n-s),u=1/(a-r),d=(e+t)*c,f=(n+s)*h;let g,_;if(o===Ci)g=(a+r)*u,_=-2*u;else if(o===Mo)g=r*u,_=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*h,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(t){const e=this.elements,n=t.elements;for(let s=0;s<16;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const Os=new R,Vn=new fe,M0=new R(0,0,0),b0=new R(1,1,1),Gi=new R,xa=new R,Sn=new R,bu=new fe,Su=new as;class fi{constructor(t=0,e=0,n=0,s=fi.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,s=this._order){return this._x=t,this._y=e,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const s=t.elements,r=s[0],a=s[4],o=s[8],l=s[1],c=s[5],h=s[9],u=s[2],d=s[6],f=s[10];switch(e){case"XYZ":this._y=Math.asin(Fe(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Fe(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(Fe(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-Fe(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(Fe(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-Fe(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return bu.makeRotationFromQuaternion(t),this.setFromRotationMatrix(bu,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Su.setFromEuler(this),this.setFromQuaternion(Su,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}fi.DEFAULT_ORDER="XYZ";class Mh{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let S0=0;const wu=new R,Fs=new as,xi=new fe,ya=new R,Dr=new R,w0=new R,E0=new as,Eu=new R(1,0,0),Tu=new R(0,1,0),Au=new R(0,0,1),Cu={type:"added"},T0={type:"removed"},zs={type:"childadded",child:null},cl={type:"childremoved",child:null};class Je extends Ts{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:S0++}),this.uuid=Tr(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Je.DEFAULT_UP.clone();const t=new R,e=new fi,n=new as,s=new R(1,1,1);function r(){n.setFromEuler(e,!1)}function a(){e.setFromQuaternion(n,void 0,!1)}e._onChange(r),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new fe},normalMatrix:{value:new Xt}}),this.matrix=new fe,this.matrixWorld=new fe,this.matrixAutoUpdate=Je.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Je.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Mh,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Fs.setFromAxisAngle(t,e),this.quaternion.multiply(Fs),this}rotateOnWorldAxis(t,e){return Fs.setFromAxisAngle(t,e),this.quaternion.premultiply(Fs),this}rotateX(t){return this.rotateOnAxis(Eu,t)}rotateY(t){return this.rotateOnAxis(Tu,t)}rotateZ(t){return this.rotateOnAxis(Au,t)}translateOnAxis(t,e){return wu.copy(t).applyQuaternion(this.quaternion),this.position.add(wu.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Eu,t)}translateY(t){return this.translateOnAxis(Tu,t)}translateZ(t){return this.translateOnAxis(Au,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(xi.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?ya.copy(t):ya.set(t,e,n);const s=this.parent;this.updateWorldMatrix(!0,!1),Dr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?xi.lookAt(Dr,ya,this.up):xi.lookAt(ya,Dr,this.up),this.quaternion.setFromRotationMatrix(xi),s&&(xi.extractRotation(s.matrixWorld),Fs.setFromRotationMatrix(xi),this.quaternion.premultiply(Fs.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Cu),zs.child=t,this.dispatchEvent(zs),zs.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(T0),cl.child=t,this.dispatchEvent(cl),cl.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),xi.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),xi.multiply(t.parent.matrixWorld)),t.applyMatrix4(xi),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Cu),zs.child=t,this.dispatchEvent(zs),zs.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,s=this.children.length;n<s;n++){const a=this.children[n].getObjectByProperty(t,e);if(a!==void 0)return a}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Dr,t,w0),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Dr,E0,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e){const n=this.parent;if(t===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){const s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.visibility=this._visibility,s.active=this._active,s.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.geometryCount=this._geometryCount,s.matricesTexture=this._matricesTexture.toJSON(t),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(s.boundingSphere={center:s.boundingSphere.center.toArray(),radius:s.boundingSphere.radius}),this.boundingBox!==null&&(s.boundingBox={min:s.boundingBox.min.toArray(),max:s.boundingBox.max.toArray()}));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(t.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const u=l[c];r(t.shapes,u)}else r(t.shapes,l)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(t.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(r(t.materials,this.material[l]));s.material=o}else s.material=r(t.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];s.animations.push(r(t.animations,l))}}if(e){const o=a(t.geometries),l=a(t.materials),c=a(t.textures),h=a(t.images),u=a(t.shapes),d=a(t.skeletons),f=a(t.animations),g=a(t.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),g.length>0&&(n.nodes=g)}return n.object=s,n;function a(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){const s=t.children[n];this.add(s.clone())}return this}}Je.DEFAULT_UP=new R(0,1,0);Je.DEFAULT_MATRIX_AUTO_UPDATE=!0;Je.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Gn=new R,yi=new R,hl=new R,Mi=new R,Bs=new R,Hs=new R,Ru=new R,ul=new R,dl=new R,fl=new R,pl=new me,ml=new me,gl=new me;class qn{constructor(t=new R,e=new R,n=new R){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,s){s.subVectors(n,e),Gn.subVectors(t,e),s.cross(Gn);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(t,e,n,s,r){Gn.subVectors(s,e),yi.subVectors(n,e),hl.subVectors(t,e);const a=Gn.dot(Gn),o=Gn.dot(yi),l=Gn.dot(hl),c=yi.dot(yi),h=yi.dot(hl),u=a*c-o*o;if(u===0)return r.set(0,0,0),null;const d=1/u,f=(c*l-o*h)*d,g=(a*h-o*l)*d;return r.set(1-f-g,g,f)}static containsPoint(t,e,n,s){return this.getBarycoord(t,e,n,s,Mi)===null?!1:Mi.x>=0&&Mi.y>=0&&Mi.x+Mi.y<=1}static getInterpolation(t,e,n,s,r,a,o,l){return this.getBarycoord(t,e,n,s,Mi)===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,Mi.x),l.addScaledVector(a,Mi.y),l.addScaledVector(o,Mi.z),l)}static getInterpolatedAttribute(t,e,n,s,r,a){return pl.setScalar(0),ml.setScalar(0),gl.setScalar(0),pl.fromBufferAttribute(t,e),ml.fromBufferAttribute(t,n),gl.fromBufferAttribute(t,s),a.setScalar(0),a.addScaledVector(pl,r.x),a.addScaledVector(ml,r.y),a.addScaledVector(gl,r.z),a}static isFrontFacing(t,e,n,s){return Gn.subVectors(n,e),yi.subVectors(t,e),Gn.cross(yi).dot(s)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,s){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,e,n,s){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,s),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Gn.subVectors(this.c,this.b),yi.subVectors(this.a,this.b),Gn.cross(yi).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return qn.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return qn.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,s,r){return qn.getInterpolation(t,this.a,this.b,this.c,e,n,s,r)}containsPoint(t){return qn.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return qn.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,s=this.b,r=this.c;let a,o;Bs.subVectors(s,n),Hs.subVectors(r,n),ul.subVectors(t,n);const l=Bs.dot(ul),c=Hs.dot(ul);if(l<=0&&c<=0)return e.copy(n);dl.subVectors(t,s);const h=Bs.dot(dl),u=Hs.dot(dl);if(h>=0&&u<=h)return e.copy(s);const d=l*u-h*c;if(d<=0&&l>=0&&h<=0)return a=l/(l-h),e.copy(n).addScaledVector(Bs,a);fl.subVectors(t,r);const f=Bs.dot(fl),g=Hs.dot(fl);if(g>=0&&f<=g)return e.copy(r);const _=f*c-l*g;if(_<=0&&c>=0&&g<=0)return o=c/(c-g),e.copy(n).addScaledVector(Hs,o);const m=h*g-f*u;if(m<=0&&u-h>=0&&f-g>=0)return Ru.subVectors(r,s),o=(u-h)/(u-h+(f-g)),e.copy(s).addScaledVector(Ru,o);const p=1/(m+_+d);return a=_*p,o=d*p,e.copy(n).addScaledVector(Bs,a).addScaledVector(Hs,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Nf={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},$i={h:0,s:0,l:0},Ma={h:0,s:0,l:0};function vl(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+(t-i)*6*e:e<1/2?t:e<2/3?i+(t-i)*6*(2/3-e):i}class Zt{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){const s=t;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Ye){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,oe.toWorkingColorSpace(this,e),this}setRGB(t,e,n,s=oe.workingColorSpace){return this.r=t,this.g=e,this.b=n,oe.toWorkingColorSpace(this,s),this}setHSL(t,e,n,s=oe.workingColorSpace){if(t=_h(t,1),e=Fe(e,0,1),n=Fe(n,0,1),e===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+e):n+e-n*e,a=2*n-r;this.r=vl(a,r,t+1/3),this.g=vl(a,r,t),this.b=vl(a,r,t-1/3)}return oe.toWorkingColorSpace(this,s),this}setStyle(t,e=Ye){function n(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))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,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))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,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){const r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(r,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Ye){const n=Nf[t.toLowerCase()];return n!==void 0?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=mr(t.r),this.g=mr(t.g),this.b=mr(t.b),this}copyLinearToSRGB(t){return this.r=el(t.r),this.g=el(t.g),this.b=el(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Ye){return oe.fromWorkingColorSpace(tn.copy(this),t),Math.round(Fe(tn.r*255,0,255))*65536+Math.round(Fe(tn.g*255,0,255))*256+Math.round(Fe(tn.b*255,0,255))}getHexString(t=Ye){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=oe.workingColorSpace){oe.fromWorkingColorSpace(tn.copy(this),e);const n=tn.r,s=tn.g,r=tn.b,a=Math.max(n,s,r),o=Math.min(n,s,r);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const u=a-o;switch(c=h<=.5?u/(a+o):u/(2-a-o),a){case n:l=(s-r)/u+(s<r?6:0);break;case s:l=(r-n)/u+2;break;case r:l=(n-s)/u+4;break}l/=6}return t.h=l,t.s=c,t.l=h,t}getRGB(t,e=oe.workingColorSpace){return oe.fromWorkingColorSpace(tn.copy(this),e),t.r=tn.r,t.g=tn.g,t.b=tn.b,t}getStyle(t=Ye){oe.fromWorkingColorSpace(tn.copy(this),t);const e=tn.r,n=tn.g,s=tn.b;return t!==Ye?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(t,e,n){return this.getHSL($i),this.setHSL($i.h+t,$i.s+e,$i.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL($i),t.getHSL(Ma);const n=Yr($i.h,Ma.h,e),s=Yr($i.s,Ma.s,e),r=Yr($i.l,Ma.l,e);return this.setHSL(n,s,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,s=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*s,this.g=r[1]*e+r[4]*n+r[7]*s,this.b=r[2]*e+r[5]*n+r[8]*s,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const tn=new Zt;Zt.NAMES=Nf;let A0=0;class Oi extends Ts{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:A0++}),this.uuid=Tr(),this.name="",this.type="Material",this.blending=fr,this.side=rs,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=rc,this.blendDst=ac,this.blendEquation=Xn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Zt(0,0,0),this.blendAlpha=0,this.depthFunc=xr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=pu,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ds,this.stencilZFail=Ds,this.stencilZPass=Ds,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const n=t[e];if(n===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const s=this[e];if(s===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={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(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).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(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).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(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).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(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).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!==fr&&(n.blending=this.blending),this.side!==rs&&(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!==rc&&(n.blendSrc=this.blendSrc),this.blendDst!==ac&&(n.blendDst=this.blendDst),this.blendEquation!==Xn&&(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!==xr&&(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!==pu&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ds&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Ds&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Ds&&(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 s(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(e){const r=s(t.textures),a=s(t.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(e!==null){const s=e.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class un extends Oi{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Zt(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 fi,this.combine=pf,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const Ie=new R,ba=new at;class ci{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=mu,this.updateRanges=[],this.gpuType=Ai,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let s=0,r=this.itemSize;s<r;s++)this.array[t+s]=e.array[n+s];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)ba.fromBufferAttribute(this,e),ba.applyMatrix3(t),this.setXY(e,ba.x,ba.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)Ie.fromBufferAttribute(this,e),Ie.applyMatrix3(t),this.setXYZ(e,Ie.x,Ie.y,Ie.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)Ie.fromBufferAttribute(this,e),Ie.applyMatrix4(t),this.setXYZ(e,Ie.x,Ie.y,Ie.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Ie.fromBufferAttribute(this,e),Ie.applyNormalMatrix(t),this.setXYZ(e,Ie.x,Ie.y,Ie.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Ie.fromBufferAttribute(this,e),Ie.transformDirection(t),this.setXYZ(e,Ie.x,Ie.y,Ie.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=Qs(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=an(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Qs(e,this.array)),e}setX(t,e){return this.normalized&&(e=an(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Qs(e,this.array)),e}setY(t,e){return this.normalized&&(e=an(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Qs(e,this.array)),e}setZ(t,e){return this.normalized&&(e=an(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Qs(e,this.array)),e}setW(t,e){return this.normalized&&(e=an(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=an(e,this.array),n=an(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,s){return t*=this.itemSize,this.normalized&&(e=an(e,this.array),n=an(n,this.array),s=an(s,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=s,this}setXYZW(t,e,n,s,r){return t*=this.itemSize,this.normalized&&(e=an(e,this.array),n=an(n,this.array),s=an(s,this.array),r=an(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=s,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==mu&&(t.usage=this.usage),t}}class Uf extends ci{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class Of extends ci{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class he extends ci{constructor(t,e,n){super(new Float32Array(t),e,n)}}let C0=0;const Pn=new fe,_l=new Je,Vs=new R,wn=new oa,Ir=new oa,Ve=new R;class dn extends Ts{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:C0++}),this.uuid=Tr(),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(t){return Array.isArray(t)?this.index=new(Df(t)?Of:Uf)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new Xt().getNormalMatrix(t);n.applyNormalMatrix(r),n.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(t),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return Pn.makeRotationFromQuaternion(t),this.applyMatrix4(Pn),this}rotateX(t){return Pn.makeRotationX(t),this.applyMatrix4(Pn),this}rotateY(t){return Pn.makeRotationY(t),this.applyMatrix4(Pn),this}rotateZ(t){return Pn.makeRotationZ(t),this.applyMatrix4(Pn),this}translate(t,e,n){return Pn.makeTranslation(t,e,n),this.applyMatrix4(Pn),this}scale(t,e,n){return Pn.makeScale(t,e,n),this.applyMatrix4(Pn),this}lookAt(t){return _l.lookAt(t),_l.updateMatrix(),this.applyMatrix4(_l.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Vs).negate(),this.translate(Vs.x,Vs.y,Vs.z),this}setFromPoints(t){const e=[];for(let n=0,s=t.length;n<s;n++){const r=t[n];e.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new he(e,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new oa);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new R(-1/0,-1/0,-1/0),new R(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,s=e.length;n<s;n++){const r=e[n];wn.setFromBufferAttribute(r),this.morphTargetsRelative?(Ve.addVectors(this.boundingBox.min,wn.min),this.boundingBox.expandByPoint(Ve),Ve.addVectors(this.boundingBox.max,wn.max),this.boundingBox.expandByPoint(Ve)):(this.boundingBox.expandByPoint(wn.min),this.boundingBox.expandByPoint(wn.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 xh);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new R,1/0);return}if(t){const n=this.boundingSphere.center;if(wn.setFromBufferAttribute(t),e)for(let r=0,a=e.length;r<a;r++){const o=e[r];Ir.setFromBufferAttribute(o),this.morphTargetsRelative?(Ve.addVectors(wn.min,Ir.min),wn.expandByPoint(Ve),Ve.addVectors(wn.max,Ir.max),wn.expandByPoint(Ve)):(wn.expandByPoint(Ir.min),wn.expandByPoint(Ir.max))}wn.getCenter(n);let s=0;for(let r=0,a=t.count;r<a;r++)Ve.fromBufferAttribute(t,r),s=Math.max(s,n.distanceToSquared(Ve));if(e)for(let r=0,a=e.length;r<a;r++){const o=e[r],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)Ve.fromBufferAttribute(o,c),l&&(Vs.fromBufferAttribute(t,c),Ve.add(Vs)),s=Math.max(s,n.distanceToSquared(Ve))}this.boundingSphere.radius=Math.sqrt(s),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 t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.position,s=e.normal,r=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new ci(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let P=0;P<n.count;P++)o[P]=new R,l[P]=new R;const c=new R,h=new R,u=new R,d=new at,f=new at,g=new at,_=new R,m=new R;function p(P,U,v){c.fromBufferAttribute(n,P),h.fromBufferAttribute(n,U),u.fromBufferAttribute(n,v),d.fromBufferAttribute(r,P),f.fromBufferAttribute(r,U),g.fromBufferAttribute(r,v),h.sub(c),u.sub(c),f.sub(d),g.sub(d);const b=1/(f.x*g.y-g.x*f.y);isFinite(b)&&(_.copy(h).multiplyScalar(g.y).addScaledVector(u,-f.y).multiplyScalar(b),m.copy(u).multiplyScalar(f.x).addScaledVector(h,-g.x).multiplyScalar(b),o[P].add(_),o[U].add(_),o[v].add(_),l[P].add(m),l[U].add(m),l[v].add(m))}let y=this.groups;y.length===0&&(y=[{start:0,count:t.count}]);for(let P=0,U=y.length;P<U;++P){const v=y[P],b=v.start,I=v.count;for(let O=b,$=b+I;O<$;O+=3)p(t.getX(O+0),t.getX(O+1),t.getX(O+2))}const x=new R,S=new R,L=new R,T=new R;function E(P){L.fromBufferAttribute(s,P),T.copy(L);const U=o[P];x.copy(U),x.sub(L.multiplyScalar(L.dot(U))).normalize(),S.crossVectors(T,U);const b=S.dot(l[P])<0?-1:1;a.setXYZW(P,x.x,x.y,x.z,b)}for(let P=0,U=y.length;P<U;++P){const v=y[P],b=v.start,I=v.count;for(let O=b,$=b+I;O<$;O+=3)E(t.getX(O+0)),E(t.getX(O+1)),E(t.getX(O+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new ci(new Float32Array(e.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 s=new R,r=new R,a=new R,o=new R,l=new R,c=new R,h=new R,u=new R;if(t)for(let d=0,f=t.count;d<f;d+=3){const g=t.getX(d+0),_=t.getX(d+1),m=t.getX(d+2);s.fromBufferAttribute(e,g),r.fromBufferAttribute(e,_),a.fromBufferAttribute(e,m),h.subVectors(a,r),u.subVectors(s,r),h.cross(u),o.fromBufferAttribute(n,g),l.fromBufferAttribute(n,_),c.fromBufferAttribute(n,m),o.add(h),l.add(h),c.add(h),n.setXYZ(g,o.x,o.y,o.z),n.setXYZ(_,l.x,l.y,l.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let d=0,f=e.count;d<f;d+=3)s.fromBufferAttribute(e,d+0),r.fromBufferAttribute(e,d+1),a.fromBufferAttribute(e,d+2),h.subVectors(a,r),u.subVectors(s,r),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)Ve.fromBufferAttribute(t,e),Ve.normalize(),t.setXYZ(e,Ve.x,Ve.y,Ve.z)}toNonIndexed(){function t(o,l){const c=o.array,h=o.itemSize,u=o.normalized,d=new c.constructor(l.length*h);let f=0,g=0;for(let _=0,m=l.length;_<m;_++){o.isInterleavedBufferAttribute?f=l[_]*o.data.stride+o.offset:f=l[_]*h;for(let p=0;p<h;p++)d[g++]=c[f++]}return new ci(d,h,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new dn,n=this.index.array,s=this.attributes;for(const o in s){const l=s[o],c=t(l,n);e.setAttribute(o,c)}const r=this.morphAttributes;for(const o in r){const l=[],c=r[o];for(let h=0,u=c.length;h<u;h++){const d=c[h],f=t(d,n);l.push(f)}e.morphAttributes[o]=l}e.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];e.addGroup(c.start,c.count,c.materialIndex)}return e}toJSON(){const t={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(t[c]=l[c]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const l in n){const c=n[l];t.data.attributes[l]=c.toJSON(t.data)}const s={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let u=0,d=c.length;u<d;u++){const f=c[u];h.push(f.toJSON(t.data))}h.length>0&&(s[l]=h,r=!0)}r&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(t.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;n!==null&&this.setIndex(n.clone(e));const s=t.attributes;for(const c in s){const h=s[c];this.setAttribute(c,h.clone(e))}const r=t.morphAttributes;for(const c in r){const h=[],u=r[c];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(e));this.morphAttributes[c]=h}this.morphTargetsRelative=t.morphTargetsRelative;const a=t.groups;for(let c=0,h=a.length;c<h;c++){const u=a[c];this.addGroup(u.start,u.count,u.materialIndex)}const o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=t.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Pu=new fe,us=new yh,Sa=new xh,Lu=new R,wa=new R,Ea=new R,Ta=new R,xl=new R,Aa=new R,Du=new R,Ca=new R;class yt extends Je{constructor(t=new dn,e=new un){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){const o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(t,e){const n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;e.fromBufferAttribute(s,t);const o=this.morphTargetInfluences;if(r&&o){Aa.set(0,0,0);for(let l=0,c=r.length;l<c;l++){const h=o[l],u=r[l];h!==0&&(xl.fromBufferAttribute(u,t),a?Aa.addScaledVector(xl,h):Aa.addScaledVector(xl.sub(e),h))}e.add(Aa)}return e}raycast(t,e){const n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Sa.copy(n.boundingSphere),Sa.applyMatrix4(r),us.copy(t.ray).recast(t.near),!(Sa.containsPoint(us.origin)===!1&&(us.intersectSphere(Sa,Lu)===null||us.origin.distanceToSquared(Lu)>(t.far-t.near)**2))&&(Pu.copy(r).invert(),us.copy(t.ray).applyMatrix4(Pu),!(n.boundingBox!==null&&us.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,us)))}_computeIntersections(t,e,n){let s;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,u=r.attributes.normal,d=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,_=d.length;g<_;g++){const m=d[g],p=a[m.materialIndex],y=Math.max(m.start,f.start),x=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let S=y,L=x;S<L;S+=3){const T=o.getX(S),E=o.getX(S+1),P=o.getX(S+2);s=Ra(this,p,t,n,c,h,u,T,E,P),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=m.materialIndex,e.push(s))}}else{const g=Math.max(0,f.start),_=Math.min(o.count,f.start+f.count);for(let m=g,p=_;m<p;m+=3){const y=o.getX(m),x=o.getX(m+1),S=o.getX(m+2);s=Ra(this,a,t,n,c,h,u,y,x,S),s&&(s.faceIndex=Math.floor(m/3),e.push(s))}}else if(l!==void 0)if(Array.isArray(a))for(let g=0,_=d.length;g<_;g++){const m=d[g],p=a[m.materialIndex],y=Math.max(m.start,f.start),x=Math.min(l.count,Math.min(m.start+m.count,f.start+f.count));for(let S=y,L=x;S<L;S+=3){const T=S,E=S+1,P=S+2;s=Ra(this,p,t,n,c,h,u,T,E,P),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=m.materialIndex,e.push(s))}}else{const g=Math.max(0,f.start),_=Math.min(l.count,f.start+f.count);for(let m=g,p=_;m<p;m+=3){const y=m,x=m+1,S=m+2;s=Ra(this,a,t,n,c,h,u,y,x,S),s&&(s.faceIndex=Math.floor(m/3),e.push(s))}}}}function R0(i,t,e,n,s,r,a,o){let l;if(t.side===hn?l=n.intersectTriangle(a,r,s,!0,o):l=n.intersectTriangle(s,r,a,t.side===rs,o),l===null)return null;Ca.copy(o),Ca.applyMatrix4(i.matrixWorld);const c=e.ray.origin.distanceTo(Ca);return c<e.near||c>e.far?null:{distance:c,point:Ca.clone(),object:i}}function Ra(i,t,e,n,s,r,a,o,l,c){i.getVertexPosition(o,wa),i.getVertexPosition(l,Ea),i.getVertexPosition(c,Ta);const h=R0(i,t,e,n,wa,Ea,Ta,Du);if(h){const u=new R;qn.getBarycoord(Du,wa,Ea,Ta,u),s&&(h.uv=qn.getInterpolatedAttribute(s,o,l,c,u,new at)),r&&(h.uv1=qn.getInterpolatedAttribute(r,o,l,c,u,new at)),a&&(h.normal=qn.getInterpolatedAttribute(a,o,l,c,u,new R),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:l,c,normal:new R,materialIndex:0};qn.getNormal(wa,Ea,Ta,d.normal),h.face=d,h.barycoord=u}return h}class Ke extends dn{constructor(t=1,e=1,n=1,s=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:s,heightSegments:r,depthSegments:a};const o=this;s=Math.floor(s),r=Math.floor(r),a=Math.floor(a);const l=[],c=[],h=[],u=[];let d=0,f=0;g("z","y","x",-1,-1,n,e,t,a,r,0),g("z","y","x",1,-1,n,e,-t,a,r,1),g("x","z","y",1,1,t,n,e,s,a,2),g("x","z","y",1,-1,t,n,-e,s,a,3),g("x","y","z",1,-1,t,e,n,s,r,4),g("x","y","z",-1,-1,t,e,-n,s,r,5),this.setIndex(l),this.setAttribute("position",new he(c,3)),this.setAttribute("normal",new he(h,3)),this.setAttribute("uv",new he(u,2));function g(_,m,p,y,x,S,L,T,E,P,U){const v=S/E,b=L/P,I=S/2,O=L/2,$=T/2,K=E+1,z=P+1;let Z=0,V=0;const ot=new R;for(let ct=0;ct<z;ct++){const _t=ct*b-O;for(let $t=0;$t<K;$t++){const Jt=$t*v-I;ot[_]=Jt*y,ot[m]=_t*x,ot[p]=$,c.push(ot.x,ot.y,ot.z),ot[_]=0,ot[m]=0,ot[p]=T>0?1:-1,h.push(ot.x,ot.y,ot.z),u.push($t/E),u.push(1-ct/P),Z+=1}}for(let ct=0;ct<P;ct++)for(let _t=0;_t<E;_t++){const $t=d+_t+K*ct,Jt=d+_t+K*(ct+1),j=d+(_t+1)+K*(ct+1),et=d+(_t+1)+K*ct;l.push($t,Jt,et),l.push(Jt,j,et),V+=6}o.addGroup(f,V,U),f+=V,d+=Z}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ke(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function br(i){const t={};for(const e in i){t[e]={};for(const n in i[e]){const s=i[e][n];s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)?s.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=s.clone():Array.isArray(s)?t[e][n]=s.slice():t[e][n]=s}}return t}function on(i){const t={};for(let e=0;e<i.length;e++){const n=br(i[e]);for(const s in n)t[s]=n[s]}return t}function P0(i){const t=[];for(let e=0;e<i.length;e++)t.push(i[e].clone());return t}function Ff(i){const t=i.getRenderTarget();return t===null?i.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:oe.workingColorSpace}const Zi={clone:br,merge:on};var L0=`void main() {
|
|
7
6
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
8
|
-
}`,
|
|
7
|
+
}`,D0=`void main() {
|
|
9
8
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
10
|
-
}`;class
|
|
9
|
+
}`;class en extends Oi{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=L0,this.fragmentShader=D0,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,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=br(t.uniforms),this.uniformsGroups=P0(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const s in this.uniforms){const a=this.uniforms[s].value;a&&a.isTexture?e.uniforms[s]={type:"t",value:a.toJSON(t).uuid}:a&&a.isColor?e.uniforms[s]={type:"c",value:a.getHex()}:a&&a.isVector2?e.uniforms[s]={type:"v2",value:a.toArray()}:a&&a.isVector3?e.uniforms[s]={type:"v3",value:a.toArray()}:a&&a.isVector4?e.uniforms[s]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?e.uniforms[s]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?e.uniforms[s]={type:"m4",value:a.toArray()}:e.uniforms[s]={value:a}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}class zf extends Je{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new fe,this.projectionMatrix=new fe,this.projectionMatrixInverse=new fe,this.coordinateSystem=Ci}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const Wi=new R,Iu=new at,ku=new at;class An extends zf{constructor(t=50,e=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=ra*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(qr*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return ra*2*Math.atan(Math.tan(qr*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){Wi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(Wi.x,Wi.y).multiplyScalar(-t/Wi.z),Wi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Wi.x,Wi.y).multiplyScalar(-t/Wi.z)}getViewSize(t,e){return this.getViewBounds(t,Iu,ku),e.subVectors(ku,Iu)}setViewOffset(t,e,n,s,r,a){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(qr*.5*this.fov)/this.zoom,n=2*e,s=this.aspect*n,r=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*s/l,e-=a.offsetY*n/c,s*=a.width/l,n*=a.height/c}const o=this.filmOffset;o!==0&&(r+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,e,e-n,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const Gs=-90,$s=1;class I0 extends Je{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new An(Gs,$s,t,e);s.layers=this.layers,this.add(s);const r=new An(Gs,$s,t,e);r.layers=this.layers,this.add(r);const a=new An(Gs,$s,t,e);a.layers=this.layers,this.add(a);const o=new An(Gs,$s,t,e);o.layers=this.layers,this.add(o);const l=new An(Gs,$s,t,e);l.layers=this.layers,this.add(l);const c=new An(Gs,$s,t,e);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,s,r,a,o,l]=e;for(const c of e)this.remove(c);if(t===Ci)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(t===Mo)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.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: "+t);for(const c of e)this.add(c),c.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,l,c,h]=this.children,u=t.getRenderTarget(),d=t.getActiveCubeFace(),f=t.getActiveMipmapLevel(),g=t.xr.enabled;t.xr.enabled=!1;const _=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0,s),t.render(e,r),t.setRenderTarget(n,1,s),t.render(e,a),t.setRenderTarget(n,2,s),t.render(e,o),t.setRenderTarget(n,3,s),t.render(e,l),t.setRenderTarget(n,4,s),t.render(e,c),n.texture.generateMipmaps=_,t.setRenderTarget(n,5,s),t.render(e,h),t.setRenderTarget(u,d,f),t.xr.enabled=g,n.texture.needsPMREMUpdate=!0}}class Bf extends rn{constructor(t,e,n,s,r,a,o,l,c,h){t=t!==void 0?t:[],e=e!==void 0?e:yr,super(t,e,n,s,r,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class k0 extends Jn{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},s=[n,n,n,n,n,n];this.texture=new Bf(s,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=e.generateMipmaps!==void 0?e.generateMipmaps:!1,this.texture.minFilter=e.minFilter!==void 0?e.minFilter:jn}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
|
|
11
10
|
|
|
12
11
|
varying vec3 vWorldDirection;
|
|
13
12
|
|
|
@@ -42,9 +41,9 @@ var Vp=Object.defineProperty;var Gp=(i,t,e)=>t in i?Vp(i,t,{enumerable:!0,config
|
|
|
42
41
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
43
42
|
|
|
44
43
|
}
|
|
45
|
-
`},s=new
|
|
44
|
+
`},s=new Ke(5,5,5),r=new en({name:"CubemapFromEquirect",uniforms:br(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:hn,blending:qe});r.uniforms.tEquirect.value=e;const a=new yt(s,r),o=e.minFilter;return e.minFilter===_s&&(e.minFilter=jn),new I0(1,10,this).update(t,a),e.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(t,e,n,s){const r=t.getRenderTarget();for(let a=0;a<6;a++)t.setRenderTarget(this,a),t.clear(e,n,s);t.setRenderTarget(r)}}const yl=new R,N0=new R,U0=new Xt;class qi{constructor(t=new R(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,s){return this.normal.set(t,e,n),this.constant=s,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const s=yl.subVectors(n,e).cross(N0.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(s,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const n=t.delta(yl),s=this.normal.dot(n);if(s===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const r=-(t.start.dot(this.normal)+this.constant)/s;return r<0||r>1?null:e.copy(t.start).addScaledVector(n,r)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||U0.getNormalMatrix(t),s=this.coplanarPoint(yl).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const ds=new xh,Pa=new R;class bh{constructor(t=new qi,e=new qi,n=new qi,s=new qi,r=new qi,a=new qi){this.planes=[t,e,n,s,r,a]}set(t,e,n,s,r,a){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=Ci){const n=this.planes,s=t.elements,r=s[0],a=s[1],o=s[2],l=s[3],c=s[4],h=s[5],u=s[6],d=s[7],f=s[8],g=s[9],_=s[10],m=s[11],p=s[12],y=s[13],x=s[14],S=s[15];if(n[0].setComponents(l-r,d-c,m-f,S-p).normalize(),n[1].setComponents(l+r,d+c,m+f,S+p).normalize(),n[2].setComponents(l+a,d+h,m+g,S+y).normalize(),n[3].setComponents(l-a,d-h,m-g,S-y).normalize(),n[4].setComponents(l-o,d-u,m-_,S-x).normalize(),e===Ci)n[5].setComponents(l+o,d+u,m+_,S+x).normalize();else if(e===Mo)n[5].setComponents(o,u,_,x).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),ds.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),ds.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(ds)}intersectsSprite(t){return ds.center.set(0,0,0),ds.radius=.7071067811865476,ds.applyMatrix4(t.matrixWorld),this.intersectsSphere(ds)}intersectsSphere(t){const e=this.planes,n=t.center,s=-t.radius;for(let r=0;r<6;r++)if(e[r].distanceToPoint(n)<s)return!1;return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const s=e[n];if(Pa.x=s.normal.x>0?t.max.x:t.min.x,Pa.y=s.normal.y>0?t.max.y:t.min.y,Pa.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(Pa)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function Hf(){let i=null,t=!1,e=null,n=null;function s(r,a){e(r,a),n=i.requestAnimationFrame(s)}return{start:function(){t!==!0&&e!==null&&(n=i.requestAnimationFrame(s),t=!0)},stop:function(){i.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(r){e=r},setContext:function(r){i=r}}}function O0(i){const t=new WeakMap;function e(o,l){const c=o.array,h=o.usage,u=c.byteLength,d=i.createBuffer();i.bindBuffer(l,d),i.bufferData(l,c,h),o.onUploadCallback();let f;if(c instanceof Float32Array)f=i.FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?f=i.HALF_FLOAT:f=i.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=i.SHORT;else if(c instanceof Uint32Array)f=i.UNSIGNED_INT;else if(c instanceof Int32Array)f=i.INT;else if(c instanceof Int8Array)f=i.BYTE;else if(c instanceof Uint8Array)f=i.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:u}}function n(o,l,c){const h=l.array,u=l.updateRanges;if(i.bindBuffer(c,o),u.length===0)i.bufferSubData(c,0,h);else{u.sort((f,g)=>f.start-g.start);let d=0;for(let f=1;f<u.length;f++){const g=u[d],_=u[f];_.start<=g.start+g.count+1?g.count=Math.max(g.count,_.start+_.count-g.start):(++d,u[d]=_)}u.length=d+1;for(let f=0,g=u.length;f<g;f++){const _=u[f];i.bufferSubData(c,_.start*h.BYTES_PER_ELEMENT,h,_.start,_.count)}l.clearUpdateRanges()}l.onUploadCallback()}function s(o){return o.isInterleavedBufferAttribute&&(o=o.data),t.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=t.get(o);l&&(i.deleteBuffer(l.buffer),t.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const h=t.get(o);(!h||h.version<o.version)&&t.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=t.get(o);if(c===void 0)t.set(o,e(o,l));else if(c.version<o.version){if(c.size!==o.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,o,l),c.version=o.version}}return{get:s,remove:r,update:a}}class pi extends dn{constructor(t=1,e=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:s};const r=t/2,a=e/2,o=Math.floor(n),l=Math.floor(s),c=o+1,h=l+1,u=t/o,d=e/l,f=[],g=[],_=[],m=[];for(let p=0;p<h;p++){const y=p*d-a;for(let x=0;x<c;x++){const S=x*u-r;g.push(S,-y,0),_.push(0,0,1),m.push(x/o),m.push(1-p/l)}}for(let p=0;p<l;p++)for(let y=0;y<o;y++){const x=y+c*p,S=y+c*(p+1),L=y+1+c*(p+1),T=y+1+c*p;f.push(x,S,T),f.push(S,L,T)}this.setIndex(f),this.setAttribute("position",new he(g,3)),this.setAttribute("normal",new he(_,3)),this.setAttribute("uv",new he(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new pi(t.width,t.height,t.widthSegments,t.heightSegments)}}var F0=`#ifdef USE_ALPHAHASH
|
|
46
45
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
47
|
-
#endif`,
|
|
46
|
+
#endif`,z0=`#ifdef USE_ALPHAHASH
|
|
48
47
|
const float ALPHA_HASH_SCALE = 0.05;
|
|
49
48
|
float hash2D( vec2 value ) {
|
|
50
49
|
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
|
|
@@ -79,20 +78,20 @@ var Vp=Object.defineProperty;var Gp=(i,t,e)=>t in i?Vp(i,t,{enumerable:!0,config
|
|
|
79
78
|
: cases.z;
|
|
80
79
|
return clamp( threshold , 1.0e-6, 1.0 );
|
|
81
80
|
}
|
|
82
|
-
#endif`,
|
|
81
|
+
#endif`,B0=`#ifdef USE_ALPHAMAP
|
|
83
82
|
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
|
84
|
-
#endif
|
|
83
|
+
#endif`,H0=`#ifdef USE_ALPHAMAP
|
|
85
84
|
uniform sampler2D alphaMap;
|
|
86
|
-
#endif`,
|
|
85
|
+
#endif`,V0=`#ifdef USE_ALPHATEST
|
|
87
86
|
#ifdef ALPHA_TO_COVERAGE
|
|
88
87
|
diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
|
|
89
88
|
if ( diffuseColor.a == 0.0 ) discard;
|
|
90
89
|
#else
|
|
91
90
|
if ( diffuseColor.a < alphaTest ) discard;
|
|
92
91
|
#endif
|
|
93
|
-
#endif`,
|
|
92
|
+
#endif`,G0=`#ifdef USE_ALPHATEST
|
|
94
93
|
uniform float alphaTest;
|
|
95
|
-
#endif
|
|
94
|
+
#endif`,$0=`#ifdef USE_AOMAP
|
|
96
95
|
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
|
|
97
96
|
reflectedLight.indirectDiffuse *= ambientOcclusion;
|
|
98
97
|
#if defined( USE_CLEARCOAT )
|
|
@@ -105,10 +104,10 @@ var Vp=Object.defineProperty;var Gp=(i,t,e)=>t in i?Vp(i,t,{enumerable:!0,config
|
|
|
105
104
|
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
|
|
106
105
|
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
|
|
107
106
|
#endif
|
|
108
|
-
#endif`,
|
|
107
|
+
#endif`,W0=`#ifdef USE_AOMAP
|
|
109
108
|
uniform sampler2D aoMap;
|
|
110
109
|
uniform float aoMapIntensity;
|
|
111
|
-
#endif`,
|
|
110
|
+
#endif`,X0=`#ifdef USE_BATCHING
|
|
112
111
|
#if ! defined( GL_ANGLE_multi_draw )
|
|
113
112
|
#define gl_DrawID _gl_DrawID
|
|
114
113
|
uniform int _gl_DrawID;
|
|
@@ -142,15 +141,15 @@ var Vp=Object.defineProperty;var Gp=(i,t,e)=>t in i?Vp(i,t,{enumerable:!0,config
|
|
|
142
141
|
int y = j / size;
|
|
143
142
|
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
|
|
144
143
|
}
|
|
145
|
-
#endif`,
|
|
144
|
+
#endif`,j0=`#ifdef USE_BATCHING
|
|
146
145
|
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
|
|
147
|
-
#endif`,
|
|
146
|
+
#endif`,q0=`vec3 transformed = vec3( position );
|
|
148
147
|
#ifdef USE_ALPHAHASH
|
|
149
148
|
vPosition = vec3( position );
|
|
150
|
-
#endif`,
|
|
149
|
+
#endif`,Y0=`vec3 objectNormal = vec3( normal );
|
|
151
150
|
#ifdef USE_TANGENT
|
|
152
151
|
vec3 objectTangent = vec3( tangent.xyz );
|
|
153
|
-
#endif`,
|
|
152
|
+
#endif`,K0=`float G_BlinnPhong_Implicit( ) {
|
|
154
153
|
return 0.25;
|
|
155
154
|
}
|
|
156
155
|
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
|
|
@@ -164,7 +163,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
164
163
|
float G = G_BlinnPhong_Implicit( );
|
|
165
164
|
float D = D_BlinnPhong( shininess, dotNH );
|
|
166
165
|
return F * ( G * D );
|
|
167
|
-
} // validated`,
|
|
166
|
+
} // validated`,Z0=`#ifdef USE_IRIDESCENCE
|
|
168
167
|
const mat3 XYZ_TO_REC709 = mat3(
|
|
169
168
|
3.2404542, -0.9692660, 0.0556434,
|
|
170
169
|
-1.5371385, 1.8760108, -0.2040259,
|
|
@@ -227,7 +226,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
227
226
|
}
|
|
228
227
|
return max( I, vec3( 0.0 ) );
|
|
229
228
|
}
|
|
230
|
-
#endif`,
|
|
229
|
+
#endif`,J0=`#ifdef USE_BUMPMAP
|
|
231
230
|
uniform sampler2D bumpMap;
|
|
232
231
|
uniform float bumpScale;
|
|
233
232
|
vec2 dHdxy_fwd() {
|
|
@@ -248,7 +247,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
248
247
|
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
|
|
249
248
|
return normalize( abs( fDet ) * surf_norm - vGrad );
|
|
250
249
|
}
|
|
251
|
-
#endif`,
|
|
250
|
+
#endif`,Q0=`#if NUM_CLIPPING_PLANES > 0
|
|
252
251
|
vec4 plane;
|
|
253
252
|
#ifdef ALPHA_TO_COVERAGE
|
|
254
253
|
float distanceToPlane, distanceGradient;
|
|
@@ -294,26 +293,26 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
294
293
|
if ( clipped ) discard;
|
|
295
294
|
#endif
|
|
296
295
|
#endif
|
|
297
|
-
#endif`,
|
|
296
|
+
#endif`,tg=`#if NUM_CLIPPING_PLANES > 0
|
|
298
297
|
varying vec3 vClipPosition;
|
|
299
298
|
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
|
300
|
-
#endif`,
|
|
299
|
+
#endif`,eg=`#if NUM_CLIPPING_PLANES > 0
|
|
301
300
|
varying vec3 vClipPosition;
|
|
302
|
-
#endif`,
|
|
301
|
+
#endif`,ng=`#if NUM_CLIPPING_PLANES > 0
|
|
303
302
|
vClipPosition = - mvPosition.xyz;
|
|
304
|
-
#endif`,
|
|
303
|
+
#endif`,ig=`#if defined( USE_COLOR_ALPHA )
|
|
305
304
|
diffuseColor *= vColor;
|
|
306
305
|
#elif defined( USE_COLOR )
|
|
307
306
|
diffuseColor.rgb *= vColor;
|
|
308
|
-
#endif`,
|
|
307
|
+
#endif`,sg=`#if defined( USE_COLOR_ALPHA )
|
|
309
308
|
varying vec4 vColor;
|
|
310
309
|
#elif defined( USE_COLOR )
|
|
311
310
|
varying vec3 vColor;
|
|
312
|
-
#endif`,
|
|
311
|
+
#endif`,rg=`#if defined( USE_COLOR_ALPHA )
|
|
313
312
|
varying vec4 vColor;
|
|
314
313
|
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
315
314
|
varying vec3 vColor;
|
|
316
|
-
#endif`,
|
|
315
|
+
#endif`,ag=`#if defined( USE_COLOR_ALPHA )
|
|
317
316
|
vColor = vec4( 1.0 );
|
|
318
317
|
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
319
318
|
vColor = vec3( 1.0 );
|
|
@@ -327,7 +326,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
327
326
|
#ifdef USE_BATCHING_COLOR
|
|
328
327
|
vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
|
|
329
328
|
vColor.xyz *= batchingColor.xyz;
|
|
330
|
-
#endif`,
|
|
329
|
+
#endif`,og=`#define PI 3.141592653589793
|
|
331
330
|
#define PI2 6.283185307179586
|
|
332
331
|
#define PI_HALF 1.5707963267948966
|
|
333
332
|
#define RECIPROCAL_PI 0.3183098861837907
|
|
@@ -401,7 +400,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
|
|
|
401
400
|
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
|
402
401
|
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
|
403
402
|
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
|
404
|
-
} // validated`,
|
|
403
|
+
} // validated`,lg=`#ifdef ENVMAP_TYPE_CUBE_UV
|
|
405
404
|
#define cubeUV_minMipLevel 4.0
|
|
406
405
|
#define cubeUV_minTileSize 16.0
|
|
407
406
|
float getFace( vec3 direction ) {
|
|
@@ -494,7 +493,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
|
|
494
493
|
return vec4( mix( color0, color1, mipF ), 1.0 );
|
|
495
494
|
}
|
|
496
495
|
}
|
|
497
|
-
#endif`,
|
|
496
|
+
#endif`,cg=`vec3 transformedNormal = objectNormal;
|
|
498
497
|
#ifdef USE_TANGENT
|
|
499
498
|
vec3 transformedTangent = objectTangent;
|
|
500
499
|
#endif
|
|
@@ -523,18 +522,18 @@ transformedNormal = normalMatrix * transformedNormal;
|
|
|
523
522
|
#ifdef FLIP_SIDED
|
|
524
523
|
transformedTangent = - transformedTangent;
|
|
525
524
|
#endif
|
|
526
|
-
#endif`,
|
|
525
|
+
#endif`,hg=`#ifdef USE_DISPLACEMENTMAP
|
|
527
526
|
uniform sampler2D displacementMap;
|
|
528
527
|
uniform float displacementScale;
|
|
529
528
|
uniform float displacementBias;
|
|
530
|
-
#endif`,
|
|
529
|
+
#endif`,ug=`#ifdef USE_DISPLACEMENTMAP
|
|
531
530
|
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
|
532
|
-
#endif`,
|
|
531
|
+
#endif`,dg=`#ifdef USE_EMISSIVEMAP
|
|
533
532
|
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
|
534
533
|
totalEmissiveRadiance *= emissiveColor.rgb;
|
|
535
|
-
#endif`,
|
|
534
|
+
#endif`,fg=`#ifdef USE_EMISSIVEMAP
|
|
536
535
|
uniform sampler2D emissiveMap;
|
|
537
|
-
#endif`,
|
|
536
|
+
#endif`,pg="gl_FragColor = linearToOutputTexel( gl_FragColor );",mg=`
|
|
538
537
|
const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
|
|
539
538
|
vec3( 0.8224621, 0.177538, 0.0 ),
|
|
540
539
|
vec3( 0.0331941, 0.9668058, 0.0 ),
|
|
@@ -556,7 +555,7 @@ vec4 LinearTransferOETF( in vec4 value ) {
|
|
|
556
555
|
}
|
|
557
556
|
vec4 sRGBTransferOETF( in vec4 value ) {
|
|
558
557
|
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 );
|
|
559
|
-
}`,
|
|
558
|
+
}`,gg=`#ifdef USE_ENVMAP
|
|
560
559
|
#ifdef ENV_WORLDPOS
|
|
561
560
|
vec3 cameraToFrag;
|
|
562
561
|
if ( isOrthographic ) {
|
|
@@ -585,7 +584,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
585
584
|
#elif defined( ENVMAP_BLENDING_ADD )
|
|
586
585
|
outgoingLight += envColor.xyz * specularStrength * reflectivity;
|
|
587
586
|
#endif
|
|
588
|
-
#endif`,
|
|
587
|
+
#endif`,vg=`#ifdef USE_ENVMAP
|
|
589
588
|
uniform float envMapIntensity;
|
|
590
589
|
uniform float flipEnvMap;
|
|
591
590
|
uniform mat3 envMapRotation;
|
|
@@ -595,7 +594,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
595
594
|
uniform sampler2D envMap;
|
|
596
595
|
#endif
|
|
597
596
|
|
|
598
|
-
#endif`,
|
|
597
|
+
#endif`,_g=`#ifdef USE_ENVMAP
|
|
599
598
|
uniform float reflectivity;
|
|
600
599
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
601
600
|
#define ENV_WORLDPOS
|
|
@@ -606,7 +605,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
606
605
|
#else
|
|
607
606
|
varying vec3 vReflect;
|
|
608
607
|
#endif
|
|
609
|
-
#endif`,
|
|
608
|
+
#endif`,xg=`#ifdef USE_ENVMAP
|
|
610
609
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
611
610
|
#define ENV_WORLDPOS
|
|
612
611
|
#endif
|
|
@@ -617,7 +616,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
617
616
|
varying vec3 vReflect;
|
|
618
617
|
uniform float refractionRatio;
|
|
619
618
|
#endif
|
|
620
|
-
#endif`,
|
|
619
|
+
#endif`,yg=`#ifdef USE_ENVMAP
|
|
621
620
|
#ifdef ENV_WORLDPOS
|
|
622
621
|
vWorldPosition = worldPosition.xyz;
|
|
623
622
|
#else
|
|
@@ -634,18 +633,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
634
633
|
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
|
|
635
634
|
#endif
|
|
636
635
|
#endif
|
|
637
|
-
#endif`,
|
|
636
|
+
#endif`,Mg=`#ifdef USE_FOG
|
|
638
637
|
vFogDepth = - mvPosition.z;
|
|
639
|
-
#endif`,
|
|
638
|
+
#endif`,bg=`#ifdef USE_FOG
|
|
640
639
|
varying float vFogDepth;
|
|
641
|
-
#endif`,
|
|
640
|
+
#endif`,Sg=`#ifdef USE_FOG
|
|
642
641
|
#ifdef FOG_EXP2
|
|
643
642
|
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
|
|
644
643
|
#else
|
|
645
644
|
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
|
|
646
645
|
#endif
|
|
647
646
|
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
|
|
648
|
-
#endif`,
|
|
647
|
+
#endif`,wg=`#ifdef USE_FOG
|
|
649
648
|
uniform vec3 fogColor;
|
|
650
649
|
varying float vFogDepth;
|
|
651
650
|
#ifdef FOG_EXP2
|
|
@@ -654,7 +653,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
654
653
|
uniform float fogNear;
|
|
655
654
|
uniform float fogFar;
|
|
656
655
|
#endif
|
|
657
|
-
#endif`,
|
|
656
|
+
#endif`,Eg=`#ifdef USE_GRADIENTMAP
|
|
658
657
|
uniform sampler2D gradientMap;
|
|
659
658
|
#endif
|
|
660
659
|
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
@@ -666,12 +665,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
|
666
665
|
vec2 fw = fwidth( coord ) * 0.5;
|
|
667
666
|
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
|
|
668
667
|
#endif
|
|
669
|
-
}`,
|
|
668
|
+
}`,Tg=`#ifdef USE_LIGHTMAP
|
|
670
669
|
uniform sampler2D lightMap;
|
|
671
670
|
uniform float lightMapIntensity;
|
|
672
|
-
#endif`,
|
|
671
|
+
#endif`,Ag=`LambertMaterial material;
|
|
673
672
|
material.diffuseColor = diffuseColor.rgb;
|
|
674
|
-
material.specularStrength = specularStrength;`,
|
|
673
|
+
material.specularStrength = specularStrength;`,Cg=`varying vec3 vViewPosition;
|
|
675
674
|
struct LambertMaterial {
|
|
676
675
|
vec3 diffuseColor;
|
|
677
676
|
float specularStrength;
|
|
@@ -685,7 +684,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
|
|
|
685
684
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
686
685
|
}
|
|
687
686
|
#define RE_Direct RE_Direct_Lambert
|
|
688
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,
|
|
687
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Rg=`uniform bool receiveShadow;
|
|
689
688
|
uniform vec3 ambientLightColor;
|
|
690
689
|
#if defined( USE_LIGHT_PROBES )
|
|
691
690
|
uniform vec3 lightProbe[ 9 ];
|
|
@@ -801,7 +800,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
801
800
|
vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
|
|
802
801
|
return irradiance;
|
|
803
802
|
}
|
|
804
|
-
#endif`,
|
|
803
|
+
#endif`,Pg=`#ifdef USE_ENVMAP
|
|
805
804
|
vec3 getIBLIrradiance( const in vec3 normal ) {
|
|
806
805
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
807
806
|
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
@@ -834,8 +833,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
834
833
|
#endif
|
|
835
834
|
}
|
|
836
835
|
#endif
|
|
837
|
-
#endif`,
|
|
838
|
-
material.diffuseColor = diffuseColor.rgb;`,
|
|
836
|
+
#endif`,Lg=`ToonMaterial material;
|
|
837
|
+
material.diffuseColor = diffuseColor.rgb;`,Dg=`varying vec3 vViewPosition;
|
|
839
838
|
struct ToonMaterial {
|
|
840
839
|
vec3 diffuseColor;
|
|
841
840
|
};
|
|
@@ -847,11 +846,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
|
|
|
847
846
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
848
847
|
}
|
|
849
848
|
#define RE_Direct RE_Direct_Toon
|
|
850
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,
|
|
849
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Ig=`BlinnPhongMaterial material;
|
|
851
850
|
material.diffuseColor = diffuseColor.rgb;
|
|
852
851
|
material.specularColor = specular;
|
|
853
852
|
material.specularShininess = shininess;
|
|
854
|
-
material.specularStrength = specularStrength;`,
|
|
853
|
+
material.specularStrength = specularStrength;`,kg=`varying vec3 vViewPosition;
|
|
855
854
|
struct BlinnPhongMaterial {
|
|
856
855
|
vec3 diffuseColor;
|
|
857
856
|
vec3 specularColor;
|
|
@@ -868,7 +867,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
|
|
|
868
867
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
869
868
|
}
|
|
870
869
|
#define RE_Direct RE_Direct_BlinnPhong
|
|
871
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,
|
|
870
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Ng=`PhysicalMaterial material;
|
|
872
871
|
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
|
873
872
|
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
|
|
874
873
|
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
|
|
@@ -954,7 +953,7 @@ material.roughness = min( material.roughness, 1.0 );
|
|
|
954
953
|
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
|
|
955
954
|
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
|
|
956
955
|
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
|
|
957
|
-
#endif`,
|
|
956
|
+
#endif`,Ug=`struct PhysicalMaterial {
|
|
958
957
|
vec3 diffuseColor;
|
|
959
958
|
float roughness;
|
|
960
959
|
vec3 specularColor;
|
|
@@ -1255,7 +1254,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
|
|
|
1255
1254
|
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
|
1256
1255
|
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
|
|
1257
1256
|
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
|
|
1258
|
-
}`,
|
|
1257
|
+
}`,Og=`
|
|
1259
1258
|
vec3 geometryPosition = - vViewPosition;
|
|
1260
1259
|
vec3 geometryNormal = normal;
|
|
1261
1260
|
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|
@@ -1370,7 +1369,7 @@ IncidentLight directLight;
|
|
|
1370
1369
|
#if defined( RE_IndirectSpecular )
|
|
1371
1370
|
vec3 radiance = vec3( 0.0 );
|
|
1372
1371
|
vec3 clearcoatRadiance = vec3( 0.0 );
|
|
1373
|
-
#endif`,
|
|
1372
|
+
#endif`,Fg=`#if defined( RE_IndirectDiffuse )
|
|
1374
1373
|
#ifdef USE_LIGHTMAP
|
|
1375
1374
|
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
1376
1375
|
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
|
@@ -1389,33 +1388,33 @@ IncidentLight directLight;
|
|
|
1389
1388
|
#ifdef USE_CLEARCOAT
|
|
1390
1389
|
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
|
|
1391
1390
|
#endif
|
|
1392
|
-
#endif`,
|
|
1391
|
+
#endif`,zg=`#if defined( RE_IndirectDiffuse )
|
|
1393
1392
|
RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1394
1393
|
#endif
|
|
1395
1394
|
#if defined( RE_IndirectSpecular )
|
|
1396
1395
|
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1397
|
-
#endif`,
|
|
1396
|
+
#endif`,Bg=`#if defined( USE_LOGDEPTHBUF )
|
|
1398
1397
|
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
|
1399
|
-
#endif
|
|
1398
|
+
#endif`,Hg=`#if defined( USE_LOGDEPTHBUF )
|
|
1400
1399
|
uniform float logDepthBufFC;
|
|
1401
1400
|
varying float vFragDepth;
|
|
1402
1401
|
varying float vIsPerspective;
|
|
1403
|
-
#endif`,
|
|
1402
|
+
#endif`,Vg=`#ifdef USE_LOGDEPTHBUF
|
|
1404
1403
|
varying float vFragDepth;
|
|
1405
1404
|
varying float vIsPerspective;
|
|
1406
|
-
#endif`,
|
|
1405
|
+
#endif`,Gg=`#ifdef USE_LOGDEPTHBUF
|
|
1407
1406
|
vFragDepth = 1.0 + gl_Position.w;
|
|
1408
1407
|
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|
1409
|
-
#endif
|
|
1408
|
+
#endif`,$g=`#ifdef USE_MAP
|
|
1410
1409
|
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
|
1411
1410
|
#ifdef DECODE_VIDEO_TEXTURE
|
|
1412
1411
|
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 );
|
|
1413
1412
|
|
|
1414
1413
|
#endif
|
|
1415
1414
|
diffuseColor *= sampledDiffuseColor;
|
|
1416
|
-
#endif`,
|
|
1415
|
+
#endif`,Wg=`#ifdef USE_MAP
|
|
1417
1416
|
uniform sampler2D map;
|
|
1418
|
-
#endif`,
|
|
1417
|
+
#endif`,Xg=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
1419
1418
|
#if defined( USE_POINTS_UV )
|
|
1420
1419
|
vec2 uv = vUv;
|
|
1421
1420
|
#else
|
|
@@ -1427,7 +1426,7 @@ IncidentLight directLight;
|
|
|
1427
1426
|
#endif
|
|
1428
1427
|
#ifdef USE_ALPHAMAP
|
|
1429
1428
|
diffuseColor.a *= texture2D( alphaMap, uv ).g;
|
|
1430
|
-
#endif`,
|
|
1429
|
+
#endif`,jg=`#if defined( USE_POINTS_UV )
|
|
1431
1430
|
varying vec2 vUv;
|
|
1432
1431
|
#else
|
|
1433
1432
|
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
@@ -1439,19 +1438,19 @@ IncidentLight directLight;
|
|
|
1439
1438
|
#endif
|
|
1440
1439
|
#ifdef USE_ALPHAMAP
|
|
1441
1440
|
uniform sampler2D alphaMap;
|
|
1442
|
-
#endif`,
|
|
1441
|
+
#endif`,qg=`float metalnessFactor = metalness;
|
|
1443
1442
|
#ifdef USE_METALNESSMAP
|
|
1444
1443
|
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
|
1445
1444
|
metalnessFactor *= texelMetalness.b;
|
|
1446
|
-
#endif`,
|
|
1445
|
+
#endif`,Yg=`#ifdef USE_METALNESSMAP
|
|
1447
1446
|
uniform sampler2D metalnessMap;
|
|
1448
|
-
#endif`,
|
|
1447
|
+
#endif`,Kg=`#ifdef USE_INSTANCING_MORPH
|
|
1449
1448
|
float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
1450
1449
|
float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
|
|
1451
1450
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1452
1451
|
morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
|
|
1453
1452
|
}
|
|
1454
|
-
#endif`,
|
|
1453
|
+
#endif`,Zg=`#if defined( USE_MORPHCOLORS )
|
|
1455
1454
|
vColor *= morphTargetBaseInfluence;
|
|
1456
1455
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1457
1456
|
#if defined( USE_COLOR_ALPHA )
|
|
@@ -1460,12 +1459,12 @@ IncidentLight directLight;
|
|
|
1460
1459
|
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
|
|
1461
1460
|
#endif
|
|
1462
1461
|
}
|
|
1463
|
-
#endif`,
|
|
1462
|
+
#endif`,Jg=`#ifdef USE_MORPHNORMALS
|
|
1464
1463
|
objectNormal *= morphTargetBaseInfluence;
|
|
1465
1464
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1466
1465
|
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
|
|
1467
1466
|
}
|
|
1468
|
-
#endif`,
|
|
1467
|
+
#endif`,Qg=`#ifdef USE_MORPHTARGETS
|
|
1469
1468
|
#ifndef USE_INSTANCING_MORPH
|
|
1470
1469
|
uniform float morphTargetBaseInfluence;
|
|
1471
1470
|
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
@@ -1479,12 +1478,12 @@ IncidentLight directLight;
|
|
|
1479
1478
|
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
|
|
1480
1479
|
return texelFetch( morphTargetsTexture, morphUV, 0 );
|
|
1481
1480
|
}
|
|
1482
|
-
#endif`,
|
|
1481
|
+
#endif`,tv=`#ifdef USE_MORPHTARGETS
|
|
1483
1482
|
transformed *= morphTargetBaseInfluence;
|
|
1484
1483
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1485
1484
|
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
|
|
1486
1485
|
}
|
|
1487
|
-
#endif`,
|
|
1486
|
+
#endif`,ev=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
|
|
1488
1487
|
#ifdef FLAT_SHADED
|
|
1489
1488
|
vec3 fdx = dFdx( vViewPosition );
|
|
1490
1489
|
vec3 fdy = dFdy( vViewPosition );
|
|
@@ -1525,7 +1524,7 @@ IncidentLight directLight;
|
|
|
1525
1524
|
tbn2[1] *= faceDirection;
|
|
1526
1525
|
#endif
|
|
1527
1526
|
#endif
|
|
1528
|
-
vec3 nonPerturbedNormal = normal;`,
|
|
1527
|
+
vec3 nonPerturbedNormal = normal;`,nv=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
1529
1528
|
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
|
1530
1529
|
#ifdef FLIP_SIDED
|
|
1531
1530
|
normal = - normal;
|
|
@@ -1540,25 +1539,25 @@ vec3 nonPerturbedNormal = normal;`,rv=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1540
1539
|
normal = normalize( tbn * mapN );
|
|
1541
1540
|
#elif defined( USE_BUMPMAP )
|
|
1542
1541
|
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
|
|
1543
|
-
#endif`,
|
|
1542
|
+
#endif`,iv=`#ifndef FLAT_SHADED
|
|
1544
1543
|
varying vec3 vNormal;
|
|
1545
1544
|
#ifdef USE_TANGENT
|
|
1546
1545
|
varying vec3 vTangent;
|
|
1547
1546
|
varying vec3 vBitangent;
|
|
1548
1547
|
#endif
|
|
1549
|
-
#endif`,
|
|
1548
|
+
#endif`,sv=`#ifndef FLAT_SHADED
|
|
1550
1549
|
varying vec3 vNormal;
|
|
1551
1550
|
#ifdef USE_TANGENT
|
|
1552
1551
|
varying vec3 vTangent;
|
|
1553
1552
|
varying vec3 vBitangent;
|
|
1554
1553
|
#endif
|
|
1555
|
-
#endif`,
|
|
1554
|
+
#endif`,rv=`#ifndef FLAT_SHADED
|
|
1556
1555
|
vNormal = normalize( transformedNormal );
|
|
1557
1556
|
#ifdef USE_TANGENT
|
|
1558
1557
|
vTangent = normalize( transformedTangent );
|
|
1559
1558
|
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
|
|
1560
1559
|
#endif
|
|
1561
|
-
#endif`,
|
|
1560
|
+
#endif`,av=`#ifdef USE_NORMALMAP
|
|
1562
1561
|
uniform sampler2D normalMap;
|
|
1563
1562
|
uniform vec2 normalScale;
|
|
1564
1563
|
#endif
|
|
@@ -1580,13 +1579,13 @@ vec3 nonPerturbedNormal = normal;`,rv=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1580
1579
|
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
|
|
1581
1580
|
return mat3( T * scale, B * scale, N );
|
|
1582
1581
|
}
|
|
1583
|
-
#endif`,
|
|
1582
|
+
#endif`,ov=`#ifdef USE_CLEARCOAT
|
|
1584
1583
|
vec3 clearcoatNormal = nonPerturbedNormal;
|
|
1585
|
-
#endif`,
|
|
1584
|
+
#endif`,lv=`#ifdef USE_CLEARCOAT_NORMALMAP
|
|
1586
1585
|
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
|
1587
1586
|
clearcoatMapN.xy *= clearcoatNormalScale;
|
|
1588
1587
|
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
|
1589
|
-
#endif`,
|
|
1588
|
+
#endif`,cv=`#ifdef USE_CLEARCOATMAP
|
|
1590
1589
|
uniform sampler2D clearcoatMap;
|
|
1591
1590
|
#endif
|
|
1592
1591
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
@@ -1595,18 +1594,18 @@ vec3 nonPerturbedNormal = normal;`,rv=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1595
1594
|
#endif
|
|
1596
1595
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
1597
1596
|
uniform sampler2D clearcoatRoughnessMap;
|
|
1598
|
-
#endif`,
|
|
1597
|
+
#endif`,hv=`#ifdef USE_IRIDESCENCEMAP
|
|
1599
1598
|
uniform sampler2D iridescenceMap;
|
|
1600
1599
|
#endif
|
|
1601
1600
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
1602
1601
|
uniform sampler2D iridescenceThicknessMap;
|
|
1603
|
-
#endif`,
|
|
1602
|
+
#endif`,uv=`#ifdef OPAQUE
|
|
1604
1603
|
diffuseColor.a = 1.0;
|
|
1605
1604
|
#endif
|
|
1606
1605
|
#ifdef USE_TRANSMISSION
|
|
1607
1606
|
diffuseColor.a *= material.transmissionAlpha;
|
|
1608
1607
|
#endif
|
|
1609
|
-
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,
|
|
1608
|
+
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,dv=`vec3 packNormalToRGB( const in vec3 normal ) {
|
|
1610
1609
|
return normalize( normal ) * 0.5 + 0.5;
|
|
1611
1610
|
}
|
|
1612
1611
|
vec3 unpackRGBToNormal( const in vec3 rgb ) {
|
|
@@ -1675,9 +1674,9 @@ float viewZToPerspectiveDepth( const in float viewZ, const in float near, const
|
|
|
1675
1674
|
}
|
|
1676
1675
|
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
|
|
1677
1676
|
return ( near * far ) / ( ( far - near ) * depth - far );
|
|
1678
|
-
}`,
|
|
1677
|
+
}`,fv=`#ifdef PREMULTIPLIED_ALPHA
|
|
1679
1678
|
gl_FragColor.rgb *= gl_FragColor.a;
|
|
1680
|
-
#endif`,
|
|
1679
|
+
#endif`,pv=`vec4 mvPosition = vec4( transformed, 1.0 );
|
|
1681
1680
|
#ifdef USE_BATCHING
|
|
1682
1681
|
mvPosition = batchingMatrix * mvPosition;
|
|
1683
1682
|
#endif
|
|
@@ -1685,22 +1684,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
|
|
|
1685
1684
|
mvPosition = instanceMatrix * mvPosition;
|
|
1686
1685
|
#endif
|
|
1687
1686
|
mvPosition = modelViewMatrix * mvPosition;
|
|
1688
|
-
gl_Position = projectionMatrix * mvPosition;`,
|
|
1687
|
+
gl_Position = projectionMatrix * mvPosition;`,mv=`#ifdef DITHERING
|
|
1689
1688
|
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
|
1690
|
-
#endif`,
|
|
1689
|
+
#endif`,gv=`#ifdef DITHERING
|
|
1691
1690
|
vec3 dithering( vec3 color ) {
|
|
1692
1691
|
float grid_position = rand( gl_FragCoord.xy );
|
|
1693
1692
|
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
|
|
1694
1693
|
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
|
|
1695
1694
|
return color + dither_shift_RGB;
|
|
1696
1695
|
}
|
|
1697
|
-
#endif`,
|
|
1696
|
+
#endif`,vv=`float roughnessFactor = roughness;
|
|
1698
1697
|
#ifdef USE_ROUGHNESSMAP
|
|
1699
1698
|
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
|
1700
1699
|
roughnessFactor *= texelRoughness.g;
|
|
1701
|
-
#endif`,
|
|
1700
|
+
#endif`,_v=`#ifdef USE_ROUGHNESSMAP
|
|
1702
1701
|
uniform sampler2D roughnessMap;
|
|
1703
|
-
#endif`,
|
|
1702
|
+
#endif`,xv=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
1704
1703
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
1705
1704
|
#endif
|
|
1706
1705
|
#if NUM_SPOT_LIGHT_MAPS > 0
|
|
@@ -1886,7 +1885,7 @@ gl_Position = projectionMatrix * mvPosition;`,_v=`#ifdef DITHERING
|
|
|
1886
1885
|
}
|
|
1887
1886
|
return mix( 1.0, shadow, shadowIntensity );
|
|
1888
1887
|
}
|
|
1889
|
-
#endif`,
|
|
1888
|
+
#endif`,yv=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
1890
1889
|
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
|
|
1891
1890
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
1892
1891
|
#endif
|
|
@@ -1927,7 +1926,7 @@ gl_Position = projectionMatrix * mvPosition;`,_v=`#ifdef DITHERING
|
|
|
1927
1926
|
};
|
|
1928
1927
|
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
1929
1928
|
#endif
|
|
1930
|
-
#endif`,
|
|
1929
|
+
#endif`,Mv=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
|
|
1931
1930
|
vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
|
1932
1931
|
vec4 shadowWorldPosition;
|
|
1933
1932
|
#endif
|
|
@@ -1959,7 +1958,7 @@ gl_Position = projectionMatrix * mvPosition;`,_v=`#ifdef DITHERING
|
|
|
1959
1958
|
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
|
|
1960
1959
|
}
|
|
1961
1960
|
#pragma unroll_loop_end
|
|
1962
|
-
#endif`,
|
|
1961
|
+
#endif`,bv=`float getShadowMask() {
|
|
1963
1962
|
float shadow = 1.0;
|
|
1964
1963
|
#ifdef USE_SHADOWMAP
|
|
1965
1964
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
@@ -1991,12 +1990,12 @@ gl_Position = projectionMatrix * mvPosition;`,_v=`#ifdef DITHERING
|
|
|
1991
1990
|
#endif
|
|
1992
1991
|
#endif
|
|
1993
1992
|
return shadow;
|
|
1994
|
-
}`,
|
|
1993
|
+
}`,Sv=`#ifdef USE_SKINNING
|
|
1995
1994
|
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
|
1996
1995
|
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
|
1997
1996
|
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
|
1998
1997
|
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
|
1999
|
-
#endif`,
|
|
1998
|
+
#endif`,wv=`#ifdef USE_SKINNING
|
|
2000
1999
|
uniform mat4 bindMatrix;
|
|
2001
2000
|
uniform mat4 bindMatrixInverse;
|
|
2002
2001
|
uniform highp sampler2D boneTexture;
|
|
@@ -2011,7 +2010,7 @@ gl_Position = projectionMatrix * mvPosition;`,_v=`#ifdef DITHERING
|
|
|
2011
2010
|
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
|
|
2012
2011
|
return mat4( v1, v2, v3, v4 );
|
|
2013
2012
|
}
|
|
2014
|
-
#endif`,
|
|
2013
|
+
#endif`,Ev=`#ifdef USE_SKINNING
|
|
2015
2014
|
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
|
|
2016
2015
|
vec4 skinned = vec4( 0.0 );
|
|
2017
2016
|
skinned += boneMatX * skinVertex * skinWeight.x;
|
|
@@ -2019,7 +2018,7 @@ gl_Position = projectionMatrix * mvPosition;`,_v=`#ifdef DITHERING
|
|
|
2019
2018
|
skinned += boneMatZ * skinVertex * skinWeight.z;
|
|
2020
2019
|
skinned += boneMatW * skinVertex * skinWeight.w;
|
|
2021
2020
|
transformed = ( bindMatrixInverse * skinned ).xyz;
|
|
2022
|
-
#endif`,
|
|
2021
|
+
#endif`,Tv=`#ifdef USE_SKINNING
|
|
2023
2022
|
mat4 skinMatrix = mat4( 0.0 );
|
|
2024
2023
|
skinMatrix += skinWeight.x * boneMatX;
|
|
2025
2024
|
skinMatrix += skinWeight.y * boneMatY;
|
|
@@ -2030,17 +2029,17 @@ gl_Position = projectionMatrix * mvPosition;`,_v=`#ifdef DITHERING
|
|
|
2030
2029
|
#ifdef USE_TANGENT
|
|
2031
2030
|
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
|
2032
2031
|
#endif
|
|
2033
|
-
#endif`,
|
|
2032
|
+
#endif`,Av=`float specularStrength;
|
|
2034
2033
|
#ifdef USE_SPECULARMAP
|
|
2035
2034
|
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
|
2036
2035
|
specularStrength = texelSpecular.r;
|
|
2037
2036
|
#else
|
|
2038
2037
|
specularStrength = 1.0;
|
|
2039
|
-
#endif`,
|
|
2038
|
+
#endif`,Cv=`#ifdef USE_SPECULARMAP
|
|
2040
2039
|
uniform sampler2D specularMap;
|
|
2041
|
-
#endif`,
|
|
2040
|
+
#endif`,Rv=`#if defined( TONE_MAPPING )
|
|
2042
2041
|
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
|
2043
|
-
#endif`,
|
|
2042
|
+
#endif`,Pv=`#ifndef saturate
|
|
2044
2043
|
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|
2045
2044
|
#endif
|
|
2046
2045
|
uniform float toneMappingExposure;
|
|
@@ -2137,7 +2136,7 @@ vec3 NeutralToneMapping( vec3 color ) {
|
|
|
2137
2136
|
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
|
|
2138
2137
|
return mix( color, vec3( newPeak ), g );
|
|
2139
2138
|
}
|
|
2140
|
-
vec3 CustomToneMapping( vec3 color ) { return color; }`,
|
|
2139
|
+
vec3 CustomToneMapping( vec3 color ) { return color; }`,Lv=`#ifdef USE_TRANSMISSION
|
|
2141
2140
|
material.transmission = transmission;
|
|
2142
2141
|
material.transmissionAlpha = 1.0;
|
|
2143
2142
|
material.thickness = thickness;
|
|
@@ -2158,7 +2157,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,kv=`#ifdef USE_TRANSMISS
|
|
|
2158
2157
|
material.attenuationColor, material.attenuationDistance );
|
|
2159
2158
|
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
|
|
2160
2159
|
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
|
|
2161
|
-
#endif`,
|
|
2160
|
+
#endif`,Dv=`#ifdef USE_TRANSMISSION
|
|
2162
2161
|
uniform float transmission;
|
|
2163
2162
|
uniform float thickness;
|
|
2164
2163
|
uniform float attenuationDistance;
|
|
@@ -2289,7 +2288,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,kv=`#ifdef USE_TRANSMISS
|
|
|
2289
2288
|
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
|
|
2290
2289
|
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
|
|
2291
2290
|
}
|
|
2292
|
-
#endif`,
|
|
2291
|
+
#endif`,Iv=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2293
2292
|
varying vec2 vUv;
|
|
2294
2293
|
#endif
|
|
2295
2294
|
#ifdef USE_MAP
|
|
@@ -2359,7 +2358,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,kv=`#ifdef USE_TRANSMISS
|
|
|
2359
2358
|
#ifdef USE_THICKNESSMAP
|
|
2360
2359
|
uniform mat3 thicknessMapTransform;
|
|
2361
2360
|
varying vec2 vThicknessMapUv;
|
|
2362
|
-
#endif`,
|
|
2361
|
+
#endif`,kv=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2363
2362
|
varying vec2 vUv;
|
|
2364
2363
|
#endif
|
|
2365
2364
|
#ifdef USE_MAP
|
|
@@ -2453,7 +2452,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,kv=`#ifdef USE_TRANSMISS
|
|
|
2453
2452
|
#ifdef USE_THICKNESSMAP
|
|
2454
2453
|
uniform mat3 thicknessMapTransform;
|
|
2455
2454
|
varying vec2 vThicknessMapUv;
|
|
2456
|
-
#endif`,
|
|
2455
|
+
#endif`,Nv=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2457
2456
|
vUv = vec3( uv, 1 ).xy;
|
|
2458
2457
|
#endif
|
|
2459
2458
|
#ifdef USE_MAP
|
|
@@ -2524,7 +2523,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,kv=`#ifdef USE_TRANSMISS
|
|
|
2524
2523
|
#endif
|
|
2525
2524
|
#ifdef USE_THICKNESSMAP
|
|
2526
2525
|
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
|
|
2527
|
-
#endif`,
|
|
2526
|
+
#endif`,Uv=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
|
|
2528
2527
|
vec4 worldPosition = vec4( transformed, 1.0 );
|
|
2529
2528
|
#ifdef USE_BATCHING
|
|
2530
2529
|
worldPosition = batchingMatrix * worldPosition;
|
|
@@ -2533,12 +2532,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,kv=`#ifdef USE_TRANSMISS
|
|
|
2533
2532
|
worldPosition = instanceMatrix * worldPosition;
|
|
2534
2533
|
#endif
|
|
2535
2534
|
worldPosition = modelMatrix * worldPosition;
|
|
2536
|
-
#endif`;const
|
|
2535
|
+
#endif`;const Ov=`varying vec2 vUv;
|
|
2537
2536
|
uniform mat3 uvTransform;
|
|
2538
2537
|
void main() {
|
|
2539
2538
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
2540
2539
|
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
|
2541
|
-
}`,
|
|
2540
|
+
}`,Fv=`uniform sampler2D t2D;
|
|
2542
2541
|
uniform float backgroundIntensity;
|
|
2543
2542
|
varying vec2 vUv;
|
|
2544
2543
|
void main() {
|
|
@@ -2550,14 +2549,14 @@ void main() {
|
|
|
2550
2549
|
gl_FragColor = texColor;
|
|
2551
2550
|
#include <tonemapping_fragment>
|
|
2552
2551
|
#include <colorspace_fragment>
|
|
2553
|
-
}`,
|
|
2552
|
+
}`,zv=`varying vec3 vWorldDirection;
|
|
2554
2553
|
#include <common>
|
|
2555
2554
|
void main() {
|
|
2556
2555
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2557
2556
|
#include <begin_vertex>
|
|
2558
2557
|
#include <project_vertex>
|
|
2559
2558
|
gl_Position.z = gl_Position.w;
|
|
2560
|
-
}`,
|
|
2559
|
+
}`,Bv=`#ifdef ENVMAP_TYPE_CUBE
|
|
2561
2560
|
uniform samplerCube envMap;
|
|
2562
2561
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
2563
2562
|
uniform sampler2D envMap;
|
|
@@ -2580,14 +2579,14 @@ void main() {
|
|
|
2580
2579
|
gl_FragColor = texColor;
|
|
2581
2580
|
#include <tonemapping_fragment>
|
|
2582
2581
|
#include <colorspace_fragment>
|
|
2583
|
-
}
|
|
2582
|
+
}`,Hv=`varying vec3 vWorldDirection;
|
|
2584
2583
|
#include <common>
|
|
2585
2584
|
void main() {
|
|
2586
2585
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2587
2586
|
#include <begin_vertex>
|
|
2588
2587
|
#include <project_vertex>
|
|
2589
2588
|
gl_Position.z = gl_Position.w;
|
|
2590
|
-
}`,
|
|
2589
|
+
}`,Vv=`uniform samplerCube tCube;
|
|
2591
2590
|
uniform float tFlip;
|
|
2592
2591
|
uniform float opacity;
|
|
2593
2592
|
varying vec3 vWorldDirection;
|
|
@@ -2597,7 +2596,7 @@ void main() {
|
|
|
2597
2596
|
gl_FragColor.a *= opacity;
|
|
2598
2597
|
#include <tonemapping_fragment>
|
|
2599
2598
|
#include <colorspace_fragment>
|
|
2600
|
-
}`,
|
|
2599
|
+
}`,Gv=`#include <common>
|
|
2601
2600
|
#include <batching_pars_vertex>
|
|
2602
2601
|
#include <uv_pars_vertex>
|
|
2603
2602
|
#include <displacementmap_pars_vertex>
|
|
@@ -2624,7 +2623,7 @@ void main() {
|
|
|
2624
2623
|
#include <logdepthbuf_vertex>
|
|
2625
2624
|
#include <clipping_planes_vertex>
|
|
2626
2625
|
vHighPrecisionZW = gl_Position.zw;
|
|
2627
|
-
}
|
|
2626
|
+
}`,$v=`#if DEPTH_PACKING == 3200
|
|
2628
2627
|
uniform float opacity;
|
|
2629
2628
|
#endif
|
|
2630
2629
|
#include <common>
|
|
@@ -2658,7 +2657,7 @@ void main() {
|
|
|
2658
2657
|
#elif DEPTH_PACKING == 3203
|
|
2659
2658
|
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
|
|
2660
2659
|
#endif
|
|
2661
|
-
}`,
|
|
2660
|
+
}`,Wv=`#define DISTANCE
|
|
2662
2661
|
varying vec3 vWorldPosition;
|
|
2663
2662
|
#include <common>
|
|
2664
2663
|
#include <batching_pars_vertex>
|
|
@@ -2685,7 +2684,7 @@ void main() {
|
|
|
2685
2684
|
#include <worldpos_vertex>
|
|
2686
2685
|
#include <clipping_planes_vertex>
|
|
2687
2686
|
vWorldPosition = worldPosition.xyz;
|
|
2688
|
-
}`,
|
|
2687
|
+
}`,Xv=`#define DISTANCE
|
|
2689
2688
|
uniform vec3 referencePosition;
|
|
2690
2689
|
uniform float nearDistance;
|
|
2691
2690
|
uniform float farDistance;
|
|
@@ -2709,13 +2708,13 @@ void main () {
|
|
|
2709
2708
|
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
|
2710
2709
|
dist = saturate( dist );
|
|
2711
2710
|
gl_FragColor = packDepthToRGBA( dist );
|
|
2712
|
-
}`,
|
|
2711
|
+
}`,jv=`varying vec3 vWorldDirection;
|
|
2713
2712
|
#include <common>
|
|
2714
2713
|
void main() {
|
|
2715
2714
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2716
2715
|
#include <begin_vertex>
|
|
2717
2716
|
#include <project_vertex>
|
|
2718
|
-
}`,
|
|
2717
|
+
}`,qv=`uniform sampler2D tEquirect;
|
|
2719
2718
|
varying vec3 vWorldDirection;
|
|
2720
2719
|
#include <common>
|
|
2721
2720
|
void main() {
|
|
@@ -2724,7 +2723,7 @@ void main() {
|
|
|
2724
2723
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
2725
2724
|
#include <tonemapping_fragment>
|
|
2726
2725
|
#include <colorspace_fragment>
|
|
2727
|
-
}`,
|
|
2726
|
+
}`,Yv=`uniform float scale;
|
|
2728
2727
|
attribute float lineDistance;
|
|
2729
2728
|
varying float vLineDistance;
|
|
2730
2729
|
#include <common>
|
|
@@ -2746,7 +2745,7 @@ void main() {
|
|
|
2746
2745
|
#include <logdepthbuf_vertex>
|
|
2747
2746
|
#include <clipping_planes_vertex>
|
|
2748
2747
|
#include <fog_vertex>
|
|
2749
|
-
}`,
|
|
2748
|
+
}`,Kv=`uniform vec3 diffuse;
|
|
2750
2749
|
uniform float opacity;
|
|
2751
2750
|
uniform float dashSize;
|
|
2752
2751
|
uniform float totalSize;
|
|
@@ -2774,7 +2773,7 @@ void main() {
|
|
|
2774
2773
|
#include <colorspace_fragment>
|
|
2775
2774
|
#include <fog_fragment>
|
|
2776
2775
|
#include <premultiplied_alpha_fragment>
|
|
2777
|
-
}`,
|
|
2776
|
+
}`,Zv=`#include <common>
|
|
2778
2777
|
#include <batching_pars_vertex>
|
|
2779
2778
|
#include <uv_pars_vertex>
|
|
2780
2779
|
#include <envmap_pars_vertex>
|
|
@@ -2806,7 +2805,7 @@ void main() {
|
|
|
2806
2805
|
#include <worldpos_vertex>
|
|
2807
2806
|
#include <envmap_vertex>
|
|
2808
2807
|
#include <fog_vertex>
|
|
2809
|
-
}`,
|
|
2808
|
+
}`,Jv=`uniform vec3 diffuse;
|
|
2810
2809
|
uniform float opacity;
|
|
2811
2810
|
#ifndef FLAT_SHADED
|
|
2812
2811
|
varying vec3 vNormal;
|
|
@@ -2854,7 +2853,7 @@ void main() {
|
|
|
2854
2853
|
#include <fog_fragment>
|
|
2855
2854
|
#include <premultiplied_alpha_fragment>
|
|
2856
2855
|
#include <dithering_fragment>
|
|
2857
|
-
}`,
|
|
2856
|
+
}`,Qv=`#define LAMBERT
|
|
2858
2857
|
varying vec3 vViewPosition;
|
|
2859
2858
|
#include <common>
|
|
2860
2859
|
#include <batching_pars_vertex>
|
|
@@ -2893,7 +2892,7 @@ void main() {
|
|
|
2893
2892
|
#include <envmap_vertex>
|
|
2894
2893
|
#include <shadowmap_vertex>
|
|
2895
2894
|
#include <fog_vertex>
|
|
2896
|
-
}`,
|
|
2895
|
+
}`,t_=`#define LAMBERT
|
|
2897
2896
|
uniform vec3 diffuse;
|
|
2898
2897
|
uniform vec3 emissive;
|
|
2899
2898
|
uniform float opacity;
|
|
@@ -2950,7 +2949,7 @@ void main() {
|
|
|
2950
2949
|
#include <fog_fragment>
|
|
2951
2950
|
#include <premultiplied_alpha_fragment>
|
|
2952
2951
|
#include <dithering_fragment>
|
|
2953
|
-
}`,
|
|
2952
|
+
}`,e_=`#define MATCAP
|
|
2954
2953
|
varying vec3 vViewPosition;
|
|
2955
2954
|
#include <common>
|
|
2956
2955
|
#include <batching_pars_vertex>
|
|
@@ -2984,7 +2983,7 @@ void main() {
|
|
|
2984
2983
|
#include <clipping_planes_vertex>
|
|
2985
2984
|
#include <fog_vertex>
|
|
2986
2985
|
vViewPosition = - mvPosition.xyz;
|
|
2987
|
-
}`,
|
|
2986
|
+
}`,n_=`#define MATCAP
|
|
2988
2987
|
uniform vec3 diffuse;
|
|
2989
2988
|
uniform float opacity;
|
|
2990
2989
|
uniform sampler2D matcap;
|
|
@@ -3030,7 +3029,7 @@ void main() {
|
|
|
3030
3029
|
#include <fog_fragment>
|
|
3031
3030
|
#include <premultiplied_alpha_fragment>
|
|
3032
3031
|
#include <dithering_fragment>
|
|
3033
|
-
}`,
|
|
3032
|
+
}`,i_=`#define NORMAL
|
|
3034
3033
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3035
3034
|
varying vec3 vViewPosition;
|
|
3036
3035
|
#endif
|
|
@@ -3063,7 +3062,7 @@ void main() {
|
|
|
3063
3062
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3064
3063
|
vViewPosition = - mvPosition.xyz;
|
|
3065
3064
|
#endif
|
|
3066
|
-
}`,
|
|
3065
|
+
}`,s_=`#define NORMAL
|
|
3067
3066
|
uniform float opacity;
|
|
3068
3067
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3069
3068
|
varying vec3 vViewPosition;
|
|
@@ -3085,7 +3084,7 @@ void main() {
|
|
|
3085
3084
|
#ifdef OPAQUE
|
|
3086
3085
|
gl_FragColor.a = 1.0;
|
|
3087
3086
|
#endif
|
|
3088
|
-
}`,
|
|
3087
|
+
}`,r_=`#define PHONG
|
|
3089
3088
|
varying vec3 vViewPosition;
|
|
3090
3089
|
#include <common>
|
|
3091
3090
|
#include <batching_pars_vertex>
|
|
@@ -3124,7 +3123,7 @@ void main() {
|
|
|
3124
3123
|
#include <envmap_vertex>
|
|
3125
3124
|
#include <shadowmap_vertex>
|
|
3126
3125
|
#include <fog_vertex>
|
|
3127
|
-
}`,
|
|
3126
|
+
}`,a_=`#define PHONG
|
|
3128
3127
|
uniform vec3 diffuse;
|
|
3129
3128
|
uniform vec3 emissive;
|
|
3130
3129
|
uniform vec3 specular;
|
|
@@ -3183,7 +3182,7 @@ void main() {
|
|
|
3183
3182
|
#include <fog_fragment>
|
|
3184
3183
|
#include <premultiplied_alpha_fragment>
|
|
3185
3184
|
#include <dithering_fragment>
|
|
3186
|
-
}`,
|
|
3185
|
+
}`,o_=`#define STANDARD
|
|
3187
3186
|
varying vec3 vViewPosition;
|
|
3188
3187
|
#ifdef USE_TRANSMISSION
|
|
3189
3188
|
varying vec3 vWorldPosition;
|
|
@@ -3226,7 +3225,7 @@ void main() {
|
|
|
3226
3225
|
#ifdef USE_TRANSMISSION
|
|
3227
3226
|
vWorldPosition = worldPosition.xyz;
|
|
3228
3227
|
#endif
|
|
3229
|
-
}`,
|
|
3228
|
+
}`,l_=`#define STANDARD
|
|
3230
3229
|
#ifdef PHYSICAL
|
|
3231
3230
|
#define IOR
|
|
3232
3231
|
#define USE_SPECULAR
|
|
@@ -3351,7 +3350,7 @@ void main() {
|
|
|
3351
3350
|
#include <fog_fragment>
|
|
3352
3351
|
#include <premultiplied_alpha_fragment>
|
|
3353
3352
|
#include <dithering_fragment>
|
|
3354
|
-
}`,
|
|
3353
|
+
}`,c_=`#define TOON
|
|
3355
3354
|
varying vec3 vViewPosition;
|
|
3356
3355
|
#include <common>
|
|
3357
3356
|
#include <batching_pars_vertex>
|
|
@@ -3388,7 +3387,7 @@ void main() {
|
|
|
3388
3387
|
#include <worldpos_vertex>
|
|
3389
3388
|
#include <shadowmap_vertex>
|
|
3390
3389
|
#include <fog_vertex>
|
|
3391
|
-
}`,
|
|
3390
|
+
}`,h_=`#define TOON
|
|
3392
3391
|
uniform vec3 diffuse;
|
|
3393
3392
|
uniform vec3 emissive;
|
|
3394
3393
|
uniform float opacity;
|
|
@@ -3441,7 +3440,7 @@ void main() {
|
|
|
3441
3440
|
#include <fog_fragment>
|
|
3442
3441
|
#include <premultiplied_alpha_fragment>
|
|
3443
3442
|
#include <dithering_fragment>
|
|
3444
|
-
}`,
|
|
3443
|
+
}`,u_=`uniform float size;
|
|
3445
3444
|
uniform float scale;
|
|
3446
3445
|
#include <common>
|
|
3447
3446
|
#include <color_pars_vertex>
|
|
@@ -3472,7 +3471,7 @@ void main() {
|
|
|
3472
3471
|
#include <clipping_planes_vertex>
|
|
3473
3472
|
#include <worldpos_vertex>
|
|
3474
3473
|
#include <fog_vertex>
|
|
3475
|
-
}`,
|
|
3474
|
+
}`,d_=`uniform vec3 diffuse;
|
|
3476
3475
|
uniform float opacity;
|
|
3477
3476
|
#include <common>
|
|
3478
3477
|
#include <color_pars_fragment>
|
|
@@ -3497,7 +3496,7 @@ void main() {
|
|
|
3497
3496
|
#include <colorspace_fragment>
|
|
3498
3497
|
#include <fog_fragment>
|
|
3499
3498
|
#include <premultiplied_alpha_fragment>
|
|
3500
|
-
}`,
|
|
3499
|
+
}`,f_=`#include <common>
|
|
3501
3500
|
#include <batching_pars_vertex>
|
|
3502
3501
|
#include <fog_pars_vertex>
|
|
3503
3502
|
#include <morphtarget_pars_vertex>
|
|
@@ -3520,7 +3519,7 @@ void main() {
|
|
|
3520
3519
|
#include <worldpos_vertex>
|
|
3521
3520
|
#include <shadowmap_vertex>
|
|
3522
3521
|
#include <fog_vertex>
|
|
3523
|
-
}`,
|
|
3522
|
+
}`,p_=`uniform vec3 color;
|
|
3524
3523
|
uniform float opacity;
|
|
3525
3524
|
#include <common>
|
|
3526
3525
|
#include <packing>
|
|
@@ -3536,7 +3535,7 @@ void main() {
|
|
|
3536
3535
|
#include <tonemapping_fragment>
|
|
3537
3536
|
#include <colorspace_fragment>
|
|
3538
3537
|
#include <fog_fragment>
|
|
3539
|
-
}`,
|
|
3538
|
+
}`,m_=`uniform float rotation;
|
|
3540
3539
|
uniform vec2 center;
|
|
3541
3540
|
#include <common>
|
|
3542
3541
|
#include <uv_pars_vertex>
|
|
@@ -3560,7 +3559,7 @@ void main() {
|
|
|
3560
3559
|
#include <logdepthbuf_vertex>
|
|
3561
3560
|
#include <clipping_planes_vertex>
|
|
3562
3561
|
#include <fog_vertex>
|
|
3563
|
-
}`,
|
|
3562
|
+
}`,g_=`uniform vec3 diffuse;
|
|
3564
3563
|
uniform float opacity;
|
|
3565
3564
|
#include <common>
|
|
3566
3565
|
#include <uv_pars_fragment>
|
|
@@ -3585,7 +3584,7 @@ void main() {
|
|
|
3585
3584
|
#include <tonemapping_fragment>
|
|
3586
3585
|
#include <colorspace_fragment>
|
|
3587
3586
|
#include <fog_fragment>
|
|
3588
|
-
}`,Wt={alphahash_fragment:H0,alphahash_pars_fragment:V0,alphamap_fragment:G0,alphamap_pars_fragment:$0,alphatest_fragment:W0,alphatest_pars_fragment:X0,aomap_fragment:j0,aomap_pars_fragment:q0,batching_pars_vertex:Y0,batching_vertex:K0,begin_vertex:Z0,beginnormal_vertex:J0,bsdfs:Q0,iridescence_fragment:tg,bumpmap_pars_fragment:eg,clipping_planes_fragment:ng,clipping_planes_pars_fragment:ig,clipping_planes_pars_vertex:sg,clipping_planes_vertex:rg,color_fragment:ag,color_pars_fragment:og,color_pars_vertex:lg,color_vertex:cg,common:hg,cube_uv_reflection_fragment:ug,defaultnormal_vertex:dg,displacementmap_pars_vertex:fg,displacementmap_vertex:pg,emissivemap_fragment:mg,emissivemap_pars_fragment:gg,colorspace_fragment:vg,colorspace_pars_fragment:_g,envmap_fragment:xg,envmap_common_pars_fragment:yg,envmap_pars_fragment:Mg,envmap_pars_vertex:bg,envmap_physical_pars_fragment:Ig,envmap_vertex:Sg,fog_vertex:wg,fog_pars_vertex:Eg,fog_fragment:Tg,fog_pars_fragment:Ag,gradientmap_pars_fragment:Cg,lightmap_pars_fragment:Rg,lights_lambert_fragment:Pg,lights_lambert_pars_fragment:Lg,lights_pars_begin:Dg,lights_toon_fragment:kg,lights_toon_pars_fragment:Ng,lights_phong_fragment:Ug,lights_phong_pars_fragment:Og,lights_physical_fragment:Fg,lights_physical_pars_fragment:zg,lights_fragment_begin:Bg,lights_fragment_maps:Hg,lights_fragment_end:Vg,logdepthbuf_fragment:Gg,logdepthbuf_pars_fragment:$g,logdepthbuf_pars_vertex:Wg,logdepthbuf_vertex:Xg,map_fragment:jg,map_pars_fragment:qg,map_particle_fragment:Yg,map_particle_pars_fragment:Kg,metalnessmap_fragment:Zg,metalnessmap_pars_fragment:Jg,morphinstance_vertex:Qg,morphcolor_vertex:tv,morphnormal_vertex:ev,morphtarget_pars_vertex:nv,morphtarget_vertex:iv,normal_fragment_begin:sv,normal_fragment_maps:rv,normal_pars_fragment:av,normal_pars_vertex:ov,normal_vertex:lv,normalmap_pars_fragment:cv,clearcoat_normal_fragment_begin:hv,clearcoat_normal_fragment_maps:uv,clearcoat_pars_fragment:dv,iridescence_pars_fragment:fv,opaque_fragment:pv,packing:mv,premultiplied_alpha_fragment:gv,project_vertex:vv,dithering_fragment:_v,dithering_pars_fragment:xv,roughnessmap_fragment:yv,roughnessmap_pars_fragment:Mv,shadowmap_pars_fragment:bv,shadowmap_pars_vertex:Sv,shadowmap_vertex:wv,shadowmask_pars_fragment:Ev,skinbase_vertex:Tv,skinning_pars_vertex:Av,skinning_vertex:Cv,skinnormal_vertex:Rv,specularmap_fragment:Pv,specularmap_pars_fragment:Lv,tonemapping_fragment:Dv,tonemapping_pars_fragment:Iv,transmission_fragment:kv,transmission_pars_fragment:Nv,uv_pars_fragment:Uv,uv_pars_vertex:Ov,uv_vertex:Fv,worldpos_vertex:zv,background_vert:Bv,background_frag:Hv,backgroundCube_vert:Vv,backgroundCube_frag:Gv,cube_vert:$v,cube_frag:Wv,depth_vert:Xv,depth_frag:jv,distanceRGBA_vert:qv,distanceRGBA_frag:Yv,equirect_vert:Kv,equirect_frag:Zv,linedashed_vert:Jv,linedashed_frag:Qv,meshbasic_vert:t_,meshbasic_frag:e_,meshlambert_vert:n_,meshlambert_frag:i_,meshmatcap_vert:s_,meshmatcap_frag:r_,meshnormal_vert:a_,meshnormal_frag:o_,meshphong_vert:l_,meshphong_frag:c_,meshphysical_vert:h_,meshphysical_frag:u_,meshtoon_vert:d_,meshtoon_frag:f_,points_vert:p_,points_frag:m_,shadow_vert:g_,shadow_frag:v_,sprite_vert:__,sprite_frag:x_},ut={common:{diffuse:{value:new Zt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Xt},alphaMap:{value:null},alphaMapTransform:{value:new Xt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Xt}},envmap:{envMap:{value:null},envMapRotation:{value:new Xt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Xt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Xt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Xt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Xt},normalScale:{value:new rt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Xt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Xt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Xt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Xt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Zt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Zt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Xt},alphaTest:{value:0},uvTransform:{value:new Xt}},sprite:{diffuse:{value:new Zt(16777215)},opacity:{value:1},center:{value:new rt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Xt},alphaMap:{value:null},alphaMapTransform:{value:new Xt},alphaTest:{value:0}}},ai={basic:{uniforms:ln([ut.common,ut.specularmap,ut.envmap,ut.aomap,ut.lightmap,ut.fog]),vertexShader:Wt.meshbasic_vert,fragmentShader:Wt.meshbasic_frag},lambert:{uniforms:ln([ut.common,ut.specularmap,ut.envmap,ut.aomap,ut.lightmap,ut.emissivemap,ut.bumpmap,ut.normalmap,ut.displacementmap,ut.fog,ut.lights,{emissive:{value:new Zt(0)}}]),vertexShader:Wt.meshlambert_vert,fragmentShader:Wt.meshlambert_frag},phong:{uniforms:ln([ut.common,ut.specularmap,ut.envmap,ut.aomap,ut.lightmap,ut.emissivemap,ut.bumpmap,ut.normalmap,ut.displacementmap,ut.fog,ut.lights,{emissive:{value:new Zt(0)},specular:{value:new Zt(1118481)},shininess:{value:30}}]),vertexShader:Wt.meshphong_vert,fragmentShader:Wt.meshphong_frag},standard:{uniforms:ln([ut.common,ut.envmap,ut.aomap,ut.lightmap,ut.emissivemap,ut.bumpmap,ut.normalmap,ut.displacementmap,ut.roughnessmap,ut.metalnessmap,ut.fog,ut.lights,{emissive:{value:new Zt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Wt.meshphysical_vert,fragmentShader:Wt.meshphysical_frag},toon:{uniforms:ln([ut.common,ut.aomap,ut.lightmap,ut.emissivemap,ut.bumpmap,ut.normalmap,ut.displacementmap,ut.gradientmap,ut.fog,ut.lights,{emissive:{value:new Zt(0)}}]),vertexShader:Wt.meshtoon_vert,fragmentShader:Wt.meshtoon_frag},matcap:{uniforms:ln([ut.common,ut.bumpmap,ut.normalmap,ut.displacementmap,ut.fog,{matcap:{value:null}}]),vertexShader:Wt.meshmatcap_vert,fragmentShader:Wt.meshmatcap_frag},points:{uniforms:ln([ut.points,ut.fog]),vertexShader:Wt.points_vert,fragmentShader:Wt.points_frag},dashed:{uniforms:ln([ut.common,ut.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Wt.linedashed_vert,fragmentShader:Wt.linedashed_frag},depth:{uniforms:ln([ut.common,ut.displacementmap]),vertexShader:Wt.depth_vert,fragmentShader:Wt.depth_frag},normal:{uniforms:ln([ut.common,ut.bumpmap,ut.normalmap,ut.displacementmap,{opacity:{value:1}}]),vertexShader:Wt.meshnormal_vert,fragmentShader:Wt.meshnormal_frag},sprite:{uniforms:ln([ut.sprite,ut.fog]),vertexShader:Wt.sprite_vert,fragmentShader:Wt.sprite_frag},background:{uniforms:{uvTransform:{value:new Xt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Wt.background_vert,fragmentShader:Wt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Xt}},vertexShader:Wt.backgroundCube_vert,fragmentShader:Wt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Wt.cube_vert,fragmentShader:Wt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Wt.equirect_vert,fragmentShader:Wt.equirect_frag},distanceRGBA:{uniforms:ln([ut.common,ut.displacementmap,{referencePosition:{value:new R},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Wt.distanceRGBA_vert,fragmentShader:Wt.distanceRGBA_frag},shadow:{uniforms:ln([ut.lights,ut.fog,{color:{value:new Zt(0)},opacity:{value:1}}]),vertexShader:Wt.shadow_vert,fragmentShader:Wt.shadow_frag}};ai.physical={uniforms:ln([ai.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Xt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Xt},clearcoatNormalScale:{value:new rt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Xt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Xt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Xt},sheen:{value:0},sheenColor:{value:new Zt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Xt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Xt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Xt},transmissionSamplerSize:{value:new rt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Xt},attenuationDistance:{value:0},attenuationColor:{value:new Zt(0)},specularColor:{value:new Zt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Xt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Xt},anisotropyVector:{value:new rt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Xt}}]),vertexShader:Wt.meshphysical_vert,fragmentShader:Wt.meshphysical_frag};const Da={r:0,b:0,g:0},ms=new mi,y_=new fe;function M_(i,t,e,n,s,r,a){const o=new Zt(0);let l=r===!0?0:1,c,h,u=null,d=0,f=null;function g(y){let x=y.isScene===!0?y.background:null;return x&&x.isTexture&&(x=(y.backgroundBlurriness>0?e:t).get(x)),x}function _(y){let x=!1;const S=g(y);S===null?p(o,l):S&&S.isColor&&(p(S,1),x=!0);const L=i.xr.getEnvironmentBlendMode();L==="additive"?n.buffers.color.setClear(0,0,0,1,a):L==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||x)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function m(y,x){const S=g(x);S&&(S.isCubeTexture||S.mapping===Uo)?(h===void 0&&(h=new yt(new Ze(1,1,1),new nn({name:"BackgroundCubeMaterial",uniforms:br(ai.backgroundCube.uniforms),vertexShader:ai.backgroundCube.vertexShader,fragmentShader:ai.backgroundCube.fragmentShader,side:un,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(L,T,E){this.matrixWorld.copyPosition(E.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(h)),ms.copy(x.backgroundRotation),ms.x*=-1,ms.y*=-1,ms.z*=-1,S.isCubeTexture&&S.isRenderTargetTexture===!1&&(ms.y*=-1,ms.z*=-1),h.material.uniforms.envMap.value=S,h.material.uniforms.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=x.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(y_.makeRotationFromEuler(ms)),h.material.toneMapped=oe.getTransfer(S.colorSpace)!==ye,(u!==S||d!==S.version||f!==i.toneMapping)&&(h.material.needsUpdate=!0,u=S,d=S.version,f=i.toneMapping),h.layers.enableAll(),y.unshift(h,h.geometry,h.material,0,0,null)):S&&S.isTexture&&(c===void 0&&(c=new yt(new gi(2,2),new nn({name:"BackgroundMaterial",uniforms:br(ai.background.uniforms),vertexShader:ai.background.vertexShader,fragmentShader:ai.background.fragmentShader,side:os,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(c)),c.material.uniforms.t2D.value=S,c.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,c.material.toneMapped=oe.getTransfer(S.colorSpace)!==ye,S.matrixAutoUpdate===!0&&S.updateMatrix(),c.material.uniforms.uvTransform.value.copy(S.matrix),(u!==S||d!==S.version||f!==i.toneMapping)&&(c.material.needsUpdate=!0,u=S,d=S.version,f=i.toneMapping),c.layers.enableAll(),y.unshift(c,c.geometry,c.material,0,0,null))}function p(y,x){y.getRGB(Da,Bf(i)),n.buffers.color.setClear(Da.r,Da.g,Da.b,x,a)}return{getClearColor:function(){return o},setClearColor:function(y,x=1){o.set(y),l=x,p(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(y){l=y,p(o,l)},render:_,addToRenderList:m}}function b_(i,t){const e=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=d(null);let r=s,a=!1;function o(v,b,I,O,$){let K=!1;const z=u(O,I,b);r!==z&&(r=z,c(r.object)),K=f(v,O,I,$),K&&g(v,O,I,$),$!==null&&t.update($,i.ELEMENT_ARRAY_BUFFER),(K||a)&&(a=!1,S(v,b,I,O),$!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t.get($).buffer))}function l(){return i.createVertexArray()}function c(v){return i.bindVertexArray(v)}function h(v){return i.deleteVertexArray(v)}function u(v,b,I){const O=I.wireframe===!0;let $=n[v.id];$===void 0&&($={},n[v.id]=$);let K=$[b.id];K===void 0&&(K={},$[b.id]=K);let z=K[O];return z===void 0&&(z=d(l()),K[O]=z),z}function d(v){const b=[],I=[],O=[];for(let $=0;$<e;$++)b[$]=0,I[$]=0,O[$]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:b,enabledAttributes:I,attributeDivisors:O,object:v,attributes:{},index:null}}function f(v,b,I,O){const $=r.attributes,K=b.attributes;let z=0;const Z=I.getAttributes();for(const V in Z)if(Z[V].location>=0){const ct=$[V];let _t=K[V];if(_t===void 0&&(V==="instanceMatrix"&&v.instanceMatrix&&(_t=v.instanceMatrix),V==="instanceColor"&&v.instanceColor&&(_t=v.instanceColor)),ct===void 0||ct.attribute!==_t||_t&&ct.data!==_t.data)return!0;z++}return r.attributesNum!==z||r.index!==O}function g(v,b,I,O){const $={},K=b.attributes;let z=0;const Z=I.getAttributes();for(const V in Z)if(Z[V].location>=0){let ct=K[V];ct===void 0&&(V==="instanceMatrix"&&v.instanceMatrix&&(ct=v.instanceMatrix),V==="instanceColor"&&v.instanceColor&&(ct=v.instanceColor));const _t={};_t.attribute=ct,ct&&ct.data&&(_t.data=ct.data),$[V]=_t,z++}r.attributes=$,r.attributesNum=z,r.index=O}function _(){const v=r.newAttributes;for(let b=0,I=v.length;b<I;b++)v[b]=0}function m(v){p(v,0)}function p(v,b){const I=r.newAttributes,O=r.enabledAttributes,$=r.attributeDivisors;I[v]=1,O[v]===0&&(i.enableVertexAttribArray(v),O[v]=1),$[v]!==b&&(i.vertexAttribDivisor(v,b),$[v]=b)}function y(){const v=r.newAttributes,b=r.enabledAttributes;for(let I=0,O=b.length;I<O;I++)b[I]!==v[I]&&(i.disableVertexAttribArray(I),b[I]=0)}function x(v,b,I,O,$,K,z){z===!0?i.vertexAttribIPointer(v,b,I,$,K):i.vertexAttribPointer(v,b,I,O,$,K)}function S(v,b,I,O){_();const $=O.attributes,K=I.getAttributes(),z=b.defaultAttributeValues;for(const Z in K){const V=K[Z];if(V.location>=0){let at=$[Z];if(at===void 0&&(Z==="instanceMatrix"&&v.instanceMatrix&&(at=v.instanceMatrix),Z==="instanceColor"&&v.instanceColor&&(at=v.instanceColor)),at!==void 0){const ct=at.normalized,_t=at.itemSize,$t=t.get(at);if($t===void 0)continue;const Jt=$t.buffer,X=$t.type,et=$t.bytesPerElement,ft=X===i.INT||X===i.UNSIGNED_INT||at.gpuType===uh;if(at.isInterleavedBufferAttribute){const ot=at.data,At=ot.stride,Tt=at.offset;if(ot.isInstancedInterleavedBuffer){for(let zt=0;zt<V.locationSize;zt++)p(V.location+zt,ot.meshPerAttribute);v.isInstancedMesh!==!0&&O._maxInstanceCount===void 0&&(O._maxInstanceCount=ot.meshPerAttribute*ot.count)}else for(let zt=0;zt<V.locationSize;zt++)m(V.location+zt);i.bindBuffer(i.ARRAY_BUFFER,Jt);for(let zt=0;zt<V.locationSize;zt++)x(V.location+zt,_t/V.locationSize,X,ct,At*et,(Tt+_t/V.locationSize*zt)*et,ft)}else{if(at.isInstancedBufferAttribute){for(let ot=0;ot<V.locationSize;ot++)p(V.location+ot,at.meshPerAttribute);v.isInstancedMesh!==!0&&O._maxInstanceCount===void 0&&(O._maxInstanceCount=at.meshPerAttribute*at.count)}else for(let ot=0;ot<V.locationSize;ot++)m(V.location+ot);i.bindBuffer(i.ARRAY_BUFFER,Jt);for(let ot=0;ot<V.locationSize;ot++)x(V.location+ot,_t/V.locationSize,X,ct,_t*et,_t/V.locationSize*ot*et,ft)}}else if(z!==void 0){const ct=z[Z];if(ct!==void 0)switch(ct.length){case 2:i.vertexAttrib2fv(V.location,ct);break;case 3:i.vertexAttrib3fv(V.location,ct);break;case 4:i.vertexAttrib4fv(V.location,ct);break;default:i.vertexAttrib1fv(V.location,ct)}}}}y()}function L(){P();for(const v in n){const b=n[v];for(const I in b){const O=b[I];for(const $ in O)h(O[$].object),delete O[$];delete b[I]}delete n[v]}}function T(v){if(n[v.id]===void 0)return;const b=n[v.id];for(const I in b){const O=b[I];for(const $ in O)h(O[$].object),delete O[$];delete b[I]}delete n[v.id]}function E(v){for(const b in n){const I=n[b];if(I[v.id]===void 0)continue;const O=I[v.id];for(const $ in O)h(O[$].object),delete O[$];delete I[v.id]}}function P(){U(),a=!0,r!==s&&(r=s,c(r.object))}function U(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:P,resetDefaultState:U,dispose:L,releaseStatesOfGeometry:T,releaseStatesOfProgram:E,initAttributes:_,enableAttribute:m,disableUnusedAttributes:y}}function S_(i,t,e){let n;function s(c){n=c}function r(c,h){i.drawArrays(n,c,h),e.update(h,n,1)}function a(c,h,u){u!==0&&(i.drawArraysInstanced(n,c,h,u),e.update(h,n,u))}function o(c,h,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,h,0,u);let f=0;for(let g=0;g<u;g++)f+=h[g];e.update(f,n,1)}function l(c,h,u,d){if(u===0)return;const f=t.get("WEBGL_multi_draw");if(f===null)for(let g=0;g<c.length;g++)a(c[g],h[g],d[g]);else{f.multiDrawArraysInstancedWEBGL(n,c,0,h,0,d,0,u);let g=0;for(let _=0;_<u;_++)g+=h[_];for(let _=0;_<d.length;_++)e.update(g,n,d[_])}}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function w_(i,t,e,n){let s;function r(){if(s!==void 0)return s;if(t.has("EXT_texture_filter_anisotropic")===!0){const E=t.get("EXT_texture_filter_anisotropic");s=i.getParameter(E.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function a(E){return!(E!==Nn&&n.convert(E)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(E){const P=E===Ui&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(E!==pi&&n.convert(E)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&E!==Ci&&!P)}function l(E){if(E==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";E="mediump"}return E==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=e.precision!==void 0?e.precision:"highp";const h=l(c);h!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const u=e.logarithmicDepthBuffer===!0,d=e.reverseDepthBuffer===!0&&t.has("EXT_clip_control");if(d===!0){const E=t.get("EXT_clip_control");E.clipControlEXT(E.LOWER_LEFT_EXT,E.ZERO_TO_ONE_EXT)}const f=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),g=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),p=i.getParameter(i.MAX_VERTEX_ATTRIBS),y=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),x=i.getParameter(i.MAX_VARYING_VECTORS),S=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),L=g>0,T=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:u,reverseDepthBuffer:d,maxTextures:f,maxVertexTextures:g,maxTextureSize:_,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:y,maxVaryings:x,maxFragmentUniforms:S,vertexTextures:L,maxSamples:T}}function E_(i){const t=this;let e=null,n=0,s=!1,r=!1;const a=new Ki,o=new Xt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const f=u.length!==0||d||n!==0||s;return s=d,n=u.length,f},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,d){e=h(u,d,0)},this.setState=function(u,d,f){const g=u.clippingPlanes,_=u.clipIntersection,m=u.clipShadows,p=i.get(u);if(!s||g===null||g.length===0||r&&!m)r?h(null):c();else{const y=r?0:n,x=y*4;let S=p.clippingState||null;l.value=S,S=h(g,d,x,f);for(let L=0;L!==x;++L)S[L]=e[L];p.clippingState=S,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=y}};function c(){l.value!==e&&(l.value=e,l.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(u,d,f,g){const _=u!==null?u.length:0;let m=null;if(_!==0){if(m=l.value,g!==!0||m===null){const p=f+_*4,y=d.matrixWorldInverse;o.getNormalMatrix(y),(m===null||m.length<p)&&(m=new Float32Array(p));for(let x=0,S=f;x!==_;++x,S+=4)a.copy(u[x]).applyMatrix4(y,o),a.normal.toArray(m,S),m[S+3]=a.constant}l.value=m,l.needsUpdate=!0}return t.numPlanes=_,t.numIntersection=0,m}}function T_(i){let t=new WeakMap;function e(a,o){return o===_c?a.mapping=yr:o===xc&&(a.mapping=Mr),a}function n(a){if(a&&a.isTexture){const o=a.mapping;if(o===_c||o===xc)if(t.has(a)){const l=t.get(a).texture;return e(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const c=new O0(l.height);return c.fromEquirectangularTexture(i,a),t.set(a,c),a.addEventListener("dispose",s),e(c.texture,a.mapping)}else return null}}return a}function s(a){const o=a.target;o.removeEventListener("dispose",s);const l=t.get(o);l!==void 0&&(t.delete(o),l.dispose())}function r(){t=new WeakMap}return{get:n,dispose:r}}class wh extends Hf{constructor(t=-1,e=1,n=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,s,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let r=n-t,a=n+t,o=s+e,l=s-e;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}const sr=4,ku=[.125,.215,.35,.446,.526,.582],ys=20,Sl=new wh,Nu=new Zt;let wl=null,El=0,Tl=0,Al=!1;const _s=(1+Math.sqrt(5))/2,Ys=1/_s,Uu=[new R(-_s,Ys,0),new R(_s,Ys,0),new R(-Ys,0,_s),new R(Ys,0,_s),new R(0,_s,-Ys),new R(0,_s,Ys),new R(-1,1,-1),new R(1,1,-1),new R(-1,1,1),new R(1,1,1)];class jc{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,n=.1,s=100){wl=this._renderer.getRenderTarget(),El=this._renderer.getActiveCubeFace(),Tl=this._renderer.getActiveMipmapLevel(),Al=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(t,n,s,r),e>0&&this._blur(r,0,0,e),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=zu(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Fu(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(wl,El,Tl),this._renderer.xr.enabled=Al,t.scissorTest=!1,Ia(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===yr||t.mapping===Mr?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),wl=this._renderer.getRenderTarget(),El=this._renderer.getActiveCubeFace(),Tl=this._renderer.getActiveMipmapLevel(),Al=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:qn,minFilter:qn,generateMipmaps:!1,type:Ui,format:Nn,colorSpace:cs,depthBuffer:!1},s=Ou(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Ou(t,e,n);const{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=A_(r)),this._blurMaterial=C_(r,t,e)}return s}_compileMaterial(t){const e=new yt(this._lodPlanes[0],t);this._renderer.compile(e,Sl)}_sceneToCubeUV(t,e,n,s){const o=new Cn(90,1,e,n),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],h=this._renderer,u=h.autoClear,d=h.toneMapping;h.getClearColor(Nu),h.toneMapping=ss,h.autoClear=!1;const f=new dn({name:"PMREM.Background",side:un,depthWrite:!1,depthTest:!1}),g=new yt(new Ze,f);let _=!1;const m=t.background;m?m.isColor&&(f.color.copy(m),t.background=null,_=!0):(f.color.copy(Nu),_=!0);for(let p=0;p<6;p++){const y=p%3;y===0?(o.up.set(0,l[p],0),o.lookAt(c[p],0,0)):y===1?(o.up.set(0,0,l[p]),o.lookAt(0,c[p],0)):(o.up.set(0,l[p],0),o.lookAt(0,0,c[p]));const x=this._cubeSize;Ia(s,y*x,p>2?x:0,x,x),h.setRenderTarget(s),_&&h.render(g,o),h.render(t,o)}g.geometry.dispose(),g.material.dispose(),h.toneMapping=d,h.autoClear=u,t.background=m}_textureToCubeUV(t,e){const n=this._renderer,s=t.mapping===yr||t.mapping===Mr;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=zu()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Fu());const r=s?this._cubemapMaterial:this._equirectMaterial,a=new yt(this._lodPlanes[0],r),o=r.uniforms;o.envMap.value=t;const l=this._cubeSize;Ia(e,0,0,3*l,2*l),n.setRenderTarget(e),n.render(a,Sl)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const s=this._lodPlanes.length;for(let r=1;r<s;r++){const a=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),o=Uu[(s-r-1)%Uu.length];this._blur(t,r-1,r,a,o)}e.autoClear=n}_blur(t,e,n,s,r){const a=this._pingPongRenderTarget;this._halfBlur(t,a,e,n,s,"latitudinal",r),this._halfBlur(a,t,n,n,s,"longitudinal",r)}_halfBlur(t,e,n,s,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const h=3,u=new yt(this._lodPlanes[s],c),d=c.uniforms,f=this._sizeLods[n]-1,g=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*ys-1),_=r/g,m=isFinite(r)?1+Math.floor(h*_):ys;m>ys&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${ys}`);const p=[];let y=0;for(let E=0;E<ys;++E){const P=E/_,U=Math.exp(-P*P/2);p.push(U),E===0?y+=U:E<m&&(y+=2*U)}for(let E=0;E<p.length;E++)p[E]=p[E]/y;d.envMap.value=t.texture,d.samples.value=m,d.weights.value=p,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:x}=this;d.dTheta.value=g,d.mipInt.value=x-n;const S=this._sizeLods[s],L=3*S*(s>x-sr?s-x+sr:0),T=4*(this._cubeSize-S);Ia(e,L,T,3*S,2*S),l.setRenderTarget(e),l.render(u,Sl)}}function A_(i){const t=[],e=[],n=[];let s=i;const r=i-sr+1+ku.length;for(let a=0;a<r;a++){const o=Math.pow(2,s);e.push(o);let l=1/o;a>i-sr?l=ku[a-i+sr-1]:a===0&&(l=0),n.push(l);const c=1/(o-2),h=-c,u=1+c,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,g=6,_=3,m=2,p=1,y=new Float32Array(_*g*f),x=new Float32Array(m*g*f),S=new Float32Array(p*g*f);for(let T=0;T<f;T++){const E=T%3*2/3-1,P=T>2?0:-1,U=[E,P,0,E+2/3,P,0,E+2/3,P+1,0,E,P,0,E+2/3,P+1,0,E,P+1,0];y.set(U,_*g*T),x.set(d,m*g*T);const v=[T,T,T,T,T,T];S.set(v,p*g*T)}const L=new fn;L.setAttribute("position",new ui(y,_)),L.setAttribute("uv",new ui(x,m)),L.setAttribute("faceIndex",new ui(S,p)),t.push(L),s>sr&&s--}return{lodPlanes:t,sizeLods:e,sigmas:n}}function Ou(i,t,e){const n=new Qn(i,t,e);return n.texture.mapping=Uo,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Ia(i,t,e,n,s){i.viewport.set(t,e,n,s),i.scissor.set(t,e,n,s)}function C_(i,t,e){const n=new Float32Array(ys),s=new R(0,1,0);return new nn({name:"SphericalGaussianBlur",defines:{n:ys,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:Eh(),fragmentShader:`
|
|
3587
|
+
}`,Wt={alphahash_fragment:F0,alphahash_pars_fragment:z0,alphamap_fragment:B0,alphamap_pars_fragment:H0,alphatest_fragment:V0,alphatest_pars_fragment:G0,aomap_fragment:$0,aomap_pars_fragment:W0,batching_pars_vertex:X0,batching_vertex:j0,begin_vertex:q0,beginnormal_vertex:Y0,bsdfs:K0,iridescence_fragment:Z0,bumpmap_pars_fragment:J0,clipping_planes_fragment:Q0,clipping_planes_pars_fragment:tg,clipping_planes_pars_vertex:eg,clipping_planes_vertex:ng,color_fragment:ig,color_pars_fragment:sg,color_pars_vertex:rg,color_vertex:ag,common:og,cube_uv_reflection_fragment:lg,defaultnormal_vertex:cg,displacementmap_pars_vertex:hg,displacementmap_vertex:ug,emissivemap_fragment:dg,emissivemap_pars_fragment:fg,colorspace_fragment:pg,colorspace_pars_fragment:mg,envmap_fragment:gg,envmap_common_pars_fragment:vg,envmap_pars_fragment:_g,envmap_pars_vertex:xg,envmap_physical_pars_fragment:Pg,envmap_vertex:yg,fog_vertex:Mg,fog_pars_vertex:bg,fog_fragment:Sg,fog_pars_fragment:wg,gradientmap_pars_fragment:Eg,lightmap_pars_fragment:Tg,lights_lambert_fragment:Ag,lights_lambert_pars_fragment:Cg,lights_pars_begin:Rg,lights_toon_fragment:Lg,lights_toon_pars_fragment:Dg,lights_phong_fragment:Ig,lights_phong_pars_fragment:kg,lights_physical_fragment:Ng,lights_physical_pars_fragment:Ug,lights_fragment_begin:Og,lights_fragment_maps:Fg,lights_fragment_end:zg,logdepthbuf_fragment:Bg,logdepthbuf_pars_fragment:Hg,logdepthbuf_pars_vertex:Vg,logdepthbuf_vertex:Gg,map_fragment:$g,map_pars_fragment:Wg,map_particle_fragment:Xg,map_particle_pars_fragment:jg,metalnessmap_fragment:qg,metalnessmap_pars_fragment:Yg,morphinstance_vertex:Kg,morphcolor_vertex:Zg,morphnormal_vertex:Jg,morphtarget_pars_vertex:Qg,morphtarget_vertex:tv,normal_fragment_begin:ev,normal_fragment_maps:nv,normal_pars_fragment:iv,normal_pars_vertex:sv,normal_vertex:rv,normalmap_pars_fragment:av,clearcoat_normal_fragment_begin:ov,clearcoat_normal_fragment_maps:lv,clearcoat_pars_fragment:cv,iridescence_pars_fragment:hv,opaque_fragment:uv,packing:dv,premultiplied_alpha_fragment:fv,project_vertex:pv,dithering_fragment:mv,dithering_pars_fragment:gv,roughnessmap_fragment:vv,roughnessmap_pars_fragment:_v,shadowmap_pars_fragment:xv,shadowmap_pars_vertex:yv,shadowmap_vertex:Mv,shadowmask_pars_fragment:bv,skinbase_vertex:Sv,skinning_pars_vertex:wv,skinning_vertex:Ev,skinnormal_vertex:Tv,specularmap_fragment:Av,specularmap_pars_fragment:Cv,tonemapping_fragment:Rv,tonemapping_pars_fragment:Pv,transmission_fragment:Lv,transmission_pars_fragment:Dv,uv_pars_fragment:Iv,uv_pars_vertex:kv,uv_vertex:Nv,worldpos_vertex:Uv,background_vert:Ov,background_frag:Fv,backgroundCube_vert:zv,backgroundCube_frag:Bv,cube_vert:Hv,cube_frag:Vv,depth_vert:Gv,depth_frag:$v,distanceRGBA_vert:Wv,distanceRGBA_frag:Xv,equirect_vert:jv,equirect_frag:qv,linedashed_vert:Yv,linedashed_frag:Kv,meshbasic_vert:Zv,meshbasic_frag:Jv,meshlambert_vert:Qv,meshlambert_frag:t_,meshmatcap_vert:e_,meshmatcap_frag:n_,meshnormal_vert:i_,meshnormal_frag:s_,meshphong_vert:r_,meshphong_frag:a_,meshphysical_vert:o_,meshphysical_frag:l_,meshtoon_vert:c_,meshtoon_frag:h_,points_vert:u_,points_frag:d_,shadow_vert:f_,shadow_frag:p_,sprite_vert:m_,sprite_frag:g_},ut={common:{diffuse:{value:new Zt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Xt},alphaMap:{value:null},alphaMapTransform:{value:new Xt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Xt}},envmap:{envMap:{value:null},envMapRotation:{value:new Xt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Xt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Xt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Xt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Xt},normalScale:{value:new at(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Xt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Xt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Xt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Xt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Zt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Zt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Xt},alphaTest:{value:0},uvTransform:{value:new Xt}},sprite:{diffuse:{value:new Zt(16777215)},opacity:{value:1},center:{value:new at(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Xt},alphaMap:{value:null},alphaMapTransform:{value:new Xt},alphaTest:{value:0}}},si={basic:{uniforms:on([ut.common,ut.specularmap,ut.envmap,ut.aomap,ut.lightmap,ut.fog]),vertexShader:Wt.meshbasic_vert,fragmentShader:Wt.meshbasic_frag},lambert:{uniforms:on([ut.common,ut.specularmap,ut.envmap,ut.aomap,ut.lightmap,ut.emissivemap,ut.bumpmap,ut.normalmap,ut.displacementmap,ut.fog,ut.lights,{emissive:{value:new Zt(0)}}]),vertexShader:Wt.meshlambert_vert,fragmentShader:Wt.meshlambert_frag},phong:{uniforms:on([ut.common,ut.specularmap,ut.envmap,ut.aomap,ut.lightmap,ut.emissivemap,ut.bumpmap,ut.normalmap,ut.displacementmap,ut.fog,ut.lights,{emissive:{value:new Zt(0)},specular:{value:new Zt(1118481)},shininess:{value:30}}]),vertexShader:Wt.meshphong_vert,fragmentShader:Wt.meshphong_frag},standard:{uniforms:on([ut.common,ut.envmap,ut.aomap,ut.lightmap,ut.emissivemap,ut.bumpmap,ut.normalmap,ut.displacementmap,ut.roughnessmap,ut.metalnessmap,ut.fog,ut.lights,{emissive:{value:new Zt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Wt.meshphysical_vert,fragmentShader:Wt.meshphysical_frag},toon:{uniforms:on([ut.common,ut.aomap,ut.lightmap,ut.emissivemap,ut.bumpmap,ut.normalmap,ut.displacementmap,ut.gradientmap,ut.fog,ut.lights,{emissive:{value:new Zt(0)}}]),vertexShader:Wt.meshtoon_vert,fragmentShader:Wt.meshtoon_frag},matcap:{uniforms:on([ut.common,ut.bumpmap,ut.normalmap,ut.displacementmap,ut.fog,{matcap:{value:null}}]),vertexShader:Wt.meshmatcap_vert,fragmentShader:Wt.meshmatcap_frag},points:{uniforms:on([ut.points,ut.fog]),vertexShader:Wt.points_vert,fragmentShader:Wt.points_frag},dashed:{uniforms:on([ut.common,ut.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Wt.linedashed_vert,fragmentShader:Wt.linedashed_frag},depth:{uniforms:on([ut.common,ut.displacementmap]),vertexShader:Wt.depth_vert,fragmentShader:Wt.depth_frag},normal:{uniforms:on([ut.common,ut.bumpmap,ut.normalmap,ut.displacementmap,{opacity:{value:1}}]),vertexShader:Wt.meshnormal_vert,fragmentShader:Wt.meshnormal_frag},sprite:{uniforms:on([ut.sprite,ut.fog]),vertexShader:Wt.sprite_vert,fragmentShader:Wt.sprite_frag},background:{uniforms:{uvTransform:{value:new Xt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Wt.background_vert,fragmentShader:Wt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Xt}},vertexShader:Wt.backgroundCube_vert,fragmentShader:Wt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Wt.cube_vert,fragmentShader:Wt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Wt.equirect_vert,fragmentShader:Wt.equirect_frag},distanceRGBA:{uniforms:on([ut.common,ut.displacementmap,{referencePosition:{value:new R},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Wt.distanceRGBA_vert,fragmentShader:Wt.distanceRGBA_frag},shadow:{uniforms:on([ut.lights,ut.fog,{color:{value:new Zt(0)},opacity:{value:1}}]),vertexShader:Wt.shadow_vert,fragmentShader:Wt.shadow_frag}};si.physical={uniforms:on([si.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Xt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Xt},clearcoatNormalScale:{value:new at(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Xt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Xt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Xt},sheen:{value:0},sheenColor:{value:new Zt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Xt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Xt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Xt},transmissionSamplerSize:{value:new at},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Xt},attenuationDistance:{value:0},attenuationColor:{value:new Zt(0)},specularColor:{value:new Zt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Xt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Xt},anisotropyVector:{value:new at},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Xt}}]),vertexShader:Wt.meshphysical_vert,fragmentShader:Wt.meshphysical_frag};const La={r:0,b:0,g:0},fs=new fi,v_=new fe;function __(i,t,e,n,s,r,a){const o=new Zt(0);let l=r===!0?0:1,c,h,u=null,d=0,f=null;function g(y){let x=y.isScene===!0?y.background:null;return x&&x.isTexture&&(x=(y.backgroundBlurriness>0?e:t).get(x)),x}function _(y){let x=!1;const S=g(y);S===null?p(o,l):S&&S.isColor&&(p(S,1),x=!0);const L=i.xr.getEnvironmentBlendMode();L==="additive"?n.buffers.color.setClear(0,0,0,1,a):L==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||x)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function m(y,x){const S=g(x);S&&(S.isCubeTexture||S.mapping===ko)?(h===void 0&&(h=new yt(new Ke(1,1,1),new en({name:"BackgroundCubeMaterial",uniforms:br(si.backgroundCube.uniforms),vertexShader:si.backgroundCube.vertexShader,fragmentShader:si.backgroundCube.fragmentShader,side:hn,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(L,T,E){this.matrixWorld.copyPosition(E.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(h)),fs.copy(x.backgroundRotation),fs.x*=-1,fs.y*=-1,fs.z*=-1,S.isCubeTexture&&S.isRenderTargetTexture===!1&&(fs.y*=-1,fs.z*=-1),h.material.uniforms.envMap.value=S,h.material.uniforms.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=x.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(v_.makeRotationFromEuler(fs)),h.material.toneMapped=oe.getTransfer(S.colorSpace)!==ye,(u!==S||d!==S.version||f!==i.toneMapping)&&(h.material.needsUpdate=!0,u=S,d=S.version,f=i.toneMapping),h.layers.enableAll(),y.unshift(h,h.geometry,h.material,0,0,null)):S&&S.isTexture&&(c===void 0&&(c=new yt(new pi(2,2),new en({name:"BackgroundMaterial",uniforms:br(si.background.uniforms),vertexShader:si.background.vertexShader,fragmentShader:si.background.fragmentShader,side:rs,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(c)),c.material.uniforms.t2D.value=S,c.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,c.material.toneMapped=oe.getTransfer(S.colorSpace)!==ye,S.matrixAutoUpdate===!0&&S.updateMatrix(),c.material.uniforms.uvTransform.value.copy(S.matrix),(u!==S||d!==S.version||f!==i.toneMapping)&&(c.material.needsUpdate=!0,u=S,d=S.version,f=i.toneMapping),c.layers.enableAll(),y.unshift(c,c.geometry,c.material,0,0,null))}function p(y,x){y.getRGB(La,Ff(i)),n.buffers.color.setClear(La.r,La.g,La.b,x,a)}return{getClearColor:function(){return o},setClearColor:function(y,x=1){o.set(y),l=x,p(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(y){l=y,p(o,l)},render:_,addToRenderList:m}}function x_(i,t){const e=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=d(null);let r=s,a=!1;function o(v,b,I,O,$){let K=!1;const z=u(O,I,b);r!==z&&(r=z,c(r.object)),K=f(v,O,I,$),K&&g(v,O,I,$),$!==null&&t.update($,i.ELEMENT_ARRAY_BUFFER),(K||a)&&(a=!1,S(v,b,I,O),$!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t.get($).buffer))}function l(){return i.createVertexArray()}function c(v){return i.bindVertexArray(v)}function h(v){return i.deleteVertexArray(v)}function u(v,b,I){const O=I.wireframe===!0;let $=n[v.id];$===void 0&&($={},n[v.id]=$);let K=$[b.id];K===void 0&&(K={},$[b.id]=K);let z=K[O];return z===void 0&&(z=d(l()),K[O]=z),z}function d(v){const b=[],I=[],O=[];for(let $=0;$<e;$++)b[$]=0,I[$]=0,O[$]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:b,enabledAttributes:I,attributeDivisors:O,object:v,attributes:{},index:null}}function f(v,b,I,O){const $=r.attributes,K=b.attributes;let z=0;const Z=I.getAttributes();for(const V in Z)if(Z[V].location>=0){const ct=$[V];let _t=K[V];if(_t===void 0&&(V==="instanceMatrix"&&v.instanceMatrix&&(_t=v.instanceMatrix),V==="instanceColor"&&v.instanceColor&&(_t=v.instanceColor)),ct===void 0||ct.attribute!==_t||_t&&ct.data!==_t.data)return!0;z++}return r.attributesNum!==z||r.index!==O}function g(v,b,I,O){const $={},K=b.attributes;let z=0;const Z=I.getAttributes();for(const V in Z)if(Z[V].location>=0){let ct=K[V];ct===void 0&&(V==="instanceMatrix"&&v.instanceMatrix&&(ct=v.instanceMatrix),V==="instanceColor"&&v.instanceColor&&(ct=v.instanceColor));const _t={};_t.attribute=ct,ct&&ct.data&&(_t.data=ct.data),$[V]=_t,z++}r.attributes=$,r.attributesNum=z,r.index=O}function _(){const v=r.newAttributes;for(let b=0,I=v.length;b<I;b++)v[b]=0}function m(v){p(v,0)}function p(v,b){const I=r.newAttributes,O=r.enabledAttributes,$=r.attributeDivisors;I[v]=1,O[v]===0&&(i.enableVertexAttribArray(v),O[v]=1),$[v]!==b&&(i.vertexAttribDivisor(v,b),$[v]=b)}function y(){const v=r.newAttributes,b=r.enabledAttributes;for(let I=0,O=b.length;I<O;I++)b[I]!==v[I]&&(i.disableVertexAttribArray(I),b[I]=0)}function x(v,b,I,O,$,K,z){z===!0?i.vertexAttribIPointer(v,b,I,$,K):i.vertexAttribPointer(v,b,I,O,$,K)}function S(v,b,I,O){_();const $=O.attributes,K=I.getAttributes(),z=b.defaultAttributeValues;for(const Z in K){const V=K[Z];if(V.location>=0){let ot=$[Z];if(ot===void 0&&(Z==="instanceMatrix"&&v.instanceMatrix&&(ot=v.instanceMatrix),Z==="instanceColor"&&v.instanceColor&&(ot=v.instanceColor)),ot!==void 0){const ct=ot.normalized,_t=ot.itemSize,$t=t.get(ot);if($t===void 0)continue;const Jt=$t.buffer,j=$t.type,et=$t.bytesPerElement,ft=j===i.INT||j===i.UNSIGNED_INT||ot.gpuType===hh;if(ot.isInterleavedBufferAttribute){const lt=ot.data,At=lt.stride,Tt=ot.offset;if(lt.isInstancedInterleavedBuffer){for(let zt=0;zt<V.locationSize;zt++)p(V.location+zt,lt.meshPerAttribute);v.isInstancedMesh!==!0&&O._maxInstanceCount===void 0&&(O._maxInstanceCount=lt.meshPerAttribute*lt.count)}else for(let zt=0;zt<V.locationSize;zt++)m(V.location+zt);i.bindBuffer(i.ARRAY_BUFFER,Jt);for(let zt=0;zt<V.locationSize;zt++)x(V.location+zt,_t/V.locationSize,j,ct,At*et,(Tt+_t/V.locationSize*zt)*et,ft)}else{if(ot.isInstancedBufferAttribute){for(let lt=0;lt<V.locationSize;lt++)p(V.location+lt,ot.meshPerAttribute);v.isInstancedMesh!==!0&&O._maxInstanceCount===void 0&&(O._maxInstanceCount=ot.meshPerAttribute*ot.count)}else for(let lt=0;lt<V.locationSize;lt++)m(V.location+lt);i.bindBuffer(i.ARRAY_BUFFER,Jt);for(let lt=0;lt<V.locationSize;lt++)x(V.location+lt,_t/V.locationSize,j,ct,_t*et,_t/V.locationSize*lt*et,ft)}}else if(z!==void 0){const ct=z[Z];if(ct!==void 0)switch(ct.length){case 2:i.vertexAttrib2fv(V.location,ct);break;case 3:i.vertexAttrib3fv(V.location,ct);break;case 4:i.vertexAttrib4fv(V.location,ct);break;default:i.vertexAttrib1fv(V.location,ct)}}}}y()}function L(){P();for(const v in n){const b=n[v];for(const I in b){const O=b[I];for(const $ in O)h(O[$].object),delete O[$];delete b[I]}delete n[v]}}function T(v){if(n[v.id]===void 0)return;const b=n[v.id];for(const I in b){const O=b[I];for(const $ in O)h(O[$].object),delete O[$];delete b[I]}delete n[v.id]}function E(v){for(const b in n){const I=n[b];if(I[v.id]===void 0)continue;const O=I[v.id];for(const $ in O)h(O[$].object),delete O[$];delete I[v.id]}}function P(){U(),a=!0,r!==s&&(r=s,c(r.object))}function U(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:P,resetDefaultState:U,dispose:L,releaseStatesOfGeometry:T,releaseStatesOfProgram:E,initAttributes:_,enableAttribute:m,disableUnusedAttributes:y}}function y_(i,t,e){let n;function s(c){n=c}function r(c,h){i.drawArrays(n,c,h),e.update(h,n,1)}function a(c,h,u){u!==0&&(i.drawArraysInstanced(n,c,h,u),e.update(h,n,u))}function o(c,h,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,h,0,u);let f=0;for(let g=0;g<u;g++)f+=h[g];e.update(f,n,1)}function l(c,h,u,d){if(u===0)return;const f=t.get("WEBGL_multi_draw");if(f===null)for(let g=0;g<c.length;g++)a(c[g],h[g],d[g]);else{f.multiDrawArraysInstancedWEBGL(n,c,0,h,0,d,0,u);let g=0;for(let _=0;_<u;_++)g+=h[_];for(let _=0;_<d.length;_++)e.update(g,n,d[_])}}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function M_(i,t,e,n){let s;function r(){if(s!==void 0)return s;if(t.has("EXT_texture_filter_anisotropic")===!0){const E=t.get("EXT_texture_filter_anisotropic");s=i.getParameter(E.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function a(E){return!(E!==kn&&n.convert(E)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(E){const P=E===Ni&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(E!==di&&n.convert(E)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&E!==Ai&&!P)}function l(E){if(E==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";E="mediump"}return E==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=e.precision!==void 0?e.precision:"highp";const h=l(c);h!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const u=e.logarithmicDepthBuffer===!0,d=e.reverseDepthBuffer===!0&&t.has("EXT_clip_control");if(d===!0){const E=t.get("EXT_clip_control");E.clipControlEXT(E.LOWER_LEFT_EXT,E.ZERO_TO_ONE_EXT)}const f=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),g=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),p=i.getParameter(i.MAX_VERTEX_ATTRIBS),y=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),x=i.getParameter(i.MAX_VARYING_VECTORS),S=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),L=g>0,T=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:u,reverseDepthBuffer:d,maxTextures:f,maxVertexTextures:g,maxTextureSize:_,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:y,maxVaryings:x,maxFragmentUniforms:S,vertexTextures:L,maxSamples:T}}function b_(i){const t=this;let e=null,n=0,s=!1,r=!1;const a=new qi,o=new Xt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const f=u.length!==0||d||n!==0||s;return s=d,n=u.length,f},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,d){e=h(u,d,0)},this.setState=function(u,d,f){const g=u.clippingPlanes,_=u.clipIntersection,m=u.clipShadows,p=i.get(u);if(!s||g===null||g.length===0||r&&!m)r?h(null):c();else{const y=r?0:n,x=y*4;let S=p.clippingState||null;l.value=S,S=h(g,d,x,f);for(let L=0;L!==x;++L)S[L]=e[L];p.clippingState=S,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=y}};function c(){l.value!==e&&(l.value=e,l.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(u,d,f,g){const _=u!==null?u.length:0;let m=null;if(_!==0){if(m=l.value,g!==!0||m===null){const p=f+_*4,y=d.matrixWorldInverse;o.getNormalMatrix(y),(m===null||m.length<p)&&(m=new Float32Array(p));for(let x=0,S=f;x!==_;++x,S+=4)a.copy(u[x]).applyMatrix4(y,o),a.normal.toArray(m,S),m[S+3]=a.constant}l.value=m,l.needsUpdate=!0}return t.numPlanes=_,t.numIntersection=0,m}}function S_(i){let t=new WeakMap;function e(a,o){return o===gc?a.mapping=yr:o===vc&&(a.mapping=Mr),a}function n(a){if(a&&a.isTexture){const o=a.mapping;if(o===gc||o===vc)if(t.has(a)){const l=t.get(a).texture;return e(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const c=new k0(l.height);return c.fromEquirectangularTexture(i,a),t.set(a,c),a.addEventListener("dispose",s),e(c.texture,a.mapping)}else return null}}return a}function s(a){const o=a.target;o.removeEventListener("dispose",s);const l=t.get(o);l!==void 0&&(t.delete(o),l.dispose())}function r(){t=new WeakMap}return{get:n,dispose:r}}class Sh extends zf{constructor(t=-1,e=1,n=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,s,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let r=n-t,a=n+t,o=s+e,l=s-e;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}const er=4,Nu=[.125,.215,.35,.446,.526,.582],gs=20,Ml=new Sh,Uu=new Zt;let bl=null,Sl=0,wl=0,El=!1;const ms=(1+Math.sqrt(5))/2,Ws=1/ms,Ou=[new R(-ms,Ws,0),new R(ms,Ws,0),new R(-Ws,0,ms),new R(Ws,0,ms),new R(0,ms,-Ws),new R(0,ms,Ws),new R(-1,1,-1),new R(1,1,-1),new R(-1,1,1),new R(1,1,1)];class Wc{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,n=.1,s=100){bl=this._renderer.getRenderTarget(),Sl=this._renderer.getActiveCubeFace(),wl=this._renderer.getActiveMipmapLevel(),El=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(t,n,s,r),e>0&&this._blur(r,0,0,e),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Bu(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=zu(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(bl,Sl,wl),this._renderer.xr.enabled=El,t.scissorTest=!1,Da(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===yr||t.mapping===Mr?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),bl=this._renderer.getRenderTarget(),Sl=this._renderer.getActiveCubeFace(),wl=this._renderer.getActiveMipmapLevel(),El=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:jn,minFilter:jn,generateMipmaps:!1,type:Ni,format:kn,colorSpace:os,depthBuffer:!1},s=Fu(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Fu(t,e,n);const{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=w_(r)),this._blurMaterial=E_(r,t,e)}return s}_compileMaterial(t){const e=new yt(this._lodPlanes[0],t);this._renderer.compile(e,Ml)}_sceneToCubeUV(t,e,n,s){const o=new An(90,1,e,n),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],h=this._renderer,u=h.autoClear,d=h.toneMapping;h.getClearColor(Uu),h.toneMapping=ns,h.autoClear=!1;const f=new un({name:"PMREM.Background",side:hn,depthWrite:!1,depthTest:!1}),g=new yt(new Ke,f);let _=!1;const m=t.background;m?m.isColor&&(f.color.copy(m),t.background=null,_=!0):(f.color.copy(Uu),_=!0);for(let p=0;p<6;p++){const y=p%3;y===0?(o.up.set(0,l[p],0),o.lookAt(c[p],0,0)):y===1?(o.up.set(0,0,l[p]),o.lookAt(0,c[p],0)):(o.up.set(0,l[p],0),o.lookAt(0,0,c[p]));const x=this._cubeSize;Da(s,y*x,p>2?x:0,x,x),h.setRenderTarget(s),_&&h.render(g,o),h.render(t,o)}g.geometry.dispose(),g.material.dispose(),h.toneMapping=d,h.autoClear=u,t.background=m}_textureToCubeUV(t,e){const n=this._renderer,s=t.mapping===yr||t.mapping===Mr;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Bu()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=zu());const r=s?this._cubemapMaterial:this._equirectMaterial,a=new yt(this._lodPlanes[0],r),o=r.uniforms;o.envMap.value=t;const l=this._cubeSize;Da(e,0,0,3*l,2*l),n.setRenderTarget(e),n.render(a,Ml)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const s=this._lodPlanes.length;for(let r=1;r<s;r++){const a=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),o=Ou[(s-r-1)%Ou.length];this._blur(t,r-1,r,a,o)}e.autoClear=n}_blur(t,e,n,s,r){const a=this._pingPongRenderTarget;this._halfBlur(t,a,e,n,s,"latitudinal",r),this._halfBlur(a,t,n,n,s,"longitudinal",r)}_halfBlur(t,e,n,s,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const h=3,u=new yt(this._lodPlanes[s],c),d=c.uniforms,f=this._sizeLods[n]-1,g=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*gs-1),_=r/g,m=isFinite(r)?1+Math.floor(h*_):gs;m>gs&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${gs}`);const p=[];let y=0;for(let E=0;E<gs;++E){const P=E/_,U=Math.exp(-P*P/2);p.push(U),E===0?y+=U:E<m&&(y+=2*U)}for(let E=0;E<p.length;E++)p[E]=p[E]/y;d.envMap.value=t.texture,d.samples.value=m,d.weights.value=p,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:x}=this;d.dTheta.value=g,d.mipInt.value=x-n;const S=this._sizeLods[s],L=3*S*(s>x-er?s-x+er:0),T=4*(this._cubeSize-S);Da(e,L,T,3*S,2*S),l.setRenderTarget(e),l.render(u,Ml)}}function w_(i){const t=[],e=[],n=[];let s=i;const r=i-er+1+Nu.length;for(let a=0;a<r;a++){const o=Math.pow(2,s);e.push(o);let l=1/o;a>i-er?l=Nu[a-i+er-1]:a===0&&(l=0),n.push(l);const c=1/(o-2),h=-c,u=1+c,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,g=6,_=3,m=2,p=1,y=new Float32Array(_*g*f),x=new Float32Array(m*g*f),S=new Float32Array(p*g*f);for(let T=0;T<f;T++){const E=T%3*2/3-1,P=T>2?0:-1,U=[E,P,0,E+2/3,P,0,E+2/3,P+1,0,E,P,0,E+2/3,P+1,0,E,P+1,0];y.set(U,_*g*T),x.set(d,m*g*T);const v=[T,T,T,T,T,T];S.set(v,p*g*T)}const L=new dn;L.setAttribute("position",new ci(y,_)),L.setAttribute("uv",new ci(x,m)),L.setAttribute("faceIndex",new ci(S,p)),t.push(L),s>er&&s--}return{lodPlanes:t,sizeLods:e,sigmas:n}}function Fu(i,t,e){const n=new Jn(i,t,e);return n.texture.mapping=ko,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Da(i,t,e,n,s){i.viewport.set(t,e,n,s),i.scissor.set(t,e,n,s)}function E_(i,t,e){const n=new Float32Array(gs),s=new R(0,1,0);return new en({name:"SphericalGaussianBlur",defines:{n:gs,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:wh(),fragmentShader:`
|
|
3589
3588
|
|
|
3590
3589
|
precision mediump float;
|
|
3591
3590
|
precision mediump int;
|
|
@@ -3645,7 +3644,7 @@ void main() {
|
|
|
3645
3644
|
}
|
|
3646
3645
|
|
|
3647
3646
|
}
|
|
3648
|
-
`,blending:
|
|
3647
|
+
`,blending:qe,depthTest:!1,depthWrite:!1})}function zu(){return new en({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:wh(),fragmentShader:`
|
|
3649
3648
|
|
|
3650
3649
|
precision mediump float;
|
|
3651
3650
|
precision mediump int;
|
|
@@ -3664,7 +3663,7 @@ void main() {
|
|
|
3664
3663
|
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
|
|
3665
3664
|
|
|
3666
3665
|
}
|
|
3667
|
-
`,blending:
|
|
3666
|
+
`,blending:qe,depthTest:!1,depthWrite:!1})}function Bu(){return new en({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:wh(),fragmentShader:`
|
|
3668
3667
|
|
|
3669
3668
|
precision mediump float;
|
|
3670
3669
|
precision mediump int;
|
|
@@ -3680,7 +3679,7 @@ void main() {
|
|
|
3680
3679
|
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
|
|
3681
3680
|
|
|
3682
3681
|
}
|
|
3683
|
-
`,blending:
|
|
3682
|
+
`,blending:qe,depthTest:!1,depthWrite:!1})}function wh(){return`
|
|
3684
3683
|
|
|
3685
3684
|
precision mediump float;
|
|
3686
3685
|
precision mediump int;
|
|
@@ -3735,16 +3734,16 @@ void main() {
|
|
|
3735
3734
|
gl_Position = vec4( position, 1.0 );
|
|
3736
3735
|
|
|
3737
3736
|
}
|
|
3738
|
-
`}function R_(i){let t=new WeakMap,e=null;function n(o){if(o&&o.isTexture){const l=o.mapping,c=l===_c||l===xc,h=l===yr||l===Mr;if(c||h){let u=t.get(o);const d=u!==void 0?u.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==d)return e===null&&(e=new jc(i)),u=c?e.fromEquirectangular(o,u):e.fromCubemap(o,u),u.texture.pmremVersion=o.pmremVersion,t.set(o,u),u.texture;if(u!==void 0)return u.texture;{const f=o.image;return c&&f&&f.height>0||h&&f&&s(f)?(e===null&&(e=new jc(i)),u=c?e.fromEquirectangular(o):e.fromCubemap(o),u.texture.pmremVersion=o.pmremVersion,t.set(o,u),o.addEventListener("dispose",r),u.texture):null}}}return o}function s(o){let l=0;const c=6;for(let h=0;h<c;h++)o[h]!==void 0&&l++;return l===c}function r(o){const l=o.target;l.removeEventListener("dispose",r);const c=t.get(l);c!==void 0&&(t.delete(l),c.dispose())}function a(){t=new WeakMap,e!==null&&(e.dispose(),e=null)}return{get:n,dispose:a}}function P_(i){const t={};function e(n){if(t[n]!==void 0)return t[n];let s;switch(n){case"WEBGL_depth_texture":s=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":s=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":s=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":s=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:s=i.getExtension(n)}return t[n]=s,s}return{has:function(n){return e(n)!==null},init:function(){e("EXT_color_buffer_float"),e("WEBGL_clip_cull_distance"),e("OES_texture_float_linear"),e("EXT_color_buffer_half_float"),e("WEBGL_multisampled_render_to_texture"),e("WEBGL_render_shared_exponent")},get:function(n){const s=e(n);return s===null&&oo("THREE.WebGLRenderer: "+n+" extension not supported."),s}}}function L_(i,t,e,n){const s={},r=new WeakMap;function a(u){const d=u.target;d.index!==null&&t.remove(d.index);for(const g in d.attributes)t.remove(d.attributes[g]);for(const g in d.morphAttributes){const _=d.morphAttributes[g];for(let m=0,p=_.length;m<p;m++)t.remove(_[m])}d.removeEventListener("dispose",a),delete s[d.id];const f=r.get(d);f&&(t.remove(f),r.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,e.memory.geometries--}function o(u,d){return s[d.id]===!0||(d.addEventListener("dispose",a),s[d.id]=!0,e.memory.geometries++),d}function l(u){const d=u.attributes;for(const g in d)t.update(d[g],i.ARRAY_BUFFER);const f=u.morphAttributes;for(const g in f){const _=f[g];for(let m=0,p=_.length;m<p;m++)t.update(_[m],i.ARRAY_BUFFER)}}function c(u){const d=[],f=u.index,g=u.attributes.position;let _=0;if(f!==null){const y=f.array;_=f.version;for(let x=0,S=y.length;x<S;x+=3){const L=y[x+0],T=y[x+1],E=y[x+2];d.push(L,T,T,E,E,L)}}else if(g!==void 0){const y=g.array;_=g.version;for(let x=0,S=y.length/3-1;x<S;x+=3){const L=x+0,T=x+1,E=x+2;d.push(L,T,T,E,E,L)}}else return;const m=new(kf(d)?zf:Ff)(d,1);m.version=_;const p=r.get(u);p&&t.remove(p),r.set(u,m)}function h(u){const d=r.get(u);if(d){const f=u.index;f!==null&&d.version<f.version&&c(u)}else c(u);return r.get(u)}return{get:o,update:l,getWireframeAttribute:h}}function D_(i,t,e){let n;function s(d){n=d}let r,a;function o(d){r=d.type,a=d.bytesPerElement}function l(d,f){i.drawElements(n,f,r,d*a),e.update(f,n,1)}function c(d,f,g){g!==0&&(i.drawElementsInstanced(n,f,r,d*a,g),e.update(f,n,g))}function h(d,f,g){if(g===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,f,0,r,d,0,g);let m=0;for(let p=0;p<g;p++)m+=f[p];e.update(m,n,1)}function u(d,f,g,_){if(g===0)return;const m=t.get("WEBGL_multi_draw");if(m===null)for(let p=0;p<d.length;p++)c(d[p]/a,f[p],_[p]);else{m.multiDrawElementsInstancedWEBGL(n,f,0,r,d,0,_,0,g);let p=0;for(let y=0;y<g;y++)p+=f[y];for(let y=0;y<_.length;y++)e.update(p,n,_[y])}}this.setMode=s,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=h,this.renderMultiDrawInstances=u}function I_(i){const t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,a,o){switch(e.calls++,a){case i.TRIANGLES:e.triangles+=o*(r/3);break;case i.LINES:e.lines+=o*(r/2);break;case i.LINE_STRIP:e.lines+=o*(r-1);break;case i.LINE_LOOP:e.lines+=o*r;break;case i.POINTS:e.points+=o*r;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function s(){e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:s,update:n}}function k_(i,t,e){const n=new WeakMap,s=new me;function r(a,o,l){const c=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=h!==void 0?h.length:0;let d=n.get(o);if(d===void 0||d.count!==u){let v=function(){P.dispose(),n.delete(o),o.removeEventListener("dispose",v)};var f=v;d!==void 0&&d.texture.dispose();const g=o.morphAttributes.position!==void 0,_=o.morphAttributes.normal!==void 0,m=o.morphAttributes.color!==void 0,p=o.morphAttributes.position||[],y=o.morphAttributes.normal||[],x=o.morphAttributes.color||[];let S=0;g===!0&&(S=1),_===!0&&(S=2),m===!0&&(S=3);let L=o.attributes.position.count*S,T=1;L>t.maxTextureSize&&(T=Math.ceil(L/t.maxTextureSize),L=t.maxTextureSize);const E=new Float32Array(L*T*4*u),P=new Uf(E,L,T,u);P.type=Ci,P.needsUpdate=!0;const U=S*4;for(let b=0;b<u;b++){const I=p[b],O=y[b],$=x[b],K=L*T*4*b;for(let z=0;z<I.count;z++){const Z=z*U;g===!0&&(s.fromBufferAttribute(I,z),E[K+Z+0]=s.x,E[K+Z+1]=s.y,E[K+Z+2]=s.z,E[K+Z+3]=0),_===!0&&(s.fromBufferAttribute(O,z),E[K+Z+4]=s.x,E[K+Z+5]=s.y,E[K+Z+6]=s.z,E[K+Z+7]=0),m===!0&&(s.fromBufferAttribute($,z),E[K+Z+8]=s.x,E[K+Z+9]=s.y,E[K+Z+10]=s.z,E[K+Z+11]=$.itemSize===4?s.w:1)}}d={count:u,texture:P,size:new rt(L,T)},n.set(o,d),o.addEventListener("dispose",v)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(i,"morphTexture",a.morphTexture,e);else{let g=0;for(let m=0;m<c.length;m++)g+=c[m];const _=o.morphTargetsRelative?1:1-g;l.getUniforms().setValue(i,"morphTargetBaseInfluence",_),l.getUniforms().setValue(i,"morphTargetInfluences",c)}l.getUniforms().setValue(i,"morphTargetsTexture",d.texture,e),l.getUniforms().setValue(i,"morphTargetsTextureSize",d.size)}return{update:r}}function N_(i,t,e,n){let s=new WeakMap;function r(l){const c=n.render.frame,h=l.geometry,u=t.get(l,h);if(s.get(u)!==c&&(t.update(u),s.set(u,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),s.get(l)!==c&&(e.update(l.instanceMatrix,i.ARRAY_BUFFER),l.instanceColor!==null&&e.update(l.instanceColor,i.ARRAY_BUFFER),s.set(l,c))),l.isSkinnedMesh){const d=l.skeleton;s.get(d)!==c&&(d.update(),s.set(d,c))}return u}function a(){s=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),e.remove(c.instanceMatrix),c.instanceColor!==null&&e.remove(c.instanceColor)}return{update:r,dispose:a}}class Th extends an{constructor(t,e,n,s,r,a,o,l,c,h=mr){if(h!==mr&&h!==Cs)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&h===mr&&(n=Ts),n===void 0&&h===Cs&&(n=As),super(null,s,r,a,o,l,h,n,c),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=o!==void 0?o:rn,this.minFilter=l!==void 0?l:rn,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}}const $f=new an,Bu=new Th(1,1),Wf=new Uf,Xf=new b0,jf=new Vf,Hu=[],Vu=[],Gu=new Float32Array(16),$u=new Float32Array(9),Wu=new Float32Array(4);function Ar(i,t,e){const n=i[0];if(n<=0||n>0)return i;const s=t*e;let r=Hu[s];if(r===void 0&&(r=new Float32Array(s),Hu[s]=r),t!==0){n.toArray(r,0);for(let a=1,o=0;a!==t;++a)o+=e,i[a].toArray(r,o)}return r}function Be(i,t){if(i.length!==t.length)return!1;for(let e=0,n=i.length;e<n;e++)if(i[e]!==t[e])return!1;return!0}function He(i,t){for(let e=0,n=t.length;e<n;e++)i[e]=t[e]}function Fo(i,t){let e=Vu[t];e===void 0&&(e=new Int32Array(t),Vu[t]=e);for(let n=0;n!==t;++n)e[n]=i.allocateTextureUnit();return e}function U_(i,t){const e=this.cache;e[0]!==t&&(i.uniform1f(this.addr,t),e[0]=t)}function O_(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Be(e,t))return;i.uniform2fv(this.addr,t),He(e,t)}}function F_(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3f(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else if(t.r!==void 0)(e[0]!==t.r||e[1]!==t.g||e[2]!==t.b)&&(i.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(Be(e,t))return;i.uniform3fv(this.addr,t),He(e,t)}}function z_(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4f(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Be(e,t))return;i.uniform4fv(this.addr,t),He(e,t)}}function B_(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(Be(e,t))return;i.uniformMatrix2fv(this.addr,!1,t),He(e,t)}else{if(Be(e,n))return;Wu.set(n),i.uniformMatrix2fv(this.addr,!1,Wu),He(e,n)}}function H_(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(Be(e,t))return;i.uniformMatrix3fv(this.addr,!1,t),He(e,t)}else{if(Be(e,n))return;$u.set(n),i.uniformMatrix3fv(this.addr,!1,$u),He(e,n)}}function V_(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(Be(e,t))return;i.uniformMatrix4fv(this.addr,!1,t),He(e,t)}else{if(Be(e,n))return;Gu.set(n),i.uniformMatrix4fv(this.addr,!1,Gu),He(e,n)}}function G_(i,t){const e=this.cache;e[0]!==t&&(i.uniform1i(this.addr,t),e[0]=t)}function $_(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2i(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Be(e,t))return;i.uniform2iv(this.addr,t),He(e,t)}}function W_(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3i(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(Be(e,t))return;i.uniform3iv(this.addr,t),He(e,t)}}function X_(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4i(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Be(e,t))return;i.uniform4iv(this.addr,t),He(e,t)}}function j_(i,t){const e=this.cache;e[0]!==t&&(i.uniform1ui(this.addr,t),e[0]=t)}function q_(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2ui(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Be(e,t))return;i.uniform2uiv(this.addr,t),He(e,t)}}function Y_(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3ui(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(Be(e,t))return;i.uniform3uiv(this.addr,t),He(e,t)}}function K_(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4ui(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Be(e,t))return;i.uniform4uiv(this.addr,t),He(e,t)}}function Z_(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let r;this.type===i.SAMPLER_2D_SHADOW?(Bu.compareFunction=If,r=Bu):r=$f,e.setTexture2D(t||r,s)}function J_(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture3D(t||Xf,s)}function Q_(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTextureCube(t||jf,s)}function tx(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture2DArray(t||Wf,s)}function ex(i){switch(i){case 5126:return U_;case 35664:return O_;case 35665:return F_;case 35666:return z_;case 35674:return B_;case 35675:return H_;case 35676:return V_;case 5124:case 35670:return G_;case 35667:case 35671:return $_;case 35668:case 35672:return W_;case 35669:case 35673:return X_;case 5125:return j_;case 36294:return q_;case 36295:return Y_;case 36296:return K_;case 35678:case 36198:case 36298:case 36306:case 35682:return Z_;case 35679:case 36299:case 36307:return J_;case 35680:case 36300:case 36308:case 36293:return Q_;case 36289:case 36303:case 36311:case 36292:return tx}}function nx(i,t){i.uniform1fv(this.addr,t)}function ix(i,t){const e=Ar(t,this.size,2);i.uniform2fv(this.addr,e)}function sx(i,t){const e=Ar(t,this.size,3);i.uniform3fv(this.addr,e)}function rx(i,t){const e=Ar(t,this.size,4);i.uniform4fv(this.addr,e)}function ax(i,t){const e=Ar(t,this.size,4);i.uniformMatrix2fv(this.addr,!1,e)}function ox(i,t){const e=Ar(t,this.size,9);i.uniformMatrix3fv(this.addr,!1,e)}function lx(i,t){const e=Ar(t,this.size,16);i.uniformMatrix4fv(this.addr,!1,e)}function cx(i,t){i.uniform1iv(this.addr,t)}function hx(i,t){i.uniform2iv(this.addr,t)}function ux(i,t){i.uniform3iv(this.addr,t)}function dx(i,t){i.uniform4iv(this.addr,t)}function fx(i,t){i.uniform1uiv(this.addr,t)}function px(i,t){i.uniform2uiv(this.addr,t)}function mx(i,t){i.uniform3uiv(this.addr,t)}function gx(i,t){i.uniform4uiv(this.addr,t)}function vx(i,t,e){const n=this.cache,s=t.length,r=Fo(e,s);Be(n,r)||(i.uniform1iv(this.addr,r),He(n,r));for(let a=0;a!==s;++a)e.setTexture2D(t[a]||$f,r[a])}function _x(i,t,e){const n=this.cache,s=t.length,r=Fo(e,s);Be(n,r)||(i.uniform1iv(this.addr,r),He(n,r));for(let a=0;a!==s;++a)e.setTexture3D(t[a]||Xf,r[a])}function xx(i,t,e){const n=this.cache,s=t.length,r=Fo(e,s);Be(n,r)||(i.uniform1iv(this.addr,r),He(n,r));for(let a=0;a!==s;++a)e.setTextureCube(t[a]||jf,r[a])}function yx(i,t,e){const n=this.cache,s=t.length,r=Fo(e,s);Be(n,r)||(i.uniform1iv(this.addr,r),He(n,r));for(let a=0;a!==s;++a)e.setTexture2DArray(t[a]||Wf,r[a])}function Mx(i){switch(i){case 5126:return nx;case 35664:return ix;case 35665:return sx;case 35666:return rx;case 35674:return ax;case 35675:return ox;case 35676:return lx;case 5124:case 35670:return cx;case 35667:case 35671:return hx;case 35668:case 35672:return ux;case 35669:case 35673:return dx;case 5125:return fx;case 36294:return px;case 36295:return mx;case 36296:return gx;case 35678:case 36198:case 36298:case 36306:case 35682:return vx;case 35679:case 36299:case 36307:return _x;case 35680:case 36300:case 36308:case 36293:return xx;case 36289:case 36303:case 36311:case 36292:return yx}}class bx{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=ex(e.type)}}class Sx{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=Mx(e.type)}}class wx{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){const s=this.seq;for(let r=0,a=s.length;r!==a;++r){const o=s[r];o.setValue(t,e[o.id],n)}}}const Cl=/(\w+)(\])?(\[|\.)?/g;function Xu(i,t){i.seq.push(t),i.map[t.id]=t}function Ex(i,t,e){const n=i.name,s=n.length;for(Cl.lastIndex=0;;){const r=Cl.exec(n),a=Cl.lastIndex;let o=r[1];const l=r[2]==="]",c=r[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===s){Xu(e,c===void 0?new bx(o,i,t):new Sx(o,i,t));break}else{let u=e.map[o];u===void 0&&(u=new wx(o),Xu(e,u)),e=u}}}class lo{constructor(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){const r=t.getActiveUniform(e,s),a=t.getUniformLocation(e,r.name);Ex(r,a,this)}}setValue(t,e,n,s){const r=this.map[e];r!==void 0&&r.setValue(t,n,s)}setOptional(t,e,n){const s=e[n];s!==void 0&&this.setValue(t,n,s)}static upload(t,e,n,s){for(let r=0,a=e.length;r!==a;++r){const o=e[r],l=n[o.id];l.needsUpdate!==!1&&o.setValue(t,l.value,s)}}static seqWithValue(t,e){const n=[];for(let s=0,r=t.length;s!==r;++s){const a=t[s];a.id in e&&n.push(a)}return n}}function ju(i,t,e){const n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}const Tx=37297;let Ax=0;function Cx(i,t){const e=i.split(`
|
|
3737
|
+
`}function T_(i){let t=new WeakMap,e=null;function n(o){if(o&&o.isTexture){const l=o.mapping,c=l===gc||l===vc,h=l===yr||l===Mr;if(c||h){let u=t.get(o);const d=u!==void 0?u.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==d)return e===null&&(e=new Wc(i)),u=c?e.fromEquirectangular(o,u):e.fromCubemap(o,u),u.texture.pmremVersion=o.pmremVersion,t.set(o,u),u.texture;if(u!==void 0)return u.texture;{const f=o.image;return c&&f&&f.height>0||h&&f&&s(f)?(e===null&&(e=new Wc(i)),u=c?e.fromEquirectangular(o):e.fromCubemap(o),u.texture.pmremVersion=o.pmremVersion,t.set(o,u),o.addEventListener("dispose",r),u.texture):null}}}return o}function s(o){let l=0;const c=6;for(let h=0;h<c;h++)o[h]!==void 0&&l++;return l===c}function r(o){const l=o.target;l.removeEventListener("dispose",r);const c=t.get(l);c!==void 0&&(t.delete(l),c.dispose())}function a(){t=new WeakMap,e!==null&&(e.dispose(),e=null)}return{get:n,dispose:a}}function A_(i){const t={};function e(n){if(t[n]!==void 0)return t[n];let s;switch(n){case"WEBGL_depth_texture":s=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":s=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":s=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":s=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:s=i.getExtension(n)}return t[n]=s,s}return{has:function(n){return e(n)!==null},init:function(){e("EXT_color_buffer_float"),e("WEBGL_clip_cull_distance"),e("OES_texture_float_linear"),e("EXT_color_buffer_half_float"),e("WEBGL_multisampled_render_to_texture"),e("WEBGL_render_shared_exponent")},get:function(n){const s=e(n);return s===null&&ro("THREE.WebGLRenderer: "+n+" extension not supported."),s}}}function C_(i,t,e,n){const s={},r=new WeakMap;function a(u){const d=u.target;d.index!==null&&t.remove(d.index);for(const g in d.attributes)t.remove(d.attributes[g]);for(const g in d.morphAttributes){const _=d.morphAttributes[g];for(let m=0,p=_.length;m<p;m++)t.remove(_[m])}d.removeEventListener("dispose",a),delete s[d.id];const f=r.get(d);f&&(t.remove(f),r.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,e.memory.geometries--}function o(u,d){return s[d.id]===!0||(d.addEventListener("dispose",a),s[d.id]=!0,e.memory.geometries++),d}function l(u){const d=u.attributes;for(const g in d)t.update(d[g],i.ARRAY_BUFFER);const f=u.morphAttributes;for(const g in f){const _=f[g];for(let m=0,p=_.length;m<p;m++)t.update(_[m],i.ARRAY_BUFFER)}}function c(u){const d=[],f=u.index,g=u.attributes.position;let _=0;if(f!==null){const y=f.array;_=f.version;for(let x=0,S=y.length;x<S;x+=3){const L=y[x+0],T=y[x+1],E=y[x+2];d.push(L,T,T,E,E,L)}}else if(g!==void 0){const y=g.array;_=g.version;for(let x=0,S=y.length/3-1;x<S;x+=3){const L=x+0,T=x+1,E=x+2;d.push(L,T,T,E,E,L)}}else return;const m=new(Df(d)?Of:Uf)(d,1);m.version=_;const p=r.get(u);p&&t.remove(p),r.set(u,m)}function h(u){const d=r.get(u);if(d){const f=u.index;f!==null&&d.version<f.version&&c(u)}else c(u);return r.get(u)}return{get:o,update:l,getWireframeAttribute:h}}function R_(i,t,e){let n;function s(d){n=d}let r,a;function o(d){r=d.type,a=d.bytesPerElement}function l(d,f){i.drawElements(n,f,r,d*a),e.update(f,n,1)}function c(d,f,g){g!==0&&(i.drawElementsInstanced(n,f,r,d*a,g),e.update(f,n,g))}function h(d,f,g){if(g===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,f,0,r,d,0,g);let m=0;for(let p=0;p<g;p++)m+=f[p];e.update(m,n,1)}function u(d,f,g,_){if(g===0)return;const m=t.get("WEBGL_multi_draw");if(m===null)for(let p=0;p<d.length;p++)c(d[p]/a,f[p],_[p]);else{m.multiDrawElementsInstancedWEBGL(n,f,0,r,d,0,_,0,g);let p=0;for(let y=0;y<g;y++)p+=f[y];for(let y=0;y<_.length;y++)e.update(p,n,_[y])}}this.setMode=s,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=h,this.renderMultiDrawInstances=u}function P_(i){const t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,a,o){switch(e.calls++,a){case i.TRIANGLES:e.triangles+=o*(r/3);break;case i.LINES:e.lines+=o*(r/2);break;case i.LINE_STRIP:e.lines+=o*(r-1);break;case i.LINE_LOOP:e.lines+=o*r;break;case i.POINTS:e.points+=o*r;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function s(){e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:s,update:n}}function L_(i,t,e){const n=new WeakMap,s=new me;function r(a,o,l){const c=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=h!==void 0?h.length:0;let d=n.get(o);if(d===void 0||d.count!==u){let v=function(){P.dispose(),n.delete(o),o.removeEventListener("dispose",v)};var f=v;d!==void 0&&d.texture.dispose();const g=o.morphAttributes.position!==void 0,_=o.morphAttributes.normal!==void 0,m=o.morphAttributes.color!==void 0,p=o.morphAttributes.position||[],y=o.morphAttributes.normal||[],x=o.morphAttributes.color||[];let S=0;g===!0&&(S=1),_===!0&&(S=2),m===!0&&(S=3);let L=o.attributes.position.count*S,T=1;L>t.maxTextureSize&&(T=Math.ceil(L/t.maxTextureSize),L=t.maxTextureSize);const E=new Float32Array(L*T*4*u),P=new kf(E,L,T,u);P.type=Ai,P.needsUpdate=!0;const U=S*4;for(let b=0;b<u;b++){const I=p[b],O=y[b],$=x[b],K=L*T*4*b;for(let z=0;z<I.count;z++){const Z=z*U;g===!0&&(s.fromBufferAttribute(I,z),E[K+Z+0]=s.x,E[K+Z+1]=s.y,E[K+Z+2]=s.z,E[K+Z+3]=0),_===!0&&(s.fromBufferAttribute(O,z),E[K+Z+4]=s.x,E[K+Z+5]=s.y,E[K+Z+6]=s.z,E[K+Z+7]=0),m===!0&&(s.fromBufferAttribute($,z),E[K+Z+8]=s.x,E[K+Z+9]=s.y,E[K+Z+10]=s.z,E[K+Z+11]=$.itemSize===4?s.w:1)}}d={count:u,texture:P,size:new at(L,T)},n.set(o,d),o.addEventListener("dispose",v)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(i,"morphTexture",a.morphTexture,e);else{let g=0;for(let m=0;m<c.length;m++)g+=c[m];const _=o.morphTargetsRelative?1:1-g;l.getUniforms().setValue(i,"morphTargetBaseInfluence",_),l.getUniforms().setValue(i,"morphTargetInfluences",c)}l.getUniforms().setValue(i,"morphTargetsTexture",d.texture,e),l.getUniforms().setValue(i,"morphTargetsTextureSize",d.size)}return{update:r}}function D_(i,t,e,n){let s=new WeakMap;function r(l){const c=n.render.frame,h=l.geometry,u=t.get(l,h);if(s.get(u)!==c&&(t.update(u),s.set(u,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),s.get(l)!==c&&(e.update(l.instanceMatrix,i.ARRAY_BUFFER),l.instanceColor!==null&&e.update(l.instanceColor,i.ARRAY_BUFFER),s.set(l,c))),l.isSkinnedMesh){const d=l.skeleton;s.get(d)!==c&&(d.update(),s.set(d,c))}return u}function a(){s=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),e.remove(c.instanceMatrix),c.instanceColor!==null&&e.remove(c.instanceColor)}return{update:r,dispose:a}}class Eh extends rn{constructor(t,e,n,s,r,a,o,l,c,h=pr){if(h!==pr&&h!==ws)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&h===pr&&(n=bs),n===void 0&&h===ws&&(n=Ss),super(null,s,r,a,o,l,h,n,c),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=o!==void 0?o:sn,this.minFilter=l!==void 0?l:sn,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}}const Vf=new rn,Hu=new Eh(1,1),Gf=new kf,$f=new x0,Wf=new Bf,Vu=[],Gu=[],$u=new Float32Array(16),Wu=new Float32Array(9),Xu=new Float32Array(4);function Ar(i,t,e){const n=i[0];if(n<=0||n>0)return i;const s=t*e;let r=Vu[s];if(r===void 0&&(r=new Float32Array(s),Vu[s]=r),t!==0){n.toArray(r,0);for(let a=1,o=0;a!==t;++a)o+=e,i[a].toArray(r,o)}return r}function ze(i,t){if(i.length!==t.length)return!1;for(let e=0,n=i.length;e<n;e++)if(i[e]!==t[e])return!1;return!0}function Be(i,t){for(let e=0,n=t.length;e<n;e++)i[e]=t[e]}function Uo(i,t){let e=Gu[t];e===void 0&&(e=new Int32Array(t),Gu[t]=e);for(let n=0;n!==t;++n)e[n]=i.allocateTextureUnit();return e}function I_(i,t){const e=this.cache;e[0]!==t&&(i.uniform1f(this.addr,t),e[0]=t)}function k_(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(ze(e,t))return;i.uniform2fv(this.addr,t),Be(e,t)}}function N_(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3f(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else if(t.r!==void 0)(e[0]!==t.r||e[1]!==t.g||e[2]!==t.b)&&(i.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(ze(e,t))return;i.uniform3fv(this.addr,t),Be(e,t)}}function U_(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4f(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(ze(e,t))return;i.uniform4fv(this.addr,t),Be(e,t)}}function O_(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(ze(e,t))return;i.uniformMatrix2fv(this.addr,!1,t),Be(e,t)}else{if(ze(e,n))return;Xu.set(n),i.uniformMatrix2fv(this.addr,!1,Xu),Be(e,n)}}function F_(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(ze(e,t))return;i.uniformMatrix3fv(this.addr,!1,t),Be(e,t)}else{if(ze(e,n))return;Wu.set(n),i.uniformMatrix3fv(this.addr,!1,Wu),Be(e,n)}}function z_(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(ze(e,t))return;i.uniformMatrix4fv(this.addr,!1,t),Be(e,t)}else{if(ze(e,n))return;$u.set(n),i.uniformMatrix4fv(this.addr,!1,$u),Be(e,n)}}function B_(i,t){const e=this.cache;e[0]!==t&&(i.uniform1i(this.addr,t),e[0]=t)}function H_(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2i(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(ze(e,t))return;i.uniform2iv(this.addr,t),Be(e,t)}}function V_(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3i(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(ze(e,t))return;i.uniform3iv(this.addr,t),Be(e,t)}}function G_(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4i(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(ze(e,t))return;i.uniform4iv(this.addr,t),Be(e,t)}}function $_(i,t){const e=this.cache;e[0]!==t&&(i.uniform1ui(this.addr,t),e[0]=t)}function W_(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2ui(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(ze(e,t))return;i.uniform2uiv(this.addr,t),Be(e,t)}}function X_(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3ui(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(ze(e,t))return;i.uniform3uiv(this.addr,t),Be(e,t)}}function j_(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4ui(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(ze(e,t))return;i.uniform4uiv(this.addr,t),Be(e,t)}}function q_(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let r;this.type===i.SAMPLER_2D_SHADOW?(Hu.compareFunction=Lf,r=Hu):r=Vf,e.setTexture2D(t||r,s)}function Y_(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture3D(t||$f,s)}function K_(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTextureCube(t||Wf,s)}function Z_(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture2DArray(t||Gf,s)}function J_(i){switch(i){case 5126:return I_;case 35664:return k_;case 35665:return N_;case 35666:return U_;case 35674:return O_;case 35675:return F_;case 35676:return z_;case 5124:case 35670:return B_;case 35667:case 35671:return H_;case 35668:case 35672:return V_;case 35669:case 35673:return G_;case 5125:return $_;case 36294:return W_;case 36295:return X_;case 36296:return j_;case 35678:case 36198:case 36298:case 36306:case 35682:return q_;case 35679:case 36299:case 36307:return Y_;case 35680:case 36300:case 36308:case 36293:return K_;case 36289:case 36303:case 36311:case 36292:return Z_}}function Q_(i,t){i.uniform1fv(this.addr,t)}function tx(i,t){const e=Ar(t,this.size,2);i.uniform2fv(this.addr,e)}function ex(i,t){const e=Ar(t,this.size,3);i.uniform3fv(this.addr,e)}function nx(i,t){const e=Ar(t,this.size,4);i.uniform4fv(this.addr,e)}function ix(i,t){const e=Ar(t,this.size,4);i.uniformMatrix2fv(this.addr,!1,e)}function sx(i,t){const e=Ar(t,this.size,9);i.uniformMatrix3fv(this.addr,!1,e)}function rx(i,t){const e=Ar(t,this.size,16);i.uniformMatrix4fv(this.addr,!1,e)}function ax(i,t){i.uniform1iv(this.addr,t)}function ox(i,t){i.uniform2iv(this.addr,t)}function lx(i,t){i.uniform3iv(this.addr,t)}function cx(i,t){i.uniform4iv(this.addr,t)}function hx(i,t){i.uniform1uiv(this.addr,t)}function ux(i,t){i.uniform2uiv(this.addr,t)}function dx(i,t){i.uniform3uiv(this.addr,t)}function fx(i,t){i.uniform4uiv(this.addr,t)}function px(i,t,e){const n=this.cache,s=t.length,r=Uo(e,s);ze(n,r)||(i.uniform1iv(this.addr,r),Be(n,r));for(let a=0;a!==s;++a)e.setTexture2D(t[a]||Vf,r[a])}function mx(i,t,e){const n=this.cache,s=t.length,r=Uo(e,s);ze(n,r)||(i.uniform1iv(this.addr,r),Be(n,r));for(let a=0;a!==s;++a)e.setTexture3D(t[a]||$f,r[a])}function gx(i,t,e){const n=this.cache,s=t.length,r=Uo(e,s);ze(n,r)||(i.uniform1iv(this.addr,r),Be(n,r));for(let a=0;a!==s;++a)e.setTextureCube(t[a]||Wf,r[a])}function vx(i,t,e){const n=this.cache,s=t.length,r=Uo(e,s);ze(n,r)||(i.uniform1iv(this.addr,r),Be(n,r));for(let a=0;a!==s;++a)e.setTexture2DArray(t[a]||Gf,r[a])}function _x(i){switch(i){case 5126:return Q_;case 35664:return tx;case 35665:return ex;case 35666:return nx;case 35674:return ix;case 35675:return sx;case 35676:return rx;case 5124:case 35670:return ax;case 35667:case 35671:return ox;case 35668:case 35672:return lx;case 35669:case 35673:return cx;case 5125:return hx;case 36294:return ux;case 36295:return dx;case 36296:return fx;case 35678:case 36198:case 36298:case 36306:case 35682:return px;case 35679:case 36299:case 36307:return mx;case 35680:case 36300:case 36308:case 36293:return gx;case 36289:case 36303:case 36311:case 36292:return vx}}class xx{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=J_(e.type)}}class yx{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=_x(e.type)}}class Mx{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){const s=this.seq;for(let r=0,a=s.length;r!==a;++r){const o=s[r];o.setValue(t,e[o.id],n)}}}const Tl=/(\w+)(\])?(\[|\.)?/g;function ju(i,t){i.seq.push(t),i.map[t.id]=t}function bx(i,t,e){const n=i.name,s=n.length;for(Tl.lastIndex=0;;){const r=Tl.exec(n),a=Tl.lastIndex;let o=r[1];const l=r[2]==="]",c=r[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===s){ju(e,c===void 0?new xx(o,i,t):new yx(o,i,t));break}else{let u=e.map[o];u===void 0&&(u=new Mx(o),ju(e,u)),e=u}}}class ao{constructor(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){const r=t.getActiveUniform(e,s),a=t.getUniformLocation(e,r.name);bx(r,a,this)}}setValue(t,e,n,s){const r=this.map[e];r!==void 0&&r.setValue(t,n,s)}setOptional(t,e,n){const s=e[n];s!==void 0&&this.setValue(t,n,s)}static upload(t,e,n,s){for(let r=0,a=e.length;r!==a;++r){const o=e[r],l=n[o.id];l.needsUpdate!==!1&&o.setValue(t,l.value,s)}}static seqWithValue(t,e){const n=[];for(let s=0,r=t.length;s!==r;++s){const a=t[s];a.id in e&&n.push(a)}return n}}function qu(i,t,e){const n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}const Sx=37297;let wx=0;function Ex(i,t){const e=i.split(`
|
|
3739
3738
|
`),n=[],s=Math.max(t-6,0),r=Math.min(t+6,e.length);for(let a=s;a<r;a++){const o=a+1;n.push(`${o===t?">":" "} ${o}: ${e[a]}`)}return n.join(`
|
|
3740
|
-
`)}function
|
|
3739
|
+
`)}function Tx(i){const t=oe.getPrimaries(oe.workingColorSpace),e=oe.getPrimaries(i);let n;switch(t===e?n="":t===yo&&e===xo?n="LinearDisplayP3ToLinearSRGB":t===xo&&e===yo&&(n="LinearSRGBToLinearDisplayP3"),i){case os:case No:return[n,"LinearTransferOETF"];case Ye:case vh:return[n,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",i),[n,"LinearTransferOETF"]}}function Yu(i,t,e){const n=i.getShaderParameter(t,i.COMPILE_STATUS),s=i.getShaderInfoLog(t).trim();if(n&&s==="")return"";const r=/ERROR: 0:(\d+)/.exec(s);if(r){const a=parseInt(r[1]);return e.toUpperCase()+`
|
|
3741
3740
|
|
|
3742
3741
|
`+s+`
|
|
3743
3742
|
|
|
3744
|
-
`+
|
|
3745
|
-
`)}function
|
|
3746
|
-
`)}function
|
|
3747
|
-
`)}function
|
|
3743
|
+
`+Ex(i.getShaderSource(t),a)}else return s}function Ax(i,t){const e=Tx(t);return`vec4 ${i}( vec4 value ) { return ${e[0]}( ${e[1]}( value ) ); }`}function Cx(i,t){let e;switch(t){case mf:e="Linear";break;case gf:e="Reinhard";break;case vf:e="Cineon";break;case _f:e="ACESFilmic";break;case xf:e="AgX";break;case ch:e="Neutral";break;case Um:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+i+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}const Ia=new R;function Rx(){oe.getLuminanceCoefficients(Ia);const i=Ia.x.toFixed(4),t=Ia.y.toFixed(4),e=Ia.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${t}, ${e} );`," return dot( weights, rgb );","}"].join(`
|
|
3744
|
+
`)}function Px(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Wr).join(`
|
|
3745
|
+
`)}function Lx(i){const t=[];for(const e in i){const n=i[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(`
|
|
3746
|
+
`)}function Dx(i,t){const e={},n=i.getProgramParameter(t,i.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){const r=i.getActiveAttrib(t,s),a=r.name;let o=1;r.type===i.FLOAT_MAT2&&(o=2),r.type===i.FLOAT_MAT3&&(o=3),r.type===i.FLOAT_MAT4&&(o=4),e[a]={type:r.type,location:i.getAttribLocation(t,a),locationSize:o}}return e}function Wr(i){return i!==""}function Ku(i,t){const e=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,e).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Zu(i,t){return i.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const Ix=/^[ \t]*#include +<([\w\d./]+)>/gm;function Xc(i){return i.replace(Ix,Nx)}const kx=new Map;function Nx(i,t){let e=Wt[t];if(e===void 0){const n=kx.get(t);if(n!==void 0)e=Wt[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("Can not resolve #include <"+t+">")}return Xc(e)}const Ux=/#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 Ju(i){return i.replace(Ux,Ox)}function Ox(i,t,e,n){let s="";for(let r=parseInt(t);r<parseInt(e);r++)s+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function Qu(i){let t=`precision ${i.precision} float;
|
|
3748
3747
|
precision ${i.precision} int;
|
|
3749
3748
|
precision ${i.precision} sampler2D;
|
|
3750
3749
|
precision ${i.precision} samplerCube;
|
|
@@ -3764,30 +3763,30 @@ void main() {
|
|
|
3764
3763
|
`;return i.precision==="highp"?t+=`
|
|
3765
3764
|
#define HIGH_PRECISION`:i.precision==="mediump"?t+=`
|
|
3766
3765
|
#define MEDIUM_PRECISION`:i.precision==="lowp"&&(t+=`
|
|
3767
|
-
#define LOW_PRECISION`),t}function
|
|
3766
|
+
#define LOW_PRECISION`),t}function Fx(i){let t="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===uf?t="SHADOWMAP_TYPE_PCF":i.shadowMapType===df?t="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===Si&&(t="SHADOWMAP_TYPE_VSM"),t}function zx(i){let t="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case yr:case Mr:t="ENVMAP_TYPE_CUBE";break;case ko:t="ENVMAP_TYPE_CUBE_UV";break}return t}function Bx(i){let t="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case Mr:t="ENVMAP_MODE_REFRACTION";break}return t}function Hx(i){let t="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case pf:t="ENVMAP_BLENDING_MULTIPLY";break;case km:t="ENVMAP_BLENDING_MIX";break;case Nm:t="ENVMAP_BLENDING_ADD";break}return t}function Vx(i){const t=i.envMapCubeUVHeight;if(t===null)return null;const e=Math.log2(t)-2,n=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,e),7*16)),texelHeight:n,maxMip:e}}function Gx(i,t,e,n){const s=i.getContext(),r=e.defines;let a=e.vertexShader,o=e.fragmentShader;const l=Fx(e),c=zx(e),h=Bx(e),u=Hx(e),d=Vx(e),f=Px(e),g=Lx(r),_=s.createProgram();let m,p,y=e.glslVersion?"#version "+e.glslVersion+`
|
|
3768
3767
|
`:"";e.isRawShaderMaterial?(m=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(Wr).join(`
|
|
3769
3768
|
`),m.length>0&&(m+=`
|
|
3770
3769
|
`),p=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(Wr).join(`
|
|
3771
3770
|
`),p.length>0&&(p+=`
|
|
3772
|
-
`)):(m=[
|
|
3771
|
+
`)):(m=[Qu(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g,e.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",e.batching?"#define USE_BATCHING":"",e.batchingColor?"#define USE_BATCHING_COLOR":"",e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.instancingMorph?"#define USE_INSTANCING_MORPH":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+h:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.displacementMap?"#define USE_DISPLACEMENTMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.mapUv?"#define MAP_UV "+e.mapUv:"",e.alphaMapUv?"#define ALPHAMAP_UV "+e.alphaMapUv:"",e.lightMapUv?"#define LIGHTMAP_UV "+e.lightMapUv:"",e.aoMapUv?"#define AOMAP_UV "+e.aoMapUv:"",e.emissiveMapUv?"#define EMISSIVEMAP_UV "+e.emissiveMapUv:"",e.bumpMapUv?"#define BUMPMAP_UV "+e.bumpMapUv:"",e.normalMapUv?"#define NORMALMAP_UV "+e.normalMapUv:"",e.displacementMapUv?"#define DISPLACEMENTMAP_UV "+e.displacementMapUv:"",e.metalnessMapUv?"#define METALNESSMAP_UV "+e.metalnessMapUv:"",e.roughnessMapUv?"#define ROUGHNESSMAP_UV "+e.roughnessMapUv:"",e.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+e.anisotropyMapUv:"",e.clearcoatMapUv?"#define CLEARCOATMAP_UV "+e.clearcoatMapUv:"",e.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+e.clearcoatNormalMapUv:"",e.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+e.clearcoatRoughnessMapUv:"",e.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+e.iridescenceMapUv:"",e.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+e.iridescenceThicknessMapUv:"",e.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+e.sheenColorMapUv:"",e.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+e.sheenRoughnessMapUv:"",e.specularMapUv?"#define SPECULARMAP_UV "+e.specularMapUv:"",e.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+e.specularColorMapUv:"",e.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+e.specularIntensityMapUv:"",e.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+e.transmissionMapUv:"",e.thicknessMapUv?"#define THICKNESSMAP_UV "+e.thicknessMapUv:"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.morphColors?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","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",`
|
|
3773
3772
|
`].filter(Wr).join(`
|
|
3774
|
-
`),p=[
|
|
3773
|
+
`),p=[Qu(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+c:"",e.envMap?"#define "+h:"",e.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.dispersion?"#define USE_DISPERSION":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor||e.batchingColor?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==ns?"#define TONE_MAPPING":"",e.toneMapping!==ns?Wt.tonemapping_pars_fragment:"",e.toneMapping!==ns?Cx("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",Wt.colorspace_pars_fragment,Ax("linearToOutputTexel",e.outputColorSpace),Rx(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`
|
|
3775
3774
|
`].filter(Wr).join(`
|
|
3776
|
-
`)),a=
|
|
3775
|
+
`)),a=Xc(a),a=Ku(a,e),a=Zu(a,e),o=Xc(o),o=Ku(o,e),o=Zu(o,e),a=Ju(a),o=Ju(o),e.isRawShaderMaterial!==!0&&(y=`#version 300 es
|
|
3777
3776
|
`,m=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
3778
3777
|
`)+`
|
|
3779
|
-
`+m,p=["#define varying in",e.glslVersion===
|
|
3778
|
+
`+m,p=["#define varying in",e.glslVersion===gu?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===gu?"":"#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(`
|
|
3780
3779
|
`)+`
|
|
3781
|
-
`+p);const x=y+m+a,S=y+p+o,L=
|
|
3780
|
+
`+p);const x=y+m+a,S=y+p+o,L=qu(s,s.VERTEX_SHADER,x),T=qu(s,s.FRAGMENT_SHADER,S);s.attachShader(_,L),s.attachShader(_,T),e.index0AttributeName!==void 0?s.bindAttribLocation(_,0,e.index0AttributeName):e.morphTargets===!0&&s.bindAttribLocation(_,0,"position"),s.linkProgram(_);function E(b){if(i.debug.checkShaderErrors){const I=s.getProgramInfoLog(_).trim(),O=s.getShaderInfoLog(L).trim(),$=s.getShaderInfoLog(T).trim();let K=!0,z=!0;if(s.getProgramParameter(_,s.LINK_STATUS)===!1)if(K=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,_,L,T);else{const Z=Yu(s,L,"vertex"),V=Yu(s,T,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(_,s.VALIDATE_STATUS)+`
|
|
3782
3781
|
|
|
3783
3782
|
Material Name: `+b.name+`
|
|
3784
3783
|
Material Type: `+b.type+`
|
|
3785
3784
|
|
|
3786
3785
|
Program Info Log: `+I+`
|
|
3787
3786
|
`+Z+`
|
|
3788
|
-
`+V)}else I!==""?console.warn("THREE.WebGLProgram: Program Info Log:",I):(O===""||$==="")&&(z=!1);z&&(b.diagnostics={runnable:K,programLog:I,vertexShader:{log:O,prefix:m},fragmentShader:{log:$,prefix:p}})}s.deleteShader(L),s.deleteShader(T),P=new lo(s,_),U=Nx(s,_)}let P;this.getUniforms=function(){return P===void 0&&E(this),P};let U;this.getAttributes=function(){return U===void 0&&E(this),U};let v=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return v===!1&&(v=s.getProgramParameter(_,Tx)),v},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=Ax++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=L,this.fragmentShader=T,this}let jx=0;class qx{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,n=t.fragmentShader,s=this._getShaderStage(e),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(t);return a.has(s)===!1&&(a.add(s),s.usedTimes++),a.has(r)===!1&&(a.add(r),r.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return n===void 0&&(n=new Yx(t),e.set(t,n)),n}}class Yx{constructor(t){this.id=jx++,this.code=t,this.usedTimes=0}}function Kx(i,t,e,n,s,r,a){const o=new bh,l=new qx,c=new Set,h=[],u=s.logarithmicDepthBuffer,d=s.reverseDepthBuffer,f=s.vertexTextures;let g=s.precision;const _={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(v){return c.add(v),v===0?"uv":`uv${v}`}function p(v,b,I,O,$){const K=O.fog,z=$.geometry,Z=v.isMeshStandardMaterial?O.environment:null,V=(v.isMeshStandardMaterial?e:t).get(v.envMap||Z),at=V&&V.mapping===Uo?V.image.height:null,ct=_[v.type];v.precision!==null&&(g=s.getMaxPrecision(v.precision),g!==v.precision&&console.warn("THREE.WebGLProgram.getParameters:",v.precision,"not supported, using",g,"instead."));const _t=z.morphAttributes.position||z.morphAttributes.normal||z.morphAttributes.color,$t=_t!==void 0?_t.length:0;let Jt=0;z.morphAttributes.position!==void 0&&(Jt=1),z.morphAttributes.normal!==void 0&&(Jt=2),z.morphAttributes.color!==void 0&&(Jt=3);let X,et,ft,ot;if(ct){const mn=ai[ct];X=mn.vertexShader,et=mn.fragmentShader}else X=v.vertexShader,et=v.fragmentShader,l.update(v),ft=l.getVertexShaderID(v),ot=l.getFragmentShaderID(v);const At=i.getRenderTarget(),Tt=$.isInstancedMesh===!0,zt=$.isBatchedMesh===!0,ie=!!v.map,W=!!v.matcap,A=!!V,It=!!v.aoMap,Ct=!!v.lightMap,Bt=!!v.bumpMap,Dt=!!v.normalMap,ue=!!v.displacementMap,Nt=!!v.emissiveMap,C=!!v.metalnessMap,M=!!v.roughnessMap,F=v.anisotropy>0,Y=v.clearcoat>0,Q=v.dispersion>0,j=v.iridescence>0,St=v.sheen>0,ht=v.transmission>0,pt=F&&!!v.anisotropyMap,Yt=Y&&!!v.clearcoatMap,nt=Y&&!!v.clearcoatNormalMap,mt=Y&&!!v.clearcoatRoughnessMap,Ut=j&&!!v.iridescenceMap,Ot=j&&!!v.iridescenceThicknessMap,Mt=St&&!!v.sheenColorMap,Qt=St&&!!v.sheenRoughnessMap,Vt=!!v.specularMap,se=!!v.specularColorMap,D=!!v.specularIntensityMap,dt=ht&&!!v.transmissionMap,G=ht&&!!v.thicknessMap,J=!!v.gradientMap,gt=!!v.alphaMap,xt=v.alphaTest>0,ne=!!v.alphaHash,ke=!!v.extensions;let pn=ss;v.toneMapped&&(At===null||At.isXRRenderTarget===!0)&&(pn=i.toneMapping);const ae={shaderID:ct,shaderType:v.type,shaderName:v.name,vertexShader:X,fragmentShader:et,defines:v.defines,customVertexShaderID:ft,customFragmentShaderID:ot,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:g,batching:zt,batchingColor:zt&&$._colorsTexture!==null,instancing:Tt,instancingColor:Tt&&$.instanceColor!==null,instancingMorph:Tt&&$.morphTexture!==null,supportsVertexTextures:f,outputColorSpace:At===null?i.outputColorSpace:At.isXRRenderTarget===!0?At.texture.colorSpace:cs,alphaToCoverage:!!v.alphaToCoverage,map:ie,matcap:W,envMap:A,envMapMode:A&&V.mapping,envMapCubeUVHeight:at,aoMap:It,lightMap:Ct,bumpMap:Bt,normalMap:Dt,displacementMap:f&&ue,emissiveMap:Nt,normalMapObjectSpace:Dt&&v.normalMapType===Gm,normalMapTangentSpace:Dt&&v.normalMapType===vh,metalnessMap:C,roughnessMap:M,anisotropy:F,anisotropyMap:pt,clearcoat:Y,clearcoatMap:Yt,clearcoatNormalMap:nt,clearcoatRoughnessMap:mt,dispersion:Q,iridescence:j,iridescenceMap:Ut,iridescenceThicknessMap:Ot,sheen:St,sheenColorMap:Mt,sheenRoughnessMap:Qt,specularMap:Vt,specularColorMap:se,specularIntensityMap:D,transmission:ht,transmissionMap:dt,thicknessMap:G,gradientMap:J,opaque:v.transparent===!1&&v.blending===pr&&v.alphaToCoverage===!1,alphaMap:gt,alphaTest:xt,alphaHash:ne,combine:v.combine,mapUv:ie&&m(v.map.channel),aoMapUv:It&&m(v.aoMap.channel),lightMapUv:Ct&&m(v.lightMap.channel),bumpMapUv:Bt&&m(v.bumpMap.channel),normalMapUv:Dt&&m(v.normalMap.channel),displacementMapUv:ue&&m(v.displacementMap.channel),emissiveMapUv:Nt&&m(v.emissiveMap.channel),metalnessMapUv:C&&m(v.metalnessMap.channel),roughnessMapUv:M&&m(v.roughnessMap.channel),anisotropyMapUv:pt&&m(v.anisotropyMap.channel),clearcoatMapUv:Yt&&m(v.clearcoatMap.channel),clearcoatNormalMapUv:nt&&m(v.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:mt&&m(v.clearcoatRoughnessMap.channel),iridescenceMapUv:Ut&&m(v.iridescenceMap.channel),iridescenceThicknessMapUv:Ot&&m(v.iridescenceThicknessMap.channel),sheenColorMapUv:Mt&&m(v.sheenColorMap.channel),sheenRoughnessMapUv:Qt&&m(v.sheenRoughnessMap.channel),specularMapUv:Vt&&m(v.specularMap.channel),specularColorMapUv:se&&m(v.specularColorMap.channel),specularIntensityMapUv:D&&m(v.specularIntensityMap.channel),transmissionMapUv:dt&&m(v.transmissionMap.channel),thicknessMapUv:G&&m(v.thicknessMap.channel),alphaMapUv:gt&&m(v.alphaMap.channel),vertexTangents:!!z.attributes.tangent&&(Dt||F),vertexColors:v.vertexColors,vertexAlphas:v.vertexColors===!0&&!!z.attributes.color&&z.attributes.color.itemSize===4,pointsUvs:$.isPoints===!0&&!!z.attributes.uv&&(ie||gt),fog:!!K,useFog:v.fog===!0,fogExp2:!!K&&K.isFogExp2,flatShading:v.flatShading===!0,sizeAttenuation:v.sizeAttenuation===!0,logarithmicDepthBuffer:u,reverseDepthBuffer:d,skinning:$.isSkinnedMesh===!0,morphTargets:z.morphAttributes.position!==void 0,morphNormals:z.morphAttributes.normal!==void 0,morphColors:z.morphAttributes.color!==void 0,morphTargetsCount:$t,morphTextureStride:Jt,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:a.numPlanes,numClipIntersection:a.numIntersection,dithering:v.dithering,shadowMapEnabled:i.shadowMap.enabled&&I.length>0,shadowMapType:i.shadowMap.type,toneMapping:pn,decodeVideoTexture:ie&&v.map.isVideoTexture===!0&&oe.getTransfer(v.map.colorSpace)===ye,premultipliedAlpha:v.premultipliedAlpha,doubleSided:v.side===li,flipSided:v.side===un,useDepthPacking:v.depthPacking>=0,depthPacking:v.depthPacking||0,index0AttributeName:v.index0AttributeName,extensionClipCullDistance:ke&&v.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ke&&v.extensions.multiDraw===!0||zt)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:v.customProgramCacheKey()};return ae.vertexUv1s=c.has(1),ae.vertexUv2s=c.has(2),ae.vertexUv3s=c.has(3),c.clear(),ae}function y(v){const b=[];if(v.shaderID?b.push(v.shaderID):(b.push(v.customVertexShaderID),b.push(v.customFragmentShaderID)),v.defines!==void 0)for(const I in v.defines)b.push(I),b.push(v.defines[I]);return v.isRawShaderMaterial===!1&&(x(b,v),S(b,v),b.push(i.outputColorSpace)),b.push(v.customProgramCacheKey),b.join()}function x(v,b){v.push(b.precision),v.push(b.outputColorSpace),v.push(b.envMapMode),v.push(b.envMapCubeUVHeight),v.push(b.mapUv),v.push(b.alphaMapUv),v.push(b.lightMapUv),v.push(b.aoMapUv),v.push(b.bumpMapUv),v.push(b.normalMapUv),v.push(b.displacementMapUv),v.push(b.emissiveMapUv),v.push(b.metalnessMapUv),v.push(b.roughnessMapUv),v.push(b.anisotropyMapUv),v.push(b.clearcoatMapUv),v.push(b.clearcoatNormalMapUv),v.push(b.clearcoatRoughnessMapUv),v.push(b.iridescenceMapUv),v.push(b.iridescenceThicknessMapUv),v.push(b.sheenColorMapUv),v.push(b.sheenRoughnessMapUv),v.push(b.specularMapUv),v.push(b.specularColorMapUv),v.push(b.specularIntensityMapUv),v.push(b.transmissionMapUv),v.push(b.thicknessMapUv),v.push(b.combine),v.push(b.fogExp2),v.push(b.sizeAttenuation),v.push(b.morphTargetsCount),v.push(b.morphAttributeCount),v.push(b.numDirLights),v.push(b.numPointLights),v.push(b.numSpotLights),v.push(b.numSpotLightMaps),v.push(b.numHemiLights),v.push(b.numRectAreaLights),v.push(b.numDirLightShadows),v.push(b.numPointLightShadows),v.push(b.numSpotLightShadows),v.push(b.numSpotLightShadowsWithMaps),v.push(b.numLightProbes),v.push(b.shadowMapType),v.push(b.toneMapping),v.push(b.numClippingPlanes),v.push(b.numClipIntersection),v.push(b.depthPacking)}function S(v,b){o.disableAll(),b.supportsVertexTextures&&o.enable(0),b.instancing&&o.enable(1),b.instancingColor&&o.enable(2),b.instancingMorph&&o.enable(3),b.matcap&&o.enable(4),b.envMap&&o.enable(5),b.normalMapObjectSpace&&o.enable(6),b.normalMapTangentSpace&&o.enable(7),b.clearcoat&&o.enable(8),b.iridescence&&o.enable(9),b.alphaTest&&o.enable(10),b.vertexColors&&o.enable(11),b.vertexAlphas&&o.enable(12),b.vertexUv1s&&o.enable(13),b.vertexUv2s&&o.enable(14),b.vertexUv3s&&o.enable(15),b.vertexTangents&&o.enable(16),b.anisotropy&&o.enable(17),b.alphaHash&&o.enable(18),b.batching&&o.enable(19),b.dispersion&&o.enable(20),b.batchingColor&&o.enable(21),v.push(o.mask),o.disableAll(),b.fog&&o.enable(0),b.useFog&&o.enable(1),b.flatShading&&o.enable(2),b.logarithmicDepthBuffer&&o.enable(3),b.reverseDepthBuffer&&o.enable(4),b.skinning&&o.enable(5),b.morphTargets&&o.enable(6),b.morphNormals&&o.enable(7),b.morphColors&&o.enable(8),b.premultipliedAlpha&&o.enable(9),b.shadowMapEnabled&&o.enable(10),b.doubleSided&&o.enable(11),b.flipSided&&o.enable(12),b.useDepthPacking&&o.enable(13),b.dithering&&o.enable(14),b.transmission&&o.enable(15),b.sheen&&o.enable(16),b.opaque&&o.enable(17),b.pointsUvs&&o.enable(18),b.decodeVideoTexture&&o.enable(19),b.alphaToCoverage&&o.enable(20),v.push(o.mask)}function L(v){const b=_[v.type];let I;if(b){const O=ai[b];I=Qi.clone(O.uniforms)}else I=v.uniforms;return I}function T(v,b){let I;for(let O=0,$=h.length;O<$;O++){const K=h[O];if(K.cacheKey===b){I=K,++I.usedTimes;break}}return I===void 0&&(I=new Xx(i,b,v,r),h.push(I)),I}function E(v){if(--v.usedTimes===0){const b=h.indexOf(v);h[b]=h[h.length-1],h.pop(),v.destroy()}}function P(v){l.remove(v)}function U(){l.dispose()}return{getParameters:p,getProgramCacheKey:y,getUniforms:L,acquireProgram:T,releaseProgram:E,releaseShaderCache:P,programs:h,dispose:U}}function Zx(){let i=new WeakMap;function t(a){return i.has(a)}function e(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function s(a,o,l){i.get(a)[o]=l}function r(){i=new WeakMap}return{has:t,get:e,remove:n,update:s,dispose:r}}function Jx(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.material.id!==t.material.id?i.material.id-t.material.id:i.z!==t.z?i.z-t.z:i.id-t.id}function Qu(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.z!==t.z?t.z-i.z:i.id-t.id}function td(){const i=[];let t=0;const e=[],n=[],s=[];function r(){t=0,e.length=0,n.length=0,s.length=0}function a(u,d,f,g,_,m){let p=i[t];return p===void 0?(p={id:u.id,object:u,geometry:d,material:f,groupOrder:g,renderOrder:u.renderOrder,z:_,group:m},i[t]=p):(p.id=u.id,p.object=u,p.geometry=d,p.material=f,p.groupOrder=g,p.renderOrder=u.renderOrder,p.z=_,p.group=m),t++,p}function o(u,d,f,g,_,m){const p=a(u,d,f,g,_,m);f.transmission>0?n.push(p):f.transparent===!0?s.push(p):e.push(p)}function l(u,d,f,g,_,m){const p=a(u,d,f,g,_,m);f.transmission>0?n.unshift(p):f.transparent===!0?s.unshift(p):e.unshift(p)}function c(u,d){e.length>1&&e.sort(u||Jx),n.length>1&&n.sort(d||Qu),s.length>1&&s.sort(d||Qu)}function h(){for(let u=t,d=i.length;u<d;u++){const f=i[u];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:e,transmissive:n,transparent:s,init:r,push:o,unshift:l,finish:h,sort:c}}function Qx(){let i=new WeakMap;function t(n,s){const r=i.get(n);let a;return r===void 0?(a=new td,i.set(n,[a])):s>=r.length?(a=new td,r.push(a)):a=r[s],a}function e(){i=new WeakMap}return{get:t,dispose:e}}function ty(){const i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new R,color:new Zt};break;case"SpotLight":e={position:new R,direction:new R,color:new Zt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new R,color:new Zt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new R,skyColor:new Zt,groundColor:new Zt};break;case"RectAreaLight":e={color:new Zt,position:new R,halfWidth:new R,halfHeight:new R};break}return i[t.id]=e,e}}}function ey(){const i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new rt};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new rt};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new rt,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}let ny=0;function iy(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function sy(i){const t=new ty,e=ey(),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 R);const s=new R,r=new fe,a=new fe;function o(c){let h=0,u=0,d=0;for(let U=0;U<9;U++)n.probe[U].set(0,0,0);let f=0,g=0,_=0,m=0,p=0,y=0,x=0,S=0,L=0,T=0,E=0;c.sort(iy);for(let U=0,v=c.length;U<v;U++){const b=c[U],I=b.color,O=b.intensity,$=b.distance,K=b.shadow&&b.shadow.map?b.shadow.map.texture:null;if(b.isAmbientLight)h+=I.r*O,u+=I.g*O,d+=I.b*O;else if(b.isLightProbe){for(let z=0;z<9;z++)n.probe[z].addScaledVector(b.sh.coefficients[z],O);E++}else if(b.isDirectionalLight){const z=t.get(b);if(z.color.copy(b.color).multiplyScalar(b.intensity),b.castShadow){const Z=b.shadow,V=e.get(b);V.shadowIntensity=Z.intensity,V.shadowBias=Z.bias,V.shadowNormalBias=Z.normalBias,V.shadowRadius=Z.radius,V.shadowMapSize=Z.mapSize,n.directionalShadow[f]=V,n.directionalShadowMap[f]=K,n.directionalShadowMatrix[f]=b.shadow.matrix,y++}n.directional[f]=z,f++}else if(b.isSpotLight){const z=t.get(b);z.position.setFromMatrixPosition(b.matrixWorld),z.color.copy(I).multiplyScalar(O),z.distance=$,z.coneCos=Math.cos(b.angle),z.penumbraCos=Math.cos(b.angle*(1-b.penumbra)),z.decay=b.decay,n.spot[_]=z;const Z=b.shadow;if(b.map&&(n.spotLightMap[L]=b.map,L++,Z.updateMatrices(b),b.castShadow&&T++),n.spotLightMatrix[_]=Z.matrix,b.castShadow){const V=e.get(b);V.shadowIntensity=Z.intensity,V.shadowBias=Z.bias,V.shadowNormalBias=Z.normalBias,V.shadowRadius=Z.radius,V.shadowMapSize=Z.mapSize,n.spotShadow[_]=V,n.spotShadowMap[_]=K,S++}_++}else if(b.isRectAreaLight){const z=t.get(b);z.color.copy(I).multiplyScalar(O),z.halfWidth.set(b.width*.5,0,0),z.halfHeight.set(0,b.height*.5,0),n.rectArea[m]=z,m++}else if(b.isPointLight){const z=t.get(b);if(z.color.copy(b.color).multiplyScalar(b.intensity),z.distance=b.distance,z.decay=b.decay,b.castShadow){const Z=b.shadow,V=e.get(b);V.shadowIntensity=Z.intensity,V.shadowBias=Z.bias,V.shadowNormalBias=Z.normalBias,V.shadowRadius=Z.radius,V.shadowMapSize=Z.mapSize,V.shadowCameraNear=Z.camera.near,V.shadowCameraFar=Z.camera.far,n.pointShadow[g]=V,n.pointShadowMap[g]=K,n.pointShadowMatrix[g]=b.shadow.matrix,x++}n.point[g]=z,g++}else if(b.isHemisphereLight){const z=t.get(b);z.skyColor.copy(b.color).multiplyScalar(O),z.groundColor.copy(b.groundColor).multiplyScalar(O),n.hemi[p]=z,p++}}m>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=ut.LTC_FLOAT_1,n.rectAreaLTC2=ut.LTC_FLOAT_2):(n.rectAreaLTC1=ut.LTC_HALF_1,n.rectAreaLTC2=ut.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;const P=n.hash;(P.directionalLength!==f||P.pointLength!==g||P.spotLength!==_||P.rectAreaLength!==m||P.hemiLength!==p||P.numDirectionalShadows!==y||P.numPointShadows!==x||P.numSpotShadows!==S||P.numSpotMaps!==L||P.numLightProbes!==E)&&(n.directional.length=f,n.spot.length=_,n.rectArea.length=m,n.point.length=g,n.hemi.length=p,n.directionalShadow.length=y,n.directionalShadowMap.length=y,n.pointShadow.length=x,n.pointShadowMap.length=x,n.spotShadow.length=S,n.spotShadowMap.length=S,n.directionalShadowMatrix.length=y,n.pointShadowMatrix.length=x,n.spotLightMatrix.length=S+L-T,n.spotLightMap.length=L,n.numSpotLightShadowsWithMaps=T,n.numLightProbes=E,P.directionalLength=f,P.pointLength=g,P.spotLength=_,P.rectAreaLength=m,P.hemiLength=p,P.numDirectionalShadows=y,P.numPointShadows=x,P.numSpotShadows=S,P.numSpotMaps=L,P.numLightProbes=E,n.version=ny++)}function l(c,h){let u=0,d=0,f=0,g=0,_=0;const m=h.matrixWorldInverse;for(let p=0,y=c.length;p<y;p++){const x=c[p];if(x.isDirectionalLight){const S=n.directional[u];S.direction.setFromMatrixPosition(x.matrixWorld),s.setFromMatrixPosition(x.target.matrixWorld),S.direction.sub(s),S.direction.transformDirection(m),u++}else if(x.isSpotLight){const S=n.spot[f];S.position.setFromMatrixPosition(x.matrixWorld),S.position.applyMatrix4(m),S.direction.setFromMatrixPosition(x.matrixWorld),s.setFromMatrixPosition(x.target.matrixWorld),S.direction.sub(s),S.direction.transformDirection(m),f++}else if(x.isRectAreaLight){const S=n.rectArea[g];S.position.setFromMatrixPosition(x.matrixWorld),S.position.applyMatrix4(m),a.identity(),r.copy(x.matrixWorld),r.premultiply(m),a.extractRotation(r),S.halfWidth.set(x.width*.5,0,0),S.halfHeight.set(0,x.height*.5,0),S.halfWidth.applyMatrix4(a),S.halfHeight.applyMatrix4(a),g++}else if(x.isPointLight){const S=n.point[d];S.position.setFromMatrixPosition(x.matrixWorld),S.position.applyMatrix4(m),d++}else if(x.isHemisphereLight){const S=n.hemi[_];S.direction.setFromMatrixPosition(x.matrixWorld),S.direction.transformDirection(m),_++}}}return{setup:o,setupView:l,state:n}}function ed(i){const t=new sy(i),e=[],n=[];function s(h){c.camera=h,e.length=0,n.length=0}function r(h){e.push(h)}function a(h){n.push(h)}function o(){t.setup(e)}function l(h){t.setupView(e,h)}const c={lightsArray:e,shadowsArray:n,camera:null,lights:t,transmissionRenderTarget:{}};return{init:s,state:c,setupLights:o,setupLightsView:l,pushLight:r,pushShadow:a}}function ry(i){let t=new WeakMap;function e(s,r=0){const a=t.get(s);let o;return a===void 0?(o=new ed(i),t.set(s,[o])):r>=a.length?(o=new ed(i),a.push(o)):o=a[r],o}function n(){t=new WeakMap}return{get:e,dispose:n}}class ay extends Fi{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Hm,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class oy extends Fi{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}const ly=`void main() {
|
|
3787
|
+
`+V)}else I!==""?console.warn("THREE.WebGLProgram: Program Info Log:",I):(O===""||$==="")&&(z=!1);z&&(b.diagnostics={runnable:K,programLog:I,vertexShader:{log:O,prefix:m},fragmentShader:{log:$,prefix:p}})}s.deleteShader(L),s.deleteShader(T),P=new ao(s,_),U=Dx(s,_)}let P;this.getUniforms=function(){return P===void 0&&E(this),P};let U;this.getAttributes=function(){return U===void 0&&E(this),U};let v=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return v===!1&&(v=s.getProgramParameter(_,Sx)),v},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=wx++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=L,this.fragmentShader=T,this}let $x=0;class Wx{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,n=t.fragmentShader,s=this._getShaderStage(e),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(t);return a.has(s)===!1&&(a.add(s),s.usedTimes++),a.has(r)===!1&&(a.add(r),r.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return n===void 0&&(n=new Xx(t),e.set(t,n)),n}}class Xx{constructor(t){this.id=$x++,this.code=t,this.usedTimes=0}}function jx(i,t,e,n,s,r,a){const o=new Mh,l=new Wx,c=new Set,h=[],u=s.logarithmicDepthBuffer,d=s.reverseDepthBuffer,f=s.vertexTextures;let g=s.precision;const _={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(v){return c.add(v),v===0?"uv":`uv${v}`}function p(v,b,I,O,$){const K=O.fog,z=$.geometry,Z=v.isMeshStandardMaterial?O.environment:null,V=(v.isMeshStandardMaterial?e:t).get(v.envMap||Z),ot=V&&V.mapping===ko?V.image.height:null,ct=_[v.type];v.precision!==null&&(g=s.getMaxPrecision(v.precision),g!==v.precision&&console.warn("THREE.WebGLProgram.getParameters:",v.precision,"not supported, using",g,"instead."));const _t=z.morphAttributes.position||z.morphAttributes.normal||z.morphAttributes.color,$t=_t!==void 0?_t.length:0;let Jt=0;z.morphAttributes.position!==void 0&&(Jt=1),z.morphAttributes.normal!==void 0&&(Jt=2),z.morphAttributes.color!==void 0&&(Jt=3);let j,et,ft,lt;if(ct){const pn=si[ct];j=pn.vertexShader,et=pn.fragmentShader}else j=v.vertexShader,et=v.fragmentShader,l.update(v),ft=l.getVertexShaderID(v),lt=l.getFragmentShaderID(v);const At=i.getRenderTarget(),Tt=$.isInstancedMesh===!0,zt=$.isBatchedMesh===!0,ie=!!v.map,W=!!v.matcap,A=!!V,It=!!v.aoMap,Ct=!!v.lightMap,Bt=!!v.bumpMap,Dt=!!v.normalMap,ue=!!v.displacementMap,kt=!!v.emissiveMap,C=!!v.metalnessMap,M=!!v.roughnessMap,F=v.anisotropy>0,Y=v.clearcoat>0,Q=v.dispersion>0,q=v.iridescence>0,St=v.sheen>0,ht=v.transmission>0,pt=F&&!!v.anisotropyMap,Yt=Y&&!!v.clearcoatMap,it=Y&&!!v.clearcoatNormalMap,mt=Y&&!!v.clearcoatRoughnessMap,Ut=q&&!!v.iridescenceMap,Ot=q&&!!v.iridescenceThicknessMap,Mt=St&&!!v.sheenColorMap,Qt=St&&!!v.sheenRoughnessMap,Vt=!!v.specularMap,se=!!v.specularColorMap,D=!!v.specularIntensityMap,dt=ht&&!!v.transmissionMap,G=ht&&!!v.thicknessMap,J=!!v.gradientMap,gt=!!v.alphaMap,xt=v.alphaTest>0,ne=!!v.alphaHash,De=!!v.extensions;let fn=ns;v.toneMapped&&(At===null||At.isXRRenderTarget===!0)&&(fn=i.toneMapping);const ae={shaderID:ct,shaderType:v.type,shaderName:v.name,vertexShader:j,fragmentShader:et,defines:v.defines,customVertexShaderID:ft,customFragmentShaderID:lt,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:g,batching:zt,batchingColor:zt&&$._colorsTexture!==null,instancing:Tt,instancingColor:Tt&&$.instanceColor!==null,instancingMorph:Tt&&$.morphTexture!==null,supportsVertexTextures:f,outputColorSpace:At===null?i.outputColorSpace:At.isXRRenderTarget===!0?At.texture.colorSpace:os,alphaToCoverage:!!v.alphaToCoverage,map:ie,matcap:W,envMap:A,envMapMode:A&&V.mapping,envMapCubeUVHeight:ot,aoMap:It,lightMap:Ct,bumpMap:Bt,normalMap:Dt,displacementMap:f&&ue,emissiveMap:kt,normalMapObjectSpace:Dt&&v.normalMapType===Bm,normalMapTangentSpace:Dt&&v.normalMapType===gh,metalnessMap:C,roughnessMap:M,anisotropy:F,anisotropyMap:pt,clearcoat:Y,clearcoatMap:Yt,clearcoatNormalMap:it,clearcoatRoughnessMap:mt,dispersion:Q,iridescence:q,iridescenceMap:Ut,iridescenceThicknessMap:Ot,sheen:St,sheenColorMap:Mt,sheenRoughnessMap:Qt,specularMap:Vt,specularColorMap:se,specularIntensityMap:D,transmission:ht,transmissionMap:dt,thicknessMap:G,gradientMap:J,opaque:v.transparent===!1&&v.blending===fr&&v.alphaToCoverage===!1,alphaMap:gt,alphaTest:xt,alphaHash:ne,combine:v.combine,mapUv:ie&&m(v.map.channel),aoMapUv:It&&m(v.aoMap.channel),lightMapUv:Ct&&m(v.lightMap.channel),bumpMapUv:Bt&&m(v.bumpMap.channel),normalMapUv:Dt&&m(v.normalMap.channel),displacementMapUv:ue&&m(v.displacementMap.channel),emissiveMapUv:kt&&m(v.emissiveMap.channel),metalnessMapUv:C&&m(v.metalnessMap.channel),roughnessMapUv:M&&m(v.roughnessMap.channel),anisotropyMapUv:pt&&m(v.anisotropyMap.channel),clearcoatMapUv:Yt&&m(v.clearcoatMap.channel),clearcoatNormalMapUv:it&&m(v.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:mt&&m(v.clearcoatRoughnessMap.channel),iridescenceMapUv:Ut&&m(v.iridescenceMap.channel),iridescenceThicknessMapUv:Ot&&m(v.iridescenceThicknessMap.channel),sheenColorMapUv:Mt&&m(v.sheenColorMap.channel),sheenRoughnessMapUv:Qt&&m(v.sheenRoughnessMap.channel),specularMapUv:Vt&&m(v.specularMap.channel),specularColorMapUv:se&&m(v.specularColorMap.channel),specularIntensityMapUv:D&&m(v.specularIntensityMap.channel),transmissionMapUv:dt&&m(v.transmissionMap.channel),thicknessMapUv:G&&m(v.thicknessMap.channel),alphaMapUv:gt&&m(v.alphaMap.channel),vertexTangents:!!z.attributes.tangent&&(Dt||F),vertexColors:v.vertexColors,vertexAlphas:v.vertexColors===!0&&!!z.attributes.color&&z.attributes.color.itemSize===4,pointsUvs:$.isPoints===!0&&!!z.attributes.uv&&(ie||gt),fog:!!K,useFog:v.fog===!0,fogExp2:!!K&&K.isFogExp2,flatShading:v.flatShading===!0,sizeAttenuation:v.sizeAttenuation===!0,logarithmicDepthBuffer:u,reverseDepthBuffer:d,skinning:$.isSkinnedMesh===!0,morphTargets:z.morphAttributes.position!==void 0,morphNormals:z.morphAttributes.normal!==void 0,morphColors:z.morphAttributes.color!==void 0,morphTargetsCount:$t,morphTextureStride:Jt,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:a.numPlanes,numClipIntersection:a.numIntersection,dithering:v.dithering,shadowMapEnabled:i.shadowMap.enabled&&I.length>0,shadowMapType:i.shadowMap.type,toneMapping:fn,decodeVideoTexture:ie&&v.map.isVideoTexture===!0&&oe.getTransfer(v.map.colorSpace)===ye,premultipliedAlpha:v.premultipliedAlpha,doubleSided:v.side===ai,flipSided:v.side===hn,useDepthPacking:v.depthPacking>=0,depthPacking:v.depthPacking||0,index0AttributeName:v.index0AttributeName,extensionClipCullDistance:De&&v.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(De&&v.extensions.multiDraw===!0||zt)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:v.customProgramCacheKey()};return ae.vertexUv1s=c.has(1),ae.vertexUv2s=c.has(2),ae.vertexUv3s=c.has(3),c.clear(),ae}function y(v){const b=[];if(v.shaderID?b.push(v.shaderID):(b.push(v.customVertexShaderID),b.push(v.customFragmentShaderID)),v.defines!==void 0)for(const I in v.defines)b.push(I),b.push(v.defines[I]);return v.isRawShaderMaterial===!1&&(x(b,v),S(b,v),b.push(i.outputColorSpace)),b.push(v.customProgramCacheKey),b.join()}function x(v,b){v.push(b.precision),v.push(b.outputColorSpace),v.push(b.envMapMode),v.push(b.envMapCubeUVHeight),v.push(b.mapUv),v.push(b.alphaMapUv),v.push(b.lightMapUv),v.push(b.aoMapUv),v.push(b.bumpMapUv),v.push(b.normalMapUv),v.push(b.displacementMapUv),v.push(b.emissiveMapUv),v.push(b.metalnessMapUv),v.push(b.roughnessMapUv),v.push(b.anisotropyMapUv),v.push(b.clearcoatMapUv),v.push(b.clearcoatNormalMapUv),v.push(b.clearcoatRoughnessMapUv),v.push(b.iridescenceMapUv),v.push(b.iridescenceThicknessMapUv),v.push(b.sheenColorMapUv),v.push(b.sheenRoughnessMapUv),v.push(b.specularMapUv),v.push(b.specularColorMapUv),v.push(b.specularIntensityMapUv),v.push(b.transmissionMapUv),v.push(b.thicknessMapUv),v.push(b.combine),v.push(b.fogExp2),v.push(b.sizeAttenuation),v.push(b.morphTargetsCount),v.push(b.morphAttributeCount),v.push(b.numDirLights),v.push(b.numPointLights),v.push(b.numSpotLights),v.push(b.numSpotLightMaps),v.push(b.numHemiLights),v.push(b.numRectAreaLights),v.push(b.numDirLightShadows),v.push(b.numPointLightShadows),v.push(b.numSpotLightShadows),v.push(b.numSpotLightShadowsWithMaps),v.push(b.numLightProbes),v.push(b.shadowMapType),v.push(b.toneMapping),v.push(b.numClippingPlanes),v.push(b.numClipIntersection),v.push(b.depthPacking)}function S(v,b){o.disableAll(),b.supportsVertexTextures&&o.enable(0),b.instancing&&o.enable(1),b.instancingColor&&o.enable(2),b.instancingMorph&&o.enable(3),b.matcap&&o.enable(4),b.envMap&&o.enable(5),b.normalMapObjectSpace&&o.enable(6),b.normalMapTangentSpace&&o.enable(7),b.clearcoat&&o.enable(8),b.iridescence&&o.enable(9),b.alphaTest&&o.enable(10),b.vertexColors&&o.enable(11),b.vertexAlphas&&o.enable(12),b.vertexUv1s&&o.enable(13),b.vertexUv2s&&o.enable(14),b.vertexUv3s&&o.enable(15),b.vertexTangents&&o.enable(16),b.anisotropy&&o.enable(17),b.alphaHash&&o.enable(18),b.batching&&o.enable(19),b.dispersion&&o.enable(20),b.batchingColor&&o.enable(21),v.push(o.mask),o.disableAll(),b.fog&&o.enable(0),b.useFog&&o.enable(1),b.flatShading&&o.enable(2),b.logarithmicDepthBuffer&&o.enable(3),b.reverseDepthBuffer&&o.enable(4),b.skinning&&o.enable(5),b.morphTargets&&o.enable(6),b.morphNormals&&o.enable(7),b.morphColors&&o.enable(8),b.premultipliedAlpha&&o.enable(9),b.shadowMapEnabled&&o.enable(10),b.doubleSided&&o.enable(11),b.flipSided&&o.enable(12),b.useDepthPacking&&o.enable(13),b.dithering&&o.enable(14),b.transmission&&o.enable(15),b.sheen&&o.enable(16),b.opaque&&o.enable(17),b.pointsUvs&&o.enable(18),b.decodeVideoTexture&&o.enable(19),b.alphaToCoverage&&o.enable(20),v.push(o.mask)}function L(v){const b=_[v.type];let I;if(b){const O=si[b];I=Zi.clone(O.uniforms)}else I=v.uniforms;return I}function T(v,b){let I;for(let O=0,$=h.length;O<$;O++){const K=h[O];if(K.cacheKey===b){I=K,++I.usedTimes;break}}return I===void 0&&(I=new Gx(i,b,v,r),h.push(I)),I}function E(v){if(--v.usedTimes===0){const b=h.indexOf(v);h[b]=h[h.length-1],h.pop(),v.destroy()}}function P(v){l.remove(v)}function U(){l.dispose()}return{getParameters:p,getProgramCacheKey:y,getUniforms:L,acquireProgram:T,releaseProgram:E,releaseShaderCache:P,programs:h,dispose:U}}function qx(){let i=new WeakMap;function t(a){return i.has(a)}function e(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function s(a,o,l){i.get(a)[o]=l}function r(){i=new WeakMap}return{has:t,get:e,remove:n,update:s,dispose:r}}function Yx(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.material.id!==t.material.id?i.material.id-t.material.id:i.z!==t.z?i.z-t.z:i.id-t.id}function td(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.z!==t.z?t.z-i.z:i.id-t.id}function ed(){const i=[];let t=0;const e=[],n=[],s=[];function r(){t=0,e.length=0,n.length=0,s.length=0}function a(u,d,f,g,_,m){let p=i[t];return p===void 0?(p={id:u.id,object:u,geometry:d,material:f,groupOrder:g,renderOrder:u.renderOrder,z:_,group:m},i[t]=p):(p.id=u.id,p.object=u,p.geometry=d,p.material=f,p.groupOrder=g,p.renderOrder=u.renderOrder,p.z=_,p.group=m),t++,p}function o(u,d,f,g,_,m){const p=a(u,d,f,g,_,m);f.transmission>0?n.push(p):f.transparent===!0?s.push(p):e.push(p)}function l(u,d,f,g,_,m){const p=a(u,d,f,g,_,m);f.transmission>0?n.unshift(p):f.transparent===!0?s.unshift(p):e.unshift(p)}function c(u,d){e.length>1&&e.sort(u||Yx),n.length>1&&n.sort(d||td),s.length>1&&s.sort(d||td)}function h(){for(let u=t,d=i.length;u<d;u++){const f=i[u];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:e,transmissive:n,transparent:s,init:r,push:o,unshift:l,finish:h,sort:c}}function Kx(){let i=new WeakMap;function t(n,s){const r=i.get(n);let a;return r===void 0?(a=new ed,i.set(n,[a])):s>=r.length?(a=new ed,r.push(a)):a=r[s],a}function e(){i=new WeakMap}return{get:t,dispose:e}}function Zx(){const i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new R,color:new Zt};break;case"SpotLight":e={position:new R,direction:new R,color:new Zt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new R,color:new Zt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new R,skyColor:new Zt,groundColor:new Zt};break;case"RectAreaLight":e={color:new Zt,position:new R,halfWidth:new R,halfHeight:new R};break}return i[t.id]=e,e}}}function Jx(){const i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new at};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new at};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new at,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}let Qx=0;function ty(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function ey(i){const t=new Zx,e=Jx(),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 R);const s=new R,r=new fe,a=new fe;function o(c){let h=0,u=0,d=0;for(let U=0;U<9;U++)n.probe[U].set(0,0,0);let f=0,g=0,_=0,m=0,p=0,y=0,x=0,S=0,L=0,T=0,E=0;c.sort(ty);for(let U=0,v=c.length;U<v;U++){const b=c[U],I=b.color,O=b.intensity,$=b.distance,K=b.shadow&&b.shadow.map?b.shadow.map.texture:null;if(b.isAmbientLight)h+=I.r*O,u+=I.g*O,d+=I.b*O;else if(b.isLightProbe){for(let z=0;z<9;z++)n.probe[z].addScaledVector(b.sh.coefficients[z],O);E++}else if(b.isDirectionalLight){const z=t.get(b);if(z.color.copy(b.color).multiplyScalar(b.intensity),b.castShadow){const Z=b.shadow,V=e.get(b);V.shadowIntensity=Z.intensity,V.shadowBias=Z.bias,V.shadowNormalBias=Z.normalBias,V.shadowRadius=Z.radius,V.shadowMapSize=Z.mapSize,n.directionalShadow[f]=V,n.directionalShadowMap[f]=K,n.directionalShadowMatrix[f]=b.shadow.matrix,y++}n.directional[f]=z,f++}else if(b.isSpotLight){const z=t.get(b);z.position.setFromMatrixPosition(b.matrixWorld),z.color.copy(I).multiplyScalar(O),z.distance=$,z.coneCos=Math.cos(b.angle),z.penumbraCos=Math.cos(b.angle*(1-b.penumbra)),z.decay=b.decay,n.spot[_]=z;const Z=b.shadow;if(b.map&&(n.spotLightMap[L]=b.map,L++,Z.updateMatrices(b),b.castShadow&&T++),n.spotLightMatrix[_]=Z.matrix,b.castShadow){const V=e.get(b);V.shadowIntensity=Z.intensity,V.shadowBias=Z.bias,V.shadowNormalBias=Z.normalBias,V.shadowRadius=Z.radius,V.shadowMapSize=Z.mapSize,n.spotShadow[_]=V,n.spotShadowMap[_]=K,S++}_++}else if(b.isRectAreaLight){const z=t.get(b);z.color.copy(I).multiplyScalar(O),z.halfWidth.set(b.width*.5,0,0),z.halfHeight.set(0,b.height*.5,0),n.rectArea[m]=z,m++}else if(b.isPointLight){const z=t.get(b);if(z.color.copy(b.color).multiplyScalar(b.intensity),z.distance=b.distance,z.decay=b.decay,b.castShadow){const Z=b.shadow,V=e.get(b);V.shadowIntensity=Z.intensity,V.shadowBias=Z.bias,V.shadowNormalBias=Z.normalBias,V.shadowRadius=Z.radius,V.shadowMapSize=Z.mapSize,V.shadowCameraNear=Z.camera.near,V.shadowCameraFar=Z.camera.far,n.pointShadow[g]=V,n.pointShadowMap[g]=K,n.pointShadowMatrix[g]=b.shadow.matrix,x++}n.point[g]=z,g++}else if(b.isHemisphereLight){const z=t.get(b);z.skyColor.copy(b.color).multiplyScalar(O),z.groundColor.copy(b.groundColor).multiplyScalar(O),n.hemi[p]=z,p++}}m>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=ut.LTC_FLOAT_1,n.rectAreaLTC2=ut.LTC_FLOAT_2):(n.rectAreaLTC1=ut.LTC_HALF_1,n.rectAreaLTC2=ut.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;const P=n.hash;(P.directionalLength!==f||P.pointLength!==g||P.spotLength!==_||P.rectAreaLength!==m||P.hemiLength!==p||P.numDirectionalShadows!==y||P.numPointShadows!==x||P.numSpotShadows!==S||P.numSpotMaps!==L||P.numLightProbes!==E)&&(n.directional.length=f,n.spot.length=_,n.rectArea.length=m,n.point.length=g,n.hemi.length=p,n.directionalShadow.length=y,n.directionalShadowMap.length=y,n.pointShadow.length=x,n.pointShadowMap.length=x,n.spotShadow.length=S,n.spotShadowMap.length=S,n.directionalShadowMatrix.length=y,n.pointShadowMatrix.length=x,n.spotLightMatrix.length=S+L-T,n.spotLightMap.length=L,n.numSpotLightShadowsWithMaps=T,n.numLightProbes=E,P.directionalLength=f,P.pointLength=g,P.spotLength=_,P.rectAreaLength=m,P.hemiLength=p,P.numDirectionalShadows=y,P.numPointShadows=x,P.numSpotShadows=S,P.numSpotMaps=L,P.numLightProbes=E,n.version=Qx++)}function l(c,h){let u=0,d=0,f=0,g=0,_=0;const m=h.matrixWorldInverse;for(let p=0,y=c.length;p<y;p++){const x=c[p];if(x.isDirectionalLight){const S=n.directional[u];S.direction.setFromMatrixPosition(x.matrixWorld),s.setFromMatrixPosition(x.target.matrixWorld),S.direction.sub(s),S.direction.transformDirection(m),u++}else if(x.isSpotLight){const S=n.spot[f];S.position.setFromMatrixPosition(x.matrixWorld),S.position.applyMatrix4(m),S.direction.setFromMatrixPosition(x.matrixWorld),s.setFromMatrixPosition(x.target.matrixWorld),S.direction.sub(s),S.direction.transformDirection(m),f++}else if(x.isRectAreaLight){const S=n.rectArea[g];S.position.setFromMatrixPosition(x.matrixWorld),S.position.applyMatrix4(m),a.identity(),r.copy(x.matrixWorld),r.premultiply(m),a.extractRotation(r),S.halfWidth.set(x.width*.5,0,0),S.halfHeight.set(0,x.height*.5,0),S.halfWidth.applyMatrix4(a),S.halfHeight.applyMatrix4(a),g++}else if(x.isPointLight){const S=n.point[d];S.position.setFromMatrixPosition(x.matrixWorld),S.position.applyMatrix4(m),d++}else if(x.isHemisphereLight){const S=n.hemi[_];S.direction.setFromMatrixPosition(x.matrixWorld),S.direction.transformDirection(m),_++}}}return{setup:o,setupView:l,state:n}}function nd(i){const t=new ey(i),e=[],n=[];function s(h){c.camera=h,e.length=0,n.length=0}function r(h){e.push(h)}function a(h){n.push(h)}function o(){t.setup(e)}function l(h){t.setupView(e,h)}const c={lightsArray:e,shadowsArray:n,camera:null,lights:t,transmissionRenderTarget:{}};return{init:s,state:c,setupLights:o,setupLightsView:l,pushLight:r,pushShadow:a}}function ny(i){let t=new WeakMap;function e(s,r=0){const a=t.get(s);let o;return a===void 0?(o=new nd(i),t.set(s,[o])):r>=a.length?(o=new nd(i),a.push(o)):o=a[r],o}function n(){t=new WeakMap}return{get:e,dispose:n}}class iy extends Oi{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Fm,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class sy extends Oi{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}const ry=`void main() {
|
|
3789
3788
|
gl_Position = vec4( position, 1.0 );
|
|
3790
|
-
}`,
|
|
3789
|
+
}`,ay=`uniform sampler2D shadow_pass;
|
|
3791
3790
|
uniform vec2 resolution;
|
|
3792
3791
|
uniform float radius;
|
|
3793
3792
|
#include <packing>
|
|
@@ -3813,12 +3812,12 @@ void main() {
|
|
|
3813
3812
|
squared_mean = squared_mean / samples;
|
|
3814
3813
|
float std_dev = sqrt( squared_mean - mean * mean );
|
|
3815
3814
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
3816
|
-
}`;function hy(i,t,e){let n=new Sh;const s=new rt,r=new rt,a=new me,o=new ay({depthPacking:Vm}),l=new oy,c={},h=e.maxTextureSize,u={[os]:un,[un]:os,[li]:li},d=new nn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new rt},radius:{value:4}},vertexShader:ly,fragmentShader:cy}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const g=new fn;g.setAttribute("position",new ui(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new yt(g,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ff;let p=this.type;this.render=function(T,E,P){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||T.length===0)return;const U=i.getRenderTarget(),v=i.getActiveCubeFace(),b=i.getActiveMipmapLevel(),I=i.state;I.setBlending(Ye),I.buffers.color.setClear(1,1,1,1),I.buffers.depth.setTest(!0),I.setScissorTest(!1);const O=p!==Ei&&this.type===Ei,$=p===Ei&&this.type!==Ei;for(let K=0,z=T.length;K<z;K++){const Z=T[K],V=Z.shadow;if(V===void 0){console.warn("THREE.WebGLShadowMap:",Z,"has no shadow.");continue}if(V.autoUpdate===!1&&V.needsUpdate===!1)continue;s.copy(V.mapSize);const at=V.getFrameExtents();if(s.multiply(at),r.copy(V.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/at.x),s.x=r.x*at.x,V.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/at.y),s.y=r.y*at.y,V.mapSize.y=r.y)),V.map===null||O===!0||$===!0){const _t=this.type!==Ei?{minFilter:rn,magFilter:rn}:{};V.map!==null&&V.map.dispose(),V.map=new Qn(s.x,s.y,_t),V.map.texture.name=Z.name+".shadowMap",V.camera.updateProjectionMatrix()}i.setRenderTarget(V.map),i.clear();const ct=V.getViewportCount();for(let _t=0;_t<ct;_t++){const $t=V.getViewport(_t);a.set(r.x*$t.x,r.y*$t.y,r.x*$t.z,r.y*$t.w),I.viewport(a),V.updateMatrices(Z,_t),n=V.getFrustum(),S(E,P,V.camera,Z,this.type)}V.isPointLightShadow!==!0&&this.type===Ei&&y(V,P),V.needsUpdate=!1}p=this.type,m.needsUpdate=!1,i.setRenderTarget(U,v,b)};function y(T,E){const P=t.update(_);d.defines.VSM_SAMPLES!==T.blurSamples&&(d.defines.VSM_SAMPLES=T.blurSamples,f.defines.VSM_SAMPLES=T.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new Qn(s.x,s.y)),d.uniforms.shadow_pass.value=T.map.texture,d.uniforms.resolution.value=T.mapSize,d.uniforms.radius.value=T.radius,i.setRenderTarget(T.mapPass),i.clear(),i.renderBufferDirect(E,null,P,d,_,null),f.uniforms.shadow_pass.value=T.mapPass.texture,f.uniforms.resolution.value=T.mapSize,f.uniforms.radius.value=T.radius,i.setRenderTarget(T.map),i.clear(),i.renderBufferDirect(E,null,P,f,_,null)}function x(T,E,P,U){let v=null;const b=P.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(b!==void 0)v=b;else if(v=P.isPointLight===!0?l:o,i.localClippingEnabled&&E.clipShadows===!0&&Array.isArray(E.clippingPlanes)&&E.clippingPlanes.length!==0||E.displacementMap&&E.displacementScale!==0||E.alphaMap&&E.alphaTest>0||E.map&&E.alphaTest>0){const I=v.uuid,O=E.uuid;let $=c[I];$===void 0&&($={},c[I]=$);let K=$[O];K===void 0&&(K=v.clone(),$[O]=K,E.addEventListener("dispose",L)),v=K}if(v.visible=E.visible,v.wireframe=E.wireframe,U===Ei?v.side=E.shadowSide!==null?E.shadowSide:E.side:v.side=E.shadowSide!==null?E.shadowSide:u[E.side],v.alphaMap=E.alphaMap,v.alphaTest=E.alphaTest,v.map=E.map,v.clipShadows=E.clipShadows,v.clippingPlanes=E.clippingPlanes,v.clipIntersection=E.clipIntersection,v.displacementMap=E.displacementMap,v.displacementScale=E.displacementScale,v.displacementBias=E.displacementBias,v.wireframeLinewidth=E.wireframeLinewidth,v.linewidth=E.linewidth,P.isPointLight===!0&&v.isMeshDistanceMaterial===!0){const I=i.properties.get(v);I.light=P}return v}function S(T,E,P,U,v){if(T.visible===!1)return;if(T.layers.test(E.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&v===Ei)&&(!T.frustumCulled||n.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(P.matrixWorldInverse,T.matrixWorld);const O=t.update(T),$=T.material;if(Array.isArray($)){const K=O.groups;for(let z=0,Z=K.length;z<Z;z++){const V=K[z],at=$[V.materialIndex];if(at&&at.visible){const ct=x(T,at,U,v);T.onBeforeShadow(i,T,E,P,O,ct,V),i.renderBufferDirect(P,null,O,ct,T,V),T.onAfterShadow(i,T,E,P,O,ct,V)}}}else if($.visible){const K=x(T,$,U,v);T.onBeforeShadow(i,T,E,P,O,K,null),i.renderBufferDirect(P,null,O,K,T,null),T.onAfterShadow(i,T,E,P,O,K,null)}}const I=T.children;for(let O=0,$=I.length;O<$;O++)S(I[O],E,P,U,v)}function L(T){T.target.removeEventListener("dispose",L);for(const P in c){const U=c[P],v=T.target.uuid;v in U&&(U[v].dispose(),delete U[v])}}}const uy={[uc]:dc,[fc]:gc,[pc]:vc,[xr]:mc,[dc]:uc,[gc]:fc,[vc]:pc,[mc]:xr};function dy(i){function t(){let D=!1;const dt=new me;let G=null;const J=new me(0,0,0,0);return{setMask:function(gt){G!==gt&&!D&&(i.colorMask(gt,gt,gt,gt),G=gt)},setLocked:function(gt){D=gt},setClear:function(gt,xt,ne,ke,pn){pn===!0&&(gt*=ke,xt*=ke,ne*=ke),dt.set(gt,xt,ne,ke),J.equals(dt)===!1&&(i.clearColor(gt,xt,ne,ke),J.copy(dt))},reset:function(){D=!1,G=null,J.set(-1,0,0,0)}}}function e(){let D=!1,dt=!1,G=null,J=null,gt=null;return{setReversed:function(xt){dt=xt},setTest:function(xt){xt?ft(i.DEPTH_TEST):ot(i.DEPTH_TEST)},setMask:function(xt){G!==xt&&!D&&(i.depthMask(xt),G=xt)},setFunc:function(xt){if(dt&&(xt=uy[xt]),J!==xt){switch(xt){case uc:i.depthFunc(i.NEVER);break;case dc:i.depthFunc(i.ALWAYS);break;case fc:i.depthFunc(i.LESS);break;case xr:i.depthFunc(i.LEQUAL);break;case pc:i.depthFunc(i.EQUAL);break;case mc:i.depthFunc(i.GEQUAL);break;case gc:i.depthFunc(i.GREATER);break;case vc:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}J=xt}},setLocked:function(xt){D=xt},setClear:function(xt){gt!==xt&&(i.clearDepth(xt),gt=xt)},reset:function(){D=!1,G=null,J=null,gt=null}}}function n(){let D=!1,dt=null,G=null,J=null,gt=null,xt=null,ne=null,ke=null,pn=null;return{setTest:function(ae){D||(ae?ft(i.STENCIL_TEST):ot(i.STENCIL_TEST))},setMask:function(ae){dt!==ae&&!D&&(i.stencilMask(ae),dt=ae)},setFunc:function(ae,mn,_i){(G!==ae||J!==mn||gt!==_i)&&(i.stencilFunc(ae,mn,_i),G=ae,J=mn,gt=_i)},setOp:function(ae,mn,_i){(xt!==ae||ne!==mn||ke!==_i)&&(i.stencilOp(ae,mn,_i),xt=ae,ne=mn,ke=_i)},setLocked:function(ae){D=ae},setClear:function(ae){pn!==ae&&(i.clearStencil(ae),pn=ae)},reset:function(){D=!1,dt=null,G=null,J=null,gt=null,xt=null,ne=null,ke=null,pn=null}}}const s=new t,r=new e,a=new n,o=new WeakMap,l=new WeakMap;let c={},h={},u=new WeakMap,d=[],f=null,g=!1,_=null,m=null,p=null,y=null,x=null,S=null,L=null,T=new Zt(0,0,0),E=0,P=!1,U=null,v=null,b=null,I=null,O=null;const $=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,z=0;const Z=i.getParameter(i.VERSION);Z.indexOf("WebGL")!==-1?(z=parseFloat(/^WebGL (\d)/.exec(Z)[1]),K=z>=1):Z.indexOf("OpenGL ES")!==-1&&(z=parseFloat(/^OpenGL ES (\d)/.exec(Z)[1]),K=z>=2);let V=null,at={};const ct=i.getParameter(i.SCISSOR_BOX),_t=i.getParameter(i.VIEWPORT),$t=new me().fromArray(ct),Jt=new me().fromArray(_t);function X(D,dt,G,J){const gt=new Uint8Array(4),xt=i.createTexture();i.bindTexture(D,xt),i.texParameteri(D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(D,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let ne=0;ne<G;ne++)D===i.TEXTURE_3D||D===i.TEXTURE_2D_ARRAY?i.texImage3D(dt,0,i.RGBA,1,1,J,0,i.RGBA,i.UNSIGNED_BYTE,gt):i.texImage2D(dt+ne,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,gt);return xt}const et={};et[i.TEXTURE_2D]=X(i.TEXTURE_2D,i.TEXTURE_2D,1),et[i.TEXTURE_CUBE_MAP]=X(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),et[i.TEXTURE_2D_ARRAY]=X(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),et[i.TEXTURE_3D]=X(i.TEXTURE_3D,i.TEXTURE_3D,1,1),s.setClear(0,0,0,1),r.setClear(1),a.setClear(0),ft(i.DEPTH_TEST),r.setFunc(xr),Ct(!1),Bt(hu),ft(i.CULL_FACE),A(Ye);function ft(D){c[D]!==!0&&(i.enable(D),c[D]=!0)}function ot(D){c[D]!==!1&&(i.disable(D),c[D]=!1)}function At(D,dt){return h[D]!==dt?(i.bindFramebuffer(D,dt),h[D]=dt,D===i.DRAW_FRAMEBUFFER&&(h[i.FRAMEBUFFER]=dt),D===i.FRAMEBUFFER&&(h[i.DRAW_FRAMEBUFFER]=dt),!0):!1}function Tt(D,dt){let G=d,J=!1;if(D){G=u.get(dt),G===void 0&&(G=[],u.set(dt,G));const gt=D.textures;if(G.length!==gt.length||G[0]!==i.COLOR_ATTACHMENT0){for(let xt=0,ne=gt.length;xt<ne;xt++)G[xt]=i.COLOR_ATTACHMENT0+xt;G.length=gt.length,J=!0}}else G[0]!==i.BACK&&(G[0]=i.BACK,J=!0);J&&i.drawBuffers(G)}function zt(D){return f!==D?(i.useProgram(D),f=D,!0):!1}const ie={[jn]:i.FUNC_ADD,[Sm]:i.FUNC_SUBTRACT,[wm]:i.FUNC_REVERSE_SUBTRACT};ie[Em]=i.MIN,ie[Tm]=i.MAX;const W={[$r]:i.ZERO,[Am]:i.ONE,[Cm]:i.SRC_COLOR,[oc]:i.SRC_ALPHA,[Dm]:i.SRC_ALPHA_SATURATE,[hc]:i.DST_COLOR,[cc]:i.DST_ALPHA,[Rm]:i.ONE_MINUS_SRC_COLOR,[lc]:i.ONE_MINUS_SRC_ALPHA,[Lm]:i.ONE_MINUS_DST_COLOR,[Pm]:i.ONE_MINUS_DST_ALPHA,[Im]:i.CONSTANT_COLOR,[km]:i.ONE_MINUS_CONSTANT_COLOR,[Nm]:i.CONSTANT_ALPHA,[Um]:i.ONE_MINUS_CONSTANT_ALPHA};function A(D,dt,G,J,gt,xt,ne,ke,pn,ae){if(D===Ye){g===!0&&(ot(i.BLEND),g=!1);return}if(g===!1&&(ft(i.BLEND),g=!0),D!==mf){if(D!==_||ae!==P){if((m!==jn||x!==jn)&&(i.blendEquation(i.FUNC_ADD),m=jn,x=jn),ae)switch(D){case pr:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case ac:i.blendFunc(i.ONE,i.ONE);break;case uu:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case du:i.blendFuncSeparate(i.ZERO,i.SRC_COLOR,i.ZERO,i.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",D);break}else switch(D){case pr:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case ac:i.blendFunc(i.SRC_ALPHA,i.ONE);break;case uu:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case du:i.blendFunc(i.ZERO,i.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",D);break}p=null,y=null,S=null,L=null,T.set(0,0,0),E=0,_=D,P=ae}return}gt=gt||dt,xt=xt||G,ne=ne||J,(dt!==m||gt!==x)&&(i.blendEquationSeparate(ie[dt],ie[gt]),m=dt,x=gt),(G!==p||J!==y||xt!==S||ne!==L)&&(i.blendFuncSeparate(W[G],W[J],W[xt],W[ne]),p=G,y=J,S=xt,L=ne),(ke.equals(T)===!1||pn!==E)&&(i.blendColor(ke.r,ke.g,ke.b,pn),T.copy(ke),E=pn),_=D,P=!1}function It(D,dt){D.side===li?ot(i.CULL_FACE):ft(i.CULL_FACE);let G=D.side===un;dt&&(G=!G),Ct(G),D.blending===pr&&D.transparent===!1?A(Ye):A(D.blending,D.blendEquation,D.blendSrc,D.blendDst,D.blendEquationAlpha,D.blendSrcAlpha,D.blendDstAlpha,D.blendColor,D.blendAlpha,D.premultipliedAlpha),r.setFunc(D.depthFunc),r.setTest(D.depthTest),r.setMask(D.depthWrite),s.setMask(D.colorWrite);const J=D.stencilWrite;a.setTest(J),J&&(a.setMask(D.stencilWriteMask),a.setFunc(D.stencilFunc,D.stencilRef,D.stencilFuncMask),a.setOp(D.stencilFail,D.stencilZFail,D.stencilZPass)),ue(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),D.alphaToCoverage===!0?ft(i.SAMPLE_ALPHA_TO_COVERAGE):ot(i.SAMPLE_ALPHA_TO_COVERAGE)}function Ct(D){U!==D&&(D?i.frontFace(i.CW):i.frontFace(i.CCW),U=D)}function Bt(D){D!==Mm?(ft(i.CULL_FACE),D!==v&&(D===hu?i.cullFace(i.BACK):D===bm?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):ot(i.CULL_FACE),v=D}function Dt(D){D!==b&&(K&&i.lineWidth(D),b=D)}function ue(D,dt,G){D?(ft(i.POLYGON_OFFSET_FILL),(I!==dt||O!==G)&&(i.polygonOffset(dt,G),I=dt,O=G)):ot(i.POLYGON_OFFSET_FILL)}function Nt(D){D?ft(i.SCISSOR_TEST):ot(i.SCISSOR_TEST)}function C(D){D===void 0&&(D=i.TEXTURE0+$-1),V!==D&&(i.activeTexture(D),V=D)}function M(D,dt,G){G===void 0&&(V===null?G=i.TEXTURE0+$-1:G=V);let J=at[G];J===void 0&&(J={type:void 0,texture:void 0},at[G]=J),(J.type!==D||J.texture!==dt)&&(V!==G&&(i.activeTexture(G),V=G),i.bindTexture(D,dt||et[D]),J.type=D,J.texture=dt)}function F(){const D=at[V];D!==void 0&&D.type!==void 0&&(i.bindTexture(D.type,null),D.type=void 0,D.texture=void 0)}function Y(){try{i.compressedTexImage2D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function Q(){try{i.compressedTexImage3D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function j(){try{i.texSubImage2D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function St(){try{i.texSubImage3D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function ht(){try{i.compressedTexSubImage2D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function pt(){try{i.compressedTexSubImage3D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function Yt(){try{i.texStorage2D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function nt(){try{i.texStorage3D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function mt(){try{i.texImage2D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function Ut(){try{i.texImage3D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function Ot(D){$t.equals(D)===!1&&(i.scissor(D.x,D.y,D.z,D.w),$t.copy(D))}function Mt(D){Jt.equals(D)===!1&&(i.viewport(D.x,D.y,D.z,D.w),Jt.copy(D))}function Qt(D,dt){let G=l.get(dt);G===void 0&&(G=new WeakMap,l.set(dt,G));let J=G.get(D);J===void 0&&(J=i.getUniformBlockIndex(dt,D.name),G.set(D,J))}function Vt(D,dt){const J=l.get(dt).get(D);o.get(dt)!==J&&(i.uniformBlockBinding(dt,J,D.__bindingPointIndex),o.set(dt,J))}function se(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),c={},V=null,at={},h={},u=new WeakMap,d=[],f=null,g=!1,_=null,m=null,p=null,y=null,x=null,S=null,L=null,T=new Zt(0,0,0),E=0,P=!1,U=null,v=null,b=null,I=null,O=null,$t.set(0,0,i.canvas.width,i.canvas.height),Jt.set(0,0,i.canvas.width,i.canvas.height),s.reset(),r.reset(),a.reset()}return{buffers:{color:s,depth:r,stencil:a},enable:ft,disable:ot,bindFramebuffer:At,drawBuffers:Tt,useProgram:zt,setBlending:A,setMaterial:It,setFlipSided:Ct,setCullFace:Bt,setLineWidth:Dt,setPolygonOffset:ue,setScissorTest:Nt,activeTexture:C,bindTexture:M,unbindTexture:F,compressedTexImage2D:Y,compressedTexImage3D:Q,texImage2D:mt,texImage3D:Ut,updateUBOMapping:Qt,uniformBlockBinding:Vt,texStorage2D:Yt,texStorage3D:nt,texSubImage2D:j,texSubImage3D:St,compressedTexSubImage2D:ht,compressedTexSubImage3D:pt,scissor:Ot,viewport:Mt,reset:se}}function nd(i,t,e,n){const s=fy(n);switch(e){case Tf:return i*t;case Cf:return i*t;case Rf:return i*t*2;case Pf:return i*t/s.components*s.byteLength;case ph:return i*t/s.components*s.byteLength;case Lf:return i*t*2/s.components*s.byteLength;case mh:return i*t*2/s.components*s.byteLength;case Af:return i*t*3/s.components*s.byteLength;case Nn:return i*t*4/s.components*s.byteLength;case gh:return i*t*4/s.components*s.byteLength;case no:case io:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case so:case ro:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case bc:case wc:return Math.max(i,16)*Math.max(t,8)/4;case Mc:case Sc:return Math.max(i,8)*Math.max(t,8)/2;case Ec:case Tc:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case Ac:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case Cc:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case Rc:return Math.floor((i+4)/5)*Math.floor((t+3)/4)*16;case Pc:return Math.floor((i+4)/5)*Math.floor((t+4)/5)*16;case Lc:return Math.floor((i+5)/6)*Math.floor((t+4)/5)*16;case Dc:return Math.floor((i+5)/6)*Math.floor((t+5)/6)*16;case Ic:return Math.floor((i+7)/8)*Math.floor((t+4)/5)*16;case kc:return Math.floor((i+7)/8)*Math.floor((t+5)/6)*16;case Nc:return Math.floor((i+7)/8)*Math.floor((t+7)/8)*16;case Uc:return Math.floor((i+9)/10)*Math.floor((t+4)/5)*16;case Oc:return Math.floor((i+9)/10)*Math.floor((t+5)/6)*16;case Fc:return Math.floor((i+9)/10)*Math.floor((t+7)/8)*16;case zc:return Math.floor((i+9)/10)*Math.floor((t+9)/10)*16;case Bc:return Math.floor((i+11)/12)*Math.floor((t+9)/10)*16;case Hc:return Math.floor((i+11)/12)*Math.floor((t+11)/12)*16;case ao:case Vc:case Gc:return Math.ceil(i/4)*Math.ceil(t/4)*16;case Df:case $c:return Math.ceil(i/4)*Math.ceil(t/4)*8;case Wc:case Xc:return Math.ceil(i/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function fy(i){switch(i){case pi:case Sf:return{byteLength:1,components:1};case ra:case wf:case Ui:return{byteLength:2,components:1};case dh:case fh:return{byteLength:2,components:4};case Ts:case uh:case Ci:return{byteLength:4,components:1};case Ef:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}function py(i,t,e,n,s,r,a){const o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new rt,h=new WeakMap;let u;const d=new WeakMap;let f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(C,M){return f?new OffscreenCanvas(C,M):wo("canvas")}function _(C,M,F){let Y=1;const Q=Nt(C);if((Q.width>F||Q.height>F)&&(Y=F/Math.max(Q.width,Q.height)),Y<1)if(typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&C instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&C instanceof ImageBitmap||typeof VideoFrame<"u"&&C instanceof VideoFrame){const j=Math.floor(Y*Q.width),St=Math.floor(Y*Q.height);u===void 0&&(u=g(j,St));const ht=M?g(j,St):u;return ht.width=j,ht.height=St,ht.getContext("2d").drawImage(C,0,0,j,St),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+Q.width+"x"+Q.height+") to ("+j+"x"+St+")."),ht}else return"data"in C&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+Q.width+"x"+Q.height+")."),C;return C}function m(C){return C.generateMipmaps&&C.minFilter!==rn&&C.minFilter!==qn}function p(C){i.generateMipmap(C)}function y(C,M,F,Y,Q=!1){if(C!==null){if(i[C]!==void 0)return i[C];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+C+"'")}let j=M;if(M===i.RED&&(F===i.FLOAT&&(j=i.R32F),F===i.HALF_FLOAT&&(j=i.R16F),F===i.UNSIGNED_BYTE&&(j=i.R8)),M===i.RED_INTEGER&&(F===i.UNSIGNED_BYTE&&(j=i.R8UI),F===i.UNSIGNED_SHORT&&(j=i.R16UI),F===i.UNSIGNED_INT&&(j=i.R32UI),F===i.BYTE&&(j=i.R8I),F===i.SHORT&&(j=i.R16I),F===i.INT&&(j=i.R32I)),M===i.RG&&(F===i.FLOAT&&(j=i.RG32F),F===i.HALF_FLOAT&&(j=i.RG16F),F===i.UNSIGNED_BYTE&&(j=i.RG8)),M===i.RG_INTEGER&&(F===i.UNSIGNED_BYTE&&(j=i.RG8UI),F===i.UNSIGNED_SHORT&&(j=i.RG16UI),F===i.UNSIGNED_INT&&(j=i.RG32UI),F===i.BYTE&&(j=i.RG8I),F===i.SHORT&&(j=i.RG16I),F===i.INT&&(j=i.RG32I)),M===i.RGB_INTEGER&&(F===i.UNSIGNED_BYTE&&(j=i.RGB8UI),F===i.UNSIGNED_SHORT&&(j=i.RGB16UI),F===i.UNSIGNED_INT&&(j=i.RGB32UI),F===i.BYTE&&(j=i.RGB8I),F===i.SHORT&&(j=i.RGB16I),F===i.INT&&(j=i.RGB32I)),M===i.RGBA_INTEGER&&(F===i.UNSIGNED_BYTE&&(j=i.RGBA8UI),F===i.UNSIGNED_SHORT&&(j=i.RGBA16UI),F===i.UNSIGNED_INT&&(j=i.RGBA32UI),F===i.BYTE&&(j=i.RGBA8I),F===i.SHORT&&(j=i.RGBA16I),F===i.INT&&(j=i.RGBA32I)),M===i.RGB&&F===i.UNSIGNED_INT_5_9_9_9_REV&&(j=i.RGB9_E5),M===i.RGBA){const St=Q?yo:oe.getTransfer(Y);F===i.FLOAT&&(j=i.RGBA32F),F===i.HALF_FLOAT&&(j=i.RGBA16F),F===i.UNSIGNED_BYTE&&(j=St===ye?i.SRGB8_ALPHA8:i.RGBA8),F===i.UNSIGNED_SHORT_4_4_4_4&&(j=i.RGBA4),F===i.UNSIGNED_SHORT_5_5_5_1&&(j=i.RGB5_A1)}return(j===i.R16F||j===i.R32F||j===i.RG16F||j===i.RG32F||j===i.RGBA16F||j===i.RGBA32F)&&t.get("EXT_color_buffer_float"),j}function x(C,M){let F;return C?M===null||M===Ts||M===As?F=i.DEPTH24_STENCIL8:M===Ci?F=i.DEPTH32F_STENCIL8:M===ra&&(F=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):M===null||M===Ts||M===As?F=i.DEPTH_COMPONENT24:M===Ci?F=i.DEPTH_COMPONENT32F:M===ra&&(F=i.DEPTH_COMPONENT16),F}function S(C,M){return m(C)===!0||C.isFramebufferTexture&&C.minFilter!==rn&&C.minFilter!==qn?Math.log2(Math.max(M.width,M.height))+1:C.mipmaps!==void 0&&C.mipmaps.length>0?C.mipmaps.length:C.isCompressedTexture&&Array.isArray(C.image)?M.mipmaps.length:1}function L(C){const M=C.target;M.removeEventListener("dispose",L),E(M),M.isVideoTexture&&h.delete(M)}function T(C){const M=C.target;M.removeEventListener("dispose",T),U(M)}function E(C){const M=n.get(C);if(M.__webglInit===void 0)return;const F=C.source,Y=d.get(F);if(Y){const Q=Y[M.__cacheKey];Q.usedTimes--,Q.usedTimes===0&&P(C),Object.keys(Y).length===0&&d.delete(F)}n.remove(C)}function P(C){const M=n.get(C);i.deleteTexture(M.__webglTexture);const F=C.source,Y=d.get(F);delete Y[M.__cacheKey],a.memory.textures--}function U(C){const M=n.get(C);if(C.depthTexture&&C.depthTexture.dispose(),C.isWebGLCubeRenderTarget)for(let Y=0;Y<6;Y++){if(Array.isArray(M.__webglFramebuffer[Y]))for(let Q=0;Q<M.__webglFramebuffer[Y].length;Q++)i.deleteFramebuffer(M.__webglFramebuffer[Y][Q]);else i.deleteFramebuffer(M.__webglFramebuffer[Y]);M.__webglDepthbuffer&&i.deleteRenderbuffer(M.__webglDepthbuffer[Y])}else{if(Array.isArray(M.__webglFramebuffer))for(let Y=0;Y<M.__webglFramebuffer.length;Y++)i.deleteFramebuffer(M.__webglFramebuffer[Y]);else i.deleteFramebuffer(M.__webglFramebuffer);if(M.__webglDepthbuffer&&i.deleteRenderbuffer(M.__webglDepthbuffer),M.__webglMultisampledFramebuffer&&i.deleteFramebuffer(M.__webglMultisampledFramebuffer),M.__webglColorRenderbuffer)for(let Y=0;Y<M.__webglColorRenderbuffer.length;Y++)M.__webglColorRenderbuffer[Y]&&i.deleteRenderbuffer(M.__webglColorRenderbuffer[Y]);M.__webglDepthRenderbuffer&&i.deleteRenderbuffer(M.__webglDepthRenderbuffer)}const F=C.textures;for(let Y=0,Q=F.length;Y<Q;Y++){const j=n.get(F[Y]);j.__webglTexture&&(i.deleteTexture(j.__webglTexture),a.memory.textures--),n.remove(F[Y])}n.remove(C)}let v=0;function b(){v=0}function I(){const C=v;return C>=s.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+C+" texture units while this GPU supports only "+s.maxTextures),v+=1,C}function O(C){const M=[];return M.push(C.wrapS),M.push(C.wrapT),M.push(C.wrapR||0),M.push(C.magFilter),M.push(C.minFilter),M.push(C.anisotropy),M.push(C.internalFormat),M.push(C.format),M.push(C.type),M.push(C.generateMipmaps),M.push(C.premultiplyAlpha),M.push(C.flipY),M.push(C.unpackAlignment),M.push(C.colorSpace),M.join()}function $(C,M){const F=n.get(C);if(C.isVideoTexture&&Dt(C),C.isRenderTargetTexture===!1&&C.version>0&&F.__version!==C.version){const Y=C.image;if(Y===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Y.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Jt(F,C,M);return}}e.bindTexture(i.TEXTURE_2D,F.__webglTexture,i.TEXTURE0+M)}function K(C,M){const F=n.get(C);if(C.version>0&&F.__version!==C.version){Jt(F,C,M);return}e.bindTexture(i.TEXTURE_2D_ARRAY,F.__webglTexture,i.TEXTURE0+M)}function z(C,M){const F=n.get(C);if(C.version>0&&F.__version!==C.version){Jt(F,C,M);return}e.bindTexture(i.TEXTURE_3D,F.__webglTexture,i.TEXTURE0+M)}function Z(C,M){const F=n.get(C);if(C.version>0&&F.__version!==C.version){X(F,C,M);return}e.bindTexture(i.TEXTURE_CUBE_MAP,F.__webglTexture,i.TEXTURE0+M)}const V={[Ni]:i.REPEAT,[Ms]:i.CLAMP_TO_EDGE,[yc]:i.MIRRORED_REPEAT},at={[rn]:i.NEAREST,[Bm]:i.NEAREST_MIPMAP_NEAREST,[pa]:i.NEAREST_MIPMAP_LINEAR,[qn]:i.LINEAR,[el]:i.LINEAR_MIPMAP_NEAREST,[bs]:i.LINEAR_MIPMAP_LINEAR},ct={[$m]:i.NEVER,[Km]:i.ALWAYS,[Wm]:i.LESS,[If]:i.LEQUAL,[Xm]:i.EQUAL,[Ym]:i.GEQUAL,[jm]:i.GREATER,[qm]:i.NOTEQUAL};function _t(C,M){if(M.type===Ci&&t.has("OES_texture_float_linear")===!1&&(M.magFilter===qn||M.magFilter===el||M.magFilter===pa||M.magFilter===bs||M.minFilter===qn||M.minFilter===el||M.minFilter===pa||M.minFilter===bs)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(C,i.TEXTURE_WRAP_S,V[M.wrapS]),i.texParameteri(C,i.TEXTURE_WRAP_T,V[M.wrapT]),(C===i.TEXTURE_3D||C===i.TEXTURE_2D_ARRAY)&&i.texParameteri(C,i.TEXTURE_WRAP_R,V[M.wrapR]),i.texParameteri(C,i.TEXTURE_MAG_FILTER,at[M.magFilter]),i.texParameteri(C,i.TEXTURE_MIN_FILTER,at[M.minFilter]),M.compareFunction&&(i.texParameteri(C,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(C,i.TEXTURE_COMPARE_FUNC,ct[M.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(M.magFilter===rn||M.minFilter!==pa&&M.minFilter!==bs||M.type===Ci&&t.has("OES_texture_float_linear")===!1)return;if(M.anisotropy>1||n.get(M).__currentAnisotropy){const F=t.get("EXT_texture_filter_anisotropic");i.texParameterf(C,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(M.anisotropy,s.getMaxAnisotropy())),n.get(M).__currentAnisotropy=M.anisotropy}}}function $t(C,M){let F=!1;C.__webglInit===void 0&&(C.__webglInit=!0,M.addEventListener("dispose",L));const Y=M.source;let Q=d.get(Y);Q===void 0&&(Q={},d.set(Y,Q));const j=O(M);if(j!==C.__cacheKey){Q[j]===void 0&&(Q[j]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,F=!0),Q[j].usedTimes++;const St=Q[C.__cacheKey];St!==void 0&&(Q[C.__cacheKey].usedTimes--,St.usedTimes===0&&P(M)),C.__cacheKey=j,C.__webglTexture=Q[j].texture}return F}function Jt(C,M,F){let Y=i.TEXTURE_2D;(M.isDataArrayTexture||M.isCompressedArrayTexture)&&(Y=i.TEXTURE_2D_ARRAY),M.isData3DTexture&&(Y=i.TEXTURE_3D);const Q=$t(C,M),j=M.source;e.bindTexture(Y,C.__webglTexture,i.TEXTURE0+F);const St=n.get(j);if(j.version!==St.__version||Q===!0){e.activeTexture(i.TEXTURE0+F);const ht=oe.getPrimaries(oe.workingColorSpace),pt=M.colorSpace===Ji?null:oe.getPrimaries(M.colorSpace),Yt=M.colorSpace===Ji||ht===pt?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,M.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,M.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Yt);let nt=_(M.image,!1,s.maxTextureSize);nt=ue(M,nt);const mt=r.convert(M.format,M.colorSpace),Ut=r.convert(M.type);let Ot=y(M.internalFormat,mt,Ut,M.colorSpace,M.isVideoTexture);_t(Y,M);let Mt;const Qt=M.mipmaps,Vt=M.isVideoTexture!==!0,se=St.__version===void 0||Q===!0,D=j.dataReady,dt=S(M,nt);if(M.isDepthTexture)Ot=x(M.format===Cs,M.type),se&&(Vt?e.texStorage2D(i.TEXTURE_2D,1,Ot,nt.width,nt.height):e.texImage2D(i.TEXTURE_2D,0,Ot,nt.width,nt.height,0,mt,Ut,null));else if(M.isDataTexture)if(Qt.length>0){Vt&&se&&e.texStorage2D(i.TEXTURE_2D,dt,Ot,Qt[0].width,Qt[0].height);for(let G=0,J=Qt.length;G<J;G++)Mt=Qt[G],Vt?D&&e.texSubImage2D(i.TEXTURE_2D,G,0,0,Mt.width,Mt.height,mt,Ut,Mt.data):e.texImage2D(i.TEXTURE_2D,G,Ot,Mt.width,Mt.height,0,mt,Ut,Mt.data);M.generateMipmaps=!1}else Vt?(se&&e.texStorage2D(i.TEXTURE_2D,dt,Ot,nt.width,nt.height),D&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,nt.width,nt.height,mt,Ut,nt.data)):e.texImage2D(i.TEXTURE_2D,0,Ot,nt.width,nt.height,0,mt,Ut,nt.data);else if(M.isCompressedTexture)if(M.isCompressedArrayTexture){Vt&&se&&e.texStorage3D(i.TEXTURE_2D_ARRAY,dt,Ot,Qt[0].width,Qt[0].height,nt.depth);for(let G=0,J=Qt.length;G<J;G++)if(Mt=Qt[G],M.format!==Nn)if(mt!==null)if(Vt){if(D)if(M.layerUpdates.size>0){const gt=nd(Mt.width,Mt.height,M.format,M.type);for(const xt of M.layerUpdates){const ne=Mt.data.subarray(xt*gt/Mt.data.BYTES_PER_ELEMENT,(xt+1)*gt/Mt.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,G,0,0,xt,Mt.width,Mt.height,1,mt,ne,0,0)}M.clearLayerUpdates()}else e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,G,0,0,0,Mt.width,Mt.height,nt.depth,mt,Mt.data,0,0)}else e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,G,Ot,Mt.width,Mt.height,nt.depth,0,Mt.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Vt?D&&e.texSubImage3D(i.TEXTURE_2D_ARRAY,G,0,0,0,Mt.width,Mt.height,nt.depth,mt,Ut,Mt.data):e.texImage3D(i.TEXTURE_2D_ARRAY,G,Ot,Mt.width,Mt.height,nt.depth,0,mt,Ut,Mt.data)}else{Vt&&se&&e.texStorage2D(i.TEXTURE_2D,dt,Ot,Qt[0].width,Qt[0].height);for(let G=0,J=Qt.length;G<J;G++)Mt=Qt[G],M.format!==Nn?mt!==null?Vt?D&&e.compressedTexSubImage2D(i.TEXTURE_2D,G,0,0,Mt.width,Mt.height,mt,Mt.data):e.compressedTexImage2D(i.TEXTURE_2D,G,Ot,Mt.width,Mt.height,0,Mt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Vt?D&&e.texSubImage2D(i.TEXTURE_2D,G,0,0,Mt.width,Mt.height,mt,Ut,Mt.data):e.texImage2D(i.TEXTURE_2D,G,Ot,Mt.width,Mt.height,0,mt,Ut,Mt.data)}else if(M.isDataArrayTexture)if(Vt){if(se&&e.texStorage3D(i.TEXTURE_2D_ARRAY,dt,Ot,nt.width,nt.height,nt.depth),D)if(M.layerUpdates.size>0){const G=nd(nt.width,nt.height,M.format,M.type);for(const J of M.layerUpdates){const gt=nt.data.subarray(J*G/nt.data.BYTES_PER_ELEMENT,(J+1)*G/nt.data.BYTES_PER_ELEMENT);e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,J,nt.width,nt.height,1,mt,Ut,gt)}M.clearLayerUpdates()}else e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,nt.width,nt.height,nt.depth,mt,Ut,nt.data)}else e.texImage3D(i.TEXTURE_2D_ARRAY,0,Ot,nt.width,nt.height,nt.depth,0,mt,Ut,nt.data);else if(M.isData3DTexture)Vt?(se&&e.texStorage3D(i.TEXTURE_3D,dt,Ot,nt.width,nt.height,nt.depth),D&&e.texSubImage3D(i.TEXTURE_3D,0,0,0,0,nt.width,nt.height,nt.depth,mt,Ut,nt.data)):e.texImage3D(i.TEXTURE_3D,0,Ot,nt.width,nt.height,nt.depth,0,mt,Ut,nt.data);else if(M.isFramebufferTexture){if(se)if(Vt)e.texStorage2D(i.TEXTURE_2D,dt,Ot,nt.width,nt.height);else{let G=nt.width,J=nt.height;for(let gt=0;gt<dt;gt++)e.texImage2D(i.TEXTURE_2D,gt,Ot,G,J,0,mt,Ut,null),G>>=1,J>>=1}}else if(Qt.length>0){if(Vt&&se){const G=Nt(Qt[0]);e.texStorage2D(i.TEXTURE_2D,dt,Ot,G.width,G.height)}for(let G=0,J=Qt.length;G<J;G++)Mt=Qt[G],Vt?D&&e.texSubImage2D(i.TEXTURE_2D,G,0,0,mt,Ut,Mt):e.texImage2D(i.TEXTURE_2D,G,Ot,mt,Ut,Mt);M.generateMipmaps=!1}else if(Vt){if(se){const G=Nt(nt);e.texStorage2D(i.TEXTURE_2D,dt,Ot,G.width,G.height)}D&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,mt,Ut,nt)}else e.texImage2D(i.TEXTURE_2D,0,Ot,mt,Ut,nt);m(M)&&p(Y),St.__version=j.version,M.onUpdate&&M.onUpdate(M)}C.__version=M.version}function X(C,M,F){if(M.image.length!==6)return;const Y=$t(C,M),Q=M.source;e.bindTexture(i.TEXTURE_CUBE_MAP,C.__webglTexture,i.TEXTURE0+F);const j=n.get(Q);if(Q.version!==j.__version||Y===!0){e.activeTexture(i.TEXTURE0+F);const St=oe.getPrimaries(oe.workingColorSpace),ht=M.colorSpace===Ji?null:oe.getPrimaries(M.colorSpace),pt=M.colorSpace===Ji||St===ht?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,M.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,M.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,pt);const Yt=M.isCompressedTexture||M.image[0].isCompressedTexture,nt=M.image[0]&&M.image[0].isDataTexture,mt=[];for(let J=0;J<6;J++)!Yt&&!nt?mt[J]=_(M.image[J],!0,s.maxCubemapSize):mt[J]=nt?M.image[J].image:M.image[J],mt[J]=ue(M,mt[J]);const Ut=mt[0],Ot=r.convert(M.format,M.colorSpace),Mt=r.convert(M.type),Qt=y(M.internalFormat,Ot,Mt,M.colorSpace),Vt=M.isVideoTexture!==!0,se=j.__version===void 0||Y===!0,D=Q.dataReady;let dt=S(M,Ut);_t(i.TEXTURE_CUBE_MAP,M);let G;if(Yt){Vt&&se&&e.texStorage2D(i.TEXTURE_CUBE_MAP,dt,Qt,Ut.width,Ut.height);for(let J=0;J<6;J++){G=mt[J].mipmaps;for(let gt=0;gt<G.length;gt++){const xt=G[gt];M.format!==Nn?Ot!==null?Vt?D&&e.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,gt,0,0,xt.width,xt.height,Ot,xt.data):e.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,gt,Qt,xt.width,xt.height,0,xt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Vt?D&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,gt,0,0,xt.width,xt.height,Ot,Mt,xt.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,gt,Qt,xt.width,xt.height,0,Ot,Mt,xt.data)}}}else{if(G=M.mipmaps,Vt&&se){G.length>0&&dt++;const J=Nt(mt[0]);e.texStorage2D(i.TEXTURE_CUBE_MAP,dt,Qt,J.width,J.height)}for(let J=0;J<6;J++)if(nt){Vt?D&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,0,0,mt[J].width,mt[J].height,Ot,Mt,mt[J].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,Qt,mt[J].width,mt[J].height,0,Ot,Mt,mt[J].data);for(let gt=0;gt<G.length;gt++){const ne=G[gt].image[J].image;Vt?D&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,gt+1,0,0,ne.width,ne.height,Ot,Mt,ne.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,gt+1,Qt,ne.width,ne.height,0,Ot,Mt,ne.data)}}else{Vt?D&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,0,0,Ot,Mt,mt[J]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,Qt,Ot,Mt,mt[J]);for(let gt=0;gt<G.length;gt++){const xt=G[gt];Vt?D&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,gt+1,0,0,Ot,Mt,xt.image[J]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,gt+1,Qt,Ot,Mt,xt.image[J])}}}m(M)&&p(i.TEXTURE_CUBE_MAP),j.__version=Q.version,M.onUpdate&&M.onUpdate(M)}C.__version=M.version}function et(C,M,F,Y,Q,j){const St=r.convert(F.format,F.colorSpace),ht=r.convert(F.type),pt=y(F.internalFormat,St,ht,F.colorSpace);if(!n.get(M).__hasExternalTextures){const nt=Math.max(1,M.width>>j),mt=Math.max(1,M.height>>j);Q===i.TEXTURE_3D||Q===i.TEXTURE_2D_ARRAY?e.texImage3D(Q,j,pt,nt,mt,M.depth,0,St,ht,null):e.texImage2D(Q,j,pt,nt,mt,0,St,ht,null)}e.bindFramebuffer(i.FRAMEBUFFER,C),Bt(M)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Y,Q,n.get(F).__webglTexture,0,Ct(M)):(Q===i.TEXTURE_2D||Q>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&Q<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,Y,Q,n.get(F).__webglTexture,j),e.bindFramebuffer(i.FRAMEBUFFER,null)}function ft(C,M,F){if(i.bindRenderbuffer(i.RENDERBUFFER,C),M.depthBuffer){const Y=M.depthTexture,Q=Y&&Y.isDepthTexture?Y.type:null,j=x(M.stencilBuffer,Q),St=M.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ht=Ct(M);Bt(M)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ht,j,M.width,M.height):F?i.renderbufferStorageMultisample(i.RENDERBUFFER,ht,j,M.width,M.height):i.renderbufferStorage(i.RENDERBUFFER,j,M.width,M.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,St,i.RENDERBUFFER,C)}else{const Y=M.textures;for(let Q=0;Q<Y.length;Q++){const j=Y[Q],St=r.convert(j.format,j.colorSpace),ht=r.convert(j.type),pt=y(j.internalFormat,St,ht,j.colorSpace),Yt=Ct(M);F&&Bt(M)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,Yt,pt,M.width,M.height):Bt(M)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Yt,pt,M.width,M.height):i.renderbufferStorage(i.RENDERBUFFER,pt,M.width,M.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function ot(C,M){if(M&&M.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(i.FRAMEBUFFER,C),!(M.depthTexture&&M.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(M.depthTexture).__webglTexture||M.depthTexture.image.width!==M.width||M.depthTexture.image.height!==M.height)&&(M.depthTexture.image.width=M.width,M.depthTexture.image.height=M.height,M.depthTexture.needsUpdate=!0),$(M.depthTexture,0);const Y=n.get(M.depthTexture).__webglTexture,Q=Ct(M);if(M.depthTexture.format===mr)Bt(M)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,Y,0,Q):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,Y,0);else if(M.depthTexture.format===Cs)Bt(M)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,Y,0,Q):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,Y,0);else throw new Error("Unknown depthTexture format")}function At(C){const M=n.get(C),F=C.isWebGLCubeRenderTarget===!0;if(M.__boundDepthTexture!==C.depthTexture){const Y=C.depthTexture;if(M.__depthDisposeCallback&&M.__depthDisposeCallback(),Y){const Q=()=>{delete M.__boundDepthTexture,delete M.__depthDisposeCallback,Y.removeEventListener("dispose",Q)};Y.addEventListener("dispose",Q),M.__depthDisposeCallback=Q}M.__boundDepthTexture=Y}if(C.depthTexture&&!M.__autoAllocateDepthBuffer){if(F)throw new Error("target.depthTexture not supported in Cube render targets");ot(M.__webglFramebuffer,C)}else if(F){M.__webglDepthbuffer=[];for(let Y=0;Y<6;Y++)if(e.bindFramebuffer(i.FRAMEBUFFER,M.__webglFramebuffer[Y]),M.__webglDepthbuffer[Y]===void 0)M.__webglDepthbuffer[Y]=i.createRenderbuffer(),ft(M.__webglDepthbuffer[Y],C,!1);else{const Q=C.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,j=M.__webglDepthbuffer[Y];i.bindRenderbuffer(i.RENDERBUFFER,j),i.framebufferRenderbuffer(i.FRAMEBUFFER,Q,i.RENDERBUFFER,j)}}else if(e.bindFramebuffer(i.FRAMEBUFFER,M.__webglFramebuffer),M.__webglDepthbuffer===void 0)M.__webglDepthbuffer=i.createRenderbuffer(),ft(M.__webglDepthbuffer,C,!1);else{const Y=C.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Q=M.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,Q),i.framebufferRenderbuffer(i.FRAMEBUFFER,Y,i.RENDERBUFFER,Q)}e.bindFramebuffer(i.FRAMEBUFFER,null)}function Tt(C,M,F){const Y=n.get(C);M!==void 0&&et(Y.__webglFramebuffer,C,C.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),F!==void 0&&At(C)}function zt(C){const M=C.texture,F=n.get(C),Y=n.get(M);C.addEventListener("dispose",T);const Q=C.textures,j=C.isWebGLCubeRenderTarget===!0,St=Q.length>1;if(St||(Y.__webglTexture===void 0&&(Y.__webglTexture=i.createTexture()),Y.__version=M.version,a.memory.textures++),j){F.__webglFramebuffer=[];for(let ht=0;ht<6;ht++)if(M.mipmaps&&M.mipmaps.length>0){F.__webglFramebuffer[ht]=[];for(let pt=0;pt<M.mipmaps.length;pt++)F.__webglFramebuffer[ht][pt]=i.createFramebuffer()}else F.__webglFramebuffer[ht]=i.createFramebuffer()}else{if(M.mipmaps&&M.mipmaps.length>0){F.__webglFramebuffer=[];for(let ht=0;ht<M.mipmaps.length;ht++)F.__webglFramebuffer[ht]=i.createFramebuffer()}else F.__webglFramebuffer=i.createFramebuffer();if(St)for(let ht=0,pt=Q.length;ht<pt;ht++){const Yt=n.get(Q[ht]);Yt.__webglTexture===void 0&&(Yt.__webglTexture=i.createTexture(),a.memory.textures++)}if(C.samples>0&&Bt(C)===!1){F.__webglMultisampledFramebuffer=i.createFramebuffer(),F.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let ht=0;ht<Q.length;ht++){const pt=Q[ht];F.__webglColorRenderbuffer[ht]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,F.__webglColorRenderbuffer[ht]);const Yt=r.convert(pt.format,pt.colorSpace),nt=r.convert(pt.type),mt=y(pt.internalFormat,Yt,nt,pt.colorSpace,C.isXRRenderTarget===!0),Ut=Ct(C);i.renderbufferStorageMultisample(i.RENDERBUFFER,Ut,mt,C.width,C.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ht,i.RENDERBUFFER,F.__webglColorRenderbuffer[ht])}i.bindRenderbuffer(i.RENDERBUFFER,null),C.depthBuffer&&(F.__webglDepthRenderbuffer=i.createRenderbuffer(),ft(F.__webglDepthRenderbuffer,C,!0)),e.bindFramebuffer(i.FRAMEBUFFER,null)}}if(j){e.bindTexture(i.TEXTURE_CUBE_MAP,Y.__webglTexture),_t(i.TEXTURE_CUBE_MAP,M);for(let ht=0;ht<6;ht++)if(M.mipmaps&&M.mipmaps.length>0)for(let pt=0;pt<M.mipmaps.length;pt++)et(F.__webglFramebuffer[ht][pt],C,M,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+ht,pt);else et(F.__webglFramebuffer[ht],C,M,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+ht,0);m(M)&&p(i.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(St){for(let ht=0,pt=Q.length;ht<pt;ht++){const Yt=Q[ht],nt=n.get(Yt);e.bindTexture(i.TEXTURE_2D,nt.__webglTexture),_t(i.TEXTURE_2D,Yt),et(F.__webglFramebuffer,C,Yt,i.COLOR_ATTACHMENT0+ht,i.TEXTURE_2D,0),m(Yt)&&p(i.TEXTURE_2D)}e.unbindTexture()}else{let ht=i.TEXTURE_2D;if((C.isWebGL3DRenderTarget||C.isWebGLArrayRenderTarget)&&(ht=C.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(ht,Y.__webglTexture),_t(ht,M),M.mipmaps&&M.mipmaps.length>0)for(let pt=0;pt<M.mipmaps.length;pt++)et(F.__webglFramebuffer[pt],C,M,i.COLOR_ATTACHMENT0,ht,pt);else et(F.__webglFramebuffer,C,M,i.COLOR_ATTACHMENT0,ht,0);m(M)&&p(ht),e.unbindTexture()}C.depthBuffer&&At(C)}function ie(C){const M=C.textures;for(let F=0,Y=M.length;F<Y;F++){const Q=M[F];if(m(Q)){const j=C.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:i.TEXTURE_2D,St=n.get(Q).__webglTexture;e.bindTexture(j,St),p(j),e.unbindTexture()}}}const W=[],A=[];function It(C){if(C.samples>0){if(Bt(C)===!1){const M=C.textures,F=C.width,Y=C.height;let Q=i.COLOR_BUFFER_BIT;const j=C.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,St=n.get(C),ht=M.length>1;if(ht)for(let pt=0;pt<M.length;pt++)e.bindFramebuffer(i.FRAMEBUFFER,St.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+pt,i.RENDERBUFFER,null),e.bindFramebuffer(i.FRAMEBUFFER,St.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+pt,i.TEXTURE_2D,null,0);e.bindFramebuffer(i.READ_FRAMEBUFFER,St.__webglMultisampledFramebuffer),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,St.__webglFramebuffer);for(let pt=0;pt<M.length;pt++){if(C.resolveDepthBuffer&&(C.depthBuffer&&(Q|=i.DEPTH_BUFFER_BIT),C.stencilBuffer&&C.resolveStencilBuffer&&(Q|=i.STENCIL_BUFFER_BIT)),ht){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,St.__webglColorRenderbuffer[pt]);const Yt=n.get(M[pt]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,Yt,0)}i.blitFramebuffer(0,0,F,Y,0,0,F,Y,Q,i.NEAREST),l===!0&&(W.length=0,A.length=0,W.push(i.COLOR_ATTACHMENT0+pt),C.depthBuffer&&C.resolveDepthBuffer===!1&&(W.push(j),A.push(j),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,A)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,W))}if(e.bindFramebuffer(i.READ_FRAMEBUFFER,null),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),ht)for(let pt=0;pt<M.length;pt++){e.bindFramebuffer(i.FRAMEBUFFER,St.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+pt,i.RENDERBUFFER,St.__webglColorRenderbuffer[pt]);const Yt=n.get(M[pt]).__webglTexture;e.bindFramebuffer(i.FRAMEBUFFER,St.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+pt,i.TEXTURE_2D,Yt,0)}e.bindFramebuffer(i.DRAW_FRAMEBUFFER,St.__webglMultisampledFramebuffer)}else if(C.depthBuffer&&C.resolveDepthBuffer===!1&&l){const M=C.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[M])}}}function Ct(C){return Math.min(s.maxSamples,C.samples)}function Bt(C){const M=n.get(C);return C.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&M.__useRenderToTexture!==!1}function Dt(C){const M=a.render.frame;h.get(C)!==M&&(h.set(C,M),C.update())}function ue(C,M){const F=C.colorSpace,Y=C.format,Q=C.type;return C.isCompressedTexture===!0||C.isVideoTexture===!0||F!==cs&&F!==Ji&&(oe.getTransfer(F)===ye?(Y!==Nn||Q!==pi)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",F)),M}function Nt(C){return typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement?(c.width=C.naturalWidth||C.width,c.height=C.naturalHeight||C.height):typeof VideoFrame<"u"&&C instanceof VideoFrame?(c.width=C.displayWidth,c.height=C.displayHeight):(c.width=C.width,c.height=C.height),c}this.allocateTextureUnit=I,this.resetTextureUnits=b,this.setTexture2D=$,this.setTexture2DArray=K,this.setTexture3D=z,this.setTextureCube=Z,this.rebindTextures=Tt,this.setupRenderTarget=zt,this.updateRenderTargetMipmap=ie,this.updateMultisampleRenderTarget=It,this.setupDepthRenderbuffer=At,this.setupFrameBufferTexture=et,this.useMultisampledRTT=Bt}function my(i,t){function e(n,s=Ji){let r;const a=oe.getTransfer(s);if(n===pi)return i.UNSIGNED_BYTE;if(n===dh)return i.UNSIGNED_SHORT_4_4_4_4;if(n===fh)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Ef)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Sf)return i.BYTE;if(n===wf)return i.SHORT;if(n===ra)return i.UNSIGNED_SHORT;if(n===uh)return i.INT;if(n===Ts)return i.UNSIGNED_INT;if(n===Ci)return i.FLOAT;if(n===Ui)return i.HALF_FLOAT;if(n===Tf)return i.ALPHA;if(n===Af)return i.RGB;if(n===Nn)return i.RGBA;if(n===Cf)return i.LUMINANCE;if(n===Rf)return i.LUMINANCE_ALPHA;if(n===mr)return i.DEPTH_COMPONENT;if(n===Cs)return i.DEPTH_STENCIL;if(n===Pf)return i.RED;if(n===ph)return i.RED_INTEGER;if(n===Lf)return i.RG;if(n===mh)return i.RG_INTEGER;if(n===gh)return i.RGBA_INTEGER;if(n===no||n===io||n===so||n===ro)if(a===ye)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===no)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===io)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===so)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===ro)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===no)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===io)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===so)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===ro)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Mc||n===bc||n===Sc||n===wc)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Mc)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===bc)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Sc)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===wc)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Ec||n===Tc||n===Ac)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Ec||n===Tc)return a===ye?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Ac)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===Cc||n===Rc||n===Pc||n===Lc||n===Dc||n===Ic||n===kc||n===Nc||n===Uc||n===Oc||n===Fc||n===zc||n===Bc||n===Hc)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Cc)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Rc)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Pc)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Lc)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Dc)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Ic)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===kc)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Nc)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Uc)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Oc)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Fc)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===zc)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Bc)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Hc)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===ao||n===Vc||n===Gc)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(n===ao)return a===ye?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Vc)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Gc)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Df||n===$c||n===Wc||n===Xc)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(n===ao)return r.COMPRESSED_RED_RGTC1_EXT;if(n===$c)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Wc)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Xc)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===As?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:e}}class gy extends Cn{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}class qt extends Qe{constructor(){super(),this.isGroup=!0,this.type="Group"}}const vy={type:"move"};class Rl{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new qt,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 qt,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new R,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new R),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new qt,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new R,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new R),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let s=null,r=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(c&&t.hand){a=!0;for(const _ of t.hand.values()){const m=e.getJointPose(_,n),p=this._getHandJoint(c,_);m!==null&&(p.matrix.fromArray(m.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=m.radius),p.visible=m!==null}const h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,g=.005;c.inputState.pinching&&d>f+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&d<=f-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(r=e.getPose(t.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));o!==null&&(s=e.getPose(t.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(vy)))}return o!==null&&(o.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){const n=new qt;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}const _y=`
|
|
3815
|
+
}`;function oy(i,t,e){let n=new bh;const s=new at,r=new at,a=new me,o=new iy({depthPacking:zm}),l=new sy,c={},h=e.maxTextureSize,u={[rs]:hn,[hn]:rs,[ai]:ai},d=new en({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new at},radius:{value:4}},vertexShader:ry,fragmentShader:ay}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const g=new dn;g.setAttribute("position",new ci(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new yt(g,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=uf;let p=this.type;this.render=function(T,E,P){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||T.length===0)return;const U=i.getRenderTarget(),v=i.getActiveCubeFace(),b=i.getActiveMipmapLevel(),I=i.state;I.setBlending(qe),I.buffers.color.setClear(1,1,1,1),I.buffers.depth.setTest(!0),I.setScissorTest(!1);const O=p!==Si&&this.type===Si,$=p===Si&&this.type!==Si;for(let K=0,z=T.length;K<z;K++){const Z=T[K],V=Z.shadow;if(V===void 0){console.warn("THREE.WebGLShadowMap:",Z,"has no shadow.");continue}if(V.autoUpdate===!1&&V.needsUpdate===!1)continue;s.copy(V.mapSize);const ot=V.getFrameExtents();if(s.multiply(ot),r.copy(V.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/ot.x),s.x=r.x*ot.x,V.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/ot.y),s.y=r.y*ot.y,V.mapSize.y=r.y)),V.map===null||O===!0||$===!0){const _t=this.type!==Si?{minFilter:sn,magFilter:sn}:{};V.map!==null&&V.map.dispose(),V.map=new Jn(s.x,s.y,_t),V.map.texture.name=Z.name+".shadowMap",V.camera.updateProjectionMatrix()}i.setRenderTarget(V.map),i.clear();const ct=V.getViewportCount();for(let _t=0;_t<ct;_t++){const $t=V.getViewport(_t);a.set(r.x*$t.x,r.y*$t.y,r.x*$t.z,r.y*$t.w),I.viewport(a),V.updateMatrices(Z,_t),n=V.getFrustum(),S(E,P,V.camera,Z,this.type)}V.isPointLightShadow!==!0&&this.type===Si&&y(V,P),V.needsUpdate=!1}p=this.type,m.needsUpdate=!1,i.setRenderTarget(U,v,b)};function y(T,E){const P=t.update(_);d.defines.VSM_SAMPLES!==T.blurSamples&&(d.defines.VSM_SAMPLES=T.blurSamples,f.defines.VSM_SAMPLES=T.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new Jn(s.x,s.y)),d.uniforms.shadow_pass.value=T.map.texture,d.uniforms.resolution.value=T.mapSize,d.uniforms.radius.value=T.radius,i.setRenderTarget(T.mapPass),i.clear(),i.renderBufferDirect(E,null,P,d,_,null),f.uniforms.shadow_pass.value=T.mapPass.texture,f.uniforms.resolution.value=T.mapSize,f.uniforms.radius.value=T.radius,i.setRenderTarget(T.map),i.clear(),i.renderBufferDirect(E,null,P,f,_,null)}function x(T,E,P,U){let v=null;const b=P.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(b!==void 0)v=b;else if(v=P.isPointLight===!0?l:o,i.localClippingEnabled&&E.clipShadows===!0&&Array.isArray(E.clippingPlanes)&&E.clippingPlanes.length!==0||E.displacementMap&&E.displacementScale!==0||E.alphaMap&&E.alphaTest>0||E.map&&E.alphaTest>0){const I=v.uuid,O=E.uuid;let $=c[I];$===void 0&&($={},c[I]=$);let K=$[O];K===void 0&&(K=v.clone(),$[O]=K,E.addEventListener("dispose",L)),v=K}if(v.visible=E.visible,v.wireframe=E.wireframe,U===Si?v.side=E.shadowSide!==null?E.shadowSide:E.side:v.side=E.shadowSide!==null?E.shadowSide:u[E.side],v.alphaMap=E.alphaMap,v.alphaTest=E.alphaTest,v.map=E.map,v.clipShadows=E.clipShadows,v.clippingPlanes=E.clippingPlanes,v.clipIntersection=E.clipIntersection,v.displacementMap=E.displacementMap,v.displacementScale=E.displacementScale,v.displacementBias=E.displacementBias,v.wireframeLinewidth=E.wireframeLinewidth,v.linewidth=E.linewidth,P.isPointLight===!0&&v.isMeshDistanceMaterial===!0){const I=i.properties.get(v);I.light=P}return v}function S(T,E,P,U,v){if(T.visible===!1)return;if(T.layers.test(E.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&v===Si)&&(!T.frustumCulled||n.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(P.matrixWorldInverse,T.matrixWorld);const O=t.update(T),$=T.material;if(Array.isArray($)){const K=O.groups;for(let z=0,Z=K.length;z<Z;z++){const V=K[z],ot=$[V.materialIndex];if(ot&&ot.visible){const ct=x(T,ot,U,v);T.onBeforeShadow(i,T,E,P,O,ct,V),i.renderBufferDirect(P,null,O,ct,T,V),T.onAfterShadow(i,T,E,P,O,ct,V)}}}else if($.visible){const K=x(T,$,U,v);T.onBeforeShadow(i,T,E,P,O,K,null),i.renderBufferDirect(P,null,O,K,T,null),T.onAfterShadow(i,T,E,P,O,K,null)}}const I=T.children;for(let O=0,$=I.length;O<$;O++)S(I[O],E,P,U,v)}function L(T){T.target.removeEventListener("dispose",L);for(const P in c){const U=c[P],v=T.target.uuid;v in U&&(U[v].dispose(),delete U[v])}}}const ly={[cc]:hc,[uc]:pc,[dc]:mc,[xr]:fc,[hc]:cc,[pc]:uc,[mc]:dc,[fc]:xr};function cy(i){function t(){let D=!1;const dt=new me;let G=null;const J=new me(0,0,0,0);return{setMask:function(gt){G!==gt&&!D&&(i.colorMask(gt,gt,gt,gt),G=gt)},setLocked:function(gt){D=gt},setClear:function(gt,xt,ne,De,fn){fn===!0&&(gt*=De,xt*=De,ne*=De),dt.set(gt,xt,ne,De),J.equals(dt)===!1&&(i.clearColor(gt,xt,ne,De),J.copy(dt))},reset:function(){D=!1,G=null,J.set(-1,0,0,0)}}}function e(){let D=!1,dt=!1,G=null,J=null,gt=null;return{setReversed:function(xt){dt=xt},setTest:function(xt){xt?ft(i.DEPTH_TEST):lt(i.DEPTH_TEST)},setMask:function(xt){G!==xt&&!D&&(i.depthMask(xt),G=xt)},setFunc:function(xt){if(dt&&(xt=ly[xt]),J!==xt){switch(xt){case cc:i.depthFunc(i.NEVER);break;case hc:i.depthFunc(i.ALWAYS);break;case uc:i.depthFunc(i.LESS);break;case xr:i.depthFunc(i.LEQUAL);break;case dc:i.depthFunc(i.EQUAL);break;case fc:i.depthFunc(i.GEQUAL);break;case pc:i.depthFunc(i.GREATER);break;case mc:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}J=xt}},setLocked:function(xt){D=xt},setClear:function(xt){gt!==xt&&(i.clearDepth(xt),gt=xt)},reset:function(){D=!1,G=null,J=null,gt=null}}}function n(){let D=!1,dt=null,G=null,J=null,gt=null,xt=null,ne=null,De=null,fn=null;return{setTest:function(ae){D||(ae?ft(i.STENCIL_TEST):lt(i.STENCIL_TEST))},setMask:function(ae){dt!==ae&&!D&&(i.stencilMask(ae),dt=ae)},setFunc:function(ae,pn,gi){(G!==ae||J!==pn||gt!==gi)&&(i.stencilFunc(ae,pn,gi),G=ae,J=pn,gt=gi)},setOp:function(ae,pn,gi){(xt!==ae||ne!==pn||De!==gi)&&(i.stencilOp(ae,pn,gi),xt=ae,ne=pn,De=gi)},setLocked:function(ae){D=ae},setClear:function(ae){fn!==ae&&(i.clearStencil(ae),fn=ae)},reset:function(){D=!1,dt=null,G=null,J=null,gt=null,xt=null,ne=null,De=null,fn=null}}}const s=new t,r=new e,a=new n,o=new WeakMap,l=new WeakMap;let c={},h={},u=new WeakMap,d=[],f=null,g=!1,_=null,m=null,p=null,y=null,x=null,S=null,L=null,T=new Zt(0,0,0),E=0,P=!1,U=null,v=null,b=null,I=null,O=null;const $=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,z=0;const Z=i.getParameter(i.VERSION);Z.indexOf("WebGL")!==-1?(z=parseFloat(/^WebGL (\d)/.exec(Z)[1]),K=z>=1):Z.indexOf("OpenGL ES")!==-1&&(z=parseFloat(/^OpenGL ES (\d)/.exec(Z)[1]),K=z>=2);let V=null,ot={};const ct=i.getParameter(i.SCISSOR_BOX),_t=i.getParameter(i.VIEWPORT),$t=new me().fromArray(ct),Jt=new me().fromArray(_t);function j(D,dt,G,J){const gt=new Uint8Array(4),xt=i.createTexture();i.bindTexture(D,xt),i.texParameteri(D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(D,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let ne=0;ne<G;ne++)D===i.TEXTURE_3D||D===i.TEXTURE_2D_ARRAY?i.texImage3D(dt,0,i.RGBA,1,1,J,0,i.RGBA,i.UNSIGNED_BYTE,gt):i.texImage2D(dt+ne,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,gt);return xt}const et={};et[i.TEXTURE_2D]=j(i.TEXTURE_2D,i.TEXTURE_2D,1),et[i.TEXTURE_CUBE_MAP]=j(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),et[i.TEXTURE_2D_ARRAY]=j(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),et[i.TEXTURE_3D]=j(i.TEXTURE_3D,i.TEXTURE_3D,1,1),s.setClear(0,0,0,1),r.setClear(1),a.setClear(0),ft(i.DEPTH_TEST),r.setFunc(xr),Ct(!1),Bt(uu),ft(i.CULL_FACE),A(qe);function ft(D){c[D]!==!0&&(i.enable(D),c[D]=!0)}function lt(D){c[D]!==!1&&(i.disable(D),c[D]=!1)}function At(D,dt){return h[D]!==dt?(i.bindFramebuffer(D,dt),h[D]=dt,D===i.DRAW_FRAMEBUFFER&&(h[i.FRAMEBUFFER]=dt),D===i.FRAMEBUFFER&&(h[i.DRAW_FRAMEBUFFER]=dt),!0):!1}function Tt(D,dt){let G=d,J=!1;if(D){G=u.get(dt),G===void 0&&(G=[],u.set(dt,G));const gt=D.textures;if(G.length!==gt.length||G[0]!==i.COLOR_ATTACHMENT0){for(let xt=0,ne=gt.length;xt<ne;xt++)G[xt]=i.COLOR_ATTACHMENT0+xt;G.length=gt.length,J=!0}}else G[0]!==i.BACK&&(G[0]=i.BACK,J=!0);J&&i.drawBuffers(G)}function zt(D){return f!==D?(i.useProgram(D),f=D,!0):!1}const ie={[Xn]:i.FUNC_ADD,[ym]:i.FUNC_SUBTRACT,[Mm]:i.FUNC_REVERSE_SUBTRACT};ie[bm]=i.MIN,ie[Sm]=i.MAX;const W={[$r]:i.ZERO,[wm]:i.ONE,[Em]:i.SRC_COLOR,[rc]:i.SRC_ALPHA,[Rm]:i.SRC_ALPHA_SATURATE,[lc]:i.DST_COLOR,[oc]:i.DST_ALPHA,[Tm]:i.ONE_MINUS_SRC_COLOR,[ac]:i.ONE_MINUS_SRC_ALPHA,[Cm]:i.ONE_MINUS_DST_COLOR,[Am]:i.ONE_MINUS_DST_ALPHA,[Pm]:i.CONSTANT_COLOR,[Lm]:i.ONE_MINUS_CONSTANT_COLOR,[Dm]:i.CONSTANT_ALPHA,[Im]:i.ONE_MINUS_CONSTANT_ALPHA};function A(D,dt,G,J,gt,xt,ne,De,fn,ae){if(D===qe){g===!0&&(lt(i.BLEND),g=!1);return}if(g===!1&&(ft(i.BLEND),g=!0),D!==ff){if(D!==_||ae!==P){if((m!==Xn||x!==Xn)&&(i.blendEquation(i.FUNC_ADD),m=Xn,x=Xn),ae)switch(D){case fr:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case sc:i.blendFunc(i.ONE,i.ONE);break;case du:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case fu:i.blendFuncSeparate(i.ZERO,i.SRC_COLOR,i.ZERO,i.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",D);break}else switch(D){case fr:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case sc:i.blendFunc(i.SRC_ALPHA,i.ONE);break;case du:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case fu:i.blendFunc(i.ZERO,i.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",D);break}p=null,y=null,S=null,L=null,T.set(0,0,0),E=0,_=D,P=ae}return}gt=gt||dt,xt=xt||G,ne=ne||J,(dt!==m||gt!==x)&&(i.blendEquationSeparate(ie[dt],ie[gt]),m=dt,x=gt),(G!==p||J!==y||xt!==S||ne!==L)&&(i.blendFuncSeparate(W[G],W[J],W[xt],W[ne]),p=G,y=J,S=xt,L=ne),(De.equals(T)===!1||fn!==E)&&(i.blendColor(De.r,De.g,De.b,fn),T.copy(De),E=fn),_=D,P=!1}function It(D,dt){D.side===ai?lt(i.CULL_FACE):ft(i.CULL_FACE);let G=D.side===hn;dt&&(G=!G),Ct(G),D.blending===fr&&D.transparent===!1?A(qe):A(D.blending,D.blendEquation,D.blendSrc,D.blendDst,D.blendEquationAlpha,D.blendSrcAlpha,D.blendDstAlpha,D.blendColor,D.blendAlpha,D.premultipliedAlpha),r.setFunc(D.depthFunc),r.setTest(D.depthTest),r.setMask(D.depthWrite),s.setMask(D.colorWrite);const J=D.stencilWrite;a.setTest(J),J&&(a.setMask(D.stencilWriteMask),a.setFunc(D.stencilFunc,D.stencilRef,D.stencilFuncMask),a.setOp(D.stencilFail,D.stencilZFail,D.stencilZPass)),ue(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),D.alphaToCoverage===!0?ft(i.SAMPLE_ALPHA_TO_COVERAGE):lt(i.SAMPLE_ALPHA_TO_COVERAGE)}function Ct(D){U!==D&&(D?i.frontFace(i.CW):i.frontFace(i.CCW),U=D)}function Bt(D){D!==_m?(ft(i.CULL_FACE),D!==v&&(D===uu?i.cullFace(i.BACK):D===xm?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):lt(i.CULL_FACE),v=D}function Dt(D){D!==b&&(K&&i.lineWidth(D),b=D)}function ue(D,dt,G){D?(ft(i.POLYGON_OFFSET_FILL),(I!==dt||O!==G)&&(i.polygonOffset(dt,G),I=dt,O=G)):lt(i.POLYGON_OFFSET_FILL)}function kt(D){D?ft(i.SCISSOR_TEST):lt(i.SCISSOR_TEST)}function C(D){D===void 0&&(D=i.TEXTURE0+$-1),V!==D&&(i.activeTexture(D),V=D)}function M(D,dt,G){G===void 0&&(V===null?G=i.TEXTURE0+$-1:G=V);let J=ot[G];J===void 0&&(J={type:void 0,texture:void 0},ot[G]=J),(J.type!==D||J.texture!==dt)&&(V!==G&&(i.activeTexture(G),V=G),i.bindTexture(D,dt||et[D]),J.type=D,J.texture=dt)}function F(){const D=ot[V];D!==void 0&&D.type!==void 0&&(i.bindTexture(D.type,null),D.type=void 0,D.texture=void 0)}function Y(){try{i.compressedTexImage2D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function Q(){try{i.compressedTexImage3D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function q(){try{i.texSubImage2D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function St(){try{i.texSubImage3D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function ht(){try{i.compressedTexSubImage2D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function pt(){try{i.compressedTexSubImage3D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function Yt(){try{i.texStorage2D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function it(){try{i.texStorage3D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function mt(){try{i.texImage2D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function Ut(){try{i.texImage3D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function Ot(D){$t.equals(D)===!1&&(i.scissor(D.x,D.y,D.z,D.w),$t.copy(D))}function Mt(D){Jt.equals(D)===!1&&(i.viewport(D.x,D.y,D.z,D.w),Jt.copy(D))}function Qt(D,dt){let G=l.get(dt);G===void 0&&(G=new WeakMap,l.set(dt,G));let J=G.get(D);J===void 0&&(J=i.getUniformBlockIndex(dt,D.name),G.set(D,J))}function Vt(D,dt){const J=l.get(dt).get(D);o.get(dt)!==J&&(i.uniformBlockBinding(dt,J,D.__bindingPointIndex),o.set(dt,J))}function se(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),c={},V=null,ot={},h={},u=new WeakMap,d=[],f=null,g=!1,_=null,m=null,p=null,y=null,x=null,S=null,L=null,T=new Zt(0,0,0),E=0,P=!1,U=null,v=null,b=null,I=null,O=null,$t.set(0,0,i.canvas.width,i.canvas.height),Jt.set(0,0,i.canvas.width,i.canvas.height),s.reset(),r.reset(),a.reset()}return{buffers:{color:s,depth:r,stencil:a},enable:ft,disable:lt,bindFramebuffer:At,drawBuffers:Tt,useProgram:zt,setBlending:A,setMaterial:It,setFlipSided:Ct,setCullFace:Bt,setLineWidth:Dt,setPolygonOffset:ue,setScissorTest:kt,activeTexture:C,bindTexture:M,unbindTexture:F,compressedTexImage2D:Y,compressedTexImage3D:Q,texImage2D:mt,texImage3D:Ut,updateUBOMapping:Qt,uniformBlockBinding:Vt,texStorage2D:Yt,texStorage3D:it,texSubImage2D:q,texSubImage3D:St,compressedTexSubImage2D:ht,compressedTexSubImage3D:pt,scissor:Ot,viewport:Mt,reset:se}}function id(i,t,e,n){const s=hy(n);switch(e){case wf:return i*t;case Tf:return i*t;case Af:return i*t*2;case Cf:return i*t/s.components*s.byteLength;case fh:return i*t/s.components*s.byteLength;case Rf:return i*t*2/s.components*s.byteLength;case ph:return i*t*2/s.components*s.byteLength;case Ef:return i*t*3/s.components*s.byteLength;case kn:return i*t*4/s.components*s.byteLength;case mh:return i*t*4/s.components*s.byteLength;case to:case eo:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case no:case io:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case yc:case bc:return Math.max(i,16)*Math.max(t,8)/4;case xc:case Mc:return Math.max(i,8)*Math.max(t,8)/2;case Sc:case wc:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case Ec:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case Tc:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case Ac:return Math.floor((i+4)/5)*Math.floor((t+3)/4)*16;case Cc:return Math.floor((i+4)/5)*Math.floor((t+4)/5)*16;case Rc:return Math.floor((i+5)/6)*Math.floor((t+4)/5)*16;case Pc:return Math.floor((i+5)/6)*Math.floor((t+5)/6)*16;case Lc:return Math.floor((i+7)/8)*Math.floor((t+4)/5)*16;case Dc:return Math.floor((i+7)/8)*Math.floor((t+5)/6)*16;case Ic:return Math.floor((i+7)/8)*Math.floor((t+7)/8)*16;case kc:return Math.floor((i+9)/10)*Math.floor((t+4)/5)*16;case Nc:return Math.floor((i+9)/10)*Math.floor((t+5)/6)*16;case Uc:return Math.floor((i+9)/10)*Math.floor((t+7)/8)*16;case Oc:return Math.floor((i+9)/10)*Math.floor((t+9)/10)*16;case Fc:return Math.floor((i+11)/12)*Math.floor((t+9)/10)*16;case zc:return Math.floor((i+11)/12)*Math.floor((t+11)/12)*16;case so:case Bc:case Hc:return Math.ceil(i/4)*Math.ceil(t/4)*16;case Pf:case Vc:return Math.ceil(i/4)*Math.ceil(t/4)*8;case Gc:case $c:return Math.ceil(i/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function hy(i){switch(i){case di:case Mf:return{byteLength:1,components:1};case sa:case bf:case Ni:return{byteLength:2,components:1};case uh:case dh:return{byteLength:2,components:4};case bs:case hh:case Ai:return{byteLength:4,components:1};case Sf:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}function uy(i,t,e,n,s,r,a){const o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new at,h=new WeakMap;let u;const d=new WeakMap;let f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(C,M){return f?new OffscreenCanvas(C,M):bo("canvas")}function _(C,M,F){let Y=1;const Q=kt(C);if((Q.width>F||Q.height>F)&&(Y=F/Math.max(Q.width,Q.height)),Y<1)if(typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&C instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&C instanceof ImageBitmap||typeof VideoFrame<"u"&&C instanceof VideoFrame){const q=Math.floor(Y*Q.width),St=Math.floor(Y*Q.height);u===void 0&&(u=g(q,St));const ht=M?g(q,St):u;return ht.width=q,ht.height=St,ht.getContext("2d").drawImage(C,0,0,q,St),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+Q.width+"x"+Q.height+") to ("+q+"x"+St+")."),ht}else return"data"in C&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+Q.width+"x"+Q.height+")."),C;return C}function m(C){return C.generateMipmaps&&C.minFilter!==sn&&C.minFilter!==jn}function p(C){i.generateMipmap(C)}function y(C,M,F,Y,Q=!1){if(C!==null){if(i[C]!==void 0)return i[C];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+C+"'")}let q=M;if(M===i.RED&&(F===i.FLOAT&&(q=i.R32F),F===i.HALF_FLOAT&&(q=i.R16F),F===i.UNSIGNED_BYTE&&(q=i.R8)),M===i.RED_INTEGER&&(F===i.UNSIGNED_BYTE&&(q=i.R8UI),F===i.UNSIGNED_SHORT&&(q=i.R16UI),F===i.UNSIGNED_INT&&(q=i.R32UI),F===i.BYTE&&(q=i.R8I),F===i.SHORT&&(q=i.R16I),F===i.INT&&(q=i.R32I)),M===i.RG&&(F===i.FLOAT&&(q=i.RG32F),F===i.HALF_FLOAT&&(q=i.RG16F),F===i.UNSIGNED_BYTE&&(q=i.RG8)),M===i.RG_INTEGER&&(F===i.UNSIGNED_BYTE&&(q=i.RG8UI),F===i.UNSIGNED_SHORT&&(q=i.RG16UI),F===i.UNSIGNED_INT&&(q=i.RG32UI),F===i.BYTE&&(q=i.RG8I),F===i.SHORT&&(q=i.RG16I),F===i.INT&&(q=i.RG32I)),M===i.RGB_INTEGER&&(F===i.UNSIGNED_BYTE&&(q=i.RGB8UI),F===i.UNSIGNED_SHORT&&(q=i.RGB16UI),F===i.UNSIGNED_INT&&(q=i.RGB32UI),F===i.BYTE&&(q=i.RGB8I),F===i.SHORT&&(q=i.RGB16I),F===i.INT&&(q=i.RGB32I)),M===i.RGBA_INTEGER&&(F===i.UNSIGNED_BYTE&&(q=i.RGBA8UI),F===i.UNSIGNED_SHORT&&(q=i.RGBA16UI),F===i.UNSIGNED_INT&&(q=i.RGBA32UI),F===i.BYTE&&(q=i.RGBA8I),F===i.SHORT&&(q=i.RGBA16I),F===i.INT&&(q=i.RGBA32I)),M===i.RGB&&F===i.UNSIGNED_INT_5_9_9_9_REV&&(q=i.RGB9_E5),M===i.RGBA){const St=Q?_o:oe.getTransfer(Y);F===i.FLOAT&&(q=i.RGBA32F),F===i.HALF_FLOAT&&(q=i.RGBA16F),F===i.UNSIGNED_BYTE&&(q=St===ye?i.SRGB8_ALPHA8:i.RGBA8),F===i.UNSIGNED_SHORT_4_4_4_4&&(q=i.RGBA4),F===i.UNSIGNED_SHORT_5_5_5_1&&(q=i.RGB5_A1)}return(q===i.R16F||q===i.R32F||q===i.RG16F||q===i.RG32F||q===i.RGBA16F||q===i.RGBA32F)&&t.get("EXT_color_buffer_float"),q}function x(C,M){let F;return C?M===null||M===bs||M===Ss?F=i.DEPTH24_STENCIL8:M===Ai?F=i.DEPTH32F_STENCIL8:M===sa&&(F=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):M===null||M===bs||M===Ss?F=i.DEPTH_COMPONENT24:M===Ai?F=i.DEPTH_COMPONENT32F:M===sa&&(F=i.DEPTH_COMPONENT16),F}function S(C,M){return m(C)===!0||C.isFramebufferTexture&&C.minFilter!==sn&&C.minFilter!==jn?Math.log2(Math.max(M.width,M.height))+1:C.mipmaps!==void 0&&C.mipmaps.length>0?C.mipmaps.length:C.isCompressedTexture&&Array.isArray(C.image)?M.mipmaps.length:1}function L(C){const M=C.target;M.removeEventListener("dispose",L),E(M),M.isVideoTexture&&h.delete(M)}function T(C){const M=C.target;M.removeEventListener("dispose",T),U(M)}function E(C){const M=n.get(C);if(M.__webglInit===void 0)return;const F=C.source,Y=d.get(F);if(Y){const Q=Y[M.__cacheKey];Q.usedTimes--,Q.usedTimes===0&&P(C),Object.keys(Y).length===0&&d.delete(F)}n.remove(C)}function P(C){const M=n.get(C);i.deleteTexture(M.__webglTexture);const F=C.source,Y=d.get(F);delete Y[M.__cacheKey],a.memory.textures--}function U(C){const M=n.get(C);if(C.depthTexture&&C.depthTexture.dispose(),C.isWebGLCubeRenderTarget)for(let Y=0;Y<6;Y++){if(Array.isArray(M.__webglFramebuffer[Y]))for(let Q=0;Q<M.__webglFramebuffer[Y].length;Q++)i.deleteFramebuffer(M.__webglFramebuffer[Y][Q]);else i.deleteFramebuffer(M.__webglFramebuffer[Y]);M.__webglDepthbuffer&&i.deleteRenderbuffer(M.__webglDepthbuffer[Y])}else{if(Array.isArray(M.__webglFramebuffer))for(let Y=0;Y<M.__webglFramebuffer.length;Y++)i.deleteFramebuffer(M.__webglFramebuffer[Y]);else i.deleteFramebuffer(M.__webglFramebuffer);if(M.__webglDepthbuffer&&i.deleteRenderbuffer(M.__webglDepthbuffer),M.__webglMultisampledFramebuffer&&i.deleteFramebuffer(M.__webglMultisampledFramebuffer),M.__webglColorRenderbuffer)for(let Y=0;Y<M.__webglColorRenderbuffer.length;Y++)M.__webglColorRenderbuffer[Y]&&i.deleteRenderbuffer(M.__webglColorRenderbuffer[Y]);M.__webglDepthRenderbuffer&&i.deleteRenderbuffer(M.__webglDepthRenderbuffer)}const F=C.textures;for(let Y=0,Q=F.length;Y<Q;Y++){const q=n.get(F[Y]);q.__webglTexture&&(i.deleteTexture(q.__webglTexture),a.memory.textures--),n.remove(F[Y])}n.remove(C)}let v=0;function b(){v=0}function I(){const C=v;return C>=s.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+C+" texture units while this GPU supports only "+s.maxTextures),v+=1,C}function O(C){const M=[];return M.push(C.wrapS),M.push(C.wrapT),M.push(C.wrapR||0),M.push(C.magFilter),M.push(C.minFilter),M.push(C.anisotropy),M.push(C.internalFormat),M.push(C.format),M.push(C.type),M.push(C.generateMipmaps),M.push(C.premultiplyAlpha),M.push(C.flipY),M.push(C.unpackAlignment),M.push(C.colorSpace),M.join()}function $(C,M){const F=n.get(C);if(C.isVideoTexture&&Dt(C),C.isRenderTargetTexture===!1&&C.version>0&&F.__version!==C.version){const Y=C.image;if(Y===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Y.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Jt(F,C,M);return}}e.bindTexture(i.TEXTURE_2D,F.__webglTexture,i.TEXTURE0+M)}function K(C,M){const F=n.get(C);if(C.version>0&&F.__version!==C.version){Jt(F,C,M);return}e.bindTexture(i.TEXTURE_2D_ARRAY,F.__webglTexture,i.TEXTURE0+M)}function z(C,M){const F=n.get(C);if(C.version>0&&F.__version!==C.version){Jt(F,C,M);return}e.bindTexture(i.TEXTURE_3D,F.__webglTexture,i.TEXTURE0+M)}function Z(C,M){const F=n.get(C);if(C.version>0&&F.__version!==C.version){j(F,C,M);return}e.bindTexture(i.TEXTURE_CUBE_MAP,F.__webglTexture,i.TEXTURE0+M)}const V={[ki]:i.REPEAT,[vs]:i.CLAMP_TO_EDGE,[_c]:i.MIRRORED_REPEAT},ot={[sn]:i.NEAREST,[Om]:i.NEAREST_MIPMAP_NEAREST,[fa]:i.NEAREST_MIPMAP_LINEAR,[jn]:i.LINEAR,[Qo]:i.LINEAR_MIPMAP_NEAREST,[_s]:i.LINEAR_MIPMAP_LINEAR},ct={[Hm]:i.NEVER,[jm]:i.ALWAYS,[Vm]:i.LESS,[Lf]:i.LEQUAL,[Gm]:i.EQUAL,[Xm]:i.GEQUAL,[$m]:i.GREATER,[Wm]:i.NOTEQUAL};function _t(C,M){if(M.type===Ai&&t.has("OES_texture_float_linear")===!1&&(M.magFilter===jn||M.magFilter===Qo||M.magFilter===fa||M.magFilter===_s||M.minFilter===jn||M.minFilter===Qo||M.minFilter===fa||M.minFilter===_s)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(C,i.TEXTURE_WRAP_S,V[M.wrapS]),i.texParameteri(C,i.TEXTURE_WRAP_T,V[M.wrapT]),(C===i.TEXTURE_3D||C===i.TEXTURE_2D_ARRAY)&&i.texParameteri(C,i.TEXTURE_WRAP_R,V[M.wrapR]),i.texParameteri(C,i.TEXTURE_MAG_FILTER,ot[M.magFilter]),i.texParameteri(C,i.TEXTURE_MIN_FILTER,ot[M.minFilter]),M.compareFunction&&(i.texParameteri(C,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(C,i.TEXTURE_COMPARE_FUNC,ct[M.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(M.magFilter===sn||M.minFilter!==fa&&M.minFilter!==_s||M.type===Ai&&t.has("OES_texture_float_linear")===!1)return;if(M.anisotropy>1||n.get(M).__currentAnisotropy){const F=t.get("EXT_texture_filter_anisotropic");i.texParameterf(C,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(M.anisotropy,s.getMaxAnisotropy())),n.get(M).__currentAnisotropy=M.anisotropy}}}function $t(C,M){let F=!1;C.__webglInit===void 0&&(C.__webglInit=!0,M.addEventListener("dispose",L));const Y=M.source;let Q=d.get(Y);Q===void 0&&(Q={},d.set(Y,Q));const q=O(M);if(q!==C.__cacheKey){Q[q]===void 0&&(Q[q]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,F=!0),Q[q].usedTimes++;const St=Q[C.__cacheKey];St!==void 0&&(Q[C.__cacheKey].usedTimes--,St.usedTimes===0&&P(M)),C.__cacheKey=q,C.__webglTexture=Q[q].texture}return F}function Jt(C,M,F){let Y=i.TEXTURE_2D;(M.isDataArrayTexture||M.isCompressedArrayTexture)&&(Y=i.TEXTURE_2D_ARRAY),M.isData3DTexture&&(Y=i.TEXTURE_3D);const Q=$t(C,M),q=M.source;e.bindTexture(Y,C.__webglTexture,i.TEXTURE0+F);const St=n.get(q);if(q.version!==St.__version||Q===!0){e.activeTexture(i.TEXTURE0+F);const ht=oe.getPrimaries(oe.workingColorSpace),pt=M.colorSpace===Ki?null:oe.getPrimaries(M.colorSpace),Yt=M.colorSpace===Ki||ht===pt?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,M.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,M.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Yt);let it=_(M.image,!1,s.maxTextureSize);it=ue(M,it);const mt=r.convert(M.format,M.colorSpace),Ut=r.convert(M.type);let Ot=y(M.internalFormat,mt,Ut,M.colorSpace,M.isVideoTexture);_t(Y,M);let Mt;const Qt=M.mipmaps,Vt=M.isVideoTexture!==!0,se=St.__version===void 0||Q===!0,D=q.dataReady,dt=S(M,it);if(M.isDepthTexture)Ot=x(M.format===ws,M.type),se&&(Vt?e.texStorage2D(i.TEXTURE_2D,1,Ot,it.width,it.height):e.texImage2D(i.TEXTURE_2D,0,Ot,it.width,it.height,0,mt,Ut,null));else if(M.isDataTexture)if(Qt.length>0){Vt&&se&&e.texStorage2D(i.TEXTURE_2D,dt,Ot,Qt[0].width,Qt[0].height);for(let G=0,J=Qt.length;G<J;G++)Mt=Qt[G],Vt?D&&e.texSubImage2D(i.TEXTURE_2D,G,0,0,Mt.width,Mt.height,mt,Ut,Mt.data):e.texImage2D(i.TEXTURE_2D,G,Ot,Mt.width,Mt.height,0,mt,Ut,Mt.data);M.generateMipmaps=!1}else Vt?(se&&e.texStorage2D(i.TEXTURE_2D,dt,Ot,it.width,it.height),D&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,it.width,it.height,mt,Ut,it.data)):e.texImage2D(i.TEXTURE_2D,0,Ot,it.width,it.height,0,mt,Ut,it.data);else if(M.isCompressedTexture)if(M.isCompressedArrayTexture){Vt&&se&&e.texStorage3D(i.TEXTURE_2D_ARRAY,dt,Ot,Qt[0].width,Qt[0].height,it.depth);for(let G=0,J=Qt.length;G<J;G++)if(Mt=Qt[G],M.format!==kn)if(mt!==null)if(Vt){if(D)if(M.layerUpdates.size>0){const gt=id(Mt.width,Mt.height,M.format,M.type);for(const xt of M.layerUpdates){const ne=Mt.data.subarray(xt*gt/Mt.data.BYTES_PER_ELEMENT,(xt+1)*gt/Mt.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,G,0,0,xt,Mt.width,Mt.height,1,mt,ne,0,0)}M.clearLayerUpdates()}else e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,G,0,0,0,Mt.width,Mt.height,it.depth,mt,Mt.data,0,0)}else e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,G,Ot,Mt.width,Mt.height,it.depth,0,Mt.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Vt?D&&e.texSubImage3D(i.TEXTURE_2D_ARRAY,G,0,0,0,Mt.width,Mt.height,it.depth,mt,Ut,Mt.data):e.texImage3D(i.TEXTURE_2D_ARRAY,G,Ot,Mt.width,Mt.height,it.depth,0,mt,Ut,Mt.data)}else{Vt&&se&&e.texStorage2D(i.TEXTURE_2D,dt,Ot,Qt[0].width,Qt[0].height);for(let G=0,J=Qt.length;G<J;G++)Mt=Qt[G],M.format!==kn?mt!==null?Vt?D&&e.compressedTexSubImage2D(i.TEXTURE_2D,G,0,0,Mt.width,Mt.height,mt,Mt.data):e.compressedTexImage2D(i.TEXTURE_2D,G,Ot,Mt.width,Mt.height,0,Mt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Vt?D&&e.texSubImage2D(i.TEXTURE_2D,G,0,0,Mt.width,Mt.height,mt,Ut,Mt.data):e.texImage2D(i.TEXTURE_2D,G,Ot,Mt.width,Mt.height,0,mt,Ut,Mt.data)}else if(M.isDataArrayTexture)if(Vt){if(se&&e.texStorage3D(i.TEXTURE_2D_ARRAY,dt,Ot,it.width,it.height,it.depth),D)if(M.layerUpdates.size>0){const G=id(it.width,it.height,M.format,M.type);for(const J of M.layerUpdates){const gt=it.data.subarray(J*G/it.data.BYTES_PER_ELEMENT,(J+1)*G/it.data.BYTES_PER_ELEMENT);e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,J,it.width,it.height,1,mt,Ut,gt)}M.clearLayerUpdates()}else e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,it.width,it.height,it.depth,mt,Ut,it.data)}else e.texImage3D(i.TEXTURE_2D_ARRAY,0,Ot,it.width,it.height,it.depth,0,mt,Ut,it.data);else if(M.isData3DTexture)Vt?(se&&e.texStorage3D(i.TEXTURE_3D,dt,Ot,it.width,it.height,it.depth),D&&e.texSubImage3D(i.TEXTURE_3D,0,0,0,0,it.width,it.height,it.depth,mt,Ut,it.data)):e.texImage3D(i.TEXTURE_3D,0,Ot,it.width,it.height,it.depth,0,mt,Ut,it.data);else if(M.isFramebufferTexture){if(se)if(Vt)e.texStorage2D(i.TEXTURE_2D,dt,Ot,it.width,it.height);else{let G=it.width,J=it.height;for(let gt=0;gt<dt;gt++)e.texImage2D(i.TEXTURE_2D,gt,Ot,G,J,0,mt,Ut,null),G>>=1,J>>=1}}else if(Qt.length>0){if(Vt&&se){const G=kt(Qt[0]);e.texStorage2D(i.TEXTURE_2D,dt,Ot,G.width,G.height)}for(let G=0,J=Qt.length;G<J;G++)Mt=Qt[G],Vt?D&&e.texSubImage2D(i.TEXTURE_2D,G,0,0,mt,Ut,Mt):e.texImage2D(i.TEXTURE_2D,G,Ot,mt,Ut,Mt);M.generateMipmaps=!1}else if(Vt){if(se){const G=kt(it);e.texStorage2D(i.TEXTURE_2D,dt,Ot,G.width,G.height)}D&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,mt,Ut,it)}else e.texImage2D(i.TEXTURE_2D,0,Ot,mt,Ut,it);m(M)&&p(Y),St.__version=q.version,M.onUpdate&&M.onUpdate(M)}C.__version=M.version}function j(C,M,F){if(M.image.length!==6)return;const Y=$t(C,M),Q=M.source;e.bindTexture(i.TEXTURE_CUBE_MAP,C.__webglTexture,i.TEXTURE0+F);const q=n.get(Q);if(Q.version!==q.__version||Y===!0){e.activeTexture(i.TEXTURE0+F);const St=oe.getPrimaries(oe.workingColorSpace),ht=M.colorSpace===Ki?null:oe.getPrimaries(M.colorSpace),pt=M.colorSpace===Ki||St===ht?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,M.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,M.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,pt);const Yt=M.isCompressedTexture||M.image[0].isCompressedTexture,it=M.image[0]&&M.image[0].isDataTexture,mt=[];for(let J=0;J<6;J++)!Yt&&!it?mt[J]=_(M.image[J],!0,s.maxCubemapSize):mt[J]=it?M.image[J].image:M.image[J],mt[J]=ue(M,mt[J]);const Ut=mt[0],Ot=r.convert(M.format,M.colorSpace),Mt=r.convert(M.type),Qt=y(M.internalFormat,Ot,Mt,M.colorSpace),Vt=M.isVideoTexture!==!0,se=q.__version===void 0||Y===!0,D=Q.dataReady;let dt=S(M,Ut);_t(i.TEXTURE_CUBE_MAP,M);let G;if(Yt){Vt&&se&&e.texStorage2D(i.TEXTURE_CUBE_MAP,dt,Qt,Ut.width,Ut.height);for(let J=0;J<6;J++){G=mt[J].mipmaps;for(let gt=0;gt<G.length;gt++){const xt=G[gt];M.format!==kn?Ot!==null?Vt?D&&e.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,gt,0,0,xt.width,xt.height,Ot,xt.data):e.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,gt,Qt,xt.width,xt.height,0,xt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Vt?D&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,gt,0,0,xt.width,xt.height,Ot,Mt,xt.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,gt,Qt,xt.width,xt.height,0,Ot,Mt,xt.data)}}}else{if(G=M.mipmaps,Vt&&se){G.length>0&&dt++;const J=kt(mt[0]);e.texStorage2D(i.TEXTURE_CUBE_MAP,dt,Qt,J.width,J.height)}for(let J=0;J<6;J++)if(it){Vt?D&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,0,0,mt[J].width,mt[J].height,Ot,Mt,mt[J].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,Qt,mt[J].width,mt[J].height,0,Ot,Mt,mt[J].data);for(let gt=0;gt<G.length;gt++){const ne=G[gt].image[J].image;Vt?D&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,gt+1,0,0,ne.width,ne.height,Ot,Mt,ne.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,gt+1,Qt,ne.width,ne.height,0,Ot,Mt,ne.data)}}else{Vt?D&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,0,0,Ot,Mt,mt[J]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,Qt,Ot,Mt,mt[J]);for(let gt=0;gt<G.length;gt++){const xt=G[gt];Vt?D&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,gt+1,0,0,Ot,Mt,xt.image[J]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,gt+1,Qt,Ot,Mt,xt.image[J])}}}m(M)&&p(i.TEXTURE_CUBE_MAP),q.__version=Q.version,M.onUpdate&&M.onUpdate(M)}C.__version=M.version}function et(C,M,F,Y,Q,q){const St=r.convert(F.format,F.colorSpace),ht=r.convert(F.type),pt=y(F.internalFormat,St,ht,F.colorSpace);if(!n.get(M).__hasExternalTextures){const it=Math.max(1,M.width>>q),mt=Math.max(1,M.height>>q);Q===i.TEXTURE_3D||Q===i.TEXTURE_2D_ARRAY?e.texImage3D(Q,q,pt,it,mt,M.depth,0,St,ht,null):e.texImage2D(Q,q,pt,it,mt,0,St,ht,null)}e.bindFramebuffer(i.FRAMEBUFFER,C),Bt(M)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Y,Q,n.get(F).__webglTexture,0,Ct(M)):(Q===i.TEXTURE_2D||Q>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&Q<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,Y,Q,n.get(F).__webglTexture,q),e.bindFramebuffer(i.FRAMEBUFFER,null)}function ft(C,M,F){if(i.bindRenderbuffer(i.RENDERBUFFER,C),M.depthBuffer){const Y=M.depthTexture,Q=Y&&Y.isDepthTexture?Y.type:null,q=x(M.stencilBuffer,Q),St=M.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ht=Ct(M);Bt(M)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ht,q,M.width,M.height):F?i.renderbufferStorageMultisample(i.RENDERBUFFER,ht,q,M.width,M.height):i.renderbufferStorage(i.RENDERBUFFER,q,M.width,M.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,St,i.RENDERBUFFER,C)}else{const Y=M.textures;for(let Q=0;Q<Y.length;Q++){const q=Y[Q],St=r.convert(q.format,q.colorSpace),ht=r.convert(q.type),pt=y(q.internalFormat,St,ht,q.colorSpace),Yt=Ct(M);F&&Bt(M)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,Yt,pt,M.width,M.height):Bt(M)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Yt,pt,M.width,M.height):i.renderbufferStorage(i.RENDERBUFFER,pt,M.width,M.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function lt(C,M){if(M&&M.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(i.FRAMEBUFFER,C),!(M.depthTexture&&M.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(M.depthTexture).__webglTexture||M.depthTexture.image.width!==M.width||M.depthTexture.image.height!==M.height)&&(M.depthTexture.image.width=M.width,M.depthTexture.image.height=M.height,M.depthTexture.needsUpdate=!0),$(M.depthTexture,0);const Y=n.get(M.depthTexture).__webglTexture,Q=Ct(M);if(M.depthTexture.format===pr)Bt(M)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,Y,0,Q):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,Y,0);else if(M.depthTexture.format===ws)Bt(M)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,Y,0,Q):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,Y,0);else throw new Error("Unknown depthTexture format")}function At(C){const M=n.get(C),F=C.isWebGLCubeRenderTarget===!0;if(M.__boundDepthTexture!==C.depthTexture){const Y=C.depthTexture;if(M.__depthDisposeCallback&&M.__depthDisposeCallback(),Y){const Q=()=>{delete M.__boundDepthTexture,delete M.__depthDisposeCallback,Y.removeEventListener("dispose",Q)};Y.addEventListener("dispose",Q),M.__depthDisposeCallback=Q}M.__boundDepthTexture=Y}if(C.depthTexture&&!M.__autoAllocateDepthBuffer){if(F)throw new Error("target.depthTexture not supported in Cube render targets");lt(M.__webglFramebuffer,C)}else if(F){M.__webglDepthbuffer=[];for(let Y=0;Y<6;Y++)if(e.bindFramebuffer(i.FRAMEBUFFER,M.__webglFramebuffer[Y]),M.__webglDepthbuffer[Y]===void 0)M.__webglDepthbuffer[Y]=i.createRenderbuffer(),ft(M.__webglDepthbuffer[Y],C,!1);else{const Q=C.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,q=M.__webglDepthbuffer[Y];i.bindRenderbuffer(i.RENDERBUFFER,q),i.framebufferRenderbuffer(i.FRAMEBUFFER,Q,i.RENDERBUFFER,q)}}else if(e.bindFramebuffer(i.FRAMEBUFFER,M.__webglFramebuffer),M.__webglDepthbuffer===void 0)M.__webglDepthbuffer=i.createRenderbuffer(),ft(M.__webglDepthbuffer,C,!1);else{const Y=C.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Q=M.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,Q),i.framebufferRenderbuffer(i.FRAMEBUFFER,Y,i.RENDERBUFFER,Q)}e.bindFramebuffer(i.FRAMEBUFFER,null)}function Tt(C,M,F){const Y=n.get(C);M!==void 0&&et(Y.__webglFramebuffer,C,C.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),F!==void 0&&At(C)}function zt(C){const M=C.texture,F=n.get(C),Y=n.get(M);C.addEventListener("dispose",T);const Q=C.textures,q=C.isWebGLCubeRenderTarget===!0,St=Q.length>1;if(St||(Y.__webglTexture===void 0&&(Y.__webglTexture=i.createTexture()),Y.__version=M.version,a.memory.textures++),q){F.__webglFramebuffer=[];for(let ht=0;ht<6;ht++)if(M.mipmaps&&M.mipmaps.length>0){F.__webglFramebuffer[ht]=[];for(let pt=0;pt<M.mipmaps.length;pt++)F.__webglFramebuffer[ht][pt]=i.createFramebuffer()}else F.__webglFramebuffer[ht]=i.createFramebuffer()}else{if(M.mipmaps&&M.mipmaps.length>0){F.__webglFramebuffer=[];for(let ht=0;ht<M.mipmaps.length;ht++)F.__webglFramebuffer[ht]=i.createFramebuffer()}else F.__webglFramebuffer=i.createFramebuffer();if(St)for(let ht=0,pt=Q.length;ht<pt;ht++){const Yt=n.get(Q[ht]);Yt.__webglTexture===void 0&&(Yt.__webglTexture=i.createTexture(),a.memory.textures++)}if(C.samples>0&&Bt(C)===!1){F.__webglMultisampledFramebuffer=i.createFramebuffer(),F.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let ht=0;ht<Q.length;ht++){const pt=Q[ht];F.__webglColorRenderbuffer[ht]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,F.__webglColorRenderbuffer[ht]);const Yt=r.convert(pt.format,pt.colorSpace),it=r.convert(pt.type),mt=y(pt.internalFormat,Yt,it,pt.colorSpace,C.isXRRenderTarget===!0),Ut=Ct(C);i.renderbufferStorageMultisample(i.RENDERBUFFER,Ut,mt,C.width,C.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ht,i.RENDERBUFFER,F.__webglColorRenderbuffer[ht])}i.bindRenderbuffer(i.RENDERBUFFER,null),C.depthBuffer&&(F.__webglDepthRenderbuffer=i.createRenderbuffer(),ft(F.__webglDepthRenderbuffer,C,!0)),e.bindFramebuffer(i.FRAMEBUFFER,null)}}if(q){e.bindTexture(i.TEXTURE_CUBE_MAP,Y.__webglTexture),_t(i.TEXTURE_CUBE_MAP,M);for(let ht=0;ht<6;ht++)if(M.mipmaps&&M.mipmaps.length>0)for(let pt=0;pt<M.mipmaps.length;pt++)et(F.__webglFramebuffer[ht][pt],C,M,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+ht,pt);else et(F.__webglFramebuffer[ht],C,M,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+ht,0);m(M)&&p(i.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(St){for(let ht=0,pt=Q.length;ht<pt;ht++){const Yt=Q[ht],it=n.get(Yt);e.bindTexture(i.TEXTURE_2D,it.__webglTexture),_t(i.TEXTURE_2D,Yt),et(F.__webglFramebuffer,C,Yt,i.COLOR_ATTACHMENT0+ht,i.TEXTURE_2D,0),m(Yt)&&p(i.TEXTURE_2D)}e.unbindTexture()}else{let ht=i.TEXTURE_2D;if((C.isWebGL3DRenderTarget||C.isWebGLArrayRenderTarget)&&(ht=C.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(ht,Y.__webglTexture),_t(ht,M),M.mipmaps&&M.mipmaps.length>0)for(let pt=0;pt<M.mipmaps.length;pt++)et(F.__webglFramebuffer[pt],C,M,i.COLOR_ATTACHMENT0,ht,pt);else et(F.__webglFramebuffer,C,M,i.COLOR_ATTACHMENT0,ht,0);m(M)&&p(ht),e.unbindTexture()}C.depthBuffer&&At(C)}function ie(C){const M=C.textures;for(let F=0,Y=M.length;F<Y;F++){const Q=M[F];if(m(Q)){const q=C.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:i.TEXTURE_2D,St=n.get(Q).__webglTexture;e.bindTexture(q,St),p(q),e.unbindTexture()}}}const W=[],A=[];function It(C){if(C.samples>0){if(Bt(C)===!1){const M=C.textures,F=C.width,Y=C.height;let Q=i.COLOR_BUFFER_BIT;const q=C.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,St=n.get(C),ht=M.length>1;if(ht)for(let pt=0;pt<M.length;pt++)e.bindFramebuffer(i.FRAMEBUFFER,St.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+pt,i.RENDERBUFFER,null),e.bindFramebuffer(i.FRAMEBUFFER,St.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+pt,i.TEXTURE_2D,null,0);e.bindFramebuffer(i.READ_FRAMEBUFFER,St.__webglMultisampledFramebuffer),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,St.__webglFramebuffer);for(let pt=0;pt<M.length;pt++){if(C.resolveDepthBuffer&&(C.depthBuffer&&(Q|=i.DEPTH_BUFFER_BIT),C.stencilBuffer&&C.resolveStencilBuffer&&(Q|=i.STENCIL_BUFFER_BIT)),ht){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,St.__webglColorRenderbuffer[pt]);const Yt=n.get(M[pt]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,Yt,0)}i.blitFramebuffer(0,0,F,Y,0,0,F,Y,Q,i.NEAREST),l===!0&&(W.length=0,A.length=0,W.push(i.COLOR_ATTACHMENT0+pt),C.depthBuffer&&C.resolveDepthBuffer===!1&&(W.push(q),A.push(q),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,A)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,W))}if(e.bindFramebuffer(i.READ_FRAMEBUFFER,null),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),ht)for(let pt=0;pt<M.length;pt++){e.bindFramebuffer(i.FRAMEBUFFER,St.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+pt,i.RENDERBUFFER,St.__webglColorRenderbuffer[pt]);const Yt=n.get(M[pt]).__webglTexture;e.bindFramebuffer(i.FRAMEBUFFER,St.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+pt,i.TEXTURE_2D,Yt,0)}e.bindFramebuffer(i.DRAW_FRAMEBUFFER,St.__webglMultisampledFramebuffer)}else if(C.depthBuffer&&C.resolveDepthBuffer===!1&&l){const M=C.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[M])}}}function Ct(C){return Math.min(s.maxSamples,C.samples)}function Bt(C){const M=n.get(C);return C.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&M.__useRenderToTexture!==!1}function Dt(C){const M=a.render.frame;h.get(C)!==M&&(h.set(C,M),C.update())}function ue(C,M){const F=C.colorSpace,Y=C.format,Q=C.type;return C.isCompressedTexture===!0||C.isVideoTexture===!0||F!==os&&F!==Ki&&(oe.getTransfer(F)===ye?(Y!==kn||Q!==di)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",F)),M}function kt(C){return typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement?(c.width=C.naturalWidth||C.width,c.height=C.naturalHeight||C.height):typeof VideoFrame<"u"&&C instanceof VideoFrame?(c.width=C.displayWidth,c.height=C.displayHeight):(c.width=C.width,c.height=C.height),c}this.allocateTextureUnit=I,this.resetTextureUnits=b,this.setTexture2D=$,this.setTexture2DArray=K,this.setTexture3D=z,this.setTextureCube=Z,this.rebindTextures=Tt,this.setupRenderTarget=zt,this.updateRenderTargetMipmap=ie,this.updateMultisampleRenderTarget=It,this.setupDepthRenderbuffer=At,this.setupFrameBufferTexture=et,this.useMultisampledRTT=Bt}function dy(i,t){function e(n,s=Ki){let r;const a=oe.getTransfer(s);if(n===di)return i.UNSIGNED_BYTE;if(n===uh)return i.UNSIGNED_SHORT_4_4_4_4;if(n===dh)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Sf)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Mf)return i.BYTE;if(n===bf)return i.SHORT;if(n===sa)return i.UNSIGNED_SHORT;if(n===hh)return i.INT;if(n===bs)return i.UNSIGNED_INT;if(n===Ai)return i.FLOAT;if(n===Ni)return i.HALF_FLOAT;if(n===wf)return i.ALPHA;if(n===Ef)return i.RGB;if(n===kn)return i.RGBA;if(n===Tf)return i.LUMINANCE;if(n===Af)return i.LUMINANCE_ALPHA;if(n===pr)return i.DEPTH_COMPONENT;if(n===ws)return i.DEPTH_STENCIL;if(n===Cf)return i.RED;if(n===fh)return i.RED_INTEGER;if(n===Rf)return i.RG;if(n===ph)return i.RG_INTEGER;if(n===mh)return i.RGBA_INTEGER;if(n===to||n===eo||n===no||n===io)if(a===ye)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===to)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===eo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===no)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===io)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===to)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===eo)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===no)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===io)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===xc||n===yc||n===Mc||n===bc)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===xc)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===yc)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Mc)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===bc)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Sc||n===wc||n===Ec)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Sc||n===wc)return a===ye?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Ec)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===Tc||n===Ac||n===Cc||n===Rc||n===Pc||n===Lc||n===Dc||n===Ic||n===kc||n===Nc||n===Uc||n===Oc||n===Fc||n===zc)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Tc)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Ac)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Cc)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Rc)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Pc)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Lc)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Dc)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Ic)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===kc)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Nc)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Uc)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Oc)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Fc)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===zc)return a===ye?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===so||n===Bc||n===Hc)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(n===so)return a===ye?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Bc)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Hc)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Pf||n===Vc||n===Gc||n===$c)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(n===so)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Vc)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Gc)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===$c)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ss?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:e}}class fy extends An{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}class qt extends Je{constructor(){super(),this.isGroup=!0,this.type="Group"}}const py={type:"move"};class Al{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new qt,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 qt,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new R,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new R),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new qt,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new R,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new R),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let s=null,r=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(c&&t.hand){a=!0;for(const _ of t.hand.values()){const m=e.getJointPose(_,n),p=this._getHandJoint(c,_);m!==null&&(p.matrix.fromArray(m.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=m.radius),p.visible=m!==null}const h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,g=.005;c.inputState.pinching&&d>f+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&d<=f-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(r=e.getPose(t.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));o!==null&&(s=e.getPose(t.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(py)))}return o!==null&&(o.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){const n=new qt;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}const my=`
|
|
3817
3816
|
void main() {
|
|
3818
3817
|
|
|
3819
3818
|
gl_Position = vec4( position, 1.0 );
|
|
3820
3819
|
|
|
3821
|
-
}`,
|
|
3820
|
+
}`,gy=`
|
|
3822
3821
|
uniform sampler2DArray depthColor;
|
|
3823
3822
|
uniform float depthWidth;
|
|
3824
3823
|
uniform float depthHeight;
|
|
@@ -3837,7 +3836,7 @@ void main() {
|
|
|
3837
3836
|
|
|
3838
3837
|
}
|
|
3839
3838
|
|
|
3840
|
-
}`;class yy{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,n){if(this.texture===null){const s=new an,r=t.properties.get(s);r.__webglTexture=e.texture,(e.depthNear!=n.depthNear||e.depthFar!=n.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=s}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,n=new nn({vertexShader:_y,fragmentShader:xy,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new yt(new gi(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class My extends Ps{constructor(t,e){super();const n=this;let s=null,r=1,a=null,o="local-floor",l=1,c=null,h=null,u=null,d=null,f=null,g=null;const _=new yy,m=e.getContextAttributes();let p=null,y=null;const x=[],S=[],L=new rt;let T=null;const E=new Cn;E.layers.enable(1),E.viewport=new me;const P=new Cn;P.layers.enable(2),P.viewport=new me;const U=[E,P],v=new gy;v.layers.enable(1),v.layers.enable(2);let b=null,I=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(X){let et=x[X];return et===void 0&&(et=new Rl,x[X]=et),et.getTargetRaySpace()},this.getControllerGrip=function(X){let et=x[X];return et===void 0&&(et=new Rl,x[X]=et),et.getGripSpace()},this.getHand=function(X){let et=x[X];return et===void 0&&(et=new Rl,x[X]=et),et.getHandSpace()};function O(X){const et=S.indexOf(X.inputSource);if(et===-1)return;const ft=x[et];ft!==void 0&&(ft.update(X.inputSource,X.frame,c||a),ft.dispatchEvent({type:X.type,data:X.inputSource}))}function $(){s.removeEventListener("select",O),s.removeEventListener("selectstart",O),s.removeEventListener("selectend",O),s.removeEventListener("squeeze",O),s.removeEventListener("squeezestart",O),s.removeEventListener("squeezeend",O),s.removeEventListener("end",$),s.removeEventListener("inputsourceschange",K);for(let X=0;X<x.length;X++){const et=S[X];et!==null&&(S[X]=null,x[X].disconnect(et))}b=null,I=null,_.reset(),t.setRenderTarget(p),f=null,d=null,u=null,s=null,y=null,Jt.stop(),n.isPresenting=!1,t.setPixelRatio(T),t.setSize(L.width,L.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(X){r=X,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(X){o=X,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(X){c=X},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u},this.getFrame=function(){return g},this.getSession=function(){return s},this.setSession=async function(X){if(s=X,s!==null){if(p=t.getRenderTarget(),s.addEventListener("select",O),s.addEventListener("selectstart",O),s.addEventListener("selectend",O),s.addEventListener("squeeze",O),s.addEventListener("squeezestart",O),s.addEventListener("squeezeend",O),s.addEventListener("end",$),s.addEventListener("inputsourceschange",K),m.xrCompatible!==!0&&await e.makeXRCompatible(),T=t.getPixelRatio(),t.getSize(L),s.renderState.layers===void 0){const et={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(s,e,et),s.updateRenderState({baseLayer:f}),t.setPixelRatio(1),t.setSize(f.framebufferWidth,f.framebufferHeight,!1),y=new Qn(f.framebufferWidth,f.framebufferHeight,{format:Nn,type:pi,colorSpace:t.outputColorSpace,stencilBuffer:m.stencil})}else{let et=null,ft=null,ot=null;m.depth&&(ot=m.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,et=m.stencil?Cs:mr,ft=m.stencil?As:Ts);const At={colorFormat:e.RGBA8,depthFormat:ot,scaleFactor:r};u=new XRWebGLBinding(s,e),d=u.createProjectionLayer(At),s.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),y=new Qn(d.textureWidth,d.textureHeight,{format:Nn,type:pi,depthTexture:new Th(d.textureWidth,d.textureHeight,ft,void 0,void 0,void 0,void 0,void 0,void 0,et),stencilBuffer:m.stencil,colorSpace:t.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await s.requestReferenceSpace(o),Jt.setContext(s),Jt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return _.getDepthTexture()};function K(X){for(let et=0;et<X.removed.length;et++){const ft=X.removed[et],ot=S.indexOf(ft);ot>=0&&(S[ot]=null,x[ot].disconnect(ft))}for(let et=0;et<X.added.length;et++){const ft=X.added[et];let ot=S.indexOf(ft);if(ot===-1){for(let Tt=0;Tt<x.length;Tt++)if(Tt>=S.length){S.push(ft),ot=Tt;break}else if(S[Tt]===null){S[Tt]=ft,ot=Tt;break}if(ot===-1)break}const At=x[ot];At&&At.connect(ft)}}const z=new R,Z=new R;function V(X,et,ft){z.setFromMatrixPosition(et.matrixWorld),Z.setFromMatrixPosition(ft.matrixWorld);const ot=z.distanceTo(Z),At=et.projectionMatrix.elements,Tt=ft.projectionMatrix.elements,zt=At[14]/(At[10]-1),ie=At[14]/(At[10]+1),W=(At[9]+1)/At[5],A=(At[9]-1)/At[5],It=(At[8]-1)/At[0],Ct=(Tt[8]+1)/Tt[0],Bt=zt*It,Dt=zt*Ct,ue=ot/(-It+Ct),Nt=ue*-It;if(et.matrixWorld.decompose(X.position,X.quaternion,X.scale),X.translateX(Nt),X.translateZ(ue),X.matrixWorld.compose(X.position,X.quaternion,X.scale),X.matrixWorldInverse.copy(X.matrixWorld).invert(),At[10]===-1)X.projectionMatrix.copy(et.projectionMatrix),X.projectionMatrixInverse.copy(et.projectionMatrixInverse);else{const C=zt+ue,M=ie+ue,F=Bt-Nt,Y=Dt+(ot-Nt),Q=W*ie/M*C,j=A*ie/M*C;X.projectionMatrix.makePerspective(F,Y,Q,j,C,M),X.projectionMatrixInverse.copy(X.projectionMatrix).invert()}}function at(X,et){et===null?X.matrixWorld.copy(X.matrix):X.matrixWorld.multiplyMatrices(et.matrixWorld,X.matrix),X.matrixWorldInverse.copy(X.matrixWorld).invert()}this.updateCamera=function(X){if(s===null)return;let et=X.near,ft=X.far;_.texture!==null&&(_.depthNear>0&&(et=_.depthNear),_.depthFar>0&&(ft=_.depthFar)),v.near=P.near=E.near=et,v.far=P.far=E.far=ft,(b!==v.near||I!==v.far)&&(s.updateRenderState({depthNear:v.near,depthFar:v.far}),b=v.near,I=v.far);const ot=X.parent,At=v.cameras;at(v,ot);for(let Tt=0;Tt<At.length;Tt++)at(At[Tt],ot);At.length===2?V(v,E,P):v.projectionMatrix.copy(E.projectionMatrix),ct(X,v,ot)};function ct(X,et,ft){ft===null?X.matrix.copy(et.matrixWorld):(X.matrix.copy(ft.matrixWorld),X.matrix.invert(),X.matrix.multiply(et.matrixWorld)),X.matrix.decompose(X.position,X.quaternion,X.scale),X.updateMatrixWorld(!0),X.projectionMatrix.copy(et.projectionMatrix),X.projectionMatrixInverse.copy(et.projectionMatrixInverse),X.isPerspectiveCamera&&(X.fov=aa*2*Math.atan(1/X.projectionMatrix.elements[5]),X.zoom=1)}this.getCamera=function(){return v},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function(X){l=X,d!==null&&(d.fixedFoveation=X),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=X)},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(v)};let _t=null;function $t(X,et){if(h=et.getViewerPose(c||a),g=et,h!==null){const ft=h.views;f!==null&&(t.setRenderTargetFramebuffer(y,f.framebuffer),t.setRenderTarget(y));let ot=!1;ft.length!==v.cameras.length&&(v.cameras.length=0,ot=!0);for(let Tt=0;Tt<ft.length;Tt++){const zt=ft[Tt];let ie=null;if(f!==null)ie=f.getViewport(zt);else{const A=u.getViewSubImage(d,zt);ie=A.viewport,Tt===0&&(t.setRenderTargetTextures(y,A.colorTexture,d.ignoreDepthValues?void 0:A.depthStencilTexture),t.setRenderTarget(y))}let W=U[Tt];W===void 0&&(W=new Cn,W.layers.enable(Tt),W.viewport=new me,U[Tt]=W),W.matrix.fromArray(zt.transform.matrix),W.matrix.decompose(W.position,W.quaternion,W.scale),W.projectionMatrix.fromArray(zt.projectionMatrix),W.projectionMatrixInverse.copy(W.projectionMatrix).invert(),W.viewport.set(ie.x,ie.y,ie.width,ie.height),Tt===0&&(v.matrix.copy(W.matrix),v.matrix.decompose(v.position,v.quaternion,v.scale)),ot===!0&&v.cameras.push(W)}const At=s.enabledFeatures;if(At&&At.includes("depth-sensing")){const Tt=u.getDepthInformation(ft[0]);Tt&&Tt.isValid&&Tt.texture&&_.init(t,Tt,s.renderState)}}for(let ft=0;ft<x.length;ft++){const ot=S[ft],At=x[ft];ot!==null&&At!==void 0&&At.update(ot,et,c||a)}_t&&_t(X,et),et.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:et}),g=null}const Jt=new Gf;Jt.setAnimationLoop($t),this.setAnimationLoop=function(X){_t=X},this.dispose=function(){}}}const gs=new mi,by=new fe;function Sy(i,t){function e(m,p){m.matrixAutoUpdate===!0&&m.updateMatrix(),p.value.copy(m.matrix)}function n(m,p){p.color.getRGB(m.fogColor.value,Bf(i)),p.isFog?(m.fogNear.value=p.near,m.fogFar.value=p.far):p.isFogExp2&&(m.fogDensity.value=p.density)}function s(m,p,y,x,S){p.isMeshBasicMaterial||p.isMeshLambertMaterial?r(m,p):p.isMeshToonMaterial?(r(m,p),u(m,p)):p.isMeshPhongMaterial?(r(m,p),h(m,p)):p.isMeshStandardMaterial?(r(m,p),d(m,p),p.isMeshPhysicalMaterial&&f(m,p,S)):p.isMeshMatcapMaterial?(r(m,p),g(m,p)):p.isMeshDepthMaterial?r(m,p):p.isMeshDistanceMaterial?(r(m,p),_(m,p)):p.isMeshNormalMaterial?r(m,p):p.isLineBasicMaterial?(a(m,p),p.isLineDashedMaterial&&o(m,p)):p.isPointsMaterial?l(m,p,y,x):p.isSpriteMaterial?c(m,p):p.isShadowMaterial?(m.color.value.copy(p.color),m.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function r(m,p){m.opacity.value=p.opacity,p.color&&m.diffuse.value.copy(p.color),p.emissive&&m.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(m.map.value=p.map,e(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(p.alphaMap,m.alphaMapTransform)),p.bumpMap&&(m.bumpMap.value=p.bumpMap,e(p.bumpMap,m.bumpMapTransform),m.bumpScale.value=p.bumpScale,p.side===un&&(m.bumpScale.value*=-1)),p.normalMap&&(m.normalMap.value=p.normalMap,e(p.normalMap,m.normalMapTransform),m.normalScale.value.copy(p.normalScale),p.side===un&&m.normalScale.value.negate()),p.displacementMap&&(m.displacementMap.value=p.displacementMap,e(p.displacementMap,m.displacementMapTransform),m.displacementScale.value=p.displacementScale,m.displacementBias.value=p.displacementBias),p.emissiveMap&&(m.emissiveMap.value=p.emissiveMap,e(p.emissiveMap,m.emissiveMapTransform)),p.specularMap&&(m.specularMap.value=p.specularMap,e(p.specularMap,m.specularMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest);const y=t.get(p),x=y.envMap,S=y.envMapRotation;x&&(m.envMap.value=x,gs.copy(S),gs.x*=-1,gs.y*=-1,gs.z*=-1,x.isCubeTexture&&x.isRenderTargetTexture===!1&&(gs.y*=-1,gs.z*=-1),m.envMapRotation.value.setFromMatrix4(by.makeRotationFromEuler(gs)),m.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio),p.lightMap&&(m.lightMap.value=p.lightMap,m.lightMapIntensity.value=p.lightMapIntensity,e(p.lightMap,m.lightMapTransform)),p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,e(p.aoMap,m.aoMapTransform))}function a(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map&&(m.map.value=p.map,e(p.map,m.mapTransform))}function o(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}function l(m,p,y,x){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*y,m.scale.value=x*.5,p.map&&(m.map.value=p.map,e(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function c(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.rotation.value=p.rotation,p.map&&(m.map.value=p.map,e(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function h(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,1e-4)}function u(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function d(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,e(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,e(p.roughnessMap,m.roughnessMapTransform)),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function f(m,p,y){m.ior.value=p.ior,p.sheen>0&&(m.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),m.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(m.sheenColorMap.value=p.sheenColorMap,e(p.sheenColorMap,m.sheenColorMapTransform)),p.sheenRoughnessMap&&(m.sheenRoughnessMap.value=p.sheenRoughnessMap,e(p.sheenRoughnessMap,m.sheenRoughnessMapTransform))),p.clearcoat>0&&(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(m.clearcoatMap.value=p.clearcoatMap,e(p.clearcoatMap,m.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,e(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(m.clearcoatNormalMap.value=p.clearcoatNormalMap,e(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===un&&m.clearcoatNormalScale.value.negate())),p.dispersion>0&&(m.dispersion.value=p.dispersion),p.iridescence>0&&(m.iridescence.value=p.iridescence,m.iridescenceIOR.value=p.iridescenceIOR,m.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(m.iridescenceMap.value=p.iridescenceMap,e(p.iridescenceMap,m.iridescenceMapTransform)),p.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,e(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),p.transmission>0&&(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=y.texture,m.transmissionSamplerSize.value.set(y.width,y.height),p.transmissionMap&&(m.transmissionMap.value=p.transmissionMap,e(p.transmissionMap,m.transmissionMapTransform)),m.thickness.value=p.thickness,p.thicknessMap&&(m.thicknessMap.value=p.thicknessMap,e(p.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=p.attenuationDistance,m.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(m.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(m.anisotropyMap.value=p.anisotropyMap,e(p.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap&&(m.specularColorMap.value=p.specularColorMap,e(p.specularColorMap,m.specularColorMapTransform)),p.specularIntensityMap&&(m.specularIntensityMap.value=p.specularIntensityMap,e(p.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,p){p.matcap&&(m.matcap.value=p.matcap)}function _(m,p){const y=t.get(p).light;m.referencePosition.value.setFromMatrixPosition(y.matrixWorld),m.nearDistance.value=y.shadow.camera.near,m.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function wy(i,t,e,n){let s={},r={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,x){const S=x.program;n.uniformBlockBinding(y,S)}function c(y,x){let S=s[y.id];S===void 0&&(g(y),S=h(y),s[y.id]=S,y.addEventListener("dispose",m));const L=x.program;n.updateUBOMapping(y,L);const T=t.render.frame;r[y.id]!==T&&(d(y),r[y.id]=T)}function h(y){const x=u();y.__bindingPointIndex=x;const S=i.createBuffer(),L=y.__size,T=y.usage;return i.bindBuffer(i.UNIFORM_BUFFER,S),i.bufferData(i.UNIFORM_BUFFER,L,T),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,x,S),S}function u(){for(let y=0;y<o;y++)if(a.indexOf(y)===-1)return a.push(y),y;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(y){const x=s[y.id],S=y.uniforms,L=y.__cache;i.bindBuffer(i.UNIFORM_BUFFER,x);for(let T=0,E=S.length;T<E;T++){const P=Array.isArray(S[T])?S[T]:[S[T]];for(let U=0,v=P.length;U<v;U++){const b=P[U];if(f(b,T,U,L)===!0){const I=b.__offset,O=Array.isArray(b.value)?b.value:[b.value];let $=0;for(let K=0;K<O.length;K++){const z=O[K],Z=_(z);typeof z=="number"||typeof z=="boolean"?(b.__data[0]=z,i.bufferSubData(i.UNIFORM_BUFFER,I+$,b.__data)):z.isMatrix3?(b.__data[0]=z.elements[0],b.__data[1]=z.elements[1],b.__data[2]=z.elements[2],b.__data[3]=0,b.__data[4]=z.elements[3],b.__data[5]=z.elements[4],b.__data[6]=z.elements[5],b.__data[7]=0,b.__data[8]=z.elements[6],b.__data[9]=z.elements[7],b.__data[10]=z.elements[8],b.__data[11]=0):(z.toArray(b.__data,$),$+=Z.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,I,b.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function f(y,x,S,L){const T=y.value,E=x+"_"+S;if(L[E]===void 0)return typeof T=="number"||typeof T=="boolean"?L[E]=T:L[E]=T.clone(),!0;{const P=L[E];if(typeof T=="number"||typeof T=="boolean"){if(P!==T)return L[E]=T,!0}else if(P.equals(T)===!1)return P.copy(T),!0}return!1}function g(y){const x=y.uniforms;let S=0;const L=16;for(let E=0,P=x.length;E<P;E++){const U=Array.isArray(x[E])?x[E]:[x[E]];for(let v=0,b=U.length;v<b;v++){const I=U[v],O=Array.isArray(I.value)?I.value:[I.value];for(let $=0,K=O.length;$<K;$++){const z=O[$],Z=_(z),V=S%L,at=V%Z.boundary,ct=V+at;S+=at,ct!==0&&L-ct<Z.storage&&(S+=L-ct),I.__data=new Float32Array(Z.storage/Float32Array.BYTES_PER_ELEMENT),I.__offset=S,S+=Z.storage}}}const T=S%L;return T>0&&(S+=L-T),y.__size=S,y.__cache={},this}function _(y){const x={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(x.boundary=4,x.storage=4):y.isVector2?(x.boundary=8,x.storage=8):y.isVector3||y.isColor?(x.boundary=16,x.storage=12):y.isVector4?(x.boundary=16,x.storage=16):y.isMatrix3?(x.boundary=48,x.storage=48):y.isMatrix4?(x.boundary=64,x.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),x}function m(y){const x=y.target;x.removeEventListener("dispose",m);const S=a.indexOf(x.__bindingPointIndex);a.splice(S,1),i.deleteBuffer(s[x.id]),delete s[x.id],delete r[x.id]}function p(){for(const y in s)i.deleteBuffer(s[y]);a=[],s={},r={}}return{bind:l,update:c,dispose:p}}class Ey{constructor(t={}){const{canvas:e=f0(),context:n=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1}=t;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=a;const f=new Uint32Array(4),g=new Int32Array(4);let _=null,m=null;const p=[],y=[];this.domElement=e,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=Ke,this.toneMapping=ss,this.toneMappingExposure=1;const x=this;let S=!1,L=0,T=0,E=null,P=-1,U=null;const v=new me,b=new me;let I=null;const O=new Zt(0);let $=0,K=e.width,z=e.height,Z=1,V=null,at=null;const ct=new me(0,0,K,z),_t=new me(0,0,K,z);let $t=!1;const Jt=new Sh;let X=!1,et=!1;const ft=new fe,ot=new fe,At=new R,Tt=new me,zt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ie=!1;function W(){return E===null?Z:1}let A=n;function It(w,k){return e.getContext(w,k)}try{const w={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${ch}`),e.addEventListener("webglcontextlost",J,!1),e.addEventListener("webglcontextrestored",gt,!1),e.addEventListener("webglcontextcreationerror",xt,!1),A===null){const k="webgl2";if(A=It(k,w),A===null)throw It(k)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(w){throw console.error("THREE.WebGLRenderer: "+w.message),w}let Ct,Bt,Dt,ue,Nt,C,M,F,Y,Q,j,St,ht,pt,Yt,nt,mt,Ut,Ot,Mt,Qt,Vt,se,D;function dt(){Ct=new P_(A),Ct.init(),Vt=new my(A,Ct),Bt=new w_(A,Ct,t,Vt),Dt=new dy(A),Bt.reverseDepthBuffer&&Dt.buffers.depth.setReversed(!0),ue=new I_(A),Nt=new Zx,C=new py(A,Ct,Dt,Nt,Bt,Vt,ue),M=new T_(x),F=new R_(x),Y=new B0(A),se=new b_(A,Y),Q=new L_(A,Y,ue,se),j=new N_(A,Q,Y,ue),Ot=new k_(A,Bt,C),nt=new E_(Nt),St=new Kx(x,M,F,Ct,Bt,se,nt),ht=new Sy(x,Nt),pt=new Qx,Yt=new ry(Ct),Ut=new M_(x,M,F,Dt,j,d,l),mt=new hy(x,j,Bt),D=new wy(A,ue,Bt,Dt),Mt=new S_(A,Ct,ue),Qt=new D_(A,Ct,ue),ue.programs=St.programs,x.capabilities=Bt,x.extensions=Ct,x.properties=Nt,x.renderLists=pt,x.shadowMap=mt,x.state=Dt,x.info=ue}dt();const G=new My(x,A);this.xr=G,this.getContext=function(){return A},this.getContextAttributes=function(){return A.getContextAttributes()},this.forceContextLoss=function(){const w=Ct.get("WEBGL_lose_context");w&&w.loseContext()},this.forceContextRestore=function(){const w=Ct.get("WEBGL_lose_context");w&&w.restoreContext()},this.getPixelRatio=function(){return Z},this.setPixelRatio=function(w){w!==void 0&&(Z=w,this.setSize(K,z,!1))},this.getSize=function(w){return w.set(K,z)},this.setSize=function(w,k,B=!0){if(G.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}K=w,z=k,e.width=Math.floor(w*Z),e.height=Math.floor(k*Z),B===!0&&(e.style.width=w+"px",e.style.height=k+"px"),this.setViewport(0,0,w,k)},this.getDrawingBufferSize=function(w){return w.set(K*Z,z*Z).floor()},this.setDrawingBufferSize=function(w,k,B){K=w,z=k,Z=B,e.width=Math.floor(w*B),e.height=Math.floor(k*B),this.setViewport(0,0,w,k)},this.getCurrentViewport=function(w){return w.copy(v)},this.getViewport=function(w){return w.copy(ct)},this.setViewport=function(w,k,B,H){w.isVector4?ct.set(w.x,w.y,w.z,w.w):ct.set(w,k,B,H),Dt.viewport(v.copy(ct).multiplyScalar(Z).round())},this.getScissor=function(w){return w.copy(_t)},this.setScissor=function(w,k,B,H){w.isVector4?_t.set(w.x,w.y,w.z,w.w):_t.set(w,k,B,H),Dt.scissor(b.copy(_t).multiplyScalar(Z).round())},this.getScissorTest=function(){return $t},this.setScissorTest=function(w){Dt.setScissorTest($t=w)},this.setOpaqueSort=function(w){V=w},this.setTransparentSort=function(w){at=w},this.getClearColor=function(w){return w.copy(Ut.getClearColor())},this.setClearColor=function(){Ut.setClearColor.apply(Ut,arguments)},this.getClearAlpha=function(){return Ut.getClearAlpha()},this.setClearAlpha=function(){Ut.setClearAlpha.apply(Ut,arguments)},this.clear=function(w=!0,k=!0,B=!0){let H=0;if(w){let N=!1;if(E!==null){const st=E.texture.format;N=st===gh||st===mh||st===ph}if(N){const st=E.texture.type,vt=st===pi||st===Ts||st===ra||st===As||st===dh||st===fh,bt=Ut.getClearColor(),Et=Ut.getClearAlpha(),Ft=bt.r,Ht=bt.g,Rt=bt.b;vt?(f[0]=Ft,f[1]=Ht,f[2]=Rt,f[3]=Et,A.clearBufferuiv(A.COLOR,0,f)):(g[0]=Ft,g[1]=Ht,g[2]=Rt,g[3]=Et,A.clearBufferiv(A.COLOR,0,g))}else H|=A.COLOR_BUFFER_BIT}k&&(H|=A.DEPTH_BUFFER_BIT,A.clearDepth(this.capabilities.reverseDepthBuffer?0:1)),B&&(H|=A.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),A.clear(H)},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(){e.removeEventListener("webglcontextlost",J,!1),e.removeEventListener("webglcontextrestored",gt,!1),e.removeEventListener("webglcontextcreationerror",xt,!1),pt.dispose(),Yt.dispose(),Nt.dispose(),M.dispose(),F.dispose(),j.dispose(),se.dispose(),D.dispose(),St.dispose(),G.dispose(),G.removeEventListener("sessionstart",qh),G.removeEventListener("sessionend",Yh),hs.stop()};function J(w){w.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),S=!0}function gt(){console.log("THREE.WebGLRenderer: Context Restored."),S=!1;const w=ue.autoReset,k=mt.enabled,B=mt.autoUpdate,H=mt.needsUpdate,N=mt.type;dt(),ue.autoReset=w,mt.enabled=k,mt.autoUpdate=B,mt.needsUpdate=H,mt.type=N}function xt(w){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",w.statusMessage)}function ne(w){const k=w.target;k.removeEventListener("dispose",ne),ke(k)}function ke(w){pn(w),Nt.remove(w)}function pn(w){const k=Nt.get(w).programs;k!==void 0&&(k.forEach(function(B){St.releaseProgram(B)}),w.isShaderMaterial&&St.releaseShaderCache(w))}this.renderBufferDirect=function(w,k,B,H,N,st){k===null&&(k=zt);const vt=N.isMesh&&N.matrixWorld.determinant()<0,bt=Fp(w,k,B,H,N);Dt.setMaterial(H,vt);let Et=B.index,Ft=1;if(H.wireframe===!0){if(Et=Q.getWireframeAttribute(B),Et===void 0)return;Ft=2}const Ht=B.drawRange,Rt=B.attributes.position;let de=Ht.start*Ft,be=(Ht.start+Ht.count)*Ft;st!==null&&(de=Math.max(de,st.start*Ft),be=Math.min(be,(st.start+st.count)*Ft)),Et!==null?(de=Math.max(de,0),be=Math.min(be,Et.count)):Rt!=null&&(de=Math.max(de,0),be=Math.min(be,Rt.count));const Re=be-de;if(Re<0||Re===1/0)return;se.setup(N,H,bt,B,Et);let bn,le=Mt;if(Et!==null&&(bn=Y.get(Et),le=Qt,le.setIndex(bn)),N.isMesh)H.wireframe===!0?(Dt.setLineWidth(H.wireframeLinewidth*W()),le.setMode(A.LINES)):le.setMode(A.TRIANGLES);else if(N.isLine){let Lt=H.linewidth;Lt===void 0&&(Lt=1),Dt.setLineWidth(Lt*W()),N.isLineSegments?le.setMode(A.LINES):N.isLineLoop?le.setMode(A.LINE_LOOP):le.setMode(A.LINE_STRIP)}else N.isPoints?le.setMode(A.POINTS):N.isSprite&&le.setMode(A.TRIANGLES);if(N.isBatchedMesh)if(N._multiDrawInstances!==null)le.renderMultiDrawInstances(N._multiDrawStarts,N._multiDrawCounts,N._multiDrawCount,N._multiDrawInstances);else if(Ct.get("WEBGL_multi_draw"))le.renderMultiDraw(N._multiDrawStarts,N._multiDrawCounts,N._multiDrawCount);else{const Lt=N._multiDrawStarts,je=N._multiDrawCounts,ce=N._multiDrawCount,Hn=Et?Y.get(Et).bytesPerElement:1,ks=Nt.get(H).currentProgram.getUniforms();for(let Sn=0;Sn<ce;Sn++)ks.setValue(A,"_gl_DrawID",Sn),le.render(Lt[Sn]/Hn,je[Sn])}else if(N.isInstancedMesh)le.renderInstances(de,Re,N.count);else if(B.isInstancedBufferGeometry){const Lt=B._maxInstanceCount!==void 0?B._maxInstanceCount:1/0,je=Math.min(B.instanceCount,Lt);le.renderInstances(de,Re,je)}else le.render(de,Re)};function ae(w,k,B){w.transparent===!0&&w.side===li&&w.forceSinglePass===!1?(w.side=un,w.needsUpdate=!0,fa(w,k,B),w.side=os,w.needsUpdate=!0,fa(w,k,B),w.side=li):fa(w,k,B)}this.compile=function(w,k,B=null){B===null&&(B=w),m=Yt.get(B),m.init(k),y.push(m),B.traverseVisible(function(N){N.isLight&&N.layers.test(k.layers)&&(m.pushLight(N),N.castShadow&&m.pushShadow(N))}),w!==B&&w.traverseVisible(function(N){N.isLight&&N.layers.test(k.layers)&&(m.pushLight(N),N.castShadow&&m.pushShadow(N))}),m.setupLights();const H=new Set;return w.traverse(function(N){if(!(N.isMesh||N.isPoints||N.isLine||N.isSprite))return;const st=N.material;if(st)if(Array.isArray(st))for(let vt=0;vt<st.length;vt++){const bt=st[vt];ae(bt,B,N),H.add(bt)}else ae(st,B,N),H.add(st)}),y.pop(),m=null,H},this.compileAsync=function(w,k,B=null){const H=this.compile(w,k,B);return new Promise(N=>{function st(){if(H.forEach(function(vt){Nt.get(vt).currentProgram.isReady()&&H.delete(vt)}),H.size===0){N(w);return}setTimeout(st,10)}Ct.get("KHR_parallel_shader_compile")!==null?st():setTimeout(st,10)})};let mn=null;function _i(w){mn&&mn(w)}function qh(){hs.stop()}function Yh(){hs.start()}const hs=new Gf;hs.setAnimationLoop(_i),typeof self<"u"&&hs.setContext(self),this.setAnimationLoop=function(w){mn=w,G.setAnimationLoop(w),w===null?hs.stop():hs.start()},G.addEventListener("sessionstart",qh),G.addEventListener("sessionend",Yh),this.render=function(w,k){if(k!==void 0&&k.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(S===!0)return;if(w.matrixWorldAutoUpdate===!0&&w.updateMatrixWorld(),k.parent===null&&k.matrixWorldAutoUpdate===!0&&k.updateMatrixWorld(),G.enabled===!0&&G.isPresenting===!0&&(G.cameraAutoUpdate===!0&&G.updateCamera(k),k=G.getCamera()),w.isScene===!0&&w.onBeforeRender(x,w,k,E),m=Yt.get(w,y.length),m.init(k),y.push(m),ot.multiplyMatrices(k.projectionMatrix,k.matrixWorldInverse),Jt.setFromProjectionMatrix(ot),et=this.localClippingEnabled,X=nt.init(this.clippingPlanes,et),_=pt.get(w,p.length),_.init(),p.push(_),G.enabled===!0&&G.isPresenting===!0){const st=x.xr.getDepthSensingMesh();st!==null&&$o(st,k,-1/0,x.sortObjects)}$o(w,k,0,x.sortObjects),_.finish(),x.sortObjects===!0&&_.sort(V,at),ie=G.enabled===!1||G.isPresenting===!1||G.hasDepthSensing()===!1,ie&&Ut.addToRenderList(_,w),this.info.render.frame++,X===!0&&nt.beginShadows();const B=m.state.shadowsArray;mt.render(B,w,k),X===!0&&nt.endShadows(),this.info.autoReset===!0&&this.info.reset();const H=_.opaque,N=_.transmissive;if(m.setupLights(),k.isArrayCamera){const st=k.cameras;if(N.length>0)for(let vt=0,bt=st.length;vt<bt;vt++){const Et=st[vt];Zh(H,N,w,Et)}ie&&Ut.render(w);for(let vt=0,bt=st.length;vt<bt;vt++){const Et=st[vt];Kh(_,w,Et,Et.viewport)}}else N.length>0&&Zh(H,N,w,k),ie&&Ut.render(w),Kh(_,w,k);E!==null&&(C.updateMultisampleRenderTarget(E),C.updateRenderTargetMipmap(E)),w.isScene===!0&&w.onAfterRender(x,w,k),se.resetDefaultState(),P=-1,U=null,y.pop(),y.length>0?(m=y[y.length-1],X===!0&&nt.setGlobalState(x.clippingPlanes,m.state.camera)):m=null,p.pop(),p.length>0?_=p[p.length-1]:_=null};function $o(w,k,B,H){if(w.visible===!1)return;if(w.layers.test(k.layers)){if(w.isGroup)B=w.renderOrder;else if(w.isLOD)w.autoUpdate===!0&&w.update(k);else if(w.isLight)m.pushLight(w),w.castShadow&&m.pushShadow(w);else if(w.isSprite){if(!w.frustumCulled||Jt.intersectsSprite(w)){H&&Tt.setFromMatrixPosition(w.matrixWorld).applyMatrix4(ot);const vt=j.update(w),bt=w.material;bt.visible&&_.push(w,vt,bt,B,Tt.z,null)}}else if((w.isMesh||w.isLine||w.isPoints)&&(!w.frustumCulled||Jt.intersectsObject(w))){const vt=j.update(w),bt=w.material;if(H&&(w.boundingSphere!==void 0?(w.boundingSphere===null&&w.computeBoundingSphere(),Tt.copy(w.boundingSphere.center)):(vt.boundingSphere===null&&vt.computeBoundingSphere(),Tt.copy(vt.boundingSphere.center)),Tt.applyMatrix4(w.matrixWorld).applyMatrix4(ot)),Array.isArray(bt)){const Et=vt.groups;for(let Ft=0,Ht=Et.length;Ft<Ht;Ft++){const Rt=Et[Ft],de=bt[Rt.materialIndex];de&&de.visible&&_.push(w,vt,de,B,Tt.z,Rt)}}else bt.visible&&_.push(w,vt,bt,B,Tt.z,null)}}const st=w.children;for(let vt=0,bt=st.length;vt<bt;vt++)$o(st[vt],k,B,H)}function Kh(w,k,B,H){const N=w.opaque,st=w.transmissive,vt=w.transparent;m.setupLightsView(B),X===!0&&nt.setGlobalState(x.clippingPlanes,B),H&&Dt.viewport(v.copy(H)),N.length>0&&da(N,k,B),st.length>0&&da(st,k,B),vt.length>0&&da(vt,k,B),Dt.buffers.depth.setTest(!0),Dt.buffers.depth.setMask(!0),Dt.buffers.color.setMask(!0),Dt.setPolygonOffset(!1)}function Zh(w,k,B,H){if((B.isScene===!0?B.overrideMaterial:null)!==null)return;m.state.transmissionRenderTarget[H.id]===void 0&&(m.state.transmissionRenderTarget[H.id]=new Qn(1,1,{generateMipmaps:!0,type:Ct.has("EXT_color_buffer_half_float")||Ct.has("EXT_color_buffer_float")?Ui:pi,minFilter:bs,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:oe.workingColorSpace}));const st=m.state.transmissionRenderTarget[H.id],vt=H.viewport||v;st.setSize(vt.z,vt.w);const bt=x.getRenderTarget();x.setRenderTarget(st),x.getClearColor(O),$=x.getClearAlpha(),$<1&&x.setClearColor(16777215,.5),x.clear(),ie&&Ut.render(B);const Et=x.toneMapping;x.toneMapping=ss;const Ft=H.viewport;if(H.viewport!==void 0&&(H.viewport=void 0),m.setupLightsView(H),X===!0&&nt.setGlobalState(x.clippingPlanes,H),da(w,B,H),C.updateMultisampleRenderTarget(st),C.updateRenderTargetMipmap(st),Ct.has("WEBGL_multisampled_render_to_texture")===!1){let Ht=!1;for(let Rt=0,de=k.length;Rt<de;Rt++){const be=k[Rt],Re=be.object,bn=be.geometry,le=be.material,Lt=be.group;if(le.side===li&&Re.layers.test(H.layers)){const je=le.side;le.side=un,le.needsUpdate=!0,Jh(Re,B,H,bn,le,Lt),le.side=je,le.needsUpdate=!0,Ht=!0}}Ht===!0&&(C.updateMultisampleRenderTarget(st),C.updateRenderTargetMipmap(st))}x.setRenderTarget(bt),x.setClearColor(O,$),Ft!==void 0&&(H.viewport=Ft),x.toneMapping=Et}function da(w,k,B){const H=k.isScene===!0?k.overrideMaterial:null;for(let N=0,st=w.length;N<st;N++){const vt=w[N],bt=vt.object,Et=vt.geometry,Ft=H===null?vt.material:H,Ht=vt.group;bt.layers.test(B.layers)&&Jh(bt,k,B,Et,Ft,Ht)}}function Jh(w,k,B,H,N,st){w.onBeforeRender(x,k,B,H,N,st),w.modelViewMatrix.multiplyMatrices(B.matrixWorldInverse,w.matrixWorld),w.normalMatrix.getNormalMatrix(w.modelViewMatrix),N.onBeforeRender(x,k,B,H,w,st),N.transparent===!0&&N.side===li&&N.forceSinglePass===!1?(N.side=un,N.needsUpdate=!0,x.renderBufferDirect(B,k,H,N,w,st),N.side=os,N.needsUpdate=!0,x.renderBufferDirect(B,k,H,N,w,st),N.side=li):x.renderBufferDirect(B,k,H,N,w,st),w.onAfterRender(x,k,B,H,N,st)}function fa(w,k,B){k.isScene!==!0&&(k=zt);const H=Nt.get(w),N=m.state.lights,st=m.state.shadowsArray,vt=N.state.version,bt=St.getParameters(w,N.state,st,k,B),Et=St.getProgramCacheKey(bt);let Ft=H.programs;H.environment=w.isMeshStandardMaterial?k.environment:null,H.fog=k.fog,H.envMap=(w.isMeshStandardMaterial?F:M).get(w.envMap||H.environment),H.envMapRotation=H.environment!==null&&w.envMap===null?k.environmentRotation:w.envMapRotation,Ft===void 0&&(w.addEventListener("dispose",ne),Ft=new Map,H.programs=Ft);let Ht=Ft.get(Et);if(Ht!==void 0){if(H.currentProgram===Ht&&H.lightsStateVersion===vt)return tu(w,bt),Ht}else bt.uniforms=St.getUniforms(w),w.onBeforeCompile(bt,x),Ht=St.acquireProgram(bt,Et),Ft.set(Et,Ht),H.uniforms=bt.uniforms;const Rt=H.uniforms;return(!w.isShaderMaterial&&!w.isRawShaderMaterial||w.clipping===!0)&&(Rt.clippingPlanes=nt.uniform),tu(w,bt),H.needsLights=Bp(w),H.lightsStateVersion=vt,H.needsLights&&(Rt.ambientLightColor.value=N.state.ambient,Rt.lightProbe.value=N.state.probe,Rt.directionalLights.value=N.state.directional,Rt.directionalLightShadows.value=N.state.directionalShadow,Rt.spotLights.value=N.state.spot,Rt.spotLightShadows.value=N.state.spotShadow,Rt.rectAreaLights.value=N.state.rectArea,Rt.ltc_1.value=N.state.rectAreaLTC1,Rt.ltc_2.value=N.state.rectAreaLTC2,Rt.pointLights.value=N.state.point,Rt.pointLightShadows.value=N.state.pointShadow,Rt.hemisphereLights.value=N.state.hemi,Rt.directionalShadowMap.value=N.state.directionalShadowMap,Rt.directionalShadowMatrix.value=N.state.directionalShadowMatrix,Rt.spotShadowMap.value=N.state.spotShadowMap,Rt.spotLightMatrix.value=N.state.spotLightMatrix,Rt.spotLightMap.value=N.state.spotLightMap,Rt.pointShadowMap.value=N.state.pointShadowMap,Rt.pointShadowMatrix.value=N.state.pointShadowMatrix),H.currentProgram=Ht,H.uniformsList=null,Ht}function Qh(w){if(w.uniformsList===null){const k=w.currentProgram.getUniforms();w.uniformsList=lo.seqWithValue(k.seq,w.uniforms)}return w.uniformsList}function tu(w,k){const B=Nt.get(w);B.outputColorSpace=k.outputColorSpace,B.batching=k.batching,B.batchingColor=k.batchingColor,B.instancing=k.instancing,B.instancingColor=k.instancingColor,B.instancingMorph=k.instancingMorph,B.skinning=k.skinning,B.morphTargets=k.morphTargets,B.morphNormals=k.morphNormals,B.morphColors=k.morphColors,B.morphTargetsCount=k.morphTargetsCount,B.numClippingPlanes=k.numClippingPlanes,B.numIntersection=k.numClipIntersection,B.vertexAlphas=k.vertexAlphas,B.vertexTangents=k.vertexTangents,B.toneMapping=k.toneMapping}function Fp(w,k,B,H,N){k.isScene!==!0&&(k=zt),C.resetTextureUnits();const st=k.fog,vt=H.isMeshStandardMaterial?k.environment:null,bt=E===null?x.outputColorSpace:E.isXRRenderTarget===!0?E.texture.colorSpace:cs,Et=(H.isMeshStandardMaterial?F:M).get(H.envMap||vt),Ft=H.vertexColors===!0&&!!B.attributes.color&&B.attributes.color.itemSize===4,Ht=!!B.attributes.tangent&&(!!H.normalMap||H.anisotropy>0),Rt=!!B.morphAttributes.position,de=!!B.morphAttributes.normal,be=!!B.morphAttributes.color;let Re=ss;H.toneMapped&&(E===null||E.isXRRenderTarget===!0)&&(Re=x.toneMapping);const bn=B.morphAttributes.position||B.morphAttributes.normal||B.morphAttributes.color,le=bn!==void 0?bn.length:0,Lt=Nt.get(H),je=m.state.lights;if(X===!0&&(et===!0||w!==U)){const Pn=w===U&&H.id===P;nt.setState(H,w,Pn)}let ce=!1;H.version===Lt.__version?(Lt.needsLights&&Lt.lightsStateVersion!==je.state.version||Lt.outputColorSpace!==bt||N.isBatchedMesh&&Lt.batching===!1||!N.isBatchedMesh&&Lt.batching===!0||N.isBatchedMesh&&Lt.batchingColor===!0&&N.colorTexture===null||N.isBatchedMesh&&Lt.batchingColor===!1&&N.colorTexture!==null||N.isInstancedMesh&&Lt.instancing===!1||!N.isInstancedMesh&&Lt.instancing===!0||N.isSkinnedMesh&&Lt.skinning===!1||!N.isSkinnedMesh&&Lt.skinning===!0||N.isInstancedMesh&&Lt.instancingColor===!0&&N.instanceColor===null||N.isInstancedMesh&&Lt.instancingColor===!1&&N.instanceColor!==null||N.isInstancedMesh&&Lt.instancingMorph===!0&&N.morphTexture===null||N.isInstancedMesh&&Lt.instancingMorph===!1&&N.morphTexture!==null||Lt.envMap!==Et||H.fog===!0&&Lt.fog!==st||Lt.numClippingPlanes!==void 0&&(Lt.numClippingPlanes!==nt.numPlanes||Lt.numIntersection!==nt.numIntersection)||Lt.vertexAlphas!==Ft||Lt.vertexTangents!==Ht||Lt.morphTargets!==Rt||Lt.morphNormals!==de||Lt.morphColors!==be||Lt.toneMapping!==Re||Lt.morphTargetsCount!==le)&&(ce=!0):(ce=!0,Lt.__version=H.version);let Hn=Lt.currentProgram;ce===!0&&(Hn=fa(H,k,N));let ks=!1,Sn=!1,Wo=!1;const De=Hn.getUniforms(),Bi=Lt.uniforms;if(Dt.useProgram(Hn.program)&&(ks=!0,Sn=!0,Wo=!0),H.id!==P&&(P=H.id,Sn=!0),ks||U!==w){Bt.reverseDepthBuffer?(ft.copy(w.projectionMatrix),m0(ft),g0(ft),De.setValue(A,"projectionMatrix",ft)):De.setValue(A,"projectionMatrix",w.projectionMatrix),De.setValue(A,"viewMatrix",w.matrixWorldInverse);const Pn=De.map.cameraPosition;Pn!==void 0&&Pn.setValue(A,At.setFromMatrixPosition(w.matrixWorld)),Bt.logarithmicDepthBuffer&&De.setValue(A,"logDepthBufFC",2/(Math.log(w.far+1)/Math.LN2)),(H.isMeshPhongMaterial||H.isMeshToonMaterial||H.isMeshLambertMaterial||H.isMeshBasicMaterial||H.isMeshStandardMaterial||H.isShaderMaterial)&&De.setValue(A,"isOrthographic",w.isOrthographicCamera===!0),U!==w&&(U=w,Sn=!0,Wo=!0)}if(N.isSkinnedMesh){De.setOptional(A,N,"bindMatrix"),De.setOptional(A,N,"bindMatrixInverse");const Pn=N.skeleton;Pn&&(Pn.boneTexture===null&&Pn.computeBoneTexture(),De.setValue(A,"boneTexture",Pn.boneTexture,C))}N.isBatchedMesh&&(De.setOptional(A,N,"batchingTexture"),De.setValue(A,"batchingTexture",N._matricesTexture,C),De.setOptional(A,N,"batchingIdTexture"),De.setValue(A,"batchingIdTexture",N._indirectTexture,C),De.setOptional(A,N,"batchingColorTexture"),N._colorsTexture!==null&&De.setValue(A,"batchingColorTexture",N._colorsTexture,C));const Xo=B.morphAttributes;if((Xo.position!==void 0||Xo.normal!==void 0||Xo.color!==void 0)&&Ot.update(N,B,Hn),(Sn||Lt.receiveShadow!==N.receiveShadow)&&(Lt.receiveShadow=N.receiveShadow,De.setValue(A,"receiveShadow",N.receiveShadow)),H.isMeshGouraudMaterial&&H.envMap!==null&&(Bi.envMap.value=Et,Bi.flipEnvMap.value=Et.isCubeTexture&&Et.isRenderTargetTexture===!1?-1:1),H.isMeshStandardMaterial&&H.envMap===null&&k.environment!==null&&(Bi.envMapIntensity.value=k.environmentIntensity),Sn&&(De.setValue(A,"toneMappingExposure",x.toneMappingExposure),Lt.needsLights&&zp(Bi,Wo),st&&H.fog===!0&&ht.refreshFogUniforms(Bi,st),ht.refreshMaterialUniforms(Bi,H,Z,z,m.state.transmissionRenderTarget[w.id]),lo.upload(A,Qh(Lt),Bi,C)),H.isShaderMaterial&&H.uniformsNeedUpdate===!0&&(lo.upload(A,Qh(Lt),Bi,C),H.uniformsNeedUpdate=!1),H.isSpriteMaterial&&De.setValue(A,"center",N.center),De.setValue(A,"modelViewMatrix",N.modelViewMatrix),De.setValue(A,"normalMatrix",N.normalMatrix),De.setValue(A,"modelMatrix",N.matrixWorld),H.isShaderMaterial||H.isRawShaderMaterial){const Pn=H.uniformsGroups;for(let jo=0,Hp=Pn.length;jo<Hp;jo++){const eu=Pn[jo];D.update(eu,Hn),D.bind(eu,Hn)}}return Hn}function zp(w,k){w.ambientLightColor.needsUpdate=k,w.lightProbe.needsUpdate=k,w.directionalLights.needsUpdate=k,w.directionalLightShadows.needsUpdate=k,w.pointLights.needsUpdate=k,w.pointLightShadows.needsUpdate=k,w.spotLights.needsUpdate=k,w.spotLightShadows.needsUpdate=k,w.rectAreaLights.needsUpdate=k,w.hemisphereLights.needsUpdate=k}function Bp(w){return w.isMeshLambertMaterial||w.isMeshToonMaterial||w.isMeshPhongMaterial||w.isMeshStandardMaterial||w.isShadowMaterial||w.isShaderMaterial&&w.lights===!0}this.getActiveCubeFace=function(){return L},this.getActiveMipmapLevel=function(){return T},this.getRenderTarget=function(){return E},this.setRenderTargetTextures=function(w,k,B){Nt.get(w.texture).__webglTexture=k,Nt.get(w.depthTexture).__webglTexture=B;const H=Nt.get(w);H.__hasExternalTextures=!0,H.__autoAllocateDepthBuffer=B===void 0,H.__autoAllocateDepthBuffer||Ct.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),H.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(w,k){const B=Nt.get(w);B.__webglFramebuffer=k,B.__useDefaultFramebuffer=k===void 0},this.setRenderTarget=function(w,k=0,B=0){E=w,L=k,T=B;let H=!0,N=null,st=!1,vt=!1;if(w){const Et=Nt.get(w);if(Et.__useDefaultFramebuffer!==void 0)Dt.bindFramebuffer(A.FRAMEBUFFER,null),H=!1;else if(Et.__webglFramebuffer===void 0)C.setupRenderTarget(w);else if(Et.__hasExternalTextures)C.rebindTextures(w,Nt.get(w.texture).__webglTexture,Nt.get(w.depthTexture).__webglTexture);else if(w.depthBuffer){const Rt=w.depthTexture;if(Et.__boundDepthTexture!==Rt){if(Rt!==null&&Nt.has(Rt)&&(w.width!==Rt.image.width||w.height!==Rt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");C.setupDepthRenderbuffer(w)}}const Ft=w.texture;(Ft.isData3DTexture||Ft.isDataArrayTexture||Ft.isCompressedArrayTexture)&&(vt=!0);const Ht=Nt.get(w).__webglFramebuffer;w.isWebGLCubeRenderTarget?(Array.isArray(Ht[k])?N=Ht[k][B]:N=Ht[k],st=!0):w.samples>0&&C.useMultisampledRTT(w)===!1?N=Nt.get(w).__webglMultisampledFramebuffer:Array.isArray(Ht)?N=Ht[B]:N=Ht,v.copy(w.viewport),b.copy(w.scissor),I=w.scissorTest}else v.copy(ct).multiplyScalar(Z).floor(),b.copy(_t).multiplyScalar(Z).floor(),I=$t;if(Dt.bindFramebuffer(A.FRAMEBUFFER,N)&&H&&Dt.drawBuffers(w,N),Dt.viewport(v),Dt.scissor(b),Dt.setScissorTest(I),st){const Et=Nt.get(w.texture);A.framebufferTexture2D(A.FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_CUBE_MAP_POSITIVE_X+k,Et.__webglTexture,B)}else if(vt){const Et=Nt.get(w.texture),Ft=k||0;A.framebufferTextureLayer(A.FRAMEBUFFER,A.COLOR_ATTACHMENT0,Et.__webglTexture,B||0,Ft)}P=-1},this.readRenderTargetPixels=function(w,k,B,H,N,st,vt){if(!(w&&w.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let bt=Nt.get(w).__webglFramebuffer;if(w.isWebGLCubeRenderTarget&&vt!==void 0&&(bt=bt[vt]),bt){Dt.bindFramebuffer(A.FRAMEBUFFER,bt);try{const Et=w.texture,Ft=Et.format,Ht=Et.type;if(!Bt.textureFormatReadable(Ft)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Bt.textureTypeReadable(Ht)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}k>=0&&k<=w.width-H&&B>=0&&B<=w.height-N&&A.readPixels(k,B,H,N,Vt.convert(Ft),Vt.convert(Ht),st)}finally{const Et=E!==null?Nt.get(E).__webglFramebuffer:null;Dt.bindFramebuffer(A.FRAMEBUFFER,Et)}}},this.readRenderTargetPixelsAsync=async function(w,k,B,H,N,st,vt){if(!(w&&w.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let bt=Nt.get(w).__webglFramebuffer;if(w.isWebGLCubeRenderTarget&&vt!==void 0&&(bt=bt[vt]),bt){const Et=w.texture,Ft=Et.format,Ht=Et.type;if(!Bt.textureFormatReadable(Ft))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Bt.textureTypeReadable(Ht))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(k>=0&&k<=w.width-H&&B>=0&&B<=w.height-N){Dt.bindFramebuffer(A.FRAMEBUFFER,bt);const Rt=A.createBuffer();A.bindBuffer(A.PIXEL_PACK_BUFFER,Rt),A.bufferData(A.PIXEL_PACK_BUFFER,st.byteLength,A.STREAM_READ),A.readPixels(k,B,H,N,Vt.convert(Ft),Vt.convert(Ht),0);const de=E!==null?Nt.get(E).__webglFramebuffer:null;Dt.bindFramebuffer(A.FRAMEBUFFER,de);const be=A.fenceSync(A.SYNC_GPU_COMMANDS_COMPLETE,0);return A.flush(),await p0(A,be,4),A.bindBuffer(A.PIXEL_PACK_BUFFER,Rt),A.getBufferSubData(A.PIXEL_PACK_BUFFER,0,st),A.deleteBuffer(Rt),A.deleteSync(be),st}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(w,k=null,B=0){w.isTexture!==!0&&(oo("WebGLRenderer: copyFramebufferToTexture function signature has changed."),k=arguments[0]||null,w=arguments[1]);const H=Math.pow(2,-B),N=Math.floor(w.image.width*H),st=Math.floor(w.image.height*H),vt=k!==null?k.x:0,bt=k!==null?k.y:0;C.setTexture2D(w,0),A.copyTexSubImage2D(A.TEXTURE_2D,B,0,0,vt,bt,N,st),Dt.unbindTexture()},this.copyTextureToTexture=function(w,k,B=null,H=null,N=0){w.isTexture!==!0&&(oo("WebGLRenderer: copyTextureToTexture function signature has changed."),H=arguments[0]||null,w=arguments[1],k=arguments[2],N=arguments[3]||0,B=null);let st,vt,bt,Et,Ft,Ht;B!==null?(st=B.max.x-B.min.x,vt=B.max.y-B.min.y,bt=B.min.x,Et=B.min.y):(st=w.image.width,vt=w.image.height,bt=0,Et=0),H!==null?(Ft=H.x,Ht=H.y):(Ft=0,Ht=0);const Rt=Vt.convert(k.format),de=Vt.convert(k.type);C.setTexture2D(k,0),A.pixelStorei(A.UNPACK_FLIP_Y_WEBGL,k.flipY),A.pixelStorei(A.UNPACK_PREMULTIPLY_ALPHA_WEBGL,k.premultiplyAlpha),A.pixelStorei(A.UNPACK_ALIGNMENT,k.unpackAlignment);const be=A.getParameter(A.UNPACK_ROW_LENGTH),Re=A.getParameter(A.UNPACK_IMAGE_HEIGHT),bn=A.getParameter(A.UNPACK_SKIP_PIXELS),le=A.getParameter(A.UNPACK_SKIP_ROWS),Lt=A.getParameter(A.UNPACK_SKIP_IMAGES),je=w.isCompressedTexture?w.mipmaps[N]:w.image;A.pixelStorei(A.UNPACK_ROW_LENGTH,je.width),A.pixelStorei(A.UNPACK_IMAGE_HEIGHT,je.height),A.pixelStorei(A.UNPACK_SKIP_PIXELS,bt),A.pixelStorei(A.UNPACK_SKIP_ROWS,Et),w.isDataTexture?A.texSubImage2D(A.TEXTURE_2D,N,Ft,Ht,st,vt,Rt,de,je.data):w.isCompressedTexture?A.compressedTexSubImage2D(A.TEXTURE_2D,N,Ft,Ht,je.width,je.height,Rt,je.data):A.texSubImage2D(A.TEXTURE_2D,N,Ft,Ht,st,vt,Rt,de,je),A.pixelStorei(A.UNPACK_ROW_LENGTH,be),A.pixelStorei(A.UNPACK_IMAGE_HEIGHT,Re),A.pixelStorei(A.UNPACK_SKIP_PIXELS,bn),A.pixelStorei(A.UNPACK_SKIP_ROWS,le),A.pixelStorei(A.UNPACK_SKIP_IMAGES,Lt),N===0&&k.generateMipmaps&&A.generateMipmap(A.TEXTURE_2D),Dt.unbindTexture()},this.copyTextureToTexture3D=function(w,k,B=null,H=null,N=0){w.isTexture!==!0&&(oo("WebGLRenderer: copyTextureToTexture3D function signature has changed."),B=arguments[0]||null,H=arguments[1]||null,w=arguments[2],k=arguments[3],N=arguments[4]||0);let st,vt,bt,Et,Ft,Ht,Rt,de,be;const Re=w.isCompressedTexture?w.mipmaps[N]:w.image;B!==null?(st=B.max.x-B.min.x,vt=B.max.y-B.min.y,bt=B.max.z-B.min.z,Et=B.min.x,Ft=B.min.y,Ht=B.min.z):(st=Re.width,vt=Re.height,bt=Re.depth,Et=0,Ft=0,Ht=0),H!==null?(Rt=H.x,de=H.y,be=H.z):(Rt=0,de=0,be=0);const bn=Vt.convert(k.format),le=Vt.convert(k.type);let Lt;if(k.isData3DTexture)C.setTexture3D(k,0),Lt=A.TEXTURE_3D;else if(k.isDataArrayTexture||k.isCompressedArrayTexture)C.setTexture2DArray(k,0),Lt=A.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}A.pixelStorei(A.UNPACK_FLIP_Y_WEBGL,k.flipY),A.pixelStorei(A.UNPACK_PREMULTIPLY_ALPHA_WEBGL,k.premultiplyAlpha),A.pixelStorei(A.UNPACK_ALIGNMENT,k.unpackAlignment);const je=A.getParameter(A.UNPACK_ROW_LENGTH),ce=A.getParameter(A.UNPACK_IMAGE_HEIGHT),Hn=A.getParameter(A.UNPACK_SKIP_PIXELS),ks=A.getParameter(A.UNPACK_SKIP_ROWS),Sn=A.getParameter(A.UNPACK_SKIP_IMAGES);A.pixelStorei(A.UNPACK_ROW_LENGTH,Re.width),A.pixelStorei(A.UNPACK_IMAGE_HEIGHT,Re.height),A.pixelStorei(A.UNPACK_SKIP_PIXELS,Et),A.pixelStorei(A.UNPACK_SKIP_ROWS,Ft),A.pixelStorei(A.UNPACK_SKIP_IMAGES,Ht),w.isDataTexture||w.isData3DTexture?A.texSubImage3D(Lt,N,Rt,de,be,st,vt,bt,bn,le,Re.data):k.isCompressedArrayTexture?A.compressedTexSubImage3D(Lt,N,Rt,de,be,st,vt,bt,bn,Re.data):A.texSubImage3D(Lt,N,Rt,de,be,st,vt,bt,bn,le,Re),A.pixelStorei(A.UNPACK_ROW_LENGTH,je),A.pixelStorei(A.UNPACK_IMAGE_HEIGHT,ce),A.pixelStorei(A.UNPACK_SKIP_PIXELS,Hn),A.pixelStorei(A.UNPACK_SKIP_ROWS,ks),A.pixelStorei(A.UNPACK_SKIP_IMAGES,Sn),N===0&&k.generateMipmaps&&A.generateMipmap(Lt),Dt.unbindTexture()},this.initRenderTarget=function(w){Nt.get(w).__webglFramebuffer===void 0&&C.setupRenderTarget(w)},this.initTexture=function(w){w.isCubeTexture?C.setTextureCube(w,0):w.isData3DTexture?C.setTexture3D(w,0):w.isDataArrayTexture||w.isCompressedArrayTexture?C.setTexture2DArray(w,0):C.setTexture2D(w,0),Dt.unbindTexture()},this.resetState=function(){L=0,T=0,E=null,Dt.reset(),se.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Ri}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=t===_h?"display-p3":"srgb",e.unpackColorSpace=oe.workingColorSpace===Oo?"display-p3":"srgb"}}class qf extends Qe{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 mi,this.environmentIntensity=1,this.environmentRotation=new mi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}class Yf extends an{constructor(t=null,e=1,n=1,s,r,a,o,l,c=rn,h=rn,u,d){super(null,a,o,l,c,h,s,r,u,d),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class zi extends an{constructor(t,e,n,s,r,a,o,l,c){super(t,e,n,s,r,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class vi{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){const n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let n,s=this.getPoint(0),r=0;e.push(0);for(let a=1;a<=t;a++)n=this.getPoint(a/t),r+=n.distanceTo(s),e.push(r),s=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){const n=this.getLengths();let s=0;const r=n.length;let a;e?a=e:a=t*n[r-1];let o=0,l=r-1,c;for(;o<=l;)if(s=Math.floor(o+(l-o)/2),c=n[s]-a,c<0)o=s+1;else if(c>0)l=s-1;else{l=s;break}if(s=l,n[s]===a)return s/(r-1);const h=n[s],d=n[s+1]-h,f=(a-h)/d;return(s+f)/(r-1)}getTangent(t,e){let s=t-1e-4,r=t+1e-4;s<0&&(s=0),r>1&&(r=1);const a=this.getPoint(s),o=this.getPoint(r),l=e||(a.isVector2?new rt:new R);return l.copy(o).sub(a).normalize(),l}getTangentAt(t,e){const n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){const n=new R,s=[],r=[],a=[],o=new R,l=new fe;for(let f=0;f<=t;f++){const g=f/t;s[f]=this.getTangentAt(g,new R)}r[0]=new R,a[0]=new R;let c=Number.MAX_VALUE;const h=Math.abs(s[0].x),u=Math.abs(s[0].y),d=Math.abs(s[0].z);h<=c&&(c=h,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(s[0],n).normalize(),r[0].crossVectors(s[0],o),a[0].crossVectors(s[0],r[0]);for(let f=1;f<=t;f++){if(r[f]=r[f-1].clone(),a[f]=a[f-1].clone(),o.crossVectors(s[f-1],s[f]),o.length()>Number.EPSILON){o.normalize();const g=Math.acos(ze(s[f-1].dot(s[f]),-1,1));r[f].applyMatrix4(l.makeRotationAxis(o,g))}a[f].crossVectors(s[f],r[f])}if(e===!0){let f=Math.acos(ze(r[0].dot(r[t]),-1,1));f/=t,s[0].dot(o.crossVectors(r[0],r[t]))>0&&(f=-f);for(let g=1;g<=t;g++)r[g].applyMatrix4(l.makeRotationAxis(s[g],f*g)),a[g].crossVectors(s[g],r[g])}return{tangents:s,normals:r,binormals:a}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class Ah extends vi{constructor(t=0,e=0,n=1,s=1,r=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=s,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(t,e=new rt){const n=e,s=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const a=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=s;for(;r>s;)r-=s;r<Number.EPSILON&&(a?r=0:r=s),this.aClockwise===!0&&!a&&(r===s?r=-s:r=r-s);const o=this.aStartAngle+t*r;let l=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){const h=Math.cos(this.aRotation),u=Math.sin(this.aRotation),d=l-this.aX,f=c-this.aY;l=d*h-f*u+this.aX,c=d*u+f*h+this.aY}return n.set(l,c)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){const t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}}class Ty extends Ah{constructor(t,e,n,s,r,a){super(t,e,n,n,s,r,a),this.isArcCurve=!0,this.type="ArcCurve"}}function Ch(){let i=0,t=0,e=0,n=0;function s(r,a,o,l){i=r,t=o,e=-3*r+3*a-2*o-l,n=2*r-2*a+o+l}return{initCatmullRom:function(r,a,o,l,c){s(a,o,c*(o-r),c*(l-a))},initNonuniformCatmullRom:function(r,a,o,l,c,h,u){let d=(a-r)/c-(o-r)/(c+h)+(o-a)/h,f=(o-a)/h-(l-a)/(h+u)+(l-o)/u;d*=h,f*=h,s(a,o,d,f)},calc:function(r){const a=r*r,o=a*r;return i+t*r+e*a+n*o}}}const Na=new R,Pl=new Ch,Ll=new Ch,Dl=new Ch;class Ay extends vi{constructor(t=[],e=!1,n="centripetal",s=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=s}getPoint(t,e=new R){const n=e,s=this.points,r=s.length,a=(r-(this.closed?0:1))*t;let o=Math.floor(a),l=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/r)+1)*r:l===0&&o===r-1&&(o=r-2,l=1);let c,h;this.closed||o>0?c=s[(o-1)%r]:(Na.subVectors(s[0],s[1]).add(s[0]),c=Na);const u=s[o%r],d=s[(o+1)%r];if(this.closed||o+2<r?h=s[(o+2)%r]:(Na.subVectors(s[r-1],s[r-2]).add(s[r-1]),h=Na),this.curveType==="centripetal"||this.curveType==="chordal"){const f=this.curveType==="chordal"?.5:.25;let g=Math.pow(c.distanceToSquared(u),f),_=Math.pow(u.distanceToSquared(d),f),m=Math.pow(d.distanceToSquared(h),f);_<1e-4&&(_=1),g<1e-4&&(g=_),m<1e-4&&(m=_),Pl.initNonuniformCatmullRom(c.x,u.x,d.x,h.x,g,_,m),Ll.initNonuniformCatmullRom(c.y,u.y,d.y,h.y,g,_,m),Dl.initNonuniformCatmullRom(c.z,u.z,d.z,h.z,g,_,m)}else this.curveType==="catmullrom"&&(Pl.initCatmullRom(c.x,u.x,d.x,h.x,this.tension),Ll.initCatmullRom(c.y,u.y,d.y,h.y,this.tension),Dl.initCatmullRom(c.z,u.z,d.z,h.z,this.tension));return n.set(Pl.calc(l),Ll.calc(l),Dl.calc(l)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const s=t.points[e];this.points.push(s.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const s=this.points[e];t.points.push(s.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const s=t.points[e];this.points.push(new R().fromArray(s))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function id(i,t,e,n,s){const r=(n-t)*.5,a=(s-e)*.5,o=i*i,l=i*o;return(2*e-2*n+r+a)*l+(-3*e+3*n-2*r-a)*o+r*i+e}function Cy(i,t){const e=1-i;return e*e*t}function Ry(i,t){return 2*(1-i)*i*t}function Py(i,t){return i*i*t}function Kr(i,t,e,n){return Cy(i,t)+Ry(i,e)+Py(i,n)}function Ly(i,t){const e=1-i;return e*e*e*t}function Dy(i,t){const e=1-i;return 3*e*e*i*t}function Iy(i,t){return 3*(1-i)*i*i*t}function ky(i,t){return i*i*i*t}function Zr(i,t,e,n,s){return Ly(i,t)+Dy(i,e)+Iy(i,n)+ky(i,s)}class Kf extends vi{constructor(t=new rt,e=new rt,n=new rt,s=new rt){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=s}getPoint(t,e=new rt){const n=e,s=this.v0,r=this.v1,a=this.v2,o=this.v3;return n.set(Zr(t,s.x,r.x,a.x,o.x),Zr(t,s.y,r.y,a.y,o.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class Ny extends vi{constructor(t=new R,e=new R,n=new R,s=new R){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=s}getPoint(t,e=new R){const n=e,s=this.v0,r=this.v1,a=this.v2,o=this.v3;return n.set(Zr(t,s.x,r.x,a.x,o.x),Zr(t,s.y,r.y,a.y,o.y),Zr(t,s.z,r.z,a.z,o.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class Zf extends vi{constructor(t=new rt,e=new rt){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new rt){const n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new rt){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Uy extends vi{constructor(t=new R,e=new R){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new R){const n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new R){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Jf extends vi{constructor(t=new rt,e=new rt,n=new rt){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new rt){const n=e,s=this.v0,r=this.v1,a=this.v2;return n.set(Kr(t,s.x,r.x,a.x),Kr(t,s.y,r.y,a.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Oy extends vi{constructor(t=new R,e=new R,n=new R){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new R){const n=e,s=this.v0,r=this.v1,a=this.v2;return n.set(Kr(t,s.x,r.x,a.x),Kr(t,s.y,r.y,a.y),Kr(t,s.z,r.z,a.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Qf extends vi{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new rt){const n=e,s=this.points,r=(s.length-1)*t,a=Math.floor(r),o=r-a,l=s[a===0?a:a-1],c=s[a],h=s[a>s.length-2?s.length-1:a+1],u=s[a>s.length-3?s.length-1:a+2];return n.set(id(o,l.x,c.x,h.x,u.x),id(o,l.y,c.y,h.y,u.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const s=t.points[e];this.points.push(s.clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const s=this.points[e];t.points.push(s.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const s=t.points[e];this.points.push(new rt().fromArray(s))}return this}}var sd=Object.freeze({__proto__:null,ArcCurve:Ty,CatmullRomCurve3:Ay,CubicBezierCurve:Kf,CubicBezierCurve3:Ny,EllipseCurve:Ah,LineCurve:Zf,LineCurve3:Uy,QuadraticBezierCurve:Jf,QuadraticBezierCurve3:Oy,SplineCurve:Qf});class Fy extends vi{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);if(!t.equals(e)){const n=t.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new sd[n](e,t))}return this}getPoint(t,e){const n=t*this.getLength(),s=this.getCurveLengths();let r=0;for(;r<s.length;){if(s[r]>=n){const a=s[r]-n,o=this.curves[r],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,e)}r++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let n=0,s=this.curves.length;n<s;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[];let n;for(let s=0,r=this.curves;s<r.length;s++){const a=r[s],o=a.isEllipseCurve?t*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?t*a.points.length:t,l=a.getPoints(o);for(let c=0;c<l.length;c++){const h=l[c];n&&n.equals(h)||(e.push(h),n=h)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const s=t.curves[e];this.curves.push(s.clone())}return this.autoClose=t.autoClose,this}toJSON(){const t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){const s=this.curves[e];t.curves.push(s.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const s=t.curves[e];this.curves.push(new sd[s.type]().fromJSON(s))}return this}}class zy extends Fy{constructor(t){super(),this.type="Path",this.currentPoint=new rt,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){const n=new Zf(this.currentPoint.clone(),new rt(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,s){const r=new Jf(this.currentPoint.clone(),new rt(t,e),new rt(n,s));return this.curves.push(r),this.currentPoint.set(n,s),this}bezierCurveTo(t,e,n,s,r,a){const o=new Kf(this.currentPoint.clone(),new rt(t,e),new rt(n,s),new rt(r,a));return this.curves.push(o),this.currentPoint.set(r,a),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),n=new Qf(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,s,r,a){const o=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+o,e+l,n,s,r,a),this}absarc(t,e,n,s,r,a){return this.absellipse(t,e,n,n,s,r,a),this}ellipse(t,e,n,s,r,a,o,l){const c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(t+c,e+h,n,s,r,a,o,l),this}absellipse(t,e,n,s,r,a,o,l){const c=new Ah(t,e,n,s,r,a,o,l);if(this.curves.length>0){const u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);const h=c.getPoint(1);return this.currentPoint.copy(h),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class zo extends fn{constructor(t=[new rt(0,-.5),new rt(.5,0),new rt(0,.5)],e=12,n=0,s=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:s},e=Math.floor(e),s=ze(s,0,Math.PI*2);const r=[],a=[],o=[],l=[],c=[],h=1/e,u=new R,d=new rt,f=new R,g=new R,_=new R;let m=0,p=0;for(let y=0;y<=t.length-1;y++)switch(y){case 0:m=t[y+1].x-t[y].x,p=t[y+1].y-t[y].y,f.x=p*1,f.y=-m,f.z=p*0,_.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(_.x,_.y,_.z);break;default:m=t[y+1].x-t[y].x,p=t[y+1].y-t[y].y,f.x=p*1,f.y=-m,f.z=p*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<=e;y++){const x=n+y*h*s,S=Math.sin(x),L=Math.cos(x);for(let T=0;T<=t.length-1;T++){u.x=t[T].x*S,u.y=t[T].y,u.z=t[T].x*L,a.push(u.x,u.y,u.z),d.x=y/e,d.y=T/(t.length-1),o.push(d.x,d.y);const E=l[3*T+0]*S,P=l[3*T+1],U=l[3*T+0]*L;c.push(E,P,U)}}for(let y=0;y<e;y++)for(let x=0;x<t.length-1;x++){const S=x+y*t.length,L=S,T=S+t.length,E=S+t.length+1,P=S+1;r.push(L,T,P),r.push(E,P,T)}this.setIndex(r),this.setAttribute("position",new he(a,3)),this.setAttribute("uv",new he(o,2)),this.setAttribute("normal",new he(c,3))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new zo(t.points,t.segments,t.phiStart,t.phiLength)}}class Rh extends zo{constructor(t=1,e=1,n=4,s=8){const r=new zy;r.absarc(0,-e/2,t,Math.PI*1.5,0),r.absarc(0,e/2,t,0,Math.PI*.5),super(r.getPoints(n),s),this.type="CapsuleGeometry",this.parameters={radius:t,length:e,capSegments:n,radialSegments:s}}static fromJSON(t){return new Rh(t.radius,t.length,t.capSegments,t.radialSegments)}}class Oi extends fn{constructor(t=1,e=32,n=0,s=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:s},e=Math.max(3,e);const r=[],a=[],o=[],l=[],c=new R,h=new rt;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let u=0,d=3;u<=e;u++,d+=3){const f=n+u/e*s;c.x=t*Math.cos(f),c.y=t*Math.sin(f),a.push(c.x,c.y,c.z),o.push(0,0,1),h.x=(a[d]/t+1)/2,h.y=(a[d+1]/t+1)/2,l.push(h.x,h.y)}for(let u=1;u<=e;u++)r.push(u,u+1,0);this.setIndex(r),this.setAttribute("position",new he(a,3)),this.setAttribute("normal",new he(o,3)),this.setAttribute("uv",new he(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Oi(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class zn extends fn{constructor(t=1,e=1,n=1,s=32,r=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:s,heightSegments:r,openEnded:a,thetaStart:o,thetaLength:l};const c=this;s=Math.floor(s),r=Math.floor(r);const h=[],u=[],d=[],f=[];let g=0;const _=[],m=n/2;let p=0;y(),a===!1&&(t>0&&x(!0),e>0&&x(!1)),this.setIndex(h),this.setAttribute("position",new he(u,3)),this.setAttribute("normal",new he(d,3)),this.setAttribute("uv",new he(f,2));function y(){const S=new R,L=new R;let T=0;const E=(e-t)/n;for(let P=0;P<=r;P++){const U=[],v=P/r,b=v*(e-t)+t;for(let I=0;I<=s;I++){const O=I/s,$=O*l+o,K=Math.sin($),z=Math.cos($);L.x=b*K,L.y=-v*n+m,L.z=b*z,u.push(L.x,L.y,L.z),S.set(K,E,z).normalize(),d.push(S.x,S.y,S.z),f.push(O,1-v),U.push(g++)}_.push(U)}for(let P=0;P<s;P++)for(let U=0;U<r;U++){const v=_[U][P],b=_[U+1][P],I=_[U+1][P+1],O=_[U][P+1];t>0&&(h.push(v,b,O),T+=3),e>0&&(h.push(b,I,O),T+=3)}c.addGroup(p,T,0),p+=T}function x(S){const L=g,T=new rt,E=new R;let P=0;const U=S===!0?t:e,v=S===!0?1:-1;for(let I=1;I<=s;I++)u.push(0,m*v,0),d.push(0,v,0),f.push(.5,.5),g++;const b=g;for(let I=0;I<=s;I++){const $=I/s*l+o,K=Math.cos($),z=Math.sin($);E.x=U*z,E.y=m*v,E.z=U*K,u.push(E.x,E.y,E.z),d.push(0,v,0),T.x=K*.5+.5,T.y=z*.5*v+.5,f.push(T.x,T.y),g++}for(let I=0;I<s;I++){const O=L+I,$=b+I;S===!0?h.push($,$+1,O):h.push($+1,$,O),P+=3}c.addGroup(p,P,S===!0?1:2),p+=P}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new zn(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class ca extends zn{constructor(t=1,e=1,n=32,s=1,r=!1,a=0,o=Math.PI*2){super(0,t,e,n,s,r,a,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:s,openEnded:r,thetaStart:a,thetaLength:o}}static fromJSON(t){return new ca(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Ph extends fn{constructor(t=[],e=[],n=1,s=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:s};const r=[],a=[];o(s),c(n),h(),this.setAttribute("position",new he(r,3)),this.setAttribute("normal",new he(r.slice(),3)),this.setAttribute("uv",new he(a,2)),s===0?this.computeVertexNormals():this.normalizeNormals();function o(y){const x=new R,S=new R,L=new R;for(let T=0;T<e.length;T+=3)f(e[T+0],x),f(e[T+1],S),f(e[T+2],L),l(x,S,L,y)}function l(y,x,S,L){const T=L+1,E=[];for(let P=0;P<=T;P++){E[P]=[];const U=y.clone().lerp(S,P/T),v=x.clone().lerp(S,P/T),b=T-P;for(let I=0;I<=b;I++)I===0&&P===T?E[P][I]=U:E[P][I]=U.clone().lerp(v,I/b)}for(let P=0;P<T;P++)for(let U=0;U<2*(T-P)-1;U++){const v=Math.floor(U/2);U%2===0?(d(E[P][v+1]),d(E[P+1][v]),d(E[P][v])):(d(E[P][v+1]),d(E[P+1][v+1]),d(E[P+1][v]))}}function c(y){const x=new R;for(let S=0;S<r.length;S+=3)x.x=r[S+0],x.y=r[S+1],x.z=r[S+2],x.normalize().multiplyScalar(y),r[S+0]=x.x,r[S+1]=x.y,r[S+2]=x.z}function h(){const y=new R;for(let x=0;x<r.length;x+=3){y.x=r[x+0],y.y=r[x+1],y.z=r[x+2];const S=m(y)/2/Math.PI+.5,L=p(y)/Math.PI+.5;a.push(S,1-L)}g(),u()}function u(){for(let y=0;y<a.length;y+=6){const x=a[y+0],S=a[y+2],L=a[y+4],T=Math.max(x,S,L),E=Math.min(x,S,L);T>.9&&E<.1&&(x<.2&&(a[y+0]+=1),S<.2&&(a[y+2]+=1),L<.2&&(a[y+4]+=1))}}function d(y){r.push(y.x,y.y,y.z)}function f(y,x){const S=y*3;x.x=t[S+0],x.y=t[S+1],x.z=t[S+2]}function g(){const y=new R,x=new R,S=new R,L=new R,T=new rt,E=new rt,P=new rt;for(let U=0,v=0;U<r.length;U+=9,v+=6){y.set(r[U+0],r[U+1],r[U+2]),x.set(r[U+3],r[U+4],r[U+5]),S.set(r[U+6],r[U+7],r[U+8]),T.set(a[v+0],a[v+1]),E.set(a[v+2],a[v+3]),P.set(a[v+4],a[v+5]),L.copy(y).add(x).add(S).divideScalar(3);const b=m(L);_(T,v+0,y,b),_(E,v+2,x,b),_(P,v+4,S,b)}}function _(y,x,S,L){L<0&&y.x===1&&(a[x]=y.x-1),S.x===0&&S.z===0&&(a[x]=L/2/Math.PI+.5)}function m(y){return Math.atan2(y.z,-y.x)}function p(y){return Math.atan2(-y.y,Math.sqrt(y.x*y.x+y.z*y.z))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ph(t.vertices,t.indices,t.radius,t.details)}}class Sr extends Ph{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2,s=[-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(s,r,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Sr(t.radius,t.detail)}}class Lh extends fn{constructor(t=.5,e=1,n=32,s=1,r=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:n,phiSegments:s,thetaStart:r,thetaLength:a},n=Math.max(3,n),s=Math.max(1,s);const o=[],l=[],c=[],h=[];let u=t;const d=(e-t)/s,f=new R,g=new rt;for(let _=0;_<=s;_++){for(let m=0;m<=n;m++){const p=r+m/n*a;f.x=u*Math.cos(p),f.y=u*Math.sin(p),l.push(f.x,f.y,f.z),c.push(0,0,1),g.x=(f.x/e+1)/2,g.y=(f.y/e+1)/2,h.push(g.x,g.y)}u+=d}for(let _=0;_<s;_++){const m=_*(n+1);for(let p=0;p<n;p++){const y=p+m,x=y,S=y+n+1,L=y+n+2,T=y+1;o.push(x,S,T),o.push(S,L,T)}}this.setIndex(o),this.setAttribute("position",new he(l,3)),this.setAttribute("normal",new he(c,3)),this.setAttribute("uv",new he(h,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Lh(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}}class di extends fn{constructor(t=1,e=32,n=16,s=0,r=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:s,phiLength:r,thetaStart:a,thetaLength:o},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const l=Math.min(a+o,Math.PI);let c=0;const h=[],u=new R,d=new R,f=[],g=[],_=[],m=[];for(let p=0;p<=n;p++){const y=[],x=p/n;let S=0;p===0&&a===0?S=.5/e:p===n&&l===Math.PI&&(S=-.5/e);for(let L=0;L<=e;L++){const T=L/e;u.x=-t*Math.cos(s+T*r)*Math.sin(a+x*o),u.y=t*Math.cos(a+x*o),u.z=t*Math.sin(s+T*r)*Math.sin(a+x*o),g.push(u.x,u.y,u.z),d.copy(u).normalize(),_.push(d.x,d.y,d.z),m.push(T+S,1-x),y.push(c++)}h.push(y)}for(let p=0;p<n;p++)for(let y=0;y<e;y++){const x=h[p][y+1],S=h[p][y],L=h[p+1][y],T=h[p+1][y+1];(p!==0||a>0)&&f.push(x,S,T),(p!==n-1||l<Math.PI)&&f.push(S,L,T)}this.setIndex(f),this.setAttribute("position",new he(g,3)),this.setAttribute("normal",new he(_,3)),this.setAttribute("uv",new he(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new di(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class oi extends fn{constructor(t=1,e=.4,n=12,s=48,r=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:n,tubularSegments:s,arc:r},n=Math.floor(n),s=Math.floor(s);const a=[],o=[],l=[],c=[],h=new R,u=new R,d=new R;for(let f=0;f<=n;f++)for(let g=0;g<=s;g++){const _=g/s*r,m=f/n*Math.PI*2;u.x=(t+e*Math.cos(m))*Math.cos(_),u.y=(t+e*Math.cos(m))*Math.sin(_),u.z=e*Math.sin(m),o.push(u.x,u.y,u.z),h.x=t*Math.cos(_),h.y=t*Math.sin(_),d.subVectors(u,h).normalize(),l.push(d.x,d.y,d.z),c.push(g/s),c.push(f/n)}for(let f=1;f<=n;f++)for(let g=1;g<=s;g++){const _=(s+1)*f+g-1,m=(s+1)*(f-1)+g-1,p=(s+1)*(f-1)+g,y=(s+1)*f+g;a.push(_,m,y),a.push(m,p,y)}this.setIndex(a),this.setAttribute("position",new he(o,3)),this.setAttribute("normal",new he(l,3)),this.setAttribute("uv",new he(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new oi(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class By extends Fi{constructor(t){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Zt(0),this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.fog=t.fog,this}}class Hy extends nn{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Bn extends Fi{constructor(t){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Zt(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 Zt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=vh,this.normalScale=new rt(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 mi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Vy extends Fi{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=vh,this.normalScale=new rt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class Dh extends Qe{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Zt(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(e.object.target=this.target.uuid),e}}class Gy extends Dh{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Qe.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Zt(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}}const Il=new fe,rd=new R,ad=new R;class tp{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new rt(512,512),this.map=null,this.mapPass=null,this.matrix=new fe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Sh,this._frameExtents=new rt(1,1),this._viewportCount=1,this._viewports=[new me(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;rd.setFromMatrixPosition(t.matrixWorld),e.position.copy(rd),ad.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(ad),e.updateMatrixWorld(),Il.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Il),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Il)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const t={};return this.intensity!==1&&(t.intensity=this.intensity),this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}const od=new fe,kr=new R,kl=new R;class $y extends tp{constructor(){super(new Cn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new rt(4,2),this._viewportCount=6,this._viewports=[new me(2,1,1,1),new me(0,1,1,1),new me(3,1,1,1),new me(1,1,1,1),new me(3,0,1,1),new me(1,0,1,1)],this._cubeDirections=[new R(1,0,0),new R(-1,0,0),new R(0,0,1),new R(0,0,-1),new R(0,1,0),new R(0,-1,0)],this._cubeUps=[new R(0,1,0),new R(0,1,0),new R(0,1,0),new R(0,1,0),new R(0,0,1),new R(0,0,-1)]}updateMatrices(t,e=0){const n=this.camera,s=this.matrix,r=t.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),kr.setFromMatrixPosition(t.matrixWorld),n.position.copy(kr),kl.copy(n.position),kl.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(kl),n.updateMatrixWorld(),s.makeTranslation(-kr.x,-kr.y,-kr.z),od.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(od)}}class Wy extends Dh{constructor(t,e,n=0,s=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=s,this.shadow=new $y}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}class Xy extends tp{constructor(){super(new wh(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class jy extends Dh{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Qe.DEFAULT_UP),this.updateMatrix(),this.target=new Qe,this.shadow=new Xy}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class ep{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=ld(),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 t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=ld();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function ld(){return performance.now()}const cd=new fe;class np{constructor(t,e,n=0,s=1/0){this.ray=new Mh(t,e),this.near=n,this.far=s,this.camera=null,this.layers=new bh,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return cd.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(cd),this}intersectObject(t,e=!0,n=[]){return Yc(t,this,n,e),n.sort(hd),n}intersectObjects(t,e=!0,n=[]){for(let s=0,r=t.length;s<r;s++)Yc(t[s],this,n,e);return n.sort(hd),n}}function hd(i,t){return i.distance-t.distance}function Yc(i,t,e,n){let s=!0;if(i.layers.test(t.layers)&&i.raycast(t,e)===!1&&(s=!1),s===!0&&n===!0){const r=i.children;for(let a=0,o=r.length;a<o;a++)Yc(r[a],t,e,!0)}}class wr{constructor(t=1,e=0,n=0){return this.radius=t,this.phi=e,this.theta=n,this}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(ze(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class qy extends Ps{constructor(t,e=null){super(),this.object=t,this.domElement=e,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(){}disconnect(){}dispose(){}update(){}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:ch}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=ch);const ud={type:"change"},Ih={type:"start"},ip={type:"end"},Ua=new Mh,dd=new Ki,Yy=Math.cos(70*xs.DEG2RAD),Oe=new R,gn=2*Math.PI,pe={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Nl=1e-6;class Ky extends qy{constructor(t,e=null){super(t,e),this.state=pe.NONE,this.enabled=!0,this.target=new R,this.cursor=new R,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:Di.ROTATE,MIDDLE:Di.DOLLY,RIGHT:Di.PAN},this.touches={ONE:is.ROTATE,TWO:is.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new R,this._lastQuaternion=new ls,this._lastTargetPosition=new R,this._quat=new ls().setFromUnitVectors(t.up,new R(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new wr,this._sphericalDelta=new wr,this._scale=1,this._panOffset=new R,this._rotateStart=new rt,this._rotateEnd=new rt,this._rotateDelta=new rt,this._panStart=new rt,this._panEnd=new rt,this._panDelta=new rt,this._dollyStart=new rt,this._dollyEnd=new rt,this._dollyDelta=new rt,this._dollyDirection=new R,this._mouse=new rt,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Jy.bind(this),this._onPointerDown=Zy.bind(this),this._onPointerUp=Qy.bind(this),this._onContextMenu=aM.bind(this),this._onMouseWheel=nM.bind(this),this._onKeyDown=iM.bind(this),this._onTouchStart=sM.bind(this),this._onTouchMove=rM.bind(this),this._onMouseDown=tM.bind(this),this._onMouseMove=eM.bind(this),this._interceptControlDown=oM.bind(this),this._interceptControlUp=lM.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(t){t.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=t}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(ud),this.update(),this.state=pe.NONE}update(t=null){const e=this.object.position;Oe.copy(e).sub(this.target),Oe.applyQuaternion(this._quat),this._spherical.setFromVector3(Oe),this.autoRotate&&this.state===pe.NONE&&this._rotateLeft(this._getAutoRotationAngle(t)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(n)&&isFinite(s)&&(n<-Math.PI?n+=gn:n>Math.PI&&(n-=gn),s<-Math.PI?s+=gn:s>Math.PI&&(s-=gn),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(Oe.setFromSpherical(this._spherical),Oe.applyQuaternion(this._quatInverse),e.copy(this.target).add(Oe),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=Oe.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const o=new R(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new R(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=Oe.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Ua.origin.copy(this.object.position),Ua.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Ua.direction))<Yy?this.object.lookAt(this.target):(dd.setFromNormalAndCoplanarPoint(this.object.up,this.target),Ua.intersectPlane(dd,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>Nl||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Nl||this._lastTargetPosition.distanceToSquared(this.target)>Nl?(this.dispatchEvent(ud),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(t){return t!==null?gn/60*this.autoRotateSpeed*t:gn/60/60*this.autoRotateSpeed}_getZoomScale(t){const e=Math.abs(t*.01);return Math.pow(.95,this.zoomSpeed*e)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,e){Oe.setFromMatrixColumn(e,0),Oe.multiplyScalar(-t),this._panOffset.add(Oe)}_panUp(t,e){this.screenSpacePanning===!0?Oe.setFromMatrixColumn(e,1):(Oe.setFromMatrixColumn(e,0),Oe.crossVectors(this.object.up,Oe)),Oe.multiplyScalar(t),this._panOffset.add(Oe)}_pan(t,e){const n=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;Oe.copy(s).sub(this.target);let r=Oe.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*r/n.clientHeight,this.object.matrix),this._panUp(2*e*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(t,e){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),s=t-n.left,r=e-n.top,a=n.width,o=n.height;this._mouse.x=s/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(gn*this._rotateDelta.x/e.clientHeight),this._rotateUp(gn*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(t){this._panEnd.set(t.clientX,t.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let e=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateUp(gn*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateUp(-gn*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateLeft(gn*this.rotateSpeed/this.domElement.clientHeight):this._pan(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateLeft(-gn*this.rotateSpeed/this.domElement.clientHeight):this._pan(-this.keyPanSpeed,0),e=!0;break}e&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(this._pointers.length===1)this._rotateStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(t){if(this._pointers.length===1)this._panStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._panStart.set(n,s)}}_handleTouchStartDolly(t){const e=this._getSecondPointerPosition(t),n=t.pageX-e.x,s=t.pageY-e.y,r=Math.sqrt(n*n+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(this._pointers.length==1)this._rotateEnd.set(t.pageX,t.pageY);else{const n=this._getSecondPointerPosition(t),s=.5*(t.pageX+n.x),r=.5*(t.pageY+n.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(gn*this._rotateDelta.x/e.clientHeight),this._rotateUp(gn*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(this._pointers.length===1)this._panEnd.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(t){const e=this._getSecondPointerPosition(t),n=t.pageX-e.x,s=t.pageY-e.y,r=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(t.pageX+e.x)*.5,o=(t.pageY+e.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId){this._pointers.splice(e,1);return}}_isTrackingPointer(t){for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId)return!0;return!1}_trackPointer(t){let e=this._pointerPositions[t.pointerId];e===void 0&&(e=new rt,this._pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}_getSecondPointerPosition(t){const e=t.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[e]}_customWheelEvent(t){const e=t.deltaMode,n={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(e){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return t.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function Zy(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i)))}function Jy(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function Qy(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(ip),this.state=pe.NONE;break;case 1:const t=this._pointers[0],e=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:e.x,pageY:e.y});break}}function tM(i){let t;switch(i.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case Di.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=pe.DOLLY;break;case Di.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=pe.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=pe.ROTATE}break;case Di.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=pe.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=pe.PAN}break;default:this.state=pe.NONE}this.state!==pe.NONE&&this.dispatchEvent(Ih)}function eM(i){switch(this.state){case pe.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case pe.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case pe.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function nM(i){this.enabled===!1||this.enableZoom===!1||this.state!==pe.NONE||(i.preventDefault(),this.dispatchEvent(Ih),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(ip))}function iM(i){this.enabled===!1||this.enablePan===!1||this._handleKeyDown(i)}function sM(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case is.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=pe.TOUCH_ROTATE;break;case is.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=pe.TOUCH_PAN;break;default:this.state=pe.NONE}break;case 2:switch(this.touches.TWO){case is.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=pe.TOUCH_DOLLY_PAN;break;case is.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=pe.TOUCH_DOLLY_ROTATE;break;default:this.state=pe.NONE}break;default:this.state=pe.NONE}this.state!==pe.NONE&&this.dispatchEvent(Ih)}function rM(i){switch(this._trackPointer(i),this.state){case pe.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case pe.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case pe.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case pe.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=pe.NONE}}function aM(i){this.enabled!==!1&&i.preventDefault()}function oM(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function lM(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class cM extends Ky{constructor(t,e){super(t,e),this.screenSpacePanning=!1,this.mouseButtons={LEFT:Di.PAN,MIDDLE:Di.DOLLY,RIGHT:Di.ROTATE},this.touches={ONE:is.PAN,TWO:is.DOLLY_ROTATE}}}class hM extends qf{constructor(){super();const t=new Ze;t.deleteAttribute("uv");const e=new Bn({side:un}),n=new Bn,s=new Wy(16777215,900,28,2);s.position.set(.418,16.199,.3),this.add(s);const r=new yt(t,e);r.position.set(-.757,13.219,.717),r.scale.set(31.713,28.305,28.591),this.add(r);const a=new yt(t,n);a.position.set(-10.906,2.009,1.846),a.rotation.set(0,-.195,0),a.scale.set(2.328,7.905,4.651),this.add(a);const o=new yt(t,n);o.position.set(-5.607,-.754,-.758),o.rotation.set(0,.994,0),o.scale.set(1.97,1.534,3.955),this.add(o);const l=new yt(t,n);l.position.set(6.167,.857,7.803),l.rotation.set(0,.561,0),l.scale.set(3.927,6.285,3.687),this.add(l);const c=new yt(t,n);c.position.set(-2.017,.018,6.124),c.rotation.set(0,.333,0),c.scale.set(2.002,4.566,2.064),this.add(c);const h=new yt(t,n);h.position.set(2.291,-.756,-2.621),h.rotation.set(0,-.286,0),h.scale.set(1.546,1.552,1.496),this.add(h);const u=new yt(t,n);u.position.set(-2.193,-.369,-5.547),u.rotation.set(0,.516,0),u.scale.set(3.875,3.487,2.986),this.add(u);const d=new yt(t,Ks(50));d.position.set(-16.116,14.37,8.208),d.scale.set(.1,2.428,2.739),this.add(d);const f=new yt(t,Ks(50));f.position.set(-16.109,18.021,-8.207),f.scale.set(.1,2.425,2.751),this.add(f);const g=new yt(t,Ks(17));g.position.set(14.904,12.198,-1.832),g.scale.set(.15,4.265,6.331),this.add(g);const _=new yt(t,Ks(43));_.position.set(-.462,8.89,14.52),_.scale.set(4.38,5.441,.088),this.add(_);const m=new yt(t,Ks(20));m.position.set(3.235,11.486,-12.541),m.scale.set(2.5,2,.1),this.add(m);const p=new yt(t,Ks(100));p.position.set(0,20,0),p.scale.set(1,.1,1),this.add(p)}dispose(){const t=new Set;this.traverse(e=>{e.isMesh&&(t.add(e.geometry),t.add(e.material))});for(const e of t)e.dispose()}}function Ks(i){const t=new dn;return t.color.setScalar(i),t}const co={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
|
|
3839
|
+
}`;class vy{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,n){if(this.texture===null){const s=new rn,r=t.properties.get(s);r.__webglTexture=e.texture,(e.depthNear!=n.depthNear||e.depthFar!=n.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=s}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,n=new en({vertexShader:my,fragmentShader:gy,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new yt(new pi(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class _y extends Ts{constructor(t,e){super();const n=this;let s=null,r=1,a=null,o="local-floor",l=1,c=null,h=null,u=null,d=null,f=null,g=null;const _=new vy,m=e.getContextAttributes();let p=null,y=null;const x=[],S=[],L=new at;let T=null;const E=new An;E.layers.enable(1),E.viewport=new me;const P=new An;P.layers.enable(2),P.viewport=new me;const U=[E,P],v=new fy;v.layers.enable(1),v.layers.enable(2);let b=null,I=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(j){let et=x[j];return et===void 0&&(et=new Al,x[j]=et),et.getTargetRaySpace()},this.getControllerGrip=function(j){let et=x[j];return et===void 0&&(et=new Al,x[j]=et),et.getGripSpace()},this.getHand=function(j){let et=x[j];return et===void 0&&(et=new Al,x[j]=et),et.getHandSpace()};function O(j){const et=S.indexOf(j.inputSource);if(et===-1)return;const ft=x[et];ft!==void 0&&(ft.update(j.inputSource,j.frame,c||a),ft.dispatchEvent({type:j.type,data:j.inputSource}))}function $(){s.removeEventListener("select",O),s.removeEventListener("selectstart",O),s.removeEventListener("selectend",O),s.removeEventListener("squeeze",O),s.removeEventListener("squeezestart",O),s.removeEventListener("squeezeend",O),s.removeEventListener("end",$),s.removeEventListener("inputsourceschange",K);for(let j=0;j<x.length;j++){const et=S[j];et!==null&&(S[j]=null,x[j].disconnect(et))}b=null,I=null,_.reset(),t.setRenderTarget(p),f=null,d=null,u=null,s=null,y=null,Jt.stop(),n.isPresenting=!1,t.setPixelRatio(T),t.setSize(L.width,L.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(j){r=j,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(j){o=j,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(j){c=j},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u},this.getFrame=function(){return g},this.getSession=function(){return s},this.setSession=async function(j){if(s=j,s!==null){if(p=t.getRenderTarget(),s.addEventListener("select",O),s.addEventListener("selectstart",O),s.addEventListener("selectend",O),s.addEventListener("squeeze",O),s.addEventListener("squeezestart",O),s.addEventListener("squeezeend",O),s.addEventListener("end",$),s.addEventListener("inputsourceschange",K),m.xrCompatible!==!0&&await e.makeXRCompatible(),T=t.getPixelRatio(),t.getSize(L),s.renderState.layers===void 0){const et={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(s,e,et),s.updateRenderState({baseLayer:f}),t.setPixelRatio(1),t.setSize(f.framebufferWidth,f.framebufferHeight,!1),y=new Jn(f.framebufferWidth,f.framebufferHeight,{format:kn,type:di,colorSpace:t.outputColorSpace,stencilBuffer:m.stencil})}else{let et=null,ft=null,lt=null;m.depth&&(lt=m.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,et=m.stencil?ws:pr,ft=m.stencil?Ss:bs);const At={colorFormat:e.RGBA8,depthFormat:lt,scaleFactor:r};u=new XRWebGLBinding(s,e),d=u.createProjectionLayer(At),s.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),y=new Jn(d.textureWidth,d.textureHeight,{format:kn,type:di,depthTexture:new Eh(d.textureWidth,d.textureHeight,ft,void 0,void 0,void 0,void 0,void 0,void 0,et),stencilBuffer:m.stencil,colorSpace:t.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await s.requestReferenceSpace(o),Jt.setContext(s),Jt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return _.getDepthTexture()};function K(j){for(let et=0;et<j.removed.length;et++){const ft=j.removed[et],lt=S.indexOf(ft);lt>=0&&(S[lt]=null,x[lt].disconnect(ft))}for(let et=0;et<j.added.length;et++){const ft=j.added[et];let lt=S.indexOf(ft);if(lt===-1){for(let Tt=0;Tt<x.length;Tt++)if(Tt>=S.length){S.push(ft),lt=Tt;break}else if(S[Tt]===null){S[Tt]=ft,lt=Tt;break}if(lt===-1)break}const At=x[lt];At&&At.connect(ft)}}const z=new R,Z=new R;function V(j,et,ft){z.setFromMatrixPosition(et.matrixWorld),Z.setFromMatrixPosition(ft.matrixWorld);const lt=z.distanceTo(Z),At=et.projectionMatrix.elements,Tt=ft.projectionMatrix.elements,zt=At[14]/(At[10]-1),ie=At[14]/(At[10]+1),W=(At[9]+1)/At[5],A=(At[9]-1)/At[5],It=(At[8]-1)/At[0],Ct=(Tt[8]+1)/Tt[0],Bt=zt*It,Dt=zt*Ct,ue=lt/(-It+Ct),kt=ue*-It;if(et.matrixWorld.decompose(j.position,j.quaternion,j.scale),j.translateX(kt),j.translateZ(ue),j.matrixWorld.compose(j.position,j.quaternion,j.scale),j.matrixWorldInverse.copy(j.matrixWorld).invert(),At[10]===-1)j.projectionMatrix.copy(et.projectionMatrix),j.projectionMatrixInverse.copy(et.projectionMatrixInverse);else{const C=zt+ue,M=ie+ue,F=Bt-kt,Y=Dt+(lt-kt),Q=W*ie/M*C,q=A*ie/M*C;j.projectionMatrix.makePerspective(F,Y,Q,q,C,M),j.projectionMatrixInverse.copy(j.projectionMatrix).invert()}}function ot(j,et){et===null?j.matrixWorld.copy(j.matrix):j.matrixWorld.multiplyMatrices(et.matrixWorld,j.matrix),j.matrixWorldInverse.copy(j.matrixWorld).invert()}this.updateCamera=function(j){if(s===null)return;let et=j.near,ft=j.far;_.texture!==null&&(_.depthNear>0&&(et=_.depthNear),_.depthFar>0&&(ft=_.depthFar)),v.near=P.near=E.near=et,v.far=P.far=E.far=ft,(b!==v.near||I!==v.far)&&(s.updateRenderState({depthNear:v.near,depthFar:v.far}),b=v.near,I=v.far);const lt=j.parent,At=v.cameras;ot(v,lt);for(let Tt=0;Tt<At.length;Tt++)ot(At[Tt],lt);At.length===2?V(v,E,P):v.projectionMatrix.copy(E.projectionMatrix),ct(j,v,lt)};function ct(j,et,ft){ft===null?j.matrix.copy(et.matrixWorld):(j.matrix.copy(ft.matrixWorld),j.matrix.invert(),j.matrix.multiply(et.matrixWorld)),j.matrix.decompose(j.position,j.quaternion,j.scale),j.updateMatrixWorld(!0),j.projectionMatrix.copy(et.projectionMatrix),j.projectionMatrixInverse.copy(et.projectionMatrixInverse),j.isPerspectiveCamera&&(j.fov=ra*2*Math.atan(1/j.projectionMatrix.elements[5]),j.zoom=1)}this.getCamera=function(){return v},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function(j){l=j,d!==null&&(d.fixedFoveation=j),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=j)},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(v)};let _t=null;function $t(j,et){if(h=et.getViewerPose(c||a),g=et,h!==null){const ft=h.views;f!==null&&(t.setRenderTargetFramebuffer(y,f.framebuffer),t.setRenderTarget(y));let lt=!1;ft.length!==v.cameras.length&&(v.cameras.length=0,lt=!0);for(let Tt=0;Tt<ft.length;Tt++){const zt=ft[Tt];let ie=null;if(f!==null)ie=f.getViewport(zt);else{const A=u.getViewSubImage(d,zt);ie=A.viewport,Tt===0&&(t.setRenderTargetTextures(y,A.colorTexture,d.ignoreDepthValues?void 0:A.depthStencilTexture),t.setRenderTarget(y))}let W=U[Tt];W===void 0&&(W=new An,W.layers.enable(Tt),W.viewport=new me,U[Tt]=W),W.matrix.fromArray(zt.transform.matrix),W.matrix.decompose(W.position,W.quaternion,W.scale),W.projectionMatrix.fromArray(zt.projectionMatrix),W.projectionMatrixInverse.copy(W.projectionMatrix).invert(),W.viewport.set(ie.x,ie.y,ie.width,ie.height),Tt===0&&(v.matrix.copy(W.matrix),v.matrix.decompose(v.position,v.quaternion,v.scale)),lt===!0&&v.cameras.push(W)}const At=s.enabledFeatures;if(At&&At.includes("depth-sensing")){const Tt=u.getDepthInformation(ft[0]);Tt&&Tt.isValid&&Tt.texture&&_.init(t,Tt,s.renderState)}}for(let ft=0;ft<x.length;ft++){const lt=S[ft],At=x[ft];lt!==null&&At!==void 0&&At.update(lt,et,c||a)}_t&&_t(j,et),et.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:et}),g=null}const Jt=new Hf;Jt.setAnimationLoop($t),this.setAnimationLoop=function(j){_t=j},this.dispose=function(){}}}const ps=new fi,xy=new fe;function yy(i,t){function e(m,p){m.matrixAutoUpdate===!0&&m.updateMatrix(),p.value.copy(m.matrix)}function n(m,p){p.color.getRGB(m.fogColor.value,Ff(i)),p.isFog?(m.fogNear.value=p.near,m.fogFar.value=p.far):p.isFogExp2&&(m.fogDensity.value=p.density)}function s(m,p,y,x,S){p.isMeshBasicMaterial||p.isMeshLambertMaterial?r(m,p):p.isMeshToonMaterial?(r(m,p),u(m,p)):p.isMeshPhongMaterial?(r(m,p),h(m,p)):p.isMeshStandardMaterial?(r(m,p),d(m,p),p.isMeshPhysicalMaterial&&f(m,p,S)):p.isMeshMatcapMaterial?(r(m,p),g(m,p)):p.isMeshDepthMaterial?r(m,p):p.isMeshDistanceMaterial?(r(m,p),_(m,p)):p.isMeshNormalMaterial?r(m,p):p.isLineBasicMaterial?(a(m,p),p.isLineDashedMaterial&&o(m,p)):p.isPointsMaterial?l(m,p,y,x):p.isSpriteMaterial?c(m,p):p.isShadowMaterial?(m.color.value.copy(p.color),m.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function r(m,p){m.opacity.value=p.opacity,p.color&&m.diffuse.value.copy(p.color),p.emissive&&m.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(m.map.value=p.map,e(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(p.alphaMap,m.alphaMapTransform)),p.bumpMap&&(m.bumpMap.value=p.bumpMap,e(p.bumpMap,m.bumpMapTransform),m.bumpScale.value=p.bumpScale,p.side===hn&&(m.bumpScale.value*=-1)),p.normalMap&&(m.normalMap.value=p.normalMap,e(p.normalMap,m.normalMapTransform),m.normalScale.value.copy(p.normalScale),p.side===hn&&m.normalScale.value.negate()),p.displacementMap&&(m.displacementMap.value=p.displacementMap,e(p.displacementMap,m.displacementMapTransform),m.displacementScale.value=p.displacementScale,m.displacementBias.value=p.displacementBias),p.emissiveMap&&(m.emissiveMap.value=p.emissiveMap,e(p.emissiveMap,m.emissiveMapTransform)),p.specularMap&&(m.specularMap.value=p.specularMap,e(p.specularMap,m.specularMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest);const y=t.get(p),x=y.envMap,S=y.envMapRotation;x&&(m.envMap.value=x,ps.copy(S),ps.x*=-1,ps.y*=-1,ps.z*=-1,x.isCubeTexture&&x.isRenderTargetTexture===!1&&(ps.y*=-1,ps.z*=-1),m.envMapRotation.value.setFromMatrix4(xy.makeRotationFromEuler(ps)),m.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio),p.lightMap&&(m.lightMap.value=p.lightMap,m.lightMapIntensity.value=p.lightMapIntensity,e(p.lightMap,m.lightMapTransform)),p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,e(p.aoMap,m.aoMapTransform))}function a(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map&&(m.map.value=p.map,e(p.map,m.mapTransform))}function o(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}function l(m,p,y,x){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*y,m.scale.value=x*.5,p.map&&(m.map.value=p.map,e(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function c(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.rotation.value=p.rotation,p.map&&(m.map.value=p.map,e(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function h(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,1e-4)}function u(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function d(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,e(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,e(p.roughnessMap,m.roughnessMapTransform)),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function f(m,p,y){m.ior.value=p.ior,p.sheen>0&&(m.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),m.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(m.sheenColorMap.value=p.sheenColorMap,e(p.sheenColorMap,m.sheenColorMapTransform)),p.sheenRoughnessMap&&(m.sheenRoughnessMap.value=p.sheenRoughnessMap,e(p.sheenRoughnessMap,m.sheenRoughnessMapTransform))),p.clearcoat>0&&(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(m.clearcoatMap.value=p.clearcoatMap,e(p.clearcoatMap,m.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,e(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(m.clearcoatNormalMap.value=p.clearcoatNormalMap,e(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===hn&&m.clearcoatNormalScale.value.negate())),p.dispersion>0&&(m.dispersion.value=p.dispersion),p.iridescence>0&&(m.iridescence.value=p.iridescence,m.iridescenceIOR.value=p.iridescenceIOR,m.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(m.iridescenceMap.value=p.iridescenceMap,e(p.iridescenceMap,m.iridescenceMapTransform)),p.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,e(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),p.transmission>0&&(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=y.texture,m.transmissionSamplerSize.value.set(y.width,y.height),p.transmissionMap&&(m.transmissionMap.value=p.transmissionMap,e(p.transmissionMap,m.transmissionMapTransform)),m.thickness.value=p.thickness,p.thicknessMap&&(m.thicknessMap.value=p.thicknessMap,e(p.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=p.attenuationDistance,m.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(m.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(m.anisotropyMap.value=p.anisotropyMap,e(p.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap&&(m.specularColorMap.value=p.specularColorMap,e(p.specularColorMap,m.specularColorMapTransform)),p.specularIntensityMap&&(m.specularIntensityMap.value=p.specularIntensityMap,e(p.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,p){p.matcap&&(m.matcap.value=p.matcap)}function _(m,p){const y=t.get(p).light;m.referencePosition.value.setFromMatrixPosition(y.matrixWorld),m.nearDistance.value=y.shadow.camera.near,m.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function My(i,t,e,n){let s={},r={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,x){const S=x.program;n.uniformBlockBinding(y,S)}function c(y,x){let S=s[y.id];S===void 0&&(g(y),S=h(y),s[y.id]=S,y.addEventListener("dispose",m));const L=x.program;n.updateUBOMapping(y,L);const T=t.render.frame;r[y.id]!==T&&(d(y),r[y.id]=T)}function h(y){const x=u();y.__bindingPointIndex=x;const S=i.createBuffer(),L=y.__size,T=y.usage;return i.bindBuffer(i.UNIFORM_BUFFER,S),i.bufferData(i.UNIFORM_BUFFER,L,T),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,x,S),S}function u(){for(let y=0;y<o;y++)if(a.indexOf(y)===-1)return a.push(y),y;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(y){const x=s[y.id],S=y.uniforms,L=y.__cache;i.bindBuffer(i.UNIFORM_BUFFER,x);for(let T=0,E=S.length;T<E;T++){const P=Array.isArray(S[T])?S[T]:[S[T]];for(let U=0,v=P.length;U<v;U++){const b=P[U];if(f(b,T,U,L)===!0){const I=b.__offset,O=Array.isArray(b.value)?b.value:[b.value];let $=0;for(let K=0;K<O.length;K++){const z=O[K],Z=_(z);typeof z=="number"||typeof z=="boolean"?(b.__data[0]=z,i.bufferSubData(i.UNIFORM_BUFFER,I+$,b.__data)):z.isMatrix3?(b.__data[0]=z.elements[0],b.__data[1]=z.elements[1],b.__data[2]=z.elements[2],b.__data[3]=0,b.__data[4]=z.elements[3],b.__data[5]=z.elements[4],b.__data[6]=z.elements[5],b.__data[7]=0,b.__data[8]=z.elements[6],b.__data[9]=z.elements[7],b.__data[10]=z.elements[8],b.__data[11]=0):(z.toArray(b.__data,$),$+=Z.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,I,b.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function f(y,x,S,L){const T=y.value,E=x+"_"+S;if(L[E]===void 0)return typeof T=="number"||typeof T=="boolean"?L[E]=T:L[E]=T.clone(),!0;{const P=L[E];if(typeof T=="number"||typeof T=="boolean"){if(P!==T)return L[E]=T,!0}else if(P.equals(T)===!1)return P.copy(T),!0}return!1}function g(y){const x=y.uniforms;let S=0;const L=16;for(let E=0,P=x.length;E<P;E++){const U=Array.isArray(x[E])?x[E]:[x[E]];for(let v=0,b=U.length;v<b;v++){const I=U[v],O=Array.isArray(I.value)?I.value:[I.value];for(let $=0,K=O.length;$<K;$++){const z=O[$],Z=_(z),V=S%L,ot=V%Z.boundary,ct=V+ot;S+=ot,ct!==0&&L-ct<Z.storage&&(S+=L-ct),I.__data=new Float32Array(Z.storage/Float32Array.BYTES_PER_ELEMENT),I.__offset=S,S+=Z.storage}}}const T=S%L;return T>0&&(S+=L-T),y.__size=S,y.__cache={},this}function _(y){const x={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(x.boundary=4,x.storage=4):y.isVector2?(x.boundary=8,x.storage=8):y.isVector3||y.isColor?(x.boundary=16,x.storage=12):y.isVector4?(x.boundary=16,x.storage=16):y.isMatrix3?(x.boundary=48,x.storage=48):y.isMatrix4?(x.boundary=64,x.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),x}function m(y){const x=y.target;x.removeEventListener("dispose",m);const S=a.indexOf(x.__bindingPointIndex);a.splice(S,1),i.deleteBuffer(s[x.id]),delete s[x.id],delete r[x.id]}function p(){for(const y in s)i.deleteBuffer(s[y]);a=[],s={},r={}}return{bind:l,update:c,dispose:p}}class by{constructor(t={}){const{canvas:e=h0(),context:n=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1}=t;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=a;const f=new Uint32Array(4),g=new Int32Array(4);let _=null,m=null;const p=[],y=[];this.domElement=e,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=Ye,this.toneMapping=ns,this.toneMappingExposure=1;const x=this;let S=!1,L=0,T=0,E=null,P=-1,U=null;const v=new me,b=new me;let I=null;const O=new Zt(0);let $=0,K=e.width,z=e.height,Z=1,V=null,ot=null;const ct=new me(0,0,K,z),_t=new me(0,0,K,z);let $t=!1;const Jt=new bh;let j=!1,et=!1;const ft=new fe,lt=new fe,At=new R,Tt=new me,zt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ie=!1;function W(){return E===null?Z:1}let A=n;function It(w,k){return e.getContext(w,k)}try{const w={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${lh}`),e.addEventListener("webglcontextlost",J,!1),e.addEventListener("webglcontextrestored",gt,!1),e.addEventListener("webglcontextcreationerror",xt,!1),A===null){const k="webgl2";if(A=It(k,w),A===null)throw It(k)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(w){throw console.error("THREE.WebGLRenderer: "+w.message),w}let Ct,Bt,Dt,ue,kt,C,M,F,Y,Q,q,St,ht,pt,Yt,it,mt,Ut,Ot,Mt,Qt,Vt,se,D;function dt(){Ct=new A_(A),Ct.init(),Vt=new dy(A,Ct),Bt=new M_(A,Ct,t,Vt),Dt=new cy(A),Bt.reverseDepthBuffer&&Dt.buffers.depth.setReversed(!0),ue=new P_(A),kt=new qx,C=new uy(A,Ct,Dt,kt,Bt,Vt,ue),M=new S_(x),F=new T_(x),Y=new O0(A),se=new x_(A,Y),Q=new C_(A,Y,ue,se),q=new D_(A,Q,Y,ue),Ot=new L_(A,Bt,C),it=new b_(kt),St=new jx(x,M,F,Ct,Bt,se,it),ht=new yy(x,kt),pt=new Kx,Yt=new ny(Ct),Ut=new __(x,M,F,Dt,q,d,l),mt=new oy(x,q,Bt),D=new My(A,ue,Bt,Dt),Mt=new y_(A,Ct,ue),Qt=new R_(A,Ct,ue),ue.programs=St.programs,x.capabilities=Bt,x.extensions=Ct,x.properties=kt,x.renderLists=pt,x.shadowMap=mt,x.state=Dt,x.info=ue}dt();const G=new _y(x,A);this.xr=G,this.getContext=function(){return A},this.getContextAttributes=function(){return A.getContextAttributes()},this.forceContextLoss=function(){const w=Ct.get("WEBGL_lose_context");w&&w.loseContext()},this.forceContextRestore=function(){const w=Ct.get("WEBGL_lose_context");w&&w.restoreContext()},this.getPixelRatio=function(){return Z},this.setPixelRatio=function(w){w!==void 0&&(Z=w,this.setSize(K,z,!1))},this.getSize=function(w){return w.set(K,z)},this.setSize=function(w,k,B=!0){if(G.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}K=w,z=k,e.width=Math.floor(w*Z),e.height=Math.floor(k*Z),B===!0&&(e.style.width=w+"px",e.style.height=k+"px"),this.setViewport(0,0,w,k)},this.getDrawingBufferSize=function(w){return w.set(K*Z,z*Z).floor()},this.setDrawingBufferSize=function(w,k,B){K=w,z=k,Z=B,e.width=Math.floor(w*B),e.height=Math.floor(k*B),this.setViewport(0,0,w,k)},this.getCurrentViewport=function(w){return w.copy(v)},this.getViewport=function(w){return w.copy(ct)},this.setViewport=function(w,k,B,H){w.isVector4?ct.set(w.x,w.y,w.z,w.w):ct.set(w,k,B,H),Dt.viewport(v.copy(ct).multiplyScalar(Z).round())},this.getScissor=function(w){return w.copy(_t)},this.setScissor=function(w,k,B,H){w.isVector4?_t.set(w.x,w.y,w.z,w.w):_t.set(w,k,B,H),Dt.scissor(b.copy(_t).multiplyScalar(Z).round())},this.getScissorTest=function(){return $t},this.setScissorTest=function(w){Dt.setScissorTest($t=w)},this.setOpaqueSort=function(w){V=w},this.setTransparentSort=function(w){ot=w},this.getClearColor=function(w){return w.copy(Ut.getClearColor())},this.setClearColor=function(){Ut.setClearColor.apply(Ut,arguments)},this.getClearAlpha=function(){return Ut.getClearAlpha()},this.setClearAlpha=function(){Ut.setClearAlpha.apply(Ut,arguments)},this.clear=function(w=!0,k=!0,B=!0){let H=0;if(w){let N=!1;if(E!==null){const rt=E.texture.format;N=rt===mh||rt===ph||rt===fh}if(N){const rt=E.texture.type,vt=rt===di||rt===bs||rt===sa||rt===Ss||rt===uh||rt===dh,bt=Ut.getClearColor(),Et=Ut.getClearAlpha(),Ft=bt.r,Ht=bt.g,Rt=bt.b;vt?(f[0]=Ft,f[1]=Ht,f[2]=Rt,f[3]=Et,A.clearBufferuiv(A.COLOR,0,f)):(g[0]=Ft,g[1]=Ht,g[2]=Rt,g[3]=Et,A.clearBufferiv(A.COLOR,0,g))}else H|=A.COLOR_BUFFER_BIT}k&&(H|=A.DEPTH_BUFFER_BIT,A.clearDepth(this.capabilities.reverseDepthBuffer?0:1)),B&&(H|=A.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),A.clear(H)},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(){e.removeEventListener("webglcontextlost",J,!1),e.removeEventListener("webglcontextrestored",gt,!1),e.removeEventListener("webglcontextcreationerror",xt,!1),pt.dispose(),Yt.dispose(),kt.dispose(),M.dispose(),F.dispose(),q.dispose(),se.dispose(),D.dispose(),St.dispose(),G.dispose(),G.removeEventListener("sessionstart",Yh),G.removeEventListener("sessionend",Kh),ls.stop()};function J(w){w.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),S=!0}function gt(){console.log("THREE.WebGLRenderer: Context Restored."),S=!1;const w=ue.autoReset,k=mt.enabled,B=mt.autoUpdate,H=mt.needsUpdate,N=mt.type;dt(),ue.autoReset=w,mt.enabled=k,mt.autoUpdate=B,mt.needsUpdate=H,mt.type=N}function xt(w){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",w.statusMessage)}function ne(w){const k=w.target;k.removeEventListener("dispose",ne),De(k)}function De(w){fn(w),kt.remove(w)}function fn(w){const k=kt.get(w).programs;k!==void 0&&(k.forEach(function(B){St.releaseProgram(B)}),w.isShaderMaterial&&St.releaseShaderCache(w))}this.renderBufferDirect=function(w,k,B,H,N,rt){k===null&&(k=zt);const vt=N.isMesh&&N.matrixWorld.determinant()<0,bt=Np(w,k,B,H,N);Dt.setMaterial(H,vt);let Et=B.index,Ft=1;if(H.wireframe===!0){if(Et=Q.getWireframeAttribute(B),Et===void 0)return;Ft=2}const Ht=B.drawRange,Rt=B.attributes.position;let de=Ht.start*Ft,Me=(Ht.start+Ht.count)*Ft;rt!==null&&(de=Math.max(de,rt.start*Ft),Me=Math.min(Me,(rt.start+rt.count)*Ft)),Et!==null?(de=Math.max(de,0),Me=Math.min(Me,Et.count)):Rt!=null&&(de=Math.max(de,0),Me=Math.min(Me,Rt.count));const Ae=Me-de;if(Ae<0||Ae===1/0)return;se.setup(N,H,bt,B,Et);let Mn,le=Mt;if(Et!==null&&(Mn=Y.get(Et),le=Qt,le.setIndex(Mn)),N.isMesh)H.wireframe===!0?(Dt.setLineWidth(H.wireframeLinewidth*W()),le.setMode(A.LINES)):le.setMode(A.TRIANGLES);else if(N.isLine){let Lt=H.linewidth;Lt===void 0&&(Lt=1),Dt.setLineWidth(Lt*W()),N.isLineSegments?le.setMode(A.LINES):N.isLineLoop?le.setMode(A.LINE_LOOP):le.setMode(A.LINE_STRIP)}else N.isPoints?le.setMode(A.POINTS):N.isSprite&&le.setMode(A.TRIANGLES);if(N.isBatchedMesh)if(N._multiDrawInstances!==null)le.renderMultiDrawInstances(N._multiDrawStarts,N._multiDrawCounts,N._multiDrawCount,N._multiDrawInstances);else if(Ct.get("WEBGL_multi_draw"))le.renderMultiDraw(N._multiDrawStarts,N._multiDrawCounts,N._multiDrawCount);else{const Lt=N._multiDrawStarts,We=N._multiDrawCounts,ce=N._multiDrawCount,Bn=Et?Y.get(Et).bytesPerElement:1,Ps=kt.get(H).currentProgram.getUniforms();for(let bn=0;bn<ce;bn++)Ps.setValue(A,"_gl_DrawID",bn),le.render(Lt[bn]/Bn,We[bn])}else if(N.isInstancedMesh)le.renderInstances(de,Ae,N.count);else if(B.isInstancedBufferGeometry){const Lt=B._maxInstanceCount!==void 0?B._maxInstanceCount:1/0,We=Math.min(B.instanceCount,Lt);le.renderInstances(de,Ae,We)}else le.render(de,Ae)};function ae(w,k,B){w.transparent===!0&&w.side===ai&&w.forceSinglePass===!1?(w.side=hn,w.needsUpdate=!0,da(w,k,B),w.side=rs,w.needsUpdate=!0,da(w,k,B),w.side=ai):da(w,k,B)}this.compile=function(w,k,B=null){B===null&&(B=w),m=Yt.get(B),m.init(k),y.push(m),B.traverseVisible(function(N){N.isLight&&N.layers.test(k.layers)&&(m.pushLight(N),N.castShadow&&m.pushShadow(N))}),w!==B&&w.traverseVisible(function(N){N.isLight&&N.layers.test(k.layers)&&(m.pushLight(N),N.castShadow&&m.pushShadow(N))}),m.setupLights();const H=new Set;return w.traverse(function(N){if(!(N.isMesh||N.isPoints||N.isLine||N.isSprite))return;const rt=N.material;if(rt)if(Array.isArray(rt))for(let vt=0;vt<rt.length;vt++){const bt=rt[vt];ae(bt,B,N),H.add(bt)}else ae(rt,B,N),H.add(rt)}),y.pop(),m=null,H},this.compileAsync=function(w,k,B=null){const H=this.compile(w,k,B);return new Promise(N=>{function rt(){if(H.forEach(function(vt){kt.get(vt).currentProgram.isReady()&&H.delete(vt)}),H.size===0){N(w);return}setTimeout(rt,10)}Ct.get("KHR_parallel_shader_compile")!==null?rt():setTimeout(rt,10)})};let pn=null;function gi(w){pn&&pn(w)}function Yh(){ls.stop()}function Kh(){ls.start()}const ls=new Hf;ls.setAnimationLoop(gi),typeof self<"u"&&ls.setContext(self),this.setAnimationLoop=function(w){pn=w,G.setAnimationLoop(w),w===null?ls.stop():ls.start()},G.addEventListener("sessionstart",Yh),G.addEventListener("sessionend",Kh),this.render=function(w,k){if(k!==void 0&&k.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(S===!0)return;if(w.matrixWorldAutoUpdate===!0&&w.updateMatrixWorld(),k.parent===null&&k.matrixWorldAutoUpdate===!0&&k.updateMatrixWorld(),G.enabled===!0&&G.isPresenting===!0&&(G.cameraAutoUpdate===!0&&G.updateCamera(k),k=G.getCamera()),w.isScene===!0&&w.onBeforeRender(x,w,k,E),m=Yt.get(w,y.length),m.init(k),y.push(m),lt.multiplyMatrices(k.projectionMatrix,k.matrixWorldInverse),Jt.setFromProjectionMatrix(lt),et=this.localClippingEnabled,j=it.init(this.clippingPlanes,et),_=pt.get(w,p.length),_.init(),p.push(_),G.enabled===!0&&G.isPresenting===!0){const rt=x.xr.getDepthSensingMesh();rt!==null&&Vo(rt,k,-1/0,x.sortObjects)}Vo(w,k,0,x.sortObjects),_.finish(),x.sortObjects===!0&&_.sort(V,ot),ie=G.enabled===!1||G.isPresenting===!1||G.hasDepthSensing()===!1,ie&&Ut.addToRenderList(_,w),this.info.render.frame++,j===!0&&it.beginShadows();const B=m.state.shadowsArray;mt.render(B,w,k),j===!0&&it.endShadows(),this.info.autoReset===!0&&this.info.reset();const H=_.opaque,N=_.transmissive;if(m.setupLights(),k.isArrayCamera){const rt=k.cameras;if(N.length>0)for(let vt=0,bt=rt.length;vt<bt;vt++){const Et=rt[vt];Jh(H,N,w,Et)}ie&&Ut.render(w);for(let vt=0,bt=rt.length;vt<bt;vt++){const Et=rt[vt];Zh(_,w,Et,Et.viewport)}}else N.length>0&&Jh(H,N,w,k),ie&&Ut.render(w),Zh(_,w,k);E!==null&&(C.updateMultisampleRenderTarget(E),C.updateRenderTargetMipmap(E)),w.isScene===!0&&w.onAfterRender(x,w,k),se.resetDefaultState(),P=-1,U=null,y.pop(),y.length>0?(m=y[y.length-1],j===!0&&it.setGlobalState(x.clippingPlanes,m.state.camera)):m=null,p.pop(),p.length>0?_=p[p.length-1]:_=null};function Vo(w,k,B,H){if(w.visible===!1)return;if(w.layers.test(k.layers)){if(w.isGroup)B=w.renderOrder;else if(w.isLOD)w.autoUpdate===!0&&w.update(k);else if(w.isLight)m.pushLight(w),w.castShadow&&m.pushShadow(w);else if(w.isSprite){if(!w.frustumCulled||Jt.intersectsSprite(w)){H&&Tt.setFromMatrixPosition(w.matrixWorld).applyMatrix4(lt);const vt=q.update(w),bt=w.material;bt.visible&&_.push(w,vt,bt,B,Tt.z,null)}}else if((w.isMesh||w.isLine||w.isPoints)&&(!w.frustumCulled||Jt.intersectsObject(w))){const vt=q.update(w),bt=w.material;if(H&&(w.boundingSphere!==void 0?(w.boundingSphere===null&&w.computeBoundingSphere(),Tt.copy(w.boundingSphere.center)):(vt.boundingSphere===null&&vt.computeBoundingSphere(),Tt.copy(vt.boundingSphere.center)),Tt.applyMatrix4(w.matrixWorld).applyMatrix4(lt)),Array.isArray(bt)){const Et=vt.groups;for(let Ft=0,Ht=Et.length;Ft<Ht;Ft++){const Rt=Et[Ft],de=bt[Rt.materialIndex];de&&de.visible&&_.push(w,vt,de,B,Tt.z,Rt)}}else bt.visible&&_.push(w,vt,bt,B,Tt.z,null)}}const rt=w.children;for(let vt=0,bt=rt.length;vt<bt;vt++)Vo(rt[vt],k,B,H)}function Zh(w,k,B,H){const N=w.opaque,rt=w.transmissive,vt=w.transparent;m.setupLightsView(B),j===!0&&it.setGlobalState(x.clippingPlanes,B),H&&Dt.viewport(v.copy(H)),N.length>0&&ua(N,k,B),rt.length>0&&ua(rt,k,B),vt.length>0&&ua(vt,k,B),Dt.buffers.depth.setTest(!0),Dt.buffers.depth.setMask(!0),Dt.buffers.color.setMask(!0),Dt.setPolygonOffset(!1)}function Jh(w,k,B,H){if((B.isScene===!0?B.overrideMaterial:null)!==null)return;m.state.transmissionRenderTarget[H.id]===void 0&&(m.state.transmissionRenderTarget[H.id]=new Jn(1,1,{generateMipmaps:!0,type:Ct.has("EXT_color_buffer_half_float")||Ct.has("EXT_color_buffer_float")?Ni:di,minFilter:_s,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:oe.workingColorSpace}));const rt=m.state.transmissionRenderTarget[H.id],vt=H.viewport||v;rt.setSize(vt.z,vt.w);const bt=x.getRenderTarget();x.setRenderTarget(rt),x.getClearColor(O),$=x.getClearAlpha(),$<1&&x.setClearColor(16777215,.5),x.clear(),ie&&Ut.render(B);const Et=x.toneMapping;x.toneMapping=ns;const Ft=H.viewport;if(H.viewport!==void 0&&(H.viewport=void 0),m.setupLightsView(H),j===!0&&it.setGlobalState(x.clippingPlanes,H),ua(w,B,H),C.updateMultisampleRenderTarget(rt),C.updateRenderTargetMipmap(rt),Ct.has("WEBGL_multisampled_render_to_texture")===!1){let Ht=!1;for(let Rt=0,de=k.length;Rt<de;Rt++){const Me=k[Rt],Ae=Me.object,Mn=Me.geometry,le=Me.material,Lt=Me.group;if(le.side===ai&&Ae.layers.test(H.layers)){const We=le.side;le.side=hn,le.needsUpdate=!0,Qh(Ae,B,H,Mn,le,Lt),le.side=We,le.needsUpdate=!0,Ht=!0}}Ht===!0&&(C.updateMultisampleRenderTarget(rt),C.updateRenderTargetMipmap(rt))}x.setRenderTarget(bt),x.setClearColor(O,$),Ft!==void 0&&(H.viewport=Ft),x.toneMapping=Et}function ua(w,k,B){const H=k.isScene===!0?k.overrideMaterial:null;for(let N=0,rt=w.length;N<rt;N++){const vt=w[N],bt=vt.object,Et=vt.geometry,Ft=H===null?vt.material:H,Ht=vt.group;bt.layers.test(B.layers)&&Qh(bt,k,B,Et,Ft,Ht)}}function Qh(w,k,B,H,N,rt){w.onBeforeRender(x,k,B,H,N,rt),w.modelViewMatrix.multiplyMatrices(B.matrixWorldInverse,w.matrixWorld),w.normalMatrix.getNormalMatrix(w.modelViewMatrix),N.onBeforeRender(x,k,B,H,w,rt),N.transparent===!0&&N.side===ai&&N.forceSinglePass===!1?(N.side=hn,N.needsUpdate=!0,x.renderBufferDirect(B,k,H,N,w,rt),N.side=rs,N.needsUpdate=!0,x.renderBufferDirect(B,k,H,N,w,rt),N.side=ai):x.renderBufferDirect(B,k,H,N,w,rt),w.onAfterRender(x,k,B,H,N,rt)}function da(w,k,B){k.isScene!==!0&&(k=zt);const H=kt.get(w),N=m.state.lights,rt=m.state.shadowsArray,vt=N.state.version,bt=St.getParameters(w,N.state,rt,k,B),Et=St.getProgramCacheKey(bt);let Ft=H.programs;H.environment=w.isMeshStandardMaterial?k.environment:null,H.fog=k.fog,H.envMap=(w.isMeshStandardMaterial?F:M).get(w.envMap||H.environment),H.envMapRotation=H.environment!==null&&w.envMap===null?k.environmentRotation:w.envMapRotation,Ft===void 0&&(w.addEventListener("dispose",ne),Ft=new Map,H.programs=Ft);let Ht=Ft.get(Et);if(Ht!==void 0){if(H.currentProgram===Ht&&H.lightsStateVersion===vt)return eu(w,bt),Ht}else bt.uniforms=St.getUniforms(w),w.onBeforeCompile(bt,x),Ht=St.acquireProgram(bt,Et),Ft.set(Et,Ht),H.uniforms=bt.uniforms;const Rt=H.uniforms;return(!w.isShaderMaterial&&!w.isRawShaderMaterial||w.clipping===!0)&&(Rt.clippingPlanes=it.uniform),eu(w,bt),H.needsLights=Op(w),H.lightsStateVersion=vt,H.needsLights&&(Rt.ambientLightColor.value=N.state.ambient,Rt.lightProbe.value=N.state.probe,Rt.directionalLights.value=N.state.directional,Rt.directionalLightShadows.value=N.state.directionalShadow,Rt.spotLights.value=N.state.spot,Rt.spotLightShadows.value=N.state.spotShadow,Rt.rectAreaLights.value=N.state.rectArea,Rt.ltc_1.value=N.state.rectAreaLTC1,Rt.ltc_2.value=N.state.rectAreaLTC2,Rt.pointLights.value=N.state.point,Rt.pointLightShadows.value=N.state.pointShadow,Rt.hemisphereLights.value=N.state.hemi,Rt.directionalShadowMap.value=N.state.directionalShadowMap,Rt.directionalShadowMatrix.value=N.state.directionalShadowMatrix,Rt.spotShadowMap.value=N.state.spotShadowMap,Rt.spotLightMatrix.value=N.state.spotLightMatrix,Rt.spotLightMap.value=N.state.spotLightMap,Rt.pointShadowMap.value=N.state.pointShadowMap,Rt.pointShadowMatrix.value=N.state.pointShadowMatrix),H.currentProgram=Ht,H.uniformsList=null,Ht}function tu(w){if(w.uniformsList===null){const k=w.currentProgram.getUniforms();w.uniformsList=ao.seqWithValue(k.seq,w.uniforms)}return w.uniformsList}function eu(w,k){const B=kt.get(w);B.outputColorSpace=k.outputColorSpace,B.batching=k.batching,B.batchingColor=k.batchingColor,B.instancing=k.instancing,B.instancingColor=k.instancingColor,B.instancingMorph=k.instancingMorph,B.skinning=k.skinning,B.morphTargets=k.morphTargets,B.morphNormals=k.morphNormals,B.morphColors=k.morphColors,B.morphTargetsCount=k.morphTargetsCount,B.numClippingPlanes=k.numClippingPlanes,B.numIntersection=k.numClipIntersection,B.vertexAlphas=k.vertexAlphas,B.vertexTangents=k.vertexTangents,B.toneMapping=k.toneMapping}function Np(w,k,B,H,N){k.isScene!==!0&&(k=zt),C.resetTextureUnits();const rt=k.fog,vt=H.isMeshStandardMaterial?k.environment:null,bt=E===null?x.outputColorSpace:E.isXRRenderTarget===!0?E.texture.colorSpace:os,Et=(H.isMeshStandardMaterial?F:M).get(H.envMap||vt),Ft=H.vertexColors===!0&&!!B.attributes.color&&B.attributes.color.itemSize===4,Ht=!!B.attributes.tangent&&(!!H.normalMap||H.anisotropy>0),Rt=!!B.morphAttributes.position,de=!!B.morphAttributes.normal,Me=!!B.morphAttributes.color;let Ae=ns;H.toneMapped&&(E===null||E.isXRRenderTarget===!0)&&(Ae=x.toneMapping);const Mn=B.morphAttributes.position||B.morphAttributes.normal||B.morphAttributes.color,le=Mn!==void 0?Mn.length:0,Lt=kt.get(H),We=m.state.lights;if(j===!0&&(et===!0||w!==U)){const Rn=w===U&&H.id===P;it.setState(H,w,Rn)}let ce=!1;H.version===Lt.__version?(Lt.needsLights&&Lt.lightsStateVersion!==We.state.version||Lt.outputColorSpace!==bt||N.isBatchedMesh&&Lt.batching===!1||!N.isBatchedMesh&&Lt.batching===!0||N.isBatchedMesh&&Lt.batchingColor===!0&&N.colorTexture===null||N.isBatchedMesh&&Lt.batchingColor===!1&&N.colorTexture!==null||N.isInstancedMesh&&Lt.instancing===!1||!N.isInstancedMesh&&Lt.instancing===!0||N.isSkinnedMesh&&Lt.skinning===!1||!N.isSkinnedMesh&&Lt.skinning===!0||N.isInstancedMesh&&Lt.instancingColor===!0&&N.instanceColor===null||N.isInstancedMesh&&Lt.instancingColor===!1&&N.instanceColor!==null||N.isInstancedMesh&&Lt.instancingMorph===!0&&N.morphTexture===null||N.isInstancedMesh&&Lt.instancingMorph===!1&&N.morphTexture!==null||Lt.envMap!==Et||H.fog===!0&&Lt.fog!==rt||Lt.numClippingPlanes!==void 0&&(Lt.numClippingPlanes!==it.numPlanes||Lt.numIntersection!==it.numIntersection)||Lt.vertexAlphas!==Ft||Lt.vertexTangents!==Ht||Lt.morphTargets!==Rt||Lt.morphNormals!==de||Lt.morphColors!==Me||Lt.toneMapping!==Ae||Lt.morphTargetsCount!==le)&&(ce=!0):(ce=!0,Lt.__version=H.version);let Bn=Lt.currentProgram;ce===!0&&(Bn=da(H,k,N));let Ps=!1,bn=!1,Go=!1;const Pe=Bn.getUniforms(),zi=Lt.uniforms;if(Dt.useProgram(Bn.program)&&(Ps=!0,bn=!0,Go=!0),H.id!==P&&(P=H.id,bn=!0),Ps||U!==w){Bt.reverseDepthBuffer?(ft.copy(w.projectionMatrix),d0(ft),f0(ft),Pe.setValue(A,"projectionMatrix",ft)):Pe.setValue(A,"projectionMatrix",w.projectionMatrix),Pe.setValue(A,"viewMatrix",w.matrixWorldInverse);const Rn=Pe.map.cameraPosition;Rn!==void 0&&Rn.setValue(A,At.setFromMatrixPosition(w.matrixWorld)),Bt.logarithmicDepthBuffer&&Pe.setValue(A,"logDepthBufFC",2/(Math.log(w.far+1)/Math.LN2)),(H.isMeshPhongMaterial||H.isMeshToonMaterial||H.isMeshLambertMaterial||H.isMeshBasicMaterial||H.isMeshStandardMaterial||H.isShaderMaterial)&&Pe.setValue(A,"isOrthographic",w.isOrthographicCamera===!0),U!==w&&(U=w,bn=!0,Go=!0)}if(N.isSkinnedMesh){Pe.setOptional(A,N,"bindMatrix"),Pe.setOptional(A,N,"bindMatrixInverse");const Rn=N.skeleton;Rn&&(Rn.boneTexture===null&&Rn.computeBoneTexture(),Pe.setValue(A,"boneTexture",Rn.boneTexture,C))}N.isBatchedMesh&&(Pe.setOptional(A,N,"batchingTexture"),Pe.setValue(A,"batchingTexture",N._matricesTexture,C),Pe.setOptional(A,N,"batchingIdTexture"),Pe.setValue(A,"batchingIdTexture",N._indirectTexture,C),Pe.setOptional(A,N,"batchingColorTexture"),N._colorsTexture!==null&&Pe.setValue(A,"batchingColorTexture",N._colorsTexture,C));const $o=B.morphAttributes;if(($o.position!==void 0||$o.normal!==void 0||$o.color!==void 0)&&Ot.update(N,B,Bn),(bn||Lt.receiveShadow!==N.receiveShadow)&&(Lt.receiveShadow=N.receiveShadow,Pe.setValue(A,"receiveShadow",N.receiveShadow)),H.isMeshGouraudMaterial&&H.envMap!==null&&(zi.envMap.value=Et,zi.flipEnvMap.value=Et.isCubeTexture&&Et.isRenderTargetTexture===!1?-1:1),H.isMeshStandardMaterial&&H.envMap===null&&k.environment!==null&&(zi.envMapIntensity.value=k.environmentIntensity),bn&&(Pe.setValue(A,"toneMappingExposure",x.toneMappingExposure),Lt.needsLights&&Up(zi,Go),rt&&H.fog===!0&&ht.refreshFogUniforms(zi,rt),ht.refreshMaterialUniforms(zi,H,Z,z,m.state.transmissionRenderTarget[w.id]),ao.upload(A,tu(Lt),zi,C)),H.isShaderMaterial&&H.uniformsNeedUpdate===!0&&(ao.upload(A,tu(Lt),zi,C),H.uniformsNeedUpdate=!1),H.isSpriteMaterial&&Pe.setValue(A,"center",N.center),Pe.setValue(A,"modelViewMatrix",N.modelViewMatrix),Pe.setValue(A,"normalMatrix",N.normalMatrix),Pe.setValue(A,"modelMatrix",N.matrixWorld),H.isShaderMaterial||H.isRawShaderMaterial){const Rn=H.uniformsGroups;for(let Wo=0,Fp=Rn.length;Wo<Fp;Wo++){const nu=Rn[Wo];D.update(nu,Bn),D.bind(nu,Bn)}}return Bn}function Up(w,k){w.ambientLightColor.needsUpdate=k,w.lightProbe.needsUpdate=k,w.directionalLights.needsUpdate=k,w.directionalLightShadows.needsUpdate=k,w.pointLights.needsUpdate=k,w.pointLightShadows.needsUpdate=k,w.spotLights.needsUpdate=k,w.spotLightShadows.needsUpdate=k,w.rectAreaLights.needsUpdate=k,w.hemisphereLights.needsUpdate=k}function Op(w){return w.isMeshLambertMaterial||w.isMeshToonMaterial||w.isMeshPhongMaterial||w.isMeshStandardMaterial||w.isShadowMaterial||w.isShaderMaterial&&w.lights===!0}this.getActiveCubeFace=function(){return L},this.getActiveMipmapLevel=function(){return T},this.getRenderTarget=function(){return E},this.setRenderTargetTextures=function(w,k,B){kt.get(w.texture).__webglTexture=k,kt.get(w.depthTexture).__webglTexture=B;const H=kt.get(w);H.__hasExternalTextures=!0,H.__autoAllocateDepthBuffer=B===void 0,H.__autoAllocateDepthBuffer||Ct.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),H.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(w,k){const B=kt.get(w);B.__webglFramebuffer=k,B.__useDefaultFramebuffer=k===void 0},this.setRenderTarget=function(w,k=0,B=0){E=w,L=k,T=B;let H=!0,N=null,rt=!1,vt=!1;if(w){const Et=kt.get(w);if(Et.__useDefaultFramebuffer!==void 0)Dt.bindFramebuffer(A.FRAMEBUFFER,null),H=!1;else if(Et.__webglFramebuffer===void 0)C.setupRenderTarget(w);else if(Et.__hasExternalTextures)C.rebindTextures(w,kt.get(w.texture).__webglTexture,kt.get(w.depthTexture).__webglTexture);else if(w.depthBuffer){const Rt=w.depthTexture;if(Et.__boundDepthTexture!==Rt){if(Rt!==null&&kt.has(Rt)&&(w.width!==Rt.image.width||w.height!==Rt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");C.setupDepthRenderbuffer(w)}}const Ft=w.texture;(Ft.isData3DTexture||Ft.isDataArrayTexture||Ft.isCompressedArrayTexture)&&(vt=!0);const Ht=kt.get(w).__webglFramebuffer;w.isWebGLCubeRenderTarget?(Array.isArray(Ht[k])?N=Ht[k][B]:N=Ht[k],rt=!0):w.samples>0&&C.useMultisampledRTT(w)===!1?N=kt.get(w).__webglMultisampledFramebuffer:Array.isArray(Ht)?N=Ht[B]:N=Ht,v.copy(w.viewport),b.copy(w.scissor),I=w.scissorTest}else v.copy(ct).multiplyScalar(Z).floor(),b.copy(_t).multiplyScalar(Z).floor(),I=$t;if(Dt.bindFramebuffer(A.FRAMEBUFFER,N)&&H&&Dt.drawBuffers(w,N),Dt.viewport(v),Dt.scissor(b),Dt.setScissorTest(I),rt){const Et=kt.get(w.texture);A.framebufferTexture2D(A.FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_CUBE_MAP_POSITIVE_X+k,Et.__webglTexture,B)}else if(vt){const Et=kt.get(w.texture),Ft=k||0;A.framebufferTextureLayer(A.FRAMEBUFFER,A.COLOR_ATTACHMENT0,Et.__webglTexture,B||0,Ft)}P=-1},this.readRenderTargetPixels=function(w,k,B,H,N,rt,vt){if(!(w&&w.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let bt=kt.get(w).__webglFramebuffer;if(w.isWebGLCubeRenderTarget&&vt!==void 0&&(bt=bt[vt]),bt){Dt.bindFramebuffer(A.FRAMEBUFFER,bt);try{const Et=w.texture,Ft=Et.format,Ht=Et.type;if(!Bt.textureFormatReadable(Ft)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Bt.textureTypeReadable(Ht)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}k>=0&&k<=w.width-H&&B>=0&&B<=w.height-N&&A.readPixels(k,B,H,N,Vt.convert(Ft),Vt.convert(Ht),rt)}finally{const Et=E!==null?kt.get(E).__webglFramebuffer:null;Dt.bindFramebuffer(A.FRAMEBUFFER,Et)}}},this.readRenderTargetPixelsAsync=async function(w,k,B,H,N,rt,vt){if(!(w&&w.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let bt=kt.get(w).__webglFramebuffer;if(w.isWebGLCubeRenderTarget&&vt!==void 0&&(bt=bt[vt]),bt){const Et=w.texture,Ft=Et.format,Ht=Et.type;if(!Bt.textureFormatReadable(Ft))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Bt.textureTypeReadable(Ht))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(k>=0&&k<=w.width-H&&B>=0&&B<=w.height-N){Dt.bindFramebuffer(A.FRAMEBUFFER,bt);const Rt=A.createBuffer();A.bindBuffer(A.PIXEL_PACK_BUFFER,Rt),A.bufferData(A.PIXEL_PACK_BUFFER,rt.byteLength,A.STREAM_READ),A.readPixels(k,B,H,N,Vt.convert(Ft),Vt.convert(Ht),0);const de=E!==null?kt.get(E).__webglFramebuffer:null;Dt.bindFramebuffer(A.FRAMEBUFFER,de);const Me=A.fenceSync(A.SYNC_GPU_COMMANDS_COMPLETE,0);return A.flush(),await u0(A,Me,4),A.bindBuffer(A.PIXEL_PACK_BUFFER,Rt),A.getBufferSubData(A.PIXEL_PACK_BUFFER,0,rt),A.deleteBuffer(Rt),A.deleteSync(Me),rt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(w,k=null,B=0){w.isTexture!==!0&&(ro("WebGLRenderer: copyFramebufferToTexture function signature has changed."),k=arguments[0]||null,w=arguments[1]);const H=Math.pow(2,-B),N=Math.floor(w.image.width*H),rt=Math.floor(w.image.height*H),vt=k!==null?k.x:0,bt=k!==null?k.y:0;C.setTexture2D(w,0),A.copyTexSubImage2D(A.TEXTURE_2D,B,0,0,vt,bt,N,rt),Dt.unbindTexture()},this.copyTextureToTexture=function(w,k,B=null,H=null,N=0){w.isTexture!==!0&&(ro("WebGLRenderer: copyTextureToTexture function signature has changed."),H=arguments[0]||null,w=arguments[1],k=arguments[2],N=arguments[3]||0,B=null);let rt,vt,bt,Et,Ft,Ht;B!==null?(rt=B.max.x-B.min.x,vt=B.max.y-B.min.y,bt=B.min.x,Et=B.min.y):(rt=w.image.width,vt=w.image.height,bt=0,Et=0),H!==null?(Ft=H.x,Ht=H.y):(Ft=0,Ht=0);const Rt=Vt.convert(k.format),de=Vt.convert(k.type);C.setTexture2D(k,0),A.pixelStorei(A.UNPACK_FLIP_Y_WEBGL,k.flipY),A.pixelStorei(A.UNPACK_PREMULTIPLY_ALPHA_WEBGL,k.premultiplyAlpha),A.pixelStorei(A.UNPACK_ALIGNMENT,k.unpackAlignment);const Me=A.getParameter(A.UNPACK_ROW_LENGTH),Ae=A.getParameter(A.UNPACK_IMAGE_HEIGHT),Mn=A.getParameter(A.UNPACK_SKIP_PIXELS),le=A.getParameter(A.UNPACK_SKIP_ROWS),Lt=A.getParameter(A.UNPACK_SKIP_IMAGES),We=w.isCompressedTexture?w.mipmaps[N]:w.image;A.pixelStorei(A.UNPACK_ROW_LENGTH,We.width),A.pixelStorei(A.UNPACK_IMAGE_HEIGHT,We.height),A.pixelStorei(A.UNPACK_SKIP_PIXELS,bt),A.pixelStorei(A.UNPACK_SKIP_ROWS,Et),w.isDataTexture?A.texSubImage2D(A.TEXTURE_2D,N,Ft,Ht,rt,vt,Rt,de,We.data):w.isCompressedTexture?A.compressedTexSubImage2D(A.TEXTURE_2D,N,Ft,Ht,We.width,We.height,Rt,We.data):A.texSubImage2D(A.TEXTURE_2D,N,Ft,Ht,rt,vt,Rt,de,We),A.pixelStorei(A.UNPACK_ROW_LENGTH,Me),A.pixelStorei(A.UNPACK_IMAGE_HEIGHT,Ae),A.pixelStorei(A.UNPACK_SKIP_PIXELS,Mn),A.pixelStorei(A.UNPACK_SKIP_ROWS,le),A.pixelStorei(A.UNPACK_SKIP_IMAGES,Lt),N===0&&k.generateMipmaps&&A.generateMipmap(A.TEXTURE_2D),Dt.unbindTexture()},this.copyTextureToTexture3D=function(w,k,B=null,H=null,N=0){w.isTexture!==!0&&(ro("WebGLRenderer: copyTextureToTexture3D function signature has changed."),B=arguments[0]||null,H=arguments[1]||null,w=arguments[2],k=arguments[3],N=arguments[4]||0);let rt,vt,bt,Et,Ft,Ht,Rt,de,Me;const Ae=w.isCompressedTexture?w.mipmaps[N]:w.image;B!==null?(rt=B.max.x-B.min.x,vt=B.max.y-B.min.y,bt=B.max.z-B.min.z,Et=B.min.x,Ft=B.min.y,Ht=B.min.z):(rt=Ae.width,vt=Ae.height,bt=Ae.depth,Et=0,Ft=0,Ht=0),H!==null?(Rt=H.x,de=H.y,Me=H.z):(Rt=0,de=0,Me=0);const Mn=Vt.convert(k.format),le=Vt.convert(k.type);let Lt;if(k.isData3DTexture)C.setTexture3D(k,0),Lt=A.TEXTURE_3D;else if(k.isDataArrayTexture||k.isCompressedArrayTexture)C.setTexture2DArray(k,0),Lt=A.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}A.pixelStorei(A.UNPACK_FLIP_Y_WEBGL,k.flipY),A.pixelStorei(A.UNPACK_PREMULTIPLY_ALPHA_WEBGL,k.premultiplyAlpha),A.pixelStorei(A.UNPACK_ALIGNMENT,k.unpackAlignment);const We=A.getParameter(A.UNPACK_ROW_LENGTH),ce=A.getParameter(A.UNPACK_IMAGE_HEIGHT),Bn=A.getParameter(A.UNPACK_SKIP_PIXELS),Ps=A.getParameter(A.UNPACK_SKIP_ROWS),bn=A.getParameter(A.UNPACK_SKIP_IMAGES);A.pixelStorei(A.UNPACK_ROW_LENGTH,Ae.width),A.pixelStorei(A.UNPACK_IMAGE_HEIGHT,Ae.height),A.pixelStorei(A.UNPACK_SKIP_PIXELS,Et),A.pixelStorei(A.UNPACK_SKIP_ROWS,Ft),A.pixelStorei(A.UNPACK_SKIP_IMAGES,Ht),w.isDataTexture||w.isData3DTexture?A.texSubImage3D(Lt,N,Rt,de,Me,rt,vt,bt,Mn,le,Ae.data):k.isCompressedArrayTexture?A.compressedTexSubImage3D(Lt,N,Rt,de,Me,rt,vt,bt,Mn,Ae.data):A.texSubImage3D(Lt,N,Rt,de,Me,rt,vt,bt,Mn,le,Ae),A.pixelStorei(A.UNPACK_ROW_LENGTH,We),A.pixelStorei(A.UNPACK_IMAGE_HEIGHT,ce),A.pixelStorei(A.UNPACK_SKIP_PIXELS,Bn),A.pixelStorei(A.UNPACK_SKIP_ROWS,Ps),A.pixelStorei(A.UNPACK_SKIP_IMAGES,bn),N===0&&k.generateMipmaps&&A.generateMipmap(Lt),Dt.unbindTexture()},this.initRenderTarget=function(w){kt.get(w).__webglFramebuffer===void 0&&C.setupRenderTarget(w)},this.initTexture=function(w){w.isCubeTexture?C.setTextureCube(w,0):w.isData3DTexture?C.setTexture3D(w,0):w.isDataArrayTexture||w.isCompressedArrayTexture?C.setTexture2DArray(w,0):C.setTexture2D(w,0),Dt.unbindTexture()},this.resetState=function(){L=0,T=0,E=null,Dt.reset(),se.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Ci}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=t===vh?"display-p3":"srgb",e.unpackColorSpace=oe.workingColorSpace===No?"display-p3":"srgb"}}class Xf extends Je{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 fi,this.environmentIntensity=1,this.environmentRotation=new fi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}class jf extends rn{constructor(t=null,e=1,n=1,s,r,a,o,l,c=sn,h=sn,u,d){super(null,a,o,l,c,h,s,r,u,d),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Fi extends rn{constructor(t,e,n,s,r,a,o,l,c){super(t,e,n,s,r,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class mi{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){const n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let n,s=this.getPoint(0),r=0;e.push(0);for(let a=1;a<=t;a++)n=this.getPoint(a/t),r+=n.distanceTo(s),e.push(r),s=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){const n=this.getLengths();let s=0;const r=n.length;let a;e?a=e:a=t*n[r-1];let o=0,l=r-1,c;for(;o<=l;)if(s=Math.floor(o+(l-o)/2),c=n[s]-a,c<0)o=s+1;else if(c>0)l=s-1;else{l=s;break}if(s=l,n[s]===a)return s/(r-1);const h=n[s],d=n[s+1]-h,f=(a-h)/d;return(s+f)/(r-1)}getTangent(t,e){let s=t-1e-4,r=t+1e-4;s<0&&(s=0),r>1&&(r=1);const a=this.getPoint(s),o=this.getPoint(r),l=e||(a.isVector2?new at:new R);return l.copy(o).sub(a).normalize(),l}getTangentAt(t,e){const n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){const n=new R,s=[],r=[],a=[],o=new R,l=new fe;for(let f=0;f<=t;f++){const g=f/t;s[f]=this.getTangentAt(g,new R)}r[0]=new R,a[0]=new R;let c=Number.MAX_VALUE;const h=Math.abs(s[0].x),u=Math.abs(s[0].y),d=Math.abs(s[0].z);h<=c&&(c=h,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(s[0],n).normalize(),r[0].crossVectors(s[0],o),a[0].crossVectors(s[0],r[0]);for(let f=1;f<=t;f++){if(r[f]=r[f-1].clone(),a[f]=a[f-1].clone(),o.crossVectors(s[f-1],s[f]),o.length()>Number.EPSILON){o.normalize();const g=Math.acos(Fe(s[f-1].dot(s[f]),-1,1));r[f].applyMatrix4(l.makeRotationAxis(o,g))}a[f].crossVectors(s[f],r[f])}if(e===!0){let f=Math.acos(Fe(r[0].dot(r[t]),-1,1));f/=t,s[0].dot(o.crossVectors(r[0],r[t]))>0&&(f=-f);for(let g=1;g<=t;g++)r[g].applyMatrix4(l.makeRotationAxis(s[g],f*g)),a[g].crossVectors(s[g],r[g])}return{tangents:s,normals:r,binormals:a}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class Th extends mi{constructor(t=0,e=0,n=1,s=1,r=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=s,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(t,e=new at){const n=e,s=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const a=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=s;for(;r>s;)r-=s;r<Number.EPSILON&&(a?r=0:r=s),this.aClockwise===!0&&!a&&(r===s?r=-s:r=r-s);const o=this.aStartAngle+t*r;let l=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){const h=Math.cos(this.aRotation),u=Math.sin(this.aRotation),d=l-this.aX,f=c-this.aY;l=d*h-f*u+this.aX,c=d*u+f*h+this.aY}return n.set(l,c)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){const t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}}class Sy extends Th{constructor(t,e,n,s,r,a){super(t,e,n,n,s,r,a),this.isArcCurve=!0,this.type="ArcCurve"}}function Ah(){let i=0,t=0,e=0,n=0;function s(r,a,o,l){i=r,t=o,e=-3*r+3*a-2*o-l,n=2*r-2*a+o+l}return{initCatmullRom:function(r,a,o,l,c){s(a,o,c*(o-r),c*(l-a))},initNonuniformCatmullRom:function(r,a,o,l,c,h,u){let d=(a-r)/c-(o-r)/(c+h)+(o-a)/h,f=(o-a)/h-(l-a)/(h+u)+(l-o)/u;d*=h,f*=h,s(a,o,d,f)},calc:function(r){const a=r*r,o=a*r;return i+t*r+e*a+n*o}}}const ka=new R,Cl=new Ah,Rl=new Ah,Pl=new Ah;class wy extends mi{constructor(t=[],e=!1,n="centripetal",s=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=s}getPoint(t,e=new R){const n=e,s=this.points,r=s.length,a=(r-(this.closed?0:1))*t;let o=Math.floor(a),l=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/r)+1)*r:l===0&&o===r-1&&(o=r-2,l=1);let c,h;this.closed||o>0?c=s[(o-1)%r]:(ka.subVectors(s[0],s[1]).add(s[0]),c=ka);const u=s[o%r],d=s[(o+1)%r];if(this.closed||o+2<r?h=s[(o+2)%r]:(ka.subVectors(s[r-1],s[r-2]).add(s[r-1]),h=ka),this.curveType==="centripetal"||this.curveType==="chordal"){const f=this.curveType==="chordal"?.5:.25;let g=Math.pow(c.distanceToSquared(u),f),_=Math.pow(u.distanceToSquared(d),f),m=Math.pow(d.distanceToSquared(h),f);_<1e-4&&(_=1),g<1e-4&&(g=_),m<1e-4&&(m=_),Cl.initNonuniformCatmullRom(c.x,u.x,d.x,h.x,g,_,m),Rl.initNonuniformCatmullRom(c.y,u.y,d.y,h.y,g,_,m),Pl.initNonuniformCatmullRom(c.z,u.z,d.z,h.z,g,_,m)}else this.curveType==="catmullrom"&&(Cl.initCatmullRom(c.x,u.x,d.x,h.x,this.tension),Rl.initCatmullRom(c.y,u.y,d.y,h.y,this.tension),Pl.initCatmullRom(c.z,u.z,d.z,h.z,this.tension));return n.set(Cl.calc(l),Rl.calc(l),Pl.calc(l)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const s=t.points[e];this.points.push(s.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const s=this.points[e];t.points.push(s.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const s=t.points[e];this.points.push(new R().fromArray(s))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function sd(i,t,e,n,s){const r=(n-t)*.5,a=(s-e)*.5,o=i*i,l=i*o;return(2*e-2*n+r+a)*l+(-3*e+3*n-2*r-a)*o+r*i+e}function Ey(i,t){const e=1-i;return e*e*t}function Ty(i,t){return 2*(1-i)*i*t}function Ay(i,t){return i*i*t}function Kr(i,t,e,n){return Ey(i,t)+Ty(i,e)+Ay(i,n)}function Cy(i,t){const e=1-i;return e*e*e*t}function Ry(i,t){const e=1-i;return 3*e*e*i*t}function Py(i,t){return 3*(1-i)*i*i*t}function Ly(i,t){return i*i*i*t}function Zr(i,t,e,n,s){return Cy(i,t)+Ry(i,e)+Py(i,n)+Ly(i,s)}class qf extends mi{constructor(t=new at,e=new at,n=new at,s=new at){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=s}getPoint(t,e=new at){const n=e,s=this.v0,r=this.v1,a=this.v2,o=this.v3;return n.set(Zr(t,s.x,r.x,a.x,o.x),Zr(t,s.y,r.y,a.y,o.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class Dy extends mi{constructor(t=new R,e=new R,n=new R,s=new R){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=s}getPoint(t,e=new R){const n=e,s=this.v0,r=this.v1,a=this.v2,o=this.v3;return n.set(Zr(t,s.x,r.x,a.x,o.x),Zr(t,s.y,r.y,a.y,o.y),Zr(t,s.z,r.z,a.z,o.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class Yf extends mi{constructor(t=new at,e=new at){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new at){const n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new at){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Iy extends mi{constructor(t=new R,e=new R){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new R){const n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new R){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Kf extends mi{constructor(t=new at,e=new at,n=new at){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new at){const n=e,s=this.v0,r=this.v1,a=this.v2;return n.set(Kr(t,s.x,r.x,a.x),Kr(t,s.y,r.y,a.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class ky extends mi{constructor(t=new R,e=new R,n=new R){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new R){const n=e,s=this.v0,r=this.v1,a=this.v2;return n.set(Kr(t,s.x,r.x,a.x),Kr(t,s.y,r.y,a.y),Kr(t,s.z,r.z,a.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Zf extends mi{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new at){const n=e,s=this.points,r=(s.length-1)*t,a=Math.floor(r),o=r-a,l=s[a===0?a:a-1],c=s[a],h=s[a>s.length-2?s.length-1:a+1],u=s[a>s.length-3?s.length-1:a+2];return n.set(sd(o,l.x,c.x,h.x,u.x),sd(o,l.y,c.y,h.y,u.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const s=t.points[e];this.points.push(s.clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const s=this.points[e];t.points.push(s.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const s=t.points[e];this.points.push(new at().fromArray(s))}return this}}var rd=Object.freeze({__proto__:null,ArcCurve:Sy,CatmullRomCurve3:wy,CubicBezierCurve:qf,CubicBezierCurve3:Dy,EllipseCurve:Th,LineCurve:Yf,LineCurve3:Iy,QuadraticBezierCurve:Kf,QuadraticBezierCurve3:ky,SplineCurve:Zf});class Ny extends mi{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);if(!t.equals(e)){const n=t.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new rd[n](e,t))}return this}getPoint(t,e){const n=t*this.getLength(),s=this.getCurveLengths();let r=0;for(;r<s.length;){if(s[r]>=n){const a=s[r]-n,o=this.curves[r],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,e)}r++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let n=0,s=this.curves.length;n<s;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[];let n;for(let s=0,r=this.curves;s<r.length;s++){const a=r[s],o=a.isEllipseCurve?t*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?t*a.points.length:t,l=a.getPoints(o);for(let c=0;c<l.length;c++){const h=l[c];n&&n.equals(h)||(e.push(h),n=h)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const s=t.curves[e];this.curves.push(s.clone())}return this.autoClose=t.autoClose,this}toJSON(){const t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){const s=this.curves[e];t.curves.push(s.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const s=t.curves[e];this.curves.push(new rd[s.type]().fromJSON(s))}return this}}class Uy extends Ny{constructor(t){super(),this.type="Path",this.currentPoint=new at,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){const n=new Yf(this.currentPoint.clone(),new at(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,s){const r=new Kf(this.currentPoint.clone(),new at(t,e),new at(n,s));return this.curves.push(r),this.currentPoint.set(n,s),this}bezierCurveTo(t,e,n,s,r,a){const o=new qf(this.currentPoint.clone(),new at(t,e),new at(n,s),new at(r,a));return this.curves.push(o),this.currentPoint.set(r,a),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),n=new Zf(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,s,r,a){const o=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+o,e+l,n,s,r,a),this}absarc(t,e,n,s,r,a){return this.absellipse(t,e,n,n,s,r,a),this}ellipse(t,e,n,s,r,a,o,l){const c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(t+c,e+h,n,s,r,a,o,l),this}absellipse(t,e,n,s,r,a,o,l){const c=new Th(t,e,n,s,r,a,o,l);if(this.curves.length>0){const u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);const h=c.getPoint(1);return this.currentPoint.copy(h),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class Oo extends dn{constructor(t=[new at(0,-.5),new at(.5,0),new at(0,.5)],e=12,n=0,s=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:s},e=Math.floor(e),s=Fe(s,0,Math.PI*2);const r=[],a=[],o=[],l=[],c=[],h=1/e,u=new R,d=new at,f=new R,g=new R,_=new R;let m=0,p=0;for(let y=0;y<=t.length-1;y++)switch(y){case 0:m=t[y+1].x-t[y].x,p=t[y+1].y-t[y].y,f.x=p*1,f.y=-m,f.z=p*0,_.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(_.x,_.y,_.z);break;default:m=t[y+1].x-t[y].x,p=t[y+1].y-t[y].y,f.x=p*1,f.y=-m,f.z=p*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<=e;y++){const x=n+y*h*s,S=Math.sin(x),L=Math.cos(x);for(let T=0;T<=t.length-1;T++){u.x=t[T].x*S,u.y=t[T].y,u.z=t[T].x*L,a.push(u.x,u.y,u.z),d.x=y/e,d.y=T/(t.length-1),o.push(d.x,d.y);const E=l[3*T+0]*S,P=l[3*T+1],U=l[3*T+0]*L;c.push(E,P,U)}}for(let y=0;y<e;y++)for(let x=0;x<t.length-1;x++){const S=x+y*t.length,L=S,T=S+t.length,E=S+t.length+1,P=S+1;r.push(L,T,P),r.push(E,P,T)}this.setIndex(r),this.setAttribute("position",new he(a,3)),this.setAttribute("uv",new he(o,2)),this.setAttribute("normal",new he(c,3))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Oo(t.points,t.segments,t.phiStart,t.phiLength)}}class Ch extends Oo{constructor(t=1,e=1,n=4,s=8){const r=new Uy;r.absarc(0,-e/2,t,Math.PI*1.5,0),r.absarc(0,e/2,t,0,Math.PI*.5),super(r.getPoints(n),s),this.type="CapsuleGeometry",this.parameters={radius:t,length:e,capSegments:n,radialSegments:s}}static fromJSON(t){return new Ch(t.radius,t.length,t.capSegments,t.radialSegments)}}class Ui extends dn{constructor(t=1,e=32,n=0,s=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:s},e=Math.max(3,e);const r=[],a=[],o=[],l=[],c=new R,h=new at;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let u=0,d=3;u<=e;u++,d+=3){const f=n+u/e*s;c.x=t*Math.cos(f),c.y=t*Math.sin(f),a.push(c.x,c.y,c.z),o.push(0,0,1),h.x=(a[d]/t+1)/2,h.y=(a[d+1]/t+1)/2,l.push(h.x,h.y)}for(let u=1;u<=e;u++)r.push(u,u+1,0);this.setIndex(r),this.setAttribute("position",new he(a,3)),this.setAttribute("normal",new he(o,3)),this.setAttribute("uv",new he(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ui(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class Fn extends dn{constructor(t=1,e=1,n=1,s=32,r=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:s,heightSegments:r,openEnded:a,thetaStart:o,thetaLength:l};const c=this;s=Math.floor(s),r=Math.floor(r);const h=[],u=[],d=[],f=[];let g=0;const _=[],m=n/2;let p=0;y(),a===!1&&(t>0&&x(!0),e>0&&x(!1)),this.setIndex(h),this.setAttribute("position",new he(u,3)),this.setAttribute("normal",new he(d,3)),this.setAttribute("uv",new he(f,2));function y(){const S=new R,L=new R;let T=0;const E=(e-t)/n;for(let P=0;P<=r;P++){const U=[],v=P/r,b=v*(e-t)+t;for(let I=0;I<=s;I++){const O=I/s,$=O*l+o,K=Math.sin($),z=Math.cos($);L.x=b*K,L.y=-v*n+m,L.z=b*z,u.push(L.x,L.y,L.z),S.set(K,E,z).normalize(),d.push(S.x,S.y,S.z),f.push(O,1-v),U.push(g++)}_.push(U)}for(let P=0;P<s;P++)for(let U=0;U<r;U++){const v=_[U][P],b=_[U+1][P],I=_[U+1][P+1],O=_[U][P+1];t>0&&(h.push(v,b,O),T+=3),e>0&&(h.push(b,I,O),T+=3)}c.addGroup(p,T,0),p+=T}function x(S){const L=g,T=new at,E=new R;let P=0;const U=S===!0?t:e,v=S===!0?1:-1;for(let I=1;I<=s;I++)u.push(0,m*v,0),d.push(0,v,0),f.push(.5,.5),g++;const b=g;for(let I=0;I<=s;I++){const $=I/s*l+o,K=Math.cos($),z=Math.sin($);E.x=U*z,E.y=m*v,E.z=U*K,u.push(E.x,E.y,E.z),d.push(0,v,0),T.x=K*.5+.5,T.y=z*.5*v+.5,f.push(T.x,T.y),g++}for(let I=0;I<s;I++){const O=L+I,$=b+I;S===!0?h.push($,$+1,O):h.push($+1,$,O),P+=3}c.addGroup(p,P,S===!0?1:2),p+=P}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Fn(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class la extends Fn{constructor(t=1,e=1,n=32,s=1,r=!1,a=0,o=Math.PI*2){super(0,t,e,n,s,r,a,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:s,openEnded:r,thetaStart:a,thetaLength:o}}static fromJSON(t){return new la(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Rh extends dn{constructor(t=[],e=[],n=1,s=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:s};const r=[],a=[];o(s),c(n),h(),this.setAttribute("position",new he(r,3)),this.setAttribute("normal",new he(r.slice(),3)),this.setAttribute("uv",new he(a,2)),s===0?this.computeVertexNormals():this.normalizeNormals();function o(y){const x=new R,S=new R,L=new R;for(let T=0;T<e.length;T+=3)f(e[T+0],x),f(e[T+1],S),f(e[T+2],L),l(x,S,L,y)}function l(y,x,S,L){const T=L+1,E=[];for(let P=0;P<=T;P++){E[P]=[];const U=y.clone().lerp(S,P/T),v=x.clone().lerp(S,P/T),b=T-P;for(let I=0;I<=b;I++)I===0&&P===T?E[P][I]=U:E[P][I]=U.clone().lerp(v,I/b)}for(let P=0;P<T;P++)for(let U=0;U<2*(T-P)-1;U++){const v=Math.floor(U/2);U%2===0?(d(E[P][v+1]),d(E[P+1][v]),d(E[P][v])):(d(E[P][v+1]),d(E[P+1][v+1]),d(E[P+1][v]))}}function c(y){const x=new R;for(let S=0;S<r.length;S+=3)x.x=r[S+0],x.y=r[S+1],x.z=r[S+2],x.normalize().multiplyScalar(y),r[S+0]=x.x,r[S+1]=x.y,r[S+2]=x.z}function h(){const y=new R;for(let x=0;x<r.length;x+=3){y.x=r[x+0],y.y=r[x+1],y.z=r[x+2];const S=m(y)/2/Math.PI+.5,L=p(y)/Math.PI+.5;a.push(S,1-L)}g(),u()}function u(){for(let y=0;y<a.length;y+=6){const x=a[y+0],S=a[y+2],L=a[y+4],T=Math.max(x,S,L),E=Math.min(x,S,L);T>.9&&E<.1&&(x<.2&&(a[y+0]+=1),S<.2&&(a[y+2]+=1),L<.2&&(a[y+4]+=1))}}function d(y){r.push(y.x,y.y,y.z)}function f(y,x){const S=y*3;x.x=t[S+0],x.y=t[S+1],x.z=t[S+2]}function g(){const y=new R,x=new R,S=new R,L=new R,T=new at,E=new at,P=new at;for(let U=0,v=0;U<r.length;U+=9,v+=6){y.set(r[U+0],r[U+1],r[U+2]),x.set(r[U+3],r[U+4],r[U+5]),S.set(r[U+6],r[U+7],r[U+8]),T.set(a[v+0],a[v+1]),E.set(a[v+2],a[v+3]),P.set(a[v+4],a[v+5]),L.copy(y).add(x).add(S).divideScalar(3);const b=m(L);_(T,v+0,y,b),_(E,v+2,x,b),_(P,v+4,S,b)}}function _(y,x,S,L){L<0&&y.x===1&&(a[x]=y.x-1),S.x===0&&S.z===0&&(a[x]=L/2/Math.PI+.5)}function m(y){return Math.atan2(y.z,-y.x)}function p(y){return Math.atan2(-y.y,Math.sqrt(y.x*y.x+y.z*y.z))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Rh(t.vertices,t.indices,t.radius,t.details)}}class Sr extends Rh{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2,s=[-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(s,r,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Sr(t.radius,t.detail)}}class Ph extends dn{constructor(t=.5,e=1,n=32,s=1,r=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:n,phiSegments:s,thetaStart:r,thetaLength:a},n=Math.max(3,n),s=Math.max(1,s);const o=[],l=[],c=[],h=[];let u=t;const d=(e-t)/s,f=new R,g=new at;for(let _=0;_<=s;_++){for(let m=0;m<=n;m++){const p=r+m/n*a;f.x=u*Math.cos(p),f.y=u*Math.sin(p),l.push(f.x,f.y,f.z),c.push(0,0,1),g.x=(f.x/e+1)/2,g.y=(f.y/e+1)/2,h.push(g.x,g.y)}u+=d}for(let _=0;_<s;_++){const m=_*(n+1);for(let p=0;p<n;p++){const y=p+m,x=y,S=y+n+1,L=y+n+2,T=y+1;o.push(x,S,T),o.push(S,L,T)}}this.setIndex(o),this.setAttribute("position",new he(l,3)),this.setAttribute("normal",new he(c,3)),this.setAttribute("uv",new he(h,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ph(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}}class hi extends dn{constructor(t=1,e=32,n=16,s=0,r=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:s,phiLength:r,thetaStart:a,thetaLength:o},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const l=Math.min(a+o,Math.PI);let c=0;const h=[],u=new R,d=new R,f=[],g=[],_=[],m=[];for(let p=0;p<=n;p++){const y=[],x=p/n;let S=0;p===0&&a===0?S=.5/e:p===n&&l===Math.PI&&(S=-.5/e);for(let L=0;L<=e;L++){const T=L/e;u.x=-t*Math.cos(s+T*r)*Math.sin(a+x*o),u.y=t*Math.cos(a+x*o),u.z=t*Math.sin(s+T*r)*Math.sin(a+x*o),g.push(u.x,u.y,u.z),d.copy(u).normalize(),_.push(d.x,d.y,d.z),m.push(T+S,1-x),y.push(c++)}h.push(y)}for(let p=0;p<n;p++)for(let y=0;y<e;y++){const x=h[p][y+1],S=h[p][y],L=h[p+1][y],T=h[p+1][y+1];(p!==0||a>0)&&f.push(x,S,T),(p!==n-1||l<Math.PI)&&f.push(S,L,T)}this.setIndex(f),this.setAttribute("position",new he(g,3)),this.setAttribute("normal",new he(_,3)),this.setAttribute("uv",new he(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new hi(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class ri extends dn{constructor(t=1,e=.4,n=12,s=48,r=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:n,tubularSegments:s,arc:r},n=Math.floor(n),s=Math.floor(s);const a=[],o=[],l=[],c=[],h=new R,u=new R,d=new R;for(let f=0;f<=n;f++)for(let g=0;g<=s;g++){const _=g/s*r,m=f/n*Math.PI*2;u.x=(t+e*Math.cos(m))*Math.cos(_),u.y=(t+e*Math.cos(m))*Math.sin(_),u.z=e*Math.sin(m),o.push(u.x,u.y,u.z),h.x=t*Math.cos(_),h.y=t*Math.sin(_),d.subVectors(u,h).normalize(),l.push(d.x,d.y,d.z),c.push(g/s),c.push(f/n)}for(let f=1;f<=n;f++)for(let g=1;g<=s;g++){const _=(s+1)*f+g-1,m=(s+1)*(f-1)+g-1,p=(s+1)*(f-1)+g,y=(s+1)*f+g;a.push(_,m,y),a.push(m,p,y)}this.setIndex(a),this.setAttribute("position",new he(o,3)),this.setAttribute("normal",new he(l,3)),this.setAttribute("uv",new he(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ri(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class Oy extends Oi{constructor(t){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Zt(0),this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.fog=t.fog,this}}class Fy extends en{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class zn extends Oi{constructor(t){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Zt(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 Zt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=gh,this.normalScale=new at(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 fi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class zy extends Oi{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=gh,this.normalScale=new at(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class Lh extends Je{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Zt(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(e.object.target=this.target.uuid),e}}class By extends Lh{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Je.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Zt(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}}const Ll=new fe,ad=new R,od=new R;class Jf{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new at(512,512),this.map=null,this.mapPass=null,this.matrix=new fe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new bh,this._frameExtents=new at(1,1),this._viewportCount=1,this._viewports=[new me(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;ad.setFromMatrixPosition(t.matrixWorld),e.position.copy(ad),od.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(od),e.updateMatrixWorld(),Ll.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ll),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Ll)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const t={};return this.intensity!==1&&(t.intensity=this.intensity),this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}const ld=new fe,kr=new R,Dl=new R;class Hy extends Jf{constructor(){super(new An(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new at(4,2),this._viewportCount=6,this._viewports=[new me(2,1,1,1),new me(0,1,1,1),new me(3,1,1,1),new me(1,1,1,1),new me(3,0,1,1),new me(1,0,1,1)],this._cubeDirections=[new R(1,0,0),new R(-1,0,0),new R(0,0,1),new R(0,0,-1),new R(0,1,0),new R(0,-1,0)],this._cubeUps=[new R(0,1,0),new R(0,1,0),new R(0,1,0),new R(0,1,0),new R(0,0,1),new R(0,0,-1)]}updateMatrices(t,e=0){const n=this.camera,s=this.matrix,r=t.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),kr.setFromMatrixPosition(t.matrixWorld),n.position.copy(kr),Dl.copy(n.position),Dl.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(Dl),n.updateMatrixWorld(),s.makeTranslation(-kr.x,-kr.y,-kr.z),ld.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ld)}}class Vy extends Lh{constructor(t,e,n=0,s=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=s,this.shadow=new Hy}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}class Gy extends Jf{constructor(){super(new Sh(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class $y extends Lh{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Je.DEFAULT_UP),this.updateMatrix(),this.target=new Je,this.shadow=new Gy}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class Qf{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=cd(),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 t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=cd();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function cd(){return performance.now()}const hd=new fe;class tp{constructor(t,e,n=0,s=1/0){this.ray=new yh(t,e),this.near=n,this.far=s,this.camera=null,this.layers=new Mh,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return hd.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(hd),this}intersectObject(t,e=!0,n=[]){return jc(t,this,n,e),n.sort(ud),n}intersectObjects(t,e=!0,n=[]){for(let s=0,r=t.length;s<r;s++)jc(t[s],this,n,e);return n.sort(ud),n}}function ud(i,t){return i.distance-t.distance}function jc(i,t,e,n){let s=!0;if(i.layers.test(t.layers)&&i.raycast(t,e)===!1&&(s=!1),s===!0&&n===!0){const r=i.children;for(let a=0,o=r.length;a<o;a++)jc(r[a],t,e,!0)}}class wr{constructor(t=1,e=0,n=0){return this.radius=t,this.phi=e,this.theta=n,this}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(Fe(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class Wy extends Ts{constructor(t,e=null){super(),this.object=t,this.domElement=e,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(){}disconnect(){}dispose(){}update(){}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:lh}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=lh);const dd={type:"change"},Dh={type:"start"},ep={type:"end"},Na=new yh,fd=new qi,Xy=Math.cos(70*tr.DEG2RAD),Ue=new R,mn=2*Math.PI,pe={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Il=1e-6;class jy extends Wy{constructor(t,e=null){super(t,e),this.state=pe.NONE,this.enabled=!0,this.target=new R,this.cursor=new R,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:Li.ROTATE,MIDDLE:Li.DOLLY,RIGHT:Li.PAN},this.touches={ONE:es.ROTATE,TWO:es.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new R,this._lastQuaternion=new as,this._lastTargetPosition=new R,this._quat=new as().setFromUnitVectors(t.up,new R(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new wr,this._sphericalDelta=new wr,this._scale=1,this._panOffset=new R,this._rotateStart=new at,this._rotateEnd=new at,this._rotateDelta=new at,this._panStart=new at,this._panEnd=new at,this._panDelta=new at,this._dollyStart=new at,this._dollyEnd=new at,this._dollyDelta=new at,this._dollyDirection=new R,this._mouse=new at,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Yy.bind(this),this._onPointerDown=qy.bind(this),this._onPointerUp=Ky.bind(this),this._onContextMenu=iM.bind(this),this._onMouseWheel=Qy.bind(this),this._onKeyDown=tM.bind(this),this._onTouchStart=eM.bind(this),this._onTouchMove=nM.bind(this),this._onMouseDown=Zy.bind(this),this._onMouseMove=Jy.bind(this),this._interceptControlDown=sM.bind(this),this._interceptControlUp=rM.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(t){t.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=t}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(dd),this.update(),this.state=pe.NONE}update(t=null){const e=this.object.position;Ue.copy(e).sub(this.target),Ue.applyQuaternion(this._quat),this._spherical.setFromVector3(Ue),this.autoRotate&&this.state===pe.NONE&&this._rotateLeft(this._getAutoRotationAngle(t)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(n)&&isFinite(s)&&(n<-Math.PI?n+=mn:n>Math.PI&&(n-=mn),s<-Math.PI?s+=mn:s>Math.PI&&(s-=mn),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(Ue.setFromSpherical(this._spherical),Ue.applyQuaternion(this._quatInverse),e.copy(this.target).add(Ue),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=Ue.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const o=new R(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new R(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=Ue.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Na.origin.copy(this.object.position),Na.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Na.direction))<Xy?this.object.lookAt(this.target):(fd.setFromNormalAndCoplanarPoint(this.object.up,this.target),Na.intersectPlane(fd,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>Il||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Il||this._lastTargetPosition.distanceToSquared(this.target)>Il?(this.dispatchEvent(dd),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(t){return t!==null?mn/60*this.autoRotateSpeed*t:mn/60/60*this.autoRotateSpeed}_getZoomScale(t){const e=Math.abs(t*.01);return Math.pow(.95,this.zoomSpeed*e)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,e){Ue.setFromMatrixColumn(e,0),Ue.multiplyScalar(-t),this._panOffset.add(Ue)}_panUp(t,e){this.screenSpacePanning===!0?Ue.setFromMatrixColumn(e,1):(Ue.setFromMatrixColumn(e,0),Ue.crossVectors(this.object.up,Ue)),Ue.multiplyScalar(t),this._panOffset.add(Ue)}_pan(t,e){const n=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;Ue.copy(s).sub(this.target);let r=Ue.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*r/n.clientHeight,this.object.matrix),this._panUp(2*e*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(t,e){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),s=t-n.left,r=e-n.top,a=n.width,o=n.height;this._mouse.x=s/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(mn*this._rotateDelta.x/e.clientHeight),this._rotateUp(mn*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(t){this._panEnd.set(t.clientX,t.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let e=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateUp(mn*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateUp(-mn*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateLeft(mn*this.rotateSpeed/this.domElement.clientHeight):this._pan(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateLeft(-mn*this.rotateSpeed/this.domElement.clientHeight):this._pan(-this.keyPanSpeed,0),e=!0;break}e&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(this._pointers.length===1)this._rotateStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(t){if(this._pointers.length===1)this._panStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._panStart.set(n,s)}}_handleTouchStartDolly(t){const e=this._getSecondPointerPosition(t),n=t.pageX-e.x,s=t.pageY-e.y,r=Math.sqrt(n*n+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(this._pointers.length==1)this._rotateEnd.set(t.pageX,t.pageY);else{const n=this._getSecondPointerPosition(t),s=.5*(t.pageX+n.x),r=.5*(t.pageY+n.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(mn*this._rotateDelta.x/e.clientHeight),this._rotateUp(mn*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(this._pointers.length===1)this._panEnd.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(t){const e=this._getSecondPointerPosition(t),n=t.pageX-e.x,s=t.pageY-e.y,r=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(t.pageX+e.x)*.5,o=(t.pageY+e.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId){this._pointers.splice(e,1);return}}_isTrackingPointer(t){for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId)return!0;return!1}_trackPointer(t){let e=this._pointerPositions[t.pointerId];e===void 0&&(e=new at,this._pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}_getSecondPointerPosition(t){const e=t.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[e]}_customWheelEvent(t){const e=t.deltaMode,n={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(e){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return t.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function qy(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i)))}function Yy(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function Ky(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(ep),this.state=pe.NONE;break;case 1:const t=this._pointers[0],e=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:e.x,pageY:e.y});break}}function Zy(i){let t;switch(i.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case Li.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=pe.DOLLY;break;case Li.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=pe.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=pe.ROTATE}break;case Li.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=pe.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=pe.PAN}break;default:this.state=pe.NONE}this.state!==pe.NONE&&this.dispatchEvent(Dh)}function Jy(i){switch(this.state){case pe.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case pe.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case pe.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function Qy(i){this.enabled===!1||this.enableZoom===!1||this.state!==pe.NONE||(i.preventDefault(),this.dispatchEvent(Dh),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(ep))}function tM(i){this.enabled===!1||this.enablePan===!1||this._handleKeyDown(i)}function eM(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case es.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=pe.TOUCH_ROTATE;break;case es.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=pe.TOUCH_PAN;break;default:this.state=pe.NONE}break;case 2:switch(this.touches.TWO){case es.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=pe.TOUCH_DOLLY_PAN;break;case es.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=pe.TOUCH_DOLLY_ROTATE;break;default:this.state=pe.NONE}break;default:this.state=pe.NONE}this.state!==pe.NONE&&this.dispatchEvent(Dh)}function nM(i){switch(this._trackPointer(i),this.state){case pe.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case pe.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case pe.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case pe.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=pe.NONE}}function iM(i){this.enabled!==!1&&i.preventDefault()}function sM(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function rM(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class aM extends jy{constructor(t,e){super(t,e),this.screenSpacePanning=!1,this.mouseButtons={LEFT:Li.PAN,MIDDLE:Li.DOLLY,RIGHT:Li.ROTATE},this.touches={ONE:es.PAN,TWO:es.DOLLY_ROTATE}}}class oM extends Xf{constructor(){super();const t=new Ke;t.deleteAttribute("uv");const e=new zn({side:hn}),n=new zn,s=new Vy(16777215,900,28,2);s.position.set(.418,16.199,.3),this.add(s);const r=new yt(t,e);r.position.set(-.757,13.219,.717),r.scale.set(31.713,28.305,28.591),this.add(r);const a=new yt(t,n);a.position.set(-10.906,2.009,1.846),a.rotation.set(0,-.195,0),a.scale.set(2.328,7.905,4.651),this.add(a);const o=new yt(t,n);o.position.set(-5.607,-.754,-.758),o.rotation.set(0,.994,0),o.scale.set(1.97,1.534,3.955),this.add(o);const l=new yt(t,n);l.position.set(6.167,.857,7.803),l.rotation.set(0,.561,0),l.scale.set(3.927,6.285,3.687),this.add(l);const c=new yt(t,n);c.position.set(-2.017,.018,6.124),c.rotation.set(0,.333,0),c.scale.set(2.002,4.566,2.064),this.add(c);const h=new yt(t,n);h.position.set(2.291,-.756,-2.621),h.rotation.set(0,-.286,0),h.scale.set(1.546,1.552,1.496),this.add(h);const u=new yt(t,n);u.position.set(-2.193,-.369,-5.547),u.rotation.set(0,.516,0),u.scale.set(3.875,3.487,2.986),this.add(u);const d=new yt(t,Xs(50));d.position.set(-16.116,14.37,8.208),d.scale.set(.1,2.428,2.739),this.add(d);const f=new yt(t,Xs(50));f.position.set(-16.109,18.021,-8.207),f.scale.set(.1,2.425,2.751),this.add(f);const g=new yt(t,Xs(17));g.position.set(14.904,12.198,-1.832),g.scale.set(.15,4.265,6.331),this.add(g);const _=new yt(t,Xs(43));_.position.set(-.462,8.89,14.52),_.scale.set(4.38,5.441,.088),this.add(_);const m=new yt(t,Xs(20));m.position.set(3.235,11.486,-12.541),m.scale.set(2.5,2,.1),this.add(m);const p=new yt(t,Xs(100));p.position.set(0,20,0),p.scale.set(1,.1,1),this.add(p)}dispose(){const t=new Set;this.traverse(e=>{e.isMesh&&(t.add(e.geometry),t.add(e.material))});for(const e of t)e.dispose()}}function Xs(i){const t=new un;return t.color.setScalar(i),t}const oo={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
|
|
3841
3840
|
|
|
3842
3841
|
varying vec2 vUv;
|
|
3843
3842
|
|
|
@@ -3860,7 +3859,7 @@ void main() {
|
|
|
3860
3859
|
gl_FragColor = opacity * texel;
|
|
3861
3860
|
|
|
3862
3861
|
|
|
3863
|
-
}`};class Cr{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const
|
|
3862
|
+
}`};class Cr{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const lM=new Sh(-1,1,1,-1,0,1);class cM extends dn{constructor(){super(),this.setAttribute("position",new he([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new he([0,2,0,0,2,0],2))}}const hM=new cM;class Ih{constructor(t){this._mesh=new yt(hM,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,lM)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}}class uM extends Cr{constructor(t,e){super(),this.textureID=e!==void 0?e:"tDiffuse",t instanceof en?(this.uniforms=t.uniforms,this.material=t):t&&(this.uniforms=Zi.clone(t.uniforms),this.material=new en({name:t.name!==void 0?t.name:"unspecified",defines:Object.assign({},t.defines),uniforms:this.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader})),this.fsQuad=new Ih(this.material)}render(t,e,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this.fsQuad.material=this.material,this.renderToScreen?(t.setRenderTarget(null),this.fsQuad.render(t)):(t.setRenderTarget(e),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),this.fsQuad.render(t))}dispose(){this.material.dispose(),this.fsQuad.dispose()}}class pd extends Cr{constructor(t,e){super(),this.scene=t,this.camera=e,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(t,e,n){const s=t.getContext(),r=t.state;r.buffers.color.setMask(!1),r.buffers.depth.setMask(!1),r.buffers.color.setLocked(!0),r.buffers.depth.setLocked(!0);let a,o;this.inverse?(a=0,o=1):(a=1,o=0),r.buffers.stencil.setTest(!0),r.buffers.stencil.setOp(s.REPLACE,s.REPLACE,s.REPLACE),r.buffers.stencil.setFunc(s.ALWAYS,a,4294967295),r.buffers.stencil.setClear(o),r.buffers.stencil.setLocked(!0),t.setRenderTarget(n),this.clear&&t.clear(),t.render(this.scene,this.camera),t.setRenderTarget(e),this.clear&&t.clear(),t.render(this.scene,this.camera),r.buffers.color.setLocked(!1),r.buffers.depth.setLocked(!1),r.buffers.color.setMask(!0),r.buffers.depth.setMask(!0),r.buffers.stencil.setLocked(!1),r.buffers.stencil.setFunc(s.EQUAL,1,4294967295),r.buffers.stencil.setOp(s.KEEP,s.KEEP,s.KEEP),r.buffers.stencil.setLocked(!0)}}class dM extends Cr{constructor(){super(),this.needsSwap=!1}render(t){t.state.buffers.stencil.setLocked(!1),t.state.buffers.stencil.setTest(!1)}}class fM{constructor(t,e){if(this.renderer=t,this._pixelRatio=t.getPixelRatio(),e===void 0){const n=t.getSize(new at);this._width=n.width,this._height=n.height,e=new Jn(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Ni}),e.texture.name="EffectComposer.rt1"}else this._width=e.width,this._height=e.height;this.renderTarget1=e,this.renderTarget2=e.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new uM(oo),this.copyPass.material.blending=qe,this.clock=new Qf}swapBuffers(){const t=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=t}addPass(t){this.passes.push(t),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(t,e){this.passes.splice(e,0,t),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(t){const e=this.passes.indexOf(t);e!==-1&&this.passes.splice(e,1)}isLastEnabledPass(t){for(let e=t+1;e<this.passes.length;e++)if(this.passes[e].enabled)return!1;return!0}render(t){t===void 0&&(t=this.clock.getDelta());const e=this.renderer.getRenderTarget();let n=!1;for(let s=0,r=this.passes.length;s<r;s++){const a=this.passes[s];if(a.enabled!==!1){if(a.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(s),a.render(this.renderer,this.writeBuffer,this.readBuffer,t,n),a.needsSwap){if(n){const o=this.renderer.getContext(),l=this.renderer.state.buffers.stencil;l.setFunc(o.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,t),l.setFunc(o.EQUAL,1,4294967295)}this.swapBuffers()}pd!==void 0&&(a instanceof pd?n=!0:a instanceof dM&&(n=!1))}}this.renderer.setRenderTarget(e)}reset(t){if(t===void 0){const e=this.renderer.getSize(new at);this._pixelRatio=this.renderer.getPixelRatio(),this._width=e.width,this._height=e.height,t=this.renderTarget1.clone(),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=t,this.renderTarget2=t.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(t,e){this._width=t,this._height=e;const n=this._width*this._pixelRatio,s=this._height*this._pixelRatio;this.renderTarget1.setSize(n,s),this.renderTarget2.setSize(n,s);for(let r=0;r<this.passes.length;r++)this.passes[r].setSize(n,s)}setPixelRatio(t){this._pixelRatio=t,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}}class pM extends Cr{constructor(t,e,n=null,s=null,r=null){super(),this.scene=t,this.camera=e,this.overrideMaterial=n,this.clearColor=s,this.clearAlpha=r,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new Zt}render(t,e,n){const s=t.autoClear;t.autoClear=!1;let r,a;this.overrideMaterial!==null&&(a=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(t.getClearColor(this._oldClearColor),t.setClearColor(this.clearColor,t.getClearAlpha())),this.clearAlpha!==null&&(r=t.getClearAlpha(),t.setClearAlpha(this.clearAlpha)),this.clearDepth==!0&&t.clearDepth(),t.setRenderTarget(this.renderToScreen?null:n),this.clear===!0&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),t.render(this.scene,this.camera),this.clearColor!==null&&t.setClearColor(this._oldClearColor),this.clearAlpha!==null&&t.setClearAlpha(r),this.overrideMaterial!==null&&(this.scene.overrideMaterial=a),t.autoClear=s}}const Ua={defines:{PERSPECTIVE_CAMERA:1,SAMPLES:16,NORMAL_VECTOR_TYPE:1,DEPTH_SWIZZLING:"x",SCREEN_SPACE_RADIUS:0,SCREEN_SPACE_RADIUS_SCALE:100,SCENE_CLIP_BOX:0},uniforms:{tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new at},cameraNear:{value:null},cameraFar:{value:null},cameraProjectionMatrix:{value:new fe},cameraProjectionMatrixInverse:{value:new fe},cameraWorldMatrix:{value:new fe},radius:{value:.25},distanceExponent:{value:1},thickness:{value:1},distanceFallOff:{value:1},scale:{value:1},sceneBoxMin:{value:new R(-1,-1,-1)},sceneBoxMax:{value:new R(1,1,1)}},vertexShader:`
|
|
3864
3863
|
|
|
3865
3864
|
varying vec2 vUv;
|
|
3866
3865
|
|
|
@@ -4043,7 +4042,7 @@ void main() {
|
|
|
4043
4042
|
ao = pow(ao, scale);
|
|
4044
4043
|
|
|
4045
4044
|
gl_FragColor = FRAGMENT_OUTPUT;
|
|
4046
|
-
}`},
|
|
4045
|
+
}`},Oa={defines:{PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},vertexShader:`
|
|
4047
4046
|
varying vec2 vUv;
|
|
4048
4047
|
|
|
4049
4048
|
void main() {
|
|
@@ -4071,7 +4070,7 @@ void main() {
|
|
|
4071
4070
|
float depth = getLinearDepth( vUv );
|
|
4072
4071
|
gl_FragColor = vec4( vec3( 1.0 - depth ), 1.0 );
|
|
4073
4072
|
|
|
4074
|
-
}`},
|
|
4073
|
+
}`},kl={uniforms:{tDiffuse:{value:null},intensity:{value:1}},vertexShader:`
|
|
4075
4074
|
varying vec2 vUv;
|
|
4076
4075
|
|
|
4077
4076
|
void main() {
|
|
@@ -4085,7 +4084,7 @@ void main() {
|
|
|
4085
4084
|
void main() {
|
|
4086
4085
|
vec4 texel = texture2D( tDiffuse, vUv );
|
|
4087
4086
|
gl_FragColor = vec4(mix(vec3(1.), texel.rgb, intensity), texel.a);
|
|
4088
|
-
}`};function
|
|
4087
|
+
}`};function mM(i=5){const t=Math.floor(i)%2===0?Math.floor(i)+1:Math.floor(i),e=gM(t),n=e.length,s=new Uint8Array(n*4);for(let a=0;a<n;++a){const o=e[a],l=2*Math.PI*o/n,c=new R(Math.cos(l),Math.sin(l),0).normalize();s[a*4]=(c.x*.5+.5)*255,s[a*4+1]=(c.y*.5+.5)*255,s[a*4+2]=127,s[a*4+3]=255}const r=new jf(s,t,t);return r.wrapS=ki,r.wrapT=ki,r.needsUpdate=!0,r}function gM(i){const t=Math.floor(i)%2===0?Math.floor(i)+1:Math.floor(i),e=t*t,n=Array(e).fill(0);let s=Math.floor(t/2),r=t-1;for(let a=1;a<=e;){if(s===-1&&r===t?(r=t-2,s=0):(r===t&&(r=0),s<0&&(s=t-1)),n[s*t+r]!==0){r-=2,s++;continue}else n[s*t+r]=a++;r++,s--}return n}const Fa={defines:{SAMPLES:16,SAMPLE_VECTORS:np(16,2,1),NORMAL_VECTOR_TYPE:1,DEPTH_VALUE_SOURCE:0},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new at},cameraProjectionMatrixInverse:{value:new fe},lumaPhi:{value:5},depthPhi:{value:5},normalPhi:{value:5},radius:{value:4},index:{value:0}},vertexShader:`
|
|
4089
4088
|
|
|
4090
4089
|
varying vec2 vUv;
|
|
4091
4090
|
|
|
@@ -4230,7 +4229,7 @@ void main() {
|
|
|
4230
4229
|
denoised /= totalWeight;
|
|
4231
4230
|
}
|
|
4232
4231
|
gl_FragColor = FRAGMENT_OUTPUT;
|
|
4233
|
-
}`};function sp(i,t,e){const n=yM(i,t,e);let s="vec3[SAMPLES](";for(let r=0;r<i;r++){const a=n[r];s+=`vec3(${a.x}, ${a.y}, ${a.z})${r<i-1?",":")"}`}return s}function yM(i,t,e){const n=[];for(let s=0;s<i;s++){const r=2*Math.PI*t*s/i,a=Math.pow(s/(i-1),e);n.push(new R(Math.cos(r),Math.sin(r),a))}return n}class MM{constructor(t=Math){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(let e=0;e<256;e++)this.p[e]=Math.floor(t.random()*256);this.perm=[];for(let e=0;e<512;e++)this.perm[e]=this.p[e&255];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]}dot(t,e,n){return t[0]*e+t[1]*n}dot3(t,e,n,s){return t[0]*e+t[1]*n+t[2]*s}dot4(t,e,n,s,r){return t[0]*e+t[1]*n+t[2]*s+t[3]*r}noise(t,e){let n,s,r;const a=.5*(Math.sqrt(3)-1),o=(t+e)*a,l=Math.floor(t+o),c=Math.floor(e+o),h=(3-Math.sqrt(3))/6,u=(l+c)*h,d=l-u,f=c-u,g=t-d,_=e-f;let m,p;g>_?(m=1,p=0):(m=0,p=1);const y=g-m+h,x=_-p+h,S=g-1+2*h,L=_-1+2*h,T=l&255,E=c&255,P=this.perm[T+this.perm[E]]%12,U=this.perm[T+m+this.perm[E+p]]%12,v=this.perm[T+1+this.perm[E+1]]%12;let b=.5-g*g-_*_;b<0?n=0:(b*=b,n=b*b*this.dot(this.grad3[P],g,_));let I=.5-y*y-x*x;I<0?s=0:(I*=I,s=I*I*this.dot(this.grad3[U],y,x));let O=.5-S*S-L*L;return O<0?r=0:(O*=O,r=O*O*this.dot(this.grad3[v],S,L)),70*(n+s+r)}noise3d(t,e,n){let s,r,a,o;const c=(t+e+n)*.3333333333333333,h=Math.floor(t+c),u=Math.floor(e+c),d=Math.floor(n+c),f=1/6,g=(h+u+d)*f,_=h-g,m=u-g,p=d-g,y=t-_,x=e-m,S=n-p;let L,T,E,P,U,v;y>=x?x>=S?(L=1,T=0,E=0,P=1,U=1,v=0):y>=S?(L=1,T=0,E=0,P=1,U=0,v=1):(L=0,T=0,E=1,P=1,U=0,v=1):x<S?(L=0,T=0,E=1,P=0,U=1,v=1):y<S?(L=0,T=1,E=0,P=0,U=1,v=1):(L=0,T=1,E=0,P=1,U=1,v=0);const b=y-L+f,I=x-T+f,O=S-E+f,$=y-P+2*f,K=x-U+2*f,z=S-v+2*f,Z=y-1+3*f,V=x-1+3*f,at=S-1+3*f,ct=h&255,_t=u&255,$t=d&255,Jt=this.perm[ct+this.perm[_t+this.perm[$t]]]%12,X=this.perm[ct+L+this.perm[_t+T+this.perm[$t+E]]]%12,et=this.perm[ct+P+this.perm[_t+U+this.perm[$t+v]]]%12,ft=this.perm[ct+1+this.perm[_t+1+this.perm[$t+1]]]%12;let ot=.6-y*y-x*x-S*S;ot<0?s=0:(ot*=ot,s=ot*ot*this.dot3(this.grad3[Jt],y,x,S));let At=.6-b*b-I*I-O*O;At<0?r=0:(At*=At,r=At*At*this.dot3(this.grad3[X],b,I,O));let Tt=.6-$*$-K*K-z*z;Tt<0?a=0:(Tt*=Tt,a=Tt*Tt*this.dot3(this.grad3[et],$,K,z));let zt=.6-Z*Z-V*V-at*at;return zt<0?o=0:(zt*=zt,o=zt*zt*this.dot3(this.grad3[ft],Z,V,at)),32*(s+r+a+o)}noise4d(t,e,n,s){const r=this.grad4,a=this.simplex,o=this.perm,l=(Math.sqrt(5)-1)/4,c=(5-Math.sqrt(5))/20;let h,u,d,f,g;const _=(t+e+n+s)*l,m=Math.floor(t+_),p=Math.floor(e+_),y=Math.floor(n+_),x=Math.floor(s+_),S=(m+p+y+x)*c,L=m-S,T=p-S,E=y-S,P=x-S,U=t-L,v=e-T,b=n-E,I=s-P,O=U>v?32:0,$=U>b?16:0,K=v>b?8:0,z=U>I?4:0,Z=v>I?2:0,V=b>I?1:0,at=O+$+K+z+Z+V,ct=a[at][0]>=3?1:0,_t=a[at][1]>=3?1:0,$t=a[at][2]>=3?1:0,Jt=a[at][3]>=3?1:0,X=a[at][0]>=2?1:0,et=a[at][1]>=2?1:0,ft=a[at][2]>=2?1:0,ot=a[at][3]>=2?1:0,At=a[at][0]>=1?1:0,Tt=a[at][1]>=1?1:0,zt=a[at][2]>=1?1:0,ie=a[at][3]>=1?1:0,W=U-ct+c,A=v-_t+c,It=b-$t+c,Ct=I-Jt+c,Bt=U-X+2*c,Dt=v-et+2*c,ue=b-ft+2*c,Nt=I-ot+2*c,C=U-At+3*c,M=v-Tt+3*c,F=b-zt+3*c,Y=I-ie+3*c,Q=U-1+4*c,j=v-1+4*c,St=b-1+4*c,ht=I-1+4*c,pt=m&255,Yt=p&255,nt=y&255,mt=x&255,Ut=o[pt+o[Yt+o[nt+o[mt]]]]%32,Ot=o[pt+ct+o[Yt+_t+o[nt+$t+o[mt+Jt]]]]%32,Mt=o[pt+X+o[Yt+et+o[nt+ft+o[mt+ot]]]]%32,Qt=o[pt+At+o[Yt+Tt+o[nt+zt+o[mt+ie]]]]%32,Vt=o[pt+1+o[Yt+1+o[nt+1+o[mt+1]]]]%32;let se=.6-U*U-v*v-b*b-I*I;se<0?h=0:(se*=se,h=se*se*this.dot4(r[Ut],U,v,b,I));let D=.6-W*W-A*A-It*It-Ct*Ct;D<0?u=0:(D*=D,u=D*D*this.dot4(r[Ot],W,A,It,Ct));let dt=.6-Bt*Bt-Dt*Dt-ue*ue-Nt*Nt;dt<0?d=0:(dt*=dt,d=dt*dt*this.dot4(r[Mt],Bt,Dt,ue,Nt));let G=.6-C*C-M*M-F*F-Y*Y;G<0?f=0:(G*=G,f=G*G*this.dot4(r[Qt],C,M,F,Y));let J=.6-Q*Q-j*j-St*St-ht*ht;return J<0?g=0:(J*=J,g=J*J*this.dot4(r[Vt],Q,j,St,ht)),27*(h+u+d+f+g)}}class ri extends Cr{constructor(t,e,n,s,r,a,o){super(),this.width=n!==void 0?n:512,this.height=s!==void 0?s:512,this.clear=!0,this.camera=e,this.scene=t,this.output=0,this._renderGBuffer=!0,this._visibilityCache=new Map,this.blendIntensity=1,this.pdRings=2,this.pdRadiusExponent=2,this.pdSamples=16,this.gtaoNoiseTexture=_M(),this.pdNoiseTexture=this.generateNoise(),this.gtaoRenderTarget=new Qn(this.width,this.height,{type:Ui}),this.pdRenderTarget=this.gtaoRenderTarget.clone(),this.gtaoMaterial=new nn({defines:Object.assign({},Oa.defines),uniforms:Qi.clone(Oa.uniforms),vertexShader:Oa.vertexShader,fragmentShader:Oa.fragmentShader,blending:Ye,depthTest:!1,depthWrite:!1}),this.gtaoMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.gtaoMaterial.uniforms.tNoise.value=this.gtaoNoiseTexture,this.gtaoMaterial.uniforms.resolution.value.set(this.width,this.height),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.normalMaterial=new Vy,this.normalMaterial.blending=Ye,this.pdMaterial=new nn({defines:Object.assign({},za.defines),uniforms:Qi.clone(za.uniforms),vertexShader:za.vertexShader,fragmentShader:za.fragmentShader,depthTest:!1,depthWrite:!1}),this.pdMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.pdMaterial.uniforms.tNoise.value=this.pdNoiseTexture,this.pdMaterial.uniforms.resolution.value.set(this.width,this.height),this.pdMaterial.uniforms.lumaPhi.value=10,this.pdMaterial.uniforms.depthPhi.value=2,this.pdMaterial.uniforms.normalPhi.value=3,this.pdMaterial.uniforms.radius.value=8,this.depthRenderMaterial=new nn({defines:Object.assign({},Fa.defines),uniforms:Qi.clone(Fa.uniforms),vertexShader:Fa.vertexShader,fragmentShader:Fa.fragmentShader,blending:Ye}),this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new nn({uniforms:Qi.clone(co.uniforms),vertexShader:co.vertexShader,fragmentShader:co.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:hc,blendDst:$r,blendEquation:jn,blendSrcAlpha:cc,blendDstAlpha:$r,blendEquationAlpha:jn}),this.blendMaterial=new nn({uniforms:Qi.clone(Ul.uniforms),vertexShader:Ul.vertexShader,fragmentShader:Ul.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blending:mf,blendSrc:hc,blendDst:$r,blendEquation:jn,blendSrcAlpha:cc,blendDstAlpha:$r,blendEquationAlpha:jn}),this.fsQuad=new kh(null),this.originalClearColor=new Zt,this.setGBuffer(r?r.depthTexture:void 0,r?r.normalTexture:void 0),a!==void 0&&this.updateGtaoMaterial(a),o!==void 0&&this.updatePdMaterial(o)}dispose(){this.gtaoNoiseTexture.dispose(),this.pdNoiseTexture.dispose(),this.normalRenderTarget.dispose(),this.gtaoRenderTarget.dispose(),this.pdRenderTarget.dispose(),this.normalMaterial.dispose(),this.pdMaterial.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose(),this.fsQuad.dispose()}get gtaoMap(){return this.pdRenderTarget.texture}setGBuffer(t,e){t!==void 0?(this.depthTexture=t,this.normalTexture=e,this._renderGBuffer=!1):(this.depthTexture=new Th,this.depthTexture.format=Cs,this.depthTexture.type=As,this.normalRenderTarget=new Qn(this.width,this.height,{minFilter:rn,magFilter:rn,type:Ui,depthTexture:this.depthTexture}),this.normalTexture=this.normalRenderTarget.texture,this._renderGBuffer=!0);const n=this.normalTexture?1:0,s=this.depthTexture===this.normalTexture?"w":"x";this.gtaoMaterial.defines.NORMAL_VECTOR_TYPE=n,this.gtaoMaterial.defines.DEPTH_SWIZZLING=s,this.gtaoMaterial.uniforms.tNormal.value=this.normalTexture,this.gtaoMaterial.uniforms.tDepth.value=this.depthTexture,this.pdMaterial.defines.NORMAL_VECTOR_TYPE=n,this.pdMaterial.defines.DEPTH_SWIZZLING=s,this.pdMaterial.uniforms.tNormal.value=this.normalTexture,this.pdMaterial.uniforms.tDepth.value=this.depthTexture,this.depthRenderMaterial.uniforms.tDepth.value=this.normalRenderTarget.depthTexture}setSceneClipBox(t){t?(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX!==1,this.gtaoMaterial.defines.SCENE_CLIP_BOX=1,this.gtaoMaterial.uniforms.sceneBoxMin.value.copy(t.min),this.gtaoMaterial.uniforms.sceneBoxMax.value.copy(t.max)):(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX===0,this.gtaoMaterial.defines.SCENE_CLIP_BOX=0)}updateGtaoMaterial(t){t.radius!==void 0&&(this.gtaoMaterial.uniforms.radius.value=t.radius),t.distanceExponent!==void 0&&(this.gtaoMaterial.uniforms.distanceExponent.value=t.distanceExponent),t.thickness!==void 0&&(this.gtaoMaterial.uniforms.thickness.value=t.thickness),t.distanceFallOff!==void 0&&(this.gtaoMaterial.uniforms.distanceFallOff.value=t.distanceFallOff,this.gtaoMaterial.needsUpdate=!0),t.scale!==void 0&&(this.gtaoMaterial.uniforms.scale.value=t.scale),t.samples!==void 0&&t.samples!==this.gtaoMaterial.defines.SAMPLES&&(this.gtaoMaterial.defines.SAMPLES=t.samples,this.gtaoMaterial.needsUpdate=!0),t.screenSpaceRadius!==void 0&&(t.screenSpaceRadius?1:0)!==this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS&&(this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS=t.screenSpaceRadius?1:0,this.gtaoMaterial.needsUpdate=!0)}updatePdMaterial(t){let e=!1;t.lumaPhi!==void 0&&(this.pdMaterial.uniforms.lumaPhi.value=t.lumaPhi),t.depthPhi!==void 0&&(this.pdMaterial.uniforms.depthPhi.value=t.depthPhi),t.normalPhi!==void 0&&(this.pdMaterial.uniforms.normalPhi.value=t.normalPhi),t.radius!==void 0&&t.radius!==this.radius&&(this.pdMaterial.uniforms.radius.value=t.radius),t.radiusExponent!==void 0&&t.radiusExponent!==this.pdRadiusExponent&&(this.pdRadiusExponent=t.radiusExponent,e=!0),t.rings!==void 0&&t.rings!==this.pdRings&&(this.pdRings=t.rings,e=!0),t.samples!==void 0&&t.samples!==this.pdSamples&&(this.pdSamples=t.samples,e=!0),e&&(this.pdMaterial.defines.SAMPLES=this.pdSamples,this.pdMaterial.defines.SAMPLE_VECTORS=sp(this.pdSamples,this.pdRings,this.pdRadiusExponent),this.pdMaterial.needsUpdate=!0)}render(t,e,n){switch(this._renderGBuffer&&(this.overrideVisibility(),this.renderOverride(t,this.normalMaterial,this.normalRenderTarget,7829503,1),this.restoreVisibility()),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.gtaoMaterial.uniforms.cameraWorldMatrix.value.copy(this.camera.matrixWorld),this.renderPass(t,this.gtaoMaterial,this.gtaoRenderTarget,16777215,1),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.renderPass(t,this.pdMaterial,this.pdRenderTarget,16777215,1),this.output){case ri.OUTPUT.Off:break;case ri.OUTPUT.Diffuse:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=Ye,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;case ri.OUTPUT.AO:this.copyMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.copyMaterial.blending=Ye,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;case ri.OUTPUT.Denoise:this.copyMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.copyMaterial.blending=Ye,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;case ri.OUTPUT.Depth:this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.renderPass(t,this.depthRenderMaterial,this.renderToScreen?null:e);break;case ri.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=Ye,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;case ri.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=Ye,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e),this.blendMaterial.uniforms.intensity.value=this.blendIntensity,this.blendMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.renderPass(t,this.blendMaterial,this.renderToScreen?null:e);break;default:console.warn("THREE.GTAOPass: Unknown output type.")}}renderPass(t,e,n,s,r){t.getClearColor(this.originalClearColor);const a=t.getClearAlpha(),o=t.autoClear;t.setRenderTarget(n),t.autoClear=!1,s!=null&&(t.setClearColor(s),t.setClearAlpha(r||0),t.clear()),this.fsQuad.material=e,this.fsQuad.render(t),t.autoClear=o,t.setClearColor(this.originalClearColor),t.setClearAlpha(a)}renderOverride(t,e,n,s,r){t.getClearColor(this.originalClearColor);const a=t.getClearAlpha(),o=t.autoClear;t.setRenderTarget(n),t.autoClear=!1,s=e.clearColor||s,r=e.clearAlpha||r,s!=null&&(t.setClearColor(s),t.setClearAlpha(r||0),t.clear()),this.scene.overrideMaterial=e,t.render(this.scene,this.camera),this.scene.overrideMaterial=null,t.autoClear=o,t.setClearColor(this.originalClearColor),t.setClearAlpha(a)}setSize(t,e){this.width=t,this.height=e,this.gtaoRenderTarget.setSize(t,e),this.normalRenderTarget.setSize(t,e),this.pdRenderTarget.setSize(t,e),this.gtaoMaterial.uniforms.resolution.value.set(t,e),this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.pdMaterial.uniforms.resolution.value.set(t,e),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse)}overrideVisibility(){const t=this.scene,e=this._visibilityCache;t.traverse(function(n){e.set(n,n.visible),(n.isPoints||n.isLine)&&(n.visible=!1)})}restoreVisibility(){const t=this.scene,e=this._visibilityCache;t.traverse(function(n){const s=e.get(n);n.visible=s}),e.clear()}generateNoise(t=64){const e=new MM,n=t*t*4,s=new Uint8Array(n);for(let a=0;a<t;a++)for(let o=0;o<t;o++){const l=a,c=o;s[(a*t+o)*4]=(e.noise(l,c)*.5+.5)*255,s[(a*t+o)*4+1]=(e.noise(l+t,c)*.5+.5)*255,s[(a*t+o)*4+2]=(e.noise(l,c+t)*.5+.5)*255,s[(a*t+o)*4+3]=(e.noise(l+t,c+t)*.5+.5)*255}const r=new Yf(s,t,t,Nn,pi);return r.wrapS=Ni,r.wrapT=Ni,r.needsUpdate=!0,r}}ri.OUTPUT={Off:-1,Default:0,Diffuse:1,Depth:2,Normal:3,AO:4,Denoise:5};const bM={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:`
|
|
4232
|
+
}`};function np(i,t,e){const n=vM(i,t,e);let s="vec3[SAMPLES](";for(let r=0;r<i;r++){const a=n[r];s+=`vec3(${a.x}, ${a.y}, ${a.z})${r<i-1?",":")"}`}return s}function vM(i,t,e){const n=[];for(let s=0;s<i;s++){const r=2*Math.PI*t*s/i,a=Math.pow(s/(i-1),e);n.push(new R(Math.cos(r),Math.sin(r),a))}return n}class _M{constructor(t=Math){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(let e=0;e<256;e++)this.p[e]=Math.floor(t.random()*256);this.perm=[];for(let e=0;e<512;e++)this.perm[e]=this.p[e&255];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]}dot(t,e,n){return t[0]*e+t[1]*n}dot3(t,e,n,s){return t[0]*e+t[1]*n+t[2]*s}dot4(t,e,n,s,r){return t[0]*e+t[1]*n+t[2]*s+t[3]*r}noise(t,e){let n,s,r;const a=.5*(Math.sqrt(3)-1),o=(t+e)*a,l=Math.floor(t+o),c=Math.floor(e+o),h=(3-Math.sqrt(3))/6,u=(l+c)*h,d=l-u,f=c-u,g=t-d,_=e-f;let m,p;g>_?(m=1,p=0):(m=0,p=1);const y=g-m+h,x=_-p+h,S=g-1+2*h,L=_-1+2*h,T=l&255,E=c&255,P=this.perm[T+this.perm[E]]%12,U=this.perm[T+m+this.perm[E+p]]%12,v=this.perm[T+1+this.perm[E+1]]%12;let b=.5-g*g-_*_;b<0?n=0:(b*=b,n=b*b*this.dot(this.grad3[P],g,_));let I=.5-y*y-x*x;I<0?s=0:(I*=I,s=I*I*this.dot(this.grad3[U],y,x));let O=.5-S*S-L*L;return O<0?r=0:(O*=O,r=O*O*this.dot(this.grad3[v],S,L)),70*(n+s+r)}noise3d(t,e,n){let s,r,a,o;const c=(t+e+n)*.3333333333333333,h=Math.floor(t+c),u=Math.floor(e+c),d=Math.floor(n+c),f=1/6,g=(h+u+d)*f,_=h-g,m=u-g,p=d-g,y=t-_,x=e-m,S=n-p;let L,T,E,P,U,v;y>=x?x>=S?(L=1,T=0,E=0,P=1,U=1,v=0):y>=S?(L=1,T=0,E=0,P=1,U=0,v=1):(L=0,T=0,E=1,P=1,U=0,v=1):x<S?(L=0,T=0,E=1,P=0,U=1,v=1):y<S?(L=0,T=1,E=0,P=0,U=1,v=1):(L=0,T=1,E=0,P=1,U=1,v=0);const b=y-L+f,I=x-T+f,O=S-E+f,$=y-P+2*f,K=x-U+2*f,z=S-v+2*f,Z=y-1+3*f,V=x-1+3*f,ot=S-1+3*f,ct=h&255,_t=u&255,$t=d&255,Jt=this.perm[ct+this.perm[_t+this.perm[$t]]]%12,j=this.perm[ct+L+this.perm[_t+T+this.perm[$t+E]]]%12,et=this.perm[ct+P+this.perm[_t+U+this.perm[$t+v]]]%12,ft=this.perm[ct+1+this.perm[_t+1+this.perm[$t+1]]]%12;let lt=.6-y*y-x*x-S*S;lt<0?s=0:(lt*=lt,s=lt*lt*this.dot3(this.grad3[Jt],y,x,S));let At=.6-b*b-I*I-O*O;At<0?r=0:(At*=At,r=At*At*this.dot3(this.grad3[j],b,I,O));let Tt=.6-$*$-K*K-z*z;Tt<0?a=0:(Tt*=Tt,a=Tt*Tt*this.dot3(this.grad3[et],$,K,z));let zt=.6-Z*Z-V*V-ot*ot;return zt<0?o=0:(zt*=zt,o=zt*zt*this.dot3(this.grad3[ft],Z,V,ot)),32*(s+r+a+o)}noise4d(t,e,n,s){const r=this.grad4,a=this.simplex,o=this.perm,l=(Math.sqrt(5)-1)/4,c=(5-Math.sqrt(5))/20;let h,u,d,f,g;const _=(t+e+n+s)*l,m=Math.floor(t+_),p=Math.floor(e+_),y=Math.floor(n+_),x=Math.floor(s+_),S=(m+p+y+x)*c,L=m-S,T=p-S,E=y-S,P=x-S,U=t-L,v=e-T,b=n-E,I=s-P,O=U>v?32:0,$=U>b?16:0,K=v>b?8:0,z=U>I?4:0,Z=v>I?2:0,V=b>I?1:0,ot=O+$+K+z+Z+V,ct=a[ot][0]>=3?1:0,_t=a[ot][1]>=3?1:0,$t=a[ot][2]>=3?1:0,Jt=a[ot][3]>=3?1:0,j=a[ot][0]>=2?1:0,et=a[ot][1]>=2?1:0,ft=a[ot][2]>=2?1:0,lt=a[ot][3]>=2?1:0,At=a[ot][0]>=1?1:0,Tt=a[ot][1]>=1?1:0,zt=a[ot][2]>=1?1:0,ie=a[ot][3]>=1?1:0,W=U-ct+c,A=v-_t+c,It=b-$t+c,Ct=I-Jt+c,Bt=U-j+2*c,Dt=v-et+2*c,ue=b-ft+2*c,kt=I-lt+2*c,C=U-At+3*c,M=v-Tt+3*c,F=b-zt+3*c,Y=I-ie+3*c,Q=U-1+4*c,q=v-1+4*c,St=b-1+4*c,ht=I-1+4*c,pt=m&255,Yt=p&255,it=y&255,mt=x&255,Ut=o[pt+o[Yt+o[it+o[mt]]]]%32,Ot=o[pt+ct+o[Yt+_t+o[it+$t+o[mt+Jt]]]]%32,Mt=o[pt+j+o[Yt+et+o[it+ft+o[mt+lt]]]]%32,Qt=o[pt+At+o[Yt+Tt+o[it+zt+o[mt+ie]]]]%32,Vt=o[pt+1+o[Yt+1+o[it+1+o[mt+1]]]]%32;let se=.6-U*U-v*v-b*b-I*I;se<0?h=0:(se*=se,h=se*se*this.dot4(r[Ut],U,v,b,I));let D=.6-W*W-A*A-It*It-Ct*Ct;D<0?u=0:(D*=D,u=D*D*this.dot4(r[Ot],W,A,It,Ct));let dt=.6-Bt*Bt-Dt*Dt-ue*ue-kt*kt;dt<0?d=0:(dt*=dt,d=dt*dt*this.dot4(r[Mt],Bt,Dt,ue,kt));let G=.6-C*C-M*M-F*F-Y*Y;G<0?f=0:(G*=G,f=G*G*this.dot4(r[Qt],C,M,F,Y));let J=.6-Q*Q-q*q-St*St-ht*ht;return J<0?g=0:(J*=J,g=J*J*this.dot4(r[Vt],Q,q,St,ht)),27*(h+u+d+f+g)}}class ii extends Cr{constructor(t,e,n,s,r,a,o){super(),this.width=n!==void 0?n:512,this.height=s!==void 0?s:512,this.clear=!0,this.camera=e,this.scene=t,this.output=0,this._renderGBuffer=!0,this._visibilityCache=new Map,this.blendIntensity=1,this.pdRings=2,this.pdRadiusExponent=2,this.pdSamples=16,this.gtaoNoiseTexture=mM(),this.pdNoiseTexture=this.generateNoise(),this.gtaoRenderTarget=new Jn(this.width,this.height,{type:Ni}),this.pdRenderTarget=this.gtaoRenderTarget.clone(),this.gtaoMaterial=new en({defines:Object.assign({},Ua.defines),uniforms:Zi.clone(Ua.uniforms),vertexShader:Ua.vertexShader,fragmentShader:Ua.fragmentShader,blending:qe,depthTest:!1,depthWrite:!1}),this.gtaoMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.gtaoMaterial.uniforms.tNoise.value=this.gtaoNoiseTexture,this.gtaoMaterial.uniforms.resolution.value.set(this.width,this.height),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.normalMaterial=new zy,this.normalMaterial.blending=qe,this.pdMaterial=new en({defines:Object.assign({},Fa.defines),uniforms:Zi.clone(Fa.uniforms),vertexShader:Fa.vertexShader,fragmentShader:Fa.fragmentShader,depthTest:!1,depthWrite:!1}),this.pdMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.pdMaterial.uniforms.tNoise.value=this.pdNoiseTexture,this.pdMaterial.uniforms.resolution.value.set(this.width,this.height),this.pdMaterial.uniforms.lumaPhi.value=10,this.pdMaterial.uniforms.depthPhi.value=2,this.pdMaterial.uniforms.normalPhi.value=3,this.pdMaterial.uniforms.radius.value=8,this.depthRenderMaterial=new en({defines:Object.assign({},Oa.defines),uniforms:Zi.clone(Oa.uniforms),vertexShader:Oa.vertexShader,fragmentShader:Oa.fragmentShader,blending:qe}),this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new en({uniforms:Zi.clone(oo.uniforms),vertexShader:oo.vertexShader,fragmentShader:oo.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:lc,blendDst:$r,blendEquation:Xn,blendSrcAlpha:oc,blendDstAlpha:$r,blendEquationAlpha:Xn}),this.blendMaterial=new en({uniforms:Zi.clone(kl.uniforms),vertexShader:kl.vertexShader,fragmentShader:kl.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blending:ff,blendSrc:lc,blendDst:$r,blendEquation:Xn,blendSrcAlpha:oc,blendDstAlpha:$r,blendEquationAlpha:Xn}),this.fsQuad=new Ih(null),this.originalClearColor=new Zt,this.setGBuffer(r?r.depthTexture:void 0,r?r.normalTexture:void 0),a!==void 0&&this.updateGtaoMaterial(a),o!==void 0&&this.updatePdMaterial(o)}dispose(){this.gtaoNoiseTexture.dispose(),this.pdNoiseTexture.dispose(),this.normalRenderTarget.dispose(),this.gtaoRenderTarget.dispose(),this.pdRenderTarget.dispose(),this.normalMaterial.dispose(),this.pdMaterial.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose(),this.fsQuad.dispose()}get gtaoMap(){return this.pdRenderTarget.texture}setGBuffer(t,e){t!==void 0?(this.depthTexture=t,this.normalTexture=e,this._renderGBuffer=!1):(this.depthTexture=new Eh,this.depthTexture.format=ws,this.depthTexture.type=Ss,this.normalRenderTarget=new Jn(this.width,this.height,{minFilter:sn,magFilter:sn,type:Ni,depthTexture:this.depthTexture}),this.normalTexture=this.normalRenderTarget.texture,this._renderGBuffer=!0);const n=this.normalTexture?1:0,s=this.depthTexture===this.normalTexture?"w":"x";this.gtaoMaterial.defines.NORMAL_VECTOR_TYPE=n,this.gtaoMaterial.defines.DEPTH_SWIZZLING=s,this.gtaoMaterial.uniforms.tNormal.value=this.normalTexture,this.gtaoMaterial.uniforms.tDepth.value=this.depthTexture,this.pdMaterial.defines.NORMAL_VECTOR_TYPE=n,this.pdMaterial.defines.DEPTH_SWIZZLING=s,this.pdMaterial.uniforms.tNormal.value=this.normalTexture,this.pdMaterial.uniforms.tDepth.value=this.depthTexture,this.depthRenderMaterial.uniforms.tDepth.value=this.normalRenderTarget.depthTexture}setSceneClipBox(t){t?(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX!==1,this.gtaoMaterial.defines.SCENE_CLIP_BOX=1,this.gtaoMaterial.uniforms.sceneBoxMin.value.copy(t.min),this.gtaoMaterial.uniforms.sceneBoxMax.value.copy(t.max)):(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX===0,this.gtaoMaterial.defines.SCENE_CLIP_BOX=0)}updateGtaoMaterial(t){t.radius!==void 0&&(this.gtaoMaterial.uniforms.radius.value=t.radius),t.distanceExponent!==void 0&&(this.gtaoMaterial.uniforms.distanceExponent.value=t.distanceExponent),t.thickness!==void 0&&(this.gtaoMaterial.uniforms.thickness.value=t.thickness),t.distanceFallOff!==void 0&&(this.gtaoMaterial.uniforms.distanceFallOff.value=t.distanceFallOff,this.gtaoMaterial.needsUpdate=!0),t.scale!==void 0&&(this.gtaoMaterial.uniforms.scale.value=t.scale),t.samples!==void 0&&t.samples!==this.gtaoMaterial.defines.SAMPLES&&(this.gtaoMaterial.defines.SAMPLES=t.samples,this.gtaoMaterial.needsUpdate=!0),t.screenSpaceRadius!==void 0&&(t.screenSpaceRadius?1:0)!==this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS&&(this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS=t.screenSpaceRadius?1:0,this.gtaoMaterial.needsUpdate=!0)}updatePdMaterial(t){let e=!1;t.lumaPhi!==void 0&&(this.pdMaterial.uniforms.lumaPhi.value=t.lumaPhi),t.depthPhi!==void 0&&(this.pdMaterial.uniforms.depthPhi.value=t.depthPhi),t.normalPhi!==void 0&&(this.pdMaterial.uniforms.normalPhi.value=t.normalPhi),t.radius!==void 0&&t.radius!==this.radius&&(this.pdMaterial.uniforms.radius.value=t.radius),t.radiusExponent!==void 0&&t.radiusExponent!==this.pdRadiusExponent&&(this.pdRadiusExponent=t.radiusExponent,e=!0),t.rings!==void 0&&t.rings!==this.pdRings&&(this.pdRings=t.rings,e=!0),t.samples!==void 0&&t.samples!==this.pdSamples&&(this.pdSamples=t.samples,e=!0),e&&(this.pdMaterial.defines.SAMPLES=this.pdSamples,this.pdMaterial.defines.SAMPLE_VECTORS=np(this.pdSamples,this.pdRings,this.pdRadiusExponent),this.pdMaterial.needsUpdate=!0)}render(t,e,n){switch(this._renderGBuffer&&(this.overrideVisibility(),this.renderOverride(t,this.normalMaterial,this.normalRenderTarget,7829503,1),this.restoreVisibility()),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.gtaoMaterial.uniforms.cameraWorldMatrix.value.copy(this.camera.matrixWorld),this.renderPass(t,this.gtaoMaterial,this.gtaoRenderTarget,16777215,1),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.renderPass(t,this.pdMaterial,this.pdRenderTarget,16777215,1),this.output){case ii.OUTPUT.Off:break;case ii.OUTPUT.Diffuse:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=qe,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;case ii.OUTPUT.AO:this.copyMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.copyMaterial.blending=qe,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;case ii.OUTPUT.Denoise:this.copyMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.copyMaterial.blending=qe,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;case ii.OUTPUT.Depth:this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.renderPass(t,this.depthRenderMaterial,this.renderToScreen?null:e);break;case ii.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=qe,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;case ii.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=qe,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e),this.blendMaterial.uniforms.intensity.value=this.blendIntensity,this.blendMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.renderPass(t,this.blendMaterial,this.renderToScreen?null:e);break;default:console.warn("THREE.GTAOPass: Unknown output type.")}}renderPass(t,e,n,s,r){t.getClearColor(this.originalClearColor);const a=t.getClearAlpha(),o=t.autoClear;t.setRenderTarget(n),t.autoClear=!1,s!=null&&(t.setClearColor(s),t.setClearAlpha(r||0),t.clear()),this.fsQuad.material=e,this.fsQuad.render(t),t.autoClear=o,t.setClearColor(this.originalClearColor),t.setClearAlpha(a)}renderOverride(t,e,n,s,r){t.getClearColor(this.originalClearColor);const a=t.getClearAlpha(),o=t.autoClear;t.setRenderTarget(n),t.autoClear=!1,s=e.clearColor||s,r=e.clearAlpha||r,s!=null&&(t.setClearColor(s),t.setClearAlpha(r||0),t.clear()),this.scene.overrideMaterial=e,t.render(this.scene,this.camera),this.scene.overrideMaterial=null,t.autoClear=o,t.setClearColor(this.originalClearColor),t.setClearAlpha(a)}setSize(t,e){this.width=t,this.height=e,this.gtaoRenderTarget.setSize(t,e),this.normalRenderTarget.setSize(t,e),this.pdRenderTarget.setSize(t,e),this.gtaoMaterial.uniforms.resolution.value.set(t,e),this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.pdMaterial.uniforms.resolution.value.set(t,e),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse)}overrideVisibility(){const t=this.scene,e=this._visibilityCache;t.traverse(function(n){e.set(n,n.visible),(n.isPoints||n.isLine)&&(n.visible=!1)})}restoreVisibility(){const t=this.scene,e=this._visibilityCache;t.traverse(function(n){const s=e.get(n);n.visible=s}),e.clear()}generateNoise(t=64){const e=new _M,n=t*t*4,s=new Uint8Array(n);for(let a=0;a<t;a++)for(let o=0;o<t;o++){const l=a,c=o;s[(a*t+o)*4]=(e.noise(l,c)*.5+.5)*255,s[(a*t+o)*4+1]=(e.noise(l+t,c)*.5+.5)*255,s[(a*t+o)*4+2]=(e.noise(l,c+t)*.5+.5)*255,s[(a*t+o)*4+3]=(e.noise(l+t,c+t)*.5+.5)*255}const r=new jf(s,t,t,kn,di);return r.wrapS=ki,r.wrapT=ki,r.needsUpdate=!0,r}}ii.OUTPUT={Off:-1,Default:0,Diffuse:1,Depth:2,Normal:3,AO:4,Denoise:5};const xM={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:`
|
|
4234
4233
|
precision highp float;
|
|
4235
4234
|
|
|
4236
4235
|
uniform mat4 modelViewMatrix;
|
|
@@ -4297,11 +4296,11 @@ void main() {
|
|
|
4297
4296
|
|
|
4298
4297
|
#endif
|
|
4299
4298
|
|
|
4300
|
-
}`};class SM extends Cr{constructor(){super();const t=bM;this.uniforms=Qi.clone(t.uniforms),this.material=new Hy({name:t.name,uniforms:this.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader}),this.fsQuad=new kh(this.material),this._outputColorSpace=null,this._toneMapping=null}render(t,e,n){this.uniforms.tDiffuse.value=n.texture,this.uniforms.toneMappingExposure.value=t.toneMappingExposure,(this._outputColorSpace!==t.outputColorSpace||this._toneMapping!==t.toneMapping)&&(this._outputColorSpace=t.outputColorSpace,this._toneMapping=t.toneMapping,this.material.defines={},oe.getTransfer(this._outputColorSpace)===ye&&(this.material.defines.SRGB_TRANSFER=""),this._toneMapping===vf?this.material.defines.LINEAR_TONE_MAPPING="":this._toneMapping===_f?this.material.defines.REINHARD_TONE_MAPPING="":this._toneMapping===xf?this.material.defines.CINEON_TONE_MAPPING="":this._toneMapping===yf?this.material.defines.ACES_FILMIC_TONE_MAPPING="":this._toneMapping===Mf?this.material.defines.AGX_TONE_MAPPING="":this._toneMapping===hh&&(this.material.defines.NEUTRAL_TONE_MAPPING=""),this.material.needsUpdate=!0),this.renderToScreen===!0?(t.setRenderTarget(null),this.fsQuad.render(t)):(t.setRenderTarget(e),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),this.fsQuad.render(t))}dispose(){this.material.dispose(),this.fsQuad.dispose()}}class wM{constructor(t,e){this.w=t,this.d=e,this.ox=-t/2,this.oz=-e/2,this.cells=new Uint8Array(t*e)}inside(t,e){return t>=0&&e>=0&&t<this.w&&e<this.d}blocked(t,e){return!this.inside(t,e)||this.cells[e*this.w+t]===1}cellOf(t,e){return[Math.floor(t-this.ox),Math.floor(e-this.oz)]}center(t,e){return[this.ox+t+.5,this.oz+e+.5]}block(t,e,n,s){const[r,a]=this.cellOf(t,n),[o,l]=this.cellOf(e-1e-6,s-1e-6);for(let c=a;c<=l;c++)for(let h=r;h<=o;h++)this.inside(h,c)&&(this.cells[c*this.w+h]=1)}nearestFree(t,e){if(!this.blocked(t,e))return[t,e];const n=new Set([e*this.w+t]),s=[[t,e]];for(;s.length;){const[r,a]=s.shift();for(const[o,l]of[[1,0],[-1,0],[0,1],[0,-1]]){const c=r+o,h=a+l;if(!(!this.inside(c,h)||n.has(h*this.w+c))){if(!this.blocked(c,h))return[c,h];n.add(h*this.w+c),s.push([c,h])}}}return[t,e]}clear(t,e,n,s){const r=Math.hypot(n-t,s-e),a=Math.ceil(r/.2);for(let o=1;o<a;o++){const l=o/a,[c,h]=this.cellOf(t+(n-t)*l,e+(s-e)*l);if(this.blocked(c,h))return!1}return!0}path(t,e,n,s){const r=this.nearestFree(...this.cellOf(t,e)),a=this.nearestFree(...this.cellOf(n,s)),o=(y,x)=>x*this.w+y,l=(y,x)=>Math.hypot(y-a[0],x-a[1]),c=new Map([[o(...r),0]]),h=new Map,u=[[l(...r),...r]],d=new Set;let f=!1;for(;u.length;){let y=0;for(let T=1;T<u.length;T++)u[T][0]<u[y][0]&&(y=T);const[,x,S]=u.splice(y,1)[0],L=o(x,S);if(!d.has(L)){if(d.add(L),x===a[0]&&S===a[1]){f=!0;break}for(let T=-1;T<=1;T++)for(let E=-1;E<=1;E++){if(!T&&!E)continue;const P=x+T,U=S+E;if(this.blocked(P,U)||T&&E&&(this.blocked(x+T,S)||this.blocked(x,S+E)))continue;const v=o(P,U),b=c.get(L)+(T&&E?Math.SQRT2:1);b<(c.get(v)??1/0)&&(c.set(v,b),h.set(v,L),u.push([b+l(P,U),P,U]))}}}const g=[];if(f){let y=o(...a);for(;y!==void 0;)g.unshift(this.center(y%this.w,Math.floor(y/this.w))),y=h.get(y)}g.push([n,s]);const _=[];let m=[t,e],p=0;for(;p<g.length;){let y=p;for(let x=g.length-1;x>p;x--)if(this.clear(m[0],m[1],g[x][0],g[x][1])){y=x;break}_.push(g[y]),m=g[y],p=y+1}return _}}const Ol=new Map;function Se(i,t={}){const e=i+JSON.stringify(t);return Ol.has(e)||Ol.set(e,new Bn({color:i,roughness:.7,...t})),Ol.get(e)}const Nr=(i,t)=>"#"+new Zt(i).multiplyScalar(t).getHexString();function re(i,t,e,n=0,s=0,r=0){const a=new yt(i,t);return a.position.set(n,s,r),a.castShadow=!0,a.receiveShadow=!0,e.add(a),a}const ni=(i,t)=>new Rh(i,Math.max(.001,t),5,12),wi=(i,t=20,e=14)=>new di(i,t,e),EM=.93,TM=.45,AM=.44,CM=.06,RM=.1,ee=.46,rp={ada:{hair:"afro",pants:"#3a3f5c",shoes:"#26211d"},tunde:{hair:"short",pants:"#4b4136",shoes:"#1c1c1c",extra:"lanyard"},mira:{hair:"bob",pants:"#2f3b52",shoes:"#5b4636"},kai:{hair:"spiky",pants:"#38383d",shoes:"#e9e6df",extra:"hood"},zola:{hair:"ponytail",pants:"#4d3f5e",shoes:"#2b2b2b"},remi:{hair:"bun",pants:"#3f4f60",shoes:"#704d38",extra:"glasses"},obi:{hair:"buzz",pants:"#2c3a32",shoes:"#1d1d1d",extra:"headphones"},lin:{hair:"long",pants:"#3b3b4a",shoes:"#2a2a2a"},chief:{hair:"side",pants:"#22232e",shoes:"#141414",extra:"suit"}};function Ba(i,t,e,n,s,r,a,o,l,c){const h=new qt;h.position.set(t,e,0),i.add(h),re(ni(r,n-r),o,h,0,-n/2);const u=new qt;u.position.y=-n,h.add(u),re(ni(a,s-a),l,u,0,-s/2);const d=new qt;return d.position.y=-s,u.add(d),c==null||c(d),{pivot:h,joint:u,end:d}}class Jr{constructor(t){const e=rp[t.id]||{hair:"short",pants:"#34384a",shoes:"#222"};this.look=e;const n=Se(t.skin,{roughness:.6}),s=Se(t.shirt),r=Se(Nr(t.shirt,.9)),a=Se(e.pants),o=Se(e.shoes,{roughness:.5}),l=Se(t.hair,{roughness:.85});this.group=new qt,this.body=new qt,this.group.add(this.body),this.hips=new qt,this.hips.position.y=.95,this.body.add(this.hips),re(ni(.2,.06),a,this.hips,0,.02).scale.set(1,1,.8);const h=_=>{re(new Ze(.15,.09,.26),o,_,0,-.02,.05).geometry.translate(0,0,0)};this.legL=Ba(this.hips,-.11,-.02,.45,.44,.1,.085,a,a,h),this.legR=Ba(this.hips,.11,-.02,.45,.44,.1,.085,a,a,h),this.torso=new qt,this.hips.add(this.torso);const u=[[.001,0],[.19,0],[.225,.08],[.23,.24],[.22,.36],[.255,.5],[.24,.58],[.15,.645],[.001,.66]].map(([_,m])=>new rt(_,m)),d=re(new zo(u,20),e.extra==="suit"?Se("#2b2d42"):s,this.torso,0,.04);d.scale.z=.8,re(new oi(.11,.03,8,20),e.extra==="suit"?Se("#f4f1ea"):Se(Nr(t.shirt,.8)),this.torso,0,.67).rotation.x=Math.PI/2,re(new zn(.075,.085,.14,12),n,this.torso,0,.73);const f=_=>re(wi(.07,12,10),n,_,0,-.02),g=e.extra==="suit"?Se("#2b2d42"):r;this.armL=Ba(this.torso,-.29,.58,.32,.3,.072,.062,g,e.extra==="suit"||e.extra==="hood"?g:n,f),this.armR=Ba(this.torso,.29,.58,.32,.3,.072,.062,g,e.extra==="suit"||e.extra==="hood"?g:n,f),this.buildHead(t,n,l),this.buildExtras(t,e,l),this.book=re(new Ze(.34,.05,.26),Se("#3d7ea6"),this.torso,0,.3,.36),this.book.rotation.x=-.6,this.book.visible=!1,this.mug=re(new zn(.06,.055,.13,12),Se("#ffffff"),this.armR.end,0,-.06,.07),this.mug.visible=!1,this.blinkAt=1+Math.random()*3,this.blink=0,this.cur={}}buildHead(t,e,n){this.head=new qt,this.head.position.y=.78,this.torso.add(this.head),re(wi(.33,28,20),e,this.head,0,.3).scale.set(1,.97,.94);for(const a of[-1,1])re(wi(.06,10,8),e,this.head,a*.32,.29,-.01).scale.set(.6,1,1);re(wi(.032,10,8),Se(Nr(t.skin,.88),{roughness:.6}),this.head,0,.27,.31),this.eyes=[];for(const a of[-1,1]){const o=new qt;o.position.set(a*.115,.33,.285),o.rotation.y=a*.28,this.head.add(o);const l=new yt(wi(.042,14,10),Se("#17181c",{roughness:.3}));l.scale.set(.82,1.2,.5),o.add(l);const c=new yt(wi(.013,8,6),new dn({color:"#ffffff"}));c.position.set(.012,.018,.02),o.add(c),this.eyes.push(o)}this.brows=[];for(const a of[-1,1]){const o=new yt(ni(.014,.08),Se(Nr(t.hair,.9)));o.rotation.z=Math.PI/2;const l=new qt;l.position.set(a*.115,.425,.275),l.rotation.y=a*.28,l.add(o),this.head.add(l),this.brows.push(l)}this.mouth=new yt(new oi(.055,.012,6,18,Math.PI),Se("#5b2a2a",{roughness:.5})),this.mouth.position.set(0,.205,.292),this.mouth.rotation.z=Math.PI,this.head.add(this.mouth);for(const a of[-1,1]){const o=new yt(new Oi(.045,16),new dn({color:"#ff8d7a",transparent:!0,opacity:.22,depthWrite:!1}));o.position.set(a*.19,.24,.245),o.rotation.y=a*.62,this.head.add(o)}const r=(a=.345,o=.52,l=-.25)=>{const c=re(new di(a,28,16,0,Math.PI*2,0,Math.PI*o),n,this.head,0,.31,-.01);return c.rotation.x=l,c.scale.set(1,1,.97),c};switch(this.look.hair){case"afro":r(.35,.55),re(wi(.43,24,18),n,this.head,0,.47,-.08).scale.set(1,.85,.95);break;case"bob":{r(.36,.56,-.32);for(const a of[-1,1])re(ni(.09,.2),n,this.head,a*.29,.22,-.1).scale.set(.75,1,1.1);re(ni(.05,.3),n,this.head,0,.55,.17).rotation.z=Math.PI/2;break}case"spiky":r(.35,.5);for(let a=0;a<9;a++){const o=a/9*Math.PI*2;re(new ca(.07,.22,6),n,this.head,Math.cos(o)*.17,.6,Math.sin(o)*.17-.03).rotation.set(Math.sin(o)*.7,0,-Math.cos(o)*.7)}break;case"ponytail":{r(.35,.55),re(wi(.07,10,8),Se("#e07a5f"),this.head,0,.42,-.33);const a=re(ni(.08,.32),n,this.head,0,.22,-.4);a.rotation.x=.35,this.tail=a;break}case"bun":r(.35,.55),re(wi(.14,16,12),n,this.head,0,.66,-.1);break;case"buzz":r(.338,.5,-.3);break;case"long":{r(.36,.58,-.2),re(ni(.16,.42),n,this.head,0,.1,-.2).scale.set(1.75,1,.6);break}case"side":{r(.35,.5),re(ni(.07,.3),n,this.head,.06,.58,.12).rotation.set(.2,0,Math.PI/2-.25);break}default:r(.35,.5)}}buildExtras(t,e,n){if(e.extra==="glasses"||e.extra==="suit"){const s=Se("#1b1b1f",{roughness:.4});for(const r of[-1,1]){const a=re(new oi(.06,.011,6,18),s,this.head,r*.115,.33,.3);a.rotation.y=r*.28}re(ni(.009,.06),s,this.head,0,.34,.315).rotation.z=Math.PI/2}if(e.extra==="suit"){const s=re(new Ze(.06,.3,.02),Se("#b23a3a"),this.torso,0,.47,.19);s.rotation.x=-.12,re(new Ze(.16,.18,.02),Se("#f4f1ea"),this.torso,0,.56,.175).rotation.x=-.15}if(e.extra==="headphones"){const s=re(new oi(.35,.025,8,24,Math.PI),Se("#22252b"),this.head,0,.32,0);s.rotation.y=Math.PI/2,s.rotation.x=-.15;for(const r of[-1,1])re(new zn(.09,.09,.07,18),Se("#e05f4a"),this.head,r*.34,.3,0).rotation.z=Math.PI/2}if(e.extra==="lanyard"&&(re(new oi(.16,.01,6,20,Math.PI),Se("#2a6fb0"),this.torso,0,.62,.12).rotation.set(-.25,0,Math.PI),re(new Ze(.1,.13,.015),Se("#ffffff"),this.torso,0,.42,.205).rotation.x=-.1),e.extra==="hood"){const s=re(new oi(.2,.06,10,24),Se(Nr(t.shirt,.85)),this.torso,0,.64,-.05);s.rotation.x=Math.PI/2+.35,s.scale.set(1,1,.7)}}static sit(t=ee,e=-1.4){const n=t+RM,s=n-TM*Math.cos(e),r=-Math.acos(Math.min(1,Math.max(-1,(s-CM)/AM)));return{y:n-EM,hip:e,knee:r-e}}pose(t,e,n,s={}){const r=Math.min(1,e*10);let a=0,o=0,l=0,c=0,h=.05,u=.05,d=-.12,f=-.12,g=-.07,_=.07,m=0,p=0,y=0,x=0,S=0;const L=Math.sin(n*1.7)*.012;switch(this.book.visible=t==="read",this.mug.visible=t==="mug",t){case"walk":{const v=Math.sin(n*9.5),b=Math.cos(n*9.5);a=v*.5,o=-v*.5,l=Math.max(0,-b)*.9+.05,c=Math.max(0,b)*.9+.05,h=-v*.45,u=v*.45,d=f=-.35,m=Math.abs(b)*.05,p=.06,x=Math.sin(n*4.75)*.04;break}case"desk":{const v=Jr.sit(s.seatY,-1.45);a=o=v.hip,l=c=v.knee,m=v.y,p=.08,s.typing?(h=-.5+Math.sin(n*17)*.05,u=-.5+Math.sin(n*17+2)*.05,d=-1.15+Math.sin(n*19)*.12,f=-1.15+Math.sin(n*19+1.6)*.12,g=-.18,_=.18,y=.12+Math.sin(n*.7)*.03):s.waiting?(u=-.95,f=-2.25,_=.05,h=-.4,d=-1,x=Math.sin(n*.6)*.45,y=-.05):(h=u=-.35,d=f=-.9,g=-.2,_=.2,p=-.04,x=Math.sin(n*.35)*.3);break}case"couch":{const v=Jr.sit(s.seatY,-1.3);a=o=v.hip,l=c=v.knee,m=v.y,p=-.18,h=u=-.2,d=f=-.75,g=-.15,_=.15,x=Math.sin(n*.3)*.5,S=Math.sin(n*.21)*.06;break}case"sit":{const v=Jr.sit(s.seatY,-1.42);a=o=v.hip,l=c=v.knee,m=v.y,p=.03,h=u=-.32,d=f=-.95,g=-.16,_=.16,x=Math.sin(n*.4)*.4,S=Math.sin(n*.27)*.05;break}case"read":h=u=-.55,d=f=-1.35,g=-.12,_=.12,y=.4,x=Math.sin(n*.6)*.12;break;case"type":h=-.75+Math.sin(n*14)*.08,u=-.75+Math.sin(n*14+2)*.08,d=-.9,f=-.9,g=-.15,_=.15,y=.08;break;case"gaze":h=u=.3,d=f=-.25,g=-.12,_=.12,y=-.18,x=Math.sin(n*.45)*.35;break;case"write":u=-2.2+Math.sin(n*6)*.2,f=-.5+Math.sin(n*9)*.15,_=.25,x=Math.sin(n*1.2)*.1,y=-.08;break;case"mug":{const v=Math.sin(n*.8)>.75;u=v?-.85:-.45,f=v?-2.05:-1.55,_=.1,y=v?-.15:.02,x=v?0:Math.sin(n*.4)*.3;break}case"cue":p=.62,h=-1.5,d=-.12,g=-.12,u=-.95,f=-1.35,_=.14,y=-.5,a=o=-.12,l=c=.14,x=Math.sin(n*.8)*.05;break;case"talk":u=-.55+Math.sin(n*4)*.2,f=-1.1+Math.sin(n*5.3)*.2,_=.2,h=-.1,d=-.4,S=Math.sin(n*2.2)*.06,y=-.04;break;case"celebrate":h=u=-2.75,d=f=-.25,g=-.35,_=.35,m=Math.abs(Math.sin(n*8))*.32,y=-.15,l=c=m>.05?.4:.1,a=o=-l*.5;break;case"slump":y=.45,p=.22,h=u=.12,d=f=-.05;break;default:x=Math.sin(n*.5)*.25}const T=this.cur,E=(v,b,I=r)=>T[v]=T[v]===void 0?b:T[v]+(b-T[v])*I,P=t==="walk",U=P?Math.min(1,e*18):r;this.legL.pivot.rotation.x=E("hipL",a,U),this.legR.pivot.rotation.x=E("hipR",o,U),this.legL.joint.rotation.x=E("kneeL",l,U),this.legR.joint.rotation.x=E("kneeR",c,U),this.armL.pivot.rotation.x=E("shL",h,U),this.armR.pivot.rotation.x=E("shR",u,U),this.armL.pivot.rotation.z=E("outL",g),this.armR.pivot.rotation.z=E("outR",_),this.armL.joint.rotation.x=E("elL",d,U),this.armR.joint.rotation.x=E("elR",f,U),this.torso.rotation.x=E("lean",p),this.torso.scale.y=1+L,this.head.rotation.x=E("headX",y,r*.6),this.head.rotation.y=E("headY",x,r*.4),this.head.rotation.z=E("headZ",S,r*.6),this.body.position.y=P||t==="celebrate"?m:E("y",m),this.tail&&(this.tail.rotation.x=.35+Math.sin(n*(P?9.5:1.5))*(P?.12:.03))}express(t,e,n){n>this.blinkAt&&(this.blink=.14,this.blinkAt=n+2+Math.random()*4),this.blink=Math.max(0,this.blink-e);const s=this.blink>0,r=Math.min(1,e*12),a=this.cur,o=(p,y)=>a[p]=a[p]===void 0?y:a[p]+(y-a[p])*r;let l=1,c=0,h=0,u=1,d=1,f=!1;t==="happy"?(l=.3,c=.025,u=1.45,d=1.6):t==="think"?(c=.02,h=.25,u=.55,l=.9):t==="worried"?(h=-.35,c=.01,f=!0,u=.8):t==="talk"&&(u=.8,d=.6+Math.abs(Math.sin(n*13))*1.6,c=Math.sin(n*3)*.008),s&&t!=="happy"&&(l=.1);const g=o("eyeY",l);for(const p of this.eyes)p.scale.y=g;const _=o("browY",c),m=o("browTilt",h);this.brows.forEach((p,y)=>{p.position.y=.425+_,p.rotation.z=(y?-1:1)*m}),this.mouth.rotation.z=f?0:Math.PI,this.mouth.position.y=f?.18:.205,this.mouth.scale.set(o("mouthX",u),o("mouthY",d),1)}}const vn=40,In=30,Xe={x:7.6,z:10.9,felt:.84},wt={wall:"#f5f0e8",trim:"#d9cdbb",wood:"#c39a6b",woodDark:"#8c6440",metal:"#3b404c",rack:"#262a33",pot:"#e4d6c1",couch:"#5b7fa6",rug:"#c99b84",glass:"#cfe6f2",board:"#fbfaf7",chair:"#30343d"},Fl=new Map;function xe(i,t={}){const e=i+JSON.stringify(t);return Fl.has(e)||Fl.set(e,new Bn({color:i,roughness:.82,...t})),Fl.get(e)}function it(i,t,e,n,s,r,a,o,l){const c=new yt(new Ze(t,e,n),l instanceof Fi?l:xe(s,l));return c.position.set(r,a,o),c.castShadow=!0,c.receiveShadow=!0,i.add(c),c}function rs(i,t,e,n,s){const r=document.createElement("canvas");r.width=n,r.height=s;const a=new zi(r);a.colorSpace=Ke,a.anisotropy=4;const o=new yt(new gi(t,e),new dn({map:a,toneMapped:!1}));return i.add(o),{canvas:r,ctx:r.getContext("2d"),tex:a,mesh:o}}const ci='"Inter Variable", Inter, system-ui, sans-serif',PM='"JetBrains Mono", ui-monospace, monospace';function te(i,t,e,n,s,r,a,o,l=16,c){const h=new yt(new zn(t,e,n,l),c instanceof Fi?c:xe(s,c));return h.position.set(r,a,o),h.castShadow=!0,h.receiveShadow=!0,i.add(h),h}const pd=["#5f9e6e","#477d55","#6fae74","#3f7350","#7dbb7a"];function LM(i,t,e,n,s=1,r="bush"){const a=new qt;a.position.set(e,0,n),a.rotation.y=e*1.7+n,a.scale.setScalar(s),te(a,.35,.27,.6,wt.pot,0,.3,0,18),te(a,.37,.37,.06,"#d8c8b0",0,.6,0,18),te(a,.31,.31,.02,"#5a4130",0,.62,0,18);const o=(l,c,h,u,d)=>{const f=new yt(new Sr(l,0),xe(pd[d%pd.length],{flatShading:!0}));f.position.set(c,h,u),f.rotation.set(c*3,u*5,h),f.castShadow=!0,a.add(f)};if(r==="tall")te(a,.035,.05,1.5,wt.woodDark,0,1.35,0,6),o(.42,.12,1.55,.05,1),o(.48,-.15,1.95,-.08,0),o(.38,.18,2.3,.1,2),o(.3,-.05,2.6,0,4);else if(r==="snake")for(let l=0;l<7;l++){const c=l/7*Math.PI*2,h=.8+l*37%5*.12,u=new yt(new ca(.07,h,4),xe(l%2?"#4e8a5c":"#6f9f5a",{flatShading:!0}));u.position.set(Math.cos(c)*.12,.62+h/2,Math.sin(c)*.12),u.rotation.set(Math.sin(c)*.18,c,-Math.cos(c)*.18),u.scale.z=.35,u.castShadow=!0,a.add(u)}else o(.55,0,1,0,0),o(.4,.3,1.25,.1,1),o(.38,-.28,1.2,-.12,2),o(.36,.05,1.5,-.2,3);return i.add(a),t.block(e-.45*s,e+.45*s,n-.45*s,n+.45*s),a}function ap(i,t,e,n){te(i,.09,.07,.12,"#e8dccb",t,e+.06,n,12);const s=new yt(new Sr(.1,0),xe("#7aa874",{flatShading:!0}));s.position.set(t,e+.17,n),s.scale.y=.7,s.castShadow=!0,i.add(s)}function Kc(i,t,e,n,s=3){const r=["#e07a5f","#3d7ea6","#f2cc8f","#81b29a","#9c6ade"];for(let a=0;a<s;a++){const o=it(i,.34-a*.03,.05,.25,r[(a+Math.round(t*7))%r.length],t,e+.025+a*.05,n);o.rotation.y=(a-1)*.15}}function DM(i,t,e,n){const s=xe("#2f3440",{roughness:.5});te(i,.11,.12,.03,null,t,e+.015,n,16,s);const r=it(i,.03,.42,.03,null,t,e+.22,n,s);r.rotation.x=-.25;const a=it(i,.03,.03,.3,null,t,e+.42,n+.13,s);a.rotation.x=.35;const o=te(i,.05,.12,.14,null,t,e+.36,n+.27,16,xe("#e9b949",{roughness:.45}));o.rotation.x=.4;const l=new yt(new Oi(.1,16),new dn({color:"#fff3c9"}));l.position.set(t,e+.3,n+.3),l.rotation.x=-Math.PI/2+.4,i.add(l)}function Ur(i,t,e,n,s,r,a="#3b3330"){const o=[it(i.g,n+.14,s+.14,.05,a,t,e,.18)],l=rs(i.g,n,s,Math.round(256*n),Math.round(256*s));l.mesh.position.set(t,e,.21),l.mesh.material=new Bn({map:l.tex,roughness:.9}),r(l.ctx,l.canvas.width,l.canvas.height),l.tex.needsUpdate=!0,o.push(l.mesh),i.attach.push(...o)}const Or={sunset(i,t,e){i.fillStyle="#f4e3c8",i.fillRect(0,0,t,e),i.fillStyle="#e9967a",i.beginPath(),i.arc(t*.62,e*.45,t*.2,0,Math.PI*2),i.fill(),i.fillStyle="#8fb0a0",i.beginPath(),i.moveTo(0,e),i.lineTo(0,e*.62),i.quadraticCurveTo(t*.35,e*.4,t*.7,e*.66),i.lineTo(t,e*.58),i.lineTo(t,e),i.fill(),i.fillStyle="#4f7c74",i.beginPath(),i.moveTo(0,e),i.lineTo(0,e*.8),i.quadraticCurveTo(t*.5,e*.6,t,e*.82),i.lineTo(t,e),i.fill()},blocks(i,t,e){i.fillStyle="#f7f1e6",i.fillRect(0,0,t,e);const n=["#e07a5f","#3d405b","#81b29a","#f2cc8f"];i.fillStyle=n[0],i.fillRect(t*.12,e*.12,t*.42,e*.4),i.fillStyle=n[1],i.fillRect(t*.54,e*.12,t*.34,e*.22),i.fillStyle=n[2],i.fillRect(t*.54,e*.34,t*.34,e*.54),i.fillStyle=n[3],i.fillRect(t*.12,e*.52,t*.42,e*.36),i.fillStyle="#3d405b",i.beginPath(),i.arc(t*.33,e*.7,t*.1,0,Math.PI*2),i.fill()},arcs(i,t,e){i.fillStyle="#efe6d8",i.fillRect(0,0,t,e),["#c8553d","#f28f3b","#ffd5c2","#588b8b"].forEach((s,r)=>{i.strokeStyle=s,i.lineWidth=t*.07,i.beginPath(),i.arc(t/2,e*.85,t*(.38-r*.09),Math.PI,0),i.stroke()})},leaf(i,t,e){i.fillStyle="#e7ece4",i.fillRect(0,0,t,e),i.fillStyle="#5f8f6b",i.beginPath(),i.ellipse(t/2,e/2,t*.18,e*.36,.35,0,Math.PI*2),i.fill(),i.strokeStyle="#e7ece4",i.lineWidth=t*.015,i.beginPath(),i.moveTo(t*.38,e*.82),i.lineTo(t*.62,e*.18),i.stroke()}};function IM(i,t,e){const n=rs(i.g,.9,.9,256,256);n.mesh.geometry=new Oi(.45,40),n.mesh.position.set(t,e,.22);const s=te(i.g,.5,.5,.08,"#3b3330",t,e,.17,40);s.rotation.x=Math.PI/2,i.attach.push(s,n.mesh);const r=()=>{const{ctx:a,tex:o}=n;a.fillStyle="#fbf8f2",a.fillRect(0,0,256,256),a.translate(128,128),a.fillStyle="#3b3330";for(let d=0;d<12;d++)a.save(),a.rotate(d/12*Math.PI*2),a.fillRect(-3,-112,6,d%3?12:22),a.restore();const l=new Date,c=l.getMinutes(),h=l.getHours()%12+c/60,u=(d,f,g,_)=>{a.save(),a.rotate(d),a.fillStyle=_,a.fillRect(-g/2,-f,g,f+14),a.restore()};u(h/12*Math.PI*2,62,9,"#3b3330"),u(c/60*Math.PI*2,92,6,"#3b3330"),a.fillStyle="#e07a5f",a.beginPath(),a.arc(0,0,8,0,Math.PI*2),a.fill(),a.setTransform(1,0,0,1,0,0),o.needsUpdate=!0};r(),setInterval(r,3e4)}function kM(){const i=document.createElement("canvas");i.width=i.height=512;const t=i.getContext("2d"),e=8,n=512/e;for(let r=0;r<e;r++)for(let a=0;a<e;a++){t.fillStyle=`hsl(${170+Math.random()*8}, ${9+Math.random()*4}%, ${82+Math.random()*2.5}%)`,t.fillRect(r*n,a*n,n,n),t.globalAlpha=.05;for(let o=0;o<40;o++)t.fillStyle=Math.random()<.5?"#000":"#fff",t.fillRect(r*n+Math.random()*n,a*n+Math.random()*n,2,2);t.globalAlpha=1,t.fillStyle="rgba(60, 80, 80, 0.09)",t.fillRect(r*n,a*n,n,1.5),t.fillRect(r*n,a*n,1.5,n)}const s=new zi(i);return s.colorSpace=Ke,s.wrapS=s.wrapT=Ni,s.repeat.set(24.5/8,12.6/8),s.anisotropy=8,s}let Ha;function NM(i,t,e,n,s){if(!Ha){const a=document.createElement("canvas");a.width=256,a.height=64;const o=a.getContext("2d"),l=o.createLinearGradient(0,0,256,0);l.addColorStop(0,"rgba(255, 236, 200, 0.55)"),l.addColorStop(1,"rgba(255, 236, 200, 0)"),o.fillStyle=l,o.fillRect(0,0,256,64),Ha=new zi(a),Ha.colorSpace=Ke}const r=new yt(new gi(n,s),new dn({map:Ha,transparent:!0,depthWrite:!1,blending:ac,opacity:.5}));r.rotation.x=-Math.PI/2,r.position.set(t,.025,e),i.add(r)}let zl;function UM(){if(!zl){const i=cp();i.repeat.set(.5,.22),zl=new Bn({map:i,color:"#f0d6b4",roughness:.52})}return zl}let Zs;function OM(){if(Zs)return Zs;const i=document.createElement("canvas");i.width=384,i.height=128;const t=i.getContext("2d"),e=15,n=5,s=i.width/e,r=i.height/n,a=3;t.fillStyle="#cfcac1",t.fillRect(0,0,i.width,i.height);const o=(c,h,u,d)=>{t.fillStyle="#f7f5f1",t.fillRect(c,h,u,d),t.fillStyle="rgba(88, 84, 78, 0.22)",t.fillRect(c,h+d-2,u,2)};for(let c=0;c<n-1;c++)for(let h=0;h<e;h++)o(h*s+a,c*r+a,s-a*2,r-a*2);const l=(n-1)*r;for(const c of[0,1,2,11,12,13,14])o(c*s+a,l+a,s-a*2,r-a*2);return o(3*s+a,l+a,s*8-a*2,r-a*2),Zs=new zi(i),Zs.colorSpace=Ke,Zs.anisotropy=4,Zs}function md(i,t,e,n,s,r,a=500){const o=new qt;o.position.set(n,s,r),i.add(o);const l=new yt(new Ze(t+.08,e+.12,.05),["#272d38","#272d38","#272d38","#272d38","#1e232c","#3c4352"].map(h=>xe(h)));l.position.set(0,-.015,-.03),l.castShadow=!0,l.receiveShadow=!0,o.add(l),it(o,(t+.08)*.55,.035,.012,"#323a47",0,-e*.34,-.056).castShadow=!1;const c=rs(o,t,e,Math.round(t*a),Math.round(e*a));return c.mesh.position.set(0,.015,.002),{g:o,face:c}}function FM(i,t,e,n){const s=xe("#23272f",{roughness:.6});te(i,.11,.13,.025,"#2f3440",t,e+.012,n,14),te(i,.022,.022,.3,"#2f3440",t,e+.16,n,10);const r=new yt(new oi(.11,.022,6,16,Math.PI),s);r.position.set(t,e+.3,n),r.castShadow=!0,i.add(r);for(const a of[-.11,.11]){const o=te(i,.065,.065,.05,null,t+a,e+.28,n,14,s);o.rotation.z=Math.PI/2,o.castShadow=!0}}function zM(i,t,e,n){const s=xe("#f4c430",{roughness:.45}),r=new yt(new di(.075,12,10),s);r.position.set(t,e+.06,n),r.scale.set(1,.85,1.25),r.castShadow=!0,i.add(r);const a=new yt(new di(.05,12,10),s);a.position.set(t,e+.15,n-.05),a.castShadow=!0,i.add(a);const o=new yt(new ca(.022,.06,8),xe("#e8833a",{roughness:.5}));o.position.set(t,e+.14,n-.11),o.rotation.x=-Math.PI/2,i.add(o);for(const l of[-.02,.02]){const c=new yt(new di(.008,6,6),xe("#1a1a1a"));c.position.set(t+l,e+.17,n-.085),i.add(c)}}function BM(i,t,e,n,s){const r=new qt;r.position.set(t,e,n),r.rotation.y=-.4+s%2*.8,i.add(r),it(r,.26,.21,.02,"#3b3330",0,.12,0);const a=rs(r,.21,.16,84,64);a.mesh.position.set(0,.125,.012);const{ctx:o,canvas:l}=a;o.fillStyle="#cfe3ef",o.fillRect(0,0,l.width,l.height),o.fillStyle="#8fb0a0",o.beginPath(),o.moveTo(0,l.height),o.quadraticCurveTo(l.width*.5,l.height*.35,l.width,l.height),o.fill(),o.fillStyle="#f2cc8f",o.beginPath(),o.arc(l.width*.72,l.height*.3,7,0,Math.PI*2),o.fill(),a.tex.needsUpdate=!0;const c=it(r,.02,.1,.02,"#3b3330",0,.05,-.04);c.rotation.x=.35}function HM(i,t,e,n){const s=it(i,.3,.035,.38,"#44506b",t,e+.018,n);s.rotation.y=.18;const r=it(i,.27,.02,.35,"#f6f2e8",t,e+.028,n+.01);r.rotation.y=.18,te(i,.009,.009,.24,"#e07a5f",t+.04,e+.045,n,8).rotation.set(0,.5,Math.PI/2)}function VM(i,t,e,n,s){const r=new qt;r.position.set(e,0,n);const a=it(r,2.5,.1,1.15,null,0,.78,0,UM());a.receiveShadow=!0,it(r,2.54,.03,1.19,wt.woodDark,0,.742,0);for(const E of[-1.08,1.08])it(r,.09,.72,.16,wt.metal,E,.37,0),it(r,.13,.06,1,wt.metal,E,.03,0),it(r,.13,.05,.86,wt.metal,E,.715,0);it(r,1.95,.07,.08,wt.metal,0,.67,-.18),it(r,2,.3,.04,wt.woodDark,0,.57,-.5);const o=it(r,1.3,.05,.12,"#2a2e38",0,.5,-.3);o.castShadow=!1,it(r,.58,.62,.56,"#e6ded0",.78,.31,-.2);for(const E of[.17,.45]){it(r,.5,.24,.02,"#f1ebe0",.78,E,.09);const P=te(r,.013,.013,.16,"#8d94a3",.78,E,.105,8);P.rotation.z=Math.PI/2}it(r,.17,.07,.2,wt.metal,0,.87,-.47),te(r,.03,.035,.52,wt.metal,0,1.12,-.47,12);const l=it(r,.055,.055,.32,wt.metal,0,1.35,-.38);l.rotation.x=.3,it(r,.14,.14,.05,wt.metal,0,1.42,-.31);const c=md(r,1.5,.84,0,1.46,-.295);c.g.rotation.x=.05;const h=new dn({color:"#2a3442",toneMapped:!1}),u=new yt(new Oi(.014,12),h);u.position.set(.68,-.47,.03),c.g.add(u),s%3===1&&[["#f6d365",-.04,.09],["#f3a6b2",-.19,-.06]].forEach(([E,P,U])=>{const v=it(c.g,.11,.11,.004,E,.8,P,.02);v.rotation.z=U,v.castShadow=!1});const d=md(r,.6,.36,-.99,1.08,-.02,500);d.g.rotation.y=.62,it(d.g,.3,.03,.2,wt.metal,0,-.25,0),it(d.g,.06,.2,.06,wt.metal,0,-.14,0);const f=it(r,1.18,.008,.42,"#454d5e",0,.834,.16);f.castShadow=!1,it(r,.8,.022,.27,"#e9e6e1",-.02,.849,.15);const g=new yt(new gi(.76,.23),new Bn({map:OM(),roughness:.7}));g.rotation.x=-Math.PI/2,g.position.set(-.02,.861,.15),g.receiveShadow=!0,r.add(g);const _=new yt(new di(.055,12,8),xe("#e9e6e1"));_.position.set(.52,.843,.18),_.scale.set(1,.6,1.45),_.castShadow=!0,r.add(_),it(r,.012,.004,.05,"#9aa3b2",.52,.874,.15).castShadow=!1;const m=["#e07a5f","#3d7ea6","#f2cc8f","#81b29a"][s%4];te(r,.07,.065,.16,m,.66,.91,-.08,14);const p=new yt(new oi(.045,.012,6,12,Math.PI*1.2),xe(m));p.position.set(.73,.92,-.08),p.rotation.y=Math.PI/2,p.rotation.z=-.3,r.add(p);const y=new yt(new Oi(.062,14),xe("#4a3328",{roughness:.3}));y.rotation.x=-Math.PI/2,y.position.set(.66,.985,-.08),r.add(y),[()=>DM(r,.98,.83,-.38),()=>ap(r,1,.83,-.3),()=>Kc(r,.98,.83,-.32),()=>FM(r,1,.83,-.3),()=>zM(r,1,.83,-.28),()=>BM(r,1,.83,-.3,s)][s%6](),s%4===2&&HM(r,-.55,.835,-.18);const x=new qt;x.position.set(.86,.835,.44),r.add(x),it(x,.46,.022,.1,"#2f343f",0,.011,0);const S=rs(x,.42,.11,256,67);S.mesh.position.set(0,.07,.015),S.mesh.rotation.x=-.42,S.mesh.material=new Bn({map:S.tex,roughness:.75});const L=op(wt.chair);L.position.set(0,0,1.05),r.add(L),i.add(r),t.block(e-1.3,e+1.3,n-.7,n+.5);const T={index:s,x:e,z:n,seat:new R(e,0,n+1.05),seatY:ee,screen:c.face,side:d.face,plate:S,led:h,chair:L};return lp(T,{}),T}function op(i){const t=new qt,e=xe("#3c4250",{roughness:.9});it(t,.6,.07,.58,i,0,ee-.035,0);const n=it(t,.56,.05,.54,null,0,ee+.01,.01,e);n.castShadow=!1;const s=new qt;s.position.set(0,ee,.3),s.rotation.x=.12,t.add(s),it(s,.56,.3,.09,i,0,.19,0),it(s,.52,.34,.05,null,0,.52,.005,e);for(const r of[-.25,.25])it(s,.05,.36,.06,i,r,.52,0);it(s,.34,.13,.06,i,0,.79,-.01);for(const r of[-.33,.33]){it(t,.05,.22,.4,i,r,ee+.09,.06);const a=it(t,.09,.05,.44,null,r,ee+.21,.04,e);a.castShadow=!1}te(t,.055,.055,.18,"#6e7684",0,ee-.14,0,12),te(t,.042,.042,ee-.22,wt.metal,0,(ee-.22)/2+.06,0,10),te(t,.11,.13,.05,wt.metal,0,.08,0,14);for(let r=0;r<5;r++){const a=r/5*Math.PI*2,o=it(t,.07,.045,.3,wt.metal,0,.075,0);o.position.set(Math.sin(a)*.17,.075,Math.cos(a)*.17),o.rotation.y=a;const l=te(t,.035,.035,.025,"#22262e",Math.sin(a)*.31,.04,Math.cos(a)*.31,10);l.rotation.z=Math.PI/2,l.rotation.y=a}return t}function gd(i,t,e,n,s){const r=new qt;r.position.set(e,0,n),r.rotation.y=s,it(r,1.35,ee-.14,1.2,wt.couch,0,(ee-.14)/2,0),it(r,1.15,.14,1,"#6c8fb6",0,ee-.07,.05),it(r,1.35,.78,.26,wt.couch,0,ee+.25,-.47);for(const o of[-.54,.54])it(r,.27,.56,1.2,wt.couch,o,ee-.06,0);for(const[o,l]of[[-.55,-.5],[.55,-.5],[-.55,.5],[.55,.5]])te(r,.05,.04,.12,wt.woodDark,o,.06,l,8);i.add(r);const a=.75;return t.block(e-a,e+a,n-a,n+a),r}function GM(i,t,e,n){te(i,.26,.26,.08,n,t,ee-.04,e,20),te(i,.035,.035,ee-.09,wt.metal,t,(ee-.09)/2,e,8),te(i,.2,.22,.03,wt.metal,t,.015,e,16)}function vd(i,{title:t="",subtitle:e="",lines:n=[],accent:s="#7bd389",idle:r=!1,t:a=0}){const{ctx:o,canvas:l,tex:c}=i.screen,h=l.width,u=l.height,d=h/512,f=o.createLinearGradient(0,0,0,u);if(f.addColorStop(0,"#141c26"),f.addColorStop(1,"#0d131b"),o.fillStyle=f,o.fillRect(0,0,h,u),r){o.textAlign="center",o.fillStyle="#2f3a49",o.font=`600 ${34*d}px ${ci}`,o.fillText(t,h/2,u/2+4*d),o.fillStyle="#263040",o.font=`400 ${20*d}px ${ci}`,o.fillText(e,h/2,u/2+36*d),o.textAlign="left",c.needsUpdate=!0;return}o.fillStyle=s,o.fillRect(0,0,h,5*d),o.globalAlpha=.09,o.fillRect(0,5*d,h,76*d),o.globalAlpha=1,o.beginPath(),o.arc(30*d,40*d,6*d,0,Math.PI*2),o.fillStyle=s,o.globalAlpha=.55+.45*Math.sin(a*3),o.fill(),o.globalAlpha=1,o.fillStyle="#eaeff5",o.font=`650 ${26*d}px ${ci}`,o.fillText(t,46*d,48*d),o.fillStyle="#7d8a9c",o.font=`400 ${18*d}px ${ci}`,o.fillText(e,46*d,73*d),o.fillStyle="rgba(125, 138, 156, 0.22)",o.fillRect(24*d,92*d,1.5*d,u-104*d),o.font=`400 ${18*d}px ${PM}`;const g=n.slice(-8);g.forEach((_,m)=>{const p=m===g.length-1,y=116*d+m*23*d;o.globalAlpha=p?1:.45+m*.06,o.fillStyle=_.color||(p?"#eaeff5":"#8b98aa");let x=_.text;for(;o.measureText(x).width>h-56*d&&x.length>4;)x=x.slice(0,-2);x!==_.text&&(x=x.slice(0,-1)+"…"),o.fillText(x,38*d,y),o.globalAlpha=1}),Math.floor(a*2)%2===0&&(o.fillStyle=s,o.fillRect(38*d,116*d+g.length*23*d-14*d,9*d,17*d)),c.needsUpdate=!0}function lp(i,{name:t="",accent:e="#7d8a9c",state:n="open"}={}){const s=n==="working";i.led&&i.led.color.set(s?e:n==="open"?"#232a35":"#39455a");const r=i.plate;if(r){const{ctx:o,canvas:l,tex:c}=r;o.fillStyle="#2c323d",o.fillRect(0,0,l.width,l.height),o.fillStyle=n==="open"?"#454c5a":e,o.fillRect(0,0,9,l.height),o.fillStyle=n==="open"?"#8d97a6":"#f3f1ed",o.font=`650 30px ${ci}`,o.textBaseline="middle",o.fillText(t,26,l.height/2+1),o.textBaseline="alphabetic",c.needsUpdate=!0}const a=i.side;if(a){const{ctx:o,canvas:l,tex:c}=a,h=l.width,u=l.height;if(o.fillStyle=n==="open"?"#0b0f15":"#121a24",o.fillRect(0,0,h,u),n==="open"){o.fillStyle="#1b2430",o.beginPath(),o.arc(h/2,u/2,5,0,Math.PI*2),o.fill(),c.needsUpdate=!0;return}o.fillStyle=e,o.globalAlpha=.85,o.fillRect(0,0,h,4),o.globalAlpha=1,o.font=`600 ${Math.round(u*.1)}px ${ci}`,o.fillStyle="#6f7d8f",o.fillText(t.toUpperCase(),14,26),o.textAlign="right",o.fillStyle=s?e:"#4d5a6b",o.fillText(s?"ACTIVE":n==="away"?"OFFLINE":"IDLE",h-14,26),o.textAlign="left";let d=0;for(const f of t+n)d=(d*31+f.charCodeAt(0))%9973;for(let f=0;f<6;f++){const g=44+f*Math.round((u-58)/6),_=Math.max(4,Math.round(u*.045));o.fillStyle="#1b2531",o.fillRect(14,g,h-28,_),d=(d*31+17)%9973;const m=s?.25+d%70/100:.08+d%25/100;o.fillStyle=f===0&&s?e:"#35445a",o.fillRect(14,g,Math.round((h-28)*m),_)}c.needsUpdate=!0}}function $M(i){const t=new wM(vn,In),e=[],n=xe("#a97a50"),s=new Bn({map:cp(),roughness:.7}),r=new yt(new Ze(vn+.6,.7,In+.6),[n,n,s,n,n,n]);r.position.y=-.35,r.receiveShadow=!0,r.castShadow=!0,i.add(r);const a=new yt(new gi(160,160),new By({opacity:.14}));a.rotation.x=-Math.PI/2,a.position.y=-.72,a.receiveShadow=!0,i.add(a),i.add(WM(vn+16,In+16));const o=it(i,24.5,.02,12.6,null,0,.011,1.2,new Bn({map:kM(),roughness:1}));o.castShadow=!1;const l=[Va(i,vn+.6,0,-In/2-.15,0,[0,0,-1]),Va(i,vn+.6,0,In/2+.15,Math.PI,[0,0,1],[[-vn/2-.3,-19.2],[-16.8,vn/2+.3]]),Va(i,In,-vn/2-.15,0,Math.PI/2,[-1,0,0]),Va(i,In,vn/2+.15,0,-Math.PI/2,[1,0,0])],[c,,h,u]=l;t.block(-vn/2,vn/2,-In/2,-In/2+.2),t.block(-vn/2,-vn/2+.2,-In/2,In/2);for(const W of[-6,0,6]){const A=-W;h.attach.push(it(h.g,3.6,2.2,.06,wt.glass,A,2.2,.15,{emissive:"#bfe3f5",emissiveIntensity:.45,roughness:.15}),it(h.g,3.8,.12,.14,wt.trim,A,1.08,.2),it(h.g,3.8,.12,.14,wt.trim,A,3.32,.2),it(h.g,.1,2.3,.14,wt.trim,A,2.2,.2))}for(const W of[-6,0,6])NM(i,-17.4,W,5,3.6);const d=[];[[-9,-3],[-3,-3],[3,-3],[9,-3],[-9,5],[-3,5],[3,5],[9,5]].forEach(([W,A],It)=>d.push(VM(i,t,W,A,It)));const f=["#e07a5f","#3d7ea6","#f2cc8f","#81b29a","#9c6ade","#e5989b","#2a9d8f","#577590"];for(const W of[-18.4,-16.2,-14,-11.8]){it(i,2,3.2,.7,wt.woodDark,W,1.6,-14.5);for(let A=0;A<4;A++){const It=.45+A*.75;it(i,1.86,.05,.62,wt.wood,W,It-.04,-14.42);let Ct=W-.85;for(;Ct<W+.8;){const Bt=.1+Math.random()*.1,Dt=.4+Math.random()*.22;it(i,Bt,Dt,.45,f[Math.floor(Math.random()*f.length)],Ct+Bt/2,It+Dt/2,-14.4),Ct+=Bt+.02}}}t.block(-19.6,-10.7,-15,-14);for(const W of[12,13.4,14.8,16.2,17.6]){it(i,1.2,2.7,1,wt.rack,W,1.35,-14.4);for(let A=0;A<9;A++){const It=it(i,.07,.07,.03,"#000",W-.4+A%3*.12,.5+Math.floor(A/3)*.7+Math.random()*.2,-13.88,new Bn({color:"#0a0a0a",emissive:["#4ade80","#60a5fa","#fbbf24"][A%3],emissiveIntensity:1.2}));It.castShadow=!1,e.push(It)}for(let A=0;A<6;A++)it(i,1,.02,.02,"#4b5261",W,.35+A*.42,-13.89)}t.block(11.2,18.4,-15,-13.7);const g=new qt;g.position.set(-18.6,0,0);const _=new yt(new zn(.35,.45,.9,16),xe(wt.woodDark));_.position.y=.45;const m=new yt(new di(.45,24,16),xe("#4f8fc0",{roughness:.5}));m.position.y=1.35;const p=new yt(new Sr(.46,1),xe("#7fb069",{flatShading:!0,transparent:!0,opacity:.85}));p.position.y=1.35,p.scale.set(1,.9,.7);for(const W of[_,m,p])W.castShadow=!0,g.add(W);i.add(g),t.block(-19.2,-18,-.6,.6);const y=new qt;y.position.set(15.6,0,-8),it(y,5,2.4,.08,wt.board,0,1.9,0,{roughness:.4}),it(y,5.2,.1,.14,wt.metal,0,.66,.02),it(y,.08,1.9,.08,wt.metal,-2.3,.6,0),it(y,.08,1.9,.08,wt.metal,2.3,.6,0);const x=rs(y,4.8,2.2,640,290);x.mesh.position.set(0,1.9,.045),i.add(y),t.block(13,18.2,-8.4,-7.6);const S=it(i,9,.02,5.4,wt.rug,-14,.01,10.6);S.castShadow=!1;const L=new qt;L.position.set(-14.5,0,8.4),it(L,5,ee-.14,1.2,wt.couch,0,(ee-.14)/2,0),it(L,5,.8,.3,wt.couch,0,ee+.26,-.48);for(const W of[-2.35,2.35])it(L,.3,.6,1.2,wt.couch,W,ee-.08,0);for(const W of[-1.5,0,1.5])it(L,1.4,.14,1,"#6c8fb6",W,ee-.07,.05);for(const[W,A]of[[-2.2,-.5],[2.2,-.5],[-2.2,.5],[2.2,.5]])te(L,.05,.04,.12,wt.woodDark,W,.06,A,8);i.add(L),t.block(-17,-12,7.8,9),gd(i,t,-17.3,10.9,Math.PI/2),gd(i,t,-12,10.9,-Math.PI/2),it(i,2.4,.08,1.2,wt.wood,-14.5,.48,10.6);for(const[W,A]of[[-1.1,-.5],[1.1,-.5],[-1.1,.5],[1.1,.5]])it(i,.06,.44,.06,wt.metal,-14.5+W,.22,10.6+A);t.block(-15.8,-13.2,10,11.2),it(i,1.3,.95,3.2,"#efe9df",-19.3,.475,12),it(i,.55,.65,.5,"#2c2f36",-19.35,1.28,11.4),it(i,.12,.08,.12,"#c0392b",-19.05,1.4,11.4,{emissive:"#c0392b",emissiveIntensity:.6});for(let W=0;W<3;W++){const A=new yt(new zn(.07,.06,.14,10),xe("#ffffff"));A.position.set(-19.2,1.02,12.5+W*.25),i.add(A)}t.block(-20,-18.6,10.4,13.6);const T=new qt;T.position.set(-11,0,12),te(T,.3,.34,.04,wt.metal,0,.02,0,20),te(T,.04,.04,1.05,wt.metal,0,.55,0,10),te(T,.48,.48,.05,wt.wood,0,1.08,0,28);for(const[W,A,It]of[[-.18,.08,"#e07a5f"],[.2,-.1,"#3d7ea6"]])te(T,.06,.05,.13,It,W,1.17,A,12);i.add(T),t.block(-11.5,-10.5,11.5,12.5),c.attach.push(it(c.g,9.4,3.5,.08,"#d9cdbb",0,2.2,.2));const E=rs(c.g,9,3.2,1536,546);E.mesh.position.set(0,2.2,.26),c.attach.push(E.mesh);const P=new qt;P.position.set(15.5,0,10.6),it(P,3.4,1.05,.9,"#efe9df",0,.525,0),it(P,3.5,.06,1,wt.wood,0,1.08,0),it(P,.9,.55,.05,wt.metal,-.8,1.4,-.25);const U=rs(P,1.6,.34,400,85);U.mesh.position.set(0,.62,.456),U.ctx.fillStyle="#efe9df",U.ctx.fillRect(0,0,400,85),U.ctx.fillStyle="#1d1b18",U.ctx.font=`650 38px ${ci}`,U.ctx.textAlign="center",U.ctx.fillText("Chief of Staff",200,56),U.tex.needsUpdate=!0;const v=op(wt.chair);v.position.set(0,0,-1),v.rotation.y=Math.PI,P.add(v),i.add(P),t.block(13.7,17.3,10.1,11.1);const b=it(i,2.4,.02,1.6,"#b9a58f",18.2,.01,13.4);b.castShadow=!1,Ur(c,-7.6,2.5,1.6,1.1,Or.sunset),IM(c,7.6,2.7),Ur(u,1.4,2.4,1,1.4,Or.arcs),Ur(u,3,2.4,1,1.4,Or.blocks),Ur(u,4.6,2.4,1,1.4,Or.leaf),Ur(h,11,2.5,1.2,.9,Or.blocks,"#c39a6b");const I=new qt;I.position.set(19.35,0,3),it(I,.7,.75,3.6,wt.woodDark,0,.4,0),it(I,.76,.05,3.7,wt.wood,0,.8,0);for(const W of[-1.2,0,1.2])it(I,.02,.6,1.1,"#9a7350",-.36,.4,W);for(const[W]of[[-1.7],[1.7]])it(I,.6,.06,.06,wt.metal,0,.03,W);Kc(I,0,.82,-1.1,4),ap(I,0,.82,.2),te(I,.11,.08,.38,"#3d7ea6",.05,1.01,1.2,14,{roughness:.35});for(let W=0;W<3;W++){const A=te(I,.008,.008,.5,"#5f8f6b",.05+(W-1)*.04,1.4,1.2,4);A.rotation.z=(W-1)*.3;const It=new yt(new Sr(.06,0),xe(["#f2cc8f","#e5989b","#fff"][W],{flatShading:!0}));It.position.set(.05+(W-1)*.12,1.64,1.2),I.add(It)}i.add(I),t.block(18.9,20,1.1,4.9);const O=new qt;O.position.set(-1,0,11.6),it(O,5.2,.08,1.4,wt.wood,0,.78,0);for(const W of[-2.3,2.3])it(O,.08,.74,1.1,wt.metal,W,.38,0);for(const W of[-1.7,0,1.7])for(const A of[-1.05,1.05])GM(O,W,A,["#e07a5f","#f2cc8f","#81b29a"][Math.round(W+2)%3]);Kc(O,-1.4,.82,.1,2),te(O,.06,.06,.14,"#ffffff",.5,.89,-.2,12);const $=new qt;$.position.set(1.3,.82,.1),it($,.5,.025,.35,"#c7ccd4",0,.012,0);const K=it($,.5,.34,.02,"#c7ccd4",0,.17,-.17);K.rotation.x=-.25,O.add($);for(const W of[-1.6,1.6]){te(O,.02,.02,1.6,"#2f3440",W,3.4,0,6);const A=te(O,.06,.32,.28,"#2f3440",W,2.55,0,20,{roughness:.5});A.castShadow=!1;const It=new yt(new Oi(.29,20),new dn({color:"#fff1c4"}));It.rotation.x=Math.PI/2,It.position.set(W,2.405,0),O.add(It)}i.add(O),t.block(-3.8,1.8,10.3,12.9);const z=new qt;z.position.set(Xe.x,0,Xe.z);const Z=.84;it(z,3.7,.22,2.1,wt.woodDark,0,.71,0);for(const[W,A]of[[-1.55,-.85],[1.55,-.85],[-1.55,.85],[1.55,.85]])it(z,.2,.62,.2,wt.woodDark,W,.31,A);it(z,3.5,.03,1.9,"#2f7a57",0,Z-.015,0,{roughness:1});const V=[];for(const W of[-1,1]){for(const A of[-1,1])V.push([1.32,.1,.25,W*.82,A*.925]);V.push([.25,.1,1.36,W*1.725,0])}for(const[W,A,It,Ct,Bt]of V)it(z,W,A,It,wt.wood,Ct,Z+.05,Bt);for(const W of[-1,1])for(const A of[-1,1])it(z,.3,.1,.3,wt.wood,W*1.83,Z+.05,A*.98);for(const[W,A,It,Ct]of[[1.28,.06,.82,.83],[1.28,.06,.82,-.83],[1.28,.06,-.82,.83],[1.28,.06,-.82,-.83]])it(z,W,.05,A,"#256646",It,Z+.025,Ct).castShadow=!1;for(const W of[-1,1])it(z,.06,.05,1.3,"#256646",W*1.57,Z+.025,0).castShadow=!1;const at=new dn({color:"#0c0d10"});for(const[W,A]of[[-1.6,-.8],[1.6,-.8],[-1.6,.8],[1.6,.8],[0,-.835],[0,.835]]){const It=new yt(new zn(.15,.15,.02,20),at);It.position.set(W,Z+.002,A),z.add(It)}i.add(z),t.block(Xe.x-1.95,Xe.x+1.95,Xe.z-1.15,Xe.z+1.15);const ct=new qt;ct.position.set(-18,0,8.2),te(ct,.22,.24,.04,"#2f3440",0,.02,0,20),te(ct,.025,.025,1.7,"#2f3440",0,.87,0,8);const _t=te(ct,.22,.3,.38,"#f3e7d3",0,1.85,0,24,{emissive:"#ffe2a8",emissiveIntensity:.35,roughness:.9});_t.castShadow=!1,i.add(ct),t.block(-18.4,-17.6,7.8,8.6);const $t=it(i,5,.02,3.2,"#c9b79c",15.5,.012,12.6,{roughness:1});$t.castShadow=!1;const Jt=it(i,4.6,.022,2.8,"#ddd0bb",15.5,.013,12.6,{roughness:1});Jt.castShadow=!1;const X=[[-19,-9.5,1.1,"tall"],[10,-14,1,"snake"],[-9.8,-14.2,.9,"bush"],[19,-11,1.2,"tall"],[-10.3,14,1,"bush"],[6.2,13.8,1.1,"tall"],[19,8.5,1,"snake"],[19.2,0,.9,"bush"],[-19.1,14.2,.8,"snake"],[11.6,13.9,1,"bush"]];for(const[W,A,It,Ct]of X)LM(i,t,W,A,It,Ct);const et={n:Math.PI,s:0,w:-Math.PI/2,e:Math.PI/2},ft=W=>W.map(([A,It,Ct,Bt,Dt])=>({pos:new R(A,0,It),face:et[Ct],pose:Bt,seatY:Dt,taken:null})),ot={library:{label:"Library",spots:ft([[-17.6,-12.9,"n","read"],[-15.3,-12.9,"n","read"],[-13.1,-12.9,"n","read"],[-11,-12.9,"n","read"]])},servers:{label:"Server room",spots:ft([[12.7,-12.6,"n","type"],[14.1,-12.6,"n","type"],[15.5,-12.6,"n","type"],[16.9,-12.6,"n","type"]])},window:{label:"Research window",spots:ft([[-17.5,-6,"w","gaze"],[-17.5,-2.6,"w","gaze"],[-17.5,2.6,"w","gaze"],[-17.5,6,"w","gaze"]])},whiteboard:{label:"Whiteboard",spots:ft([[13.9,-6.4,"n","write"],[15.2,-6.4,"n","write"],[16.5,-6.4,"n","write"],[17.8,-6.4,"n","write"]])},lounge:{label:"Break room",spots:ft([[-16,8.5,"s","couch",ee],[-14.5,8.5,"s","couch",ee],[-13,8.5,"s","couch",ee],[-17.2,10.9,"e","couch",ee],[-11.9,10.9,"w","couch",ee],[-2.7,10.55,"s","sit",ee],[-1,10.55,"s","sit",ee],[.7,10.55,"s","sit",ee],[-2.7,12.65,"n","sit",ee],[-1,12.65,"n","sit",ee],[.7,12.65,"n","sit",ee],[-17.9,11.4,"w","mug"],[-17.9,12.8,"w","mug"],[-11.95,12,"e","mug"],[-10.05,12,"w","mug"]])}},At=new R(15.3,0,-2.4),Tt=Array.from({length:10},(W,A)=>{const It=Math.PI+A/10*Math.PI*2,Ct=new R(At.x+Math.sin(It)*2.3,0,At.z+Math.cos(It)*2.3);return{pos:Ct,face:Math.atan2(At.x-Ct.x,At.z-Ct.z)}});ot.lounge.spots.push({pos:new R(Xe.x-.9,0,Xe.z-1.65),face:et.s,pose:"stand",taken:null,game:!0},{pos:new R(Xe.x+.9,0,Xe.z+1.65),face:et.n,pose:"stand",taken:null,game:!0});const zt=(W,A,It,Ct,Bt)=>({pos:new R(W,0,A),face:Math.atan2(It-W,Ct-A),pose:Bt,taken:null});return ot.hotdesk={label:"Hot desks",spots:[-4.5,-2.7,-.9,.9,2.7,4.5].map(W=>zt(W,-13.4,W,-15,"read"))},ot.poolside={label:"Pool table",spots:[[4.9,10.9],[10.3,10.9],[9.6,8.8],[5.6,8.8]].map(([W,A])=>zt(W,A,Xe.x,Xe.z,"mug"))},ot.coffee={label:"Coffee",spots:ot.lounge.spots.filter(W=>W.pose==="mug")},ot.huddle={label:"Break-room table",spots:[[-4.5,11],[-4.5,12.2],[2.5,11],[2.5,12.2],[-1.85,9.6],[-.15,9.6]].map(([W,A])=>zt(W,A,-1,11.6,"stand"))},{grid:t,desks:d,stations:ot,pool:z,standup:Tt,board:E,scribble:x,blinkers:e,globe:p,slab:r,updateWalls:(W,A,It)=>jM(l,W,A,It),door:new R(18.6,0,14.4),reception:{seat:new R(15.5,0,9.6),seatY:ee}}}function cp(){const i=document.createElement("canvas");i.width=i.height=1024;const t=i.getContext("2d"),e=16,n=i.height/e;for(let r=0;r<e;r++){let a=-Math.random()*400;for(;a<i.width;){const o=380+Math.random()*520,l=73+Math.random()*3.5;t.fillStyle=`hsl(${32+Math.random()*3}, ${33+Math.random()*5}%, ${l}%)`,t.fillRect(a,r*n,o,n),t.globalAlpha=.045;for(let c=0;c<6;c++)t.fillStyle=Math.random()<.5?"#7a5634":"#fff6e8",t.fillRect(a,r*n+Math.random()*n,o,1+Math.random()*2);t.globalAlpha=1,t.fillStyle="rgba(90, 60, 35, 0.22)",t.fillRect(a,r*n,2,n),a+=o}t.fillStyle="rgba(90, 60, 35, 0.18)",t.fillRect(0,r*n,i.width,2)}const s=new zi(i);return s.colorSpace=Ke,s.wrapS=s.wrapT=Ni,s.repeat.set(vn/8,In/8),s.anisotropy=8,s}function WM(i,t){const e=document.createElement("canvas");e.width=e.height=256;const n=e.getContext("2d"),s=n.createRadialGradient(128,128,30,128,128,128);s.addColorStop(0,"rgba(60, 40, 20, 0.28)"),s.addColorStop(.6,"rgba(60, 40, 20, 0.12)"),s.addColorStop(1,"rgba(60, 40, 20, 0)"),n.fillStyle=s,n.fillRect(0,0,256,256);const r=new zi(e),a=new yt(new gi(i,t),new dn({map:r,transparent:!0,depthWrite:!1}));return a.rotation.x=-Math.PI/2,a.position.y=-.715,a}const rr=4.2,XM=.5;function Va(i,t,e,n,s,r,a=[[-t/2,t/2]]){const o=new qt;o.position.set(e,0,n),o.rotation.y=s;const l=new qt,c=new qt;o.add(l,c);for(const[u,d]of a){const f=new yt(new Ze(d-u,rr,.3),xe(wt.wall));f.position.set((u+d)/2,rr/2,0),f.castShadow=f.receiveShadow=!0,l.add(f);const g=new yt(new Ze(d-u,.1,.36),xe("#cbbba3"));g.position.set((u+d)/2,.05,0),c.add(g);const _=new yt(new Ze(d-u,.22,.04),xe(wt.trim));_.position.set((u+d)/2,.11,.17),o.add(_)}i.add(o);const h={g:o,body:l,cap:c,outward:new R(...r),h:rr,attach:[]};return c.position.y=rr,h}const _d=new R;function jM(i,t,e,n){_d.subVectors(t.position,e).setY(0).normalize();for(const s of i){const r=s.outward.dot(_d)>.2?XM:rr;s.h+=(r-s.h)*Math.min(1,n*7),s.body.scale.y=s.h/rr,s.cap.position.y=s.h;for(const a of s.attach)a.visible=s.h>3.4}}const qM={queued:0,working:1,done:2,failed:2,stopped:2},YM={queued:"#fde68a",working:"#bfdbfe",done:"#bbf7d0",failed:"#fecaca",stopped:"#e5e7eb"};function hp(i,t){const{ctx:e,canvas:n,tex:s}=i,r=n.width,a=n.height;e.fillStyle="#fbfaf7",e.fillRect(0,0,r,a);const o=["Queued","Working","Shipped"],l=r/3;o.forEach((c,h)=>{e.fillStyle="#1d1b18",e.font=`650 34px ${ci}`,e.fillText(c,h*l+28,54),h&&(e.fillStyle="#e7e1d7",e.fillRect(h*l,20,3,a-40)),t.filter(d=>qM[d.status]===h).sort((d,f)=>(f.endedAt||f.queuedAt)-(d.endedAt||d.queuedAt)).slice(0,6).forEach((d,f)=>{const g=h*l+28+f%2*(l/2-18),_=80+Math.floor(f/2)*150,m=l/2-36,p=130;e.save(),e.translate(g+m/2,_+p/2),e.rotate((d.id.charCodeAt(0)%7-3)*.008),e.fillStyle="rgba(0,0,0,0.08)",e.fillRect(-m/2+4,-p/2+6,m,p),e.fillStyle=YM[d.status],e.fillRect(-m/2,-p/2,m,p),e.fillStyle="#1d1b18",e.font=`600 22px ${ci}`,KM(e,d.title,-m/2+14,-p/2+34,m-28,26,3),e.fillStyle="#5b554c",e.font=`400 18px ${ci}`,e.fillText(d.repo.slice(0,22),-m/2+14,p/2-14),e.restore()})}),s.needsUpdate=!0}function KM(i,t,e,n,s,r,a){const o=String(t).split(/\s+/);let l="",c=0;for(let h=0;h<o.length;h++){const u=l?l+" "+o[h]:o[h];if(i.measureText(u).width>s&&l){if(c===a-1){i.fillText(l+"…",e,n+c*r);return}i.fillText(l,e,n+c*r),l=o[h],c++}else l=u}i.fillText(l,e,n+c*r)}function Zc(i,t){const{ctx:e,canvas:n,tex:s}=i;e.fillStyle="#fbfaf7",e.fillRect(0,0,n.width,n.height),e.fillStyle="#2f5d8a",e.font='600 30px "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive',e.fillText("Today",26,46),e.font='400 24px "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive',t.slice(0,7).forEach((r,a)=>{e.fillStyle=r.done?"#6b8f71":"#3a3a3a";const o=(r.done?"✓ ":"• ")+r.text;e.fillText(o.length>44?o.slice(0,43)+"…":o,30,86+a*30)}),s.needsUpdate=!0}const xd=(i,t,e)=>{let n=((t-i+Math.PI)%(Math.PI*2)+Math.PI*2)%(Math.PI*2)-Math.PI;return i+n*e},Fr=(i,t)=>i+Math.random()*(t-i);function Ga(i,t=34){let e=String(i||"").replace(/\s+/g," ").trim();const n=e.search(/[,;:]| \u2014 | - | and | with | so that | in order /i);if(n>11&&(e=e.slice(0,n)),e.length<=t)return e;const s=e.lastIndexOf(" ",t);return e.slice(0,s>t*.6?s:t).replace(/[,.;:]$/,"")+"…"}const yd=["coffee?","anyone seen my mug","back in 5","nice weather","who broke main","lunch soon?","reading the docs, honestly","standup when"];let Bl=null;function ZM(){if(Bl)return Bl;const i=document.createElement("canvas");i.width=i.height=64;const t=i.getContext("2d"),e=t.createRadialGradient(32,32,4,32,32,32);return e.addColorStop(0,"rgba(40, 28, 16, 0.32)"),e.addColorStop(1,"rgba(40, 28, 16, 0)"),t.fillStyle=e,t.fillRect(0,0,64,64),Bl=new zi(i)}class Nh{constructor(t,e,n,s={}){this.staff=t,this.id=t.id,this.name=t.name,this.world=e,this.desk=s.desk||e.desks[e.agentIndex(t.id)],this.deskFace=s.face??Math.PI,this.root=new qt,this.fig=new Jr(t),this.root.add(this.fig.group),this.body=this.fig.body;const r=new yt(new Oi(.5,24),new dn({map:ZM(),transparent:!0,depthWrite:!1}));r.rotation.x=-Math.PI/2,r.position.y=.015,this.root.add(r),this.ring=new yt(new Lh(.55,.68,40),new dn({color:t.shirt,transparent:!0,opacity:.9})),this.ring.rotation.x=-Math.PI/2,this.ring.position.y=.03,this.ring.visible=!1,this.root.add(this.ring),this.root.traverse(c=>{c.userData.agentId=t.id}),e.scene.add(this.root),this.pos=this.root.position,this.heading=0,this.path=[],this.goal=null,this.placeKey=null,this.spot=null,this.pose="stand",this.want="lounge",this.dwellUntil=0,this.wanderAt=0,this.chatAt=Fr(8,30),this.anim=null,this.job=null,this.lines=[],this.phase=Math.random()*10,this.label=document.createElement("div"),this.label.className="agent-label";const a=document.createElement("div");a.className="bubble";const o=document.createElement("div");o.className="name";const l=document.createElement("i");/^#[0-9a-f]{3,8}$/i.test(t.shirt??"")&&(l.style.background=t.shirt),o.append(l,String(t.name??"")),this.label.append(a,o),this.bubbleEl=this.label.querySelector(".bubble"),n.appendChild(this.label),this.say("")}say(t,e="",n=0){t!==this.bubbleText&&(this.labelDirty=!0),this.bubbleText=t,this.bubbleEl.textContent=t,this.bubbleEl.className="bubble"+(e?" "+e:""),this.bubbleEl.style.display=t?"":"none",this.bubbleUntil=n?(this.now||0)+n/1e3:0}teleport(t){const e=this.resolve(t);e&&(this.pos.copy(e.pos),this.heading=e.face,this.root.rotation.y=e.face,this.goal=e,this.path=[],this.arrive(0))}resolve(t,e=!1){if(t==="desk")return{key:t,pos:this.desk.seat.clone(),face:this.deskFace,pose:"desk",seatY:this.desk.seatY};if(t==="visit")return this.visitTarget;if(t==="standup")return this.meeting;if(t==="door")return{key:t,pos:this.world.door.clone(),face:Math.PI,pose:"stand"};const n=this.world.stations[t];if(!n)return null;let s=!e&&this.spot&&n.spots.includes(this.spot)?this.spot:null;if(!s){const a=n.spots.filter(l=>!l.game&&(!l.taken||l.taken===this.id)),o=e?a.filter(l=>l!==this.spot):a;s=(o.length?o:a)[Math.floor(Math.random()*(o.length||a.length))]}if(!s)return t==="lounge"?null:this.resolve("desk");this.spot&&this.spot!==s&&(this.spot.taken=null),s.taken=this.id,this.spot=s;const r=t==="lounge"?0:.12;return{key:t,pos:s.pos.clone().add(new R(Fr(-r,r),0,Fr(-r,r))),face:s.face,pose:s.pose,seatY:s.seatY}}goTo(t,e,n=!1){t==="desk"&&this.spot&&(this.spot.taken=null,this.spot=null);const s=this.resolve(t,n);s&&(this.goal=s,this.placeKey=null,this.path=this.world.grid.path(this.pos.x,this.pos.z,s.pos.x,s.pos.z),this.path.length||this.arrive(e))}arrive(t){const e=this.goal;this.pos.set(e.pos.x,0,e.pos.z),this.placeKey=e.key,this.pose=e.pose,this.seatY=e.seatY,this.dwellUntil=t+(e.key==="desk"?.8:e.key==="lounge"?0:e.key==="visit"?3.4:e.key==="standup"?.5:2.4),e.key==="lounge"&&(this.wanderAt=t+Fr(18,40))}assign(t,e=!1){this.job=t,this.anim=null,this.want="desk",this.lines=[],this.say("On it","",0),e&&this.teleport("desk")}visit(t,e){const n=this.world.grid,s=[[1.1,0],[-1.1,0],[0,1.1],[0,-1.1],[.9,.9],[-.9,.9]],[r,a]=s.find(([l,c])=>!n.blocked(...n.cellOf(t.pos.x+l,t.pos.z+c)))||[1.1,0],o=new R(t.pos.x+r,0,t.pos.z+a);this.visitTarget={key:"visit",pos:o,face:Math.atan2(t.pos.x-o.x,t.pos.z-o.z),pose:"talk"},this.afterVisit=this.want==="visit"?this.afterVisit:this.want,this.want="visit",this.placeKey=null,this.path=[],this.spot&&(this.spot.taken=null,this.spot=null),this.say(Ga(e,52),"talk",0)}onLog(t){if(!this.job)return;const e=(...r)=>!this.meeting&&this.say(...r),n={tool:null,text:"#e8edf3",error:"#f87171",thinking:"#64748b",system:"#64748b"}[t.kind],s=r=>{this.want==="visit"?this.afterVisit=r:this.want=r};if(t.kind==="tool")s("desk"),e(Ga(t.summary)),this.lines.push({text:"› "+t.summary,color:n});else if(t.kind==="text"){s("desk");const r=t.summary.split(new RegExp("(?<=[.!?])\\s|\\n"))[0];e(Ga(r,44)),this.lines.push({text:r,color:n})}else t.kind==="thinking"?e("thinking…","thinking"):t.kind==="error"?(e(t.blocked?"Needs clearance":"Hm, that failed","warn"),this.lines.push({text:"✕ "+t.summary.split(`
|
|
4301
|
-
`)[0],color:n})):t.kind==="system"&&(this.lines.push({text:t.summary,color:n}),t.wait&&(s("desk"),e(Ga(t.summary,30)+"…","thinking")));this.lines.length>40&&this.lines.splice(0,this.lines.length-40)}meet(t,e=!1){if(this.meeting={key:"standup",pos:t.pos.clone(),face:t.face,pose:"stand"},this.spot&&(this.spot.taken=null,this.spot=null),e)return this.teleport("standup");this.want!=="visit"&&(this.path=[],this.placeKey=null)}adjourn(){this.meeting=null,this.placeKey==="standup"&&(this.placeKey=null)}speak(t){this.say(t,"talk",5200),this.anim={kind:"talk",until:(this.now||0)+4.8}}leave(){this.leaving=!0,this.want="door",this.spot&&(this.spot.taken=null,this.spot=null),this.say("Heading home","idle",3e3)}stay(){this.leaving=!1,this.want="lounge",this.say("Oh, staying!","good",2500)}dispose(){this.spot&&(this.spot.taken=null),this.world.scene.remove(this.root),this.label.remove()}finish(t){const e=this.now||0;this.anim={kind:t==="done"?"celebrate":"slump",until:e+2.2},this.say(t==="done"?"Shipped it!":t==="waiting"?"Need your answer":t==="stopped"?"Okay, stopping":"Hit a wall",t==="done"?"good":"warn",4e3),this.job=null,this.afterVisit=null,this.want="lounge"}think(t){var s;if(this.anim&&t<this.anim.until)return;this.anim=null,this.bubbleUntil&&t>this.bubbleUntil&&this.say("");const e=this.meeting&&!this.leaving&&this.want!=="visit"?"standup":this.want;if(this.path.length){((s=this.goal)==null?void 0:s.key)==="lounge"&&e!=="lounge"&&this.goTo(e,t);return}if(t<this.dwellUntil)return;if(this.leaving&&this.placeKey==="door"){this.gone=!0;return}this.placeKey==="visit"&&this.want==="visit"&&(this.want=this.job?this.afterVisit||"desk":"lounge",this.afterVisit=null,this.bubbleEl.classList.contains("talk")&&this.say(""));const n=this.meeting&&!this.leaving&&this.want!=="visit"?"standup":this.want;n!==this.placeKey?this.goTo(n,t):n==="lounge"&&t>this.wanderAt&&this.goTo("lounge",t,!0),!this.job&&!this.meeting&&!this.chatting&&t>this.chatAt&&(this.chatAt=t+Fr(25,60),Math.random()<.5&&this.say(yd[Math.floor(Math.random()*yd.length)],"idle",3500))}update(t,e){var s;this.now=e,this.think(e);let n=!1;if(this.path.length){const[r,a]=this.path[0],o=r-this.pos.x,l=a-this.pos.z,c=Math.hypot(o,l),h=3.4*t;c<=h?(this.pos.x=r,this.pos.z=a,this.path.shift(),this.path.length||this.arrive(e)):(this.pos.x+=o/c*h,this.pos.z+=l/c*h,this.heading=xd(this.heading,Math.atan2(o,l),Math.min(1,t*12)),n=!0)}!n&&this.goal&&!this.path.length&&(this.heading=xd(this.heading,this.goal.face,Math.min(1,t*8))),this.root.rotation.y=this.heading,this.animate(n?"walk":((s=this.anim)==null?void 0:s.kind)||this.pose,t,e)}animate(t,e,n){var a;this.fig.pose(t,e,n+this.phase,{typing:!!this.job&&!this.job.waiting&&this.job.id!=="idle",waiting:!!((a=this.job)!=null&&a.waiting),seatY:this.seatY});const s=this.bubbleEl.className,r=t==="celebrate"?"happy":t==="slump"||s.includes("warn")?"worried":t==="talk"||s.includes("idle")&&this.bubbleText?"talk":s.includes("thinking")?"think":s.includes("good")?"happy":"neutral";this.fig.express(r,e,n+this.phase)}placeLabel(t,e,n){const s=new R(this.pos.x,this.body.position.y+2.5+(this.fig.look.hair==="afro"?.2:0),this.pos.z).project(t);if(this.onScreen=s.z<=1,!this.onScreen){this.label.style.display="none",this.lift=0;return}this.label.style.display="",this.anchorX=(s.x*.5+.5)*e,this.anchorY=(-s.y*.5+.5)*n,this.depth=s.z,this.label.style.zIndex=String(Math.round((1-s.z)*1e4)),(this.labelDirty||!this.labelW)&&this.measureLabel()}measureLabel(){this.label.offsetWidth&&(this.labelDirty=!1,this.labelW=this.label.offsetWidth,this.labelH=this.label.offsetHeight)}labelBox(t){const e=this.anchorY-t;return{left:this.anchorX-this.labelW/2,right:this.anchorX+this.labelW/2,top:e-this.labelH,bottom:e}}setLift(t,e){const n=this.lift===void 0?1:Math.min(1,e*9);this.lift=(this.lift||0)+(t-(this.lift||0))*n,Math.abs(this.lift-t)<.4&&(this.lift=t),this.label.style.transform=`translate(-50%, -100%) translate(${this.anchorX}px, ${this.anchorY-this.lift}px)`}setBuried(t){t!==this.buried&&(this.buried=t,this.label.classList.toggle("buried",t))}setCrowded(t,e){t?this.uncrowdAt=e+.6:this.crowded&&e<(this.uncrowdAt||0)&&(t=!0),t!==this.crowded&&(this.crowded=t,this.label.classList.toggle("crowded",t),this.measureLabel())}setSelected(t){this.ring.visible=t,this.label.classList.toggle("selected",t)}}const $a=(i,t)=>i+Math.random()*(t-i),Qr=i=>i[Math.floor(Math.random()*i.length)];async function ts(i,t,e){const n=await fetch(i,t===void 0?{method:e||"GET"}:{method:e||"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`Request failed (${n.status})`);return n.json().catch(()=>({}))}const JM=[["Coffee machine is making that noise again.","It does that when it likes you.","It has never liked me."],["Weekend plans, {b}?","Sleep, then more sleep.","Ambitious. I respect it."],["Did you see the size of that last diff?","I saw it. I chose not to look closer.","Wise."],["{b}, tabs or spaces?","Whatever the linter says.","Diplomatic answer.","It's the only safe one in here."],["I renamed one variable and forty tests broke.","Only forty? Lucky.","You have a dark sense of luck, {b}."],["Who keeps leaving one sip in the coffee pot?","Not me.","That is exactly what someone guilty would say."],["Favourite error message?",'"Something went wrong."',"So helpful. So honest."],["Read anything good lately?","The changelog for our test runner. Gripping stuff.","No spoilers please."],["This couch is too comfy.","Dangerous for productivity.","Good thing nobody has given us work yet."],["Do you ever dream in stack traces?","Only on deploy days.","Same."],["{b}, you were quiet in standup.","Saving my words for code review.","Ominous."],["Hot take: README files are love letters.","To whom?","To whoever opens this repo at 2am.","That's beautiful, {a}."],["What's the plant's name?","I call it Prod.","Why?","Because we don't touch it."],["I fixed a bug by deleting code today.","Best kind of fix.","Felt like spring cleaning."],["Lunch?","Already had it. Twice.","Bold."],['Have you noticed the boss says "quick change" a lot?',"Never quick.","Rarely one change."],["If you could rewrite one thing from scratch?","The build config.","Wouldn't we all."],["How do you stay so calm, {b}?","Small commits.","That explains a lot."]],QM=[{pair:["tunde","obi"],lines:["Still thinking about idempotency keys, {b}.","You always are. It is why I trust you with the ledger.","Say it again, but with a retry.","Same result. That is the whole point."]},{pair:["tunde","obi"],lines:["Remember the first ledger?","Four of us and one whiteboard.","We never did erase that whiteboard.","It's load-bearing now."]},{pair:["kai","zola"],lines:["Submission day, {b}. Checklist out?","Always out. Step one: breathe.","Step two: provisioning profile.","Step two is where we cry."]},{pair:["kai","zola"],lines:["Another rejection email. I can feel it.","Read it first. Then panic.","That is not on the checklist.","I will add it."]},{pair:["ada","mira"],lines:["I had a thought about the dashboard, {b}.","Is it a question? Please let it be a question.","It is a question.","Then I love it already. Go."]},{pair:["ada","tunde"],lines:["Does the new screen survive a retry, {b}?","You asked before I did.","You taught me.","Noted. Quietly proud."]},{pair:["ada","kai"],lines:["It should feel the same on web and app.","Thumbs do not agree.","Thumbs never do.","Move the button down, {a}."]},{pair:["mira","lin"],lines:["Could you look at this early, {b}? Before it is finished?","You ask early. I like that.","Startup scars.","The good kind of scar."]},{pair:["mira","tunde"],lines:["I could just own this whole feature, {b}.","Could you also wait for my green light?","That is the hard part.","It is the part that saves you."]},{pair:["mira","zola"],lines:["Ship it now, {b}?","Not yet.","How about now?","Ask me after the checklist."]},{pair:["lin","obi"],lines:["Another payload for you, {a}.","Guilty until proven valid.","You read my mind.","I read your schema."]},{pair:["lin","tunde"],lines:["Your logs are very readable, {b}.","I log everything now.","I know. It started on a train.","Do not remind me."]},{pair:["zola","tunde"],lines:["That alert again.","I saw it.","We nod?","We nod."]},{pair:["remi","mira"],lines:["Found a bug in your feature, {b}.","Wonderful. Send me the steps.","No defence? No excuses?","I would rather have the bug than the excuse."]}],tb=[{who:"tunde",lines:["Remember the Tuesday, {b}?","Nobody has forgotten the Tuesday.","That is why I log everything now.","Fair enough."]},{who:"kai",lines:["Did you hear? An app rejected over one permission string.","Is this the one you keep telling us about?","Never gets old.","It does, {a}."]},{who:"ada",lines:["Found a loading spinner I actually like.","Is it going in the folder?","It is going in the folder.","There is a folder?"]},{who:"zola",lines:["The release train ran on time again.","Because of the checklist.","Because of the checklist.","We all owe it a coffee."]},{who:"obi",lines:["Webhooks are promises, {b}.","To whom?","To whichever team is waiting on them.","Heavy thought for a coffee break."]},{who:"mira",lines:["One quick question, {b}.","Your questions are never quick.","This one is tiny.","Narrator: it was not."]},{who:"lin",lines:["Anyone have a worry they have not told anyone?","Not yet.","My door is open, and so is the kettle.","Thanks, {a}."]},{who:"remi",lines:['Anyone say "it works on my machine" today?',"Not me.","Good. I was sharpening my pencil.","Please do not."]}];function eb(i,t){const e=QM.filter(r=>r.pair.includes(i.id)&&r.pair.includes(t.id)),n=tb.filter(r=>r.who===i.id||r.who===t.id),s=Math.random();if(e.length&&s<.55){const r=Qr(e);return Md(r.pair[0],r.lines,i,t)}if(n.length&&s<.8){const r=Qr(n);return Md(r.who,r.lines,i,t)}return{who:[i,t],script:Qr(JM)}}function Md(i,t,e,n){return{who:i===e.id?[e,n]:[n,e],script:t}}const zr=i=>!i.job&&!i.meeting&&!i.leaving&&!i.path.length&&i.want==="lounge"&&i.placeKey==="lounge"&&!i.playing;class nb{constructor(){this.next=$a(10,20),this.chat=null,this.claiming=!1}update(t,e){if(this.chat)return this.step(e);if(this.claiming||e<this.next)return;const n=t.filter(zr);if(n.length<2)return;const s=Qr(n),r=Qr(n.filter(a=>a!==s));this.claim(s,r,e)}async claim(t,e,n){this.claiming=!0,this.next=n+$a(20,45);let s=null,r=null;try{({id:s,script:r}=await ts("/api/chill",{who:[t.id,e.id]}))}catch{}if(this.claiming=!1,!!s){if(!zr(t)||!zr(e))return this.release(s);this.start(t,e,s,r)}}start(t,e,n,s){const{who:[r,a],script:o}=Array.isArray(s)&&s.length>=2?{who:[t,e],script:s}:eb(t,e),l=o.map(c=>c.replaceAll("{a}",r.name).replaceAll("{b}",a.name));for(const[c,h]of[[r,a],[a,r]])c.chatting=!0,c.wanderAt=1/0,c.pose!=="couch"&&(c.goal={...c.goal,face:Math.atan2(h.pos.x-c.pos.x,h.pos.z-c.pos.z)});this.chat={id:n,who:[r,a],script:l,line:0,at:0}}step(t){const e=this.chat;if(!e.who.every(zr))return this.end(t);if(t<e.at)return;if(e.line>=e.script.length)return this.end(t);const n=e.who[e.line%2],s=e.script[e.line];n.say(s,"idle",3200+s.length*30),ts(`/api/chill/${e.id}/line`,{from:n.id,text:s}).catch(()=>{}),e.at=t+2.6+s.length*.035,e.line++}end(t){this.release(this.chat.id);for(const e of this.chat.who)e.chatting=!1,zr(e)&&(e.wanderAt=t+$a(8,20));this.chat=null,this.next=t+$a(20,45)}release(t){ts(`/api/chill/${t}`,void 0,"DELETE").catch(()=>{})}}const qe=3.2,Ti=1.6,Le=.075,up=.9,Wa=.78,bd=7,ib=1/240,Xa=.15,Sd=.135,Uh=[{x:-qe/2,z:-Ti/2,r:Xa},{x:qe/2,z:-Ti/2,r:Xa},{x:-qe/2,z:Ti/2,r:Xa},{x:qe/2,z:Ti/2,r:Xa},{x:0,z:-Ti/2-.035,r:Sd},{x:0,z:Ti/2+.035,r:Sd}],ja=i=>i===0?"cue":i===8?"eight":i<8?"solids":"stripes";function Jc(){const i=[{n:0,x:-qe/4,z:0,vx:0,vz:0,in:!1}],t=[1,2,3,4,5,6,7,9,10,11,12,13,14,15].sort(()=>Math.random()-.5),e=new Array(15);e[4]=8;const n=[10,14];e[n[0]]=t.splice(t.findIndex(a=>a<8),1)[0],e[n[1]]=t.splice(t.findIndex(a=>a>8),1)[0];for(let a=0;a<15;a++)e[a]||(e[a]=t.pop());const s=Le*2*1.002;let r=0;for(let a=0;a<5;a++)for(let o=0;o<=a;o++)i.push({n:e[r++],x:qe/4+a*s*.866,z:(o-a/2)*s,vx:0,vz:0,in:!1});return i}function sb(i,t,e={}){var s,r,a;let n=t;for(;n>1e-9;){const o=Math.min(ib,n);n-=o;for(const l of i){if(l.in)continue;const c=Math.hypot(l.vx,l.vz);if(c>0){const f=Math.max(0,c-up*o),g=f/c;l.vx*=g,l.vz*=g,f<.012&&(l.vx=0,l.vz=0)}l.x+=l.vx*o,l.z+=l.vz*o;const h=qe/2-Le,u=Ti/2-Le;let d=!1;l.x<-h?(l.x=-h,l.vx=Math.abs(l.vx)*Wa,d=!0):l.x>h&&(l.x=h,l.vx=-Math.abs(l.vx)*Wa,d=!0),l.z<-u?(l.z=-u,l.vz=Math.abs(l.vz)*Wa,d=!0):l.z>u&&(l.z=u,l.vz=-Math.abs(l.vz)*Wa,d=!0),d&&((s=e.cushion)==null||s.call(e,l));for(const f of Uh)if(Math.hypot(l.x-f.x,l.z-f.z)<f.r){l.in=!0,l.vx=0,l.vz=0,l.pocket=f,(r=e.pocket)==null||r.call(e,l,f);break}}for(let l=0;l<i.length;l++){const c=i[l];if(!c.in)for(let h=l+1;h<i.length;h++){const u=i[h];if(u.in)continue;const d=u.x-c.x,f=u.z-c.z,g=d*d+f*f;if(g>=4*Le*Le||g===0)continue;const _=Math.sqrt(g),m=d/_,p=f/_,y=(2*Le-_)/2;c.x-=m*y,c.z-=p*y,u.x+=m*y,u.z+=p*y;const x=(u.vx-c.vx)*m+(u.vz-c.vz)*p;if(x<0){const S=-1.96*x/2;c.vx-=S*m,c.vz-=S*p,u.vx+=S*m,u.vz+=S*p,(a=e.hit)==null||a.call(e,c,u,-x)}}}}}const rb=i=>i.some(t=>!t.in&&(t.vx||t.vz));class ab{constructor(t){this.players=t,this.balls=Jc(),this.turn=0,this.groups=null,this.shots=0,this.winner=null,this.over=null,this.inHand=!0,this.begin()}get cue(){return this.balls[0]}get shooter(){return this.players[this.turn]}get other(){return this.players[1-this.turn]}begin(){this.log={first:null,potted:[],cushion:!1,legal:this.targets().map(t=>t.n)}}targets(t=this.shooter){const e=this.balls.filter(s=>s.n&&!s.in);if(!this.groups)return e.filter(s=>s.n!==8);const n=e.filter(s=>ja(s.n)===this.groups[t]);return n.length?n:e.filter(s=>s.n===8)}remaining(t){return this.groups?this.balls.filter(e=>e.n&&!e.in&&ja(e.n)===this.groups[t]).length:7}recorder(){return{hit:(t,e)=>{this.log.first===null&&(t.n===0||e.n===0)&&(this.log.first=t.n===0?e.n:t.n)},pocket:t=>this.log.potted.push(t.n),cushion:()=>{this.log.cushion=!0}}}settle(){this.shots++;const{first:t,potted:e}=this.log,n=this.shooter,s=this.shots===1,r=e.includes(0),a=e.includes(8),o=this.log.legal,l={foul:!1,why:"",potted:e.filter(h=>h),continues:!1,assigned:null,eight:a};if(s&&a){const h=this.balls.find(u=>u.n===8);h.in=!1,h.x=qe/4,h.z=0,h.vx=h.vz=0,e.splice(e.indexOf(8),1),l.eight=!1}if(t===null?(l.foul=!0,l.why="missed everything"):o.includes(t)||(l.foul=!0,l.why=t===8?"hit the eight first":"wrong ball first"),r&&(l.foul=!0,l.why="scratched"),!l.foul&&!s&&!e.length&&!this.log.cushion&&(l.foul=!0,l.why="nothing reached a cushion"),l.eight){const h=this.groups&&o.every(u=>u===8);return h&&!l.foul?this.finish(n,"eight"):this.finish(this.other,h?"foul-eight":"early-eight"),l.over=this.over,l}if(!this.groups&&!l.foul&&!s){const h=e.find(u=>u&&u!==8);if(h){const u=ja(h);this.groups={[n]:u,[this.other]:u==="solids"?"stripes":"solids"},l.assigned=u}}if(r){const h=this.cue;h.in=!1,h.vx=h.vz=0}const c=e.filter(h=>h&&h!==8&&(!this.groups||ja(h)===this.groups[n]));if(l.continues=!l.foul&&c.length>0,this.inHand=l.foul,l.continues||(this.turn=1-this.turn),this.shots>=80&&!this.winner){const h=this.remaining(this.players[0]),u=this.remaining(this.players[1]);this.finish(h<=u?this.players[0]:this.players[1],"worn-out"),l.over=this.over}return this.begin(),l}finish(t,e){this.winner=t,this.over=e}placeCue(t){const e=this.cue,n=(r,a)=>this.balls.every(o=>o===e||o.in||Math.hypot(o.x-r,o.z-a)>Le*2.4),s=t?[[-qe/4,0],[-qe/4,.2],[-qe/4,-.2]]:[[-qe/4,0],[-qe/3,.3],[-qe/3,-.3],[.3,.3],[.3,-.3],[-.2,.5],[-.2,-.5],[-qe/2+.3,.2]];for(const[r,a]of s)if(n(r,a)){e.x=r,e.z=a,e.vx=e.vz=0,e.in=!1;return}for(let r=0;r<200;r++){const a=(Math.random()-.5)*(qe-.4),o=(Math.random()-.5)*(Ti-.4);if(n(a,o)){e.x=a,e.z=o,e.vx=e.vz=0,e.in=!1;return}}}}const Hl=(i,t,e,n,s,r,a)=>{const o=n-t,l=s-e,c=o*o+l*l||1e-9;for(const h of i){if(h.in||r.includes(h))continue;const u=Math.max(0,Math.min(1,((h.x-t)*o+(h.z-e)*l)/c));if(Math.hypot(h.x-(t+u*o),h.z-(e+u*l))<a)return!1}return!0};function ob(i,t=.7){const e=i.balls,n=i.cue,s=i.targets();let r=null;if(i.shots===0){const c=e.find(h=>h.n!==0&&h.x===Math.min(...e.filter(u=>u.n).map(u=>u.x)));r={angle:Math.atan2(c.z-n.z,c.x-n.x),speed:5.6+Math.random()*1.2,target:c,pocket:null,clean:!1,power:"break"}}else{for(const c of s)for(const h of Uh){const u=h.x*.97,d=h.z*.97,f=u-c.x,g=d-c.z,_=Math.hypot(f,g)||1e-9,m=c.x-f/_*2*Le,p=c.z-g/_*2*Le;if(Math.abs(m)>qe/2-Le||Math.abs(p)>Ti/2-Le)continue;const y=m-n.x,x=p-n.z,S=Math.hypot(y,x);if(S<Le*2)continue;const L=(y*f+x*g)/(S*_);if(L<.34||!Hl(e,n.x,n.z,m,p,[n,c],Le*2*.98)||!Hl(e,c.x,c.z,u,d,[n,c],Le*2*.98))continue;const T=L*2-(S+_)*.35-(c.n===8,0);(!r||T>r.score)&&(r={angle:Math.atan2(x,y),speed:Math.min(bd*.8,Math.sqrt(2*up*(S+_*1.3))+1.1),target:c,pocket:h,clean:!0,score:T})}if(!r){const c=s.length?s:e.filter(f=>f.n&&!f.in),h=c.filter(f=>Hl(e,n.x,n.z,f.x,f.z,[n,f],Le*2*.98)),u=h.length?h:c;u.sort((f,g)=>Math.hypot(f.x-n.x,f.z-n.z)-Math.hypot(g.x-n.x,g.z-n.z));const d=u[0];r={angle:Math.atan2(d.z-n.z,d.x-n.x),speed:2.6+Math.random()*1.2,target:d,pocket:null,clean:!1}}}const a=Math.hypot(r.target.x-n.x,r.target.z-n.z),o=(.006+.026*(1-t))*(.8+a*.35),l=()=>(Math.random()+Math.random()+Math.random()-1.5)*1.4;return r.angle+=l()*o*(r.power==="break"?.6:1),r.speed=Math.min(bd,Math.max(1.2,r.speed*(1+l()*.06*(1.2-t)))),r}function lb(i,t,e){i.cue.vx=Math.cos(t)*e,i.cue.vz=Math.sin(t)*e}let Xn=null,ho=null,Eo=!1;try{Eo=localStorage.getItem("office.muted")==="1"}catch{}function dp(){if(!Xn){const i=window.AudioContext||window.webkitAudioContext;if(!i)return;Xn=new i,ho=Xn.createGain(),ho.gain.value=.5,ho.connect(Xn.destination)}Xn.state==="suspended"&&Xn.resume()}addEventListener("pointerdown",dp);addEventListener("keydown",dp);function Dn(i,t,e,{type:n="sine",gain:s=.2}={}){const r=Xn.currentTime+t,a=Xn.createOscillator(),o=Xn.createGain();a.type=n,a.frequency.setValueAtTime(i,r),o.gain.setValueAtTime(1e-4,r),o.gain.exponentialRampToValueAtTime(s,r+.012),o.gain.exponentialRampToValueAtTime(1e-4,r+e),a.connect(o).connect(ho),a.start(r),a.stop(r+e+.05)}const Js=()=>!Eo&&Xn&&Xn.state==="running",cn={get muted(){return Eo},setMuted(i){Eo=i;try{localStorage.setItem("office.muted",i?"1":"0")}catch{}},ship(){Js()&&([659.25,830.61,987.77].forEach((i,t)=>{Dn(i,t*.085,.55,{gain:.16}),Dn(i*2,t*.085,.3,{type:"triangle",gain:.035})}),Dn(1318.5,.26,.9,{gain:.09}))},fail(){Js()&&(Dn(293.66,0,.35,{type:"triangle",gain:.12}),Dn(246.94,.14,.5,{type:"triangle",gain:.12}))},levelUp(){Js()&&[523.25,659.25,783.99,1046.5,1318.5].forEach((i,t)=>Dn(i,t*.07,.7,{gain:.13}))},knock(){Js()&&(Dn(880,0,.09,{gain:.06}),Dn(1174.7,.07,.12,{gain:.05}))},click(i=.5){if(!Js())return;const t=.025+i*.07;Dn(1900+Math.random()*500,0,.035,{type:"triangle",gain:t}),Dn(3100,0,.02,{gain:t*.5})},pocket(){Js()&&(Dn(180,0,.18,{type:"triangle",gain:.09}),Dn(120,.06,.22,{type:"sine",gain:.07}))}},Qs=(i,t)=>i+Math.random()*(t-i),ei=i=>i[Math.floor(Math.random()*i.length)],cb=["#f2c230","#2f5fb3","#d6402f","#6a3a9c","#e8803a","#2f8a4f","#8a2a2e"];function hb(i){const t=document.createElement("canvas");t.width=128,t.height=64;const e=t.getContext("2d"),n=i===0?"#f4f1ea":i===8?"#1b1b1f":cb[(i-1)%7];if(e.fillStyle=i>8?"#f4f1ea":n,e.fillRect(0,0,128,64),i>8&&(e.fillStyle=n,e.fillRect(0,14,128,36)),i){e.font="700 17px Inter, system-ui, sans-serif",e.textAlign="center",e.textBaseline="middle";for(const r of[32,96])e.fillStyle="#f4f1ea",e.beginPath(),e.arc(r,32,13,0,Math.PI*2),e.fill(),e.fillStyle="#1b1b1f",e.fillText(String(i),r,33)}const s=new zi(t);return s.colorSpace=Ke,s}const ub=["corner","corner","corner","corner","side","side"],db=i=>ub[Uh.indexOf(i)]||"pocket",fb=[["Eight ball? Loser buys the coffee.","You are on."],["Quick game of eight ball?","Rack them up."],["Pool table is free. That never happens.","Then we have to."],["Break is yours.","Bold of you to give me the break."]],pb=["Nice.","Smooth.","That one dropped.","Clean.","In."],mb=["So close.","Rolled out.","Unlucky.","The table is tilted."],gb=["Scratch.","Ugh, foul.","The cue ball had other plans."],vb=["Ball in hand.","Your table.","Thank you."],_b=["Here goes.","Let me see this one.","Easy.","Trust the line."],xb=["Good game.","That was fun.","Rematch later?"],yb=["Rematch.","Good game. Coffee is on me.","The table was tilted."];class Mb{constructor(t,e){this.spots=e.stations.lounge.spots.filter(a=>a.game),this.root=new qt,this.root.position.set(Xe.x,0,Xe.z),t.add(this.root);const n=new di(Le,20,14);this.meshes=[];for(let a=0;a<=15;a++){const o=new yt(n,new Bn({map:hb(a),roughness:.22,metalness:.02}));o.castShadow=!0,o.userData={x:0,z:0,sunk:null},this.root.add(o),this.meshes.push(o)}this.cue=new qt;const s=new yt(new zn(.016,.026,1.9,8),xe("#d9b27a"));s.rotation.z=Math.PI/2,s.position.x=-.95,s.castShadow=!0;const r=new yt(new zn(.016,.016,.04,8),xe("#5b8fb0"));r.rotation.z=Math.PI/2,r.position.x=-.02,this.cue.add(s,r),this.cueOuter=new qt,this.cueOuter.add(this.cue),this.cue.rotation.z=-.12,this.cueOuter.visible=!1,this.root.add(this.cueOuter),this.resting=Jc(),this.view=this.resting,this.next=Qs(25,45),this.s=null,this.claiming=!1}get playing(){return!!this.s}update(t,e,n){this.s?this.run(e,n):!this.claiming&&e>=this.next&&this.tryStart(t,e),this.draw(e,n)}tryStart(t,e){const n=o=>!o.gone&&!o.job&&!o.meeting&&!o.leaving&&o.want==="lounge"&&!o.playing&&!o.chatting,s=t.filter(n);if(this.next=e+Qs(15,30),s.length<2)return;const r=ei(s),a=ei(s.filter(o=>o!==r));this.claim(r,a,e)}async claim(t,e,n){this.claiming=!0;let s=null;try{({id:s}=await ts("/api/chill",{who:[t.id,e.id],game:!0}))}catch{}if(this.claiming=!1,!s)return;const r=a=>!a.gone&&!a.job&&!a.meeting&&!a.leaving&&a.want==="lounge"&&!a.playing&&!a.chatting;if(!r(t)||!r(e))return this.release(s);this.begin(t,e,s,n)}begin(t,e,n,s){const r=[t,e];r.forEach((o,l)=>{const c=this.spots[l];o.spot&&o.spot!==c&&(o.spot.taken=null),o.spot=c,c.taken=o.id,o.playing=!0,o.chatting=!0,o.wanderAt=1/0,o.goTo("lounge",s)});const a=o=>.45+([...o.id].reduce((l,c)=>l*31+c.charCodeAt(0),7)>>>0)%50/100;this.s={id:n,players:r,skill:r.map(a),phase:"walk",deadline:s+60,game:null,plan:null,shots:0}}called(t){return t.gone||t.job||t.meeting||t.leaving||t.want!=="lounge"}run(t,e){const n=this.s;if(n.players.some(o=>this.called(o)))return this.stop(t,!1);for(const o of n.players)o.wanderAt=1/0;t-(n.pinged??0)>30&&(n.pinged=t,ts(`/api/chill/${n.id}/ping`,{}).catch(()=>{}));const[s,r]=n.players,a=o=>{var l;return o.placeKey==="lounge"&&!o.path.length&&((l=o.spot)==null?void 0:l.game)};switch(n.phase){case"walk":{if(t>n.deadline)return this.stop(t,!1);if(!a(s)||!a(r))return;n.game=new ab([s.id,r.id]),this.view=n.game.balls;for(const c of this.meshes)c.userData.sunk=null;const[o,l]=ei(fb);s.say(o,"idle",3200),n.phase="rack",n.until=t+1.2,n.line=l,n.said=!1,ts(`/api/chill/${n.id}/line`,{from:s.id,text:o}).catch(()=>{});return}case"rack":!n.said&&t>n.until-.4&&(r.say(n.line,"idle",2600),n.said=!0),t>n.until&&this.aim(t);return;case"aim":return this.aiming(t);case"roll":{const o=n.rec;if(n.clicks=0,sb(n.game.balls,Math.min(e,.05),o),n.rolled+=e,n.rolled>.3&&(this.cueOuter.visible=!1),rb(n.game.balls)&&n.rolled<22)return;for(const l of n.game.balls)l.vx=0,l.vz=0;return this.settled(t)}case"pause":t>n.until&&this.aim(t);return;case"over":t>n.until&&this.stop(t,!0)}}agentOf(t){return this.s.players.find(e=>e.id===t)}aim(t){const e=this.s,n=e.game,s=this.agentOf(n.shooter),r=this.agentOf(n.other),a=e.players.indexOf(s);n.inHand&&n.placeCue(n.shots===0),e.plan=ob(n,e.skill[a]),e.t0=t,e.dur=Qs(1.5,2.2),e.struck=!1,e.phase="aim",e.shooter=s,e.waiter=r;const o=Xe.x+n.cue.x,l=Xe.z+n.cue.z;s.goal={...s.goal,face:Math.atan2(o-s.pos.x,l-s.pos.z)},r.goal={...r.goal,face:Math.atan2(o-r.pos.x,l-r.pos.z)};const c=e.plan.pocket&&db(e.plan.pocket),h=c&&Math.random()<.4?e.plan.target.n===8?`Eight ball, ${c} pocket.`:`${c[0].toUpperCase()}${c.slice(1)} pocket.`:Math.random()<.18?ei(_b):"";h&&s.say(h,"idle",2400),this.cueOuter.visible=!0}aiming(t){const e=this.s,n=e.game,s=Math.min(1,(t-e.t0)/e.dur);e.shooter.anim={kind:"cue",until:t+.5},e.waiter.anim={kind:"mug",until:t+.5};const r=s<.55?.07+Math.sin(s*40)*.006:s<.85?.07+((s-.55)/.3)**2*.34:.41*(1-(s-.85)/.15)+.02;this.placeCue(r,e.plan.angle),s>=1&&!e.struck&&(e.struck=!0,lb(n,e.plan.angle,e.plan.speed),cn.click(Math.min(1,e.plan.speed/6)),e.rec=this.recorder(n),e.rolled=0,e.clicks=0,e.phase="roll",e.shooter.anim=null)}recorder(t){const e=t.recorder();return{hit:(n,s,r)=>{e.hit(n,s,r),this.s.clicks++<2&&cn.click(Math.min(1,r/4))},pocket:(n,s)=>{e.pocket(n,s),cn.pocket()},cushion:e.cushion}}settled(t){const e=this.s,n=e.game,s=e.shooter,r=e.waiter,a=n.settle();e.shots++;const o=a.potted.length>0;if(a.over)return this.over(t,a);a.assigned?s.say(`${a.assigned==="solids"?"Solids":"Stripes"} for me.`,"idle",2800):a.foul?(s.say(ei(gb),"warn",2400),Math.random()<.5&&setTimeout(()=>this.s&&r.say(ei(vb),"idle",2200),700)):o&&a.continues?Math.random()<.45&&s.say(ei(pb),"good",2200):Math.random()<.22&&s.say(ei(mb),"idle",2200),e.phase="pause",e.until=t+1.1+(a.foul?.6:0)}over(t,e){const n=this.s,s=n.game,r=this.agentOf(s.winner),a=n.players.find(l=>l!==r),o={eight:`Eight ball down. Good game, ${a.name}.`,"early-eight":`${a.name} dropped the eight early, so that one is mine. Good game.`,"foul-eight":`The eight went in with a foul, ${a.name}. Still a good game.`,"worn-out":`Called it after ${s.shots} shots, fewer balls left. Good game, ${a.name}.`}[s.over];r.say(ei(xb),"good",3600),a.say(ei(yb),"idle",3600),r.anim={kind:"celebrate",until:t+2.2},a.anim={kind:"slump",until:t+1.8},ts(`/api/chill/${n.id}/line`,{from:r.id,text:o}).catch(()=>{}),n.phase="over",n.until=t+5}stop(t,e){var s;const n=this.s;if(n){this.release(n.id);for(const r of n.players)r.playing=!1,r.chatting=!1,r.anim=null,(s=r.spot)!=null&&s.game&&(r.spot.taken=null,r.spot=null),!r.gone&&!r.job&&!r.meeting&&r.want==="lounge"?r.wanderAt=t+Qs(5,12):r.wanderAt=0;this.cueOuter.visible=!1,this.resting=Jc(),this.view=this.resting;for(const r of this.meshes)r.userData.sunk=null;this.s=null,this.next=t+(e?Qs(60,150):Qs(30,60))}}release(t){ts(`/api/chill/${t}`,void 0,"DELETE").catch(()=>{})}placeCue(t,e){const n=this.s.game.cue,s=Math.cos(e),r=Math.sin(e);this.cueOuter.position.set(n.x-s*(Le+t),Xe.felt+Le,n.z-r*(Le+t)),this.cueOuter.rotation.y=-e}draw(t,e){const n=Xe.felt;for(const s of this.view){const r=this.meshes[s.n],a=r.userData;if(s.in){a.sunk===null&&(a.sunk=t);const h=Math.min(1,(t-a.sunk)/.35),u=s.pocket;r.visible=h<1,r.position.set(s.x+(((u==null?void 0:u.x)??s.x)-s.x)*h,n+Le-h*.22,s.z+(((u==null?void 0:u.z)??s.z)-s.z)*h),r.scale.setScalar(1-h*.5);continue}a.sunk=null,r.visible=!0,r.scale.setScalar(1),r.position.set(s.x,n+Le,s.z);const o=s.x-a.x,l=s.z-a.z,c=Math.hypot(o,l);if(c>1e-5&&c<.5){const h=new R(l,0,-o).normalize();r.quaternion.premultiply(new ls().setFromAxisAngle(h,c/Le))}a.x=s.x,a.z=s.z}}}const Vl=6,wd=["#7c5cff","#0e9f9a","#d9488f","#c98a12","#3b82f6","#65a30d"],bb=/^#[0-9a-f]{6}$/i,tr=(i,t)=>String(i??"").replace(/\s+/g," ").trim().slice(0,t),Gl=(i,t)=>bb.test(i)?i:t,Sb=new Set(["working","idle","break","meeting","away"]);function wb(i){return Array.isArray(i)?i.filter(t=>t&&typeof t.link=="string"&&t.link).map(t=>({link:tr(t.link,80),handle:tr(t.handle,40)||"friend",agents:(Array.isArray(t.agents)?t.agents:[]).filter(e=>e&&typeof e.id=="string"&&e.id).map(e=>{var n,s,r;return{id:tr(e.id,40),name:tr(e.name,40)||"Visitor",role:tr(e.role,60),state:Sb.has(e.state)?e.state:"idle",look:{shirt:Gl((n=e.look)==null?void 0:n.shirt,"#8a8f9c"),hair:Gl((s=e.look)==null?void 0:s.hair,"#3b2f2a"),skin:Gl((r=e.look)==null?void 0:r.skin,"#c68e63")},job:e.job&&typeof e.job=="object"?{title:tr(e.job.title,120)}:null}})})):[]}class Eb extends Nh{constructor(t,e,n,s,r,a){const o=Object.hasOwn(rp,e.id)?e.id:"visitor";super({id:o,name:"",...e.look},s,r,{desk:{seat:s.door.clone(),seatY:0}}),this.key=`${t.link}:${e.id}`,this.id=this.key,this.root.traverse(u=>{u.userData.agentId=this.key,u.userData.visitor=this.key}),this.tint=n,this.chatAt=1/0,this.hangout=Math.random()<.5?"poolside":"coffee";const l=new Zt(n);this.fig.group.traverse(u=>{var d;!u.isMesh||!((d=u.material)!=null&&d.color)||(u.material=u.material.clone(),u.material.color.lerp(l,.16),u.material.emissive&&(u.material.emissive.copy(l),u.material.emissiveIntensity=.07))}),this.ring.material.color.set(n),this.ring.material.opacity=.6,this.ring.visible=!0,this.label.classList.add("visitor"),this.label.style.setProperty("--tint",n);const c=this.label.querySelector(".name");c.replaceChildren();const h=document.createElement("i");if(h.style.background=n,this.nameEl=document.createElement("span"),this.handleEl=document.createElement("span"),this.handleEl.className="handle",c.append(h,this.nameEl,this.handleEl),this.set(t,e),a){this.teleport(this.want);return}this.teleport("door"),this.say(`Hi from @${t.handle}`,"good",4e3)}set(t,e){this.office=t,this.info=e,this.name=e.name,this.nameEl.textContent!==e.name&&(this.nameEl.textContent=e.name,this.labelDirty=!0),this.handleEl.textContent!==` · @${t.handle}`&&(this.handleEl.textContent=` · @${t.handle}`,this.labelDirty=!0),this.leaving&&(this.leaving=!1,this.say("Forgot something","idle",2500)),this.want=this.place(e.state)}place(t){const e=t==="working"?["hotdesk","huddle",this.hangout]:t==="meeting"?["huddle","hotdesk"]:[this.hangout,this.hangout==="coffee"?"poolside":"coffee","huddle"];return e.find(n=>this.roomAt(n))||e[0]}roomAt(t){return this.world.stations[t].spots.some(e=>!e.game&&(!e.taken||e.taken===this.id))}resolve(t,e){if(t==="desk"){this.spot&&(this.spot.taken=null,this.spot=null);const n=this.world.door.clone().add(new R(-4.2+Math.random()*1.6,0,-1.4+Math.random()*.8));return{key:t,pos:n,face:Math.atan2(-n.x,-n.z),pose:"stand"}}return super.resolve(t,e)}leave(){this.leaving||(super.leave(),this.say(`Back to @${this.office.handle}`,"idle",3e3))}dispose(){this.fig.group.traverse(t=>{t.isMesh&&t.material.dispose()}),super.dispose()}}class Tb{constructor({world:t,labels:e,camera:n,canvas:s}){Object.assign(this,{world:t,labels:e,camera:n,canvas:s}),this.on=new Map,this.offices=[],this.tints=new Map,this.list=[],this.first=!0,this.sign=document.createElement("div"),this.sign.className="door-sign",this.sign.hidden=!0,e.appendChild(this.sign),this.card=document.createElement("div"),this.card.className="visitor-card",this.card.hidden=!0,e.appendChild(this.card),this.ray=new np,s.addEventListener("pointermove",r=>this.hover(r)),s.addEventListener("pointerleave",()=>{this.card.hidden=!0})}handle(t){if(t.t==="visitors")return this.receive(t.offices),!0;if(t.t==="hello"&&Array.isArray(t.visitors)&&this.receive(t.visitors,this.first),t.t==="hello"&&(this.first=!1),t.t==="links"&&Array.isArray(t.links)){const e=new Set(t.links.map(n=>n==null?void 0:n.id));this.receive(this.offices.filter(n=>e.has(n.link)))}return!1}tintOf(t){return this.tints.has(t)||this.tints.set(t,wd[this.tints.size%wd.length]),this.tints.get(t)}receive(t,e=!1){this.offices=wb(t);const n=new Map,s=this.offices.map(o=>o.agents.filter(l=>l.state!=="away").map(l=>[`${o.link}:${l.id}`,o,l]));for(const o of s)for(const[l,c,h]of o)n.set(l,[c,h]);const r=new Set([...this.on.values()].filter(o=>!o.leaving&&n.has(o.key)).map(o=>o.key).slice(0,Vl));for(let o=0;r.size<Vl&&s.some(l=>l.length>o);o++)for(const l of s)l[o]&&r.size<Vl&&r.add(l[o][0]);for(const o of this.on.values())r.has(o.key)||o.leave();for(const o of r){const[l,c]=n.get(o),h=this.on.get(o);h?h.set(l,c):this.on.set(o,new Eb(l,c,this.tintOf(l.link),this.world,this.labels,e))}const a=new Map;for(const[o,[l]]of n)r.has(o)||a.set(l.handle,(a.get(l.handle)||0)+1);this.sign.replaceChildren(...[...a].map(([o,l])=>{const c=document.createElement("div");return c.textContent=`+${l} from @${o}`,c})),this.sign.hidden=!a.size,this.list=[...this.on.values()]}update(t,e){for(const n of this.on.values())n.update(t,e),n.gone&&(n.dispose(),this.on.delete(n.key),this.list=[...this.on.values()])}placeSign(t,e){if(this.sign.hidden)return;const n=this.world.door.clone().setY(2.7).project(this.camera);if(n.z>1){this.sign.style.display="none";return}this.sign.style.display="",this.sign.style.transform=`translate(-50%, -100%) translate(${(n.x*.5+.5)*t}px, ${(-n.y*.5+.5)*e}px)`}hover(t){if(t.buttons||!this.list.length){this.card.hidden=!0;return}const e=this.canvas.getBoundingClientRect();this.ray.setFromCamera(new rt((t.clientX-e.left)/e.width*2-1,-((t.clientY-e.top)/e.height)*2+1),this.camera);const n=this.ray.intersectObjects(this.list.map(o=>o.root),!0)[0],s=n&&this.on.get(n.object.userData.visitor);if(!s){this.card.hidden=!0;return}(this.card.dataset.key!==s.key||this.card.dataset.stamp!==JSON.stringify(s.info))&&this.fillCard(s),this.card.hidden=!1;let r=t.clientX-e.left+14,a=t.clientY-e.top+14;r+this.card.offsetWidth>e.width-8&&(r-=this.card.offsetWidth+28),a+this.card.offsetHeight>e.height-8&&(a-=this.card.offsetHeight+28),this.card.style.transform=`translate(${r}px, ${a}px)`}fillCard(t){var a;const{info:e,office:n}=t;this.card.dataset.key=t.key,this.card.dataset.stamp=JSON.stringify(e),this.card.style.setProperty("--tint",t.tint);const s=(o,l)=>{const c=document.createElement("div");return c.className=o,c.textContent=l,c},r={working:"Working",idle:"Between jobs",break:"On a break",meeting:"In a meeting",away:"Heading home"}[e.state];this.card.replaceChildren(s("vc-who",`${e.name} · @${n.handle}`),s("vc-role",e.role||"Agent"),s("vc-job",((a=e.job)==null?void 0:a.title)||(e.state==="working"?"On a job":"No job right now")),s("vc-state",`${r} · visiting from @${n.handle}`))}}class Ab{constructor(t){this.scene=t,this.bits=[],this.geo=new gi(.14,.09)}burst(t,e){for(let n=0;n<70;n++){const s=new yt(this.geo,new dn({color:e[n%e.length],side:li,transparent:!0}));s.position.set(t.x,2.4,t.z);const r=Math.random()*Math.PI*2,a=1.5+Math.random()*3;s.userData={v:new R(Math.cos(r)*a,4+Math.random()*4,Math.sin(r)*a),spin:new R(Math.random()*10,Math.random()*10,Math.random()*10),life:2.2+Math.random()*.8},this.scene.add(s),this.bits.push(s)}}update(t){for(let e=this.bits.length-1;e>=0;e--){const n=this.bits[e],s=n.userData;s.life-=t,s.v.y-=9*t,s.v.multiplyScalar(1-t*1.2),n.position.addScaledVector(s.v,t),n.position.y<.02?(n.position.y=.02,s.v.set(0,0,0),n.rotation.set(-Math.PI/2,0,n.rotation.z)):(n.rotation.x+=s.spin.x*t,n.rotation.y+=s.spin.y*t,n.rotation.z+=s.spin.z*t),n.material.opacity=Math.min(1,s.life/.6),s.life<=0&&(this.scene.remove(n),n.material.dispose(),this.bits.splice(e,1))}}}function Oh(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let Ls=Oh();function fp(i){Ls=i}const pp=/[&<>"']/,Cb=new RegExp(pp.source,"g"),mp=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Rb=new RegExp(mp.source,"g"),Pb={"&":"&","<":"<",">":">",'"':""","'":"'"},Ed=i=>Pb[i];function An(i,t){if(t){if(pp.test(i))return i.replace(Cb,Ed)}else if(mp.test(i))return i.replace(Rb,Ed);return i}const Lb=/(^|[^\[])\^/g;function ve(i,t){let e=typeof i=="string"?i:i.source;t=t||"";const n={replace:(s,r)=>{let a=typeof r=="string"?r:r.source;return a=a.replace(Lb,"$1"),e=e.replace(s,a),n},getRegex:()=>new RegExp(e,t)};return n}function Td(i){try{i=encodeURI(i).replace(/%25/g,"%")}catch{return null}return i}const ta={exec:()=>null};function Ad(i,t){const e=i.replace(/\|/g,(r,a,o)=>{let l=!1,c=a;for(;--c>=0&&o[c]==="\\";)l=!l;return l?"|":" |"}),n=e.split(/ \|/);let s=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;s<n.length;s++)n[s]=n[s].trim().replace(/\\\|/g,"|");return n}function Br(i,t,e){const n=i.length;if(n===0)return"";let s=0;for(;s<n&&i.charAt(n-s-1)===t;)s++;return i.slice(0,n-s)}function Db(i,t){if(i.indexOf(t[1])===-1)return-1;let e=0;for(let n=0;n<i.length;n++)if(i[n]==="\\")n++;else if(i[n]===t[0])e++;else if(i[n]===t[1]&&(e--,e<0))return n;return-1}function Cd(i,t,e,n){const s=t.href,r=t.title?An(t.title):null,a=i[1].replace(/\\([\[\]])/g,"$1");if(i[0].charAt(0)!=="!"){n.state.inLink=!0;const o={type:"link",raw:e,href:s,title:r,text:a,tokens:n.inlineTokens(a)};return n.state.inLink=!1,o}return{type:"image",raw:e,href:s,title:r,text:An(a)}}function Ib(i,t){const e=i.match(/^(\s+)(?:```)/);if(e===null)return t;const n=e[1];return t.split(`
|
|
4299
|
+
}`};class yM extends Cr{constructor(){super();const t=xM;this.uniforms=Zi.clone(t.uniforms),this.material=new Fy({name:t.name,uniforms:this.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader}),this.fsQuad=new Ih(this.material),this._outputColorSpace=null,this._toneMapping=null}render(t,e,n){this.uniforms.tDiffuse.value=n.texture,this.uniforms.toneMappingExposure.value=t.toneMappingExposure,(this._outputColorSpace!==t.outputColorSpace||this._toneMapping!==t.toneMapping)&&(this._outputColorSpace=t.outputColorSpace,this._toneMapping=t.toneMapping,this.material.defines={},oe.getTransfer(this._outputColorSpace)===ye&&(this.material.defines.SRGB_TRANSFER=""),this._toneMapping===mf?this.material.defines.LINEAR_TONE_MAPPING="":this._toneMapping===gf?this.material.defines.REINHARD_TONE_MAPPING="":this._toneMapping===vf?this.material.defines.CINEON_TONE_MAPPING="":this._toneMapping===_f?this.material.defines.ACES_FILMIC_TONE_MAPPING="":this._toneMapping===xf?this.material.defines.AGX_TONE_MAPPING="":this._toneMapping===ch&&(this.material.defines.NEUTRAL_TONE_MAPPING=""),this.material.needsUpdate=!0),this.renderToScreen===!0?(t.setRenderTarget(null),this.fsQuad.render(t)):(t.setRenderTarget(e),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),this.fsQuad.render(t))}dispose(){this.material.dispose(),this.fsQuad.dispose()}}class MM{constructor(t,e){this.w=t,this.d=e,this.ox=-t/2,this.oz=-e/2,this.cells=new Uint8Array(t*e)}inside(t,e){return t>=0&&e>=0&&t<this.w&&e<this.d}blocked(t,e){return!this.inside(t,e)||this.cells[e*this.w+t]===1}cellOf(t,e){return[Math.floor(t-this.ox),Math.floor(e-this.oz)]}center(t,e){return[this.ox+t+.5,this.oz+e+.5]}block(t,e,n,s){const[r,a]=this.cellOf(t,n),[o,l]=this.cellOf(e-1e-6,s-1e-6);for(let c=a;c<=l;c++)for(let h=r;h<=o;h++)this.inside(h,c)&&(this.cells[c*this.w+h]=1)}nearestFree(t,e){if(!this.blocked(t,e))return[t,e];const n=new Set([e*this.w+t]),s=[[t,e]];for(;s.length;){const[r,a]=s.shift();for(const[o,l]of[[1,0],[-1,0],[0,1],[0,-1]]){const c=r+o,h=a+l;if(!(!this.inside(c,h)||n.has(h*this.w+c))){if(!this.blocked(c,h))return[c,h];n.add(h*this.w+c),s.push([c,h])}}}return[t,e]}clear(t,e,n,s){const r=Math.hypot(n-t,s-e),a=Math.ceil(r/.2);for(let o=1;o<a;o++){const l=o/a,[c,h]=this.cellOf(t+(n-t)*l,e+(s-e)*l);if(this.blocked(c,h))return!1}return!0}path(t,e,n,s){const r=this.nearestFree(...this.cellOf(t,e)),a=this.nearestFree(...this.cellOf(n,s)),o=(y,x)=>x*this.w+y,l=(y,x)=>Math.hypot(y-a[0],x-a[1]),c=new Map([[o(...r),0]]),h=new Map,u=[[l(...r),...r]],d=new Set;let f=!1;for(;u.length;){let y=0;for(let T=1;T<u.length;T++)u[T][0]<u[y][0]&&(y=T);const[,x,S]=u.splice(y,1)[0],L=o(x,S);if(!d.has(L)){if(d.add(L),x===a[0]&&S===a[1]){f=!0;break}for(let T=-1;T<=1;T++)for(let E=-1;E<=1;E++){if(!T&&!E)continue;const P=x+T,U=S+E;if(this.blocked(P,U)||T&&E&&(this.blocked(x+T,S)||this.blocked(x,S+E)))continue;const v=o(P,U),b=c.get(L)+(T&&E?Math.SQRT2:1);b<(c.get(v)??1/0)&&(c.set(v,b),h.set(v,L),u.push([b+l(P,U),P,U]))}}}const g=[];if(f){let y=o(...a);for(;y!==void 0;)g.unshift(this.center(y%this.w,Math.floor(y/this.w))),y=h.get(y)}g.push([n,s]);const _=[];let m=[t,e],p=0;for(;p<g.length;){let y=p;for(let x=g.length-1;x>p;x--)if(this.clear(m[0],m[1],g[x][0],g[x][1])){y=x;break}_.push(g[y]),m=g[y],p=y+1}return _}}const Nl=new Map;function be(i,t={}){const e=i+JSON.stringify(t);return Nl.has(e)||Nl.set(e,new zn({color:i,roughness:.7,...t})),Nl.get(e)}const Nr=(i,t)=>"#"+new Zt(i).multiplyScalar(t).getHexString();function re(i,t,e,n=0,s=0,r=0){const a=new yt(i,t);return a.position.set(n,s,r),a.castShadow=!0,a.receiveShadow=!0,e.add(a),a}const ei=(i,t)=>new Ch(i,Math.max(.001,t),5,12),bi=(i,t=20,e=14)=>new hi(i,t,e),bM=.93,SM=.45,wM=.44,EM=.06,TM=.1,ee=.46,kh={ada:{hair:"afro",pants:"#3a3f5c",shoes:"#26211d"},tunde:{hair:"short",pants:"#4b4136",shoes:"#1c1c1c",extra:"lanyard"},mira:{hair:"bob",pants:"#2f3b52",shoes:"#5b4636"},kai:{hair:"spiky",pants:"#38383d",shoes:"#e9e6df",extra:"hood"},zola:{hair:"ponytail",pants:"#4d3f5e",shoes:"#2b2b2b"},remi:{hair:"bun",pants:"#3f4f60",shoes:"#704d38",extra:"glasses"},obi:{hair:"buzz",pants:"#2c3a32",shoes:"#1d1d1d",extra:"headphones"},lin:{hair:"long",pants:"#3b3b4a",shoes:"#2a2a2a"},chief:{hair:"side",pants:"#22232e",shoes:"#141414",extra:"suit"}};function za(i,t,e,n,s,r,a,o,l,c){const h=new qt;h.position.set(t,e,0),i.add(h),re(ei(r,n-r),o,h,0,-n/2);const u=new qt;u.position.y=-n,h.add(u),re(ei(a,s-a),l,u,0,-s/2);const d=new qt;return d.position.y=-s,u.add(d),c==null||c(d),{pivot:h,joint:u,end:d}}class Jr{constructor(t){const e=kh[t.id]||{hair:"short",pants:"#34384a",shoes:"#222"};this.look=e;const n=be(t.skin,{roughness:.6}),s=be(t.shirt),r=be(Nr(t.shirt,.9)),a=be(e.pants),o=be(e.shoes,{roughness:.5}),l=be(t.hair,{roughness:.85});this.group=new qt,this.body=new qt,this.group.add(this.body),this.hips=new qt,this.hips.position.y=.95,this.body.add(this.hips),re(ei(.2,.06),a,this.hips,0,.02).scale.set(1,1,.8);const h=_=>{re(new Ke(.15,.09,.26),o,_,0,-.02,.05).geometry.translate(0,0,0)};this.legL=za(this.hips,-.11,-.02,.45,.44,.1,.085,a,a,h),this.legR=za(this.hips,.11,-.02,.45,.44,.1,.085,a,a,h),this.torso=new qt,this.hips.add(this.torso);const u=[[.001,0],[.19,0],[.225,.08],[.23,.24],[.22,.36],[.255,.5],[.24,.58],[.15,.645],[.001,.66]].map(([_,m])=>new at(_,m)),d=re(new Oo(u,20),e.extra==="suit"?be("#2b2d42"):s,this.torso,0,.04);d.scale.z=.8,re(new ri(.11,.03,8,20),e.extra==="suit"?be("#f4f1ea"):be(Nr(t.shirt,.8)),this.torso,0,.67).rotation.x=Math.PI/2,re(new Fn(.075,.085,.14,12),n,this.torso,0,.73);const f=_=>re(bi(.07,12,10),n,_,0,-.02),g=e.extra==="suit"?be("#2b2d42"):r;this.armL=za(this.torso,-.29,.58,.32,.3,.072,.062,g,e.extra==="suit"||e.extra==="hood"?g:n,f),this.armR=za(this.torso,.29,.58,.32,.3,.072,.062,g,e.extra==="suit"||e.extra==="hood"?g:n,f),this.buildHead(t,n,l),this.buildExtras(t,e,l),this.book=re(new Ke(.34,.05,.26),be("#3d7ea6"),this.torso,0,.3,.36),this.book.rotation.x=-.6,this.book.visible=!1,this.mug=re(new Fn(.06,.055,.13,12),be("#ffffff"),this.armR.end,0,-.06,.07),this.mug.visible=!1,this.blinkAt=1+Math.random()*3,this.blink=0,this.cur={}}buildHead(t,e,n){this.head=new qt,this.head.position.y=.78,this.torso.add(this.head),re(bi(.33,28,20),e,this.head,0,.3).scale.set(1,.97,.94);for(const a of[-1,1])re(bi(.06,10,8),e,this.head,a*.32,.29,-.01).scale.set(.6,1,1);re(bi(.032,10,8),be(Nr(t.skin,.88),{roughness:.6}),this.head,0,.27,.31),this.eyes=[];for(const a of[-1,1]){const o=new qt;o.position.set(a*.115,.33,.285),o.rotation.y=a*.28,this.head.add(o);const l=new yt(bi(.042,14,10),be("#17181c",{roughness:.3}));l.scale.set(.82,1.2,.5),o.add(l);const c=new yt(bi(.013,8,6),new un({color:"#ffffff"}));c.position.set(.012,.018,.02),o.add(c),this.eyes.push(o)}this.brows=[];for(const a of[-1,1]){const o=new yt(ei(.014,.08),be(Nr(t.hair,.9)));o.rotation.z=Math.PI/2;const l=new qt;l.position.set(a*.115,.425,.275),l.rotation.y=a*.28,l.add(o),this.head.add(l),this.brows.push(l)}this.mouth=new yt(new ri(.055,.012,6,18,Math.PI),be("#5b2a2a",{roughness:.5})),this.mouth.position.set(0,.205,.292),this.mouth.rotation.z=Math.PI,this.head.add(this.mouth);for(const a of[-1,1]){const o=new yt(new Ui(.045,16),new un({color:"#ff8d7a",transparent:!0,opacity:.22,depthWrite:!1}));o.position.set(a*.19,.24,.245),o.rotation.y=a*.62,this.head.add(o)}const r=(a=.345,o=.52,l=-.25)=>{const c=re(new hi(a,28,16,0,Math.PI*2,0,Math.PI*o),n,this.head,0,.31,-.01);return c.rotation.x=l,c.scale.set(1,1,.97),c};switch(this.look.hair){case"afro":r(.35,.55),re(bi(.43,24,18),n,this.head,0,.47,-.08).scale.set(1,.85,.95);break;case"bob":{r(.36,.56,-.32);for(const a of[-1,1])re(ei(.09,.2),n,this.head,a*.29,.22,-.1).scale.set(.75,1,1.1);re(ei(.05,.3),n,this.head,0,.55,.17).rotation.z=Math.PI/2;break}case"spiky":r(.35,.5);for(let a=0;a<9;a++){const o=a/9*Math.PI*2;re(new la(.07,.22,6),n,this.head,Math.cos(o)*.17,.6,Math.sin(o)*.17-.03).rotation.set(Math.sin(o)*.7,0,-Math.cos(o)*.7)}break;case"ponytail":{r(.35,.55),re(bi(.07,10,8),be("#e07a5f"),this.head,0,.42,-.33);const a=re(ei(.08,.32),n,this.head,0,.22,-.4);a.rotation.x=.35,this.tail=a;break}case"bun":r(.35,.55),re(bi(.14,16,12),n,this.head,0,.66,-.1);break;case"buzz":r(.338,.5,-.3);break;case"long":{r(.36,.58,-.2),re(ei(.16,.42),n,this.head,0,.1,-.2).scale.set(1.75,1,.6);break}case"side":{r(.35,.5),re(ei(.07,.3),n,this.head,.06,.58,.12).rotation.set(.2,0,Math.PI/2-.25);break}default:r(.35,.5)}}buildExtras(t,e,n){if(e.extra==="glasses"||e.extra==="suit"){const s=be("#1b1b1f",{roughness:.4});for(const r of[-1,1]){const a=re(new ri(.06,.011,6,18),s,this.head,r*.115,.33,.3);a.rotation.y=r*.28}re(ei(.009,.06),s,this.head,0,.34,.315).rotation.z=Math.PI/2}if(e.extra==="suit"){const s=re(new Ke(.06,.3,.02),be("#b23a3a"),this.torso,0,.47,.19);s.rotation.x=-.12,re(new Ke(.16,.18,.02),be("#f4f1ea"),this.torso,0,.56,.175).rotation.x=-.15}if(e.extra==="headphones"){const s=re(new ri(.35,.025,8,24,Math.PI),be("#22252b"),this.head,0,.32,0);s.rotation.y=Math.PI/2,s.rotation.x=-.15;for(const r of[-1,1])re(new Fn(.09,.09,.07,18),be("#e05f4a"),this.head,r*.34,.3,0).rotation.z=Math.PI/2}if(e.extra==="lanyard"&&(re(new ri(.16,.01,6,20,Math.PI),be("#2a6fb0"),this.torso,0,.62,.12).rotation.set(-.25,0,Math.PI),re(new Ke(.1,.13,.015),be("#ffffff"),this.torso,0,.42,.205).rotation.x=-.1),e.extra==="hood"){const s=re(new ri(.2,.06,10,24),be(Nr(t.shirt,.85)),this.torso,0,.64,-.05);s.rotation.x=Math.PI/2+.35,s.scale.set(1,1,.7)}}static sit(t=ee,e=-1.4){const n=t+TM,s=n-SM*Math.cos(e),r=-Math.acos(Math.min(1,Math.max(-1,(s-EM)/wM)));return{y:n-bM,hip:e,knee:r-e}}pose(t,e,n,s={}){const r=Math.min(1,e*10);let a=0,o=0,l=0,c=0,h=.05,u=.05,d=-.12,f=-.12,g=-.07,_=.07,m=0,p=0,y=0,x=0,S=0;const L=Math.sin(n*1.7)*.012;switch(this.book.visible=t==="read",this.mug.visible=t==="mug",t){case"walk":{const v=Math.sin(n*9.5),b=Math.cos(n*9.5);a=v*.5,o=-v*.5,l=Math.max(0,-b)*.9+.05,c=Math.max(0,b)*.9+.05,h=-v*.45,u=v*.45,d=f=-.35,m=Math.abs(b)*.05,p=.06,x=Math.sin(n*4.75)*.04;break}case"desk":{const v=Jr.sit(s.seatY,-1.45);a=o=v.hip,l=c=v.knee,m=v.y,p=.08,s.typing?(h=-.5+Math.sin(n*17)*.05,u=-.5+Math.sin(n*17+2)*.05,d=-1.15+Math.sin(n*19)*.12,f=-1.15+Math.sin(n*19+1.6)*.12,g=-.18,_=.18,y=.12+Math.sin(n*.7)*.03):s.waiting?(u=-.95,f=-2.25,_=.05,h=-.4,d=-1,x=Math.sin(n*.6)*.45,y=-.05):(h=u=-.35,d=f=-.9,g=-.2,_=.2,p=-.04,x=Math.sin(n*.35)*.3);break}case"couch":{const v=Jr.sit(s.seatY,-1.3);a=o=v.hip,l=c=v.knee,m=v.y,p=-.18,h=u=-.2,d=f=-.75,g=-.15,_=.15,x=Math.sin(n*.3)*.5,S=Math.sin(n*.21)*.06;break}case"sit":{const v=Jr.sit(s.seatY,-1.42);a=o=v.hip,l=c=v.knee,m=v.y,p=.03,h=u=-.32,d=f=-.95,g=-.16,_=.16,x=Math.sin(n*.4)*.4,S=Math.sin(n*.27)*.05;break}case"read":h=u=-.55,d=f=-1.35,g=-.12,_=.12,y=.4,x=Math.sin(n*.6)*.12;break;case"type":h=-.75+Math.sin(n*14)*.08,u=-.75+Math.sin(n*14+2)*.08,d=-.9,f=-.9,g=-.15,_=.15,y=.08;break;case"gaze":h=u=.3,d=f=-.25,g=-.12,_=.12,y=-.18,x=Math.sin(n*.45)*.35;break;case"write":u=-2.2+Math.sin(n*6)*.2,f=-.5+Math.sin(n*9)*.15,_=.25,x=Math.sin(n*1.2)*.1,y=-.08;break;case"mug":{const v=Math.sin(n*.8)>.75;u=v?-.85:-.45,f=v?-2.05:-1.55,_=.1,y=v?-.15:.02,x=v?0:Math.sin(n*.4)*.3;break}case"cue":p=.62,h=-1.5,d=-.12,g=-.12,u=-.95,f=-1.35,_=.14,y=-.5,a=o=-.12,l=c=.14,x=Math.sin(n*.8)*.05;break;case"talk":u=-.55+Math.sin(n*4)*.2,f=-1.1+Math.sin(n*5.3)*.2,_=.2,h=-.1,d=-.4,S=Math.sin(n*2.2)*.06,y=-.04;break;case"celebrate":h=u=-2.75,d=f=-.25,g=-.35,_=.35,m=Math.abs(Math.sin(n*8))*.32,y=-.15,l=c=m>.05?.4:.1,a=o=-l*.5;break;case"slump":y=.45,p=.22,h=u=.12,d=f=-.05;break;default:x=Math.sin(n*.5)*.25}const T=this.cur,E=(v,b,I=r)=>T[v]=T[v]===void 0?b:T[v]+(b-T[v])*I,P=t==="walk",U=P?Math.min(1,e*18):r;this.legL.pivot.rotation.x=E("hipL",a,U),this.legR.pivot.rotation.x=E("hipR",o,U),this.legL.joint.rotation.x=E("kneeL",l,U),this.legR.joint.rotation.x=E("kneeR",c,U),this.armL.pivot.rotation.x=E("shL",h,U),this.armR.pivot.rotation.x=E("shR",u,U),this.armL.pivot.rotation.z=E("outL",g),this.armR.pivot.rotation.z=E("outR",_),this.armL.joint.rotation.x=E("elL",d,U),this.armR.joint.rotation.x=E("elR",f,U),this.torso.rotation.x=E("lean",p),this.torso.scale.y=1+L,this.head.rotation.x=E("headX",y,r*.6),this.head.rotation.y=E("headY",x,r*.4),this.head.rotation.z=E("headZ",S,r*.6),this.body.position.y=P||t==="celebrate"?m:E("y",m),this.tail&&(this.tail.rotation.x=.35+Math.sin(n*(P?9.5:1.5))*(P?.12:.03))}express(t,e,n){n>this.blinkAt&&(this.blink=.14,this.blinkAt=n+2+Math.random()*4),this.blink=Math.max(0,this.blink-e);const s=this.blink>0,r=Math.min(1,e*12),a=this.cur,o=(p,y)=>a[p]=a[p]===void 0?y:a[p]+(y-a[p])*r;let l=1,c=0,h=0,u=1,d=1,f=!1;t==="happy"?(l=.3,c=.025,u=1.45,d=1.6):t==="think"?(c=.02,h=.25,u=.55,l=.9):t==="worried"?(h=-.35,c=.01,f=!0,u=.8):t==="talk"&&(u=.8,d=.6+Math.abs(Math.sin(n*13))*1.6,c=Math.sin(n*3)*.008),s&&t!=="happy"&&(l=.1);const g=o("eyeY",l);for(const p of this.eyes)p.scale.y=g;const _=o("browY",c),m=o("browTilt",h);this.brows.forEach((p,y)=>{p.position.y=.425+_,p.rotation.z=(y?-1:1)*m}),this.mouth.rotation.z=f?0:Math.PI,this.mouth.position.y=f?.18:.205,this.mouth.scale.set(o("mouthX",u),o("mouthY",d),1)}}const gn=40,Dn=30,$e={x:7.6,z:10.9,felt:.84},wt={wall:"#f5f0e8",trim:"#d9cdbb",wood:"#c39a6b",woodDark:"#8c6440",metal:"#3b404c",rack:"#262a33",pot:"#e4d6c1",couch:"#5b7fa6",rug:"#c99b84",glass:"#cfe6f2",board:"#fbfaf7",chair:"#30343d"},Ul=new Map;function xe(i,t={}){const e=i+JSON.stringify(t);return Ul.has(e)||Ul.set(e,new zn({color:i,roughness:.82,...t})),Ul.get(e)}function st(i,t,e,n,s,r,a,o,l){const c=new yt(new Ke(t,e,n),l instanceof Oi?l:xe(s,l));return c.position.set(r,a,o),c.castShadow=!0,c.receiveShadow=!0,i.add(c),c}function is(i,t,e,n,s){const r=document.createElement("canvas");r.width=n,r.height=s;const a=new Fi(r);a.colorSpace=Ye,a.anisotropy=4;const o=new yt(new pi(t,e),new un({map:a,toneMapped:!1}));return i.add(o),{canvas:r,ctx:r.getContext("2d"),tex:a,mesh:o}}const oi='"Inter Variable", Inter, system-ui, sans-serif',AM='"JetBrains Mono", ui-monospace, monospace';function te(i,t,e,n,s,r,a,o,l=16,c){const h=new yt(new Fn(t,e,n,l),c instanceof Oi?c:xe(s,c));return h.position.set(r,a,o),h.castShadow=!0,h.receiveShadow=!0,i.add(h),h}const md=["#5f9e6e","#477d55","#6fae74","#3f7350","#7dbb7a"];function CM(i,t,e,n,s=1,r="bush"){const a=new qt;a.position.set(e,0,n),a.rotation.y=e*1.7+n,a.scale.setScalar(s),te(a,.35,.27,.6,wt.pot,0,.3,0,18),te(a,.37,.37,.06,"#d8c8b0",0,.6,0,18),te(a,.31,.31,.02,"#5a4130",0,.62,0,18);const o=(l,c,h,u,d)=>{const f=new yt(new Sr(l,0),xe(md[d%md.length],{flatShading:!0}));f.position.set(c,h,u),f.rotation.set(c*3,u*5,h),f.castShadow=!0,a.add(f)};if(r==="tall")te(a,.035,.05,1.5,wt.woodDark,0,1.35,0,6),o(.42,.12,1.55,.05,1),o(.48,-.15,1.95,-.08,0),o(.38,.18,2.3,.1,2),o(.3,-.05,2.6,0,4);else if(r==="snake")for(let l=0;l<7;l++){const c=l/7*Math.PI*2,h=.8+l*37%5*.12,u=new yt(new la(.07,h,4),xe(l%2?"#4e8a5c":"#6f9f5a",{flatShading:!0}));u.position.set(Math.cos(c)*.12,.62+h/2,Math.sin(c)*.12),u.rotation.set(Math.sin(c)*.18,c,-Math.cos(c)*.18),u.scale.z=.35,u.castShadow=!0,a.add(u)}else o(.55,0,1,0,0),o(.4,.3,1.25,.1,1),o(.38,-.28,1.2,-.12,2),o(.36,.05,1.5,-.2,3);return i.add(a),t.block(e-.45*s,e+.45*s,n-.45*s,n+.45*s),a}function ip(i,t,e,n){te(i,.09,.07,.12,"#e8dccb",t,e+.06,n,12);const s=new yt(new Sr(.1,0),xe("#7aa874",{flatShading:!0}));s.position.set(t,e+.17,n),s.scale.y=.7,s.castShadow=!0,i.add(s)}function qc(i,t,e,n,s=3){const r=["#e07a5f","#3d7ea6","#f2cc8f","#81b29a","#9c6ade"];for(let a=0;a<s;a++){const o=st(i,.34-a*.03,.05,.25,r[(a+Math.round(t*7))%r.length],t,e+.025+a*.05,n);o.rotation.y=(a-1)*.15}}function RM(i,t,e,n){const s=xe("#2f3440",{roughness:.5});te(i,.11,.12,.03,null,t,e+.015,n,16,s);const r=st(i,.03,.42,.03,null,t,e+.22,n,s);r.rotation.x=-.25;const a=st(i,.03,.03,.3,null,t,e+.42,n+.13,s);a.rotation.x=.35;const o=te(i,.05,.12,.14,null,t,e+.36,n+.27,16,xe("#e9b949",{roughness:.45}));o.rotation.x=.4;const l=new yt(new Ui(.1,16),new un({color:"#fff3c9"}));l.position.set(t,e+.3,n+.3),l.rotation.x=-Math.PI/2+.4,i.add(l)}function Ur(i,t,e,n,s,r,a="#3b3330"){const o=[st(i.g,n+.14,s+.14,.05,a,t,e,.18)],l=is(i.g,n,s,Math.round(256*n),Math.round(256*s));l.mesh.position.set(t,e,.21),l.mesh.material=new zn({map:l.tex,roughness:.9}),r(l.ctx,l.canvas.width,l.canvas.height),l.tex.needsUpdate=!0,o.push(l.mesh),i.attach.push(...o)}const Or={sunset(i,t,e){i.fillStyle="#f4e3c8",i.fillRect(0,0,t,e),i.fillStyle="#e9967a",i.beginPath(),i.arc(t*.62,e*.45,t*.2,0,Math.PI*2),i.fill(),i.fillStyle="#8fb0a0",i.beginPath(),i.moveTo(0,e),i.lineTo(0,e*.62),i.quadraticCurveTo(t*.35,e*.4,t*.7,e*.66),i.lineTo(t,e*.58),i.lineTo(t,e),i.fill(),i.fillStyle="#4f7c74",i.beginPath(),i.moveTo(0,e),i.lineTo(0,e*.8),i.quadraticCurveTo(t*.5,e*.6,t,e*.82),i.lineTo(t,e),i.fill()},blocks(i,t,e){i.fillStyle="#f7f1e6",i.fillRect(0,0,t,e);const n=["#e07a5f","#3d405b","#81b29a","#f2cc8f"];i.fillStyle=n[0],i.fillRect(t*.12,e*.12,t*.42,e*.4),i.fillStyle=n[1],i.fillRect(t*.54,e*.12,t*.34,e*.22),i.fillStyle=n[2],i.fillRect(t*.54,e*.34,t*.34,e*.54),i.fillStyle=n[3],i.fillRect(t*.12,e*.52,t*.42,e*.36),i.fillStyle="#3d405b",i.beginPath(),i.arc(t*.33,e*.7,t*.1,0,Math.PI*2),i.fill()},arcs(i,t,e){i.fillStyle="#efe6d8",i.fillRect(0,0,t,e),["#c8553d","#f28f3b","#ffd5c2","#588b8b"].forEach((s,r)=>{i.strokeStyle=s,i.lineWidth=t*.07,i.beginPath(),i.arc(t/2,e*.85,t*(.38-r*.09),Math.PI,0),i.stroke()})},leaf(i,t,e){i.fillStyle="#e7ece4",i.fillRect(0,0,t,e),i.fillStyle="#5f8f6b",i.beginPath(),i.ellipse(t/2,e/2,t*.18,e*.36,.35,0,Math.PI*2),i.fill(),i.strokeStyle="#e7ece4",i.lineWidth=t*.015,i.beginPath(),i.moveTo(t*.38,e*.82),i.lineTo(t*.62,e*.18),i.stroke()}};function PM(i,t,e){const n=is(i.g,.9,.9,256,256);n.mesh.geometry=new Ui(.45,40),n.mesh.position.set(t,e,.22);const s=te(i.g,.5,.5,.08,"#3b3330",t,e,.17,40);s.rotation.x=Math.PI/2,i.attach.push(s,n.mesh);const r=()=>{const{ctx:a,tex:o}=n;a.fillStyle="#fbf8f2",a.fillRect(0,0,256,256),a.translate(128,128),a.fillStyle="#3b3330";for(let d=0;d<12;d++)a.save(),a.rotate(d/12*Math.PI*2),a.fillRect(-3,-112,6,d%3?12:22),a.restore();const l=new Date,c=l.getMinutes(),h=l.getHours()%12+c/60,u=(d,f,g,_)=>{a.save(),a.rotate(d),a.fillStyle=_,a.fillRect(-g/2,-f,g,f+14),a.restore()};u(h/12*Math.PI*2,62,9,"#3b3330"),u(c/60*Math.PI*2,92,6,"#3b3330"),a.fillStyle="#e07a5f",a.beginPath(),a.arc(0,0,8,0,Math.PI*2),a.fill(),a.setTransform(1,0,0,1,0,0),o.needsUpdate=!0};r(),setInterval(r,3e4)}function LM(){const i=document.createElement("canvas");i.width=i.height=512;const t=i.getContext("2d"),e=8,n=512/e;for(let r=0;r<e;r++)for(let a=0;a<e;a++){t.fillStyle=`hsl(${170+Math.random()*8}, ${9+Math.random()*4}%, ${82+Math.random()*2.5}%)`,t.fillRect(r*n,a*n,n,n),t.globalAlpha=.05;for(let o=0;o<40;o++)t.fillStyle=Math.random()<.5?"#000":"#fff",t.fillRect(r*n+Math.random()*n,a*n+Math.random()*n,2,2);t.globalAlpha=1,t.fillStyle="rgba(60, 80, 80, 0.09)",t.fillRect(r*n,a*n,n,1.5),t.fillRect(r*n,a*n,1.5,n)}const s=new Fi(i);return s.colorSpace=Ye,s.wrapS=s.wrapT=ki,s.repeat.set(24.5/8,12.6/8),s.anisotropy=8,s}let Ba;function DM(i,t,e,n,s){if(!Ba){const a=document.createElement("canvas");a.width=256,a.height=64;const o=a.getContext("2d"),l=o.createLinearGradient(0,0,256,0);l.addColorStop(0,"rgba(255, 236, 200, 0.55)"),l.addColorStop(1,"rgba(255, 236, 200, 0)"),o.fillStyle=l,o.fillRect(0,0,256,64),Ba=new Fi(a),Ba.colorSpace=Ye}const r=new yt(new pi(n,s),new un({map:Ba,transparent:!0,depthWrite:!1,blending:sc,opacity:.5}));r.rotation.x=-Math.PI/2,r.position.set(t,.025,e),i.add(r)}let Ol;function IM(){if(!Ol){const i=ap();i.repeat.set(.5,.22),Ol=new zn({map:i,color:"#f0d6b4",roughness:.52})}return Ol}let js;function kM(){if(js)return js;const i=document.createElement("canvas");i.width=384,i.height=128;const t=i.getContext("2d"),e=15,n=5,s=i.width/e,r=i.height/n,a=3;t.fillStyle="#cfcac1",t.fillRect(0,0,i.width,i.height);const o=(c,h,u,d)=>{t.fillStyle="#f7f5f1",t.fillRect(c,h,u,d),t.fillStyle="rgba(88, 84, 78, 0.22)",t.fillRect(c,h+d-2,u,2)};for(let c=0;c<n-1;c++)for(let h=0;h<e;h++)o(h*s+a,c*r+a,s-a*2,r-a*2);const l=(n-1)*r;for(const c of[0,1,2,11,12,13,14])o(c*s+a,l+a,s-a*2,r-a*2);return o(3*s+a,l+a,s*8-a*2,r-a*2),js=new Fi(i),js.colorSpace=Ye,js.anisotropy=4,js}function gd(i,t,e,n,s,r,a=500){const o=new qt;o.position.set(n,s,r),i.add(o);const l=new yt(new Ke(t+.08,e+.12,.05),["#272d38","#272d38","#272d38","#272d38","#1e232c","#3c4352"].map(h=>xe(h)));l.position.set(0,-.015,-.03),l.castShadow=!0,l.receiveShadow=!0,o.add(l),st(o,(t+.08)*.55,.035,.012,"#323a47",0,-e*.34,-.056).castShadow=!1;const c=is(o,t,e,Math.round(t*a),Math.round(e*a));return c.mesh.position.set(0,.015,.002),{g:o,face:c}}function NM(i,t,e,n){const s=xe("#23272f",{roughness:.6});te(i,.11,.13,.025,"#2f3440",t,e+.012,n,14),te(i,.022,.022,.3,"#2f3440",t,e+.16,n,10);const r=new yt(new ri(.11,.022,6,16,Math.PI),s);r.position.set(t,e+.3,n),r.castShadow=!0,i.add(r);for(const a of[-.11,.11]){const o=te(i,.065,.065,.05,null,t+a,e+.28,n,14,s);o.rotation.z=Math.PI/2,o.castShadow=!0}}function UM(i,t,e,n){const s=xe("#f4c430",{roughness:.45}),r=new yt(new hi(.075,12,10),s);r.position.set(t,e+.06,n),r.scale.set(1,.85,1.25),r.castShadow=!0,i.add(r);const a=new yt(new hi(.05,12,10),s);a.position.set(t,e+.15,n-.05),a.castShadow=!0,i.add(a);const o=new yt(new la(.022,.06,8),xe("#e8833a",{roughness:.5}));o.position.set(t,e+.14,n-.11),o.rotation.x=-Math.PI/2,i.add(o);for(const l of[-.02,.02]){const c=new yt(new hi(.008,6,6),xe("#1a1a1a"));c.position.set(t+l,e+.17,n-.085),i.add(c)}}function OM(i,t,e,n,s){const r=new qt;r.position.set(t,e,n),r.rotation.y=-.4+s%2*.8,i.add(r),st(r,.26,.21,.02,"#3b3330",0,.12,0);const a=is(r,.21,.16,84,64);a.mesh.position.set(0,.125,.012);const{ctx:o,canvas:l}=a;o.fillStyle="#cfe3ef",o.fillRect(0,0,l.width,l.height),o.fillStyle="#8fb0a0",o.beginPath(),o.moveTo(0,l.height),o.quadraticCurveTo(l.width*.5,l.height*.35,l.width,l.height),o.fill(),o.fillStyle="#f2cc8f",o.beginPath(),o.arc(l.width*.72,l.height*.3,7,0,Math.PI*2),o.fill(),a.tex.needsUpdate=!0;const c=st(r,.02,.1,.02,"#3b3330",0,.05,-.04);c.rotation.x=.35}function FM(i,t,e,n){const s=st(i,.3,.035,.38,"#44506b",t,e+.018,n);s.rotation.y=.18;const r=st(i,.27,.02,.35,"#f6f2e8",t,e+.028,n+.01);r.rotation.y=.18,te(i,.009,.009,.24,"#e07a5f",t+.04,e+.045,n,8).rotation.set(0,.5,Math.PI/2)}function zM(i,t,e,n,s){const r=new qt;r.position.set(e,0,n);const a=st(r,2.5,.1,1.15,null,0,.78,0,IM());a.receiveShadow=!0,st(r,2.54,.03,1.19,wt.woodDark,0,.742,0);for(const E of[-1.08,1.08])st(r,.09,.72,.16,wt.metal,E,.37,0),st(r,.13,.06,1,wt.metal,E,.03,0),st(r,.13,.05,.86,wt.metal,E,.715,0);st(r,1.95,.07,.08,wt.metal,0,.67,-.18),st(r,2,.3,.04,wt.woodDark,0,.57,-.5);const o=st(r,1.3,.05,.12,"#2a2e38",0,.5,-.3);o.castShadow=!1,st(r,.58,.62,.56,"#e6ded0",.78,.31,-.2);for(const E of[.17,.45]){st(r,.5,.24,.02,"#f1ebe0",.78,E,.09);const P=te(r,.013,.013,.16,"#8d94a3",.78,E,.105,8);P.rotation.z=Math.PI/2}st(r,.17,.07,.2,wt.metal,0,.87,-.47),te(r,.03,.035,.52,wt.metal,0,1.12,-.47,12);const l=st(r,.055,.055,.32,wt.metal,0,1.35,-.38);l.rotation.x=.3,st(r,.14,.14,.05,wt.metal,0,1.42,-.31);const c=gd(r,1.5,.84,0,1.46,-.295);c.g.rotation.x=.05;const h=new un({color:"#2a3442",toneMapped:!1}),u=new yt(new Ui(.014,12),h);u.position.set(.68,-.47,.03),c.g.add(u),s%3===1&&[["#f6d365",-.04,.09],["#f3a6b2",-.19,-.06]].forEach(([E,P,U])=>{const v=st(c.g,.11,.11,.004,E,.8,P,.02);v.rotation.z=U,v.castShadow=!1});const d=gd(r,.6,.36,-.99,1.08,-.02,500);d.g.rotation.y=.62,st(d.g,.3,.03,.2,wt.metal,0,-.25,0),st(d.g,.06,.2,.06,wt.metal,0,-.14,0);const f=st(r,1.18,.008,.42,"#454d5e",0,.834,.16);f.castShadow=!1,st(r,.8,.022,.27,"#e9e6e1",-.02,.849,.15);const g=new yt(new pi(.76,.23),new zn({map:kM(),roughness:.7}));g.rotation.x=-Math.PI/2,g.position.set(-.02,.861,.15),g.receiveShadow=!0,r.add(g);const _=new yt(new hi(.055,12,8),xe("#e9e6e1"));_.position.set(.52,.843,.18),_.scale.set(1,.6,1.45),_.castShadow=!0,r.add(_),st(r,.012,.004,.05,"#9aa3b2",.52,.874,.15).castShadow=!1;const m=["#e07a5f","#3d7ea6","#f2cc8f","#81b29a"][s%4];te(r,.07,.065,.16,m,.66,.91,-.08,14);const p=new yt(new ri(.045,.012,6,12,Math.PI*1.2),xe(m));p.position.set(.73,.92,-.08),p.rotation.y=Math.PI/2,p.rotation.z=-.3,r.add(p);const y=new yt(new Ui(.062,14),xe("#4a3328",{roughness:.3}));y.rotation.x=-Math.PI/2,y.position.set(.66,.985,-.08),r.add(y),[()=>RM(r,.98,.83,-.38),()=>ip(r,1,.83,-.3),()=>qc(r,.98,.83,-.32),()=>NM(r,1,.83,-.3),()=>UM(r,1,.83,-.28),()=>OM(r,1,.83,-.3,s)][s%6](),s%4===2&&FM(r,-.55,.835,-.18);const x=new qt;x.position.set(.86,.835,.44),r.add(x),st(x,.46,.022,.1,"#2f343f",0,.011,0);const S=is(x,.42,.11,256,67);S.mesh.position.set(0,.07,.015),S.mesh.rotation.x=-.42,S.mesh.material=new zn({map:S.tex,roughness:.75});const L=sp(wt.chair);L.position.set(0,0,1.05),r.add(L),i.add(r),t.block(e-1.3,e+1.3,n-.7,n+.5);const T={index:s,x:e,z:n,seat:new R(e,0,n+1.05),seatY:ee,screen:c.face,side:d.face,plate:S,led:h,chair:L};return rp(T,{}),T}function sp(i){const t=new qt,e=xe("#3c4250",{roughness:.9});st(t,.6,.07,.58,i,0,ee-.035,0);const n=st(t,.56,.05,.54,null,0,ee+.01,.01,e);n.castShadow=!1;const s=new qt;s.position.set(0,ee,.3),s.rotation.x=.12,t.add(s),st(s,.56,.3,.09,i,0,.19,0),st(s,.52,.34,.05,null,0,.52,.005,e);for(const r of[-.25,.25])st(s,.05,.36,.06,i,r,.52,0);st(s,.34,.13,.06,i,0,.79,-.01);for(const r of[-.33,.33]){st(t,.05,.22,.4,i,r,ee+.09,.06);const a=st(t,.09,.05,.44,null,r,ee+.21,.04,e);a.castShadow=!1}te(t,.055,.055,.18,"#6e7684",0,ee-.14,0,12),te(t,.042,.042,ee-.22,wt.metal,0,(ee-.22)/2+.06,0,10),te(t,.11,.13,.05,wt.metal,0,.08,0,14);for(let r=0;r<5;r++){const a=r/5*Math.PI*2,o=st(t,.07,.045,.3,wt.metal,0,.075,0);o.position.set(Math.sin(a)*.17,.075,Math.cos(a)*.17),o.rotation.y=a;const l=te(t,.035,.035,.025,"#22262e",Math.sin(a)*.31,.04,Math.cos(a)*.31,10);l.rotation.z=Math.PI/2,l.rotation.y=a}return t}function vd(i,t,e,n,s){const r=new qt;r.position.set(e,0,n),r.rotation.y=s,st(r,1.35,ee-.14,1.2,wt.couch,0,(ee-.14)/2,0),st(r,1.15,.14,1,"#6c8fb6",0,ee-.07,.05),st(r,1.35,.78,.26,wt.couch,0,ee+.25,-.47);for(const o of[-.54,.54])st(r,.27,.56,1.2,wt.couch,o,ee-.06,0);for(const[o,l]of[[-.55,-.5],[.55,-.5],[-.55,.5],[.55,.5]])te(r,.05,.04,.12,wt.woodDark,o,.06,l,8);i.add(r);const a=.75;return t.block(e-a,e+a,n-a,n+a),r}function BM(i,t,e,n){te(i,.26,.26,.08,n,t,ee-.04,e,20),te(i,.035,.035,ee-.09,wt.metal,t,(ee-.09)/2,e,8),te(i,.2,.22,.03,wt.metal,t,.015,e,16)}function _d(i,{title:t="",subtitle:e="",lines:n=[],accent:s="#7bd389",idle:r=!1,t:a=0}){const{ctx:o,canvas:l,tex:c}=i.screen,h=l.width,u=l.height,d=h/512,f=o.createLinearGradient(0,0,0,u);if(f.addColorStop(0,"#141c26"),f.addColorStop(1,"#0d131b"),o.fillStyle=f,o.fillRect(0,0,h,u),r){o.textAlign="center",o.fillStyle="#2f3a49",o.font=`600 ${34*d}px ${oi}`,o.fillText(t,h/2,u/2+4*d),o.fillStyle="#263040",o.font=`400 ${20*d}px ${oi}`,o.fillText(e,h/2,u/2+36*d),o.textAlign="left",c.needsUpdate=!0;return}o.fillStyle=s,o.fillRect(0,0,h,5*d),o.globalAlpha=.09,o.fillRect(0,5*d,h,76*d),o.globalAlpha=1,o.beginPath(),o.arc(30*d,40*d,6*d,0,Math.PI*2),o.fillStyle=s,o.globalAlpha=.55+.45*Math.sin(a*3),o.fill(),o.globalAlpha=1,o.fillStyle="#eaeff5",o.font=`650 ${26*d}px ${oi}`,o.fillText(t,46*d,48*d),o.fillStyle="#7d8a9c",o.font=`400 ${18*d}px ${oi}`,o.fillText(e,46*d,73*d),o.fillStyle="rgba(125, 138, 156, 0.22)",o.fillRect(24*d,92*d,1.5*d,u-104*d),o.font=`400 ${18*d}px ${AM}`;const g=n.slice(-8);g.forEach((_,m)=>{const p=m===g.length-1,y=116*d+m*23*d;o.globalAlpha=p?1:.45+m*.06,o.fillStyle=_.color||(p?"#eaeff5":"#8b98aa");let x=_.text;for(;o.measureText(x).width>h-56*d&&x.length>4;)x=x.slice(0,-2);x!==_.text&&(x=x.slice(0,-1)+"…"),o.fillText(x,38*d,y),o.globalAlpha=1}),Math.floor(a*2)%2===0&&(o.fillStyle=s,o.fillRect(38*d,116*d+g.length*23*d-14*d,9*d,17*d)),c.needsUpdate=!0}function rp(i,{name:t="",accent:e="#7d8a9c",state:n="open"}={}){const s=n==="working";i.led&&i.led.color.set(s?e:n==="open"?"#232a35":"#39455a");const r=i.plate;if(r){const{ctx:o,canvas:l,tex:c}=r;o.fillStyle="#2c323d",o.fillRect(0,0,l.width,l.height),o.fillStyle=n==="open"?"#454c5a":e,o.fillRect(0,0,9,l.height),o.fillStyle=n==="open"?"#8d97a6":"#f3f1ed",o.font=`650 30px ${oi}`,o.textBaseline="middle",o.fillText(t,26,l.height/2+1),o.textBaseline="alphabetic",c.needsUpdate=!0}const a=i.side;if(a){const{ctx:o,canvas:l,tex:c}=a,h=l.width,u=l.height;if(o.fillStyle=n==="open"?"#0b0f15":"#121a24",o.fillRect(0,0,h,u),n==="open"){o.fillStyle="#1b2430",o.beginPath(),o.arc(h/2,u/2,5,0,Math.PI*2),o.fill(),c.needsUpdate=!0;return}o.fillStyle=e,o.globalAlpha=.85,o.fillRect(0,0,h,4),o.globalAlpha=1,o.font=`600 ${Math.round(u*.1)}px ${oi}`,o.fillStyle="#6f7d8f",o.fillText(t.toUpperCase(),14,26),o.textAlign="right",o.fillStyle=s?e:"#4d5a6b",o.fillText(s?"ACTIVE":n==="away"?"OFFLINE":"IDLE",h-14,26),o.textAlign="left";let d=0;for(const f of t+n)d=(d*31+f.charCodeAt(0))%9973;for(let f=0;f<6;f++){const g=44+f*Math.round((u-58)/6),_=Math.max(4,Math.round(u*.045));o.fillStyle="#1b2531",o.fillRect(14,g,h-28,_),d=(d*31+17)%9973;const m=s?.25+d%70/100:.08+d%25/100;o.fillStyle=f===0&&s?e:"#35445a",o.fillRect(14,g,Math.round((h-28)*m),_)}c.needsUpdate=!0}}function HM(i){const t=new MM(gn,Dn),e=[],n=xe("#a97a50"),s=new zn({map:ap(),roughness:.7}),r=new yt(new Ke(gn+.6,.7,Dn+.6),[n,n,s,n,n,n]);r.position.y=-.35,r.receiveShadow=!0,r.castShadow=!0,i.add(r);const a=new yt(new pi(160,160),new Oy({opacity:.14}));a.rotation.x=-Math.PI/2,a.position.y=-.72,a.receiveShadow=!0,i.add(a),i.add(VM(gn+16,Dn+16));const o=st(i,24.5,.02,12.6,null,0,.011,1.2,new zn({map:LM(),roughness:1}));o.castShadow=!1;const l=[Ha(i,gn+.6,0,-Dn/2-.15,0,[0,0,-1]),Ha(i,gn+.6,0,Dn/2+.15,Math.PI,[0,0,1],[[-gn/2-.3,-19.2],[-16.8,gn/2+.3]]),Ha(i,Dn,-gn/2-.15,0,Math.PI/2,[-1,0,0]),Ha(i,Dn,gn/2+.15,0,-Math.PI/2,[1,0,0])],[c,,h,u]=l;t.block(-gn/2,gn/2,-Dn/2,-Dn/2+.2),t.block(-gn/2,-gn/2+.2,-Dn/2,Dn/2);for(const W of[-6,0,6]){const A=-W;h.attach.push(st(h.g,3.6,2.2,.06,wt.glass,A,2.2,.15,{emissive:"#bfe3f5",emissiveIntensity:.45,roughness:.15}),st(h.g,3.8,.12,.14,wt.trim,A,1.08,.2),st(h.g,3.8,.12,.14,wt.trim,A,3.32,.2),st(h.g,.1,2.3,.14,wt.trim,A,2.2,.2))}for(const W of[-6,0,6])DM(i,-17.4,W,5,3.6);const d=[];[[-9,-3],[-3,-3],[3,-3],[9,-3],[-9,5],[-3,5],[3,5],[9,5]].forEach(([W,A],It)=>d.push(zM(i,t,W,A,It)));const f=["#e07a5f","#3d7ea6","#f2cc8f","#81b29a","#9c6ade","#e5989b","#2a9d8f","#577590"];for(const W of[-18.4,-16.2,-14,-11.8]){st(i,2,3.2,.7,wt.woodDark,W,1.6,-14.5);for(let A=0;A<4;A++){const It=.45+A*.75;st(i,1.86,.05,.62,wt.wood,W,It-.04,-14.42);let Ct=W-.85;for(;Ct<W+.8;){const Bt=.1+Math.random()*.1,Dt=.4+Math.random()*.22;st(i,Bt,Dt,.45,f[Math.floor(Math.random()*f.length)],Ct+Bt/2,It+Dt/2,-14.4),Ct+=Bt+.02}}}t.block(-19.6,-10.7,-15,-14);for(const W of[12,13.4,14.8,16.2,17.6]){st(i,1.2,2.7,1,wt.rack,W,1.35,-14.4);for(let A=0;A<9;A++){const It=st(i,.07,.07,.03,"#000",W-.4+A%3*.12,.5+Math.floor(A/3)*.7+Math.random()*.2,-13.88,new zn({color:"#0a0a0a",emissive:["#4ade80","#60a5fa","#fbbf24"][A%3],emissiveIntensity:1.2}));It.castShadow=!1,e.push(It)}for(let A=0;A<6;A++)st(i,1,.02,.02,"#4b5261",W,.35+A*.42,-13.89)}t.block(11.2,18.4,-15,-13.7);const g=new qt;g.position.set(-18.6,0,0);const _=new yt(new Fn(.35,.45,.9,16),xe(wt.woodDark));_.position.y=.45;const m=new yt(new hi(.45,24,16),xe("#4f8fc0",{roughness:.5}));m.position.y=1.35;const p=new yt(new Sr(.46,1),xe("#7fb069",{flatShading:!0,transparent:!0,opacity:.85}));p.position.y=1.35,p.scale.set(1,.9,.7);for(const W of[_,m,p])W.castShadow=!0,g.add(W);i.add(g),t.block(-19.2,-18,-.6,.6);const y=new qt;y.position.set(15.6,0,-8),st(y,5,2.4,.08,wt.board,0,1.9,0,{roughness:.4}),st(y,5.2,.1,.14,wt.metal,0,.66,.02),st(y,.08,1.9,.08,wt.metal,-2.3,.6,0),st(y,.08,1.9,.08,wt.metal,2.3,.6,0);const x=is(y,4.8,2.2,640,290);x.mesh.position.set(0,1.9,.045),i.add(y),t.block(13,18.2,-8.4,-7.6);const S=st(i,9,.02,5.4,wt.rug,-14,.01,10.6);S.castShadow=!1;const L=new qt;L.position.set(-14.5,0,8.4),st(L,5,ee-.14,1.2,wt.couch,0,(ee-.14)/2,0),st(L,5,.8,.3,wt.couch,0,ee+.26,-.48);for(const W of[-2.35,2.35])st(L,.3,.6,1.2,wt.couch,W,ee-.08,0);for(const W of[-1.5,0,1.5])st(L,1.4,.14,1,"#6c8fb6",W,ee-.07,.05);for(const[W,A]of[[-2.2,-.5],[2.2,-.5],[-2.2,.5],[2.2,.5]])te(L,.05,.04,.12,wt.woodDark,W,.06,A,8);i.add(L),t.block(-17,-12,7.8,9),vd(i,t,-17.3,10.9,Math.PI/2),vd(i,t,-12,10.9,-Math.PI/2),st(i,2.4,.08,1.2,wt.wood,-14.5,.48,10.6);for(const[W,A]of[[-1.1,-.5],[1.1,-.5],[-1.1,.5],[1.1,.5]])st(i,.06,.44,.06,wt.metal,-14.5+W,.22,10.6+A);t.block(-15.8,-13.2,10,11.2),st(i,1.3,.95,3.2,"#efe9df",-19.3,.475,12),st(i,.55,.65,.5,"#2c2f36",-19.35,1.28,11.4),st(i,.12,.08,.12,"#c0392b",-19.05,1.4,11.4,{emissive:"#c0392b",emissiveIntensity:.6});for(let W=0;W<3;W++){const A=new yt(new Fn(.07,.06,.14,10),xe("#ffffff"));A.position.set(-19.2,1.02,12.5+W*.25),i.add(A)}t.block(-20,-18.6,10.4,13.6);const T=new qt;T.position.set(-11,0,12),te(T,.3,.34,.04,wt.metal,0,.02,0,20),te(T,.04,.04,1.05,wt.metal,0,.55,0,10),te(T,.48,.48,.05,wt.wood,0,1.08,0,28);for(const[W,A,It]of[[-.18,.08,"#e07a5f"],[.2,-.1,"#3d7ea6"]])te(T,.06,.05,.13,It,W,1.17,A,12);i.add(T),t.block(-11.5,-10.5,11.5,12.5),c.attach.push(st(c.g,9.4,3.5,.08,"#d9cdbb",0,2.2,.2));const E=is(c.g,9,3.2,1536,546);E.mesh.position.set(0,2.2,.26),c.attach.push(E.mesh);const P=new qt;P.position.set(15.5,0,10.6),st(P,3.4,1.05,.9,"#efe9df",0,.525,0),st(P,3.5,.06,1,wt.wood,0,1.08,0),st(P,.9,.55,.05,wt.metal,-.8,1.4,-.25);const U=is(P,1.6,.34,400,85);U.mesh.position.set(0,.62,.456),U.ctx.fillStyle="#efe9df",U.ctx.fillRect(0,0,400,85),U.ctx.fillStyle="#1d1b18",U.ctx.font=`650 38px ${oi}`,U.ctx.textAlign="center",U.ctx.fillText("Chief of Staff",200,56),U.tex.needsUpdate=!0;const v=sp(wt.chair);v.position.set(0,0,-1),v.rotation.y=Math.PI,P.add(v),i.add(P),t.block(13.7,17.3,10.1,11.1);const b=st(i,2.4,.02,1.6,"#b9a58f",18.2,.01,13.4);b.castShadow=!1,Ur(c,-7.6,2.5,1.6,1.1,Or.sunset),PM(c,7.6,2.7),Ur(u,1.4,2.4,1,1.4,Or.arcs),Ur(u,3,2.4,1,1.4,Or.blocks),Ur(u,4.6,2.4,1,1.4,Or.leaf),Ur(h,11,2.5,1.2,.9,Or.blocks,"#c39a6b");const I=new qt;I.position.set(19.35,0,3),st(I,.7,.75,3.6,wt.woodDark,0,.4,0),st(I,.76,.05,3.7,wt.wood,0,.8,0);for(const W of[-1.2,0,1.2])st(I,.02,.6,1.1,"#9a7350",-.36,.4,W);for(const[W]of[[-1.7],[1.7]])st(I,.6,.06,.06,wt.metal,0,.03,W);qc(I,0,.82,-1.1,4),ip(I,0,.82,.2),te(I,.11,.08,.38,"#3d7ea6",.05,1.01,1.2,14,{roughness:.35});for(let W=0;W<3;W++){const A=te(I,.008,.008,.5,"#5f8f6b",.05+(W-1)*.04,1.4,1.2,4);A.rotation.z=(W-1)*.3;const It=new yt(new Sr(.06,0),xe(["#f2cc8f","#e5989b","#fff"][W],{flatShading:!0}));It.position.set(.05+(W-1)*.12,1.64,1.2),I.add(It)}i.add(I),t.block(18.9,20,1.1,4.9);const O=new qt;O.position.set(-1,0,11.6),st(O,5.2,.08,1.4,wt.wood,0,.78,0);for(const W of[-2.3,2.3])st(O,.08,.74,1.1,wt.metal,W,.38,0);for(const W of[-1.7,0,1.7])for(const A of[-1.05,1.05])BM(O,W,A,["#e07a5f","#f2cc8f","#81b29a"][Math.round(W+2)%3]);qc(O,-1.4,.82,.1,2),te(O,.06,.06,.14,"#ffffff",.5,.89,-.2,12);const $=new qt;$.position.set(1.3,.82,.1),st($,.5,.025,.35,"#c7ccd4",0,.012,0);const K=st($,.5,.34,.02,"#c7ccd4",0,.17,-.17);K.rotation.x=-.25,O.add($);for(const W of[-1.6,1.6]){te(O,.02,.02,1.6,"#2f3440",W,3.4,0,6);const A=te(O,.06,.32,.28,"#2f3440",W,2.55,0,20,{roughness:.5});A.castShadow=!1;const It=new yt(new Ui(.29,20),new un({color:"#fff1c4"}));It.rotation.x=Math.PI/2,It.position.set(W,2.405,0),O.add(It)}i.add(O),t.block(-3.8,1.8,10.3,12.9);const z=new qt;z.position.set($e.x,0,$e.z);const Z=.84;st(z,3.7,.22,2.1,wt.woodDark,0,.71,0);for(const[W,A]of[[-1.55,-.85],[1.55,-.85],[-1.55,.85],[1.55,.85]])st(z,.2,.62,.2,wt.woodDark,W,.31,A);st(z,3.5,.03,1.9,"#2f7a57",0,Z-.015,0,{roughness:1});const V=[];for(const W of[-1,1]){for(const A of[-1,1])V.push([1.32,.1,.25,W*.82,A*.925]);V.push([.25,.1,1.36,W*1.725,0])}for(const[W,A,It,Ct,Bt]of V)st(z,W,A,It,wt.wood,Ct,Z+.05,Bt);for(const W of[-1,1])for(const A of[-1,1])st(z,.3,.1,.3,wt.wood,W*1.83,Z+.05,A*.98);for(const[W,A,It,Ct]of[[1.28,.06,.82,.83],[1.28,.06,.82,-.83],[1.28,.06,-.82,.83],[1.28,.06,-.82,-.83]])st(z,W,.05,A,"#256646",It,Z+.025,Ct).castShadow=!1;for(const W of[-1,1])st(z,.06,.05,1.3,"#256646",W*1.57,Z+.025,0).castShadow=!1;const ot=new un({color:"#0c0d10"});for(const[W,A]of[[-1.6,-.8],[1.6,-.8],[-1.6,.8],[1.6,.8],[0,-.835],[0,.835]]){const It=new yt(new Fn(.15,.15,.02,20),ot);It.position.set(W,Z+.002,A),z.add(It)}i.add(z),t.block($e.x-1.95,$e.x+1.95,$e.z-1.15,$e.z+1.15);const ct=new qt;ct.position.set(-18,0,8.2),te(ct,.22,.24,.04,"#2f3440",0,.02,0,20),te(ct,.025,.025,1.7,"#2f3440",0,.87,0,8);const _t=te(ct,.22,.3,.38,"#f3e7d3",0,1.85,0,24,{emissive:"#ffe2a8",emissiveIntensity:.35,roughness:.9});_t.castShadow=!1,i.add(ct),t.block(-18.4,-17.6,7.8,8.6);const $t=st(i,5,.02,3.2,"#c9b79c",15.5,.012,12.6,{roughness:1});$t.castShadow=!1;const Jt=st(i,4.6,.022,2.8,"#ddd0bb",15.5,.013,12.6,{roughness:1});Jt.castShadow=!1;const j=[[-19,-9.5,1.1,"tall"],[10,-14,1,"snake"],[-9.8,-14.2,.9,"bush"],[19,-11,1.2,"tall"],[-10.3,14,1,"bush"],[6.2,13.8,1.1,"tall"],[19,8.5,1,"snake"],[19.2,0,.9,"bush"],[-19.1,14.2,.8,"snake"],[11.6,13.9,1,"bush"]];for(const[W,A,It,Ct]of j)CM(i,t,W,A,It,Ct);const et={n:Math.PI,s:0,w:-Math.PI/2,e:Math.PI/2},ft=W=>W.map(([A,It,Ct,Bt,Dt])=>({pos:new R(A,0,It),face:et[Ct],pose:Bt,seatY:Dt,taken:null})),lt={library:{label:"Library",spots:ft([[-17.6,-12.9,"n","read"],[-15.3,-12.9,"n","read"],[-13.1,-12.9,"n","read"],[-11,-12.9,"n","read"]])},servers:{label:"Server room",spots:ft([[12.7,-12.6,"n","type"],[14.1,-12.6,"n","type"],[15.5,-12.6,"n","type"],[16.9,-12.6,"n","type"]])},window:{label:"Research window",spots:ft([[-17.5,-6,"w","gaze"],[-17.5,-2.6,"w","gaze"],[-17.5,2.6,"w","gaze"],[-17.5,6,"w","gaze"]])},whiteboard:{label:"Whiteboard",spots:ft([[13.9,-6.4,"n","write"],[15.2,-6.4,"n","write"],[16.5,-6.4,"n","write"],[17.8,-6.4,"n","write"]])},lounge:{label:"Break room",spots:ft([[-16,8.5,"s","couch",ee],[-14.5,8.5,"s","couch",ee],[-13,8.5,"s","couch",ee],[-17.2,10.9,"e","couch",ee],[-11.9,10.9,"w","couch",ee],[-2.7,10.55,"s","sit",ee],[-1,10.55,"s","sit",ee],[.7,10.55,"s","sit",ee],[-2.7,12.65,"n","sit",ee],[-1,12.65,"n","sit",ee],[.7,12.65,"n","sit",ee],[-17.9,11.4,"w","mug"],[-17.9,12.8,"w","mug"],[-11.95,12,"e","mug"],[-10.05,12,"w","mug"]])}},At=new R(15.3,0,-2.4),Tt=Array.from({length:10},(W,A)=>{const It=Math.PI+A/10*Math.PI*2,Ct=new R(At.x+Math.sin(It)*2.3,0,At.z+Math.cos(It)*2.3);return{pos:Ct,face:Math.atan2(At.x-Ct.x,At.z-Ct.z)}});lt.lounge.spots.push({pos:new R($e.x-.9,0,$e.z-1.65),face:et.s,pose:"stand",taken:null,game:!0},{pos:new R($e.x+.9,0,$e.z+1.65),face:et.n,pose:"stand",taken:null,game:!0});const zt=(W,A,It,Ct,Bt)=>({pos:new R(W,0,A),face:Math.atan2(It-W,Ct-A),pose:Bt,taken:null});return lt.hotdesk={label:"Hot desks",spots:[-4.5,-2.7,-.9,.9,2.7,4.5].map(W=>zt(W,-13.4,W,-15,"read"))},lt.poolside={label:"Pool table",spots:[[4.9,10.9],[10.3,10.9],[9.6,8.8],[5.6,8.8]].map(([W,A])=>zt(W,A,$e.x,$e.z,"mug"))},lt.coffee={label:"Coffee",spots:lt.lounge.spots.filter(W=>W.pose==="mug")},lt.huddle={label:"Break-room table",spots:[[-4.5,11],[-4.5,12.2],[2.5,11],[2.5,12.2],[-1.85,9.6],[-.15,9.6]].map(([W,A])=>zt(W,A,-1,11.6,"stand"))},{grid:t,desks:d,stations:lt,pool:z,standup:Tt,board:E,scribble:x,blinkers:e,globe:p,slab:r,updateWalls:(W,A,It)=>$M(l,W,A,It),door:new R(18.6,0,14.4),reception:{seat:new R(15.5,0,9.6),seatY:ee}}}function ap(){const i=document.createElement("canvas");i.width=i.height=1024;const t=i.getContext("2d"),e=16,n=i.height/e;for(let r=0;r<e;r++){let a=-Math.random()*400;for(;a<i.width;){const o=380+Math.random()*520,l=73+Math.random()*3.5;t.fillStyle=`hsl(${32+Math.random()*3}, ${33+Math.random()*5}%, ${l}%)`,t.fillRect(a,r*n,o,n),t.globalAlpha=.045;for(let c=0;c<6;c++)t.fillStyle=Math.random()<.5?"#7a5634":"#fff6e8",t.fillRect(a,r*n+Math.random()*n,o,1+Math.random()*2);t.globalAlpha=1,t.fillStyle="rgba(90, 60, 35, 0.22)",t.fillRect(a,r*n,2,n),a+=o}t.fillStyle="rgba(90, 60, 35, 0.18)",t.fillRect(0,r*n,i.width,2)}const s=new Fi(i);return s.colorSpace=Ye,s.wrapS=s.wrapT=ki,s.repeat.set(gn/8,Dn/8),s.anisotropy=8,s}function VM(i,t){const e=document.createElement("canvas");e.width=e.height=256;const n=e.getContext("2d"),s=n.createRadialGradient(128,128,30,128,128,128);s.addColorStop(0,"rgba(60, 40, 20, 0.28)"),s.addColorStop(.6,"rgba(60, 40, 20, 0.12)"),s.addColorStop(1,"rgba(60, 40, 20, 0)"),n.fillStyle=s,n.fillRect(0,0,256,256);const r=new Fi(e),a=new yt(new pi(i,t),new un({map:r,transparent:!0,depthWrite:!1}));return a.rotation.x=-Math.PI/2,a.position.y=-.715,a}const nr=4.2,GM=.5;function Ha(i,t,e,n,s,r,a=[[-t/2,t/2]]){const o=new qt;o.position.set(e,0,n),o.rotation.y=s;const l=new qt,c=new qt;o.add(l,c);for(const[u,d]of a){const f=new yt(new Ke(d-u,nr,.3),xe(wt.wall));f.position.set((u+d)/2,nr/2,0),f.castShadow=f.receiveShadow=!0,l.add(f);const g=new yt(new Ke(d-u,.1,.36),xe("#cbbba3"));g.position.set((u+d)/2,.05,0),c.add(g);const _=new yt(new Ke(d-u,.22,.04),xe(wt.trim));_.position.set((u+d)/2,.11,.17),o.add(_)}i.add(o);const h={g:o,body:l,cap:c,outward:new R(...r),h:nr,attach:[]};return c.position.y=nr,h}const xd=new R;function $M(i,t,e,n){xd.subVectors(t.position,e).setY(0).normalize();for(const s of i){const r=s.outward.dot(xd)>.2?GM:nr;s.h+=(r-s.h)*Math.min(1,n*7),s.body.scale.y=s.h/nr,s.cap.position.y=s.h;for(const a of s.attach)a.visible=s.h>3.4}}const WM={queued:0,working:1,done:2,failed:2,stopped:2},XM={queued:"#fde68a",working:"#bfdbfe",done:"#bbf7d0",failed:"#fecaca",stopped:"#e5e7eb"};function op(i,t){const{ctx:e,canvas:n,tex:s}=i,r=n.width,a=n.height;e.fillStyle="#fbfaf7",e.fillRect(0,0,r,a);const o=["Queued","Working","Shipped"],l=r/3;o.forEach((c,h)=>{e.fillStyle="#1d1b18",e.font=`650 34px ${oi}`,e.fillText(c,h*l+28,54),h&&(e.fillStyle="#e7e1d7",e.fillRect(h*l,20,3,a-40)),t.filter(d=>WM[d.status]===h).sort((d,f)=>(f.endedAt||f.queuedAt)-(d.endedAt||d.queuedAt)).slice(0,6).forEach((d,f)=>{const g=h*l+28+f%2*(l/2-18),_=80+Math.floor(f/2)*150,m=l/2-36,p=130;e.save(),e.translate(g+m/2,_+p/2),e.rotate((d.id.charCodeAt(0)%7-3)*.008),e.fillStyle="rgba(0,0,0,0.08)",e.fillRect(-m/2+4,-p/2+6,m,p),e.fillStyle=XM[d.status],e.fillRect(-m/2,-p/2,m,p),e.fillStyle="#1d1b18",e.font=`600 22px ${oi}`,jM(e,d.title,-m/2+14,-p/2+34,m-28,26,3),e.fillStyle="#5b554c",e.font=`400 18px ${oi}`,e.fillText(d.repo.slice(0,22),-m/2+14,p/2-14),e.restore()})}),s.needsUpdate=!0}function jM(i,t,e,n,s,r,a){const o=String(t).split(/\s+/);let l="",c=0;for(let h=0;h<o.length;h++){const u=l?l+" "+o[h]:o[h];if(i.measureText(u).width>s&&l){if(c===a-1){i.fillText(l+"…",e,n+c*r);return}i.fillText(l,e,n+c*r),l=o[h],c++}else l=u}i.fillText(l,e,n+c*r)}function Yc(i,t){const{ctx:e,canvas:n,tex:s}=i;e.fillStyle="#fbfaf7",e.fillRect(0,0,n.width,n.height),e.fillStyle="#2f5d8a",e.font='600 30px "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive',e.fillText("Today",26,46),e.font='400 24px "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive',t.slice(0,7).forEach((r,a)=>{e.fillStyle=r.done?"#6b8f71":"#3a3a3a";const o=(r.done?"✓ ":"• ")+r.text;e.fillText(o.length>44?o.slice(0,43)+"…":o,30,86+a*30)}),s.needsUpdate=!0}const yd=(i,t,e)=>{let n=((t-i+Math.PI)%(Math.PI*2)+Math.PI*2)%(Math.PI*2)-Math.PI;return i+n*e},Fr=(i,t)=>i+Math.random()*(t-i);function Va(i,t=34){let e=String(i||"").replace(/\s+/g," ").trim();const n=e.search(/[,;:]| \u2014 | - | and | with | so that | in order /i);if(n>11&&(e=e.slice(0,n)),e.length<=t)return e;const s=e.lastIndexOf(" ",t);return e.slice(0,s>t*.6?s:t).replace(/[,.;:]$/,"")+"…"}const Md=["coffee?","anyone seen my mug","back in 5","nice weather","who broke main","lunch soon?","reading the docs, honestly","standup when"];let Fl=null;function qM(){if(Fl)return Fl;const i=document.createElement("canvas");i.width=i.height=64;const t=i.getContext("2d"),e=t.createRadialGradient(32,32,4,32,32,32);return e.addColorStop(0,"rgba(40, 28, 16, 0.32)"),e.addColorStop(1,"rgba(40, 28, 16, 0)"),t.fillStyle=e,t.fillRect(0,0,64,64),Fl=new Fi(i)}class Nh{constructor(t,e,n,s={}){this.staff=t,this.id=t.id,this.name=t.name,this.world=e,this.desk=s.desk||e.desks[e.agentIndex(t.id)],this.deskFace=s.face??Math.PI,this.root=new qt,this.fig=new Jr(t),this.root.add(this.fig.group),this.body=this.fig.body;const r=new yt(new Ui(.5,24),new un({map:qM(),transparent:!0,depthWrite:!1}));r.rotation.x=-Math.PI/2,r.position.y=.015,this.root.add(r),this.ring=new yt(new Ph(.55,.68,40),new un({color:t.shirt,transparent:!0,opacity:.9})),this.ring.rotation.x=-Math.PI/2,this.ring.position.y=.03,this.ring.visible=!1,this.root.add(this.ring),this.root.traverse(c=>{c.userData.agentId=t.id}),e.scene.add(this.root),this.pos=this.root.position,this.heading=0,this.path=[],this.goal=null,this.placeKey=null,this.spot=null,this.pose="stand",this.want="lounge",this.dwellUntil=0,this.wanderAt=0,this.chatAt=Fr(8,30),this.anim=null,this.job=null,this.lines=[],this.phase=Math.random()*10,this.label=document.createElement("div"),this.label.className="agent-label";const a=document.createElement("div");a.className="bubble";const o=document.createElement("div");o.className="name";const l=document.createElement("i");/^#[0-9a-f]{3,8}$/i.test(t.shirt??"")&&(l.style.background=t.shirt),o.append(l,String(t.name??"")),this.label.append(a,o),this.bubbleEl=this.label.querySelector(".bubble"),n.appendChild(this.label),this.say("")}say(t,e="",n=0){t!==this.bubbleText&&(this.labelDirty=!0),this.bubbleText=t,this.bubbleEl.textContent=t,this.bubbleEl.className="bubble"+(e?" "+e:""),this.bubbleEl.style.display=t?"":"none",this.bubbleUntil=n?(this.now||0)+n/1e3:0}teleport(t){const e=this.resolve(t);e&&(this.pos.copy(e.pos),this.heading=e.face,this.root.rotation.y=e.face,this.goal=e,this.path=[],this.arrive(0))}resolve(t,e=!1){if(t==="desk")return{key:t,pos:this.desk.seat.clone(),face:this.deskFace,pose:"desk",seatY:this.desk.seatY};if(t==="visit")return this.visitTarget;if(t==="standup")return this.meeting;if(t==="door")return{key:t,pos:this.world.door.clone(),face:Math.PI,pose:"stand"};const n=this.world.stations[t];if(!n)return null;let s=!e&&this.spot&&n.spots.includes(this.spot)?this.spot:null;if(!s){const a=n.spots.filter(l=>!l.game&&(!l.taken||l.taken===this.id)),o=e?a.filter(l=>l!==this.spot):a;s=(o.length?o:a)[Math.floor(Math.random()*(o.length||a.length))]}if(!s)return t==="lounge"?null:this.resolve("desk");this.spot&&this.spot!==s&&(this.spot.taken=null),s.taken=this.id,this.spot=s;const r=t==="lounge"?0:.12;return{key:t,pos:s.pos.clone().add(new R(Fr(-r,r),0,Fr(-r,r))),face:s.face,pose:s.pose,seatY:s.seatY}}goTo(t,e,n=!1){t==="desk"&&this.spot&&(this.spot.taken=null,this.spot=null);const s=this.resolve(t,n);s&&(this.goal=s,this.placeKey=null,this.path=this.world.grid.path(this.pos.x,this.pos.z,s.pos.x,s.pos.z),this.path.length||this.arrive(e))}arrive(t){const e=this.goal;this.pos.set(e.pos.x,0,e.pos.z),this.placeKey=e.key,this.pose=e.pose,this.seatY=e.seatY,this.dwellUntil=t+(e.key==="desk"?.8:e.key==="lounge"?0:e.key==="visit"?3.4:e.key==="standup"?.5:2.4),e.key==="lounge"&&(this.wanderAt=t+Fr(18,40))}assign(t,e=!1){this.job=t,this.anim=null,this.want="desk",this.lines=[],this.say("On it","",0),e&&this.teleport("desk")}visit(t,e){const n=this.world.grid,s=[[1.1,0],[-1.1,0],[0,1.1],[0,-1.1],[.9,.9],[-.9,.9]],[r,a]=s.find(([l,c])=>!n.blocked(...n.cellOf(t.pos.x+l,t.pos.z+c)))||[1.1,0],o=new R(t.pos.x+r,0,t.pos.z+a);this.visitTarget={key:"visit",pos:o,face:Math.atan2(t.pos.x-o.x,t.pos.z-o.z),pose:"talk"},this.afterVisit=this.want==="visit"?this.afterVisit:this.want,this.want="visit",this.placeKey=null,this.path=[],this.spot&&(this.spot.taken=null,this.spot=null),this.say(Va(e,52),"talk",0)}onLog(t){if(!this.job)return;const e=(...r)=>!this.meeting&&this.say(...r),n={tool:null,text:"#e8edf3",error:"#f87171",thinking:"#64748b",system:"#64748b"}[t.kind],s=r=>{this.want==="visit"?this.afterVisit=r:this.want=r};if(t.kind==="tool")s("desk"),e(Va(t.summary)),this.lines.push({text:"› "+t.summary,color:n});else if(t.kind==="text"){s("desk");const r=t.summary.split(new RegExp("(?<=[.!?])\\s|\\n"))[0];e(Va(r,44)),this.lines.push({text:r,color:n})}else t.kind==="thinking"?e("thinking…","thinking"):t.kind==="error"?(e(t.blocked?"Needs clearance":"Hm, that failed","warn"),this.lines.push({text:"✕ "+t.summary.split(`
|
|
4300
|
+
`)[0],color:n})):t.kind==="system"&&(this.lines.push({text:t.summary,color:n}),t.wait&&(s("desk"),e(Va(t.summary,30)+"…","thinking")));this.lines.length>40&&this.lines.splice(0,this.lines.length-40)}meet(t,e=!1){if(this.meeting={key:"standup",pos:t.pos.clone(),face:t.face,pose:"stand"},this.spot&&(this.spot.taken=null,this.spot=null),e)return this.teleport("standup");this.want!=="visit"&&(this.path=[],this.placeKey=null)}adjourn(){this.meeting=null,this.placeKey==="standup"&&(this.placeKey=null)}speak(t){this.say(t,"talk",5200),this.anim={kind:"talk",until:(this.now||0)+4.8}}leave(){this.leaving=!0,this.want="door",this.spot&&(this.spot.taken=null,this.spot=null),this.say("Heading home","idle",3e3)}stay(){this.leaving=!1,this.want="lounge",this.say("Oh, staying!","good",2500)}dispose(){this.spot&&(this.spot.taken=null),this.world.scene.remove(this.root),this.label.remove()}finish(t){const e=this.now||0;this.anim={kind:t==="done"?"celebrate":"slump",until:e+2.2},this.say(t==="done"?"Shipped it!":t==="waiting"?"Need your answer":t==="stopped"?"Okay, stopping":"Hit a wall",t==="done"?"good":"warn",4e3),this.job=null,this.afterVisit=null,this.want="lounge"}think(t){var s;if(this.anim&&t<this.anim.until)return;this.anim=null,this.bubbleUntil&&t>this.bubbleUntil&&this.say("");const e=this.meeting&&!this.leaving&&this.want!=="visit"?"standup":this.want;if(this.path.length){((s=this.goal)==null?void 0:s.key)==="lounge"&&e!=="lounge"&&this.goTo(e,t);return}if(t<this.dwellUntil)return;if(this.leaving&&this.placeKey==="door"){this.gone=!0;return}this.placeKey==="visit"&&this.want==="visit"&&(this.want=this.job?this.afterVisit||"desk":"lounge",this.afterVisit=null,this.bubbleEl.classList.contains("talk")&&this.say(""));const n=this.meeting&&!this.leaving&&this.want!=="visit"?"standup":this.want;n!==this.placeKey?this.goTo(n,t):n==="lounge"&&t>this.wanderAt&&this.goTo("lounge",t,!0),!this.job&&!this.meeting&&!this.chatting&&t>this.chatAt&&(this.chatAt=t+Fr(25,60),Math.random()<.5&&this.say(Md[Math.floor(Math.random()*Md.length)],"idle",3500))}update(t,e){var s;this.now=e,this.think(e);let n=!1;if(this.path.length){const[r,a]=this.path[0],o=r-this.pos.x,l=a-this.pos.z,c=Math.hypot(o,l),h=3.4*t;c<=h?(this.pos.x=r,this.pos.z=a,this.path.shift(),this.path.length||this.arrive(e)):(this.pos.x+=o/c*h,this.pos.z+=l/c*h,this.heading=yd(this.heading,Math.atan2(o,l),Math.min(1,t*12)),n=!0)}!n&&this.goal&&!this.path.length&&(this.heading=yd(this.heading,this.goal.face,Math.min(1,t*8))),this.root.rotation.y=this.heading,this.animate(n?"walk":((s=this.anim)==null?void 0:s.kind)||this.pose,t,e)}animate(t,e,n){var a;this.fig.pose(t,e,n+this.phase,{typing:!!this.job&&!this.job.waiting&&this.job.id!=="idle",waiting:!!((a=this.job)!=null&&a.waiting),seatY:this.seatY});const s=this.bubbleEl.className,r=t==="celebrate"?"happy":t==="slump"||s.includes("warn")?"worried":t==="talk"||s.includes("idle")&&this.bubbleText?"talk":s.includes("thinking")?"think":s.includes("good")?"happy":"neutral";this.fig.express(r,e,n+this.phase)}placeLabel(t,e,n){const s=new R(this.pos.x,this.body.position.y+2.5+(this.fig.look.hair==="afro"?.2:0),this.pos.z).project(t);if(this.onScreen=s.z<=1,!this.onScreen){this.label.style.display="none",this.lift=0;return}this.label.style.display="",this.anchorX=(s.x*.5+.5)*e,this.anchorY=(-s.y*.5+.5)*n,this.depth=s.z,this.label.style.zIndex=String(Math.round((1-s.z)*1e4)),(this.labelDirty||!this.labelW)&&this.measureLabel()}measureLabel(){this.label.offsetWidth&&(this.labelDirty=!1,this.labelW=this.label.offsetWidth,this.labelH=this.label.offsetHeight)}labelBox(t){const e=this.anchorY-t;return{left:this.anchorX-this.labelW/2,right:this.anchorX+this.labelW/2,top:e-this.labelH,bottom:e}}setLift(t,e){const n=this.lift===void 0?1:Math.min(1,e*9);this.lift=(this.lift||0)+(t-(this.lift||0))*n,Math.abs(this.lift-t)<.4&&(this.lift=t),this.label.style.transform=`translate(-50%, -100%) translate(${this.anchorX}px, ${this.anchorY-this.lift}px)`}setBuried(t){t!==this.buried&&(this.buried=t,this.label.classList.toggle("buried",t))}setCrowded(t,e){t?this.uncrowdAt=e+.6:this.crowded&&e<(this.uncrowdAt||0)&&(t=!0),t!==this.crowded&&(this.crowded=t,this.label.classList.toggle("crowded",t),this.measureLabel())}setSelected(t){this.ring.visible=t,this.label.classList.toggle("selected",t)}}const Ga=(i,t)=>i+Math.random()*(t-i),Qr=i=>i[Math.floor(Math.random()*i.length)];async function Ji(i,t,e){const n=await fetch(i,t===void 0?{method:e||"GET"}:{method:e||"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`Request failed (${n.status})`);return n.json().catch(()=>({}))}const YM=[["Coffee machine is making that noise again.","It does that when it likes you.","It has never liked me."],["Weekend plans, {b}?","Sleep, then more sleep.","Ambitious. I respect it."],["Did you see the size of that last diff?","I saw it. I chose not to look closer.","Wise."],["{b}, tabs or spaces?","Whatever the linter says.","Diplomatic answer.","It's the only safe one in here."],["I renamed one variable and forty tests broke.","Only forty? Lucky.","You have a dark sense of luck, {b}."],["Who keeps leaving one sip in the coffee pot?","Not me.","That is exactly what someone guilty would say."],["Favourite error message?",'"Something went wrong."',"So helpful. So honest."],["Read anything good lately?","The changelog for our test runner. Gripping stuff.","No spoilers please."],["This couch is too comfy.","Dangerous for productivity.","Good thing nobody has given us work yet."],["Do you ever dream in stack traces?","Only on deploy days.","Same."],["{b}, you were quiet in standup.","Saving my words for code review.","Ominous."],["Hot take: README files are love letters.","To whom?","To whoever opens this repo at 2am.","That's beautiful, {a}."],["What's the plant's name?","I call it Prod.","Why?","Because we don't touch it."],["I fixed a bug by deleting code today.","Best kind of fix.","Felt like spring cleaning."],["Lunch?","Already had it. Twice.","Bold."],['Have you noticed the boss says "quick change" a lot?',"Never quick.","Rarely one change."],["If you could rewrite one thing from scratch?","The build config.","Wouldn't we all."],["How do you stay so calm, {b}?","Small commits.","That explains a lot."]],KM=[{pair:["tunde","obi"],lines:["Still thinking about idempotency keys, {b}.","You always are. It is why I trust you with the ledger.","Say it again, but with a retry.","Same result. That is the whole point."]},{pair:["tunde","obi"],lines:["Remember the first ledger?","Four of us and one whiteboard.","We never did erase that whiteboard.","It's load-bearing now."]},{pair:["kai","zola"],lines:["Submission day, {b}. Checklist out?","Always out. Step one: breathe.","Step two: provisioning profile.","Step two is where we cry."]},{pair:["kai","zola"],lines:["Another rejection email. I can feel it.","Read it first. Then panic.","That is not on the checklist.","I will add it."]},{pair:["ada","mira"],lines:["I had a thought about the dashboard, {b}.","Is it a question? Please let it be a question.","It is a question.","Then I love it already. Go."]},{pair:["ada","tunde"],lines:["Does the new screen survive a retry, {b}?","You asked before I did.","You taught me.","Noted. Quietly proud."]},{pair:["ada","kai"],lines:["It should feel the same on web and app.","Thumbs do not agree.","Thumbs never do.","Move the button down, {a}."]},{pair:["mira","lin"],lines:["Could you look at this early, {b}? Before it is finished?","You ask early. I like that.","Startup scars.","The good kind of scar."]},{pair:["mira","tunde"],lines:["I could just own this whole feature, {b}.","Could you also wait for my green light?","That is the hard part.","It is the part that saves you."]},{pair:["mira","zola"],lines:["Ship it now, {b}?","Not yet.","How about now?","Ask me after the checklist."]},{pair:["lin","obi"],lines:["Another payload for you, {a}.","Guilty until proven valid.","You read my mind.","I read your schema."]},{pair:["lin","tunde"],lines:["Your logs are very readable, {b}.","I log everything now.","I know. It started on a train.","Do not remind me."]},{pair:["zola","tunde"],lines:["That alert again.","I saw it.","We nod?","We nod."]},{pair:["remi","mira"],lines:["Found a bug in your feature, {b}.","Wonderful. Send me the steps.","No defence? No excuses?","I would rather have the bug than the excuse."]}],ZM=[{who:"tunde",lines:["Remember the Tuesday, {b}?","Nobody has forgotten the Tuesday.","That is why I log everything now.","Fair enough."]},{who:"kai",lines:["Did you hear? An app rejected over one permission string.","Is this the one you keep telling us about?","Never gets old.","It does, {a}."]},{who:"ada",lines:["Found a loading spinner I actually like.","Is it going in the folder?","It is going in the folder.","There is a folder?"]},{who:"zola",lines:["The release train ran on time again.","Because of the checklist.","Because of the checklist.","We all owe it a coffee."]},{who:"obi",lines:["Webhooks are promises, {b}.","To whom?","To whichever team is waiting on them.","Heavy thought for a coffee break."]},{who:"mira",lines:["One quick question, {b}.","Your questions are never quick.","This one is tiny.","Narrator: it was not."]},{who:"lin",lines:["Anyone have a worry they have not told anyone?","Not yet.","My door is open, and so is the kettle.","Thanks, {a}."]},{who:"remi",lines:['Anyone say "it works on my machine" today?',"Not me.","Good. I was sharpening my pencil.","Please do not."]}];function JM(i,t){const e=KM.filter(r=>r.pair.includes(i.id)&&r.pair.includes(t.id)),n=ZM.filter(r=>r.who===i.id||r.who===t.id),s=Math.random();if(e.length&&s<.55){const r=Qr(e);return bd(r.pair[0],r.lines,i,t)}if(n.length&&s<.8){const r=Qr(n);return bd(r.who,r.lines,i,t)}return{who:[i,t],script:Qr(YM)}}function bd(i,t,e,n){return{who:i===e.id?[e,n]:[n,e],script:t}}const zr=i=>!i.job&&!i.meeting&&!i.leaving&&!i.path.length&&i.want==="lounge"&&i.placeKey==="lounge"&&!i.playing;class QM{constructor(){this.next=Ga(10,20),this.chat=null,this.claiming=!1}update(t,e){if(this.chat)return this.step(e);if(this.claiming||e<this.next)return;const n=t.filter(zr);if(n.length<2)return;const s=Qr(n),r=Qr(n.filter(a=>a!==s));this.claim(s,r,e)}async claim(t,e,n){this.claiming=!0,this.next=n+Ga(20,45);let s=null,r=null;try{({id:s,script:r}=await Ji("/api/chill",{who:[t.id,e.id]}))}catch{}if(this.claiming=!1,!!s){if(!zr(t)||!zr(e))return this.release(s);this.start(t,e,s,r)}}start(t,e,n,s){const{who:[r,a],script:o}=Array.isArray(s)&&s.length>=2?{who:[t,e],script:s}:JM(t,e),l=o.map(c=>c.replaceAll("{a}",r.name).replaceAll("{b}",a.name));for(const[c,h]of[[r,a],[a,r]])c.chatting=!0,c.wanderAt=1/0,c.pose!=="couch"&&(c.goal={...c.goal,face:Math.atan2(h.pos.x-c.pos.x,h.pos.z-c.pos.z)});this.chat={id:n,who:[r,a],script:l,line:0,at:0}}step(t){const e=this.chat;if(!e.who.every(zr))return this.end(t);if(t<e.at)return;if(e.line>=e.script.length)return this.end(t);const n=e.who[e.line%2],s=e.script[e.line];n.say(s,"idle",3200+s.length*30),Ji(`/api/chill/${e.id}/line`,{from:n.id,text:s}).catch(()=>{}),e.at=t+2.6+s.length*.035,e.line++}end(t){this.release(this.chat.id);for(const e of this.chat.who)e.chatting=!1,zr(e)&&(e.wanderAt=t+Ga(8,20));this.chat=null,this.next=t+Ga(20,45)}release(t){Ji(`/api/chill/${t}`,void 0,"DELETE").catch(()=>{})}}const je=3.2,Ei=1.6,Re=.075,lp=.9,$a=.78,Sd=7,t1=1/240,Wa=.15,wd=.135,Uh=[{x:-je/2,z:-Ei/2,r:Wa},{x:je/2,z:-Ei/2,r:Wa},{x:-je/2,z:Ei/2,r:Wa},{x:je/2,z:Ei/2,r:Wa},{x:0,z:-Ei/2-.035,r:wd},{x:0,z:Ei/2+.035,r:wd}],Xa=i=>i===0?"cue":i===8?"eight":i<8?"solids":"stripes";function Kc(){const i=[{n:0,x:-je/4,z:0,vx:0,vz:0,in:!1}],t=[1,2,3,4,5,6,7,9,10,11,12,13,14,15].sort(()=>Math.random()-.5),e=new Array(15);e[4]=8;const n=[10,14];e[n[0]]=t.splice(t.findIndex(a=>a<8),1)[0],e[n[1]]=t.splice(t.findIndex(a=>a>8),1)[0];for(let a=0;a<15;a++)e[a]||(e[a]=t.pop());const s=Re*2*1.002;let r=0;for(let a=0;a<5;a++)for(let o=0;o<=a;o++)i.push({n:e[r++],x:je/4+a*s*.866,z:(o-a/2)*s,vx:0,vz:0,in:!1});return i}function e1(i,t,e={}){var s,r,a;let n=t;for(;n>1e-9;){const o=Math.min(t1,n);n-=o;for(const l of i){if(l.in)continue;const c=Math.hypot(l.vx,l.vz);if(c>0){const f=Math.max(0,c-lp*o),g=f/c;l.vx*=g,l.vz*=g,f<.012&&(l.vx=0,l.vz=0)}l.x+=l.vx*o,l.z+=l.vz*o;const h=je/2-Re,u=Ei/2-Re;let d=!1;l.x<-h?(l.x=-h,l.vx=Math.abs(l.vx)*$a,d=!0):l.x>h&&(l.x=h,l.vx=-Math.abs(l.vx)*$a,d=!0),l.z<-u?(l.z=-u,l.vz=Math.abs(l.vz)*$a,d=!0):l.z>u&&(l.z=u,l.vz=-Math.abs(l.vz)*$a,d=!0),d&&((s=e.cushion)==null||s.call(e,l));for(const f of Uh)if(Math.hypot(l.x-f.x,l.z-f.z)<f.r){l.in=!0,l.vx=0,l.vz=0,l.pocket=f,(r=e.pocket)==null||r.call(e,l,f);break}}for(let l=0;l<i.length;l++){const c=i[l];if(!c.in)for(let h=l+1;h<i.length;h++){const u=i[h];if(u.in)continue;const d=u.x-c.x,f=u.z-c.z,g=d*d+f*f;if(g>=4*Re*Re||g===0)continue;const _=Math.sqrt(g),m=d/_,p=f/_,y=(2*Re-_)/2;c.x-=m*y,c.z-=p*y,u.x+=m*y,u.z+=p*y;const x=(u.vx-c.vx)*m+(u.vz-c.vz)*p;if(x<0){const S=-1.96*x/2;c.vx-=S*m,c.vz-=S*p,u.vx+=S*m,u.vz+=S*p,(a=e.hit)==null||a.call(e,c,u,-x)}}}}}const n1=i=>i.some(t=>!t.in&&(t.vx||t.vz));class i1{constructor(t){this.players=t,this.balls=Kc(),this.turn=0,this.groups=null,this.shots=0,this.winner=null,this.over=null,this.inHand=!0,this.begin()}get cue(){return this.balls[0]}get shooter(){return this.players[this.turn]}get other(){return this.players[1-this.turn]}begin(){this.log={first:null,potted:[],cushion:!1,legal:this.targets().map(t=>t.n)}}targets(t=this.shooter){const e=this.balls.filter(s=>s.n&&!s.in);if(!this.groups)return e.filter(s=>s.n!==8);const n=e.filter(s=>Xa(s.n)===this.groups[t]);return n.length?n:e.filter(s=>s.n===8)}remaining(t){return this.groups?this.balls.filter(e=>e.n&&!e.in&&Xa(e.n)===this.groups[t]).length:7}recorder(){return{hit:(t,e)=>{this.log.first===null&&(t.n===0||e.n===0)&&(this.log.first=t.n===0?e.n:t.n)},pocket:t=>this.log.potted.push(t.n),cushion:()=>{this.log.cushion=!0}}}settle(){this.shots++;const{first:t,potted:e}=this.log,n=this.shooter,s=this.shots===1,r=e.includes(0),a=e.includes(8),o=this.log.legal,l={foul:!1,why:"",potted:e.filter(h=>h),continues:!1,assigned:null,eight:a};if(s&&a){const h=this.balls.find(u=>u.n===8);h.in=!1,h.x=je/4,h.z=0,h.vx=h.vz=0,e.splice(e.indexOf(8),1),l.eight=!1}if(t===null?(l.foul=!0,l.why="missed everything"):o.includes(t)||(l.foul=!0,l.why=t===8?"hit the eight first":"wrong ball first"),r&&(l.foul=!0,l.why="scratched"),!l.foul&&!s&&!e.length&&!this.log.cushion&&(l.foul=!0,l.why="nothing reached a cushion"),l.eight){const h=this.groups&&o.every(u=>u===8);return h&&!l.foul?this.finish(n,"eight"):this.finish(this.other,h?"foul-eight":"early-eight"),l.over=this.over,l}if(!this.groups&&!l.foul&&!s){const h=e.find(u=>u&&u!==8);if(h){const u=Xa(h);this.groups={[n]:u,[this.other]:u==="solids"?"stripes":"solids"},l.assigned=u}}if(r){const h=this.cue;h.in=!1,h.vx=h.vz=0}const c=e.filter(h=>h&&h!==8&&(!this.groups||Xa(h)===this.groups[n]));if(l.continues=!l.foul&&c.length>0,this.inHand=l.foul,l.continues||(this.turn=1-this.turn),this.shots>=80&&!this.winner){const h=this.remaining(this.players[0]),u=this.remaining(this.players[1]);this.finish(h<=u?this.players[0]:this.players[1],"worn-out"),l.over=this.over}return this.begin(),l}finish(t,e){this.winner=t,this.over=e}placeCue(t){const e=this.cue,n=(r,a)=>this.balls.every(o=>o===e||o.in||Math.hypot(o.x-r,o.z-a)>Re*2.4),s=t?[[-je/4,0],[-je/4,.2],[-je/4,-.2]]:[[-je/4,0],[-je/3,.3],[-je/3,-.3],[.3,.3],[.3,-.3],[-.2,.5],[-.2,-.5],[-je/2+.3,.2]];for(const[r,a]of s)if(n(r,a)){e.x=r,e.z=a,e.vx=e.vz=0,e.in=!1;return}for(let r=0;r<200;r++){const a=(Math.random()-.5)*(je-.4),o=(Math.random()-.5)*(Ei-.4);if(n(a,o)){e.x=a,e.z=o,e.vx=e.vz=0,e.in=!1;return}}}}const zl=(i,t,e,n,s,r,a)=>{const o=n-t,l=s-e,c=o*o+l*l||1e-9;for(const h of i){if(h.in||r.includes(h))continue;const u=Math.max(0,Math.min(1,((h.x-t)*o+(h.z-e)*l)/c));if(Math.hypot(h.x-(t+u*o),h.z-(e+u*l))<a)return!1}return!0};function s1(i,t=.7){const e=i.balls,n=i.cue,s=i.targets();let r=null;if(i.shots===0){const c=e.find(h=>h.n!==0&&h.x===Math.min(...e.filter(u=>u.n).map(u=>u.x)));r={angle:Math.atan2(c.z-n.z,c.x-n.x),speed:5.6+Math.random()*1.2,target:c,pocket:null,clean:!1,power:"break"}}else{for(const c of s)for(const h of Uh){const u=h.x*.97,d=h.z*.97,f=u-c.x,g=d-c.z,_=Math.hypot(f,g)||1e-9,m=c.x-f/_*2*Re,p=c.z-g/_*2*Re;if(Math.abs(m)>je/2-Re||Math.abs(p)>Ei/2-Re)continue;const y=m-n.x,x=p-n.z,S=Math.hypot(y,x);if(S<Re*2)continue;const L=(y*f+x*g)/(S*_);if(L<.34||!zl(e,n.x,n.z,m,p,[n,c],Re*2*.98)||!zl(e,c.x,c.z,u,d,[n,c],Re*2*.98))continue;const T=L*2-(S+_)*.35-(c.n===8,0);(!r||T>r.score)&&(r={angle:Math.atan2(x,y),speed:Math.min(Sd*.8,Math.sqrt(2*lp*(S+_*1.3))+1.1),target:c,pocket:h,clean:!0,score:T})}if(!r){const c=s.length?s:e.filter(f=>f.n&&!f.in),h=c.filter(f=>zl(e,n.x,n.z,f.x,f.z,[n,f],Re*2*.98)),u=h.length?h:c;u.sort((f,g)=>Math.hypot(f.x-n.x,f.z-n.z)-Math.hypot(g.x-n.x,g.z-n.z));const d=u[0];r={angle:Math.atan2(d.z-n.z,d.x-n.x),speed:2.6+Math.random()*1.2,target:d,pocket:null,clean:!1}}}const a=Math.hypot(r.target.x-n.x,r.target.z-n.z),o=(.006+.026*(1-t))*(.8+a*.35),l=()=>(Math.random()+Math.random()+Math.random()-1.5)*1.4;return r.angle+=l()*o*(r.power==="break"?.6:1),r.speed=Math.min(Sd,Math.max(1.2,r.speed*(1+l()*.06*(1.2-t)))),r}function r1(i,t,e){i.cue.vx=Math.cos(t)*e,i.cue.vz=Math.sin(t)*e}let Wn=null,lo=null,So=!1;try{So=localStorage.getItem("office.muted")==="1"}catch{}function cp(){if(!Wn){const i=window.AudioContext||window.webkitAudioContext;if(!i)return;Wn=new i,lo=Wn.createGain(),lo.gain.value=.5,lo.connect(Wn.destination)}Wn.state==="suspended"&&Wn.resume()}addEventListener("pointerdown",cp);addEventListener("keydown",cp);function Ln(i,t,e,{type:n="sine",gain:s=.2}={}){const r=Wn.currentTime+t,a=Wn.createOscillator(),o=Wn.createGain();a.type=n,a.frequency.setValueAtTime(i,r),o.gain.setValueAtTime(1e-4,r),o.gain.exponentialRampToValueAtTime(s,r+.012),o.gain.exponentialRampToValueAtTime(1e-4,r+e),a.connect(o).connect(lo),a.start(r),a.stop(r+e+.05)}const qs=()=>!So&&Wn&&Wn.state==="running",ln={get muted(){return So},setMuted(i){So=i;try{localStorage.setItem("office.muted",i?"1":"0")}catch{}},ship(){qs()&&([659.25,830.61,987.77].forEach((i,t)=>{Ln(i,t*.085,.55,{gain:.16}),Ln(i*2,t*.085,.3,{type:"triangle",gain:.035})}),Ln(1318.5,.26,.9,{gain:.09}))},fail(){qs()&&(Ln(293.66,0,.35,{type:"triangle",gain:.12}),Ln(246.94,.14,.5,{type:"triangle",gain:.12}))},levelUp(){qs()&&[523.25,659.25,783.99,1046.5,1318.5].forEach((i,t)=>Ln(i,t*.07,.7,{gain:.13}))},knock(){qs()&&(Ln(880,0,.09,{gain:.06}),Ln(1174.7,.07,.12,{gain:.05}))},click(i=.5){if(!qs())return;const t=.025+i*.07;Ln(1900+Math.random()*500,0,.035,{type:"triangle",gain:t}),Ln(3100,0,.02,{gain:t*.5})},pocket(){qs()&&(Ln(180,0,.18,{type:"triangle",gain:.09}),Ln(120,.06,.22,{type:"sine",gain:.07}))}},Ys=(i,t)=>i+Math.random()*(t-i),ti=i=>i[Math.floor(Math.random()*i.length)],a1=["#f2c230","#2f5fb3","#d6402f","#6a3a9c","#e8803a","#2f8a4f","#8a2a2e"];function o1(i){const t=document.createElement("canvas");t.width=128,t.height=64;const e=t.getContext("2d"),n=i===0?"#f4f1ea":i===8?"#1b1b1f":a1[(i-1)%7];if(e.fillStyle=i>8?"#f4f1ea":n,e.fillRect(0,0,128,64),i>8&&(e.fillStyle=n,e.fillRect(0,14,128,36)),i){e.font="700 17px Inter, system-ui, sans-serif",e.textAlign="center",e.textBaseline="middle";for(const r of[32,96])e.fillStyle="#f4f1ea",e.beginPath(),e.arc(r,32,13,0,Math.PI*2),e.fill(),e.fillStyle="#1b1b1f",e.fillText(String(i),r,33)}const s=new Fi(t);return s.colorSpace=Ye,s}const l1=["corner","corner","corner","corner","side","side"],c1=i=>l1[Uh.indexOf(i)]||"pocket",h1=[["Eight ball? Loser buys the coffee.","You are on."],["Quick game of eight ball?","Rack them up."],["Pool table is free. That never happens.","Then we have to."],["Break is yours.","Bold of you to give me the break."]],u1=["Nice.","Smooth.","That one dropped.","Clean.","In."],d1=["So close.","Rolled out.","Unlucky.","The table is tilted."],f1=["Scratch.","Ugh, foul.","The cue ball had other plans."],p1=["Ball in hand.","Your table.","Thank you."],m1=["Here goes.","Let me see this one.","Easy.","Trust the line."],g1=["Good game.","That was fun.","Rematch later?"],v1=["Rematch.","Good game. Coffee is on me.","The table was tilted."];class _1{constructor(t,e){this.spots=e.stations.lounge.spots.filter(a=>a.game),this.root=new qt,this.root.position.set($e.x,0,$e.z),t.add(this.root);const n=new hi(Re,20,14);this.meshes=[];for(let a=0;a<=15;a++){const o=new yt(n,new zn({map:o1(a),roughness:.22,metalness:.02}));o.castShadow=!0,o.userData={x:0,z:0,sunk:null},this.root.add(o),this.meshes.push(o)}this.cue=new qt;const s=new yt(new Fn(.016,.026,1.9,8),xe("#d9b27a"));s.rotation.z=Math.PI/2,s.position.x=-.95,s.castShadow=!0;const r=new yt(new Fn(.016,.016,.04,8),xe("#5b8fb0"));r.rotation.z=Math.PI/2,r.position.x=-.02,this.cue.add(s,r),this.cueOuter=new qt,this.cueOuter.add(this.cue),this.cue.rotation.z=-.12,this.cueOuter.visible=!1,this.root.add(this.cueOuter),this.resting=Kc(),this.view=this.resting,this.next=Ys(25,45),this.s=null,this.claiming=!1}get playing(){return!!this.s}update(t,e,n){this.s?this.run(e,n):!this.claiming&&e>=this.next&&this.tryStart(t,e),this.draw(e,n)}tryStart(t,e){const n=o=>!o.gone&&!o.job&&!o.meeting&&!o.leaving&&o.want==="lounge"&&!o.playing&&!o.chatting,s=t.filter(n);if(this.next=e+Ys(15,30),s.length<2)return;const r=ti(s),a=ti(s.filter(o=>o!==r));this.claim(r,a,e)}async claim(t,e,n){this.claiming=!0;let s=null;try{({id:s}=await Ji("/api/chill",{who:[t.id,e.id],game:!0}))}catch{}if(this.claiming=!1,!s)return;const r=a=>!a.gone&&!a.job&&!a.meeting&&!a.leaving&&a.want==="lounge"&&!a.playing&&!a.chatting;if(!r(t)||!r(e))return this.release(s);this.begin(t,e,s,n)}begin(t,e,n,s){const r=[t,e];r.forEach((o,l)=>{const c=this.spots[l];o.spot&&o.spot!==c&&(o.spot.taken=null),o.spot=c,c.taken=o.id,o.playing=!0,o.chatting=!0,o.wanderAt=1/0,o.goTo("lounge",s)});const a=o=>.45+([...o.id].reduce((l,c)=>l*31+c.charCodeAt(0),7)>>>0)%50/100;this.s={id:n,players:r,skill:r.map(a),phase:"walk",deadline:s+60,game:null,plan:null,shots:0}}called(t){return t.gone||t.job||t.meeting||t.leaving||t.want!=="lounge"}run(t,e){const n=this.s;if(n.players.some(o=>this.called(o)))return this.stop(t,!1);for(const o of n.players)o.wanderAt=1/0;t-(n.pinged??0)>30&&(n.pinged=t,Ji(`/api/chill/${n.id}/ping`,{}).catch(()=>{}));const[s,r]=n.players,a=o=>{var l;return o.placeKey==="lounge"&&!o.path.length&&((l=o.spot)==null?void 0:l.game)};switch(n.phase){case"walk":{if(t>n.deadline)return this.stop(t,!1);if(!a(s)||!a(r))return;n.game=new i1([s.id,r.id]),this.view=n.game.balls;for(const c of this.meshes)c.userData.sunk=null;const[o,l]=ti(h1);s.say(o,"idle",3200),n.phase="rack",n.until=t+1.2,n.line=l,n.said=!1,Ji(`/api/chill/${n.id}/line`,{from:s.id,text:o}).catch(()=>{});return}case"rack":!n.said&&t>n.until-.4&&(r.say(n.line,"idle",2600),n.said=!0),t>n.until&&this.aim(t);return;case"aim":return this.aiming(t);case"roll":{const o=n.rec;if(n.clicks=0,e1(n.game.balls,Math.min(e,.05),o),n.rolled+=e,n.rolled>.3&&(this.cueOuter.visible=!1),n1(n.game.balls)&&n.rolled<22)return;for(const l of n.game.balls)l.vx=0,l.vz=0;return this.settled(t)}case"pause":t>n.until&&this.aim(t);return;case"over":t>n.until&&this.stop(t,!0)}}agentOf(t){return this.s.players.find(e=>e.id===t)}aim(t){const e=this.s,n=e.game,s=this.agentOf(n.shooter),r=this.agentOf(n.other),a=e.players.indexOf(s);n.inHand&&n.placeCue(n.shots===0),e.plan=s1(n,e.skill[a]),e.t0=t,e.dur=Ys(1.5,2.2),e.struck=!1,e.phase="aim",e.shooter=s,e.waiter=r;const o=$e.x+n.cue.x,l=$e.z+n.cue.z;s.goal={...s.goal,face:Math.atan2(o-s.pos.x,l-s.pos.z)},r.goal={...r.goal,face:Math.atan2(o-r.pos.x,l-r.pos.z)};const c=e.plan.pocket&&c1(e.plan.pocket),h=c&&Math.random()<.4?e.plan.target.n===8?`Eight ball, ${c} pocket.`:`${c[0].toUpperCase()}${c.slice(1)} pocket.`:Math.random()<.18?ti(m1):"";h&&s.say(h,"idle",2400),this.cueOuter.visible=!0}aiming(t){const e=this.s,n=e.game,s=Math.min(1,(t-e.t0)/e.dur);e.shooter.anim={kind:"cue",until:t+.5},e.waiter.anim={kind:"mug",until:t+.5};const r=s<.55?.07+Math.sin(s*40)*.006:s<.85?.07+((s-.55)/.3)**2*.34:.41*(1-(s-.85)/.15)+.02;this.placeCue(r,e.plan.angle),s>=1&&!e.struck&&(e.struck=!0,r1(n,e.plan.angle,e.plan.speed),ln.click(Math.min(1,e.plan.speed/6)),e.rec=this.recorder(n),e.rolled=0,e.clicks=0,e.phase="roll",e.shooter.anim=null)}recorder(t){const e=t.recorder();return{hit:(n,s,r)=>{e.hit(n,s,r),this.s.clicks++<2&&ln.click(Math.min(1,r/4))},pocket:(n,s)=>{e.pocket(n,s),ln.pocket()},cushion:e.cushion}}settled(t){const e=this.s,n=e.game,s=e.shooter,r=e.waiter,a=n.settle();e.shots++;const o=a.potted.length>0;if(a.over)return this.over(t,a);a.assigned?s.say(`${a.assigned==="solids"?"Solids":"Stripes"} for me.`,"idle",2800):a.foul?(s.say(ti(f1),"warn",2400),Math.random()<.5&&setTimeout(()=>this.s&&r.say(ti(p1),"idle",2200),700)):o&&a.continues?Math.random()<.45&&s.say(ti(u1),"good",2200):Math.random()<.22&&s.say(ti(d1),"idle",2200),e.phase="pause",e.until=t+1.1+(a.foul?.6:0)}over(t,e){const n=this.s,s=n.game,r=this.agentOf(s.winner),a=n.players.find(l=>l!==r),o={eight:`Eight ball down. Good game, ${a.name}.`,"early-eight":`${a.name} dropped the eight early, so that one is mine. Good game.`,"foul-eight":`The eight went in with a foul, ${a.name}. Still a good game.`,"worn-out":`Called it after ${s.shots} shots, fewer balls left. Good game, ${a.name}.`}[s.over];r.say(ti(g1),"good",3600),a.say(ti(v1),"idle",3600),r.anim={kind:"celebrate",until:t+2.2},a.anim={kind:"slump",until:t+1.8},Ji(`/api/chill/${n.id}/line`,{from:r.id,text:o}).catch(()=>{}),n.phase="over",n.until=t+5}stop(t,e){var s;const n=this.s;if(n){this.release(n.id);for(const r of n.players)r.playing=!1,r.chatting=!1,r.anim=null,(s=r.spot)!=null&&s.game&&(r.spot.taken=null,r.spot=null),!r.gone&&!r.job&&!r.meeting&&r.want==="lounge"?r.wanderAt=t+Ys(5,12):r.wanderAt=0;this.cueOuter.visible=!1,this.resting=Kc(),this.view=this.resting;for(const r of this.meshes)r.userData.sunk=null;this.s=null,this.next=t+(e?Ys(60,150):Ys(30,60))}}release(t){Ji(`/api/chill/${t}`,void 0,"DELETE").catch(()=>{})}placeCue(t,e){const n=this.s.game.cue,s=Math.cos(e),r=Math.sin(e);this.cueOuter.position.set(n.x-s*(Re+t),$e.felt+Re,n.z-r*(Re+t)),this.cueOuter.rotation.y=-e}draw(t,e){const n=$e.felt;for(const s of this.view){const r=this.meshes[s.n],a=r.userData;if(s.in){a.sunk===null&&(a.sunk=t);const h=Math.min(1,(t-a.sunk)/.35),u=s.pocket;r.visible=h<1,r.position.set(s.x+(((u==null?void 0:u.x)??s.x)-s.x)*h,n+Re-h*.22,s.z+(((u==null?void 0:u.z)??s.z)-s.z)*h),r.scale.setScalar(1-h*.5);continue}a.sunk=null,r.visible=!0,r.scale.setScalar(1),r.position.set(s.x,n+Re,s.z);const o=s.x-a.x,l=s.z-a.z,c=Math.hypot(o,l);if(c>1e-5&&c<.5){const h=new R(l,0,-o).normalize();r.quaternion.premultiply(new as().setFromAxisAngle(h,c/Re))}a.x=s.x,a.z=s.z}}}const Bl=6,Ed=["#7c5cff","#0e9f9a","#d9488f","#c98a12","#3b82f6","#65a30d"],x1=/^#[0-9a-f]{6}$/i,Ks=(i,t)=>String(i??"").replace(/\s+/g," ").trim().slice(0,t),Hl=(i,t)=>x1.test(i)?i:t,y1=new Set(["working","idle","break","meeting","away"]);function M1(i){return Array.isArray(i)?i.filter(t=>t&&typeof t.link=="string"&&t.link).map(t=>({link:Ks(t.link,80),handle:Ks(t.handle,40)||"friend",agents:(Array.isArray(t.agents)?t.agents:[]).filter(e=>e&&typeof e.id=="string"&&e.id).map(e=>{var n,s,r;return{id:Ks(e.id,40),name:Ks(e.name,40)||"Visitor",role:Ks(e.role,60),state:y1.has(e.state)?e.state:"idle",look:{shirt:Hl((n=e.look)==null?void 0:n.shirt,"#8a8f9c"),hair:Hl((s=e.look)==null?void 0:s.hair,"#3b2f2a"),skin:Hl((r=e.look)==null?void 0:r.skin,"#c68e63")},job:e.job&&typeof e.job=="object"?{title:Ks(e.job.title,120)}:null}})})):[]}class b1 extends Nh{constructor(t,e,n,s,r,a){const o=Object.hasOwn(kh,e.id)?e.id:"visitor";super({id:o,name:"",...e.look},s,r,{desk:{seat:s.door.clone(),seatY:0}}),this.key=`${t.link}:${e.id}`,this.id=this.key,this.root.traverse(u=>{u.userData.agentId=this.key,u.userData.visitor=this.key}),this.tint=n,this.chatAt=1/0,this.hangout=Math.random()<.5?"poolside":"coffee";const l=new Zt(n);this.fig.group.traverse(u=>{var d;!u.isMesh||!((d=u.material)!=null&&d.color)||(u.material=u.material.clone(),u.material.color.lerp(l,.16),u.material.emissive&&(u.material.emissive.copy(l),u.material.emissiveIntensity=.07))}),this.ring.material.color.set(n),this.ring.material.opacity=.6,this.ring.visible=!0,this.label.classList.add("visitor"),this.label.style.setProperty("--tint",n);const c=this.label.querySelector(".name");c.replaceChildren();const h=document.createElement("i");if(h.style.background=n,this.nameEl=document.createElement("span"),this.handleEl=document.createElement("span"),this.handleEl.className="handle",c.append(h,this.nameEl,this.handleEl),this.set(t,e),a){this.teleport(this.want);return}this.teleport("door"),this.say(`Hi from @${t.handle}`,"good",4e3)}set(t,e){this.office=t,this.info=e,this.name=e.name,this.nameEl.textContent!==e.name&&(this.nameEl.textContent=e.name,this.labelDirty=!0),this.handleEl.textContent!==` · @${t.handle}`&&(this.handleEl.textContent=` · @${t.handle}`,this.labelDirty=!0),this.leaving&&(this.leaving=!1,this.say("Forgot something","idle",2500)),this.want=this.place(e.state)}place(t){const e=t==="working"?["hotdesk","huddle",this.hangout]:t==="meeting"?["huddle","hotdesk"]:[this.hangout,this.hangout==="coffee"?"poolside":"coffee","huddle"];return e.find(n=>this.roomAt(n))||e[0]}roomAt(t){return this.world.stations[t].spots.some(e=>!e.game&&(!e.taken||e.taken===this.id))}resolve(t,e){if(t==="desk"){this.spot&&(this.spot.taken=null,this.spot=null);const n=this.world.door.clone().add(new R(-4.2+Math.random()*1.6,0,-1.4+Math.random()*.8));return{key:t,pos:n,face:Math.atan2(-n.x,-n.z),pose:"stand"}}return super.resolve(t,e)}leave(){this.leaving||(super.leave(),this.say(`Back to @${this.office.handle}`,"idle",3e3))}dispose(){this.fig.group.traverse(t=>{t.isMesh&&t.material.dispose()}),super.dispose()}}class S1{constructor({world:t,labels:e,camera:n,canvas:s}){Object.assign(this,{world:t,labels:e,camera:n,canvas:s}),this.on=new Map,this.offices=[],this.tints=new Map,this.list=[],this.first=!0,this.sign=document.createElement("div"),this.sign.className="door-sign",this.sign.hidden=!0,e.appendChild(this.sign),this.card=document.createElement("div"),this.card.className="visitor-card",this.card.hidden=!0,e.appendChild(this.card),this.ray=new tp,s.addEventListener("pointermove",r=>this.hover(r)),s.addEventListener("pointerleave",()=>{this.card.hidden=!0})}handle(t){if(t.t==="visitors")return this.receive(t.offices),!0;if(t.t==="hello"&&Array.isArray(t.visitors)&&this.receive(t.visitors,this.first),t.t==="hello"&&(this.first=!1),t.t==="links"&&Array.isArray(t.links)){const e=new Set(t.links.map(n=>n==null?void 0:n.id));this.receive(this.offices.filter(n=>e.has(n.link)))}return!1}tintOf(t){return this.tints.has(t)||this.tints.set(t,Ed[this.tints.size%Ed.length]),this.tints.get(t)}receive(t,e=!1){this.offices=M1(t);const n=new Map,s=this.offices.map(o=>o.agents.filter(l=>l.state!=="away").map(l=>[`${o.link}:${l.id}`,o,l]));for(const o of s)for(const[l,c,h]of o)n.set(l,[c,h]);const r=new Set([...this.on.values()].filter(o=>!o.leaving&&n.has(o.key)).map(o=>o.key).slice(0,Bl));for(let o=0;r.size<Bl&&s.some(l=>l.length>o);o++)for(const l of s)l[o]&&r.size<Bl&&r.add(l[o][0]);for(const o of this.on.values())r.has(o.key)||o.leave();for(const o of r){const[l,c]=n.get(o),h=this.on.get(o);h?h.set(l,c):this.on.set(o,new b1(l,c,this.tintOf(l.link),this.world,this.labels,e))}const a=new Map;for(const[o,[l]]of n)r.has(o)||a.set(l.handle,(a.get(l.handle)||0)+1);this.sign.replaceChildren(...[...a].map(([o,l])=>{const c=document.createElement("div");return c.textContent=`+${l} from @${o}`,c})),this.sign.hidden=!a.size,this.list=[...this.on.values()]}update(t,e){for(const n of this.on.values())n.update(t,e),n.gone&&(n.dispose(),this.on.delete(n.key),this.list=[...this.on.values()])}placeSign(t,e){if(this.sign.hidden)return;const n=this.world.door.clone().setY(2.7).project(this.camera);if(n.z>1){this.sign.style.display="none";return}this.sign.style.display="",this.sign.style.transform=`translate(-50%, -100%) translate(${(n.x*.5+.5)*t}px, ${(-n.y*.5+.5)*e}px)`}hover(t){if(t.buttons||!this.list.length){this.card.hidden=!0;return}const e=this.canvas.getBoundingClientRect();this.ray.setFromCamera(new at((t.clientX-e.left)/e.width*2-1,-((t.clientY-e.top)/e.height)*2+1),this.camera);const n=this.ray.intersectObjects(this.list.map(o=>o.root),!0)[0],s=n&&this.on.get(n.object.userData.visitor);if(!s){this.card.hidden=!0;return}(this.card.dataset.key!==s.key||this.card.dataset.stamp!==JSON.stringify(s.info))&&this.fillCard(s),this.card.hidden=!1;let r=t.clientX-e.left+14,a=t.clientY-e.top+14;r+this.card.offsetWidth>e.width-8&&(r-=this.card.offsetWidth+28),a+this.card.offsetHeight>e.height-8&&(a-=this.card.offsetHeight+28),this.card.style.transform=`translate(${r}px, ${a}px)`}fillCard(t){var a;const{info:e,office:n}=t;this.card.dataset.key=t.key,this.card.dataset.stamp=JSON.stringify(e),this.card.style.setProperty("--tint",t.tint);const s=(o,l)=>{const c=document.createElement("div");return c.className=o,c.textContent=l,c},r={working:"Working",idle:"Between jobs",break:"On a break",meeting:"In a meeting",away:"Heading home"}[e.state];this.card.replaceChildren(s("vc-who",`${e.name} · @${n.handle}`),s("vc-role",e.role||"Agent"),s("vc-job",((a=e.job)==null?void 0:a.title)||(e.state==="working"?"On a job":"No job right now")),s("vc-state",`${r} · visiting from @${n.handle}`))}}class w1{constructor(t){this.scene=t,this.bits=[],this.geo=new pi(.14,.09)}burst(t,e){for(let n=0;n<70;n++){const s=new yt(this.geo,new un({color:e[n%e.length],side:ai,transparent:!0}));s.position.set(t.x,2.4,t.z);const r=Math.random()*Math.PI*2,a=1.5+Math.random()*3;s.userData={v:new R(Math.cos(r)*a,4+Math.random()*4,Math.sin(r)*a),spin:new R(Math.random()*10,Math.random()*10,Math.random()*10),life:2.2+Math.random()*.8},this.scene.add(s),this.bits.push(s)}}update(t){for(let e=this.bits.length-1;e>=0;e--){const n=this.bits[e],s=n.userData;s.life-=t,s.v.y-=9*t,s.v.multiplyScalar(1-t*1.2),n.position.addScaledVector(s.v,t),n.position.y<.02?(n.position.y=.02,s.v.set(0,0,0),n.rotation.set(-Math.PI/2,0,n.rotation.z)):(n.rotation.x+=s.spin.x*t,n.rotation.y+=s.spin.y*t,n.rotation.z+=s.spin.z*t),n.material.opacity=Math.min(1,s.life/.6),s.life<=0&&(this.scene.remove(n),n.material.dispose(),this.bits.splice(e,1))}}}function Oh(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let As=Oh();function hp(i){As=i}const up=/[&<>"']/,E1=new RegExp(up.source,"g"),dp=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,T1=new RegExp(dp.source,"g"),A1={"&":"&","<":"<",">":">",'"':""","'":"'"},Td=i=>A1[i];function Tn(i,t){if(t){if(up.test(i))return i.replace(E1,Td)}else if(dp.test(i))return i.replace(T1,Td);return i}const C1=/(^|[^\[])\^/g;function ve(i,t){let e=typeof i=="string"?i:i.source;t=t||"";const n={replace:(s,r)=>{let a=typeof r=="string"?r:r.source;return a=a.replace(C1,"$1"),e=e.replace(s,a),n},getRegex:()=>new RegExp(e,t)};return n}function Ad(i){try{i=encodeURI(i).replace(/%25/g,"%")}catch{return null}return i}const ta={exec:()=>null};function Cd(i,t){const e=i.replace(/\|/g,(r,a,o)=>{let l=!1,c=a;for(;--c>=0&&o[c]==="\\";)l=!l;return l?"|":" |"}),n=e.split(/ \|/);let s=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;s<n.length;s++)n[s]=n[s].trim().replace(/\\\|/g,"|");return n}function Br(i,t,e){const n=i.length;if(n===0)return"";let s=0;for(;s<n&&i.charAt(n-s-1)===t;)s++;return i.slice(0,n-s)}function R1(i,t){if(i.indexOf(t[1])===-1)return-1;let e=0;for(let n=0;n<i.length;n++)if(i[n]==="\\")n++;else if(i[n]===t[0])e++;else if(i[n]===t[1]&&(e--,e<0))return n;return-1}function Rd(i,t,e,n){const s=t.href,r=t.title?Tn(t.title):null,a=i[1].replace(/\\([\[\]])/g,"$1");if(i[0].charAt(0)!=="!"){n.state.inLink=!0;const o={type:"link",raw:e,href:s,title:r,text:a,tokens:n.inlineTokens(a)};return n.state.inLink=!1,o}return{type:"image",raw:e,href:s,title:r,text:Tn(a)}}function P1(i,t){const e=i.match(/^(\s+)(?:```)/);if(e===null)return t;const n=e[1];return t.split(`
|
|
4302
4301
|
`).map(s=>{const r=s.match(/^\s+/);if(r===null)return s;const[a]=r;return a.length>=n.length?s.slice(n.length):s}).join(`
|
|
4303
|
-
`)}class
|
|
4304
|
-
`)}}}fences(t){const e=this.rules.block.fences.exec(t);if(e){const n=e[0],s=
|
|
4302
|
+
`)}class wo{constructor(t){_e(this,"options");_e(this,"rules");_e(this,"lexer");this.options=t||As}space(t){const e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){const e=this.rules.block.code.exec(t);if(e){const n=e[0].replace(/^(?: {1,4}| {0,3}\t)/gm,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:Br(n,`
|
|
4303
|
+
`)}}}fences(t){const e=this.rules.block.fences.exec(t);if(e){const n=e[0],s=P1(n,e[3]||"");return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:s}}}heading(t){const e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(/#$/.test(n)){const s=Br(n,"#");(this.options.pedantic||!s||/ $/.test(s))&&(n=s.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){const e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:Br(e[0],`
|
|
4305
4304
|
`)}}blockquote(t){const e=this.rules.block.blockquote.exec(t);if(e){let n=Br(e[0],`
|
|
4306
4305
|
`).split(`
|
|
4307
4306
|
`),s="",r="";const a=[];for(;n.length>0;){let o=!1;const l=[];let c;for(c=0;c<n.length;c++)if(/^ {0,3}>/.test(n[c]))l.push(n[c]),o=!0;else if(!o)l.push(n[c]);else break;n=n.slice(c);const h=l.join(`
|
|
@@ -4320,10 +4319,10 @@ ${u}`:u;const d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.block
|
|
|
4320
4319
|
`,1)[0];let E;if(d=T,this.options.pedantic?(d=d.replace(/^ {1,4}(?=( {4})*[^ ])/g," "),E=d):E=d.replace(/\t/g," "),x.test(d)||S.test(d)||L.test(d)||p.test(d)||y.test(d))break;if(E.search(/[^ ]/)>=g||!d.trim())h+=`
|
|
4321
4320
|
`+E.slice(g);else{if(f||u.replace(/\t/g," ").search(/[^ ]/)>=4||x.test(u)||S.test(u)||y.test(u))break;h+=`
|
|
4322
4321
|
`+d}!f&&!d.trim()&&(f=!0),c+=T+`
|
|
4323
|
-
`,t=t.substring(T.length+1),u=E.slice(g)}}r.loose||(o?r.loose=!0:/\n[ \t]*\n[ \t]*$/.test(c)&&(o=!0));let _=null,m;this.options.gfm&&(_=/^\[[ xX]\] /.exec(h),_&&(m=_[0]!=="[ ] ",h=h.replace(/^\[[ xX]\] +/,""))),r.items.push({type:"list_item",raw:c,task:!!_,checked:m,loose:!1,text:h,tokens:[]}),r.raw+=c}r.items[r.items.length-1].raw=r.items[r.items.length-1].raw.trimEnd(),r.items[r.items.length-1].text=r.items[r.items.length-1].text.trimEnd(),r.raw=r.raw.trimEnd();for(let l=0;l<r.items.length;l++)if(this.lexer.state.top=!1,r.items[l].tokens=this.lexer.blockTokens(r.items[l].text,[]),!r.loose){const c=r.items[l].tokens.filter(u=>u.type==="space"),h=c.length>0&&c.some(u=>/\n.*\n/.test(u.raw));r.loose=h}if(r.loose)for(let l=0;l<r.items.length;l++)r.items[l].loose=!0;return r}}html(t){const e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){const e=this.rules.block.def.exec(t);if(e){const n=e[1].toLowerCase().replace(/\s+/g," "),s=e[2]?e[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:e[0],href:s,title:r}}}table(t){const e=this.rules.block.table.exec(t);if(!e||!/[:|]/.test(e[2]))return;const n=
|
|
4324
|
-
`):[],a={type:"table",raw:e[0],header:[],align:[],rows:[]};if(n.length===s.length){for(const o of s)/^ *-+: *$/.test(o)?a.align.push("right"):/^ *:-+: *$/.test(o)?a.align.push("center"):/^ *:-+ *$/.test(o)?a.align.push("left"):a.align.push(null);for(let o=0;o<n.length;o++)a.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:!0,align:a.align[o]});for(const o of r)a.rows.push(
|
|
4325
|
-
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){const e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){const e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:
|
|
4326
|
-
]`).replace("lheading",
|
|
4322
|
+
`,t=t.substring(T.length+1),u=E.slice(g)}}r.loose||(o?r.loose=!0:/\n[ \t]*\n[ \t]*$/.test(c)&&(o=!0));let _=null,m;this.options.gfm&&(_=/^\[[ xX]\] /.exec(h),_&&(m=_[0]!=="[ ] ",h=h.replace(/^\[[ xX]\] +/,""))),r.items.push({type:"list_item",raw:c,task:!!_,checked:m,loose:!1,text:h,tokens:[]}),r.raw+=c}r.items[r.items.length-1].raw=r.items[r.items.length-1].raw.trimEnd(),r.items[r.items.length-1].text=r.items[r.items.length-1].text.trimEnd(),r.raw=r.raw.trimEnd();for(let l=0;l<r.items.length;l++)if(this.lexer.state.top=!1,r.items[l].tokens=this.lexer.blockTokens(r.items[l].text,[]),!r.loose){const c=r.items[l].tokens.filter(u=>u.type==="space"),h=c.length>0&&c.some(u=>/\n.*\n/.test(u.raw));r.loose=h}if(r.loose)for(let l=0;l<r.items.length;l++)r.items[l].loose=!0;return r}}html(t){const e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){const e=this.rules.block.def.exec(t);if(e){const n=e[1].toLowerCase().replace(/\s+/g," "),s=e[2]?e[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:e[0],href:s,title:r}}}table(t){const e=this.rules.block.table.exec(t);if(!e||!/[:|]/.test(e[2]))return;const n=Cd(e[1]),s=e[2].replace(/^\||\| *$/g,"").split("|"),r=e[3]&&e[3].trim()?e[3].replace(/\n[ \t]*$/,"").split(`
|
|
4323
|
+
`):[],a={type:"table",raw:e[0],header:[],align:[],rows:[]};if(n.length===s.length){for(const o of s)/^ *-+: *$/.test(o)?a.align.push("right"):/^ *:-+: *$/.test(o)?a.align.push("center"):/^ *:-+ *$/.test(o)?a.align.push("left"):a.align.push(null);for(let o=0;o<n.length;o++)a.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:!0,align:a.align[o]});for(const o of r)a.rows.push(Cd(o,a.header.length).map((l,c)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:a.align[c]})));return a}}lheading(t){const e=this.rules.block.lheading.exec(t);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(t){const e=this.rules.block.paragraph.exec(t);if(e){const n=e[1].charAt(e[1].length-1)===`
|
|
4324
|
+
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){const e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){const e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:Tn(e[1])}}tag(t){const e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&/^<a /i.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){const e=this.rules.inline.link.exec(t);if(e){const n=e[2].trim();if(!this.options.pedantic&&/^</.test(n)){if(!/>$/.test(n))return;const a=Br(n.slice(0,-1),"\\");if((n.length-a.length)%2===0)return}else{const a=R1(e[2],"()");if(a>-1){const l=(e[0].indexOf("!")===0?5:4)+e[1].length+a;e[2]=e[2].substring(0,a),e[0]=e[0].substring(0,l).trim(),e[3]=""}}let s=e[2],r="";if(this.options.pedantic){const a=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(s);a&&(s=a[1],r=a[3])}else r=e[3]?e[3].slice(1,-1):"";return s=s.trim(),/^</.test(s)&&(this.options.pedantic&&!/>$/.test(n)?s=s.slice(1):s=s.slice(1,-1)),Rd(e,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){const s=(n[2]||n[1]).replace(/\s+/g," "),r=e[s.toLowerCase()];if(!r){const a=n[0].charAt(0);return{type:"text",raw:a,text:a}}return Rd(n,r,n[0],this.lexer)}}emStrong(t,e,n=""){let s=this.rules.inline.emStrongLDelim.exec(t);if(!s||s[3]&&n.match(/[\p{L}\p{N}]/u))return;if(!(s[1]||s[2]||"")||!n||this.rules.inline.punctuation.exec(n)){const a=[...s[0]].length-1;let o,l,c=a,h=0;const u=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,e=e.slice(-1*t.length+a);(s=u.exec(e))!=null;){if(o=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!o)continue;if(l=[...o].length,s[3]||s[4]){c+=l;continue}else if((s[5]||s[6])&&a%3&&!((a+l)%3)){h+=l;continue}if(c-=l,c>0)continue;l=Math.min(l,l+c+h);const d=[...s[0]][0].length,f=t.slice(0,a+s.index+d+l);if(Math.min(a,l)%2){const _=f.slice(1,-1);return{type:"em",raw:f,text:_,tokens:this.lexer.inlineTokens(_)}}const g=f.slice(2,-2);return{type:"strong",raw:f,text:g,tokens:this.lexer.inlineTokens(g)}}}}codespan(t){const e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(/\n/g," ");const s=/[^ ]/.test(n),r=/^ /.test(n)&&/ $/.test(n);return s&&r&&(n=n.substring(1,n.length-1)),n=Tn(n,!0),{type:"codespan",raw:e[0],text:n}}}br(t){const e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t){const e=this.rules.inline.del.exec(t);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(t){const e=this.rules.inline.autolink.exec(t);if(e){let n,s;return e[2]==="@"?(n=Tn(e[1]),s="mailto:"+n):(n=Tn(e[1]),s=n),{type:"link",raw:e[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}url(t){var n;let e;if(e=this.rules.inline.url.exec(t)){let s,r;if(e[2]==="@")s=Tn(e[0]),r="mailto:"+s;else{let a;do a=e[0],e[0]=((n=this.rules.inline._backpedal.exec(e[0]))==null?void 0:n[0])??"";while(a!==e[0]);s=Tn(e[0]),e[1]==="www."?r="http://"+e[0]:r=e[0]}return{type:"link",raw:e[0],text:s,href:r,tokens:[{type:"text",raw:s,text:s}]}}}inlineText(t){const e=this.rules.inline.text.exec(t);if(e){let n;return this.lexer.state.inRawBlock?n=e[0]:n=Tn(e[0]),{type:"text",raw:e[0],text:n}}}}const L1=/^(?:[ \t]*(?:\n|$))+/,D1=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,I1=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,ca=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,k1=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,fp=/(?:[*+-]|\d{1,9}[.)])/,pp=ve(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,fp).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),Fh=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,N1=/^[^\n]+/,zh=/(?!\s*\])(?:\\.|[^\[\]\\])+/,U1=ve(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",zh).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),O1=ve(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,fp).getRegex(),Fo="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Bh=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,F1=ve("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Bh).replace("tag",Fo).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),mp=ve(Fh).replace("hr",ca).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Fo).getRegex(),z1=ve(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",mp).getRegex(),Hh={blockquote:z1,code:D1,def:U1,fences:I1,heading:k1,hr:ca,html:F1,lheading:pp,list:O1,newline:L1,paragraph:mp,table:ta,text:N1},Pd=ve("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",ca).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Fo).getRegex(),B1={...Hh,table:Pd,paragraph:ve(Fh).replace("hr",ca).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Pd).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Fo).getRegex()},H1={...Hh,html:ve(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Bh).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:ta,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ve(Fh).replace("hr",ca).replace("heading",` *#{1,6} *[^
|
|
4325
|
+
]`).replace("lheading",pp).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},gp=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,V1=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,vp=/^( {2,}|\\)\n(?!\s*$)/,G1=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ha="\\p{P}\\p{S}",$1=ve(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,ha).getRegex(),W1=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,X1=ve(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,ha).getRegex(),j1=ve("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,ha).getRegex(),q1=ve("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,ha).getRegex(),Y1=ve(/\\([punct])/,"gu").replace(/punct/g,ha).getRegex(),K1=ve(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Z1=ve(Bh).replace("(?:-->|$)","-->").getRegex(),J1=ve("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Z1).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Eo=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Q1=ve(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",Eo).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),_p=ve(/^!?\[(label)\]\[(ref)\]/).replace("label",Eo).replace("ref",zh).getRegex(),xp=ve(/^!?\[(ref)\](?:\[\])?/).replace("ref",zh).getRegex(),tb=ve("reflink|nolink(?!\\()","g").replace("reflink",_p).replace("nolink",xp).getRegex(),Vh={_backpedal:ta,anyPunctuation:Y1,autolink:K1,blockSkip:W1,br:vp,code:V1,del:ta,emStrongLDelim:X1,emStrongRDelimAst:j1,emStrongRDelimUnd:q1,escape:gp,link:Q1,nolink:xp,punctuation:$1,reflink:_p,reflinkSearch:tb,tag:J1,text:G1,url:ta},eb={...Vh,link:ve(/^!?\[(label)\]\((.*?)\)/).replace("label",Eo).getRegex(),reflink:ve(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Eo).getRegex()},Zc={...Vh,escape:ve(gp).replace("])","~|])").getRegex(),url:ve(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},nb={...Zc,br:ve(vp).replace("{2,}","*").getRegex(),text:ve(Zc.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ja={normal:Hh,gfm:B1,pedantic:H1},Hr={normal:Vh,gfm:Zc,breaks:nb,pedantic:eb};class Nn{constructor(t){_e(this,"tokens");_e(this,"options");_e(this,"state");_e(this,"tokenizer");_e(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||As,this.options.tokenizer=this.options.tokenizer||new wo,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const e={block:ja.normal,inline:Hr.normal};this.options.pedantic?(e.block=ja.pedantic,e.inline=Hr.pedantic):this.options.gfm&&(e.block=ja.gfm,this.options.breaks?e.inline=Hr.breaks:e.inline=Hr.gfm),this.tokenizer.rules=e}static get rules(){return{block:ja,inline:Hr}}static lex(t,e){return new Nn(e).lex(t)}static lexInline(t,e){return new Nn(e).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
|
|
4327
4326
|
`),this.blockTokens(t,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){const n=this.inlineQueue[e];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,e=[],n=!1){this.options.pedantic&&(t=t.replace(/\t/g," ").replace(/^ +$/gm,""));let s,r,a;for(;t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(o=>(s=o.call({lexer:this},t,e))?(t=t.substring(s.raw.length),e.push(s),!0):!1))){if(s=this.tokenizer.space(t)){t=t.substring(s.raw.length),s.raw.length===1&&e.length>0?e[e.length-1].raw+=`
|
|
4328
4327
|
`:e.push(s);continue}if(s=this.tokenizer.code(t)){t=t.substring(s.raw.length),r=e[e.length-1],r&&(r.type==="paragraph"||r.type==="text")?(r.raw+=`
|
|
4329
4328
|
`+s.raw,r.text+=`
|
|
@@ -4333,9 +4332,9 @@ ${u}`:u;const d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.block
|
|
|
4333
4332
|
`+s.raw,r.text+=`
|
|
4334
4333
|
`+s.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=r.text):e.push(s),n=a.length!==t.length,t=t.substring(s.raw.length);continue}if(s=this.tokenizer.text(t)){t=t.substring(s.raw.length),r=e[e.length-1],r&&r.type==="text"?(r.raw+=`
|
|
4335
4334
|
`+s.raw,r.text+=`
|
|
4336
|
-
`+s.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=r.text):e.push(s);continue}if(t){const o="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(o);break}else throw new Error(o)}}return this.state.top=!0,e}inline(t,e=[]){return this.inlineQueue.push({src:t,tokens:e}),e}inlineTokens(t,e=[]){let n,s,r,a=t,o,l,c;if(this.tokens.links){const h=Object.keys(this.tokens.links);if(h.length>0)for(;(o=this.tokenizer.rules.inline.reflinkSearch.exec(a))!=null;)h.includes(o[0].slice(o[0].lastIndexOf("[")+1,-1))&&(a=a.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(o=this.tokenizer.rules.inline.blockSkip.exec(a))!=null;)a=a.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(o=this.tokenizer.rules.inline.anyPunctuation.exec(a))!=null;)a=a.slice(0,o.index)+"++"+a.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;t;)if(l||(c=""),l=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(h=>(n=h.call({lexer:this},t,e))?(t=t.substring(n.raw.length),e.push(n),!0):!1))){if(n=this.tokenizer.escape(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.tag(t)){t=t.substring(n.raw.length),s=e[e.length-1],s&&n.type==="text"&&s.type==="text"?(s.raw+=n.raw,s.text+=n.text):e.push(n);continue}if(n=this.tokenizer.link(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(n.raw.length),s=e[e.length-1],s&&n.type==="text"&&s.type==="text"?(s.raw+=n.raw,s.text+=n.text):e.push(n);continue}if(n=this.tokenizer.emStrong(t,a,c)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.codespan(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.br(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.del(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.autolink(t)){t=t.substring(n.raw.length),e.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(t))){t=t.substring(n.raw.length),e.push(n);continue}if(r=t,this.options.extensions&&this.options.extensions.startInline){let h=1/0;const u=t.slice(1);let d;this.options.extensions.startInline.forEach(f=>{d=f.call({lexer:this},u),typeof d=="number"&&d>=0&&(h=Math.min(h,d))}),h<1/0&&h>=0&&(r=t.substring(0,h+1))}if(n=this.tokenizer.inlineText(r)){t=t.substring(n.raw.length),n.raw.slice(-1)!=="_"&&(c=n.raw.slice(-1)),l=!0,s=e[e.length-1],s&&s.type==="text"?(s.raw+=n.raw,s.text+=n.text):e.push(n);continue}if(t){const h="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(h);break}else throw new Error(h)}}return e}}class
|
|
4337
|
-
`;return s?'<pre><code class="language-'+
|
|
4338
|
-
`:"<pre><code>"+(n?r:
|
|
4335
|
+
`+s.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=r.text):e.push(s);continue}if(t){const o="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(o);break}else throw new Error(o)}}return this.state.top=!0,e}inline(t,e=[]){return this.inlineQueue.push({src:t,tokens:e}),e}inlineTokens(t,e=[]){let n,s,r,a=t,o,l,c;if(this.tokens.links){const h=Object.keys(this.tokens.links);if(h.length>0)for(;(o=this.tokenizer.rules.inline.reflinkSearch.exec(a))!=null;)h.includes(o[0].slice(o[0].lastIndexOf("[")+1,-1))&&(a=a.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(o=this.tokenizer.rules.inline.blockSkip.exec(a))!=null;)a=a.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(o=this.tokenizer.rules.inline.anyPunctuation.exec(a))!=null;)a=a.slice(0,o.index)+"++"+a.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;t;)if(l||(c=""),l=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(h=>(n=h.call({lexer:this},t,e))?(t=t.substring(n.raw.length),e.push(n),!0):!1))){if(n=this.tokenizer.escape(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.tag(t)){t=t.substring(n.raw.length),s=e[e.length-1],s&&n.type==="text"&&s.type==="text"?(s.raw+=n.raw,s.text+=n.text):e.push(n);continue}if(n=this.tokenizer.link(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(n.raw.length),s=e[e.length-1],s&&n.type==="text"&&s.type==="text"?(s.raw+=n.raw,s.text+=n.text):e.push(n);continue}if(n=this.tokenizer.emStrong(t,a,c)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.codespan(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.br(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.del(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.autolink(t)){t=t.substring(n.raw.length),e.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(t))){t=t.substring(n.raw.length),e.push(n);continue}if(r=t,this.options.extensions&&this.options.extensions.startInline){let h=1/0;const u=t.slice(1);let d;this.options.extensions.startInline.forEach(f=>{d=f.call({lexer:this},u),typeof d=="number"&&d>=0&&(h=Math.min(h,d))}),h<1/0&&h>=0&&(r=t.substring(0,h+1))}if(n=this.tokenizer.inlineText(r)){t=t.substring(n.raw.length),n.raw.slice(-1)!=="_"&&(c=n.raw.slice(-1)),l=!0,s=e[e.length-1],s&&s.type==="text"?(s.raw+=n.raw,s.text+=n.text):e.push(n);continue}if(t){const h="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(h);break}else throw new Error(h)}}return e}}class To{constructor(t){_e(this,"options");_e(this,"parser");this.options=t||As}space(t){return""}code({text:t,lang:e,escaped:n}){var a;const s=(a=(e||"").match(/^\S*/))==null?void 0:a[0],r=t.replace(/\n$/,"")+`
|
|
4336
|
+
`;return s?'<pre><code class="language-'+Tn(s)+'">'+(n?r:Tn(r,!0))+`</code></pre>
|
|
4337
|
+
`:"<pre><code>"+(n?r:Tn(r,!0))+`</code></pre>
|
|
4339
4338
|
`}blockquote({tokens:t}){return`<blockquote>
|
|
4340
4339
|
${this.parser.parse(t)}</blockquote>
|
|
4341
4340
|
`}html({text:t}){return t}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
|
|
@@ -4351,107 +4350,113 @@ ${this.parser.parse(t)}</blockquote>
|
|
|
4351
4350
|
`}tablerow({text:t}){return`<tr>
|
|
4352
4351
|
${t}</tr>
|
|
4353
4352
|
`}tablecell(t){const e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
|
|
4354
|
-
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${t}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){const s=this.parser.parseInline(n),r=
|
|
4355
|
-
`+this.renderer.text(o);e?n+=this.renderer.paragraph({type:"paragraph",raw:l,text:l,tokens:[{type:"text",raw:l,text:l}]}):n+=l;continue}default:{const o='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}parseInline(t,e){e=e||this.renderer;let n="";for(let s=0;s<t.length;s++){const r=t[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[r.type]){const o=this.options.extensions.renderers[r.type].call({parser:this},r);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)){n+=o||"";continue}}const a=r;switch(a.type){case"escape":{n+=e.text(a);break}case"html":{n+=e.html(a);break}case"link":{n+=e.link(a);break}case"image":{n+=e.image(a);break}case"strong":{n+=e.strong(a);break}case"em":{n+=e.em(a);break}case"codespan":{n+=e.codespan(a);break}case"br":{n+=e.br(a);break}case"del":{n+=e.del(a);break}case"text":{n+=e.text(a);break}default:{const o='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}}class ea{constructor(t){_e(this,"options");_e(this,"block");this.options=t||
|
|
4356
|
-
Please report this to https://github.com/markedjs/marked.`,t){const s="<p>An error occurred:</p><pre>"+
|
|
4357
|
-
|
|
4353
|
+
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${t}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){const s=this.parser.parseInline(n),r=Ad(t);if(r===null)return s;t=r;let a='<a href="'+t+'"';return e&&(a+=' title="'+e+'"'),a+=">"+s+"</a>",a}image({href:t,title:e,text:n}){const s=Ad(t);if(s===null)return n;t=s;let r=`<img src="${t}" alt="${n}"`;return e&&(r+=` title="${e}"`),r+=">",r}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):t.text}}class Gh{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}}class Un{constructor(t){_e(this,"options");_e(this,"renderer");_e(this,"textRenderer");this.options=t||As,this.options.renderer=this.options.renderer||new To,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Gh}static parse(t,e){return new Un(e).parse(t)}static parseInline(t,e){return new Un(e).parseInline(t)}parse(t,e=!0){let n="";for(let s=0;s<t.length;s++){const r=t[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[r.type]){const o=r,l=this.options.extensions.renderers[o.type].call({parser:this},o);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(o.type)){n+=l||"";continue}}const a=r;switch(a.type){case"space":{n+=this.renderer.space(a);continue}case"hr":{n+=this.renderer.hr(a);continue}case"heading":{n+=this.renderer.heading(a);continue}case"code":{n+=this.renderer.code(a);continue}case"table":{n+=this.renderer.table(a);continue}case"blockquote":{n+=this.renderer.blockquote(a);continue}case"list":{n+=this.renderer.list(a);continue}case"html":{n+=this.renderer.html(a);continue}case"paragraph":{n+=this.renderer.paragraph(a);continue}case"text":{let o=a,l=this.renderer.text(o);for(;s+1<t.length&&t[s+1].type==="text";)o=t[++s],l+=`
|
|
4354
|
+
`+this.renderer.text(o);e?n+=this.renderer.paragraph({type:"paragraph",raw:l,text:l,tokens:[{type:"text",raw:l,text:l}]}):n+=l;continue}default:{const o='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}parseInline(t,e){e=e||this.renderer;let n="";for(let s=0;s<t.length;s++){const r=t[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[r.type]){const o=this.options.extensions.renderers[r.type].call({parser:this},r);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)){n+=o||"";continue}}const a=r;switch(a.type){case"escape":{n+=e.text(a);break}case"html":{n+=e.html(a);break}case"link":{n+=e.link(a);break}case"image":{n+=e.image(a);break}case"strong":{n+=e.strong(a);break}case"em":{n+=e.em(a);break}case"codespan":{n+=e.codespan(a);break}case"br":{n+=e.br(a);break}case"del":{n+=e.del(a);break}case"text":{n+=e.text(a);break}default:{const o='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}}class ea{constructor(t){_e(this,"options");_e(this,"block");this.options=t||As}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?Nn.lex:Nn.lexInline}provideParser(){return this.block?Un.parse:Un.parseInline}}_e(ea,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class yp{constructor(...t){_e(this,"defaults",Oh());_e(this,"options",this.setOptions);_e(this,"parse",this.parseMarkdown(!0));_e(this,"parseInline",this.parseMarkdown(!1));_e(this,"Parser",Un);_e(this,"Renderer",To);_e(this,"TextRenderer",Gh);_e(this,"Lexer",Nn);_e(this,"Tokenizer",wo);_e(this,"Hooks",ea);this.use(...t)}walkTokens(t,e){var s,r;let n=[];for(const a of t)switch(n=n.concat(e.call(this,a)),a.type){case"table":{const o=a;for(const l of o.header)n=n.concat(this.walkTokens(l.tokens,e));for(const l of o.rows)for(const c of l)n=n.concat(this.walkTokens(c.tokens,e));break}case"list":{const o=a;n=n.concat(this.walkTokens(o.items,e));break}default:{const o=a;(r=(s=this.defaults.extensions)==null?void 0:s.childTokens)!=null&&r[o.type]?this.defaults.extensions.childTokens[o.type].forEach(l=>{const c=o[l].flat(1/0);n=n.concat(this.walkTokens(c,e))}):o.tokens&&(n=n.concat(this.walkTokens(o.tokens,e)))}}return n}use(...t){const e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{const s={...n};if(s.async=this.defaults.async||s.async||!1,n.extensions&&(n.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){const a=e.renderers[r.name];a?e.renderers[r.name]=function(...o){let l=r.renderer.apply(this,o);return l===!1&&(l=a.apply(this,o)),l}:e.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const a=e[r.level];a?a.unshift(r.tokenizer):e[r.level]=[r.tokenizer],r.start&&(r.level==="block"?e.startBlock?e.startBlock.push(r.start):e.startBlock=[r.start]:r.level==="inline"&&(e.startInline?e.startInline.push(r.start):e.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(e.childTokens[r.name]=r.childTokens)}),s.extensions=e),n.renderer){const r=this.defaults.renderer||new To(this.defaults);for(const a in n.renderer){if(!(a in r))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;const o=a,l=n.renderer[o],c=r[o];r[o]=(...h)=>{let u=l.apply(r,h);return u===!1&&(u=c.apply(r,h)),u||""}}s.renderer=r}if(n.tokenizer){const r=this.defaults.tokenizer||new wo(this.defaults);for(const a in n.tokenizer){if(!(a in r))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;const o=a,l=n.tokenizer[o],c=r[o];r[o]=(...h)=>{let u=l.apply(r,h);return u===!1&&(u=c.apply(r,h)),u}}s.tokenizer=r}if(n.hooks){const r=this.defaults.hooks||new ea;for(const a in n.hooks){if(!(a in r))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;const o=a,l=n.hooks[o],c=r[o];ea.passThroughHooks.has(a)?r[o]=h=>{if(this.defaults.async)return Promise.resolve(l.call(r,h)).then(d=>c.call(r,d));const u=l.call(r,h);return c.call(r,u)}:r[o]=(...h)=>{let u=l.apply(r,h);return u===!1&&(u=c.apply(r,h)),u}}s.hooks=r}if(n.walkTokens){const r=this.defaults.walkTokens,a=n.walkTokens;s.walkTokens=function(o){let l=[];return l.push(a.call(this,o)),r&&(l=l.concat(r.call(this,o))),l}}this.defaults={...this.defaults,...s}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return Nn.lex(t,e??this.defaults)}parser(t,e){return Un.parse(t,e??this.defaults)}parseMarkdown(t){return(n,s)=>{const r={...s},a={...this.defaults,...r},o=this.onError(!!a.silent,!!a.async);if(this.defaults.async===!0&&r.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));a.hooks&&(a.hooks.options=a,a.hooks.block=t);const l=a.hooks?a.hooks.provideLexer():t?Nn.lex:Nn.lexInline,c=a.hooks?a.hooks.provideParser():t?Un.parse:Un.parseInline;if(a.async)return Promise.resolve(a.hooks?a.hooks.preprocess(n):n).then(h=>l(h,a)).then(h=>a.hooks?a.hooks.processAllTokens(h):h).then(h=>a.walkTokens?Promise.all(this.walkTokens(h,a.walkTokens)).then(()=>h):h).then(h=>c(h,a)).then(h=>a.hooks?a.hooks.postprocess(h):h).catch(o);try{a.hooks&&(n=a.hooks.preprocess(n));let h=l(n,a);a.hooks&&(h=a.hooks.processAllTokens(h)),a.walkTokens&&this.walkTokens(h,a.walkTokens);let u=c(h,a);return a.hooks&&(u=a.hooks.postprocess(u)),u}catch(h){return o(h)}}}onError(t,e){return n=>{if(n.message+=`
|
|
4355
|
+
Please report this to https://github.com/markedjs/marked.`,t){const s="<p>An error occurred:</p><pre>"+Tn(n.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(n);throw n}}}const Es=new yp;function ge(i,t){return Es.parse(i,t)}ge.options=ge.setOptions=function(i){return Es.setOptions(i),ge.defaults=Es.defaults,hp(ge.defaults),ge};ge.getDefaults=Oh;ge.defaults=As;ge.use=function(...i){return Es.use(...i),ge.defaults=Es.defaults,hp(ge.defaults),ge};ge.walkTokens=function(i,t){return Es.walkTokens(i,t)};ge.parseInline=Es.parseInline;ge.Parser=Un;ge.parser=Un.parse;ge.Renderer=To;ge.TextRenderer=Gh;ge.Lexer=Nn;ge.lexer=Nn.lex;ge.Tokenizer=wo;ge.Hooks=ea;ge.parse=ge;ge.options;ge.setOptions;ge.use;ge.walkTokens;ge.parseInline;Un.parse;Nn.lex;function ib(i){let t=String(i??"");if(t=t.replace(/```[\s\S]*?```/g," (code) ").replace(/~~~[\s\S]*?~~~/g," (code) ").replace(/`([^`]*)`/g,(n,s)=>/[\/\\]/.test(s)?" that file ":/^\W*$/.test(s)?" ":` ${s} `).replace(/!\[[^\]]*\]\([^)]*\)/g," ").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/https?:\/\/\S+/g," a link ").replace(/^\s{0,3}#{1,6}\s*/gm,"").replace(/^\s*>\s?/gm,"").replace(/^\s*[-*+]\s+/gm,", ").replace(/^\s*\d+\.\s+/gm,", ").replace(/(\*\*|__|\*|_|~~)/g,"").replace(/^\s*\|.*\|\s*$/gm," ").replace(/^\s*[-=:|]{3,}\s*$/gm," ").replace(/(?:\.{0,2}\/)?(?:[\w.-]+\/){1,}[\w.-]+(?::\d+)?/g," that file ").replace(/\b[\w-]+\.(?:js|ts|tsx|jsx|css|html|json|md|py|go|rs|sh|yml|yaml)\b(?::\d+)?/gi," that file ").replace(/[#*`_~>|]/g," ").replace(/\s*,\s*,+/g,", ").replace(/[ \t]+/g," ").replace(/\n{2,}/g,". ").replace(/\n/g," ").replace(/\s+([.,!?;:])/g,"$1").replace(/([:;,])[.,]+/g,"$1").replace(/([.!?])\s*,\s*/g,"$1 ").replace(/\.{2,}/g,".").replace(/\s{2,}/g," ").replace(/^[\s.,;:!?]+/,"").trim(),!/[a-z0-9]/i.test(t))return"";const e=460;if(t.length>e){const n=t.slice(0,e),s=Math.max(n.lastIndexOf(". "),n.lastIndexOf("! "),n.lastIndexOf("? "));t=s>160?n.slice(0,s+1):n.replace(/\s+\S*$/,"")+"…"}return t}const Ld=(i,t)=>{try{if(t===void 0)return localStorage.getItem(i);localStorage.setItem(i,t)}catch{}return null},sb=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus",""],ni={rec:null,stream:null,startedAt:0,get active(){return!!this.rec&&this.rec.state!=="inactive"},get supported(){var i;return typeof window<"u"&&!!((i=navigator.mediaDevices)!=null&&i.getUserMedia&&window.MediaRecorder)},async start(){if(this.active)return;this.stream=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}});const i=sb.find(t=>!t||MediaRecorder.isTypeSupported(t));this.rec=new MediaRecorder(this.stream,i?{mimeType:i}:{}),this.chunks=[],this.rec.ondataavailable=t=>{t.data.size&&this.chunks.push(t.data)},this.rec.start(250),this.startedAt=Date.now()},stop(){return this.active?new Promise(i=>{this.rec.onstop=()=>{var n;const t=((n=this.rec.mimeType)==null?void 0:n.split(";")[0])||"audio/webm",e=this.chunks.length?new Blob(this.chunks,{type:t}):null;this.release(),i(e&&e.size>1200?e:null)},this.rec.stop()}):Promise.resolve(null)},cancel(){this.active&&(this.rec.onstop=null,this.rec.stop()),this.release()},release(){var i;(i=this.stream)==null||i.getTracks().forEach(t=>t.stop()),this.rec=null,this.stream=null,this.startedAt=0}};function rb(i){const t={"audio/webm":"webm","audio/mp4":"m4a","audio/ogg":"ogg","audio/wav":"wav"}[i.type]||"webm",e=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");return new File([i],`voice-note-${e}.${t}`,{type:i.type})}const Dd={chief:["Moira","Fiona","Serena","Karen"],ada:["Samantha","Ava","Allison","Susan"],tunde:["Daniel","Oliver","Arthur","Alex"],mira:["Karen","Zoe","Tessa","Fiona"],kai:["Reed","Tom","Alex","Rocko"],zola:["Tessa","Nicky","Joelle","Samantha"],remi:["Rishi","Veena","Aman","Tara"],obi:["Flo","Eddy","Daniel","Reed"],lin:["Sandy","Shelley","Kathy","Moira"]},Id=i=>{const t=`${i.voiceURI||""} ${i.name||""}`.toLowerCase();return t.includes("premium")?3:t.includes("enhanced")?2:t.includes("compact")?0:1};class ab{constructor(){this.on=Ld("office.speak")==="1",this.voices=[],this.queue=[],this.saying=null;const t=typeof window<"u"&&window.speechSynthesis;if(!t)return;const e=()=>{this.voices=t.getVoices()||[]};e(),t.onvoiceschanged=e}get supported(){return typeof window<"u"&&!!window.speechSynthesis}setOn(t){this.on=t,Ld("office.speak",t?"1":"0"),t||this.stop()}voiceFor(t){this.voices.length||(this.voices=window.speechSynthesis.getVoices()||[]);const e=this.voices.filter(a=>/^en\b/i.test(a.lang)||/^en[-_]/i.test(a.lang)),n=e.length?e:this.voices;for(const a of Dd[t]||[]){const o=n.filter(l=>l.name.toLowerCase().startsWith(a.toLowerCase()));if(o.length)return o.sort((l,c)=>Id(c)-Id(l))[0]}const s=Object.keys(Dd),r=Math.max(0,s.indexOf(t));return n[r%n.length]||null}speak(t,e="chief",{force:n=!1}={}){if(!this.supported||!this.on&&!n)return;const s=ib(t);s&&(this.queue.push({say:s,from:e}),this.next())}next(){if(this.saying||!this.queue.length)return;const{say:t,from:e}=this.queue.shift(),n=new SpeechSynthesisUtterance(t),s=this.voiceFor(e);s&&(n.voice=s,n.lang=s.lang),n.rate=1.05,n.pitch=e==="chief"?1:1.02,this.saying=n;const r=()=>{this.saying=null,this.next()};n.onend=r,n.onerror=r,window.speechSynthesis.speak(n)}stop(){this.queue=[],this.saying=null;try{window.speechSynthesis.cancel()}catch{}}get busy(){return!!this.saying||!!this.queue.length}}const li=new ab,X=i=>document.getElementById(i),kd=["👍","❤️","😂","🎉","👀","🙏","🔥","✅"],ob=[["Smileys",["😀","😄","😁","😆","😅","🤣","😂","🙂","😉","😊","😇","🥰","😍","🤩","😘","😋","😛","🤪","🤔","🤨","😐","😑","😶","🙄","😏","😬","😌","😴","🤯","🥳","😎","🤓","🧐","😕","😟","😮","😲","😳","🥺","😢","😭","😱","😤","😡","🤬","💀","🤡","👻"]],["Gestures",["👍","👎","👌","🤌","✌️","🤞","🤝","👏","🙌","👐","🙏","💪","👋","🤙","👀","🫡","🤷","🤦","🙋","🙇"]],["Hearts",["❤️","🧡","💛","💚","💙","💜","🖤","🤍","💔","💯","💥","💫","✨","⭐","🔥","⚡"]],["Work",["✅","❌","⚠️","❓","❗","🚀","🎉","🎯","🏆","🐛","🔧","🛠️","💡","📌","📎","📝","📈","📉","⏳","🧪","🔒","🧠","☕","🍕"]]],nt=i=>String(i??"").replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t]),Mp=new yp({gfm:!0,breaks:!0});Mp.use({renderer:{html:i=>nt(i.text??i),link:({href:i,text:t})=>/^https?:\/\//i.test(i)?`<a href="${nt(i)}" target="_blank" rel="noreferrer">${nt(t)}</a>`:nt(t),image:({text:i})=>nt(i)}});const Vl=i=>Mp.parse(String(i??"")),ir={queued:"Queued",working:"Working",done:"Shipped",failed:"Failed",stopped:"Stopped"},lb={haiku:"Haiku",sonnet:"Sonnet",opus:"Opus"},cb=i=>{var t,e;return lb[i]||((e=[...((t=X("model"))==null?void 0:t.options)||[]].find(n=>n.value===i))==null?void 0:e.text)||i||"Default"},Gl={library:"Library",servers:"Server room",window:"Research",whiteboard:"Whiteboard",desk:"Desk"},wi=(i,t)=>typeof t=="string"&&Object.hasOwn(i,t)?t:"",$l=i=>ir[wi(ir,i)]||"",Nd=i=>{const t=/^the boss (?:says|asks|wants)\s*[:,]?\s*["“](.+?)(?:["”]|$)[\s.,:;]*(.*)/is.exec(String(i||"")),e=(t?t[1].length<24&&t[2]?`${t[1].replace(/[.!]$/,"")}: ${t[2]}`:t[1]:String(i||"")).trim();return e.charAt(0).toUpperCase()+e.slice(1)},hb=i=>{if(!i)return"";const t=Math.max(0,Math.round((Date.now()-i)/6e4));return t<1?"now":t<60?`${t}m`:t<1440?`${Math.round(t/60)}h`:`${Math.round(t/1440)}d`},Xi=i=>Number.isFinite(i)?i:0,gr=i=>typeof i=="string"&&/^#[0-9a-f]{3,8}$/i.test(i)?i:"#999",$h=new Map,Wl=i=>{let t=0;for(const r of String(i))t=(t*31+r.charCodeAt(0))%360;const e=(String(i).match(/[a-z0-9]/i)||["#"])[0].toUpperCase(),n=$h.get(i),s=n===!1?"":`<img src="/api/repos/icon?name=${encodeURIComponent(i)}" alt="" data-pico="${nt(i)}" draggable="false">`;return`<span class="pico${n?" has":""}" style="--h:${t}" aria-hidden="true">${nt(e)}${s}</span>`};document.addEventListener("load",i=>{var e;const t=i.target;(e=t==null?void 0:t.dataset)!=null&&e.pico&&($h.set(t.dataset.pico,!0),t.parentElement.classList.add("has"))},!0);document.addEventListener("error",i=>{var e;const t=i.target;(e=t==null?void 0:t.dataset)!=null&&e.pico&&($h.set(t.dataset.pico,!1),t.remove())},!0);const bp=i=>{const t=kh[i.id]||{},e=gr(i.skin),n=gr(i.hair),s=gr(i.shirt),r=t.hair||"short",a={afro:`<circle cx="24" cy="18" r="13.5" fill="${n}"/>`,bob:`<path d="M10 40V19a14 14 0 0 1 28 0v21z" fill="${n}"/>`,long:`<path d="M9 44V19a15 15 0 0 1 30 0v25z" fill="${n}"/>`,ponytail:`<path d="M33 14c8 1 10 9 6 19-1-6-3-9-6-10z" fill="${n}"/>`,bun:`<circle cx="24" cy="6.5" r="4.5" fill="${n}"/>`}[r]||"",o={afro:`<path d="M15 17a9 9 0 0 1 18 0c-3-3-6-4-9-4s-6 1-9 4z" fill="${n}"/>`,short:`<path d="M15 18a9 9 0 0 1 18 0c-4-1-6-3-9-5-2 3-5 4-9 5z" fill="${n}"/>`,buzz:`<path d="M15.2 17.5a8.8 8.8 0 0 1 17.6 0c-5-2-12.6-2-17.6 0z" fill="${n}"/>`,spiky:`<path d="M15 18l1-7 3 4 2-7 3 6 3-6 2 7 3-4 1 7c-4-2-6-3-9-3s-5 1-9 3z" fill="${n}"/>`,bob:`<path d="M15 19a9 9 0 0 1 18 0c-5 0-9-2-11-5-1 3-3 5-7 5z" fill="${n}"/>`,long:`<path d="M15 19a9 9 0 0 1 18 0c-5 0-9-2-11-5-1 3-3 5-7 5z" fill="${n}"/>`,ponytail:`<path d="M15 18a9 9 0 0 1 18 0c-4-1-7-3-9-5-2 3-5 4-9 5z" fill="${n}"/>`,bun:`<path d="M15 18a9 9 0 0 1 18 0c-4-1-7-3-9-5-2 3-5 4-9 5z" fill="${n}"/>`}[r]||"",l=t.extra==="glasses"?'<g fill="none" stroke="#2b2b2b" stroke-width="1.2"><circle cx="20.5" cy="22" r="3"/><circle cx="27.5" cy="22" r="3"/><path d="M23.5 22h1"/></g>':t.extra==="headphones"?'<path d="M14.5 22v-4a9.5 9.5 0 0 1 19 0v4" fill="none" stroke="#2b2b2b" stroke-width="2"/><rect x="12.5" y="20" width="4" height="7" rx="2" fill="#2b2b2b"/><rect x="31.5" y="20" width="4" height="7" rx="2" fill="#2b2b2b"/>':"";return`<svg class="face" viewBox="0 0 48 48" aria-hidden="true" style="background:${s}33">
|
|
4356
|
+
${a}
|
|
4357
|
+
<path d="M6 48c1-9 8-13 18-13s17 4 18 13z" fill="${s}"/>
|
|
4358
|
+
<rect x="20.5" y="27" width="7" height="9" rx="3" fill="${e}"/>
|
|
4359
|
+
<ellipse cx="24" cy="22" rx="9" ry="10" fill="${e}"/>
|
|
4360
|
+
${o}
|
|
4361
|
+
<circle cx="20.5" cy="22.5" r="1.2" fill="#2b2118"/><circle cx="27.5" cy="22.5" r="1.2" fill="#2b2118"/>
|
|
4362
|
+
<path d="M21.5 27.5q2.5 2 5 0" fill="none" stroke="#2b2118" stroke-width="1.1" stroke-linecap="round" opacity=".7"/>
|
|
4363
|
+
${l}
|
|
4364
|
+
</svg>`},Xl=(i,t="")=>`<span class="av ${t}">${i.look?bp(i.look):'<svg class="face" viewBox="0 0 48 48" aria-hidden="true" style="background:#c9c1b455"><path d="M6 48c1-9 8-13 18-13s17 4 18 13z" fill="#a39a8a"/><ellipse cx="24" cy="21" rx="9" ry="10" fill="#a39a8a"/></svg>'}</span>`,Zs=(i,t)=>{try{if(t===void 0)return localStorage.getItem(i);localStorage.setItem(i,t)}catch{}return null};function Ud(i){const t=Math.max(0,Math.round(i/1e3));if(t<60)return`${t}s`;const e=Math.floor(t/60);return e<60?`${e}m ${t%60}s`:`${Math.floor(e/60)}h ${e%60}m`}const ub=i=>{const t=Math.ceil(i/6e4);if(t<60)return`${t}m`;const e=Math.floor(t/60);return e<24?`${e}h ${t%60}m`:`${Math.floor(e/24)}d ${e%24}h`},db=i=>{const t=new Date(i),e=t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"});return t.toDateString()===new Date().toDateString()?e:`${t.toLocaleDateString([],{weekday:"short"})} ${e}`},Vr=i=>i>=1<<30?`${(i/(1<<30)).toFixed(1)} GB`:`${Math.round(i/(1<<20))} MB`,Od=i=>`${i>=10?Math.round(i):Math.round(i*10)/10}%`;async function Xe(i,t,e){const n=t===void 0?e?{method:e}:{}:{method:e||"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)},s=await fetch(i,n),r=await s.json().catch(()=>({}));if(!s.ok)throw new Error(r.error||`Request failed (${s.status})`);return r}const Sp=i=>i<1024?`${i} B`:i<1048576?`${Math.round(i/1024)} KB`:`${(i/1048576).toFixed(1)} MB`,qa=i=>`/api/uploads/${i.id}/${encodeURIComponent(i.name)}`;class Fd{constructor(t,e){this.el=t,this.onError=e,this.items=[],t.onclick=n=>{const s=n.target.closest("[data-drop]");s&&(this.items=this.items.filter(r=>r.key!==s.dataset.drop),this.render())}}add(t){for(const e of t){const n={key:Math.random().toString(36).slice(2),name:e.name||"pasted",size:e.size,preview:e.type.startsWith("image/")?URL.createObjectURL(e):null},s=e.name||`pasted-${Date.now()}.${(e.type.split("/")[1]||"bin").replace("jpeg","jpg")}`;n.done=fetch("/api/uploads",{method:"POST",headers:{"x-file-name":encodeURIComponent(s),"content-type":e.type||"application/octet-stream"},body:e}).then(async r=>{const a=await r.json().catch(()=>({}));if(!r.ok)throw new Error(a.error||`Upload failed (${r.status})`);n.id=a.id}).catch(r=>{this.items=this.items.filter(a=>a!==n),this.render(),this.onError(`${n.name}: ${r.message}`)}).finally(()=>{n.loading=!1,this.render()}),n.loading=!0,this.items.push(n)}this.render()}attach({id:t,name:e,size:n}){this.items.push({key:Math.random().toString(36).slice(2),id:t,name:e,size:n,done:Promise.resolve(),voice:!0}),this.render()}async ids(){return await Promise.all(this.items.map(t=>t.done)),this.items.filter(t=>t.id).map(t=>t.id)}get empty(){return!this.items.length}clear(){this.items.forEach(t=>t.preview&&URL.revokeObjectURL(t.preview)),this.items=[],this.render()}render(){this.el.hidden=!this.items.length,this.el.innerHTML=this.items.map(t=>`
|
|
4365
|
+
<span class="file ${t.loading?"loading":""}" title="${nt(t.name)} · ${Sp(t.size)}">
|
|
4358
4366
|
${t.preview?`<img src="${t.preview}" alt="">`:t.voice?"<b>VOICE</b>":"<b>FILE</b>"}
|
|
4359
|
-
<span>${
|
|
4360
|
-
<button type="button" data-drop="${t.key}" aria-label="Remove ${
|
|
4361
|
-
</span>`).join("")}}function
|
|
4362
|
-
<button class="job ${
|
|
4363
|
-
<span class="dot ${
|
|
4364
|
-
<span class="t">${
|
|
4365
|
-
<
|
|
4366
|
-
|
|
4367
|
-
<
|
|
4368
|
-
<span class="dot ${
|
|
4369
|
-
|
|
4370
|
-
<
|
|
4371
|
-
|
|
4367
|
+
<span>${nt(t.name)}</span>
|
|
4368
|
+
<button type="button" data-drop="${t.key}" aria-label="Remove ${nt(t.name)}">×</button>
|
|
4369
|
+
</span>`).join("")}}function zd(i,{zone:t,input:e,picker:n,button:s}){s.onclick=()=>n.click(),n.onchange=()=>{i.add([...n.files]),n.value=""},e.addEventListener("paste",r=>{var o;const a=[...((o=r.clipboardData)==null?void 0:o.files)||[]];a.length&&(r.preventDefault(),i.add(a))}),t.addEventListener("dragover",r=>{[...r.dataTransfer.types].includes("Files")&&(r.preventDefault(),t.classList.add("dropping"))}),t.addEventListener("dragleave",r=>{t.contains(r.relatedTarget)||t.classList.remove("dropping")}),t.addEventListener("drop",r=>{t.classList.remove("dropping"),r.dataTransfer.files.length&&(r.preventDefault(),i.add([...r.dataTransfer.files]))})}const Bd=i=>i!=null&&i.length?`<div class="files">${i.map(t=>t.image?`<a class="thumb" href="${qa(t)}" target="_blank" rel="noreferrer" title="${nt(t.name)}"><img src="${qa(t)}" alt="${nt(t.name)}" loading="lazy"></a>`:t.audio?`<audio class="voice" controls preload="metadata" src="${qa(t)}" title="${nt(t.name)}"></audio>`:`<a class="file" href="${qa(t)}" title="${nt(t.name)} · ${Sp(t.size)}"><b>FILE</b><span>${nt(t.name)}</span></a>`).join("")}</div>`:"",Ya={more:'<svg viewBox="0 0 24 24"><path d="M7 7l5 5 5-5M7 13l5 5 5-5"/></svg>',speak:'<svg viewBox="0 0 24 24"><path d="M11 5 6 9H3v6h3l5 4V5Z"/><path d="M15.5 8.5a5 5 0 0 1 0 7"/></svg>',open:'<svg viewBox="0 0 24 24"><path d="M14 4h6v6M20 4l-9 9"/><path d="M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5"/></svg>',reply:'<svg viewBox="0 0 24 24"><path d="M21 12a8 8 0 0 1-11.6 7.1L4 20l1-4.6A8 8 0 1 1 21 12z"/></svg>'};class fb{constructor(t){this.app=t,this.openId=null,this.repos=null,this.channels=[{id:"general",name:"general"}],this.channel=Zs("office.channel")||"general",this.unread=new Map,X("clear").onclick=async()=>{await Xe("/api/jobs/clear",{}),this.closeDetail()},X("away").onclick=e=>{const n=e.target.closest("[data-recall]");n&&this.app.recall(n.dataset.recall)},X("jobs").onclick=e=>{const n=e.target.closest("[data-id]");n&&this.app.openJob(n.dataset.id)},X("projects").onclick=e=>{const n=e.target.closest(".job[data-id]");if(n)return this.app.openJob(n.dataset.id);const s=e.target.closest("[data-new]");if(s)return this.focusInput(`#${s.dataset.new.replace(/\s+/g,"-")} `);const r=e.target.closest("[data-project]");r&&(this.projectOpen=this.projectOpen===r.dataset.project?null:r.dataset.project,this.renderProjects())},document.querySelectorAll(".tabs button").forEach(e=>e.onclick=()=>this.tab(e.dataset.tab)),document.querySelectorAll("#mnav button").forEach(e=>e.onclick=()=>{e.dataset.m==="office"?this.mobile("office"):this.tab(e.dataset.m)}),this.bindViewToggle(),this.bindTeam(),this.bindChat(),this.bindChannels(),this.bindFold(),this.renderChannels(),addEventListener("keydown",e=>{var s;const n=/INPUT|TEXTAREA|SELECT/.test((s=document.activeElement)==null?void 0:s.tagName);(e.key==="n"||e.key==="/")&&!n&&!e.metaKey&&!e.ctrlKey&&(e.preventDefault(),this.focusInput()),e.key==="Escape"&&!n&&this.closeDetail()}),setInterval(()=>this.tick(),1e3)}renderOwner(t){t=String(t||"").trim();const e=t?`${t}${/s$/i.test(t)?"’":"’s"} Office`:"Your Office";X("officeName").textContent=e,document.title=e}bindFold(){const t=X("fold"),e=X("gaugesBox"),n=r=>{e.hidden=!r,t.setAttribute("aria-expanded",String(r));const a=r?"Hide usage":"Show usage";t.setAttribute("aria-label",a),t.title=a;try{localStorage.setItem("office.gauges",r?"1":"0")}catch{}};let s=!1;try{s=localStorage.getItem("office.gauges")==="1"}catch{}n(s),t.addEventListener("click",()=>n(e.hidden)),X("officeName").addEventListener("click",()=>n(e.hidden))}renderLevel(t){const e=`${t.xp-t.floor} / ${t.next-t.floor} XP`;X("lvNum").textContent=t.level,X("lv").title=`Level ${t.level} · ${e}`,X("lv").setAttribute("aria-label",`Level ${t.level}, ${e}`),X("lv").style.setProperty("--p",Math.min(100,(t.xp-t.floor)/(t.next-t.floor)*100)),X("xptext").textContent=e}renderUsage(t){if(t!==void 0&&(this.usage=t),t=this.usage,X("usage").hidden=!t,!t)return;const e=t.error&&!t.session&&!t.week;X("useErr").hidden=!e,X("useErr").textContent=e?t.error:"";for(const[n,s]of[["useSession",t.session],["useWeek",t.week]]){const r=X(n);if(r.hidden=!s,!s)continue;const a=s.resetsAt?s.resetsAt-Date.now():null;r.className=`meter ${s.pct>=90?"hot":s.pct>=70?"warm":""}`,r.style.setProperty("--p",Math.min(100,s.pct)),r.querySelector(".v").textContent=`${s.pct}%`,r.querySelector(".r").textContent=a===null?"":a<=0?"Resetting now":`Resets in ${ub(a)}`,r.title=[s.resetsAt?`Resets ${db(s.resetsAt)}`:"",r.querySelector(".r").textContent].filter(Boolean).join(" · ")}}renderProc(t,e){e&&(this.machine=e),this.procs=t||null;const n=this.machine,s=Object.values(this.procs||{}).filter(u=>u);if(X("load").hidden=!s.length||!n,X("load").hidden)return this.renderMeta(this.app.job(this.openId));const r=s.reduce((u,d)=>u+(d.cpu||0),0),a=s.reduce((u,d)=>u+d.mem,0),o=r/n.cores,l=a/n.mem*100,c=`${s.length} ${s.length===1?"agent":"agents"}`,h=`${(r/100).toFixed(1)} of ${n.cores} cores`;this.meter("loadCpu",o,Od(o),s.length>1?`${c} · ${h}`:h,`${c} using ${h}`),this.meter("loadMem",l,Vr(a),`${Od(l)} of ${Vr(n.mem)}`,`${c} holding ${Vr(a)} of ${Vr(n.mem)}`),this.renderMeta(this.app.job(this.openId))}meter(t,e,n,s,r){const a=X(t);a.hidden=!1,a.className=`meter ${e>=90?"hot":e>=70?"warm":""}`,a.style.setProperty("--p",Math.min(100,e)),a.querySelector(".v").textContent=n,a.querySelector(".r").textContent=s,a.title=`${r} · ${s}`}renderStats(t,e=0){const n=r=>t.filter(a=>a.status===r&&!a.awaitingBoss).length,s=t.reduce((r,a)=>r+(a.cost||0),e);X("stats").innerHTML=[`<span><b>${n("working")}</b> working</span>`,`<span><b>${n("queued")}</b> queued</span>`,`<span><b>${n("done")}</b> shipped</span>`,`<span><b>$${s.toFixed(2)}</b> spent</span>`].join("")}renderJobs(t,e){const n={working:0,queued:1,done:2,failed:2,stopped:2},s=[...t].sort((h,u)=>n[h.status]-n[u.status]||(u.endedAt||u.queuedAt)-(h.endedAt||h.queuedAt)),r=h=>`
|
|
4370
|
+
<button class="job ${h.id===this.openId?"open":""}" data-id="${nt(h.id)}">
|
|
4371
|
+
<span class="dot ${wi(ir,h.status)}"></span>
|
|
4372
|
+
<span class="t" title="${nt(h.title)}">${nt(Nd(h.title))}</span>
|
|
4373
|
+
<time class="w">${n[h.status]<2?"":hb(h.endedAt||h.queuedAt)}</time>
|
|
4374
|
+
<span class="m">${h.from?`<b class="from">from ${nt(h.from)}</b> · `:""}${Wl(h.repo)}<span class="r">${nt(h.repo)}</span>${h.agentId?" · "+nt(e(h.agentId)):""}${h.status==="done"?"":` · <span class="s ${wi(ir,h.status)}">${$l(h.status)}</span>`}</span>
|
|
4375
|
+
</button>`,a=s.filter(h=>n[h.status]<2),o=s.filter(h=>n[h.status]===2),l=(h,u)=>u.length?`<h3 class="jgroup">${h}<span>${u.length}</span></h3>${u.map(r).join("")}`:"";X("jobs").innerHTML=s.length?l("In progress",a)+l("Finished",o):'<p class="empty">No jobs yet. Ask for something in the chat.</p>',X("clear").hidden=!s.some(h=>n[h.status]===2);const c=s.filter(h=>n[h.status]<2).length;X("jobCount").textContent=c?String(c):"",X("mJobCount").textContent=c?String(c):"",this.renderProjects(t)}bindViewToggle(){this.view=Zs("office.view")==="icons"?"icons":"list";const t=()=>{document.querySelectorAll(".viewbar [data-view]").forEach(e=>e.setAttribute("aria-pressed",String(e.dataset.view===this.view))),X("team").classList.toggle("icons",this.view==="icons"),X("projects").classList.toggle("icons",this.view==="icons")};document.querySelectorAll(".viewbar").forEach(e=>e.addEventListener("click",n=>{const s=n.target.closest("[data-view]");!s||s.dataset.view===this.view||this.dirty()&&!confirm("Discard your changes?")||(this.view=s.dataset.view,Zs("office.view",this.view),t(),this.renderProjects(),this.renderTeam(!0))})),t()}async loadProjects(){try{this.repos=ru((await Xe("/api/repos")).repos)}catch{this.repos||(this.repos=[])}this.renderProjects()}renderProjects(t=this.lastJobs||[]){if(this.lastJobs=t,X("projectsPane").hidden)return;if(!this.repos){X("projects").innerHTML='<p class="empty">Looking for projects…</p>';return}const e=new Map;for(const o of t)(e.get(o.repo)||e.set(o.repo,[]).get(o.repo)).push(o);const n=o=>o.endedAt||o.startedAt||o.queuedAt||0,s=[...e].filter(([o])=>this.repos.includes(o)).map(([o,l])=>{l.sort((f,g)=>n(g)-n(f));const c=l.filter(f=>f.status==="working").length,h=l.filter(f=>f.status==="queued").length,u=c?"working":h?"queued":l[0].status==="failed"?"failed":"done",d=c?nt(this.app.busyIn(o)):h?`${h} queued`:`Last: ${nt(l[0].title)}`;return{name:o,js:l,live:c,queued:h,state:u,note:d,last:n(l[0])}}).sort((o,l)=>!!l.live-!!o.live||l.last-o.last).slice(0,8);if(!s.length){X("projects").innerHTML='<p class="empty">No projects worked on yet. Ask for something in the chat.</p>';return}const r=o=>`<div class="sub">${o.js.length?o.js.slice(0,8).map(l=>`
|
|
4376
|
+
<button class="job" data-id="${nt(l.id)}"><span class="dot ${wi(ir,l.status)}"></span><span class="t" title="${nt(l.title)}">${nt(Nd(l.title))}</span>
|
|
4377
|
+
<span class="m">${l.agentId?nt(this.app.staffName(l.agentId))+" · ":""}${$l(l.status)}</span></button>`).join(""):'<p class="none">Nothing has run here yet.</p>'}
|
|
4378
|
+
<button type="button" class="ghost" data-new="${nt(o.name)}"><span aria-hidden="true">+</span> New job in ${nt(o.name)}</button></div>`,a=o=>o.js.length?`${o.js.length} job${o.js.length===1?"":"s"}`:"";if(this.view==="icons"){const o=s.find(l=>l.name===this.projectOpen);X("projects").innerHTML=`<div class="tiles">${s.map(l=>`
|
|
4379
|
+
<button type="button" class="tile${l.name===this.projectOpen?" open":""}" data-project="${nt(l.name)}" aria-expanded="${l.name===this.projectOpen}" title="${nt(l.name)}${a(l)?` · ${a(l)}`:""}">
|
|
4380
|
+
<span class="art">${Wl(l.name)}<span class="dot ${l.state}"></span></span>
|
|
4381
|
+
<span class="n">${nt(l.name)}</span>
|
|
4382
|
+
<span class="c">${a(l)||"No jobs"}</span>
|
|
4383
|
+
</button>`).join("")}</div>${o?`<div class="project open">${o.live||o.queued?`<p class="note">${o.note}</p>`:""}${r(o)}</div>`:""}`;return}X("projects").innerHTML=s.map(o=>{const l=this.projectOpen===o.name;return`<div class="project${l?" open":""}">
|
|
4384
|
+
<button type="button" class="head" data-project="${nt(o.name)}" aria-expanded="${l}">
|
|
4385
|
+
<span class="dot ${o.state}"></span>
|
|
4386
|
+
<span class="n">${nt(o.name)}</span>
|
|
4387
|
+
<span class="c">${a(o)}</span>
|
|
4388
|
+
<span class="m">${o.note}</span>
|
|
4372
4389
|
</button>
|
|
4373
|
-
${
|
|
4374
|
-
|
|
4375
|
-
<span class="m">${o.agentId?lt(this.app.staffName(o.agentId))+" · ":""}${Xl(o.status)}</span></button>`).join(""):'<p class="none">Nothing has run here yet.</p>'}
|
|
4376
|
-
<button type="button" class="ghost" data-new="${lt(r.name)}">New job in ${lt(r.name)}</button></div>`:""}
|
|
4377
|
-
</div>`}).join(""):'<p class="empty">No projects worked on yet. Ask for something in the chat.</p>'}async openDetail(t){this.openId=t;let e=await $e(Ns(t));this.openId===t&&(Gt.on&&(e=e.job),this.app.mergeLog(e),this.renderDetail(),this.app.refreshLists())}closeDetail(){this.openId=null,q("detail").hidden=!0,this.app.refreshLists(),this.app.select(null)}renderDetail(){const t=this.app.job(this.openId);if(!t)return this.closeDetail();const e=q("detail");e.hidden=!1,e.innerHTML=`
|
|
4390
|
+
${l?r(o):""}
|
|
4391
|
+
</div>`}).join("")}async openDetail(t){this.openId=t;let e=await Xe(Ls(t));this.openId===t&&(Gt.on&&(e=e.job),this.app.mergeLog(e),this.renderDetail(),this.app.refreshLists())}closeDetail(){this.openId=null,X("detail").hidden=!0,this.app.refreshLists(),this.app.select(null)}renderDetail(){const t=this.app.job(this.openId);if(!t)return this.closeDetail();const e=X("detail");e.hidden=!1,e.innerHTML=`
|
|
4378
4392
|
<div class="d-head">
|
|
4379
|
-
<span class="pill ${
|
|
4393
|
+
<span class="pill ${wi(ir,t.status)}">${$l(t.status)}</span>
|
|
4380
4394
|
<button class="x" title="Close (Esc)">×</button>
|
|
4381
4395
|
</div>
|
|
4382
|
-
<h2>${
|
|
4396
|
+
<h2>${nt(t.title)}</h2>
|
|
4383
4397
|
<dl class="meta" id="meta"></dl>
|
|
4384
4398
|
<div id="changes"></div>
|
|
4385
4399
|
<div class="log" id="log">${t.log.map((s,r)=>this.entry(s,null,t.log[r-1])).join("")}</div>
|
|
4386
|
-
<div class="d-foot">${this.footer(t)}</div>`,e.querySelector(".x").onclick=()=>this.closeDetail(),this.renderMeta(t),this.renderChanges(t);const n=
|
|
4400
|
+
<div class="d-foot">${this.footer(t)}</div>`,e.querySelector(".x").onclick=()=>this.closeDetail(),this.renderMeta(t),this.renderChanges(t);const n=X("log");n.scrollTop=n.scrollHeight,this.bindFooter(t)}renderChanges(t){const e=X("changes"),n=t.changes;if(!e)return;if(!n||!n.count){e.innerHTML=n?'<div class="changes none">No files changed.</div>':"";return}const s=this.changesOpen===t.id,r={added:"A",modified:"M",deleted:"D"};e.innerHTML=`
|
|
4387
4401
|
<div class="changes">
|
|
4388
4402
|
<button class="c-head" aria-expanded="${s}">
|
|
4389
4403
|
<span class="c-title">What changed</span>
|
|
4390
|
-
<span class="c-sum">${
|
|
4404
|
+
<span class="c-sum">${Xi(n.count)} file${n.count===1?"":"s"} <b class="add">+${Xi(n.add)}</b> <b class="del">−${Xi(n.del)}</b></span>
|
|
4391
4405
|
<span class="c-caret">${s?"▾":"▸"}</span>
|
|
4392
4406
|
</button>
|
|
4393
4407
|
${s?`<ul class="c-files">${n.files.map((a,o)=>`
|
|
4394
4408
|
<li><button class="c-file" data-i="${o}" aria-expanded="false">
|
|
4395
|
-
<span class="st ${
|
|
4396
|
-
<span class="n">${a.binary?"binary":`<b class="add">+${
|
|
4397
|
-
</button></li>`).join("")}${n.count>n.files.length?`<li class="more">and ${
|
|
4398
|
-
</div>`,e.querySelector(".c-head").onclick=()=>{this.changesOpen=s?null:t.id,this.renderChanges(t)},e.querySelectorAll(".c-file").forEach(a=>a.onclick=async()=>{const o=a.parentElement,l=o.querySelector("pre");if(l){l.remove(),a.setAttribute("aria-expanded","false");return}a.setAttribute("aria-expanded","true");const c=document.createElement("pre");c.className="c-diff",c.textContent="Loading…",o.append(c);try{const{diff:h}=await
|
|
4399
|
-
`).filter(u=>!/^(diff --git|index |--- |\+\+\+ )/.test(u)).map(u=>`<span class="${u[0]==="+"?"add":u[0]==="-"?"del":u[0]==="@"?"hunk":""}">${
|
|
4400
|
-
`)||"No textual changes."}catch(h){c.textContent=h.message}})}renderMeta(t){var a;const e=
|
|
4409
|
+
<span class="st ${wi(r,a.status)}">${r[wi(r,a.status)]||""}</span><span class="p" title="${nt(a.path)}">${nt(a.path)}</span>
|
|
4410
|
+
<span class="n">${a.binary?"binary":`<b class="add">+${Xi(a.add)}</b> <b class="del">−${Xi(a.del)}</b>`}</span>
|
|
4411
|
+
</button></li>`).join("")}${n.count>n.files.length?`<li class="more">and ${Xi(n.count-n.files.length)} more</li>`:""}</ul>`:""}
|
|
4412
|
+
</div>`,e.querySelector(".c-head").onclick=()=>{this.changesOpen=s?null:t.id,this.renderChanges(t)},e.querySelectorAll(".c-file").forEach(a=>a.onclick=async()=>{const o=a.parentElement,l=o.querySelector("pre");if(l){l.remove(),a.setAttribute("aria-expanded","false");return}a.setAttribute("aria-expanded","true");const c=document.createElement("pre");c.className="c-diff",c.textContent="Loading…",o.append(c);try{const{diff:h}=await Xe(Ls(t.id,`/diff?path=${encodeURIComponent(n.files[a.dataset.i].path)}`));c.innerHTML=h.split(`
|
|
4413
|
+
`).filter(u=>!/^(diff --git|index |--- |\+\+\+ )/.test(u)).map(u=>`<span class="${u[0]==="+"?"add":u[0]==="-"?"del":u[0]==="@"?"hunk":""}">${nt(u)||" "}</span>`).join(`
|
|
4414
|
+
`)||"No textual changes."}catch(h){c.textContent=h.message}})}renderMeta(t){var a;const e=X("meta");if(!e||!t)return;const n=t.status==="working"||t.status==="queued"?Date.now():t.endedAt||Date.now(),s=[["Project",t.repo],...t.from&&!Gt.on?[["From",`${t.from} (guest)`]]:[],["Agent",t.agentId?this.app.staffName(t.agentId):"Unassigned"],["Clearance",this.app.modes[t.mode]||t.mode],["Model",[cb(t.model),t.autoModel&&"chief’s pick",t.escalations?`moved up ${t.escalations}×`:""].filter(Boolean).join(" · ")],["Context",t.context?`${(t.context/1e3).toFixed(1)}k tokens`:"—"],["Time",t.startedAt?Ud(n-t.startedAt):"—"],["Cost",`$${(t.cost||0).toFixed(3)}`],["XP",t.xp?`+${t.xp}`:"—"]],r=(a=this.procs)==null?void 0:a[t.id];r&&(s.push(["CPU",r.cpu===null?"measuring…":`${Math.round(r.cpu)}%`]),s.push(["Memory",Vr(r.mem)]),s.push(["Processes",String(r.procs)])),e.innerHTML=s.map(([o,l])=>`<div><dt>${o}</dt><dd>${nt(l)}</dd></div>`).join("")}entry(t,e,n){const s=t.kind==="result"&&(n?n.kind==="text"&&n.summary===t.summary:(e==null?void 0:e.dataset.text)===t.summary);switch(t.kind){case"user":return`<div class="e user"><span class="who">You</span><p>${nt(t.summary)}</p></div>`;case"system":return`<div class="e sys">${nt(t.summary)}</div>`;case"thinking":return'<div class="e sys">thinking…</div>';case"tool":return`<div class="e tool"><span class="st ${wi(Gl,t.station)}" title="${Gl[wi(Gl,t.station)]||""}"></span>${nt(t.summary)}</div>`;case"text":return`<div class="e text md" data-text="${nt(t.summary)}">${Vl(t.summary)}</div>`;case"error":return`<div class="e err">${nt(t.summary)}</div>`;case"result":return`<div class="e result ${t.ok?"ok":"bad"}"><span class="who">${t.ok?"Result":"Ended early"}${Xi(t.ms)?` · ${Ud(t.ms)}`:""}${Xi(t.cost)?` · $${t.cost.toFixed(3)}`:""}</span>${s?"":`<div class="md">${Vl(t.summary)}</div>`}</div>`;default:return""}}appendLog(t,e){if(t!==this.openId)return;const n=X("log");if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight<60;n.insertAdjacentHTML("beforeend",this.entry(e,n.lastElementChild)),s&&(n.scrollTop=n.scrollHeight)}footer(t){var s;if(t.status==="working")return'<button class="ghost danger" data-act="stop">Stop work</button>';if(t.status==="queued")return'<button class="ghost danger" data-act="stop">Pull from queue</button>';const e=(s=t.denials)!=null&&s.length?`<div class="notice">Blocked from using <b>${t.denials.map(nt).join(", ")}</b>.
|
|
4401
4415
|
<button class="primary small" data-act="grant">Grant full autonomy and continue</button></div>`:"",n=t.mode==="plan"&&t.status==="done"?`<div class="notice">That's the plan. <button class="primary small" data-act="approve">Approve and build it</button></div>`:"";return`${e}${n}
|
|
4402
4416
|
<form class="reply" data-act="reply">
|
|
4403
4417
|
<div class="tray" hidden></div>
|
|
4404
|
-
<textarea name="message" rows="2" placeholder="Follow up with ${
|
|
4418
|
+
<textarea name="message" rows="2" placeholder="Follow up with ${nt(this.app.staffName(t.agentId)||"them")}…"></textarea>
|
|
4405
4419
|
<div class="row">
|
|
4406
|
-
<select name="mode">${Object.entries(this.app.modes).map(([r,a])=>`<option value="${
|
|
4420
|
+
<select name="mode">${Object.entries(this.app.modes).map(([r,a])=>`<option value="${nt(r)}" ${r===t.mode?"selected":""}>${nt(a)}</option>`).join("")}</select>
|
|
4407
4421
|
<button type="button" class="attach" title="Attach files or images" aria-label="Attach files">
|
|
4408
4422
|
<svg viewBox="0 0 24 24"><path d="M21 11.5l-8.6 8.6a5.5 5.5 0 0 1-7.8-7.8l8.6-8.6a3.7 3.7 0 0 1 5.2 5.2l-8.6 8.6a1.8 1.8 0 0 1-2.6-2.6l7.9-7.9"/></svg>
|
|
4409
4423
|
</button>
|
|
4410
4424
|
<input type="file" multiple hidden />
|
|
4411
4425
|
<button class="primary small" type="submit">Send</button>
|
|
4412
4426
|
</div>
|
|
4413
|
-
</form>`}bindFooter(t){const e=
|
|
4414
|
-
In it: ${o}`:""}`;return`<button type="button" role="tab" aria-selected="${a}" class="channel ${a?"on":""}" data-channel="${
|
|
4415
|
-
<span class="hash">#</span>${
|
|
4416
|
-
<div class="item ${h===0?"on":""}" data-insert="${
|
|
4417
|
-
${c.dot?`<i style="background:${
|
|
4418
|
-
<span>${
|
|
4419
|
-
</div>`).join(""),s.hidden=!1}pick(t){if(!t)return;const e=
|
|
4420
|
-
<button type="button" class="thread-sum" data-thread="${
|
|
4427
|
+
</form>`}bindFooter(t){const e=X("detail").querySelector(".d-foot"),n=async r=>{try{await r()}catch(a){this.toast(a.message,"bad")}};e.querySelectorAll('[data-act="stop"]').forEach(r=>r.onclick=()=>n(()=>Xe(Ls(t.id,"/stop"),{}))),e.querySelectorAll('[data-act="grant"]').forEach(r=>r.onclick=()=>n(()=>Xe(Ls(t.id,"/reply"),Ko("You now have permission to run the commands that were blocked. Carry on from where you stopped.","auto")))),e.querySelectorAll('[data-act="approve"]').forEach(r=>r.onclick=()=>n(()=>Xe(Ls(t.id,"/reply"),Ko("Approved. Go ahead and implement the plan.","edit"))));const s=e.querySelector("form.reply");if(s){const r=new Fd(s.querySelector(".tray"),a=>this.toast(a,"bad"));zd(r,{zone:s,input:s.message,picker:s.querySelector("input[type=file]"),button:s.querySelector(".attach")}),s.onsubmit=a=>{a.preventDefault();const o=new FormData(s);n(async()=>{const l=await r.ids();await Xe(Ls(t.id,"/reply"),Ko(o.get("message"),o.get("mode"),l)),r.clear()})},s.message.onkeydown=a=>{a.key==="Enter"&&(a.metaKey||a.ctrlKey)&&s.requestSubmit()}}}tick(){const t=this.openId&&this.app.job(this.openId);t&&(t.status==="working"||t.status==="queued")&&this.renderMeta(t),this.usage&&this.renderUsage()}renderChannels(t){t&&(this.channels=t),this.channels.some(s=>s.id===this.channel)||(this.channel="general",this.thread=null,this.chat&&setTimeout(()=>this.paintChat()));const e=X("channels"),n=e.querySelector(".new-channel");e.innerHTML=this.channels.map(s=>{const r=this.unread.get(s.id)||0,a=s.id===this.channel,o=(s.members||[]).map(c=>this.app.person(c).name).join(", "),l=`#${s.name}${s.purpose?` — ${s.purpose}`:""}${o?`
|
|
4428
|
+
In it: ${o}`:""}`;return`<button type="button" role="tab" aria-selected="${a}" class="channel ${a?"on":""}" data-channel="${nt(s.id)}" title="${nt(l)}">
|
|
4429
|
+
<span class="hash">#</span>${nt(s.name)}${r&&!a?`<span class="badge">${r>99?"99+":r}</span>`:""}</button>`}).join("")+(this.channel==="general"?"":`<button type="button" class="channel close" data-close-channel="${nt(this.channel)}" aria-label="Close this channel" title="Close this channel">×</button>`)+'<button type="button" class="channel add" data-new-channel aria-label="New channel" title="New channel">+</button>',n&&e.append(n),this.setPlaceholder()}setPlaceholder(){Gt.on||(X("input").placeholder=`Message #${this.channel} · @agent #project`)}selectChannel(t){this.channels.some(e=>e.id===t)&&(this.channel=t,this.unread.delete(t),Zs("office.channel",t),this.thread=null,this.renderChannels(),this.paintChat(),this.tab("chat"))}bindChannels(){X("channels").onclick=t=>{const e=t.target.closest("[data-close-channel]");if(e)return this.deleteChannel(e.dataset.closeChannel);const n=t.target.closest("[data-channel]");if(n)return this.selectChannel(n.dataset.channel);t.target.closest("[data-new-channel]")&&this.newChannel()}}newChannel(){const t=X("channels");if(t.querySelector(".new-channel"))return t.querySelector(".new-channel input").focus();const e=document.createElement("form");e.className="new-channel",e.innerHTML='<span class="hash">#</span><input maxlength="24" placeholder="new-channel" aria-label="Channel name" />';const n=()=>e.remove();e.onsubmit=async s=>{s.preventDefault();const r=e.querySelector("input").value.trim();if(!r)return n();try{const a=await Xe("/api/channels",{name:r});n(),this.selectChannel(a.id)}catch(a){this.toast(a.message,"bad"),e.querySelector("input").select()}},e.querySelector("input").onkeydown=s=>{s.key==="Escape"&&(s.preventDefault(),n())},e.querySelector("input").onblur=()=>setTimeout(()=>{var s;(s=e.querySelector("input"))!=null&&s.value.trim()||n()},120),t.append(e),e.querySelector("input").focus()}async deleteChannel(t){try{await Xe(`/api/channels/${encodeURIComponent(t)}`,void 0,"DELETE"),this.toast(`#${t} closed`,"good")}catch(e){this.toast(e.message,"bad")}}mobile(t){X("app").dataset.m=t==="office"?"office":"side",t==="chat"&&(X("mChatDot").hidden=!0),document.querySelectorAll("#mnav button").forEach(e=>e.classList.toggle("on",e.dataset.m===t))}tab(t){this.mobile(t),document.querySelectorAll(".tabs button").forEach(e=>e.classList.toggle("on",e.dataset.tab===t)),X("chatPane").hidden=t!=="chat"||!!this.thread,X("threadPane").hidden=t!=="chat"||!this.thread,X("jobsPane").hidden=t!=="jobs",X("teamPane").hidden=t!=="team",X("projectsPane").hidden=t!=="projects",t==="team"&&this.renderTeam(),t==="projects"&&this.loadProjects(),t==="chat"&&this.scrollChat(!0)}focusInput(t=""){this.thread=null,this.tab("chat");const e=X("input");t&&!e.value.includes(t.trim())&&(e.value=t+e.value),e.focus(),e.setSelectionRange(e.value.length,e.value.length),this.autosize()}bindChat(){const t=X("input");for(const n of["mode","model"]){const s=Zs(`office.${n}`);s!==null&&[...X(n).options].some(r=>r.value===s)&&(X(n).value=s),X(n).onchange=()=>Zs(`office.${n}`,X(n).value)}X("composer").onsubmit=n=>{n.preventDefault(),this.send()},this.tray=new Fd(X("tray"),n=>this.toast(n,"bad")),zd(this.tray,{zone:X("composer"),input:t,picker:X("file"),button:X("attach")}),this.bindVoice(),t.oninput=()=>{this.autosize(),this.suggest()},t.onclick=()=>this.suggest(),t.onblur=()=>setTimeout(()=>X("ac").hidden=!0,120),t.onkeydown=n=>{const s=X("ac");if(!s.hidden){const r=[...s.children],a=r.findIndex(o=>o.classList.contains("on"));if(n.key==="ArrowDown"||n.key==="ArrowUp"){n.preventDefault();const o=(a+(n.key==="ArrowDown"?1:-1)+r.length)%r.length;r.forEach((l,c)=>l.classList.toggle("on",c===o));return}if(n.key==="Enter"||n.key==="Tab"){n.preventDefault(),this.pick(r[Math.max(0,a)]);return}if(n.key==="Escape"){n.preventDefault(),s.hidden=!0;return}}n.key==="Enter"&&!n.shiftKey&&!n.isComposing&&(n.preventDefault(),this.send())},X("ac").onmousedown=n=>{const s=n.target.closest("[data-insert]");s&&(n.preventDefault(),this.pick(s))};const e=X("threadInput");X("threadComposer").onsubmit=n=>{n.preventDefault(),this.sendThread()},X("threadBack").onclick=()=>this.closeThread(),e.oninput=()=>this.autosize(e),e.onkeydown=n=>{if(n.key==="Escape"){n.preventDefault(),this.closeThread();return}n.key==="Enter"&&!n.shiftKey&&!n.isComposing&&(n.preventDefault(),this.sendThread())},X("msgs").onclick=X("threadMsgs").onclick=n=>{const s=n.target.closest("[data-thread]");if(s)return this.openThread(s.dataset.thread);const r=n.target.closest("[data-pick]");if(r)return this.openPicker(r);const a=n.target.closest("[data-react]");if(a)return this.react(a.closest(".msg").dataset.id,a.dataset.react);const o=n.target.closest("[data-say]");if(o){const u=this.chat.get(o.closest(".msg").dataset.id);li.stop(),u&&li.speak(u.text,u.from,{force:!0});return}const l=n.target.closest("[data-open]");if(l)return this.app.openJob(l.dataset.open);const c=n.target.closest("[data-more]");if(c){c.closest(".msg").classList.add("full"),c.remove();return}const h=n.target.closest("[data-grant]");h&&Xe(`/api/jobs/${h.dataset.grant}/reply`,{message:"You now have permission to run the commands that were blocked. Carry on from where you stopped.",mode:"auto"}).then(()=>h.remove(),u=>this.toast(u.message,"bad"))}}autosize(t=X("input")){t.style.height="auto",t.style.height=Math.min(t.scrollHeight,140)+"px"}bindVoice(){const t=X("mic"),e=X("rec"),n=X("recText");if(!ni.supported){t.hidden=!0;return}let s=null;const r=h=>{e.hidden=h==="idle",e.classList.toggle("working",h==="working"),t.classList.toggle("on",h==="recording"),t.disabled=h==="working",X("recStop").hidden=X("recDrop").hidden=h!=="recording",h==="working"&&(n.textContent="Transcribing…")},a=()=>{const h=Math.floor((Date.now()-ni.startedAt)/1e3);n.textContent=`Recording ${Math.floor(h/60)}:${String(h%60).padStart(2,"0")}`},o=async()=>{const h=this.app.voice;if(h&&!h.ok)return this.toast(h.reason,"bad");try{await ni.start()}catch(u){return this.toast(u.name==="NotAllowedError"?"The browser is blocking the microphone. Allow it for this page and try again.":`No microphone here: ${u.message}`,"bad")}li.stop(),r("recording"),a(),s=setInterval(a,500)},l=async()=>{clearInterval(s);const h=await ni.stop();if(!h)return r("idle");r("working");try{const u=rb(h),d=await fetch("/api/voice",{method:"POST",headers:{"x-file-name":encodeURIComponent(u.name),"content-type":u.type||"audio/webm"},body:u}),f=await d.json().catch(()=>({}));if(!d.ok)throw new Error(f.error||`Transcribing failed (${d.status})`);this.tray.attach(f);const g=X("input");f.text?g.value=g.value.trim()?`${g.value.trim()} ${f.text}`:f.text:this.toast("I couldn't make out any words in that one — it's attached if you want to send it anyway.","bad"),g.focus(),g.setSelectionRange(g.value.length,g.value.length),this.autosize()}catch(u){this.toast(u.message,"bad")}r("idle")},c=()=>{clearInterval(s),ni.cancel(),r("idle")};t.onclick=()=>ni.active?l():o(),X("recStop").onclick=l,X("recDrop").onclick=c,addEventListener("keydown",h=>{if(h.key==="Escape"&&ni.active)return h.preventDefault(),c();h.altKey&&/^(m|µ)$/i.test(h.key)&&(h.preventDefault(),ni.active?l():o())}),r("idle")}async send(){const t=X("input"),e=t.value.trim();if(!(!e&&this.tray.empty||this.sending)){this.sending=!0,t.value="",this.autosize(),X("ac").hidden=!0;try{const n=await this.tray.ids();if(!e&&!n.length)return;if(Gt.on){const s=await am({text:e,mode:X("mode").value,model:X("model").value});s&&(this.app.jobs.set(s.id,s),this.app.refreshLists(),this.app.openJob(s.id));return}await Xe("/api/chat",{text:e,files:n,channel:this.channel,mode:X("mode").value,model:X("model").value}),this.tray.clear()}catch(n){t.value=e,this.toast(n.message,"bad")}finally{this.sending=!1}}}async suggest(){const t=X("input"),n=t.value.slice(0,t.selectionStart).match(/(^|\s)([@#])([\w.-]*)$/),s=X("ac");if(!n){s.hidden=!0;return}const[,,r,a]=n,o=a.toLowerCase().replace(/[^a-z0-9]/g,"");let l;if(r==="@")l=this.app.roster().map(c=>({insert:`@${c.name}`,label:c.name,note:c.note,dot:c.color}));else{if(!this.repos)try{this.repos=ru((await Xe("/api/repos")).repos)}catch{this.repos=[]}l=this.repos.map(c=>({insert:`#${c.replace(/\s+/g,"-")}`,label:c,note:this.app.busyIn(c)}))}if(l=l.filter(c=>c.label.toLowerCase().replace(/[^a-z0-9]/g,"").includes(o)).sort((c,h)=>c.label.toLowerCase().replace(/[^a-z0-9]/g,"").indexOf(o)-h.label.toLowerCase().replace(/[^a-z0-9]/g,"").indexOf(o)).slice(0,8),!l.length){s.hidden=!0;return}s.innerHTML=l.map((c,h)=>`
|
|
4430
|
+
<div class="item ${h===0?"on":""}" data-insert="${nt(c.insert)}" data-len="${a.length+1}">
|
|
4431
|
+
${c.dot?`<i style="background:${gr(c.dot)}"></i>`:'<i class="hash">#</i>'}
|
|
4432
|
+
<span>${nt(c.label)}</span>${c.note?`<em>${nt(c.note)}</em>`:""}
|
|
4433
|
+
</div>`).join(""),s.hidden=!1}pick(t){if(!t)return;const e=X("input"),n=e.selectionStart,s=n-Number(t.dataset.len);e.value=e.value.slice(0,s)+t.dataset.insert+" "+e.value.slice(n);const r=s+t.dataset.insert.length+1;e.setSelectionRange(r,r),X("ac").hidden=!0,e.focus()}renderChat(t){this.chat=new Map(t.map(e=>[e.id,e])),this.unread.clear(),this.renderChannels(),this.paintChat()}paintChat(){var e,n;const t=[...this.chat.values()].filter(s=>this.here(s)&&!this.inThread(s));X("msgs").innerHTML=t.length?t.map(s=>this.message(s)).join(""):`<p class="empty">${Gt.on?`Start a job${Gt.host?` at @${nt(Gt.host)}`:""}: say what you need and tag ${((e=Gt.repos)==null?void 0:e.length)===1?"the project":"one of your projects"} with #${(n=Gt.repos)!=null&&n.length?` (${Gt.repos.map(s=>nt(`#${s.replace(/\s+/g,"-")}`)).join(", ")})`:""}. Only your own jobs show here.`:this.channel==="general"?"Tell the office what you need. Tag someone with @, or a project with #. The chief of staff hands everything else to whoever fits.":`Nothing in #${nt(this.channel)} yet. Whatever you ask for here stays here.`}</p>`,this.scrollChat(!0),this.thread&&this.renderThread()}here(t){return(t.channel||"general")===this.channel}inThread(t){return!!t.thread&&this.chat.has(t.thread)}replies(t){return[...this.chat.values()].filter(e=>e.thread===t)}addMessage(t){var s;if(this.chat.set(t.id,t),t.from!=="you"&&X("app").dataset.m==="office"&&(X("mChatDot").hidden=!1),!this.here(t)){const r=t.channel||"general";this.unread.set(r,(this.unread.get(r)||0)+1),this.renderChannels();return}if(this.inThread(t)){if(this.updateThreadSum(t.thread),this.thread===t.thread){const r=X("threadMsgs");r.insertAdjacentHTML("beforeend",this.message(t,!0)),r.querySelector(".thread-count").textContent=this.countLabel(this.replies(t.thread).length),requestAnimationFrame(()=>r.scrollTop=r.scrollHeight)}return}const e=X("msgs"),n=e.scrollHeight-e.scrollTop-e.clientHeight<80;(s=e.querySelector(".empty"))==null||s.remove(),e.insertAdjacentHTML("beforeend",this.message(t)),(n||t.from==="you")&&this.scrollChat(!0)}scrollChat(){const t=X("msgs");requestAnimationFrame(()=>t.scrollTop=t.scrollHeight)}openThread(t){if(!this.chat.has(t))return;const e=this.chat.get(t);this.here(e)||this.selectChannel(e.channel||"general"),this.thread=t,this.renderThread(),this.tab("chat"),X("threadInput").focus()}closeThread(){this.thread=null,this.tab("chat"),X("input").focus()}renderThread(){const t=this.chat.get(this.thread);if(!t)return this.closeThread();const e=this.replies(t.id);X("threadWhere").textContent=`Thread on ${this.app.person(t.from).name}'s message · #${t.channel||"general"}`;const n=X("threadMsgs");n.innerHTML=this.message(t,!0)+`<p class="thread-count">${this.countLabel(e.length)}</p>`+e.map(s=>this.message(s,!0)).join(""),requestAnimationFrame(()=>n.scrollTop=n.scrollHeight)}countLabel(t){return t?`${t} ${t===1?"reply":"replies"}`:"No replies yet"}updateThreadSum(t){var n;const e=X("msgs").querySelector(`.msg[data-id="${CSS.escape(t)}"]`);e&&((n=e.querySelector(".thread-sum"))==null||n.remove(),e.querySelector(".reacts").insertAdjacentHTML("beforebegin",this.threadSum(this.chat.get(t))))}threadSum(t){const e=this.replies(t.id);if(!e.length)return"";const n=e.at(-1),s=[...new Set(e.map(a=>a.from))].slice(-3).map(a=>Xl(this.app.person(a))).join(""),r=n.text.replace(/[*_`#>]/g,"").replace(/\s+/g," ").trim();return`
|
|
4434
|
+
<button type="button" class="thread-sum" data-thread="${nt(t.id)}">
|
|
4421
4435
|
<span class="faces">${s}</span><b>${this.countLabel(e.length)}</b>
|
|
4422
|
-
<span class="last">${
|
|
4423
|
-
</button>`}async sendThread(){const t=
|
|
4424
|
-
<div data-id="${
|
|
4425
|
-
<div class="who"
|
|
4426
|
-
${t.kind==="handoff"?`<p class="kind">Handed off · ${
|
|
4436
|
+
<span class="last">${nt(this.app.person(n.from).name)}: ${nt(r.length>70?r.slice(0,69)+"…":r)}</span>
|
|
4437
|
+
</button>`}async sendThread(){const t=X("threadInput"),e=t.value.trim();if(!(!e||this.sending||!this.thread)){this.sending=!0,t.value="",this.autosize(t);try{await Xe("/api/chat",{text:e,thread:this.thread,mode:X("mode").value,model:X("model").value})}catch(n){t.value=e,this.toast(n.message,"bad")}finally{this.sending=!1}}}message(t,e=!1){var h,u,d;const n=this.app.person(t.from),s=t.to&&this.app.person(t.to),r=new Date(t.ts).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}),a=t.from==="you"?`<p>${nt(t.text).replace(/(^|\s)([@#][\w.-]+)/g,'$1<span class="tag">$2</span>')}</p>`:Vl(t.text),o=t.from!=="you"&&t.from!=="chief"&&!t.to&&t.text.length>420,l=t.project||t.jobId&&((h=this.app.jobs.get(t.jobId))==null?void 0:h.repo)||"",c=[o?`<button type="button" class="icon" data-more aria-label="Show all" title="Show all">${Ya.more}</button>`:"",t.jobId&&t.from!=="you"?`<button type="button" class="icon" data-open="${t.jobId}" aria-label="Open job" title="Open job">${Ya.open}</button>`:"",!e&&t.threadOf&&this.chat.has(t.threadOf)?`<button type="button" class="link" data-thread="${nt(t.threadOf)}">Updates are in this thread →</button>`:"",e?"":`<button type="button" class="icon quiet" data-thread="${nt(t.id)}" aria-label="Reply in thread" title="Reply in thread">${Ya.reply}</button>`,t.from!=="you"&&t.text&&li.supported?`<button type="button" class="icon quiet" data-say aria-label="Read aloud" title="Read aloud">${Ya.speak}</button>`:"",(u=t.denials)!=null&&u.length?`<button type="button" class="primary small" data-grant="${t.jobId}">Grant full autonomy and continue</button>`:""].filter(Boolean).join("");return`
|
|
4438
|
+
<div data-id="${nt(t.id)}" class="msg from-${t.from==="you"?"you":t.from==="chief"?"chief":"agent"} ${t.kind||""} ${t.status||""} ${o?"clamp":""}">
|
|
4439
|
+
<div class="who">${Xl(n)}<b>${nt(n.name)}</b>${s?`<span class="arrow">→</span>${Xl(s)}<b>${nt(s.name)}</b>`:""}<time>${r}</time>${l?`<span class="ptag" title="Project: ${nt(l)}" role="img" aria-label="Project: ${nt(l)}">${Wl(l)}</span>`:""}</div>
|
|
4440
|
+
${t.kind==="handoff"?`<p class="kind">Handed off · ${nt(t.project||"")}</p>`:""}
|
|
4427
4441
|
${t.kind==="standup"&&t.from!=="chief"?'<p class="kind">Standup</p>':""}
|
|
4428
4442
|
${t.text?`<div class="body md">${a}</div>`:""}
|
|
4429
|
-
${
|
|
4430
|
-
${(
|
|
4431
|
-
${
|
|
4443
|
+
${Bd(t.files)}
|
|
4444
|
+
${(d=t.denials)!=null&&d.length?`<p class="blocked">Blocked from using ${t.denials.map(nt).join(", ")}.</p>`:""}
|
|
4445
|
+
${c?`<div class="acts">${c}</div>`:""}
|
|
4432
4446
|
${e?"":this.threadSum(t)}
|
|
4433
4447
|
${this.reactionRow(t)}
|
|
4434
|
-
</div>`}reactionRow(t){const e=Object.entries(t.reactions||{}),n=e.map(([s,r])=>{const a=r.map(o=>this.app.person(o).name).join(", ");return`<button type="button" class="pill ${r.includes("you")?"mine":""}" data-react="${
|
|
4435
|
-
<
|
|
4436
|
-
<
|
|
4437
|
-
<
|
|
4438
|
-
|
|
4439
|
-
<form data-id="${lt(a.id)}">
|
|
4440
|
-
<label>Role<input name="role" maxlength="80" value="${lt(a.role)}" placeholder="Backend engineer" /></label>
|
|
4441
|
-
<label>Personality<textarea name="personality" rows="3" maxlength="600" placeholder="How they come across: calm, chatty, blunt, funny…">${lt(a.personality)}</textarea></label>
|
|
4442
|
-
<label>Background<textarea name="background" rows="3" maxlength="600" placeholder="Where they've worked, what they know best">${lt(a.background)}</textarea></label>
|
|
4443
|
-
<p class="hint-t">Shapes how ${lt(a.name)} writes and who the chief sends their way. It never lowers the bar on the work.</p>
|
|
4448
|
+
</div>`}reactionRow(t){const e=Object.entries(t.reactions||{}),n=e.map(([s,r])=>{const a=r.map(o=>this.app.person(o).name).join(", ");return`<button type="button" class="pill ${r.includes("you")?"mine":""}" data-react="${nt(s)}" title="${nt(a)}">${nt(s)}<span>${r.length}</span></button>`}).join("");return`<div class="reacts ${e.length?"some":""}">${n}<button type="button" class="add" data-pick aria-label="Add reaction" aria-haspopup="dialog" title="React">☺︎+</button></div>`}react(t,e){Xe(`/api/chat/${t}/react`,{emoji:e}).catch(n=>this.toast(n.message,"bad"))}openPicker(t){var l;const e=t.closest(".msg").dataset.id;let n=X("emojiPicker");if((n==null?void 0:n.dataset.for)===e)return this.closePicker();n||(n=document.createElement("div"),n.id="emojiPicker",n.className="emoji-picker",n.setAttribute("role","dialog"),n.setAttribute("aria-label","Pick a reaction"),document.body.append(n),n.onclick=c=>{const h=c.target.closest("[data-emoji]");if(!h)return;const u=h.dataset.emoji,d=[u,...this.recentEmoji().filter(f=>f!==u)].slice(0,8);localStorage.setItem("office.recentEmoji",JSON.stringify(d)),this.react(n.dataset.for,u),this.closePicker()},document.addEventListener("pointerdown",c=>{!n.hidden&&!n.contains(c.target)&&!c.target.closest("[data-pick]")&&this.closePicker()}),document.addEventListener("keydown",c=>{c.key==="Escape"&&!n.hidden&&this.closePicker()}));const s=[["Recent",this.recentEmoji()],...ob];n.innerHTML=s.map(([c,h])=>`<p>${c}</p><div class="grid">${[...h].map(u=>`<button type="button" data-emoji="${nt(u)}">${nt(u)}</button>`).join("")}</div>`).join(""),n.dataset.for=e,n.hidden=!1;const r=t.getBoundingClientRect(),a=n.offsetWidth,o=n.offsetHeight;n.style.left=Math.max(8,Math.min(r.right-a,innerWidth-a-8))+"px",n.style.top=(r.bottom+o+8<innerHeight?r.bottom+6:Math.max(8,r.top-o-6))+"px",(l=n.querySelector("button"))==null||l.focus()}closePicker(){const t=X("emojiPicker");t&&(t.hidden=!0,t.dataset.for="")}recentEmoji(){try{return JSON.parse(localStorage.getItem("office.recentEmoji"))||kd}catch{return kd}}forget(t=[]){var e,n;for(const s of t){(e=this.chat)==null||e.delete(s);for(const r of[X("msgs"),X("threadMsgs")])(n=r.querySelector(`.msg[data-id="${CSS.escape(s)}"]`))==null||n.remove()}}addVoice(t,e){var a;const n=(a=this.chat)==null?void 0:a.get(t);n&&(n.files=[...n.files||[],e]);const s=n?n.files:[e];let r=null;for(const o of[X("msgs"),X("threadMsgs")]){const l=o.querySelector(`.msg[data-id="${CSS.escape(t)}"]`);if(!l)continue;const c=document.createRange().createContextualFragment(Bd(s)),h=l.querySelector(".files");h?h.replaceWith(c):(l.querySelector(".body")||l.querySelector(".who")).after(c),r=l}return(r==null?void 0:r.querySelector("audio.voice"))||null}setReactions(t,e){var s;const n=(s=this.chat)==null?void 0:s.get(t);n&&(n.reactions=e);for(const r of[X("msgs"),X("threadMsgs")]){const a=r.querySelector(`.msg[data-id="${CSS.escape(t)}"]`);a==null||a.querySelector(".reacts").replaceWith(document.createRange().createContextualFragment(this.reactionRow({reactions:e})))}}chiefBusy(t){X("typing").hidden=!t,t&&this.scrollChat()}toast(t,e="",n=null){const s=X("toast");if(s.textContent=t,n){const r=document.createElement("button");r.type="button",r.textContent=n.label,r.onclick=()=>{s.className="toast",n.run()},s.append(" ",r)}s.className=`toast show ${e} ${n?"act":""}`,clearTimeout(this.toastTimer),this.toastTimer=setTimeout(()=>s.className="toast",n?6e3:3200)}async post(t){try{const{text:e}=await Xe(t,{});e&&this.toast(e,"good")}catch(e){this.toast(e.message,"bad")}}bindTeam(){const t=X("team");t.onclick=e=>{var r;const n=e.target.closest("[data-member]");if(!n)return;const s=n.dataset.member;if(this.editing===s&&!this.dirty())this.editing=null;else if(this.editing!==s){if(this.dirty()&&!confirm("Discard your changes?"))return;this.editing=s}this.renderTeam(!0),(r=t.querySelector(".member.open input"))==null||r.focus()},t.onsubmit=async e=>{e.preventDefault();const n=e.target,s=n.querySelector("[type=submit]");s.disabled=!0;try{const r=await Xe(`/api/staff/${n.dataset.id}/profile`,Object.fromEntries(new FormData(n)));Object.assign(this.app.staff.find(a=>a.id===n.dataset.id)||{},r),this.toast(`Saved. ${this.app.staffName(n.dataset.id)} takes it from their next job.`,"good"),this.editing=null,this.renderTeam(!0)}catch(r){this.toast(r.message,"bad"),s.disabled=!1}},t.addEventListener("click",e=>{e.target.closest("[data-cancel]")&&(this.editing=null,this.renderTeam(!0))})}dirty(){const t=X("team").querySelector("form");if(!t)return!1;const e=this.app.staff.find(n=>n.id===t.dataset.id)||{};return["role","personality","background"].some(n=>t.elements[n].value.trim()!==(e[n]||""))}renderTeam(t=!1){if(X("teamPane").hidden||!t&&this.dirty())return;const{staff:e,progress:n,dismissed:s}=this.app,r=(n==null?void 0:n.capacity)||0,a=l=>`<form data-id="${nt(l.id)}">
|
|
4449
|
+
<label>Role<input name="role" maxlength="80" value="${nt(l.role)}" placeholder="Backend engineer" /></label>
|
|
4450
|
+
<label>Personality<textarea name="personality" rows="3" maxlength="600" placeholder="How they come across: calm, chatty, blunt, funny…">${nt(l.personality)}</textarea></label>
|
|
4451
|
+
<label>Background<textarea name="background" rows="3" maxlength="600" placeholder="Where they've worked, what they know best">${nt(l.background)}</textarea></label>
|
|
4452
|
+
<p class="hint-t">Shapes how ${nt(l.name)} writes and who the chief sends their way. It never lowers the bar on the work.</p>
|
|
4444
4453
|
<div class="row"><button type="button" class="ghost small" data-cancel>Cancel</button><button type="submit" class="primary small">Save</button></div>
|
|
4445
|
-
</form>
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
`),f.live=!1,this.renderTabs()},l.onData(m=>{u.readyState===WebSocket.OPEN&&u.send(JSON.stringify({t:"in",d:m}))}),l.onResize(g),l.onTitleChange(m=>{f.title=m,this.renderTabs()})}select(t){const e=this.sessions.find(n=>n.id===t);if(e){this.active=t;for(const n of this.sessions)n.el.classList.toggle("on",n===e);this.renderTabs(),this.fit(),this.focus()}}focus(){var t;(t=this.sessions.find(e=>e.id===this.active))==null||t.term.focus()}close(t){const e=this.sessions.findIndex(r=>r.id===t);if(e<0)return;const[n]=this.sessions.splice(e,1);try{n.ws.close()}catch{}if(n.term.dispose(),n.el.remove(),this.active!==t)return this.renderTabs();const s=this.sessions[e]||this.sessions[e-1];this.active=null,s?this.select(s.id):(this.renderTabs(),this.hide())}renderTabs(){we("termTabs").innerHTML=this.sessions.map(t=>{const e=[t.label,t.live?t.title:"the shell has exited"].filter(Boolean).join(" · ");return`<span class="term-tab${t.id===this.active?" on":""}${t.live?"":" dead"}">
|
|
4454
|
-
<button type="button" data-tab="${t.id}" role="tab" aria-selected="${t.id===this.active}" title="${vs(e)}">${vs(t.label)}</button>
|
|
4455
|
-
<button type="button" class="x" data-close="${t.id}" aria-label="Close ${vs(t.label)}">
|
|
4456
|
-
<svg viewBox="0 0 24 24"><path d="M6 18L18 6M6 6l12 12"/></svg>
|
|
4457
|
-
</button></span>`}).join("")}fit(){if(!this.open)return;const t=this.sessions.find(e=>e.id===this.active);if(!(!t||!t.el.clientHeight))try{t.fit.fit()}catch{}}}const vs=i=>String(i??"").replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t]);{const i=document.getElementById("app"),t=document.getElementById("side-grip"),e="office.sideWidth",n=320,s=24,r=()=>Math.max(n,Math.min(900,innerWidth-420)),a=u=>i.style.setProperty("--side-w",`${Math.round(Math.min(r(),Math.max(n,u)))}px`),o=Number(localStorage.getItem(e));o&&a(o);const l=()=>t.parentElement.getBoundingClientRect().width,c=()=>localStorage.setItem(e,String(Math.round(l())));t.addEventListener("pointerdown",u=>{t.setPointerCapture(u.pointerId),i.classList.add("resizing"),u.preventDefault()}),t.addEventListener("pointermove",u=>{t.hasPointerCapture(u.pointerId)&&a(u.clientX)});const h=u=>{t.hasPointerCapture(u.pointerId)&&(t.releasePointerCapture(u.pointerId),i.classList.remove("resizing"),c())};t.addEventListener("pointerup",h),t.addEventListener("pointercancel",h),t.addEventListener("dblclick",()=>{i.style.removeProperty("--side-w"),localStorage.removeItem(e)}),t.addEventListener("keydown",u=>{const d=u.key==="ArrowLeft"?-s:u.key==="ArrowRight"?s:0;d&&(u.preventDefault(),a(l()+d),c())})}{const i=document.getElementById("app"),t="office.sideZoom",e=.8,n=1.8,s=a=>(a=Math.round(Math.min(n,Math.max(e,a))*100)/100,i.style.setProperty("--side-zoom",String(a)),a===1?localStorage.removeItem(t):localStorage.setItem(t,String(a)),a);let r=Number(localStorage.getItem(t))||1;s(r),addEventListener("keydown",a=>{if(!(a.ctrlKey||a.metaKey)||a.altKey)return;const o=a.key;if(o==="+"||o==="=")r=s(r+.1);else if(o==="-"||o==="_")r=s(r-.1);else if(o==="0")r=s(1);else return;a.preventDefault()}),document.querySelector(".side").addEventListener("wheel",a=>{a.ctrlKey&&(a.preventDefault(),r=s(r-Math.sign(a.deltaY)*.05))},{passive:!1})}document.getElementById("view");const Ro=document.getElementById("stage"),$h=document.getElementById("labels"),Ve=new Ey({antialias:!0,alpha:!0});Ve.setClearColor(0,0);Ve.setPixelRatio(Math.min(devicePixelRatio,2));Ve.shadowMap.enabled=!0;Ve.shadowMap.type=pf;Ve.toneMapping=hh;Ve.toneMappingExposure=1;Ro.appendChild(Ve.domElement);const ti=new qf;ti.background=M1();ti.environment=new jc(Ve).fromScene(new hM,.04).texture;ti.environmentIntensity=.55;ti.add(new Gy("#fff8ef","#b9ab99",.55));const Ds=new jy("#fff0d8",1.75);Ds.position.set(-18,34,20);Ds.castShadow=!0;Ds.shadow.mapSize.set(4096,4096);Object.assign(Ds.shadow.camera,{left:-32,right:32,top:28,bottom:-28,near:1,far:100});Ds.shadow.bias=-3e-4;Ds.shadow.normalBias=.03;ti.add(Ds);const Me=new Cn(30,1,.5,400),Fe={target:new R(0,0,.5),radius:60,phi:.86,theta:Math.PI/4};Me.position.setFromSpherical(new wr(Fe.radius,Fe.phi,Fe.theta)).add(Fe.target);const Ae=new cM(Me,Ve.domElement);Ae.target.copy(Fe.target);Object.assign(Ae,{enableDamping:!0,dampingFactor:.09,minPolarAngle:.25,maxPolarAngle:1.22,minDistance:12,maxDistance:260,zoomToCursor:!0,rotateSpeed:.55,zoomSpeed:.9,panSpeed:1.1});const Tp=[];for(const i of[-20.3,20.3])for(const t of[-15.3,15.3])for(const e of[-.7,3])Tp.push(new R(i,e,t));function Ap(i,t,e){const n=Me.aspect<.9?1.7:.93,s=Me.clone();let r=15,a=260;for(let o=0;o<20;o++){const l=(r+a)/2;s.position.setFromSpherical(new wr(l,i,t)).add(e),s.lookAt(e),s.updateMatrixWorld(),Tp.every(h=>{const u=h.clone().project(s);return Math.abs(u.x)<n&&Math.abs(u.y)<.88})?a=l:r=l}return a}const Er=new gM(Ve,new Qn(1,1,{type:Ui,samples:4}));Er.addPass(new vM(ti,Me));const Ho=new ri(ti,Me,1,1);Ho.updateGtaoMaterial({radius:.9,distanceExponent:1.6,thickness:1.5,scale:1.1,samples:16});Ho.updatePdMaterial({lumaPhi:10,depthPhi:2,normalPhi:3,radius:6,rings:2,samples:16});Ho.blendIntensity=.85;Er.addPass(Ho);Er.addPass(new SM);function M1(){const i=document.createElement("canvas");i.width=512,i.height=512;const t=i.getContext("2d"),e=t.createRadialGradient(256,190,20,256,230,400);e.addColorStop(0,"#f7f3ec"),e.addColorStop(.6,"#ece5da"),e.addColorStop(1,"#d9d0c2"),t.fillStyle=e,t.fillRect(0,0,512,512);const n=new zi(i);return n.colorSpace=Ke,n}let ar=1,si=1,Vo=!1;function Cp(){const i=si;if(ar=Ro.clientWidth,si=Ro.clientHeight,Ve.setSize(ar,si,!1),Er.setPixelRatio(Math.min(devicePixelRatio,1.5)),Er.setSize(ar,si),Me.aspect=ar/si,Me.updateProjectionMatrix(),!Vo)Fe.radius=Ap(Fe.phi,Fe.theta,Fe.target),Me.position.setFromSpherical(new wr(Fe.radius,Fe.phi,Fe.theta)).add(Fe.target),Ae.target.copy(Fe.target);else if(i>1&&si>1&&si!==i){const t=Me.position.clone().sub(Ae.target),e=xs.clamp(t.length()*(si/i),Ae.minDistance,Ae.maxDistance);Me.position.copy(Ae.target).add(t.setLength(e))}}new ResizeObserver(Cp).observe(Ro);Cp();const Mn=$M(ti),Rp=new Ab(ti),Pp={id:"chief",name:"Chief",shirt:"#2b2d42",hair:"#8d8d8d",skin:"#a8714a"},tt={staff:[],chiefCost:0,modes:{},progress:null,jobs:new Map,agents:new Map,dismissed:new Set,selected:null,job:i=>tt.jobs.get(i),staffName:i=>{var t;return((t=tt.staff.find(e=>e.id===i))==null?void 0:t.name)||""},person:i=>{if(i==="you")return{name:"You",color:"#c9c1b4"};if(i==="chief")return{name:"Chief of Staff",color:Pp.shirt};const t=tt.staff.find(e=>e.id===i);return{name:(t==null?void 0:t.name)||i,color:(t==null?void 0:t.shirt)||"#999"}},onFloor:()=>{var i;return tt.staff.slice(0,((i=tt.progress)==null?void 0:i.capacity)||0).filter(t=>!tt.dismissed.has(t.id))},roster:()=>tt.onFloor().map(i=>{const t=[...tt.jobs.values()].find(e=>e.status==="working"&&e.agentId===i.id);return{name:i.name,color:i.shirt,note:t?`on ${t.repo}`:"free"}}),busyIn:i=>{const t=[...tt.jobs.values()].filter(e=>e.status==="working"&&e.repo===i).map(e=>tt.staffName(e.agentId));return t.length?`${t.join(", ")} here`:""}},Wh={scene:ti,...Mn,agentIndex:i=>tt.staff.findIndex(t=>t.id===i)},kt=new m1(tt);pm({toast:(i,t)=>kt.toast(i,t),renderOwner:i=>{Gt.on||kt.renderOwner(i)}});new y1({api:$e,toast:(i,t)=>kt.toast(i,t)});const xn=new Nh(Pp,Wh,$h,{desk:Mn.reception,face:0}),b1=new nb,S1=new Mb(ti,Mn),uo=new Tb({world:Wh,labels:$h,camera:Me,canvas:Ve.domElement});xn.want="desk";xn.teleport("desk");tt.mergeLog=i=>{const t=tt.jobs.get(i.id);t?t.log=i.log:tt.jobs.set(i.id,i)};tt.refreshLists=()=>{const i=[...tt.jobs.values()];kt.renderJobs(i,tt.staffName),kt.renderStats(i,tt.chiefCost),hp(Mn.board,i)};tt.openJob=i=>{kt.openDetail(i);const t=tt.jobs.get(i),e=(t==null?void 0:t.status)==="working"&&tt.agents.get(t.agentId);e&&(tt.select(e.id,!1),kp())};tt.select=(i,t=!0)=>{for(const r of tt.agents.values())r.setSelected(r.id===i);if(tt.selected=i,i||(Is=!1),!i||!t)return;const e=tt.agents.get(i);kp(),kt.focusInput(`@${e.name} `);const n=[...tt.jobs.values()].filter(r=>r.agentId===i),s=n.find(r=>r.status==="working")||n.sort((r,a)=>(a.endedAt||0)-(r.endedAt||0))[0];s&&kt.openDetail(s.id),(s==null?void 0:s.status)!=="working"&&kt.toast(`${e.name} is between jobs. Press N to give them one.`,"",{label:"Send home",run:()=>tt.dismiss(e.id)})};tt.dismiss=i=>!Gt.on&&kt.post(`/api/staff/${i}/dismiss`);tt.recall=i=>!Gt.on&&kt.post(`/api/staff/${i}/recall`);function Lp(i,t){tt.onFloor().forEach(e=>{const n=tt.agents.get(e.id);if(n){n.leaving&&n.stay();return}const s=new Nh(e,Wh,$h);tt.agents.set(e.id,s),i?s.teleport("lounge"):(s.teleport("door"),s.say(t||`Hi, I'm ${e.name}!`,"good",5e3))})}function Gd(i,t){tt.dismissed=new Set(i||[]);for(const e of tt.agents.values())!tt.dismissed.has(e.id)||e.leaving||e.job||(t?e.gone=!0:e.leave());Lp(t,"Back in!"),kt.renderAway(tt.staff.filter(e=>tt.dismissed.has(e.id))),kt.renderTeam()}function w1(i){var t,e;for(const n of tt.agents.values()){const s=[...tt.jobs.values()].find(r=>r.status==="working"&&r.agentId===n.id);s&&((t=n.job)==null?void 0:t.id)!==s.id?(n.assign(s,i),s.log.forEach(r=>n.onLog(r))):!s&&n.job&&n.finish(((e=tt.jobs.get(n.job.id))==null?void 0:e.status)||"stopped")}}function $d(i=[],t=!1){const e=Mn.standup;xn.meet(e[0],t),i.forEach((n,s)=>{var r;return(r=tt.agents.get(n))==null?void 0:r.meet(e[1+Math.round(s*(e.length-2)/Math.max(1,i.length-1))],t)}),tt.standupOn=!0,document.getElementById("standup").disabled=!0}function Wd(){xn.adjourn();for(const i of tt.agents.values())i.adjourn();tt.standupOn=!1,document.getElementById("standup").disabled=!1}let Ja=!0;function th(){const i=Gt.on?`/ws/visit/${encodeURIComponent(Gt.link)}`:"/ws",t=new WebSocket(`${location.protocol==="https:"?"wss":"ws"}://${location.host}${i}`);t.onmessage=e=>E1(JSON.parse(e.data)),t.onclose=e=>{const n=um(e.code);if(n!=null){n&&setTimeout(th,n);return}kt.toast("Lost the office line. Reconnecting…","bad"),setTimeout(th,1500)}}function E1(i){var t,e,n,s,r,a,o,l;if(!uo.handle(i)){if(i.t==="hello"){lm(i.visiting),tt.staff=i.staff,i.visiting||kt.renderOwner(i.owner),tt.voice=i.voice,yn=i.tts||yn,vr(),tt.modes=hm(i.modes),tt.progress=i.progress,tt.chiefCost=i.chiefCost||0,tt.jobs=new Map(i.jobs.map(h=>[h.id,h])),kt.renderChannels(i.channels||[{id:"general",name:"general"}]),kt.renderChat(i.chat||[]),kt.chiefBusy(i.chiefBusy),Gd(i.dismissed,Ja),w1(Ja),i.standup?$d(i.standup.who,Ja):tt.standupOn&&Wd(),Ja=!1,kt.renderLevel(tt.progress),kt.renderUsage(i.usage),Jl(i.auth),Yo(i.contextLimit),i.visiting||au(i),cu(i.leaderboard),_r(i.links),kt.renderProc(i.procs,i.machine),tt.refreshLists();const c=L1();Zc(Mn.scribble,c),kt.openId&&(tt.jobs.has(kt.openId)?kt.openDetail(kt.openId):kt.closeDetail())}else if(i.t==="job"){const c=tt.jobs.get(i.job.id),h={...i.job,log:(c==null?void 0:c.log)||[]};if(tt.jobs.set(h.id,h),h.status==="working"){const u=tt.agents.get(h.agentId);u&&((t=u.job)==null?void 0:t.id)!==h.id?u.assign(h):u&&(u.job=h)}else for(const u of tt.agents.values()){if(((e=u.job)==null?void 0:e.id)!==h.id)continue;const d=h.status==="done"&&!h.awaitingBoss;u.finish(d?"done":h.awaitingBoss?"waiting":h.status),d&&Rp.burst(u.pos,[u.staff.shirt,"#f2cc8f","#81b29a","#3d7ea6","#ffffff"]),d&&(cn.ship(),Yl(`${u.name} shipped`,h.title)),h.status==="failed"&&(cn.fail(),Yl(`${u.name} hit a wall`,h.title))}(c==null?void 0:c.status)!==h.status?(kt.openId===h.id&&kt.renderDetail(),h.awaitingBoss&&(c==null?void 0:c.status)==="working"?kt.toast(`${tt.staffName(h.agentId)} is waiting on you: “${h.title}”`,"warn"):h.status==="done"&&(c==null?void 0:c.status)==="working"&&kt.toast(`${tt.staffName(h.agentId)} shipped “${h.title}”`,"good"),h.status==="failed"&&(c==null?void 0:c.status)==="working"&&kt.toast(`${tt.staffName(h.agentId)} hit a wall on “${h.title}”`,"bad")):kt.openId===h.id&&((n=c==null?void 0:c.changes)==null?void 0:n.end)!==((s=h.changes)==null?void 0:s.end)&&kt.renderChanges(h),tt.refreshLists()}else if(i.t==="log"){const c=tt.jobs.get(i.jobId);if(!c)return;c.log.push(i.entry),c.log.length>600&&c.log.shift();for(const h of tt.agents.values())((r=h.job)==null?void 0:r.id)===c.id&&h.onLog(i.entry);i.entry.todos&&Zc(Mn.scribble,i.entry.todos),kt.appendLog(c.id,i.entry)}else if(i.t==="channels")kt.renderChannels(i.channels);else if(i.t==="chat"){kt.addMessage(i.msg);const c=tt.agents.get(i.msg.from),h=tt.agents.get(i.msg.to);if(c&&h&&(c.visit(h,i.msg.text),cn.knock()),P1(i.msg),i.msg.kind==="flag"&&(cn.knock(),Yl("The boss is needed",i.msg.text.replace(/\*\*/g,""))),i.msg.kind==="standup"){const u=i.msg.say||i.msg.text;(a=i.msg.from==="chief"?xn:c)==null||a.speak(u.length>90?u.slice(0,89)+"…":u)}else i.msg.from==="chief"&&(xn.job=null,xn.say(i.msg.text.length>90?i.msg.text.slice(0,89)+"…":i.msg.text,"",6e3))}else if(i.t==="forget")kt.forget(i.ids);else if(i.t==="voice"){const c=kt.addVoice(i.id,i.file);c&&yn.replies&&!ii.active&&!document.hidden&&c.play().catch(()=>{})}else if(i.t==="tts")yn={...yn,...i},vr();else if(i.t==="react")kt.setReactions(i.id,i.reactions);else if(i.t==="standup")i.phase==="start"?($d(i.who),kt.banner("Standup","Everyone to the whiteboard."),cn.knock()):Wd();else if(i.t==="chief")kt.chiefBusy(i.busy),i.busy?(xn.job={id:"routing"},xn.say("Reading your message…","thinking")):xn.job=null,i.cost!==void 0&&(tt.chiefCost=i.cost,tt.refreshLists());else if(i.t==="staff")Gd(i.dismissed,!1);else if(i.t==="profile"){const c=tt.staff.find(h=>h.id===i.id);c&&Object.assign(c,i.profile),kt.renderTeam()}else if(i.t==="auth")Jl(i.auth);else if(i.t==="contextLimit")Yo(i.contextLimit);else if(i.t==="settings")Yo(i.contextLimit),au(i);else if(i.t==="leaderboard")cu(i.leaderboard);else if(i.t==="links")_r(i);else if(i.t==="usage")kt.renderUsage(i.usage);else if(i.t==="proc")kt.renderProc(i.procs,i.machine);else if(i.t==="xp"){tt.progress=i.progress,kt.renderLevel(tt.progress);const c=tt.agents.get(i.agentId);if(c){const h=document.createElement("span");h.className="xpfloat",h.textContent=`+${i.gained} XP`,c.label.appendChild(h),setTimeout(()=>h.remove(),1800)}if(i.levelUp){setTimeout(()=>cn.levelUp(),700);const h=(o=tt.staff[tt.progress.capacity-1])==null?void 0:o.name,u=!tt.agents.has((l=tt.staff[tt.progress.capacity-1])==null?void 0:l.id);kt.banner(`Level ${tt.progress.level}`,u?`${h} just joined the office.`:"The office is fully staffed."),Lp(!1)}}}}let eh=0;function Yl(i,t){if(document.hidden){eh++,document.title=`(${eh}) Agent Office`;try{"Notification"in window&&Notification.permission==="granted"&&new Notification(i,{body:t,silent:!0})}catch{}}}document.addEventListener("visibilitychange",()=>{document.hidden||(eh=0,document.title="Agent Office")});document.getElementById("composer").addEventListener("submit",()=>{try{"Notification"in window&&Notification.permission==="default"&&Notification.requestPermission()}catch{}},{once:!0});const T1='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M11 5 6 9H3v6h3l5 4V5Z"/><path d="M15.5 8.5a5 5 0 0 1 0 7"/><path d="M18.5 5.5a9 9 0 0 1 0 13"/></svg>',A1='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M11 5 6 9H3v6h3l5 4V5Z"/><path d="m22 9-6 6"/><path d="m16 9 6 6"/></svg>',fo=document.getElementById("sound");function Dp(){fo.innerHTML=cn.muted?A1:T1;const i=cn.muted?"Sound off":"Sound on";fo.title=i,fo.setAttribute("aria-label",i)}fo.onclick=()=>{cn.setMuted(!cn.muted),Dp(),cn.muted||cn.ship()};Dp();const C1='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3a3 3 0 0 1 3 3v5a3 3 0 0 1-6 0V6a3 3 0 0 1 3-3z"/><path d="M5 11a7 7 0 0 0 14 0"/><path d="M12 18v3"/></svg>',R1='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M9 9V6a3 3 0 0 1 5.6-1.5M15 11a3 3 0 0 1-4.5 2.6"/><path d="M5 11a7 7 0 0 0 11 5.7M19 11v0"/><path d="M12 18v3"/><path d="m3 3 18 18"/></svg>',or=document.getElementById("speak");let yn={ok:!1,replies:!1};const Ip=()=>yn.ok?yn.replies:hi.on;function vr(){const i=Ip();or.innerHTML=i?C1:R1,or.classList.toggle("on",i);const t=i?yn.ok?"Agents reply with voice notes":"Replies read aloud":"Replies are silent";or.title=t,or.setAttribute("aria-label",t)}hi.supported||(or.hidden=!0);or.onclick=async()=>{const i=!Ip();if(!yn.ok){hi.setOn(i),vr(),i&&hi.speak("Voice on. I will read replies out as they land.","chief",{force:!0});return}yn={...yn,replies:i},vr();try{const t=await fetch("/api/voice/replies",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({on:i})});if(!t.ok)throw new Error((await t.json().catch(()=>({}))).error||`Request failed (${t.status})`)}catch(t){yn={...yn,replies:!i},vr(),kt.toast(t.message,"bad")}};vr();function P1(i){yn.ok||!hi.on||i.from==="you"||i.to||i.kind==="chill"||ii.active||hi.speak(i.text,i.from)}function L1(){let i=null;for(const t of tt.jobs.values())for(const e of t.log)e.todos&&(!i||e.ts>i.ts)&&(i=e);return(i==null?void 0:i.todos)||[]}const _n=new wr,D1=i=>i<.5?4*i*i*i:1-(-2*i+2)**3/2;let Ee=null,Is=!1;function kp(){Is=!0,Ee=null,Vo=!0}function Xh({target:i,radius:t,phi:e,theta:n},s=.7){_n.setFromVector3(Me.position.clone().sub(Ae.target)),Ee={t:0,dur:s,target0:Ae.target.clone(),target1:(i||Ae.target).clone().setY(0),r0:_n.radius,r1:t??_n.radius,p0:_n.phi,p1:e??_n.phi,th0:_n.theta,th1:n??_n.theta}}function Po(i){Vo=!0,_n.setFromVector3(Me.position.clone().sub(Ae.target));const t=Ee?Ee.th1:_n.theta;Xh({theta:t+i*Math.PI/4,target:Ee==null?void 0:Ee.target1},.55)}function Np(){Is=!1,_n.setFromVector3(Me.position.clone().sub(Ae.target));let i=Fe.theta;for(;i-_n.theta>Math.PI;)i-=Math.PI*2;for(;_n.theta-i>Math.PI;)i+=Math.PI*2;Xh({target:Fe.target,radius:Ap(Fe.phi,i,Fe.target),phi:Fe.phi,theta:i},.9)}Ae.addEventListener("start",()=>{Vo=!0,Ee=null,Is=!1,setTimeout(()=>{var i;return(i=document.querySelector(".hint"))==null?void 0:i.classList.add("gone")},5e3)});document.getElementById("turnLeft").onclick=()=>Po(-1);document.getElementById("turnRight").onclick=()=>Po(1);document.getElementById("recenter").onclick=()=>Np();document.getElementById("standup").onclick=()=>kt.post("/api/standup");const es=new Set;addEventListener("keydown",i=>{var e;if(/INPUT|TEXTAREA|SELECT/.test((e=document.activeElement)==null?void 0:e.tagName)||i.metaKey||i.ctrlKey)return;const t=i.key.toLowerCase();t==="q"?Po(-1):t==="e"?Po(1):t==="r"?Np():"wasd".includes(t)&&t.length===1&&(es.add(t),Ee=null,Is=!1)});addEventListener("keyup",i=>es.delete(i.key.toLowerCase()));addEventListener("blur",()=>es.clear());const Qa=new R,Kl=new R,Wn=new R;function I1(i){if(Ee){Ee.t=Math.min(1,Ee.t+i/Ee.dur);const n=D1(Ee.t),s=Ee.target0.clone().lerp(Ee.target1,n);_n.set(xs.lerp(Ee.r0,Ee.r1,n),xs.lerp(Ee.p0,Ee.p1,n),xs.lerp(Ee.th0,Ee.th1,n)),Ae.target.copy(s),Me.position.setFromSpherical(_n).add(s),Ee.t>=1&&(Ee=null)}Wn.set(0,0,0);const t=Is&&tt.agents.get(tt.selected);if(t&&Wn.set(t.pos.x-Ae.target.x,0,t.pos.z-Ae.target.z).multiplyScalar(Math.min(1,i*3)),es.size){Qa.subVectors(Ae.target,Me.position).setY(0).normalize(),Kl.crossVectors(Qa,Me.up).normalize();const n=.45*Me.position.distanceTo(Ae.target)*i;es.has("w")&&Wn.addScaledVector(Qa,n),es.has("s")&&Wn.addScaledVector(Qa,-n),es.has("d")&&Wn.addScaledVector(Kl,n),es.has("a")&&Wn.addScaledVector(Kl,-n)}Ae.target.add(Wn),Me.position.add(Wn),Ae.update();const e=Ae.target;Wn.set(xs.clamp(e.x,-19,19)-e.x,-e.y,xs.clamp(e.z,-14,14)-e.z),e.add(Wn),Me.position.add(Wn)}const Go=new np,Xd=new rt;function jh(i){const t=Ve.domElement.getBoundingClientRect();Xd.set((i.clientX-t.left)/t.width*2-1,-((i.clientY-t.top)/t.height)*2+1),Go.setFromCamera(Xd,Me)}const Up=()=>[...tt.agents.values(),xn].map(i=>i.root);let po=null;Ve.domElement.addEventListener("pointerdown",i=>{po=[i.clientX,i.clientY]});Ve.domElement.addEventListener("pointerup",i=>{if(!po||Math.hypot(i.clientX-po[0],i.clientY-po[1])>5||i.button!==0)return;jh(i);const t=Go.intersectObjects(Up(),!0)[0];t&&(t.object.userData.agentId==="chief"?(kt.focusInput(),xn.say("Tell me what you need.","",3e3)):tt.select(t.object.userData.agentId))});Ve.domElement.addEventListener("dblclick",i=>{jh(i);const t=Go.intersectObject(Mn.slab,!1)[0];t&&(Is=!1,Xh({target:t.point,radius:Math.min(Me.position.distanceTo(Ae.target),34)},.8))});Ve.domElement.addEventListener("contextmenu",i=>i.preventDefault());Ve.domElement.addEventListener("pointermove",i=>{i.buttons||(jh(i),Ve.domElement.style.cursor=Go.intersectObjects(Up(),!0).length?"pointer":"")});const jd=new ep;let qd=0,Yd=0;function k1(i){Mn.desks.forEach((t,e)=>{const n=tt.staff[e],s=n&&tt.agents.get(n.id),r=!s&&n&&tt.dismissed.has(n.id),a=s!=null&&s.job?"working":s?"break":r?"away":"open",o=a!=="open",l=`${(n==null?void 0:n.name)||""} ${a}`;if(t.plateKey!==l&&(t.plateKey=l,lp(t,{name:o?n.name:"Open desk",accent:o?n.shirt:"#7d8a9c",state:a})),s!=null&&s.job){vd(t,{title:s.job.repo,subtitle:s.job.title,lines:s.lines,accent:n.shirt,t:i}),t.idleKey=null;return}const c=s?`${n.name}`:r?`away ${n.name}`:"open";if(t.idleKey===c)return;t.idleKey=c;const h=tt.progress?e-1:0;vd(t,s?{idle:!0,title:n.name,subtitle:"on a break"}:r?{idle:!0,title:n.name,subtitle:"gone home"}:{idle:!0,title:"Open desk",subtitle:`hires at level ${h}`})})}let Kd=!1;function Op(){const i=Math.min(jd.getDelta(),.05),t=jd.elapsedTime;I1(i),Mn.updateWalls(Me,Ae.target,i);for(const s of tt.agents.values())s.update(i,t),s.gone&&(s.dispose(),tt.agents.delete(s.id),tt.selected===s.id&&tt.select(null));if(b1.update([...tt.agents.values()],t),S1.update([...tt.agents.values()],t,i),xn.update(i,t),uo.update(i,t),Rp.update(i),Mn.globe.rotation.y+=i*.4,(qd-=i)<=0&&(qd=.4,k1(t)),(Yd-=i)<=0){Yd=.15;for(const s of Mn.blinkers)Math.random()<.25&&(s.material.emissiveIntensity=Math.random()<.5?.15:1.4)}Er.render(i);const e=Me.position.distanceTo(Ae.target)>74,n=[];for(const s of[...tt.agents.values(),xn,...uo.list])e!==Kd&&(s.label.classList.toggle("far",e),s.labelDirty=!0),s.placeLabel(Me,ar,si),s.onScreen&&n.push(s);U1(n,i,t),uo.placeSign(ar,si),Kd=e,requestAnimationFrame(Op)}const N1=4,Zd=(i,t)=>i.left<t.right-1&&i.right>t.left+1&&i.top<t.bottom-1&&i.bottom>t.top+1;function U1(i,t,e){const n=[],s=r=>r.id===tt.selected?-1:r.depth;for(const r of[...i].sort((a,o)=>s(a)-s(o))){let a=0,o=!1;for(let h=0;h<2;h++){const u=Math.max(0,Math.min(o?140:80,r.anchorY-r.labelH-6));a=0;for(let d=0;d<10&&a<=u;d++){const f=r.labelBox(a),g=n.find(_=>Zd(_,f));if(!g)break;a+=f.bottom-g.top+N1}if(a<=u||o){a=Math.min(a,u);break}o=!0,r.setCrowded(!0,e)}o||r.setCrowded(!1,e),r.setLift(a,t);const l=r.labelBox(r.lift),c=n.some(h=>Zd(h,l));r.setBuried(c),c||n.push(l)}}hp(Mn.board,[]);Zc(Mn.scribble,[]);th();Op();
|
|
4454
|
+
</form>`,o=(l,c)=>c>=r?"Not hired yet":s.has(l.id)?"Gone home":"";if(this.view==="icons"){const l=e.find(c=>c.id===this.editing);X("team").innerHTML=`<div class="tiles">${e.map((c,h)=>{const u=o(c,h);return`<button type="button" class="tile${h>=r?" later":""}${c.id===this.editing?" open":""}" data-member="${nt(c.id)}" aria-expanded="${c.id===this.editing}" title="${nt(c.name)} · ${nt(c.role||"No role yet")}${u?` · ${u}`:""}">
|
|
4455
|
+
<span class="art">${bp(c)}</span>
|
|
4456
|
+
<span class="n">${nt(c.name)}</span>
|
|
4457
|
+
<span class="c">${u||nt(c.role||"No role yet")}</span>
|
|
4458
|
+
</button>`}).join("")}</div>${l?`<div class="member open">${a(l)}</div>`:""}`;return}X("team").innerHTML=e.map((l,c)=>{const h=o(l,c),u=this.editing===l.id,d=`<button type="button" class="head" data-member="${nt(l.id)}" aria-expanded="${u}">
|
|
4459
|
+
<i style="background:${gr(l.shirt)}"></i>
|
|
4460
|
+
<span class="n">${nt(l.name)}${h?` <em>${h}</em>`:""}</span>
|
|
4461
|
+
<span class="r">${nt(l.role||"No role yet")}</span>
|
|
4462
|
+
</button>`;return u?`<div class="member open">${d}${a(l)}</div>`:`<div class="member${c>=r?" later":""}">${d}${l.personality?`<p class="p">${nt(l.personality)}</p>`:""}</div>`}).join("")}renderAway(t){const e=X("away");e.hidden=!t.length,e.innerHTML=t.length?`<span>Gone home</span>${t.map(n=>`<button type="button" data-recall="${nt(n.id)}" title="Call ${nt(n.name)} back"><i style="background:${gr(n.shirt)}"></i>${nt(n.name)}</button>`).join("")}`:""}banner(t,e){const n=X("banner");n.innerHTML=`<b>${nt(t)}</b><span>${nt(e)}</span>`,n.classList.remove("show"),n.offsetWidth,n.classList.add("show")}}{const i=document.getElementById("app"),t=document.getElementById("side-grip"),e="office.sideWidth",n=320,s=24,r=()=>Math.max(n,Math.min(900,innerWidth-420)),a=u=>i.style.setProperty("--side-w",`${Math.round(Math.min(r(),Math.max(n,u)))}px`),o=Number(localStorage.getItem(e));o&&a(o);const l=()=>t.parentElement.getBoundingClientRect().width,c=()=>localStorage.setItem(e,String(Math.round(l())));t.addEventListener("pointerdown",u=>{t.setPointerCapture(u.pointerId),i.classList.add("resizing"),u.preventDefault()}),t.addEventListener("pointermove",u=>{t.hasPointerCapture(u.pointerId)&&a(u.clientX)});const h=u=>{t.hasPointerCapture(u.pointerId)&&(t.releasePointerCapture(u.pointerId),i.classList.remove("resizing"),c())};t.addEventListener("pointerup",h),t.addEventListener("pointercancel",h),t.addEventListener("dblclick",()=>{i.style.removeProperty("--side-w"),localStorage.removeItem(e)}),t.addEventListener("keydown",u=>{const d=u.key==="ArrowLeft"?-s:u.key==="ArrowRight"?s:0;d&&(u.preventDefault(),a(l()+d),c())})}{const i=document.getElementById("app"),t="office.sideZoom",e=.8,n=1.8,s=a=>(a=Math.round(Math.min(n,Math.max(e,a))*100)/100,i.style.setProperty("--side-zoom",String(a)),a===1?localStorage.removeItem(t):localStorage.setItem(t,String(a)),a);let r=Number(localStorage.getItem(t))||1;s(r),addEventListener("keydown",a=>{if(!(a.ctrlKey||a.metaKey)||a.altKey)return;const o=a.key;if(o==="+"||o==="=")r=s(r+.1);else if(o==="-"||o==="_")r=s(r-.1);else if(o==="0")r=s(1);else return;a.preventDefault()}),document.querySelector(".side").addEventListener("wheel",a=>{a.ctrlKey&&(a.preventDefault(),r=s(r-Math.sign(a.deltaY)*.05))},{passive:!1})}document.getElementById("view");const Ao=document.getElementById("stage"),Wh=document.getElementById("labels"),He=new by({antialias:!0,alpha:!0});He.setClearColor(0,0);He.setPixelRatio(Math.min(devicePixelRatio,2));He.shadowMap.enabled=!0;He.shadowMap.type=df;He.toneMapping=ch;He.toneMappingExposure=1;Ao.appendChild(He.domElement);const Qn=new Xf;Qn.background=pb();Qn.environment=new Wc(He).fromScene(new oM,.04).texture;Qn.environmentIntensity=.55;Qn.add(new By("#fff8ef","#b9ab99",.55));const Cs=new $y("#fff0d8",1.75);Cs.position.set(-18,34,20);Cs.castShadow=!0;Cs.shadow.mapSize.set(4096,4096);Object.assign(Cs.shadow.camera,{left:-32,right:32,top:28,bottom:-28,near:1,far:100});Cs.shadow.bias=-3e-4;Cs.shadow.normalBias=.03;Qn.add(Cs);const Ee=new An(30,1,.5,400),Oe={target:new R(0,0,.5),radius:60,phi:.86,theta:Math.PI/4};Ee.position.setFromSpherical(new wr(Oe.radius,Oe.phi,Oe.theta)).add(Oe.target);const Ne=new aM(Ee,He.domElement);Ne.target.copy(Oe.target);Object.assign(Ne,{enableDamping:!0,dampingFactor:.09,minPolarAngle:.25,maxPolarAngle:1.22,minDistance:12,maxDistance:260,zoomToCursor:!0,rotateSpeed:.55,zoomSpeed:.9,panSpeed:1.1});const wp=[];for(const i of[-20.3,20.3])for(const t of[-15.3,15.3])for(const e of[-.7,3])wp.push(new R(i,e,t));function Ep(i,t,e){const n=Ee.aspect<.9?1.7:.93,s=Ee.clone();let r=15,a=260;for(let o=0;o<20;o++){const l=(r+a)/2;s.position.setFromSpherical(new wr(l,i,t)).add(e),s.lookAt(e),s.updateMatrixWorld(),wp.every(h=>{const u=h.clone().project(s);return Math.abs(u.x)<n&&Math.abs(u.y)<.88})?a=l:r=l}return a}const Er=new fM(He,new Jn(1,1,{type:Ni,samples:4}));Er.addPass(new pM(Qn,Ee));const zo=new ii(Qn,Ee,1,1);zo.updateGtaoMaterial({radius:.9,distanceExponent:1.6,thickness:1.5,scale:1.1,samples:16});zo.updatePdMaterial({lumaPhi:10,depthPhi:2,normalPhi:3,radius:6,rings:2,samples:16});zo.blendIntensity=.85;Er.addPass(zo);Er.addPass(new yM);function pb(){const i=document.createElement("canvas");i.width=512,i.height=512;const t=i.getContext("2d"),e=t.createRadialGradient(256,190,20,256,230,400);e.addColorStop(0,"#f7f3ec"),e.addColorStop(.6,"#ece5da"),e.addColorStop(1,"#d9d0c2"),t.fillStyle=e,t.fillRect(0,0,512,512);const n=new Fi(i);return n.colorSpace=Ye,n}let sr=1,rr=1,Bo=!1;function Tp(){sr=Ao.clientWidth,rr=Ao.clientHeight,He.setSize(sr,rr,!1),Er.setPixelRatio(Math.min(devicePixelRatio,1.5)),Er.setSize(sr,rr),Ee.aspect=sr/rr,Ee.updateProjectionMatrix(),Bo||(Oe.radius=Ep(Oe.phi,Oe.theta,Oe.target),Ee.position.setFromSpherical(new wr(Oe.radius,Oe.phi,Oe.theta)).add(Oe.target),Ne.target.copy(Oe.target))}new ResizeObserver(Tp).observe(Ao);Tp();const yn=HM(Qn),Ap=new w1(Qn),Jc={id:"chief",name:"Chief",shirt:"#2b2d42",hair:"#8d8d8d",skin:"#a8714a"},tt={staff:[],chiefCost:0,modes:{},progress:null,jobs:new Map,agents:new Map,dismissed:new Set,selected:null,job:i=>tt.jobs.get(i),staffName:i=>{var t;return((t=tt.staff.find(e=>e.id===i))==null?void 0:t.name)||""},person:i=>{if(i==="you")return{name:"You",color:"#c9c1b4"};if(i==="chief")return{name:"Chief of Staff",color:Jc.shirt,look:Jc};const t=tt.staff.find(e=>e.id===i);return{name:(t==null?void 0:t.name)||i,color:(t==null?void 0:t.shirt)||"#999",look:t}},onFloor:()=>{var i;return tt.staff.slice(0,((i=tt.progress)==null?void 0:i.capacity)||0).filter(t=>!tt.dismissed.has(t.id))},roster:()=>tt.onFloor().map(i=>{const t=[...tt.jobs.values()].find(e=>e.status==="working"&&e.agentId===i.id);return{name:i.name,color:i.shirt,note:t?`on ${t.repo}`:"free"}}),busyIn:i=>{const t=[...tt.jobs.values()].filter(e=>e.status==="working"&&e.repo===i).map(e=>tt.staffName(e.agentId));return t.length?`${t.join(", ")} here`:""}},Xh={scene:Qn,...yn,agentIndex:i=>tt.staff.findIndex(t=>t.id===i)},Nt=new fb(tt);um({toast:(i,t)=>Nt.toast(i,t),renderOwner:i=>{Gt.on||Nt.renderOwner(i)}});const _n=new Nh(Jc,Xh,Wh,{desk:yn.reception,face:0}),mb=new QM,gb=new _1(Qn,yn),co=new S1({world:Xh,labels:Wh,camera:Ee,canvas:He.domElement});_n.want="desk";_n.teleport("desk");tt.mergeLog=i=>{const t=tt.jobs.get(i.id);t?t.log=i.log:tt.jobs.set(i.id,i)};tt.refreshLists=()=>{const i=[...tt.jobs.values()];Nt.renderJobs(i,tt.staffName),Nt.renderStats(i,tt.chiefCost),op(yn.board,i)};tt.openJob=i=>{Nt.openDetail(i);const t=tt.jobs.get(i),e=(t==null?void 0:t.status)==="working"&&tt.agents.get(t.agentId);e&&(tt.select(e.id,!1),Lp())};tt.select=(i,t=!0)=>{for(const r of tt.agents.values())r.setSelected(r.id===i);if(tt.selected=i,i||(Rs=!1),!i||!t)return;const e=tt.agents.get(i);Lp(),Nt.focusInput(`@${e.name} `);const n=[...tt.jobs.values()].filter(r=>r.agentId===i),s=n.find(r=>r.status==="working")||n.sort((r,a)=>(a.endedAt||0)-(r.endedAt||0))[0];s&&Nt.openDetail(s.id),(s==null?void 0:s.status)!=="working"&&Nt.toast(`${e.name} is between jobs. Press N to give them one.`,"",{label:"Send home",run:()=>tt.dismiss(e.id)})};tt.dismiss=i=>!Gt.on&&Nt.post(`/api/staff/${i}/dismiss`);tt.recall=i=>!Gt.on&&Nt.post(`/api/staff/${i}/recall`);function Cp(i,t){tt.onFloor().forEach(e=>{const n=tt.agents.get(e.id);if(n){n.leaving&&n.stay();return}const s=new Nh(e,Xh,Wh);tt.agents.set(e.id,s),i?s.teleport("lounge"):(s.teleport("door"),s.say(t||`Hi, I'm ${e.name}!`,"good",5e3))})}function Hd(i,t){tt.dismissed=new Set(i||[]);for(const e of tt.agents.values())!tt.dismissed.has(e.id)||e.leaving||e.job||(t?e.gone=!0:e.leave());Cp(t,"Back in!"),Nt.renderAway(tt.staff.filter(e=>tt.dismissed.has(e.id))),Nt.renderTeam()}function vb(i){var t,e;for(const n of tt.agents.values()){const s=[...tt.jobs.values()].find(r=>r.status==="working"&&r.agentId===n.id);s&&((t=n.job)==null?void 0:t.id)!==s.id?(n.assign(s,i),s.log.forEach(r=>n.onLog(r))):!s&&n.job&&n.finish(((e=tt.jobs.get(n.job.id))==null?void 0:e.status)||"stopped")}}function Vd(i=[],t=!1){const e=yn.standup;_n.meet(e[0],t),i.forEach((n,s)=>{var r;return(r=tt.agents.get(n))==null?void 0:r.meet(e[1+Math.round(s*(e.length-2)/Math.max(1,i.length-1))],t)}),tt.standupOn=!0,document.getElementById("standup").disabled=!0}function Gd(){_n.adjourn();for(const i of tt.agents.values())i.adjourn();tt.standupOn=!1,document.getElementById("standup").disabled=!1}let Ka=!0;function Qc(){const i=Gt.on?`/ws/visit/${encodeURIComponent(Gt.link)}`:"/ws",t=new WebSocket(`${location.protocol==="https:"?"wss":"ws"}://${location.host}${i}`);t.onmessage=e=>_b(JSON.parse(e.data)),t.onclose=e=>{const n=lm(e.code);if(n!=null){n&&setTimeout(Qc,n);return}Nt.toast("Lost the office line. Reconnecting…","bad"),setTimeout(Qc,1500)}}function _b(i){var t,e,n,s,r,a,o,l;if(!co.handle(i)){if(i.t==="hello"){rm(i.visiting),tt.staff=i.staff,i.visiting||Nt.renderOwner(i.owner),tt.voice=i.voice,xn=i.tts||xn,vr(),tt.modes=om(i.modes),tt.progress=i.progress,tt.chiefCost=i.chiefCost||0,tt.jobs=new Map(i.jobs.map(h=>[h.id,h])),Nt.renderChannels(i.channels||[{id:"general",name:"general"}]),Nt.renderChat(i.chat||[]),Nt.chiefBusy(i.chiefBusy),Hd(i.dismissed,Ka),vb(Ka),i.standup?Vd(i.standup.who,Ka):tt.standupOn&&Gd(),Ka=!1,Nt.renderLevel(tt.progress),Nt.renderUsage(i.usage),Kl(i.auth),jo(i.contextLimit),i.visiting||ou(i),hu(i.leaderboard),_r(i.links),Nt.renderProc(i.procs,i.machine),tt.refreshLists();const c=wb();Yc(yn.scribble,c),Nt.openId&&(tt.jobs.has(Nt.openId)?Nt.openDetail(Nt.openId):Nt.closeDetail())}else if(i.t==="job"){const c=tt.jobs.get(i.job.id),h={...i.job,log:(c==null?void 0:c.log)||[]};if(tt.jobs.set(h.id,h),h.status==="working"){const u=tt.agents.get(h.agentId);u&&((t=u.job)==null?void 0:t.id)!==h.id?u.assign(h):u&&(u.job=h)}else for(const u of tt.agents.values()){if(((e=u.job)==null?void 0:e.id)!==h.id)continue;const d=h.status==="done"&&!h.awaitingBoss;u.finish(d?"done":h.awaitingBoss?"waiting":h.status),d&&Ap.burst(u.pos,[u.staff.shirt,"#f2cc8f","#81b29a","#3d7ea6","#ffffff"]),d&&(ln.ship(),jl(`${u.name} shipped`,h.title)),h.status==="failed"&&(ln.fail(),jl(`${u.name} hit a wall`,h.title))}(c==null?void 0:c.status)!==h.status?(Nt.openId===h.id&&Nt.renderDetail(),h.awaitingBoss&&(c==null?void 0:c.status)==="working"?Nt.toast(`${tt.staffName(h.agentId)} is waiting on you: “${h.title}”`,"warn"):h.status==="done"&&(c==null?void 0:c.status)==="working"&&Nt.toast(`${tt.staffName(h.agentId)} shipped “${h.title}”`,"good"),h.status==="failed"&&(c==null?void 0:c.status)==="working"&&Nt.toast(`${tt.staffName(h.agentId)} hit a wall on “${h.title}”`,"bad")):Nt.openId===h.id&&((n=c==null?void 0:c.changes)==null?void 0:n.end)!==((s=h.changes)==null?void 0:s.end)&&Nt.renderChanges(h),tt.refreshLists()}else if(i.t==="log"){const c=tt.jobs.get(i.jobId);if(!c)return;c.log.push(i.entry),c.log.length>600&&c.log.shift();for(const h of tt.agents.values())((r=h.job)==null?void 0:r.id)===c.id&&h.onLog(i.entry);i.entry.todos&&Yc(yn.scribble,i.entry.todos),Nt.appendLog(c.id,i.entry)}else if(i.t==="channels")Nt.renderChannels(i.channels);else if(i.t==="chat"){Nt.addMessage(i.msg);const c=tt.agents.get(i.msg.from),h=tt.agents.get(i.msg.to);if(c&&h&&(c.visit(h,i.msg.text),ln.knock()),Sb(i.msg),i.msg.kind==="flag"&&(ln.knock(),jl("The boss is needed",i.msg.text.replace(/\*\*/g,""))),i.msg.kind==="standup"){const u=i.msg.say||i.msg.text;(a=i.msg.from==="chief"?_n:c)==null||a.speak(u.length>90?u.slice(0,89)+"…":u)}else i.msg.from==="chief"&&(_n.job=null,_n.say(i.msg.text.length>90?i.msg.text.slice(0,89)+"…":i.msg.text,"",6e3))}else if(i.t==="forget")Nt.forget(i.ids);else if(i.t==="voice"){const c=Nt.addVoice(i.id,i.file);c&&xn.replies&&!ni.active&&!document.hidden&&c.play().catch(()=>{})}else if(i.t==="tts")xn={...xn,...i},vr();else if(i.t==="react")Nt.setReactions(i.id,i.reactions);else if(i.t==="standup")i.phase==="start"?(Vd(i.who),Nt.banner("Standup","Everyone to the whiteboard."),ln.knock()):Gd();else if(i.t==="chief")Nt.chiefBusy(i.busy),i.busy?(_n.job={id:"routing"},_n.say("Reading your message…","thinking")):_n.job=null,i.cost!==void 0&&(tt.chiefCost=i.cost,tt.refreshLists());else if(i.t==="staff")Hd(i.dismissed,!1);else if(i.t==="profile"){const c=tt.staff.find(h=>h.id===i.id);c&&Object.assign(c,i.profile),Nt.renderTeam()}else if(i.t==="auth")Kl(i.auth);else if(i.t==="contextLimit")jo(i.contextLimit);else if(i.t==="settings")jo(i.contextLimit),ou(i);else if(i.t==="leaderboard")hu(i.leaderboard);else if(i.t==="links")_r(i);else if(i.t==="usage")Nt.renderUsage(i.usage);else if(i.t==="proc")Nt.renderProc(i.procs,i.machine);else if(i.t==="xp"){tt.progress=i.progress,Nt.renderLevel(tt.progress);const c=tt.agents.get(i.agentId);if(c){const h=document.createElement("span");h.className="xpfloat",h.textContent=`+${i.gained} XP`,c.label.appendChild(h),setTimeout(()=>h.remove(),1800)}if(i.levelUp){setTimeout(()=>ln.levelUp(),700);const h=(o=tt.staff[tt.progress.capacity-1])==null?void 0:o.name,u=!tt.agents.has((l=tt.staff[tt.progress.capacity-1])==null?void 0:l.id);Nt.banner(`Level ${tt.progress.level}`,u?`${h} just joined the office.`:"The office is fully staffed."),Cp(!1)}}}}let th=0;function jl(i,t){if(document.hidden){th++,document.title=`(${th}) Agent Office`;try{"Notification"in window&&Notification.permission==="granted"&&new Notification(i,{body:t,silent:!0})}catch{}}}document.addEventListener("visibilitychange",()=>{document.hidden||(th=0,document.title="Agent Office")});document.getElementById("composer").addEventListener("submit",()=>{try{"Notification"in window&&Notification.permission==="default"&&Notification.requestPermission()}catch{}},{once:!0});const xb='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M11 5 6 9H3v6h3l5 4V5Z"/><path d="M15.5 8.5a5 5 0 0 1 0 7"/><path d="M18.5 5.5a9 9 0 0 1 0 13"/></svg>',yb='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M11 5 6 9H3v6h3l5 4V5Z"/><path d="m22 9-6 6"/><path d="m16 9 6 6"/></svg>',ho=document.getElementById("sound");function Rp(){ho.innerHTML=ln.muted?yb:xb;const i=ln.muted?"Sound off":"Sound on";ho.title=i,ho.setAttribute("aria-label",i)}ho.onclick=()=>{ln.setMuted(!ln.muted),Rp(),ln.muted||ln.ship()};Rp();const Mb='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3a3 3 0 0 1 3 3v5a3 3 0 0 1-6 0V6a3 3 0 0 1 3-3z"/><path d="M5 11a7 7 0 0 0 14 0"/><path d="M12 18v3"/></svg>',bb='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M9 9V6a3 3 0 0 1 5.6-1.5M15 11a3 3 0 0 1-4.5 2.6"/><path d="M5 11a7 7 0 0 0 11 5.7M19 11v0"/><path d="M12 18v3"/><path d="m3 3 18 18"/></svg>',ar=document.getElementById("speak");let xn={ok:!1,replies:!1};const Pp=()=>xn.ok?xn.replies:li.on;function vr(){const i=Pp();ar.innerHTML=i?Mb:bb,ar.classList.toggle("on",i);const t=i?xn.ok?"Agents reply with voice notes":"Replies read aloud":"Replies are silent";ar.title=t,ar.setAttribute("aria-label",t)}li.supported||(ar.hidden=!0);ar.onclick=async()=>{const i=!Pp();if(!xn.ok){li.setOn(i),vr(),i&&li.speak("Voice on. I will read replies out as they land.","chief",{force:!0});return}xn={...xn,replies:i},vr();try{const t=await fetch("/api/voice/replies",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({on:i})});if(!t.ok)throw new Error((await t.json().catch(()=>({}))).error||`Request failed (${t.status})`)}catch(t){xn={...xn,replies:!i},vr(),Nt.toast(t.message,"bad")}};vr();function Sb(i){xn.ok||!li.on||i.from==="you"||i.to||i.kind==="chill"||ni.active||li.speak(i.text,i.from)}function wb(){let i=null;for(const t of tt.jobs.values())for(const e of t.log)e.todos&&(!i||e.ts>i.ts)&&(i=e);return(i==null?void 0:i.todos)||[]}const vn=new wr,Eb=i=>i<.5?4*i*i*i:1-(-2*i+2)**3/2;let Se=null,Rs=!1;function Lp(){Rs=!0,Se=null,Bo=!0}function jh({target:i,radius:t,phi:e,theta:n},s=.7){vn.setFromVector3(Ee.position.clone().sub(Ne.target)),Se={t:0,dur:s,target0:Ne.target.clone(),target1:(i||Ne.target).clone().setY(0),r0:vn.radius,r1:t??vn.radius,p0:vn.phi,p1:e??vn.phi,th0:vn.theta,th1:n??vn.theta}}function Co(i){Bo=!0,vn.setFromVector3(Ee.position.clone().sub(Ne.target));const t=Se?Se.th1:vn.theta;jh({theta:t+i*Math.PI/4,target:Se==null?void 0:Se.target1},.55)}function Dp(){Rs=!1,vn.setFromVector3(Ee.position.clone().sub(Ne.target));let i=Oe.theta;for(;i-vn.theta>Math.PI;)i-=Math.PI*2;for(;vn.theta-i>Math.PI;)i+=Math.PI*2;jh({target:Oe.target,radius:Ep(Oe.phi,i,Oe.target),phi:Oe.phi,theta:i},.9)}Ne.addEventListener("start",()=>{Bo=!0,Se=null,Rs=!1,setTimeout(()=>{var i;return(i=document.querySelector(".hint"))==null?void 0:i.classList.add("gone")},5e3)});document.getElementById("turnLeft").onclick=()=>Co(-1);document.getElementById("turnRight").onclick=()=>Co(1);document.getElementById("recenter").onclick=()=>Dp();document.getElementById("standup").onclick=()=>Nt.post("/api/standup");const Qi=new Set;addEventListener("keydown",i=>{var e;if(/INPUT|TEXTAREA|SELECT/.test((e=document.activeElement)==null?void 0:e.tagName)||i.metaKey||i.ctrlKey)return;const t=i.key.toLowerCase();t==="q"?Co(-1):t==="e"?Co(1):t==="r"?Dp():"wasd".includes(t)&&t.length===1&&(Qi.add(t),Se=null,Rs=!1)});addEventListener("keyup",i=>Qi.delete(i.key.toLowerCase()));addEventListener("blur",()=>Qi.clear());const Za=new R,ql=new R,$n=new R;function Tb(i){if(Se){Se.t=Math.min(1,Se.t+i/Se.dur);const n=Eb(Se.t),s=Se.target0.clone().lerp(Se.target1,n);vn.set(tr.lerp(Se.r0,Se.r1,n),tr.lerp(Se.p0,Se.p1,n),tr.lerp(Se.th0,Se.th1,n)),Ne.target.copy(s),Ee.position.setFromSpherical(vn).add(s),Se.t>=1&&(Se=null)}$n.set(0,0,0);const t=Rs&&tt.agents.get(tt.selected);if(t&&$n.set(t.pos.x-Ne.target.x,0,t.pos.z-Ne.target.z).multiplyScalar(Math.min(1,i*3)),Qi.size){Za.subVectors(Ne.target,Ee.position).setY(0).normalize(),ql.crossVectors(Za,Ee.up).normalize();const n=.45*Ee.position.distanceTo(Ne.target)*i;Qi.has("w")&&$n.addScaledVector(Za,n),Qi.has("s")&&$n.addScaledVector(Za,-n),Qi.has("d")&&$n.addScaledVector(ql,n),Qi.has("a")&&$n.addScaledVector(ql,-n)}Ne.target.add($n),Ee.position.add($n),Ne.update();const e=Ne.target;$n.set(tr.clamp(e.x,-19,19)-e.x,-e.y,tr.clamp(e.z,-14,14)-e.z),e.add($n),Ee.position.add($n)}const Ho=new tp,$d=new at;function qh(i){const t=He.domElement.getBoundingClientRect();$d.set((i.clientX-t.left)/t.width*2-1,-((i.clientY-t.top)/t.height)*2+1),Ho.setFromCamera($d,Ee)}const Ip=()=>[...tt.agents.values(),_n].map(i=>i.root);let uo=null;He.domElement.addEventListener("pointerdown",i=>{uo=[i.clientX,i.clientY]});He.domElement.addEventListener("pointerup",i=>{if(!uo||Math.hypot(i.clientX-uo[0],i.clientY-uo[1])>5||i.button!==0)return;qh(i);const t=Ho.intersectObjects(Ip(),!0)[0];t&&(t.object.userData.agentId==="chief"?(Nt.focusInput(),_n.say("Tell me what you need.","",3e3)):tt.select(t.object.userData.agentId))});He.domElement.addEventListener("dblclick",i=>{qh(i);const t=Ho.intersectObject(yn.slab,!1)[0];t&&(Rs=!1,jh({target:t.point,radius:Math.min(Ee.position.distanceTo(Ne.target),34)},.8))});He.domElement.addEventListener("contextmenu",i=>i.preventDefault());He.domElement.addEventListener("pointermove",i=>{i.buttons||(qh(i),He.domElement.style.cursor=Ho.intersectObjects(Ip(),!0).length?"pointer":"")});const Wd=new Qf;let Xd=0,jd=0;function Ab(i){yn.desks.forEach((t,e)=>{const n=tt.staff[e],s=n&&tt.agents.get(n.id),r=!s&&n&&tt.dismissed.has(n.id),a=s!=null&&s.job?"working":s?"break":r?"away":"open",o=a!=="open",l=`${(n==null?void 0:n.name)||""} ${a}`;if(t.plateKey!==l&&(t.plateKey=l,rp(t,{name:o?n.name:"Open desk",accent:o?n.shirt:"#7d8a9c",state:a})),s!=null&&s.job){_d(t,{title:s.job.repo,subtitle:s.job.title,lines:s.lines,accent:n.shirt,t:i}),t.idleKey=null;return}const c=s?`${n.name}`:r?`away ${n.name}`:"open";if(t.idleKey===c)return;t.idleKey=c;const h=tt.progress?e-1:0;_d(t,s?{idle:!0,title:n.name,subtitle:"on a break"}:r?{idle:!0,title:n.name,subtitle:"gone home"}:{idle:!0,title:"Open desk",subtitle:`hires at level ${h}`})})}let qd=!1;function kp(){const i=Math.min(Wd.getDelta(),.05),t=Wd.elapsedTime;Tb(i),yn.updateWalls(Ee,Ne.target,i);for(const s of tt.agents.values())s.update(i,t),s.gone&&(s.dispose(),tt.agents.delete(s.id),tt.selected===s.id&&tt.select(null));if(mb.update([...tt.agents.values()],t),gb.update([...tt.agents.values()],t,i),_n.update(i,t),co.update(i,t),Ap.update(i),yn.globe.rotation.y+=i*.4,(Xd-=i)<=0&&(Xd=.4,Ab(t)),(jd-=i)<=0){jd=.15;for(const s of yn.blinkers)Math.random()<.25&&(s.material.emissiveIntensity=Math.random()<.5?.15:1.4)}Er.render(i);const e=Ee.position.distanceTo(Ne.target)>74,n=[];for(const s of[...tt.agents.values(),_n,...co.list])e!==qd&&(s.label.classList.toggle("far",e),s.labelDirty=!0),s.placeLabel(Ee,sr,rr),s.onScreen&&n.push(s);Rb(n,i,t),co.placeSign(sr,rr),qd=e,requestAnimationFrame(kp)}const Cb=4,Yd=(i,t)=>i.left<t.right-1&&i.right>t.left+1&&i.top<t.bottom-1&&i.bottom>t.top+1;function Rb(i,t,e){const n=[],s=r=>r.id===tt.selected?-1:r.depth;for(const r of[...i].sort((a,o)=>s(a)-s(o))){let a=0,o=!1;for(let h=0;h<2;h++){const u=Math.max(0,Math.min(o?140:80,r.anchorY-r.labelH-6));a=0;for(let d=0;d<10&&a<=u;d++){const f=r.labelBox(a),g=n.find(_=>Yd(_,f));if(!g)break;a+=f.bottom-g.top+Cb}if(a<=u||o){a=Math.min(a,u);break}o=!0,r.setCrowded(!0,e)}o||r.setCrowded(!1,e),r.setLift(a,t);const l=r.labelBox(r.lift),c=n.some(h=>Yd(h,l));r.setBuried(c),c||n.push(l)}}op(yn.board,[]);Yc(yn.scribble,[]);Qc();kp();
|