easter-egg-quest 1.0.20 → 1.0.22

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.
@@ -1 +1 @@
1
- var t,e;t=this,e=function(t){"use strict";var e,i;const n={hiddenEntryHints:["hey, it's not a bug — there's a hidden game on this page","look carefully — two words are hiding among the text","it blends in with everything else, but it’s clickable"],entryConfirmation:["...","you noticed","then we can begin"],stage1Intro:["three eggs are hidden here","each one asks something different","the first riddle:","I am a cat that comes only to those who ignore it. Open your hand — and I leave. Close it — and I was never there."],stage1Reactions:["the cat is watching","it doesn’t trust you yet","you’re trying too hard","what does a cat want?","the hand is still clenched","have you tried not trying?","forget the egg exists","it won’t come if you’re waiting","some things can’t be taken","only given"],stage1Success:["you understood","stillness was the answer","the first egg reveals itself","to those who can stop","hold it to collect"],stage2Intro:["you solved the first one","the second riddle:","I am a river that needs you to flow. Without you, I dry up. But you can’t carry me — only become me. What am I?"],stage2Reactions:["the river is dry","nothing flows","what does a river need?","you are the current","without you, there’s no river","the answer isn’t in your head","it’s in your hands","be the water"],stage2Success:["movement was the answer","the second egg appears","hold it to collect"],stage3Intro:["the final riddle:","Every living thing knows it. You’ve been doing it your whole life without thinking."],stage3Reactions:["one truth alone is not enough","the other alone is not enough either","what do all living things share?","you have known it since the beginning","listen to yourself","in","out"],stage3Success:["rhythm was the answer","you found the third egg"],finale:["all three eggs found","stillness, motion, rhythm","that's the whole set"],results:["begin again","challenge someone"]},s={overlayBg:"rgba(0,0,0,0.25)",textColor:"rgba(255,255,255,0.92)",textSecondary:"rgba(255,255,255,0.55)",accent:"#D4A574",accentGlow:"rgba(212,165,116,0.4)",hudBg:"rgba(0,0,0,0.45)",hudText:"rgba(255,255,255,0.85)"},r=["buy","purchase","checkout","pay","delete","remove","submit","confirm","order","sign out","log out","logout","signout","unsubscribe","cancel","close account"],a=['form [type="submit"]',"[data-no-easter]"];function o(t,e){if(void 0===t)return e;const i=Number(t);return!Number.isFinite(i)||i<1e3||i>3e5?e:i}function l(t,e,i,n){if(void 0===t)return e;const s=Math.round(Number(t));return!Number.isFinite(s)||s<i||s>n?e:s}function h(t){if(t&&"string"==typeof t&&!(t.length>200)){try{document.querySelector(t)}catch{return}return t}}class c{constructor(){this.listeners=new Map}on(t,e){this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(e)}off(t,e){var i;null==(i=this.listeners.get(t))||i.delete(e)}emit(t,...e){var i;null==(i=this.listeners.get(t))||i.forEach(t=>{try{t(...e)}catch{}})}clear(){this.listeners.clear()}}const u={idle:["entry"],entry:["stage1-intro"],"stage1-intro":["stage1-active"],"stage1-active":["stage1-success"],"stage1-success":["stage2-intro"],"stage2-intro":["stage2-active"],"stage2-active":["stage2-success"],"stage2-success":["stage3-intro"],"stage3-intro":["stage3-active"],"stage3-active":["stage3-success"],"stage3-success":["finale"],finale:["results"],results:["complete","idle"],complete:["idle"]};class d{constructor(){this._state="idle",this._onTransition=null}get state(){return this._state}onTransition(t){this._onTransition=t}transitionTo(t){var e;const i=u[this._state];if(!i||!i.includes(t))return!1;const n=this._state;return this._state=t,null==(e=this._onTransition)||e.call(this,n,t),!0}reset(){this._state="idle"}forceState(t){this._state=t}get label(){return p[this._state]??""}}const p={idle:"",entry:"Searching","stage1-intro":"Stillness","stage1-active":"Stillness","stage1-success":"Stillness","stage2-intro":"Motion","stage2-active":"Motion","stage2-success":"Motion","stage3-intro":"Rhythm","stage3-active":"Rhythm","stage3-success":"Rhythm",finale:"Finale",results:"Results",complete:"Complete"};class m{constructor(){this._snapshot={isMoving:!1,lastMoveTime:0,lastStillTime:Date.now(),mouseX:0,mouseY:0,velocity:0,totalClicks:0,totalScrolls:0,totalKeyPresses:0,totalDistance:0,maxVelocity:0},this._phases=[],this._currentPhaseType="still",this._currentPhaseStart=Date.now(),this._prevX=0,this._prevY=0,this._prevMoveTs=0,this.DEFAULT_STILL_THRESHOLD_MS=400,this._stillThresholdMs=this.DEFAULT_STILL_THRESHOLD_MS,this.DEFAULT_MIN_PHASE_MS=300,this._minPhaseMs=this.DEFAULT_MIN_PHASE_MS,this._stillTimer=null,this._handlers=[],this._active=!1,this._onVisibilityChange=()=>{if(document.hidden)this._snapshot.isMoving=!0;else{const t=Date.now();this._snapshot.isMoving=!1,this._snapshot.lastStillTime=t,this._snapshot.velocity=0,this._currentPhaseType="still",this._currentPhaseStart=t}},this._onWindowBlur=()=>{this._snapshot.isMoving=!0},this._onPointerMove=t=>{const e=Date.now(),i=t.clientX-this._prevX,n=t.clientY-this._prevY,s=e-this._prevMoveTs||1,r=Math.sqrt(i*i+n*n);r<2||(this._snapshot.mouseX=t.clientX,this._snapshot.mouseY=t.clientY,this._snapshot.velocity=r/s*1e3,this._snapshot.totalDistance+=r,this._snapshot.velocity>this._snapshot.maxVelocity&&(this._snapshot.maxVelocity=this._snapshot.velocity),this._prevX=t.clientX,this._prevY=t.clientY,this._prevMoveTs=e,this._registerMove(e))},this._onTouchMove=t=>{const e=t.touches[0];if(!e)return;const i=Date.now(),n=e.clientX-this._prevX,s=e.clientY-this._prevY;Math.sqrt(n*n+s*s)<2||(this._snapshot.mouseX=e.clientX,this._snapshot.mouseY=e.clientY,this._prevX=e.clientX,this._prevY=e.clientY,this._prevMoveTs=i,this._registerMove(i))},this._onClick=()=>{this._snapshot.totalClicks++,this._registerMove(Date.now())},this._onActivity=()=>{this._registerMove(Date.now())},this._onScroll=()=>{this._snapshot.totalScrolls++,this._registerMove(Date.now())},this._onKeyDown=()=>{this._snapshot.totalKeyPresses++,this._registerMove(Date.now())}}get snapshot(){return{...this._snapshot}}get phases(){return this._phases.slice()}get stillDuration(){return this._snapshot.isMoving?0:Date.now()-this._snapshot.lastStillTime}get moveDuration(){return this._snapshot.isMoving?Date.now()-this._snapshot.lastMoveTime:0}get timeSinceLastActivity(){return Date.now()-Math.max(this._snapshot.lastMoveTime,this._snapshot.lastStillTime)}start(){if(this._active)return;this._active=!0,this._snapshot.lastStillTime=Date.now();const t=(t,e,i)=>{window.addEventListener(t,e,{passive:!0,...i}),this._handlers.push({event:t,fn:e})};t("mousemove",this._onPointerMove),t("touchmove",this._onTouchMove),t("click",this._onClick),t("mousedown",this._onActivity),t("touchstart",this._onActivity),t("scroll",this._onScroll,{capture:!0}),t("keydown",this._onKeyDown),t("wheel",this._onScroll);const e=this._onVisibilityChange;document.addEventListener("visibilitychange",e),this._handlers.push({event:"visibilitychange",fn:e}),window.addEventListener("blur",this._onWindowBlur),this._handlers.push({event:"blur",fn:this._onWindowBlur})}stop(){this._active=!1;for(const{event:t,fn:e}of this._handlers)window.removeEventListener(t,e),document.removeEventListener(t,e);this._handlers=[],this._stillTimer&&clearTimeout(this._stillTimer)}resetPhases(){this._phases=[],this._currentPhaseType="still",this._currentPhaseStart=Date.now(),this._snapshot.isMoving=!1,this._snapshot.velocity=0,this._stillTimer&&(clearTimeout(this._stillTimer),this._stillTimer=null)}resetCounts(){this._snapshot.totalClicks=0,this._snapshot.totalScrolls=0,this._snapshot.totalKeyPresses=0,this._snapshot.totalDistance=0,this._snapshot.maxVelocity=0}configurePhaseDetection(t){"number"==typeof t.stillThresholdMs&&(this._stillThresholdMs=Math.max(250,t.stillThresholdMs)),"number"==typeof t.minPhaseMs&&(this._minPhaseMs=Math.max(150,t.minPhaseMs))}resetPhaseDetection(){this._stillThresholdMs=this.DEFAULT_STILL_THRESHOLD_MS,this._minPhaseMs=this.DEFAULT_MIN_PHASE_MS}_registerMove(t){this._snapshot.lastMoveTime=t,this._snapshot.isMoving||(this._snapshot.isMoving=!0,this._completePhase("still",t),this._currentPhaseType="move",this._currentPhaseStart=t),this._stillTimer&&clearTimeout(this._stillTimer),this._stillTimer=setTimeout(()=>{this._becomeStill()},this._stillThresholdMs)}_becomeStill(){if(!this._snapshot.isMoving)return;const t=Date.now();this._snapshot.isMoving=!1,this._snapshot.lastStillTime=t,this._snapshot.velocity=0,this._completePhase("move",t),this._currentPhaseType="still",this._currentPhaseStart=t}_completePhase(t,e){const i=e-this._currentPhaseStart;i>=this._minPhaseMs&&this._phases.push({type:t,startTime:this._currentPhaseStart,endTime:e,duration:i}),this._phases.length>200&&(this._phases=this._phases.slice(-100))}}function f(t){const e=Math.floor(t/1e3),i=Math.floor(e/60),n=e%60;return`${String(i).padStart(2,"0")}:${String(n).padStart(2,"0")}`}class g{constructor(t,e,i){this.targetElement=null,this.hintTimers=[],this.hintIndex=0,this.hintContainer=null,this.shimmerStyle=null,this.clickHandler=null,this.fallbackButton=null,this._injectedElement=null,this._destroyed=!1,this._hintVisibleElapsed=0,this._hintVisibleStart=0,this._hintCheckInterval=null,this._hintVisibilityHandler=null,this._domObserver=null,this._intersectionObserver=null,this._mutationDebounce=null,this._navigationHandler=null,this._bootstrapObserver=null,this._retryTimer=null,this._fallbackTimer=null,this._retryCount=0,this._historyPatched=!1,this.config=t,this.script=e,this.onFound=i}start(){this.config.accessibility.disableHiddenEntry?this._createFallbackEntry():(this._startHintEscalation(),this._startBootstrapWatch(),this._scheduleFallback(),this._attemptInjection(0))}cleanup(){var t,e,i,n;this._destroyed=!0,this._stopHintTimer();for(const s of this.hintTimers)clearTimeout(s);this.hintTimers=[],this.clickHandler&&this.targetElement&&this.targetElement.removeEventListener("click",this.clickHandler),this.targetElement&&(this.targetElement.style.removeProperty("animation"),this.targetElement.classList.remove("eeq-entry-target")),this._stopWatchdog(),this._stopBootstrapWatch(),null==(t=this._injectedElement)||t.remove(),this._injectedElement=null,null==(e=this.hintContainer)||e.remove(),null==(i=this.shimmerStyle)||i.remove(),null==(n=this.fallbackButton)||n.remove()}_possessElement(t){this.targetElement=function(t){if(0!==t.length)return t[Math.floor(Math.random()*t.length)]}(t),this._attachToElement(this.targetElement)}_injectIntoExisting(){var t;const e=this._getSearchRoot(),i=this._findTextCandidates(e);if(0===i.length)return!1;const n=i.sort((t,e)=>{const i=null!==t.closest("nav")||null!==t.closest("header")?1:0,n=null!==e.closest("nav")||null!==e.closest("header")?1:0;return i!==n?i-n:parseFloat(getComputedStyle(t).fontSize)-parseFloat(getComputedStyle(e).fontSize)}),s=n.map(t=>{var e;return`${t.tagName}:${((null==(e=t.textContent)?void 0:e.trim())??"").slice(0,30)}`}),r="eeq_trigger_history";let a=[];try{const t=localStorage.getItem(r);t&&(a=JSON.parse(t))}catch{}let o=new Set(a);const l="eeq_visit";let h=0;try{h=parseInt(localStorage.getItem(l)||"0",10)||0,localStorage.setItem(l,String(h+1))}catch{}const c=n.filter(t=>!t.closest("nav")&&!t.closest("header")),u=n.filter(t=>null!==t.closest("nav")||null!==t.closest("header")),d=c.length>1?h%c.length:0,p=[...c.slice(d),...c.slice(0,d),...u],m=p.map(t=>{var e;return`${t.tagName}:${((null==(e=t.textContent)?void 0:e.trim())??"").slice(0,30)}`}),f=p.filter((t,e)=>!o.has(m[e]));0===f.length&&(o.clear(),a=[]);const g=f.length>0?[...f,...p.filter((t,e)=>o.has(m[e]))]:p;for(const _ of g){const e=_,i="A"===e.tagName||"BUTTON"===e.tagName||"LI"===e.tagName||null!==e.closest("nav"),a=document.createElement("span");if(a.textContent=i?" · start hunt":" start hunt",a.setAttribute("data-eeq","trigger"),a.style.cssText="\n font: inherit;\n color: inherit;\n letter-spacing: inherit;\n cursor: pointer;\n ",i||!this._tryInsertBetweenWords(e,a)){const t=e.getBoundingClientRect().height;e.appendChild(a);const i=e.getBoundingClientRect().height;if(Math.abs(i-t)>2){e.removeChild(a);continue}}const l=n.indexOf(_);if(l>=0){o.add(s[l]);try{localStorage.setItem(r,JSON.stringify([...o].slice(-20)))}catch{}}return this._injectedElement=a,this.targetElement=a,this._attachToElement(a),this._retryCount=0,this._clearRetryTimer(),this._clearFallbackTimer(),null==(t=this.fallbackButton)||t.remove(),this.fallbackButton=null,this._stopBootstrapWatch(),this._startWatchdog(),!0}return!1}_attemptInjection(t){this._clearRetryTimer(),this._retryTimer=setTimeout(()=>{this._destroyed||this._injectedElement||this._injectIntoExisting()||this._scheduleNextRetry()},t)}_scheduleNextRetry(){if(this._destroyed||this._injectedElement)return;const t=[300,900,1800,3200,5e3,8e3],e=t[Math.min(this._retryCount,t.length-1)];this._retryCount+=1,this._attemptInjection(e)}_scheduleFallback(){this.fallbackButton||this._fallbackTimer||(this._fallbackTimer=setTimeout(()=>{this._destroyed||this._injectedElement||this.fallbackButton||this._createFallbackEntry()},1e4))}_clearRetryTimer(){this._retryTimer&&(clearTimeout(this._retryTimer),this._retryTimer=null)}_clearFallbackTimer(){this._fallbackTimer&&(clearTimeout(this._fallbackTimer),this._fallbackTimer=null)}_getSearchRoot(){return this.config.hiddenEntry.selector?document.querySelector(this.config.hiddenEntry.selector)??document.body:document.body}_findTextCandidates(t){var e;const i=["p","li","figcaption","blockquote","caption","label","td","th","h1","h2","h3","h4","h5","h6","a","button",'[role="button"]','[role="link"]',"div","span","article","section","summary","[data-easter-entry]","[mat-button]","[mat-list-item]",".mat-mdc-button",".mat-mdc-list-item",".ag-cell",".ag-header-cell"].join(", "),n=new Set;for(const s of this.config.hiddenEntry.excludeSelectors)null==(e=t.querySelectorAll)||e.call(t,s).forEach(t=>n.add(t));return Array.from(t.querySelectorAll(i)).filter(t=>{var e,i;if(!(t instanceof HTMLElement))return!1;if(n.has(t))return!1;if(t.closest("[data-eeq]"))return!1;if(t.closest("script, style, noscript, svg, canvas, form"))return!1;if(function(t){const e=`${(t.textContent??"").toLowerCase().trim()} ${(t.getAttribute("aria-label")??"").toLowerCase()}`;return r.some(t=>e.includes(t))}(t))return!1;if(!function(t){const e=t.getBoundingClientRect();if(0===e.width||0===e.height)return!1;const i=getComputedStyle(t);if("none"===i.display||"hidden"===i.visibility||"0"===i.opacity)return!1;if(!(e.top<window.innerHeight&&e.bottom>0&&e.left<window.innerWidth&&e.right>0))return!1;let n=t.parentElement;for(;n&&n!==document.body;){const t=getComputedStyle(n);if([t.overflow,t.overflowX,t.overflowY].some(t=>["auto","scroll","hidden","clip"].includes(t))){const t=n.getBoundingClientRect();if(e.bottom<=t.top||e.top>=t.bottom||e.right<=t.left||e.left>=t.right)return!1}n=n.parentElement}return!0}(t))return!1;const s=(null==(e=t.innerText)?void 0:e.trim())||(null==(i=t.textContent)?void 0:i.trim())||"";if(s.length<6||s.length>220)return!1;if(t.children.length>12)return!1;const a=t.getBoundingClientRect();return!(a.width<18||a.height<12)})}_startBootstrapWatch(){this._stopBootstrapWatch();const t=this._getSearchRoot(),e=t instanceof HTMLElement?t:document.body;if(this._bootstrapObserver=new MutationObserver(()=>{this._destroyed||this._injectedElement||(this._mutationDebounce&&clearTimeout(this._mutationDebounce),this._mutationDebounce=setTimeout(()=>{this._destroyed||this._injectedElement||this._attemptInjection(150)},250))}),this._bootstrapObserver.observe(e,{childList:!0,subtree:!0}),this._navigationHandler=()=>{this._destroyed||this._injectedElement||this._attemptInjection(700)},window.addEventListener("popstate",this._navigationHandler),window.addEventListener("hashchange",this._navigationHandler),!this._historyPatched&&void 0!==window.history){this._historyPatched=!0;const t=t=>{const e=window.history[t].bind(window.history);window.history[t]=(...t)=>{const i=e(...t);return window.dispatchEvent(new Event("eeq:navigation")),i}};t("pushState"),t("replaceState")}window.addEventListener("eeq:navigation",this._navigationHandler)}_stopBootstrapWatch(){this._bootstrapObserver&&(this._bootstrapObserver.disconnect(),this._bootstrapObserver=null),this._clearRetryTimer(),this._clearFallbackTimer(),this._mutationDebounce&&(clearTimeout(this._mutationDebounce),this._mutationDebounce=null),this._navigationHandler&&(window.removeEventListener("popstate",this._navigationHandler),window.removeEventListener("hashchange",this._navigationHandler),window.removeEventListener("eeq:navigation",this._navigationHandler),this._navigationHandler=null)}_startWatchdog(){if(this._stopWatchdog(),!this._injectedElement)return;this._intersectionObserver=new IntersectionObserver(t=>{if(this._destroyed||!this._injectedElement)return;const e=t[0];e&&!e.isIntersecting&&this._reinject()},{threshold:0}),this._intersectionObserver.observe(this._injectedElement);const t=this._findStableAncestor(this._injectedElement);this._domObserver=new MutationObserver(()=>{!this._destroyed&&this._injectedElement&&(this._mutationDebounce&&clearTimeout(this._mutationDebounce),this._mutationDebounce=setTimeout(()=>{!this._destroyed&&this._injectedElement&&(document.body.contains(this._injectedElement)||this._reinject())},300))}),this._domObserver.observe(t,{childList:!0,subtree:!0}),this._navigationHandler=()=>{!this._destroyed&&this._injectedElement&&setTimeout(()=>{!this._destroyed&&this._injectedElement&&(document.body.contains(this._injectedElement)||this._reinject())},500)},window.addEventListener("popstate",this._navigationHandler),window.addEventListener("hashchange",this._navigationHandler),window.addEventListener("eeq:navigation",this._navigationHandler)}_findStableAncestor(t){let e=t.parentElement;for(;e&&e!==document.body;){const t=e.tagName.toLowerCase();if("main"===t||"body"===t||t.includes("app-")||t.includes("-root")||null!==e.querySelector("router-outlet")||"app"===e.id||"root"===e.id||"__next"===e.id)return e;e=e.parentElement}return document.body}_stopWatchdog(){this._domObserver&&(this._domObserver.disconnect(),this._domObserver=null),this._intersectionObserver&&(this._intersectionObserver.disconnect(),this._intersectionObserver=null),this._mutationDebounce&&(clearTimeout(this._mutationDebounce),this._mutationDebounce=null),this._navigationHandler&&(window.removeEventListener("popstate",this._navigationHandler),window.removeEventListener("hashchange",this._navigationHandler),window.removeEventListener("eeq:navigation",this._navigationHandler),this._navigationHandler=null)}_reinject(){this._stopWatchdog(),this.clickHandler&&this.targetElement&&this.targetElement.removeEventListener("click",this.clickHandler),this._injectedElement&&document.body.contains(this._injectedElement)&&this._injectedElement.remove(),this._injectedElement=null,this.targetElement=null,this._startBootstrapWatch(),this._scheduleFallback(),setTimeout(()=>{this._destroyed||this._injectIntoExisting()||this._scheduleNextRetry()},1200)}_tryInsertBetweenWords(t,e){const i=[],n=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,{acceptNode(t){var e;if(((null==(e=t.textContent)?void 0:e.trim())??"").length<=5)return NodeFilter.FILTER_REJECT;const i=t.parentElement;return i?i.closest("[data-eeq], script, style, noscript")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}});let s=n.nextNode();for(;s;)i.push(s),s=n.nextNode();if(!i.length)return!1;const r=Math.floor(Date.now()/12e4),a=i[r%i.length],o=a.textContent??"",l=[];for(let v=1;v<o.length-1;v++)" "===o[v]&&l.push(v);if(l.length<2)return!1;const h=Math.floor(.25*l.length),c=Math.floor(.75*l.length),u=h+r%Math.max(1,c-h),d=l[Math.min(u,l.length-1)],p=o.slice(0,d),m=o.slice(d),f=t.getBoundingClientRect(),g=document.createTextNode(m);a.textContent=p,t.insertBefore(g,a.nextSibling),t.insertBefore(e,g);const _=t.getBoundingClientRect();return!(Math.abs(_.height-f.height)>8||Math.abs(_.width-f.width)>24)||(t.removeChild(e),t.removeChild(g),a.textContent=o,!1)}_attachToElement(t){this.clickHandler=t=>{t.preventDefault(),t.stopPropagation(),this._destroyed||(this.cleanup(),this.onFound())},t.addEventListener("click",this.clickHandler,{capture:!0,once:!0})}_startHintEscalation(){this._injectShimmerStyles(),this._createHintContainer();const t=this.script.hiddenEntryHints,e=[{at:6e4,fired:!1,action:()=>{this._stopHintTimer(),this._showFirstHintWithConfirm(t[0]??"",()=>{const e=t.slice(1),i=[];for(let t=0;t<e.length;t++)i.push({at:6e4*(t+1),fired:!1,action:()=>this._showHint(e[t])});i.push({at:12e4,fired:!1,action:()=>{this.targetElement&&this.targetElement.classList.add("eeq-entry-target")}}),0!==i.length&&this._startVisibilityTimer(i)})}}];this._startVisibilityTimer(e)}_startVisibilityTimer(t){this._hintVisibleElapsed=0,this._hintVisibleStart=0;const e=()=>this._hintVisibleElapsed+(this._hintVisibleStart?Date.now()-this._hintVisibleStart:0),i=()=>{if(this._destroyed)return;const i=e();for(const e of t)!e.fired&&i>=e.at&&(e.fired=!0,e.action());t.every(t=>t.fired)&&this._stopHintTimer()},n=()=>{this._hintCheckInterval||(this._hintVisibleStart=Date.now(),this._hintCheckInterval=setInterval(i,1e3))},s=()=>{this._hintVisibleStart&&(this._hintVisibleElapsed+=Date.now()-this._hintVisibleStart,this._hintVisibleStart=0),this._hintCheckInterval&&(clearInterval(this._hintCheckInterval),this._hintCheckInterval=null)};this._hintVisibilityHandler=()=>{this._destroyed||("visible"===document.visibilityState?n():s())},document.addEventListener("visibilitychange",this._hintVisibilityHandler),"visible"===document.visibilityState&&n()}_showFirstHintWithConfirm(t,e){if(!this.hintContainer)return;const i=document.createElement("div");i.className="eeq-snackbar";const n=document.createElement("span");n.textContent=t,i.appendChild(n);const s=document.createElement("button");s.className="eeq-snackbar-btn",s.textContent="Let's go!",s.addEventListener("click",()=>{a(),e()}),i.appendChild(s);const r=document.createElement("button");r.className="eeq-snackbar-btn",r.textContent="Not interested",r.addEventListener("click",()=>{try{localStorage.setItem("eeq_optout","1")}catch{}this.cleanup()}),i.appendChild(r),this.hintContainer.appendChild(i);const a=()=>{i.style.transform="translateY(20px)",i.style.opacity="0",setTimeout(()=>i.remove(),400)};requestAnimationFrame(()=>{i.style.transform="translateY(0)",i.style.opacity="1"})}_stopHintTimer(){this._hintCheckInterval&&(clearInterval(this._hintCheckInterval),this._hintCheckInterval=null),this._hintVisibilityHandler&&(document.removeEventListener("visibilitychange",this._hintVisibilityHandler),this._hintVisibilityHandler=null)}_showHint(t){if(!this.hintContainer)return;const e=document.createElement("div");e.className="eeq-snackbar";const i=document.createElement("span");i.textContent=t,e.appendChild(i);const n=document.createElement("button");n.className="eeq-snackbar-btn",n.textContent="Not interested",n.addEventListener("click",()=>{try{localStorage.setItem("eeq_optout","1")}catch{}this.cleanup()}),e.appendChild(n),this.hintContainer.appendChild(e),requestAnimationFrame(()=>{e.style.transform="translateY(0)",e.style.opacity="1"}),setTimeout(()=>{e.parentNode&&(e.style.transform="translateY(20px)",e.style.opacity="0",setTimeout(()=>e.remove(),400))},8e3)}_createHintContainer(){this.hintContainer=document.createElement("div"),Object.assign(this.hintContainer.style,{position:"fixed",bottom:"24px",left:"50%",transform:"translateX(-50%)",zIndex:"999980",pointerEvents:"none",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px"}),document.body.appendChild(this.hintContainer)}_injectShimmerStyles(){this.shimmerStyle=document.createElement("style"),this.shimmerStyle.textContent="\n .eeq-entry-target {\n animation: eeq-shimmer 3s ease-in-out infinite !important;\n }\n @keyframes eeq-shimmer {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.55; }\n }\n .eeq-snackbar {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n font-size: 14px;\n line-height: 20px;\n letter-spacing: 0.01em;\n color: #fff;\n background: #323232;\n padding: 14px 24px;\n border-radius: 4px;\n box-shadow: 0 3px 5px -1px rgba(0,0,0,0.2), 0 6px 10px rgba(0,0,0,0.14), 0 1px 18px rgba(0,0,0,0.12);\n min-width: 288px;\n max-width: 568px;\n opacity: 0;\n transform: translateY(20px);\n transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n pointer-events: auto;\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 24px;\n }\n .eeq-snackbar-btn {\n font-family: inherit;\n font-size: 14px;\n font-weight: 500;\n letter-spacing: 0.04em;\n text-transform: none;\n color: #fff;\n background: none;\n border: none;\n padding: 0;\n margin: 0;\n cursor: pointer;\n white-space: nowrap;\n flex-shrink: 0;\n }\n .eeq-snackbar-btn:hover {\n opacity: 0.8;\n }\n ",document.head.appendChild(this.shimmerStyle)}_createFallbackEntry(){if(this.fallbackButton)return;this.fallbackButton=document.createElement("button"),this.fallbackButton.textContent="·",this.fallbackButton.setAttribute("aria-label","Hidden game entry"),Object.assign(this.fallbackButton.style,{position:"fixed",bottom:"16px",right:"16px",width:"28px",height:"28px",borderRadius:"50%",border:`1px solid ${this.config.theme.accent}`,background:"transparent",color:this.config.theme.accent,fontSize:"16px",cursor:"pointer",zIndex:"999980",opacity:"0.4",transition:"opacity 0.6s",fontFamily:"serif",lineHeight:"1",padding:"0"}),this.fallbackButton.addEventListener("mouseenter",()=>{this.fallbackButton&&(this.fallbackButton.style.opacity="0.8")}),this.fallbackButton.addEventListener("mouseleave",()=>{this.fallbackButton&&(this.fallbackButton.style.opacity="0.4")}),this.fallbackButton.addEventListener("click",()=>{this._destroyed||(this.cleanup(),this.onFound())}),document.body.appendChild(this.fallbackButton),this._createHintContainer(),this._injectShimmerStyles();const t=this.script.hiddenEntryHints;for(let e=0;e<t.length;e++){const i=setTimeout(()=>{this._destroyed||this._showHint(t[e])},6e3+1e4*e);this.hintTimers.push(i)}}}class _{constructor(t){this.host=null,this.shadow=null,this.container=null,this.currentLine=null,this.clearTimer=null,this.awaitingConfirm=!1,this.config=t}mount(){this.host=document.createElement("div"),this.host.id="eeq-narrative-host",Object.assign(this.host.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"999993"}),document.body.appendChild(this.host),this.shadow=this.host.attachShadow({mode:"closed"});const t=document.createElement("style");t.textContent=this._getStyles(),this.shadow.appendChild(t),this.container=document.createElement("div"),this.container.className="eeq-narrative",this.shadow.appendChild(this.container)}_removeCurrentLine(t=!1){if(!this.currentLine)return;const e=this.currentLine;this.currentLine=null,t?e.remove():(e.classList.add("eeq-narrative-exit"),setTimeout(()=>e.remove(),750))}showLine(t,e="eeq-line"){if(!this.container)return;if(this.awaitingConfirm)return;this._removeCurrentLine(!0),this.clearTimer&&(clearTimeout(this.clearTimer),this.clearTimer=null);const i=document.createElement("div");i.className=e,i.textContent=t,this.container.appendChild(i),requestAnimationFrame(()=>{requestAnimationFrame(()=>{i.classList.add("eeq-line-visible")})}),this.currentLine=i,this.clearTimer=setTimeout(()=>{this.clear()},15e3)}showLineWithConfirm(t){return new Promise(e=>{if(!this.container)return void e();this.awaitingConfirm=!0,this._removeCurrentLine(!0),this.clearTimer&&(clearTimeout(this.clearTimer),this.clearTimer=null);const i=document.createElement("div");i.className="eeq-line",i.textContent=t,this.container.appendChild(i);const n=document.createElement("button");n.className="eeq-confirm-btn",n.textContent="OK",n.addEventListener("click",()=>{this.awaitingConfirm=!1,e()},{once:!0}),i.appendChild(n),requestAnimationFrame(()=>{requestAnimationFrame(()=>{i.classList.add("eeq-line-visible")})}),this.currentLine=i})}async showSequence(t,e=4500){for(const i of t)this.showLine(i),await new Promise(t=>setTimeout(t,e))}showCelebration(t){this.showLine(t,"eeq-line eeq-celebration")}clear(t=!1){this.awaitingConfirm&&!t||(this.clearTimer&&(clearTimeout(this.clearTimer),this.clearTimer=null),this._removeCurrentLine(t),this.awaitingConfirm=!1)}destroy(){var t;this.clear(!0),null==(t=this.host)||t.remove(),this.host=null,this.shadow=null,this.container=null}_getStyles(){return`\n .eeq-narrative {\n position: fixed;\n bottom: 0;\n left: 0;\n width: 100%;\n height: auto;\n display: flex;\n align-items: center;\n justify-content: center;\n padding-bottom: 48px;\n pointer-events: none;\n font-family: 'Georgia', 'Times New Roman', 'Noto Serif', serif;\n }\n\n .eeq-line {\n position: absolute;\n bottom: 48px;\n left: 50%;\n transform: translateX(-50%);\n color: ${this.config.theme.textColor};\n font-size: clamp(13px, 1.8vw, 19px);\n letter-spacing: 0.04em;\n text-align: center;\n max-width: 440px;\n padding: 12px 24px;\n opacity: 0;\n filter: blur(12px);\n transition: opacity 0.8s ease, filter 0.9s cubic-bezier(0.22, 1, 0.36, 1);\n line-height: 1.6;\n\n /* Frosted glass dialogue card */\n background: rgba(10, 10, 14, 0.55);\n backdrop-filter: blur(18px) saturate(1.4);\n -webkit-backdrop-filter: blur(18px) saturate(1.4);\n border: 1px solid rgba(255, 255, 255, 0.08);\n border-radius: 16px;\n box-shadow:\n 0 4px 24px rgba(0, 0, 0, 0.25),\n 0 0 0 0.5px rgba(255, 255, 255, 0.04) inset;\n }\n\n .eeq-line-visible {\n opacity: 1;\n filter: blur(0px);\n }\n\n .eeq-narrative-exit {\n opacity: 0 !important;\n filter: blur(14px) !important;\n transition: opacity 0.6s ease, filter 0.7s cubic-bezier(0.22, 1, 0.36, 1) !important;\n }\n\n .eeq-celebration {\n /* Override positioning: center of viewport via fixed */\n position: fixed !important;\n bottom: auto !important;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%) scale(0.8);\n max-width: 90vw;\n padding: 20px 40px;\n\n color: #ffe8a0;\n font-size: clamp(18px, 3.5vw, 28px);\n font-weight: bold;\n letter-spacing: 0.1em;\n text-transform: uppercase;\n\n background: linear-gradient(135deg, rgba(50,35,10,0.85), rgba(25,18,8,0.9));\n border: 2px solid rgba(255, 215, 80, 0.35);\n border-radius: 20px;\n box-shadow:\n 0 0 60px rgba(255, 200, 60, 0.25),\n 0 8px 40px rgba(0, 0, 0, 0.5),\n inset 0 1px 0 rgba(255, 230, 140, 0.15);\n text-shadow:\n 0 0 20px rgba(255, 200, 60, 0.6),\n 0 0 40px rgba(255, 180, 40, 0.3);\n }\n\n .eeq-celebration.eeq-line-visible {\n transform: translate(-50%, -50%) scale(1);\n transition: opacity 0.6s ease, filter 0.8s ease, transform 0.6s cubic-bezier(0.17, 0.67, 0.29, 1.2);\n }\n\n .eeq-celebration.eeq-narrative-exit {\n transform: translate(-50%, -50%) scale(1.1) !important;\n }\n\n .eeq-confirm-btn {\n display: block;\n margin: 14px auto 0;\n padding: 5px 32px;\n border: 1px solid rgba(255,255,255,0.18);\n border-radius: 20px;\n background: rgba(255,255,255,0.08);\n color: inherit;\n font-family: inherit;\n font-size: 0.8em;\n letter-spacing: 0.08em;\n cursor: pointer;\n pointer-events: auto;\n transition: background 0.3s, border-color 0.3s;\n }\n\n .eeq-confirm-btn:hover {\n background: rgba(255,255,255,0.18);\n border-color: rgba(255,255,255,0.35);\n }\n `}}class v{constructor(t){this.host=null,this.shadow=null,this.slots=[],this._activeSlot=null,this._onEggClick=null,this.config=t}mount(t){if(!this.config.shrine.enabled)return;this._onEggClick=t,this.host=document.createElement("div"),this.host.id="eeq-shrine-host";const e=this.config.shrine.position,i={"bottom-right":{bottom:"16px",right:"16px"},"bottom-left":{bottom:"16px",left:"16px"},"bottom-center":{bottom:"16px",left:"50%",transform:"translateX(-50%)"}};Object.assign(this.host.style,{position:"fixed",zIndex:"999994",opacity:"0",transform:"translateY(20px)",transition:"opacity 0.8s ease, transform 0.8s ease",...i[e]??i["bottom-right"]}),document.body.appendChild(this.host),this.shadow=this.host.attachShadow({mode:"closed"});const n=document.createElement("style");n.textContent=this._getStyles(),this.shadow.appendChild(n);const s=document.createElement("div");s.className="eeq-shrine";for(let r=0;r<3;r++){const t=document.createElement("div");t.className="eeq-slot eeq-slot-empty",t.setAttribute("data-egg",String(r)),t.setAttribute("aria-label",`Egg ${r+1} slot`),t.setAttribute("role","button"),t.setAttribute("tabindex","0");const e=document.createElement("div");e.className="eeq-egg-inner",t.appendChild(e),t.addEventListener("click",()=>{var t;this._activeSlot===r&&(null==(t=this._onEggClick)||t.call(this,r))}),t.addEventListener("keydown",t=>{var e;"Enter"===t.key&&this._activeSlot===r&&(null==(e=this._onEggClick)||e.call(this,r))}),s.appendChild(t),this.slots.push(t)}this.shadow.appendChild(s)}show(){this.host&&requestAnimationFrame(()=>{this.host&&(this.host.style.opacity="1",this.host.style.transform="translateY(0)")})}fillSlot(t){const e=this.slots[t];e&&(e.classList.remove("eeq-slot-empty"),e.classList.add("eeq-slot-filled"))}activateSlot(t){this._activeSlot=t;const e=this.slots[t];e&&(e.classList.add("eeq-slot-active"),e.style.cursor="pointer",e.style.pointerEvents="auto")}deactivateSlot(t){this._activeSlot=null;const e=this.slots[t];e&&(e.classList.remove("eeq-slot-active"),e.style.cursor="default",e.style.pointerEvents="none")}hideAll(){for(const t of this.slots)t.classList.add("eeq-slot-finale-exit")}reset(){this._activeSlot=null;for(const t of this.slots)t.className="eeq-slot eeq-slot-empty",t.style.cursor="default",t.style.pointerEvents="none"}destroy(){var t;null==(t=this.host)||t.remove(),this.host=null,this.shadow=null,this.slots=[]}_getStyles(){const t=this.config.theme;return`\n .eeq-shrine {\n display: flex;\n gap: 14px;\n padding: 12px 16px;\n background: ${t.hudBg};\n backdrop-filter: blur(12px);\n -webkit-backdrop-filter: blur(12px);\n border: 1px solid rgba(255,255,255,0.08);\n border-radius: 12px;\n }\n\n .eeq-slot {\n width: 36px;\n height: 44px;\n border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.6s ease;\n pointer-events: none;\n position: relative;\n }\n\n .eeq-slot-empty {\n border: 1.5px dashed rgba(255,255,255,0.2);\n background: transparent;\n }\n\n .eeq-slot-filled {\n border: 1.5px solid ${t.accent};\n background: radial-gradient(ellipse at 40% 30%, rgba(255,255,255,0.15), transparent);\n }\n\n .eeq-slot-filled .eeq-egg-inner {\n width: 60%;\n height: 70%;\n border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;\n background: linear-gradient(135deg, ${t.accent}, rgba(255,255,255,0.3));\n opacity: 0.8;\n }\n\n .eeq-slot-active {\n animation: eeq-slot-pulse 2s ease-in-out infinite;\n border-color: ${t.accent} !important;\n box-shadow: 0 0 16px ${t.accentGlow};\n }\n\n .eeq-slot-finale-exit {\n opacity: 0;\n transform: translateY(-20px) scale(0.6);\n transition: all 1s ease;\n }\n\n .eeq-egg-inner {\n transition: all 0.4s ease;\n }\n\n @keyframes eeq-slot-pulse {\n 0%, 100% { transform: scale(1); opacity: 0.8; }\n 50% { transform: scale(1.08); opacity: 1; }\n }\n `}}class y{constructor(t){this.canvas=null,this.THREE=null,this.renderer=null,this.scene=null,this.camera=null,this.eggs=[],this.eggBodies=[],this.lights=[],this._raf=0,this._running=!1,this._clock=null,this._eggStates=[{visible:!1,phase:"hidden",t:0,targetPos:[0,0,0]},{visible:!1,phase:"hidden",t:0,targetPos:[0,0,0]},{visible:!1,phase:"hidden",t:0,targetPos:[0,0,0]}],this._finaleActive=!1,this._finaleT=0,this._greetingOverlay=null,this._trailParticles=[],this._ambientParticles=[],this._lastAmbientSpawnAt=0,this._revealParticles=[],this._disposed=!1,this._interactiveEgg=null,this._isDragging=!1,this._dragStartX=0,this._dragStartY=0,this._dragRotX=0,this._dragRotY=0,this._dragMoved=!1,this._longPressStartTime=0,this._longPressActive=!1,this._holdProgress=0,this._holdRing=null,this._holdShockwave=null,this._miniEggs=[],this._collectLight=null,this._onCollectEgg=null,this._vortexParticles=[],this._emberParticles=[],this._collectFlashOpacity=0,this._collectShake=0,this._collectCamBaseZ=5,this._finaleInteractive=!1,this._finaleDragTarget=null,this._finalePausedRotation=[!1,!1,!1],this._onPointerDown=t=>{if(this._disposed)return;if(this._finaleInteractive&&this._finaleActive){let e=-1,i=1/0;for(let s=0;s<3;s++){const n=this.eggs[s];if(!n||!n.visible)continue;const r=this._worldToScreen(n.position),a=Math.sqrt((t.clientX-r.x)**2+(t.clientY-r.y)**2);a<i&&(i=a,e=s)}if(e<0||i>140)return;t.preventDefault(),t.stopPropagation(),this._finaleDragTarget=e,this._isDragging=!0,this._dragMoved=!1,this._dragStartX=t.clientX,this._dragStartY=t.clientY;const n=this.eggs[e];return this._dragRotX=n.rotation.x,this._dragRotY=n.rotation.y,void(this.canvas&&(this.canvas.style.cursor="grabbing"))}if(null===this._interactiveEgg)return;const e=this.eggs[this._interactiveEgg];if(!e||!e.visible)return;const i=this._worldToScreen(e.position),n=t.clientX-i.x,s=t.clientY-i.y;Math.sqrt(n*n+s*s)>120||(t.preventDefault(),t.stopPropagation(),this.canvas&&(this.canvas.style.cursor="grabbing"),this._isDragging=!0,this._dragMoved=!1,this._dragStartX=t.clientX,this._dragStartY=t.clientY,this._dragRotX=e.rotation.x,this._dragRotY=e.rotation.y,this._longPressStartTime=Date.now(),this._longPressActive=!0,this._holdProgress=0)},this._onPointerMove=t=>{if(!this._isDragging)return;if(null!==this._finaleDragTarget){t.preventDefault(),t.stopPropagation();const e=this.eggs[this._finaleDragTarget];if(!e)return;const i=t.clientX-this._dragStartX,n=t.clientY-this._dragStartY;return e.rotation.y=this._dragRotY+.008*i,e.rotation.x=this._dragRotX+.005*n,void((Math.abs(i)>5||Math.abs(n)>5)&&(this._finalePausedRotation[this._finaleDragTarget]=!0))}if(null===this._interactiveEgg)return;t.preventDefault(),t.stopPropagation();const e=this.eggs[this._interactiveEgg];if(!e)return;const i=t.clientX-this._dragStartX,n=t.clientY-this._dragStartY;e.rotation.y=this._dragRotY+.008*i,e.rotation.x=this._dragRotX+.005*n,(Math.abs(i)>15||Math.abs(n)>15)&&(this._dragMoved=!0,this._cancelLongPress())},this._onPointerUp=t=>{this._isDragging&&(t.preventDefault(),t.stopPropagation()),this._isDragging=!1,this._finaleDragTarget=null,this._cancelLongPress(),(null!==this._interactiveEgg||this._finaleInteractive)&&this.canvas&&(this.canvas.style.cursor="grab")},this._onWheel=t=>{this._disposed||this._isPointerNearAnyEgg(t.clientX,t.clientY)&&(t.preventDefault(),t.stopPropagation())},this._onClickCapture=t=>{this._disposed||this._isPointerNearAnyEgg(t.clientX,t.clientY)&&(t.preventDefault(),t.stopPropagation())},this._onMouseDownCapture=t=>{this._disposed||this._isPointerNearAnyEgg(t.clientX,t.clientY)&&(t.preventDefault(),t.stopPropagation())},this._onMouseUpCapture=t=>{this._isDragging&&(t.preventDefault(),t.stopPropagation())},this._onTouchStartCapture=t=>{if(this._disposed)return;const e=t.touches[0];e&&this._isPointerNearAnyEgg(e.clientX,e.clientY)&&(t.preventDefault(),t.stopPropagation())},this._onTouchMoveCapture=t=>{this._isDragging&&(t.preventDefault(),t.stopPropagation())},this._animate=()=>{if(!this._running||this._disposed)return;this._raf=requestAnimationFrame(this._animate);const t=Math.min(this._clock.getDelta(),.05);this._updateEggs(t),this._updateHoldRing(),this._updateMiniEggs(t),this._updateTrails(t),this._updateAmbientParticles(t),this._updateRevealParticles(t),this._updateFinale(t),this.renderer.render(this.scene,this.camera)},this._onResize=()=>{this.camera&&this.renderer&&this.canvas&&(this.camera.aspect=window.innerWidth/window.innerHeight,this.camera.updateProjectionMatrix(),this.renderer.setSize(window.innerWidth,window.innerHeight))},this.config=t,this._reducedMotion=t.accessibility.reducedMotion}onCollectEgg(t){this._onCollectEgg=t}async init(){try{const t="undefined"!=typeof window&&window.THREE;this.THREE=t||await Promise.resolve().then(()=>Kd)}catch{return!1}const t=this.THREE;return this.canvas=document.createElement("canvas"),this.canvas.id="eeq-three-canvas",Object.assign(this.canvas.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"999992"}),document.body.appendChild(this.canvas),this.renderer=new t.WebGLRenderer({canvas:this.canvas,alpha:!0,antialias:!0,powerPreference:"high-performance"}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.renderer.setSize(window.innerWidth,window.innerHeight),this.renderer.toneMapping=t.ACESFilmicToneMapping,this.renderer.toneMappingExposure=1.1,this.scene=new t.Scene,this.camera=new t.PerspectiveCamera(45,window.innerWidth/window.innerHeight,.1,100),this.camera.position.set(0,0,5),this._setupLights(t),this._setupEnvironment(t),this._createEggs(t),this._createHoldRing(t),this._clock=new t.Clock,window.addEventListener("resize",this._onResize),document.addEventListener("pointerdown",this._onPointerDown,{capture:!0}),document.addEventListener("pointermove",this._onPointerMove,{capture:!0}),document.addEventListener("pointerup",this._onPointerUp,{capture:!0}),document.addEventListener("wheel",this._onWheel,{capture:!0,passive:!1}),document.addEventListener("click",this._onClickCapture,{capture:!0}),document.addEventListener("mousedown",this._onMouseDownCapture,{capture:!0}),document.addEventListener("mouseup",this._onMouseUpCapture,{capture:!0}),document.addEventListener("touchstart",this._onTouchStartCapture,{capture:!0,passive:!1}),document.addEventListener("touchmove",this._onTouchMoveCapture,{capture:!0,passive:!1}),!0}startRenderLoop(){this._running||(this._running=!0,this._animate())}stopRenderLoop(){this._running=!1,this._raf&&cancelAnimationFrame(this._raf)}enableInteraction(t){this._interactiveEgg=t,this.canvas&&(this.canvas.style.cursor="grab")}disableInteraction(){this._interactiveEgg=null,this._isDragging=!1,this._finaleDragTarget=null,this._finaleInteractive=!1,this._cancelLongPress(),this.canvas&&(this.canvas.style.cursor="")}revealEgg(t){const e=this._eggStates[t];if(!e)return;e.visible=!0,e.phase="reveal",e.t=0;const i=this.eggs[t];i&&(i.visible=!0,i.scale.set(.01,.01,.01),i.position.set(0,0,0)),this._spawnRevealBurst(t),this.enableInteraction(t)}collectEgg(t){const e=this._eggStates[t];if(!e)return;const i=this.eggs[t];i&&(i.visible=!1);const n=this.eggBodies[t];(null==n?void 0:n.material)&&(n.material.emissiveIntensity=.05,n.material.opacity=1,n.material.transparent=!1),this.disableInteraction(),e.phase="shrine",e.t=0}resetForRestart(){var t,e,i,n,s,r,a;null==(t=this._greetingOverlay)||t.remove(),this._greetingOverlay=null,this.stopRenderLoop();for(let o=0;o<3;o++){this._eggStates[o]={visible:!1,phase:"hidden",t:0,targetPos:[0,0,0]},this.eggs[o]&&(this.eggs[o].visible=!1,this.eggs[o].scale.set(1,1,1),this.eggs[o].position.set(0,0,0),this.eggs[o].rotation.set(0,0,0));const t=this.eggBodies[o];(null==t?void 0:t.material)&&(t.material.emissiveIntensity=.05,t.material.opacity=1,t.material.transparent=!1)}this._finaleActive=!1,this._finaleT=0,this.disableInteraction();for(const o of[...this._trailParticles,...this._ambientParticles,...this._revealParticles,...this._vortexParticles,...this._emberParticles])null==(e=this.scene)||e.remove(o.mesh),null==(i=o.mesh.geometry)||i.dispose(),null==(n=o.mesh.material)||n.dispose();this._trailParticles=[],this._ambientParticles=[],this._revealParticles=[],this._vortexParticles=[],this._emberParticles=[];for(const o of this._miniEggs)null==(s=this.scene)||s.remove(o.mesh),null==(r=o.mesh.geometry)||r.dispose(),null==(a=o.mesh.material)||a.dispose();this._miniEggs=[]}addTrail(t,e,i){if(!this.THREE||!this.scene)return;const n=this.THREE,s=this._screenToWorld(t,e),r=Math.min(.05,3e-5*i),a=this._createMiniEggGeo(n,r),o=this._createMiniEggMat(n,.65),l=new n.Mesh(a,o);if(l.position.copy(s),l.rotation.set(Math.random()*Math.PI,Math.random()*Math.PI,Math.random()*Math.PI),this.scene.add(l),this._trailParticles.push({mesh:l,life:1}),this._trailParticles.length>100){const t=this._trailParticles.shift();t&&(this.scene.remove(t.mesh),t.mesh.geometry.dispose(),t.mesh.material.dispose())}}showProgressParticles(t,e="default"){if(!this.THREE||!this.scene||t<.05)return;const i=this.THREE,n=performance.now(),s="rhythm"===e;if(s){const e=Math.max(80,180-120*t);if(n-this._lastAmbientSpawnAt<e)return}else if(Math.random()>.3*t)return;this._lastAmbientSpawnAt=n;const r=s&&t>.6?2:1;for(let a=0;a<r;a++){const t=Math.random()*Math.PI*2,e=s?1.1+1.8*Math.random():2+2*Math.random(),n=Math.cos(t)*e,r=s?-2.8-.9*Math.random():4*Math.random()-2,a=s?.03+.03*Math.random():.02+.025*Math.random(),o=this._createMiniEggGeo(i,a),l=this._createMiniEggMat(i,0),h=new i.Mesh(o,l);h.position.set(n,r,.5*Math.random()-1),h.rotation.set(Math.random()*Math.PI,Math.random()*Math.PI,Math.random()*Math.PI),this.scene.add(h),this._ambientParticles.push({mesh:h,life:s?1.25:1,vy:s?.45+.35*Math.random():.2+.3*Math.random(),fadeIn:!0})}if(this._ambientParticles.length>60){const t=this._ambientParticles.shift();t&&(this.scene.remove(t.mesh),t.mesh.geometry.dispose(),t.mesh.material.dispose())}}fadeOutAmbientParticles(){for(const t of this._ambientParticles)t.fadeIn=!1,t.life>.3&&(t.life=.3)}startFinale(){this._finaleActive=!0,this._finaleT=0,this.disableInteraction(),this._finaleInteractive=!0,this._finaleDragTarget=null,this._finalePausedRotation=[!1,!1,!1],this.canvas&&(this.canvas.style.cursor="grab");for(let i=0;i<3;i++){const t=this._eggStates[i];t.phase="finale",t.t=0,this.eggs[i]&&(this.eggs[i].visible=!0)}this._greetingOverlay=document.createElement("div"),Object.assign(this._greetingOverlay.style,{position:"fixed",bottom:"12%",left:"0",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",zIndex:"999997",pointerEvents:"none",opacity:"0",transition:"opacity 2s ease",fontFamily:"'Georgia', 'Times New Roman', serif",textAlign:"center"}),this._greetingOverlay.innerHTML="";const t=document.createElement("div");Object.assign(t.style,{fontSize:"48px",color:"#fff8e8",textShadow:"0 0 60px rgba(212,165,80,0.7), 0 0 20px rgba(212,165,80,0.4), 0 2px 8px rgba(0,0,0,0.6)",marginBottom:"10px",letterSpacing:"0.03em",fontWeight:"bold"}),t.textContent="Happy Easter! 🐰🥚",this._greetingOverlay.appendChild(t);const e=document.createElement("div");Object.assign(e.style,{fontSize:"17px",color:"rgba(245,240,230,0.85)",fontStyle:"italic",textShadow:"0 0 12px rgba(212,165,80,0.3), 0 1px 6px rgba(0,0,0,0.4)"}),e.textContent="Wishing you joy, peace, and light",this._greetingOverlay.appendChild(e),document.body.appendChild(this._greetingOverlay),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._greetingOverlay&&(this._greetingOverlay.style.opacity="1")})})}setFestiveEggSeed(t){var e;const i=this.eggBodies[2];if(!i||!this.THREE)return;const n=this.THREE,s=new n.CanvasTexture(this._drawFestivePattern(t));s.colorSpace=n.SRGBColorSpace,s.wrapS=n.RepeatWrapping,null==(e=i.material.map)||e.dispose(),i.material.map=s,i.material.needsUpdate=!0}setBreathIntensity(t){if(!this.camera)return;const e=.04*t,i=.001*Date.now();this.camera.position.z=5+Math.sin(.8*i)*e}setOverlayIntensity(t){}destroy(){var t,e,i,n,s,r,a,o,l,h,c,u,d,p,m,f,g,_,v,y,x;this._disposed=!0,this.stopRenderLoop(),this.disableInteraction(),window.removeEventListener("resize",this._onResize),document.removeEventListener("pointerdown",this._onPointerDown,{capture:!0}),document.removeEventListener("pointermove",this._onPointerMove,{capture:!0}),document.removeEventListener("pointerup",this._onPointerUp,{capture:!0}),document.removeEventListener("wheel",this._onWheel,{capture:!0}),document.removeEventListener("click",this._onClickCapture,{capture:!0}),document.removeEventListener("mousedown",this._onMouseDownCapture,{capture:!0}),document.removeEventListener("mouseup",this._onMouseUpCapture,{capture:!0}),document.removeEventListener("touchstart",this._onTouchStartCapture,{capture:!0}),document.removeEventListener("touchmove",this._onTouchMoveCapture,{capture:!0}),document.body.style.cursor="";const M=[...this._trailParticles,...this._ambientParticles,...this._revealParticles,...this._vortexParticles,...this._emberParticles];for(const b of M)null==(t=this.scene)||t.remove(b.mesh),null==(e=b.mesh.geometry)||e.dispose(),null==(i=b.mesh.material)||i.dispose();this._trailParticles=[],this._ambientParticles=[],this._revealParticles=[],this._vortexParticles=[],this._emberParticles=[];for(const b of this.eggs)null==b||b.traverse(t=>{t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(t=>t.dispose()):t.material.dispose())}),null==(n=this.scene)||n.remove(b);this.eggs=[],this.eggBodies=[],this._holdRing&&(null==(s=this.scene)||s.remove(this._holdRing),null==(r=this._holdRing.geometry)||r.dispose(),null==(a=this._holdRing.material)||a.dispose()),this._holdShockwave&&(null==(o=this.scene)||o.remove(this._holdShockwave),null==(l=this._holdShockwave.geometry)||l.dispose(),null==(h=this._holdShockwave.material)||h.dispose());for(const b of this._miniEggs)null==(c=this.scene)||c.remove(b.mesh),null==(u=b.mesh.geometry)||u.dispose(),null==(d=b.mesh.material)||d.dispose();this._miniEggs=[],this._collectLight&&(null==(p=this.scene)||p.remove(this._collectLight),null==(f=(m=this._collectLight).dispose)||f.call(m),this._collectLight=null);for(const b of this.lights)null==(g=this.scene)||g.remove(b);this.lights=[],(null==(_=this.scene)?void 0:_.environment)&&(this.scene.environment.dispose(),this.scene.environment=null),null==(v=this.renderer)||v.dispose(),null==(y=this.canvas)||y.remove(),null==(x=this._greetingOverlay)||x.remove(),this._greetingOverlay=null,this.canvas=null,this.renderer=null,this.scene=null,this.camera=null}_setupLights(t){const e=new t.AmbientLight(16775408,.6);this.scene.add(e),this.lights.push(e);const i=new t.DirectionalLight(16772306,1);i.position.set(3,5,4),this.scene.add(i),this.lights.push(i);const n=new t.DirectionalLight(13687024,.35);n.position.set(-4,3,2),this.scene.add(n),this.lights.push(n);const s=new t.PointLight(16763016,.5,12);s.position.set(0,-3,3),this.scene.add(s),this.lights.push(s);const r=new t.PointLight(16777215,.3,10);r.position.set(0,4,2),this.scene.add(r),this.lights.push(r)}_setupEnvironment(t){const e=new t.PMREMGenerator(this.renderer);e.compileCubemapShader();const i=new t.Scene,n=new t.SphereGeometry(50,32,16),s=new t.ShaderMaterial({side:t.BackSide,uniforms:{},vertexShader:"\n varying vec3 vWorldPos;\n void main() {\n vWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;\n gl_Position = projectionMatrix * viewMatrix * vec4(vWorldPos, 1.0);\n }\n ",fragmentShader:"\n varying vec3 vWorldPos;\n void main() {\n float y = normalize(vWorldPos).y;\n // Top: warm bright sky\n vec3 top = vec3(0.85, 0.88, 0.95);\n // Horizon: bright neutral white\n vec3 mid = vec3(0.95, 0.93, 0.90);\n // Bottom: warm ground bounce\n vec3 bot = vec3(0.75, 0.68, 0.62);\n vec3 color;\n if (y > 0.0) {\n color = mix(mid, top, y);\n } else {\n color = mix(mid, bot, -y);\n }\n // Bright highlight (simulates studio softbox)\n float sun = max(0.0, dot(normalize(vWorldPos), normalize(vec3(2.0, 5.0, 3.0))));\n color += vec3(1.0, 0.97, 0.92) * pow(sun, 16.0) * 0.8;\n // Fill light opposite side\n float fill = max(0.0, dot(normalize(vWorldPos), normalize(vec3(-3.0, 2.0, 1.0))));\n color += vec3(0.7, 0.8, 0.95) * pow(fill, 8.0) * 0.3;\n gl_FragColor = vec4(color, 1.0);\n }\n "}),r=new t.Mesh(n,s);i.add(r);const a=e.fromScene(i,.04).texture;this.scene.environment=a,n.dispose(),s.dispose(),i.clear(),e.dispose()}_createEggs(t){const e=this._createEggGeometry(t),i=new t.Group,n=new t.CanvasTexture(this._drawSilverPolkaDots());n.colorSpace=t.SRGBColorSpace,n.wrapS=t.RepeatWrapping;const s=new t.CanvasTexture(this._drawSilverRoughness());s.wrapS=t.RepeatWrapping;const r=new t.Mesh(e.clone(),new t.MeshPhysicalMaterial({map:n,roughness:.15,roughnessMap:s,metalness:.92,clearcoat:.3,clearcoatRoughness:.1,emissive:2236979,emissiveIntensity:.02,envMapIntensity:1}));i.add(r),i.visible=!1,this.scene.add(i),this.eggs.push(i),this.eggBodies.push(r);const a=new t.Group,o=new t.CanvasTexture(this._drawGoldPattern());o.colorSpace=t.SRGBColorSpace,o.wrapS=t.RepeatWrapping;const l=new t.CanvasTexture(this._drawGoldRoughness());l.wrapS=t.RepeatWrapping;const h=new t.Mesh(e.clone(),new t.MeshPhysicalMaterial({map:o,roughness:.2,roughnessMap:l,metalness:.95,clearcoat:.2,clearcoatRoughness:.15,emissive:3811848,emissiveIntensity:.06,envMapIntensity:1}));a.add(h),a.visible=!1,this.scene.add(a),this.eggs.push(a),this.eggBodies.push(h);const c=new t.Group,u=new t.CanvasTexture(this._drawFestivePattern());u.colorSpace=t.SRGBColorSpace,u.wrapS=t.RepeatWrapping;const d=new t.CanvasTexture(this._drawFestiveRoughness());d.wrapS=t.RepeatWrapping;const p=new t.Mesh(e.clone(),new t.MeshPhysicalMaterial({map:u,roughness:.22,roughnessMap:d,metalness:.35,clearcoat:.8,clearcoatRoughness:.05,emissive:1708064,emissiveIntensity:.04,envMapIntensity:.8,sheen:.4,sheenColor:new t.Color(16765088),sheenRoughness:.3}));c.add(p),c.visible=!1,this.scene.add(c),this.eggs.push(c),this.eggBodies.push(p)}_createMiniEggGeo(t,e){const i=new t.SphereGeometry(e,12,12),n=i.attributes.position;for(let s=0;s<n.count;s++){let t=n.getY(s);const e=n.getX(s),i=n.getZ(s);t=1.08*t*(t>0?.95:1);const r=1-.03*Math.abs(t);n.setX(s,e*r),n.setY(s,t),n.setZ(s,i*r)}return i.computeVertexNormals(),i}_createMiniEggMat(t,e){const i=document.createElement("canvas");i.width=64,i.height=64;const n=i.getContext("2d"),s=360*Math.random(),r=60+25*Math.random(),a=68+14*Math.random();n.fillStyle=`hsl(${s}, ${r}%, ${a}%)`,n.fillRect(0,0,64,64);const o=(s+80+100*Math.random())%360,l=r+10,h=Math.max(35,a-30);n.lineWidth=2;const c=1+Math.floor(2*Math.random());for(let d=0;d<c;d++){const t=0===d?o:(o+120)%360;n.strokeStyle=`hsla(${t}, ${l}%, ${h}%, 0.7)`,n.fillStyle=`hsla(${t}, ${l}%, ${h+10}%, 0.5)`;const e=16*d-8;switch(Math.floor(6*Math.random())){case 0:n.beginPath(),n.moveTo(0,24+e),n.lineTo(64,24+e),n.moveTo(0,40+e),n.lineTo(64,40+e),n.stroke();break;case 1:for(let t=0;t<6;t++)n.beginPath(),n.arc(8+48*Math.random(),8+48*Math.random(),2.5+2.5*Math.random(),0,2*Math.PI),n.fill();break;case 2:n.beginPath(),n.moveTo(0,32+e);for(let t=6;t<=64;t+=6)n.lineTo(t,32+e+(t/6%2==0?-7:7));n.stroke();break;case 3:n.fillRect(0,24+e,64,16);break;case 4:n.beginPath();for(let t=0;t<64;t+=12)n.moveTo(t,0),n.lineTo(t+32,64),n.moveTo(t+32,0),n.lineTo(t,64);n.stroke();break;default:n.beginPath(),n.moveTo(0,32+e);for(let t=0;t<=64;t+=2)n.lineTo(t,32+e+5*Math.sin(.3*t));n.stroke()}}const u=new t.CanvasTexture(i);return new t.MeshBasicMaterial({map:u,transparent:!0,opacity:e||.85})}_createEggGeometry(t){const e=new t.SphereGeometry(.42,48,48),i=e.attributes.position;for(let n=0;n<i.count;n++){let t=i.getY(n);const e=i.getX(n),s=i.getZ(n);t=1.45*t*(t>0?.82:1);const r=1-.12*Math.abs(t);i.setX(n,e*r),i.setY(n,t),i.setZ(n,s*r)}return e.computeVertexNormals(),e}_drawSilverPolkaDots(){const t=512,e=document.createElement("canvas");e.width=t,e.height=t;const i=e.getContext("2d"),n=i.createLinearGradient(0,0,0,t);n.addColorStop(0,"#e0e4ea"),n.addColorStop(.4,"#d5d9e0"),n.addColorStop(.6,"#cdd1d8"),n.addColorStop(1,"#c8c4c0"),i.fillStyle=n,i.fillRect(0,0,t,t),i.fillStyle="#f4f4f6",i.shadowColor="rgba(255,255,255,0.5)",i.shadowBlur=6;for(let s=0;s<t/52+1;s++){const t=s%2*32;for(let e=-1;e<9;e++){const n=64*e+t,r=52*s;i.beginPath(),i.arc(n,r,22,0,2*Math.PI),i.fill()}}return i.shadowBlur=0,e}_drawSilverRoughness(){const t=512,e=document.createElement("canvas");e.width=t,e.height=t;const i=e.getContext("2d");i.fillStyle="#333",i.fillRect(0,0,t,t),i.fillStyle="#999";for(let n=0;n<t/52+1;n++){const t=n%2*32;for(let e=-1;e<9;e++){const s=64*e+t,r=52*n;i.beginPath(),i.arc(s,r,22,0,2*Math.PI),i.fill()}}return e}_drawGoldPattern(){const t=512,e=document.createElement("canvas");e.width=t,e.height=t;const i=e.getContext("2d"),n=i.createLinearGradient(0,0,0,t);n.addColorStop(0,"#c8960a"),n.addColorStop(.3,"#daa520"),n.addColorStop(.5,"#e6b422"),n.addColorStop(.7,"#c89618"),n.addColorStop(1,"#b8860b"),i.fillStyle=n,i.fillRect(0,0,t,t),i.globalAlpha=.2;for(const s of[.25,.5,.75]){const e=s*t,n=30,r=i.createLinearGradient(0,e-n,0,e+n);r.addColorStop(0,"#b8860b"),r.addColorStop(.5,"#f0d060"),r.addColorStop(1,"#b8860b"),i.fillStyle=r,i.fillRect(0,e-n,t,2*n)}i.globalAlpha=1,i.strokeStyle="#a07008",i.lineWidth=1.2,i.globalAlpha=.15;for(let s=-512;s<1024;s+=32)i.beginPath(),i.moveTo(s,0),i.lineTo(s+t,t),i.stroke(),i.beginPath(),i.moveTo(s+t,0),i.lineTo(s,t),i.stroke();i.globalAlpha=1,i.strokeStyle="#d4a510",i.lineWidth=2,i.globalAlpha=.3;for(const s of[.22,.28,.47,.53,.72,.78]){const e=s*t;i.beginPath(),i.moveTo(0,e),i.lineTo(t,e),i.stroke()}return i.globalAlpha=1,e}_drawGoldRoughness(){const t=512,e=document.createElement("canvas");e.width=t,e.height=t;const i=e.getContext("2d");i.fillStyle="#444",i.fillRect(0,0,t,t);for(const n of[.25,.5,.75]){const e=n*t;i.fillStyle="#666",i.fillRect(0,e-30,t,60)}return e}_drawFestivePattern(t){const e=512,i=document.createElement("canvas");i.width=e,i.height=e;const n=i.getContext("2d");let s=t??25214903917^Date.now();const r=()=>{s=s+1831565813|0;let t=Math.imul(s^s>>>15,1|s);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296},a=360*r(),o=[];for(let u=0;u<5;u++)o.push((a+u*(50+30*r()))%360);const l=e/9;for(let u=0;u<9;u++){const t=u*l;if(u%2==1){const e=52+10*r(),i=n.createLinearGradient(0,t,0,t+l);i.addColorStop(0,`hsl(43, 80%, ${e}%)`),i.addColorStop(1,`hsl(43, 75%, ${e-6}%)`),n.fillStyle=i}else{const e=o[Math.floor(u/2)%o.length],i=55+30*r(),s=35+15*r(),a=n.createLinearGradient(0,t,0,t+l);a.addColorStop(0,`hsl(${e}, ${i}%, ${s}%)`),a.addColorStop(1,`hsl(${e}, ${i}%, ${s-8}%)`),n.fillStyle=a}n.fillRect(0,t,e,l+1)}const h=Math.floor(4*r());if(n.strokeStyle="hsla(43, 70%, 60%, 0.2)",n.lineWidth=1.5,0===h){const t=r()<.5?32:64;for(let i=-512;i<1024;i+=t)n.beginPath(),n.moveTo(i,0),n.lineTo(i+e,e),n.stroke(),n.beginPath(),n.moveTo(i+e,0),n.lineTo(i,e),n.stroke()}else if(1===h){const t=32;for(let i=0;i<9;i+=2){const s=(i+.5)*l;for(let i=t/2;i<e;i+=t)n.beginPath(),n.arc(i,s,.38*t,0,2*Math.PI),n.stroke()}}else if(2===h){const t=8+8*r(),i=[16,32,64][Math.floor(3*r())];for(let s=0;s<9;s+=2){const r=(s+.5)*l;n.beginPath(),n.moveTo(0,r);for(let s=0;s<=e;s+=i)n.lineTo(s,r+(s/i%2==0?-t:t));n.stroke()}}else for(let u=0;u<9;u+=2){const t=(u+.5)*l;for(const i of[.2*-l,.2*l]){n.beginPath();for(let s=0;s<=e;s+=2)n.lineTo(s,t+i+4*Math.sin(s*(8*Math.PI/e)+.5*r()));n.stroke()}}const c=10+Math.floor(10*r());for(let u=1;u<9;u+=2){const t=(u+.5)*l;for(let i=0;i<c;i++){const s=(i+.5)*(e/c),a=o[Math.floor(r()*o.length)];if(n.fillStyle=`hsl(${a}, 70%, 55%)`,n.beginPath(),r()<.5)n.arc(s,t,3+3*r(),0,2*Math.PI);else{const e=3+3*r();n.moveTo(s,t-e),n.lineTo(s+e,t),n.lineTo(s,t+e),n.lineTo(s-e,t)}n.fill()}}return i}_drawFestiveRoughness(){const t=512,e=document.createElement("canvas");e.width=t,e.height=t;const i=e.getContext("2d");i.fillStyle="#555",i.fillRect(0,0,t,t);const n=t/9,s=[1,3,5,7];for(const r of s)i.fillStyle="#333",i.fillRect(0,r*n,t,n);return e}_createHoldRing(t){}_spawnRevealBurst(t){if(!this.THREE||!this.scene)return;const e=this.THREE,i=[[12632264,14540270,16777215],[16766720,13145600,16769152],[13369376,17612,43568,16766720,8913066]],n=i[t]??i[0],s=40+20*t;for(let r=0;r<s;r++){const t=.015+.03*Math.random(),i=new e.SphereGeometry(t,5,5),s=n[Math.floor(Math.random()*n.length)],r=new e.MeshBasicMaterial({color:s,transparent:!0,opacity:.8}),a=new e.Mesh(i,r),o=Math.random()*Math.PI*2,l=Math.random()*Math.PI,h=1.5+2.5*Math.random(),c=Math.sin(l)*Math.cos(o)*h,u=Math.sin(l)*Math.sin(o)*h,d=Math.cos(l)*h;a.position.set(0,0,0),this.scene.add(a),this._revealParticles.push({mesh:a,life:1,vx:c,vy:u,vz:d})}}_spawnVortex(t){if(!this.THREE||!this.scene)return;const e=this.THREE,i=this.eggs[t],n=i?i.position.clone():new e.Vector3(0,0,0);for(let s=0;s<60;s++){const t=.008+.015*Math.random(),i=new e.SphereGeometry(t,6,6),r=.1+.06*Math.random(),a=(new e.Color).setHSL(r,.8,.6+.3*Math.random()),o=new e.MeshBasicMaterial({color:a,transparent:!0,opacity:0}),l=new e.Mesh(i,o),h=s/60*Math.PI*2+.3*Math.random(),c=1.2+.8*Math.random(),u=1*(Math.random()-.5);l.position.set(n.x+Math.cos(h)*c,n.y+u,n.z+Math.sin(h)*c),this.scene.add(l),this._vortexParticles.push({mesh:l,life:1,angle:h,radius:c,yOff:u,originX:n.x,originY:n.y,originZ:n.z,speed:1.5+1.5*Math.random(),delay:.008*s+.15*Math.random()})}}_spawnEmbers(t){if(!this.THREE||!this.scene)return;const e=this.THREE,i=this.eggs[t],n=i?i.position.clone():new e.Vector3(0,0,0);for(let s=0;s<35;s++){const t=.006+.012*Math.random(),i=new e.SphereGeometry(t,4,4),s=.08+.1*Math.random(),r=(new e.Color).setHSL(s,.7,.5+.4*Math.random()),a=new e.MeshBasicMaterial({color:r,transparent:!0,opacity:.9}),o=new e.Mesh(i,a),l=.3;o.position.set(n.x+(Math.random()-.5)*l,n.y+(Math.random()-.5)*l,n.z+(Math.random()-.5)*l*.3),this.scene.add(o),this._emberParticles.push({mesh:o,life:1,vx:.3*(Math.random()-.5),vy:.4+.6*Math.random(),vz:.1*(Math.random()-.5),flicker:Math.random()*Math.PI*2})}}_updateVortexParticles(t,e){var i;for(let n=this._vortexParticles.length-1;n>=0;n--){const s=this._vortexParticles[n];if(e<s.delay)continue;const r=Math.min(1,(e-s.delay)/(.55-s.delay)),a=s.radius*(1-r*r*.95);s.angle+=t*s.speed*(1+4*r);const o=s.yOff*(1-r);s.mesh.position.x=s.originX+Math.cos(s.angle)*a,s.mesh.position.y=s.originY+o,s.mesh.position.z=s.originZ+Math.sin(s.angle)*a,s.mesh.material.opacity=r<.2?r/.2*.85:r>.85?(1-r)/.15*.85:.85,s.mesh.scale.setScalar(.8+.3*Math.sin(3*s.angle)),r>=1&&(null==(i=this.scene)||i.remove(s.mesh),s.mesh.geometry.dispose(),s.mesh.material.dispose(),this._vortexParticles.splice(n,1))}}_updateEmberParticles(t){var e;for(let i=this._emberParticles.length-1;i>=0;i--){const n=this._emberParticles[i];n.life-=.4*t,n.mesh.position.x+=n.vx*t,n.mesh.position.y+=n.vy*t,n.mesh.position.z+=n.vz*t,n.flicker+=3*t,n.mesh.position.x+=Math.sin(n.flicker)*t*.15,n.vx*=.995,n.vz*=.995;const s=.7+.3*Math.sin(4*n.flicker);n.mesh.material.opacity=Math.max(0,n.life*s),n.mesh.scale.setScalar(.5+.5*n.life),n.life<=0&&(null==(e=this.scene)||e.remove(n.mesh),n.mesh.geometry.dispose(),n.mesh.material.dispose(),this._emberParticles.splice(i,1))}}_cancelLongPress(){var t;if(this._longPressActive=!1,this._holdProgress=0,null!==this._interactiveEgg){const e=this.eggs[this._interactiveEgg];e&&(e.scale.setScalar(.9),e.rotation.z=0);const i=this.eggBodies[this._interactiveEgg];void 0!==(null==(t=null==i?void 0:i.material)?void 0:t.emissiveIntensity)&&(i.material.emissiveIntensity=.05)}}_worldToScreen(t){if(!this.THREE||!this.camera)return{x:0,y:0};const e=(new this.THREE.Vector3).copy(t);return e.project(this.camera),{x:(.5*e.x+.5)*window.innerWidth,y:(.5*-e.y+.5)*window.innerHeight}}_isPointerNearAnyEgg(t,e){if(this._finaleInteractive){for(let i=0;i<3;i++){const n=this.eggs[i];if(!n||!n.visible)continue;const s=this._worldToScreen(n.position);if(Math.sqrt((t-s.x)**2+(e-s.y)**2)<=140)return!0}return!1}if(null===this._interactiveEgg)return!1;const i=this.eggs[this._interactiveEgg];if(!i||!i.visible)return!1;const n=this._worldToScreen(i.position);return Math.sqrt((t-n.x)**2+(e-n.y)**2)<=120}_screenToWorld(t,e){const i=this.THREE,n=t/window.innerWidth*2-1,s=-e/window.innerHeight*2+1,r=new i.Vector3(n,s,.5);r.unproject(this.camera);const a=r.sub(this.camera.position).normalize(),o=-this.camera.position.z/a.z;return this.camera.position.clone().add(a.multiplyScalar(o))}_updateEggs(t){var e,i;if(this.THREE)for(let n=0;n<3;n++){const s=this.eggs[n],r=this._eggStates[n];if(r.visible&&s)switch(r.t+=t,r.phase){case"reveal":{const t=3,i=Math.min(1,r.t/t),a=2*Math.PI/3,o=0===i?0:1===i?1:Math.pow(2,-10*i)*Math.sin((10*i-.75)*a)+1;s.scale.setScalar(.9*o),s.rotation.y=1.2*r.t,s.position.y=.06*Math.sin(2*r.t)*(1-i);const l=this.eggBodies[n];void 0!==(null==(e=null==l?void 0:l.material)?void 0:e.emissiveIntensity)&&(l.material.emissiveIntensity=.15+.1*Math.sin(4*r.t)),i>=1&&(r.phase="interactive",r.t=0);break}case"interactive":{this._isDragging&&this._interactiveEgg===n||(s.rotation.y+=.25*t),s.position.y=.04*Math.sin(.7*r.t);const e=this.eggBodies[n];void 0!==(null==(i=null==e?void 0:e.material)?void 0:i.emissiveIntensity)&&(e.material.emissiveIntensity=.05+.04*Math.sin(1.5*r.t));break}case"collecting":s.visible=!1,r.phase="shrine",r.t=0;break;case"shrine":{s.rotation.y+=.15*t;const e=.32+.01*Math.sin(1*r.t);s.scale.setScalar(e);break}}}}_updateHoldRing(){var t;if(!this._longPressActive||null===this._interactiveEgg)return;const e=Date.now()-this._longPressStartTime;this._holdProgress=Math.min(1,e/1200);const i=this._holdProgress,n=.001*e,s=this.eggs[this._interactiveEgg];if(!s)return;const r=.9*(1+.35*i);if(s.scale.setScalar(r),i>.4){const t=.03*(i-.4);s.rotation.z=Math.sin(12*n)*t,s.rotation.x=Math.cos(10*n)*t*.5}if(i>=1){const e=this._interactiveEgg;this._spawnMiniEggBurst(e),this._cancelLongPress(),null==(t=this._onCollectEgg)||t.call(this,e)}}_spawnMiniEggBurst(t){if(!this.THREE||!this.scene)return;const e=this.THREE,i=this.eggs[t];if(!i)return;const n=i.position.clone(),s=[{main:12634328,accent:8425648},{main:15253568,accent:13934624},{main:13647968,accent:8401056}],r=s[t]??s[0],a=new e.SphereGeometry(.06,12,12),o=a.attributes.position;for(let l=0;l<o.count;l++){let t=o.getY(l);t=1.4*t*(t>0?.82:1),o.setY(l,t)}a.computeVertexNormals();for(let l=0;l<18;l++){const t=Math.random()>.35?r.main:r.accent,i=new e.MeshStandardMaterial({color:t,roughness:.3,metalness:.5,emissive:t,emissiveIntensity:.15,transparent:!0,opacity:1}),s=new e.Mesh(a,i);s.position.copy(n);const o=.5+.8*Math.random();s.scale.setScalar(o),s.rotation.set(Math.random()*Math.PI,Math.random()*Math.PI,Math.random()*Math.PI);const l=Math.random()*Math.PI*2,h=Math.acos(2*Math.random()-1),c=2+3*Math.random(),u=Math.sin(h)*Math.cos(l)*c,d=Math.sin(h)*Math.sin(l)*c*.8+1,p=Math.cos(h)*c;this.scene.add(s),this._miniEggs.push({mesh:s,vx:u,vy:d,vz:p,life:1,spin:8*(Math.random()-.5)})}}_updateMiniEggs(t){var e,i;for(let n=this._miniEggs.length-1;n>=0;n--){const s=this._miniEggs[n];s.life-=1.2*t,s.vy-=5*t,s.mesh.position.x+=s.vx*t,s.mesh.position.y+=s.vy*t,s.mesh.position.z+=s.vz*t,s.mesh.rotation.y+=s.spin*t,s.mesh.rotation.x+=s.spin*t*.5;const r=Math.max(0,s.life);s.mesh.material.opacity=r,s.mesh.scale.multiplyScalar(1-.5*t),s.life<=0&&(null==(e=this.scene)||e.remove(s.mesh),null==(i=s.mesh.material)||i.dispose(),this._miniEggs.splice(n,1))}}_updateFinale(t){var e;if(!this._finaleActive||!this.THREE)return;this._finaleT+=t;const i=.35*this._finaleT;for(let n=0;n<3;n++){const t=this.eggs[n];if(!t)continue;t.visible=!0;const s=i+n*(2*Math.PI/3),r=1.4*Math.sin(s),a=.05*Math.sin(.6*this._finaleT+1.2*n)-.1,o=.42*Math.cos(s);t.position.x+=.06*(r-t.position.x),t.position.y+=.06*(a-t.position.y),t.position.z+=.06*(o-t.position.z),this._finalePausedRotation[n]||(t.rotation.y=.4*this._finaleT+n*(2*Math.PI/3)),t.scale.setScalar(t.scale.x+.04*(.55-t.scale.x));const l=this.eggBodies[n];if(void 0!==(null==(e=null==l?void 0:l.material)?void 0:e.emissiveIntensity)){const t=.15+.08*Math.sin(2*this._finaleT+1.5*n);l.material.emissiveIntensity+=.05*(t-l.material.emissiveIntensity)}}this._finaleT>5&&this._finaleT<5.1&&this.renderer&&(this.renderer.toneMappingExposure=2.8),this._finaleT>5.1&&this._finaleT<8&&this.renderer&&(this.renderer.toneMappingExposure=Math.max(1.1,2.8-.55*(this._finaleT-5.1)))}_updateTrails(t){for(let e=this._trailParticles.length-1;e>=0;e--){const i=this._trailParticles[e];i.life-=.5*t,i.life<=0?(this.scene.remove(i.mesh),i.mesh.geometry.dispose(),i.mesh.material.dispose(),this._trailParticles.splice(e,1)):(i.mesh.material.opacity=.65*i.life,i.mesh.position.y+=.15*t,i.mesh.scale.setScalar(i.life),i.mesh.rotation.z+=.8*t)}}_updateAmbientParticles(t){for(let e=this._ambientParticles.length-1;e>=0;e--){const i=this._ambientParticles[e];i.life-=.25*t,i.mesh.position.y+=i.vy*t,i.mesh.rotation.z+=.5*t,i.fadeIn&&i.life>.7?(i.mesh.material.opacity=Math.min(.9,i.mesh.material.opacity+1*t),i.mesh.material.opacity>=.85&&(i.fadeIn=!1)):i.mesh.material.opacity=Math.max(0,.85*i.life),i.life<=0&&(this.scene.remove(i.mesh),i.mesh.geometry.dispose(),i.mesh.material.dispose(),this._ambientParticles.splice(e,1))}}_updateRevealParticles(t){for(let e=this._revealParticles.length-1;e>=0;e--){const i=this._revealParticles[e];i.life-=.6*t,i.mesh.position.x+=i.vx*t,i.mesh.position.y+=i.vy*t,i.mesh.position.z+=i.vz*t,i.vy-=1.5*t,i.mesh.material.opacity=Math.max(0,.8*i.life),i.mesh.scale.setScalar(Math.max(.01,i.life)),i.life<=0&&(this.scene.remove(i.mesh),i.mesh.geometry.dispose(),i.mesh.material.dispose(),this._revealParticles.splice(e,1))}}}class x{constructor(t){this.host=null,this.shadow=null,this.container=null,this.eggs=[],this._finaleActive=!1,this.config=t}async init(){this.host=document.createElement("div"),this.host.id="eeq-fallback-host",Object.assign(this.host.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"999992"}),document.body.appendChild(this.host),this.shadow=this.host.attachShadow({mode:"closed"});const t=document.createElement("style");t.textContent=this._getStyles(),this.shadow.appendChild(t),this.container=document.createElement("div"),this.container.className="eeq-f-container",this.shadow.appendChild(this.container);for(let e=0;e<3;e++){const t=document.createElement("div");t.className=`eeq-f-egg eeq-f-egg-${e+1} eeq-f-hidden`;const i=document.createElement("div");i.className="eeq-f-egg-inner";const n=document.createElement("div");n.className="eeq-f-egg-shine",i.appendChild(n),t.appendChild(i),this.container.appendChild(t),this.eggs.push(t)}return!0}startRenderLoop(){}stopRenderLoop(){}revealEgg(t){const e=this.eggs[t];e&&(e.classList.remove("eeq-f-hidden"),e.classList.add("eeq-f-reveal"))}collectEgg(t){const e=this.eggs[t];e&&(e.classList.remove("eeq-f-reveal"),e.classList.add("eeq-f-collected"))}addTrail(t,e,i){if(!this.container)return;const n=document.createElement("div");n.className="eeq-f-trail";const s=360*Math.random();n.style.background=`hsl(${s}, 50%, 78%)`,n.style.left=`${t}px`,n.style.top=`${e}px`,this.container.appendChild(n),setTimeout(()=>n.remove(),1200)}startFinale(){this._finaleActive=!0;for(const t of this.eggs)t.classList.remove("eeq-f-collected","eeq-f-hidden"),t.classList.add("eeq-f-finale");this.container&&this.container.classList.add("eeq-f-finale-active")}setBreathIntensity(t){}setOverlayIntensity(t){}destroy(){var t;null==(t=this.host)||t.remove(),this.host=null,this.shadow=null,this.container=null,this.eggs=[]}_getStyles(){const t=this.config.theme;return`\n .eeq-f-container {\n position: fixed;\n top: 0; left: 0;\n width: 100%; height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 32px;\n pointer-events: none;\n }\n\n .eeq-f-egg {\n width: 60px;\n height: 80px;\n border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;\n position: relative;\n transition: all 1.5s cubic-bezier(0.22, 1, 0.36, 1);\n }\n\n .eeq-f-hidden {\n opacity: 0;\n transform: scale(0.1);\n }\n\n .eeq-f-reveal {\n opacity: 1;\n transform: scale(1);\n animation: eeq-f-float 3s ease-in-out infinite;\n }\n\n .eeq-f-collected {\n opacity: 0.6;\n transform: scale(0.5) translateY(200px);\n position: fixed;\n bottom: 30px;\n }\n\n .eeq-f-finale {\n opacity: 1;\n transform: scale(1);\n animation: eeq-f-finale-spin 3s linear infinite;\n }\n\n .eeq-f-finale-active {\n animation: eeq-f-glow-bg 2s ease-in-out forwards;\n }\n\n .eeq-f-egg-inner {\n width: 100%;\n height: 100%;\n border-radius: inherit;\n position: relative;\n overflow: hidden;\n }\n\n .eeq-f-egg-shine {\n position: absolute;\n top: 15%;\n left: 20%;\n width: 30%;\n height: 25%;\n border-radius: 50%;\n background: rgba(255,255,255,0.4);\n filter: blur(4px);\n }\n\n /* Egg 1: Porcelain */\n .eeq-f-egg-1 .eeq-f-egg-inner {\n background: linear-gradient(145deg, #f5f0eb 0%, #e8e0d8 50%, #d8d0c8 100%);\n box-shadow: 0 4px 24px rgba(212,165,116,0.2), inset 0 2px 8px rgba(255,255,255,0.3);\n }\n\n /* Egg 2: Luminous pearl */\n .eeq-f-egg-2 .eeq-f-egg-inner {\n background: linear-gradient(145deg, #faf5f0 0%, #f0e8e0 40%, #e5ddd5 100%);\n box-shadow: 0 4px 28px rgba(212,165,116,0.3), inset 0 2px 12px rgba(255,255,255,0.4);\n }\n\n /* Egg 3: Golden core */\n .eeq-f-egg-3 .eeq-f-egg-inner {\n background: linear-gradient(145deg, #fff8f0 0%, #f5e8d5 40%, ${t.accent} 100%);\n box-shadow: 0 4px 32px ${t.accentGlow}, inset 0 2px 16px rgba(255,255,255,0.4);\n }\n\n .eeq-f-trail {\n position: fixed;\n width: 8px;\n height: 11px;\n border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;\n background: ${t.accent};\n opacity: 0.4;\n pointer-events: none;\n animation: eeq-f-trail-fade 1.2s ease-out forwards;\n }\n\n @keyframes eeq-f-float {\n 0%, 100% { transform: scale(1) translateY(0); }\n 50% { transform: scale(1) translateY(-8px); }\n }\n\n @keyframes eeq-f-finale-spin {\n from { transform: scale(1) rotate(0deg); }\n to { transform: scale(1) rotate(360deg); }\n }\n\n @keyframes eeq-f-trail-fade {\n 0% { opacity: 0.5; transform: scale(1); }\n 100% { opacity: 0; transform: scale(0.2) translateY(-10px); }\n }\n\n @keyframes eeq-f-glow-bg {\n 0% { background: transparent; }\n 50% { background: rgba(212,165,116,0.08); }\n 100% { background: transparent; }\n }\n `}}class M{constructor(t){this.overlay=null,this._visible=!1,this.config=t}mount(){this.overlay=document.createElement("div"),this.overlay.id="eeq-overlay",Object.assign(this.overlay.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",background:"transparent",backdropFilter:"none",WebkitBackdropFilter:"none",zIndex:"999985",pointerEvents:"none",transition:"background 1.5s ease, backdrop-filter 1.5s ease",opacity:"0"}),document.body.appendChild(this.overlay)}show(){this.overlay&&!this._visible&&(this._visible=!0,requestAnimationFrame(()=>{this.overlay&&(this.overlay.style.opacity="1",this.overlay.style.background=this.config.theme.overlayBg,this.overlay.style.backdropFilter="blur(2px)",this.overlay.style.WebkitBackdropFilter="blur(2px)")}))}setIntensity(t){if(!this.overlay)return;const e=.25+.25*t;this.overlay.style.background=`rgba(0,0,0,${e})`;const i=2+4*t;this.overlay.style.backdropFilter=`blur(${i}px)`,this.overlay.style.WebkitBackdropFilter=`blur(${i}px)`}hide(){this.overlay&&(this._visible=!1,this.overlay.style.opacity="0",this.overlay.style.background="transparent",this.overlay.style.backdropFilter="none",this.overlay.style.WebkitBackdropFilter="none")}destroy(){var t;null==(t=this.overlay)||t.remove(),this.overlay=null}}const b=class{constructor(t){this.host=null,this.shadow=null,this._onFinish=null,this.config=t}show(t,e){var i,n;this._onFinish=e,this.host=document.createElement("div"),this.host.id="eeq-results-host",Object.assign(this.host.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",zIndex:"999998",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none"}),document.body.appendChild(this.host),this.shadow=this.host.attachShadow({mode:"closed"});const s=document.createElement("style");s.textContent=this._getStyles(),this.shadow.appendChild(s);const r=document.createElement("div");r.className="eeq-results",this._buildContentDOM(r,t),this.shadow.appendChild(r),requestAnimationFrame(()=>{requestAnimationFrame(()=>{r.classList.add("eeq-results-visible")})}),null==(i=this.shadow.querySelector(".eeq-btn-finish"))||i.addEventListener("click",()=>{var t;return null==(t=this._onFinish)?void 0:t.call(this)}),null==(n=this.shadow.querySelector(".eeq-btn-share"))||n.addEventListener("click",()=>this._copyShareImage(t))}destroy(){var t;null==(t=this.host)||t.remove(),this.host=null,this.shadow=null}_buildContentDOM(t,e){const i=e.behaviorProfile,n=document.createElement("div");n.className="eeq-results-inner";const s=document.createElement("div");s.className="eeq-results-title",s.textContent=`« ${i.title} »`,n.appendChild(s);const r=document.createElement("div");r.className="eeq-time",r.textContent=f(e.totalTime),n.appendChild(r);const a=document.createElement("div");a.className="eeq-badges";const o=[{icon:{clicker:"🖱",scroller:"📜",typist:"⌨",minimalist:"🧘",mover:"🖱"}[i.dominantAction],label:i.dominantAction},{icon:{tornado:"🌪",conductor:"🎼",surgeon:"🎯",ghost:"👻"}[i.mousePersonality],label:i.mousePersonality},{icon:{speedster:"⚡",steady:"🚶",explorer:"🧭",philosopher:"🕊"}[i.pace],label:i.pace}];for(const{icon:m,label:f}of o){if(!m)continue;const t=document.createElement("span");t.className="eeq-badge",t.title=f,t.textContent=m,a.appendChild(t)}n.appendChild(a);const l=document.createElement("div");l.className="eeq-share-invite",l.textContent="share or copy your result",n.appendChild(l);const h=document.createElement("div");h.className="eeq-results-actions";const c=document.createElement("button");c.className="eeq-btn eeq-btn-share",c.title="share or copy result",c.innerHTML='<svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M4.5 10.5a2 2 0 1 1 0-4 2 2 0 0 1 0 4zm7-4a2 2 0 1 1 0-4 2 2 0 0 1 0 4zm0 8a2 2 0 1 1 0-4 2 2 0 0 1 0 4z" stroke="currentColor" stroke-width="1.2"/><path d="M6.3 9.2l3.4 1.6M6.3 7.8l3.4-1.6" stroke="currentColor" stroke-width="1.2"/></svg>';const u=document.createElement("span");u.textContent="share / copy",c.appendChild(u),h.appendChild(c);const d=document.createElement("button");d.className="eeq-btn eeq-btn-finish",d.title="finish",d.innerHTML='<svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M4 8.5l3 3 5-6.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>';const p=document.createElement("span");p.textContent="finish",d.appendChild(p),h.appendChild(d),n.appendChild(h),t.appendChild(n)}_makeRand(t){let e=t;return()=>{e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}_drawTypedEgg2D(t,e,i,n){const s=Math.min(window.devicePixelRatio||1,3);t.width=72*s,t.height=96*s,t.style.width="72px",t.style.height="96px";const r=t.getContext("2d");r.scale(s,s);const a=30.24,o=96*.46;i?0===e?this._paintSilverEgg(r,36,48,a,o):1===e?this._paintGoldEgg(r,36,48,a,o):this._paintFestiveEgg(r,36,48,a,o,n):this._drawEggOutline(r,36,48,a,o,!0)}_eggPath(t,e,i,n,s){t.beginPath();for(let r=0;r<=2*Math.PI;r+=.02){const a=1-.15*Math.sin(r),o=e+Math.cos(r)*n*a,l=i-Math.sin(r)*s;0===r?t.moveTo(o,l):t.lineTo(o,l)}t.closePath()}_drawEggOutline(t,e,i,n,s,r){t.save(),r&&t.setLineDash([5,4]),this._eggPath(t,e,i,n,s),t.strokeStyle="rgba(255,255,255,0.15)",t.lineWidth=1.5,t.stroke(),t.restore()}_drawSpecular(t,e,i,n,s){const r=t.createRadialGradient(e-.25*n,i-.4*s,0,e-.25*n,i-.4*s,.7*n);r.addColorStop(0,"rgba(255,255,255,0.4)"),r.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=r,t.fillRect(e-n-2,i-s-2,2*n+4,2*s+4)}_paintSilverEgg(t,e,i,n,s){t.save(),this._eggPath(t,e,i,n,s),t.clip();const r=t.createLinearGradient(e,i-s,e,i+s);r.addColorStop(0,"#e8ecf2"),r.addColorStop(.3,"#dde1e8"),r.addColorStop(.6,"#d0d4dc"),r.addColorStop(1,"#c4c0bc"),t.fillStyle=r,t.fillRect(e-n-2,i-s-2,2*n+4,2*s+4),t.fillStyle="rgba(255,255,255,0.55)";for(let o=-1;o<2*s/10+2;o++){const r=o%2*6;for(let a=-1;a<2*n/12+2;a++){const l=e-n+12*a+r,h=i-s+10*o;t.beginPath(),t.arc(l,h,3.5,0,2*Math.PI),t.fill()}}const a=t.createLinearGradient(e-n,i-.2*s,e+n,i+.2*s);a.addColorStop(0,"rgba(255,255,255,0)"),a.addColorStop(.4,"rgba(255,255,255,0.12)"),a.addColorStop(.6,"rgba(255,255,255,0.12)"),a.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=a,t.fillRect(e-n-2,i-s-2,2*n+4,2*s+4),this._drawSpecular(t,e,i,n,s),t.restore(),t.save(),this._eggPath(t,e,i,n,s),t.strokeStyle="rgba(200,205,215,0.5)",t.lineWidth=1.2,t.stroke(),t.restore()}_paintGoldEgg(t,e,i,n,s){t.save(),this._eggPath(t,e,i,n,s),t.clip();const r=t.createLinearGradient(e,i-s,e,i+s);r.addColorStop(0,"#d4a520"),r.addColorStop(.25,"#e6c040"),r.addColorStop(.5,"#daa520"),r.addColorStop(.75,"#c89618"),r.addColorStop(1,"#b8860b"),t.fillStyle=r,t.fillRect(e-n-2,i-s-2,2*n+4,2*s+4),t.globalAlpha=.25;for(const a of[.28,.5,.72]){const r=i-s+a*s*2,o=5,l=t.createLinearGradient(e,r-o,e,r+o);l.addColorStop(0,"#b8860b"),l.addColorStop(.5,"#f0d060"),l.addColorStop(1,"#b8860b"),t.fillStyle=l,t.fillRect(e-n-2,r-o,2*n+4,2*o)}t.globalAlpha=1,t.strokeStyle="rgba(160,112,8,0.18)",t.lineWidth=.8;for(let a=e-2*n;a<e+2*n;a+=8)t.beginPath(),t.moveTo(a,i-s),t.lineTo(a+2*s,i+s),t.stroke(),t.beginPath(),t.moveTo(a+2*s,i-s),t.lineTo(a,i+s),t.stroke();t.strokeStyle="rgba(212,165,16,0.35)",t.lineWidth=.7;for(const a of[.24,.32,.46,.54,.68,.76]){const r=i-s+a*s*2;t.beginPath(),t.moveTo(e-n,r),t.lineTo(e+n,r),t.stroke()}this._drawSpecular(t,e,i,n,s),t.restore(),t.save(),this._eggPath(t,e,i,n,s),t.strokeStyle="rgba(200,165,30,0.5)",t.lineWidth=1.2,t.stroke(),t.restore()}_paintFestiveEgg(t,e,i,n,s,r){const a=this._makeRand(r);t.save(),this._eggPath(t,e,i,n,s),t.clip();const o=360*a(),l=[];for(let d=0;d<5;d++)l.push((o+d*(50+30*a()))%360);const h=2*s/9,c=i-s;for(let d=0;d<9;d++){const i=c+d*h;if(d%2==1){const n=52+10*a(),s=t.createLinearGradient(e,i,e,i+h);s.addColorStop(0,`hsl(43, 80%, ${n}%)`),s.addColorStop(1,`hsl(43, 75%, ${n-6}%)`),t.fillStyle=s}else{const n=l[Math.floor(d/2)%l.length],s=55+30*a(),r=35+15*a(),o=t.createLinearGradient(e,i,e,i+h);o.addColorStop(0,`hsl(${n}, ${s}%, ${r}%)`),o.addColorStop(1,`hsl(${n}, ${s}%, ${r-8}%)`),t.fillStyle=o}t.fillRect(e-n-2,i,2*n+4,h+1)}const u=5+Math.floor(4*a());for(let d=1;d<9;d+=2){const i=c+(d+.5)*h;for(let s=0;s<u;s++){const r=e-.7*n+(s+.5)*(1.4*n/u),o=l[Math.floor(a()*l.length)];t.fillStyle=`hsl(${o}, 70%, 55%)`,t.beginPath(),t.arc(r,i,1.5+a(),0,2*Math.PI),t.fill()}}this._drawSpecular(t,e,i,n,s),t.restore(),t.save(),this._eggPath(t,e,i,n,s),t.strokeStyle="rgba(200,150,100,0.45)",t.lineWidth=1.2,t.stroke(),t.restore()}_copyShareImage(t){var e;const i=this._renderCard(t),n=this._buildShareText(t),s=i.toDataURL("image/png"),r=atob(s.split(",")[1]),a=new ArrayBuffer(r.length),o=new Uint8Array(a);for(let h=0;h<r.length;h++)o[h]=r.charCodeAt(h);const l=new Blob([a],{type:"image/png"});if(/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)&&window.innerWidth<768&&navigator.share){const t=new File([l],"easter-egg-quest.png",{type:"image/png"});return(null==(e=navigator.canShare)?void 0:e.call(navigator,{files:[t]}))?void navigator.share({files:[t],title:"Easter Egg Quest",text:n}).catch(()=>{}):void navigator.share({title:"Easter Egg Quest",text:n}).catch(()=>{})}navigator.clipboard&&"undefined"!=typeof ClipboardItem?navigator.clipboard.write([new ClipboardItem({"image/png":l})]).then(()=>{this._flashButton(".eeq-btn-share","image copied")}).catch(()=>{this._copyShareText(n,l)}):this._copyShareText(n,l)}_copyShareText(t,e){var i;(null==(i=navigator.clipboard)?void 0:i.writeText)?navigator.clipboard.writeText(t).then(()=>{this._flashButton(".eeq-btn-share","text copied")}).catch(()=>{this._downloadBlob(e)}):this._downloadBlob(e)}_buildShareText(t){const e=f(t.totalTime),i=`${t.eggsFound}/3 eggs`;return`Easter Egg Quest: ${t.behaviorProfile.title} • ${e} • ${i}`}_downloadBlob(t){const e=URL.createObjectURL(t),i=document.createElement("a");i.href=e,i.download="easter-egg-quest.png",i.click(),setTimeout(()=>URL.revokeObjectURL(e),5e3),this._flashButton(".eeq-btn-share","saved!")}_renderCard(t){const e=Math.min(window.devicePixelRatio||1,3),i=document.createElement("canvas");i.width=480*e,i.height=400*e;const n=i.getContext("2d");n.scale(e,e);const s=n.createLinearGradient(0,0,0,400);s.addColorStop(0,"#1e1815"),s.addColorStop(.5,"#14110e"),s.addColorStop(1,"#0d0b09"),n.fillStyle=s,this._roundRect(n,0,0,480,400,16),n.fill(),n.strokeStyle="rgba(212,165,80,0.18)",n.lineWidth=1,this._roundRect(n,.5,.5,479,399,16),n.stroke(),n.textAlign="center",n.font="11px Georgia, serif",n.fillStyle="rgba(232,224,214,0.3)",n.fillText("🥚 Easter Egg Quest",240,28);const r=20.16,a=29.44;for(let c=0;c<3;c++){const e=176+64*c;c<t.eggsFound?0===c?this._paintSilverEgg(n,e,72,r,a):1===c?this._paintGoldEgg(n,e,72,r,a):this._paintFestiveEgg(n,e,72,r,a,t.eggSeed):this._drawEggOutline(n,e,72,r,a,!0)}const o=3===t.eggsFound?"All eggs collected!":`${t.eggsFound} of 3 eggs collected`;n.font="10px Georgia, serif",n.fillStyle="rgba(232,224,214,0.35)",n.fillText(o,240,119.44);const l=131.44;n.strokeStyle="rgba(212,165,80,0.12)",n.lineWidth=.5,n.beginPath(),n.moveTo(96,l),n.lineTo(384,l),n.stroke(),n.font="italic 18px Georgia, serif",n.fillStyle=this.config.theme.accent,n.fillText(`« ${t.behaviorProfile.title} »`,240,159.44),n.font='32px "SF Mono", "Fira Code", Consolas, monospace',n.fillStyle="#e8e0d6",n.fillText(f(t.totalTime),240,199.44);const h=[t.behaviorProfile.dominantAction,t.behaviorProfile.mousePersonality,t.behaviorProfile.pace];return n.font="12px Georgia, serif",n.fillStyle="rgba(232,224,214,0.4)",n.fillText(h.join(" · "),240,223.44),n.font="14px Georgia, serif",n.fillStyle="rgba(232,224,214,0.55)",n.fillText("All three eggs found",240,261.44),n.font="11px Georgia, serif",n.fillStyle="rgba(232,224,214,0.3)",n.fillText("Share or copy your result",240,281.44),n.font="9px Georgia, serif",n.fillStyle="rgba(232,224,214,0.12)",n.fillText("easter egg quest",240,384),i}_roundRect(t,e,i,n,s,r){t.beginPath(),t.moveTo(e+r,i),t.lineTo(e+n-r,i),t.quadraticCurveTo(e+n,i,e+n,i+r),t.lineTo(e+n,i+s-r),t.quadraticCurveTo(e+n,i+s,e+n-r,i+s),t.lineTo(e+r,i+s),t.quadraticCurveTo(e,i+s,e,i+s-r),t.lineTo(e,i+r),t.quadraticCurveTo(e,i,e+r,i),t.closePath()}_flashButton(t,e){var i;const n=null==(i=this.shadow)?void 0:i.querySelector(`${t} span`);if(!n)return;const s=n.textContent;n.textContent=e,setTimeout(()=>{n.textContent=s},1500)}_getStyles(){const t=this.config.theme;return`\n .eeq-results {\n pointer-events: auto;\n background: linear-gradient(175deg, rgba(28,22,18,0.95) 0%, rgba(10,8,6,0.97) 100%);\n backdrop-filter: blur(28px);\n -webkit-backdrop-filter: blur(28px);\n border: 1px solid rgba(212,165,80,0.1);\n border-radius: 20px;\n padding: 28px 36px 24px;\n max-width: 320px;\n width: 85vw;\n opacity: 0;\n transform: translateY(24px) scale(0.95);\n transition: opacity 0.9s ease, transform 0.9s cubic-bezier(0.23, 1, 0.32, 1);\n font-family: 'Georgia', 'Times New Roman', serif;\n color: ${t.textColor};\n text-align: center;\n box-shadow: 0 24px 80px rgba(0,0,0,0.6), 0 4px 16px rgba(0,0,0,0.4),\n inset 0 1px 0 rgba(255,255,255,0.04);\n }\n\n .eeq-results-visible {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n\n .eeq-results-title {\n font-size: 18px;\n font-style: italic;\n letter-spacing: 0.04em;\n color: ${t.accent};\n margin-bottom: 10px;\n line-height: 1.35;\n text-shadow: 0 0 30px rgba(212,165,80,0.15);\n }\n\n .eeq-time {\n font-size: 30px;\n font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;\n letter-spacing: 0.06em;\n margin-bottom: 12px;\n background: linear-gradient(180deg, #f0ece6, #c8c0b4);\n -webkit-background-clip: text;\n -webkit-text-fill-color: transparent;\n background-clip: text;\n }\n\n .eeq-badges {\n display: flex;\n justify-content: center;\n gap: 10px;\n margin-bottom: 12px;\n font-size: 18px;\n }\n\n .eeq-share-invite {\n font-size: 13px;\n color: rgba(232,224,214,0.5);\n margin-bottom: 16px;\n letter-spacing: 0.03em;\n }\n\n .eeq-badge {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 36px;\n height: 36px;\n border-radius: 50%;\n background: rgba(255,255,255,0.03);\n border: 1px solid rgba(255,255,255,0.07);\n cursor: default;\n transition: background 0.3s, border-color 0.3s;\n }\n\n .eeq-badge:hover {\n background: rgba(212,165,80,0.08);\n border-color: rgba(212,165,80,0.2);\n }\n\n .eeq-results-actions {\n display: flex;\n justify-content: center;\n gap: 10px;\n }\n\n .eeq-btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n background: rgba(255,255,255,0.02);\n border: 1px solid rgba(255,255,255,0.1);\n color: ${t.textColor};\n padding: 8px 18px;\n border-radius: 10px;\n font-family: 'Georgia', serif;\n font-size: 12px;\n letter-spacing: 0.04em;\n cursor: pointer;\n transition: all 0.3s ease;\n white-space: nowrap;\n }\n\n .eeq-btn svg {\n flex-shrink: 0;\n opacity: 0.7;\n transition: opacity 0.3s;\n }\n\n .eeq-btn:hover {\n border-color: ${t.accent};\n color: ${t.accent};\n background: rgba(212,165,80,0.06);\n box-shadow: 0 0 20px rgba(212,165,80,0.08);\n }\n\n .eeq-btn:hover svg {\n opacity: 1;\n }\n\n .eeq-btn:focus {\n outline: 2px solid ${t.accent};\n outline-offset: 2px;\n }\n\n .eeq-btn:active {\n transform: scale(0.96);\n }\n `}};b.EGG_PALETTES=[{base1:"#e0e4ea",base2:"#c8c4c0",accent:"#f4f4f6",outline:"rgba(200,200,210,0.6)",label:"Silver"},{base1:"#daa520",base2:"#b8860b",accent:"#f0d060",outline:"rgba(218,165,32,0.6)",label:"Gold"},{base1:"#c05070",base2:"#3060a0",accent:"#e6b422",outline:"rgba(200,100,120,0.6)",label:"Fabergé"}];let S=b;class w{constructor(){this._startTime=0,this._entryTime=0,this._stageResults=[],this._extraClicks=0,this._chaoticMoveFrames=0,this._hesitations=0,this._failedAttempts=0,this._overcorrections=0}start(){this._startTime=Date.now(),this._stageResults=[],this._extraClicks=0,this._chaoticMoveFrames=0,this._hesitations=0,this._failedAttempts=0,this._overcorrections=0}recordEntryFound(){this._entryTime=Date.now()-this._startTime}recordStageResult(t){this._stageResults.push(t),this._failedAttempts+=Math.max(0,t.attempts-1)}analyseFrame(t){t.velocity>2e3&&this._chaoticMoveFrames++}recordExtraClick(){this._extraClicks++}recordHesitation(){this._hesitations++}recordOvercorrection(){this._overcorrections++}computeFinalScore(t){const e=Date.now()-this._startTime,i=this._stageResults[0],n=this._stageResults[1],s=this._stageResults[2],r=this._computePredictability(),a=(null==t?void 0:t.totalClicks)??0,o=(null==t?void 0:t.totalScrolls)??0,l=(null==t?void 0:t.totalKeyPresses)??0,h=(null==t?void 0:t.totalDistance)??0,c=this._computeBehaviorProfile({totalTime:e,clicks:a,scrolls:o,keys:l,distance:h,maxVelocity:(null==t?void 0:t.maxVelocity)??0,stillnessBreaks:(null==i?void 0:i.breaks)??0,motionFades:(null==n?void 0:n.fades)??0,rhythmAccuracy:(null==s?void 0:s.rhythmAccuracy)??0,predictabilityScore:r.score});return{eggsFound:this._stageResults.length,totalTime:e,entryTime:this._entryTime,egg1Time:(null==i?void 0:i.stageTime)??0,egg2Time:(null==n?void 0:n.stageTime)??0,egg3Time:(null==s?void 0:s.stageTime)??0,stillnessBreaks:(null==i?void 0:i.breaks)??0,motionFades:(null==n?void 0:n.fades)??0,rhythmAccuracy:(null==s?void 0:s.rhythmAccuracy)??0,predictabilityScore:r.score,predictabilityLabel:r.label,stageResults:this._stageResults,behaviorProfile:c,totalClicks:a,totalScrolls:o,totalKeyPresses:l,totalDistance:h,eggSeed:Math.floor(2147483647*Math.random())}}_computeBehaviorProfile(t){let e;e=0===Math.max(t.clicks,t.scrolls,t.keys)?"minimalist":t.clicks>=t.scrolls&&t.clicks>=t.keys?"clicker":t.scrolls>=t.clicks&&t.scrolls>=t.keys?"scroller":"typist";const i=t.distance/Math.max(t.totalTime/1e3,1);let n;n=i>600?"tornado":i>250?"conductor":i>60?"surgeon":"ghost";const s=t.totalTime/1e3;let r;return r=s<45?"speedster":s<120?"steady":s<360?"explorer":"philosopher",{title:this._pickTitle(t,e,n,r),dominantAction:e,mousePersonality:n,pace:r}}_pickTitle(t,e,i,n){const s=[],r=t.totalTime/1e3;r<30?s.push({score:.95,title:"Quantum Egg Locator"}):r<45?s.push({score:.8,title:"Easter Lightning"}):r>600?s.push({score:.85,title:"Egg Philosopher Supreme"}):r>360&&s.push({score:.7,title:"Scenic Route Connoisseur"});const a=t.clicks/Math.max(r/60,.5);a>40?s.push({score:.9,title:"The Click Machine"}):a>20?s.push({score:.7,title:"Click Enthusiast"}):t.clicks<=3&&r>30&&s.push({score:.75,title:"Clickless Wonder"}),t.scrolls>100?s.push({score:.85,title:"Scroll Archaeologist"}):t.scrolls>50&&s.push({score:.65,title:"Infinite Scroller"}),t.keys>50?s.push({score:.8,title:"Keyboard Adventurer"}):t.keys>20&&s.push({score:.6,title:"Secret Code Seeker"});const o=t.distance/1e3;return o>50?s.push({score:.85,title:"Mouse Marathon Runner"}):o>20?s.push({score:.65,title:"Cursor Voyager"}):o<2&&r>30&&s.push({score:.7,title:"Laser Pointer Specialist"}),t.maxVelocity>8e3&&s.push({score:.75,title:"Speed Demon"}),t.predictabilityScore>=92?s.push({score:.85,title:"Human Clockwork"}):t.predictabilityScore>=80?s.push({score:.6,title:"The Algorithm"}):t.predictabilityScore<=12?s.push({score:.9,title:"Agent of Chaos"}):t.predictabilityScore<=25&&s.push({score:.7,title:"Chaos Butterfly"}),t.rhythmAccuracy>=95?s.push({score:.85,title:"Rhythm Oracle"}):t.rhythmAccuracy>=80?s.push({score:.6,title:"Beat Keeper"}):t.rhythmAccuracy<20&&t.rhythmAccuracy>0&&s.push({score:.75,title:"Jazz Improviser"}),0===t.stillnessBreaks?s.push({score:.8,title:"Stone Buddha"}):t.stillnessBreaks>=15&&s.push({score:.7,title:"Caffeinated Explorer"}),0===t.motionFades&&r>20&&s.push({score:.65,title:"Perpetual Motion"}),"speedster"===n&&"clicker"===e&&s.push({score:.92,title:"Turbo Clicker"}),"philosopher"===n&&"ghost"===i&&s.push({score:.88,title:"Meditation Champion"}),"tornado"===i&&"typist"===e&&s.push({score:.87,title:"Keyboard Tornado"}),t.rhythmAccuracy>=85&&t.clicks<=5&&s.push({score:.82,title:"Silent Perfectionist"}),t.predictabilityScore<=20&&"speedster"===n&&s.push({score:.88,title:"Controlled Chaos"}),"scroller"===e&&"explorer"===n&&s.push({score:.78,title:"Digital Archaeologist"}),"conductor"===i&&t.rhythmAccuracy>=70&&s.push({score:.8,title:"Cursor Choreographer"}),"minimalist"===e&&"steady"===n&&s.push({score:.75,title:"Zen Navigator"}),t.stillnessBreaks>=10&&t.rhythmAccuracy>=80&&s.push({score:.78,title:"Restless Virtuoso"}),o>30&&"speedster"===n&&s.push({score:.82,title:"Hyperdrive Activated"}),s.sort((t,e)=>e.score-t.score),s.length>0?s[0].title:{speedster:"Swift Egg Seeker",steady:"Determined Hunter",explorer:"Curious Wanderer",philosopher:"Patient Sage"}[n]??"Egg Explorer"}_computePredictability(){const t=.2*Math.min(this._extraClicks/30,1)+.25*Math.min(this._chaoticMoveFrames/200,1)+.2*Math.min(this._hesitations/20,1)+.2*Math.min(this._failedAttempts/10,1)+.15*Math.min(this._overcorrections/15,1),e=Math.round(100*(1-t)),i=Math.max(0,Math.min(100,e));return{score:i,label:this._labelForScore(i)}}_labelForScore(t){return t>=90?"highly predictable":t>=75?`more predictable than ${t}% of players`:t>=55?"moderately predictable":t>=35?`less predictable than ${100-t}% of players`:t>=15?"rare pattern":"deeply unpredictable"}}const T="eeq_scores",E="eeq_progress";class A{constructor(t){this._enabled=t}saveScore(t){if(this._enabled)try{const e=this._loadAll();e.push({...t,date:(new Date).toISOString()});const i=e.slice(-50);localStorage.setItem(T,JSON.stringify(i))}catch{}}getBestTime(){const t=this._loadAll();return 0===t.length?null:Math.min(...t.map(t=>t.totalTime))}getScoreCount(){return this._loadAll().length}getLastScore(){const t=this._loadAll();return t.length>0?t[t.length-1]:null}clearScores(){try{localStorage.removeItem(T)}catch{}}_loadAll(){try{const t=localStorage.getItem(T);if(!t)return[];const e=JSON.parse(t);return Array.isArray(e)?e.filter(t=>"object"==typeof t&&null!==t&&"number"==typeof t.totalTime&&Number.isFinite(t.totalTime)):[]}catch{return[]}}saveProgress(t){if(this._enabled)try{localStorage.setItem(E,JSON.stringify(t))}catch{}}loadProgress(){if(!this._enabled)return null;try{const t=localStorage.getItem(E);return t?JSON.parse(t):null}catch{return null}}clearProgress(){try{localStorage.removeItem(E)}catch{}}}class C{constructor(t,e,i,n){this._status="active",this._startTime=0,this._breaks=0,this._attempts=0,this._lastBreakNarrativeTime=0,this._narrativeIndex=0,this._bestProgress=0,this._introPlayed=!1,this.config=t,this.script=e,this.input=i,this.bus=n}async start(){this._startTime=Date.now(),this._attempts=1,this.input.resetPhases(),this.input.resetCounts(),this.bus.emit("narrative:clear"),await this._wait(850),this._introPlayed=!1;const t=this.script.stage1Intro;for(let e=0;e<t.length;e++)e===t.length-1?await this._showAndConfirm(t[e]):(this.bus.emit("narrative:show",t[e]),await this._wait(5e3));this.bus.emit("narrative:clear"),await this._wait(1e3),this._introPlayed=!0}update(t){if("complete"===this._status||!this._introPlayed)return this._status;const e=this.config.stageDurations.stillnessMs,i=this.input.stillDuration,n=Math.min(1,i/e);return n>this._bestProgress&&(this._bestProgress=n),this.bus.emit("stage:progress",n),this.input.snapshot.isMoving&&n>.05?(this._handleBreak(),this._status):i>=e?(this._status="complete",this.bus.emit("stage:progress",1),this.bus.emit("egg:reveal",0),this._status):this._status}cleanup(){}getResult(){return{stageTime:Date.now()-this._startTime,attempts:this._attempts,breaks:this._breaks}}_handleBreak(){this._breaks++;const t=Date.now();if(t-this._lastBreakNarrativeTime>6e4){this._lastBreakNarrativeTime=t;const e=this.script.stage1Reactions,i=e[this._narrativeIndex%e.length];this._narrativeIndex++,this.bus.emit("narrative:show",i)}}_wait(t){return new Promise(e=>setTimeout(e,t))}_showAndConfirm(t){return this.bus.emit("narrative:showConfirm",t),new Promise(t=>{const e=()=>{this.bus.off("narrative:confirmed",e),t()};this.bus.on("narrative:confirmed",e)})}}class R{constructor(t,e,i,n){this._status="active",this._startTime=0,this._fades=0,this._attempts=0,this._movingAccum=0,this._lastUpdateTime=0,this._narrativeIndex=0,this._lastFadeNarrativeTime=0,this._introPlayed=!1,this.FADE_THRESHOLD_MS=500,this.config=t,this.script=e,this.input=i,this.bus=n}async start(){this._startTime=Date.now(),this._lastUpdateTime=Date.now(),this._movingAccum=0,this._attempts=1,this.input.resetPhases(),this.input.resetCounts(),this.bus.emit("narrative:clear"),await this._wait(850),this._introPlayed=!1;const t=this.script.stage2Intro;for(let e=0;e<t.length;e++)e===t.length-1?await this._showAndConfirm(t[e]):(this.bus.emit("narrative:show",t[e]),await this._wait(5e3));this.bus.emit("narrative:clear"),await this._wait(1e3),this._lastUpdateTime=Date.now(),this._movingAccum=0,this._introPlayed=!0}update(t){if("complete"===this._status||!this._introPlayed)return this._status;const e=Date.now(),i=e-this._lastUpdateTime;this._lastUpdateTime=e;const n=this.config.stageDurations.motionMs;if(this.input.snapshot.isMoving){this._movingAccum+=i;const t=this.input.snapshot.velocity;if(t>50){const e=Math.max(.15,1-t/1200);Math.random()<e&&this.bus.emit("motion:trail",{x:this.input.snapshot.mouseX,y:this.input.snapshot.mouseY,velocity:t})}}else this.input.stillDuration>this.FADE_THRESHOLD_MS&&this._movingAccum>0&&(this._fades++,this._movingAccum=0,this._handleFade());const s=Math.min(1,this._movingAccum/n);return this.bus.emit("stage:progress",s),this._movingAccum>=n?(this._status="complete",this.bus.emit("stage:progress",1),this.bus.emit("egg:reveal",1),this._status):this._status}cleanup(){}getResult(){return{stageTime:Date.now()-this._startTime,attempts:this._attempts,fades:this._fades}}_handleFade(){const t=Date.now();if(t-this._lastFadeNarrativeTime>6e4){this._lastFadeNarrativeTime=t;const e=this.script.stage2Reactions,i=e[this._narrativeIndex%e.length];this._narrativeIndex++,this.bus.emit("narrative:show",i)}}_wait(t){return new Promise(e=>setTimeout(e,t))}_showAndConfirm(t){return this.bus.emit("narrative:showConfirm",t),new Promise(t=>{const e=()=>{this.bus.off("narrative:confirmed",e),t()};this.bus.on("narrative:confirmed",e)})}}class P{constructor(t,e,i,n){this._status="active",this._startTime=0,this._attempts=0,this._narrativeIndex=0,this._lastNarrativeTime=0,this._introPlayed=!1,this._goodCycles=0,this._totalCycles=0,this._lastPhaseCount=0,this._bestAccuracy=0,this._lastGuideTime=0,this.IDEAL_MOVE_MIN=900,this.IDEAL_MOVE_MAX=4200,this.IDEAL_PAUSE_MIN=600,this.IDEAL_PAUSE_MAX=2800,this.config=t,this.script=e,this.input=i,this.bus=n}async start(){this._startTime=Date.now(),this._attempts=1,this._goodCycles=0,this._totalCycles=0,this.input.configurePhaseDetection({stillThresholdMs:450,minPhaseMs:350}),this.input.resetPhases(),this.input.resetCounts(),this.bus.emit("narrative:clear"),await this._wait(850),this._introPlayed=!1;const t=this.script.stage3Intro;for(let e=0;e<t.length;e++)e===t.length-1?await this._showAndConfirm(t[e]):(this.bus.emit("narrative:show",t[e]),await this._wait(5e3));this.bus.emit("narrative:clear"),await this._wait(1e3),this.input.resetPhases(),this._lastPhaseCount=this.input.phases.length,this._introPlayed=!0,this._lastGuideTime=Date.now()}update(t){if("complete"===this._status||!this._introPlayed)return this._status;const e=this.input.phases,i=this.config.stageDurations.rhythmCycles;for(;this._lastPhaseCount+1<e.length;){const t=e[this._lastPhaseCount],i=e[this._lastPhaseCount+1];if(!t||!i)break;{const e=this._evaluateCycle(t,i);this._totalCycles++,e?this._goodCycles++:(this._goodCycles=Math.max(0,this._goodCycles-.5),this._showReaction()),this._lastPhaseCount+=2}}const n=this._totalCycles>0?this._goodCycles/this._totalCycles:0;n>this._bestAccuracy&&(this._bestAccuracy=n);const s=Math.min(1,this._goodCycles/i);return this.bus.emit("stage:progress",s),this.bus.emit("rhythm:breathe",{accuracy:n,isMoving:this.input.snapshot.isMoving,progress:s,moveDuration:this.input.moveDuration,stillDuration:this.input.stillDuration}),0===n&&Date.now()-this._lastGuideTime>12e3&&(this._lastGuideTime=Date.now(),this._showReaction()),this._goodCycles>=i?(this._status="complete",this.bus.emit("stage:progress",1),this.bus.emit("egg:reveal",2),this._status):this._status}cleanup(){this.input.resetPhaseDetection()}getResult(){return{stageTime:Date.now()-this._startTime,attempts:this._attempts,rhythmAccuracy:this._totalCycles>0?Math.round(this._goodCycles/this._totalCycles*100):0}}_evaluateCycle(t,e){const i="move"===t.type?t:"move"===e.type?e:null,n="still"===t.type?t:"still"===e.type?e:null;if(!i||!n)return!1;const s=i.duration>=this.IDEAL_MOVE_MIN&&i.duration<=this.IDEAL_MOVE_MAX,r=n.duration>=this.IDEAL_PAUSE_MIN&&n.duration<=this.IDEAL_PAUSE_MAX;return s&&r}_showReaction(){const t=Date.now();if(t-this._lastNarrativeTime>12e3){this._lastNarrativeTime=t;const e=this.script.stage3Reactions,i=e[this._narrativeIndex%e.length];this._narrativeIndex++,this.bus.emit("narrative:show",i)}}_wait(t){return new Promise(e=>setTimeout(e,t))}_showAndConfirm(t){return this.bus.emit("narrative:showConfirm",t),new Promise(t=>{const e=()=>{this.bus.off("narrative:confirmed",e),t()};this.bus.on("narrative:confirmed",e)})}}class L{constructor(){this._styleEl=null,this._reactClass="eeq-page-react",this._injectStyles()}react(){const t=this._findCandidates();if(!t.length)return;const e=Math.min(t.length,2+Math.floor(2*Math.random())),i=this._pickRandom(t,e),n=["eeq-react-pulse","eeq-react-glow","eeq-react-lift"];for(let s=0;s<i.length;s++){const t=i[s],e=n[Math.floor(Math.random()*n.length)];setTimeout(()=>{t.classList.add(this._reactClass,e),setTimeout(()=>{t.classList.remove(this._reactClass,e)},1100)},200*s)}}destroy(){var t;document.querySelectorAll(`.${this._reactClass}`).forEach(t=>{t.className=t.className.replace(/\beeq-react-\S+/g,"").trim()}),null==(t=this._styleEl)||t.remove(),this._styleEl=null}_findCandidates(){var t;const e=document.querySelectorAll("p, h1, h2, h3, h4, h5, li, a, img, button, blockquote, figcaption, td, th"),i=[];for(const n of e){if(null==(t=n.id)?void 0:t.startsWith("eeq-"))continue;if(n.closest('[id^="eeq-"]'))continue;const e=n.getBoundingClientRect();0!==e.width&&0!==e.height&&(e.bottom<0||e.top>window.innerHeight||n.classList.contains(this._reactClass)||i.push(n))}return i}_pickRandom(t,e){const i=[...t],n=[];for(let s=0;s<e&&i.length;s++){const t=Math.floor(Math.random()*i.length);n.push(i.splice(t,1)[0])}return n}_injectStyles(){this._styleEl=document.createElement("style"),this._styleEl.textContent="\n @keyframes eeq-pulse-kf {\n 0%, 100% { transform: scale(1); }\n 50% { transform: scale(1.018); }\n }\n @keyframes eeq-glow-kf {\n 0%, 100% { filter: brightness(1); }\n 50% { filter: brightness(1.15) saturate(1.1); }\n }\n @keyframes eeq-lift-kf {\n 0%, 100% { transform: translateY(0); }\n 50% { transform: translateY(-2px); }\n }\n .eeq-react-pulse {\n animation: eeq-pulse-kf 1s ease-in-out !important;\n }\n .eeq-react-glow {\n animation: eeq-glow-kf 1s ease-in-out !important;\n }\n .eeq-react-lift {\n animation: eeq-lift-kf 1s ease-in-out !important;\n }\n ",document.head.appendChild(this._styleEl)}}class I{constructor(){this._active=!1,this._intensity=0,this._targetIntensity=0,this._rafId=0,this._overlay=null,this._label=null,this._startTime=0,this._isUserMoving=!1,this._inSync=!1,this._accuracy=0,this.CYCLE_MS=6e3,this._tick=()=>{if(!this._active||!this._overlay)return;this._rafId=requestAnimationFrame(this._tick),this._intensity+=.06*(this._targetIntensity-this._intensity);const t=(Date.now()-this._startTime)%this.CYCLE_MS/this.CYCLE_MS,e=.5*(Math.sin(t*Math.PI*2-Math.PI/2)+1),i=t<.5;this._inSync=this._accuracy>0&&i===this._isUserMoving;const n=.85*e,s=this._inSync?.22:0,r=this._intensity*(.18+n+.12*(1-e)+s);this._overlay.style.opacity=String(Math.min(.9,r)),this._overlay.style.transform=`scale(${1+.015*e})`,this._label&&(this._label.textContent=i?"In":"Out",this._label.style.opacity=i===this._isUserMoving?"0.98":"0.82",this._label.style.boxShadow=this._inSync?"0 0 28px rgba(212,165,80,0.4)":"0 0 20px rgba(255,255,255,0.08)",this._label.style.borderColor=this._inSync?"rgba(212,165,80,0.55)":"rgba(255,255,255,0.12)")}}start(){if(this._active)return;this._active=!0,this._startTime=Date.now();const t=document.createElement("div");t.style.cssText=["position:fixed","top:0","left:0","width:100%","height:100%","pointer-events:none","z-index:999980","opacity:0","background:radial-gradient(ellipse at center, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.02) 24%, rgba(8,12,22,0.18) 46%, rgba(4,6,12,0.82) 100%)","transition:opacity 0.3s ease"].join(";"),document.body.appendChild(t),this._overlay=t;const e=document.createElement("div");e.style.cssText=["position:fixed","left:50%","top:18%","transform:translateX(-50%)","pointer-events:none","z-index:999981","padding:8px 14px","border-radius:999px","font-family:Georgia, Times New Roman, serif","font-size:12px","letter-spacing:0.12em","text-transform:uppercase","color:rgba(255,248,232,0.95)","background:rgba(8,10,18,0.36)","border:1px solid rgba(255,255,255,0.12)","box-shadow:0 0 20px rgba(255,255,255,0.08)","opacity:0.78"].join(";"),e.textContent="In",document.body.appendChild(e),this._label=e,this._tick()}update(t,e){if(!this._active)return;this._isUserMoving=e,this._accuracy=t;const i=Math.max(0,Math.min(1,(t-.02)/.45));this._targetIntensity=.68+.32*i}isInSync(){return this._inSync}stop(){var t,e;this._active&&(this._active=!1,cancelAnimationFrame(this._rafId),null==(t=this._overlay)||t.remove(),this._overlay=null,null==(e=this._label)||e.remove(),this._label=null,this._intensity=0,this._targetIntensity=0,this._inSync=!1,this._accuracy=0)}destroy(){this.stop()}}class D{constructor(t,e){this.bus=new c,this.fsm=new d,this.input=new m,this.scoring=new w,this.hiddenEntry=null,this.narrative=null,this.hud=null,this.shrine=null,this.threeRenderer=null,this.fallbackRenderer=null,this.overlay=null,this.results=null,this.eggRenderer=null,this.activeStage=null,this.pageReactor=null,this._lastPageReactTime=0,this._lastReactProgress=0,this.pageBreather=null,this._updateRaf=0,this._running=!1,this._destroyed=!1,this._onPageHide=()=>this._handlePageClose(),this._tremorStyle=null,this._tremorClass="eeq-tremor",this._lastFrameTime=0,this._gameLoop=()=>{var t;if(!this._running||this._destroyed)return;if(this._updateRaf=requestAnimationFrame(this._gameLoop),this.state.isPaused)return;const e=performance.now(),i=(e-this._lastFrameTime)/1e3;if(this._lastFrameTime=e,this.scoring.analyseFrame(this.input.snapshot),null==(t=this.hud)||t.update(this.state,this.fsm.label),this.activeStage&&"complete"===this.activeStage.update(i)){this._running=!1,cancelAnimationFrame(this._updateRaf);const t=this.fsm.state;"stage1-active"===t?this.fsm.transitionTo("stage1-success"):"stage2-active"===t?this.fsm.transitionTo("stage2-success"):"stage3-active"===t&&this.fsm.transitionTo("stage3-success")}},this.config=t,this.script=e,this.persistence=new A(t.scoring.enableLocal),this.state={stage:"idle",eggsFound:0,startTime:0,stageStartTime:0,isPaused:!1,eggs:[{found:!1},{found:!1},{found:!1}]}}async init(){var t,e;this.fsm.onTransition((t,e)=>this._onTransition(t,e)),this.bus.on("narrative:show",t=>{var e;return null==(e=this.narrative)?void 0:e.showLine(t)}),this.bus.on("narrative:showConfirm",async t=>{var e;await(null==(e=this.narrative)?void 0:e.showLineWithConfirm(t)),this.bus.emit("narrative:confirmed")}),this.bus.on("narrative:clear",()=>{var t;return null==(t=this.narrative)?void 0:t.clear(!0)}),this.bus.on("egg:reveal",t=>this._handleEggReveal(t)),this.bus.on("stage:progress",t=>this._handleStageProgress(t)),this.bus.on("motion:trail",t=>{var e;null==(e=this.eggRenderer)||e.addTrail(t.x,t.y,t.velocity)}),this.bus.on("rhythm:breathe",t=>{var e,i;null==(e=this.eggRenderer)||e.setBreathIntensity(t.accuracy),null==(i=this.pageBreather)||i.update(t.accuracy,t.isMoving);const n=Math.max(t.accuracy,.75*t.progress),s=t.moveDuration>700||t.stillDuration>700;if((n>.08||s)&&this.threeRenderer){const t=s?.2:0;this.threeRenderer.showProgressParticles(Math.max(.35,.45+.55*Math.max(n,t)),"rhythm")}else this.threeRenderer&&this.threeRenderer.fadeOutAmbientParticles()}),this.overlay=new M(this.config),this.overlay.mount(),this.narrative=new _(this.config),this.narrative.mount(),this.shrine=new v(this.config),this.shrine.mount(t=>this._onShrineEggClick(t)),await this._initEggRenderer(),this.threeRenderer&&this.threeRenderer.onCollectEgg(t=>{this._onEggLongPressCollect(t)}),this.scoring.start(),null==(e=(t=this.config.callbacks).onInit)||e.call(t),window.addEventListener("pagehide",this._onPageHide),window.addEventListener("beforeunload",this._onPageHide);const i=this.persistence.loadProgress();i?this._resumeFromCheckpoint(i):this.fsm.transitionTo("entry")}pause(){var t;this.state.isPaused=!0,null==(t=this.hud)||t.pause()}resume(){var t;this.state.isPaused=!1,null==(t=this.hud)||t.resume()}async restart(){this._cleanup(),this.fsm.reset(),this.persistence.clearProgress(),this.state={stage:"idle",eggsFound:0,startTime:0,stageStartTime:0,isPaused:!1,eggs:[{found:!1},{found:!1},{found:!1}]},this.scoring.start(),this.fsm.transitionTo("entry")}destroy(){var t,e,i,n,s,r,a,o,l,h,c;this._destroyed=!0,window.removeEventListener("pagehide",this._onPageHide),window.removeEventListener("beforeunload",this._onPageHide),this._cleanup(),null==(t=this.narrative)||t.destroy(),null==(e=this.hud)||e.destroy(),null==(i=this.shrine)||i.destroy(),null==(n=this.threeRenderer)||n.destroy(),null==(s=this.fallbackRenderer)||s.destroy(),null==(r=this.overlay)||r.destroy(),null==(a=this.results)||a.destroy(),this._stopAnticipationTremor(),null==(o=this.pageReactor)||o.destroy(),this.pageReactor=null,null==(l=this.pageBreather)||l.destroy(),this.pageBreather=null,this.input.stop(),this.bus.clear(),this.fsm.reset(),null==(c=(h=this.config.callbacks).onDestroy)||c.call(h)}_handlePageClose(){if(this._destroyed)return;const t=this.fsm.state;"idle"!==t&&"entry"!==t&&"results"!==t&&"complete"!==t&&this._saveCheckpoint(t),this.destroy()}async _onTransition(t,e){var i;switch(this.state.stage=e,this.state.stageStartTime=Date.now(),null==(i=this.hud)||i.update(this.state,this.fsm.label),["stage1-intro","stage2-intro","stage3-intro","finale"].includes(e)&&this._saveCheckpoint(e),e){case"entry":await this._startEntry();break;case"stage1-intro":await this._startStage1();break;case"stage1-active":case"stage2-active":case"stage3-active":this._startGameLoop();break;case"stage1-success":await this._handleStageSuccess(0);break;case"stage2-intro":await this._startStage2();break;case"stage2-success":await this._handleStageSuccess(1);break;case"stage3-intro":await this._startStage3();break;case"stage3-success":await this._handleStageSuccess(2);break;case"finale":await this._startFinale();break;case"results":this._showResults()}}_saveCheckpoint(t){this.persistence.saveProgress({stage:t,eggsFound:this.state.eggsFound,eggsState:[this.state.eggs[0].found,this.state.eggs[1].found,this.state.eggs[2].found],savedAt:Date.now()})}_resumeFromCheckpoint(t){var e,i;if(!["stage1-intro","stage2-intro","stage3-intro","finale"].includes(t.stage))return this.persistence.clearProgress(),void this.fsm.transitionTo("entry");this.state.eggsFound=t.eggsFound,this.state.startTime=Date.now();for(let n=0;n<3;n++)this.state.eggs[n].found=t.eggsState[n];null==(e=this.shrine)||e.show();for(let n=0;n<t.eggsFound;n++)null==(i=this.shrine)||i.fillSlot(n);this.fsm.forceState(t.stage),this._onTransition("idle",t.stage)}async _startEntry(){var t;try{if("1"===localStorage.getItem("eeq_optout"))return}catch{}this.state.startTime=Date.now(),null==(t=this.hud)||t.startTimer(),this.hiddenEntry=new g(this.config,this.script,()=>{var t,e;this.scoring.recordEntryFound(),null==(e=(t=this.config.callbacks).onEntryFound)||e.call(t),this._onEntryFound()}),this.hiddenEntry.start()}async _onEntryFound(){var t,e,i,n;null==(t=this.hiddenEntry)||t.cleanup(),this.hiddenEntry=null,this._startAnticipationTremor(),null==(e=this.shrine)||e.show(),await(null==(i=this.narrative)?void 0:i.showSequence(this.script.entryConfirmation,4200)),null==(n=this.narrative)||n.clear(),this._stopAnticipationTremor(),await this._wait(800),this.input.start(),this.fsm.transitionTo("stage1-intro")}_startAnticipationTremor(){this._tremorStyle=document.createElement("style"),this._tremorStyle.textContent=`\n @keyframes eeq-tremor {\n 0%, 100% { transform: translate(0, 0); }\n 10% { transform: translate(-0.5px, 0.3px); }\n 20% { transform: translate(0.6px, -0.4px); }\n 30% { transform: translate(-0.3px, 0.5px); }\n 40% { transform: translate(0.4px, 0.2px); }\n 50% { transform: translate(-0.4px, -0.3px); }\n 60% { transform: translate(0.3px, 0.5px); }\n 70% { transform: translate(-0.5px, -0.2px); }\n 80% { transform: translate(0.2px, 0.4px); }\n 90% { transform: translate(-0.3px, -0.5px); }\n }\n .${this._tremorClass} {\n animation: eeq-tremor 0.6s ease-in-out infinite !important;\n }\n `,document.head.appendChild(this._tremorStyle),document.querySelectorAll('a, button, span, small, label, svg, img, i, [role="button"], nav li').forEach(t=>{var e;const i=t.getBoundingClientRect();if(i.width>300||i.height>100)return;if(0===i.width||0===i.height)return;if(i.bottom<0||i.top>window.innerHeight)return;if(null==(e=t.id)?void 0:e.startsWith("eeq-"))return;if(t.closest('[id^="eeq-"]'))return;const n=800*Math.random(),s=t;setTimeout(()=>{this._tremorStyle&&s.classList.add(this._tremorClass)},n)})}_stopAnticipationTremor(){var t;document.querySelectorAll(`.${this._tremorClass}`).forEach(t=>{t.classList.remove(this._tremorClass)}),null==(t=this._tremorStyle)||t.remove(),this._tremorStyle=null}async _startStage1(){var t,e,i,n;null==(e=(t=this.config.callbacks).onStageStart)||e.call(t,"stage1-intro"),null==(i=this.hud)||i.update(this.state,this.fsm.label),null==(n=this.eggRenderer)||n.startRenderLoop();const s=new C(this.config,this.script,this.input,this.bus);this.activeStage=s,await s.start(),this.fsm.transitionTo("stage1-active")}async _startStage2(){var t,e,i;null==(e=(t=this.config.callbacks).onStageStart)||e.call(t,"stage2-intro"),null==(i=this.hud)||i.update(this.state,this.fsm.label);const n=new R(this.config,this.script,this.input,this.bus);this.activeStage=n,await n.start(),this.fsm.transitionTo("stage2-active")}async _startStage3(){var t,e,i;null==(e=(t=this.config.callbacks).onStageStart)||e.call(t,"stage3-intro"),null==(i=this.hud)||i.update(this.state,this.fsm.label);const n=new P(this.config,this.script,this.input,this.bus);this.activeStage=n,await n.start(),this.fsm.transitionTo("stage3-active"),this.pageBreather=new I,this.pageBreather.start()}_startGameLoop(){this._running||(this._running=!0,this._lastFrameTime=performance.now(),this._gameLoop())}_handleEggReveal(t){var e,i,n,s;this.state.eggs[t].found=!0,this.state.eggs[t].foundTime=Date.now(),this.state.eggsFound++,null==(e=this.eggRenderer)||e.revealEgg(t),null==(i=this.hud)||i.flashEggFound(t),null==(s=(n=this.config.callbacks).onEggFound)||s.call(n,t)}async _handleStageSuccess(t){var e,i,n,s,r,a,o;if(this.activeStage){const t=this.activeStage.getResult();this.scoring.recordStageResult(t),this.activeStage.cleanup(),this.activeStage=null,null==(i=(e=this.config.callbacks).onStageComplete)||i.call(e,this.fsm.state,t)}const l=0===t?this.script.stage1Success:1===t?this.script.stage2Success:this.script.stage3Success;await(null==(n=this.narrative)?void 0:n.showSequence(l,4500)),await this._wait(3e3),null==(s=this.narrative)||s.clear(),await this._wait(800),this.threeRenderer?this.threeRenderer.enableInteraction(t):(null==(r=this.eggRenderer)||r.collectEgg(t),null==(a=this.shrine)||a.fillSlot(t),await this._wait(1500),t<2?null==(o=this.shrine)||o.activateSlot(t):(await this._wait(1e3),this.fsm.transitionTo("finale")))}_onShrineEggClick(t){var e;null==(e=this.shrine)||e.deactivateSlot(t),0===t?this.fsm.transitionTo("stage2-intro"):1===t&&this.fsm.transitionTo("stage3-intro")}async _onEggLongPressCollect(t){var e,i,n,s,r;null==(e=this.eggRenderer)||e.collectEgg(t),null==(i=this.shrine)||i.fillSlot(t),2===t&&(null==(n=this.pageBreather)||n.destroy(),this.pageBreather=null),null==(s=this.narrative)||s.showCelebration(["egg found — well done","another one — you're getting closer","all three — remarkable"][t]??"egg collected"),await this._wait(3500),null==(r=this.narrative)||r.clear(),await this._wait(900),t<2?0===t?this.fsm.transitionTo("stage2-intro"):this.fsm.transitionTo("stage3-intro"):(await this._wait(800),this.fsm.transitionTo("finale"))}_handleStageProgress(t){const e=this.fsm.state;this.threeRenderer&&"stage3-active"!==e&&this.threeRenderer.showProgressParticles(t);const i=Date.now();t>this._lastReactProgress+.03&&i-this._lastPageReactTime>8e3&&(this._lastPageReactTime=i,this._lastReactProgress=t,this.pageReactor||(this.pageReactor=new L),this.pageReactor.react()),t<this._lastReactProgress-.1&&(this._lastReactProgress=t)}async _startFinale(){var t,e,i,n,s,r;null==(e=(t=this.config.callbacks).onFinaleStart)||e.call(t),null==(i=this.shrine)||i.hideAll(),await this._wait(1e3),null==(n=this.eggRenderer)||n.startFinale(),await(null==(s=this.narrative)?void 0:s.showSequence(this.script.finale,5e3)),null==(r=this.narrative)||r.clear(),await this._wait(4e3),this.fsm.transitionTo("results")}_showResults(){var t,e,i;const n=this.input.snapshot,s=this.scoring.computeFinalScore({totalClicks:n.totalClicks,totalScrolls:n.totalScrolls,totalKeyPresses:n.totalKeyPresses,totalDistance:n.totalDistance,maxVelocity:n.maxVelocity});this.threeRenderer&&this.threeRenderer.setFestiveEggSeed(s.eggSeed),this.persistence.saveScore(s),this.persistence.clearProgress(),this.config.scoring.leaderboardAdapter&&this.config.scoring.leaderboardAdapter.submitScore(s).catch(()=>{}),null==(t=this.eggRenderer)||t.stopRenderLoop(),this.results=new S(this.config),this.results.show(s,()=>{this.destroy()}),null==(i=(e=this.config.callbacks).onComplete)||i.call(e,s)}async _initEggRenderer(){const t=this.config.renderer;if("3d"===t||"auto"===t){if(this.threeRenderer=new y(this.config),await this.threeRenderer.init())return void(this.eggRenderer=this.threeRenderer);this.threeRenderer=null}this.fallbackRenderer=new x(this.config),await this.fallbackRenderer.init(),this.eggRenderer=this.fallbackRenderer}_cleanup(){var t,e,i,n,s,r,a,o;this._running=!1,this._updateRaf&&cancelAnimationFrame(this._updateRaf),null==(t=this.hiddenEntry)||t.cleanup(),null==(e=this.activeStage)||e.cleanup(),this.activeStage=null,null==(i=this.shrine)||i.reset(),null==(n=this.narrative)||n.clear(),null==(s=this.overlay)||s.hide(),this._lastPageReactTime=0,this._lastReactProgress=0,this._stopAnticipationTremor(),null==(r=this.pageReactor)||r.destroy(),this.pageReactor=null,null==(a=this.pageBreather)||a.destroy(),this.pageBreather=null,null==(o=this.results)||o.destroy(),this.results=null,this.threeRenderer&&this.threeRenderer.resetForRestart()}_wait(t){return new Promise(e=>setTimeout(e,t))}}let U=null;const N={async init(t={}){U&&(U.destroy(),U=null);const e=function(t={}){var e,i,n,r,c,u,d,p,m,f,g,_,v,y,x,M,b,S;const w="undefined"!=typeof window&&(null==(e=window.matchMedia)?void 0:e.call(window,"(prefers-reduced-motion: reduce)").matches);return{theme:function(t){if(!t||"auto"===t||"light"===t||"dark"===t)return{...s};const e=["overlayBg","textColor","textSecondary","accent","accentGlow","hudBg","hudText"],i={};for(const n of e)n in t&&"string"==typeof t[n]&&(i[n]=t[n]);return{...s,...i}}(t.theme),hiddenEntry:{mode:(null==(i=t.hiddenEntry)?void 0:i.mode)??"auto",selector:h(null==(n=t.hiddenEntry)?void 0:n.selector),excludeSelectors:[...a,...((null==(r=t.hiddenEntry)?void 0:r.excludeSelectors)??[]).filter(t=>"string"==typeof t&&t.length<200)]},hud:"boolean"==typeof t.hud?{enabled:t.hud,position:"top-left"}:{enabled:(null==(c=t.hud)?void 0:c.enabled)??!0,position:(null==(u=t.hud)?void 0:u.position)??"top-left"},shrine:"boolean"==typeof t.shrine?{enabled:t.shrine,position:"bottom-right"}:{enabled:(null==(d=t.shrine)?void 0:d.enabled)??!0,position:(null==(p=t.shrine)?void 0:p.position)??"bottom-right"},sounds:t.sounds??!1,stageDurations:{stillnessMs:o(null==(m=t.stageDurations)?void 0:m.stillnessMs,2e4),motionMs:o(null==(f=t.stageDurations)?void 0:f.motionMs,2e4),rhythmCycles:l(null==(g=t.stageDurations)?void 0:g.rhythmCycles,6,1,50)},renderer:t.renderer??"auto",scoring:{enableLocal:(null==(_=t.scoring)?void 0:_.enableLocal)??!0,leaderboardAdapter:null==(v=t.scoring)?void 0:v.leaderboardAdapter},accessibility:{reducedMotion:"auto"===(null==(y=t.accessibility)?void 0:y.reducedMotion)?w:(null==(x=t.accessibility)?void 0:x.reducedMotion)??w,highContrast:(null==(M=t.accessibility)?void 0:M.highContrast)??!1,disableHiddenEntry:(null==(b=t.accessibility)?void 0:b.disableHiddenEntry)??!1,subtitlesLog:(null==(S=t.accessibility)?void 0:S.subtitlesLog)??!1},callbacks:t.callbacks??{}}}(t),i=(r=t.narrative)?{...n,...r}:{...n};var r;U=new D(e,i),await U.init()},pause(){null==U||U.pause()},resume(){null==U||U.resume()},async restart(){await(null==U?void 0:U.restart())},destroy(){null==U||U.destroy(),U=null}};if("undefined"!=typeof window&&"undefined"!=typeof document&&(void 0!==globalThis.EasterEggQuest||(null==(i=null==(e=document.currentScript)?void 0:e.getAttribute("src"))?void 0:i.includes("easter-egg-quest")))){const t=()=>N.init();"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}const O="160",F=0,B=1,z=2,k=100,V=101,G=102,H=200,W=201,q=202,X=203,j=204,Y=205,Z=206,J=207,K=208,$=209,Q=210,tt=211,et=212,it=213,nt=214,st="attached",rt="detached",at=300,ot=301,lt=302,ht=303,ct=304,ut=306,dt=1e3,pt=1001,mt=1002,ft=1003,gt=1004,_t=1005,vt=1006,yt=1007,xt=1008,Mt=1009,bt=1012,St=1013,wt=1014,Tt=1015,Et=1016,At=1017,Ct=1018,Rt=1020,Pt=1023,Lt=1026,It=1027,Dt=1029,Ut=1031,Nt=1033,Ot=33776,Ft=33777,Bt=33778,zt=33779,kt=35840,Vt=35841,Gt=35842,Ht=35843,Wt=36196,qt=37492,Xt=37496,jt=37808,Yt=37809,Zt=37810,Jt=37811,Kt=37812,$t=37813,Qt=37814,te=37815,ee=37816,ie=37817,ne=37818,se=37819,re=37820,ae=37821,oe=36492,le=36494,he=36495,ce=36284,ue=36285,de=36286,pe=2300,me=2301,fe=2302,ge=2400,_e=2401,ve=2402,ye=2501,xe=3e3,Me=3001,be="",Se="srgb",we="srgb-linear",Te="display-p3",Ee="display-p3-linear",Ae="linear",Ce="srgb",Re="rec709",Pe="p3",Le=7680,Ie=512,De=513,Ue=514,Ne=515,Oe=516,Fe=517,Be=518,ze=519,ke=35044,Ve="300 es",Ge=1035,He=2e3,We=2001;class qe{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const i=this._listeners;void 0===i[t]&&(i[t]=[]),-1===i[t].indexOf(e)&&i[t].push(e)}hasEventListener(t,e){if(void 0===this._listeners)return!1;const i=this._listeners;return void 0!==i[t]&&-1!==i[t].indexOf(e)}removeEventListener(t,e){if(void 0===this._listeners)return;const i=this._listeners[t];if(void 0!==i){const t=i.indexOf(e);-1!==t&&i.splice(t,1)}}dispatchEvent(t){if(void 0===this._listeners)return;const e=this._listeners[t.type];if(void 0!==e){t.target=this;const i=e.slice(0);for(let e=0,n=i.length;e<n;e++)i[e].call(this,t);t.target=null}}}const Xe=["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 je=1234567;const Ye=Math.PI/180,Ze=180/Math.PI;function Je(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,i=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return(Xe[255&t]+Xe[t>>8&255]+Xe[t>>16&255]+Xe[t>>24&255]+"-"+Xe[255&e]+Xe[e>>8&255]+"-"+Xe[e>>16&15|64]+Xe[e>>24&255]+"-"+Xe[63&i|128]+Xe[i>>8&255]+"-"+Xe[i>>16&255]+Xe[i>>24&255]+Xe[255&n]+Xe[n>>8&255]+Xe[n>>16&255]+Xe[n>>24&255]).toLowerCase()}function Ke(t,e,i){return Math.max(e,Math.min(i,t))}function $e(t,e){return(t%e+e)%e}function Qe(t,e,i){return(1-i)*t+i*e}function ti(t){return!(t&t-1)&&0!==t}function ei(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function ii(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function ni(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}const si={DEG2RAD:Ye,RAD2DEG:Ze,generateUUID:Je,clamp:Ke,euclideanModulo:$e,mapLinear:(t,e,i,n,s)=>n+(t-e)*(s-n)/(i-e),inverseLerp:(t,e,i)=>t!==e?(i-t)/(e-t):0,lerp:Qe,damp:(t,e,i,n)=>Qe(t,e,1-Math.exp(-i*n)),pingpong:(t,e=1)=>e-Math.abs($e(t,2*e)-e),smoothstep:(t,e,i)=>t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t),smootherstep:(t,e,i)=>t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*t*(t*(6*t-15)+10),randInt:(t,e)=>t+Math.floor(Math.random()*(e-t+1)),randFloat:(t,e)=>t+Math.random()*(e-t),randFloatSpread:t=>t*(.5-Math.random()),seededRandom(t){void 0!==t&&(je=t);let e=je+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296},degToRad:t=>t*Ye,radToDeg:t=>t*Ze,isPowerOfTwo:ti,ceilPowerOfTwo:t=>Math.pow(2,Math.ceil(Math.log(t)/Math.LN2)),floorPowerOfTwo:ei,setQuaternionFromProperEuler(t,e,i,n,s){const r=Math.cos,a=Math.sin,o=r(i/2),l=a(i/2),h=r((e+n)/2),c=a((e+n)/2),u=r((e-n)/2),d=a((e-n)/2),p=r((n-e)/2),m=a((n-e)/2);switch(s){case"XYX":t.set(o*c,l*u,l*d,o*h);break;case"YZY":t.set(l*d,o*c,l*u,o*h);break;case"ZXZ":t.set(l*u,l*d,o*c,o*h);break;case"XZX":t.set(o*c,l*m,l*p,o*h);break;case"YXY":t.set(l*p,o*c,l*m,o*h);break;case"ZYZ":t.set(l*m,l*p,o*c,o*h)}},normalize:ni,denormalize:ii};class ri{constructor(t=0,e=0){ri.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,i=this.y,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[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 i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}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(0===e)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(Ke(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,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 i=Math.cos(e),n=Math.sin(e),s=this.x-t.x,r=this.y-t.y;return this.x=s*i-r*n+t.x,this.y=s*n+r*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ai{constructor(t,e,i,n,s,r,a,o,l){ai.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,i,n,s,r,a,o,l)}set(t,e,i,n,s,r,a,o,l){const h=this.elements;return h[0]=t,h[1]=n,h[2]=a,h[3]=e,h[4]=s,h[5]=o,h[6]=i,h[7]=r,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.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 i=t.elements,n=e.elements,s=this.elements,r=i[0],a=i[3],o=i[6],l=i[1],h=i[4],c=i[7],u=i[2],d=i[5],p=i[8],m=n[0],f=n[3],g=n[6],_=n[1],v=n[4],y=n[7],x=n[2],M=n[5],b=n[8];return s[0]=r*m+a*_+o*x,s[3]=r*f+a*v+o*M,s[6]=r*g+a*y+o*b,s[1]=l*m+h*_+c*x,s[4]=l*f+h*v+c*M,s[7]=l*g+h*y+c*b,s[2]=u*m+d*_+p*x,s[5]=u*f+d*v+p*M,s[8]=u*g+d*y+p*b,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],i=t[1],n=t[2],s=t[3],r=t[4],a=t[5],o=t[6],l=t[7],h=t[8];return e*r*h-e*a*l-i*s*h+i*a*o+n*s*l-n*r*o}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],a=t[5],o=t[6],l=t[7],h=t[8],c=h*r-a*l,u=a*o-h*s,d=l*s-r*o,p=e*c+i*u+n*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return t[0]=c*m,t[1]=(n*l-h*i)*m,t[2]=(a*i-n*r)*m,t[3]=u*m,t[4]=(h*e-n*o)*m,t[5]=(n*s-a*e)*m,t[6]=d*m,t[7]=(i*o-l*e)*m,t[8]=(r*e-i*s)*m,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,i,n,s,r,a){const o=Math.cos(s),l=Math.sin(s);return this.set(i*o,i*l,-i*(o*r+l*a)+r+t,-n*l,n*o,-n*(-l*r+o*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(oi.makeScale(t,e)),this}rotate(t){return this.premultiply(oi.makeRotation(-t)),this}translate(t,e){return this.premultiply(oi.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),i=Math.sin(t);return this.set(e,-i,0,i,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,i=t.elements;for(let n=0;n<9;n++)if(e[n]!==i[n])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const oi=new ai;function li(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}const hi={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function ci(t,e){return new hi[t](e)}function ui(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function di(){const t=ui("canvas");return t.style.display="block",t}const pi={};function mi(t){t in pi||(pi[t]=!0)}const fi=(new ai).set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),gi=(new ai).set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),_i={[we]:{transfer:Ae,primaries:Re,toReference:t=>t,fromReference:t=>t},[Se]:{transfer:Ce,primaries:Re,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[Ee]:{transfer:Ae,primaries:Pe,toReference:t=>t.applyMatrix3(gi),fromReference:t=>t.applyMatrix3(fi)},[Te]:{transfer:Ce,primaries:Pe,toReference:t=>t.convertSRGBToLinear().applyMatrix3(gi),fromReference:t=>t.applyMatrix3(fi).convertLinearToSRGB()}},vi=new Set([we,Ee]),yi={enabled:!0,_workingColorSpace:we,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(t){if(!vi.has(t))throw new Error(`Unsupported working color space, "${t}".`);this._workingColorSpace=t},convert(t,e,i){if(!1===this.enabled||e===i||!e||!i)return t;const n=_i[e].toReference;return(0,_i[i].fromReference)(n(t))},fromWorkingColorSpace(t,e){return this.convert(t,this._workingColorSpace,e)},toWorkingColorSpace(t,e){return this.convert(t,e,this._workingColorSpace)},getPrimaries:t=>_i[t].primaries,getTransfer:t=>t===be?Ae:_i[t].transfer};function xi(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function Mi(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}let bi;class Si{static getDataURL(t){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===bi&&(bi=ui("canvas")),bi.width=t.width,bi.height=t.height;const i=bi.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),e=bi}return e.width>2048||e.height>2048?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}static sRGBToLinear(t){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=ui("canvas");e.width=t.width,e.height=t.height;const i=e.getContext("2d");i.drawImage(t,0,0,t.width,t.height);const n=i.getImageData(0,0,t.width,t.height),s=n.data;for(let t=0;t<s.length;t++)s[t]=255*xi(s[t]/255);return i.putImageData(n,0,0),e}if(t.data){const e=t.data.slice(0);for(let t=0;t<e.length;t++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[t]=Math.floor(255*xi(e[t]/255)):e[t]=xi(e[t]);return{data:e,width:t.width,height:t.height}}return t}}let wi=0;class Ti{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:wi++}),this.uuid=Je(),this.data=t,this.version=0}set needsUpdate(t){!0===t&&this.version++}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.images[this.uuid])return t.images[this.uuid];const i={uuid:this.uuid,url:""},n=this.data;if(null!==n){let t;if(Array.isArray(n)){t=[];for(let e=0,i=n.length;e<i;e++)n[e].isDataTexture?t.push(Ei(n[e].image)):t.push(Ei(n[e]))}else t=Ei(n);i.url=t}return e||(t.images[this.uuid]=i),i}}function Ei(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?Si.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:{}}let Ai=0;class Ci extends qe{constructor(t=Ci.DEFAULT_IMAGE,e=Ci.DEFAULT_MAPPING,i=1001,n=1001,s=1006,r=1008,a=1023,o=1009,l=Ci.DEFAULT_ANISOTROPY,h=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Ai++}),this.uuid=Je(),this.name="",this.source=new Ti(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=s,this.minFilter=r,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=o,this.offset=new ri(0,0),this.repeat=new ri(1,1),this.center=new ri(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ai,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,"string"==typeof h?this.colorSpace=h:(mi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=h===Me?Se:be),this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}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=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const i={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&&(i.userData=this.userData),e||(t.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==at)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case dt:t.x=t.x-Math.floor(t.x);break;case pt:t.x=t.x<0?0:1;break;case mt:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case dt:t.y=t.y-Math.floor(t.y);break;case pt:t.y=t.y<0?0:1;break;case mt:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return mi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Se?Me:xe}set encoding(t){mi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=t===Me?Se:be}}Ci.DEFAULT_IMAGE=null,Ci.DEFAULT_MAPPING=at,Ci.DEFAULT_ANISOTROPY=1;class Ri{constructor(t=0,e=0,i=0,n=1){Ri.prototype.isVector4=!0,this.x=t,this.y=e,this.z=i,this.w=n}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,i,n){return this.x=t,this.y=e,this.z=i,this.w=n,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=void 0!==t.w?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,i=this.y,n=this.z,s=this.w,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*n+r[12]*s,this.y=r[1]*e+r[5]*i+r[9]*n+r[13]*s,this.z=r[2]*e+r[6]*i+r[10]*n+r[14]*s,this.w=r[3]*e+r[7]*i+r[11]*n+r[15]*s,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,i,n,s;const r=.01,a=.1,o=t.elements,l=o[0],h=o[4],c=o[8],u=o[1],d=o[5],p=o[9],m=o[2],f=o[6],g=o[10];if(Math.abs(h-u)<r&&Math.abs(c-m)<r&&Math.abs(p-f)<r){if(Math.abs(h+u)<a&&Math.abs(c+m)<a&&Math.abs(p+f)<a&&Math.abs(l+d+g-3)<a)return this.set(1,0,0,0),this;e=Math.PI;const t=(l+1)/2,o=(d+1)/2,_=(g+1)/2,v=(h+u)/4,y=(c+m)/4,x=(p+f)/4;return t>o&&t>_?t<r?(i=0,n=.707106781,s=.707106781):(i=Math.sqrt(t),n=v/i,s=y/i):o>_?o<r?(i=.707106781,n=0,s=.707106781):(n=Math.sqrt(o),i=v/n,s=x/n):_<r?(i=.707106781,n=.707106781,s=0):(s=Math.sqrt(_),i=y/s,n=x/s),this.set(i,n,s,e),this}let _=Math.sqrt((f-p)*(f-p)+(c-m)*(c-m)+(u-h)*(u-h));return Math.abs(_)<.001&&(_=1),this.x=(f-p)/_,this.y=(c-m)/_,this.z=(u-h)/_,this.w=Math.acos((l+d+g-1)/2),this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this.w=t.w+(e.w-t.w)*i,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 Pi extends qe{constructor(t=1,e=1,i={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new Ri(0,0,t,e),this.scissorTest=!1,this.viewport=new Ri(0,0,t,e);const n={width:t,height:e,depth:1};void 0!==i.encoding&&(mi("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),i.colorSpace=i.encoding===Me?Se:be),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:vt,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},i),this.texture=new Ci(n,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=i.generateMipmaps,this.texture.internalFormat=i.internalFormat,this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.depthTexture=i.depthTexture,this.samples=i.samples}setSize(t,e,i=1){this.width===t&&this.height===e&&this.depth===i||(this.width=t,this.height=e,this.depth=i,this.texture.image.width=t,this.texture.image.height=e,this.texture.image.depth=i,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.texture=t.texture.clone(),this.texture.isRenderTargetTexture=!0;const e=Object.assign({},t.texture.image);return this.texture.source=new Ti(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,null!==t.depthTexture&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Li extends Pi{constructor(t=1,e=1,i={}){super(t,e,i),this.isWebGLRenderTarget=!0}}class Ii extends Ci{constructor(t=null,e=1,i=1,n=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:i,depth:n},this.magFilter=ft,this.minFilter=ft,this.wrapR=pt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Di extends Ci{constructor(t=null,e=1,i=1,n=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:i,depth:n},this.magFilter=ft,this.minFilter=ft,this.wrapR=pt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ui{constructor(t=0,e=0,i=0,n=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=i,this._w=n}static slerpFlat(t,e,i,n,s,r,a){let o=i[n+0],l=i[n+1],h=i[n+2],c=i[n+3];const u=s[r+0],d=s[r+1],p=s[r+2],m=s[r+3];if(0===a)return t[e+0]=o,t[e+1]=l,t[e+2]=h,void(t[e+3]=c);if(1===a)return t[e+0]=u,t[e+1]=d,t[e+2]=p,void(t[e+3]=m);if(c!==m||o!==u||l!==d||h!==p){let t=1-a;const e=o*u+l*d+h*p+c*m,i=e>=0?1:-1,n=1-e*e;if(n>Number.EPSILON){const s=Math.sqrt(n),r=Math.atan2(s,e*i);t=Math.sin(t*r)/s,a=Math.sin(a*r)/s}const s=a*i;if(o=o*t+u*s,l=l*t+d*s,h=h*t+p*s,c=c*t+m*s,t===1-a){const t=1/Math.sqrt(o*o+l*l+h*h+c*c);o*=t,l*=t,h*=t,c*=t}}t[e]=o,t[e+1]=l,t[e+2]=h,t[e+3]=c}static multiplyQuaternionsFlat(t,e,i,n,s,r){const a=i[n],o=i[n+1],l=i[n+2],h=i[n+3],c=s[r],u=s[r+1],d=s[r+2],p=s[r+3];return t[e]=a*p+h*c+o*d-l*u,t[e+1]=o*p+h*u+l*c-a*d,t[e+2]=l*p+h*d+a*u-o*c,t[e+3]=h*p-a*c-o*u-l*d,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,i,n){return this._x=t,this._y=e,this._z=i,this._w=n,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 i=t._x,n=t._y,s=t._z,r=t._order,a=Math.cos,o=Math.sin,l=a(i/2),h=a(n/2),c=a(s/2),u=o(i/2),d=o(n/2),p=o(s/2);switch(r){case"XYZ":this._x=u*h*c+l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c-u*d*p;break;case"YXZ":this._x=u*h*c+l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c+u*d*p;break;case"ZXY":this._x=u*h*c-l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c-u*d*p;break;case"ZYX":this._x=u*h*c-l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c+u*d*p;break;case"YZX":this._x=u*h*c+l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c-u*d*p;break;case"XZY":this._x=u*h*c-l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c+u*d*p}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,n=Math.sin(i);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],n=e[4],s=e[8],r=e[1],a=e[5],o=e[9],l=e[2],h=e[6],c=e[10],u=i+a+c;if(u>0){const t=.5/Math.sqrt(u+1);this._w=.25/t,this._x=(h-o)*t,this._y=(s-l)*t,this._z=(r-n)*t}else if(i>a&&i>c){const t=2*Math.sqrt(1+i-a-c);this._w=(h-o)/t,this._x=.25*t,this._y=(n+r)/t,this._z=(s+l)/t}else if(a>c){const t=2*Math.sqrt(1+a-i-c);this._w=(s-l)/t,this._x=(n+r)/t,this._y=.25*t,this._z=(o+h)/t}else{const t=2*Math.sqrt(1+c-i-a);this._w=(r-n)/t,this._x=(s+l)/t,this._y=(o+h)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<Number.EPSILON?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(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=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Ke(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(0===i)return this;const n=Math.min(1,e/i);return this.slerp(t,n),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 0===t?(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 i=t._x,n=t._y,s=t._z,r=t._w,a=e._x,o=e._y,l=e._z,h=e._w;return this._x=i*h+r*a+n*l-s*o,this._y=n*h+r*o+s*a-i*l,this._z=s*h+r*l+i*o-n*a,this._w=r*h-i*a-n*o-s*l,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const i=this._x,n=this._y,s=this._z,r=this._w;let a=r*t._w+i*t._x+n*t._y+s*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=r,this._x=i,this._y=n,this._z=s,this;const o=1-a*a;if(o<=Number.EPSILON){const t=1-e;return this._w=t*r+e*this._w,this._x=t*i+e*this._x,this._y=t*n+e*this._y,this._z=t*s+e*this._z,this.normalize(),this}const l=Math.sqrt(o),h=Math.atan2(l,a),c=Math.sin((1-e)*h)/l,u=Math.sin(e*h)/l;return this._w=r*c+this._w*u,this._x=i*c+this._x*u,this._y=n*c+this._y*u,this._z=s*c+this._z*u,this._onChangeCallback(),this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=Math.random(),e=Math.sqrt(1-t),i=Math.sqrt(t),n=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(e*Math.cos(n),i*Math.sin(s),i*Math.cos(s),e*Math.sin(n))}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 Ni{constructor(t=0,e=0,i=0){Ni.prototype.isVector3=!0,this.x=t,this.y=e,this.z=i}set(t,e,i){return void 0===i&&(i=this.z),this.x=t,this.y=e,this.z=i,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(Fi.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Fi.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,n=this.z,s=t.elements;return this.x=s[0]*e+s[3]*i+s[6]*n,this.y=s[1]*e+s[4]*i+s[7]*n,this.z=s[2]*e+s[5]*i+s[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,s=t.elements,r=1/(s[3]*e+s[7]*i+s[11]*n+s[15]);return this.x=(s[0]*e+s[4]*i+s[8]*n+s[12])*r,this.y=(s[1]*e+s[5]*i+s[9]*n+s[13])*r,this.z=(s[2]*e+s[6]*i+s[10]*n+s[14])*r,this}applyQuaternion(t){const e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,a=t.z,o=t.w,l=2*(r*n-a*i),h=2*(a*e-s*n),c=2*(s*i-r*e);return this.x=e+o*l+r*c-a*h,this.y=i+o*h+a*l-s*c,this.z=n+o*c+s*h-r*l,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,i=this.y,n=this.z,s=t.elements;return this.x=s[0]*e+s[4]*i+s[8]*n,this.y=s[1]*e+s[5]*i+s[9]*n,this.z=s[2]*e+s[6]*i+s[10]*n,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 i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,n=t.y,s=t.z,r=e.x,a=e.y,o=e.z;return this.x=n*o-s*a,this.y=s*r-i*o,this.z=i*a-n*r,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return Oi.copy(this).projectOnVector(t),this.sub(Oi)}reflect(t){return this.sub(Oi.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(Ke(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return e*e+i*i+n*n}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,i){const n=Math.sin(e)*t;return this.x=n*Math.sin(i),this.y=Math.cos(e)*t,this.z=n*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,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(),i=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=n,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}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=2*(Math.random()-.5),e=Math.random()*Math.PI*2,i=Math.sqrt(1-t**2);return this.x=i*Math.cos(e),this.y=i*Math.sin(e),this.z=t,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Oi=new Ni,Fi=new Ui;class Bi{constructor(t=new Ni(1/0,1/0,1/0),e=new Ni(-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,i=t.length;e<i;e+=3)this.expandByPoint(ki.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,i=t.count;e<i;e++)this.expandByPoint(ki.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=ki.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),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 i=t.geometry;if(void 0!==i){const n=i.getAttribute("position");if(!0===e&&void 0!==n&&!0!==t.isInstancedMesh)for(let e=0,i=n.count;e<i;e++)!0===t.isMesh?t.getVertexPosition(e,ki):ki.fromBufferAttribute(n,e),ki.applyMatrix4(t.matrixWorld),this.expandByPoint(ki);else void 0!==t.boundingBox?(null===t.boundingBox&&t.computeBoundingBox(),Vi.copy(t.boundingBox)):(null===i.boundingBox&&i.computeBoundingBox(),Vi.copy(i.boundingBox)),Vi.applyMatrix4(t.matrixWorld),this.union(Vi)}const n=t.children;for(let s=0,r=n.length;s<r;s++)this.expandByObject(n[s],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,ki),ki.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Yi),Zi.subVectors(this.max,Yi),Gi.subVectors(t.a,Yi),Hi.subVectors(t.b,Yi),Wi.subVectors(t.c,Yi),qi.subVectors(Hi,Gi),Xi.subVectors(Wi,Hi),ji.subVectors(Gi,Wi);let e=[0,-qi.z,qi.y,0,-Xi.z,Xi.y,0,-ji.z,ji.y,qi.z,0,-qi.x,Xi.z,0,-Xi.x,ji.z,0,-ji.x,-qi.y,qi.x,0,-Xi.y,Xi.x,0,-ji.y,ji.x,0];return!!$i(e,Gi,Hi,Wi,Zi)&&(e=[1,0,0,0,1,0,0,0,1],!!$i(e,Gi,Hi,Wi,Zi)&&(Ji.crossVectors(qi,Xi),e=[Ji.x,Ji.y,Ji.z],$i(e,Gi,Hi,Wi,Zi)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,ki).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(ki).length()),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()||(zi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),zi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),zi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),zi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),zi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),zi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),zi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),zi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(zi)),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 zi=[new Ni,new Ni,new Ni,new Ni,new Ni,new Ni,new Ni,new Ni],ki=new Ni,Vi=new Bi,Gi=new Ni,Hi=new Ni,Wi=new Ni,qi=new Ni,Xi=new Ni,ji=new Ni,Yi=new Ni,Zi=new Ni,Ji=new Ni,Ki=new Ni;function $i(t,e,i,n,s){for(let r=0,a=t.length-3;r<=a;r+=3){Ki.fromArray(t,r);const a=s.x*Math.abs(Ki.x)+s.y*Math.abs(Ki.y)+s.z*Math.abs(Ki.z),o=e.dot(Ki),l=i.dot(Ki),h=n.dot(Ki);if(Math.max(-Math.max(o,l,h),Math.min(o,l,h))>a)return!1}return!0}const Qi=new Bi,tn=new Ni,en=new Ni;class nn{constructor(t=new Ni,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 i=this.center;void 0!==e?i.copy(e):Qi.setFromPoints(t).getCenter(i);let n=0;for(let s=0,r=t.length;s<r;s++)n=Math.max(n,i.distanceToSquared(t[s]));return this.radius=Math.sqrt(n),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 i=this.center.distanceToSquared(t);return e.copy(t),i>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;tn.subVectors(t,this.center);const e=tn.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),i=.5*(t-this.radius);this.center.addScaledVector(tn,i/t),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):(en.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(tn.copy(t.center).add(en)),this.expandByPoint(tn.copy(t.center).sub(en))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const sn=new Ni,rn=new Ni,an=new Ni,on=new Ni,ln=new Ni,hn=new Ni,cn=new Ni;class un{constructor(t=new Ni,e=new Ni(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,sn)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const i=e.dot(this.direction);return i<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=sn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(sn.copy(this.origin).addScaledVector(this.direction,e),sn.distanceToSquared(t))}distanceSqToSegment(t,e,i,n){rn.copy(t).add(e).multiplyScalar(.5),an.copy(e).sub(t).normalize(),on.copy(this.origin).sub(rn);const s=.5*t.distanceTo(e),r=-this.direction.dot(an),a=on.dot(this.direction),o=-on.dot(an),l=on.lengthSq(),h=Math.abs(1-r*r);let c,u,d,p;if(h>0)if(c=r*o-a,u=r*a-o,p=s*h,c>=0)if(u>=-p)if(u<=p){const t=1/h;c*=t,u*=t,d=c*(c+r*u+2*a)+u*(r*c+u+2*o)+l}else u=s,c=Math.max(0,-(r*u+a)),d=-c*c+u*(u+2*o)+l;else u=-s,c=Math.max(0,-(r*u+a)),d=-c*c+u*(u+2*o)+l;else u<=-p?(c=Math.max(0,-(-r*s+a)),u=c>0?-s:Math.min(Math.max(-s,-o),s),d=-c*c+u*(u+2*o)+l):u<=p?(c=0,u=Math.min(Math.max(-s,-o),s),d=u*(u+2*o)+l):(c=Math.max(0,-(r*s+a)),u=c>0?s:Math.min(Math.max(-s,-o),s),d=-c*c+u*(u+2*o)+l);else u=r>0?-s:s,c=Math.max(0,-(r*u+a)),d=-c*c+u*(u+2*o)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,c),n&&n.copy(rn).addScaledVector(an,u),d}intersectSphere(t,e){sn.subVectors(t.center,this.origin);const i=sn.dot(this.direction),n=sn.dot(sn)-i*i,s=t.radius*t.radius;if(n>s)return null;const r=Math.sqrt(s-n),a=i-r,o=i+r;return o<0?null:a<0?this.at(o,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){const i=this.distanceToPlane(t);return null===i?null:this.at(i,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let i,n,s,r,a,o;const l=1/this.direction.x,h=1/this.direction.y,c=1/this.direction.z,u=this.origin;return l>=0?(i=(t.min.x-u.x)*l,n=(t.max.x-u.x)*l):(i=(t.max.x-u.x)*l,n=(t.min.x-u.x)*l),h>=0?(s=(t.min.y-u.y)*h,r=(t.max.y-u.y)*h):(s=(t.max.y-u.y)*h,r=(t.min.y-u.y)*h),i>r||s>n?null:((s>i||isNaN(i))&&(i=s),(r<n||isNaN(n))&&(n=r),c>=0?(a=(t.min.z-u.z)*c,o=(t.max.z-u.z)*c):(a=(t.max.z-u.z)*c,o=(t.min.z-u.z)*c),i>o||a>n?null:((a>i||i!=i)&&(i=a),(o<n||n!=n)&&(n=o),n<0?null:this.at(i>=0?i:n,e)))}intersectsBox(t){return null!==this.intersectBox(t,sn)}intersectTriangle(t,e,i,n,s){ln.subVectors(e,t),hn.subVectors(i,t),cn.crossVectors(ln,hn);let r,a=this.direction.dot(cn);if(a>0){if(n)return null;r=1}else{if(!(a<0))return null;r=-1,a=-a}on.subVectors(this.origin,t);const o=r*this.direction.dot(hn.crossVectors(on,hn));if(o<0)return null;const l=r*this.direction.dot(ln.cross(on));if(l<0)return null;if(o+l>a)return null;const h=-r*on.dot(cn);return h<0?null:this.at(h/a,s)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class dn{constructor(t,e,i,n,s,r,a,o,l,h,c,u,d,p,m,f){dn.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,i,n,s,r,a,o,l,h,c,u,d,p,m,f)}set(t,e,i,n,s,r,a,o,l,h,c,u,d,p,m,f){const g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=n,g[1]=s,g[5]=r,g[9]=a,g[13]=o,g[2]=l,g[6]=h,g[10]=c,g[14]=u,g[3]=d,g[7]=p,g[11]=m,g[15]=f,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 dn).fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[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,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,i=t.elements,n=1/pn.setFromMatrixColumn(t,0).length(),s=1/pn.setFromMatrixColumn(t,1).length(),r=1/pn.setFromMatrixColumn(t,2).length();return e[0]=i[0]*n,e[1]=i[1]*n,e[2]=i[2]*n,e[3]=0,e[4]=i[4]*s,e[5]=i[5]*s,e[6]=i[6]*s,e[7]=0,e[8]=i[8]*r,e[9]=i[9]*r,e[10]=i[10]*r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,i=t.x,n=t.y,s=t.z,r=Math.cos(i),a=Math.sin(i),o=Math.cos(n),l=Math.sin(n),h=Math.cos(s),c=Math.sin(s);if("XYZ"===t.order){const t=r*h,i=r*c,n=a*h,s=a*c;e[0]=o*h,e[4]=-o*c,e[8]=l,e[1]=i+n*l,e[5]=t-s*l,e[9]=-a*o,e[2]=s-t*l,e[6]=n+i*l,e[10]=r*o}else if("YXZ"===t.order){const t=o*h,i=o*c,n=l*h,s=l*c;e[0]=t+s*a,e[4]=n*a-i,e[8]=r*l,e[1]=r*c,e[5]=r*h,e[9]=-a,e[2]=i*a-n,e[6]=s+t*a,e[10]=r*o}else if("ZXY"===t.order){const t=o*h,i=o*c,n=l*h,s=l*c;e[0]=t-s*a,e[4]=-r*c,e[8]=n+i*a,e[1]=i+n*a,e[5]=r*h,e[9]=s-t*a,e[2]=-r*l,e[6]=a,e[10]=r*o}else if("ZYX"===t.order){const t=r*h,i=r*c,n=a*h,s=a*c;e[0]=o*h,e[4]=n*l-i,e[8]=t*l+s,e[1]=o*c,e[5]=s*l+t,e[9]=i*l-n,e[2]=-l,e[6]=a*o,e[10]=r*o}else if("YZX"===t.order){const t=r*o,i=r*l,n=a*o,s=a*l;e[0]=o*h,e[4]=s-t*c,e[8]=n*c+i,e[1]=c,e[5]=r*h,e[9]=-a*h,e[2]=-l*h,e[6]=i*c+n,e[10]=t-s*c}else if("XZY"===t.order){const t=r*o,i=r*l,n=a*o,s=a*l;e[0]=o*h,e[4]=-c,e[8]=l*h,e[1]=t*c+s,e[5]=r*h,e[9]=i*c-n,e[2]=n*c-i,e[6]=a*h,e[10]=s*c+t}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(fn,t,gn)}lookAt(t,e,i){const n=this.elements;return yn.subVectors(t,e),0===yn.lengthSq()&&(yn.z=1),yn.normalize(),_n.crossVectors(i,yn),0===_n.lengthSq()&&(1===Math.abs(i.z)?yn.x+=1e-4:yn.z+=1e-4,yn.normalize(),_n.crossVectors(i,yn)),_n.normalize(),vn.crossVectors(yn,_n),n[0]=_n.x,n[4]=vn.x,n[8]=yn.x,n[1]=_n.y,n[5]=vn.y,n[9]=yn.y,n[2]=_n.z,n[6]=vn.z,n[10]=yn.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,s=this.elements,r=i[0],a=i[4],o=i[8],l=i[12],h=i[1],c=i[5],u=i[9],d=i[13],p=i[2],m=i[6],f=i[10],g=i[14],_=i[3],v=i[7],y=i[11],x=i[15],M=n[0],b=n[4],S=n[8],w=n[12],T=n[1],E=n[5],A=n[9],C=n[13],R=n[2],P=n[6],L=n[10],I=n[14],D=n[3],U=n[7],N=n[11],O=n[15];return s[0]=r*M+a*T+o*R+l*D,s[4]=r*b+a*E+o*P+l*U,s[8]=r*S+a*A+o*L+l*N,s[12]=r*w+a*C+o*I+l*O,s[1]=h*M+c*T+u*R+d*D,s[5]=h*b+c*E+u*P+d*U,s[9]=h*S+c*A+u*L+d*N,s[13]=h*w+c*C+u*I+d*O,s[2]=p*M+m*T+f*R+g*D,s[6]=p*b+m*E+f*P+g*U,s[10]=p*S+m*A+f*L+g*N,s[14]=p*w+m*C+f*I+g*O,s[3]=_*M+v*T+y*R+x*D,s[7]=_*b+v*E+y*P+x*U,s[11]=_*S+v*A+y*L+x*N,s[15]=_*w+v*C+y*I+x*O,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],i=t[4],n=t[8],s=t[12],r=t[1],a=t[5],o=t[9],l=t[13],h=t[2],c=t[6],u=t[10],d=t[14];return t[3]*(+s*o*c-n*l*c-s*a*u+i*l*u+n*a*d-i*o*d)+t[7]*(+e*o*d-e*l*u+s*r*u-n*r*d+n*l*h-s*o*h)+t[11]*(+e*l*c-e*a*d-s*r*c+i*r*d+s*a*h-i*l*h)+t[15]*(-n*a*h-e*o*c+e*a*u+n*r*c-i*r*u+i*o*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,i){const n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],a=t[5],o=t[6],l=t[7],h=t[8],c=t[9],u=t[10],d=t[11],p=t[12],m=t[13],f=t[14],g=t[15],_=c*f*l-m*u*l+m*o*d-a*f*d-c*o*g+a*u*g,v=p*u*l-h*f*l-p*o*d+r*f*d+h*o*g-r*u*g,y=h*m*l-p*c*l+p*a*d-r*m*d-h*a*g+r*c*g,x=p*c*o-h*m*o-p*a*u+r*m*u+h*a*f-r*c*f,M=e*_+i*v+n*y+s*x;if(0===M)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const b=1/M;return t[0]=_*b,t[1]=(m*u*s-c*f*s-m*n*d+i*f*d+c*n*g-i*u*g)*b,t[2]=(a*f*s-m*o*s+m*n*l-i*f*l-a*n*g+i*o*g)*b,t[3]=(c*o*s-a*u*s-c*n*l+i*u*l+a*n*d-i*o*d)*b,t[4]=v*b,t[5]=(h*f*s-p*u*s+p*n*d-e*f*d-h*n*g+e*u*g)*b,t[6]=(p*o*s-r*f*s-p*n*l+e*f*l+r*n*g-e*o*g)*b,t[7]=(r*u*s-h*o*s+h*n*l-e*u*l-r*n*d+e*o*d)*b,t[8]=y*b,t[9]=(p*c*s-h*m*s-p*i*d+e*m*d+h*i*g-e*c*g)*b,t[10]=(r*m*s-p*a*s+p*i*l-e*m*l-r*i*g+e*a*g)*b,t[11]=(h*a*s-r*c*s-h*i*l+e*c*l+r*i*d-e*a*d)*b,t[12]=x*b,t[13]=(h*m*n-p*c*n+p*i*u-e*m*u-h*i*f+e*c*f)*b,t[14]=(p*a*n-r*m*n-p*i*o+e*m*o+r*i*f-e*a*f)*b,t[15]=(r*c*n-h*a*n+h*i*o-e*c*o-r*i*u+e*a*u)*b,this}scale(t){const e=this.elements,i=t.x,n=t.y,s=t.z;return e[0]*=i,e[4]*=n,e[8]*=s,e[1]*=i,e[5]*=n,e[9]*=s,e[2]*=i,e[6]*=n,e[10]*=s,e[3]*=i,e[7]*=n,e[11]*=s,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,n))}makeTranslation(t,e,i){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,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),n=Math.sin(e),s=1-i,r=t.x,a=t.y,o=t.z,l=s*r,h=s*a;return this.set(l*r+i,l*a-n*o,l*o+n*a,0,l*a+n*o,h*a+i,h*o-n*r,0,l*o-n*a,h*o+n*r,s*o*o+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,n,s,r){return this.set(1,i,s,0,t,1,r,0,e,n,1,0,0,0,0,1),this}compose(t,e,i){const n=this.elements,s=e._x,r=e._y,a=e._z,o=e._w,l=s+s,h=r+r,c=a+a,u=s*l,d=s*h,p=s*c,m=r*h,f=r*c,g=a*c,_=o*l,v=o*h,y=o*c,x=i.x,M=i.y,b=i.z;return n[0]=(1-(m+g))*x,n[1]=(d+y)*x,n[2]=(p-v)*x,n[3]=0,n[4]=(d-y)*M,n[5]=(1-(u+g))*M,n[6]=(f+_)*M,n[7]=0,n[8]=(p+v)*b,n[9]=(f-_)*b,n[10]=(1-(u+m))*b,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,i){const n=this.elements;let s=pn.set(n[0],n[1],n[2]).length();const r=pn.set(n[4],n[5],n[6]).length(),a=pn.set(n[8],n[9],n[10]).length();this.determinant()<0&&(s=-s),t.x=n[12],t.y=n[13],t.z=n[14],mn.copy(this);const o=1/s,l=1/r,h=1/a;return mn.elements[0]*=o,mn.elements[1]*=o,mn.elements[2]*=o,mn.elements[4]*=l,mn.elements[5]*=l,mn.elements[6]*=l,mn.elements[8]*=h,mn.elements[9]*=h,mn.elements[10]*=h,e.setFromRotationMatrix(mn),i.x=s,i.y=r,i.z=a,this}makePerspective(t,e,i,n,s,r,a=2e3){const o=this.elements,l=2*s/(e-t),h=2*s/(i-n),c=(e+t)/(e-t),u=(i+n)/(i-n);let d,p;if(a===He)d=-(r+s)/(r-s),p=-2*r*s/(r-s);else{if(a!==We)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);d=-r/(r-s),p=-r*s/(r-s)}return o[0]=l,o[4]=0,o[8]=c,o[12]=0,o[1]=0,o[5]=h,o[9]=u,o[13]=0,o[2]=0,o[6]=0,o[10]=d,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,i,n,s,r,a=2e3){const o=this.elements,l=1/(e-t),h=1/(i-n),c=1/(r-s),u=(e+t)*l,d=(i+n)*h;let p,m;if(a===He)p=(r+s)*c,m=-2*c;else{if(a!==We)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);p=s*c,m=-1*c}return o[0]=2*l,o[4]=0,o[8]=0,o[12]=-u,o[1]=0,o[5]=2*h,o[9]=0,o[13]=-d,o[2]=0,o[6]=0,o[10]=m,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let n=0;n<16;n++)if(e[n]!==i[n])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}const pn=new Ni,mn=new dn,fn=new Ni(0,0,0),gn=new Ni(1,1,1),_n=new Ni,vn=new Ni,yn=new Ni,xn=new dn,Mn=new Ui;class bn{constructor(t=0,e=0,i=0,n=bn.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=n}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,i,n=this._order){return this._x=t,this._y=e,this._z=i,this._order=n,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,i=!0){const n=t.elements,s=n[0],r=n[4],a=n[8],o=n[1],l=n[5],h=n[9],c=n[2],u=n[6],d=n[10];switch(e){case"XYZ":this._y=Math.asin(Ke(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-r,s)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Ke(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-c,s),this._z=0);break;case"ZXY":this._x=Math.asin(Ke(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-r,l)):(this._y=0,this._z=Math.atan2(o,s));break;case"ZYX":this._y=Math.asin(-Ke(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,s)):(this._x=0,this._z=Math.atan2(-r,l));break;case"YZX":this._z=Math.asin(Ke(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-c,s)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-Ke(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-h,d),this._y=0)}return this._order=e,!0===i&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return xn.makeRotationFromQuaternion(t),this.setFromRotationMatrix(xn,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Mn.setFromEuler(this),this.setFromQuaternion(Mn,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],void 0!==t[3]&&(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}}bn.DEFAULT_ORDER="XYZ";class Sn{constructor(){this.mask=1}set(t){this.mask=1<<t>>>0}enable(t){this.mask|=1<<t}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t}disable(t){this.mask&=~(1<<t)}disableAll(){this.mask=0}test(t){return 0!==(this.mask&t.mask)}isEnabled(t){return!!(this.mask&1<<t)}}let wn=0;const Tn=new Ni,En=new Ui,An=new dn,Cn=new Ni,Rn=new Ni,Pn=new Ni,Ln=new Ui,In=new Ni(1,0,0),Dn=new Ni(0,1,0),Un=new Ni(0,0,1),Nn={type:"added"},On={type:"removed"};class Fn extends qe{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:wn++}),this.uuid=Je(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Fn.DEFAULT_UP.clone();const t=new Ni,e=new bn,i=new Ui,n=new Ni(1,1,1);e._onChange(function(){i.setFromEuler(e,!1)}),i._onChange(function(){e.setFromQuaternion(i,void 0,!1)}),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new dn},normalMatrix:{value:new ai}}),this.matrix=new dn,this.matrixWorld=new dn,this.matrixAutoUpdate=Fn.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Fn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Sn,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 En.setFromAxisAngle(t,e),this.quaternion.multiply(En),this}rotateOnWorldAxis(t,e){return En.setFromAxisAngle(t,e),this.quaternion.premultiply(En),this}rotateX(t){return this.rotateOnAxis(In,t)}rotateY(t){return this.rotateOnAxis(Dn,t)}rotateZ(t){return this.rotateOnAxis(Un,t)}translateOnAxis(t,e){return Tn.copy(t).applyQuaternion(this.quaternion),this.position.add(Tn.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(In,t)}translateY(t){return this.translateOnAxis(Dn,t)}translateZ(t){return this.translateOnAxis(Un,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(An.copy(this.matrixWorld).invert())}lookAt(t,e,i){t.isVector3?Cn.copy(t):Cn.set(t,e,i);const n=this.parent;this.updateWorldMatrix(!0,!1),Rn.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?An.lookAt(Rn,Cn,this.up):An.lookAt(Cn,Rn,this.up),this.quaternion.setFromRotationMatrix(An),n&&(An.extractRotation(n.matrixWorld),En.setFromRotationMatrix(An),this.quaternion.premultiply(En.invert()))}add(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return t===this||t&&t.isObject3D&&(null!==t.parent&&t.parent.remove(t),t.parent=this,this.children.push(t),t.dispatchEvent(Nn)),this}remove(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.remove(arguments[t]);return this}const e=this.children.indexOf(t);return-1!==e&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(On)),this}removeFromParent(){const t=this.parent;return null!==t&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),An.copy(this.matrixWorld).invert(),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),An.multiply(t.parent.matrixWorld)),t.applyMatrix4(An),this.add(t),t.updateWorldMatrix(!1,!0),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 i=0,n=this.children.length;i<n;i++){const n=this.children[i].getObjectByProperty(t,e);if(void 0!==n)return n}}getObjectsByProperty(t,e,i=[]){this[t]===e&&i.push(this);const n=this.children;for(let s=0,r=n.length;s<r;s++)n[s].getObjectsByProperty(t,e,i);return i}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Rn,t,Pn),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Rn,Ln,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 i=0,n=e.length;i<n;i++)e[i].traverse(t)}traverseVisible(t){if(!1===this.visible)return;t(this);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].traverseVisible(t)}traverseAncestors(t){const e=this.parent;null!==e&&(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)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let i=0,n=e.length;i<n;i++){const n=e[i];!0!==n.matrixWorldAutoUpdate&&!0!==t||n.updateMatrixWorld(t)}}updateWorldMatrix(t,e){const i=this.parent;if(!0===t&&null!==i&&!0===i.matrixWorldAutoUpdate&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===e){const t=this.children;for(let e=0,i=t.length;e<i;e++){const i=t[e];!0===i.matrixWorldAutoUpdate&&i.updateWorldMatrix(!1,!0)}}}toJSON(t){const e=void 0===t||"string"==typeof t,i={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const n={};function s(e,i){return void 0===e[i.uuid]&&(e[i.uuid]=i.toJSON(t)),i.uuid}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),!0===this.castShadow&&(n.castShadow=!0),!0===this.receiveShadow&&(n.receiveShadow=!0),!1===this.visible&&(n.visible=!1),!1===this.frustumCulled&&(n.frustumCulled=!1),0!==this.renderOrder&&(n.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),n.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(n.matrixAutoUpdate=!1),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(n.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(n.type="BatchedMesh",n.perObjectFrustumCulled=this.perObjectFrustumCulled,n.sortObjects=this.sortObjects,n.drawRanges=this._drawRanges,n.reservedRanges=this._reservedRanges,n.visibility=this._visibility,n.active=this._active,n.bounds=this._bounds.map(t=>({boxInitialized:t.boxInitialized,boxMin:t.box.min.toArray(),boxMax:t.box.max.toArray(),sphereInitialized:t.sphereInitialized,sphereRadius:t.sphere.radius,sphereCenter:t.sphere.center.toArray()})),n.maxGeometryCount=this._maxGeometryCount,n.maxVertexCount=this._maxVertexCount,n.maxIndexCount=this._maxIndexCount,n.geometryInitialized=this._geometryInitialized,n.geometryCount=this._geometryCount,n.matricesTexture=this._matricesTexture.toJSON(t),null!==this.boundingSphere&&(n.boundingSphere={center:n.boundingSphere.center.toArray(),radius:n.boundingSphere.radius}),null!==this.boundingBox&&(n.boundingBox={min:n.boundingBox.min.toArray(),max:n.boundingBox.max.toArray()})),this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(n.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=s(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const i=e.shapes;if(Array.isArray(i))for(let e=0,n=i.length;e<n;e++){const n=i[e];s(t.shapes,n)}else s(t.shapes,i)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(s(t.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const e=[];for(let i=0,n=this.material.length;i<n;i++)e.push(s(t.materials,this.material[i]));n.material=e}else n.material=s(t.materials,this.material);if(this.children.length>0){n.children=[];for(let e=0;e<this.children.length;e++)n.children.push(this.children[e].toJSON(t).object)}if(this.animations.length>0){n.animations=[];for(let e=0;e<this.animations.length;e++){const i=this.animations[e];n.animations.push(s(t.animations,i))}}if(e){const e=r(t.geometries),n=r(t.materials),s=r(t.textures),a=r(t.images),o=r(t.shapes),l=r(t.skeletons),h=r(t.animations),c=r(t.nodes);e.length>0&&(i.geometries=e),n.length>0&&(i.materials=n),s.length>0&&(i.textures=s),a.length>0&&(i.images=a),o.length>0&&(i.shapes=o),l.length>0&&(i.skeletons=l),h.length>0&&(i.animations=h),c.length>0&&(i.nodes=c)}return i.object=n,i;function r(t){const e=[];for(const i in t){const n=t[i];delete n.metadata,e.push(n)}return e}}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)),!0===e)for(let i=0;i<t.children.length;i++){const e=t.children[i];this.add(e.clone())}return this}}Fn.DEFAULT_UP=new Ni(0,1,0),Fn.DEFAULT_MATRIX_AUTO_UPDATE=!0,Fn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Bn=new Ni,zn=new Ni,kn=new Ni,Vn=new Ni,Gn=new Ni,Hn=new Ni,Wn=new Ni,qn=new Ni,Xn=new Ni,jn=new Ni;let Yn=!1;class Zn{constructor(t=new Ni,e=new Ni,i=new Ni){this.a=t,this.b=e,this.c=i}static getNormal(t,e,i,n){n.subVectors(i,e),Bn.subVectors(t,e),n.cross(Bn);const s=n.lengthSq();return s>0?n.multiplyScalar(1/Math.sqrt(s)):n.set(0,0,0)}static getBarycoord(t,e,i,n,s){Bn.subVectors(n,e),zn.subVectors(i,e),kn.subVectors(t,e);const r=Bn.dot(Bn),a=Bn.dot(zn),o=Bn.dot(kn),l=zn.dot(zn),h=zn.dot(kn),c=r*l-a*a;if(0===c)return s.set(0,0,0),null;const u=1/c,d=(l*o-a*h)*u,p=(r*h-a*o)*u;return s.set(1-d-p,p,d)}static containsPoint(t,e,i,n){return null!==this.getBarycoord(t,e,i,n,Vn)&&Vn.x>=0&&Vn.y>=0&&Vn.x+Vn.y<=1}static getUV(t,e,i,n,s,r,a,o){return!1===Yn&&(Yn=!0),this.getInterpolation(t,e,i,n,s,r,a,o)}static getInterpolation(t,e,i,n,s,r,a,o){return null===this.getBarycoord(t,e,i,n,Vn)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(s,Vn.x),o.addScaledVector(r,Vn.y),o.addScaledVector(a,Vn.z),o)}static isFrontFacing(t,e,i,n){return Bn.subVectors(i,e),zn.subVectors(t,e),Bn.cross(zn).dot(n)<0}set(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this}setFromPointsAndIndices(t,e,i,n){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[n]),this}setFromAttributeAndIndices(t,e,i,n){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,i),this.c.fromBufferAttribute(t,n),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 Bn.subVectors(this.c,this.b),zn.subVectors(this.a,this.b),.5*Bn.cross(zn).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Zn.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Zn.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,i,n,s){return!1===Yn&&(Yn=!0),Zn.getInterpolation(t,this.a,this.b,this.c,e,i,n,s)}getInterpolation(t,e,i,n,s){return Zn.getInterpolation(t,this.a,this.b,this.c,e,i,n,s)}containsPoint(t){return Zn.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Zn.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const i=this.a,n=this.b,s=this.c;let r,a;Gn.subVectors(n,i),Hn.subVectors(s,i),qn.subVectors(t,i);const o=Gn.dot(qn),l=Hn.dot(qn);if(o<=0&&l<=0)return e.copy(i);Xn.subVectors(t,n);const h=Gn.dot(Xn),c=Hn.dot(Xn);if(h>=0&&c<=h)return e.copy(n);const u=o*c-h*l;if(u<=0&&o>=0&&h<=0)return r=o/(o-h),e.copy(i).addScaledVector(Gn,r);jn.subVectors(t,s);const d=Gn.dot(jn),p=Hn.dot(jn);if(p>=0&&d<=p)return e.copy(s);const m=d*l-o*p;if(m<=0&&l>=0&&p<=0)return a=l/(l-p),e.copy(i).addScaledVector(Hn,a);const f=h*p-d*c;if(f<=0&&c-h>=0&&d-p>=0)return Wn.subVectors(s,n),a=(c-h)/(c-h+(d-p)),e.copy(n).addScaledVector(Wn,a);const g=1/(f+m+u);return r=m*g,a=u*g,e.copy(i).addScaledVector(Gn,r).addScaledVector(Hn,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Jn={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},Kn={h:0,s:0,l:0},$n={h:0,s:0,l:0};function Qn(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+6*(e-t)*(2/3-i):t}class ts{constructor(t,e,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,i)}set(t,e,i){if(void 0===e&&void 0===i){const e=t;e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e)}else this.setRGB(t,e,i);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Se){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,yi.toWorkingColorSpace(this,e),this}setRGB(t,e,i,n=yi.workingColorSpace){return this.r=t,this.g=e,this.b=i,yi.toWorkingColorSpace(this,n),this}setHSL(t,e,i,n=yi.workingColorSpace){if(t=$e(t,1),e=Ke(e,0,1),i=Ke(i,0,1),0===e)this.r=this.g=this.b=i;else{const n=i<=.5?i*(1+e):i+e-i*e,s=2*i-n;this.r=Qn(s,n,t+1/3),this.g=Qn(s,n,t),this.b=Qn(s,n,t-1/3)}return yi.toWorkingColorSpace(this,n),this}setStyle(t,e=Se){function i(t){void 0!==t&&parseFloat(t)}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(t)){let t;const s=n[1],r=n[2];switch(s){case"rgb":case"rgba":if(t=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return i(t[4]),this.setRGB(Math.min(255,parseInt(t[1],10))/255,Math.min(255,parseInt(t[2],10))/255,Math.min(255,parseInt(t[3],10))/255,e);if(t=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return i(t[4]),this.setRGB(Math.min(100,parseInt(t[1],10))/100,Math.min(100,parseInt(t[2],10))/100,Math.min(100,parseInt(t[3],10))/100,e);break;case"hsl":case"hsla":if(t=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return i(t[4]),this.setHSL(parseFloat(t[1])/360,parseFloat(t[2])/100,parseFloat(t[3])/100,e)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){const t=n[1],i=t.length;if(3===i)return this.setRGB(parseInt(t.charAt(0),16)/15,parseInt(t.charAt(1),16)/15,parseInt(t.charAt(2),16)/15,e);if(6===i)return this.setHex(parseInt(t,16),e)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Se){const i=Jn[t.toLowerCase()];return void 0!==i&&this.setHex(i,e),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=xi(t.r),this.g=xi(t.g),this.b=xi(t.b),this}copyLinearToSRGB(t){return this.r=Mi(t.r),this.g=Mi(t.g),this.b=Mi(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Se){return yi.fromWorkingColorSpace(es.copy(this),t),65536*Math.round(Ke(255*es.r,0,255))+256*Math.round(Ke(255*es.g,0,255))+Math.round(Ke(255*es.b,0,255))}getHexString(t=Se){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=yi.workingColorSpace){yi.fromWorkingColorSpace(es.copy(this),e);const i=es.r,n=es.g,s=es.b,r=Math.max(i,n,s),a=Math.min(i,n,s);let o,l;const h=(a+r)/2;if(a===r)o=0,l=0;else{const t=r-a;switch(l=h<=.5?t/(r+a):t/(2-r-a),r){case i:o=(n-s)/t+(n<s?6:0);break;case n:o=(s-i)/t+2;break;case s:o=(i-n)/t+4}o/=6}return t.h=o,t.s=l,t.l=h,t}getRGB(t,e=yi.workingColorSpace){return yi.fromWorkingColorSpace(es.copy(this),e),t.r=es.r,t.g=es.g,t.b=es.b,t}getStyle(t=Se){yi.fromWorkingColorSpace(es.copy(this),t);const e=es.r,i=es.g,n=es.b;return t!==Se?`color(${t} ${e.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(255*e)},${Math.round(255*i)},${Math.round(255*n)})`}offsetHSL(t,e,i){return this.getHSL(Kn),this.setHSL(Kn.h+t,Kn.s+e,Kn.l+i)}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,i){return this.r=t.r+(e.r-t.r)*i,this.g=t.g+(e.g-t.g)*i,this.b=t.b+(e.b-t.b)*i,this}lerpHSL(t,e){this.getHSL(Kn),t.getHSL($n);const i=Qe(Kn.h,$n.h,e),n=Qe(Kn.s,$n.s,e),s=Qe(Kn.l,$n.l,e);return this.setHSL(i,n,s),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,i=this.g,n=this.b,s=t.elements;return this.r=s[0]*e+s[3]*i+s[6]*n,this.g=s[1]*e+s[4]*i+s[7]*n,this.b=s[2]*e+s[5]*i+s[8]*n,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 es=new ts;ts.NAMES=Jn;let is=0;class ns extends qe{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:is++}),this.uuid=Je(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=j,this.blendDst=Y,this.blendEquation=k,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ts(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Le,this.stencilZFail=Le,this.stencilZPass=Le,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const i=t[e];if(void 0===i)continue;const n=this[e];void 0!==n&&(n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[e]=i)}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function n(t){const e=[];for(const i in t){const n=t[i];delete n.metadata,e.push(n)}return e}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),void 0!==this.sheen&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearcoat&&(i.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.iridescence&&(i.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(i.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),void 0!==this.anisotropy&&(i.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(t).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(i.combine=this.combine)),void 0!==this.envMapIntensity&&(i.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(i.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(i.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(i.size=this.size),null!==this.shadowSide&&(i.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(i.blending=this.blending),0!==this.side&&(i.side=this.side),!0===this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=!0),this.blendSrc!==j&&(i.blendSrc=this.blendSrc),this.blendDst!==Y&&(i.blendDst=this.blendDst),this.blendEquation!==k&&(i.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(i.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(i.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(i.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(i.depthFunc=this.depthFunc),!1===this.depthTest&&(i.depthTest=this.depthTest),!1===this.depthWrite&&(i.depthWrite=this.depthWrite),!1===this.colorWrite&&(i.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(i.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(i.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(i.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Le&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Le&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Le&&(i.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(i.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(i.rotation=this.rotation),!0===this.polygonOffset&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.alphaHash&&(i.alphaHash=!0),!0===this.alphaToCoverage&&(i.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=!0),!0===this.forceSinglePass&&(i.forceSinglePass=!0),!0===this.wireframe&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(i.flatShading=!0),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),!1===this.fog&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData),e){const e=n(t.textures),s=n(t.images);e.length>0&&(i.textures=e),s.length>0&&(i.images=s)}return i}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 i=null;if(null!==e){const t=e.length;i=new Array(t);for(let n=0;n!==t;++n)i[n]=e[n].clone()}return this.clippingPlanes=i,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){!0===t&&this.version++}}class ss extends ns{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ts(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const rs=as();function as(){const t=new ArrayBuffer(4),e=new Float32Array(t),i=new Uint32Array(t),n=new Uint32Array(512),s=new Uint32Array(512);for(let l=0;l<256;++l){const t=l-127;t<-27?(n[l]=0,n[256|l]=32768,s[l]=24,s[256|l]=24):t<-14?(n[l]=1024>>-t-14,n[256|l]=1024>>-t-14|32768,s[l]=-t-1,s[256|l]=-t-1):t<=15?(n[l]=t+15<<10,n[256|l]=t+15<<10|32768,s[l]=13,s[256|l]=13):t<128?(n[l]=31744,n[256|l]=64512,s[l]=24,s[256|l]=24):(n[l]=31744,n[256|l]=64512,s[l]=13,s[256|l]=13)}const r=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let t=l<<13,e=0;for(;!(8388608&t);)t<<=1,e-=8388608;t&=-8388609,e+=947912704,r[l]=t|e}for(let l=1024;l<2048;++l)r[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)32!==l&&(o[l]=1024);return{floatView:e,uint32View:i,baseTable:n,shiftTable:s,mantissaTable:r,exponentTable:a,offsetTable:o}}function os(t){Math.abs(t),t=Ke(t,-65504,65504),rs.floatView[0]=t;const e=rs.uint32View[0],i=e>>23&511;return rs.baseTable[i]+((8388607&e)>>rs.shiftTable[i])}function ls(t){const e=t>>10;return rs.uint32View[0]=rs.mantissaTable[rs.offsetTable[e]+(1023&t)]+rs.exponentTable[e],rs.floatView[0]}const hs={toHalfFloat:os,fromHalfFloat:ls},cs=new Ni,us=new ri;class ds{constructor(t,e,i=!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=void 0!==t?t.length/e:0,this.normalized=i,this.usage=ke,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Tt,this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}get updateRange(){return this._updateRange}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,i){t*=this.itemSize,i*=e.itemSize;for(let n=0,s=this.itemSize;n<s;n++)this.array[t+n]=e.array[i+n];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(2===this.itemSize)for(let e=0,i=this.count;e<i;e++)us.fromBufferAttribute(this,e),us.applyMatrix3(t),this.setXY(e,us.x,us.y);else if(3===this.itemSize)for(let e=0,i=this.count;e<i;e++)cs.fromBufferAttribute(this,e),cs.applyMatrix3(t),this.setXYZ(e,cs.x,cs.y,cs.z);return this}applyMatrix4(t){for(let e=0,i=this.count;e<i;e++)cs.fromBufferAttribute(this,e),cs.applyMatrix4(t),this.setXYZ(e,cs.x,cs.y,cs.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)cs.fromBufferAttribute(this,e),cs.applyNormalMatrix(t),this.setXYZ(e,cs.x,cs.y,cs.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)cs.fromBufferAttribute(this,e),cs.transformDirection(t),this.setXYZ(e,cs.x,cs.y,cs.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let i=this.array[t*this.itemSize+e];return this.normalized&&(i=ii(i,this.array)),i}setComponent(t,e,i){return this.normalized&&(i=ni(i,this.array)),this.array[t*this.itemSize+e]=i,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=ii(e,this.array)),e}setX(t,e){return this.normalized&&(e=ni(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=ii(e,this.array)),e}setY(t,e){return this.normalized&&(e=ni(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=ii(e,this.array)),e}setZ(t,e){return this.normalized&&(e=ni(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=ii(e,this.array)),e}setW(t,e){return this.normalized&&(e=ni(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=ni(e,this.array),i=ni(i,this.array)),this.array[t+0]=e,this.array[t+1]=i,this}setXYZ(t,e,i,n){return t*=this.itemSize,this.normalized&&(e=ni(e,this.array),i=ni(i,this.array),n=ni(n,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this}setXYZW(t,e,i,n,s){return t*=this.itemSize,this.normalized&&(e=ni(e,this.array),i=ni(i,this.array),n=ni(n,this.array),s=ni(s,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this.array[t+3]=s,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!==ke&&(t.usage=this.usage),t}}class ps extends ds{constructor(t,e,i){super(new Uint16Array(t),e,i)}}class ms extends ds{constructor(t,e,i){super(new Uint32Array(t),e,i)}}class fs extends ds{constructor(t,e,i){super(new Float32Array(t),e,i)}}let gs=0;const _s=new dn,vs=new Fn,ys=new Ni,xs=new Bi,Ms=new Bi,bs=new Ni;class Ss extends qe{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:gs++}),this.uuid=Je(),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(li(t)?ms:ps)(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 void 0!==this.attributes[t]}addGroup(t,e,i=0){this.groups.push({start:t,count:e,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const i=this.attributes.normal;if(void 0!==i){const e=(new ai).getNormalMatrix(t);i.applyNormalMatrix(e),i.needsUpdate=!0}const n=this.attributes.tangent;return void 0!==n&&(n.transformDirection(t),n.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(t){return _s.makeRotationFromQuaternion(t),this.applyMatrix4(_s),this}rotateX(t){return _s.makeRotationX(t),this.applyMatrix4(_s),this}rotateY(t){return _s.makeRotationY(t),this.applyMatrix4(_s),this}rotateZ(t){return _s.makeRotationZ(t),this.applyMatrix4(_s),this}translate(t,e,i){return _s.makeTranslation(t,e,i),this.applyMatrix4(_s),this}scale(t,e,i){return _s.makeScale(t,e,i),this.applyMatrix4(_s),this}lookAt(t){return vs.lookAt(t),vs.updateMatrix(),this.applyMatrix4(vs.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ys).negate(),this.translate(ys.x,ys.y,ys.z),this}setFromPoints(t){const e=[];for(let i=0,n=t.length;i<n;i++){const n=t[i];e.push(n.x,n.y,n.z||0)}return this.setAttribute("position",new fs(e,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Bi);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)this.boundingBox.set(new Ni(-1/0,-1/0,-1/0),new Ni(1/0,1/0,1/0));else{if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,i=e.length;t<i;t++){const i=e[t];xs.setFromBufferAttribute(i),this.morphTargetsRelative?(bs.addVectors(this.boundingBox.min,xs.min),this.boundingBox.expandByPoint(bs),bs.addVectors(this.boundingBox.max,xs.max),this.boundingBox.expandByPoint(bs)):(this.boundingBox.expandByPoint(xs.min),this.boundingBox.expandByPoint(xs.max))}}else this.boundingBox.makeEmpty();isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z)}}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new nn);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)this.boundingSphere.set(new Ni,1/0);else if(t){const i=this.boundingSphere.center;if(xs.setFromBufferAttribute(t),e)for(let t=0,s=e.length;t<s;t++){const i=e[t];Ms.setFromBufferAttribute(i),this.morphTargetsRelative?(bs.addVectors(xs.min,Ms.min),xs.expandByPoint(bs),bs.addVectors(xs.max,Ms.max),xs.expandByPoint(bs)):(xs.expandByPoint(Ms.min),xs.expandByPoint(Ms.max))}xs.getCenter(i);let n=0;for(let e=0,s=t.count;e<s;e++)bs.fromBufferAttribute(t,e),n=Math.max(n,i.distanceToSquared(bs));if(e)for(let s=0,r=e.length;s<r;s++){const r=e[s],a=this.morphTargetsRelative;for(let e=0,s=r.count;e<s;e++)bs.fromBufferAttribute(r,e),a&&(ys.fromBufferAttribute(t,e),bs.add(ys)),n=Math.max(n,i.distanceToSquared(bs))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)}}computeTangents(){const t=this.index,e=this.attributes;if(null===t||void 0===e.position||void 0===e.normal||void 0===e.uv)return;const i=t.array,n=e.position.array,s=e.normal.array,r=e.uv.array,a=n.length/3;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new ds(new Float32Array(4*a),4));const o=this.getAttribute("tangent").array,l=[],h=[];for(let T=0;T<a;T++)l[T]=new Ni,h[T]=new Ni;const c=new Ni,u=new Ni,d=new Ni,p=new ri,m=new ri,f=new ri,g=new Ni,_=new Ni;function v(t,e,i){c.fromArray(n,3*t),u.fromArray(n,3*e),d.fromArray(n,3*i),p.fromArray(r,2*t),m.fromArray(r,2*e),f.fromArray(r,2*i),u.sub(c),d.sub(c),m.sub(p),f.sub(p);const s=1/(m.x*f.y-f.x*m.y);isFinite(s)&&(g.copy(u).multiplyScalar(f.y).addScaledVector(d,-m.y).multiplyScalar(s),_.copy(d).multiplyScalar(m.x).addScaledVector(u,-f.x).multiplyScalar(s),l[t].add(g),l[e].add(g),l[i].add(g),h[t].add(_),h[e].add(_),h[i].add(_))}let y=this.groups;0===y.length&&(y=[{start:0,count:i.length}]);for(let T=0,E=y.length;T<E;++T){const t=y[T],e=t.start;for(let n=e,s=e+t.count;n<s;n+=3)v(i[n+0],i[n+1],i[n+2])}const x=new Ni,M=new Ni,b=new Ni,S=new Ni;function w(t){b.fromArray(s,3*t),S.copy(b);const e=l[t];x.copy(e),x.sub(b.multiplyScalar(b.dot(e))).normalize(),M.crossVectors(S,e);const i=M.dot(h[t])<0?-1:1;o[4*t]=x.x,o[4*t+1]=x.y,o[4*t+2]=x.z,o[4*t+3]=i}for(let T=0,E=y.length;T<E;++T){const t=y[T],e=t.start;for(let n=e,s=e+t.count;n<s;n+=3)w(i[n+0]),w(i[n+1]),w(i[n+2])}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(void 0!==e){let i=this.getAttribute("normal");if(void 0===i)i=new ds(new Float32Array(3*e.count),3),this.setAttribute("normal",i);else for(let t=0,e=i.count;t<e;t++)i.setXYZ(t,0,0,0);const n=new Ni,s=new Ni,r=new Ni,a=new Ni,o=new Ni,l=new Ni,h=new Ni,c=new Ni;if(t)for(let u=0,d=t.count;u<d;u+=3){const d=t.getX(u+0),p=t.getX(u+1),m=t.getX(u+2);n.fromBufferAttribute(e,d),s.fromBufferAttribute(e,p),r.fromBufferAttribute(e,m),h.subVectors(r,s),c.subVectors(n,s),h.cross(c),a.fromBufferAttribute(i,d),o.fromBufferAttribute(i,p),l.fromBufferAttribute(i,m),a.add(h),o.add(h),l.add(h),i.setXYZ(d,a.x,a.y,a.z),i.setXYZ(p,o.x,o.y,o.z),i.setXYZ(m,l.x,l.y,l.z)}else for(let t=0,u=e.count;t<u;t+=3)n.fromBufferAttribute(e,t+0),s.fromBufferAttribute(e,t+1),r.fromBufferAttribute(e,t+2),h.subVectors(r,s),c.subVectors(n,s),h.cross(c),i.setXYZ(t+0,h.x,h.y,h.z),i.setXYZ(t+1,h.x,h.y,h.z),i.setXYZ(t+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,i=t.count;e<i;e++)bs.fromBufferAttribute(t,e),bs.normalize(),t.setXYZ(e,bs.x,bs.y,bs.z)}toNonIndexed(){function t(t,e){const i=t.array,n=t.itemSize,s=t.normalized,r=new i.constructor(e.length*n);let a=0,o=0;for(let l=0,h=e.length;l<h;l++){a=t.isInterleavedBufferAttribute?e[l]*t.data.stride+t.offset:e[l]*n;for(let t=0;t<n;t++)r[o++]=i[a++]}return new ds(r,n,s)}if(null===this.index)return this;const e=new Ss,i=this.index.array,n=this.attributes;for(const a in n){const s=t(n[a],i);e.setAttribute(a,s)}const s=this.morphAttributes;for(const a in s){const n=[],r=s[a];for(let e=0,s=r.length;e<s;e++){const s=t(r[e],i);n.push(s)}e.morphAttributes[a]=n}e.morphTargetsRelative=this.morphTargetsRelative;const r=this.groups;for(let a=0,o=r.length;a<o;a++){const t=r[a];e.addGroup(t.start,t.count,t.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),void 0!==this.parameters){const e=this.parameters;for(const i in e)void 0!==e[i]&&(t[i]=e[i]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const i=this.attributes;for(const o in i){const e=i[o];t.data.attributes[o]=e.toJSON(t.data)}const n={};let s=!1;for(const o in this.morphAttributes){const e=this.morphAttributes[o],i=[];for(let n=0,s=e.length;n<s;n++){const s=e[n];i.push(s.toJSON(t.data))}i.length>0&&(n[o]=i,s=!0)}s&&(t.data.morphAttributes=n,t.data.morphTargetsRelative=this.morphTargetsRelative);const r=this.groups;r.length>0&&(t.data.groups=JSON.parse(JSON.stringify(r)));const a=this.boundingSphere;return null!==a&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return(new this.constructor).copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const i=t.index;null!==i&&this.setIndex(i.clone(e));const n=t.attributes;for(const l in n){const t=n[l];this.setAttribute(l,t.clone(e))}const s=t.morphAttributes;for(const l in s){const t=[],i=s[l];for(let n=0,s=i.length;n<s;n++)t.push(i[n].clone(e));this.morphAttributes[l]=t}this.morphTargetsRelative=t.morphTargetsRelative;const r=t.groups;for(let l=0,h=r.length;l<h;l++){const t=r[l];this.addGroup(t.start,t.count,t.materialIndex)}const a=t.boundingBox;null!==a&&(this.boundingBox=a.clone());const o=t.boundingSphere;return null!==o&&(this.boundingSphere=o.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const ws=new dn,Ts=new un,Es=new nn,As=new Ni,Cs=new Ni,Rs=new Ni,Ps=new Ni,Ls=new Ni,Is=new Ni,Ds=new ri,Us=new ri,Ns=new ri,Os=new Ni,Fs=new Ni,Bs=new Ni,zs=new Ni,ks=new Ni;class Vs extends Fn{constructor(t=new Ss,e=new ss){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),void 0!==t.morphTargetInfluences&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;t<e;t++){const e=i[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}getVertexPosition(t,e){const i=this.geometry,n=i.attributes.position,s=i.morphAttributes.position,r=i.morphTargetsRelative;e.fromBufferAttribute(n,t);const a=this.morphTargetInfluences;if(s&&a){Is.set(0,0,0);for(let i=0,n=s.length;i<n;i++){const n=a[i],o=s[i];0!==n&&(Ls.fromBufferAttribute(o,t),r?Is.addScaledVector(Ls,n):Is.addScaledVector(Ls.sub(e),n))}e.add(Is)}return e}raycast(t,e){const i=this.geometry,n=this.material,s=this.matrixWorld;if(void 0!==n){if(null===i.boundingSphere&&i.computeBoundingSphere(),Es.copy(i.boundingSphere),Es.applyMatrix4(s),Ts.copy(t.ray).recast(t.near),!1===Es.containsPoint(Ts.origin)){if(null===Ts.intersectSphere(Es,As))return;if(Ts.origin.distanceToSquared(As)>(t.far-t.near)**2)return}ws.copy(s).invert(),Ts.copy(t.ray).applyMatrix4(ws),null!==i.boundingBox&&!1===Ts.intersectsBox(i.boundingBox)||this._computeIntersections(t,e,Ts)}}_computeIntersections(t,e,i){let n;const s=this.geometry,r=this.material,a=s.index,o=s.attributes.position,l=s.attributes.uv,h=s.attributes.uv1,c=s.attributes.normal,u=s.groups,d=s.drawRange;if(null!==a)if(Array.isArray(r))for(let p=0,m=u.length;p<m;p++){const s=u[p],o=r[s.materialIndex];for(let r=Math.max(s.start,d.start),u=Math.min(a.count,Math.min(s.start+s.count,d.start+d.count));r<u;r+=3)n=Gs(this,o,t,i,l,h,c,a.getX(r),a.getX(r+1),a.getX(r+2)),n&&(n.faceIndex=Math.floor(r/3),n.face.materialIndex=s.materialIndex,e.push(n))}else for(let p=Math.max(0,d.start),m=Math.min(a.count,d.start+d.count);p<m;p+=3)n=Gs(this,r,t,i,l,h,c,a.getX(p),a.getX(p+1),a.getX(p+2)),n&&(n.faceIndex=Math.floor(p/3),e.push(n));else if(void 0!==o)if(Array.isArray(r))for(let p=0,m=u.length;p<m;p++){const s=u[p],a=r[s.materialIndex];for(let r=Math.max(s.start,d.start),u=Math.min(o.count,Math.min(s.start+s.count,d.start+d.count));r<u;r+=3)n=Gs(this,a,t,i,l,h,c,r,r+1,r+2),n&&(n.faceIndex=Math.floor(r/3),n.face.materialIndex=s.materialIndex,e.push(n))}else for(let p=Math.max(0,d.start),m=Math.min(o.count,d.start+d.count);p<m;p+=3)n=Gs(this,r,t,i,l,h,c,p,p+1,p+2),n&&(n.faceIndex=Math.floor(p/3),e.push(n))}}function Gs(t,e,i,n,s,r,a,o,l,h){t.getVertexPosition(o,Cs),t.getVertexPosition(l,Rs),t.getVertexPosition(h,Ps);const c=function(t,e,i,n,s,r,a,o){let l;if(l=1===e.side?n.intersectTriangle(a,r,s,!0,o):n.intersectTriangle(s,r,a,0===e.side,o),null===l)return null;ks.copy(o),ks.applyMatrix4(t.matrixWorld);const h=i.ray.origin.distanceTo(ks);return h<i.near||h>i.far?null:{distance:h,point:ks.clone(),object:t}}(t,e,i,n,Cs,Rs,Ps,zs);if(c){s&&(Ds.fromBufferAttribute(s,o),Us.fromBufferAttribute(s,l),Ns.fromBufferAttribute(s,h),c.uv=Zn.getInterpolation(zs,Cs,Rs,Ps,Ds,Us,Ns,new ri)),r&&(Ds.fromBufferAttribute(r,o),Us.fromBufferAttribute(r,l),Ns.fromBufferAttribute(r,h),c.uv1=Zn.getInterpolation(zs,Cs,Rs,Ps,Ds,Us,Ns,new ri),c.uv2=c.uv1),a&&(Os.fromBufferAttribute(a,o),Fs.fromBufferAttribute(a,l),Bs.fromBufferAttribute(a,h),c.normal=Zn.getInterpolation(zs,Cs,Rs,Ps,Os,Fs,Bs,new Ni),c.normal.dot(n.direction)>0&&c.normal.multiplyScalar(-1));const t={a:o,b:l,c:h,normal:new Ni,materialIndex:0};Zn.getNormal(Cs,Rs,Ps,t.normal),c.face=t}return c}class Hs extends Ss{constructor(t=1,e=1,i=1,n=1,s=1,r=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:n,heightSegments:s,depthSegments:r};const a=this;n=Math.floor(n),s=Math.floor(s),r=Math.floor(r);const o=[],l=[],h=[],c=[];let u=0,d=0;function p(t,e,i,n,s,r,p,m,f,g,_){const v=r/f,y=p/g,x=r/2,M=p/2,b=m/2,S=f+1,w=g+1;let T=0,E=0;const A=new Ni;for(let a=0;a<w;a++){const r=a*y-M;for(let o=0;o<S;o++){const u=o*v-x;A[t]=u*n,A[e]=r*s,A[i]=b,l.push(A.x,A.y,A.z),A[t]=0,A[e]=0,A[i]=m>0?1:-1,h.push(A.x,A.y,A.z),c.push(o/f),c.push(1-a/g),T+=1}}for(let a=0;a<g;a++)for(let t=0;t<f;t++){const e=u+t+S*a,i=u+t+S*(a+1),n=u+(t+1)+S*(a+1),s=u+(t+1)+S*a;o.push(e,i,s),o.push(i,n,s),E+=6}a.addGroup(d,E,_),d+=E,u+=T}p("z","y","x",-1,-1,i,e,t,r,s,0),p("z","y","x",1,-1,i,e,-t,r,s,1),p("x","z","y",1,1,t,i,e,n,r,2),p("x","z","y",1,-1,t,i,-e,n,r,3),p("x","y","z",1,-1,t,e,i,n,s,4),p("x","y","z",-1,-1,t,e,-i,n,s,5),this.setIndex(o),this.setAttribute("position",new fs(l,3)),this.setAttribute("normal",new fs(h,3)),this.setAttribute("uv",new fs(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Hs(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function Ws(t){const e={};for(const i in t){e[i]={};for(const n in t[i]){const s=t[i][n];s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)?s.isRenderTargetTexture?e[i][n]=null:e[i][n]=s.clone():Array.isArray(s)?e[i][n]=s.slice():e[i][n]=s}}return e}function qs(t){const e={};for(let i=0;i<t.length;i++){const n=Ws(t[i]);for(const t in n)e[t]=n[t]}return e}function Xs(t){return null===t.getRenderTarget()?t.outputColorSpace:yi.workingColorSpace}const js={clone:Ws,merge:qs};class Ys extends ns{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1,clipCullDistance:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==t&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Ws(t.uniforms),this.uniformsGroups=function(t){const e=[];for(let i=0;i<t.length;i++)e.push(t[i].clone());return e}(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 n in this.uniforms){const i=this.uniforms[n].value;i&&i.isTexture?e.uniforms[n]={type:"t",value:i.toJSON(t).uuid}:i&&i.isColor?e.uniforms[n]={type:"c",value:i.getHex()}:i&&i.isVector2?e.uniforms[n]={type:"v2",value:i.toArray()}:i&&i.isVector3?e.uniforms[n]={type:"v3",value:i.toArray()}:i&&i.isVector4?e.uniforms[n]={type:"v4",value:i.toArray()}:i&&i.isMatrix3?e.uniforms[n]={type:"m3",value:i.toArray()}:i&&i.isMatrix4?e.uniforms[n]={type:"m4",value:i.toArray()}:e.uniforms[n]={value:i}}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 i={};for(const n in this.extensions)!0===this.extensions[n]&&(i[n]=!0);return Object.keys(i).length>0&&(e.extensions=i),e}}class Zs extends Fn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new dn,this.projectionMatrix=new dn,this.projectionMatrixInverse=new dn,this.coordinateSystem=He}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)}}class Js extends Zs{constructor(t=50,e=1,i=.1,n=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=i,this.far=n,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=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=2*Ze*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*Ye*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*Ze*Math.atan(Math.tan(.5*Ye*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(t,e,i,n,s,r){this.aspect=t/e,null===this.view&&(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=i,this.view.offsetY=n,this.view.width=s,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*Ye*this.fov)/this.zoom,i=2*e,n=this.aspect*i,s=-.5*n;const r=this.view;if(null!==this.view&&this.view.enabled){const t=r.fullWidth,a=r.fullHeight;s+=r.offsetX*n/t,e-=r.offsetY*i/a,n*=r.width/t,i*=r.height/a}const a=this.filmOffset;0!==a&&(s+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+n,e,e-i,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,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const Ks=-90;class $s extends Fn{constructor(t,e,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const n=new Js(Ks,1,t,e);n.layers=this.layers,this.add(n);const s=new Js(Ks,1,t,e);s.layers=this.layers,this.add(s);const r=new Js(Ks,1,t,e);r.layers=this.layers,this.add(r);const a=new Js(Ks,1,t,e);a.layers=this.layers,this.add(a);const o=new Js(Ks,1,t,e);o.layers=this.layers,this.add(o);const l=new Js(Ks,1,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[i,n,s,r,a,o]=e;for(const l of e)this.remove(l);if(t===He)i.up.set(0,1,0),i.lookAt(1,0,0),n.up.set(0,1,0),n.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),r.up.set(0,0,1),r.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(t!==We)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);i.up.set(0,-1,0),i.lookAt(-1,0,0),n.up.set(0,-1,0),n.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),r.up.set(0,0,-1),r.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const l of e)this.add(l),l.updateMatrixWorld()}update(t,e){null===this.parent&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:n}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[s,r,a,o,l,h]=this.children,c=t.getRenderTarget(),u=t.getActiveCubeFace(),d=t.getActiveMipmapLevel(),p=t.xr.enabled;t.xr.enabled=!1;const m=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,t.setRenderTarget(i,0,n),t.render(e,s),t.setRenderTarget(i,1,n),t.render(e,r),t.setRenderTarget(i,2,n),t.render(e,a),t.setRenderTarget(i,3,n),t.render(e,o),t.setRenderTarget(i,4,n),t.render(e,l),i.texture.generateMipmaps=m,t.setRenderTarget(i,5,n),t.render(e,h),t.setRenderTarget(c,u,d),t.xr.enabled=p,i.texture.needsPMREMUpdate=!0}}class Qs extends Ci{constructor(t,e,i,n,s,r,a,o,l,h){super(t=void 0!==t?t:[],e=void 0!==e?e:ot,i,n,s,r,a,o,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class tr extends Li{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const i={width:t,height:t,depth:1},n=[i,i,i,i,i,i];void 0!==e.encoding&&(mi("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),e.colorSpace=e.encoding===Me?Se:be),this.texture=new Qs(n,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=void 0!==e.generateMipmaps&&e.generateMipmaps,this.texture.minFilter=void 0!==e.minFilter?e.minFilter:vt}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 i=new Hs(5,5,5),n=new Ys({name:"CubemapFromEquirect",uniforms:Ws({tEquirect:{value:null}}),vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",side:1,blending:0});n.uniforms.tEquirect.value=e;const s=new Vs(i,n),r=e.minFilter;return e.minFilter===xt&&(e.minFilter=vt),new $s(1,10,this).update(t,s),e.minFilter=r,s.geometry.dispose(),s.material.dispose(),this}clear(t,e,i,n){const s=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,i,n);t.setRenderTarget(s)}}const er=new Ni,ir=new Ni,nr=new ai;class sr{constructor(t=new Ni(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,i,n){return this.normal.set(t,e,i),this.constant=n,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,i){const n=er.subVectors(i,e).cross(ir.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(n,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 i=t.delta(er),n=this.normal.dot(i);if(0===n)return 0===this.distanceToPoint(t.start)?e.copy(t.start):null;const s=-(t.start.dot(this.normal)+this.constant)/n;return s<0||s>1?null:e.copy(t.start).addScaledVector(i,s)}intersectsLine(t){const e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<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 i=e||nr.getNormalMatrix(t),n=this.coplanarPoint(er).applyMatrix4(t),s=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(s),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const rr=new nn,ar=new Ni;class or{constructor(t=new sr,e=new sr,i=new sr,n=new sr,s=new sr,r=new sr){this.planes=[t,e,i,n,s,r]}set(t,e,i,n,s,r){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(i),a[3].copy(n),a[4].copy(s),a[5].copy(r),this}copy(t){const e=this.planes;for(let i=0;i<6;i++)e[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t,e=2e3){const i=this.planes,n=t.elements,s=n[0],r=n[1],a=n[2],o=n[3],l=n[4],h=n[5],c=n[6],u=n[7],d=n[8],p=n[9],m=n[10],f=n[11],g=n[12],_=n[13],v=n[14],y=n[15];if(i[0].setComponents(o-s,u-l,f-d,y-g).normalize(),i[1].setComponents(o+s,u+l,f+d,y+g).normalize(),i[2].setComponents(o+r,u+h,f+p,y+_).normalize(),i[3].setComponents(o-r,u-h,f-p,y-_).normalize(),i[4].setComponents(o-a,u-c,f-m,y-v).normalize(),e===He)i[5].setComponents(o+a,u+c,f+m,y+v).normalize();else{if(e!==We)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);i[5].setComponents(a,c,m,v).normalize()}return this}intersectsObject(t){if(void 0!==t.boundingSphere)null===t.boundingSphere&&t.computeBoundingSphere(),rr.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;null===e.boundingSphere&&e.computeBoundingSphere(),rr.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(rr)}intersectsSprite(t){return rr.center.set(0,0,0),rr.radius=.7071067811865476,rr.applyMatrix4(t.matrixWorld),this.intersectsSphere(rr)}intersectsSphere(t){const e=this.planes,i=t.center,n=-t.radius;for(let s=0;s<6;s++)if(e[s].distanceToPoint(i)<n)return!1;return!0}intersectsBox(t){const e=this.planes;for(let i=0;i<6;i++){const n=e[i];if(ar.x=n.normal.x>0?t.max.x:t.min.x,ar.y=n.normal.y>0?t.max.y:t.min.y,ar.z=n.normal.z>0?t.max.z:t.min.z,n.distanceToPoint(ar)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function lr(){let t=null,e=!1,i=null,n=null;function s(e,r){i(e,r),n=t.requestAnimationFrame(s)}return{start(){!0!==e&&null!==i&&(n=t.requestAnimationFrame(s),e=!0)},stop(){t.cancelAnimationFrame(n),e=!1},setAnimationLoop(t){i=t},setContext(e){t=e}}}function hr(t,e){const i=e.isWebGL2,n=new WeakMap;return{get:t=>(t.isInterleavedBufferAttribute&&(t=t.data),n.get(t)),remove(e){e.isInterleavedBufferAttribute&&(e=e.data);const i=n.get(e);i&&(t.deleteBuffer(i.buffer),n.delete(e))},update(e,s){if(e.isGLBufferAttribute){const t=n.get(e);return void((!t||t.version<e.version)&&n.set(e,{buffer:e.buffer,type:e.type,bytesPerElement:e.elementSize,version:e.version}))}e.isInterleavedBufferAttribute&&(e=e.data);const r=n.get(e);if(void 0===r)n.set(e,function(e,n){const s=e.array,r=e.usage,a=s.byteLength,o=t.createBuffer();let l;if(t.bindBuffer(n,o),t.bufferData(n,s,r),e.onUploadCallback(),s instanceof Float32Array)l=t.FLOAT;else if(s instanceof Uint16Array)if(e.isFloat16BufferAttribute){if(!i)throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");l=t.HALF_FLOAT}else l=t.UNSIGNED_SHORT;else if(s instanceof Int16Array)l=t.SHORT;else if(s instanceof Uint32Array)l=t.UNSIGNED_INT;else if(s instanceof Int32Array)l=t.INT;else if(s instanceof Int8Array)l=t.BYTE;else if(s instanceof Uint8Array)l=t.UNSIGNED_BYTE;else{if(!(s instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+s);l=t.UNSIGNED_BYTE}return{buffer:o,type:l,bytesPerElement:s.BYTES_PER_ELEMENT,version:e.version,size:a}}(e,s));else if(r.version<e.version){if(r.size!==e.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.");!function(e,n,s){const r=n.array,a=n._updateRange,o=n.updateRanges;if(t.bindBuffer(s,e),-1===a.count&&0===o.length&&t.bufferSubData(s,0,r),0!==o.length){for(let e=0,n=o.length;e<n;e++){const n=o[e];i?t.bufferSubData(s,n.start*r.BYTES_PER_ELEMENT,r,n.start,n.count):t.bufferSubData(s,n.start*r.BYTES_PER_ELEMENT,r.subarray(n.start,n.start+n.count))}n.clearUpdateRanges()}-1!==a.count&&(i?t.bufferSubData(s,a.offset*r.BYTES_PER_ELEMENT,r,a.offset,a.count):t.bufferSubData(s,a.offset*r.BYTES_PER_ELEMENT,r.subarray(a.offset,a.offset+a.count)),a.count=-1),n.onUploadCallback()}(r.buffer,e,s),r.version=e.version}}}}class cr extends Ss{constructor(t=1,e=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:i,heightSegments:n};const s=t/2,r=e/2,a=Math.floor(i),o=Math.floor(n),l=a+1,h=o+1,c=t/a,u=e/o,d=[],p=[],m=[],f=[];for(let g=0;g<h;g++){const t=g*u-r;for(let e=0;e<l;e++){const i=e*c-s;p.push(i,-t,0),m.push(0,0,1),f.push(e/a),f.push(1-g/o)}}for(let g=0;g<o;g++)for(let t=0;t<a;t++){const e=t+l*g,i=t+l*(g+1),n=t+1+l*(g+1),s=t+1+l*g;d.push(e,i,s),d.push(i,n,s)}this.setIndex(d),this.setAttribute("position",new fs(p,3)),this.setAttribute("normal",new fs(m,3)),this.setAttribute("uv",new fs(f,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new cr(t.width,t.height,t.widthSegments,t.heightSegments)}}const ur={alphahash_fragment:"#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n\tattribute float batchId;\n\tuniform highp sampler2D batchingTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",batching_vertex:"#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( batchId );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n\t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"\nconst mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(\n\tvec3( 0.8224621, 0.177538, 0.0 ),\n\tvec3( 0.0331941, 0.9668058, 0.0 ),\n\tvec3( 0.0170827, 0.0723974, 0.9105199 )\n);\nconst mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.2249401, - 0.2249404, 0.0 ),\n\tvec3( - 0.0420569, 1.0420571, 0.0 ),\n\tvec3( - 0.0196376, - 0.0786361, 1.0982735 )\n);\nvec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );\n}\nvec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );\n}\nvec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn 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 );\n}\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn sRGBTransferOETF( value );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( LEGACY_LIGHTS )\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#else\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = 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 );\n\t\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec2 packDepthToRG( in highp float v ) {\n\treturn packDepthToRGBA( v ).yx;\n}\nfloat unpackRGToDepth( const in highp vec2 v ) {\n\treturn unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor *= toneMappingExposure;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\treturn color;\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",depth_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}"},dr={common:{diffuse:{value:new ts(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ai},alphaMap:{value:null},alphaMapTransform:{value:new ai},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ai}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ai}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ai}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ai},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ai},normalScale:{value:new ri(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ai},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ai}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ai}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ai}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ts(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new ts(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ai},alphaTest:{value:0},uvTransform:{value:new ai}},sprite:{diffuse:{value:new ts(16777215)},opacity:{value:1},center:{value:new ri(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ai},alphaMap:{value:null},alphaMapTransform:{value:new ai},alphaTest:{value:0}}},pr={basic:{uniforms:qs([dr.common,dr.specularmap,dr.envmap,dr.aomap,dr.lightmap,dr.fog]),vertexShader:ur.meshbasic_vert,fragmentShader:ur.meshbasic_frag},lambert:{uniforms:qs([dr.common,dr.specularmap,dr.envmap,dr.aomap,dr.lightmap,dr.emissivemap,dr.bumpmap,dr.normalmap,dr.displacementmap,dr.fog,dr.lights,{emissive:{value:new ts(0)}}]),vertexShader:ur.meshlambert_vert,fragmentShader:ur.meshlambert_frag},phong:{uniforms:qs([dr.common,dr.specularmap,dr.envmap,dr.aomap,dr.lightmap,dr.emissivemap,dr.bumpmap,dr.normalmap,dr.displacementmap,dr.fog,dr.lights,{emissive:{value:new ts(0)},specular:{value:new ts(1118481)},shininess:{value:30}}]),vertexShader:ur.meshphong_vert,fragmentShader:ur.meshphong_frag},standard:{uniforms:qs([dr.common,dr.envmap,dr.aomap,dr.lightmap,dr.emissivemap,dr.bumpmap,dr.normalmap,dr.displacementmap,dr.roughnessmap,dr.metalnessmap,dr.fog,dr.lights,{emissive:{value:new ts(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ur.meshphysical_vert,fragmentShader:ur.meshphysical_frag},toon:{uniforms:qs([dr.common,dr.aomap,dr.lightmap,dr.emissivemap,dr.bumpmap,dr.normalmap,dr.displacementmap,dr.gradientmap,dr.fog,dr.lights,{emissive:{value:new ts(0)}}]),vertexShader:ur.meshtoon_vert,fragmentShader:ur.meshtoon_frag},matcap:{uniforms:qs([dr.common,dr.bumpmap,dr.normalmap,dr.displacementmap,dr.fog,{matcap:{value:null}}]),vertexShader:ur.meshmatcap_vert,fragmentShader:ur.meshmatcap_frag},points:{uniforms:qs([dr.points,dr.fog]),vertexShader:ur.points_vert,fragmentShader:ur.points_frag},dashed:{uniforms:qs([dr.common,dr.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ur.linedashed_vert,fragmentShader:ur.linedashed_frag},depth:{uniforms:qs([dr.common,dr.displacementmap]),vertexShader:ur.depth_vert,fragmentShader:ur.depth_frag},normal:{uniforms:qs([dr.common,dr.bumpmap,dr.normalmap,dr.displacementmap,{opacity:{value:1}}]),vertexShader:ur.meshnormal_vert,fragmentShader:ur.meshnormal_frag},sprite:{uniforms:qs([dr.sprite,dr.fog]),vertexShader:ur.sprite_vert,fragmentShader:ur.sprite_frag},background:{uniforms:{uvTransform:{value:new ai},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ur.background_vert,fragmentShader:ur.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:ur.backgroundCube_vert,fragmentShader:ur.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ur.cube_vert,fragmentShader:ur.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ur.equirect_vert,fragmentShader:ur.equirect_frag},distanceRGBA:{uniforms:qs([dr.common,dr.displacementmap,{referencePosition:{value:new Ni},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ur.distanceRGBA_vert,fragmentShader:ur.distanceRGBA_frag},shadow:{uniforms:qs([dr.lights,dr.fog,{color:{value:new ts(0)},opacity:{value:1}}]),vertexShader:ur.shadow_vert,fragmentShader:ur.shadow_frag}};pr.physical={uniforms:qs([pr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ai},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ai},clearcoatNormalScale:{value:new ri(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ai},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ai},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ai},sheen:{value:0},sheenColor:{value:new ts(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ai},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ai},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ai},transmissionSamplerSize:{value:new ri},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ai},attenuationDistance:{value:0},attenuationColor:{value:new ts(0)},specularColor:{value:new ts(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ai},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ai},anisotropyVector:{value:new ri},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ai}}]),vertexShader:ur.meshphysical_vert,fragmentShader:ur.meshphysical_frag};const mr={r:0,b:0,g:0};function fr(t,e,i,n,s,r,a){const o=new ts(0);let l,h,c=!0===r?0:1,u=null,d=0,p=null;function m(e,i){e.getRGB(mr,Xs(t)),n.buffers.color.setClear(mr.r,mr.g,mr.b,i,a)}return{getClearColor:()=>o,setClearColor(t,e=1){o.set(t),c=e,m(o,c)},getClearAlpha:()=>c,setClearAlpha(t){c=t,m(o,c)},render(r,f){let g=!1,_=!0===f.isScene?f.background:null;_&&_.isTexture&&(_=(f.backgroundBlurriness>0?i:e).get(_)),null===_?m(o,c):_&&_.isColor&&(m(_,1),g=!0);const v=t.xr.getEnvironmentBlendMode();"additive"===v?n.buffers.color.setClear(0,0,0,1,a):"alpha-blend"===v&&n.buffers.color.setClear(0,0,0,0,a),(t.autoClear||g)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),_&&(_.isCubeTexture||_.mapping===ut)?(void 0===h&&(h=new Vs(new Hs(1,1,1),new Ys({name:"BackgroundCubeMaterial",uniforms:Ws(pr.backgroundCube.uniforms),vertexShader:pr.backgroundCube.vertexShader,fragmentShader:pr.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(t,e,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(h.material,"envMap",{get(){return this.uniforms.envMap.value}}),s.update(h)),h.material.uniforms.envMap.value=_,h.material.uniforms.flipEnvMap.value=_.isCubeTexture&&!1===_.isRenderTargetTexture?-1:1,h.material.uniforms.backgroundBlurriness.value=f.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=f.backgroundIntensity,h.material.toneMapped=yi.getTransfer(_.colorSpace)!==Ce,u===_&&d===_.version&&p===t.toneMapping||(h.material.needsUpdate=!0,u=_,d=_.version,p=t.toneMapping),h.layers.enableAll(),r.unshift(h,h.geometry,h.material,0,0,null)):_&&_.isTexture&&(void 0===l&&(l=new Vs(new cr(2,2),new Ys({name:"BackgroundMaterial",uniforms:Ws(pr.background.uniforms),vertexShader:pr.background.vertexShader,fragmentShader:pr.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get(){return this.uniforms.t2D.value}}),s.update(l)),l.material.uniforms.t2D.value=_,l.material.uniforms.backgroundIntensity.value=f.backgroundIntensity,l.material.toneMapped=yi.getTransfer(_.colorSpace)!==Ce,!0===_.matrixAutoUpdate&&_.updateMatrix(),l.material.uniforms.uvTransform.value.copy(_.matrix),u===_&&d===_.version&&p===t.toneMapping||(l.material.needsUpdate=!0,u=_,d=_.version,p=t.toneMapping),l.layers.enableAll(),r.unshift(l,l.geometry,l.material,0,0,null))}}}function gr(t,e,i,n){const s=t.getParameter(t.MAX_VERTEX_ATTRIBS),r=n.isWebGL2?null:e.get("OES_vertex_array_object"),a=n.isWebGL2||null!==r,o={},l=p(null);let h=l,c=!1;function u(e){return n.isWebGL2?t.bindVertexArray(e):r.bindVertexArrayOES(e)}function d(e){return n.isWebGL2?t.deleteVertexArray(e):r.deleteVertexArrayOES(e)}function p(t){const e=[],i=[],n=[];for(let r=0;r<s;r++)e[r]=0,i[r]=0,n[r]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:e,enabledAttributes:i,attributeDivisors:n,object:t,attributes:{},index:null}}function m(){const t=h.newAttributes;for(let e=0,i=t.length;e<i;e++)t[e]=0}function f(t){g(t,0)}function g(i,s){const r=h.newAttributes,a=h.enabledAttributes,o=h.attributeDivisors;r[i]=1,0===a[i]&&(t.enableVertexAttribArray(i),a[i]=1),o[i]!==s&&((n.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](i,s),o[i]=s)}function _(){const e=h.newAttributes,i=h.enabledAttributes;for(let n=0,s=i.length;n<s;n++)i[n]!==e[n]&&(t.disableVertexAttribArray(n),i[n]=0)}function v(e,i,n,s,r,a,o){!0===o?t.vertexAttribIPointer(e,i,n,r,a):t.vertexAttribPointer(e,i,n,s,r,a)}function y(){x(),c=!0,h!==l&&(h=l,u(h.object))}function x(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup(s,l,d,y,x){let M=!1;if(a){const e=function(e,i,s){const a=!0===s.wireframe;let l=o[e.id];void 0===l&&(l={},o[e.id]=l);let h=l[i.id];void 0===h&&(h={},l[i.id]=h);let c=h[a];return void 0===c&&(c=p(n.isWebGL2?t.createVertexArray():r.createVertexArrayOES()),h[a]=c),c}(y,d,l);h!==e&&(h=e,u(h.object)),M=function(t,e,i,n){const s=h.attributes,r=e.attributes;let a=0;const o=i.getAttributes();for(const l in o)if(o[l].location>=0){const e=s[l];let i=r[l];if(void 0===i&&("instanceMatrix"===l&&t.instanceMatrix&&(i=t.instanceMatrix),"instanceColor"===l&&t.instanceColor&&(i=t.instanceColor)),void 0===e)return!0;if(e.attribute!==i)return!0;if(i&&e.data!==i.data)return!0;a++}return h.attributesNum!==a||h.index!==n}(s,y,d,x),M&&function(t,e,i,n){const s={},r=e.attributes;let a=0;const o=i.getAttributes();for(const l in o)if(o[l].location>=0){let e=r[l];void 0===e&&("instanceMatrix"===l&&t.instanceMatrix&&(e=t.instanceMatrix),"instanceColor"===l&&t.instanceColor&&(e=t.instanceColor));const i={};i.attribute=e,e&&e.data&&(i.data=e.data),s[l]=i,a++}h.attributes=s,h.attributesNum=a,h.index=n}(s,y,d,x)}else{const t=!0===l.wireframe;h.geometry===y.id&&h.program===d.id&&h.wireframe===t||(h.geometry=y.id,h.program=d.id,h.wireframe=t,M=!0)}null!==x&&i.update(x,t.ELEMENT_ARRAY_BUFFER),(M||c)&&(c=!1,function(s,r,a,o){if(!1===n.isWebGL2&&(s.isInstancedMesh||o.isInstancedBufferGeometry)&&null===e.get("ANGLE_instanced_arrays"))return;m();const l=o.attributes,h=a.getAttributes(),c=r.defaultAttributeValues;for(const e in h){const r=h[e];if(r.location>=0){let a=l[e];if(void 0===a&&("instanceMatrix"===e&&s.instanceMatrix&&(a=s.instanceMatrix),"instanceColor"===e&&s.instanceColor&&(a=s.instanceColor)),void 0!==a){const e=a.normalized,l=a.itemSize,h=i.get(a);if(void 0===h)continue;const c=h.buffer,u=h.type,d=h.bytesPerElement,p=!0===n.isWebGL2&&(u===t.INT||u===t.UNSIGNED_INT||a.gpuType===St);if(a.isInterleavedBufferAttribute){const i=a.data,n=i.stride,h=a.offset;if(i.isInstancedInterleavedBuffer){for(let t=0;t<r.locationSize;t++)g(r.location+t,i.meshPerAttribute);!0!==s.isInstancedMesh&&void 0===o._maxInstanceCount&&(o._maxInstanceCount=i.meshPerAttribute*i.count)}else for(let t=0;t<r.locationSize;t++)f(r.location+t);t.bindBuffer(t.ARRAY_BUFFER,c);for(let t=0;t<r.locationSize;t++)v(r.location+t,l/r.locationSize,u,e,n*d,(h+l/r.locationSize*t)*d,p)}else{if(a.isInstancedBufferAttribute){for(let t=0;t<r.locationSize;t++)g(r.location+t,a.meshPerAttribute);!0!==s.isInstancedMesh&&void 0===o._maxInstanceCount&&(o._maxInstanceCount=a.meshPerAttribute*a.count)}else for(let t=0;t<r.locationSize;t++)f(r.location+t);t.bindBuffer(t.ARRAY_BUFFER,c);for(let t=0;t<r.locationSize;t++)v(r.location+t,l/r.locationSize,u,e,l*d,l/r.locationSize*t*d,p)}}else if(void 0!==c){const i=c[e];if(void 0!==i)switch(i.length){case 2:t.vertexAttrib2fv(r.location,i);break;case 3:t.vertexAttrib3fv(r.location,i);break;case 4:t.vertexAttrib4fv(r.location,i);break;default:t.vertexAttrib1fv(r.location,i)}}}}_()}(s,l,d,y),null!==x&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,i.get(x).buffer))},reset:y,resetDefaultState:x,dispose(){y();for(const t in o){const e=o[t];for(const t in e){const i=e[t];for(const t in i)d(i[t].object),delete i[t];delete e[t]}delete o[t]}},releaseStatesOfGeometry(t){if(void 0===o[t.id])return;const e=o[t.id];for(const i in e){const t=e[i];for(const e in t)d(t[e].object),delete t[e];delete e[i]}delete o[t.id]},releaseStatesOfProgram(t){for(const e in o){const i=o[e];if(void 0===i[t.id])continue;const n=i[t.id];for(const t in n)d(n[t].object),delete n[t];delete i[t.id]}},initAttributes:m,enableAttribute:f,disableUnusedAttributes:_}}function _r(t,e,i,n){const s=n.isWebGL2;let r;this.setMode=function(t){r=t},this.render=function(e,n){t.drawArrays(r,e,n),i.update(n,r,1)},this.renderInstances=function(n,a,o){if(0===o)return;let l,h;if(s)l=t,h="drawArraysInstanced";else if(l=e.get("ANGLE_instanced_arrays"),h="drawArraysInstancedANGLE",null===l)return;l[h](r,n,a,o),i.update(a,r,o)},this.renderMultiDraw=function(t,n,s){if(0===s)return;const a=e.get("WEBGL_multi_draw");if(null===a)for(let e=0;e<s;e++)this.render(t[e],n[e]);else{a.multiDrawArraysWEBGL(r,t,0,n,0,s);let e=0;for(let t=0;t<s;t++)e+=n[t];i.update(e,r,1)}}}function vr(t,e,i){let n;function s(e){if("highp"===e){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const r="undefined"!=typeof WebGL2RenderingContext&&"WebGL2RenderingContext"===t.constructor.name;let a=void 0!==i.precision?i.precision:"highp";const o=s(a);o!==a&&(a=o);const l=r||e.has("WEBGL_draw_buffers"),h=!0===i.logarithmicDepthBuffer,c=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),u=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),d=t.getParameter(t.MAX_TEXTURE_SIZE),p=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),m=t.getParameter(t.MAX_VERTEX_ATTRIBS),f=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),g=t.getParameter(t.MAX_VARYING_VECTORS),_=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),v=u>0,y=r||e.has("OES_texture_float"),x=v&&y,M=r?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:r,drawBuffers:l,getMaxAnisotropy(){if(void 0!==n)return n;if(!0===e.has("EXT_texture_filter_anisotropic")){const i=e.get("EXT_texture_filter_anisotropic");n=t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n},getMaxPrecision:s,precision:a,logarithmicDepthBuffer:h,maxTextures:c,maxVertexTextures:u,maxTextureSize:d,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:f,maxVaryings:g,maxFragmentUniforms:_,vertexTextures:v,floatFragmentTextures:y,floatVertexTextures:x,maxSamples:M}}function yr(t){const e=this;let i=null,n=0,s=!1,r=!1;const a=new sr,o=new ai,l={value:null,needsUpdate:!1};function h(t,i,n,s){const r=null!==t?t.length:0;let h=null;if(0!==r){if(h=l.value,!0!==s||null===h){const e=n+4*r,s=i.matrixWorldInverse;o.getNormalMatrix(s),(null===h||h.length<e)&&(h=new Float32Array(e));for(let i=0,l=n;i!==r;++i,l+=4)a.copy(t[i]).applyMatrix4(s,o),a.normal.toArray(h,l),h[l+3]=a.constant}l.value=h,l.needsUpdate=!0}return e.numPlanes=r,e.numIntersection=0,h}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(t,e){const i=0!==t.length||e||0!==n||s;return s=e,n=t.length,i},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(t,e){i=h(t,e,0)},this.setState=function(a,o,c){const u=a.clippingPlanes,d=a.clipIntersection,p=a.clipShadows,m=t.get(a);if(!s||null===u||0===u.length||r&&!p)r?h(null):(l.value!==i&&(l.value=i,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0);else{const t=r?0:n,e=4*t;let s=m.clippingState||null;l.value=s,s=h(u,o,e,c);for(let n=0;n!==e;++n)s[n]=i[n];m.clippingState=s,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=t}}}function xr(t){let e=new WeakMap;function i(t,e){return e===ht?t.mapping=ot:e===ct&&(t.mapping=lt),t}function n(t){const i=t.target;i.removeEventListener("dispose",n);const s=e.get(i);void 0!==s&&(e.delete(i),s.dispose())}return{get(s){if(s&&s.isTexture){const r=s.mapping;if(r===ht||r===ct){if(e.has(s))return i(e.get(s).texture,s.mapping);{const r=s.image;if(r&&r.height>0){const a=new tr(r.height/2);return a.fromEquirectangularTexture(t,s),e.set(s,a),s.addEventListener("dispose",n),i(a.texture,s.mapping)}return null}}}return s},dispose(){e=new WeakMap}}}class Mr extends Zs{constructor(t=-1,e=1,i=1,n=-1,s=.1,r=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=i,this.bottom=n,this.near=s,this.far=r,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=null===t.view?null:Object.assign({},t.view),this}setViewOffset(t,e,i,n,s,r){null===this.view&&(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=i,this.view.offsetY=n,this.view.width=s,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let s=i-t,r=i+t,a=n+e,o=n-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=t*this.view.offsetX,r=s+t*this.view.width,a-=e*this.view.offsetY,o=a-e*this.view.height}this.projectionMatrix.makeOrthographic(s,r,a,o,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,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}const br=[.125,.215,.35,.446,.526,.582],Sr=new Mr,wr=new ts;let Tr=null,Er=0,Ar=0;const Cr=(1+Math.sqrt(5))/2,Rr=1/Cr,Pr=[new Ni(1,1,1),new Ni(-1,1,1),new Ni(1,1,-1),new Ni(-1,1,-1),new Ni(0,Cr,Rr),new Ni(0,Cr,-Rr),new Ni(Rr,0,Cr),new Ni(-Rr,0,Cr),new Ni(Cr,Rr,0),new Ni(-Cr,Rr,0)];class Lr{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,i=.1,n=100){Tr=this._renderer.getRenderTarget(),Er=this._renderer.getActiveCubeFace(),Ar=this._renderer.getActiveMipmapLevel(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(t,i,n,s),e>0&&this._blur(s,0,0,e),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Nr(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Ur(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(Tr,Er,Ar),t.scissorTest=!1,Dr(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===ot||t.mapping===lt?this._setSize(0===t.image.length?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Tr=this._renderer.getRenderTarget(),Er=this._renderer.getActiveCubeFace(),Ar=this._renderer.getActiveMipmapLevel();const i=e||this._allocateTargets();return this._textureToCubeUV(t,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,i={magFilter:vt,minFilter:vt,generateMipmaps:!1,type:Et,format:Pt,colorSpace:we,depthBuffer:!1},n=Ir(t,e,i);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=Ir(t,e,i);const{_lodMax:n}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=function(t){const e=[],i=[],n=[];let s=t;const r=t-4+1+br.length;for(let a=0;a<r;a++){const r=Math.pow(2,s);i.push(r);let o=1/r;a>t-4?o=br[a-t+4-1]:0===a&&(o=0),n.push(o);const l=1/(r-2),h=-l,c=1+l,u=[h,h,c,h,c,c,h,h,c,c,h,c],d=6,p=6,m=3,f=2,g=1,_=new Float32Array(m*p*d),v=new Float32Array(f*p*d),y=new Float32Array(g*p*d);for(let t=0;t<d;t++){const e=t%3*2/3-1,i=t>2?0:-1,n=[e,i,0,e+2/3,i,0,e+2/3,i+1,0,e,i,0,e+2/3,i+1,0,e,i+1,0];_.set(n,m*p*t),v.set(u,f*p*t);const s=[t,t,t,t,t,t];y.set(s,g*p*t)}const x=new Ss;x.setAttribute("position",new ds(_,m)),x.setAttribute("uv",new ds(v,f)),x.setAttribute("faceIndex",new ds(y,g)),e.push(x),s>4&&s--}return{lodPlanes:e,sizeLods:i,sigmas:n}}(n)),this._blurMaterial=function(t,e,i){const n=new Float32Array(20),s=new Ni(0,1,0);return new Ys({name:"SphericalGaussianBlur",defines:{n:20,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}(n,t,e)}return n}_compileMaterial(t){const e=new Vs(this._lodPlanes[0],t);this._renderer.compile(e,Sr)}_sceneToCubeUV(t,e,i,n){const s=new Js(90,1,e,i),r=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear,h=o.toneMapping;o.getClearColor(wr),o.toneMapping=0,o.autoClear=!1;const c=new ss({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),u=new Vs(new Hs,c);let d=!1;const p=t.background;p?p.isColor&&(c.color.copy(p),t.background=null,d=!0):(c.color.copy(wr),d=!0);for(let m=0;m<6;m++){const e=m%3;0===e?(s.up.set(0,r[m],0),s.lookAt(a[m],0,0)):1===e?(s.up.set(0,0,r[m]),s.lookAt(0,a[m],0)):(s.up.set(0,r[m],0),s.lookAt(0,0,a[m]));const i=this._cubeSize;Dr(n,e*i,m>2?i:0,i,i),o.setRenderTarget(n),d&&o.render(u,s),o.render(t,s)}u.geometry.dispose(),u.material.dispose(),o.toneMapping=h,o.autoClear=l,t.background=p}_textureToCubeUV(t,e){const i=this._renderer,n=t.mapping===ot||t.mapping===lt;n?(null===this._cubemapMaterial&&(this._cubemapMaterial=Nr()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===t.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=Ur());const s=n?this._cubemapMaterial:this._equirectMaterial,r=new Vs(this._lodPlanes[0],s);s.uniforms.envMap.value=t;const a=this._cubeSize;Dr(e,0,0,3*a,2*a),i.setRenderTarget(e),i.render(r,Sr)}_applyPMREM(t){const e=this._renderer,i=e.autoClear;e.autoClear=!1;for(let n=1;n<this._lodPlanes.length;n++){const e=Math.sqrt(this._sigmas[n]*this._sigmas[n]-this._sigmas[n-1]*this._sigmas[n-1]),i=Pr[(n-1)%Pr.length];this._blur(t,n-1,n,e,i)}e.autoClear=i}_blur(t,e,i,n,s){const r=this._pingPongRenderTarget;this._halfBlur(t,r,e,i,n,"latitudinal",s),this._halfBlur(r,t,i,i,n,"longitudinal",s)}_halfBlur(t,e,i,n,s,r,a){const o=this._renderer,l=this._blurMaterial,h=new Vs(this._lodPlanes[n],l),c=l.uniforms,u=this._sizeLods[i]-1,d=isFinite(s)?Math.PI/(2*u):2*Math.PI/39,p=s/d,m=isFinite(s)?1+Math.floor(3*p):20,f=[];let g=0;for(let y=0;y<20;++y){const t=y/p,e=Math.exp(-t*t/2);f.push(e),0===y?g+=e:y<m&&(g+=2*e)}for(let y=0;y<f.length;y++)f[y]=f[y]/g;c.envMap.value=t.texture,c.samples.value=m,c.weights.value=f,c.latitudinal.value="latitudinal"===r,a&&(c.poleAxis.value=a);const{_lodMax:_}=this;c.dTheta.value=d,c.mipInt.value=_-i;const v=this._sizeLods[n];Dr(e,3*v*(n>_-4?n-_+4:0),4*(this._cubeSize-v),3*v,2*v),o.setRenderTarget(e),o.render(h,Sr)}}function Ir(t,e,i){const n=new Li(t,e,i);return n.texture.mapping=ut,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Dr(t,e,i,n,s){t.viewport.set(e,i,n,s),t.scissor.set(e,i,n,s)}function Ur(){return new Ys({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Nr(){return new Ys({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Or(t){let e=new WeakMap,i=null;function n(t){const i=t.target;i.removeEventListener("dispose",n);const s=e.get(i);void 0!==s&&(e.delete(i),s.dispose())}return{get(s){if(s&&s.isTexture){const r=s.mapping,a=r===ht||r===ct,o=r===ot||r===lt;if(a||o){if(s.isRenderTargetTexture&&!0===s.needsPMREMUpdate){s.needsPMREMUpdate=!1;let n=e.get(s);return null===i&&(i=new Lr(t)),n=a?i.fromEquirectangular(s,n):i.fromCubemap(s,n),e.set(s,n),n.texture}if(e.has(s))return e.get(s).texture;{const r=s.image;if(a&&r&&r.height>0||o&&r&&function(t){let e=0;for(let i=0;i<6;i++)void 0!==t[i]&&e++;return 6===e}(r)){null===i&&(i=new Lr(t));const r=a?i.fromEquirectangular(s):i.fromCubemap(s);return e.set(s,r),s.addEventListener("dispose",n),r.texture}return null}}}return s},dispose(){e=new WeakMap,null!==i&&(i.dispose(),i=null)}}}function Fr(t){const e={};function i(i){if(void 0!==e[i])return e[i];let n;switch(i){case"WEBGL_depth_texture":n=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:n=t.getExtension(i)}return e[i]=n,n}return{has:t=>null!==i(t),init(t){t.isWebGL2?(i("EXT_color_buffer_float"),i("WEBGL_clip_cull_distance")):(i("WEBGL_depth_texture"),i("OES_texture_float"),i("OES_texture_half_float"),i("OES_texture_half_float_linear"),i("OES_standard_derivatives"),i("OES_element_index_uint"),i("OES_vertex_array_object"),i("ANGLE_instanced_arrays")),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float"),i("WEBGL_multisampled_render_to_texture")},get(t){return i(t)}}}function Br(t,e,i,n){const s={},r=new WeakMap;function a(t){const o=t.target;null!==o.index&&e.remove(o.index);for(const i in o.attributes)e.remove(o.attributes[i]);for(const i in o.morphAttributes){const t=o.morphAttributes[i];for(let i=0,n=t.length;i<n;i++)e.remove(t[i])}o.removeEventListener("dispose",a),delete s[o.id];const l=r.get(o);l&&(e.remove(l),r.delete(o)),n.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,i.memory.geometries--}function o(t){const i=[],n=t.index,s=t.attributes.position;let a=0;if(null!==n){const t=n.array;a=n.version;for(let e=0,n=t.length;e<n;e+=3){const n=t[e+0],s=t[e+1],r=t[e+2];i.push(n,s,s,r,r,n)}}else{if(void 0===s)return;{const t=s.array;a=s.version;for(let e=0,n=t.length/3-1;e<n;e+=3){const t=e+0,n=e+1,s=e+2;i.push(t,n,n,s,s,t)}}}const o=new(li(i)?ms:ps)(i,1);o.version=a;const l=r.get(t);l&&e.remove(l),r.set(t,o)}return{get:(t,e)=>(!0===s[e.id]||(e.addEventListener("dispose",a),s[e.id]=!0,i.memory.geometries++),e),update(i){const n=i.attributes;for(const r in n)e.update(n[r],t.ARRAY_BUFFER);const s=i.morphAttributes;for(const r in s){const i=s[r];for(let n=0,s=i.length;n<s;n++)e.update(i[n],t.ARRAY_BUFFER)}},getWireframeAttribute(t){const e=r.get(t);if(e){const i=t.index;null!==i&&e.version<i.version&&o(t)}else o(t);return r.get(t)}}}function zr(t,e,i,n){const s=n.isWebGL2;let r,a,o;this.setMode=function(t){r=t},this.setIndex=function(t){a=t.type,o=t.bytesPerElement},this.render=function(e,n){t.drawElements(r,n,a,e*o),i.update(n,r,1)},this.renderInstances=function(n,l,h){if(0===h)return;let c,u;if(s)c=t,u="drawElementsInstanced";else if(c=e.get("ANGLE_instanced_arrays"),u="drawElementsInstancedANGLE",null===c)return;c[u](r,l,a,n*o,h),i.update(l,r,h)},this.renderMultiDraw=function(t,n,s){if(0===s)return;const l=e.get("WEBGL_multi_draw");if(null===l)for(let e=0;e<s;e++)this.render(t[e]/o,n[e]);else{l.multiDrawElementsWEBGL(r,n,0,a,t,0,s);let e=0;for(let t=0;t<s;t++)e+=n[t];i.update(e,r,1)}}}function kr(t){const e={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:e,programs:null,autoReset:!0,reset(){e.calls=0,e.triangles=0,e.points=0,e.lines=0},update(i,n,s){switch(e.calls++,n){case t.TRIANGLES:e.triangles+=s*(i/3);break;case t.LINES:e.lines+=s*(i/2);break;case t.LINE_STRIP:e.lines+=s*(i-1);break;case t.LINE_LOOP:e.lines+=s*i;break;case t.POINTS:e.points+=s*i}}}}function Vr(t,e){return t[0]-e[0]}function Gr(t,e){return Math.abs(e[1])-Math.abs(t[1])}function Hr(t,e,i){const n={},s=new Float32Array(8),r=new WeakMap,a=new Ri,o=[];for(let l=0;l<8;l++)o[l]=[l,0];return{update(l,h,c){const u=l.morphTargetInfluences;if(!0===e.isWebGL2){const n=h.morphAttributes.position||h.morphAttributes.normal||h.morphAttributes.color,s=void 0!==n?n.length:0;let o=r.get(h);if(void 0===o||o.count!==s){let t=function(){_.dispose(),r.delete(h),h.removeEventListener("dispose",t)};void 0!==o&&o.texture.dispose();const i=void 0!==h.morphAttributes.position,n=void 0!==h.morphAttributes.normal,l=void 0!==h.morphAttributes.color,c=h.morphAttributes.position||[],u=h.morphAttributes.normal||[],d=h.morphAttributes.color||[];let p=0;!0===i&&(p=1),!0===n&&(p=2),!0===l&&(p=3);let m=h.attributes.position.count*p,f=1;m>e.maxTextureSize&&(f=Math.ceil(m/e.maxTextureSize),m=e.maxTextureSize);const g=new Float32Array(m*f*4*s),_=new Ii(g,m,f,s);_.type=Tt,_.needsUpdate=!0;const v=4*p;for(let e=0;e<s;e++){const t=c[e],s=u[e],r=d[e],o=m*f*4*e;for(let e=0;e<t.count;e++){const h=e*v;!0===i&&(a.fromBufferAttribute(t,e),g[o+h+0]=a.x,g[o+h+1]=a.y,g[o+h+2]=a.z,g[o+h+3]=0),!0===n&&(a.fromBufferAttribute(s,e),g[o+h+4]=a.x,g[o+h+5]=a.y,g[o+h+6]=a.z,g[o+h+7]=0),!0===l&&(a.fromBufferAttribute(r,e),g[o+h+8]=a.x,g[o+h+9]=a.y,g[o+h+10]=a.z,g[o+h+11]=4===r.itemSize?a.w:1)}}o={count:s,texture:_,size:new ri(m,f)},r.set(h,o),h.addEventListener("dispose",t)}let l=0;for(let t=0;t<u.length;t++)l+=u[t];const d=h.morphTargetsRelative?1:1-l;c.getUniforms().setValue(t,"morphTargetBaseInfluence",d),c.getUniforms().setValue(t,"morphTargetInfluences",u),c.getUniforms().setValue(t,"morphTargetsTexture",o.texture,i),c.getUniforms().setValue(t,"morphTargetsTextureSize",o.size)}else{const e=void 0===u?0:u.length;let i=n[h.id];if(void 0===i||i.length!==e){i=[];for(let t=0;t<e;t++)i[t]=[t,0];n[h.id]=i}for(let t=0;t<e;t++){const e=i[t];e[0]=t,e[1]=u[t]}i.sort(Gr);for(let t=0;t<8;t++)t<e&&i[t][1]?(o[t][0]=i[t][0],o[t][1]=i[t][1]):(o[t][0]=Number.MAX_SAFE_INTEGER,o[t][1]=0);o.sort(Vr);const r=h.morphAttributes.position,a=h.morphAttributes.normal;let l=0;for(let t=0;t<8;t++){const e=o[t],i=e[0],n=e[1];i!==Number.MAX_SAFE_INTEGER&&n?(r&&h.getAttribute("morphTarget"+t)!==r[i]&&h.setAttribute("morphTarget"+t,r[i]),a&&h.getAttribute("morphNormal"+t)!==a[i]&&h.setAttribute("morphNormal"+t,a[i]),s[t]=n,l+=n):(r&&!0===h.hasAttribute("morphTarget"+t)&&h.deleteAttribute("morphTarget"+t),a&&!0===h.hasAttribute("morphNormal"+t)&&h.deleteAttribute("morphNormal"+t),s[t]=0)}const d=h.morphTargetsRelative?1:1-l;c.getUniforms().setValue(t,"morphTargetBaseInfluence",d),c.getUniforms().setValue(t,"morphTargetInfluences",s)}}}}function Wr(t,e,i,n){let s=new WeakMap;function r(t){const e=t.target;e.removeEventListener("dispose",r),i.remove(e.instanceMatrix),null!==e.instanceColor&&i.remove(e.instanceColor)}return{update(a){const o=n.render.frame,l=a.geometry,h=e.get(a,l);if(s.get(h)!==o&&(e.update(h),s.set(h,o)),a.isInstancedMesh&&(!1===a.hasEventListener("dispose",r)&&a.addEventListener("dispose",r),s.get(a)!==o&&(i.update(a.instanceMatrix,t.ARRAY_BUFFER),null!==a.instanceColor&&i.update(a.instanceColor,t.ARRAY_BUFFER),s.set(a,o))),a.isSkinnedMesh){const t=a.skeleton;s.get(t)!==o&&(t.update(),s.set(t,o))}return h},dispose(){s=new WeakMap}}}class qr extends Ci{constructor(t,e,i,n,s,r,a,o,l,h){if((h=void 0!==h?h:Lt)!==Lt&&h!==It)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===i&&h===Lt&&(i=wt),void 0===i&&h===It&&(i=Rt),super(null,n,s,r,a,o,h,i,l),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=void 0!==a?a:ft,this.minFilter=void 0!==o?o:ft,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 null!==this.compareFunction&&(e.compareFunction=this.compareFunction),e}}const Xr=new Ci,jr=new qr(1,1);jr.compareFunction=515;const Yr=new Ii,Zr=new Di,Jr=new Qs,Kr=[],$r=[],Qr=new Float32Array(16),ta=new Float32Array(9),ea=new Float32Array(4);function ia(t,e,i){const n=t[0];if(n<=0||n>0)return t;const s=e*i;let r=Kr[s];if(void 0===r&&(r=new Float32Array(s),Kr[s]=r),0!==e){n.toArray(r,0);for(let n=1,s=0;n!==e;++n)s+=i,t[n].toArray(r,s)}return r}function na(t,e){if(t.length!==e.length)return!1;for(let i=0,n=t.length;i<n;i++)if(t[i]!==e[i])return!1;return!0}function sa(t,e){for(let i=0,n=e.length;i<n;i++)t[i]=e[i]}function ra(t,e){let i=$r[e];void 0===i&&(i=new Int32Array(e),$r[e]=i);for(let n=0;n!==e;++n)i[n]=t.allocateTextureUnit();return i}function aa(t,e){const i=this.cache;i[0]!==e&&(t.uniform1f(this.addr,e),i[0]=e)}function oa(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2f(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(na(i,e))return;t.uniform2fv(this.addr,e),sa(i,e)}}function la(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3f(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else if(void 0!==e.r)i[0]===e.r&&i[1]===e.g&&i[2]===e.b||(t.uniform3f(this.addr,e.r,e.g,e.b),i[0]=e.r,i[1]=e.g,i[2]=e.b);else{if(na(i,e))return;t.uniform3fv(this.addr,e),sa(i,e)}}function ha(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(na(i,e))return;t.uniform4fv(this.addr,e),sa(i,e)}}function ca(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(na(i,e))return;t.uniformMatrix2fv(this.addr,!1,e),sa(i,e)}else{if(na(i,n))return;ea.set(n),t.uniformMatrix2fv(this.addr,!1,ea),sa(i,n)}}function ua(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(na(i,e))return;t.uniformMatrix3fv(this.addr,!1,e),sa(i,e)}else{if(na(i,n))return;ta.set(n),t.uniformMatrix3fv(this.addr,!1,ta),sa(i,n)}}function da(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(na(i,e))return;t.uniformMatrix4fv(this.addr,!1,e),sa(i,e)}else{if(na(i,n))return;Qr.set(n),t.uniformMatrix4fv(this.addr,!1,Qr),sa(i,n)}}function pa(t,e){const i=this.cache;i[0]!==e&&(t.uniform1i(this.addr,e),i[0]=e)}function ma(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2i(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(na(i,e))return;t.uniform2iv(this.addr,e),sa(i,e)}}function fa(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3i(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else{if(na(i,e))return;t.uniform3iv(this.addr,e),sa(i,e)}}function ga(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(na(i,e))return;t.uniform4iv(this.addr,e),sa(i,e)}}function _a(t,e){const i=this.cache;i[0]!==e&&(t.uniform1ui(this.addr,e),i[0]=e)}function va(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2ui(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(na(i,e))return;t.uniform2uiv(this.addr,e),sa(i,e)}}function ya(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3ui(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else{if(na(i,e))return;t.uniform3uiv(this.addr,e),sa(i,e)}}function xa(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(na(i,e))return;t.uniform4uiv(this.addr,e),sa(i,e)}}function Ma(t,e,i){const n=this.cache,s=i.allocateTextureUnit();n[0]!==s&&(t.uniform1i(this.addr,s),n[0]=s);const r=this.type===t.SAMPLER_2D_SHADOW?jr:Xr;i.setTexture2D(e||r,s)}function ba(t,e,i){const n=this.cache,s=i.allocateTextureUnit();n[0]!==s&&(t.uniform1i(this.addr,s),n[0]=s),i.setTexture3D(e||Zr,s)}function Sa(t,e,i){const n=this.cache,s=i.allocateTextureUnit();n[0]!==s&&(t.uniform1i(this.addr,s),n[0]=s),i.setTextureCube(e||Jr,s)}function wa(t,e,i){const n=this.cache,s=i.allocateTextureUnit();n[0]!==s&&(t.uniform1i(this.addr,s),n[0]=s),i.setTexture2DArray(e||Yr,s)}function Ta(t,e){t.uniform1fv(this.addr,e)}function Ea(t,e){const i=ia(e,this.size,2);t.uniform2fv(this.addr,i)}function Aa(t,e){const i=ia(e,this.size,3);t.uniform3fv(this.addr,i)}function Ca(t,e){const i=ia(e,this.size,4);t.uniform4fv(this.addr,i)}function Ra(t,e){const i=ia(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,i)}function Pa(t,e){const i=ia(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,i)}function La(t,e){const i=ia(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,i)}function Ia(t,e){t.uniform1iv(this.addr,e)}function Da(t,e){t.uniform2iv(this.addr,e)}function Ua(t,e){t.uniform3iv(this.addr,e)}function Na(t,e){t.uniform4iv(this.addr,e)}function Oa(t,e){t.uniform1uiv(this.addr,e)}function Fa(t,e){t.uniform2uiv(this.addr,e)}function Ba(t,e){t.uniform3uiv(this.addr,e)}function za(t,e){t.uniform4uiv(this.addr,e)}function ka(t,e,i){const n=this.cache,s=e.length,r=ra(i,s);na(n,r)||(t.uniform1iv(this.addr,r),sa(n,r));for(let a=0;a!==s;++a)i.setTexture2D(e[a]||Xr,r[a])}function Va(t,e,i){const n=this.cache,s=e.length,r=ra(i,s);na(n,r)||(t.uniform1iv(this.addr,r),sa(n,r));for(let a=0;a!==s;++a)i.setTexture3D(e[a]||Zr,r[a])}function Ga(t,e,i){const n=this.cache,s=e.length,r=ra(i,s);na(n,r)||(t.uniform1iv(this.addr,r),sa(n,r));for(let a=0;a!==s;++a)i.setTextureCube(e[a]||Jr,r[a])}function Ha(t,e,i){const n=this.cache,s=e.length,r=ra(i,s);na(n,r)||(t.uniform1iv(this.addr,r),sa(n,r));for(let a=0;a!==s;++a)i.setTexture2DArray(e[a]||Yr,r[a])}class Wa{constructor(t,e,i){this.id=t,this.addr=i,this.cache=[],this.type=e.type,this.setValue=function(t){switch(t){case 5126:return aa;case 35664:return oa;case 35665:return la;case 35666:return ha;case 35674:return ca;case 35675:return ua;case 35676:return da;case 5124:case 35670:return pa;case 35667:case 35671:return ma;case 35668:case 35672:return fa;case 35669:case 35673:return ga;case 5125:return _a;case 36294:return va;case 36295:return ya;case 36296:return xa;case 35678:case 36198:case 36298:case 36306:case 35682:return Ma;case 35679:case 36299:case 36307:return ba;case 35680:case 36300:case 36308:case 36293:return Sa;case 36289:case 36303:case 36311:case 36292:return wa}}(e.type)}}class qa{constructor(t,e,i){this.id=t,this.addr=i,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=function(t){switch(t){case 5126:return Ta;case 35664:return Ea;case 35665:return Aa;case 35666:return Ca;case 35674:return Ra;case 35675:return Pa;case 35676:return La;case 5124:case 35670:return Ia;case 35667:case 35671:return Da;case 35668:case 35672:return Ua;case 35669:case 35673:return Na;case 5125:return Oa;case 36294:return Fa;case 36295:return Ba;case 36296:return za;case 35678:case 36198:case 36298:case 36306:case 35682:return ka;case 35679:case 36299:case 36307:return Va;case 35680:case 36300:case 36308:case 36293:return Ga;case 36289:case 36303:case 36311:case 36292:return Ha}}(e.type)}}class Xa{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,i){const n=this.seq;for(let s=0,r=n.length;s!==r;++s){const r=n[s];r.setValue(t,e[r.id],i)}}}const ja=/(\w+)(\])?(\[|\.)?/g;function Ya(t,e){t.seq.push(e),t.map[e.id]=e}function Za(t,e,i){const n=t.name,s=n.length;for(ja.lastIndex=0;;){const r=ja.exec(n),a=ja.lastIndex;let o=r[1];const l="]"===r[2],h=r[3];if(l&&(o|=0),void 0===h||"["===h&&a+2===s){Ya(i,void 0===h?new Wa(o,t,e):new qa(o,t,e));break}{let t=i.map[o];void 0===t&&(t=new Xa(o),Ya(i,t)),i=t}}}class Ja{constructor(t,e){this.seq=[],this.map={};const i=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let n=0;n<i;++n){const i=t.getActiveUniform(e,n);Za(i,t.getUniformLocation(e,i.name),this)}}setValue(t,e,i,n){const s=this.map[e];void 0!==s&&s.setValue(t,i,n)}setOptional(t,e,i){const n=e[i];void 0!==n&&this.setValue(t,i,n)}static upload(t,e,i,n){for(let s=0,r=e.length;s!==r;++s){const r=e[s],a=i[r.id];!1!==a.needsUpdate&&r.setValue(t,a.value,n)}}static seqWithValue(t,e){const i=[];for(let n=0,s=t.length;n!==s;++n){const s=t[n];s.id in e&&i.push(s)}return i}}function Ka(t,e,i){const n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),n}let $a=0;function Qa(t,e,i){const n=t.getShaderParameter(e,t.COMPILE_STATUS),s=t.getShaderInfoLog(e).trim();if(n&&""===s)return"";const r=/ERROR: 0:(\d+)/.exec(s);if(r){const n=parseInt(r[1]);return i.toUpperCase()+"\n\n"+s+"\n\n"+function(t,e){const i=t.split("\n"),n=[],s=Math.max(e-6,0),r=Math.min(e+6,i.length);for(let a=s;a<r;a++){const t=a+1;n.push(`${t===e?">":" "} ${t}: ${i[a]}`)}return n.join("\n")}(t.getShaderSource(e),n)}return s}function to(t,e){const i=function(t){const e=yi.getPrimaries(yi.workingColorSpace),i=yi.getPrimaries(t);let n;switch(e===i?n="":e===Pe&&i===Re?n="LinearDisplayP3ToLinearSRGB":e===Re&&i===Pe&&(n="LinearSRGBToLinearDisplayP3"),t){case we:case Ee:return[n,"LinearTransferOETF"];case Se:case Te:return[n,"sRGBTransferOETF"];default:return[n,"LinearTransferOETF"]}}(e);return`vec4 ${t}( vec4 value ) { return ${i[0]}( ${i[1]}( value ) ); }`}function eo(t,e){let i;switch(e){case 1:default:i="Linear";break;case 2:i="Reinhard";break;case 3:i="OptimizedCineon";break;case 4:i="ACESFilmic";break;case 6:i="AgX";break;case 5:i="Custom"}return"vec3 "+t+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}function io(t){return""!==t}function no(t,e){const i=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,i).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function so(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const ro=/^[ \t]*#include +<([\w\d./]+)>/gm;function ao(t){return t.replace(ro,lo)}const oo=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function lo(t,e){let i=ur[e];if(void 0===i){const t=oo.get(e);if(void 0===t)throw new Error("Can not resolve #include <"+e+">");i=ur[t]}return ao(i)}const ho=/#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 co(t){return t.replace(ho,uo)}function uo(t,e,i,n){let s="";for(let r=parseInt(e);r<parseInt(i);r++)s+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function po(t){let e="precision "+t.precision+" float;\nprecision "+t.precision+" int;";return"highp"===t.precision?e+="\n#define HIGH_PRECISION":"mediump"===t.precision?e+="\n#define MEDIUM_PRECISION":"lowp"===t.precision&&(e+="\n#define LOW_PRECISION"),e}function mo(t,e,i,n){const s=t.getContext(),r=i.defines;let a=i.vertexShader,o=i.fragmentShader;const l=function(t){let e="SHADOWMAP_TYPE_BASIC";return 1===t.shadowMapType?e="SHADOWMAP_TYPE_PCF":2===t.shadowMapType?e="SHADOWMAP_TYPE_PCF_SOFT":3===t.shadowMapType&&(e="SHADOWMAP_TYPE_VSM"),e}(i),h=function(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case ot:case lt:e="ENVMAP_TYPE_CUBE";break;case ut:e="ENVMAP_TYPE_CUBE_UV"}return e}(i),c=function(t){let e="ENVMAP_MODE_REFLECTION";return t.envMap&&t.envMapMode===lt&&(e="ENVMAP_MODE_REFRACTION"),e}(i),u=function(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case 0:e="ENVMAP_BLENDING_MULTIPLY";break;case 1:e="ENVMAP_BLENDING_MIX";break;case 2:e="ENVMAP_BLENDING_ADD"}return e}(i),d=function(t){const e=t.envMapCubeUVHeight;if(null===e)return null;const i=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,i),112)),texelHeight:n,maxMip:i}}(i),p=i.isWebGL2?"":function(t){return[t.extensionDerivatives||t.envMapCubeUVHeight||t.bumpMap||t.normalMapTangentSpace||t.clearcoatNormalMap||t.flatShading||"physical"===t.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(t.extensionFragDepth||t.logarithmicDepthBuffer)&&t.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",t.extensionDrawBuffers&&t.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(t.extensionShaderTextureLOD||t.envMap||t.transmission)&&t.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(io).join("\n")}(i),m=function(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":""].filter(io).join("\n")}(i),f=function(t){const e=[];for(const i in t){const n=t[i];!1!==n&&e.push("#define "+i+" "+n)}return e.join("\n")}(r),g=s.createProgram();let _,v,y=i.glslVersion?"#version "+i.glslVersion+"\n":"";i.isRawShaderMaterial?(_=["#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,f].filter(io).join("\n"),_.length>0&&(_+="\n"),v=[p,"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,f].filter(io).join("\n"),v.length>0&&(v+="\n")):(_=[po(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,f,i.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",i.batching?"#define USE_BATCHING":"",i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+c:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.displacementMap?"#define USE_DISPLACEMENTMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.mapUv?"#define MAP_UV "+i.mapUv:"",i.alphaMapUv?"#define ALPHAMAP_UV "+i.alphaMapUv:"",i.lightMapUv?"#define LIGHTMAP_UV "+i.lightMapUv:"",i.aoMapUv?"#define AOMAP_UV "+i.aoMapUv:"",i.emissiveMapUv?"#define EMISSIVEMAP_UV "+i.emissiveMapUv:"",i.bumpMapUv?"#define BUMPMAP_UV "+i.bumpMapUv:"",i.normalMapUv?"#define NORMALMAP_UV "+i.normalMapUv:"",i.displacementMapUv?"#define DISPLACEMENTMAP_UV "+i.displacementMapUv:"",i.metalnessMapUv?"#define METALNESSMAP_UV "+i.metalnessMapUv:"",i.roughnessMapUv?"#define ROUGHNESSMAP_UV "+i.roughnessMapUv:"",i.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+i.anisotropyMapUv:"",i.clearcoatMapUv?"#define CLEARCOATMAP_UV "+i.clearcoatMapUv:"",i.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+i.clearcoatNormalMapUv:"",i.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+i.clearcoatRoughnessMapUv:"",i.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+i.iridescenceMapUv:"",i.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+i.iridescenceThicknessMapUv:"",i.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+i.sheenColorMapUv:"",i.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+i.sheenRoughnessMapUv:"",i.specularMapUv?"#define SPECULARMAP_UV "+i.specularMapUv:"",i.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+i.specularColorMapUv:"",i.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+i.specularIntensityMapUv:"",i.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+i.transmissionMapUv:"",i.thicknessMapUv?"#define THICKNESSMAP_UV "+i.thicknessMapUv:"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&!1===i.flatShading?"#define USE_MORPHNORMALS":"",i.morphColors&&i.isWebGL2?"#define USE_MORPHCOLORS":"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+i.morphTextureStride:"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_COUNT "+i.morphTargetsCount:"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+l:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.useLegacyLights?"#define LEGACY_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(io).join("\n"),v=[p,po(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,f,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+h:"",i.envMap?"#define "+c:"",i.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":"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoat?"#define USE_CLEARCOAT":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescence?"#define USE_IRIDESCENCE":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaTest?"#define USE_ALPHATEST":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.sheen?"#define USE_SHEEN":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+l:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.useLegacyLights?"#define LEGACY_LIGHTS":"",i.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==i.toneMapping?"#define TONE_MAPPING":"",0!==i.toneMapping?ur.tonemapping_pars_fragment:"",0!==i.toneMapping?eo("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",ur.colorspace_pars_fragment,to("linearToOutputTexel",i.outputColorSpace),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(io).join("\n")),a=ao(a),a=no(a,i),a=so(a,i),o=ao(o),o=no(o,i),o=so(o,i),a=co(a),o=co(o),i.isWebGL2&&!0!==i.isRawShaderMaterial&&(y="#version 300 es\n",_=[m,"precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+_,v=["precision mediump sampler2DArray;","#define varying in",i.glslVersion===Ve?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===Ve?"":"#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("\n")+"\n"+v);const x=y+_+a,M=y+v+o,b=Ka(s,s.VERTEX_SHADER,x),S=Ka(s,s.FRAGMENT_SHADER,M);function w(e){if(t.debug.checkShaderErrors){const i=s.getProgramInfoLog(g).trim(),n=s.getShaderInfoLog(b).trim(),r=s.getShaderInfoLog(S).trim();let a=!0,o=!0;!1===s.getProgramParameter(g,s.LINK_STATUS)?(a=!1,"function"==typeof t.debug.onShaderError?t.debug.onShaderError(s,g,b,S):(Qa(s,b,"vertex"),Qa(s,S,"fragment"))):""!==i||""!==n&&""!==r||(o=!1),o&&(e.diagnostics={runnable:a,programLog:i,vertexShader:{log:n,prefix:_},fragmentShader:{log:r,prefix:v}})}s.deleteShader(b),s.deleteShader(S),T=new Ja(s,g),E=function(t,e){const i={},n=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){const n=t.getActiveAttrib(e,s),r=n.name;let a=1;n.type===t.FLOAT_MAT2&&(a=2),n.type===t.FLOAT_MAT3&&(a=3),n.type===t.FLOAT_MAT4&&(a=4),i[r]={type:n.type,location:t.getAttribLocation(e,r),locationSize:a}}return i}(s,g)}let T,E;s.attachShader(g,b),s.attachShader(g,S),void 0!==i.index0AttributeName?s.bindAttribLocation(g,0,i.index0AttributeName):!0===i.morphTargets&&s.bindAttribLocation(g,0,"position"),s.linkProgram(g),this.getUniforms=function(){return void 0===T&&w(this),T},this.getAttributes=function(){return void 0===E&&w(this),E};let A=!1===i.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===A&&(A=s.getProgramParameter(g,37297)),A},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(g),this.program=void 0},this.type=i.shaderType,this.name=i.shaderName,this.id=$a++,this.cacheKey=e,this.usedTimes=1,this.program=g,this.vertexShader=b,this.fragmentShader=S,this}let fo=0;class go{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,i=t.fragmentShader,n=this._getShaderStage(e),s=this._getShaderStage(i),r=this._getShaderCacheForMaterial(t);return!1===r.has(n)&&(r.add(n),n.usedTimes++),!1===r.has(s)&&(r.add(s),s.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const i of e)i.usedTimes--,0===i.usedTimes&&this.shaderCache.delete(i.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 i=e.get(t);return void 0===i&&(i=new Set,e.set(t,i)),i}_getShaderStage(t){const e=this.shaderCache;let i=e.get(t);return void 0===i&&(i=new _o(t),e.set(t,i)),i}}class _o{constructor(t){this.id=fo++,this.code=t,this.usedTimes=0}}function vo(t,e,i,n,s,r,a){const o=new Sn,l=new go,h=[],c=s.isWebGL2,u=s.logarithmicDepthBuffer,d=s.vertexTextures;let p=s.precision;const m={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 f(t){return 0===t?"uv":`uv${t}`}return{getParameters(r,o,h,g,_){const v=g.fog,y=_.geometry,x=r.isMeshStandardMaterial?g.environment:null,M=(r.isMeshStandardMaterial?i:e).get(r.envMap||x),b=M&&M.mapping===ut?M.image.height:null,S=m[r.type];null!==r.precision&&(p=s.getMaxPrecision(r.precision),r.precision);const w=y.morphAttributes.position||y.morphAttributes.normal||y.morphAttributes.color,T=void 0!==w?w.length:0;let E,A,C,R,P=0;if(void 0!==y.morphAttributes.position&&(P=1),void 0!==y.morphAttributes.normal&&(P=2),void 0!==y.morphAttributes.color&&(P=3),S){const t=pr[S];E=t.vertexShader,A=t.fragmentShader}else E=r.vertexShader,A=r.fragmentShader,l.update(r),C=l.getVertexShaderID(r),R=l.getFragmentShaderID(r);const L=t.getRenderTarget(),I=!0===_.isInstancedMesh,D=!0===_.isBatchedMesh,U=!!r.map,N=!!r.matcap,O=!!M,F=!!r.aoMap,B=!!r.lightMap,z=!!r.bumpMap,k=!!r.normalMap,V=!!r.displacementMap,G=!!r.emissiveMap,H=!!r.metalnessMap,W=!!r.roughnessMap,q=r.anisotropy>0,X=r.clearcoat>0,j=r.iridescence>0,Y=r.sheen>0,Z=r.transmission>0,J=q&&!!r.anisotropyMap,K=X&&!!r.clearcoatMap,$=X&&!!r.clearcoatNormalMap,Q=X&&!!r.clearcoatRoughnessMap,tt=j&&!!r.iridescenceMap,et=j&&!!r.iridescenceThicknessMap,it=Y&&!!r.sheenColorMap,nt=Y&&!!r.sheenRoughnessMap,st=!!r.specularMap,rt=!!r.specularColorMap,at=!!r.specularIntensityMap,ot=Z&&!!r.transmissionMap,lt=Z&&!!r.thicknessMap,ht=!!r.gradientMap,ct=!!r.alphaMap,dt=r.alphaTest>0,pt=!!r.alphaHash,mt=!!r.extensions,ft=!!y.attributes.uv1,gt=!!y.attributes.uv2,_t=!!y.attributes.uv3;let vt=0;return r.toneMapped&&(null!==L&&!0!==L.isXRRenderTarget||(vt=t.toneMapping)),{isWebGL2:c,shaderID:S,shaderType:r.type,shaderName:r.name,vertexShader:E,fragmentShader:A,defines:r.defines,customVertexShaderID:C,customFragmentShaderID:R,isRawShaderMaterial:!0===r.isRawShaderMaterial,glslVersion:r.glslVersion,precision:p,batching:D,instancing:I,instancingColor:I&&null!==_.instanceColor,supportsVertexTextures:d,outputColorSpace:null===L?t.outputColorSpace:!0===L.isXRRenderTarget?L.texture.colorSpace:we,map:U,matcap:N,envMap:O,envMapMode:O&&M.mapping,envMapCubeUVHeight:b,aoMap:F,lightMap:B,bumpMap:z,normalMap:k,displacementMap:d&&V,emissiveMap:G,normalMapObjectSpace:k&&1===r.normalMapType,normalMapTangentSpace:k&&0===r.normalMapType,metalnessMap:H,roughnessMap:W,anisotropy:q,anisotropyMap:J,clearcoat:X,clearcoatMap:K,clearcoatNormalMap:$,clearcoatRoughnessMap:Q,iridescence:j,iridescenceMap:tt,iridescenceThicknessMap:et,sheen:Y,sheenColorMap:it,sheenRoughnessMap:nt,specularMap:st,specularColorMap:rt,specularIntensityMap:at,transmission:Z,transmissionMap:ot,thicknessMap:lt,gradientMap:ht,opaque:!1===r.transparent&&1===r.blending,alphaMap:ct,alphaTest:dt,alphaHash:pt,combine:r.combine,mapUv:U&&f(r.map.channel),aoMapUv:F&&f(r.aoMap.channel),lightMapUv:B&&f(r.lightMap.channel),bumpMapUv:z&&f(r.bumpMap.channel),normalMapUv:k&&f(r.normalMap.channel),displacementMapUv:V&&f(r.displacementMap.channel),emissiveMapUv:G&&f(r.emissiveMap.channel),metalnessMapUv:H&&f(r.metalnessMap.channel),roughnessMapUv:W&&f(r.roughnessMap.channel),anisotropyMapUv:J&&f(r.anisotropyMap.channel),clearcoatMapUv:K&&f(r.clearcoatMap.channel),clearcoatNormalMapUv:$&&f(r.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Q&&f(r.clearcoatRoughnessMap.channel),iridescenceMapUv:tt&&f(r.iridescenceMap.channel),iridescenceThicknessMapUv:et&&f(r.iridescenceThicknessMap.channel),sheenColorMapUv:it&&f(r.sheenColorMap.channel),sheenRoughnessMapUv:nt&&f(r.sheenRoughnessMap.channel),specularMapUv:st&&f(r.specularMap.channel),specularColorMapUv:rt&&f(r.specularColorMap.channel),specularIntensityMapUv:at&&f(r.specularIntensityMap.channel),transmissionMapUv:ot&&f(r.transmissionMap.channel),thicknessMapUv:lt&&f(r.thicknessMap.channel),alphaMapUv:ct&&f(r.alphaMap.channel),vertexTangents:!!y.attributes.tangent&&(k||q),vertexColors:r.vertexColors,vertexAlphas:!0===r.vertexColors&&!!y.attributes.color&&4===y.attributes.color.itemSize,vertexUv1s:ft,vertexUv2s:gt,vertexUv3s:_t,pointsUvs:!0===_.isPoints&&!!y.attributes.uv&&(U||ct),fog:!!v,useFog:!0===r.fog,fogExp2:v&&v.isFogExp2,flatShading:!0===r.flatShading,sizeAttenuation:!0===r.sizeAttenuation,logarithmicDepthBuffer:u,skinning:!0===_.isSkinnedMesh,morphTargets:void 0!==y.morphAttributes.position,morphNormals:void 0!==y.morphAttributes.normal,morphColors:void 0!==y.morphAttributes.color,morphTargetsCount:T,morphTextureStride:P,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:r.dithering,shadowMapEnabled:t.shadowMap.enabled&&h.length>0,shadowMapType:t.shadowMap.type,toneMapping:vt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:U&&!0===r.map.isVideoTexture&&yi.getTransfer(r.map.colorSpace)===Ce,premultipliedAlpha:r.premultipliedAlpha,doubleSided:2===r.side,flipSided:1===r.side,useDepthPacking:r.depthPacking>=0,depthPacking:r.depthPacking||0,index0AttributeName:r.index0AttributeName,extensionDerivatives:mt&&!0===r.extensions.derivatives,extensionFragDepth:mt&&!0===r.extensions.fragDepth,extensionDrawBuffers:mt&&!0===r.extensions.drawBuffers,extensionShaderTextureLOD:mt&&!0===r.extensions.shaderTextureLOD,extensionClipCullDistance:mt&&r.extensions.clipCullDistance&&n.has("WEBGL_clip_cull_distance"),rendererExtensionFragDepth:c||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:c||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:c||n.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:r.customProgramCacheKey()}},getProgramCacheKey(e){const i=[];if(e.shaderID?i.push(e.shaderID):(i.push(e.customVertexShaderID),i.push(e.customFragmentShaderID)),void 0!==e.defines)for(const t in e.defines)i.push(t),i.push(e.defines[t]);return!1===e.isRawShaderMaterial&&(function(t,e){t.push(e.precision),t.push(e.outputColorSpace),t.push(e.envMapMode),t.push(e.envMapCubeUVHeight),t.push(e.mapUv),t.push(e.alphaMapUv),t.push(e.lightMapUv),t.push(e.aoMapUv),t.push(e.bumpMapUv),t.push(e.normalMapUv),t.push(e.displacementMapUv),t.push(e.emissiveMapUv),t.push(e.metalnessMapUv),t.push(e.roughnessMapUv),t.push(e.anisotropyMapUv),t.push(e.clearcoatMapUv),t.push(e.clearcoatNormalMapUv),t.push(e.clearcoatRoughnessMapUv),t.push(e.iridescenceMapUv),t.push(e.iridescenceThicknessMapUv),t.push(e.sheenColorMapUv),t.push(e.sheenRoughnessMapUv),t.push(e.specularMapUv),t.push(e.specularColorMapUv),t.push(e.specularIntensityMapUv),t.push(e.transmissionMapUv),t.push(e.thicknessMapUv),t.push(e.combine),t.push(e.fogExp2),t.push(e.sizeAttenuation),t.push(e.morphTargetsCount),t.push(e.morphAttributeCount),t.push(e.numDirLights),t.push(e.numPointLights),t.push(e.numSpotLights),t.push(e.numSpotLightMaps),t.push(e.numHemiLights),t.push(e.numRectAreaLights),t.push(e.numDirLightShadows),t.push(e.numPointLightShadows),t.push(e.numSpotLightShadows),t.push(e.numSpotLightShadowsWithMaps),t.push(e.numLightProbes),t.push(e.shadowMapType),t.push(e.toneMapping),t.push(e.numClippingPlanes),t.push(e.numClipIntersection),t.push(e.depthPacking)}(i,e),function(t,e){o.disableAll(),e.isWebGL2&&o.enable(0),e.supportsVertexTextures&&o.enable(1),e.instancing&&o.enable(2),e.instancingColor&&o.enable(3),e.matcap&&o.enable(4),e.envMap&&o.enable(5),e.normalMapObjectSpace&&o.enable(6),e.normalMapTangentSpace&&o.enable(7),e.clearcoat&&o.enable(8),e.iridescence&&o.enable(9),e.alphaTest&&o.enable(10),e.vertexColors&&o.enable(11),e.vertexAlphas&&o.enable(12),e.vertexUv1s&&o.enable(13),e.vertexUv2s&&o.enable(14),e.vertexUv3s&&o.enable(15),e.vertexTangents&&o.enable(16),e.anisotropy&&o.enable(17),e.alphaHash&&o.enable(18),e.batching&&o.enable(19),t.push(o.mask),o.disableAll(),e.fog&&o.enable(0),e.useFog&&o.enable(1),e.flatShading&&o.enable(2),e.logarithmicDepthBuffer&&o.enable(3),e.skinning&&o.enable(4),e.morphTargets&&o.enable(5),e.morphNormals&&o.enable(6),e.morphColors&&o.enable(7),e.premultipliedAlpha&&o.enable(8),e.shadowMapEnabled&&o.enable(9),e.useLegacyLights&&o.enable(10),e.doubleSided&&o.enable(11),e.flipSided&&o.enable(12),e.useDepthPacking&&o.enable(13),e.dithering&&o.enable(14),e.transmission&&o.enable(15),e.sheen&&o.enable(16),e.opaque&&o.enable(17),e.pointsUvs&&o.enable(18),e.decodeVideoTexture&&o.enable(19),t.push(o.mask)}(i,e),i.push(t.outputColorSpace)),i.push(e.customProgramCacheKey),i.join()},getUniforms(t){const e=m[t.type];let i;if(e){const t=pr[e];i=js.clone(t.uniforms)}else i=t.uniforms;return i},acquireProgram(e,i){let n;for(let t=0,s=h.length;t<s;t++){const e=h[t];if(e.cacheKey===i){n=e,++n.usedTimes;break}}return void 0===n&&(n=new mo(t,i,e,r),h.push(n)),n},releaseProgram(t){if(0===--t.usedTimes){const e=h.indexOf(t);h[e]=h[h.length-1],h.pop(),t.destroy()}},releaseShaderCache(t){l.remove(t)},programs:h,dispose(){l.dispose()}}}function yo(){let t=new WeakMap;return{get(e){let i=t.get(e);return void 0===i&&(i={},t.set(e,i)),i},remove(e){t.delete(e)},update(e,i,n){t.get(e)[i]=n},dispose(){t=new WeakMap}}}function xo(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function Mo(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function bo(){const t=[];let e=0;const i=[],n=[],s=[];function r(i,n,s,r,a,o){let l=t[e];return void 0===l?(l={id:i.id,object:i,geometry:n,material:s,groupOrder:r,renderOrder:i.renderOrder,z:a,group:o},t[e]=l):(l.id=i.id,l.object=i,l.geometry=n,l.material=s,l.groupOrder=r,l.renderOrder=i.renderOrder,l.z=a,l.group=o),e++,l}return{opaque:i,transmissive:n,transparent:s,init(){e=0,i.length=0,n.length=0,s.length=0},push(t,e,a,o,l,h){const c=r(t,e,a,o,l,h);a.transmission>0?n.push(c):!0===a.transparent?s.push(c):i.push(c)},unshift(t,e,a,o,l,h){const c=r(t,e,a,o,l,h);a.transmission>0?n.unshift(c):!0===a.transparent?s.unshift(c):i.unshift(c)},finish(){for(let i=e,n=t.length;i<n;i++){const e=t[i];if(null===e.id)break;e.id=null,e.object=null,e.geometry=null,e.material=null,e.group=null}},sort(t,e){i.length>1&&i.sort(t||xo),n.length>1&&n.sort(e||Mo),s.length>1&&s.sort(e||Mo)}}}function So(){let t=new WeakMap;return{get(e,i){const n=t.get(e);let s;return void 0===n?(s=new bo,t.set(e,[s])):i>=n.length?(s=new bo,n.push(s)):s=n[i],s},dispose(){t=new WeakMap}}}function wo(){const t={};return{get(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":i={direction:new Ni,color:new ts};break;case"SpotLight":i={position:new Ni,direction:new Ni,color:new ts,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new Ni,color:new ts,distance:0,decay:0};break;case"HemisphereLight":i={direction:new Ni,skyColor:new ts,groundColor:new ts};break;case"RectAreaLight":i={color:new ts,position:new Ni,halfWidth:new Ni,halfHeight:new Ni}}return t[e.id]=i,i}}}let To=0;function Eo(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function Ao(t,e){const i=new wo,n=function(){const t={};return{get(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":case"SpotLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ri};break;case"PointLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ri,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=i,i}}}(),s={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 l=0;l<9;l++)s.probe.push(new Ni);const r=new Ni,a=new dn,o=new dn;return{setup(r,a){let o=0,l=0,h=0;for(let t=0;t<9;t++)s.probe[t].set(0,0,0);let c=0,u=0,d=0,p=0,m=0,f=0,g=0,_=0,v=0,y=0,x=0;r.sort(Eo);const M=!0===a?Math.PI:1;for(let t=0,e=r.length;t<e;t++){const e=r[t],a=e.color,b=e.intensity,S=e.distance,w=e.shadow&&e.shadow.map?e.shadow.map.texture:null;if(e.isAmbientLight)o+=a.r*b*M,l+=a.g*b*M,h+=a.b*b*M;else if(e.isLightProbe){for(let t=0;t<9;t++)s.probe[t].addScaledVector(e.sh.coefficients[t],b);x++}else if(e.isDirectionalLight){const t=i.get(e);if(t.color.copy(e.color).multiplyScalar(e.intensity*M),e.castShadow){const t=e.shadow,i=n.get(e);i.shadowBias=t.bias,i.shadowNormalBias=t.normalBias,i.shadowRadius=t.radius,i.shadowMapSize=t.mapSize,s.directionalShadow[c]=i,s.directionalShadowMap[c]=w,s.directionalShadowMatrix[c]=e.shadow.matrix,f++}s.directional[c]=t,c++}else if(e.isSpotLight){const t=i.get(e);t.position.setFromMatrixPosition(e.matrixWorld),t.color.copy(a).multiplyScalar(b*M),t.distance=S,t.coneCos=Math.cos(e.angle),t.penumbraCos=Math.cos(e.angle*(1-e.penumbra)),t.decay=e.decay,s.spot[d]=t;const r=e.shadow;if(e.map&&(s.spotLightMap[v]=e.map,v++,r.updateMatrices(e),e.castShadow&&y++),s.spotLightMatrix[d]=r.matrix,e.castShadow){const t=n.get(e);t.shadowBias=r.bias,t.shadowNormalBias=r.normalBias,t.shadowRadius=r.radius,t.shadowMapSize=r.mapSize,s.spotShadow[d]=t,s.spotShadowMap[d]=w,_++}d++}else if(e.isRectAreaLight){const t=i.get(e);t.color.copy(a).multiplyScalar(b),t.halfWidth.set(.5*e.width,0,0),t.halfHeight.set(0,.5*e.height,0),s.rectArea[p]=t,p++}else if(e.isPointLight){const t=i.get(e);if(t.color.copy(e.color).multiplyScalar(e.intensity*M),t.distance=e.distance,t.decay=e.decay,e.castShadow){const t=e.shadow,i=n.get(e);i.shadowBias=t.bias,i.shadowNormalBias=t.normalBias,i.shadowRadius=t.radius,i.shadowMapSize=t.mapSize,i.shadowCameraNear=t.camera.near,i.shadowCameraFar=t.camera.far,s.pointShadow[u]=i,s.pointShadowMap[u]=w,s.pointShadowMatrix[u]=e.shadow.matrix,g++}s.point[u]=t,u++}else if(e.isHemisphereLight){const t=i.get(e);t.skyColor.copy(e.color).multiplyScalar(b*M),t.groundColor.copy(e.groundColor).multiplyScalar(b*M),s.hemi[m]=t,m++}}p>0&&(e.isWebGL2?!0===t.has("OES_texture_float_linear")?(s.rectAreaLTC1=dr.LTC_FLOAT_1,s.rectAreaLTC2=dr.LTC_FLOAT_2):(s.rectAreaLTC1=dr.LTC_HALF_1,s.rectAreaLTC2=dr.LTC_HALF_2):!0===t.has("OES_texture_float_linear")?(s.rectAreaLTC1=dr.LTC_FLOAT_1,s.rectAreaLTC2=dr.LTC_FLOAT_2):!0===t.has("OES_texture_half_float_linear")&&(s.rectAreaLTC1=dr.LTC_HALF_1,s.rectAreaLTC2=dr.LTC_HALF_2)),s.ambient[0]=o,s.ambient[1]=l,s.ambient[2]=h;const b=s.hash;b.directionalLength===c&&b.pointLength===u&&b.spotLength===d&&b.rectAreaLength===p&&b.hemiLength===m&&b.numDirectionalShadows===f&&b.numPointShadows===g&&b.numSpotShadows===_&&b.numSpotMaps===v&&b.numLightProbes===x||(s.directional.length=c,s.spot.length=d,s.rectArea.length=p,s.point.length=u,s.hemi.length=m,s.directionalShadow.length=f,s.directionalShadowMap.length=f,s.pointShadow.length=g,s.pointShadowMap.length=g,s.spotShadow.length=_,s.spotShadowMap.length=_,s.directionalShadowMatrix.length=f,s.pointShadowMatrix.length=g,s.spotLightMatrix.length=_+v-y,s.spotLightMap.length=v,s.numSpotLightShadowsWithMaps=y,s.numLightProbes=x,b.directionalLength=c,b.pointLength=u,b.spotLength=d,b.rectAreaLength=p,b.hemiLength=m,b.numDirectionalShadows=f,b.numPointShadows=g,b.numSpotShadows=_,b.numSpotMaps=v,b.numLightProbes=x,s.version=To++)},setupView(t,e){let i=0,n=0,l=0,h=0,c=0;const u=e.matrixWorldInverse;for(let d=0,p=t.length;d<p;d++){const e=t[d];if(e.isDirectionalLight){const t=s.directional[i];t.direction.setFromMatrixPosition(e.matrixWorld),r.setFromMatrixPosition(e.target.matrixWorld),t.direction.sub(r),t.direction.transformDirection(u),i++}else if(e.isSpotLight){const t=s.spot[l];t.position.setFromMatrixPosition(e.matrixWorld),t.position.applyMatrix4(u),t.direction.setFromMatrixPosition(e.matrixWorld),r.setFromMatrixPosition(e.target.matrixWorld),t.direction.sub(r),t.direction.transformDirection(u),l++}else if(e.isRectAreaLight){const t=s.rectArea[h];t.position.setFromMatrixPosition(e.matrixWorld),t.position.applyMatrix4(u),o.identity(),a.copy(e.matrixWorld),a.premultiply(u),o.extractRotation(a),t.halfWidth.set(.5*e.width,0,0),t.halfHeight.set(0,.5*e.height,0),t.halfWidth.applyMatrix4(o),t.halfHeight.applyMatrix4(o),h++}else if(e.isPointLight){const t=s.point[n];t.position.setFromMatrixPosition(e.matrixWorld),t.position.applyMatrix4(u),n++}else if(e.isHemisphereLight){const t=s.hemi[c];t.direction.setFromMatrixPosition(e.matrixWorld),t.direction.transformDirection(u),c++}}},state:s}}function Co(t,e){const i=new Ao(t,e),n=[],s=[],r={lightsArray:n,shadowsArray:s,lights:i};return{init(){n.length=0,s.length=0},state:r,setupLights(t){i.setup(n,t)},setupLightsView(t){i.setupView(n,t)},pushLight(t){n.push(t)},pushShadow(t){s.push(t)}}}function Ro(t,e){let i=new WeakMap;return{get(n,s=0){const r=i.get(n);let a;return void 0===r?(a=new Co(t,e),i.set(n,[a])):s>=r.length?(a=new Co(t,e),r.push(a)):a=r[s],a},dispose(){i=new WeakMap}}}class Po extends ns{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,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 Lo extends ns{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}}function Io(t,e,i){let n=new or;const s=new ri,r=new ri,a=new Ri,o=new Po({depthPacking:3201}),l=new Lo,h={},c=i.maxTextureSize,u={[F]:1,[B]:0,[z]:2},d=new Ys({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ri},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const m=new Ss;m.setAttribute("position",new ds(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const f=new Vs(m,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let _=this.type;function v(i,n){const r=e.update(f);d.defines.VSM_SAMPLES!==i.blurSamples&&(d.defines.VSM_SAMPLES=i.blurSamples,p.defines.VSM_SAMPLES=i.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),null===i.mapPass&&(i.mapPass=new Li(s.x,s.y)),d.uniforms.shadow_pass.value=i.map.texture,d.uniforms.resolution.value=i.mapSize,d.uniforms.radius.value=i.radius,t.setRenderTarget(i.mapPass),t.clear(),t.renderBufferDirect(n,null,r,d,f,null),p.uniforms.shadow_pass.value=i.mapPass.texture,p.uniforms.resolution.value=i.mapSize,p.uniforms.radius.value=i.radius,t.setRenderTarget(i.map),t.clear(),t.renderBufferDirect(n,null,r,p,f,null)}function y(e,i,n,s){let r=null;const a=!0===n.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(void 0!==a)r=a;else if(r=!0===n.isPointLight?l:o,t.localClippingEnabled&&!0===i.clipShadows&&Array.isArray(i.clippingPlanes)&&0!==i.clippingPlanes.length||i.displacementMap&&0!==i.displacementScale||i.alphaMap&&i.alphaTest>0||i.map&&i.alphaTest>0){const t=r.uuid,e=i.uuid;let n=h[t];void 0===n&&(n={},h[t]=n);let s=n[e];void 0===s&&(s=r.clone(),n[e]=s,i.addEventListener("dispose",M)),r=s}return r.visible=i.visible,r.wireframe=i.wireframe,r.side=3===s?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:u[i.side],r.alphaMap=i.alphaMap,r.alphaTest=i.alphaTest,r.map=i.map,r.clipShadows=i.clipShadows,r.clippingPlanes=i.clippingPlanes,r.clipIntersection=i.clipIntersection,r.displacementMap=i.displacementMap,r.displacementScale=i.displacementScale,r.displacementBias=i.displacementBias,r.wireframeLinewidth=i.wireframeLinewidth,r.linewidth=i.linewidth,!0===n.isPointLight&&!0===r.isMeshDistanceMaterial&&(t.properties.get(r).light=n),r}function x(i,s,r,a,o){if(!1===i.visible)return;if(i.layers.test(s.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&3===o)&&(!i.frustumCulled||n.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,i.matrixWorld);const n=e.update(i),l=i.material;if(Array.isArray(l)){const e=n.groups;for(let h=0,c=e.length;h<c;h++){const c=e[h],u=l[c.materialIndex];if(u&&u.visible){const e=y(i,u,a,o);i.onBeforeShadow(t,i,s,r,n,e,c),t.renderBufferDirect(r,null,n,e,i,c),i.onAfterShadow(t,i,s,r,n,e,c)}}}else if(l.visible){const e=y(i,l,a,o);i.onBeforeShadow(t,i,s,r,n,e,null),t.renderBufferDirect(r,null,n,e,i,null),i.onAfterShadow(t,i,s,r,n,e,null)}}const l=i.children;for(let t=0,e=l.length;t<e;t++)x(l[t],s,r,a,o)}function M(t){t.target.removeEventListener("dispose",M);for(const e in h){const i=h[e],n=t.target.uuid;n in i&&(i[n].dispose(),delete i[n])}}this.render=function(e,i,o){if(!1===g.enabled)return;if(!1===g.autoUpdate&&!1===g.needsUpdate)return;if(0===e.length)return;const l=t.getRenderTarget(),h=t.getActiveCubeFace(),u=t.getActiveMipmapLevel(),d=t.state;d.setBlending(0),d.buffers.color.setClear(1,1,1,1),d.buffers.depth.setTest(!0),d.setScissorTest(!1);const p=3!==_&&3===this.type,m=3===_&&3!==this.type;for(let f=0,g=e.length;f<g;f++){const l=e[f],h=l.shadow;if(void 0===h)continue;if(!1===h.autoUpdate&&!1===h.needsUpdate)continue;s.copy(h.mapSize);const u=h.getFrameExtents();if(s.multiply(u),r.copy(h.mapSize),(s.x>c||s.y>c)&&(s.x>c&&(r.x=Math.floor(c/u.x),s.x=r.x*u.x,h.mapSize.x=r.x),s.y>c&&(r.y=Math.floor(c/u.y),s.y=r.y*u.y,h.mapSize.y=r.y)),null===h.map||!0===p||!0===m){const t=3!==this.type?{minFilter:ft,magFilter:ft}:{};null!==h.map&&h.map.dispose(),h.map=new Li(s.x,s.y,t),h.map.texture.name=l.name+".shadowMap",h.camera.updateProjectionMatrix()}t.setRenderTarget(h.map),t.clear();const g=h.getViewportCount();for(let t=0;t<g;t++){const e=h.getViewport(t);a.set(r.x*e.x,r.y*e.y,r.x*e.z,r.y*e.w),d.viewport(a),h.updateMatrices(l,t),n=h.getFrustum(),x(i,o,h.camera,l,this.type)}!0!==h.isPointLightShadow&&3===this.type&&v(h,o),h.needsUpdate=!1}_=this.type,g.needsUpdate=!1,t.setRenderTarget(l,h,u)}}function Do(t,e,i){const n=i.isWebGL2,s=new function(){let e=!1;const i=new Ri;let n=null;const s=new Ri(0,0,0,0);return{setMask(i){n===i||e||(t.colorMask(i,i,i,i),n=i)},setLocked(t){e=t},setClear(e,n,r,a,o){!0===o&&(e*=a,n*=a,r*=a),i.set(e,n,r,a),!1===s.equals(i)&&(t.clearColor(e,n,r,a),s.copy(i))},reset(){e=!1,n=null,s.set(-1,0,0,0)}}},r=new function(){let e=!1,i=null,n=null,s=null;return{setTest(e){e?at(t.DEPTH_TEST):ot(t.DEPTH_TEST)},setMask(n){i===n||e||(t.depthMask(n),i=n)},setFunc(e){if(n!==e){switch(e){case 0:t.depthFunc(t.NEVER);break;case 1:t.depthFunc(t.ALWAYS);break;case 2:t.depthFunc(t.LESS);break;case 3:default:t.depthFunc(t.LEQUAL);break;case 4:t.depthFunc(t.EQUAL);break;case 5:t.depthFunc(t.GEQUAL);break;case 6:t.depthFunc(t.GREATER);break;case 7:t.depthFunc(t.NOTEQUAL)}n=e}},setLocked(t){e=t},setClear(e){s!==e&&(t.clearDepth(e),s=e)},reset(){e=!1,i=null,n=null,s=null}}},a=new function(){let e=!1,i=null,n=null,s=null,r=null,a=null,o=null,l=null,h=null;return{setTest(i){e||(i?at(t.STENCIL_TEST):ot(t.STENCIL_TEST))},setMask(n){i===n||e||(t.stencilMask(n),i=n)},setFunc(e,i,a){n===e&&s===i&&r===a||(t.stencilFunc(e,i,a),n=e,s=i,r=a)},setOp(e,i,n){a===e&&o===i&&l===n||(t.stencilOp(e,i,n),a=e,o=i,l=n)},setLocked(t){e=t},setClear(e){h!==e&&(t.clearStencil(e),h=e)},reset(){e=!1,i=null,n=null,s=null,r=null,a=null,o=null,l=null,h=null}}},o=new WeakMap,l=new WeakMap;let h={},c={},u=new WeakMap,d=[],p=null,m=!1,f=null,g=null,_=null,v=null,y=null,x=null,M=null,b=new ts(0,0,0),S=0,w=!1,T=null,E=null,A=null,C=null,R=null;const P=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let L=!1,I=0;const D=t.getParameter(t.VERSION);-1!==D.indexOf("WebGL")?(I=parseFloat(/^WebGL (\d)/.exec(D)[1]),L=I>=1):-1!==D.indexOf("OpenGL ES")&&(I=parseFloat(/^OpenGL ES (\d)/.exec(D)[1]),L=I>=2);let U=null,N={};const O=t.getParameter(t.SCISSOR_BOX),F=t.getParameter(t.VIEWPORT),B=(new Ri).fromArray(O),z=(new Ri).fromArray(F);function st(e,i,s,r){const a=new Uint8Array(4),o=t.createTexture();t.bindTexture(e,o),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let l=0;l<s;l++)!n||e!==t.TEXTURE_3D&&e!==t.TEXTURE_2D_ARRAY?t.texImage2D(i+l,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,a):t.texImage3D(i,0,t.RGBA,1,1,r,0,t.RGBA,t.UNSIGNED_BYTE,a);return o}const rt={};function at(e){!0!==h[e]&&(t.enable(e),h[e]=!0)}function ot(e){!1!==h[e]&&(t.disable(e),h[e]=!1)}rt[t.TEXTURE_2D]=st(t.TEXTURE_2D,t.TEXTURE_2D,1),rt[t.TEXTURE_CUBE_MAP]=st(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),n&&(rt[t.TEXTURE_2D_ARRAY]=st(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),rt[t.TEXTURE_3D]=st(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),s.setClear(0,0,0,1),r.setClear(1),a.setClear(0),at(t.DEPTH_TEST),r.setFunc(3),ut(!1),dt(1),at(t.CULL_FACE),ct(0);const lt={[k]:t.FUNC_ADD,[V]:t.FUNC_SUBTRACT,[G]:t.FUNC_REVERSE_SUBTRACT};if(n)lt[103]=t.MIN,lt[104]=t.MAX;else{const t=e.get("EXT_blend_minmax");null!==t&&(lt[103]=t.MIN_EXT,lt[104]=t.MAX_EXT)}const ht={[H]:t.ZERO,[W]:t.ONE,[q]:t.SRC_COLOR,[j]:t.SRC_ALPHA,[Q]:t.SRC_ALPHA_SATURATE,[K]:t.DST_COLOR,[Z]:t.DST_ALPHA,[X]:t.ONE_MINUS_SRC_COLOR,[Y]:t.ONE_MINUS_SRC_ALPHA,[$]:t.ONE_MINUS_DST_COLOR,[J]:t.ONE_MINUS_DST_ALPHA,[tt]:t.CONSTANT_COLOR,[et]:t.ONE_MINUS_CONSTANT_COLOR,[it]:t.CONSTANT_ALPHA,[nt]:t.ONE_MINUS_CONSTANT_ALPHA};function ct(e,i,n,s,r,a,o,l,h,c){if(0!==e){if(!1===m&&(at(t.BLEND),m=!0),5===e)r=r||i,a=a||n,o=o||s,i===g&&r===y||(t.blendEquationSeparate(lt[i],lt[r]),g=i,y=r),n===_&&s===v&&a===x&&o===M||(t.blendFuncSeparate(ht[n],ht[s],ht[a],ht[o]),_=n,v=s,x=a,M=o),!1!==l.equals(b)&&h===S||(t.blendColor(l.r,l.g,l.b,h),b.copy(l),S=h),f=e,w=!1;else if(e!==f||c!==w){if(g===k&&y===k||(t.blendEquation(t.FUNC_ADD),g=k,y=k),c)switch(e){case 1:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFunc(t.ONE,t.ONE);break;case 3:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case 4:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA)}else switch(e){case 1:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case 3:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case 4:t.blendFunc(t.ZERO,t.SRC_COLOR)}_=null,v=null,x=null,M=null,b.set(0,0,0),S=0,f=e,w=c}}else!0===m&&(ot(t.BLEND),m=!1)}function ut(e){T!==e&&(e?t.frontFace(t.CW):t.frontFace(t.CCW),T=e)}function dt(e){0!==e?(at(t.CULL_FACE),e!==E&&(1===e?t.cullFace(t.BACK):2===e?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):ot(t.CULL_FACE),E=e}function pt(e,i,n){e?(at(t.POLYGON_OFFSET_FILL),C===i&&R===n||(t.polygonOffset(i,n),C=i,R=n)):ot(t.POLYGON_OFFSET_FILL)}return{buffers:{color:s,depth:r,stencil:a},enable:at,disable:ot,bindFramebuffer:(e,i)=>c[e]!==i&&(t.bindFramebuffer(e,i),c[e]=i,n&&(e===t.DRAW_FRAMEBUFFER&&(c[t.FRAMEBUFFER]=i),e===t.FRAMEBUFFER&&(c[t.DRAW_FRAMEBUFFER]=i)),!0),drawBuffers(n,s){let r=d,a=!1;if(n)if(r=u.get(s),void 0===r&&(r=[],u.set(s,r)),n.isWebGLMultipleRenderTargets){const e=n.texture;if(r.length!==e.length||r[0]!==t.COLOR_ATTACHMENT0){for(let i=0,n=e.length;i<n;i++)r[i]=t.COLOR_ATTACHMENT0+i;r.length=e.length,a=!0}}else r[0]!==t.COLOR_ATTACHMENT0&&(r[0]=t.COLOR_ATTACHMENT0,a=!0);else r[0]!==t.BACK&&(r[0]=t.BACK,a=!0);a&&(i.isWebGL2?t.drawBuffers(r):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(r))},useProgram:e=>p!==e&&(t.useProgram(e),p=e,!0),setBlending:ct,setMaterial(e,i){2===e.side?ot(t.CULL_FACE):at(t.CULL_FACE);let n=1===e.side;i&&(n=!n),ut(n),1===e.blending&&!1===e.transparent?ct(0):ct(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.blendColor,e.blendAlpha,e.premultipliedAlpha),r.setFunc(e.depthFunc),r.setTest(e.depthTest),r.setMask(e.depthWrite),s.setMask(e.colorWrite);const o=e.stencilWrite;a.setTest(o),o&&(a.setMask(e.stencilWriteMask),a.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),a.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),pt(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage?at(t.SAMPLE_ALPHA_TO_COVERAGE):ot(t.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:ut,setCullFace:dt,setLineWidth(e){e!==A&&(L&&t.lineWidth(e),A=e)},setPolygonOffset:pt,setScissorTest(e){e?at(t.SCISSOR_TEST):ot(t.SCISSOR_TEST)},activeTexture(e){void 0===e&&(e=t.TEXTURE0+P-1),U!==e&&(t.activeTexture(e),U=e)},bindTexture(e,i,n){void 0===n&&(n=null===U?t.TEXTURE0+P-1:U);let s=N[n];void 0===s&&(s={type:void 0,texture:void 0},N[n]=s),s.type===e&&s.texture===i||(U!==n&&(t.activeTexture(n),U=n),t.bindTexture(e,i||rt[e]),s.type=e,s.texture=i)},unbindTexture(){const e=N[U];void 0!==e&&void 0!==e.type&&(t.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D(){try{t.compressedTexImage2D.apply(t,arguments)}catch(e){}},compressedTexImage3D(){try{t.compressedTexImage3D.apply(t,arguments)}catch(e){}},texImage2D(){try{t.texImage2D.apply(t,arguments)}catch(e){}},texImage3D(){try{t.texImage3D.apply(t,arguments)}catch(e){}},updateUBOMapping(e,i){let n=l.get(i);void 0===n&&(n=new WeakMap,l.set(i,n));let s=n.get(e);void 0===s&&(s=t.getUniformBlockIndex(i,e.name),n.set(e,s))},uniformBlockBinding(e,i){const n=l.get(i).get(e);o.get(i)!==n&&(t.uniformBlockBinding(i,n,e.__bindingPointIndex),o.set(i,n))},texStorage2D(){try{t.texStorage2D.apply(t,arguments)}catch(e){}},texStorage3D(){try{t.texStorage3D.apply(t,arguments)}catch(e){}},texSubImage2D(){try{t.texSubImage2D.apply(t,arguments)}catch(e){}},texSubImage3D(){try{t.texSubImage3D.apply(t,arguments)}catch(e){}},compressedTexSubImage2D(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(e){}},compressedTexSubImage3D(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(e){}},scissor(e){!1===B.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),B.copy(e))},viewport(e){!1===z.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),z.copy(e))},reset(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),!0===n&&(t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null)),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),h={},U=null,N={},c={},u=new WeakMap,d=[],p=null,m=!1,f=null,g=null,_=null,v=null,y=null,x=null,M=null,b=new ts(0,0,0),S=0,w=!1,T=null,E=null,A=null,C=null,R=null,B.set(0,0,t.canvas.width,t.canvas.height),z.set(0,0,t.canvas.width,t.canvas.height),s.reset(),r.reset(),a.reset()}}}function Uo(t,e,i,n,s,r,a){const o=s.isWebGL2,l=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,h="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),c=new WeakMap;let u;const d=new WeakMap;let p=!1;try{p="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(z){}function m(t,e){return p?new OffscreenCanvas(t,e):ui("canvas")}function f(t,e,i,n){let s=1;if((t.width>n||t.height>n)&&(s=n/Math.max(t.width,t.height)),s<1||!0===e){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const n=e?ei:Math.floor,r=n(s*t.width),a=n(s*t.height);void 0===u&&(u=m(r,a));const o=i?m(r,a):u;return o.width=r,o.height=a,o.getContext("2d").drawImage(t,0,0,r,a),o}return t}return t}function g(t){return ti(t.width)&&ti(t.height)}function _(t,e){return t.generateMipmaps&&e&&t.minFilter!==ft&&t.minFilter!==vt}function v(e){t.generateMipmap(e)}function y(i,n,s,r,a=!1){if(!1===o)return n;if(null!==i&&void 0!==t[i])return t[i];let l=n;if(n===t.RED&&(s===t.FLOAT&&(l=t.R32F),s===t.HALF_FLOAT&&(l=t.R16F),s===t.UNSIGNED_BYTE&&(l=t.R8)),n===t.RED_INTEGER&&(s===t.UNSIGNED_BYTE&&(l=t.R8UI),s===t.UNSIGNED_SHORT&&(l=t.R16UI),s===t.UNSIGNED_INT&&(l=t.R32UI),s===t.BYTE&&(l=t.R8I),s===t.SHORT&&(l=t.R16I),s===t.INT&&(l=t.R32I)),n===t.RG&&(s===t.FLOAT&&(l=t.RG32F),s===t.HALF_FLOAT&&(l=t.RG16F),s===t.UNSIGNED_BYTE&&(l=t.RG8)),n===t.RGBA){const e=a?Ae:yi.getTransfer(r);s===t.FLOAT&&(l=t.RGBA32F),s===t.HALF_FLOAT&&(l=t.RGBA16F),s===t.UNSIGNED_BYTE&&(l=e===Ce?t.SRGB8_ALPHA8:t.RGBA8),s===t.UNSIGNED_SHORT_4_4_4_4&&(l=t.RGBA4),s===t.UNSIGNED_SHORT_5_5_5_1&&(l=t.RGB5_A1)}return l!==t.R16F&&l!==t.R32F&&l!==t.RG16F&&l!==t.RG32F&&l!==t.RGBA16F&&l!==t.RGBA32F||e.get("EXT_color_buffer_float"),l}function x(t,e,i){return!0===_(t,i)||t.isFramebufferTexture&&t.minFilter!==ft&&t.minFilter!==vt?Math.log2(Math.max(e.width,e.height))+1:void 0!==t.mipmaps&&t.mipmaps.length>0?t.mipmaps.length:t.isCompressedTexture&&Array.isArray(t.image)?e.mipmaps.length:1}function M(e){return e===ft||e===gt||e===_t?t.NEAREST:t.LINEAR}function b(t){const e=t.target;e.removeEventListener("dispose",b),function(t){const e=n.get(t);if(void 0===e.__webglInit)return;const i=t.source,s=d.get(i);if(s){const n=s[e.__cacheKey];n.usedTimes--,0===n.usedTimes&&w(t),0===Object.keys(s).length&&d.delete(i)}n.remove(t)}(e),e.isVideoTexture&&c.delete(e)}function S(e){const i=e.target;i.removeEventListener("dispose",S),function(e){const i=e.texture,s=n.get(e),r=n.get(i);if(void 0!==r.__webglTexture&&(t.deleteTexture(r.__webglTexture),a.memory.textures--),e.depthTexture&&e.depthTexture.dispose(),e.isWebGLCubeRenderTarget)for(let n=0;n<6;n++){if(Array.isArray(s.__webglFramebuffer[n]))for(let e=0;e<s.__webglFramebuffer[n].length;e++)t.deleteFramebuffer(s.__webglFramebuffer[n][e]);else t.deleteFramebuffer(s.__webglFramebuffer[n]);s.__webglDepthbuffer&&t.deleteRenderbuffer(s.__webglDepthbuffer[n])}else{if(Array.isArray(s.__webglFramebuffer))for(let e=0;e<s.__webglFramebuffer.length;e++)t.deleteFramebuffer(s.__webglFramebuffer[e]);else t.deleteFramebuffer(s.__webglFramebuffer);if(s.__webglDepthbuffer&&t.deleteRenderbuffer(s.__webglDepthbuffer),s.__webglMultisampledFramebuffer&&t.deleteFramebuffer(s.__webglMultisampledFramebuffer),s.__webglColorRenderbuffer)for(let e=0;e<s.__webglColorRenderbuffer.length;e++)s.__webglColorRenderbuffer[e]&&t.deleteRenderbuffer(s.__webglColorRenderbuffer[e]);s.__webglDepthRenderbuffer&&t.deleteRenderbuffer(s.__webglDepthRenderbuffer)}if(e.isWebGLMultipleRenderTargets)for(let o=0,l=i.length;o<l;o++){const e=n.get(i[o]);e.__webglTexture&&(t.deleteTexture(e.__webglTexture),a.memory.textures--),n.remove(i[o])}n.remove(i),n.remove(e)}(i)}function w(e){const i=n.get(e);t.deleteTexture(i.__webglTexture);const s=e.source;delete d.get(s)[i.__cacheKey],a.memory.textures--}let T=0;function E(e,s){const r=n.get(e);if(e.isVideoTexture&&function(t){const e=a.render.frame;c.get(t)!==e&&(c.set(t,e),t.update())}(e),!1===e.isRenderTargetTexture&&e.version>0&&r.__version!==e.version){const t=e.image;if(null===t);else if(!1!==t.complete)return void I(r,e,s)}i.bindTexture(t.TEXTURE_2D,r.__webglTexture,t.TEXTURE0+s)}const A={[dt]:t.REPEAT,[pt]:t.CLAMP_TO_EDGE,[mt]:t.MIRRORED_REPEAT},C={[ft]:t.NEAREST,[gt]:t.NEAREST_MIPMAP_NEAREST,[_t]:t.NEAREST_MIPMAP_LINEAR,[vt]:t.LINEAR,[yt]:t.LINEAR_MIPMAP_NEAREST,[xt]:t.LINEAR_MIPMAP_LINEAR},R={[Ie]:t.NEVER,[ze]:t.ALWAYS,[De]:t.LESS,[Ne]:t.LEQUAL,[Ue]:t.EQUAL,[Be]:t.GEQUAL,[Oe]:t.GREATER,[Fe]:t.NOTEQUAL};function P(i,r,a){if(a?(t.texParameteri(i,t.TEXTURE_WRAP_S,A[r.wrapS]),t.texParameteri(i,t.TEXTURE_WRAP_T,A[r.wrapT]),i!==t.TEXTURE_3D&&i!==t.TEXTURE_2D_ARRAY||t.texParameteri(i,t.TEXTURE_WRAP_R,A[r.wrapR]),t.texParameteri(i,t.TEXTURE_MAG_FILTER,C[r.magFilter]),t.texParameteri(i,t.TEXTURE_MIN_FILTER,C[r.minFilter])):(t.texParameteri(i,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(i,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),i!==t.TEXTURE_3D&&i!==t.TEXTURE_2D_ARRAY||t.texParameteri(i,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),r.wrapS!==pt||r.wrapT,t.texParameteri(i,t.TEXTURE_MAG_FILTER,M(r.magFilter)),t.texParameteri(i,t.TEXTURE_MIN_FILTER,M(r.minFilter)),r.minFilter!==ft&&r.minFilter),r.compareFunction&&(t.texParameteri(i,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(i,t.TEXTURE_COMPARE_FUNC,R[r.compareFunction])),!0===e.has("EXT_texture_filter_anisotropic")){const a=e.get("EXT_texture_filter_anisotropic");if(r.magFilter===ft)return;if(r.minFilter!==_t&&r.minFilter!==xt)return;if(r.type===Tt&&!1===e.has("OES_texture_float_linear"))return;if(!1===o&&r.type===Et&&!1===e.has("OES_texture_half_float_linear"))return;(r.anisotropy>1||n.get(r).__currentAnisotropy)&&(t.texParameterf(i,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(r.anisotropy,s.getMaxAnisotropy())),n.get(r).__currentAnisotropy=r.anisotropy)}}function L(e,i){let n=!1;void 0===e.__webglInit&&(e.__webglInit=!0,i.addEventListener("dispose",b));const s=i.source;let r=d.get(s);void 0===r&&(r={},d.set(s,r));const o=function(t){const e=[];return e.push(t.wrapS),e.push(t.wrapT),e.push(t.wrapR||0),e.push(t.magFilter),e.push(t.minFilter),e.push(t.anisotropy),e.push(t.internalFormat),e.push(t.format),e.push(t.type),e.push(t.generateMipmaps),e.push(t.premultiplyAlpha),e.push(t.flipY),e.push(t.unpackAlignment),e.push(t.colorSpace),e.join()}(i);if(o!==e.__cacheKey){void 0===r[o]&&(r[o]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,n=!0),r[o].usedTimes++;const s=r[e.__cacheKey];void 0!==s&&(r[e.__cacheKey].usedTimes--,0===s.usedTimes&&w(i)),e.__cacheKey=o,e.__webglTexture=r[o].texture}return n}function I(e,a,l){let h=t.TEXTURE_2D;(a.isDataArrayTexture||a.isCompressedArrayTexture)&&(h=t.TEXTURE_2D_ARRAY),a.isData3DTexture&&(h=t.TEXTURE_3D);const c=L(e,a),u=a.source;i.bindTexture(h,e.__webglTexture,t.TEXTURE0+l);const d=n.get(u);if(u.version!==d.__version||!0===c){i.activeTexture(t.TEXTURE0+l);const e=yi.getPrimaries(yi.workingColorSpace),n=a.colorSpace===be?null:yi.getPrimaries(a.colorSpace),p=a.colorSpace===be||e===n?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,p);const m=function(t){return!o&&(t.wrapS!==pt||t.wrapT!==pt||t.minFilter!==ft&&t.minFilter!==vt)}(a)&&!1===g(a.image);let M=f(a.image,m,!1,s.maxTextureSize);M=B(a,M);const b=g(M)||o,S=r.convert(a.format,a.colorSpace);let w,T=r.convert(a.type),E=y(a.internalFormat,S,T,a.colorSpace,a.isVideoTexture);P(h,a,b);const A=a.mipmaps,C=o&&!0!==a.isVideoTexture&&E!==Wt,R=void 0===d.__version||!0===c,L=x(a,M,b);if(a.isDepthTexture)E=t.DEPTH_COMPONENT,o?E=a.type===Tt?t.DEPTH_COMPONENT32F:a.type===wt?t.DEPTH_COMPONENT24:a.type===Rt?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT16:a.type,a.format===Lt&&E===t.DEPTH_COMPONENT&&a.type!==bt&&a.type!==wt&&(a.type=wt,T=r.convert(a.type)),a.format===It&&E===t.DEPTH_COMPONENT&&(E=t.DEPTH_STENCIL,a.type!==Rt&&(a.type=Rt,T=r.convert(a.type))),R&&(C?i.texStorage2D(t.TEXTURE_2D,1,E,M.width,M.height):i.texImage2D(t.TEXTURE_2D,0,E,M.width,M.height,0,S,T,null));else if(a.isDataTexture)if(A.length>0&&b){C&&R&&i.texStorage2D(t.TEXTURE_2D,L,E,A[0].width,A[0].height);for(let e=0,n=A.length;e<n;e++)w=A[e],C?i.texSubImage2D(t.TEXTURE_2D,e,0,0,w.width,w.height,S,T,w.data):i.texImage2D(t.TEXTURE_2D,e,E,w.width,w.height,0,S,T,w.data);a.generateMipmaps=!1}else C?(R&&i.texStorage2D(t.TEXTURE_2D,L,E,M.width,M.height),i.texSubImage2D(t.TEXTURE_2D,0,0,0,M.width,M.height,S,T,M.data)):i.texImage2D(t.TEXTURE_2D,0,E,M.width,M.height,0,S,T,M.data);else if(a.isCompressedTexture)if(a.isCompressedArrayTexture){C&&R&&i.texStorage3D(t.TEXTURE_2D_ARRAY,L,E,A[0].width,A[0].height,M.depth);for(let e=0,n=A.length;e<n;e++)w=A[e],a.format!==Pt?null!==S&&(C?i.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,w.width,w.height,M.depth,S,w.data,0,0):i.compressedTexImage3D(t.TEXTURE_2D_ARRAY,e,E,w.width,w.height,M.depth,0,w.data,0,0)):C?i.texSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,w.width,w.height,M.depth,S,T,w.data):i.texImage3D(t.TEXTURE_2D_ARRAY,e,E,w.width,w.height,M.depth,0,S,T,w.data)}else{C&&R&&i.texStorage2D(t.TEXTURE_2D,L,E,A[0].width,A[0].height);for(let e=0,n=A.length;e<n;e++)w=A[e],a.format!==Pt?null!==S&&(C?i.compressedTexSubImage2D(t.TEXTURE_2D,e,0,0,w.width,w.height,S,w.data):i.compressedTexImage2D(t.TEXTURE_2D,e,E,w.width,w.height,0,w.data)):C?i.texSubImage2D(t.TEXTURE_2D,e,0,0,w.width,w.height,S,T,w.data):i.texImage2D(t.TEXTURE_2D,e,E,w.width,w.height,0,S,T,w.data)}else if(a.isDataArrayTexture)C?(R&&i.texStorage3D(t.TEXTURE_2D_ARRAY,L,E,M.width,M.height,M.depth),i.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,M.width,M.height,M.depth,S,T,M.data)):i.texImage3D(t.TEXTURE_2D_ARRAY,0,E,M.width,M.height,M.depth,0,S,T,M.data);else if(a.isData3DTexture)C?(R&&i.texStorage3D(t.TEXTURE_3D,L,E,M.width,M.height,M.depth),i.texSubImage3D(t.TEXTURE_3D,0,0,0,0,M.width,M.height,M.depth,S,T,M.data)):i.texImage3D(t.TEXTURE_3D,0,E,M.width,M.height,M.depth,0,S,T,M.data);else if(a.isFramebufferTexture){if(R)if(C)i.texStorage2D(t.TEXTURE_2D,L,E,M.width,M.height);else{let e=M.width,n=M.height;for(let s=0;s<L;s++)i.texImage2D(t.TEXTURE_2D,s,E,e,n,0,S,T,null),e>>=1,n>>=1}}else if(A.length>0&&b){C&&R&&i.texStorage2D(t.TEXTURE_2D,L,E,A[0].width,A[0].height);for(let e=0,n=A.length;e<n;e++)w=A[e],C?i.texSubImage2D(t.TEXTURE_2D,e,0,0,S,T,w):i.texImage2D(t.TEXTURE_2D,e,E,S,T,w);a.generateMipmaps=!1}else C?(R&&i.texStorage2D(t.TEXTURE_2D,L,E,M.width,M.height),i.texSubImage2D(t.TEXTURE_2D,0,0,0,S,T,M)):i.texImage2D(t.TEXTURE_2D,0,E,S,T,M);_(a,b)&&v(h),d.__version=u.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}function D(e,s,a,o,h,c){const u=r.convert(a.format,a.colorSpace),d=r.convert(a.type),p=y(a.internalFormat,u,d,a.colorSpace);if(!n.get(s).__hasExternalTextures){const e=Math.max(1,s.width>>c),n=Math.max(1,s.height>>c);h===t.TEXTURE_3D||h===t.TEXTURE_2D_ARRAY?i.texImage3D(h,c,p,e,n,s.depth,0,u,d,null):i.texImage2D(h,c,p,e,n,0,u,d,null)}i.bindFramebuffer(t.FRAMEBUFFER,e),F(s)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,o,h,n.get(a).__webglTexture,0,O(s)):(h===t.TEXTURE_2D||h>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&h<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,o,h,n.get(a).__webglTexture,c),i.bindFramebuffer(t.FRAMEBUFFER,null)}function U(e,i,n){if(t.bindRenderbuffer(t.RENDERBUFFER,e),i.depthBuffer&&!i.stencilBuffer){let s=!0===o?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(n||F(i)){const e=i.depthTexture;e&&e.isDepthTexture&&(e.type===Tt?s=t.DEPTH_COMPONENT32F:e.type===wt&&(s=t.DEPTH_COMPONENT24));const n=O(i);F(i)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,n,s,i.width,i.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,n,s,i.width,i.height)}else t.renderbufferStorage(t.RENDERBUFFER,s,i.width,i.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e)}else if(i.depthBuffer&&i.stencilBuffer){const s=O(i);n&&!1===F(i)?t.renderbufferStorageMultisample(t.RENDERBUFFER,s,t.DEPTH24_STENCIL8,i.width,i.height):F(i)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,s,t.DEPTH24_STENCIL8,i.width,i.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,i.width,i.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e)}else{const e=!0===i.isWebGLMultipleRenderTargets?i.texture:[i.texture];for(let s=0;s<e.length;s++){const a=e[s],o=r.convert(a.format,a.colorSpace),h=r.convert(a.type),c=y(a.internalFormat,o,h,a.colorSpace),u=O(i);n&&!1===F(i)?t.renderbufferStorageMultisample(t.RENDERBUFFER,u,c,i.width,i.height):F(i)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,u,c,i.width,i.height):t.renderbufferStorage(t.RENDERBUFFER,c,i.width,i.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function N(e){const s=n.get(e),r=!0===e.isWebGLCubeRenderTarget;if(e.depthTexture&&!s.__autoAllocateDepthBuffer){if(r)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,s){if(s&&s.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(t.FRAMEBUFFER,e),!s.depthTexture||!s.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");n.get(s.depthTexture).__webglTexture&&s.depthTexture.image.width===s.width&&s.depthTexture.image.height===s.height||(s.depthTexture.image.width=s.width,s.depthTexture.image.height=s.height,s.depthTexture.needsUpdate=!0),E(s.depthTexture,0);const r=n.get(s.depthTexture).__webglTexture,a=O(s);if(s.depthTexture.format===Lt)F(s)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,r,0,a):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,r,0);else{if(s.depthTexture.format!==It)throw new Error("Unknown depthTexture format");F(s)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,r,0,a):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,r,0)}}(s.__webglFramebuffer,e)}else if(r){s.__webglDepthbuffer=[];for(let n=0;n<6;n++)i.bindFramebuffer(t.FRAMEBUFFER,s.__webglFramebuffer[n]),s.__webglDepthbuffer[n]=t.createRenderbuffer(),U(s.__webglDepthbuffer[n],e,!1)}else i.bindFramebuffer(t.FRAMEBUFFER,s.__webglFramebuffer),s.__webglDepthbuffer=t.createRenderbuffer(),U(s.__webglDepthbuffer,e,!1);i.bindFramebuffer(t.FRAMEBUFFER,null)}function O(t){return Math.min(s.maxSamples,t.samples)}function F(t){const i=n.get(t);return o&&t.samples>0&&!0===e.has("WEBGL_multisampled_render_to_texture")&&!1!==i.__useRenderToTexture}function B(t,i){const n=t.colorSpace,s=t.format;return t.type,!0===t.isCompressedTexture||!0===t.isVideoTexture||t.format===Ge||n!==we&&n!==be&&yi.getTransfer(n)===Ce&&!1===o&&(!0===e.has("EXT_sRGB")&&s===Pt?(t.format=Ge,t.minFilter=vt,t.generateMipmaps=!1):i=Si.sRGBToLinear(i)),i}this.allocateTextureUnit=function(){const t=T;return s.maxTextures,T+=1,t},this.resetTextureUnits=function(){T=0},this.setTexture2D=E,this.setTexture2DArray=function(e,s){const r=n.get(e);e.version>0&&r.__version!==e.version?I(r,e,s):i.bindTexture(t.TEXTURE_2D_ARRAY,r.__webglTexture,t.TEXTURE0+s)},this.setTexture3D=function(e,s){const r=n.get(e);e.version>0&&r.__version!==e.version?I(r,e,s):i.bindTexture(t.TEXTURE_3D,r.__webglTexture,t.TEXTURE0+s)},this.setTextureCube=function(e,a){const l=n.get(e);e.version>0&&l.__version!==e.version?function(e,a,l){if(6!==a.image.length)return;const h=L(e,a),c=a.source;i.bindTexture(t.TEXTURE_CUBE_MAP,e.__webglTexture,t.TEXTURE0+l);const u=n.get(c);if(c.version!==u.__version||!0===h){i.activeTexture(t.TEXTURE0+l);const e=yi.getPrimaries(yi.workingColorSpace),n=a.colorSpace===be?null:yi.getPrimaries(a.colorSpace),d=a.colorSpace===be||e===n?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);const p=a.isCompressedTexture||a.image[0].isCompressedTexture,m=a.image[0]&&a.image[0].isDataTexture,M=[];for(let t=0;t<6;t++)M[t]=p||m?m?a.image[t].image:a.image[t]:f(a.image[t],!1,!0,s.maxCubemapSize),M[t]=B(a,M[t]);const b=M[0],S=g(b)||o,w=r.convert(a.format,a.colorSpace),T=r.convert(a.type),E=y(a.internalFormat,w,T,a.colorSpace),A=o&&!0!==a.isVideoTexture,C=void 0===u.__version||!0===h;let R,L=x(a,b,S);if(P(t.TEXTURE_CUBE_MAP,a,S),p){A&&C&&i.texStorage2D(t.TEXTURE_CUBE_MAP,L,E,b.width,b.height);for(let e=0;e<6;e++){R=M[e].mipmaps;for(let n=0;n<R.length;n++){const s=R[n];a.format!==Pt?null!==w&&(A?i.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,0,0,s.width,s.height,w,s.data):i.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,E,s.width,s.height,0,s.data)):A?i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,0,0,s.width,s.height,w,T,s.data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,E,s.width,s.height,0,w,T,s.data)}}}else{R=a.mipmaps,A&&C&&(R.length>0&&L++,i.texStorage2D(t.TEXTURE_CUBE_MAP,L,E,M[0].width,M[0].height));for(let e=0;e<6;e++)if(m){A?i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,M[e].width,M[e].height,w,T,M[e].data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,E,M[e].width,M[e].height,0,w,T,M[e].data);for(let n=0;n<R.length;n++){const s=R[n].image[e].image;A?i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,0,0,s.width,s.height,w,T,s.data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,E,s.width,s.height,0,w,T,s.data)}}else{A?i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,w,T,M[e]):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,E,w,T,M[e]);for(let n=0;n<R.length;n++){const s=R[n];A?i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,0,0,w,T,s.image[e]):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,E,w,T,s.image[e])}}}_(a,S)&&v(t.TEXTURE_CUBE_MAP),u.__version=c.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}(l,e,a):i.bindTexture(t.TEXTURE_CUBE_MAP,l.__webglTexture,t.TEXTURE0+a)},this.rebindTextures=function(e,i,s){const r=n.get(e);void 0!==i&&D(r.__webglFramebuffer,e,e.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),void 0!==s&&N(e)},this.setupRenderTarget=function(e){const l=e.texture,h=n.get(e),c=n.get(l);e.addEventListener("dispose",S),!0!==e.isWebGLMultipleRenderTargets&&(void 0===c.__webglTexture&&(c.__webglTexture=t.createTexture()),c.__version=l.version,a.memory.textures++);const u=!0===e.isWebGLCubeRenderTarget,d=!0===e.isWebGLMultipleRenderTargets,p=g(e)||o;if(u){h.__webglFramebuffer=[];for(let e=0;e<6;e++)if(o&&l.mipmaps&&l.mipmaps.length>0){h.__webglFramebuffer[e]=[];for(let i=0;i<l.mipmaps.length;i++)h.__webglFramebuffer[e][i]=t.createFramebuffer()}else h.__webglFramebuffer[e]=t.createFramebuffer()}else{if(o&&l.mipmaps&&l.mipmaps.length>0){h.__webglFramebuffer=[];for(let e=0;e<l.mipmaps.length;e++)h.__webglFramebuffer[e]=t.createFramebuffer()}else h.__webglFramebuffer=t.createFramebuffer();if(d&&s.drawBuffers){const i=e.texture;for(let e=0,s=i.length;e<s;e++){const s=n.get(i[e]);void 0===s.__webglTexture&&(s.__webglTexture=t.createTexture(),a.memory.textures++)}}if(o&&e.samples>0&&!1===F(e)){const n=d?l:[l];h.__webglMultisampledFramebuffer=t.createFramebuffer(),h.__webglColorRenderbuffer=[],i.bindFramebuffer(t.FRAMEBUFFER,h.__webglMultisampledFramebuffer);for(let i=0;i<n.length;i++){const s=n[i];h.__webglColorRenderbuffer[i]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,h.__webglColorRenderbuffer[i]);const a=r.convert(s.format,s.colorSpace),o=r.convert(s.type),l=y(s.internalFormat,a,o,s.colorSpace,!0===e.isXRRenderTarget),c=O(e);t.renderbufferStorageMultisample(t.RENDERBUFFER,c,l,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+i,t.RENDERBUFFER,h.__webglColorRenderbuffer[i])}t.bindRenderbuffer(t.RENDERBUFFER,null),e.depthBuffer&&(h.__webglDepthRenderbuffer=t.createRenderbuffer(),U(h.__webglDepthRenderbuffer,e,!0)),i.bindFramebuffer(t.FRAMEBUFFER,null)}}if(u){i.bindTexture(t.TEXTURE_CUBE_MAP,c.__webglTexture),P(t.TEXTURE_CUBE_MAP,l,p);for(let i=0;i<6;i++)if(o&&l.mipmaps&&l.mipmaps.length>0)for(let n=0;n<l.mipmaps.length;n++)D(h.__webglFramebuffer[i][n],e,l,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+i,n);else D(h.__webglFramebuffer[i],e,l,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+i,0);_(l,p)&&v(t.TEXTURE_CUBE_MAP),i.unbindTexture()}else if(d){const s=e.texture;for(let r=0,a=s.length;r<a;r++){const a=s[r],o=n.get(a);i.bindTexture(t.TEXTURE_2D,o.__webglTexture),P(t.TEXTURE_2D,a,p),D(h.__webglFramebuffer,e,a,t.COLOR_ATTACHMENT0+r,t.TEXTURE_2D,0),_(a,p)&&v(t.TEXTURE_2D)}i.unbindTexture()}else{let n=t.TEXTURE_2D;if((e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&o&&(n=e.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),i.bindTexture(n,c.__webglTexture),P(n,l,p),o&&l.mipmaps&&l.mipmaps.length>0)for(let i=0;i<l.mipmaps.length;i++)D(h.__webglFramebuffer[i],e,l,t.COLOR_ATTACHMENT0,n,i);else D(h.__webglFramebuffer,e,l,t.COLOR_ATTACHMENT0,n,0);_(l,p)&&v(n),i.unbindTexture()}e.depthBuffer&&N(e)},this.updateRenderTargetMipmap=function(e){const s=g(e)||o,r=!0===e.isWebGLMultipleRenderTargets?e.texture:[e.texture];for(let a=0,o=r.length;a<o;a++){const o=r[a];if(_(o,s)){const s=e.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,r=n.get(o).__webglTexture;i.bindTexture(s,r),v(s),i.unbindTexture()}}},this.updateMultisampleRenderTarget=function(e){if(o&&e.samples>0&&!1===F(e)){const s=e.isWebGLMultipleRenderTargets?e.texture:[e.texture],r=e.width,a=e.height;let o=t.COLOR_BUFFER_BIT;const l=[],c=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,u=n.get(e),d=!0===e.isWebGLMultipleRenderTargets;if(d)for(let e=0;e<s.length;e++)i.bindFramebuffer(t.FRAMEBUFFER,u.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,null),i.bindFramebuffer(t.FRAMEBUFFER,u.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,null,0);i.bindFramebuffer(t.READ_FRAMEBUFFER,u.__webglMultisampledFramebuffer),i.bindFramebuffer(t.DRAW_FRAMEBUFFER,u.__webglFramebuffer);for(let i=0;i<s.length;i++){l.push(t.COLOR_ATTACHMENT0+i),e.depthBuffer&&l.push(c);const p=void 0!==u.__ignoreDepthValues&&u.__ignoreDepthValues;if(!1===p&&(e.depthBuffer&&(o|=t.DEPTH_BUFFER_BIT),e.stencilBuffer&&(o|=t.STENCIL_BUFFER_BIT)),d&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,u.__webglColorRenderbuffer[i]),!0===p&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[c]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[c])),d){const e=n.get(s[i]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0)}t.blitFramebuffer(0,0,r,a,0,0,r,a,o,t.NEAREST),h&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,l)}if(i.bindFramebuffer(t.READ_FRAMEBUFFER,null),i.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),d)for(let e=0;e<s.length;e++){i.bindFramebuffer(t.FRAMEBUFFER,u.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,u.__webglColorRenderbuffer[e]);const r=n.get(s[e]).__webglTexture;i.bindFramebuffer(t.FRAMEBUFFER,u.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,r,0)}i.bindFramebuffer(t.DRAW_FRAMEBUFFER,u.__webglMultisampledFramebuffer)}},this.setupDepthRenderbuffer=N,this.setupFrameBufferTexture=D,this.useMultisampledRTT=F}function No(t,e,i){const n=i.isWebGL2;return{convert(i,s=""){let r;const a=yi.getTransfer(s);if(i===Mt)return t.UNSIGNED_BYTE;if(i===At)return t.UNSIGNED_SHORT_4_4_4_4;if(i===Ct)return t.UNSIGNED_SHORT_5_5_5_1;if(1010===i)return t.BYTE;if(1011===i)return t.SHORT;if(i===bt)return t.UNSIGNED_SHORT;if(i===St)return t.INT;if(i===wt)return t.UNSIGNED_INT;if(i===Tt)return t.FLOAT;if(i===Et)return n?t.HALF_FLOAT:(r=e.get("OES_texture_half_float"),null!==r?r.HALF_FLOAT_OES:null);if(1021===i)return t.ALPHA;if(i===Pt)return t.RGBA;if(1024===i)return t.LUMINANCE;if(1025===i)return t.LUMINANCE_ALPHA;if(i===Lt)return t.DEPTH_COMPONENT;if(i===It)return t.DEPTH_STENCIL;if(i===Ge)return r=e.get("EXT_sRGB"),null!==r?r.SRGB_ALPHA_EXT:null;if(1028===i)return t.RED;if(i===Dt)return t.RED_INTEGER;if(1030===i)return t.RG;if(i===Ut)return t.RG_INTEGER;if(i===Nt)return t.RGBA_INTEGER;if(i===Ot||i===Ft||i===Bt||i===zt)if(a===Ce){if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),null===r)return null;if(i===Ot)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Ft)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Bt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===zt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(r=e.get("WEBGL_compressed_texture_s3tc"),null===r)return null;if(i===Ot)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Ft)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Bt)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===zt)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(i===kt||i===Vt||i===Gt||i===Ht){if(r=e.get("WEBGL_compressed_texture_pvrtc"),null===r)return null;if(i===kt)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Vt)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Gt)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Ht)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(i===Wt)return r=e.get("WEBGL_compressed_texture_etc1"),null!==r?r.COMPRESSED_RGB_ETC1_WEBGL:null;if(i===qt||i===Xt){if(r=e.get("WEBGL_compressed_texture_etc"),null===r)return null;if(i===qt)return a===Ce?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===Xt)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}if(i===jt||i===Yt||i===Zt||i===Jt||i===Kt||i===$t||i===Qt||i===te||i===ee||i===ie||i===ne||i===se||i===re||i===ae){if(r=e.get("WEBGL_compressed_texture_astc"),null===r)return null;if(i===jt)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Yt)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Zt)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Jt)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Kt)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===$t)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Qt)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===te)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===ee)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===ie)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===ne)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===se)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===re)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===ae)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}if(i===oe||i===le||i===he){if(r=e.get("EXT_texture_compression_bptc"),null===r)return null;if(i===oe)return a===Ce?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===le)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===he)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(36283===i||i===ce||i===ue||i===de){if(r=e.get("EXT_texture_compression_rgtc"),null===r)return null;if(i===oe)return r.COMPRESSED_RED_RGTC1_EXT;if(i===ce)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===ue)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===de)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return i===Rt?n?t.UNSIGNED_INT_24_8:(r=e.get("WEBGL_depth_texture"),null!==r?r.UNSIGNED_INT_24_8_WEBGL:null):void 0!==t[i]?t[i]:null}}}class Oo extends Js{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}class Fo extends Fn{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Bo={type:"move"};class zo{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new Fo,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new Fo,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Ni,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Ni),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new Fo,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Ni,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Ni),this._grip}dispatchEvent(t){return null!==this._targetRay&&this._targetRay.dispatchEvent(t),null!==this._grip&&this._grip.dispatchEvent(t),null!==this._hand&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const i of t.hand.values())this._getHandJoint(e,i)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(t,e,i){let n=null,s=null,r=null;const a=this._targetRay,o=this._grip,l=this._hand;if(t&&"visible-blurred"!==e.session.visibilityState){if(l&&t.hand){r=!0;for(const r of t.hand.values()){const t=e.getJointPose(r,i),n=this._getHandJoint(l,r);null!==t&&(n.matrix.fromArray(t.transform.matrix),n.matrix.decompose(n.position,n.rotation,n.scale),n.matrixWorldNeedsUpdate=!0,n.jointRadius=t.radius),n.visible=null!==t}const n=l.joints["index-finger-tip"],s=l.joints["thumb-tip"],a=n.position.distanceTo(s.position),o=.02,h=.005;l.inputState.pinching&&a>o+h?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&a<=o-h&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==o&&t.gripSpace&&(s=e.getPose(t.gripSpace,i),null!==s&&(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));null!==a&&(n=e.getPose(t.targetRaySpace,i),null===n&&null!==s&&(n=s),null!==n&&(a.matrix.fromArray(n.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,n.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(n.linearVelocity)):a.hasLinearVelocity=!1,n.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(n.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Bo)))}return null!==a&&(a.visible=null!==n),null!==o&&(o.visible=null!==s),null!==l&&(l.visible=null!==r),this}_getHandJoint(t,e){if(void 0===t.joints[e.jointName]){const i=new Fo;i.matrixAutoUpdate=!1,i.visible=!1,t.joints[e.jointName]=i,t.add(i)}return t.joints[e.jointName]}}class ko extends qe{constructor(t,e){super();const i=this;let n=null,s=1,r=null,a="local-floor",o=1,l=null,h=null,c=null,u=null,d=null,p=null;const m=e.getContextAttributes();let f=null,g=null;const _=[],v=[],y=new ri;let x=null;const M=new Js;M.layers.enable(1),M.viewport=new Ri;const b=new Js;b.layers.enable(2),b.viewport=new Ri;const S=[M,b],w=new Oo;w.layers.enable(1),w.layers.enable(2);let T=null,E=null;function A(t){const e=v.indexOf(t.inputSource);if(-1===e)return;const i=_[e];void 0!==i&&(i.update(t.inputSource,t.frame,l||r),i.dispatchEvent({type:t.type,data:t.inputSource}))}function C(){n.removeEventListener("select",A),n.removeEventListener("selectstart",A),n.removeEventListener("selectend",A),n.removeEventListener("squeeze",A),n.removeEventListener("squeezestart",A),n.removeEventListener("squeezeend",A),n.removeEventListener("end",C),n.removeEventListener("inputsourceschange",R);for(let t=0;t<_.length;t++){const e=v[t];null!==e&&(v[t]=null,_[t].disconnect(e))}T=null,E=null,t.setRenderTarget(f),d=null,u=null,c=null,n=null,g=null,U.stop(),i.isPresenting=!1,t.setPixelRatio(x),t.setSize(y.width,y.height,!1),i.dispatchEvent({type:"sessionend"})}function R(t){for(let e=0;e<t.removed.length;e++){const i=t.removed[e],n=v.indexOf(i);n>=0&&(v[n]=null,_[n].disconnect(i))}for(let e=0;e<t.added.length;e++){const i=t.added[e];let n=v.indexOf(i);if(-1===n){for(let t=0;t<_.length;t++){if(t>=v.length){v.push(i),n=t;break}if(null===v[t]){v[t]=i,n=t;break}}if(-1===n)break}const s=_[n];s&&s.connect(i)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=_[t];return void 0===e&&(e=new zo,_[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=_[t];return void 0===e&&(e=new zo,_[t]=e),e.getGripSpace()},this.getHand=function(t){let e=_[t];return void 0===e&&(e=new zo,_[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){s=t,i.isPresenting},this.setReferenceSpaceType=function(t){a=t,i.isPresenting},this.getReferenceSpace=function(){return l||r},this.setReferenceSpace=function(t){l=t},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return c},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(h){if(n=h,null!==n){if(f=t.getRenderTarget(),n.addEventListener("select",A),n.addEventListener("selectstart",A),n.addEventListener("selectend",A),n.addEventListener("squeeze",A),n.addEventListener("squeezestart",A),n.addEventListener("squeezeend",A),n.addEventListener("end",C),n.addEventListener("inputsourceschange",R),!0!==m.xrCompatible&&await e.makeXRCompatible(),x=t.getPixelRatio(),t.getSize(y),void 0===n.renderState.layers||!1===t.capabilities.isWebGL2){const i={antialias:void 0!==n.renderState.layers||m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(n,e,i),n.updateRenderState({baseLayer:d}),t.setPixelRatio(1),t.setSize(d.framebufferWidth,d.framebufferHeight,!1),g=new Li(d.framebufferWidth,d.framebufferHeight,{format:Pt,type:Mt,colorSpace:t.outputColorSpace,stencilBuffer:m.stencil})}else{let i=null,r=null,a=null;m.depth&&(a=m.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,i=m.stencil?It:Lt,r=m.stencil?Rt:wt);const o={colorFormat:e.RGBA8,depthFormat:a,scaleFactor:s};c=new XRWebGLBinding(n,e),u=c.createProjectionLayer(o),n.updateRenderState({layers:[u]}),t.setPixelRatio(1),t.setSize(u.textureWidth,u.textureHeight,!1),g=new Li(u.textureWidth,u.textureHeight,{format:Pt,type:Mt,depthTexture:new qr(u.textureWidth,u.textureHeight,r,void 0,void 0,void 0,void 0,void 0,void 0,i),stencilBuffer:m.stencil,colorSpace:t.outputColorSpace,samples:m.antialias?4:0}),t.properties.get(g).__ignoreDepthValues=u.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(o),l=null,r=await n.requestReferenceSpace(a),U.setContext(n),U.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==n)return n.environmentBlendMode};const P=new Ni,L=new Ni;function I(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.copy(t.matrixWorld).invert()}this.updateCamera=function(t){if(null===n)return;w.near=b.near=M.near=t.near,w.far=b.far=M.far=t.far,T===w.near&&E===w.far||(n.updateRenderState({depthNear:w.near,depthFar:w.far}),T=w.near,E=w.far);const e=t.parent,i=w.cameras;I(w,e);for(let n=0;n<i.length;n++)I(i[n],e);2===i.length?function(t,e,i){P.setFromMatrixPosition(e.matrixWorld),L.setFromMatrixPosition(i.matrixWorld);const n=P.distanceTo(L),s=e.projectionMatrix.elements,r=i.projectionMatrix.elements,a=s[14]/(s[10]-1),o=s[14]/(s[10]+1),l=(s[9]+1)/s[5],h=(s[9]-1)/s[5],c=(s[8]-1)/s[0],u=(r[8]+1)/r[0],d=a*c,p=a*u,m=n/(-c+u),f=m*-c;e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(f),t.translateZ(m),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.copy(t.matrixWorld).invert();const g=a+m,_=o+m,v=d-f,y=p+(n-f),x=l*o/_*g,M=h*o/_*g;t.projectionMatrix.makePerspective(v,y,x,M,g,_),t.projectionMatrixInverse.copy(t.projectionMatrix).invert()}(w,M,b):w.projectionMatrix.copy(M.projectionMatrix),function(t,e,i){null===i?t.matrix.copy(e.matrixWorld):(t.matrix.copy(i.matrixWorld),t.matrix.invert(),t.matrix.multiply(e.matrixWorld)),t.matrix.decompose(t.position,t.quaternion,t.scale),t.updateMatrixWorld(!0),t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse),t.isPerspectiveCamera&&(t.fov=2*Ze*Math.atan(1/t.projectionMatrix.elements[5]),t.zoom=1)}(t,w,e)},this.getCamera=function(){return w},this.getFoveation=function(){if(null!==u||null!==d)return o},this.setFoveation=function(t){o=t,null!==u&&(u.fixedFoveation=t),null!==d&&void 0!==d.fixedFoveation&&(d.fixedFoveation=t)};let D=null;const U=new lr;U.setAnimationLoop(function(e,n){if(h=n.getViewerPose(l||r),p=n,null!==h){const e=h.views;null!==d&&(t.setRenderTargetFramebuffer(g,d.framebuffer),t.setRenderTarget(g));let i=!1;e.length!==w.cameras.length&&(w.cameras.length=0,i=!0);for(let n=0;n<e.length;n++){const s=e[n];let r=null;if(null!==d)r=d.getViewport(s);else{const e=c.getViewSubImage(u,s);r=e.viewport,0===n&&(t.setRenderTargetTextures(g,e.colorTexture,u.ignoreDepthValues?void 0:e.depthStencilTexture),t.setRenderTarget(g))}let a=S[n];void 0===a&&(a=new Js,a.layers.enable(n),a.viewport=new Ri,S[n]=a),a.matrix.fromArray(s.transform.matrix),a.matrix.decompose(a.position,a.quaternion,a.scale),a.projectionMatrix.fromArray(s.projectionMatrix),a.projectionMatrixInverse.copy(a.projectionMatrix).invert(),a.viewport.set(r.x,r.y,r.width,r.height),0===n&&(w.matrix.copy(a.matrix),w.matrix.decompose(w.position,w.quaternion,w.scale)),!0===i&&w.cameras.push(a)}}for(let t=0;t<_.length;t++){const e=v[t],i=_[t];null!==e&&void 0!==i&&i.update(e,n,l||r)}D&&D(e,n),n.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:n}),p=null}),this.setAnimationLoop=function(t){D=t},this.dispose=function(){}}}function Vo(t,e){function i(t,e){!0===t.matrixAutoUpdate&&t.updateMatrix(),e.value.copy(t.matrix)}function n(n,s){n.opacity.value=s.opacity,s.color&&n.diffuse.value.copy(s.color),s.emissive&&n.emissive.value.copy(s.emissive).multiplyScalar(s.emissiveIntensity),s.map&&(n.map.value=s.map,i(s.map,n.mapTransform)),s.alphaMap&&(n.alphaMap.value=s.alphaMap,i(s.alphaMap,n.alphaMapTransform)),s.bumpMap&&(n.bumpMap.value=s.bumpMap,i(s.bumpMap,n.bumpMapTransform),n.bumpScale.value=s.bumpScale,1===s.side&&(n.bumpScale.value*=-1)),s.normalMap&&(n.normalMap.value=s.normalMap,i(s.normalMap,n.normalMapTransform),n.normalScale.value.copy(s.normalScale),1===s.side&&n.normalScale.value.negate()),s.displacementMap&&(n.displacementMap.value=s.displacementMap,i(s.displacementMap,n.displacementMapTransform),n.displacementScale.value=s.displacementScale,n.displacementBias.value=s.displacementBias),s.emissiveMap&&(n.emissiveMap.value=s.emissiveMap,i(s.emissiveMap,n.emissiveMapTransform)),s.specularMap&&(n.specularMap.value=s.specularMap,i(s.specularMap,n.specularMapTransform)),s.alphaTest>0&&(n.alphaTest.value=s.alphaTest);const r=e.get(s).envMap;if(r&&(n.envMap.value=r,n.flipEnvMap.value=r.isCubeTexture&&!1===r.isRenderTargetTexture?-1:1,n.reflectivity.value=s.reflectivity,n.ior.value=s.ior,n.refractionRatio.value=s.refractionRatio),s.lightMap){n.lightMap.value=s.lightMap;const e=!0===t._useLegacyLights?Math.PI:1;n.lightMapIntensity.value=s.lightMapIntensity*e,i(s.lightMap,n.lightMapTransform)}s.aoMap&&(n.aoMap.value=s.aoMap,n.aoMapIntensity.value=s.aoMapIntensity,i(s.aoMap,n.aoMapTransform))}return{refreshFogUniforms(e,i){i.color.getRGB(e.fogColor.value,Xs(t)),i.isFog?(e.fogNear.value=i.near,e.fogFar.value=i.far):i.isFogExp2&&(e.fogDensity.value=i.density)},refreshMaterialUniforms(t,s,r,a,o){s.isMeshBasicMaterial||s.isMeshLambertMaterial?n(t,s):s.isMeshToonMaterial?(n(t,s),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(t,s)):s.isMeshPhongMaterial?(n(t,s),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4)}(t,s)):s.isMeshStandardMaterial?(n(t,s),function(t,n){t.metalness.value=n.metalness,n.metalnessMap&&(t.metalnessMap.value=n.metalnessMap,i(n.metalnessMap,t.metalnessMapTransform)),t.roughness.value=n.roughness,n.roughnessMap&&(t.roughnessMap.value=n.roughnessMap,i(n.roughnessMap,t.roughnessMapTransform)),e.get(n).envMap&&(t.envMapIntensity.value=n.envMapIntensity)}(t,s),s.isMeshPhysicalMaterial&&function(t,e,n){t.ior.value=e.ior,e.sheen>0&&(t.sheenColor.value.copy(e.sheenColor).multiplyScalar(e.sheen),t.sheenRoughness.value=e.sheenRoughness,e.sheenColorMap&&(t.sheenColorMap.value=e.sheenColorMap,i(e.sheenColorMap,t.sheenColorMapTransform)),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap,i(e.sheenRoughnessMap,t.sheenRoughnessMapTransform))),e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap,i(e.clearcoatMap,t.clearcoatMapTransform)),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap,i(e.clearcoatRoughnessMap,t.clearcoatRoughnessMapTransform)),e.clearcoatNormalMap&&(t.clearcoatNormalMap.value=e.clearcoatNormalMap,i(e.clearcoatNormalMap,t.clearcoatNormalMapTransform),t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),1===e.side&&t.clearcoatNormalScale.value.negate())),e.iridescence>0&&(t.iridescence.value=e.iridescence,t.iridescenceIOR.value=e.iridescenceIOR,t.iridescenceThicknessMinimum.value=e.iridescenceThicknessRange[0],t.iridescenceThicknessMaximum.value=e.iridescenceThicknessRange[1],e.iridescenceMap&&(t.iridescenceMap.value=e.iridescenceMap,i(e.iridescenceMap,t.iridescenceMapTransform)),e.iridescenceThicknessMap&&(t.iridescenceThicknessMap.value=e.iridescenceThicknessMap,i(e.iridescenceThicknessMap,t.iridescenceThicknessMapTransform))),e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=n.texture,t.transmissionSamplerSize.value.set(n.width,n.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap,i(e.transmissionMap,t.transmissionMapTransform)),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap,i(e.thicknessMap,t.thicknessMapTransform)),t.attenuationDistance.value=e.attenuationDistance,t.attenuationColor.value.copy(e.attenuationColor)),e.anisotropy>0&&(t.anisotropyVector.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation)),e.anisotropyMap&&(t.anisotropyMap.value=e.anisotropyMap,i(e.anisotropyMap,t.anisotropyMapTransform))),t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap,i(e.specularColorMap,t.specularColorMapTransform)),e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap,i(e.specularIntensityMap,t.specularIntensityMapTransform))}(t,s,o)):s.isMeshMatcapMaterial?(n(t,s),function(t,e){e.matcap&&(t.matcap.value=e.matcap)}(t,s)):s.isMeshDepthMaterial?n(t,s):s.isMeshDistanceMaterial?(n(t,s),function(t,i){const n=e.get(i).light;t.referencePosition.value.setFromMatrixPosition(n.matrixWorld),t.nearDistance.value=n.shadow.camera.near,t.farDistance.value=n.shadow.camera.far}(t,s)):s.isMeshNormalMaterial?n(t,s):s.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,e.map&&(t.map.value=e.map,i(e.map,t.mapTransform))}(t,s),s.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,s)):s.isPointsMaterial?function(t,e,n,s){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*n,t.scale.value=.5*s,e.map&&(t.map.value=e.map,i(e.map,t.uvTransform)),e.alphaMap&&(t.alphaMap.value=e.alphaMap,i(e.alphaMap,t.alphaMapTransform)),e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,s,r,a):s.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map,i(e.map,t.mapTransform)),e.alphaMap&&(t.alphaMap.value=e.alphaMap,i(e.alphaMap,t.alphaMapTransform)),e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,s):s.isShadowMaterial?(t.color.value.copy(s.color),t.opacity.value=s.opacity):s.isShaderMaterial&&(s.uniformsNeedUpdate=!1)}}}function Go(t,e,i,n){let s={},r={},a=[];const o=i.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(t,e,i,n){const s=t.value,r=e+"_"+i;if(void 0===n[r])return n[r]="number"==typeof s||"boolean"==typeof s?s:s.clone(),!0;{const t=n[r];if("number"==typeof s||"boolean"==typeof s){if(t!==s)return n[r]=s,!0}else if(!1===t.equals(s))return t.copy(s),!0}return!1}function h(t){const e={boundary:0,storage:0};return"number"==typeof t||"boolean"==typeof t?(e.boundary=4,e.storage=4):t.isVector2?(e.boundary=8,e.storage=8):t.isVector3||t.isColor?(e.boundary=16,e.storage=12):t.isVector4?(e.boundary=16,e.storage=16):t.isMatrix3?(e.boundary=48,e.storage=48):t.isMatrix4?(e.boundary=64,e.storage=64):t.isTexture,e}function c(e){const i=e.target;i.removeEventListener("dispose",c);const n=a.indexOf(i.__bindingPointIndex);a.splice(n,1),t.deleteBuffer(s[i.id]),delete s[i.id],delete r[i.id]}return{bind(t,e){const i=e.program;n.uniformBlockBinding(t,i)},update(i,u){let d=s[i.id];void 0===d&&(function(t){const e=t.uniforms;let i=0;for(let s=0,r=e.length;s<r;s++){const t=Array.isArray(e[s])?e[s]:[e[s]];for(let e=0,n=t.length;e<n;e++){const n=t[e],s=Array.isArray(n.value)?n.value:[n.value];for(let t=0,e=s.length;t<e;t++){const e=h(s[t]),r=i%16;0!==r&&16-r<e.boundary&&(i+=16-r),n.__data=new Float32Array(e.storage/Float32Array.BYTES_PER_ELEMENT),n.__offset=i,i+=e.storage}}}const n=i%16;n>0&&(i+=16-n),t.__size=i,t.__cache={}}(i),d=function(e){const i=function(){for(let t=0;t<o;t++)if(-1===a.indexOf(t))return a.push(t),t;return 0}();e.__bindingPointIndex=i;const n=t.createBuffer(),s=e.__size,r=e.usage;return t.bindBuffer(t.UNIFORM_BUFFER,n),t.bufferData(t.UNIFORM_BUFFER,s,r),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,i,n),n}(i),s[i.id]=d,i.addEventListener("dispose",c));const p=u.program;n.updateUBOMapping(i,p);const m=e.render.frame;r[i.id]!==m&&(function(e){const i=s[e.id],n=e.uniforms,r=e.__cache;t.bindBuffer(t.UNIFORM_BUFFER,i);for(let s=0,a=n.length;s<a;s++){const e=Array.isArray(n[s])?n[s]:[n[s]];for(let i=0,n=e.length;i<n;i++){const n=e[i];if(!0===l(n,s,i,r)){const e=n.__offset,i=Array.isArray(n.value)?n.value:[n.value];let s=0;for(let r=0;r<i.length;r++){const a=i[r],o=h(a);"number"==typeof a||"boolean"==typeof a?(n.__data[0]=a,t.bufferSubData(t.UNIFORM_BUFFER,e+s,n.__data)):a.isMatrix3?(n.__data[0]=a.elements[0],n.__data[1]=a.elements[1],n.__data[2]=a.elements[2],n.__data[3]=0,n.__data[4]=a.elements[3],n.__data[5]=a.elements[4],n.__data[6]=a.elements[5],n.__data[7]=0,n.__data[8]=a.elements[6],n.__data[9]=a.elements[7],n.__data[10]=a.elements[8],n.__data[11]=0):(a.toArray(n.__data,s),s+=o.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,e,n.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}(i),r[i.id]=m)},dispose(){for(const e in s)t.deleteBuffer(s[e]);a=[],s={},r={}}}}class Ho{constructor(t={}){const{canvas:e=di(),context:i=null,depth:n=!0,stencil:s=!0,alpha:r=!1,antialias:a=!1,premultipliedAlpha:o=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:c=!1}=t;let u;this.isWebGLRenderer=!0,u=null!==i?i.getContextAttributes().alpha:r;const d=new Uint32Array(4),p=new Int32Array(4);let m=null,f=null;const g=[],_=[];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=Se,this._useLegacyLights=!1,this.toneMapping=0,this.toneMappingExposure=1;const v=this;let y=!1,x=0,M=0,b=null,S=-1,w=null;const T=new Ri,E=new Ri;let A=null;const C=new ts(0);let R=0,P=e.width,L=e.height,I=1,D=null,U=null;const N=new Ri(0,0,P,L),F=new Ri(0,0,P,L);let B=!1;const z=new or;let k=!1,V=!1,G=null;const H=new dn,W=new ri,q=new Ni,X={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function j(){return null===b?I:1}let Y,Z,J,K,$,Q,tt,et,it,nt,st,rt,at,ot,lt,ht,ct,ut,dt,pt,mt,ft,gt,_t,vt=i;function yt(t,i){for(let n=0;n<t.length;n++){const s=t[n],r=e.getContext(s,i);if(null!==r)return r}return null}try{const t={alpha:!0,depth:n,stencil:s,antialias:a,premultipliedAlpha:o,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:c};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${O}`),e.addEventListener("webglcontextlost",It,!1),e.addEventListener("webglcontextrestored",Ot,!1),e.addEventListener("webglcontextcreationerror",Ft,!1),null===vt){const e=["webgl2","webgl","experimental-webgl"];if(!0===v.isWebGL1Renderer&&e.shift(),vt=yt(e,t),null===vt)throw yt(e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}"undefined"!=typeof WebGLRenderingContext&&WebGLRenderingContext,void 0===vt.getShaderPrecisionFormat&&(vt.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(Kt){throw Kt}function St(){Y=new Fr(vt),Z=new vr(vt,Y,t),Y.init(Z),ft=new No(vt,Y,Z),J=new Do(vt,Y,Z),K=new kr(vt),$=new yo,Q=new Uo(vt,Y,J,$,Z,ft,K),tt=new xr(v),et=new Or(v),it=new hr(vt,Z),gt=new gr(vt,Y,it,Z),nt=new Br(vt,it,K,gt),st=new Wr(vt,nt,it,K),dt=new Hr(vt,Z,Q),ht=new yr($),rt=new vo(v,tt,et,Y,Z,gt,ht),at=new Vo(v,$),ot=new So,lt=new Ro(Y,Z),ut=new fr(v,tt,et,J,st,u,o),ct=new Io(v,st,Z),_t=new Go(vt,K,Z,J),pt=new _r(vt,Y,K,Z),mt=new zr(vt,Y,K,Z),K.programs=rt.programs,v.capabilities=Z,v.extensions=Y,v.properties=$,v.renderLists=ot,v.shadowMap=ct,v.state=J,v.info=K}St();const Lt=new ko(v,vt);function It(t){t.preventDefault(),y=!0}function Ot(){y=!1;const t=K.autoReset,e=ct.enabled,i=ct.autoUpdate,n=ct.needsUpdate,s=ct.type;St(),K.autoReset=t,ct.enabled=e,ct.autoUpdate=i,ct.needsUpdate=n,ct.type=s}function Ft(t){}function Bt(t){const e=t.target;e.removeEventListener("dispose",Bt),function(t){(function(t){const e=$.get(t).programs;void 0!==e&&(e.forEach(function(t){rt.releaseProgram(t)}),t.isShaderMaterial&&rt.releaseShaderCache(t))})(t),$.remove(t)}(e)}function zt(t,e,i){!0===t.transparent&&2===t.side&&!1===t.forceSinglePass?(t.side=1,t.needsUpdate=!0,Yt(t,e,i),t.side=0,t.needsUpdate=!0,Yt(t,e,i),t.side=2):Yt(t,e,i)}this.xr=Lt,this.getContext=function(){return vt},this.getContextAttributes=function(){return vt.getContextAttributes()},this.forceContextLoss=function(){const t=Y.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){const t=Y.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return I},this.setPixelRatio=function(t){void 0!==t&&(I=t,this.setSize(P,L,!1))},this.getSize=function(t){return t.set(P,L)},this.setSize=function(t,i,n=!0){Lt.isPresenting||(P=t,L=i,e.width=Math.floor(t*I),e.height=Math.floor(i*I),!0===n&&(e.style.width=t+"px",e.style.height=i+"px"),this.setViewport(0,0,t,i))},this.getDrawingBufferSize=function(t){return t.set(P*I,L*I).floor()},this.setDrawingBufferSize=function(t,i,n){P=t,L=i,I=n,e.width=Math.floor(t*n),e.height=Math.floor(i*n),this.setViewport(0,0,t,i)},this.getCurrentViewport=function(t){return t.copy(T)},this.getViewport=function(t){return t.copy(N)},this.setViewport=function(t,e,i,n){t.isVector4?N.set(t.x,t.y,t.z,t.w):N.set(t,e,i,n),J.viewport(T.copy(N).multiplyScalar(I).floor())},this.getScissor=function(t){return t.copy(F)},this.setScissor=function(t,e,i,n){t.isVector4?F.set(t.x,t.y,t.z,t.w):F.set(t,e,i,n),J.scissor(E.copy(F).multiplyScalar(I).floor())},this.getScissorTest=function(){return B},this.setScissorTest=function(t){J.setScissorTest(B=t)},this.setOpaqueSort=function(t){D=t},this.setTransparentSort=function(t){U=t},this.getClearColor=function(t){return t.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(t=!0,e=!0,i=!0){let n=0;if(t){let t=!1;if(null!==b){const e=b.texture.format;t=e===Nt||e===Ut||e===Dt}if(t){const t=b.texture.type,e=t===Mt||t===wt||t===bt||t===Rt||t===At||t===Ct,i=ut.getClearColor(),n=ut.getClearAlpha(),s=i.r,r=i.g,a=i.b;e?(d[0]=s,d[1]=r,d[2]=a,d[3]=n,vt.clearBufferuiv(vt.COLOR,0,d)):(p[0]=s,p[1]=r,p[2]=a,p[3]=n,vt.clearBufferiv(vt.COLOR,0,p))}else n|=vt.COLOR_BUFFER_BIT}e&&(n|=vt.DEPTH_BUFFER_BIT),i&&(n|=vt.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),vt.clear(n)},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",It,!1),e.removeEventListener("webglcontextrestored",Ot,!1),e.removeEventListener("webglcontextcreationerror",Ft,!1),ot.dispose(),lt.dispose(),$.dispose(),tt.dispose(),et.dispose(),st.dispose(),gt.dispose(),_t.dispose(),rt.dispose(),Lt.dispose(),Lt.removeEventListener("sessionstart",Vt),Lt.removeEventListener("sessionend",Gt),G&&(G.dispose(),G=null),Ht.stop()},this.renderBufferDirect=function(t,e,i,n,s,r){null===e&&(e=X);const a=s.isMesh&&s.matrixWorld.determinant()<0,o=function(t,e,i,n,s){!0!==e.isScene&&(e=X),Q.resetTextureUnits();const r=e.fog,a=n.isMeshStandardMaterial?e.environment:null,o=null===b?v.outputColorSpace:!0===b.isXRRenderTarget?b.texture.colorSpace:we,l=(n.isMeshStandardMaterial?et:tt).get(n.envMap||a),h=!0===n.vertexColors&&!!i.attributes.color&&4===i.attributes.color.itemSize,c=!!i.attributes.tangent&&(!!n.normalMap||n.anisotropy>0),u=!!i.morphAttributes.position,d=!!i.morphAttributes.normal,p=!!i.morphAttributes.color;let m=0;n.toneMapped&&(null!==b&&!0!==b.isXRRenderTarget||(m=v.toneMapping));const g=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,_=void 0!==g?g.length:0,y=$.get(n),x=f.state.lights;if(!0===k&&(!0===V||t!==w)){const e=t===w&&n.id===S;ht.setState(n,t,e)}let M=!1;n.version===y.__version?y.needsLights&&y.lightsStateVersion!==x.state.version||y.outputColorSpace!==o||s.isBatchedMesh&&!1===y.batching?M=!0:s.isBatchedMesh||!0!==y.batching?s.isInstancedMesh&&!1===y.instancing?M=!0:s.isInstancedMesh||!0!==y.instancing?s.isSkinnedMesh&&!1===y.skinning?M=!0:s.isSkinnedMesh||!0!==y.skinning?s.isInstancedMesh&&!0===y.instancingColor&&null===s.instanceColor||s.isInstancedMesh&&!1===y.instancingColor&&null!==s.instanceColor||y.envMap!==l||!0===n.fog&&y.fog!==r?M=!0:void 0===y.numClippingPlanes||y.numClippingPlanes===ht.numPlanes&&y.numIntersection===ht.numIntersection?(y.vertexAlphas!==h||y.vertexTangents!==c||y.morphTargets!==u||y.morphNormals!==d||y.morphColors!==p||y.toneMapping!==m||!0===Z.isWebGL2&&y.morphTargetsCount!==_)&&(M=!0):M=!0:M=!0:M=!0:M=!0:(M=!0,y.__version=n.version);let T=y.currentProgram;!0===M&&(T=Yt(n,e,s));let E=!1,A=!1,C=!1;const R=T.getUniforms(),P=y.uniforms;if(J.useProgram(T.program)&&(E=!0,A=!0,C=!0),n.id!==S&&(S=n.id,A=!0),E||w!==t){R.setValue(vt,"projectionMatrix",t.projectionMatrix),R.setValue(vt,"viewMatrix",t.matrixWorldInverse);const e=R.map.cameraPosition;void 0!==e&&e.setValue(vt,q.setFromMatrixPosition(t.matrixWorld)),Z.logarithmicDepthBuffer&&R.setValue(vt,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&R.setValue(vt,"isOrthographic",!0===t.isOrthographicCamera),w!==t&&(w=t,A=!0,C=!0)}if(s.isSkinnedMesh){R.setOptional(vt,s,"bindMatrix"),R.setOptional(vt,s,"bindMatrixInverse");const t=s.skeleton;t&&Z.floatVertexTextures&&(null===t.boneTexture&&t.computeBoneTexture(),R.setValue(vt,"boneTexture",t.boneTexture,Q))}s.isBatchedMesh&&(R.setOptional(vt,s,"batchingTexture"),R.setValue(vt,"batchingTexture",s._matricesTexture,Q));const D=i.morphAttributes;var U,N;if((void 0!==D.position||void 0!==D.normal||void 0!==D.color&&!0===Z.isWebGL2)&&dt.update(s,i,T),(A||y.receiveShadow!==s.receiveShadow)&&(y.receiveShadow=s.receiveShadow,R.setValue(vt,"receiveShadow",s.receiveShadow)),n.isMeshGouraudMaterial&&null!==n.envMap&&(P.envMap.value=l,P.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1),A&&(R.setValue(vt,"toneMappingExposure",v.toneMappingExposure),y.needsLights&&(N=C,(U=P).ambientLightColor.needsUpdate=N,U.lightProbe.needsUpdate=N,U.directionalLights.needsUpdate=N,U.directionalLightShadows.needsUpdate=N,U.pointLights.needsUpdate=N,U.pointLightShadows.needsUpdate=N,U.spotLights.needsUpdate=N,U.spotLightShadows.needsUpdate=N,U.rectAreaLights.needsUpdate=N,U.hemisphereLights.needsUpdate=N),r&&!0===n.fog&&at.refreshFogUniforms(P,r),at.refreshMaterialUniforms(P,n,I,L,G),Ja.upload(vt,Zt(y),P,Q)),n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(Ja.upload(vt,Zt(y),P,Q),n.uniformsNeedUpdate=!1),n.isSpriteMaterial&&R.setValue(vt,"center",s.center),R.setValue(vt,"modelViewMatrix",s.modelViewMatrix),R.setValue(vt,"normalMatrix",s.normalMatrix),R.setValue(vt,"modelMatrix",s.matrixWorld),n.isShaderMaterial||n.isRawShaderMaterial){const t=n.uniformsGroups;for(let e=0,i=t.length;e<i;e++)if(Z.isWebGL2){const i=t[e];_t.update(i,T),_t.bind(i,T)}}return T}(t,e,i,n,s);J.setMaterial(n,a);let l=i.index,h=1;if(!0===n.wireframe){if(l=nt.getWireframeAttribute(i),void 0===l)return;h=2}const c=i.drawRange,u=i.attributes.position;let d=c.start*h,p=(c.start+c.count)*h;null!==r&&(d=Math.max(d,r.start*h),p=Math.min(p,(r.start+r.count)*h)),null!==l?(d=Math.max(d,0),p=Math.min(p,l.count)):null!=u&&(d=Math.max(d,0),p=Math.min(p,u.count));const m=p-d;if(m<0||m===1/0)return;let g;gt.setup(s,n,o,i,l);let _=pt;if(null!==l&&(g=it.get(l),_=mt,_.setIndex(g)),s.isMesh)!0===n.wireframe?(J.setLineWidth(n.wireframeLinewidth*j()),_.setMode(vt.LINES)):_.setMode(vt.TRIANGLES);else if(s.isLine){let t=n.linewidth;void 0===t&&(t=1),J.setLineWidth(t*j()),s.isLineSegments?_.setMode(vt.LINES):s.isLineLoop?_.setMode(vt.LINE_LOOP):_.setMode(vt.LINE_STRIP)}else s.isPoints?_.setMode(vt.POINTS):s.isSprite&&_.setMode(vt.TRIANGLES);if(s.isBatchedMesh)_.renderMultiDraw(s._multiDrawStarts,s._multiDrawCounts,s._multiDrawCount);else if(s.isInstancedMesh)_.renderInstances(d,m,s.count);else if(i.isInstancedBufferGeometry){const t=void 0!==i._maxInstanceCount?i._maxInstanceCount:1/0,e=Math.min(i.instanceCount,t);_.renderInstances(d,m,e)}else _.render(d,m)},this.compile=function(t,e,i=null){null===i&&(i=t),f=lt.get(i),f.init(),_.push(f),i.traverseVisible(function(t){t.isLight&&t.layers.test(e.layers)&&(f.pushLight(t),t.castShadow&&f.pushShadow(t))}),t!==i&&t.traverseVisible(function(t){t.isLight&&t.layers.test(e.layers)&&(f.pushLight(t),t.castShadow&&f.pushShadow(t))}),f.setupLights(v._useLegacyLights);const n=new Set;return t.traverse(function(t){const e=t.material;if(e)if(Array.isArray(e))for(let s=0;s<e.length;s++){const r=e[s];zt(r,i,t),n.add(r)}else zt(e,i,t),n.add(e)}),_.pop(),f=null,n},this.compileAsync=function(t,e,i=null){const n=this.compile(t,e,i);return new Promise(e=>{function i(){n.forEach(function(t){$.get(t).currentProgram.isReady()&&n.delete(t)}),0!==n.size?setTimeout(i,10):e(t)}null!==Y.get("KHR_parallel_shader_compile")?i():setTimeout(i,10)})};let kt=null;function Vt(){Ht.stop()}function Gt(){Ht.start()}const Ht=new lr;function Wt(t,e,i,n){if(!1===t.visible)return;if(t.layers.test(e.layers))if(t.isGroup)i=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLight)f.pushLight(t),t.castShadow&&f.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||z.intersectsSprite(t)){n&&q.setFromMatrixPosition(t.matrixWorld).applyMatrix4(H);const e=st.update(t),s=t.material;s.visible&&m.push(t,e,s,i,q.z,null)}}else if((t.isMesh||t.isLine||t.isPoints)&&(!t.frustumCulled||z.intersectsObject(t))){const e=st.update(t),s=t.material;if(n&&(void 0!==t.boundingSphere?(null===t.boundingSphere&&t.computeBoundingSphere(),q.copy(t.boundingSphere.center)):(null===e.boundingSphere&&e.computeBoundingSphere(),q.copy(e.boundingSphere.center)),q.applyMatrix4(t.matrixWorld).applyMatrix4(H)),Array.isArray(s)){const n=e.groups;for(let r=0,a=n.length;r<a;r++){const a=n[r],o=s[a.materialIndex];o&&o.visible&&m.push(t,e,o,i,q.z,a)}}else s.visible&&m.push(t,e,s,i,q.z,null)}const s=t.children;for(let r=0,a=s.length;r<a;r++)Wt(s[r],e,i,n)}function qt(t,e,i,n){const s=t.opaque,r=t.transmissive,a=t.transparent;f.setupLightsView(i),!0===k&&ht.setGlobalState(v.clippingPlanes,i),r.length>0&&function(t,e,i,n){if(null!==(!0===i.isScene?i.overrideMaterial:null))return;const s=Z.isWebGL2;null===G&&(G=new Li(1,1,{generateMipmaps:!0,type:Y.has("EXT_color_buffer_half_float")?Et:Mt,minFilter:xt,samples:s?4:0})),v.getDrawingBufferSize(W),s?G.setSize(W.x,W.y):G.setSize(ei(W.x),ei(W.y));const r=v.getRenderTarget();v.setRenderTarget(G),v.getClearColor(C),R=v.getClearAlpha(),R<1&&v.setClearColor(16777215,.5),v.clear();const a=v.toneMapping;v.toneMapping=0,Xt(t,i,n),Q.updateMultisampleRenderTarget(G),Q.updateRenderTargetMipmap(G);let o=!1;for(let l=0,h=e.length;l<h;l++){const t=e[l],s=t.object,r=t.geometry,a=t.material,h=t.group;if(2===a.side&&s.layers.test(n.layers)){const t=a.side;a.side=1,a.needsUpdate=!0,jt(s,i,n,r,a,h),a.side=t,a.needsUpdate=!0,o=!0}}!0===o&&(Q.updateMultisampleRenderTarget(G),Q.updateRenderTargetMipmap(G)),v.setRenderTarget(r),v.setClearColor(C,R),v.toneMapping=a}(s,r,e,i),n&&J.viewport(T.copy(n)),s.length>0&&Xt(s,e,i),r.length>0&&Xt(r,e,i),a.length>0&&Xt(a,e,i),J.buffers.depth.setTest(!0),J.buffers.depth.setMask(!0),J.buffers.color.setMask(!0),J.setPolygonOffset(!1)}function Xt(t,e,i){const n=!0===e.isScene?e.overrideMaterial:null;for(let s=0,r=t.length;s<r;s++){const r=t[s],a=r.object,o=r.geometry,l=null===n?r.material:n,h=r.group;a.layers.test(i.layers)&&jt(a,e,i,o,l,h)}}function jt(t,e,i,n,s,r){t.onBeforeRender(v,e,i,n,s,r),t.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),s.onBeforeRender(v,e,i,n,t,r),!0===s.transparent&&2===s.side&&!1===s.forceSinglePass?(s.side=1,s.needsUpdate=!0,v.renderBufferDirect(i,e,n,s,t,r),s.side=0,s.needsUpdate=!0,v.renderBufferDirect(i,e,n,s,t,r),s.side=2):v.renderBufferDirect(i,e,n,s,t,r),t.onAfterRender(v,e,i,n,s,r)}function Yt(t,e,i){!0!==e.isScene&&(e=X);const n=$.get(t),s=f.state.lights,r=f.state.shadowsArray,a=s.state.version,o=rt.getParameters(t,s.state,r,e,i),l=rt.getProgramCacheKey(o);let h=n.programs;n.environment=t.isMeshStandardMaterial?e.environment:null,n.fog=e.fog,n.envMap=(t.isMeshStandardMaterial?et:tt).get(t.envMap||n.environment),void 0===h&&(t.addEventListener("dispose",Bt),h=new Map,n.programs=h);let c=h.get(l);if(void 0!==c){if(n.currentProgram===c&&n.lightsStateVersion===a)return Jt(t,o),c}else o.uniforms=rt.getUniforms(t),t.onBuild(i,o,v),t.onBeforeCompile(o,v),c=rt.acquireProgram(o,l),h.set(l,c),n.uniforms=o.uniforms;const u=n.uniforms;return(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(u.clippingPlanes=ht.uniform),Jt(t,o),n.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshToonMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),n.lightsStateVersion=a,n.needsLights&&(u.ambientLightColor.value=s.state.ambient,u.lightProbe.value=s.state.probe,u.directionalLights.value=s.state.directional,u.directionalLightShadows.value=s.state.directionalShadow,u.spotLights.value=s.state.spot,u.spotLightShadows.value=s.state.spotShadow,u.rectAreaLights.value=s.state.rectArea,u.ltc_1.value=s.state.rectAreaLTC1,u.ltc_2.value=s.state.rectAreaLTC2,u.pointLights.value=s.state.point,u.pointLightShadows.value=s.state.pointShadow,u.hemisphereLights.value=s.state.hemi,u.directionalShadowMap.value=s.state.directionalShadowMap,u.directionalShadowMatrix.value=s.state.directionalShadowMatrix,u.spotShadowMap.value=s.state.spotShadowMap,u.spotLightMatrix.value=s.state.spotLightMatrix,u.spotLightMap.value=s.state.spotLightMap,u.pointShadowMap.value=s.state.pointShadowMap,u.pointShadowMatrix.value=s.state.pointShadowMatrix),n.currentProgram=c,n.uniformsList=null,c}function Zt(t){if(null===t.uniformsList){const e=t.currentProgram.getUniforms();t.uniformsList=Ja.seqWithValue(e.seq,t.uniforms)}return t.uniformsList}function Jt(t,e){const i=$.get(t);i.outputColorSpace=e.outputColorSpace,i.batching=e.batching,i.instancing=e.instancing,i.instancingColor=e.instancingColor,i.skinning=e.skinning,i.morphTargets=e.morphTargets,i.morphNormals=e.morphNormals,i.morphColors=e.morphColors,i.morphTargetsCount=e.morphTargetsCount,i.numClippingPlanes=e.numClippingPlanes,i.numIntersection=e.numClipIntersection,i.vertexAlphas=e.vertexAlphas,i.vertexTangents=e.vertexTangents,i.toneMapping=e.toneMapping}Ht.setAnimationLoop(function(t){kt&&kt(t)}),"undefined"!=typeof self&&Ht.setContext(self),this.setAnimationLoop=function(t){kt=t,Lt.setAnimationLoop(t),null===t?Ht.stop():Ht.start()},Lt.addEventListener("sessionstart",Vt),Lt.addEventListener("sessionend",Gt),this.render=function(t,e){if(void 0!==e&&!0!==e.isCamera)return;if(!0===y)return;!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),null===e.parent&&!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),!0===Lt.enabled&&!0===Lt.isPresenting&&(!0===Lt.cameraAutoUpdate&&Lt.updateCamera(e),e=Lt.getCamera()),!0===t.isScene&&t.onBeforeRender(v,t,e,b),f=lt.get(t,_.length),f.init(),_.push(f),H.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),z.setFromProjectionMatrix(H),V=this.localClippingEnabled,k=ht.init(this.clippingPlanes,V),m=ot.get(t,g.length),m.init(),g.push(m),Wt(t,e,0,v.sortObjects),m.finish(),!0===v.sortObjects&&m.sort(D,U),this.info.render.frame++,!0===k&&ht.beginShadows();const i=f.state.shadowsArray;if(ct.render(i,t,e),!0===k&&ht.endShadows(),!0===this.info.autoReset&&this.info.reset(),ut.render(m,t),f.setupLights(v._useLegacyLights),e.isArrayCamera){const i=e.cameras;for(let e=0,n=i.length;e<n;e++){const n=i[e];qt(m,t,n,n.viewport)}}else qt(m,t,e);null!==b&&(Q.updateMultisampleRenderTarget(b),Q.updateRenderTargetMipmap(b)),!0===t.isScene&&t.onAfterRender(v,t,e),gt.resetDefaultState(),S=-1,w=null,_.pop(),f=_.length>0?_[_.length-1]:null,g.pop(),m=g.length>0?g[g.length-1]:null},this.getActiveCubeFace=function(){return x},this.getActiveMipmapLevel=function(){return M},this.getRenderTarget=function(){return b},this.setRenderTargetTextures=function(t,e,i){$.get(t.texture).__webglTexture=e,$.get(t.depthTexture).__webglTexture=i;const n=$.get(t);n.__hasExternalTextures=!0,n.__hasExternalTextures&&(n.__autoAllocateDepthBuffer=void 0===i,n.__autoAllocateDepthBuffer||!0===Y.has("WEBGL_multisampled_render_to_texture")&&(n.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(t,e){const i=$.get(t);i.__webglFramebuffer=e,i.__useDefaultFramebuffer=void 0===e},this.setRenderTarget=function(t,e=0,i=0){b=t,x=e,M=i;let n=!0,s=null,r=!1,a=!1;if(t){const o=$.get(t);void 0!==o.__useDefaultFramebuffer?(J.bindFramebuffer(vt.FRAMEBUFFER,null),n=!1):void 0===o.__webglFramebuffer?Q.setupRenderTarget(t):o.__hasExternalTextures&&Q.rebindTextures(t,$.get(t.texture).__webglTexture,$.get(t.depthTexture).__webglTexture);const l=t.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(a=!0);const h=$.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(s=Array.isArray(h[e])?h[e][i]:h[e],r=!0):s=Z.isWebGL2&&t.samples>0&&!1===Q.useMultisampledRTT(t)?$.get(t).__webglMultisampledFramebuffer:Array.isArray(h)?h[i]:h,T.copy(t.viewport),E.copy(t.scissor),A=t.scissorTest}else T.copy(N).multiplyScalar(I).floor(),E.copy(F).multiplyScalar(I).floor(),A=B;if(J.bindFramebuffer(vt.FRAMEBUFFER,s)&&Z.drawBuffers&&n&&J.drawBuffers(t,s),J.viewport(T),J.scissor(E),J.setScissorTest(A),r){const n=$.get(t.texture);vt.framebufferTexture2D(vt.FRAMEBUFFER,vt.COLOR_ATTACHMENT0,vt.TEXTURE_CUBE_MAP_POSITIVE_X+e,n.__webglTexture,i)}else if(a){const n=$.get(t.texture),s=e||0;vt.framebufferTextureLayer(vt.FRAMEBUFFER,vt.COLOR_ATTACHMENT0,n.__webglTexture,i||0,s)}S=-1},this.readRenderTargetPixels=function(t,e,i,n,s,r,a){if(!t||!t.isWebGLRenderTarget)return;let o=$.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){J.bindFramebuffer(vt.FRAMEBUFFER,o);try{const a=t.texture,o=a.format,l=a.type;if(o!==Pt&&ft.convert(o)!==vt.getParameter(vt.IMPLEMENTATION_COLOR_READ_FORMAT))return;const h=l===Et&&(Y.has("EXT_color_buffer_half_float")||Z.isWebGL2&&Y.has("EXT_color_buffer_float"));if(!(l===Mt||ft.convert(l)===vt.getParameter(vt.IMPLEMENTATION_COLOR_READ_TYPE)||l===Tt&&(Z.isWebGL2||Y.has("OES_texture_float")||Y.has("WEBGL_color_buffer_float"))||h))return;e>=0&&e<=t.width-n&&i>=0&&i<=t.height-s&&vt.readPixels(e,i,n,s,ft.convert(o),ft.convert(l),r)}finally{const t=null!==b?$.get(b).__webglFramebuffer:null;J.bindFramebuffer(vt.FRAMEBUFFER,t)}}},this.copyFramebufferToTexture=function(t,e,i=0){const n=Math.pow(2,-i),s=Math.floor(e.image.width*n),r=Math.floor(e.image.height*n);Q.setTexture2D(e,0),vt.copyTexSubImage2D(vt.TEXTURE_2D,i,0,0,t.x,t.y,s,r),J.unbindTexture()},this.copyTextureToTexture=function(t,e,i,n=0){const s=e.image.width,r=e.image.height,a=ft.convert(i.format),o=ft.convert(i.type);Q.setTexture2D(i,0),vt.pixelStorei(vt.UNPACK_FLIP_Y_WEBGL,i.flipY),vt.pixelStorei(vt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),vt.pixelStorei(vt.UNPACK_ALIGNMENT,i.unpackAlignment),e.isDataTexture?vt.texSubImage2D(vt.TEXTURE_2D,n,t.x,t.y,s,r,a,o,e.image.data):e.isCompressedTexture?vt.compressedTexSubImage2D(vt.TEXTURE_2D,n,t.x,t.y,e.mipmaps[0].width,e.mipmaps[0].height,a,e.mipmaps[0].data):vt.texSubImage2D(vt.TEXTURE_2D,n,t.x,t.y,a,o,e.image),0===n&&i.generateMipmaps&&vt.generateMipmap(vt.TEXTURE_2D),J.unbindTexture()},this.copyTextureToTexture3D=function(t,e,i,n,s=0){if(v.isWebGL1Renderer)return;const r=t.max.x-t.min.x+1,a=t.max.y-t.min.y+1,o=t.max.z-t.min.z+1,l=ft.convert(n.format),h=ft.convert(n.type);let c;if(n.isData3DTexture)Q.setTexture3D(n,0),c=vt.TEXTURE_3D;else{if(!n.isDataArrayTexture&&!n.isCompressedArrayTexture)return;Q.setTexture2DArray(n,0),c=vt.TEXTURE_2D_ARRAY}vt.pixelStorei(vt.UNPACK_FLIP_Y_WEBGL,n.flipY),vt.pixelStorei(vt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),vt.pixelStorei(vt.UNPACK_ALIGNMENT,n.unpackAlignment);const u=vt.getParameter(vt.UNPACK_ROW_LENGTH),d=vt.getParameter(vt.UNPACK_IMAGE_HEIGHT),p=vt.getParameter(vt.UNPACK_SKIP_PIXELS),m=vt.getParameter(vt.UNPACK_SKIP_ROWS),f=vt.getParameter(vt.UNPACK_SKIP_IMAGES),g=i.isCompressedTexture?i.mipmaps[s]:i.image;vt.pixelStorei(vt.UNPACK_ROW_LENGTH,g.width),vt.pixelStorei(vt.UNPACK_IMAGE_HEIGHT,g.height),vt.pixelStorei(vt.UNPACK_SKIP_PIXELS,t.min.x),vt.pixelStorei(vt.UNPACK_SKIP_ROWS,t.min.y),vt.pixelStorei(vt.UNPACK_SKIP_IMAGES,t.min.z),i.isDataTexture||i.isData3DTexture?vt.texSubImage3D(c,s,e.x,e.y,e.z,r,a,o,l,h,g.data):i.isCompressedArrayTexture?vt.compressedTexSubImage3D(c,s,e.x,e.y,e.z,r,a,o,l,g.data):vt.texSubImage3D(c,s,e.x,e.y,e.z,r,a,o,l,h,g),vt.pixelStorei(vt.UNPACK_ROW_LENGTH,u),vt.pixelStorei(vt.UNPACK_IMAGE_HEIGHT,d),vt.pixelStorei(vt.UNPACK_SKIP_PIXELS,p),vt.pixelStorei(vt.UNPACK_SKIP_ROWS,m),vt.pixelStorei(vt.UNPACK_SKIP_IMAGES,f),0===s&&n.generateMipmaps&&vt.generateMipmap(c),J.unbindTexture()},this.initTexture=function(t){t.isCubeTexture?Q.setTextureCube(t,0):t.isData3DTexture?Q.setTexture3D(t,0):t.isDataArrayTexture||t.isCompressedArrayTexture?Q.setTexture2DArray(t,0):Q.setTexture2D(t,0),J.unbindTexture()},this.resetState=function(){x=0,M=0,b=null,J.reset(),gt.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return He}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=t===Te?"display-p3":"srgb",e.unpackColorSpace=yi.workingColorSpace===Ee?"display-p3":"srgb"}get outputEncoding(){return this.outputColorSpace===Se?Me:xe}set outputEncoding(t){this.outputColorSpace=t===Me?Se:we}get useLegacyLights(){return this._useLegacyLights}set useLegacyLights(t){this._useLegacyLights=t}}class Wo extends Ho{}Wo.prototype.isWebGL1Renderer=!0;class qo{constructor(t,e=25e-5){this.isFogExp2=!0,this.name="",this.color=new ts(t),this.density=e}clone(){return new qo(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class Xo{constructor(t,e=1,i=1e3){this.isFog=!0,this.name="",this.color=new ts(t),this.near=e,this.far=i}clone(){return new Xo(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class jo extends Fn{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return null!==this.fog&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(e.object.backgroundIntensity=this.backgroundIntensity),e}}class Yo{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=ke,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Je()}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}get updateRange(){return this._updateRange}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.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,i){t*=this.stride,i*=e.stride;for(let n=0,s=this.stride;n<s;n++)this.array[t+n]=e.array[i+n];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=Je()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(e,this.stride);return i.setUsage(this.usage),i}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=Je()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Zo=new Ni;class Jo{constructor(t,e,i,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=i,this.normalized=n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,i=this.data.count;e<i;e++)Zo.fromBufferAttribute(this,e),Zo.applyMatrix4(t),this.setXYZ(e,Zo.x,Zo.y,Zo.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)Zo.fromBufferAttribute(this,e),Zo.applyNormalMatrix(t),this.setXYZ(e,Zo.x,Zo.y,Zo.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)Zo.fromBufferAttribute(this,e),Zo.transformDirection(t),this.setXYZ(e,Zo.x,Zo.y,Zo.z);return this}setX(t,e){return this.normalized&&(e=ni(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=ni(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=ni(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=ni(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=ii(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=ii(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=ii(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=ii(e,this.array)),e}setXY(t,e,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=ni(e,this.array),i=ni(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this}setXYZ(t,e,i,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=ni(e,this.array),i=ni(i,this.array),n=ni(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=n,this}setXYZW(t,e,i,n,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=ni(e,this.array),i=ni(i,this.array),n=ni(n,this.array),s=ni(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=n,this.data.array[t+3]=s,this}clone(t){if(void 0===t){const t=[];for(let e=0;e<this.count;e++){const i=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[i+e])}return new ds(new this.array.constructor(t),this.itemSize,this.normalized)}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Jo(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(void 0===t){const t=[];for(let e=0;e<this.count;e++){const i=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[i+e])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class Ko extends ns{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new ts(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}let $o;const Qo=new Ni,tl=new Ni,el=new Ni,il=new ri,nl=new ri,sl=new dn,rl=new Ni,al=new Ni,ol=new Ni,ll=new ri,hl=new ri,cl=new ri;class ul extends Fn{constructor(t=new Ko){if(super(),this.isSprite=!0,this.type="Sprite",void 0===$o){$o=new Ss;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),e=new Yo(t,5);$o.setIndex([0,1,2,0,2,3]),$o.setAttribute("position",new Jo(e,3,0,!1)),$o.setAttribute("uv",new Jo(e,2,3,!1))}this.geometry=$o,this.material=t,this.center=new ri(.5,.5)}raycast(t,e){t.camera,tl.setFromMatrixScale(this.matrixWorld),sl.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),el.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&tl.multiplyScalar(-el.z);const i=this.material.rotation;let n,s;0!==i&&(s=Math.cos(i),n=Math.sin(i));const r=this.center;dl(rl.set(-.5,-.5,0),el,r,tl,n,s),dl(al.set(.5,-.5,0),el,r,tl,n,s),dl(ol.set(.5,.5,0),el,r,tl,n,s),ll.set(0,0),hl.set(1,0),cl.set(1,1);let a=t.ray.intersectTriangle(rl,al,ol,!1,Qo);if(null===a&&(dl(al.set(-.5,.5,0),el,r,tl,n,s),hl.set(0,1),a=t.ray.intersectTriangle(rl,ol,al,!1,Qo),null===a))return;const o=t.ray.origin.distanceTo(Qo);o<t.near||o>t.far||e.push({distance:o,point:Qo.clone(),uv:Zn.getInterpolation(Qo,rl,al,ol,ll,hl,cl,new ri),face:null,object:this})}copy(t,e){return super.copy(t,e),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}}function dl(t,e,i,n,s,r){il.subVectors(t,i).addScalar(.5).multiply(n),void 0!==s?(nl.x=r*il.x-s*il.y,nl.y=s*il.x+r*il.y):nl.copy(il),t.copy(e),t.x+=nl.x,t.y+=nl.y,t.applyMatrix4(sl)}const pl=new Ni,ml=new Ni;class fl extends Fn{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const e=t.levels;for(let i=0,n=e.length;i<n;i++){const t=e[i];this.addLevel(t.object.clone(),t.distance,t.hysteresis)}return this.autoUpdate=t.autoUpdate,this}addLevel(t,e=0,i=0){e=Math.abs(e);const n=this.levels;let s;for(s=0;s<n.length&&!(e<n[s].distance);s++);return n.splice(s,0,{distance:e,hysteresis:i,object:t}),this.add(t),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(t){const e=this.levels;if(e.length>0){let i,n;for(i=1,n=e.length;i<n;i++){let n=e[i].distance;if(e[i].object.visible&&(n-=n*e[i].hysteresis),t<n)break}return e[i-1].object}return null}raycast(t,e){if(this.levels.length>0){pl.setFromMatrixPosition(this.matrixWorld);const i=t.ray.origin.distanceTo(pl);this.getObjectForDistance(i).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){pl.setFromMatrixPosition(t.matrixWorld),ml.setFromMatrixPosition(this.matrixWorld);const i=pl.distanceTo(ml)/t.zoom;let n,s;for(e[0].object.visible=!0,n=1,s=e.length;n<s;n++){let t=e[n].distance;if(e[n].object.visible&&(t-=t*e[n].hysteresis),!(i>=t))break;e[n-1].object.visible=!1,e[n].object.visible=!0}for(this._currentLevel=n-1;n<s;n++)e[n].object.visible=!1}}toJSON(t){const e=super.toJSON(t);!1===this.autoUpdate&&(e.object.autoUpdate=!1),e.object.levels=[];const i=this.levels;for(let n=0,s=i.length;n<s;n++){const t=i[n];e.object.levels.push({object:t.object.uuid,distance:t.distance,hysteresis:t.hysteresis})}return e}}const gl=new Ni,_l=new Ri,vl=new Ri,yl=new Ni,xl=new dn,Ml=new Ni,bl=new nn,Sl=new dn,wl=new un;class Tl extends Vs{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=st,this.bindMatrix=new dn,this.bindMatrixInverse=new dn,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;null===this.boundingBox&&(this.boundingBox=new Bi),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let i=0;i<e.count;i++)this.getVertexPosition(i,Ml),this.boundingBox.expandByPoint(Ml)}computeBoundingSphere(){const t=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new nn),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let i=0;i<e.count;i++)this.getVertexPosition(i,Ml),this.boundingSphere.expandByPoint(Ml)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){const i=this.material,n=this.matrixWorld;void 0!==i&&(null===this.boundingSphere&&this.computeBoundingSphere(),bl.copy(this.boundingSphere),bl.applyMatrix4(n),!1!==t.ray.intersectsSphere(bl)&&(Sl.copy(n).invert(),wl.copy(t.ray).applyMatrix4(Sl),null!==this.boundingBox&&!1===wl.intersectsBox(this.boundingBox)||this._computeIntersections(t,e,wl)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,void 0===e&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const t=new Ri,e=this.geometry.attributes.skinWeight;for(let i=0,n=e.count;i<n;i++){t.fromBufferAttribute(e,i);const n=1/t.manhattanLength();n!==1/0?t.multiplyScalar(n):t.set(1,0,0,0),e.setXYZW(i,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===st?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===rt&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}applyBoneTransform(t,e){const i=this.skeleton,n=this.geometry;_l.fromBufferAttribute(n.attributes.skinIndex,t),vl.fromBufferAttribute(n.attributes.skinWeight,t),gl.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let s=0;s<4;s++){const t=vl.getComponent(s);if(0!==t){const n=_l.getComponent(s);xl.multiplyMatrices(i.bones[n].matrixWorld,i.boneInverses[n]),e.addScaledVector(yl.copy(gl).applyMatrix4(xl),t)}}return e.applyMatrix4(this.bindMatrixInverse)}boneTransform(t,e){return this.applyBoneTransform(t,e)}}class El extends Fn{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Al extends Ci{constructor(t=null,e=1,i=1,n,s,r,a,o,l=1003,h=1003,c,u){super(null,r,a,o,l,h,n,s,c,u),this.isDataTexture=!0,this.image={data:t,width:e,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Cl=new dn,Rl=new dn;class Pl{constructor(t=[],e=[]){this.uuid=Je(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(16*t.length),0===e.length)this.calculateInverses();else if(t.length!==e.length){this.boneInverses=[];for(let t=0,e=this.bones.length;t<e;t++)this.boneInverses.push(new dn)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const e=new dn;this.bones[t]&&e.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(e)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&e.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&(e.parent&&e.parent.isBone?(e.matrix.copy(e.parent.matrixWorld).invert(),e.matrix.multiply(e.matrixWorld)):e.matrix.copy(e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale))}}update(){const t=this.bones,e=this.boneInverses,i=this.boneMatrices,n=this.boneTexture;for(let s=0,r=t.length;s<r;s++){const n=t[s]?t[s].matrixWorld:Rl;Cl.multiplyMatrices(n,e[s]),Cl.toArray(i,16*s)}null!==n&&(n.needsUpdate=!0)}clone(){return new Pl(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(4*this.bones.length);t=4*Math.ceil(t/4),t=Math.max(t,4);const e=new Float32Array(t*t*4);e.set(this.boneMatrices);const i=new Al(e,t,t,Pt,Tt);return i.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=i,this}getBoneByName(t){for(let e=0,i=this.bones.length;e<i;e++){const i=this.bones[e];if(i.name===t)return i}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let i=0,n=t.bones.length;i<n;i++){let n=e[t.bones[i]];void 0===n&&(n=new El),this.bones.push(n),this.boneInverses.push((new dn).fromArray(t.boneInverses[i]))}return this.init(),this}toJSON(){const t={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,i=this.boneInverses;for(let n=0,s=e.length;n<s;n++){const s=e[n];t.bones.push(s.uuid);const r=i[n];t.boneInverses.push(r.toArray())}return t}}class Ll extends ds{constructor(t,e,i,n=1){super(t,e,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}const Il=new dn,Dl=new dn,Ul=[],Nl=new Bi,Ol=new dn,Fl=new Vs,Bl=new nn;class zl extends Vs{constructor(t,e,i){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new Ll(new Float32Array(16*i),16),this.instanceColor=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let n=0;n<i;n++)this.setMatrixAt(n,Ol)}computeBoundingBox(){const t=this.geometry,e=this.count;null===this.boundingBox&&(this.boundingBox=new Bi),null===t.boundingBox&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<e;i++)this.getMatrixAt(i,Il),Nl.copy(t.boundingBox).applyMatrix4(Il),this.boundingBox.union(Nl)}computeBoundingSphere(){const t=this.geometry,e=this.count;null===this.boundingSphere&&(this.boundingSphere=new nn),null===t.boundingSphere&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<e;i++)this.getMatrixAt(i,Il),Bl.copy(t.boundingSphere).applyMatrix4(Il),this.boundingSphere.union(Bl)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),null!==t.instanceColor&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){e.fromArray(this.instanceColor.array,3*t)}getMatrixAt(t,e){e.fromArray(this.instanceMatrix.array,16*t)}raycast(t,e){const i=this.matrixWorld,n=this.count;if(Fl.geometry=this.geometry,Fl.material=this.material,void 0!==Fl.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),Bl.copy(this.boundingSphere),Bl.applyMatrix4(i),!1!==t.ray.intersectsSphere(Bl)))for(let s=0;s<n;s++){this.getMatrixAt(s,Il),Dl.multiplyMatrices(i,Il),Fl.matrixWorld=Dl,Fl.raycast(t,Ul);for(let t=0,i=Ul.length;t<i;t++){const i=Ul[t];i.instanceId=s,i.object=this,e.push(i)}Ul.length=0}}setColorAt(t,e){null===this.instanceColor&&(this.instanceColor=new Ll(new Float32Array(3*this.instanceMatrix.count),3)),e.toArray(this.instanceColor.array,3*t)}setMatrixAt(t,e){e.toArray(this.instanceMatrix.array,16*t)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}function kl(t,e){return t.z-e.z}function Vl(t,e){return e.z-t.z}class Gl{constructor(){this.index=0,this.pool=[],this.list=[]}push(t,e){const i=this.pool,n=this.list;this.index>=i.length&&i.push({start:-1,count:-1,z:-1});const s=i[this.index];n.push(s),this.index++,s.start=t.start,s.count=t.count,s.z=e}reset(){this.list.length=0,this.index=0}}const Hl="batchId",Wl=new dn,ql=new dn,Xl=new dn,jl=new dn,Yl=new or,Zl=new Bi,Jl=new nn,Kl=new Ni,$l=new Gl,Ql=new Vs,th=[];function eh(t,e,i=0){const n=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const s=t.count;for(let r=0;r<s;r++)for(let s=0;s<n;s++)e.setComponent(r+i,s,t.getComponent(r,s))}else e.array.set(t.array,i*n);e.needsUpdate=!0}class ih extends Vs{get maxGeometryCount(){return this._maxGeometryCount}constructor(t,e,i=2*e,n){super(new Ss,n),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawRanges=[],this._reservedRanges=[],this._visibility=[],this._active=[],this._bounds=[],this._maxGeometryCount=t,this._maxVertexCount=e,this._maxIndexCount=i,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(t),this._multiDrawStarts=new Int32Array(t),this._multiDrawCount=0,this._visibilityChanged=!0,this._matricesTexture=null,this._initMatricesTexture()}_initMatricesTexture(){let t=Math.sqrt(4*this._maxGeometryCount);t=4*Math.ceil(t/4),t=Math.max(t,4);const e=new Float32Array(t*t*4),i=new Al(e,t,t,Pt,Tt);this._matricesTexture=i}_initializeGeometry(t){const e=this.geometry,i=this._maxVertexCount,n=this._maxGeometryCount,s=this._maxIndexCount;if(!1===this._geometryInitialized){for(const n in t.attributes){const s=t.getAttribute(n),{array:r,itemSize:a,normalized:o}=s,l=new r.constructor(i*a),h=new s.constructor(l,a,o);h.setUsage(s.usage),e.setAttribute(n,h)}if(null!==t.getIndex()){const t=i>65536?new Uint32Array(s):new Uint16Array(s);e.setIndex(new ds(t,1))}const r=n>65536?new Uint32Array(i):new Uint16Array(i);e.setAttribute(Hl,new ds(r,1)),this._geometryInitialized=!0}}_validateGeometry(t){if(t.getAttribute(Hl))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Hl}"`);const e=this.geometry;if(Boolean(t.getIndex())!==Boolean(e.getIndex()))throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const i in e.attributes){if(i===Hl)continue;if(!t.hasAttribute(i))throw new Error(`BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const n=t.getAttribute(i),s=e.getAttribute(i);if(n.itemSize!==s.itemSize||n.normalized!==s.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Bi);const t=this._geometryCount,e=this.boundingBox,i=this._active;e.makeEmpty();for(let n=0;n<t;n++)!1!==i[n]&&(this.getMatrixAt(n,Wl),this.getBoundingBoxAt(n,Zl).applyMatrix4(Wl),e.union(Zl))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new nn);const t=this._geometryCount,e=this.boundingSphere,i=this._active;e.makeEmpty();for(let n=0;n<t;n++)!1!==i[n]&&(this.getMatrixAt(n,Wl),this.getBoundingSphereAt(n,Jl).applyMatrix4(Wl),e.union(Jl))}addGeometry(t,e=-1,i=-1){if(this._initializeGeometry(t),this._validateGeometry(t),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");const n={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let s=null;const r=this._reservedRanges,a=this._drawRanges,o=this._bounds;0!==this._geometryCount&&(s=r[r.length-1]),n.vertexCount=-1===e?t.getAttribute("position").count:e,n.vertexStart=null===s?0:s.vertexStart+s.vertexCount;const l=t.getIndex(),h=null!==l;if(h&&(n.indexCount=-1===i?l.count:i,n.indexStart=null===s?0:s.indexStart+s.indexCount),-1!==n.indexStart&&n.indexStart+n.indexCount>this._maxIndexCount||n.vertexStart+n.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const c=this._visibility,u=this._active,d=this._matricesTexture,p=this._matricesTexture.image.data;c.push(!0),u.push(!0);const m=this._geometryCount;this._geometryCount++,Xl.toArray(p,16*m),d.needsUpdate=!0,r.push(n),a.push({start:h?n.indexStart:n.vertexStart,count:-1}),o.push({boxInitialized:!1,box:new Bi,sphereInitialized:!1,sphere:new nn});const f=this.geometry.getAttribute(Hl);for(let g=0;g<n.vertexCount;g++)f.setX(n.vertexStart+g,m);return f.needsUpdate=!0,this.setGeometryAt(m,t),m}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);const i=this.geometry,n=null!==i.getIndex(),s=i.getIndex(),r=e.getIndex(),a=this._reservedRanges[t];if(n&&r.count>a.indexCount||e.attributes.position.count>a.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const o=a.vertexStart,l=a.vertexCount;for(const d in i.attributes){if(d===Hl)continue;const t=e.getAttribute(d),n=i.getAttribute(d);eh(t,n,o);const s=t.itemSize;for(let e=t.count,i=l;e<i;e++){const t=o+e;for(let e=0;e<s;e++)n.setComponent(t,e,0)}n.needsUpdate=!0}if(n){const t=a.indexStart;for(let e=0;e<r.count;e++)s.setX(t+e,o+r.getX(e));for(let e=r.count,i=a.indexCount;e<i;e++)s.setX(t+e,o);s.needsUpdate=!0}const h=this._bounds[t];null!==e.boundingBox?(h.box.copy(e.boundingBox),h.boxInitialized=!0):h.boxInitialized=!1,null!==e.boundingSphere?(h.sphere.copy(e.boundingSphere),h.sphereInitialized=!0):h.sphereInitialized=!1;const c=this._drawRanges[t],u=e.getAttribute("position");return c.count=n?r.count:u.count,this._visibilityChanged=!0,t}deleteGeometry(t){const e=this._active;return t>=e.length||!1===e[t]||(e[t]=!1,this._visibilityChanged=!0),this}getBoundingBoxAt(t,e){if(!1===this._active[t])return this;const i=this._bounds[t],n=i.box,s=this.geometry;if(!1===i.boxInitialized){n.makeEmpty();const e=s.index,r=s.attributes.position,a=this._drawRanges[t];for(let t=a.start,i=a.start+a.count;t<i;t++){let i=t;e&&(i=e.getX(i)),n.expandByPoint(Kl.fromBufferAttribute(r,i))}i.boxInitialized=!0}return e.copy(n),e}getBoundingSphereAt(t,e){if(!1===this._active[t])return this;const i=this._bounds[t],n=i.sphere,s=this.geometry;if(!1===i.sphereInitialized){n.makeEmpty(),this.getBoundingBoxAt(t,Zl),Zl.getCenter(n.center);const e=s.index,r=s.attributes.position,a=this._drawRanges[t];let o=0;for(let t=a.start,i=a.start+a.count;t<i;t++){let i=t;e&&(i=e.getX(i)),Kl.fromBufferAttribute(r,i),o=Math.max(o,n.center.distanceToSquared(Kl))}n.radius=Math.sqrt(o),i.sphereInitialized=!0}return e.copy(n),e}setMatrixAt(t,e){const i=this._active,n=this._matricesTexture,s=this._matricesTexture.image.data;return t>=this._geometryCount||!1===i[t]||(e.toArray(s,16*t),n.needsUpdate=!0),this}getMatrixAt(t,e){const i=this._active,n=this._matricesTexture.image.data;return t>=this._geometryCount||!1===i[t]?null:e.fromArray(n,16*t)}setVisibleAt(t,e){const i=this._visibility,n=this._active;return t>=this._geometryCount||!1===n[t]||i[t]===e||(i[t]=e,this._visibilityChanged=!0),this}getVisibleAt(t){const e=this._visibility,i=this._active;return!(t>=this._geometryCount||!1===i[t])&&e[t]}raycast(t,e){const i=this._visibility,n=this._active,s=this._drawRanges,r=this._geometryCount,a=this.matrixWorld,o=this.geometry;Ql.material=this.material,Ql.geometry.index=o.index,Ql.geometry.attributes=o.attributes,null===Ql.geometry.boundingBox&&(Ql.geometry.boundingBox=new Bi),null===Ql.geometry.boundingSphere&&(Ql.geometry.boundingSphere=new nn);for(let l=0;l<r;l++){if(!i[l]||!n[l])continue;const r=s[l];Ql.geometry.setDrawRange(r.start,r.count),this.getMatrixAt(l,Ql.matrixWorld).premultiply(a),this.getBoundingBoxAt(l,Ql.geometry.boundingBox),this.getBoundingSphereAt(l,Ql.geometry.boundingSphere),Ql.raycast(t,th);for(let t=0,i=th.length;t<i;t++){const i=th[t];i.object=this,i.batchId=l,e.push(i)}th.length=0}Ql.material=null,Ql.geometry.index=null,Ql.geometry.attributes={},Ql.geometry.setDrawRange(0,1/0)}copy(t){return super.copy(t),this.geometry=t.geometry.clone(),this.perObjectFrustumCulled=t.perObjectFrustumCulled,this.sortObjects=t.sortObjects,this.boundingBox=null!==t.boundingBox?t.boundingBox.clone():null,this.boundingSphere=null!==t.boundingSphere?t.boundingSphere.clone():null,this._drawRanges=t._drawRanges.map(t=>({...t})),this._reservedRanges=t._reservedRanges.map(t=>({...t})),this._visibility=t._visibility.slice(),this._active=t._active.slice(),this._bounds=t._bounds.map(t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.sphere.clone()})),this._maxGeometryCount=t._maxGeometryCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._geometryCount=t._geometryCount,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(t,e,i,n,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const r=n.getIndex(),a=null===r?1:r.array.BYTES_PER_ELEMENT,o=this._visibility,l=this._multiDrawStarts,h=this._multiDrawCounts,c=this._drawRanges,u=this.perObjectFrustumCulled;u&&(jl.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),Yl.setFromProjectionMatrix(jl,t.isWebGPURenderer?We:He));let d=0;if(this.sortObjects){ql.copy(this.matrixWorld).invert(),Kl.setFromMatrixPosition(i.matrixWorld).applyMatrix4(ql);for(let i=0,n=o.length;i<n;i++)if(o[i]){this.getMatrixAt(i,Wl),this.getBoundingSphereAt(i,Jl).applyMatrix4(Wl);let t=!1;if(u&&(t=!Yl.intersectsSphere(Jl)),!t){const t=Kl.distanceTo(Jl.center);$l.push(c[i],t)}}const t=$l.list,e=this.customSort;null===e?t.sort(s.transparent?Vl:kl):e.call(this,t,i);for(let i=0,n=t.length;i<n;i++){const e=t[i];l[d]=e.start*a,h[d]=e.count,d++}$l.reset()}else for(let p=0,m=o.length;p<m;p++)if(o[p]){let t=!1;if(u&&(this.getMatrixAt(p,Wl),this.getBoundingSphereAt(p,Jl).applyMatrix4(Wl),t=!Yl.intersectsSphere(Jl)),!t){const t=c[p];l[d]=t.start*a,h[d]=t.count,d++}}this._multiDrawCount=d,this._visibilityChanged=!1}onBeforeShadow(t,e,i,n,s,r){this.onBeforeRender(t,null,n,s,r)}}class nh extends ns{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ts(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const sh=new Ni,rh=new Ni,ah=new dn,oh=new un,lh=new nn;class hh extends Fn{constructor(t=new Ss,e=new nh){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,i=[0];for(let t=1,n=e.count;t<n;t++)sh.fromBufferAttribute(e,t-1),rh.fromBufferAttribute(e,t),i[t]=i[t-1],i[t]+=sh.distanceTo(rh);t.setAttribute("lineDistance",new fs(i,1))}return this}raycast(t,e){const i=this.geometry,n=this.matrixWorld,s=t.params.Line.threshold,r=i.drawRange;if(null===i.boundingSphere&&i.computeBoundingSphere(),lh.copy(i.boundingSphere),lh.applyMatrix4(n),lh.radius+=s,!1===t.ray.intersectsSphere(lh))return;ah.copy(n).invert(),oh.copy(t.ray).applyMatrix4(ah);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=new Ni,h=new Ni,c=new Ni,u=new Ni,d=this.isLineSegments?2:1,p=i.index,m=i.attributes.position;if(null!==p)for(let f=Math.max(0,r.start),g=Math.min(p.count,r.start+r.count)-1;f<g;f+=d){const i=p.getX(f),n=p.getX(f+1);if(l.fromBufferAttribute(m,i),h.fromBufferAttribute(m,n),oh.distanceSqToSegment(l,h,u,c)>o)continue;u.applyMatrix4(this.matrixWorld);const s=t.ray.origin.distanceTo(u);s<t.near||s>t.far||e.push({distance:s,point:c.clone().applyMatrix4(this.matrixWorld),index:f,face:null,faceIndex:null,object:this})}else for(let f=Math.max(0,r.start),g=Math.min(m.count,r.start+r.count)-1;f<g;f+=d){if(l.fromBufferAttribute(m,f),h.fromBufferAttribute(m,f+1),oh.distanceSqToSegment(l,h,u,c)>o)continue;u.applyMatrix4(this.matrixWorld);const i=t.ray.origin.distanceTo(u);i<t.near||i>t.far||e.push({distance:i,point:c.clone().applyMatrix4(this.matrixWorld),index:f,face:null,faceIndex:null,object:this})}}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;t<e;t++){const e=i[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}}const ch=new Ni,uh=new Ni;class dh extends hh{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,i=[];for(let t=0,n=e.count;t<n;t+=2)ch.fromBufferAttribute(e,t),uh.fromBufferAttribute(e,t+1),i[t]=0===t?0:i[t-1],i[t+1]=i[t]+ch.distanceTo(uh);t.setAttribute("lineDistance",new fs(i,1))}return this}}class ph extends hh{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}}class mh extends ns{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new ts(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}const fh=new dn,gh=new un,_h=new nn,vh=new Ni;class yh extends Fn{constructor(t=new Ss,e=new mh){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){const i=this.geometry,n=this.matrixWorld,s=t.params.Points.threshold,r=i.drawRange;if(null===i.boundingSphere&&i.computeBoundingSphere(),_h.copy(i.boundingSphere),_h.applyMatrix4(n),_h.radius+=s,!1===t.ray.intersectsSphere(_h))return;fh.copy(n).invert(),gh.copy(t.ray).applyMatrix4(fh);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=i.index,h=i.attributes.position;if(null!==l)for(let c=Math.max(0,r.start),u=Math.min(l.count,r.start+r.count);c<u;c++){const i=l.getX(c);vh.fromBufferAttribute(h,i),xh(vh,i,o,n,t,e,this)}else for(let c=Math.max(0,r.start),u=Math.min(h.count,r.start+r.count);c<u;c++)vh.fromBufferAttribute(h,c),xh(vh,c,o,n,t,e,this)}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;t<e;t++){const e=i[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}}function xh(t,e,i,n,s,r,a){const o=gh.distanceSqToPoint(t);if(o<i){const i=new Ni;gh.closestPointToPoint(t,i),i.applyMatrix4(n);const l=s.ray.origin.distanceTo(i);if(l<s.near||l>s.far)return;r.push({distance:l,distanceToRay:Math.sqrt(o),point:i,index:e,face:null,object:a})}}class Mh extends Ci{constructor(t,e,i,n,s,r,a,o,l,h,c,u){super(null,r,a,o,l,h,n,s,c,u),this.isCompressedTexture=!0,this.image={width:e,height:i},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}class bh{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return null}getPointAt(t,e){const i=this.getUtoTmapping(t);return this.getPoint(i,e)}getPoints(t=5){const e=[];for(let i=0;i<=t;i++)e.push(this.getPoint(i/t));return e}getSpacedPoints(t=5){const e=[];for(let i=0;i<=t;i++)e.push(this.getPointAt(i/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 i,n=this.getPoint(0),s=0;e.push(0);for(let r=1;r<=t;r++)i=this.getPoint(r/t),s+=i.distanceTo(n),e.push(s),n=i;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){const i=this.getLengths();let n=0;const s=i.length;let r;r=e||t*i[s-1];let a,o=0,l=s-1;for(;o<=l;)if(n=Math.floor(o+(l-o)/2),a=i[n]-r,a<0)o=n+1;else{if(!(a>0)){l=n;break}l=n-1}if(n=l,i[n]===r)return n/(s-1);const h=i[n];return(n+(r-h)/(i[n+1]-h))/(s-1)}getTangent(t,e){const i=1e-4;let n=t-i,s=t+i;n<0&&(n=0),s>1&&(s=1);const r=this.getPoint(n),a=this.getPoint(s),o=e||(r.isVector2?new ri:new Ni);return o.copy(a).sub(r).normalize(),o}getTangentAt(t,e){const i=this.getUtoTmapping(t);return this.getTangent(i,e)}computeFrenetFrames(t,e){const i=new Ni,n=[],s=[],r=[],a=new Ni,o=new dn;for(let d=0;d<=t;d++){const e=d/t;n[d]=this.getTangentAt(e,new Ni)}s[0]=new Ni,r[0]=new Ni;let l=Number.MAX_VALUE;const h=Math.abs(n[0].x),c=Math.abs(n[0].y),u=Math.abs(n[0].z);h<=l&&(l=h,i.set(1,0,0)),c<=l&&(l=c,i.set(0,1,0)),u<=l&&i.set(0,0,1),a.crossVectors(n[0],i).normalize(),s[0].crossVectors(n[0],a),r[0].crossVectors(n[0],s[0]);for(let d=1;d<=t;d++){if(s[d]=s[d-1].clone(),r[d]=r[d-1].clone(),a.crossVectors(n[d-1],n[d]),a.length()>Number.EPSILON){a.normalize();const t=Math.acos(Ke(n[d-1].dot(n[d]),-1,1));s[d].applyMatrix4(o.makeRotationAxis(a,t))}r[d].crossVectors(n[d],s[d])}if(!0===e){let e=Math.acos(Ke(s[0].dot(s[t]),-1,1));e/=t,n[0].dot(a.crossVectors(s[0],s[t]))>0&&(e=-e);for(let i=1;i<=t;i++)s[i].applyMatrix4(o.makeRotationAxis(n[i],e*i)),r[i].crossVectors(n[i],s[i])}return{tangents:n,normals:s,binormals:r}}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 Sh extends bh{constructor(t=0,e=0,i=1,n=1,s=0,r=2*Math.PI,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=i,this.yRadius=n,this.aStartAngle=s,this.aEndAngle=r,this.aClockwise=a,this.aRotation=o}getPoint(t,e){const i=e||new ri,n=2*Math.PI;let s=this.aEndAngle-this.aStartAngle;const r=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=n;for(;s>n;)s-=n;s<Number.EPSILON&&(s=r?0:n),!0!==this.aClockwise||r||(s===n?s=-n:s-=n);const a=this.aStartAngle+t*s;let o=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(0!==this.aRotation){const t=Math.cos(this.aRotation),e=Math.sin(this.aRotation),i=o-this.aX,n=l-this.aY;o=i*t-n*e+this.aX,l=i*e+n*t+this.aY}return i.set(o,l)}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 wh extends Sh{constructor(t,e,i,n,s,r){super(t,e,i,i,n,s,r),this.isArcCurve=!0,this.type="ArcCurve"}}function Th(){let t=0,e=0,i=0,n=0;function s(s,r,a,o){t=s,e=a,i=-3*s+3*r-2*a-o,n=2*s-2*r+a+o}return{initCatmullRom(t,e,i,n,r){s(e,i,r*(i-t),r*(n-e))},initNonuniformCatmullRom(t,e,i,n,r,a,o){let l=(e-t)/r-(i-t)/(r+a)+(i-e)/a,h=(i-e)/a-(n-e)/(a+o)+(n-i)/o;l*=a,h*=a,s(e,i,l,h)},calc(s){const r=s*s;return t+e*s+i*r+n*r*s}}}const Eh=new Ni,Ah=new Th,Ch=new Th,Rh=new Th;class Ph extends bh{constructor(t=[],e=!1,i="centripetal",n=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=i,this.tension=n}getPoint(t,e=new Ni){const i=e,n=this.points,s=n.length,r=(s-(this.closed?0:1))*t;let a,o,l=Math.floor(r),h=r-l;this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/s)+1)*s:0===h&&l===s-1&&(l=s-2,h=1),this.closed||l>0?a=n[(l-1)%s]:(Eh.subVectors(n[0],n[1]).add(n[0]),a=Eh);const c=n[l%s],u=n[(l+1)%s];if(this.closed||l+2<s?o=n[(l+2)%s]:(Eh.subVectors(n[s-1],n[s-2]).add(n[s-1]),o=Eh),"centripetal"===this.curveType||"chordal"===this.curveType){const t="chordal"===this.curveType?.5:.25;let e=Math.pow(a.distanceToSquared(c),t),i=Math.pow(c.distanceToSquared(u),t),n=Math.pow(u.distanceToSquared(o),t);i<1e-4&&(i=1),e<1e-4&&(e=i),n<1e-4&&(n=i),Ah.initNonuniformCatmullRom(a.x,c.x,u.x,o.x,e,i,n),Ch.initNonuniformCatmullRom(a.y,c.y,u.y,o.y,e,i,n),Rh.initNonuniformCatmullRom(a.z,c.z,u.z,o.z,e,i,n)}else"catmullrom"===this.curveType&&(Ah.initCatmullRom(a.x,c.x,u.x,o.x,this.tension),Ch.initCatmullRom(a.y,c.y,u.y,o.y,this.tension),Rh.initCatmullRom(a.z,c.z,u.z,o.z,this.tension));return i.set(Ah.calc(h),Ch.calc(h),Rh.calc(h)),i}copy(t){super.copy(t),this.points=[];for(let e=0,i=t.points.length;e<i;e++){const i=t.points[e];this.points.push(i.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,i=this.points.length;e<i;e++){const i=this.points[e];t.points.push(i.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,i=t.points.length;e<i;e++){const i=t.points[e];this.points.push((new Ni).fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function Lh(t,e,i,n,s){const r=.5*(n-e),a=.5*(s-i),o=t*t;return(2*i-2*n+r+a)*t*o+(-3*i+3*n-2*r-a)*o+r*t+i}function Ih(t,e,i,n){return function(t,e){const i=1-t;return i*i*e}(t,e)+function(t,e){return 2*(1-t)*t*e}(t,i)+function(t,e){return t*t*e}(t,n)}function Dh(t,e,i,n,s){return function(t,e){const i=1-t;return i*i*i*e}(t,e)+function(t,e){const i=1-t;return 3*i*i*t*e}(t,i)+function(t,e){return 3*(1-t)*t*t*e}(t,n)+function(t,e){return t*t*t*e}(t,s)}class Uh extends bh{constructor(t=new ri,e=new ri,i=new ri,n=new ri){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=i,this.v3=n}getPoint(t,e=new ri){const i=e,n=this.v0,s=this.v1,r=this.v2,a=this.v3;return i.set(Dh(t,n.x,s.x,r.x,a.x),Dh(t,n.y,s.y,r.y,a.y)),i}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 Nh extends bh{constructor(t=new Ni,e=new Ni,i=new Ni,n=new Ni){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=i,this.v3=n}getPoint(t,e=new Ni){const i=e,n=this.v0,s=this.v1,r=this.v2,a=this.v3;return i.set(Dh(t,n.x,s.x,r.x,a.x),Dh(t,n.y,s.y,r.y,a.y),Dh(t,n.z,s.z,r.z,a.z)),i}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 Oh extends bh{constructor(t=new ri,e=new ri){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new ri){const i=e;return 1===t?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(t).add(this.v1)),i}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new ri){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 Fh extends bh{constructor(t=new Ni,e=new Ni){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new Ni){const i=e;return 1===t?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(t).add(this.v1)),i}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new Ni){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 Bh extends bh{constructor(t=new ri,e=new ri,i=new ri){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=i}getPoint(t,e=new ri){const i=e,n=this.v0,s=this.v1,r=this.v2;return i.set(Ih(t,n.x,s.x,r.x),Ih(t,n.y,s.y,r.y)),i}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 zh extends bh{constructor(t=new Ni,e=new Ni,i=new Ni){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=i}getPoint(t,e=new Ni){const i=e,n=this.v0,s=this.v1,r=this.v2;return i.set(Ih(t,n.x,s.x,r.x),Ih(t,n.y,s.y,r.y),Ih(t,n.z,s.z,r.z)),i}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 kh extends bh{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new ri){const i=e,n=this.points,s=(n.length-1)*t,r=Math.floor(s),a=s-r,o=n[0===r?r:r-1],l=n[r],h=n[r>n.length-2?n.length-1:r+1],c=n[r>n.length-3?n.length-1:r+2];return i.set(Lh(a,o.x,l.x,h.x,c.x),Lh(a,o.y,l.y,h.y,c.y)),i}copy(t){super.copy(t),this.points=[];for(let e=0,i=t.points.length;e<i;e++){const i=t.points[e];this.points.push(i.clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,i=this.points.length;e<i;e++){const i=this.points[e];t.points.push(i.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,i=t.points.length;e<i;e++){const i=t.points[e];this.points.push((new ri).fromArray(i))}return this}}var Vh=Object.freeze({__proto__:null,ArcCurve:wh,CatmullRomCurve3:Ph,CubicBezierCurve:Uh,CubicBezierCurve3:Nh,EllipseCurve:Sh,LineCurve:Oh,LineCurve3:Fh,QuadraticBezierCurve:Bh,QuadraticBezierCurve3:zh,SplineCurve:kh});class Gh extends bh{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 i=!0===t.isVector2?"LineCurve":"LineCurve3";this.curves.push(new Vh[i](e,t))}return this}getPoint(t,e){const i=t*this.getLength(),n=this.getCurveLengths();let s=0;for(;s<n.length;){if(n[s]>=i){const t=n[s]-i,r=this.curves[s],a=r.getLength(),o=0===a?0:1-t/a;return r.getPointAt(o,e)}s++}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 i=0,n=this.curves.length;i<n;i++)e+=this.curves[i].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let i=0;i<=t;i++)e.push(this.getPoint(i/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[];let i;for(let n=0,s=this.curves;n<s.length;n++){const r=s[n],a=r.isEllipseCurve?2*t:r.isLineCurve||r.isLineCurve3?1:r.isSplineCurve?t*r.points.length:t,o=r.getPoints(a);for(let t=0;t<o.length;t++){const n=o[t];i&&i.equals(n)||(e.push(n),i=n)}}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,i=t.curves.length;e<i;e++){const i=t.curves[e];this.curves.push(i.clone())}return this.autoClose=t.autoClose,this}toJSON(){const t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,i=this.curves.length;e<i;e++){const i=this.curves[e];t.curves.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,i=t.curves.length;e<i;e++){const i=t.curves[e];this.curves.push((new Vh[i.type]).fromJSON(i))}return this}}class Hh extends Gh{constructor(t){super(),this.type="Path",this.currentPoint=new ri,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,i=t.length;e<i;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 i=new Oh(this.currentPoint.clone(),new ri(t,e));return this.curves.push(i),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,i,n){const s=new Bh(this.currentPoint.clone(),new ri(t,e),new ri(i,n));return this.curves.push(s),this.currentPoint.set(i,n),this}bezierCurveTo(t,e,i,n,s,r){const a=new Uh(this.currentPoint.clone(),new ri(t,e),new ri(i,n),new ri(s,r));return this.curves.push(a),this.currentPoint.set(s,r),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),i=new kh(e);return this.curves.push(i),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,i,n,s,r){const a=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(t+a,e+o,i,n,s,r),this}absarc(t,e,i,n,s,r){return this.absellipse(t,e,i,i,n,s,r),this}ellipse(t,e,i,n,s,r,a,o){const l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(t+l,e+h,i,n,s,r,a,o),this}absellipse(t,e,i,n,s,r,a,o){const l=new Sh(t,e,i,n,s,r,a,o);if(this.curves.length>0){const t=l.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(l);const h=l.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 Wh extends Ss{constructor(t=[new ri(0,-.5),new ri(.5,0),new ri(0,.5)],e=12,i=0,n=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:i,phiLength:n},e=Math.floor(e),n=Ke(n,0,2*Math.PI);const s=[],r=[],a=[],o=[],l=[],h=1/e,c=new Ni,u=new ri,d=new Ni,p=new Ni,m=new Ni;let f=0,g=0;for(let _=0;_<=t.length-1;_++)switch(_){case 0:f=t[_+1].x-t[_].x,g=t[_+1].y-t[_].y,d.x=1*g,d.y=-f,d.z=0*g,m.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case t.length-1:o.push(m.x,m.y,m.z);break;default:f=t[_+1].x-t[_].x,g=t[_+1].y-t[_].y,d.x=1*g,d.y=-f,d.z=0*g,p.copy(d),d.x+=m.x,d.y+=m.y,d.z+=m.z,d.normalize(),o.push(d.x,d.y,d.z),m.copy(p)}for(let _=0;_<=e;_++){const s=i+_*h*n,d=Math.sin(s),p=Math.cos(s);for(let i=0;i<=t.length-1;i++){c.x=t[i].x*d,c.y=t[i].y,c.z=t[i].x*p,r.push(c.x,c.y,c.z),u.x=_/e,u.y=i/(t.length-1),a.push(u.x,u.y);const n=o[3*i+0]*d,s=o[3*i+1],h=o[3*i+0]*p;l.push(n,s,h)}}for(let _=0;_<e;_++)for(let e=0;e<t.length-1;e++){const i=e+_*t.length,n=i,r=i+t.length,a=i+t.length+1,o=i+1;s.push(n,r,o),s.push(a,o,r)}this.setIndex(s),this.setAttribute("position",new fs(r,3)),this.setAttribute("uv",new fs(a,2)),this.setAttribute("normal",new fs(l,3))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Wh(t.points,t.segments,t.phiStart,t.phiLength)}}class qh extends Wh{constructor(t=1,e=1,i=4,n=8){const s=new Hh;s.absarc(0,-e/2,t,1.5*Math.PI,0),s.absarc(0,e/2,t,0,.5*Math.PI),super(s.getPoints(i),n),this.type="CapsuleGeometry",this.parameters={radius:t,length:e,capSegments:i,radialSegments:n}}static fromJSON(t){return new qh(t.radius,t.length,t.capSegments,t.radialSegments)}}class Xh extends Ss{constructor(t=1,e=32,i=0,n=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:i,thetaLength:n},e=Math.max(3,e);const s=[],r=[],a=[],o=[],l=new Ni,h=new ri;r.push(0,0,0),a.push(0,0,1),o.push(.5,.5);for(let c=0,u=3;c<=e;c++,u+=3){const s=i+c/e*n;l.x=t*Math.cos(s),l.y=t*Math.sin(s),r.push(l.x,l.y,l.z),a.push(0,0,1),h.x=(r[u]/t+1)/2,h.y=(r[u+1]/t+1)/2,o.push(h.x,h.y)}for(let c=1;c<=e;c++)s.push(c,c+1,0);this.setIndex(s),this.setAttribute("position",new fs(r,3)),this.setAttribute("normal",new fs(a,3)),this.setAttribute("uv",new fs(o,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Xh(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class jh extends Ss{constructor(t=1,e=1,i=1,n=32,s=1,r=!1,a=0,o=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:i,radialSegments:n,heightSegments:s,openEnded:r,thetaStart:a,thetaLength:o};const l=this;n=Math.floor(n),s=Math.floor(s);const h=[],c=[],u=[],d=[];let p=0;const m=[],f=i/2;let g=0;function _(i){const s=p,r=new ri,m=new Ni;let _=0;const v=!0===i?t:e,y=!0===i?1:-1;for(let t=1;t<=n;t++)c.push(0,f*y,0),u.push(0,y,0),d.push(.5,.5),p++;const x=p;for(let t=0;t<=n;t++){const e=t/n*o+a,i=Math.cos(e),s=Math.sin(e);m.x=v*s,m.y=f*y,m.z=v*i,c.push(m.x,m.y,m.z),u.push(0,y,0),r.x=.5*i+.5,r.y=.5*s*y+.5,d.push(r.x,r.y),p++}for(let t=0;t<n;t++){const e=s+t,n=x+t;!0===i?h.push(n,n+1,e):h.push(n+1,n,e),_+=3}l.addGroup(g,_,!0===i?1:2),g+=_}!function(){const r=new Ni,_=new Ni;let v=0;const y=(e-t)/i;for(let l=0;l<=s;l++){const h=[],g=l/s,v=g*(e-t)+t;for(let t=0;t<=n;t++){const e=t/n,s=e*o+a,l=Math.sin(s),m=Math.cos(s);_.x=v*l,_.y=-g*i+f,_.z=v*m,c.push(_.x,_.y,_.z),r.set(l,y,m).normalize(),u.push(r.x,r.y,r.z),d.push(e,1-g),h.push(p++)}m.push(h)}for(let t=0;t<n;t++)for(let e=0;e<s;e++){const i=m[e][t],n=m[e+1][t],s=m[e+1][t+1],r=m[e][t+1];h.push(i,n,r),h.push(n,s,r),v+=6}l.addGroup(g,v,0),g+=v}(),!1===r&&(t>0&&_(!0),e>0&&_(!1)),this.setIndex(h),this.setAttribute("position",new fs(c,3)),this.setAttribute("normal",new fs(u,3)),this.setAttribute("uv",new fs(d,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new jh(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Yh extends jh{constructor(t=1,e=1,i=32,n=1,s=!1,r=0,a=2*Math.PI){super(0,t,e,i,n,s,r,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:i,heightSegments:n,openEnded:s,thetaStart:r,thetaLength:a}}static fromJSON(t){return new Yh(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Zh extends Ss{constructor(t=[],e=[],i=1,n=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:i,detail:n};const s=[],r=[];function a(t,e,i,n){const s=n+1,r=[];for(let a=0;a<=s;a++){r[a]=[];const n=t.clone().lerp(i,a/s),o=e.clone().lerp(i,a/s),l=s-a;for(let t=0;t<=l;t++)r[a][t]=0===t&&a===s?n:n.clone().lerp(o,t/l)}for(let a=0;a<s;a++)for(let t=0;t<2*(s-a)-1;t++){const e=Math.floor(t/2);t%2==0?(o(r[a][e+1]),o(r[a+1][e]),o(r[a][e])):(o(r[a][e+1]),o(r[a+1][e+1]),o(r[a+1][e]))}}function o(t){s.push(t.x,t.y,t.z)}function l(e,i){const n=3*e;i.x=t[n+0],i.y=t[n+1],i.z=t[n+2]}function h(t,e,i,n){n<0&&1===t.x&&(r[e]=t.x-1),0===i.x&&0===i.z&&(r[e]=n/2/Math.PI+.5)}function c(t){return Math.atan2(t.z,-t.x)}function u(t){return Math.atan2(-t.y,Math.sqrt(t.x*t.x+t.z*t.z))}!function(t){const i=new Ni,n=new Ni,s=new Ni;for(let r=0;r<e.length;r+=3)l(e[r+0],i),l(e[r+1],n),l(e[r+2],s),a(i,n,s,t)}(n),function(t){const e=new Ni;for(let i=0;i<s.length;i+=3)e.x=s[i+0],e.y=s[i+1],e.z=s[i+2],e.normalize().multiplyScalar(t),s[i+0]=e.x,s[i+1]=e.y,s[i+2]=e.z}(i),function(){const t=new Ni;for(let e=0;e<s.length;e+=3){t.x=s[e+0],t.y=s[e+1],t.z=s[e+2];const i=c(t)/2/Math.PI+.5,n=u(t)/Math.PI+.5;r.push(i,1-n)}(function(){const t=new Ni,e=new Ni,i=new Ni,n=new Ni,a=new ri,o=new ri,l=new ri;for(let u=0,d=0;u<s.length;u+=9,d+=6){t.set(s[u+0],s[u+1],s[u+2]),e.set(s[u+3],s[u+4],s[u+5]),i.set(s[u+6],s[u+7],s[u+8]),a.set(r[d+0],r[d+1]),o.set(r[d+2],r[d+3]),l.set(r[d+4],r[d+5]),n.copy(t).add(e).add(i).divideScalar(3);const p=c(n);h(a,d+0,t,p),h(o,d+2,e,p),h(l,d+4,i,p)}})(),function(){for(let t=0;t<r.length;t+=6){const e=r[t+0],i=r[t+2],n=r[t+4],s=Math.max(e,i,n),a=Math.min(e,i,n);s>.9&&a<.1&&(e<.2&&(r[t+0]+=1),i<.2&&(r[t+2]+=1),n<.2&&(r[t+4]+=1))}}()}(),this.setAttribute("position",new fs(s,3)),this.setAttribute("normal",new fs(s.slice(),3)),this.setAttribute("uv",new fs(r,2)),0===n?this.computeVertexNormals():this.normalizeNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Zh(t.vertices,t.indices,t.radius,t.details)}}class Jh extends Zh{constructor(t=1,e=0){const i=(1+Math.sqrt(5))/2,n=1/i;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-n,-i,0,-n,i,0,n,-i,0,n,i,-n,-i,0,-n,i,0,n,-i,0,n,i,0,-i,0,-n,i,0,-n,-i,0,n,i,0,n],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Jh(t.radius,t.detail)}}const Kh=new Ni,$h=new Ni,Qh=new Ni,tc=new Zn;class ec extends Ss{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},null!==t){const i=4,n=Math.pow(10,i),s=Math.cos(Ye*e),r=t.getIndex(),a=t.getAttribute("position"),o=r?r.count:a.count,l=[0,0,0],h=["a","b","c"],c=new Array(3),u={},d=[];for(let t=0;t<o;t+=3){r?(l[0]=r.getX(t),l[1]=r.getX(t+1),l[2]=r.getX(t+2)):(l[0]=t,l[1]=t+1,l[2]=t+2);const{a:e,b:i,c:o}=tc;if(e.fromBufferAttribute(a,l[0]),i.fromBufferAttribute(a,l[1]),o.fromBufferAttribute(a,l[2]),tc.getNormal(Qh),c[0]=`${Math.round(e.x*n)},${Math.round(e.y*n)},${Math.round(e.z*n)}`,c[1]=`${Math.round(i.x*n)},${Math.round(i.y*n)},${Math.round(i.z*n)}`,c[2]=`${Math.round(o.x*n)},${Math.round(o.y*n)},${Math.round(o.z*n)}`,c[0]!==c[1]&&c[1]!==c[2]&&c[2]!==c[0])for(let t=0;t<3;t++){const e=(t+1)%3,i=c[t],n=c[e],r=tc[h[t]],a=tc[h[e]],o=`${i}_${n}`,p=`${n}_${i}`;p in u&&u[p]?(Qh.dot(u[p].normal)<=s&&(d.push(r.x,r.y,r.z),d.push(a.x,a.y,a.z)),u[p]=null):o in u||(u[o]={index0:l[t],index1:l[e],normal:Qh.clone()})}}for(const t in u)if(u[t]){const{index0:e,index1:i}=u[t];Kh.fromBufferAttribute(a,e),$h.fromBufferAttribute(a,i),d.push(Kh.x,Kh.y,Kh.z),d.push($h.x,$h.y,$h.z)}this.setAttribute("position",new fs(d,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}class ic extends Hh{constructor(t){super(t),this.uuid=Je(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let i=0,n=this.holes.length;i<n;i++)e[i]=this.holes[i].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,i=t.holes.length;e<i;e++){const i=t.holes[e];this.holes.push(i.clone())}return this}toJSON(){const t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,i=this.holes.length;e<i;e++){const i=this.holes[e];t.holes.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,i=t.holes.length;e<i;e++){const i=t.holes[e];this.holes.push((new Hh).fromJSON(i))}return this}}function nc(t,e,i,n,s){let r,a;if(s===function(t,e,i,n){let s=0;for(let r=e,a=i-n;r<i;r+=n)s+=(t[a]-t[r])*(t[r+1]+t[a+1]),a=r;return s}(t,e,i,n)>0)for(r=e;r<i;r+=n)a=wc(r,t[r],t[r+1],a);else for(r=i-n;r>=e;r-=n)a=wc(r,t[r],t[r+1],a);return a&&vc(a,a.next)&&(Tc(a),a=a.next),a}function sc(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!vc(n,n.next)&&0!==_c(n.prev,n,n.next))n=n.next;else{if(Tc(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function rc(t,e,i,n,s,r,a){if(!t)return;!a&&r&&function(t,e,i,n){let s=t;do{0===s.z&&(s.z=pc(s.x,s.y,e,i,n)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,function(t){let e,i,n,s,r,a,o,l,h=1;do{for(i=t,t=null,r=null,a=0;i;){for(a++,n=i,o=0,e=0;e<h&&(o++,n=n.nextZ,n);e++);for(l=h;o>0||l>0&&n;)0!==o&&(0===l||!n||i.z<=n.z)?(s=i,i=i.nextZ,o--):(s=n,n=n.nextZ,l--),r?r.nextZ=s:t=s,s.prevZ=r,r=s;i=n}r.nextZ=null,h*=2}while(a>1)}(s)}(t,n,s,r);let o,l,h=t;for(;t.prev!==t.next;)if(o=t.prev,l=t.next,r?oc(t,n,s,r):ac(t))e.push(o.i/i|0),e.push(t.i/i|0),e.push(l.i/i|0),Tc(t),t=l.next,h=l.next;else if((t=l)===h){a?1===a?rc(t=lc(sc(t),e,i),e,i,n,s,r,2):2===a&&hc(t,e,i,n,s,r):rc(sc(t),e,i,n,s,r,1);break}}function ac(t){const e=t.prev,i=t,n=t.next;if(_c(e,i,n)>=0)return!1;const s=e.x,r=i.x,a=n.x,o=e.y,l=i.y,h=n.y,c=s<r?s<a?s:a:r<a?r:a,u=o<l?o<h?o:h:l<h?l:h,d=s>r?s>a?s:a:r>a?r:a,p=o>l?o>h?o:h:l>h?l:h;let m=n.next;for(;m!==e;){if(m.x>=c&&m.x<=d&&m.y>=u&&m.y<=p&&fc(s,o,r,l,a,h,m.x,m.y)&&_c(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function oc(t,e,i,n){const s=t.prev,r=t,a=t.next;if(_c(s,r,a)>=0)return!1;const o=s.x,l=r.x,h=a.x,c=s.y,u=r.y,d=a.y,p=o<l?o<h?o:h:l<h?l:h,m=c<u?c<d?c:d:u<d?u:d,f=o>l?o>h?o:h:l>h?l:h,g=c>u?c>d?c:d:u>d?u:d,_=pc(p,m,e,i,n),v=pc(f,g,e,i,n);let y=t.prevZ,x=t.nextZ;for(;y&&y.z>=_&&x&&x.z<=v;){if(y.x>=p&&y.x<=f&&y.y>=m&&y.y<=g&&y!==s&&y!==a&&fc(o,c,l,u,h,d,y.x,y.y)&&_c(y.prev,y,y.next)>=0)return!1;if(y=y.prevZ,x.x>=p&&x.x<=f&&x.y>=m&&x.y<=g&&x!==s&&x!==a&&fc(o,c,l,u,h,d,x.x,x.y)&&_c(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=f&&y.y>=m&&y.y<=g&&y!==s&&y!==a&&fc(o,c,l,u,h,d,y.x,y.y)&&_c(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;x&&x.z<=v;){if(x.x>=p&&x.x<=f&&x.y>=m&&x.y<=g&&x!==s&&x!==a&&fc(o,c,l,u,h,d,x.x,x.y)&&_c(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function lc(t,e,i){let n=t;do{const s=n.prev,r=n.next.next;!vc(s,r)&&yc(s,n,n.next,r)&&bc(s,r)&&bc(r,s)&&(e.push(s.i/i|0),e.push(n.i/i|0),e.push(r.i/i|0),Tc(n),Tc(n.next),n=t=r),n=n.next}while(n!==t);return sc(n)}function hc(t,e,i,n,s,r){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&gc(a,t)){let o=Sc(a,t);return a=sc(a,a.next),o=sc(o,o.next),rc(a,e,i,n,s,r,0),void rc(o,e,i,n,s,r,0)}t=t.next}a=a.next}while(a!==t)}function cc(t,e){return t.x-e.x}function uc(t,e){const i=function(t,e){let i,n=e,s=-1/0;const r=t.x,a=t.y;do{if(a<=n.y&&a>=n.next.y&&n.next.y!==n.y){const t=n.x+(a-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(t<=r&&t>s&&(s=t,i=n.x<n.next.x?n:n.next,t===r))return i}n=n.next}while(n!==e);if(!i)return null;const o=i,l=i.x,h=i.y;let c,u=1/0;n=i;do{r>=n.x&&n.x>=l&&r!==n.x&&fc(a<h?r:s,a,l,h,a<h?s:r,a,n.x,n.y)&&(c=Math.abs(a-n.y)/(r-n.x),bc(n,t)&&(c<u||c===u&&(n.x>i.x||n.x===i.x&&dc(i,n)))&&(i=n,u=c)),n=n.next}while(n!==o);return i}(t,e);if(!i)return e;const n=Sc(i,t);return sc(n,n.next),sc(i,i.next)}function dc(t,e){return _c(t.prev,t,e.prev)<0&&_c(e.next,t,t.next)<0}function pc(t,e,i,n,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*s|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*s|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function mc(t){let e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function fc(t,e,i,n,s,r,a,o){return(s-a)*(e-o)>=(t-a)*(r-o)&&(t-a)*(n-o)>=(i-a)*(e-o)&&(i-a)*(r-o)>=(s-a)*(n-o)}function gc(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&yc(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(bc(t,e)&&bc(e,t)&&function(t,e){let i=t,n=!1;const s=(t.x+e.x)/2,r=(t.y+e.y)/2;do{i.y>r!=i.next.y>r&&i.next.y!==i.y&&s<(i.next.x-i.x)*(r-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)&&(_c(t.prev,t,e.prev)||_c(t,e.prev,e))||vc(t,e)&&_c(t.prev,t,t.next)>0&&_c(e.prev,e,e.next)>0)}function _c(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function vc(t,e){return t.x===e.x&&t.y===e.y}function yc(t,e,i,n){const s=Mc(_c(t,e,i)),r=Mc(_c(t,e,n)),a=Mc(_c(i,n,t)),o=Mc(_c(i,n,e));return s!==r&&a!==o||!(0!==s||!xc(t,i,e))||!(0!==r||!xc(t,n,e))||!(0!==a||!xc(i,t,n))||!(0!==o||!xc(i,e,n))}function xc(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function Mc(t){return t>0?1:t<0?-1:0}function bc(t,e){return _c(t.prev,t,t.next)<0?_c(t,e,t.next)>=0&&_c(t,t.prev,e)>=0:_c(t,e,t.prev)<0||_c(t,t.next,e)<0}function Sc(t,e){const i=new Ec(t.i,t.x,t.y),n=new Ec(e.i,e.x,e.y),s=t.next,r=e.prev;return t.next=e,e.prev=t,i.next=s,s.prev=i,n.next=i,i.prev=n,r.next=n,n.prev=r,n}function wc(t,e,i,n){const s=new Ec(t,e,i);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function Tc(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Ec(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}class Ac{static area(t){const e=t.length;let i=0;for(let n=e-1,s=0;s<e;n=s++)i+=t[n].x*t[s].y-t[s].x*t[n].y;return.5*i}static isClockWise(t){return Ac.area(t)<0}static triangulateShape(t,e){const i=[],n=[],s=[];Cc(t),Rc(i,t);let r=t.length;e.forEach(Cc);for(let o=0;o<e.length;o++)n.push(r),r+=e[o].length,Rc(i,e[o]);const a=function(t,e,i=2){const n=e&&e.length,s=n?e[0]*i:t.length;let r=nc(t,0,s,i,!0);const a=[];if(!r||r.next===r.prev)return a;let o,l,h,c,u,d,p;if(n&&(r=function(t,e,i,n){const s=[];let r,a,o,l,h;for(r=0,a=e.length;r<a;r++)o=e[r]*n,l=r<a-1?e[r+1]*n:t.length,h=nc(t,o,l,n,!1),h===h.next&&(h.steiner=!0),s.push(mc(h));for(s.sort(cc),r=0;r<s.length;r++)i=uc(s[r],i);return i}(t,e,r,i)),t.length>80*i){o=h=t[0],l=c=t[1];for(let e=i;e<s;e+=i)u=t[e],d=t[e+1],u<o&&(o=u),d<l&&(l=d),u>h&&(h=u),d>c&&(c=d);p=Math.max(h-o,c-l),p=0!==p?32767/p:0}return rc(r,a,i,o,l,p,0),a}(i,n);for(let o=0;o<a.length;o+=3)s.push(a.slice(o,o+3));return s}}function Cc(t){const e=t.length;e>2&&t[e-1].equals(t[0])&&t.pop()}function Rc(t,e){for(let i=0;i<e.length;i++)t.push(e[i].x),t.push(e[i].y)}class Pc extends Ss{constructor(t=new ic([new ri(.5,.5),new ri(-.5,.5),new ri(-.5,-.5),new ri(.5,-.5)]),e={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];const i=this,n=[],s=[];for(let a=0,o=t.length;a<o;a++)r(t[a]);function r(t){const r=[],a=void 0!==e.curveSegments?e.curveSegments:12,o=void 0!==e.steps?e.steps:1,l=void 0!==e.depth?e.depth:1;let h=void 0===e.bevelEnabled||e.bevelEnabled,c=void 0!==e.bevelThickness?e.bevelThickness:.2,u=void 0!==e.bevelSize?e.bevelSize:c-.1,d=void 0!==e.bevelOffset?e.bevelOffset:0,p=void 0!==e.bevelSegments?e.bevelSegments:3;const m=e.extrudePath,f=void 0!==e.UVGenerator?e.UVGenerator:Lc;let g,_,v,y,x,M=!1;m&&(g=m.getSpacedPoints(o),M=!0,h=!1,_=m.computeFrenetFrames(o,!1),v=new Ni,y=new Ni,x=new Ni),h||(p=0,c=0,u=0,d=0);const b=t.extractPoints(a);let S=b.shape;const w=b.holes;if(!Ac.isClockWise(S)){S=S.reverse();for(let t=0,e=w.length;t<e;t++){const e=w[t];Ac.isClockWise(e)&&(w[t]=e.reverse())}}const T=Ac.triangulateShape(S,w),E=S;for(let e=0,i=w.length;e<i;e++){const t=w[e];S=S.concat(t)}function A(t,e,i){return t.clone().addScaledVector(e,i)}const C=S.length,R=T.length;function P(t,e,i){let n,s,r;const a=t.x-e.x,o=t.y-e.y,l=i.x-t.x,h=i.y-t.y,c=a*a+o*o,u=a*h-o*l;if(Math.abs(u)>Number.EPSILON){const u=Math.sqrt(c),d=Math.sqrt(l*l+h*h),p=e.x-o/u,m=e.y+a/u,f=((i.x-h/d-p)*h-(i.y+l/d-m)*l)/(a*h-o*l);n=p+a*f-t.x,s=m+o*f-t.y;const g=n*n+s*s;if(g<=2)return new ri(n,s);r=Math.sqrt(g/2)}else{let t=!1;a>Number.EPSILON?l>Number.EPSILON&&(t=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(t=!0):Math.sign(o)===Math.sign(h)&&(t=!0),t?(n=-o,s=a,r=Math.sqrt(c)):(n=a,s=o,r=Math.sqrt(c/2))}return new ri(n/r,s/r)}const L=[];for(let e=0,i=E.length,n=i-1,s=e+1;e<i;e++,n++,s++)n===i&&(n=0),s===i&&(s=0),L[e]=P(E[e],E[n],E[s]);const I=[];let D,U=L.concat();for(let e=0,i=w.length;e<i;e++){const t=w[e];D=[];for(let e=0,i=t.length,n=i-1,s=e+1;e<i;e++,n++,s++)n===i&&(n=0),s===i&&(s=0),D[e]=P(t[e],t[n],t[s]);I.push(D),U=U.concat(D)}for(let e=0;e<p;e++){const t=e/p,i=c*Math.cos(t*Math.PI/2),n=u*Math.sin(t*Math.PI/2)+d;for(let e=0,s=E.length;e<s;e++){const t=A(E[e],L[e],n);F(t.x,t.y,-i)}for(let e=0,s=w.length;e<s;e++){const t=w[e];D=I[e];for(let e=0,s=t.length;e<s;e++){const s=A(t[e],D[e],n);F(s.x,s.y,-i)}}}const N=u+d;for(let e=0;e<C;e++){const t=h?A(S[e],U[e],N):S[e];M?(y.copy(_.normals[0]).multiplyScalar(t.x),v.copy(_.binormals[0]).multiplyScalar(t.y),x.copy(g[0]).add(y).add(v),F(x.x,x.y,x.z)):F(t.x,t.y,0)}for(let e=1;e<=o;e++)for(let t=0;t<C;t++){const i=h?A(S[t],U[t],N):S[t];M?(y.copy(_.normals[e]).multiplyScalar(i.x),v.copy(_.binormals[e]).multiplyScalar(i.y),x.copy(g[e]).add(y).add(v),F(x.x,x.y,x.z)):F(i.x,i.y,l/o*e)}for(let e=p-1;e>=0;e--){const t=e/p,i=c*Math.cos(t*Math.PI/2),n=u*Math.sin(t*Math.PI/2)+d;for(let e=0,s=E.length;e<s;e++){const t=A(E[e],L[e],n);F(t.x,t.y,l+i)}for(let e=0,s=w.length;e<s;e++){const t=w[e];D=I[e];for(let e=0,s=t.length;e<s;e++){const s=A(t[e],D[e],n);M?F(s.x,s.y+g[o-1].y,g[o-1].x+i):F(s.x,s.y,l+i)}}}function O(t,e){let i=t.length;for(;--i>=0;){const n=i;let s=i-1;s<0&&(s=t.length-1);for(let t=0,i=o+2*p;t<i;t++){const i=C*t,r=C*(t+1);z(e+n+i,e+s+i,e+s+r,e+n+r)}}}function F(t,e,i){r.push(t),r.push(e),r.push(i)}function B(t,e,s){k(t),k(e),k(s);const r=n.length/3,a=f.generateTopUV(i,n,r-3,r-2,r-1);V(a[0]),V(a[1]),V(a[2])}function z(t,e,s,r){k(t),k(e),k(r),k(e),k(s),k(r);const a=n.length/3,o=f.generateSideWallUV(i,n,a-6,a-3,a-2,a-1);V(o[0]),V(o[1]),V(o[3]),V(o[1]),V(o[2]),V(o[3])}function k(t){n.push(r[3*t+0]),n.push(r[3*t+1]),n.push(r[3*t+2])}function V(t){s.push(t.x),s.push(t.y)}!function(){const t=n.length/3;if(h){let t=0,e=C*t;for(let i=0;i<R;i++){const t=T[i];B(t[2]+e,t[1]+e,t[0]+e)}t=o+2*p,e=C*t;for(let i=0;i<R;i++){const t=T[i];B(t[0]+e,t[1]+e,t[2]+e)}}else{for(let t=0;t<R;t++){const e=T[t];B(e[2],e[1],e[0])}for(let t=0;t<R;t++){const e=T[t];B(e[0]+C*o,e[1]+C*o,e[2]+C*o)}}i.addGroup(t,n.length/3-t,0)}(),function(){const t=n.length/3;let e=0;O(E,e),e+=E.length;for(let i=0,n=w.length;i<n;i++){const t=w[i];O(t,e),e+=t.length}i.addGroup(t,n.length/3-t,1)}()}this.setAttribute("position",new fs(n,3)),this.setAttribute("uv",new fs(s,2)),this.computeVertexNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return function(t,e,i){if(i.shapes=[],Array.isArray(t))for(let n=0,s=t.length;n<s;n++){const e=t[n];i.shapes.push(e.uuid)}else i.shapes.push(t.uuid);return i.options=Object.assign({},e),void 0!==e.extrudePath&&(i.options.extrudePath=e.extrudePath.toJSON()),i}(this.parameters.shapes,this.parameters.options,t)}static fromJSON(t,e){const i=[];for(let s=0,r=t.shapes.length;s<r;s++){const n=e[t.shapes[s]];i.push(n)}const n=t.options.extrudePath;return void 0!==n&&(t.options.extrudePath=(new Vh[n.type]).fromJSON(n)),new Pc(i,t.options)}}const Lc={generateTopUV(t,e,i,n,s){const r=e[3*i],a=e[3*i+1],o=e[3*n],l=e[3*n+1],h=e[3*s],c=e[3*s+1];return[new ri(r,a),new ri(o,l),new ri(h,c)]},generateSideWallUV(t,e,i,n,s,r){const a=e[3*i],o=e[3*i+1],l=e[3*i+2],h=e[3*n],c=e[3*n+1],u=e[3*n+2],d=e[3*s],p=e[3*s+1],m=e[3*s+2],f=e[3*r],g=e[3*r+1],_=e[3*r+2];return Math.abs(o-c)<Math.abs(a-h)?[new ri(a,1-l),new ri(h,1-u),new ri(d,1-m),new ri(f,1-_)]:[new ri(o,1-l),new ri(c,1-u),new ri(p,1-m),new ri(g,1-_)]}};class Ic extends Zh{constructor(t=1,e=0){const i=(1+Math.sqrt(5))/2;super([-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],[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],t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Ic(t.radius,t.detail)}}class Dc extends Zh{constructor(t=1,e=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],t,e),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Dc(t.radius,t.detail)}}class Uc extends Ss{constructor(t=.5,e=1,i=32,n=1,s=0,r=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:i,phiSegments:n,thetaStart:s,thetaLength:r},i=Math.max(3,i);const a=[],o=[],l=[],h=[];let c=t;const u=(e-t)/(n=Math.max(1,n)),d=new Ni,p=new ri;for(let m=0;m<=n;m++){for(let t=0;t<=i;t++){const n=s+t/i*r;d.x=c*Math.cos(n),d.y=c*Math.sin(n),o.push(d.x,d.y,d.z),l.push(0,0,1),p.x=(d.x/e+1)/2,p.y=(d.y/e+1)/2,h.push(p.x,p.y)}c+=u}for(let m=0;m<n;m++){const t=m*(i+1);for(let e=0;e<i;e++){const n=e+t,s=n,r=n+i+1,o=n+i+2,l=n+1;a.push(s,r,l),a.push(r,o,l)}}this.setIndex(a),this.setAttribute("position",new fs(o,3)),this.setAttribute("normal",new fs(l,3)),this.setAttribute("uv",new fs(h,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Uc(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}}class Nc extends Ss{constructor(t=new ic([new ri(0,.5),new ri(-.5,-.5),new ri(.5,-.5)]),e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};const i=[],n=[],s=[],r=[];let a=0,o=0;if(!1===Array.isArray(t))l(t);else for(let h=0;h<t.length;h++)l(t[h]),this.addGroup(a,o,h),a+=o,o=0;function l(t){const a=n.length/3,l=t.extractPoints(e);let h=l.shape;const c=l.holes;!1===Ac.isClockWise(h)&&(h=h.reverse());for(let e=0,i=c.length;e<i;e++){const t=c[e];!0===Ac.isClockWise(t)&&(c[e]=t.reverse())}const u=Ac.triangulateShape(h,c);for(let e=0,i=c.length;e<i;e++){const t=c[e];h=h.concat(t)}for(let e=0,i=h.length;e<i;e++){const t=h[e];n.push(t.x,t.y,0),s.push(0,0,1),r.push(t.x,t.y)}for(let e=0,n=u.length;e<n;e++){const t=u[e],n=t[0]+a,s=t[1]+a,r=t[2]+a;i.push(n,s,r),o+=3}}this.setIndex(i),this.setAttribute("position",new fs(n,3)),this.setAttribute("normal",new fs(s,3)),this.setAttribute("uv",new fs(r,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return function(t,e){if(e.shapes=[],Array.isArray(t))for(let i=0,n=t.length;i<n;i++){const n=t[i];e.shapes.push(n.uuid)}else e.shapes.push(t.uuid);return e}(this.parameters.shapes,t)}static fromJSON(t,e){const i=[];for(let n=0,s=t.shapes.length;n<s;n++){const s=e[t.shapes[n]];i.push(s)}return new Nc(i,t.curveSegments)}}class Oc extends Ss{constructor(t=1,e=32,i=16,n=0,s=2*Math.PI,r=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:i,phiStart:n,phiLength:s,thetaStart:r,thetaLength:a},e=Math.max(3,Math.floor(e)),i=Math.max(2,Math.floor(i));const o=Math.min(r+a,Math.PI);let l=0;const h=[],c=new Ni,u=new Ni,d=[],p=[],m=[],f=[];for(let g=0;g<=i;g++){const d=[],_=g/i;let v=0;0===g&&0===r?v=.5/e:g===i&&o===Math.PI&&(v=-.5/e);for(let i=0;i<=e;i++){const o=i/e;c.x=-t*Math.cos(n+o*s)*Math.sin(r+_*a),c.y=t*Math.cos(r+_*a),c.z=t*Math.sin(n+o*s)*Math.sin(r+_*a),p.push(c.x,c.y,c.z),u.copy(c).normalize(),m.push(u.x,u.y,u.z),f.push(o+v,1-_),d.push(l++)}h.push(d)}for(let g=0;g<i;g++)for(let t=0;t<e;t++){const e=h[g][t+1],n=h[g][t],s=h[g+1][t],a=h[g+1][t+1];(0!==g||r>0)&&d.push(e,n,a),(g!==i-1||o<Math.PI)&&d.push(n,s,a)}this.setIndex(d),this.setAttribute("position",new fs(p,3)),this.setAttribute("normal",new fs(m,3)),this.setAttribute("uv",new fs(f,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Oc(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class Fc extends Zh{constructor(t=1,e=0){super([1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],t,e),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Fc(t.radius,t.detail)}}class Bc extends Ss{constructor(t=1,e=.4,i=12,n=48,s=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:i,tubularSegments:n,arc:s},i=Math.floor(i),n=Math.floor(n);const r=[],a=[],o=[],l=[],h=new Ni,c=new Ni,u=new Ni;for(let d=0;d<=i;d++)for(let r=0;r<=n;r++){const p=r/n*s,m=d/i*Math.PI*2;c.x=(t+e*Math.cos(m))*Math.cos(p),c.y=(t+e*Math.cos(m))*Math.sin(p),c.z=e*Math.sin(m),a.push(c.x,c.y,c.z),h.x=t*Math.cos(p),h.y=t*Math.sin(p),u.subVectors(c,h).normalize(),o.push(u.x,u.y,u.z),l.push(r/n),l.push(d/i)}for(let d=1;d<=i;d++)for(let t=1;t<=n;t++){const e=(n+1)*d+t-1,i=(n+1)*(d-1)+t-1,s=(n+1)*(d-1)+t,a=(n+1)*d+t;r.push(e,i,a),r.push(i,s,a)}this.setIndex(r),this.setAttribute("position",new fs(a,3)),this.setAttribute("normal",new fs(o,3)),this.setAttribute("uv",new fs(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Bc(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class zc extends Ss{constructor(t=1,e=.4,i=64,n=8,s=2,r=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:i,radialSegments:n,p:s,q:r},i=Math.floor(i),n=Math.floor(n);const a=[],o=[],l=[],h=[],c=new Ni,u=new Ni,d=new Ni,p=new Ni,m=new Ni,f=new Ni,g=new Ni;for(let v=0;v<=i;++v){const a=v/i*s*Math.PI*2;_(a,s,r,t,d),_(a+.01,s,r,t,p),f.subVectors(p,d),g.addVectors(p,d),m.crossVectors(f,g),g.crossVectors(m,f),m.normalize(),g.normalize();for(let t=0;t<=n;++t){const s=t/n*Math.PI*2,r=-e*Math.cos(s),a=e*Math.sin(s);c.x=d.x+(r*g.x+a*m.x),c.y=d.y+(r*g.y+a*m.y),c.z=d.z+(r*g.z+a*m.z),o.push(c.x,c.y,c.z),u.subVectors(c,d).normalize(),l.push(u.x,u.y,u.z),h.push(v/i),h.push(t/n)}}for(let v=1;v<=i;v++)for(let t=1;t<=n;t++){const e=(n+1)*(v-1)+(t-1),i=(n+1)*v+(t-1),s=(n+1)*v+t,r=(n+1)*(v-1)+t;a.push(e,i,r),a.push(i,s,r)}function _(t,e,i,n,s){const r=Math.cos(t),a=Math.sin(t),o=i/e*t,l=Math.cos(o);s.x=n*(2+l)*.5*r,s.y=n*(2+l)*a*.5,s.z=n*Math.sin(o)*.5}this.setIndex(a),this.setAttribute("position",new fs(o,3)),this.setAttribute("normal",new fs(l,3)),this.setAttribute("uv",new fs(h,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new zc(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}}class kc extends Ss{constructor(t=new zh(new Ni(-1,-1,0),new Ni(-1,1,0),new Ni(1,1,0)),e=64,i=1,n=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:i,radialSegments:n,closed:s};const r=t.computeFrenetFrames(e,s);this.tangents=r.tangents,this.normals=r.normals,this.binormals=r.binormals;const a=new Ni,o=new Ni,l=new ri;let h=new Ni;const c=[],u=[],d=[],p=[];function m(s){h=t.getPointAt(s/e,h);const l=r.normals[s],d=r.binormals[s];for(let t=0;t<=n;t++){const e=t/n*Math.PI*2,s=Math.sin(e),r=-Math.cos(e);o.x=r*l.x+s*d.x,o.y=r*l.y+s*d.y,o.z=r*l.z+s*d.z,o.normalize(),u.push(o.x,o.y,o.z),a.x=h.x+i*o.x,a.y=h.y+i*o.y,a.z=h.z+i*o.z,c.push(a.x,a.y,a.z)}}!function(){for(let t=0;t<e;t++)m(t);m(!1===s?e:0),function(){for(let t=0;t<=e;t++)for(let i=0;i<=n;i++)l.x=t/e,l.y=i/n,d.push(l.x,l.y)}(),function(){for(let t=1;t<=e;t++)for(let e=1;e<=n;e++){const i=(n+1)*(t-1)+(e-1),s=(n+1)*t+(e-1),r=(n+1)*t+e,a=(n+1)*(t-1)+e;p.push(i,s,a),p.push(s,r,a)}}()}(),this.setIndex(p),this.setAttribute("position",new fs(c,3)),this.setAttribute("normal",new fs(u,3)),this.setAttribute("uv",new fs(d,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return t.path=this.parameters.path.toJSON(),t}static fromJSON(t){return new kc((new Vh[t.path.type]).fromJSON(t.path),t.tubularSegments,t.radius,t.radialSegments,t.closed)}}class Vc extends Ss{constructor(t=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:t},null!==t){const e=[],i=new Set,n=new Ni,s=new Ni;if(null!==t.index){const r=t.attributes.position,a=t.index;let o=t.groups;0===o.length&&(o=[{start:0,count:a.count,materialIndex:0}]);for(let t=0,l=o.length;t<l;++t){const l=o[t],h=l.start;for(let t=h,o=h+l.count;t<o;t+=3)for(let l=0;l<3;l++){const o=a.getX(t+l),h=a.getX(t+(l+1)%3);n.fromBufferAttribute(r,o),s.fromBufferAttribute(r,h),!0===Gc(n,s,i)&&(e.push(n.x,n.y,n.z),e.push(s.x,s.y,s.z))}}}else{const r=t.attributes.position;for(let t=0,a=r.count/3;t<a;t++)for(let o=0;o<3;o++){const a=3*t+o,l=3*t+(o+1)%3;n.fromBufferAttribute(r,a),s.fromBufferAttribute(r,l),!0===Gc(n,s,i)&&(e.push(n.x,n.y,n.z),e.push(s.x,s.y,s.z))}}this.setAttribute("position",new fs(e,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}function Gc(t,e,i){const n=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`,s=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`;return!0!==i.has(n)&&!0!==i.has(s)&&(i.add(n),i.add(s),!0)}var Hc=Object.freeze({__proto__:null,BoxGeometry:Hs,CapsuleGeometry:qh,CircleGeometry:Xh,ConeGeometry:Yh,CylinderGeometry:jh,DodecahedronGeometry:Jh,EdgesGeometry:ec,ExtrudeGeometry:Pc,IcosahedronGeometry:Ic,LatheGeometry:Wh,OctahedronGeometry:Dc,PlaneGeometry:cr,PolyhedronGeometry:Zh,RingGeometry:Uc,ShapeGeometry:Nc,SphereGeometry:Oc,TetrahedronGeometry:Fc,TorusGeometry:Bc,TorusKnotGeometry:zc,TubeGeometry:kc,WireframeGeometry:Vc});class Wc extends ns{constructor(t){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new ts(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 qc extends Ys{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Xc extends ns{constructor(t){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new ts(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 ts(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ri(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,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.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 jc extends Xc{constructor(t){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new ri(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get(){return Ke(2.5*(this.ior-1)/(this.ior+1),0,1)},set(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new ts(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new ts(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new ts(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class Yc extends ns{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new ts(16777215),this.specular=new ts(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ts(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ri(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,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.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Zc extends ns{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ts(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ts(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ri(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,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.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class Jc extends ns{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ri(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 Kc extends ns{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ts(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ts(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ri(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(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.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.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class $c extends ns{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ts(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ri(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,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.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Qc extends nh{constructor(t){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}function tu(t,e,i){return!t||!i&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)}function eu(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function iu(t){const e=t.length,i=new Array(e);for(let n=0;n!==e;++n)i[n]=n;return i.sort(function(e,i){return t[e]-t[i]}),i}function nu(t,e,i){const n=t.length,s=new t.constructor(n);for(let r=0,a=0;a!==n;++r){const n=i[r]*e;for(let i=0;i!==e;++i)s[a++]=t[n+i]}return s}function su(t,e,i,n){let s=1,r=t[0];for(;void 0!==r&&void 0===r[n];)r=t[s++];if(void 0===r)return;let a=r[n];if(void 0!==a)if(Array.isArray(a))do{a=r[n],void 0!==a&&(e.push(r.time),i.push.apply(i,a)),r=t[s++]}while(void 0!==r);else if(void 0!==a.toArray)do{a=r[n],void 0!==a&&(e.push(r.time),a.toArray(i,i.length)),r=t[s++]}while(void 0!==r);else do{a=r[n],void 0!==a&&(e.push(r.time),i.push(a)),r=t[s++]}while(void 0!==r)}const ru={convertArray:tu,isTypedArray:eu,getKeyframeOrder:iu,sortedArray:nu,flattenJSON:su,subclip(t,e,i,n,s=30){const r=t.clone();r.name=e;const a=[];for(let l=0;l<r.tracks.length;++l){const t=r.tracks[l],e=t.getValueSize(),o=[],h=[];for(let r=0;r<t.times.length;++r){const a=t.times[r]*s;if(!(a<i||a>=n)){o.push(t.times[r]);for(let i=0;i<e;++i)h.push(t.values[r*e+i])}}0!==o.length&&(t.times=tu(o,t.times.constructor),t.values=tu(h,t.values.constructor),a.push(t))}r.tracks=a;let o=1/0;for(let l=0;l<r.tracks.length;++l)o>r.tracks[l].times[0]&&(o=r.tracks[l].times[0]);for(let l=0;l<r.tracks.length;++l)r.tracks[l].shift(-1*o);return r.resetDuration(),r},makeClipAdditive(t,e=0,i=t,n=30){n<=0&&(n=30);const s=i.tracks.length,r=e/n;for(let a=0;a<s;++a){const e=i.tracks[a],n=e.ValueTypeName;if("bool"===n||"string"===n)continue;const s=t.tracks.find(function(t){return t.name===e.name&&t.ValueTypeName===n});if(void 0===s)continue;let o=0;const l=e.getValueSize();e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(o=l/3);let h=0;const c=s.getValueSize();s.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=c/3);const u=e.times.length-1;let d;if(r<=e.times[0]){const t=o,i=l-o;d=e.values.slice(t,i)}else if(r>=e.times[u]){const t=u*l+o,i=t+l-o;d=e.values.slice(t,i)}else{const t=e.createInterpolant(),i=o,n=l-o;t.evaluate(r),d=t.resultBuffer.slice(i,n)}"quaternion"===n&&(new Ui).fromArray(d).normalize().conjugate().toArray(d);const p=s.times.length;for(let t=0;t<p;++t){const e=t*c+h;if("quaternion"===n)Ui.multiplyQuaternionsFlat(s.values,e,d,0,s.values,e);else{const t=c-2*h;for(let i=0;i<t;++i)s.values[e+i]-=d[i]}}}return t.blendMode=ye,t}};class au{constructor(t,e,i,n){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==n?n:new e.constructor(i),this.sampleValues=e,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let i=this._cachedIndex,n=e[i],s=e[i-1];t:{e:{let r;i:{n:if(!(t<n)){for(let r=i+2;;){if(void 0===n){if(t<s)break n;return i=e.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===r)break;if(s=n,n=e[++i],t<n)break e}r=e.length;break i}if(!(t>=s)){const a=e[1];t<a&&(i=2,s=a);for(let r=i-2;;){if(void 0===s)return this._cachedIndex=0,this.copySampleValue_(0);if(i===r)break;if(n=s,s=e[--i-1],t>=s)break e}r=i,i=0;break i}break t}for(;i<r;){const n=i+r>>>1;t<e[n]?r=n:i=n+1}if(n=e[i],s=e[i-1],void 0===s)return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===n)return i=e.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,n)}return this.interpolate_(i,s,t,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){const e=this.resultBuffer,i=this.sampleValues,n=this.valueSize,s=t*n;for(let r=0;r!==n;++r)e[r]=i[s+r];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class ou extends au{constructor(t,e,i,n){super(t,e,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:ge,endingEnd:ge}}intervalChanged_(t,e,i){const n=this.parameterPositions;let s=t-2,r=t+1,a=n[s],o=n[r];if(void 0===a)switch(this.getSettings_().endingStart){case _e:s=t,a=2*e-i;break;case ve:s=n.length-2,a=e+n[s]-n[s+1];break;default:s=t,a=i}if(void 0===o)switch(this.getSettings_().endingEnd){case _e:r=t,o=2*i-e;break;case ve:r=1,o=i+n[1]-n[0];break;default:r=t-1,o=e}const l=.5*(i-e),h=this.valueSize;this._weightPrev=l/(e-a),this._weightNext=l/(o-i),this._offsetPrev=s*h,this._offsetNext=r*h}interpolate_(t,e,i,n){const s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=t*a,l=o-a,h=this._offsetPrev,c=this._offsetNext,u=this._weightPrev,d=this._weightNext,p=(i-e)/(n-e),m=p*p,f=m*p,g=-u*f+2*u*m-u*p,_=(1+u)*f+(-1.5-2*u)*m+(-.5+u)*p+1,v=(-1-d)*f+(1.5+d)*m+.5*p,y=d*f-d*m;for(let x=0;x!==a;++x)s[x]=g*r[h+x]+_*r[l+x]+v*r[o+x]+y*r[c+x];return s}}class lu extends au{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t,e,i,n){const s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=t*a,l=o-a,h=(i-e)/(n-e),c=1-h;for(let u=0;u!==a;++u)s[u]=r[l+u]*c+r[o+u]*h;return s}}class hu extends au{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t){return this.copySampleValue_(t-1)}}class cu{constructor(t,e,i,n){if(void 0===t)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===e||0===e.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=tu(e,this.TimeBufferType),this.values=tu(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let i;if(e.toJSON!==this.toJSON)i=e.toJSON(t);else{i={name:t.name,times:tu(t.times,Array),values:tu(t.values,Array)};const e=t.getInterpolation();e!==t.DefaultInterpolation&&(i.interpolation=e)}return i.type=t.ValueTypeName,i}InterpolantFactoryMethodDiscrete(t){return new hu(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new lu(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new ou(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case pe:e=this.InterpolantFactoryMethodDiscrete;break;case me:e=this.InterpolantFactoryMethodLinear;break;case fe:e=this.InterpolantFactoryMethodSmooth}if(void 0===e){const e="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(t===this.DefaultInterpolation)throw new Error(e);this.setInterpolation(this.DefaultInterpolation)}return this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return pe;case this.InterpolantFactoryMethodLinear:return me;case this.InterpolantFactoryMethodSmooth:return fe}}getValueSize(){return this.values.length/this.times.length}shift(t){if(0!==t){const e=this.times;for(let i=0,n=e.length;i!==n;++i)e[i]+=t}return this}scale(t){if(1!==t){const e=this.times;for(let i=0,n=e.length;i!==n;++i)e[i]*=t}return this}trim(t,e){const i=this.times,n=i.length;let s=0,r=n-1;for(;s!==n&&i[s]<t;)++s;for(;-1!==r&&i[r]>e;)--r;if(++r,0!==s||r!==n){s>=r&&(r=Math.max(r,1),s=r-1);const t=this.getValueSize();this.times=i.slice(s,r),this.values=this.values.slice(s*t,r*t)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!==0&&(t=!1);const i=this.times,n=this.values,s=i.length;0===s&&(t=!1);let r=null;for(let a=0;a!==s;a++){const e=i[a];if("number"==typeof e&&isNaN(e)){t=!1;break}if(null!==r&&r>e){t=!1;break}r=e}if(void 0!==n&&eu(n))for(let a=0,o=n.length;a!==o;++a){const e=n[a];if(isNaN(e)){t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),i=this.getValueSize(),n=this.getInterpolation()===fe,s=t.length-1;let r=1;for(let a=1;a<s;++a){let s=!1;const o=t[a];if(o!==t[a+1]&&(1!==a||o!==t[0]))if(n)s=!0;else{const t=a*i,n=t-i,r=t+i;for(let a=0;a!==i;++a){const i=e[t+a];if(i!==e[n+a]||i!==e[r+a]){s=!0;break}}}if(s){if(a!==r){t[r]=t[a];const n=a*i,s=r*i;for(let t=0;t!==i;++t)e[s+t]=e[n+t]}++r}}if(s>0){t[r]=t[s];for(let t=s*i,n=r*i,a=0;a!==i;++a)e[n+a]=e[t+a];++r}return r!==t.length?(this.times=t.slice(0,r),this.values=e.slice(0,r*i)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),i=new(0,this.constructor)(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}}cu.prototype.TimeBufferType=Float32Array,cu.prototype.ValueBufferType=Float32Array,cu.prototype.DefaultInterpolation=me;class uu extends cu{}uu.prototype.ValueTypeName="bool",uu.prototype.ValueBufferType=Array,uu.prototype.DefaultInterpolation=pe,uu.prototype.InterpolantFactoryMethodLinear=void 0,uu.prototype.InterpolantFactoryMethodSmooth=void 0;class du extends cu{}du.prototype.ValueTypeName="color";class pu extends cu{}pu.prototype.ValueTypeName="number";class mu extends au{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t,e,i,n){const s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=(i-e)/(n-e);let l=t*a;for(let h=l+a;l!==h;l+=4)Ui.slerpFlat(s,0,r,l-a,r,l,o);return s}}class fu extends cu{InterpolantFactoryMethodLinear(t){return new mu(this.times,this.values,this.getValueSize(),t)}}fu.prototype.ValueTypeName="quaternion",fu.prototype.DefaultInterpolation=me,fu.prototype.InterpolantFactoryMethodSmooth=void 0;class gu extends cu{}gu.prototype.ValueTypeName="string",gu.prototype.ValueBufferType=Array,gu.prototype.DefaultInterpolation=pe,gu.prototype.InterpolantFactoryMethodLinear=void 0,gu.prototype.InterpolantFactoryMethodSmooth=void 0;class _u extends cu{}_u.prototype.ValueTypeName="vector";class vu{constructor(t,e=-1,i,n=2500){this.name=t,this.tracks=i,this.duration=e,this.blendMode=n,this.uuid=Je(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],i=t.tracks,n=1/(t.fps||1);for(let r=0,a=i.length;r!==a;++r)e.push(yu(i[r]).scale(n));const s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s}static toJSON(t){const e=[],i=t.tracks,n={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let s=0,r=i.length;s!==r;++s)e.push(cu.toJSON(i[s]));return n}static CreateFromMorphTargetSequence(t,e,i,n){const s=e.length,r=[];for(let a=0;a<s;a++){let t=[],o=[];t.push((a+s-1)%s,a,(a+1)%s),o.push(0,1,0);const l=iu(t);t=nu(t,1,l),o=nu(o,1,l),n||0!==t[0]||(t.push(s),o.push(o[0])),r.push(new pu(".morphTargetInfluences["+e[a].name+"]",t,o).scale(1/i))}return new this(t,-1,r)}static findByName(t,e){let i=t;if(!Array.isArray(t)){const e=t;i=e.geometry&&e.geometry.animations||e.animations}for(let n=0;n<i.length;n++)if(i[n].name===e)return i[n];return null}static CreateClipsFromMorphTargetSequences(t,e,i){const n={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,o=t.length;a<o;a++){const e=t[a],i=e.name.match(s);if(i&&i.length>1){const t=i[1];let s=n[t];s||(n[t]=s=[]),s.push(e)}}const r=[];for(const a in n)r.push(this.CreateFromMorphTargetSequence(a,n[a],e,i));return r}static parseAnimation(t,e){if(!t)return null;const i=function(t,e,i,n,s){if(0!==i.length){const r=[],a=[];su(i,r,a,n),0!==r.length&&s.push(new t(e,r,a))}},n=[],s=t.name||"default",r=t.fps||30,a=t.blendMode;let o=t.length||-1;const l=t.hierarchy||[];for(let h=0;h<l.length;h++){const t=l[h].keys;if(t&&0!==t.length)if(t[0].morphTargets){const e={};let i;for(i=0;i<t.length;i++)if(t[i].morphTargets)for(let n=0;n<t[i].morphTargets.length;n++)e[t[i].morphTargets[n]]=-1;for(const s in e){const e=[],r=[];for(let n=0;n!==t[i].morphTargets.length;++n){const n=t[i];e.push(n.time),r.push(n.morphTarget===s?1:0)}n.push(new pu(".morphTargetInfluence["+s+"]",e,r))}o=e.length*r}else{const s=".bones["+e[h].name+"]";i(_u,s+".position",t,"pos",n),i(fu,s+".quaternion",t,"rot",n),i(_u,s+".scale",t,"scl",n)}}return 0===n.length?null:new this(s,o,n,a)}resetDuration(){let t=0;for(let e=0,i=this.tracks.length;e!==i;++e){const i=this.tracks[e];t=Math.max(t,i.times[i.times.length-1])}return this.duration=t,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){const t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function yu(t){if(void 0===t.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return pu;case"vector":case"vector2":case"vector3":case"vector4":return _u;case"color":return du;case"quaternion":return fu;case"bool":case"boolean":return uu;case"string":return gu}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}(t.type);if(void 0===t.times){const e=[],i=[];su(t.keys,e,i,"value"),t.times=e,t.values=i}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)}const xu={enabled:!1,files:{},add(t,e){!1!==this.enabled&&(this.files[t]=e)},get(t){if(!1!==this.enabled)return this.files[t]},remove(t){delete this.files[t]},clear(){this.files={}}};class Mu{constructor(t,e,i){const n=this;let s,r=!1,a=0,o=0;const l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=i,this.itemStart=function(t){o++,!1===r&&void 0!==n.onStart&&n.onStart(t,a,o),r=!0},this.itemEnd=function(t){a++,void 0!==n.onProgress&&n.onProgress(t,a,o),a===o&&(r=!1,void 0!==n.onLoad&&n.onLoad())},this.itemError=function(t){void 0!==n.onError&&n.onError(t)},this.resolveURL=function(t){return s?s(t):t},this.setURLModifier=function(t){return s=t,this},this.addHandler=function(t,e){return l.push(t,e),this},this.removeHandler=function(t){const e=l.indexOf(t);return-1!==e&&l.splice(e,2),this},this.getHandler=function(t){for(let e=0,i=l.length;e<i;e+=2){const i=l[e],n=l[e+1];if(i.global&&(i.lastIndex=0),i.test(t))return n}return null}}}const bu=new Mu;class Su{constructor(t){this.manager=void 0!==t?t:bu,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){const i=this;return new Promise(function(n,s){i.load(t,n,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}}Su.DEFAULT_MATERIAL_NAME="__DEFAULT";const wu={};class Tu extends Error{constructor(t,e){super(t),this.response=e}}class Eu extends Su{constructor(t){super(t)}load(t,e,i,n){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const s=xu.get(t);if(void 0!==s)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(void 0!==wu[t])return void wu[t].push({onLoad:e,onProgress:i,onError:n});wu[t]=[],wu[t].push({onLoad:e,onProgress:i,onError:n});const r=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,o=this.responseType;fetch(r).then(e=>{if(200===e.status||0===e.status){if(e.status,"undefined"==typeof ReadableStream||void 0===e.body||void 0===e.body.getReader)return e;const i=wu[t],n=e.body.getReader(),s=e.headers.get("Content-Length")||e.headers.get("X-File-Size"),r=s?parseInt(s):0,a=0!==r;let o=0;const l=new ReadableStream({start(t){!function e(){n.read().then(({done:n,value:s})=>{if(n)t.close();else{o+=s.byteLength;const n=new ProgressEvent("progress",{lengthComputable:a,loaded:o,total:r});for(let t=0,e=i.length;t<e;t++){const e=i[t];e.onProgress&&e.onProgress(n)}t.enqueue(s),e()}})}()}});return new Response(l)}throw new Tu(`fetch for "${e.url}" responded with ${e.status}: ${e.statusText}`,e)}).then(t=>{switch(o){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"document":return t.text().then(t=>(new DOMParser).parseFromString(t,a));case"json":return t.json();default:if(void 0===a)return t.text();{const e=/charset="?([^;"\s]*)"?/i.exec(a),i=e&&e[1]?e[1].toLowerCase():void 0,n=new TextDecoder(i);return t.arrayBuffer().then(t=>n.decode(t))}}}).then(e=>{xu.add(t,e);const i=wu[t];delete wu[t];for(let t=0,n=i.length;t<n;t++){const n=i[t];n.onLoad&&n.onLoad(e)}}).catch(e=>{const i=wu[t];if(void 0===i)throw this.manager.itemError(t),e;delete wu[t];for(let t=0,n=i.length;t<n;t++){const n=i[t];n.onError&&n.onError(e)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class Au extends Su{constructor(t){super(t)}load(t,e,i,n){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,r=xu.get(t);if(void 0!==r)return s.manager.itemStart(t),setTimeout(function(){e&&e(r),s.manager.itemEnd(t)},0),r;const a=ui("img");function o(){h(),xu.add(t,this),e&&e(this),s.manager.itemEnd(t)}function l(e){h(),n&&n(e),s.manager.itemError(t),s.manager.itemEnd(t)}function h(){a.removeEventListener("load",o,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",o,!1),a.addEventListener("error",l,!1),"data:"!==t.slice(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(t),a.src=t,a}}class Cu extends Fn{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new ts(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,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}class Ru extends Cu{constructor(t,e,i){super(t,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Fn.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ts(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}}const Pu=new dn,Lu=new Ni,Iu=new Ni;class Du{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ri(512,512),this.map=null,this.mapPass=null,this.matrix=new dn,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new or,this._frameExtents=new ri(1,1),this._viewportCount=1,this._viewports=[new Ri(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,i=this.matrix;Lu.setFromMatrixPosition(t.matrixWorld),e.position.copy(Lu),Iu.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(Iu),e.updateMatrixWorld(),Pu.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Pu),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Pu)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const t={};return 0!==this.bias&&(t.bias=this.bias),0!==this.normalBias&&(t.normalBias=this.normalBias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class Uu extends Du{constructor(){super(new Js(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){const e=this.camera,i=2*Ze*t.angle*this.focus,n=this.mapSize.width/this.mapSize.height,s=t.distance||e.far;i===e.fov&&n===e.aspect&&s===e.far||(e.fov=i,e.aspect=n,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class Nu extends Cu{constructor(t,e,i=0,n=Math.PI/3,s=0,r=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Fn.DEFAULT_UP),this.updateMatrix(),this.target=new Fn,this.distance=i,this.angle=n,this.penumbra=s,this.decay=r,this.map=null,this.shadow=new Uu}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}const Ou=new dn,Fu=new Ni,Bu=new Ni;class zu extends Du{constructor(){super(new Js(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new ri(4,2),this._viewportCount=6,this._viewports=[new Ri(2,1,1,1),new Ri(0,1,1,1),new Ri(3,1,1,1),new Ri(1,1,1,1),new Ri(3,0,1,1),new Ri(1,0,1,1)],this._cubeDirections=[new Ni(1,0,0),new Ni(-1,0,0),new Ni(0,0,1),new Ni(0,0,-1),new Ni(0,1,0),new Ni(0,-1,0)],this._cubeUps=[new Ni(0,1,0),new Ni(0,1,0),new Ni(0,1,0),new Ni(0,1,0),new Ni(0,0,1),new Ni(0,0,-1)]}updateMatrices(t,e=0){const i=this.camera,n=this.matrix,s=t.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),Fu.setFromMatrixPosition(t.matrixWorld),i.position.copy(Fu),Bu.copy(i.position),Bu.add(this._cubeDirections[e]),i.up.copy(this._cubeUps[e]),i.lookAt(Bu),i.updateMatrixWorld(),n.makeTranslation(-Fu.x,-Fu.y,-Fu.z),Ou.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ou)}}class ku extends Cu{constructor(t,e,i=0,n=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=n,this.shadow=new zu}get power(){return 4*this.intensity*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 Vu extends Du{constructor(){super(new Mr(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Gu extends Cu{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Fn.DEFAULT_UP),this.updateMatrix(),this.target=new Fn,this.shadow=new Vu}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class Hu extends Cu{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class Wu extends Cu{constructor(t,e,i=10,n=10){super(t,e),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,this.height=n}get power(){return this.intensity*this.width*this.height*Math.PI}set power(t){this.intensity=t/(this.width*this.height*Math.PI)}copy(t){return super.copy(t),this.width=t.width,this.height=t.height,this}toJSON(t){const e=super.toJSON(t);return e.object.width=this.width,e.object.height=this.height,e}}class qu{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new Ni)}set(t){for(let e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this}zero(){for(let t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this}getAt(t,e){const i=t.x,n=t.y,s=t.z,r=this.coefficients;return e.copy(r[0]).multiplyScalar(.282095),e.addScaledVector(r[1],.488603*n),e.addScaledVector(r[2],.488603*s),e.addScaledVector(r[3],.488603*i),e.addScaledVector(r[4],i*n*1.092548),e.addScaledVector(r[5],n*s*1.092548),e.addScaledVector(r[6],.315392*(3*s*s-1)),e.addScaledVector(r[7],i*s*1.092548),e.addScaledVector(r[8],.546274*(i*i-n*n)),e}getIrradianceAt(t,e){const i=t.x,n=t.y,s=t.z,r=this.coefficients;return e.copy(r[0]).multiplyScalar(.886227),e.addScaledVector(r[1],1.023328*n),e.addScaledVector(r[2],1.023328*s),e.addScaledVector(r[3],1.023328*i),e.addScaledVector(r[4],.858086*i*n),e.addScaledVector(r[5],.858086*n*s),e.addScaledVector(r[6],.743125*s*s-.247708),e.addScaledVector(r[7],.858086*i*s),e.addScaledVector(r[8],.429043*(i*i-n*n)),e}add(t){for(let e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this}addScaledSH(t,e){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(t.coefficients[i],e);return this}scale(t){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this}lerp(t,e){for(let i=0;i<9;i++)this.coefficients[i].lerp(t.coefficients[i],e);return this}equals(t){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0}copy(t){return this.set(t.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(t,e=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].fromArray(t,e+3*n);return this}toArray(t=[],e=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].toArray(t,e+3*n);return t}static getBasisAt(t,e){const i=t.x,n=t.y,s=t.z;e[0]=.282095,e[1]=.488603*n,e[2]=.488603*s,e[3]=.488603*i,e[4]=1.092548*i*n,e[5]=1.092548*n*s,e[6]=.315392*(3*s*s-1),e[7]=1.092548*i*s,e[8]=.546274*(i*i-n*n)}}class Xu extends Cu{constructor(t=new qu,e=1){super(void 0,e),this.isLightProbe=!0,this.sh=t}copy(t){return super.copy(t),this.sh.copy(t.sh),this}fromJSON(t){return this.intensity=t.intensity,this.sh.fromArray(t.sh),this}toJSON(t){const e=super.toJSON(t);return e.object.sh=this.sh.toArray(),e}}class ju extends Su{constructor(t){super(t),this.textures={}}load(t,e,i,n){const s=this,r=new Eu(s.manager);r.setPath(s.path),r.setRequestHeader(s.requestHeader),r.setWithCredentials(s.withCredentials),r.load(t,function(i){try{e(s.parse(JSON.parse(i)))}catch(r){n&&n(r),s.manager.itemError(t)}},i,n)}parse(t){const e=this.textures;function i(t){return e[t],e[t]}const n=ju.createMaterialFromType(t.type);if(void 0!==t.uuid&&(n.uuid=t.uuid),void 0!==t.name&&(n.name=t.name),void 0!==t.color&&void 0!==n.color&&n.color.setHex(t.color),void 0!==t.roughness&&(n.roughness=t.roughness),void 0!==t.metalness&&(n.metalness=t.metalness),void 0!==t.sheen&&(n.sheen=t.sheen),void 0!==t.sheenColor&&(n.sheenColor=(new ts).setHex(t.sheenColor)),void 0!==t.sheenRoughness&&(n.sheenRoughness=t.sheenRoughness),void 0!==t.emissive&&void 0!==n.emissive&&n.emissive.setHex(t.emissive),void 0!==t.specular&&void 0!==n.specular&&n.specular.setHex(t.specular),void 0!==t.specularIntensity&&(n.specularIntensity=t.specularIntensity),void 0!==t.specularColor&&void 0!==n.specularColor&&n.specularColor.setHex(t.specularColor),void 0!==t.shininess&&(n.shininess=t.shininess),void 0!==t.clearcoat&&(n.clearcoat=t.clearcoat),void 0!==t.clearcoatRoughness&&(n.clearcoatRoughness=t.clearcoatRoughness),void 0!==t.iridescence&&(n.iridescence=t.iridescence),void 0!==t.iridescenceIOR&&(n.iridescenceIOR=t.iridescenceIOR),void 0!==t.iridescenceThicknessRange&&(n.iridescenceThicknessRange=t.iridescenceThicknessRange),void 0!==t.transmission&&(n.transmission=t.transmission),void 0!==t.thickness&&(n.thickness=t.thickness),void 0!==t.attenuationDistance&&(n.attenuationDistance=t.attenuationDistance),void 0!==t.attenuationColor&&void 0!==n.attenuationColor&&n.attenuationColor.setHex(t.attenuationColor),void 0!==t.anisotropy&&(n.anisotropy=t.anisotropy),void 0!==t.anisotropyRotation&&(n.anisotropyRotation=t.anisotropyRotation),void 0!==t.fog&&(n.fog=t.fog),void 0!==t.flatShading&&(n.flatShading=t.flatShading),void 0!==t.blending&&(n.blending=t.blending),void 0!==t.combine&&(n.combine=t.combine),void 0!==t.side&&(n.side=t.side),void 0!==t.shadowSide&&(n.shadowSide=t.shadowSide),void 0!==t.opacity&&(n.opacity=t.opacity),void 0!==t.transparent&&(n.transparent=t.transparent),void 0!==t.alphaTest&&(n.alphaTest=t.alphaTest),void 0!==t.alphaHash&&(n.alphaHash=t.alphaHash),void 0!==t.depthFunc&&(n.depthFunc=t.depthFunc),void 0!==t.depthTest&&(n.depthTest=t.depthTest),void 0!==t.depthWrite&&(n.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(n.colorWrite=t.colorWrite),void 0!==t.blendSrc&&(n.blendSrc=t.blendSrc),void 0!==t.blendDst&&(n.blendDst=t.blendDst),void 0!==t.blendEquation&&(n.blendEquation=t.blendEquation),void 0!==t.blendSrcAlpha&&(n.blendSrcAlpha=t.blendSrcAlpha),void 0!==t.blendDstAlpha&&(n.blendDstAlpha=t.blendDstAlpha),void 0!==t.blendEquationAlpha&&(n.blendEquationAlpha=t.blendEquationAlpha),void 0!==t.blendColor&&void 0!==n.blendColor&&n.blendColor.setHex(t.blendColor),void 0!==t.blendAlpha&&(n.blendAlpha=t.blendAlpha),void 0!==t.stencilWriteMask&&(n.stencilWriteMask=t.stencilWriteMask),void 0!==t.stencilFunc&&(n.stencilFunc=t.stencilFunc),void 0!==t.stencilRef&&(n.stencilRef=t.stencilRef),void 0!==t.stencilFuncMask&&(n.stencilFuncMask=t.stencilFuncMask),void 0!==t.stencilFail&&(n.stencilFail=t.stencilFail),void 0!==t.stencilZFail&&(n.stencilZFail=t.stencilZFail),void 0!==t.stencilZPass&&(n.stencilZPass=t.stencilZPass),void 0!==t.stencilWrite&&(n.stencilWrite=t.stencilWrite),void 0!==t.wireframe&&(n.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(n.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(n.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(n.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.rotation&&(n.rotation=t.rotation),void 0!==t.linewidth&&(n.linewidth=t.linewidth),void 0!==t.dashSize&&(n.dashSize=t.dashSize),void 0!==t.gapSize&&(n.gapSize=t.gapSize),void 0!==t.scale&&(n.scale=t.scale),void 0!==t.polygonOffset&&(n.polygonOffset=t.polygonOffset),void 0!==t.polygonOffsetFactor&&(n.polygonOffsetFactor=t.polygonOffsetFactor),void 0!==t.polygonOffsetUnits&&(n.polygonOffsetUnits=t.polygonOffsetUnits),void 0!==t.dithering&&(n.dithering=t.dithering),void 0!==t.alphaToCoverage&&(n.alphaToCoverage=t.alphaToCoverage),void 0!==t.premultipliedAlpha&&(n.premultipliedAlpha=t.premultipliedAlpha),void 0!==t.forceSinglePass&&(n.forceSinglePass=t.forceSinglePass),void 0!==t.visible&&(n.visible=t.visible),void 0!==t.toneMapped&&(n.toneMapped=t.toneMapped),void 0!==t.userData&&(n.userData=t.userData),void 0!==t.vertexColors&&("number"==typeof t.vertexColors?n.vertexColors=t.vertexColors>0:n.vertexColors=t.vertexColors),void 0!==t.uniforms)for(const s in t.uniforms){const e=t.uniforms[s];switch(n.uniforms[s]={},e.type){case"t":n.uniforms[s].value=i(e.value);break;case"c":n.uniforms[s].value=(new ts).setHex(e.value);break;case"v2":n.uniforms[s].value=(new ri).fromArray(e.value);break;case"v3":n.uniforms[s].value=(new Ni).fromArray(e.value);break;case"v4":n.uniforms[s].value=(new Ri).fromArray(e.value);break;case"m3":n.uniforms[s].value=(new ai).fromArray(e.value);break;case"m4":n.uniforms[s].value=(new dn).fromArray(e.value);break;default:n.uniforms[s].value=e.value}}if(void 0!==t.defines&&(n.defines=t.defines),void 0!==t.vertexShader&&(n.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(n.fragmentShader=t.fragmentShader),void 0!==t.glslVersion&&(n.glslVersion=t.glslVersion),void 0!==t.extensions)for(const s in t.extensions)n.extensions[s]=t.extensions[s];if(void 0!==t.lights&&(n.lights=t.lights),void 0!==t.clipping&&(n.clipping=t.clipping),void 0!==t.size&&(n.size=t.size),void 0!==t.sizeAttenuation&&(n.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(n.map=i(t.map)),void 0!==t.matcap&&(n.matcap=i(t.matcap)),void 0!==t.alphaMap&&(n.alphaMap=i(t.alphaMap)),void 0!==t.bumpMap&&(n.bumpMap=i(t.bumpMap)),void 0!==t.bumpScale&&(n.bumpScale=t.bumpScale),void 0!==t.normalMap&&(n.normalMap=i(t.normalMap)),void 0!==t.normalMapType&&(n.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),n.normalScale=(new ri).fromArray(e)}return void 0!==t.displacementMap&&(n.displacementMap=i(t.displacementMap)),void 0!==t.displacementScale&&(n.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(n.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(n.roughnessMap=i(t.roughnessMap)),void 0!==t.metalnessMap&&(n.metalnessMap=i(t.metalnessMap)),void 0!==t.emissiveMap&&(n.emissiveMap=i(t.emissiveMap)),void 0!==t.emissiveIntensity&&(n.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(n.specularMap=i(t.specularMap)),void 0!==t.specularIntensityMap&&(n.specularIntensityMap=i(t.specularIntensityMap)),void 0!==t.specularColorMap&&(n.specularColorMap=i(t.specularColorMap)),void 0!==t.envMap&&(n.envMap=i(t.envMap)),void 0!==t.envMapIntensity&&(n.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(n.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(n.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(n.lightMap=i(t.lightMap)),void 0!==t.lightMapIntensity&&(n.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(n.aoMap=i(t.aoMap)),void 0!==t.aoMapIntensity&&(n.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(n.gradientMap=i(t.gradientMap)),void 0!==t.clearcoatMap&&(n.clearcoatMap=i(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(n.clearcoatRoughnessMap=i(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(n.clearcoatNormalMap=i(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(n.clearcoatNormalScale=(new ri).fromArray(t.clearcoatNormalScale)),void 0!==t.iridescenceMap&&(n.iridescenceMap=i(t.iridescenceMap)),void 0!==t.iridescenceThicknessMap&&(n.iridescenceThicknessMap=i(t.iridescenceThicknessMap)),void 0!==t.transmissionMap&&(n.transmissionMap=i(t.transmissionMap)),void 0!==t.thicknessMap&&(n.thicknessMap=i(t.thicknessMap)),void 0!==t.anisotropyMap&&(n.anisotropyMap=i(t.anisotropyMap)),void 0!==t.sheenColorMap&&(n.sheenColorMap=i(t.sheenColorMap)),void 0!==t.sheenRoughnessMap&&(n.sheenRoughnessMap=i(t.sheenRoughnessMap)),n}setTextures(t){return this.textures=t,this}static createMaterialFromType(t){return new{ShadowMaterial:Wc,SpriteMaterial:Ko,RawShaderMaterial:qc,ShaderMaterial:Ys,PointsMaterial:mh,MeshPhysicalMaterial:jc,MeshStandardMaterial:Xc,MeshPhongMaterial:Yc,MeshToonMaterial:Zc,MeshNormalMaterial:Jc,MeshLambertMaterial:Kc,MeshDepthMaterial:Po,MeshDistanceMaterial:Lo,MeshBasicMaterial:ss,MeshMatcapMaterial:$c,LineDashedMaterial:Qc,LineBasicMaterial:nh,Material:ns}[t]}}class Yu{static decodeText(t){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);let e="";for(let n=0,s=t.length;n<s;n++)e+=String.fromCharCode(t[n]);try{return decodeURIComponent(escape(e))}catch(i){return e}}static extractUrlBase(t){const e=t.lastIndexOf("/");return-1===e?"./":t.slice(0,e+1)}static resolveURL(t,e){return"string"!=typeof t||""===t?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}}class Zu extends Ss{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){const t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}}class Ju extends Su{constructor(t){super(t)}load(t,e,i,n){const s=this,r=new Eu(s.manager);r.setPath(s.path),r.setRequestHeader(s.requestHeader),r.setWithCredentials(s.withCredentials),r.load(t,function(i){try{e(s.parse(JSON.parse(i)))}catch(r){n&&n(r),s.manager.itemError(t)}},i,n)}parse(t){const e={},i={};function n(t,n){if(void 0!==e[n])return e[n];const s=t.interleavedBuffers[n],r=function(t,e){if(void 0!==i[e])return i[e];const n=t.arrayBuffers[e],s=new Uint32Array(n).buffer;return i[e]=s,s}(t,s.buffer),a=ci(s.type,r),o=new Yo(a,s.stride);return o.uuid=s.uuid,e[n]=o,o}const s=t.isInstancedBufferGeometry?new Zu:new Ss,r=t.data.index;if(void 0!==r){const t=ci(r.type,r.array);s.setIndex(new ds(t,1))}const a=t.data.attributes;for(const c in a){const e=a[c];let i;if(e.isInterleavedBufferAttribute){const s=n(t.data,e.data);i=new Jo(s,e.itemSize,e.offset,e.normalized)}else{const t=ci(e.type,e.array);i=new(e.isInstancedBufferAttribute?Ll:ds)(t,e.itemSize,e.normalized)}void 0!==e.name&&(i.name=e.name),void 0!==e.usage&&i.setUsage(e.usage),s.setAttribute(c,i)}const o=t.data.morphAttributes;if(o)for(const c in o){const e=o[c],i=[];for(let s=0,r=e.length;s<r;s++){const r=e[s];let a;if(r.isInterleavedBufferAttribute){const e=n(t.data,r.data);a=new Jo(e,r.itemSize,r.offset,r.normalized)}else{const t=ci(r.type,r.array);a=new ds(t,r.itemSize,r.normalized)}void 0!==r.name&&(a.name=r.name),i.push(a)}s.morphAttributes[c]=i}t.data.morphTargetsRelative&&(s.morphTargetsRelative=!0);const l=t.data.groups||t.data.drawcalls||t.data.offsets;if(void 0!==l)for(let c=0,u=l.length;c!==u;++c){const t=l[c];s.addGroup(t.start,t.count,t.materialIndex)}const h=t.data.boundingSphere;if(void 0!==h){const t=new Ni;void 0!==h.center&&t.fromArray(h.center),s.boundingSphere=new nn(t,h.radius)}return t.name&&(s.name=t.name),t.userData&&(s.userData=t.userData),s}}const Ku={UVMapping:at,CubeReflectionMapping:ot,CubeRefractionMapping:lt,EquirectangularReflectionMapping:ht,EquirectangularRefractionMapping:ct,CubeUVReflectionMapping:ut},$u={RepeatWrapping:dt,ClampToEdgeWrapping:pt,MirroredRepeatWrapping:mt},Qu={NearestFilter:ft,NearestMipmapNearestFilter:gt,NearestMipmapLinearFilter:_t,LinearFilter:vt,LinearMipmapNearestFilter:yt,LinearMipmapLinearFilter:xt};let td;class ed{static getContext(){return void 0===td&&(td=new(window.AudioContext||window.webkitAudioContext)),td}static setContext(t){td=t}}const id=new dn,nd=new dn,sd=new dn;class rd{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=ad(),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=ad();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function ad(){return("undefined"==typeof performance?Date:performance).now()}const od=new Ni,ld=new Ui,hd=new Ni,cd=new Ni;class ud extends Fn{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(!0===this.isPlaying)return;if(!1===this.hasPlaybackControl)return;this._startedAt=this.context.currentTime+t;const e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(!1!==this.hasPlaybackControl)return this._progress=0,null!==this.source&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].connect(this.filters[t]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(!1!==this._connected){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].disconnect(this.filters[t]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(t){return t||(t=[]),!0===this._connected?(this.disconnect(),this.filters=t.slice(),this.connect()):this.filters=t.slice(),this}setDetune(t){if(this.detune=t,void 0!==this.source.detune)return!0===this.isPlaying&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(t){return this.setFilters(t?[t]:[])}setPlaybackRate(t){if(!1!==this.hasPlaybackControl)return this.playbackRate=t,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return!1!==this.hasPlaybackControl&&this.loop}setLoop(t){if(!1!==this.hasPlaybackControl)return this.loop=t,!0===this.isPlaying&&(this.source.loop=this.loop),this}setLoopStart(t){return this.loopStart=t,this}setLoopEnd(t){return this.loopEnd=t,this}getVolume(){return this.gain.gain.value}setVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}}const dd=new Ni,pd=new Ui,md=new Ni,fd=new Ni;class gd{constructor(t,e,i){let n,s,r;switch(this.binding=t,this.valueSize=i,e){case"quaternion":n=this._slerp,s=this._slerpAdditive,r=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*i),this._workIndex=5;break;case"string":case"bool":n=this._select,s=this._select,r=this._setAdditiveIdentityOther,this.buffer=new Array(5*i);break;default:n=this._lerp,s=this._lerpAdditive,r=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*i)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=s,this._setIdentity=r,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){const i=this.buffer,n=this.valueSize,s=t*n+n;let r=this.cumulativeWeight;if(0===r){for(let t=0;t!==n;++t)i[s+t]=i[t];r=e}else{r+=e;const t=e/r;this._mixBufferRegion(i,s,0,t,n)}this.cumulativeWeight=r}accumulateAdditive(t){const e=this.buffer,i=this.valueSize,n=i*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(e,n,0,t,i),this.cumulativeWeightAdditive+=t}apply(t){const e=this.valueSize,i=this.buffer,n=t*e+e,s=this.cumulativeWeight,r=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const t=e*this._origIndex;this._mixBufferRegion(i,n,t,1-s,e)}r>0&&this._mixBufferRegionAdditive(i,n,this._addIndex*e,1,e);for(let o=e,l=e+e;o!==l;++o)if(i[o]!==i[o+e]){a.setValue(i,n);break}}saveOriginalState(){const t=this.binding,e=this.buffer,i=this.valueSize,n=i*this._origIndex;t.getValue(e,n);for(let s=i,r=n;s!==r;++s)e[s]=e[n+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=3*this.valueSize;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let i=t;i<e;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[e+i]=this.buffer[t+i]}_select(t,e,i,n,s){if(n>=.5)for(let r=0;r!==s;++r)t[e+r]=t[i+r]}_slerp(t,e,i,n){Ui.slerpFlat(t,e,t,e,t,i,n)}_slerpAdditive(t,e,i,n,s){const r=this._workIndex*s;Ui.multiplyQuaternionsFlat(t,r,t,e,t,i),Ui.slerpFlat(t,e,t,e,t,r,n)}_lerp(t,e,i,n,s){const r=1-n;for(let a=0;a!==s;++a){const s=e+a;t[s]=t[s]*r+t[i+a]*n}}_lerpAdditive(t,e,i,n,s){for(let r=0;r!==s;++r){const s=e+r;t[s]=t[s]+t[i+r]*n}}}const _d="\\[\\]\\.:\\/",vd=new RegExp("["+_d+"]","g"),yd="[^"+_d+"]",xd="[^"+_d.replace("\\.","")+"]",Md=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",yd)+/(WCOD+)?/.source.replace("WCOD",xd)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",yd)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",yd)+"$"),bd=["material","materials","bones","map"];class Sd{constructor(t,e,i){this.path=e,this.parsedPath=i||Sd.parseTrackName(e),this.node=Sd.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,i){return t&&t.isAnimationObjectGroup?new Sd.Composite(t,e,i):new Sd(t,e,i)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(vd,"")}static parseTrackName(t){const e=Md.exec(t);if(null===e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const i={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==n&&-1!==n){const t=i.nodeName.substring(n+1);-1!==bd.indexOf(t)&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=t)}if(null===i.propertyName||0===i.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return i}static findNode(t,e){if(void 0===e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const i=t.skeleton.getBoneByName(e);if(void 0!==i)return i}if(t.children){const i=function(t){for(let n=0;n<t.length;n++){const s=t[n];if(s.name===e||s.uuid===e)return s;const r=i(s.children);if(r)return r}return null},n=i(t.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)t[e++]=i[n]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=t[e++]}_setValue_array_setNeedsUpdate(t,e){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node;const e=this.parsedPath,i=e.objectName,n=e.propertyName;let s=e.propertyIndex;if(t||(t=Sd.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t)return;if(i){let n=e.objectIndex;switch(i){case"materials":if(!t.material)return;if(!t.material.materials)return;t=t.material.materials;break;case"bones":if(!t.skeleton)return;t=t.skeleton.bones;for(let e=0;e<t.length;e++)if(t[e].name===n){n=e;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material)return;if(!t.material.map)return;t=t.material.map;break;default:if(void 0===t[i])return;t=t[i]}if(void 0!==n){if(void 0===t[n])return;t=t[n]}}const r=t[n];if(void 0===r)return void e.nodeName;let a=this.Versioning.None;this.targetObject=t,void 0!==t.needsUpdate?a=this.Versioning.NeedsUpdate:void 0!==t.matrixWorldNeedsUpdate&&(a=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(void 0!==s){if("morphTargetInfluences"===n){if(!t.geometry)return;if(!t.geometry.morphAttributes)return;void 0!==t.morphTargetDictionary[s]&&(s=t.morphTargetDictionary[s])}o=this.BindingType.ArrayElement,this.resolvedProperty=r,this.propertyIndex=s}else void 0!==r.fromArray&&void 0!==r.toArray?(o=this.BindingType.HasFromToArray,this.resolvedProperty=r):Array.isArray(r)?(o=this.BindingType.EntireArray,this.resolvedProperty=r):this.propertyName=n;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Sd.Composite=class{constructor(t,e,i){const n=i||Sd.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,n)}getValue(t,e){this.bind();const i=this._targetGroup.nCachedObjects_,n=this._bindings[i];void 0!==n&&n.getValue(t,e)}setValue(t,e){const i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,s=i.length;n!==s;++n)i[n].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].unbind()}},Sd.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Sd.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Sd.prototype.GetterByBindingType=[Sd.prototype._getValue_direct,Sd.prototype._getValue_array,Sd.prototype._getValue_arrayElement,Sd.prototype._getValue_toArray],Sd.prototype.SetterByBindingTypeAndVersioning=[[Sd.prototype._setValue_direct,Sd.prototype._setValue_direct_setNeedsUpdate,Sd.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Sd.prototype._setValue_array,Sd.prototype._setValue_array_setNeedsUpdate,Sd.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Sd.prototype._setValue_arrayElement,Sd.prototype._setValue_arrayElement_setNeedsUpdate,Sd.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Sd.prototype._setValue_fromArray,Sd.prototype._setValue_fromArray_setNeedsUpdate,Sd.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class wd{constructor(t,e,i=null,n=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=i,this.blendMode=n;const s=e.tracks,r=s.length,a=new Array(r),o={endingStart:ge,endingEnd:ge};for(let l=0;l!==r;++l){const t=s[l].createInterpolant(null);a[l]=t,t.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(r),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,i){if(t.fadeOut(e),this.fadeIn(e),i){const i=this._clip.duration,n=t._clip.duration,s=n/i,r=i/n;t.warp(1,s,e),this.warp(r,1,e)}return this}crossFadeTo(t,e,i){return t.crossFadeFrom(this,e,i)}stopFading(){const t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,i){const n=this._mixer,s=n.time,r=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=n._lendControlInterpolant(),this._timeScaleInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=s,o[1]=s+i,l[0]=t/r,l[1]=e/r,this}stopWarping(){const t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,i,n){if(!this.enabled)return void this._updateWeight(t);const s=this._startTime;if(null!==s){const n=(t-s)*i;n<0||0===i?e=0:(this._startTime=null,e=i*n)}e*=this._updateTimeScale(t);const r=this._updateTime(e),a=this._updateWeight(t);if(a>0){const t=this._interpolants,e=this._propertyBindings;if(this.blendMode===ye)for(let i=0,n=t.length;i!==n;++i)t[i].evaluate(r),e[i].accumulateAdditive(a);else for(let i=0,s=t.length;i!==s;++i)t[i].evaluate(r),e[i].accumulate(n,a)}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const i=this._weightInterpolant;if(null!==i){const n=i.evaluate(t)[0];e*=n,t>i.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const i=this._timeScaleInterpolant;null!==i&&(e*=i.evaluate(t)[0],t>i.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e))}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,i=this.loop;let n=this.time+t,s=this._loopCount;const r=2202===i;if(0===t)return-1===s||!r||1&~s?n:e-n;if(2200===i){-1===s&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(n>=e)n=e;else{if(!(n<0)){this.time=n;break t}n=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===s&&(t>=0?(s=0,this._setEndings(!0,0===this.repetitions,r)):this._setEndings(0===this.repetitions,!0,r)),n>=e||n<0){const i=Math.floor(n/e);n-=e*i,s+=Math.abs(i);const a=this.repetitions-s;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=t>0?e:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===a){const e=t<0;this._setEndings(e,!e,r)}else this._setEndings(!1,!1,r);this._loopCount=s,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:i})}}else this.time=n;if(r&&!(1&~s))return e-n}return n}_setEndings(t,e,i){const n=this._interpolantSettings;i?(n.endingStart=_e,n.endingEnd=_e):(n.endingStart=t?this.zeroSlopeAtStart?_e:ge:ve,n.endingEnd=e?this.zeroSlopeAtEnd?_e:ge:ve)}_scheduleFading(t,e,i){const n=this._mixer,s=n.time;let r=this._weightInterpolant;null===r&&(r=n._lendControlInterpolant(),this._weightInterpolant=r);const a=r.parameterPositions,o=r.sampleValues;return a[0]=s,o[0]=e,a[1]=s+t,o[1]=i,this}}const Td=new Float32Array(1);class Ed{constructor(t){this.value=t}clone(){return new Ed(void 0===this.value.clone?this.value:this.value.clone())}}let Ad=0;function Cd(t,e){return t.distance-e.distance}function Rd(t,e,i,n){if(t.layers.test(e.layers)&&t.raycast(e,i),!0===n){const n=t.children;for(let t=0,s=n.length;t<s;t++)Rd(n[t],e,i,!0)}}const Pd=new ri,Ld=new Ni,Id=new Ni,Dd=new Ni,Ud=new Ni,Nd=new dn,Od=new dn;function Fd(t){const e=[];!0===t.isBone&&e.push(t);for(let i=0;i<t.children.length;i++)e.push.apply(e,Fd(t.children[i]));return e}const Bd=new Ni,zd=new ts,kd=new ts,Vd=new Ni,Gd=new Ni,Hd=new Ni,Wd=new Ni,qd=new Zs;function Xd(t,e,i,n,s,r,a){Wd.set(s,r,a).unproject(n);const o=e[t];if(void 0!==o){const t=i.getAttribute("position");for(let e=0,i=o.length;e<i;e++)t.setXYZ(o[e],Wd.x,Wd.y,Wd.z)}}const jd=new Bi,Yd=new Ni;let Zd,Jd;"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:O}})),"undefined"!=typeof window&&(window.__THREE__||(window.__THREE__=O));const Kd=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:4,AddEquation:k,AddOperation:2,AdditiveAnimationBlendMode:ye,AdditiveBlending:2,AgXToneMapping:6,AlphaFormat:1021,AlwaysCompare:519,AlwaysDepth:1,AlwaysStencilFunc:519,AmbientLight:Hu,AnimationAction:wd,AnimationClip:vu,AnimationLoader:class extends Su{constructor(t){super(t)}load(t,e,i,n){const s=this,r=new Eu(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(t,function(i){try{e(s.parse(JSON.parse(i)))}catch(r){n&&n(r),s.manager.itemError(t)}},i,n)}parse(t){const e=[];for(let i=0;i<t.length;i++){const n=vu.parse(t[i]);e.push(n)}return e}},AnimationMixer:class extends qe{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const i=t._localRoot||this._root,n=t._clip.tracks,s=n.length,r=t._propertyBindings,a=t._interpolants,o=i.uuid,l=this._bindingsByRootAndName;let h=l[o];void 0===h&&(h={},l[o]=h);for(let c=0;c!==s;++c){const t=n[c],s=t.name;let l=h[s];if(void 0!==l)++l.referenceCount,r[c]=l;else{if(l=r[c],void 0!==l){null===l._cacheIndex&&(++l.referenceCount,this._addInactiveBinding(l,o,s));continue}const n=e&&e._propertyBindings[c].binding.parsedPath;l=new gd(Sd.create(i,s,n),t.ValueTypeName,t.getValueSize()),++l.referenceCount,this._addInactiveBinding(l,o,s),r[c]=l}a[c].resultBuffer=l.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,i=t._clip.uuid,n=this._actionsByClip[i];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,i,e)}const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0===i.useCount++&&(this._lendBinding(i),i.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0===--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return null!==e&&e<this._nActiveActions}_addInactiveAction(t,e,i){const n=this._actions,s=this._actionsByClip;let r=s[e];if(void 0===r)r={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,s[e]=r;else{const e=r.knownActions;t._byClipCacheIndex=e.length,e.push(t)}t._cacheIndex=n.length,n.push(t),r.actionByRoot[i]=t}_removeInactiveAction(t){const e=this._actions,i=e[e.length-1],n=t._cacheIndex;i._cacheIndex=n,e[n]=i,e.pop(),t._cacheIndex=null;const s=t._clip.uuid,r=this._actionsByClip,a=r[s],o=a.knownActions,l=o[o.length-1],h=t._byClipCacheIndex;l._byClipCacheIndex=h,o[h]=l,o.pop(),t._byClipCacheIndex=null,delete a.actionByRoot[(t._localRoot||this._root).uuid],0===o.length&&delete r[s],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){const e=t._propertyBindings;for(let i=0,n=e.length;i!==n;++i){const t=e[i];0===--t.referenceCount&&this._removeInactiveBinding(t)}}_lendAction(t){const e=this._actions,i=t._cacheIndex,n=this._nActiveActions++,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_takeBackAction(t){const e=this._actions,i=t._cacheIndex,n=--this._nActiveActions,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_addInactiveBinding(t,e,i){const n=this._bindingsByRootAndName,s=this._bindings;let r=n[e];void 0===r&&(r={},n[e]=r),r[i]=t,t._cacheIndex=s.length,s.push(t)}_removeInactiveBinding(t){const e=this._bindings,i=t.binding,n=i.rootNode.uuid,s=i.path,r=this._bindingsByRootAndName,a=r[n],o=e[e.length-1],l=t._cacheIndex;o._cacheIndex=l,e[l]=o,e.pop(),delete a[s],0===Object.keys(a).length&&delete r[n]}_lendBinding(t){const e=this._bindings,i=t._cacheIndex,n=this._nActiveBindings++,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_takeBackBinding(t){const e=this._bindings,i=t._cacheIndex,n=--this._nActiveBindings,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_lendControlInterpolant(){const t=this._controlInterpolants,e=this._nActiveControlInterpolants++;let i=t[e];return void 0===i&&(i=new lu(new Float32Array(2),new Float32Array(2),1,Td),i.__cacheIndex=e,t[e]=i),i}_takeBackControlInterpolant(t){const e=this._controlInterpolants,i=t.__cacheIndex,n=--this._nActiveControlInterpolants,s=e[n];t.__cacheIndex=n,e[n]=t,s.__cacheIndex=i,e[i]=s}clipAction(t,e,i){const n=e||this._root,s=n.uuid;let r="string"==typeof t?vu.findByName(n,t):t;const a=null!==r?r.uuid:t,o=this._actionsByClip[a];let l=null;if(void 0===i&&(i=null!==r?r.blendMode:2500),void 0!==o){const t=o.actionByRoot[s];if(void 0!==t&&t.blendMode===i)return t;l=o.knownActions[0],null===r&&(r=l._clip)}if(null===r)return null;const h=new wd(this,r,e,i);return this._bindAction(h,l),this._addInactiveAction(h,a,s),h}existingAction(t,e){const i=e||this._root,n=i.uuid,s="string"==typeof t?vu.findByName(i,t):t,r=s?s.uuid:t,a=this._actionsByClip[r];return void 0!==a&&a.actionByRoot[n]||null}stopAllAction(){const t=this._actions;for(let e=this._nActiveActions-1;e>=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,i=this._nActiveActions,n=this.time+=t,s=Math.sign(t),r=this._accuIndex^=1;for(let l=0;l!==i;++l)e[l]._update(n,t,s,r);const a=this._bindings,o=this._nActiveBindings;for(let l=0;l!==o;++l)a[l].apply(r);return this}setTime(t){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){const e=this._actions,i=t.uuid,n=this._actionsByClip,s=n[i];if(void 0!==s){const t=s.knownActions;for(let i=0,n=t.length;i!==n;++i){const n=t[i];this._deactivateAction(n);const s=n._cacheIndex,r=e[e.length-1];n._cacheIndex=null,n._byClipCacheIndex=null,r._cacheIndex=s,e[s]=r,e.pop(),this._removeInactiveBindingsForAction(n)}delete n[i]}}uncacheRoot(t){const e=t.uuid,i=this._actionsByClip;for(const s in i){const t=i[s].actionByRoot[e];void 0!==t&&(this._deactivateAction(t),this._removeInactiveAction(t))}const n=this._bindingsByRootAndName[e];if(void 0!==n)for(const s in n){const t=n[s];t.restoreOriginalState(),this._removeInactiveBinding(t)}}uncacheAction(t,e){const i=this.existingAction(t,e);null!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}},AnimationObjectGroup:class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Je(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const t={};this._indicesByUUID=t;for(let i=0,n=arguments.length;i!==n;++i)t[arguments[i].uuid]=i;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}add(){const t=this._objects,e=this._indicesByUUID,i=this._paths,n=this._parsedPaths,s=this._bindings,r=s.length;let a,o=t.length,l=this.nCachedObjects_;for(let h=0,c=arguments.length;h!==c;++h){const c=arguments[h],u=c.uuid;let d=e[u];if(void 0===d){d=o++,e[u]=d,t.push(c);for(let t=0,e=r;t!==e;++t)s[t].push(new Sd(c,i[t],n[t]))}else if(d<l){a=t[d];const o=--l,h=t[o];e[h.uuid]=d,t[d]=h,e[u]=o,t[o]=c;for(let t=0,e=r;t!==e;++t){const e=s[t],r=e[o];let a=e[d];e[d]=r,void 0===a&&(a=new Sd(c,i[t],n[t])),e[o]=a}}else t[d]}this.nCachedObjects_=l}remove(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,n=i.length;let s=this.nCachedObjects_;for(let r=0,a=arguments.length;r!==a;++r){const a=arguments[r],o=a.uuid,l=e[o];if(void 0!==l&&l>=s){const r=s++,h=t[r];e[h.uuid]=l,t[l]=h,e[o]=r,t[r]=a;for(let t=0,e=n;t!==e;++t){const e=i[t],n=e[r],s=e[l];e[l]=n,e[r]=s}}}this.nCachedObjects_=s}uncache(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,n=i.length;let s=this.nCachedObjects_,r=t.length;for(let a=0,o=arguments.length;a!==o;++a){const o=arguments[a].uuid,l=e[o];if(void 0!==l)if(delete e[o],l<s){const a=--s,o=t[a],h=--r,c=t[h];e[o.uuid]=l,t[l]=o,e[c.uuid]=a,t[a]=c,t.pop();for(let t=0,e=n;t!==e;++t){const e=i[t],n=e[a],s=e[h];e[l]=n,e[a]=s,e.pop()}}else{const s=--r,a=t[s];s>0&&(e[a.uuid]=l),t[l]=a,t.pop();for(let t=0,e=n;t!==e;++t){const e=i[t];e[l]=e[s],e.pop()}}}this.nCachedObjects_=s}subscribe_(t,e){const i=this._bindingsIndicesByPath;let n=i[t];const s=this._bindings;if(void 0!==n)return s[n];const r=this._paths,a=this._parsedPaths,o=this._objects,l=o.length,h=this.nCachedObjects_,c=new Array(l);n=s.length,i[t]=n,r.push(t),a.push(e),s.push(c);for(let u=h,d=o.length;u!==d;++u){const i=o[u];c[u]=new Sd(i,t,e)}return c}unsubscribe_(t){const e=this._bindingsIndicesByPath,i=e[t];if(void 0!==i){const n=this._paths,s=this._parsedPaths,r=this._bindings,a=r.length-1,o=r[a];e[t[a]]=i,r[i]=o,r.pop(),s[i]=s[a],s.pop(),n[i]=n[a],n.pop()}}},AnimationUtils:ru,ArcCurve:wh,ArrayCamera:Oo,ArrowHelper:class extends Fn{constructor(t=new Ni(0,0,1),e=new Ni(0,0,0),i=1,n=16776960,s=.2*i,r=.2*s){super(),this.type="ArrowHelper",void 0===Zd&&(Zd=new Ss,Zd.setAttribute("position",new fs([0,0,0,0,1,0],3)),Jd=new jh(0,.5,1,5,1),Jd.translate(0,-.5,0)),this.position.copy(e),this.line=new hh(Zd,new nh({color:n,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Vs(Jd,new ss({color:n,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(i,s,r)}setDirection(t){if(t.y>.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{Yd.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(Yd,e)}}setLength(t,e=.2*t,i=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(i,e,i),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},AttachedBindMode:st,Audio:ud,AudioAnalyser:class{constructor(t,e=2048){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=e,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let t=0;const e=this.getFrequencyData();for(let i=0;i<e.length;i++)t+=e[i];return t/e.length}},AudioContext:ed,AudioListener:class extends Fn{constructor(){super(),this.type="AudioListener",this.context=ed.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new rd}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(od,ld,hd),cd.set(0,0,-1).applyQuaternion(ld),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(od.x,t),e.positionY.linearRampToValueAtTime(od.y,t),e.positionZ.linearRampToValueAtTime(od.z,t),e.forwardX.linearRampToValueAtTime(cd.x,t),e.forwardY.linearRampToValueAtTime(cd.y,t),e.forwardZ.linearRampToValueAtTime(cd.z,t),e.upX.linearRampToValueAtTime(i.x,t),e.upY.linearRampToValueAtTime(i.y,t),e.upZ.linearRampToValueAtTime(i.z,t)}else e.setPosition(od.x,od.y,od.z),e.setOrientation(cd.x,cd.y,cd.z,i.x,i.y,i.z)}},AudioLoader:class extends Su{constructor(t){super(t)}load(t,e,i,n){const s=this,r=new Eu(this.manager);function a(e){n&&n(e),s.manager.itemError(t)}r.setResponseType("arraybuffer"),r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(t,function(t){try{const i=t.slice(0);ed.getContext().decodeAudioData(i,function(t){e(t)}).catch(a)}catch(i){a(i)}},i,n)}},AxesHelper:class extends dh{constructor(t=1){const e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],i=new Ss;i.setAttribute("position",new fs(e,3)),i.setAttribute("color",new fs([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(i,new nh({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(t,e,i){const n=new ts,s=this.geometry.attributes.color.array;return n.set(t),n.toArray(s,0),n.toArray(s,3),n.set(e),n.toArray(s,6),n.toArray(s,9),n.set(i),n.toArray(s,12),n.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},BackSide:1,BasicDepthPacking:3200,BasicShadowMap:0,BatchedMesh:ih,Bone:El,BooleanKeyframeTrack:uu,Box2:class{constructor(t=new ri(1/0,1/0),e=new ri(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=Pd.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}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=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(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}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Pd).distanceTo(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}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)}},Box3:Bi,Box3Helper:class extends dh{constructor(t,e=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new Ss;n.setIndex(new ds(i,1)),n.setAttribute("position",new fs([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(n,new nh({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){const e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}},BoxGeometry:Hs,BoxHelper:class extends dh{constructor(t,e=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new Float32Array(24),s=new Ss;s.setIndex(new ds(i,1)),s.setAttribute("position",new ds(n,3)),super(s,new nh({color:e,toneMapped:!1})),this.object=t,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(t){if(void 0!==this.object&&jd.setFromObject(this.object),jd.isEmpty())return;const e=jd.min,i=jd.max,n=this.geometry.attributes.position,s=n.array;s[0]=i.x,s[1]=i.y,s[2]=i.z,s[3]=e.x,s[4]=i.y,s[5]=i.z,s[6]=e.x,s[7]=e.y,s[8]=i.z,s[9]=i.x,s[10]=e.y,s[11]=i.z,s[12]=i.x,s[13]=i.y,s[14]=e.z,s[15]=e.x,s[16]=i.y,s[17]=e.z,s[18]=e.x,s[19]=e.y,s[20]=e.z,s[21]=i.x,s[22]=e.y,s[23]=e.z,n.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(t){return this.object=t,this.update(),this}copy(t,e){return super.copy(t,e),this.object=t.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}},BufferAttribute:ds,BufferGeometry:Ss,BufferGeometryLoader:Ju,ByteType:1010,Cache:xu,Camera:Zs,CameraHelper:class extends dh{constructor(t){const e=new Ss,i=new nh({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],s=[],r={};function a(t,e){o(t),o(e)}function o(t){n.push(0,0,0),s.push(0,0,0),void 0===r[t]&&(r[t]=[]),r[t].push(n.length/3-1)}a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4"),e.setAttribute("position",new fs(n,3)),e.setAttribute("color",new fs(s,3)),super(e,i),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=r,this.update();const l=new ts(16755200),h=new ts(16711680),c=new ts(43775),u=new ts(16777215),d=new ts(3355443);this.setColors(l,h,c,u,d)}setColors(t,e,i,n,s){const r=this.geometry.getAttribute("color");r.setXYZ(0,t.r,t.g,t.b),r.setXYZ(1,t.r,t.g,t.b),r.setXYZ(2,t.r,t.g,t.b),r.setXYZ(3,t.r,t.g,t.b),r.setXYZ(4,t.r,t.g,t.b),r.setXYZ(5,t.r,t.g,t.b),r.setXYZ(6,t.r,t.g,t.b),r.setXYZ(7,t.r,t.g,t.b),r.setXYZ(8,t.r,t.g,t.b),r.setXYZ(9,t.r,t.g,t.b),r.setXYZ(10,t.r,t.g,t.b),r.setXYZ(11,t.r,t.g,t.b),r.setXYZ(12,t.r,t.g,t.b),r.setXYZ(13,t.r,t.g,t.b),r.setXYZ(14,t.r,t.g,t.b),r.setXYZ(15,t.r,t.g,t.b),r.setXYZ(16,t.r,t.g,t.b),r.setXYZ(17,t.r,t.g,t.b),r.setXYZ(18,t.r,t.g,t.b),r.setXYZ(19,t.r,t.g,t.b),r.setXYZ(20,t.r,t.g,t.b),r.setXYZ(21,t.r,t.g,t.b),r.setXYZ(22,t.r,t.g,t.b),r.setXYZ(23,t.r,t.g,t.b),r.setXYZ(24,e.r,e.g,e.b),r.setXYZ(25,e.r,e.g,e.b),r.setXYZ(26,e.r,e.g,e.b),r.setXYZ(27,e.r,e.g,e.b),r.setXYZ(28,e.r,e.g,e.b),r.setXYZ(29,e.r,e.g,e.b),r.setXYZ(30,e.r,e.g,e.b),r.setXYZ(31,e.r,e.g,e.b),r.setXYZ(32,i.r,i.g,i.b),r.setXYZ(33,i.r,i.g,i.b),r.setXYZ(34,i.r,i.g,i.b),r.setXYZ(35,i.r,i.g,i.b),r.setXYZ(36,i.r,i.g,i.b),r.setXYZ(37,i.r,i.g,i.b),r.setXYZ(38,n.r,n.g,n.b),r.setXYZ(39,n.r,n.g,n.b),r.setXYZ(40,s.r,s.g,s.b),r.setXYZ(41,s.r,s.g,s.b),r.setXYZ(42,s.r,s.g,s.b),r.setXYZ(43,s.r,s.g,s.b),r.setXYZ(44,s.r,s.g,s.b),r.setXYZ(45,s.r,s.g,s.b),r.setXYZ(46,s.r,s.g,s.b),r.setXYZ(47,s.r,s.g,s.b),r.setXYZ(48,s.r,s.g,s.b),r.setXYZ(49,s.r,s.g,s.b),r.needsUpdate=!0}update(){const t=this.geometry,e=this.pointMap;qd.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Xd("c",e,t,qd,0,0,-1),Xd("t",e,t,qd,0,0,1),Xd("n1",e,t,qd,-1,-1,-1),Xd("n2",e,t,qd,1,-1,-1),Xd("n3",e,t,qd,-1,1,-1),Xd("n4",e,t,qd,1,1,-1),Xd("f1",e,t,qd,-1,-1,1),Xd("f2",e,t,qd,1,-1,1),Xd("f3",e,t,qd,-1,1,1),Xd("f4",e,t,qd,1,1,1),Xd("u1",e,t,qd,.7,1.1,-1),Xd("u2",e,t,qd,-.7,1.1,-1),Xd("u3",e,t,qd,0,2,-1),Xd("cf1",e,t,qd,-1,0,1),Xd("cf2",e,t,qd,1,0,1),Xd("cf3",e,t,qd,0,-1,1),Xd("cf4",e,t,qd,0,1,1),Xd("cn1",e,t,qd,-1,0,-1),Xd("cn2",e,t,qd,1,0,-1),Xd("cn3",e,t,qd,0,-1,-1),Xd("cn4",e,t,qd,0,1,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},CanvasTexture:class extends Ci{constructor(t,e,i,n,s,r,a,o,l){super(t,e,i,n,s,r,a,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},CapsuleGeometry:qh,CatmullRomCurve3:Ph,CineonToneMapping:3,CircleGeometry:Xh,ClampToEdgeWrapping:pt,Clock:rd,Color:ts,ColorKeyframeTrack:du,ColorManagement:yi,CompressedArrayTexture:class extends Mh{constructor(t,e,i,n,s,r){super(t,e,i,s,r),this.isCompressedArrayTexture=!0,this.image.depth=n,this.wrapR=pt}},CompressedCubeTexture:class extends Mh{constructor(t,e,i){super(void 0,t[0].width,t[0].height,e,i,ot),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}},CompressedTexture:Mh,CompressedTextureLoader:class extends Su{constructor(t){super(t)}load(t,e,i,n){const s=this,r=[],a=new Mh,o=new Eu(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(s.withCredentials);let l=0;function h(h){o.load(t[h],function(t){const i=s.parse(t,!0);r[h]={width:i.width,height:i.height,format:i.format,mipmaps:i.mipmaps},l+=1,6===l&&(1===i.mipmapCount&&(a.minFilter=vt),a.image=r,a.format=i.format,a.needsUpdate=!0,e&&e(a))},i,n)}if(Array.isArray(t))for(let c=0,u=t.length;c<u;++c)h(c);else o.load(t,function(t){const i=s.parse(t,!0);if(i.isCubemap){const t=i.mipmaps.length/i.mipmapCount;for(let e=0;e<t;e++){r[e]={mipmaps:[]};for(let t=0;t<i.mipmapCount;t++)r[e].mipmaps.push(i.mipmaps[e*i.mipmapCount+t]),r[e].format=i.format,r[e].width=i.width,r[e].height=i.height}a.image=r}else a.image.width=i.width,a.image.height=i.height,a.mipmaps=i.mipmaps;1===i.mipmapCount&&(a.minFilter=vt),a.format=i.format,a.needsUpdate=!0,e&&e(a)},i,n);return a}},ConeGeometry:Yh,ConstantAlphaFactor:213,ConstantColorFactor:211,CubeCamera:$s,CubeReflectionMapping:ot,CubeRefractionMapping:lt,CubeTexture:Qs,CubeTextureLoader:class extends Su{constructor(t){super(t)}load(t,e,i,n){const s=new Qs;s.colorSpace=Se;const r=new Au(this.manager);r.setCrossOrigin(this.crossOrigin),r.setPath(this.path);let a=0;function o(i){r.load(t[i],function(t){s.images[i]=t,a++,6===a&&(s.needsUpdate=!0,e&&e(s))},void 0,n)}for(let l=0;l<t.length;++l)o(l);return s}},CubeUVReflectionMapping:ut,CubicBezierCurve:Uh,CubicBezierCurve3:Nh,CubicInterpolant:ou,CullFaceBack:1,CullFaceFront:2,CullFaceFrontBack:3,CullFaceNone:0,Curve:bh,CurvePath:Gh,CustomBlending:5,CustomToneMapping:5,CylinderGeometry:jh,Cylindrical:class{constructor(t=1,e=0,i=0){return this.radius=t,this.theta=e,this.y=i,this}set(t,e,i){return this.radius=t,this.theta=e,this.y=i,this}copy(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,i){return this.radius=Math.sqrt(t*t+i*i),this.theta=Math.atan2(t,i),this.y=e,this}clone(){return(new this.constructor).copy(this)}},Data3DTexture:Di,DataArrayTexture:Ii,DataTexture:Al,DataTextureLoader:class extends Su{constructor(t){super(t)}load(t,e,i,n){const s=this,r=new Al,a=new Eu(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(s.withCredentials),a.load(t,function(t){let i;try{i=s.parse(t)}catch(a){if(void 0===n)return;n(a)}void 0!==i.image?r.image=i.image:void 0!==i.data&&(r.image.width=i.width,r.image.height=i.height,r.image.data=i.data),r.wrapS=void 0!==i.wrapS?i.wrapS:pt,r.wrapT=void 0!==i.wrapT?i.wrapT:pt,r.magFilter=void 0!==i.magFilter?i.magFilter:vt,r.minFilter=void 0!==i.minFilter?i.minFilter:vt,r.anisotropy=void 0!==i.anisotropy?i.anisotropy:1,void 0!==i.colorSpace?r.colorSpace=i.colorSpace:void 0!==i.encoding&&(r.encoding=i.encoding),void 0!==i.flipY&&(r.flipY=i.flipY),void 0!==i.format&&(r.format=i.format),void 0!==i.type&&(r.type=i.type),void 0!==i.mipmaps&&(r.mipmaps=i.mipmaps,r.minFilter=xt),1===i.mipmapCount&&(r.minFilter=vt),void 0!==i.generateMipmaps&&(r.generateMipmaps=i.generateMipmaps),r.needsUpdate=!0,e&&e(r,i)},i,n),r}},DataUtils:hs,DecrementStencilOp:7683,DecrementWrapStencilOp:34056,DefaultLoadingManager:bu,DepthFormat:Lt,DepthStencilFormat:It,DepthTexture:qr,DetachedBindMode:rt,DirectionalLight:Gu,DirectionalLightHelper:class extends Fn{constructor(t,e,i){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",void 0===e&&(e=1);let n=new Ss;n.setAttribute("position",new fs([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));const s=new nh({fog:!1,toneMapped:!1});this.lightPlane=new hh(n,s),this.add(this.lightPlane),n=new Ss,n.setAttribute("position",new fs([0,0,0,0,0,1],3)),this.targetLine=new hh(n,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Vd.setFromMatrixPosition(this.light.matrixWorld),Gd.setFromMatrixPosition(this.light.target.matrixWorld),Hd.subVectors(Gd,Vd),this.lightPlane.lookAt(Gd),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Gd),this.targetLine.scale.z=Hd.length()}},DiscreteInterpolant:hu,DisplayP3ColorSpace:Te,DodecahedronGeometry:Jh,DoubleSide:2,DstAlphaFactor:206,DstColorFactor:208,DynamicCopyUsage:35050,DynamicDrawUsage:35048,DynamicReadUsage:35049,EdgesGeometry:ec,EllipseCurve:Sh,EqualCompare:514,EqualDepth:4,EqualStencilFunc:514,EquirectangularReflectionMapping:ht,EquirectangularRefractionMapping:ct,Euler:bn,EventDispatcher:qe,ExtrudeGeometry:Pc,FileLoader:Eu,Float16BufferAttribute:class extends ds{constructor(t,e,i){super(new Uint16Array(t),e,i),this.isFloat16BufferAttribute=!0}getX(t){let e=ls(this.array[t*this.itemSize]);return this.normalized&&(e=ii(e,this.array)),e}setX(t,e){return this.normalized&&(e=ni(e,this.array)),this.array[t*this.itemSize]=os(e),this}getY(t){let e=ls(this.array[t*this.itemSize+1]);return this.normalized&&(e=ii(e,this.array)),e}setY(t,e){return this.normalized&&(e=ni(e,this.array)),this.array[t*this.itemSize+1]=os(e),this}getZ(t){let e=ls(this.array[t*this.itemSize+2]);return this.normalized&&(e=ii(e,this.array)),e}setZ(t,e){return this.normalized&&(e=ni(e,this.array)),this.array[t*this.itemSize+2]=os(e),this}getW(t){let e=ls(this.array[t*this.itemSize+3]);return this.normalized&&(e=ii(e,this.array)),e}setW(t,e){return this.normalized&&(e=ni(e,this.array)),this.array[t*this.itemSize+3]=os(e),this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=ni(e,this.array),i=ni(i,this.array)),this.array[t+0]=os(e),this.array[t+1]=os(i),this}setXYZ(t,e,i,n){return t*=this.itemSize,this.normalized&&(e=ni(e,this.array),i=ni(i,this.array),n=ni(n,this.array)),this.array[t+0]=os(e),this.array[t+1]=os(i),this.array[t+2]=os(n),this}setXYZW(t,e,i,n,s){return t*=this.itemSize,this.normalized&&(e=ni(e,this.array),i=ni(i,this.array),n=ni(n,this.array),s=ni(s,this.array)),this.array[t+0]=os(e),this.array[t+1]=os(i),this.array[t+2]=os(n),this.array[t+3]=os(s),this}},Float32BufferAttribute:fs,Float64BufferAttribute:class extends ds{constructor(t,e,i){super(new Float64Array(t),e,i)}},FloatType:Tt,Fog:Xo,FogExp2:qo,FramebufferTexture:class extends Ci{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=ft,this.minFilter=ft,this.generateMipmaps=!1,this.needsUpdate=!0}},FrontSide:0,Frustum:or,GLBufferAttribute:class{constructor(t,e,i,n,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=t,this.type=e,this.itemSize=i,this.elementSize=n,this.count=s,this.version=0}set needsUpdate(t){!0===t&&this.version++}setBuffer(t){return this.buffer=t,this}setType(t,e){return this.type=t,this.elementSize=e,this}setItemSize(t){return this.itemSize=t,this}setCount(t){return this.count=t,this}},GLSL1:"100",GLSL3:Ve,GreaterCompare:516,GreaterDepth:6,GreaterEqualCompare:518,GreaterEqualDepth:5,GreaterEqualStencilFunc:518,GreaterStencilFunc:516,GridHelper:class extends dh{constructor(t=10,e=10,i=4473924,n=8947848){i=new ts(i),n=new ts(n);const s=e/2,r=t/e,a=t/2,o=[],l=[];for(let c=0,u=0,d=-a;c<=e;c++,d+=r){o.push(-a,0,d,a,0,d),o.push(d,0,-a,d,0,a);const t=c===s?i:n;t.toArray(l,u),u+=3,t.toArray(l,u),u+=3,t.toArray(l,u),u+=3,t.toArray(l,u),u+=3}const h=new Ss;h.setAttribute("position",new fs(o,3)),h.setAttribute("color",new fs(l,3)),super(h,new nh({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},Group:Fo,HalfFloatType:Et,HemisphereLight:Ru,HemisphereLightHelper:class extends Fn{constructor(t,e,i){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";const n=new Dc(e);n.rotateY(.5*Math.PI),this.material=new ss({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const s=n.getAttribute("position"),r=new Float32Array(3*s.count);n.setAttribute("color",new ds(r,3)),this.add(new Vs(n,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const t=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const e=t.geometry.getAttribute("color");zd.copy(this.light.color),kd.copy(this.light.groundColor);for(let t=0,i=e.count;t<i;t++){const n=t<i/2?zd:kd;e.setXYZ(t,n.r,n.g,n.b)}e.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),t.lookAt(Bd.setFromMatrixPosition(this.light.matrixWorld).negate())}},IcosahedronGeometry:Ic,ImageBitmapLoader:class extends Su{constructor(t){super(t),this.isImageBitmapLoader=!0,this.options={premultiplyAlpha:"none"}}setOptions(t){return this.options=t,this}load(t,e,i,n){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,r=xu.get(t);if(void 0!==r)return s.manager.itemStart(t),r.then?void r.then(i=>{e&&e(i),s.manager.itemEnd(t)}).catch(t=>{n&&n(t)}):(setTimeout(function(){e&&e(r),s.manager.itemEnd(t)},0),r);const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader;const o=fetch(t,a).then(function(t){return t.blob()}).then(function(t){return createImageBitmap(t,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(i){return xu.add(t,i),e&&e(i),s.manager.itemEnd(t),i}).catch(function(e){n&&n(e),xu.remove(t),s.manager.itemError(t),s.manager.itemEnd(t)});xu.add(t,o),s.manager.itemStart(t)}},ImageLoader:Au,ImageUtils:Si,IncrementStencilOp:7682,IncrementWrapStencilOp:34055,InstancedBufferAttribute:Ll,InstancedBufferGeometry:Zu,InstancedInterleavedBuffer:class extends Yo{constructor(t,e,i=1){super(t,e),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}clone(t){const e=super.clone(t);return e.meshPerAttribute=this.meshPerAttribute,e}toJSON(t){const e=super.toJSON(t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}},InstancedMesh:zl,Int16BufferAttribute:class extends ds{constructor(t,e,i){super(new Int16Array(t),e,i)}},Int32BufferAttribute:class extends ds{constructor(t,e,i){super(new Int32Array(t),e,i)}},Int8BufferAttribute:class extends ds{constructor(t,e,i){super(new Int8Array(t),e,i)}},IntType:St,InterleavedBuffer:Yo,InterleavedBufferAttribute:Jo,Interpolant:au,InterpolateDiscrete:pe,InterpolateLinear:me,InterpolateSmooth:fe,InvertStencilOp:5386,KeepStencilOp:Le,KeyframeTrack:cu,LOD:fl,LatheGeometry:Wh,Layers:Sn,LessCompare:513,LessDepth:2,LessEqualCompare:515,LessEqualDepth:3,LessEqualStencilFunc:515,LessStencilFunc:513,Light:Cu,LightProbe:Xu,Line:hh,Line3:class{constructor(t=new Ni,e=new Ni){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){Ld.subVectors(t,this.start),Id.subVectors(this.end,this.start);const i=Id.dot(Id);let n=Id.dot(Ld)/i;return e&&(n=Ke(n,0,1)),n}closestPointToPoint(t,e,i){const n=this.closestPointToPointParameter(t,e);return this.delta(i).multiplyScalar(n).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}},LineBasicMaterial:nh,LineCurve:Oh,LineCurve3:Fh,LineDashedMaterial:Qc,LineLoop:ph,LineSegments:dh,LinearDisplayP3ColorSpace:Ee,LinearEncoding:xe,LinearFilter:vt,LinearInterpolant:lu,LinearMipMapLinearFilter:1008,LinearMipMapNearestFilter:1007,LinearMipmapLinearFilter:xt,LinearMipmapNearestFilter:yt,LinearSRGBColorSpace:we,LinearToneMapping:1,LinearTransfer:Ae,Loader:Su,LoaderUtils:Yu,LoadingManager:Mu,LoopOnce:2200,LoopPingPong:2202,LoopRepeat:2201,LuminanceAlphaFormat:1025,LuminanceFormat:1024,MOUSE:{LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Material:ns,MaterialLoader:ju,MathUtils:si,Matrix3:ai,Matrix4:dn,MaxEquation:104,Mesh:Vs,MeshBasicMaterial:ss,MeshDepthMaterial:Po,MeshDistanceMaterial:Lo,MeshLambertMaterial:Kc,MeshMatcapMaterial:$c,MeshNormalMaterial:Jc,MeshPhongMaterial:Yc,MeshPhysicalMaterial:jc,MeshStandardMaterial:Xc,MeshToonMaterial:Zc,MinEquation:103,MirroredRepeatWrapping:mt,MixOperation:1,MultiplyBlending:4,MultiplyOperation:0,NearestFilter:ft,NearestMipMapLinearFilter:1005,NearestMipMapNearestFilter:1004,NearestMipmapLinearFilter:_t,NearestMipmapNearestFilter:gt,NeverCompare:512,NeverDepth:0,NeverStencilFunc:512,NoBlending:0,NoColorSpace:be,NoToneMapping:0,NormalAnimationBlendMode:2500,NormalBlending:1,NotEqualCompare:517,NotEqualDepth:7,NotEqualStencilFunc:517,NumberKeyframeTrack:pu,Object3D:Fn,ObjectLoader:class extends Su{constructor(t){super(t)}load(t,e,i,n){const s=this,r=""===this.path?Yu.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||r;const a=new Eu(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(i){let r=null;try{r=JSON.parse(i)}catch(o){return void(void 0!==n&&n(o))}const a=r.metadata;void 0!==a&&void 0!==a.type&&"geometry"!==a.type.toLowerCase()?s.parse(r,e):void 0!==n&&n(new Error("THREE.ObjectLoader: Can't load "+t))},i,n)}async loadAsync(t,e){const i=""===this.path?Yu.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||i;const n=new Eu(this.manager);n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials);const s=await n.loadAsync(t,e),r=JSON.parse(s),a=r.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())throw new Error("THREE.ObjectLoader: Can't load "+t);return await this.parseAsync(r)}parse(t,e){const i=this.parseAnimations(t.animations),n=this.parseShapes(t.shapes),s=this.parseGeometries(t.geometries,n),r=this.parseImages(t.images,function(){void 0!==e&&e(l)}),a=this.parseTextures(t.textures,r),o=this.parseMaterials(t.materials,a),l=this.parseObject(t.object,s,o,a,i),h=this.parseSkeletons(t.skeletons,l);if(this.bindSkeletons(l,h),void 0!==e){let t=!1;for(const e in r)if(r[e].data instanceof HTMLImageElement){t=!0;break}!1===t&&e(l)}return l}async parseAsync(t){const e=this.parseAnimations(t.animations),i=this.parseShapes(t.shapes),n=this.parseGeometries(t.geometries,i),s=await this.parseImagesAsync(t.images),r=this.parseTextures(t.textures,s),a=this.parseMaterials(t.materials,r),o=this.parseObject(t.object,n,a,r,e),l=this.parseSkeletons(t.skeletons,o);return this.bindSkeletons(o,l),o}parseShapes(t){const e={};if(void 0!==t)for(let i=0,n=t.length;i<n;i++){const n=(new ic).fromJSON(t[i]);e[n.uuid]=n}return e}parseSkeletons(t,e){const i={},n={};if(e.traverse(function(t){t.isBone&&(n[t.uuid]=t)}),void 0!==t)for(let s=0,r=t.length;s<r;s++){const e=(new Pl).fromJSON(t[s],n);i[e.uuid]=e}return i}parseGeometries(t,e){const i={};if(void 0!==t){const n=new Ju;for(let s=0,r=t.length;s<r;s++){let r;const a=t[s];switch(a.type){case"BufferGeometry":case"InstancedBufferGeometry":r=n.parse(a);break;default:a.type in Hc&&(r=Hc[a.type].fromJSON(a,e))}r.uuid=a.uuid,void 0!==a.name&&(r.name=a.name),void 0!==a.userData&&(r.userData=a.userData),i[a.uuid]=r}}return i}parseMaterials(t,e){const i={},n={};if(void 0!==t){const s=new ju;s.setTextures(e);for(let e=0,r=t.length;e<r;e++){const r=t[e];void 0===i[r.uuid]&&(i[r.uuid]=s.parse(r)),n[r.uuid]=i[r.uuid]}}return n}parseAnimations(t){const e={};if(void 0!==t)for(let i=0;i<t.length;i++){const n=t[i],s=vu.parse(n);e[s.uuid]=s}return e}parseImages(t,e){const i=this,n={};let s;function r(t){if("string"==typeof t){const e=t;return function(t){return i.manager.itemStart(t),s.load(t,function(){i.manager.itemEnd(t)},void 0,function(){i.manager.itemError(t),i.manager.itemEnd(t)})}(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(e)?e:i.resourcePath+e)}return t.data?{data:ci(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){const i=new Mu(e);s=new Au(i),s.setCrossOrigin(this.crossOrigin);for(let e=0,s=t.length;e<s;e++){const i=t[e],s=i.url;if(Array.isArray(s)){const t=[];for(let e=0,i=s.length;e<i;e++){const i=r(s[e]);null!==i&&(i instanceof HTMLImageElement?t.push(i):t.push(new Al(i.data,i.width,i.height)))}n[i.uuid]=new Ti(t)}else{const t=r(i.url);n[i.uuid]=new Ti(t)}}}return n}async parseImagesAsync(t){const e=this,i={};let n;async function s(t){if("string"==typeof t){const i=t,s=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(i)?i:e.resourcePath+i;return await n.loadAsync(s)}return t.data?{data:ci(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){n=new Au(this.manager),n.setCrossOrigin(this.crossOrigin);for(let e=0,n=t.length;e<n;e++){const n=t[e],r=n.url;if(Array.isArray(r)){const t=[];for(let e=0,i=r.length;e<i;e++){const i=r[e],n=await s(i);null!==n&&(n instanceof HTMLImageElement?t.push(n):t.push(new Al(n.data,n.width,n.height)))}i[n.uuid]=new Ti(t)}else{const t=await s(n.url);i[n.uuid]=new Ti(t)}}}return i}parseTextures(t,e){function i(t,e){return"number"==typeof t?t:e[t]}const n={};if(void 0!==t)for(let s=0,r=t.length;s<r;s++){const r=t[s];r.image,e[r.image];const a=e[r.image],o=a.data;let l;Array.isArray(o)?(l=new Qs,6===o.length&&(l.needsUpdate=!0)):(l=o&&o.data?new Al:new Ci,o&&(l.needsUpdate=!0)),l.source=a,l.uuid=r.uuid,void 0!==r.name&&(l.name=r.name),void 0!==r.mapping&&(l.mapping=i(r.mapping,Ku)),void 0!==r.channel&&(l.channel=r.channel),void 0!==r.offset&&l.offset.fromArray(r.offset),void 0!==r.repeat&&l.repeat.fromArray(r.repeat),void 0!==r.center&&l.center.fromArray(r.center),void 0!==r.rotation&&(l.rotation=r.rotation),void 0!==r.wrap&&(l.wrapS=i(r.wrap[0],$u),l.wrapT=i(r.wrap[1],$u)),void 0!==r.format&&(l.format=r.format),void 0!==r.internalFormat&&(l.internalFormat=r.internalFormat),void 0!==r.type&&(l.type=r.type),void 0!==r.colorSpace&&(l.colorSpace=r.colorSpace),void 0!==r.encoding&&(l.encoding=r.encoding),void 0!==r.minFilter&&(l.minFilter=i(r.minFilter,Qu)),void 0!==r.magFilter&&(l.magFilter=i(r.magFilter,Qu)),void 0!==r.anisotropy&&(l.anisotropy=r.anisotropy),void 0!==r.flipY&&(l.flipY=r.flipY),void 0!==r.generateMipmaps&&(l.generateMipmaps=r.generateMipmaps),void 0!==r.premultiplyAlpha&&(l.premultiplyAlpha=r.premultiplyAlpha),void 0!==r.unpackAlignment&&(l.unpackAlignment=r.unpackAlignment),void 0!==r.compareFunction&&(l.compareFunction=r.compareFunction),void 0!==r.userData&&(l.userData=r.userData),n[r.uuid]=l}return n}parseObject(t,e,i,n,s){let r,a,o;function l(t){return e[t],e[t]}function h(t){if(void 0!==t){if(Array.isArray(t)){const e=[];for(let n=0,s=t.length;n<s;n++){const s=t[n];i[s],e.push(i[s])}return e}return i[t],i[t]}}function c(t){return n[t],n[t]}switch(t.type){case"Scene":r=new jo,void 0!==t.background&&(Number.isInteger(t.background)?r.background=new ts(t.background):r.background=c(t.background)),void 0!==t.environment&&(r.environment=c(t.environment)),void 0!==t.fog&&("Fog"===t.fog.type?r.fog=new Xo(t.fog.color,t.fog.near,t.fog.far):"FogExp2"===t.fog.type&&(r.fog=new qo(t.fog.color,t.fog.density)),""!==t.fog.name&&(r.fog.name=t.fog.name)),void 0!==t.backgroundBlurriness&&(r.backgroundBlurriness=t.backgroundBlurriness),void 0!==t.backgroundIntensity&&(r.backgroundIntensity=t.backgroundIntensity);break;case"PerspectiveCamera":r=new Js(t.fov,t.aspect,t.near,t.far),void 0!==t.focus&&(r.focus=t.focus),void 0!==t.zoom&&(r.zoom=t.zoom),void 0!==t.filmGauge&&(r.filmGauge=t.filmGauge),void 0!==t.filmOffset&&(r.filmOffset=t.filmOffset),void 0!==t.view&&(r.view=Object.assign({},t.view));break;case"OrthographicCamera":r=new Mr(t.left,t.right,t.top,t.bottom,t.near,t.far),void 0!==t.zoom&&(r.zoom=t.zoom),void 0!==t.view&&(r.view=Object.assign({},t.view));break;case"AmbientLight":r=new Hu(t.color,t.intensity);break;case"DirectionalLight":r=new Gu(t.color,t.intensity);break;case"PointLight":r=new ku(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":r=new Wu(t.color,t.intensity,t.width,t.height);break;case"SpotLight":r=new Nu(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay);break;case"HemisphereLight":r=new Ru(t.color,t.groundColor,t.intensity);break;case"LightProbe":r=(new Xu).fromJSON(t);break;case"SkinnedMesh":a=l(t.geometry),o=h(t.material),r=new Tl(a,o),void 0!==t.bindMode&&(r.bindMode=t.bindMode),void 0!==t.bindMatrix&&r.bindMatrix.fromArray(t.bindMatrix),void 0!==t.skeleton&&(r.skeleton=t.skeleton);break;case"Mesh":a=l(t.geometry),o=h(t.material),r=new Vs(a,o);break;case"InstancedMesh":a=l(t.geometry),o=h(t.material);const e=t.count,i=t.instanceMatrix,n=t.instanceColor;r=new zl(a,o,e),r.instanceMatrix=new Ll(new Float32Array(i.array),16),void 0!==n&&(r.instanceColor=new Ll(new Float32Array(n.array),n.itemSize));break;case"BatchedMesh":a=l(t.geometry),o=h(t.material),r=new ih(t.maxGeometryCount,t.maxVertexCount,t.maxIndexCount,o),r.geometry=a,r.perObjectFrustumCulled=t.perObjectFrustumCulled,r.sortObjects=t.sortObjects,r._drawRanges=t.drawRanges,r._reservedRanges=t.reservedRanges,r._visibility=t.visibility,r._active=t.active,r._bounds=t.bounds.map(t=>{const e=new Bi;e.min.fromArray(t.boxMin),e.max.fromArray(t.boxMax);const i=new nn;return i.radius=t.sphereRadius,i.center.fromArray(t.sphereCenter),{boxInitialized:t.boxInitialized,box:e,sphereInitialized:t.sphereInitialized,sphere:i}}),r._maxGeometryCount=t.maxGeometryCount,r._maxVertexCount=t.maxVertexCount,r._maxIndexCount=t.maxIndexCount,r._geometryInitialized=t.geometryInitialized,r._geometryCount=t.geometryCount,r._matricesTexture=c(t.matricesTexture.uuid);break;case"LOD":r=new fl;break;case"Line":r=new hh(l(t.geometry),h(t.material));break;case"LineLoop":r=new ph(l(t.geometry),h(t.material));break;case"LineSegments":r=new dh(l(t.geometry),h(t.material));break;case"PointCloud":case"Points":r=new yh(l(t.geometry),h(t.material));break;case"Sprite":r=new ul(h(t.material));break;case"Group":r=new Fo;break;case"Bone":r=new El;break;default:r=new Fn}if(r.uuid=t.uuid,void 0!==t.name&&(r.name=t.name),void 0!==t.matrix?(r.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(r.matrixAutoUpdate=t.matrixAutoUpdate),r.matrixAutoUpdate&&r.matrix.decompose(r.position,r.quaternion,r.scale)):(void 0!==t.position&&r.position.fromArray(t.position),void 0!==t.rotation&&r.rotation.fromArray(t.rotation),void 0!==t.quaternion&&r.quaternion.fromArray(t.quaternion),void 0!==t.scale&&r.scale.fromArray(t.scale)),void 0!==t.up&&r.up.fromArray(t.up),void 0!==t.castShadow&&(r.castShadow=t.castShadow),void 0!==t.receiveShadow&&(r.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.bias&&(r.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(r.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(r.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&r.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(r.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(r.visible=t.visible),void 0!==t.frustumCulled&&(r.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(r.renderOrder=t.renderOrder),void 0!==t.userData&&(r.userData=t.userData),void 0!==t.layers&&(r.layers.mask=t.layers),void 0!==t.children){const a=t.children;for(let t=0;t<a.length;t++)r.add(this.parseObject(a[t],e,i,n,s))}if(void 0!==t.animations){const e=t.animations;for(let t=0;t<e.length;t++){const i=e[t];r.animations.push(s[i])}}if("LOD"===t.type){void 0!==t.autoUpdate&&(r.autoUpdate=t.autoUpdate);const e=t.levels;for(let t=0;t<e.length;t++){const i=e[t],n=r.getObjectByProperty("uuid",i.object);void 0!==n&&r.addLevel(n,i.distance,i.hysteresis)}}return r}bindSkeletons(t,e){0!==Object.keys(e).length&&t.traverse(function(t){if(!0===t.isSkinnedMesh&&void 0!==t.skeleton){const i=e[t.skeleton];void 0===i||t.bind(i,t.bindMatrix)}})}},ObjectSpaceNormalMap:1,OctahedronGeometry:Dc,OneFactor:201,OneMinusConstantAlphaFactor:214,OneMinusConstantColorFactor:212,OneMinusDstAlphaFactor:207,OneMinusDstColorFactor:209,OneMinusSrcAlphaFactor:Y,OneMinusSrcColorFactor:203,OrthographicCamera:Mr,P3Primaries:Pe,PCFShadowMap:1,PCFSoftShadowMap:2,PMREMGenerator:Lr,Path:Hh,PerspectiveCamera:Js,Plane:sr,PlaneGeometry:cr,PlaneHelper:class extends hh{constructor(t,e=1,i=16776960){const n=i,s=new Ss;s.setAttribute("position",new fs([1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),s.computeBoundingSphere(),super(s,new nh({color:n,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e;const r=new Ss;r.setAttribute("position",new fs([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),r.computeBoundingSphere(),this.add(new Vs(r,new ss({color:n,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(t){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(t)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}},PointLight:ku,PointLightHelper:class extends Vs{constructor(t,e,i){super(new Oc(e,4,2),new ss({wireframe:!0,fog:!1,toneMapped:!1})),this.light=t,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},Points:yh,PointsMaterial:mh,PolarGridHelper:class extends dh{constructor(t=10,e=16,i=8,n=64,s=4473924,r=8947848){s=new ts(s),r=new ts(r);const a=[],o=[];if(e>1)for(let h=0;h<e;h++){const i=h/e*2*Math.PI,n=Math.sin(i)*t,l=Math.cos(i)*t;a.push(0,0,0),a.push(n,0,l);const c=1&h?s:r;o.push(c.r,c.g,c.b),o.push(c.r,c.g,c.b)}for(let h=0;h<i;h++){const e=1&h?s:r,l=t-t/i*h;for(let t=0;t<n;t++){let i=t/n*2*Math.PI,s=Math.sin(i)*l,r=Math.cos(i)*l;a.push(s,0,r),o.push(e.r,e.g,e.b),i=(t+1)/n*2*Math.PI,s=Math.sin(i)*l,r=Math.cos(i)*l,a.push(s,0,r),o.push(e.r,e.g,e.b)}}const l=new Ss;l.setAttribute("position",new fs(a,3)),l.setAttribute("color",new fs(o,3)),super(l,new nh({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},PolyhedronGeometry:Zh,PositionalAudio:class extends ud{constructor(t){super(t),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(t){return this.panner.refDistance=t,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(t){return this.panner.rolloffFactor=t,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(t){return this.panner.distanceModel=t,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(t){return this.panner.maxDistance=t,this}setDirectionalCone(t,e,i){return this.panner.coneInnerAngle=t,this.panner.coneOuterAngle=e,this.panner.coneOuterGain=i,this}updateMatrixWorld(t){if(super.updateMatrixWorld(t),!0===this.hasPlaybackControl&&!1===this.isPlaying)return;this.matrixWorld.decompose(dd,pd,md),fd.set(0,0,1).applyQuaternion(pd);const e=this.panner;if(e.positionX){const t=this.context.currentTime+this.listener.timeDelta;e.positionX.linearRampToValueAtTime(dd.x,t),e.positionY.linearRampToValueAtTime(dd.y,t),e.positionZ.linearRampToValueAtTime(dd.z,t),e.orientationX.linearRampToValueAtTime(fd.x,t),e.orientationY.linearRampToValueAtTime(fd.y,t),e.orientationZ.linearRampToValueAtTime(fd.z,t)}else e.setPosition(dd.x,dd.y,dd.z),e.setOrientation(fd.x,fd.y,fd.z)}},PropertyBinding:Sd,PropertyMixer:gd,QuadraticBezierCurve:Bh,QuadraticBezierCurve3:zh,Quaternion:Ui,QuaternionKeyframeTrack:fu,QuaternionLinearInterpolant:mu,RED_GREEN_RGTC2_Format:ue,RED_RGTC1_Format:36283,REVISION:O,RGBADepthPacking:3201,RGBAFormat:Pt,RGBAIntegerFormat:Nt,RGBA_ASTC_10x10_Format:se,RGBA_ASTC_10x5_Format:ee,RGBA_ASTC_10x6_Format:ie,RGBA_ASTC_10x8_Format:ne,RGBA_ASTC_12x10_Format:re,RGBA_ASTC_12x12_Format:ae,RGBA_ASTC_4x4_Format:jt,RGBA_ASTC_5x4_Format:Yt,RGBA_ASTC_5x5_Format:Zt,RGBA_ASTC_6x5_Format:Jt,RGBA_ASTC_6x6_Format:Kt,RGBA_ASTC_8x5_Format:$t,RGBA_ASTC_8x6_Format:Qt,RGBA_ASTC_8x8_Format:te,RGBA_BPTC_Format:oe,RGBA_ETC2_EAC_Format:Xt,RGBA_PVRTC_2BPPV1_Format:Ht,RGBA_PVRTC_4BPPV1_Format:Gt,RGBA_S3TC_DXT1_Format:Ft,RGBA_S3TC_DXT3_Format:Bt,RGBA_S3TC_DXT5_Format:zt,RGB_BPTC_SIGNED_Format:le,RGB_BPTC_UNSIGNED_Format:he,RGB_ETC1_Format:Wt,RGB_ETC2_Format:qt,RGB_PVRTC_2BPPV1_Format:Vt,RGB_PVRTC_4BPPV1_Format:kt,RGB_S3TC_DXT1_Format:Ot,RGFormat:1030,RGIntegerFormat:Ut,RawShaderMaterial:qc,Ray:un,Raycaster:class{constructor(t,e,i=0,n=1/0){this.ray=new un(t,e),this.near=i,this.far=n,this.camera=null,this.layers=new Sn,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)}intersectObject(t,e=!0,i=[]){return Rd(t,this,i,e),i.sort(Cd),i}intersectObjects(t,e=!0,i=[]){for(let n=0,s=t.length;n<s;n++)Rd(t[n],this,i,e);return i.sort(Cd),i}},Rec709Primaries:Re,RectAreaLight:Wu,RedFormat:1028,RedIntegerFormat:Dt,ReinhardToneMapping:2,RenderTarget:Pi,RepeatWrapping:dt,ReplaceStencilOp:7681,ReverseSubtractEquation:102,RingGeometry:Uc,SIGNED_RED_GREEN_RGTC2_Format:de,SIGNED_RED_RGTC1_Format:ce,SRGBColorSpace:Se,SRGBTransfer:Ce,Scene:jo,ShaderChunk:ur,ShaderLib:pr,ShaderMaterial:Ys,ShadowMaterial:Wc,Shape:ic,ShapeGeometry:Nc,ShapePath:class{constructor(){this.type="ShapePath",this.color=new ts,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new Hh,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,i,n){return this.currentPath.quadraticCurveTo(t,e,i,n),this}bezierCurveTo(t,e,i,n,s,r){return this.currentPath.bezierCurveTo(t,e,i,n,s,r),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(t,e){const i=e.length;let n=!1;for(let s=i-1,r=0;r<i;s=r++){let i=e[s],a=e[r],o=a.x-i.x,l=a.y-i.y;if(Math.abs(l)>Number.EPSILON){if(l<0&&(i=e[r],o=-o,a=e[s],l=-l),t.y<i.y||t.y>a.y)continue;if(t.y===i.y){if(t.x===i.x)return!0}else{const e=l*(t.x-i.x)-o*(t.y-i.y);if(0===e)return!0;if(e<0)continue;n=!n}}else{if(t.y!==i.y)continue;if(a.x<=t.x&&t.x<=i.x||i.x<=t.x&&t.x<=a.x)return!0}}return n}const i=Ac.isClockWise,n=this.subPaths;if(0===n.length)return[];let s,r,a;const o=[];if(1===n.length)return r=n[0],a=new ic,a.curves=r.curves,o.push(a),o;let l=!i(n[0].getPoints());l=t?!l:l;const h=[],c=[];let u,d,p=[],m=0;c[m]=void 0,p[m]=[];for(let f=0,g=n.length;f<g;f++)r=n[f],u=r.getPoints(),s=i(u),s=t?!s:s,s?(!l&&c[m]&&m++,c[m]={s:new ic,p:u},c[m].s.curves=r.curves,l&&m++,p[m]=[]):p[m].push({h:r,p:u[0]});if(!c[0])return function(t){const e=[];for(let i=0,n=t.length;i<n;i++){const n=t[i],s=new ic;s.curves=n.curves,e.push(s)}return e}(n);if(c.length>1){let t=!1,i=0;for(let e=0,n=c.length;e<n;e++)h[e]=[];for(let n=0,s=c.length;n<s;n++){const s=p[n];for(let r=0;r<s.length;r++){const a=s[r];let o=!0;for(let s=0;s<c.length;s++)e(a.p,c[s].p)&&(n!==s&&i++,o?(o=!1,h[s].push(a)):t=!0);o&&h[n].push(a)}}i>0&&!1===t&&(p=h)}for(let f=0,g=c.length;f<g;f++){a=c[f].s,o.push(a),d=p[f];for(let t=0,e=d.length;t<e;t++)a.holes.push(d[t].h)}return o}},ShapeUtils:Ac,ShortType:1011,Skeleton:Pl,SkeletonHelper:class extends dh{constructor(t){const e=Fd(t),i=new Ss,n=[],s=[],r=new ts(0,0,1),a=new ts(0,1,0);for(let o=0;o<e.length;o++){const t=e[o];t.parent&&t.parent.isBone&&(n.push(0,0,0),n.push(0,0,0),s.push(r.r,r.g,r.b),s.push(a.r,a.g,a.b))}i.setAttribute("position",new fs(n,3)),i.setAttribute("color",new fs(s,3)),super(i,new nh({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(t){const e=this.bones,i=this.geometry,n=i.getAttribute("position");Od.copy(this.root.matrixWorld).invert();for(let s=0,r=0;s<e.length;s++){const t=e[s];t.parent&&t.parent.isBone&&(Nd.multiplyMatrices(Od,t.matrixWorld),Ud.setFromMatrixPosition(Nd),n.setXYZ(r,Ud.x,Ud.y,Ud.z),Nd.multiplyMatrices(Od,t.parent.matrixWorld),Ud.setFromMatrixPosition(Nd),n.setXYZ(r+1,Ud.x,Ud.y,Ud.z),r+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(t)}dispose(){this.geometry.dispose(),this.material.dispose()}},SkinnedMesh:Tl,Source:Ti,Sphere:nn,SphereGeometry:Oc,Spherical:class{constructor(t=1,e=0,i=0){return this.radius=t,this.phi=e,this.theta=i,this}set(t,e,i){return this.radius=t,this.phi=e,this.theta=i,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){const t=1e-6;return this.phi=Math.max(t,Math.min(Math.PI-t,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,i){return this.radius=Math.sqrt(t*t+e*e+i*i),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,i),this.phi=Math.acos(Ke(e/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}},SphericalHarmonics3:qu,SplineCurve:kh,SpotLight:Nu,SpotLightHelper:class extends Fn{constructor(t,e){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const i=new Ss,n=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let r=0,a=1,o=32;r<o;r++,a++){const t=r/o*Math.PI*2,e=a/o*Math.PI*2;n.push(Math.cos(t),Math.sin(t),1,Math.cos(e),Math.sin(e),1)}i.setAttribute("position",new fs(n,3));const s=new nh({fog:!1,toneMapped:!1});this.cone=new dh(i,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);const t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),Dd.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Dd),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},Sprite:ul,SpriteMaterial:Ko,SrcAlphaFactor:j,SrcAlphaSaturateFactor:210,SrcColorFactor:202,StaticCopyUsage:35046,StaticDrawUsage:ke,StaticReadUsage:35045,StereoCamera:class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Js,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Js,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,sd.copy(t.projectionMatrix);const i=e.eyeSep/2,n=i*e.near/e.focus,s=e.near*Math.tan(Ye*e.fov*.5)/e.zoom;let r,a;nd.elements[12]=-i,id.elements[12]=i,r=-s*e.aspect+n,a=s*e.aspect+n,sd.elements[0]=2*e.near/(a-r),sd.elements[8]=(a+r)/(a-r),this.cameraL.projectionMatrix.copy(sd),r=-s*e.aspect-n,a=s*e.aspect-n,sd.elements[0]=2*e.near/(a-r),sd.elements[8]=(a+r)/(a-r),this.cameraR.projectionMatrix.copy(sd)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(nd),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(id)}},StreamCopyUsage:35042,StreamDrawUsage:35040,StreamReadUsage:35041,StringKeyframeTrack:gu,SubtractEquation:101,SubtractiveBlending:3,TOUCH:{ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},TangentSpaceNormalMap:0,TetrahedronGeometry:Fc,Texture:Ci,TextureLoader:class extends Su{constructor(t){super(t)}load(t,e,i,n){const s=new Ci,r=new Au(this.manager);return r.setCrossOrigin(this.crossOrigin),r.setPath(this.path),r.load(t,function(t){s.image=t,s.needsUpdate=!0,void 0!==e&&e(s)},i,n),s}},TorusGeometry:Bc,TorusKnotGeometry:zc,Triangle:Zn,TriangleFanDrawMode:2,TriangleStripDrawMode:1,TrianglesDrawMode:0,TubeGeometry:kc,TwoPassDoubleSide:2,UVMapping:at,Uint16BufferAttribute:ps,Uint32BufferAttribute:ms,Uint8BufferAttribute:class extends ds{constructor(t,e,i){super(new Uint8Array(t),e,i)}},Uint8ClampedBufferAttribute:class extends ds{constructor(t,e,i){super(new Uint8ClampedArray(t),e,i)}},Uniform:Ed,UniformsGroup:class extends qe{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:Ad++}),this.name="",this.usage=ke,this.uniforms=[]}add(t){return this.uniforms.push(t),this}remove(t){const e=this.uniforms.indexOf(t);return-1!==e&&this.uniforms.splice(e,1),this}setName(t){return this.name=t,this}setUsage(t){return this.usage=t,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(t){this.name=t.name,this.usage=t.usage;const e=t.uniforms;this.uniforms.length=0;for(let i=0,n=e.length;i<n;i++){const t=Array.isArray(e[i])?e[i]:[e[i]];for(let e=0;e<t.length;e++)this.uniforms.push(t[e].clone())}return this}clone(){return(new this.constructor).copy(this)}},UniformsLib:dr,UniformsUtils:js,UnsignedByteType:Mt,UnsignedInt248Type:Rt,UnsignedIntType:wt,UnsignedShort4444Type:At,UnsignedShort5551Type:Ct,UnsignedShortType:bt,VSMShadowMap:3,Vector2:ri,Vector3:Ni,Vector4:Ri,VectorKeyframeTrack:_u,VideoTexture:class extends Ci{constructor(t,e,i,n,s,r,a,o,l){super(t,e,i,n,s,r,a,o,l),this.isVideoTexture=!0,this.minFilter=void 0!==r?r:vt,this.magFilter=void 0!==s?s:vt,this.generateMipmaps=!1;const h=this;"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(function e(){h.needsUpdate=!0,t.requestVideoFrameCallback(e)})}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;0=="requestVideoFrameCallback"in t&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},WebGL1Renderer:Wo,WebGL3DRenderTarget:class extends Li{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new Di(null,t,e,i),this.texture.isRenderTargetTexture=!0}},WebGLArrayRenderTarget:class extends Li{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new Ii(null,t,e,i),this.texture.isRenderTargetTexture=!0}},WebGLCoordinateSystem:He,WebGLCubeRenderTarget:tr,WebGLMultipleRenderTargets:class extends Li{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isWebGLMultipleRenderTargets=!0;const s=this.texture;this.texture=[];for(let r=0;r<i;r++)this.texture[r]=s.clone(),this.texture[r].isRenderTargetTexture=!0}setSize(t,e,i=1){if(this.width!==t||this.height!==e||this.depth!==i){this.width=t,this.height=e,this.depth=i;for(let n=0,s=this.texture.length;n<s;n++)this.texture[n].image.width=t,this.texture[n].image.height=e,this.texture[n].image.depth=i;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}copy(t){this.dispose(),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.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,null!==t.depthTexture&&(this.depthTexture=t.depthTexture.clone()),this.texture.length=0;for(let e=0,i=t.texture.length;e<i;e++)this.texture[e]=t.texture[e].clone(),this.texture[e].isRenderTargetTexture=!0;return this}},WebGLRenderTarget:Li,WebGLRenderer:Ho,WebGLUtils:No,WebGPUCoordinateSystem:We,WireframeGeometry:Vc,WrapAroundEnding:ve,ZeroCurvatureEnding:ge,ZeroFactor:200,ZeroSlopeEnding:_e,ZeroStencilOp:0,_SRGBAFormat:Ge,createCanvasElement:di,sRGBEncoding:Me},Symbol.toStringTag,{value:"Module"}));t.EasterEggQuest=N,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})},"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).EasterEggQuest={});
1
+ var t,e;t=this,e=function(t){"use strict";var e,i;const n={hiddenEntryHints:["hey, it's not a bug — there's a hidden game on this page","look carefully — two words are hiding among the text","it blends in with everything else, but it’s clickable"],entryConfirmation:["...","you noticed","then we can begin"],stage1Intro:["three eggs are hidden here","each one asks something different","the first riddle:","I am a cat that comes only to those who ignore it. Open your hand — and I leave. Close it — and I was never there."],stage1Reactions:["the cat is watching","it doesn’t trust you yet","you’re trying too hard","what does a cat want?","the hand is still clenched","have you tried not trying?","forget the egg exists","it won’t come if you’re waiting","some things can’t be taken","only given"],stage1Success:["you understood","stillness was the answer","the first egg reveals itself","to those who can stop","hold it to collect"],stage2Intro:["you solved the first one","the second riddle:","I am a river that needs you to flow. Without you, I dry up. But you can’t carry me — only become me. What am I?"],stage2Reactions:["the river is dry","nothing flows","what does a river need?","you are the current","without you, there’s no river","the answer isn’t in your head","it’s in your hands","be the water"],stage2Success:["movement was the answer","the second egg appears","hold it to collect"],stage3Intro:["the final riddle:","Every living thing knows it. You’ve been doing it your whole life without thinking."],stage3Reactions:["one truth alone is not enough","the other alone is not enough either","what do all living things share?","you have known it since the beginning","listen to yourself","in","out"],stage3Success:["rhythm was the answer","you found the third egg"],finale:["all three eggs found","stillness, motion, rhythm","that's the whole set"],results:["begin again","challenge someone"]},s={overlayBg:"rgba(0,0,0,0.25)",textColor:"rgba(255,255,255,0.92)",textSecondary:"rgba(255,255,255,0.55)",accent:"#D4A574",accentGlow:"rgba(212,165,116,0.4)",hudBg:"rgba(0,0,0,0.45)",hudText:"rgba(255,255,255,0.85)"},r=["buy","purchase","checkout","pay","delete","remove","submit","confirm","order","sign out","log out","logout","signout","unsubscribe","cancel","close account"],a=['form [type="submit"]',"[data-no-easter]"];function o(t,e){if(void 0===t)return e;const i=Number(t);return!Number.isFinite(i)||i<1e3||i>3e5?e:i}function l(t,e,i,n){if(void 0===t)return e;const s=Math.round(Number(t));return!Number.isFinite(s)||s<i||s>n?e:s}function h(t){if(t&&"string"==typeof t&&!(t.length>200)){try{document.querySelector(t)}catch{return}return t}}class c{constructor(){this.listeners=new Map}on(t,e){this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(e)}off(t,e){var i;null==(i=this.listeners.get(t))||i.delete(e)}emit(t,...e){var i;null==(i=this.listeners.get(t))||i.forEach(t=>{try{t(...e)}catch{}})}clear(){this.listeners.clear()}}const u={idle:["entry"],entry:["stage1-intro"],"stage1-intro":["stage1-active"],"stage1-active":["stage1-success"],"stage1-success":["stage2-intro"],"stage2-intro":["stage2-active"],"stage2-active":["stage2-success"],"stage2-success":["stage3-intro"],"stage3-intro":["stage3-active"],"stage3-active":["stage3-success"],"stage3-success":["finale"],finale:["results"],results:["complete","idle"],complete:["idle"]};class d{constructor(){this._state="idle",this._onTransition=null}get state(){return this._state}onTransition(t){this._onTransition=t}transitionTo(t){var e;const i=u[this._state];if(!i||!i.includes(t))return!1;const n=this._state;return this._state=t,null==(e=this._onTransition)||e.call(this,n,t),!0}reset(){this._state="idle"}forceState(t){this._state=t}get label(){return p[this._state]??""}}const p={idle:"",entry:"Searching","stage1-intro":"Stillness","stage1-active":"Stillness","stage1-success":"Stillness","stage2-intro":"Motion","stage2-active":"Motion","stage2-success":"Motion","stage3-intro":"Rhythm","stage3-active":"Rhythm","stage3-success":"Rhythm",finale:"Finale",results:"Results",complete:"Complete"};class m{constructor(){this._snapshot={isMoving:!1,lastMoveTime:0,lastStillTime:Date.now(),mouseX:0,mouseY:0,velocity:0,totalClicks:0,totalScrolls:0,totalKeyPresses:0,totalDistance:0,maxVelocity:0},this._phases=[],this._currentPhaseType="still",this._currentPhaseStart=Date.now(),this._prevX=0,this._prevY=0,this._prevMoveTs=0,this.DEFAULT_STILL_THRESHOLD_MS=400,this._stillThresholdMs=this.DEFAULT_STILL_THRESHOLD_MS,this.DEFAULT_MIN_PHASE_MS=300,this._minPhaseMs=this.DEFAULT_MIN_PHASE_MS,this._stillTimer=null,this._handlers=[],this._active=!1,this._onVisibilityChange=()=>{if(document.hidden)this._snapshot.isMoving=!0;else{const t=Date.now();this._snapshot.isMoving=!1,this._snapshot.lastStillTime=t,this._snapshot.velocity=0,this._currentPhaseType="still",this._currentPhaseStart=t}},this._onWindowBlur=()=>{this._snapshot.isMoving=!0},this._onPointerMove=t=>{const e=Date.now(),i=t.clientX-this._prevX,n=t.clientY-this._prevY,s=e-this._prevMoveTs||1,r=Math.sqrt(i*i+n*n);r<2||(this._snapshot.mouseX=t.clientX,this._snapshot.mouseY=t.clientY,this._snapshot.velocity=r/s*1e3,this._snapshot.totalDistance+=r,this._snapshot.velocity>this._snapshot.maxVelocity&&(this._snapshot.maxVelocity=this._snapshot.velocity),this._prevX=t.clientX,this._prevY=t.clientY,this._prevMoveTs=e,this._registerMove(e))},this._onTouchMove=t=>{const e=t.touches[0];if(!e)return;const i=Date.now(),n=e.clientX-this._prevX,s=e.clientY-this._prevY;Math.sqrt(n*n+s*s)<2||(this._snapshot.mouseX=e.clientX,this._snapshot.mouseY=e.clientY,this._prevX=e.clientX,this._prevY=e.clientY,this._prevMoveTs=i,this._registerMove(i))},this._onClick=()=>{this._snapshot.totalClicks++,this._registerMove(Date.now())},this._onActivity=()=>{this._registerMove(Date.now())},this._onScroll=()=>{this._snapshot.totalScrolls++,this._registerMove(Date.now())},this._onKeyDown=()=>{this._snapshot.totalKeyPresses++,this._registerMove(Date.now())}}get snapshot(){return{...this._snapshot}}get phases(){return this._phases.slice()}get stillDuration(){return this._snapshot.isMoving?0:Date.now()-this._snapshot.lastStillTime}get moveDuration(){return this._snapshot.isMoving?Date.now()-this._snapshot.lastMoveTime:0}get timeSinceLastActivity(){return Date.now()-Math.max(this._snapshot.lastMoveTime,this._snapshot.lastStillTime)}start(){if(this._active)return;this._active=!0,this._snapshot.lastStillTime=Date.now();const t=(t,e,i)=>{window.addEventListener(t,e,{passive:!0,...i}),this._handlers.push({event:t,fn:e})};t("mousemove",this._onPointerMove),t("touchmove",this._onTouchMove),t("click",this._onClick),t("mousedown",this._onActivity),t("touchstart",this._onActivity),t("scroll",this._onScroll,{capture:!0}),t("keydown",this._onKeyDown),t("wheel",this._onScroll);const e=this._onVisibilityChange;document.addEventListener("visibilitychange",e),this._handlers.push({event:"visibilitychange",fn:e}),window.addEventListener("blur",this._onWindowBlur),this._handlers.push({event:"blur",fn:this._onWindowBlur})}stop(){this._active=!1;for(const{event:t,fn:e}of this._handlers)window.removeEventListener(t,e),document.removeEventListener(t,e);this._handlers=[],this._stillTimer&&clearTimeout(this._stillTimer)}resetPhases(){this._phases=[],this._currentPhaseType="still",this._currentPhaseStart=Date.now(),this._snapshot.isMoving=!1,this._snapshot.velocity=0,this._stillTimer&&(clearTimeout(this._stillTimer),this._stillTimer=null)}resetCounts(){this._snapshot.totalClicks=0,this._snapshot.totalScrolls=0,this._snapshot.totalKeyPresses=0,this._snapshot.totalDistance=0,this._snapshot.maxVelocity=0}configurePhaseDetection(t){"number"==typeof t.stillThresholdMs&&(this._stillThresholdMs=Math.max(250,t.stillThresholdMs)),"number"==typeof t.minPhaseMs&&(this._minPhaseMs=Math.max(150,t.minPhaseMs))}resetPhaseDetection(){this._stillThresholdMs=this.DEFAULT_STILL_THRESHOLD_MS,this._minPhaseMs=this.DEFAULT_MIN_PHASE_MS}_registerMove(t){this._snapshot.lastMoveTime=t,this._snapshot.isMoving||(this._snapshot.isMoving=!0,this._completePhase("still",t),this._currentPhaseType="move",this._currentPhaseStart=t),this._stillTimer&&clearTimeout(this._stillTimer),this._stillTimer=setTimeout(()=>{this._becomeStill()},this._stillThresholdMs)}_becomeStill(){if(!this._snapshot.isMoving)return;const t=Date.now();this._snapshot.isMoving=!1,this._snapshot.lastStillTime=t,this._snapshot.velocity=0,this._completePhase("move",t),this._currentPhaseType="still",this._currentPhaseStart=t}_completePhase(t,e){const i=e-this._currentPhaseStart;i>=this._minPhaseMs&&this._phases.push({type:t,startTime:this._currentPhaseStart,endTime:e,duration:i}),this._phases.length>200&&(this._phases=this._phases.slice(-100))}}function f(t){const e=Math.floor(t/1e3),i=Math.floor(e/60),n=e%60;return`${String(i).padStart(2,"0")}:${String(n).padStart(2,"0")}`}class g{constructor(t,e,i){this.targetElement=null,this.hintTimers=[],this.hintIndex=0,this.hintContainer=null,this.shimmerStyle=null,this.clickHandler=null,this.fallbackButton=null,this._injectedElement=null,this._destroyed=!1,this._hintVisibleElapsed=0,this._hintVisibleStart=0,this._hintCheckInterval=null,this._hintVisibilityHandler=null,this._domObserver=null,this._intersectionObserver=null,this._mutationDebounce=null,this._navigationHandler=null,this._bootstrapObserver=null,this._retryTimer=null,this._fallbackTimer=null,this._retryCount=0,this._historyPatched=!1,this.config=t,this.script=e,this.onFound=i}start(){this.config.accessibility.disableHiddenEntry?this._createFallbackEntry():(this._startHintEscalation(),this._startBootstrapWatch(),this._scheduleFallback(),this._attemptInjection(0))}cleanup(){var t,e,i,n;this._destroyed=!0,this._stopHintTimer();for(const s of this.hintTimers)clearTimeout(s);this.hintTimers=[],this.clickHandler&&this.targetElement&&this.targetElement.removeEventListener("click",this.clickHandler),this.targetElement&&(this.targetElement.style.removeProperty("animation"),this.targetElement.classList.remove("eeq-entry-target")),this._stopWatchdog(),this._stopBootstrapWatch(),null==(t=this._injectedElement)||t.remove(),this._injectedElement=null,null==(e=this.hintContainer)||e.remove(),null==(i=this.shimmerStyle)||i.remove(),null==(n=this.fallbackButton)||n.remove()}_possessElement(t){this.targetElement=function(t){if(0!==t.length)return t[Math.floor(Math.random()*t.length)]}(t),this._attachToElement(this.targetElement)}_injectIntoExisting(){var t;const e=this._getSearchRoot(),i=this._findTextCandidates(e);if(0===i.length)return!1;const n=i.sort((t,e)=>{const i=null!==t.closest("nav")||null!==t.closest("header")?1:0,n=null!==e.closest("nav")||null!==e.closest("header")?1:0;return i!==n?i-n:parseFloat(getComputedStyle(t).fontSize)-parseFloat(getComputedStyle(e).fontSize)}),s=n.map(t=>{var e;return`${t.tagName}:${((null==(e=t.textContent)?void 0:e.trim())??"").slice(0,30)}`}),r="eeq_trigger_history";let a=[];try{const t=localStorage.getItem(r);t&&(a=JSON.parse(t))}catch{}let o=new Set(a);const l="eeq_visit";let h=0;try{h=parseInt(localStorage.getItem(l)||"0",10)||0,localStorage.setItem(l,String(h+1))}catch{}const c=n.filter(t=>!t.closest("nav")&&!t.closest("header")),u=n.filter(t=>null!==t.closest("nav")||null!==t.closest("header")),d=c.length>1?h%c.length:0,p=[...c.slice(d),...c.slice(0,d),...u],m=p.map(t=>{var e;return`${t.tagName}:${((null==(e=t.textContent)?void 0:e.trim())??"").slice(0,30)}`}),f=p.filter((t,e)=>!o.has(m[e]));0===f.length&&(o.clear(),a=[]);const g=f.length>0?[...f,...p.filter((t,e)=>o.has(m[e]))]:p;for(const _ of g){const e=_,i="A"===e.tagName||"BUTTON"===e.tagName||"LI"===e.tagName||null!==e.closest("nav"),a=document.createElement("span");if(a.textContent=i?" · start hunt":" start hunt",a.setAttribute("data-eeq","trigger"),a.style.cssText="\n font: inherit;\n color: inherit;\n letter-spacing: inherit;\n cursor: pointer;\n ",i||!this._tryInsertBetweenWords(e,a)){const t=e.getBoundingClientRect().height;e.appendChild(a);const i=e.getBoundingClientRect().height;if(Math.abs(i-t)>2){e.removeChild(a);continue}}const l=n.indexOf(_);if(l>=0){o.add(s[l]);try{localStorage.setItem(r,JSON.stringify([...o].slice(-20)))}catch{}}return this._injectedElement=a,this.targetElement=a,this._attachToElement(a),this._retryCount=0,this._clearRetryTimer(),this._clearFallbackTimer(),null==(t=this.fallbackButton)||t.remove(),this.fallbackButton=null,this._stopBootstrapWatch(),this._startWatchdog(),!0}return!1}_attemptInjection(t){this._clearRetryTimer(),this._retryTimer=setTimeout(()=>{this._destroyed||this._injectedElement||this._injectIntoExisting()||this._scheduleNextRetry()},t)}_scheduleNextRetry(){if(this._destroyed||this._injectedElement)return;const t=[300,900,1800,3200,5e3,8e3],e=t[Math.min(this._retryCount,t.length-1)];this._retryCount+=1,this._attemptInjection(e)}_scheduleFallback(){this.fallbackButton||this._fallbackTimer||(this._fallbackTimer=setTimeout(()=>{this._destroyed||this._injectedElement||this.fallbackButton||this._createFallbackEntry()},1e4))}_clearRetryTimer(){this._retryTimer&&(clearTimeout(this._retryTimer),this._retryTimer=null)}_clearFallbackTimer(){this._fallbackTimer&&(clearTimeout(this._fallbackTimer),this._fallbackTimer=null)}_getSearchRoot(){return this.config.hiddenEntry.selector?document.querySelector(this.config.hiddenEntry.selector)??document.body:document.body}_findTextCandidates(t){var e;const i=["p","li","figcaption","blockquote","caption","label","td","th","h1","h2","h3","h4","h5","h6","a","button",'[role="button"]','[role="link"]',"div","span","article","section","summary","[data-easter-entry]","[mat-button]","[mat-list-item]",".mat-mdc-button",".mat-mdc-list-item",".ag-cell",".ag-header-cell"].join(", "),n=new Set;for(const s of this.config.hiddenEntry.excludeSelectors)null==(e=t.querySelectorAll)||e.call(t,s).forEach(t=>n.add(t));return Array.from(t.querySelectorAll(i)).filter(t=>{var e,i;if(!(t instanceof HTMLElement))return!1;if(n.has(t))return!1;if(t.closest("[data-eeq]"))return!1;if(t.closest("script, style, noscript, svg, canvas, form"))return!1;if(function(t){const e=`${(t.textContent??"").toLowerCase().trim()} ${(t.getAttribute("aria-label")??"").toLowerCase()}`;return r.some(t=>e.includes(t))}(t))return!1;if(!function(t){const e=t.getBoundingClientRect();if(0===e.width||0===e.height)return!1;const i=getComputedStyle(t);if("none"===i.display||"hidden"===i.visibility||"0"===i.opacity)return!1;if(!(e.top<window.innerHeight&&e.bottom>0&&e.left<window.innerWidth&&e.right>0))return!1;let n=t.parentElement;for(;n&&n!==document.body;){const t=getComputedStyle(n);if([t.overflow,t.overflowX,t.overflowY].some(t=>["auto","scroll","hidden","clip"].includes(t))){const t=n.getBoundingClientRect();if(e.bottom<=t.top||e.top>=t.bottom||e.right<=t.left||e.left>=t.right)return!1}n=n.parentElement}return!0}(t))return!1;const s=(null==(e=t.innerText)?void 0:e.trim())||(null==(i=t.textContent)?void 0:i.trim())||"";if(s.length<6||s.length>220)return!1;if(t.children.length>12)return!1;const a=t.getBoundingClientRect();return!(a.width<18||a.height<12)})}_startBootstrapWatch(){this._stopBootstrapWatch();const t=this._getSearchRoot(),e=t instanceof HTMLElement?t:document.body;if(this._bootstrapObserver=new MutationObserver(()=>{this._destroyed||this._injectedElement||(this._mutationDebounce&&clearTimeout(this._mutationDebounce),this._mutationDebounce=setTimeout(()=>{this._destroyed||this._injectedElement||this._attemptInjection(150)},250))}),this._bootstrapObserver.observe(e,{childList:!0,subtree:!0}),this._navigationHandler=()=>{this._destroyed||this._injectedElement||this._attemptInjection(700)},window.addEventListener("popstate",this._navigationHandler),window.addEventListener("hashchange",this._navigationHandler),!this._historyPatched&&void 0!==window.history){this._historyPatched=!0;const t=t=>{const e=window.history[t].bind(window.history);window.history[t]=(...t)=>{const i=e(...t);return window.dispatchEvent(new Event("eeq:navigation")),i}};t("pushState"),t("replaceState")}window.addEventListener("eeq:navigation",this._navigationHandler)}_stopBootstrapWatch(){this._bootstrapObserver&&(this._bootstrapObserver.disconnect(),this._bootstrapObserver=null),this._clearRetryTimer(),this._clearFallbackTimer(),this._mutationDebounce&&(clearTimeout(this._mutationDebounce),this._mutationDebounce=null),this._navigationHandler&&(window.removeEventListener("popstate",this._navigationHandler),window.removeEventListener("hashchange",this._navigationHandler),window.removeEventListener("eeq:navigation",this._navigationHandler),this._navigationHandler=null)}_startWatchdog(){if(this._stopWatchdog(),!this._injectedElement)return;this._intersectionObserver=new IntersectionObserver(t=>{if(this._destroyed||!this._injectedElement)return;const e=t[0];e&&!e.isIntersecting&&this._reinject()},{threshold:0}),this._intersectionObserver.observe(this._injectedElement);const t=this._findStableAncestor(this._injectedElement);this._domObserver=new MutationObserver(()=>{!this._destroyed&&this._injectedElement&&(this._mutationDebounce&&clearTimeout(this._mutationDebounce),this._mutationDebounce=setTimeout(()=>{!this._destroyed&&this._injectedElement&&(document.body.contains(this._injectedElement)||this._reinject())},300))}),this._domObserver.observe(t,{childList:!0,subtree:!0}),this._navigationHandler=()=>{!this._destroyed&&this._injectedElement&&setTimeout(()=>{!this._destroyed&&this._injectedElement&&(document.body.contains(this._injectedElement)||this._reinject())},500)},window.addEventListener("popstate",this._navigationHandler),window.addEventListener("hashchange",this._navigationHandler),window.addEventListener("eeq:navigation",this._navigationHandler)}_findStableAncestor(t){let e=t.parentElement;for(;e&&e!==document.body;){const t=e.tagName.toLowerCase();if("main"===t||"body"===t||t.includes("app-")||t.includes("-root")||null!==e.querySelector("router-outlet")||"app"===e.id||"root"===e.id||"__next"===e.id)return e;e=e.parentElement}return document.body}_stopWatchdog(){this._domObserver&&(this._domObserver.disconnect(),this._domObserver=null),this._intersectionObserver&&(this._intersectionObserver.disconnect(),this._intersectionObserver=null),this._mutationDebounce&&(clearTimeout(this._mutationDebounce),this._mutationDebounce=null),this._navigationHandler&&(window.removeEventListener("popstate",this._navigationHandler),window.removeEventListener("hashchange",this._navigationHandler),window.removeEventListener("eeq:navigation",this._navigationHandler),this._navigationHandler=null)}_reinject(){this._stopWatchdog(),this.clickHandler&&this.targetElement&&this.targetElement.removeEventListener("click",this.clickHandler),this._injectedElement&&document.body.contains(this._injectedElement)&&this._injectedElement.remove(),this._injectedElement=null,this.targetElement=null,this._startBootstrapWatch(),this._scheduleFallback(),setTimeout(()=>{this._destroyed||this._injectIntoExisting()||this._scheduleNextRetry()},1200)}_tryInsertBetweenWords(t,e){const i=[],n=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,{acceptNode(t){var e;if(((null==(e=t.textContent)?void 0:e.trim())??"").length<=5)return NodeFilter.FILTER_REJECT;const i=t.parentElement;return i?i.closest("[data-eeq], script, style, noscript")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}});let s=n.nextNode();for(;s;)i.push(s),s=n.nextNode();if(!i.length)return!1;const r=Math.floor(Date.now()/12e4),a=i[r%i.length],o=a.textContent??"",l=[];for(let v=1;v<o.length-1;v++)" "===o[v]&&l.push(v);if(l.length<2)return!1;const h=Math.floor(.25*l.length),c=Math.floor(.75*l.length),u=h+r%Math.max(1,c-h),d=l[Math.min(u,l.length-1)],p=o.slice(0,d),m=o.slice(d),f=t.getBoundingClientRect(),g=document.createTextNode(m);a.textContent=p,t.insertBefore(g,a.nextSibling),t.insertBefore(e,g);const _=t.getBoundingClientRect();return!(Math.abs(_.height-f.height)>8||Math.abs(_.width-f.width)>24)||(t.removeChild(e),t.removeChild(g),a.textContent=o,!1)}_attachToElement(t){this.clickHandler=t=>{t.preventDefault(),t.stopPropagation(),this._destroyed||(this.cleanup(),this.onFound())},t.addEventListener("click",this.clickHandler,{capture:!0,once:!0})}_startHintEscalation(){this._injectShimmerStyles(),this._createHintContainer();const t=this.script.hiddenEntryHints,e=[{at:6e4,fired:!1,action:()=>{this._stopHintTimer(),this._showFirstHintWithConfirm(t[0]??"",()=>{const e=t.slice(1),i=[];for(let t=0;t<e.length;t++)i.push({at:6e4*(t+1),fired:!1,action:()=>this._showHint(e[t])});i.push({at:12e4,fired:!1,action:()=>{this.targetElement&&this.targetElement.classList.add("eeq-entry-target")}}),0!==i.length&&this._startVisibilityTimer(i)})}}];this._startVisibilityTimer(e)}_startVisibilityTimer(t){this._hintVisibleElapsed=0,this._hintVisibleStart=0;const e=()=>this._hintVisibleElapsed+(this._hintVisibleStart?Date.now()-this._hintVisibleStart:0),i=()=>{if(this._destroyed)return;const i=e();for(const e of t)!e.fired&&i>=e.at&&(e.fired=!0,e.action());t.every(t=>t.fired)&&this._stopHintTimer()},n=()=>{this._hintCheckInterval||(this._hintVisibleStart=Date.now(),this._hintCheckInterval=setInterval(i,1e3))},s=()=>{this._hintVisibleStart&&(this._hintVisibleElapsed+=Date.now()-this._hintVisibleStart,this._hintVisibleStart=0),this._hintCheckInterval&&(clearInterval(this._hintCheckInterval),this._hintCheckInterval=null)};this._hintVisibilityHandler=()=>{this._destroyed||("visible"===document.visibilityState?n():s())},document.addEventListener("visibilitychange",this._hintVisibilityHandler),"visible"===document.visibilityState&&n()}_showFirstHintWithConfirm(t,e){if(!this.hintContainer)return;const i=document.createElement("div");i.className="eeq-snackbar";const n=document.createElement("span");n.textContent=t,i.appendChild(n);const s=document.createElement("button");s.className="eeq-snackbar-btn",s.textContent="Let's go!",s.addEventListener("click",()=>{a(),e()}),i.appendChild(s);const r=document.createElement("button");r.className="eeq-snackbar-btn",r.textContent="Not interested",r.addEventListener("click",()=>{try{localStorage.setItem("eeq_optout","1")}catch{}this.cleanup()}),i.appendChild(r),this.hintContainer.appendChild(i);const a=()=>{i.style.transform="translateY(20px)",i.style.opacity="0",setTimeout(()=>i.remove(),400)};requestAnimationFrame(()=>{i.style.transform="translateY(0)",i.style.opacity="1"})}_stopHintTimer(){this._hintCheckInterval&&(clearInterval(this._hintCheckInterval),this._hintCheckInterval=null),this._hintVisibilityHandler&&(document.removeEventListener("visibilitychange",this._hintVisibilityHandler),this._hintVisibilityHandler=null)}_showHint(t){if(!this.hintContainer)return;const e=document.createElement("div");e.className="eeq-snackbar";const i=document.createElement("span");i.textContent=t,e.appendChild(i);const n=document.createElement("button");n.className="eeq-snackbar-btn",n.textContent="Not interested",n.addEventListener("click",()=>{try{localStorage.setItem("eeq_optout","1")}catch{}this.cleanup()}),e.appendChild(n),this.hintContainer.appendChild(e),requestAnimationFrame(()=>{e.style.transform="translateY(0)",e.style.opacity="1"}),setTimeout(()=>{e.parentNode&&(e.style.transform="translateY(20px)",e.style.opacity="0",setTimeout(()=>e.remove(),400))},8e3)}_createHintContainer(){this.hintContainer=document.createElement("div"),Object.assign(this.hintContainer.style,{position:"fixed",bottom:"24px",left:"50%",transform:"translateX(-50%)",zIndex:"999980",pointerEvents:"none",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px"}),document.body.appendChild(this.hintContainer)}_injectShimmerStyles(){this.shimmerStyle=document.createElement("style"),this.shimmerStyle.textContent="\n .eeq-entry-target {\n animation: eeq-shimmer 3s ease-in-out infinite !important;\n }\n @keyframes eeq-shimmer {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.55; }\n }\n .eeq-snackbar {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n font-size: 14px;\n line-height: 20px;\n letter-spacing: 0.01em;\n color: #fff;\n background: #323232;\n padding: 14px 24px;\n border-radius: 4px;\n box-shadow: 0 3px 5px -1px rgba(0,0,0,0.2), 0 6px 10px rgba(0,0,0,0.14), 0 1px 18px rgba(0,0,0,0.12);\n min-width: 288px;\n max-width: 568px;\n opacity: 0;\n transform: translateY(20px);\n transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n pointer-events: auto;\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 24px;\n }\n .eeq-snackbar-btn {\n font-family: inherit;\n font-size: 14px;\n font-weight: 500;\n letter-spacing: 0.04em;\n text-transform: none;\n color: #fff;\n background: none;\n border: none;\n padding: 0;\n margin: 0;\n cursor: pointer;\n white-space: nowrap;\n flex-shrink: 0;\n }\n .eeq-snackbar-btn:hover {\n opacity: 0.8;\n }\n ",document.head.appendChild(this.shimmerStyle)}_createFallbackEntry(){if(this.fallbackButton)return;this.fallbackButton=document.createElement("button"),this.fallbackButton.textContent="·",this.fallbackButton.setAttribute("aria-label","Hidden game entry"),Object.assign(this.fallbackButton.style,{position:"fixed",bottom:"16px",right:"16px",width:"28px",height:"28px",borderRadius:"50%",border:`1px solid ${this.config.theme.accent}`,background:"transparent",color:this.config.theme.accent,fontSize:"16px",cursor:"pointer",zIndex:"999980",opacity:"0.4",transition:"opacity 0.6s",fontFamily:"serif",lineHeight:"1",padding:"0"}),this.fallbackButton.addEventListener("mouseenter",()=>{this.fallbackButton&&(this.fallbackButton.style.opacity="0.8")}),this.fallbackButton.addEventListener("mouseleave",()=>{this.fallbackButton&&(this.fallbackButton.style.opacity="0.4")}),this.fallbackButton.addEventListener("click",()=>{this._destroyed||(this.cleanup(),this.onFound())}),document.body.appendChild(this.fallbackButton),this._createHintContainer(),this._injectShimmerStyles();const t=this.script.hiddenEntryHints;for(let e=0;e<t.length;e++){const i=setTimeout(()=>{this._destroyed||this._showHint(t[e])},6e3+1e4*e);this.hintTimers.push(i)}}}class _{constructor(t){this.host=null,this.shadow=null,this.container=null,this.currentLine=null,this.clearTimer=null,this.awaitingConfirm=!1,this.config=t}mount(){this.host=document.createElement("div"),this.host.id="eeq-narrative-host",Object.assign(this.host.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"999993"}),document.body.appendChild(this.host),this.shadow=this.host.attachShadow({mode:"closed"});const t=document.createElement("style");t.textContent=this._getStyles(),this.shadow.appendChild(t),this.container=document.createElement("div"),this.container.className="eeq-narrative",this.shadow.appendChild(this.container)}_removeCurrentLine(t=!1){if(!this.currentLine)return;const e=this.currentLine;this.currentLine=null,t?e.remove():(e.classList.add("eeq-narrative-exit"),setTimeout(()=>e.remove(),750))}showLine(t,e="eeq-line"){if(!this.container)return;if(this.awaitingConfirm)return;this._removeCurrentLine(!0),this.clearTimer&&(clearTimeout(this.clearTimer),this.clearTimer=null);const i=document.createElement("div");i.className=e,i.textContent=t,this.container.appendChild(i),requestAnimationFrame(()=>{requestAnimationFrame(()=>{i.classList.add("eeq-line-visible")})}),this.currentLine=i,this.clearTimer=setTimeout(()=>{this.clear()},15e3)}showLineWithConfirm(t){return new Promise(e=>{if(!this.container)return void e();this.awaitingConfirm=!0,this._removeCurrentLine(!0),this.clearTimer&&(clearTimeout(this.clearTimer),this.clearTimer=null);const i=document.createElement("div");i.className="eeq-line",i.textContent=t,this.container.appendChild(i);const n=document.createElement("button");n.className="eeq-confirm-btn",n.textContent="OK",n.addEventListener("click",()=>{this.awaitingConfirm=!1,e()},{once:!0}),i.appendChild(n),requestAnimationFrame(()=>{requestAnimationFrame(()=>{i.classList.add("eeq-line-visible")})}),this.currentLine=i})}async showSequence(t,e=4500){for(const i of t)this.showLine(i),await new Promise(t=>setTimeout(t,e))}showCelebration(t){this.showLine(t,"eeq-line eeq-celebration")}clear(t=!1){this.awaitingConfirm&&!t||(this.clearTimer&&(clearTimeout(this.clearTimer),this.clearTimer=null),this._removeCurrentLine(t),this.awaitingConfirm=!1)}destroy(){var t;this.clear(!0),null==(t=this.host)||t.remove(),this.host=null,this.shadow=null,this.container=null}_getStyles(){return`\n .eeq-narrative {\n position: fixed;\n bottom: 0;\n left: 0;\n width: 100%;\n height: auto;\n display: flex;\n align-items: center;\n justify-content: center;\n padding-bottom: 48px;\n pointer-events: none;\n font-family: 'Georgia', 'Times New Roman', 'Noto Serif', serif;\n }\n\n .eeq-line {\n position: absolute;\n bottom: 48px;\n left: 50%;\n transform: translateX(-50%);\n color: ${this.config.theme.textColor};\n font-size: clamp(13px, 1.8vw, 19px);\n letter-spacing: 0.04em;\n text-align: center;\n max-width: 440px;\n padding: 12px 24px;\n opacity: 0;\n filter: blur(12px);\n transition: opacity 0.8s ease, filter 0.9s cubic-bezier(0.22, 1, 0.36, 1);\n line-height: 1.6;\n\n /* Frosted glass dialogue card */\n background: rgba(10, 10, 14, 0.55);\n backdrop-filter: blur(18px) saturate(1.4);\n -webkit-backdrop-filter: blur(18px) saturate(1.4);\n border: 1px solid rgba(255, 255, 255, 0.08);\n border-radius: 16px;\n box-shadow:\n 0 4px 24px rgba(0, 0, 0, 0.25),\n 0 0 0 0.5px rgba(255, 255, 255, 0.04) inset;\n }\n\n .eeq-line-visible {\n opacity: 1;\n filter: blur(0px);\n }\n\n .eeq-narrative-exit {\n opacity: 0 !important;\n filter: blur(14px) !important;\n transition: opacity 0.6s ease, filter 0.7s cubic-bezier(0.22, 1, 0.36, 1) !important;\n }\n\n .eeq-celebration {\n /* Override positioning: center of viewport via fixed */\n position: fixed !important;\n bottom: auto !important;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%) scale(0.8);\n max-width: 90vw;\n padding: 20px 40px;\n\n color: #ffe8a0;\n font-size: clamp(18px, 3.5vw, 28px);\n font-weight: bold;\n letter-spacing: 0.1em;\n text-transform: uppercase;\n\n background: linear-gradient(135deg, rgba(50,35,10,0.85), rgba(25,18,8,0.9));\n border: 2px solid rgba(255, 215, 80, 0.35);\n border-radius: 20px;\n box-shadow:\n 0 0 60px rgba(255, 200, 60, 0.25),\n 0 8px 40px rgba(0, 0, 0, 0.5),\n inset 0 1px 0 rgba(255, 230, 140, 0.15);\n text-shadow:\n 0 0 20px rgba(255, 200, 60, 0.6),\n 0 0 40px rgba(255, 180, 40, 0.3);\n }\n\n .eeq-celebration.eeq-line-visible {\n transform: translate(-50%, -50%) scale(1);\n transition: opacity 0.6s ease, filter 0.8s ease, transform 0.6s cubic-bezier(0.17, 0.67, 0.29, 1.2);\n }\n\n .eeq-celebration.eeq-narrative-exit {\n transform: translate(-50%, -50%) scale(1.1) !important;\n }\n\n .eeq-confirm-btn {\n display: block;\n margin: 14px auto 0;\n padding: 5px 32px;\n border: 1px solid rgba(255,255,255,0.18);\n border-radius: 20px;\n background: rgba(255,255,255,0.08);\n color: inherit;\n font-family: inherit;\n font-size: 0.8em;\n letter-spacing: 0.08em;\n cursor: pointer;\n pointer-events: auto;\n transition: background 0.3s, border-color 0.3s;\n }\n\n .eeq-confirm-btn:hover {\n background: rgba(255,255,255,0.18);\n border-color: rgba(255,255,255,0.35);\n }\n `}}class v{constructor(t){this.host=null,this.shadow=null,this.slots=[],this._activeSlot=null,this._onEggClick=null,this.config=t}mount(t){if(!this.config.shrine.enabled)return;this._onEggClick=t,this.host=document.createElement("div"),this.host.id="eeq-shrine-host";const e=this.config.shrine.position,i={"bottom-right":{bottom:"16px",right:"16px"},"bottom-left":{bottom:"16px",left:"16px"},"bottom-center":{bottom:"16px",left:"50%",transform:"translateX(-50%)"}};Object.assign(this.host.style,{position:"fixed",zIndex:"999994",opacity:"0",transform:"translateY(20px)",transition:"opacity 0.8s ease, transform 0.8s ease",...i[e]??i["bottom-right"]}),document.body.appendChild(this.host),this.shadow=this.host.attachShadow({mode:"closed"});const n=document.createElement("style");n.textContent=this._getStyles(),this.shadow.appendChild(n);const s=document.createElement("div");s.className="eeq-shrine";for(let r=0;r<3;r++){const t=document.createElement("div");t.className="eeq-slot eeq-slot-empty",t.setAttribute("data-egg",String(r)),t.setAttribute("aria-label",`Egg ${r+1} slot`),t.setAttribute("role","button"),t.setAttribute("tabindex","0");const e=document.createElement("div");e.className="eeq-egg-inner",t.appendChild(e),t.addEventListener("click",()=>{var t;this._activeSlot===r&&(null==(t=this._onEggClick)||t.call(this,r))}),t.addEventListener("keydown",t=>{var e;"Enter"===t.key&&this._activeSlot===r&&(null==(e=this._onEggClick)||e.call(this,r))}),s.appendChild(t),this.slots.push(t)}this.shadow.appendChild(s)}show(){this.host&&requestAnimationFrame(()=>{this.host&&(this.host.style.opacity="1",this.host.style.transform="translateY(0)")})}fillSlot(t){const e=this.slots[t];e&&(e.classList.remove("eeq-slot-empty"),e.classList.add("eeq-slot-filled"))}activateSlot(t){this._activeSlot=t;const e=this.slots[t];e&&(e.classList.add("eeq-slot-active"),e.style.cursor="pointer",e.style.pointerEvents="auto")}deactivateSlot(t){this._activeSlot=null;const e=this.slots[t];e&&(e.classList.remove("eeq-slot-active"),e.style.cursor="default",e.style.pointerEvents="none")}hideAll(){for(const t of this.slots)t.classList.add("eeq-slot-finale-exit")}reset(){this._activeSlot=null;for(const t of this.slots)t.className="eeq-slot eeq-slot-empty",t.style.cursor="default",t.style.pointerEvents="none"}destroy(){var t;null==(t=this.host)||t.remove(),this.host=null,this.shadow=null,this.slots=[]}_getStyles(){const t=this.config.theme;return`\n .eeq-shrine {\n display: flex;\n gap: 14px;\n padding: 12px 16px;\n background: ${t.hudBg};\n backdrop-filter: blur(12px);\n -webkit-backdrop-filter: blur(12px);\n border: 1px solid rgba(255,255,255,0.08);\n border-radius: 12px;\n }\n\n .eeq-slot {\n width: 36px;\n height: 44px;\n border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.6s ease;\n pointer-events: none;\n position: relative;\n }\n\n .eeq-slot-empty {\n border: 1.5px dashed rgba(255,255,255,0.2);\n background: transparent;\n }\n\n .eeq-slot-filled {\n border: 1.5px solid ${t.accent};\n background: radial-gradient(ellipse at 40% 30%, rgba(255,255,255,0.15), transparent);\n }\n\n .eeq-slot-filled .eeq-egg-inner {\n width: 60%;\n height: 70%;\n border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;\n background: linear-gradient(135deg, ${t.accent}, rgba(255,255,255,0.3));\n opacity: 0.8;\n }\n\n .eeq-slot-active {\n animation: eeq-slot-pulse 2s ease-in-out infinite;\n border-color: ${t.accent} !important;\n box-shadow: 0 0 16px ${t.accentGlow};\n }\n\n .eeq-slot-finale-exit {\n opacity: 0;\n transform: translateY(-20px) scale(0.6);\n transition: all 1s ease;\n }\n\n .eeq-egg-inner {\n transition: all 0.4s ease;\n }\n\n @keyframes eeq-slot-pulse {\n 0%, 100% { transform: scale(1); opacity: 0.8; }\n 50% { transform: scale(1.08); opacity: 1; }\n }\n `}}class y{constructor(t){this.canvas=null,this.THREE=null,this.renderer=null,this.scene=null,this.camera=null,this.eggs=[],this.eggBodies=[],this.lights=[],this._raf=0,this._running=!1,this._clock=null,this._eggStates=[{visible:!1,phase:"hidden",t:0,targetPos:[0,0,0]},{visible:!1,phase:"hidden",t:0,targetPos:[0,0,0]},{visible:!1,phase:"hidden",t:0,targetPos:[0,0,0]}],this._finaleActive=!1,this._finaleT=0,this._greetingOverlay=null,this._trailParticles=[],this._ambientParticles=[],this._lastAmbientSpawnAt=0,this._revealParticles=[],this._disposed=!1,this._interactiveEgg=null,this._isDragging=!1,this._dragStartX=0,this._dragStartY=0,this._dragRotX=0,this._dragRotY=0,this._dragMoved=!1,this._longPressStartTime=0,this._longPressActive=!1,this._holdProgress=0,this._holdRing=null,this._holdShockwave=null,this._miniEggs=[],this._collectLight=null,this._onCollectEgg=null,this._vortexParticles=[],this._emberParticles=[],this._collectFlashOpacity=0,this._collectShake=0,this._collectCamBaseZ=5,this._finaleInteractive=!1,this._finaleDragTarget=null,this._finalePausedRotation=[!1,!1,!1],this._onPointerDown=t=>{if(this._disposed)return;if(this._finaleInteractive&&this._finaleActive){let e=-1,i=1/0;for(let s=0;s<3;s++){const n=this.eggs[s];if(!n||!n.visible)continue;const r=this._worldToScreen(n.position),a=Math.sqrt((t.clientX-r.x)**2+(t.clientY-r.y)**2);a<i&&(i=a,e=s)}if(e<0||i>140)return;t.preventDefault(),t.stopPropagation(),this._finaleDragTarget=e,this._isDragging=!0,this._dragMoved=!1,this._dragStartX=t.clientX,this._dragStartY=t.clientY;const n=this.eggs[e];return this._dragRotX=n.rotation.x,this._dragRotY=n.rotation.y,void(this.canvas&&(this.canvas.style.cursor="grabbing"))}if(null===this._interactiveEgg)return;const e=this.eggs[this._interactiveEgg];if(!e||!e.visible)return;const i=this._worldToScreen(e.position),n=t.clientX-i.x,s=t.clientY-i.y;Math.sqrt(n*n+s*s)>120||(t.preventDefault(),t.stopPropagation(),this.canvas&&(this.canvas.style.cursor="grabbing"),this._isDragging=!0,this._dragMoved=!1,this._dragStartX=t.clientX,this._dragStartY=t.clientY,this._dragRotX=e.rotation.x,this._dragRotY=e.rotation.y,this._longPressStartTime=Date.now(),this._longPressActive=!0,this._holdProgress=0)},this._onPointerMove=t=>{if(!this._isDragging)return;if(null!==this._finaleDragTarget){t.preventDefault(),t.stopPropagation();const e=this.eggs[this._finaleDragTarget];if(!e)return;const i=t.clientX-this._dragStartX,n=t.clientY-this._dragStartY;return e.rotation.y=this._dragRotY+.008*i,e.rotation.x=this._dragRotX+.005*n,void((Math.abs(i)>5||Math.abs(n)>5)&&(this._finalePausedRotation[this._finaleDragTarget]=!0))}if(null===this._interactiveEgg)return;t.preventDefault(),t.stopPropagation();const e=this.eggs[this._interactiveEgg];if(!e)return;const i=t.clientX-this._dragStartX,n=t.clientY-this._dragStartY;e.rotation.y=this._dragRotY+.008*i,e.rotation.x=this._dragRotX+.005*n,(Math.abs(i)>15||Math.abs(n)>15)&&(this._dragMoved=!0,this._cancelLongPress())},this._onPointerUp=t=>{this._isDragging&&(t.preventDefault(),t.stopPropagation()),this._isDragging=!1,this._finaleDragTarget=null,this._cancelLongPress(),(null!==this._interactiveEgg||this._finaleInteractive)&&this.canvas&&(this.canvas.style.cursor="grab")},this._onWheel=t=>{this._disposed||this._isPointerNearAnyEgg(t.clientX,t.clientY)&&(t.preventDefault(),t.stopPropagation())},this._onClickCapture=t=>{this._disposed||this._isPointerNearAnyEgg(t.clientX,t.clientY)&&(t.preventDefault(),t.stopPropagation())},this._onMouseDownCapture=t=>{this._disposed||this._isPointerNearAnyEgg(t.clientX,t.clientY)&&(t.preventDefault(),t.stopPropagation())},this._onMouseUpCapture=t=>{this._isDragging&&(t.preventDefault(),t.stopPropagation())},this._onTouchStartCapture=t=>{if(this._disposed)return;const e=t.touches[0];e&&this._isPointerNearAnyEgg(e.clientX,e.clientY)&&(t.preventDefault(),t.stopPropagation())},this._onTouchMoveCapture=t=>{this._isDragging&&(t.preventDefault(),t.stopPropagation())},this._animate=()=>{if(!this._running||this._disposed)return;this._raf=requestAnimationFrame(this._animate);const t=Math.min(this._clock.getDelta(),.05);this._updateEggs(t),this._updateHoldRing(),this._updateMiniEggs(t),this._updateTrails(t),this._updateAmbientParticles(t),this._updateRevealParticles(t),this._updateFinale(t),this.renderer.render(this.scene,this.camera)},this._onResize=()=>{this.camera&&this.renderer&&this.canvas&&(this.camera.aspect=window.innerWidth/window.innerHeight,this.camera.updateProjectionMatrix(),this.renderer.setSize(window.innerWidth,window.innerHeight))},this.config=t,this._reducedMotion=t.accessibility.reducedMotion}onCollectEgg(t){this._onCollectEgg=t}async init(){try{const t="undefined"!=typeof window&&window.THREE;this.THREE=t||await Promise.resolve().then(()=>Kd)}catch{return!1}const t=this.THREE;return this.canvas=document.createElement("canvas"),this.canvas.id="eeq-three-canvas",Object.assign(this.canvas.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"999992"}),document.body.appendChild(this.canvas),this.renderer=new t.WebGLRenderer({canvas:this.canvas,alpha:!0,antialias:!0,powerPreference:"high-performance"}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.renderer.setSize(window.innerWidth,window.innerHeight),this.renderer.toneMapping=t.ACESFilmicToneMapping,this.renderer.toneMappingExposure=1.1,this.scene=new t.Scene,this.camera=new t.PerspectiveCamera(45,window.innerWidth/window.innerHeight,.1,100),this.camera.position.set(0,0,5),this._setupLights(t),this._setupEnvironment(t),this._createEggs(t),this._createHoldRing(t),this._clock=new t.Clock,window.addEventListener("resize",this._onResize),document.addEventListener("pointerdown",this._onPointerDown,{capture:!0}),document.addEventListener("pointermove",this._onPointerMove,{capture:!0}),document.addEventListener("pointerup",this._onPointerUp,{capture:!0}),document.addEventListener("wheel",this._onWheel,{capture:!0,passive:!1}),document.addEventListener("click",this._onClickCapture,{capture:!0}),document.addEventListener("mousedown",this._onMouseDownCapture,{capture:!0}),document.addEventListener("mouseup",this._onMouseUpCapture,{capture:!0}),document.addEventListener("touchstart",this._onTouchStartCapture,{capture:!0,passive:!1}),document.addEventListener("touchmove",this._onTouchMoveCapture,{capture:!0,passive:!1}),!0}startRenderLoop(){this._running||(this._running=!0,this._animate())}stopRenderLoop(){this._running=!1,this._raf&&cancelAnimationFrame(this._raf)}enableInteraction(t){this._interactiveEgg=t,this.canvas&&(this.canvas.style.cursor="grab")}disableInteraction(){this._interactiveEgg=null,this._isDragging=!1,this._finaleDragTarget=null,this._finaleInteractive=!1,this._cancelLongPress(),this.canvas&&(this.canvas.style.cursor="")}revealEgg(t){const e=this._eggStates[t];if(!e)return;e.visible=!0,e.phase="reveal",e.t=0;const i=this.eggs[t];i&&(i.visible=!0,i.scale.set(.01,.01,.01),i.position.set(0,0,0)),this._spawnRevealBurst(t),this.enableInteraction(t)}collectEgg(t){const e=this._eggStates[t];if(!e)return;const i=this.eggs[t];i&&(i.visible=!1);const n=this.eggBodies[t];(null==n?void 0:n.material)&&(n.material.emissiveIntensity=.05,n.material.opacity=1,n.material.transparent=!1),this.disableInteraction(),e.phase="shrine",e.t=0}resetForRestart(){var t,e,i,n,s,r,a;null==(t=this._greetingOverlay)||t.remove(),this._greetingOverlay=null,this.stopRenderLoop();for(let o=0;o<3;o++){this._eggStates[o]={visible:!1,phase:"hidden",t:0,targetPos:[0,0,0]},this.eggs[o]&&(this.eggs[o].visible=!1,this.eggs[o].scale.set(1,1,1),this.eggs[o].position.set(0,0,0),this.eggs[o].rotation.set(0,0,0));const t=this.eggBodies[o];(null==t?void 0:t.material)&&(t.material.emissiveIntensity=.05,t.material.opacity=1,t.material.transparent=!1)}this._finaleActive=!1,this._finaleT=0,this.disableInteraction();for(const o of[...this._trailParticles,...this._ambientParticles,...this._revealParticles,...this._vortexParticles,...this._emberParticles])null==(e=this.scene)||e.remove(o.mesh),null==(i=o.mesh.geometry)||i.dispose(),null==(n=o.mesh.material)||n.dispose();this._trailParticles=[],this._ambientParticles=[],this._revealParticles=[],this._vortexParticles=[],this._emberParticles=[];for(const o of this._miniEggs)null==(s=this.scene)||s.remove(o.mesh),null==(r=o.mesh.geometry)||r.dispose(),null==(a=o.mesh.material)||a.dispose();this._miniEggs=[]}addTrail(t,e,i){if(!this.THREE||!this.scene)return;const n=this.THREE,s=this._screenToWorld(t,e),r=Math.min(.05,3e-5*i),a=this._createMiniEggGeo(n,r),o=this._createMiniEggMat(n,.65),l=new n.Mesh(a,o);if(l.position.copy(s),l.rotation.set(Math.random()*Math.PI,Math.random()*Math.PI,Math.random()*Math.PI),this.scene.add(l),this._trailParticles.push({mesh:l,life:1}),this._trailParticles.length>100){const t=this._trailParticles.shift();t&&(this.scene.remove(t.mesh),t.mesh.geometry.dispose(),t.mesh.material.dispose())}}showProgressParticles(t,e="default"){if(!this.THREE||!this.scene||t<.05)return;const i=this.THREE,n=performance.now(),s="rhythm"===e;if(s){const e=Math.max(80,180-120*t);if(n-this._lastAmbientSpawnAt<e)return}else if(Math.random()>.3*t)return;this._lastAmbientSpawnAt=n;const r=s&&t>.6?2:1;for(let a=0;a<r;a++){const t=Math.random()*Math.PI*2,e=s?1.1+1.8*Math.random():2+2*Math.random(),n=Math.cos(t)*e,r=s?-2.8-.9*Math.random():4*Math.random()-2,a=s?.03+.03*Math.random():.02+.025*Math.random(),o=this._createMiniEggGeo(i,a),l=this._createMiniEggMat(i,0),h=new i.Mesh(o,l);h.position.set(n,r,.5*Math.random()-1),h.rotation.set(Math.random()*Math.PI,Math.random()*Math.PI,Math.random()*Math.PI),this.scene.add(h),this._ambientParticles.push({mesh:h,life:s?1.25:1,vy:s?.45+.35*Math.random():.2+.3*Math.random(),fadeIn:!0})}if(this._ambientParticles.length>60){const t=this._ambientParticles.shift();t&&(this.scene.remove(t.mesh),t.mesh.geometry.dispose(),t.mesh.material.dispose())}}fadeOutAmbientParticles(){for(const t of this._ambientParticles)t.fadeIn=!1,t.life>.3&&(t.life=.3)}startFinale(){this._finaleActive=!0,this._finaleT=0,this.disableInteraction(),this._finaleInteractive=!0,this._finaleDragTarget=null,this._finalePausedRotation=[!1,!1,!1],this.canvas&&(this.canvas.style.cursor="grab");for(let i=0;i<3;i++){const t=this._eggStates[i];t.phase="finale",t.t=0,this.eggs[i]&&(this.eggs[i].visible=!0)}this._greetingOverlay=document.createElement("div"),Object.assign(this._greetingOverlay.style,{position:"fixed",bottom:"12%",left:"0",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",zIndex:"999997",pointerEvents:"none",opacity:"0",transition:"opacity 2s ease",fontFamily:"'Georgia', 'Times New Roman', serif",textAlign:"center"}),this._greetingOverlay.innerHTML="";const t=document.createElement("div");Object.assign(t.style,{fontSize:"48px",color:"#fff8e8",textShadow:"0 0 60px rgba(212,165,80,0.7), 0 0 20px rgba(212,165,80,0.4), 0 2px 8px rgba(0,0,0,0.6)",marginBottom:"10px",letterSpacing:"0.03em",fontWeight:"bold"}),t.textContent="Happy Easter! 🐰🥚",this._greetingOverlay.appendChild(t);const e=document.createElement("div");Object.assign(e.style,{fontSize:"17px",color:"rgba(245,240,230,0.85)",fontStyle:"italic",textShadow:"0 0 12px rgba(212,165,80,0.3), 0 1px 6px rgba(0,0,0,0.4)"}),e.textContent="Wishing you joy, peace, and light",this._greetingOverlay.appendChild(e),document.body.appendChild(this._greetingOverlay),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._greetingOverlay&&(this._greetingOverlay.style.opacity="1")})})}setFestiveEggSeed(t){var e;const i=this.eggBodies[2];if(!i||!this.THREE)return;const n=this.THREE,s=new n.CanvasTexture(this._drawFestivePattern(t));s.colorSpace=n.SRGBColorSpace,s.wrapS=n.RepeatWrapping,null==(e=i.material.map)||e.dispose(),i.material.map=s,i.material.needsUpdate=!0}setBreathIntensity(t){if(!this.camera)return;const e=.04*t,i=.001*Date.now();this.camera.position.z=5+Math.sin(.8*i)*e}setOverlayIntensity(t){}destroy(){var t,e,i,n,s,r,a,o,l,h,c,u,d,p,m,f,g,_,v,y,x;this._disposed=!0,this.stopRenderLoop(),this.disableInteraction(),window.removeEventListener("resize",this._onResize),document.removeEventListener("pointerdown",this._onPointerDown,{capture:!0}),document.removeEventListener("pointermove",this._onPointerMove,{capture:!0}),document.removeEventListener("pointerup",this._onPointerUp,{capture:!0}),document.removeEventListener("wheel",this._onWheel,{capture:!0}),document.removeEventListener("click",this._onClickCapture,{capture:!0}),document.removeEventListener("mousedown",this._onMouseDownCapture,{capture:!0}),document.removeEventListener("mouseup",this._onMouseUpCapture,{capture:!0}),document.removeEventListener("touchstart",this._onTouchStartCapture,{capture:!0}),document.removeEventListener("touchmove",this._onTouchMoveCapture,{capture:!0}),document.body.style.cursor="";const M=[...this._trailParticles,...this._ambientParticles,...this._revealParticles,...this._vortexParticles,...this._emberParticles];for(const b of M)null==(t=this.scene)||t.remove(b.mesh),null==(e=b.mesh.geometry)||e.dispose(),null==(i=b.mesh.material)||i.dispose();this._trailParticles=[],this._ambientParticles=[],this._revealParticles=[],this._vortexParticles=[],this._emberParticles=[];for(const b of this.eggs)null==b||b.traverse(t=>{t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(t=>t.dispose()):t.material.dispose())}),null==(n=this.scene)||n.remove(b);this.eggs=[],this.eggBodies=[],this._holdRing&&(null==(s=this.scene)||s.remove(this._holdRing),null==(r=this._holdRing.geometry)||r.dispose(),null==(a=this._holdRing.material)||a.dispose()),this._holdShockwave&&(null==(o=this.scene)||o.remove(this._holdShockwave),null==(l=this._holdShockwave.geometry)||l.dispose(),null==(h=this._holdShockwave.material)||h.dispose());for(const b of this._miniEggs)null==(c=this.scene)||c.remove(b.mesh),null==(u=b.mesh.geometry)||u.dispose(),null==(d=b.mesh.material)||d.dispose();this._miniEggs=[],this._collectLight&&(null==(p=this.scene)||p.remove(this._collectLight),null==(f=(m=this._collectLight).dispose)||f.call(m),this._collectLight=null);for(const b of this.lights)null==(g=this.scene)||g.remove(b);this.lights=[],(null==(_=this.scene)?void 0:_.environment)&&(this.scene.environment.dispose(),this.scene.environment=null),null==(v=this.renderer)||v.dispose(),null==(y=this.canvas)||y.remove(),null==(x=this._greetingOverlay)||x.remove(),this._greetingOverlay=null,this.canvas=null,this.renderer=null,this.scene=null,this.camera=null}_setupLights(t){const e=new t.AmbientLight(16775408,.6);this.scene.add(e),this.lights.push(e);const i=new t.DirectionalLight(16772306,1);i.position.set(3,5,4),this.scene.add(i),this.lights.push(i);const n=new t.DirectionalLight(13687024,.35);n.position.set(-4,3,2),this.scene.add(n),this.lights.push(n);const s=new t.PointLight(16763016,.5,12);s.position.set(0,-3,3),this.scene.add(s),this.lights.push(s);const r=new t.PointLight(16777215,.3,10);r.position.set(0,4,2),this.scene.add(r),this.lights.push(r)}_setupEnvironment(t){const e=new t.PMREMGenerator(this.renderer);e.compileCubemapShader();const i=new t.Scene,n=new t.SphereGeometry(50,32,16),s=new t.ShaderMaterial({side:t.BackSide,uniforms:{},vertexShader:"\n varying vec3 vWorldPos;\n void main() {\n vWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;\n gl_Position = projectionMatrix * viewMatrix * vec4(vWorldPos, 1.0);\n }\n ",fragmentShader:"\n varying vec3 vWorldPos;\n void main() {\n float y = normalize(vWorldPos).y;\n // Top: warm bright sky\n vec3 top = vec3(0.85, 0.88, 0.95);\n // Horizon: bright neutral white\n vec3 mid = vec3(0.95, 0.93, 0.90);\n // Bottom: warm ground bounce\n vec3 bot = vec3(0.75, 0.68, 0.62);\n vec3 color;\n if (y > 0.0) {\n color = mix(mid, top, y);\n } else {\n color = mix(mid, bot, -y);\n }\n // Bright highlight (simulates studio softbox)\n float sun = max(0.0, dot(normalize(vWorldPos), normalize(vec3(2.0, 5.0, 3.0))));\n color += vec3(1.0, 0.97, 0.92) * pow(sun, 16.0) * 0.8;\n // Fill light opposite side\n float fill = max(0.0, dot(normalize(vWorldPos), normalize(vec3(-3.0, 2.0, 1.0))));\n color += vec3(0.7, 0.8, 0.95) * pow(fill, 8.0) * 0.3;\n gl_FragColor = vec4(color, 1.0);\n }\n "}),r=new t.Mesh(n,s);i.add(r);const a=e.fromScene(i,.04).texture;this.scene.environment=a,n.dispose(),s.dispose(),i.clear(),e.dispose()}_createEggs(t){const e=this._createEggGeometry(t),i=new t.Group,n=new t.CanvasTexture(this._drawSilverPolkaDots());n.colorSpace=t.SRGBColorSpace,n.wrapS=t.RepeatWrapping;const s=new t.CanvasTexture(this._drawSilverRoughness());s.wrapS=t.RepeatWrapping;const r=new t.Mesh(e.clone(),new t.MeshPhysicalMaterial({map:n,roughness:.15,roughnessMap:s,metalness:.92,clearcoat:.3,clearcoatRoughness:.1,emissive:2236979,emissiveIntensity:.02,envMapIntensity:1}));i.add(r),i.visible=!1,this.scene.add(i),this.eggs.push(i),this.eggBodies.push(r);const a=new t.Group,o=new t.CanvasTexture(this._drawGoldPattern());o.colorSpace=t.SRGBColorSpace,o.wrapS=t.RepeatWrapping;const l=new t.CanvasTexture(this._drawGoldRoughness());l.wrapS=t.RepeatWrapping;const h=new t.Mesh(e.clone(),new t.MeshPhysicalMaterial({map:o,roughness:.2,roughnessMap:l,metalness:.95,clearcoat:.2,clearcoatRoughness:.15,emissive:3811848,emissiveIntensity:.06,envMapIntensity:1}));a.add(h),a.visible=!1,this.scene.add(a),this.eggs.push(a),this.eggBodies.push(h);const c=new t.Group,u=new t.CanvasTexture(this._drawFestivePattern());u.colorSpace=t.SRGBColorSpace,u.wrapS=t.RepeatWrapping;const d=new t.CanvasTexture(this._drawFestiveRoughness());d.wrapS=t.RepeatWrapping;const p=new t.Mesh(e.clone(),new t.MeshPhysicalMaterial({map:u,roughness:.22,roughnessMap:d,metalness:.35,clearcoat:.8,clearcoatRoughness:.05,emissive:1708064,emissiveIntensity:.04,envMapIntensity:.8,sheen:.4,sheenColor:new t.Color(16765088),sheenRoughness:.3}));c.add(p),c.visible=!1,this.scene.add(c),this.eggs.push(c),this.eggBodies.push(p)}_createMiniEggGeo(t,e){const i=new t.SphereGeometry(e,12,12),n=i.attributes.position;for(let s=0;s<n.count;s++){let t=n.getY(s);const e=n.getX(s),i=n.getZ(s);t=1.08*t*(t>0?.95:1);const r=1-.03*Math.abs(t);n.setX(s,e*r),n.setY(s,t),n.setZ(s,i*r)}return i.computeVertexNormals(),i}_createMiniEggMat(t,e){const i=document.createElement("canvas");i.width=64,i.height=64;const n=i.getContext("2d"),s=360*Math.random(),r=60+25*Math.random(),a=68+14*Math.random();n.fillStyle=`hsl(${s}, ${r}%, ${a}%)`,n.fillRect(0,0,64,64);const o=(s+80+100*Math.random())%360,l=r+10,h=Math.max(35,a-30);n.lineWidth=2;const c=1+Math.floor(2*Math.random());for(let d=0;d<c;d++){const t=0===d?o:(o+120)%360;n.strokeStyle=`hsla(${t}, ${l}%, ${h}%, 0.7)`,n.fillStyle=`hsla(${t}, ${l}%, ${h+10}%, 0.5)`;const e=16*d-8;switch(Math.floor(6*Math.random())){case 0:n.beginPath(),n.moveTo(0,24+e),n.lineTo(64,24+e),n.moveTo(0,40+e),n.lineTo(64,40+e),n.stroke();break;case 1:for(let t=0;t<6;t++)n.beginPath(),n.arc(8+48*Math.random(),8+48*Math.random(),2.5+2.5*Math.random(),0,2*Math.PI),n.fill();break;case 2:n.beginPath(),n.moveTo(0,32+e);for(let t=6;t<=64;t+=6)n.lineTo(t,32+e+(t/6%2==0?-7:7));n.stroke();break;case 3:n.fillRect(0,24+e,64,16);break;case 4:n.beginPath();for(let t=0;t<64;t+=12)n.moveTo(t,0),n.lineTo(t+32,64),n.moveTo(t+32,0),n.lineTo(t,64);n.stroke();break;default:n.beginPath(),n.moveTo(0,32+e);for(let t=0;t<=64;t+=2)n.lineTo(t,32+e+5*Math.sin(.3*t));n.stroke()}}const u=new t.CanvasTexture(i);return new t.MeshBasicMaterial({map:u,transparent:!0,opacity:e||.85})}_createEggGeometry(t){const e=new t.SphereGeometry(.42,48,48),i=e.attributes.position;for(let n=0;n<i.count;n++){let t=i.getY(n);const e=i.getX(n),s=i.getZ(n);t=1.45*t*(t>0?.82:1);const r=1-.12*Math.abs(t);i.setX(n,e*r),i.setY(n,t),i.setZ(n,s*r)}return e.computeVertexNormals(),e}_drawSilverPolkaDots(){const t=512,e=document.createElement("canvas");e.width=t,e.height=t;const i=e.getContext("2d"),n=i.createLinearGradient(0,0,0,t);n.addColorStop(0,"#e0e4ea"),n.addColorStop(.4,"#d5d9e0"),n.addColorStop(.6,"#cdd1d8"),n.addColorStop(1,"#c8c4c0"),i.fillStyle=n,i.fillRect(0,0,t,t),i.fillStyle="#f4f4f6",i.shadowColor="rgba(255,255,255,0.5)",i.shadowBlur=6;for(let s=0;s<t/52+1;s++){const t=s%2*32;for(let e=-1;e<9;e++){const n=64*e+t,r=52*s;i.beginPath(),i.arc(n,r,22,0,2*Math.PI),i.fill()}}return i.shadowBlur=0,e}_drawSilverRoughness(){const t=512,e=document.createElement("canvas");e.width=t,e.height=t;const i=e.getContext("2d");i.fillStyle="#333",i.fillRect(0,0,t,t),i.fillStyle="#999";for(let n=0;n<t/52+1;n++){const t=n%2*32;for(let e=-1;e<9;e++){const s=64*e+t,r=52*n;i.beginPath(),i.arc(s,r,22,0,2*Math.PI),i.fill()}}return e}_drawGoldPattern(){const t=512,e=document.createElement("canvas");e.width=t,e.height=t;const i=e.getContext("2d"),n=i.createLinearGradient(0,0,0,t);n.addColorStop(0,"#c8960a"),n.addColorStop(.3,"#daa520"),n.addColorStop(.5,"#e6b422"),n.addColorStop(.7,"#c89618"),n.addColorStop(1,"#b8860b"),i.fillStyle=n,i.fillRect(0,0,t,t),i.globalAlpha=.2;for(const s of[.25,.5,.75]){const e=s*t,n=30,r=i.createLinearGradient(0,e-n,0,e+n);r.addColorStop(0,"#b8860b"),r.addColorStop(.5,"#f0d060"),r.addColorStop(1,"#b8860b"),i.fillStyle=r,i.fillRect(0,e-n,t,2*n)}i.globalAlpha=1,i.strokeStyle="#a07008",i.lineWidth=1.2,i.globalAlpha=.15;for(let s=-512;s<1024;s+=32)i.beginPath(),i.moveTo(s,0),i.lineTo(s+t,t),i.stroke(),i.beginPath(),i.moveTo(s+t,0),i.lineTo(s,t),i.stroke();i.globalAlpha=1,i.strokeStyle="#d4a510",i.lineWidth=2,i.globalAlpha=.3;for(const s of[.22,.28,.47,.53,.72,.78]){const e=s*t;i.beginPath(),i.moveTo(0,e),i.lineTo(t,e),i.stroke()}return i.globalAlpha=1,e}_drawGoldRoughness(){const t=512,e=document.createElement("canvas");e.width=t,e.height=t;const i=e.getContext("2d");i.fillStyle="#444",i.fillRect(0,0,t,t);for(const n of[.25,.5,.75]){const e=n*t;i.fillStyle="#666",i.fillRect(0,e-30,t,60)}return e}_drawFestivePattern(t){const e=512,i=document.createElement("canvas");i.width=e,i.height=e;const n=i.getContext("2d");let s=t??25214903917^Date.now();const r=()=>{s=s+1831565813|0;let t=Math.imul(s^s>>>15,1|s);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296},a=360*r(),o=[];for(let u=0;u<5;u++)o.push((a+u*(50+30*r()))%360);const l=e/9;for(let u=0;u<9;u++){const t=u*l;if(u%2==1){const e=52+10*r(),i=n.createLinearGradient(0,t,0,t+l);i.addColorStop(0,`hsl(43, 80%, ${e}%)`),i.addColorStop(1,`hsl(43, 75%, ${e-6}%)`),n.fillStyle=i}else{const e=o[Math.floor(u/2)%o.length],i=55+30*r(),s=35+15*r(),a=n.createLinearGradient(0,t,0,t+l);a.addColorStop(0,`hsl(${e}, ${i}%, ${s}%)`),a.addColorStop(1,`hsl(${e}, ${i}%, ${s-8}%)`),n.fillStyle=a}n.fillRect(0,t,e,l+1)}const h=Math.floor(4*r());if(n.strokeStyle="hsla(43, 70%, 60%, 0.2)",n.lineWidth=1.5,0===h){const t=r()<.5?32:64;for(let i=-512;i<1024;i+=t)n.beginPath(),n.moveTo(i,0),n.lineTo(i+e,e),n.stroke(),n.beginPath(),n.moveTo(i+e,0),n.lineTo(i,e),n.stroke()}else if(1===h){const t=32;for(let i=0;i<9;i+=2){const s=(i+.5)*l;for(let i=t/2;i<e;i+=t)n.beginPath(),n.arc(i,s,.38*t,0,2*Math.PI),n.stroke()}}else if(2===h){const t=8+8*r(),i=[16,32,64][Math.floor(3*r())];for(let s=0;s<9;s+=2){const r=(s+.5)*l;n.beginPath(),n.moveTo(0,r);for(let s=0;s<=e;s+=i)n.lineTo(s,r+(s/i%2==0?-t:t));n.stroke()}}else for(let u=0;u<9;u+=2){const t=(u+.5)*l;for(const i of[.2*-l,.2*l]){n.beginPath();for(let s=0;s<=e;s+=2)n.lineTo(s,t+i+4*Math.sin(s*(8*Math.PI/e)+.5*r()));n.stroke()}}const c=10+Math.floor(10*r());for(let u=1;u<9;u+=2){const t=(u+.5)*l;for(let i=0;i<c;i++){const s=(i+.5)*(e/c),a=o[Math.floor(r()*o.length)];if(n.fillStyle=`hsl(${a}, 70%, 55%)`,n.beginPath(),r()<.5)n.arc(s,t,3+3*r(),0,2*Math.PI);else{const e=3+3*r();n.moveTo(s,t-e),n.lineTo(s+e,t),n.lineTo(s,t+e),n.lineTo(s-e,t)}n.fill()}}return i}_drawFestiveRoughness(){const t=512,e=document.createElement("canvas");e.width=t,e.height=t;const i=e.getContext("2d");i.fillStyle="#555",i.fillRect(0,0,t,t);const n=t/9,s=[1,3,5,7];for(const r of s)i.fillStyle="#333",i.fillRect(0,r*n,t,n);return e}_createHoldRing(t){}_spawnRevealBurst(t){if(!this.THREE||!this.scene)return;const e=this.THREE,i=[[12632264,14540270,16777215],[16766720,13145600,16769152],[13369376,17612,43568,16766720,8913066]],n=i[t]??i[0],s=40+20*t;for(let r=0;r<s;r++){const t=.015+.03*Math.random(),i=new e.SphereGeometry(t,5,5),s=n[Math.floor(Math.random()*n.length)],r=new e.MeshBasicMaterial({color:s,transparent:!0,opacity:.8}),a=new e.Mesh(i,r),o=Math.random()*Math.PI*2,l=Math.random()*Math.PI,h=1.5+2.5*Math.random(),c=Math.sin(l)*Math.cos(o)*h,u=Math.sin(l)*Math.sin(o)*h,d=Math.cos(l)*h;a.position.set(0,0,0),this.scene.add(a),this._revealParticles.push({mesh:a,life:1,vx:c,vy:u,vz:d})}}_spawnVortex(t){if(!this.THREE||!this.scene)return;const e=this.THREE,i=this.eggs[t],n=i?i.position.clone():new e.Vector3(0,0,0);for(let s=0;s<60;s++){const t=.008+.015*Math.random(),i=new e.SphereGeometry(t,6,6),r=.1+.06*Math.random(),a=(new e.Color).setHSL(r,.8,.6+.3*Math.random()),o=new e.MeshBasicMaterial({color:a,transparent:!0,opacity:0}),l=new e.Mesh(i,o),h=s/60*Math.PI*2+.3*Math.random(),c=1.2+.8*Math.random(),u=1*(Math.random()-.5);l.position.set(n.x+Math.cos(h)*c,n.y+u,n.z+Math.sin(h)*c),this.scene.add(l),this._vortexParticles.push({mesh:l,life:1,angle:h,radius:c,yOff:u,originX:n.x,originY:n.y,originZ:n.z,speed:1.5+1.5*Math.random(),delay:.008*s+.15*Math.random()})}}_spawnEmbers(t){if(!this.THREE||!this.scene)return;const e=this.THREE,i=this.eggs[t],n=i?i.position.clone():new e.Vector3(0,0,0);for(let s=0;s<35;s++){const t=.006+.012*Math.random(),i=new e.SphereGeometry(t,4,4),s=.08+.1*Math.random(),r=(new e.Color).setHSL(s,.7,.5+.4*Math.random()),a=new e.MeshBasicMaterial({color:r,transparent:!0,opacity:.9}),o=new e.Mesh(i,a),l=.3;o.position.set(n.x+(Math.random()-.5)*l,n.y+(Math.random()-.5)*l,n.z+(Math.random()-.5)*l*.3),this.scene.add(o),this._emberParticles.push({mesh:o,life:1,vx:.3*(Math.random()-.5),vy:.4+.6*Math.random(),vz:.1*(Math.random()-.5),flicker:Math.random()*Math.PI*2})}}_updateVortexParticles(t,e){var i;for(let n=this._vortexParticles.length-1;n>=0;n--){const s=this._vortexParticles[n];if(e<s.delay)continue;const r=Math.min(1,(e-s.delay)/(.55-s.delay)),a=s.radius*(1-r*r*.95);s.angle+=t*s.speed*(1+4*r);const o=s.yOff*(1-r);s.mesh.position.x=s.originX+Math.cos(s.angle)*a,s.mesh.position.y=s.originY+o,s.mesh.position.z=s.originZ+Math.sin(s.angle)*a,s.mesh.material.opacity=r<.2?r/.2*.85:r>.85?(1-r)/.15*.85:.85,s.mesh.scale.setScalar(.8+.3*Math.sin(3*s.angle)),r>=1&&(null==(i=this.scene)||i.remove(s.mesh),s.mesh.geometry.dispose(),s.mesh.material.dispose(),this._vortexParticles.splice(n,1))}}_updateEmberParticles(t){var e;for(let i=this._emberParticles.length-1;i>=0;i--){const n=this._emberParticles[i];n.life-=.4*t,n.mesh.position.x+=n.vx*t,n.mesh.position.y+=n.vy*t,n.mesh.position.z+=n.vz*t,n.flicker+=3*t,n.mesh.position.x+=Math.sin(n.flicker)*t*.15,n.vx*=.995,n.vz*=.995;const s=.7+.3*Math.sin(4*n.flicker);n.mesh.material.opacity=Math.max(0,n.life*s),n.mesh.scale.setScalar(.5+.5*n.life),n.life<=0&&(null==(e=this.scene)||e.remove(n.mesh),n.mesh.geometry.dispose(),n.mesh.material.dispose(),this._emberParticles.splice(i,1))}}_cancelLongPress(){var t;if(this._longPressActive=!1,this._holdProgress=0,null!==this._interactiveEgg){const e=this.eggs[this._interactiveEgg];e&&(e.scale.setScalar(.9),e.rotation.z=0);const i=this.eggBodies[this._interactiveEgg];void 0!==(null==(t=null==i?void 0:i.material)?void 0:t.emissiveIntensity)&&(i.material.emissiveIntensity=.05)}}_worldToScreen(t){if(!this.THREE||!this.camera)return{x:0,y:0};const e=(new this.THREE.Vector3).copy(t);return e.project(this.camera),{x:(.5*e.x+.5)*window.innerWidth,y:(.5*-e.y+.5)*window.innerHeight}}_isPointerNearAnyEgg(t,e){if(this._finaleInteractive){for(let i=0;i<3;i++){const n=this.eggs[i];if(!n||!n.visible)continue;const s=this._worldToScreen(n.position);if(Math.sqrt((t-s.x)**2+(e-s.y)**2)<=140)return!0}return!1}if(null===this._interactiveEgg)return!1;const i=this.eggs[this._interactiveEgg];if(!i||!i.visible)return!1;const n=this._worldToScreen(i.position);return Math.sqrt((t-n.x)**2+(e-n.y)**2)<=120}_screenToWorld(t,e){const i=this.THREE,n=t/window.innerWidth*2-1,s=-e/window.innerHeight*2+1,r=new i.Vector3(n,s,.5);r.unproject(this.camera);const a=r.sub(this.camera.position).normalize(),o=-this.camera.position.z/a.z;return this.camera.position.clone().add(a.multiplyScalar(o))}_updateEggs(t){var e,i;if(this.THREE)for(let n=0;n<3;n++){const s=this.eggs[n],r=this._eggStates[n];if(r.visible&&s)switch(r.t+=t,r.phase){case"reveal":{const t=3,i=Math.min(1,r.t/t),a=2*Math.PI/3,o=0===i?0:1===i?1:Math.pow(2,-10*i)*Math.sin((10*i-.75)*a)+1;s.scale.setScalar(.9*o),s.rotation.y=1.2*r.t,s.position.y=.06*Math.sin(2*r.t)*(1-i);const l=this.eggBodies[n];void 0!==(null==(e=null==l?void 0:l.material)?void 0:e.emissiveIntensity)&&(l.material.emissiveIntensity=.15+.1*Math.sin(4*r.t)),i>=1&&(r.phase="interactive",r.t=0);break}case"interactive":{this._isDragging&&this._interactiveEgg===n||(s.rotation.y+=.25*t),s.position.y=.04*Math.sin(.7*r.t);const e=this.eggBodies[n];void 0!==(null==(i=null==e?void 0:e.material)?void 0:i.emissiveIntensity)&&(e.material.emissiveIntensity=.05+.04*Math.sin(1.5*r.t));break}case"collecting":s.visible=!1,r.phase="shrine",r.t=0;break;case"shrine":{s.rotation.y+=.15*t;const e=.32+.01*Math.sin(1*r.t);s.scale.setScalar(e);break}}}}_updateHoldRing(){var t;if(!this._longPressActive||null===this._interactiveEgg)return;const e=Date.now()-this._longPressStartTime;this._holdProgress=Math.min(1,e/1200);const i=this._holdProgress,n=.001*e,s=this.eggs[this._interactiveEgg];if(!s)return;const r=.9*(1+.35*i);if(s.scale.setScalar(r),i>.4){const t=.03*(i-.4);s.rotation.z=Math.sin(12*n)*t,s.rotation.x=Math.cos(10*n)*t*.5}if(i>=1){const e=this._interactiveEgg;this._spawnMiniEggBurst(e),this._cancelLongPress(),null==(t=this._onCollectEgg)||t.call(this,e)}}_spawnMiniEggBurst(t){if(!this.THREE||!this.scene)return;const e=this.THREE,i=this.eggs[t];if(!i)return;const n=i.position.clone(),s=[{main:12634328,accent:8425648},{main:15253568,accent:13934624},{main:13647968,accent:8401056}],r=s[t]??s[0],a=new e.SphereGeometry(.06,12,12),o=a.attributes.position;for(let l=0;l<o.count;l++){let t=o.getY(l);t=1.4*t*(t>0?.82:1),o.setY(l,t)}a.computeVertexNormals();for(let l=0;l<18;l++){const t=Math.random()>.35?r.main:r.accent,i=new e.MeshStandardMaterial({color:t,roughness:.3,metalness:.5,emissive:t,emissiveIntensity:.15,transparent:!0,opacity:1}),s=new e.Mesh(a,i);s.position.copy(n);const o=.5+.8*Math.random();s.scale.setScalar(o),s.rotation.set(Math.random()*Math.PI,Math.random()*Math.PI,Math.random()*Math.PI);const l=Math.random()*Math.PI*2,h=Math.acos(2*Math.random()-1),c=2+3*Math.random(),u=Math.sin(h)*Math.cos(l)*c,d=Math.sin(h)*Math.sin(l)*c*.8+1,p=Math.cos(h)*c;this.scene.add(s),this._miniEggs.push({mesh:s,vx:u,vy:d,vz:p,life:1,spin:8*(Math.random()-.5)})}}_updateMiniEggs(t){var e,i;for(let n=this._miniEggs.length-1;n>=0;n--){const s=this._miniEggs[n];s.life-=1.2*t,s.vy-=5*t,s.mesh.position.x+=s.vx*t,s.mesh.position.y+=s.vy*t,s.mesh.position.z+=s.vz*t,s.mesh.rotation.y+=s.spin*t,s.mesh.rotation.x+=s.spin*t*.5;const r=Math.max(0,s.life);s.mesh.material.opacity=r,s.mesh.scale.multiplyScalar(1-.5*t),s.life<=0&&(null==(e=this.scene)||e.remove(s.mesh),null==(i=s.mesh.material)||i.dispose(),this._miniEggs.splice(n,1))}}_updateFinale(t){var e;if(!this._finaleActive||!this.THREE)return;this._finaleT+=t;const i=.35*this._finaleT;for(let n=0;n<3;n++){const t=this.eggs[n];if(!t)continue;t.visible=!0;const s=i+n*(2*Math.PI/3),r=1.4*Math.sin(s),a=.05*Math.sin(.6*this._finaleT+1.2*n)-.1,o=.42*Math.cos(s);t.position.x+=.06*(r-t.position.x),t.position.y+=.06*(a-t.position.y),t.position.z+=.06*(o-t.position.z),this._finalePausedRotation[n]||(t.rotation.y=.4*this._finaleT+n*(2*Math.PI/3)),t.scale.setScalar(t.scale.x+.04*(.55-t.scale.x));const l=this.eggBodies[n];if(void 0!==(null==(e=null==l?void 0:l.material)?void 0:e.emissiveIntensity)){const t=.15+.08*Math.sin(2*this._finaleT+1.5*n);l.material.emissiveIntensity+=.05*(t-l.material.emissiveIntensity)}}this._finaleT>5&&this._finaleT<5.1&&this.renderer&&(this.renderer.toneMappingExposure=2.8),this._finaleT>5.1&&this._finaleT<8&&this.renderer&&(this.renderer.toneMappingExposure=Math.max(1.1,2.8-.55*(this._finaleT-5.1)))}_updateTrails(t){for(let e=this._trailParticles.length-1;e>=0;e--){const i=this._trailParticles[e];i.life-=.5*t,i.life<=0?(this.scene.remove(i.mesh),i.mesh.geometry.dispose(),i.mesh.material.dispose(),this._trailParticles.splice(e,1)):(i.mesh.material.opacity=.65*i.life,i.mesh.position.y+=.15*t,i.mesh.scale.setScalar(i.life),i.mesh.rotation.z+=.8*t)}}_updateAmbientParticles(t){for(let e=this._ambientParticles.length-1;e>=0;e--){const i=this._ambientParticles[e];i.life-=.25*t,i.mesh.position.y+=i.vy*t,i.mesh.rotation.z+=.5*t,i.fadeIn&&i.life>.7?(i.mesh.material.opacity=Math.min(.9,i.mesh.material.opacity+1*t),i.mesh.material.opacity>=.85&&(i.fadeIn=!1)):i.mesh.material.opacity=Math.max(0,.85*i.life),i.life<=0&&(this.scene.remove(i.mesh),i.mesh.geometry.dispose(),i.mesh.material.dispose(),this._ambientParticles.splice(e,1))}}_updateRevealParticles(t){for(let e=this._revealParticles.length-1;e>=0;e--){const i=this._revealParticles[e];i.life-=.6*t,i.mesh.position.x+=i.vx*t,i.mesh.position.y+=i.vy*t,i.mesh.position.z+=i.vz*t,i.vy-=1.5*t,i.mesh.material.opacity=Math.max(0,.8*i.life),i.mesh.scale.setScalar(Math.max(.01,i.life)),i.life<=0&&(this.scene.remove(i.mesh),i.mesh.geometry.dispose(),i.mesh.material.dispose(),this._revealParticles.splice(e,1))}}}class x{constructor(t){this.host=null,this.shadow=null,this.container=null,this.eggs=[],this._finaleActive=!1,this.config=t}async init(){this.host=document.createElement("div"),this.host.id="eeq-fallback-host",Object.assign(this.host.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"999992"}),document.body.appendChild(this.host),this.shadow=this.host.attachShadow({mode:"closed"});const t=document.createElement("style");t.textContent=this._getStyles(),this.shadow.appendChild(t),this.container=document.createElement("div"),this.container.className="eeq-f-container",this.shadow.appendChild(this.container);for(let e=0;e<3;e++){const t=document.createElement("div");t.className=`eeq-f-egg eeq-f-egg-${e+1} eeq-f-hidden`;const i=document.createElement("div");i.className="eeq-f-egg-inner";const n=document.createElement("div");n.className="eeq-f-egg-shine",i.appendChild(n),t.appendChild(i),this.container.appendChild(t),this.eggs.push(t)}return!0}startRenderLoop(){}stopRenderLoop(){}revealEgg(t){const e=this.eggs[t];e&&(e.classList.remove("eeq-f-hidden"),e.classList.add("eeq-f-reveal"))}collectEgg(t){const e=this.eggs[t];e&&(e.classList.remove("eeq-f-reveal"),e.classList.add("eeq-f-collected"))}addTrail(t,e,i){if(!this.container)return;const n=document.createElement("div");n.className="eeq-f-trail";const s=360*Math.random();n.style.background=`hsl(${s}, 50%, 78%)`,n.style.left=`${t}px`,n.style.top=`${e}px`,this.container.appendChild(n),setTimeout(()=>n.remove(),1200)}startFinale(){this._finaleActive=!0;for(const t of this.eggs)t.classList.remove("eeq-f-collected","eeq-f-hidden"),t.classList.add("eeq-f-finale");this.container&&this.container.classList.add("eeq-f-finale-active")}setBreathIntensity(t){}setOverlayIntensity(t){}destroy(){var t;null==(t=this.host)||t.remove(),this.host=null,this.shadow=null,this.container=null,this.eggs=[]}_getStyles(){const t=this.config.theme;return`\n .eeq-f-container {\n position: fixed;\n top: 0; left: 0;\n width: 100%; height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 32px;\n pointer-events: none;\n }\n\n .eeq-f-egg {\n width: 60px;\n height: 80px;\n border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;\n position: relative;\n transition: all 1.5s cubic-bezier(0.22, 1, 0.36, 1);\n }\n\n .eeq-f-hidden {\n opacity: 0;\n transform: scale(0.1);\n }\n\n .eeq-f-reveal {\n opacity: 1;\n transform: scale(1);\n animation: eeq-f-float 3s ease-in-out infinite;\n }\n\n .eeq-f-collected {\n opacity: 0.6;\n transform: scale(0.5) translateY(200px);\n position: fixed;\n bottom: 30px;\n }\n\n .eeq-f-finale {\n opacity: 1;\n transform: scale(1);\n animation: eeq-f-finale-spin 3s linear infinite;\n }\n\n .eeq-f-finale-active {\n animation: eeq-f-glow-bg 2s ease-in-out forwards;\n }\n\n .eeq-f-egg-inner {\n width: 100%;\n height: 100%;\n border-radius: inherit;\n position: relative;\n overflow: hidden;\n }\n\n .eeq-f-egg-shine {\n position: absolute;\n top: 15%;\n left: 20%;\n width: 30%;\n height: 25%;\n border-radius: 50%;\n background: rgba(255,255,255,0.4);\n filter: blur(4px);\n }\n\n /* Egg 1: Porcelain */\n .eeq-f-egg-1 .eeq-f-egg-inner {\n background: linear-gradient(145deg, #f5f0eb 0%, #e8e0d8 50%, #d8d0c8 100%);\n box-shadow: 0 4px 24px rgba(212,165,116,0.2), inset 0 2px 8px rgba(255,255,255,0.3);\n }\n\n /* Egg 2: Luminous pearl */\n .eeq-f-egg-2 .eeq-f-egg-inner {\n background: linear-gradient(145deg, #faf5f0 0%, #f0e8e0 40%, #e5ddd5 100%);\n box-shadow: 0 4px 28px rgba(212,165,116,0.3), inset 0 2px 12px rgba(255,255,255,0.4);\n }\n\n /* Egg 3: Golden core */\n .eeq-f-egg-3 .eeq-f-egg-inner {\n background: linear-gradient(145deg, #fff8f0 0%, #f5e8d5 40%, ${t.accent} 100%);\n box-shadow: 0 4px 32px ${t.accentGlow}, inset 0 2px 16px rgba(255,255,255,0.4);\n }\n\n .eeq-f-trail {\n position: fixed;\n width: 8px;\n height: 11px;\n border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;\n background: ${t.accent};\n opacity: 0.4;\n pointer-events: none;\n animation: eeq-f-trail-fade 1.2s ease-out forwards;\n }\n\n @keyframes eeq-f-float {\n 0%, 100% { transform: scale(1) translateY(0); }\n 50% { transform: scale(1) translateY(-8px); }\n }\n\n @keyframes eeq-f-finale-spin {\n from { transform: scale(1) rotate(0deg); }\n to { transform: scale(1) rotate(360deg); }\n }\n\n @keyframes eeq-f-trail-fade {\n 0% { opacity: 0.5; transform: scale(1); }\n 100% { opacity: 0; transform: scale(0.2) translateY(-10px); }\n }\n\n @keyframes eeq-f-glow-bg {\n 0% { background: transparent; }\n 50% { background: rgba(212,165,116,0.08); }\n 100% { background: transparent; }\n }\n `}}class M{constructor(t){this.overlay=null,this._visible=!1,this.config=t}mount(){this.overlay=document.createElement("div"),this.overlay.id="eeq-overlay",Object.assign(this.overlay.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",background:"transparent",backdropFilter:"none",WebkitBackdropFilter:"none",zIndex:"999985",pointerEvents:"none",transition:"background 1.5s ease, backdrop-filter 1.5s ease",opacity:"0"}),document.body.appendChild(this.overlay)}show(){this.overlay&&!this._visible&&(this._visible=!0,requestAnimationFrame(()=>{this.overlay&&(this.overlay.style.opacity="1",this.overlay.style.background=this.config.theme.overlayBg,this.overlay.style.backdropFilter="blur(2px)",this.overlay.style.WebkitBackdropFilter="blur(2px)")}))}setIntensity(t){if(!this.overlay)return;const e=.25+.25*t;this.overlay.style.background=`rgba(0,0,0,${e})`;const i=2+4*t;this.overlay.style.backdropFilter=`blur(${i}px)`,this.overlay.style.WebkitBackdropFilter=`blur(${i}px)`}hide(){this.overlay&&(this._visible=!1,this.overlay.style.opacity="0",this.overlay.style.background="transparent",this.overlay.style.backdropFilter="none",this.overlay.style.WebkitBackdropFilter="none")}destroy(){var t;null==(t=this.overlay)||t.remove(),this.overlay=null}}const b=class{constructor(t){this.host=null,this.shadow=null,this._onFinish=null,this.config=t}show(t,e){var i,n;this._onFinish=e,this.host=document.createElement("div"),this.host.id="eeq-results-host",Object.assign(this.host.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",zIndex:"999998",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto"}),document.body.appendChild(this.host),this.shadow=this.host.attachShadow({mode:"closed"});const s=document.createElement("style");s.textContent=this._getStyles(),this.shadow.appendChild(s);const r=document.createElement("div");r.className="eeq-results",this._buildContentDOM(r,t),this.shadow.appendChild(r),requestAnimationFrame(()=>{requestAnimationFrame(()=>{r.classList.add("eeq-results-visible")})}),null==(i=this.shadow.querySelector(".eeq-btn-finish"))||i.addEventListener("click",()=>{var t;return null==(t=this._onFinish)?void 0:t.call(this)}),null==(n=this.shadow.querySelector(".eeq-btn-share"))||n.addEventListener("click",()=>this._copyShareImage(t))}destroy(){var t;null==(t=this.host)||t.remove(),this.host=null,this.shadow=null}_buildContentDOM(t,e){const i=e.behaviorProfile,n=document.createElement("div");n.className="eeq-results-inner";const s=document.createElement("div");s.className="eeq-results-title",s.textContent=`« ${i.title} »`,n.appendChild(s);const r=document.createElement("div");r.className="eeq-time",r.textContent=f(e.totalTime),n.appendChild(r);const a=document.createElement("div");a.className="eeq-badges";const o=[{icon:{clicker:"🖱",scroller:"📜",typist:"⌨",minimalist:"🧘",mover:"🖱"}[i.dominantAction],label:i.dominantAction},{icon:{tornado:"🌪",conductor:"🎼",surgeon:"🎯",ghost:"👻"}[i.mousePersonality],label:i.mousePersonality},{icon:{speedster:"⚡",steady:"🚶",explorer:"🧭",philosopher:"🕊"}[i.pace],label:i.pace}];for(const{icon:m,label:f}of o){if(!m)continue;const t=document.createElement("span");t.className="eeq-badge",t.title=f,t.textContent=m,a.appendChild(t)}n.appendChild(a);const l=document.createElement("div");l.className="eeq-share-invite",l.textContent="share or copy your result",n.appendChild(l);const h=document.createElement("div");h.className="eeq-results-actions";const c=document.createElement("button");c.className="eeq-btn eeq-btn-share",c.title="share or copy result",c.innerHTML='<svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M4.5 10.5a2 2 0 1 1 0-4 2 2 0 0 1 0 4zm7-4a2 2 0 1 1 0-4 2 2 0 0 1 0 4zm0 8a2 2 0 1 1 0-4 2 2 0 0 1 0 4z" stroke="currentColor" stroke-width="1.2"/><path d="M6.3 9.2l3.4 1.6M6.3 7.8l3.4-1.6" stroke="currentColor" stroke-width="1.2"/></svg>';const u=document.createElement("span");u.textContent="share / copy",c.appendChild(u),h.appendChild(c);const d=document.createElement("button");d.className="eeq-btn eeq-btn-finish",d.title="finish",d.innerHTML='<svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M4 8.5l3 3 5-6.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>';const p=document.createElement("span");p.textContent="finish",d.appendChild(p),h.appendChild(d),n.appendChild(h),t.appendChild(n)}_makeRand(t){let e=t;return()=>{e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}_drawTypedEgg2D(t,e,i,n){const s=Math.min(window.devicePixelRatio||1,3);t.width=72*s,t.height=96*s,t.style.width="72px",t.style.height="96px";const r=t.getContext("2d");r.scale(s,s);const a=30.24,o=96*.46;i?0===e?this._paintSilverEgg(r,36,48,a,o):1===e?this._paintGoldEgg(r,36,48,a,o):this._paintFestiveEgg(r,36,48,a,o,n):this._drawEggOutline(r,36,48,a,o,!0)}_eggPath(t,e,i,n,s){t.beginPath();for(let r=0;r<=2*Math.PI;r+=.02){const a=1-.15*Math.sin(r),o=e+Math.cos(r)*n*a,l=i-Math.sin(r)*s;0===r?t.moveTo(o,l):t.lineTo(o,l)}t.closePath()}_drawEggOutline(t,e,i,n,s,r){t.save(),r&&t.setLineDash([5,4]),this._eggPath(t,e,i,n,s),t.strokeStyle="rgba(255,255,255,0.15)",t.lineWidth=1.5,t.stroke(),t.restore()}_drawSpecular(t,e,i,n,s){const r=t.createRadialGradient(e-.25*n,i-.4*s,0,e-.25*n,i-.4*s,.7*n);r.addColorStop(0,"rgba(255,255,255,0.4)"),r.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=r,t.fillRect(e-n-2,i-s-2,2*n+4,2*s+4)}_paintSilverEgg(t,e,i,n,s){t.save(),this._eggPath(t,e,i,n,s),t.clip();const r=t.createLinearGradient(e,i-s,e,i+s);r.addColorStop(0,"#e8ecf2"),r.addColorStop(.3,"#dde1e8"),r.addColorStop(.6,"#d0d4dc"),r.addColorStop(1,"#c4c0bc"),t.fillStyle=r,t.fillRect(e-n-2,i-s-2,2*n+4,2*s+4),t.fillStyle="rgba(255,255,255,0.55)";for(let o=-1;o<2*s/10+2;o++){const r=o%2*6;for(let a=-1;a<2*n/12+2;a++){const l=e-n+12*a+r,h=i-s+10*o;t.beginPath(),t.arc(l,h,3.5,0,2*Math.PI),t.fill()}}const a=t.createLinearGradient(e-n,i-.2*s,e+n,i+.2*s);a.addColorStop(0,"rgba(255,255,255,0)"),a.addColorStop(.4,"rgba(255,255,255,0.12)"),a.addColorStop(.6,"rgba(255,255,255,0.12)"),a.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=a,t.fillRect(e-n-2,i-s-2,2*n+4,2*s+4),this._drawSpecular(t,e,i,n,s),t.restore(),t.save(),this._eggPath(t,e,i,n,s),t.strokeStyle="rgba(200,205,215,0.5)",t.lineWidth=1.2,t.stroke(),t.restore()}_paintGoldEgg(t,e,i,n,s){t.save(),this._eggPath(t,e,i,n,s),t.clip();const r=t.createLinearGradient(e,i-s,e,i+s);r.addColorStop(0,"#d4a520"),r.addColorStop(.25,"#e6c040"),r.addColorStop(.5,"#daa520"),r.addColorStop(.75,"#c89618"),r.addColorStop(1,"#b8860b"),t.fillStyle=r,t.fillRect(e-n-2,i-s-2,2*n+4,2*s+4),t.globalAlpha=.25;for(const a of[.28,.5,.72]){const r=i-s+a*s*2,o=5,l=t.createLinearGradient(e,r-o,e,r+o);l.addColorStop(0,"#b8860b"),l.addColorStop(.5,"#f0d060"),l.addColorStop(1,"#b8860b"),t.fillStyle=l,t.fillRect(e-n-2,r-o,2*n+4,2*o)}t.globalAlpha=1,t.strokeStyle="rgba(160,112,8,0.18)",t.lineWidth=.8;for(let a=e-2*n;a<e+2*n;a+=8)t.beginPath(),t.moveTo(a,i-s),t.lineTo(a+2*s,i+s),t.stroke(),t.beginPath(),t.moveTo(a+2*s,i-s),t.lineTo(a,i+s),t.stroke();t.strokeStyle="rgba(212,165,16,0.35)",t.lineWidth=.7;for(const a of[.24,.32,.46,.54,.68,.76]){const r=i-s+a*s*2;t.beginPath(),t.moveTo(e-n,r),t.lineTo(e+n,r),t.stroke()}this._drawSpecular(t,e,i,n,s),t.restore(),t.save(),this._eggPath(t,e,i,n,s),t.strokeStyle="rgba(200,165,30,0.5)",t.lineWidth=1.2,t.stroke(),t.restore()}_paintFestiveEgg(t,e,i,n,s,r){const a=this._makeRand(r);t.save(),this._eggPath(t,e,i,n,s),t.clip();const o=360*a(),l=[];for(let d=0;d<5;d++)l.push((o+d*(50+30*a()))%360);const h=2*s/9,c=i-s;for(let d=0;d<9;d++){const i=c+d*h;if(d%2==1){const n=52+10*a(),s=t.createLinearGradient(e,i,e,i+h);s.addColorStop(0,`hsl(43, 80%, ${n}%)`),s.addColorStop(1,`hsl(43, 75%, ${n-6}%)`),t.fillStyle=s}else{const n=l[Math.floor(d/2)%l.length],s=55+30*a(),r=35+15*a(),o=t.createLinearGradient(e,i,e,i+h);o.addColorStop(0,`hsl(${n}, ${s}%, ${r}%)`),o.addColorStop(1,`hsl(${n}, ${s}%, ${r-8}%)`),t.fillStyle=o}t.fillRect(e-n-2,i,2*n+4,h+1)}const u=5+Math.floor(4*a());for(let d=1;d<9;d+=2){const i=c+(d+.5)*h;for(let s=0;s<u;s++){const r=e-.7*n+(s+.5)*(1.4*n/u),o=l[Math.floor(a()*l.length)];t.fillStyle=`hsl(${o}, 70%, 55%)`,t.beginPath(),t.arc(r,i,1.5+a(),0,2*Math.PI),t.fill()}}this._drawSpecular(t,e,i,n,s),t.restore(),t.save(),this._eggPath(t,e,i,n,s),t.strokeStyle="rgba(200,150,100,0.45)",t.lineWidth=1.2,t.stroke(),t.restore()}_copyShareImage(t){var e;const i=this._renderCard(t),n=this._buildShareText(t),s=i.toDataURL("image/png"),r=atob(s.split(",")[1]),a=new ArrayBuffer(r.length),o=new Uint8Array(a);for(let h=0;h<r.length;h++)o[h]=r.charCodeAt(h);const l=new Blob([a],{type:"image/png"});if(/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)&&window.innerWidth<768&&navigator.share){const t=new File([l],"easter-egg-quest.png",{type:"image/png"});return(null==(e=navigator.canShare)?void 0:e.call(navigator,{files:[t]}))?void navigator.share({files:[t],title:"Easter Egg Quest",text:n}).catch(()=>{}):void navigator.share({title:"Easter Egg Quest",text:n}).catch(()=>{})}navigator.clipboard&&"undefined"!=typeof ClipboardItem?navigator.clipboard.write([new ClipboardItem({"image/png":l})]).then(()=>{this._flashButton(".eeq-btn-share","image copied")}).catch(()=>{this._copyShareText(n,l)}):this._copyShareText(n,l)}_copyShareText(t,e){var i;(null==(i=navigator.clipboard)?void 0:i.writeText)?navigator.clipboard.writeText(t).then(()=>{this._flashButton(".eeq-btn-share","text copied")}).catch(()=>{this._downloadBlob(e)}):this._downloadBlob(e)}_buildShareText(t){const e=f(t.totalTime),i=`${t.eggsFound}/3 eggs`;return`Easter Egg Quest: ${t.behaviorProfile.title} • ${e} • ${i}`}_downloadBlob(t){const e=URL.createObjectURL(t),i=document.createElement("a");i.href=e,i.download="easter-egg-quest.png",i.click(),setTimeout(()=>URL.revokeObjectURL(e),5e3),this._flashButton(".eeq-btn-share","saved!")}_renderCard(t){const e=Math.min(window.devicePixelRatio||1,3),i=document.createElement("canvas");i.width=480*e,i.height=400*e;const n=i.getContext("2d");n.scale(e,e);const s=n.createLinearGradient(0,0,0,400);s.addColorStop(0,"#1e1815"),s.addColorStop(.5,"#14110e"),s.addColorStop(1,"#0d0b09"),n.fillStyle=s,this._roundRect(n,0,0,480,400,16),n.fill(),n.strokeStyle="rgba(212,165,80,0.18)",n.lineWidth=1,this._roundRect(n,.5,.5,479,399,16),n.stroke(),n.textAlign="center",n.font="11px Georgia, serif",n.fillStyle="rgba(232,224,214,0.3)",n.fillText("🥚 Easter Egg Quest",240,28);const r=20.16,a=29.44;for(let c=0;c<3;c++){const e=176+64*c;c<t.eggsFound?0===c?this._paintSilverEgg(n,e,72,r,a):1===c?this._paintGoldEgg(n,e,72,r,a):this._paintFestiveEgg(n,e,72,r,a,t.eggSeed):this._drawEggOutline(n,e,72,r,a,!0)}const o=3===t.eggsFound?"All eggs collected!":`${t.eggsFound} of 3 eggs collected`;n.font="10px Georgia, serif",n.fillStyle="rgba(232,224,214,0.35)",n.fillText(o,240,119.44);const l=131.44;n.strokeStyle="rgba(212,165,80,0.12)",n.lineWidth=.5,n.beginPath(),n.moveTo(96,l),n.lineTo(384,l),n.stroke(),n.font="italic 18px Georgia, serif",n.fillStyle=this.config.theme.accent,n.fillText(`« ${t.behaviorProfile.title} »`,240,159.44),n.font='32px "SF Mono", "Fira Code", Consolas, monospace',n.fillStyle="#e8e0d6",n.fillText(f(t.totalTime),240,199.44);const h=[t.behaviorProfile.dominantAction,t.behaviorProfile.mousePersonality,t.behaviorProfile.pace];return n.font="12px Georgia, serif",n.fillStyle="rgba(232,224,214,0.4)",n.fillText(h.join(" · "),240,223.44),n.font="14px Georgia, serif",n.fillStyle="rgba(232,224,214,0.55)",n.fillText("All three eggs found",240,261.44),n.font="11px Georgia, serif",n.fillStyle="rgba(232,224,214,0.3)",n.fillText("Share or copy your result",240,281.44),n.font="9px Georgia, serif",n.fillStyle="rgba(232,224,214,0.12)",n.fillText("easter egg quest",240,384),i}_roundRect(t,e,i,n,s,r){t.beginPath(),t.moveTo(e+r,i),t.lineTo(e+n-r,i),t.quadraticCurveTo(e+n,i,e+n,i+r),t.lineTo(e+n,i+s-r),t.quadraticCurveTo(e+n,i+s,e+n-r,i+s),t.lineTo(e+r,i+s),t.quadraticCurveTo(e,i+s,e,i+s-r),t.lineTo(e,i+r),t.quadraticCurveTo(e,i,e+r,i),t.closePath()}_flashButton(t,e){var i;const n=null==(i=this.shadow)?void 0:i.querySelector(`${t} span`);if(!n)return;const s=n.textContent;n.textContent=e,setTimeout(()=>{n.textContent=s},1500)}_getStyles(){const t=this.config.theme;return`\n .eeq-results {\n pointer-events: auto;\n background: linear-gradient(175deg, rgba(28,22,18,0.95) 0%, rgba(10,8,6,0.97) 100%);\n backdrop-filter: blur(28px);\n -webkit-backdrop-filter: blur(28px);\n border: 1px solid rgba(212,165,80,0.1);\n border-radius: 20px;\n padding: 28px 36px 24px;\n max-width: 320px;\n width: 85vw;\n opacity: 0;\n transform: translateY(24px) scale(0.95);\n transition: opacity 0.9s ease, transform 0.9s cubic-bezier(0.23, 1, 0.32, 1);\n font-family: 'Georgia', 'Times New Roman', serif;\n color: ${t.textColor};\n text-align: center;\n box-shadow: 0 24px 80px rgba(0,0,0,0.6), 0 4px 16px rgba(0,0,0,0.4),\n inset 0 1px 0 rgba(255,255,255,0.04);\n }\n\n .eeq-results-visible {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n\n .eeq-results-title {\n font-size: 18px;\n font-style: italic;\n letter-spacing: 0.04em;\n color: ${t.accent};\n margin-bottom: 10px;\n line-height: 1.35;\n text-shadow: 0 0 30px rgba(212,165,80,0.15);\n }\n\n .eeq-time {\n font-size: 30px;\n font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;\n letter-spacing: 0.06em;\n margin-bottom: 12px;\n background: linear-gradient(180deg, #f0ece6, #c8c0b4);\n -webkit-background-clip: text;\n -webkit-text-fill-color: transparent;\n background-clip: text;\n }\n\n .eeq-badges {\n display: flex;\n justify-content: center;\n gap: 10px;\n margin-bottom: 12px;\n font-size: 18px;\n }\n\n .eeq-share-invite {\n font-size: 13px;\n color: rgba(232,224,214,0.5);\n margin-bottom: 16px;\n letter-spacing: 0.03em;\n }\n\n .eeq-badge {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 36px;\n height: 36px;\n border-radius: 50%;\n background: rgba(255,255,255,0.03);\n border: 1px solid rgba(255,255,255,0.07);\n cursor: default;\n transition: background 0.3s, border-color 0.3s;\n }\n\n .eeq-badge:hover {\n background: rgba(212,165,80,0.08);\n border-color: rgba(212,165,80,0.2);\n }\n\n .eeq-results-actions {\n display: flex;\n justify-content: center;\n gap: 10px;\n }\n\n .eeq-btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n background: rgba(255,255,255,0.02);\n border: 1px solid rgba(255,255,255,0.1);\n color: ${t.textColor};\n padding: 8px 18px;\n border-radius: 10px;\n font-family: 'Georgia', serif;\n font-size: 12px;\n letter-spacing: 0.04em;\n cursor: pointer;\n transition: all 0.3s ease;\n white-space: nowrap;\n }\n\n .eeq-btn svg {\n flex-shrink: 0;\n opacity: 0.7;\n transition: opacity 0.3s;\n }\n\n .eeq-btn:hover {\n border-color: ${t.accent};\n color: ${t.accent};\n background: rgba(212,165,80,0.06);\n box-shadow: 0 0 20px rgba(212,165,80,0.08);\n }\n\n .eeq-btn:hover svg {\n opacity: 1;\n }\n\n .eeq-btn:focus {\n outline: 2px solid ${t.accent};\n outline-offset: 2px;\n }\n\n .eeq-btn:active {\n transform: scale(0.96);\n }\n `}};b.EGG_PALETTES=[{base1:"#e0e4ea",base2:"#c8c4c0",accent:"#f4f4f6",outline:"rgba(200,200,210,0.6)",label:"Silver"},{base1:"#daa520",base2:"#b8860b",accent:"#f0d060",outline:"rgba(218,165,32,0.6)",label:"Gold"},{base1:"#c05070",base2:"#3060a0",accent:"#e6b422",outline:"rgba(200,100,120,0.6)",label:"Fabergé"}];let S=b;class w{constructor(){this._startTime=0,this._entryTime=0,this._stageResults=[],this._extraClicks=0,this._chaoticMoveFrames=0,this._hesitations=0,this._failedAttempts=0,this._overcorrections=0}start(){this._startTime=Date.now(),this._stageResults=[],this._extraClicks=0,this._chaoticMoveFrames=0,this._hesitations=0,this._failedAttempts=0,this._overcorrections=0}recordEntryFound(){this._entryTime=Date.now()-this._startTime}recordStageResult(t){this._stageResults.push(t),this._failedAttempts+=Math.max(0,t.attempts-1)}analyseFrame(t){t.velocity>2e3&&this._chaoticMoveFrames++}recordExtraClick(){this._extraClicks++}recordHesitation(){this._hesitations++}recordOvercorrection(){this._overcorrections++}computeFinalScore(t){const e=Date.now()-this._startTime,i=this._stageResults[0],n=this._stageResults[1],s=this._stageResults[2],r=this._computePredictability(),a=(null==t?void 0:t.totalClicks)??0,o=(null==t?void 0:t.totalScrolls)??0,l=(null==t?void 0:t.totalKeyPresses)??0,h=(null==t?void 0:t.totalDistance)??0,c=this._computeBehaviorProfile({totalTime:e,clicks:a,scrolls:o,keys:l,distance:h,maxVelocity:(null==t?void 0:t.maxVelocity)??0,stillnessBreaks:(null==i?void 0:i.breaks)??0,motionFades:(null==n?void 0:n.fades)??0,rhythmAccuracy:(null==s?void 0:s.rhythmAccuracy)??0,predictabilityScore:r.score});return{eggsFound:this._stageResults.length,totalTime:e,entryTime:this._entryTime,egg1Time:(null==i?void 0:i.stageTime)??0,egg2Time:(null==n?void 0:n.stageTime)??0,egg3Time:(null==s?void 0:s.stageTime)??0,stillnessBreaks:(null==i?void 0:i.breaks)??0,motionFades:(null==n?void 0:n.fades)??0,rhythmAccuracy:(null==s?void 0:s.rhythmAccuracy)??0,predictabilityScore:r.score,predictabilityLabel:r.label,stageResults:this._stageResults,behaviorProfile:c,totalClicks:a,totalScrolls:o,totalKeyPresses:l,totalDistance:h,eggSeed:Math.floor(2147483647*Math.random())}}_computeBehaviorProfile(t){let e;e=0===Math.max(t.clicks,t.scrolls,t.keys)?"minimalist":t.clicks>=t.scrolls&&t.clicks>=t.keys?"clicker":t.scrolls>=t.clicks&&t.scrolls>=t.keys?"scroller":"typist";const i=t.distance/Math.max(t.totalTime/1e3,1);let n;n=i>600?"tornado":i>250?"conductor":i>60?"surgeon":"ghost";const s=t.totalTime/1e3;let r;return r=s<45?"speedster":s<120?"steady":s<360?"explorer":"philosopher",{title:this._pickTitle(t,e,n,r),dominantAction:e,mousePersonality:n,pace:r}}_pickTitle(t,e,i,n){const s=[],r=t.totalTime/1e3;r<30?s.push({score:.95,title:"Quantum Egg Locator"}):r<45?s.push({score:.8,title:"Easter Lightning"}):r>600?s.push({score:.85,title:"Egg Philosopher Supreme"}):r>360&&s.push({score:.7,title:"Scenic Route Connoisseur"});const a=t.clicks/Math.max(r/60,.5);a>40?s.push({score:.9,title:"The Click Machine"}):a>20?s.push({score:.7,title:"Click Enthusiast"}):t.clicks<=3&&r>30&&s.push({score:.75,title:"Clickless Wonder"}),t.scrolls>100?s.push({score:.85,title:"Scroll Archaeologist"}):t.scrolls>50&&s.push({score:.65,title:"Infinite Scroller"}),t.keys>50?s.push({score:.8,title:"Keyboard Adventurer"}):t.keys>20&&s.push({score:.6,title:"Secret Code Seeker"});const o=t.distance/1e3;return o>50?s.push({score:.85,title:"Mouse Marathon Runner"}):o>20?s.push({score:.65,title:"Cursor Voyager"}):o<2&&r>30&&s.push({score:.7,title:"Laser Pointer Specialist"}),t.maxVelocity>8e3&&s.push({score:.75,title:"Speed Demon"}),t.predictabilityScore>=92?s.push({score:.85,title:"Human Clockwork"}):t.predictabilityScore>=80?s.push({score:.6,title:"The Algorithm"}):t.predictabilityScore<=12?s.push({score:.9,title:"Agent of Chaos"}):t.predictabilityScore<=25&&s.push({score:.7,title:"Chaos Butterfly"}),t.rhythmAccuracy>=95?s.push({score:.85,title:"Rhythm Oracle"}):t.rhythmAccuracy>=80?s.push({score:.6,title:"Beat Keeper"}):t.rhythmAccuracy<20&&t.rhythmAccuracy>0&&s.push({score:.75,title:"Jazz Improviser"}),0===t.stillnessBreaks?s.push({score:.8,title:"Stone Buddha"}):t.stillnessBreaks>=15&&s.push({score:.7,title:"Caffeinated Explorer"}),0===t.motionFades&&r>20&&s.push({score:.65,title:"Perpetual Motion"}),"speedster"===n&&"clicker"===e&&s.push({score:.92,title:"Turbo Clicker"}),"philosopher"===n&&"ghost"===i&&s.push({score:.88,title:"Meditation Champion"}),"tornado"===i&&"typist"===e&&s.push({score:.87,title:"Keyboard Tornado"}),t.rhythmAccuracy>=85&&t.clicks<=5&&s.push({score:.82,title:"Silent Perfectionist"}),t.predictabilityScore<=20&&"speedster"===n&&s.push({score:.88,title:"Controlled Chaos"}),"scroller"===e&&"explorer"===n&&s.push({score:.78,title:"Digital Archaeologist"}),"conductor"===i&&t.rhythmAccuracy>=70&&s.push({score:.8,title:"Cursor Choreographer"}),"minimalist"===e&&"steady"===n&&s.push({score:.75,title:"Zen Navigator"}),t.stillnessBreaks>=10&&t.rhythmAccuracy>=80&&s.push({score:.78,title:"Restless Virtuoso"}),o>30&&"speedster"===n&&s.push({score:.82,title:"Hyperdrive Activated"}),s.sort((t,e)=>e.score-t.score),s.length>0?s[0].title:{speedster:"Swift Egg Seeker",steady:"Determined Hunter",explorer:"Curious Wanderer",philosopher:"Patient Sage"}[n]??"Egg Explorer"}_computePredictability(){const t=.2*Math.min(this._extraClicks/30,1)+.25*Math.min(this._chaoticMoveFrames/200,1)+.2*Math.min(this._hesitations/20,1)+.2*Math.min(this._failedAttempts/10,1)+.15*Math.min(this._overcorrections/15,1),e=Math.round(100*(1-t)),i=Math.max(0,Math.min(100,e));return{score:i,label:this._labelForScore(i)}}_labelForScore(t){return t>=90?"highly predictable":t>=75?`more predictable than ${t}% of players`:t>=55?"moderately predictable":t>=35?`less predictable than ${100-t}% of players`:t>=15?"rare pattern":"deeply unpredictable"}}const T="eeq_scores",E="eeq_progress";class A{constructor(t){this._enabled=t}saveScore(t){if(this._enabled)try{const e=this._loadAll();e.push({...t,date:(new Date).toISOString()});const i=e.slice(-50);localStorage.setItem(T,JSON.stringify(i))}catch{}}getBestTime(){const t=this._loadAll();return 0===t.length?null:Math.min(...t.map(t=>t.totalTime))}getScoreCount(){return this._loadAll().length}getLastScore(){const t=this._loadAll();return t.length>0?t[t.length-1]:null}clearScores(){try{localStorage.removeItem(T)}catch{}}_loadAll(){try{const t=localStorage.getItem(T);if(!t)return[];const e=JSON.parse(t);return Array.isArray(e)?e.filter(t=>"object"==typeof t&&null!==t&&"number"==typeof t.totalTime&&Number.isFinite(t.totalTime)):[]}catch{return[]}}saveProgress(t){if(this._enabled)try{localStorage.setItem(E,JSON.stringify(t))}catch{}}loadProgress(){if(!this._enabled)return null;try{const t=localStorage.getItem(E);return t?JSON.parse(t):null}catch{return null}}clearProgress(){try{localStorage.removeItem(E)}catch{}}}class C{constructor(t,e,i,n){this._status="active",this._startTime=0,this._breaks=0,this._attempts=0,this._lastBreakNarrativeTime=0,this._narrativeIndex=0,this._bestProgress=0,this._introPlayed=!1,this.config=t,this.script=e,this.input=i,this.bus=n}async start(){this._startTime=Date.now(),this._attempts=1,this.input.resetPhases(),this.input.resetCounts(),this.bus.emit("narrative:clear"),await this._wait(850),this._introPlayed=!1;const t=this.script.stage1Intro;for(let e=0;e<t.length;e++)e===t.length-1?await this._showAndConfirm(t[e]):(this.bus.emit("narrative:show",t[e]),await this._wait(5e3));this.bus.emit("narrative:clear"),await this._wait(1e3),this._introPlayed=!0}update(t){if("complete"===this._status||!this._introPlayed)return this._status;const e=this.config.stageDurations.stillnessMs,i=this.input.stillDuration,n=Math.min(1,i/e);return n>this._bestProgress&&(this._bestProgress=n),this.bus.emit("stage:progress",n),this.input.snapshot.isMoving&&n>.05?(this._handleBreak(),this._status):i>=e?(this._status="complete",this.bus.emit("stage:progress",1),this.bus.emit("egg:reveal",0),this._status):this._status}cleanup(){}getResult(){return{stageTime:Date.now()-this._startTime,attempts:this._attempts,breaks:this._breaks}}_handleBreak(){this._breaks++;const t=Date.now();if(t-this._lastBreakNarrativeTime>6e4){this._lastBreakNarrativeTime=t;const e=this.script.stage1Reactions,i=e[this._narrativeIndex%e.length];this._narrativeIndex++,this.bus.emit("narrative:show",i)}}_wait(t){return new Promise(e=>setTimeout(e,t))}_showAndConfirm(t){return this.bus.emit("narrative:showConfirm",t),new Promise(t=>{const e=()=>{this.bus.off("narrative:confirmed",e),t()};this.bus.on("narrative:confirmed",e)})}}class R{constructor(t,e,i,n){this._status="active",this._startTime=0,this._fades=0,this._attempts=0,this._movingAccum=0,this._lastUpdateTime=0,this._narrativeIndex=0,this._lastFadeNarrativeTime=0,this._introPlayed=!1,this.FADE_THRESHOLD_MS=500,this.config=t,this.script=e,this.input=i,this.bus=n}async start(){this._startTime=Date.now(),this._lastUpdateTime=Date.now(),this._movingAccum=0,this._attempts=1,this.input.resetPhases(),this.input.resetCounts(),this.bus.emit("narrative:clear"),await this._wait(850),this._introPlayed=!1;const t=this.script.stage2Intro;for(let e=0;e<t.length;e++)e===t.length-1?await this._showAndConfirm(t[e]):(this.bus.emit("narrative:show",t[e]),await this._wait(5e3));this.bus.emit("narrative:clear"),await this._wait(1e3),this._lastUpdateTime=Date.now(),this._movingAccum=0,this._introPlayed=!0}update(t){if("complete"===this._status||!this._introPlayed)return this._status;const e=Date.now(),i=e-this._lastUpdateTime;this._lastUpdateTime=e;const n=this.config.stageDurations.motionMs;if(this.input.snapshot.isMoving){this._movingAccum+=i;const t=this.input.snapshot.velocity;if(t>50){const e=Math.max(.15,1-t/1200);Math.random()<e&&this.bus.emit("motion:trail",{x:this.input.snapshot.mouseX,y:this.input.snapshot.mouseY,velocity:t})}}else this.input.stillDuration>this.FADE_THRESHOLD_MS&&this._movingAccum>0&&(this._fades++,this._movingAccum=0,this._handleFade());const s=Math.min(1,this._movingAccum/n);return this.bus.emit("stage:progress",s),this._movingAccum>=n?(this._status="complete",this.bus.emit("stage:progress",1),this.bus.emit("egg:reveal",1),this._status):this._status}cleanup(){}getResult(){return{stageTime:Date.now()-this._startTime,attempts:this._attempts,fades:this._fades}}_handleFade(){const t=Date.now();if(t-this._lastFadeNarrativeTime>6e4){this._lastFadeNarrativeTime=t;const e=this.script.stage2Reactions,i=e[this._narrativeIndex%e.length];this._narrativeIndex++,this.bus.emit("narrative:show",i)}}_wait(t){return new Promise(e=>setTimeout(e,t))}_showAndConfirm(t){return this.bus.emit("narrative:showConfirm",t),new Promise(t=>{const e=()=>{this.bus.off("narrative:confirmed",e),t()};this.bus.on("narrative:confirmed",e)})}}class P{constructor(t,e,i,n){this._status="active",this._startTime=0,this._attempts=0,this._narrativeIndex=0,this._lastNarrativeTime=0,this._introPlayed=!1,this._goodCycles=0,this._totalCycles=0,this._lastPhaseCount=0,this._bestAccuracy=0,this._lastGuideTime=0,this._lastGoodCycleAt=0,this.IDEAL_MOVE_MIN=900,this.IDEAL_MOVE_MAX=4200,this.IDEAL_PAUSE_MIN=600,this.IDEAL_PAUSE_MAX=2800,this.config=t,this.script=e,this.input=i,this.bus=n}async start(){this._startTime=Date.now(),this._attempts=1,this._goodCycles=0,this._totalCycles=0,this.input.configurePhaseDetection({stillThresholdMs:450,minPhaseMs:350}),this.input.resetPhases(),this.input.resetCounts(),this.bus.emit("narrative:clear"),await this._wait(850),this._introPlayed=!1;const t=this.script.stage3Intro;for(let e=0;e<t.length;e++)e===t.length-1?await this._showAndConfirm(t[e]):(this.bus.emit("narrative:show",t[e]),await this._wait(5e3));this.bus.emit("narrative:clear"),await this._wait(1e3),this.input.resetPhases(),this._lastPhaseCount=this.input.phases.length,this._introPlayed=!0,this._lastGuideTime=Date.now()}update(t){if("complete"===this._status||!this._introPlayed)return this._status;const e=this.input.phases,i=this.config.stageDurations.rhythmCycles;for(;this._lastPhaseCount+1<e.length;){const t=e[this._lastPhaseCount],i=e[this._lastPhaseCount+1];if(!t||!i)break;{const e=this._evaluateCycle(t,i);this._totalCycles++,e?(this._goodCycles++,this._lastGoodCycleAt=Date.now()):(this._goodCycles=Math.max(0,this._goodCycles-.5),this._showReaction()),this._lastPhaseCount+=2}}const n=this._totalCycles>0?this._goodCycles/this._totalCycles:0;n>this._bestAccuracy&&(this._bestAccuracy=n);const s=Math.min(1,this._goodCycles/i),r=this._getTargetPhase(),a=this.input.snapshot.isMoving===("move"===r),o=this._lastGoodCycleAt>0?Math.max(0,1-(Date.now()-this._lastGoodCycleAt)/2200):0;return this.bus.emit("stage:progress",s),this.bus.emit("rhythm:breathe",{accuracy:n,isMoving:this.input.snapshot.isMoving,progress:s,moveDuration:this.input.moveDuration,stillDuration:this.input.stillDuration,liveConfidence:this._getLiveConfidence(),targetPhase:r,phaseMatch:a,cycleSignal:o}),0===n&&Date.now()-this._lastGuideTime>12e3&&(this._lastGuideTime=Date.now(),this._showReaction()),this._goodCycles>=i?(this._status="complete",this.bus.emit("stage:progress",1),this.bus.emit("egg:reveal",2),this._status):this._status}cleanup(){this.input.resetPhaseDetection()}getResult(){return{stageTime:Date.now()-this._startTime,attempts:this._attempts,rhythmAccuracy:this._totalCycles>0?Math.round(this._goodCycles/this._totalCycles*100):0}}_evaluateCycle(t,e){const i="move"===t.type?t:"move"===e.type?e:null,n="still"===t.type?t:"still"===e.type?e:null;if(!i||!n)return!1;const s=i.duration>=this.IDEAL_MOVE_MIN&&i.duration<=this.IDEAL_MOVE_MAX,r=n.duration>=this.IDEAL_PAUSE_MIN&&n.duration<=this.IDEAL_PAUSE_MAX;return s&&r}_getLiveConfidence(){return this.input.snapshot.isMoving?this._scoreDuration(this.input.moveDuration,this.IDEAL_MOVE_MIN,this.IDEAL_MOVE_MAX):this._scoreDuration(this.input.stillDuration,this.IDEAL_PAUSE_MIN,this.IDEAL_PAUSE_MAX)}_getTargetPhase(){return this.input.snapshot.isMoving?this.input.moveDuration>=this.IDEAL_MOVE_MIN?"still":"move":this.input.stillDuration>=this.IDEAL_PAUSE_MIN?"move":"still"}_scoreDuration(t,e,i){if(t<=0)return 0;if(t>=e&&t<=i)return 1;const n=Math.max(300,Math.round(.35*(i-e)));return t<e?Math.max(0,1-(e-t)/n):Math.max(0,1-(t-i)/n)}_showReaction(){const t=Date.now();if(t-this._lastNarrativeTime>12e3){this._lastNarrativeTime=t;const e=this.script.stage3Reactions,i=e[this._narrativeIndex%e.length];this._narrativeIndex++,this.bus.emit("narrative:show",i)}}_wait(t){return new Promise(e=>setTimeout(e,t))}_showAndConfirm(t){return this.bus.emit("narrative:showConfirm",t),new Promise(t=>{const e=()=>{this.bus.off("narrative:confirmed",e),t()};this.bus.on("narrative:confirmed",e)})}}class L{constructor(){this._styleEl=null,this._reactClass="eeq-page-react",this._injectStyles()}react(){const t=this._findCandidates();if(!t.length)return;const e=Math.min(t.length,2+Math.floor(2*Math.random())),i=this._pickRandom(t,e),n=["eeq-react-pulse","eeq-react-glow","eeq-react-lift"];for(let s=0;s<i.length;s++){const t=i[s],e=n[Math.floor(Math.random()*n.length)];setTimeout(()=>{t.classList.add(this._reactClass,e),setTimeout(()=>{t.classList.remove(this._reactClass,e)},1100)},200*s)}}destroy(){var t;document.querySelectorAll(`.${this._reactClass}`).forEach(t=>{t.className=t.className.replace(/\beeq-react-\S+/g,"").trim()}),null==(t=this._styleEl)||t.remove(),this._styleEl=null}_findCandidates(){var t;const e=document.querySelectorAll("p, h1, h2, h3, h4, h5, li, a, img, button, blockquote, figcaption, td, th"),i=[];for(const n of e){if(null==(t=n.id)?void 0:t.startsWith("eeq-"))continue;if(n.closest('[id^="eeq-"]'))continue;const e=n.getBoundingClientRect();0!==e.width&&0!==e.height&&(e.bottom<0||e.top>window.innerHeight||n.classList.contains(this._reactClass)||i.push(n))}return i}_pickRandom(t,e){const i=[...t],n=[];for(let s=0;s<e&&i.length;s++){const t=Math.floor(Math.random()*i.length);n.push(i.splice(t,1)[0])}return n}_injectStyles(){this._styleEl=document.createElement("style"),this._styleEl.textContent="\n @keyframes eeq-pulse-kf {\n 0%, 100% { transform: scale(1); }\n 50% { transform: scale(1.018); }\n }\n @keyframes eeq-glow-kf {\n 0%, 100% { filter: brightness(1); }\n 50% { filter: brightness(1.15) saturate(1.1); }\n }\n @keyframes eeq-lift-kf {\n 0%, 100% { transform: translateY(0); }\n 50% { transform: translateY(-2px); }\n }\n .eeq-react-pulse {\n animation: eeq-pulse-kf 1s ease-in-out !important;\n }\n .eeq-react-glow {\n animation: eeq-glow-kf 1s ease-in-out !important;\n }\n .eeq-react-lift {\n animation: eeq-lift-kf 1s ease-in-out !important;\n }\n ",document.head.appendChild(this._styleEl)}}class I{constructor(){this._active=!1,this._intensity=0,this._targetIntensity=0,this._rafId=0,this._overlay=null,this._label=null,this._startTime=0,this._isUserMoving=!1,this._inSync=!1,this._accuracy=0,this._targetPhase="move",this._phaseMatch=!1,this._signal=0,this._tick=()=>{if(!this._active||!this._overlay)return;this._rafId=requestAnimationFrame(this._tick),this._intensity+=.06*(this._targetIntensity-this._intensity);const t=Date.now()-this._startTime,e=.5*(Math.sin(.004*t)+1),i="move"===this._targetPhase;this._inSync=this._phaseMatch&&this._signal>.15;const n=i?.12+.08*e:.32+.18*e,s=this._inSync?.12+.18*this._signal:0,r=this._intensity*(n+s);this._overlay.style.opacity=String(Math.min(.9,r)),this._overlay.style.transform=`scale(${1+e*(i?.01:.02)})`,this._label&&(this._label.textContent=i?"In":"Out",this._label.style.opacity=this._phaseMatch?"0.98":"0.78",this._label.style.boxShadow=this._inSync?"0 0 28px rgba(212,165,80,0.4)":"0 0 20px rgba(255,255,255,0.08)",this._label.style.borderColor=this._inSync?"rgba(212,165,80,0.55)":"rgba(255,255,255,0.12)")}}start(){if(this._active)return;this._active=!0,this._startTime=Date.now();const t=document.createElement("div");t.style.cssText=["position:fixed","top:0","left:0","width:100%","height:100%","pointer-events:none","z-index:999980","opacity:0","background:radial-gradient(ellipse at center, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.02) 24%, rgba(8,12,22,0.18) 46%, rgba(4,6,12,0.82) 100%)","transition:opacity 0.3s ease"].join(";"),document.body.appendChild(t),this._overlay=t;const e=document.createElement("div");e.style.cssText=["position:fixed","left:50%","top:18%","transform:translateX(-50%)","pointer-events:none","z-index:999981","padding:8px 14px","border-radius:999px","font-family:Georgia, Times New Roman, serif","font-size:12px","letter-spacing:0.12em","text-transform:uppercase","color:rgba(255,248,232,0.95)","background:rgba(8,10,18,0.36)","border:1px solid rgba(255,255,255,0.12)","box-shadow:0 0 20px rgba(255,255,255,0.08)","opacity:0.78"].join(";"),e.textContent="In",document.body.appendChild(e),this._label=e,this._tick()}update(t,e,i,n,s){if(!this._active)return;this._isUserMoving=e,this._accuracy=t,this._targetPhase=i,this._phaseMatch=n,this._signal=s;const r=Math.max(0,Math.min(1,Math.max(t,s)/.8));this._targetIntensity=.38+.62*r}isInSync(){return this._inSync}stop(){var t,e;this._active&&(this._active=!1,cancelAnimationFrame(this._rafId),null==(t=this._overlay)||t.remove(),this._overlay=null,null==(e=this._label)||e.remove(),this._label=null,this._intensity=0,this._targetIntensity=0,this._inSync=!1,this._accuracy=0,this._targetPhase="move",this._phaseMatch=!1,this._signal=0)}destroy(){this.stop()}}class D{constructor(t,e){this.bus=new c,this.fsm=new d,this.input=new m,this.scoring=new w,this.hiddenEntry=null,this.narrative=null,this.hud=null,this.shrine=null,this.threeRenderer=null,this.fallbackRenderer=null,this.overlay=null,this.results=null,this.eggRenderer=null,this.activeStage=null,this.pageReactor=null,this._lastPageReactTime=0,this._lastReactProgress=0,this.pageBreather=null,this._updateRaf=0,this._running=!1,this._destroyed=!1,this._onPageHide=()=>this._handlePageClose(),this._tremorStyle=null,this._tremorClass="eeq-tremor",this._lastFrameTime=0,this._gameLoop=()=>{var t;if(!this._running||this._destroyed)return;if(this._updateRaf=requestAnimationFrame(this._gameLoop),this.state.isPaused)return;const e=performance.now(),i=(e-this._lastFrameTime)/1e3;if(this._lastFrameTime=e,this.scoring.analyseFrame(this.input.snapshot),null==(t=this.hud)||t.update(this.state,this.fsm.label),this.activeStage&&"complete"===this.activeStage.update(i)){this._running=!1,cancelAnimationFrame(this._updateRaf);const t=this.fsm.state;"stage1-active"===t?this.fsm.transitionTo("stage1-success"):"stage2-active"===t?this.fsm.transitionTo("stage2-success"):"stage3-active"===t&&this.fsm.transitionTo("stage3-success")}},this.config=t,this.script=e,this.persistence=new A(t.scoring.enableLocal),this.state={stage:"idle",eggsFound:0,startTime:0,stageStartTime:0,isPaused:!1,eggs:[{found:!1},{found:!1},{found:!1}]}}async init(){var t,e;this.fsm.onTransition((t,e)=>this._onTransition(t,e)),this.bus.on("narrative:show",t=>{var e;return null==(e=this.narrative)?void 0:e.showLine(t)}),this.bus.on("narrative:showConfirm",async t=>{var e;await(null==(e=this.narrative)?void 0:e.showLineWithConfirm(t)),this.bus.emit("narrative:confirmed")}),this.bus.on("narrative:clear",()=>{var t;return null==(t=this.narrative)?void 0:t.clear(!0)}),this.bus.on("egg:reveal",t=>this._handleEggReveal(t)),this.bus.on("stage:progress",t=>this._handleStageProgress(t)),this.bus.on("motion:trail",t=>{var e;null==(e=this.eggRenderer)||e.addTrail(t.x,t.y,t.velocity)}),this.bus.on("rhythm:breathe",t=>{var e,i;null==(e=this.eggRenderer)||e.setBreathIntensity(t.accuracy),null==(i=this.pageBreather)||i.update(t.accuracy,t.isMoving,t.targetPhase,t.phaseMatch,Math.max(.55*t.liveConfidence,t.cycleSignal)),t.cycleSignal>.12&&this.threeRenderer?this.threeRenderer.showProgressParticles(.35+.65*Math.max(t.progress,t.cycleSignal),"rhythm"):this.threeRenderer&&this.threeRenderer.fadeOutAmbientParticles()}),this.overlay=new M(this.config),this.overlay.mount(),this.narrative=new _(this.config),this.narrative.mount(),this.shrine=new v(this.config),this.shrine.mount(t=>this._onShrineEggClick(t)),await this._initEggRenderer(),this.threeRenderer&&this.threeRenderer.onCollectEgg(t=>{this._onEggLongPressCollect(t)}),this.scoring.start(),null==(e=(t=this.config.callbacks).onInit)||e.call(t),window.addEventListener("pagehide",this._onPageHide),window.addEventListener("beforeunload",this._onPageHide);const i=this.persistence.loadProgress();i?this._resumeFromCheckpoint(i):this.fsm.transitionTo("entry")}pause(){var t;this.state.isPaused=!0,null==(t=this.hud)||t.pause()}resume(){var t;this.state.isPaused=!1,null==(t=this.hud)||t.resume()}async restart(){this._cleanup(),this.fsm.reset(),this.persistence.clearProgress(),this.state={stage:"idle",eggsFound:0,startTime:0,stageStartTime:0,isPaused:!1,eggs:[{found:!1},{found:!1},{found:!1}]},this.scoring.start(),this.fsm.transitionTo("entry")}destroy(){var t,e,i,n,s,r,a,o,l,h,c;this._destroyed=!0,window.removeEventListener("pagehide",this._onPageHide),window.removeEventListener("beforeunload",this._onPageHide),this._cleanup(),null==(t=this.narrative)||t.destroy(),null==(e=this.hud)||e.destroy(),null==(i=this.shrine)||i.destroy(),null==(n=this.threeRenderer)||n.destroy(),null==(s=this.fallbackRenderer)||s.destroy(),null==(r=this.overlay)||r.destroy(),null==(a=this.results)||a.destroy(),this._stopAnticipationTremor(),null==(o=this.pageReactor)||o.destroy(),this.pageReactor=null,null==(l=this.pageBreather)||l.destroy(),this.pageBreather=null,this.input.stop(),this.bus.clear(),this.fsm.reset(),null==(c=(h=this.config.callbacks).onDestroy)||c.call(h)}_handlePageClose(){if(this._destroyed)return;const t=this.fsm.state;"idle"!==t&&"entry"!==t&&"results"!==t&&"complete"!==t&&this._saveCheckpoint(t),this.destroy()}async _onTransition(t,e){var i;switch(this.state.stage=e,this.state.stageStartTime=Date.now(),null==(i=this.hud)||i.update(this.state,this.fsm.label),["stage1-intro","stage2-intro","stage3-intro","finale"].includes(e)&&this._saveCheckpoint(e),e){case"entry":await this._startEntry();break;case"stage1-intro":await this._startStage1();break;case"stage1-active":case"stage2-active":case"stage3-active":this._startGameLoop();break;case"stage1-success":await this._handleStageSuccess(0);break;case"stage2-intro":await this._startStage2();break;case"stage2-success":await this._handleStageSuccess(1);break;case"stage3-intro":await this._startStage3();break;case"stage3-success":await this._handleStageSuccess(2);break;case"finale":await this._startFinale();break;case"results":this._showResults()}}_saveCheckpoint(t){this.persistence.saveProgress({stage:t,eggsFound:this.state.eggsFound,eggsState:[this.state.eggs[0].found,this.state.eggs[1].found,this.state.eggs[2].found],savedAt:Date.now()})}_resumeFromCheckpoint(t){var e,i;if(!["stage1-intro","stage2-intro","stage3-intro","finale"].includes(t.stage))return this.persistence.clearProgress(),void this.fsm.transitionTo("entry");this.state.eggsFound=t.eggsFound,this.state.startTime=Date.now();for(let n=0;n<3;n++)this.state.eggs[n].found=t.eggsState[n];null==(e=this.shrine)||e.show();for(let n=0;n<t.eggsFound;n++)null==(i=this.shrine)||i.fillSlot(n);this.fsm.forceState(t.stage),this._onTransition("idle",t.stage)}async _startEntry(){var t;try{if("1"===localStorage.getItem("eeq_optout"))return}catch{}this.state.startTime=Date.now(),null==(t=this.hud)||t.startTimer(),this.hiddenEntry=new g(this.config,this.script,()=>{var t,e;this.scoring.recordEntryFound(),null==(e=(t=this.config.callbacks).onEntryFound)||e.call(t),this._onEntryFound()}),this.hiddenEntry.start()}async _onEntryFound(){var t,e,i,n;null==(t=this.hiddenEntry)||t.cleanup(),this.hiddenEntry=null,this._startAnticipationTremor(),null==(e=this.shrine)||e.show(),await(null==(i=this.narrative)?void 0:i.showSequence(this.script.entryConfirmation,4200)),null==(n=this.narrative)||n.clear(),this._stopAnticipationTremor(),await this._wait(800),this.input.start(),this.fsm.transitionTo("stage1-intro")}_startAnticipationTremor(){this._tremorStyle=document.createElement("style"),this._tremorStyle.textContent=`\n @keyframes eeq-tremor {\n 0%, 100% { transform: translate(0, 0); }\n 10% { transform: translate(-0.5px, 0.3px); }\n 20% { transform: translate(0.6px, -0.4px); }\n 30% { transform: translate(-0.3px, 0.5px); }\n 40% { transform: translate(0.4px, 0.2px); }\n 50% { transform: translate(-0.4px, -0.3px); }\n 60% { transform: translate(0.3px, 0.5px); }\n 70% { transform: translate(-0.5px, -0.2px); }\n 80% { transform: translate(0.2px, 0.4px); }\n 90% { transform: translate(-0.3px, -0.5px); }\n }\n .${this._tremorClass} {\n animation: eeq-tremor 0.6s ease-in-out infinite !important;\n }\n `,document.head.appendChild(this._tremorStyle),document.querySelectorAll('a, button, span, small, label, svg, img, i, [role="button"], nav li').forEach(t=>{var e;const i=t.getBoundingClientRect();if(i.width>300||i.height>100)return;if(0===i.width||0===i.height)return;if(i.bottom<0||i.top>window.innerHeight)return;if(null==(e=t.id)?void 0:e.startsWith("eeq-"))return;if(t.closest('[id^="eeq-"]'))return;const n=800*Math.random(),s=t;setTimeout(()=>{this._tremorStyle&&s.classList.add(this._tremorClass)},n)})}_stopAnticipationTremor(){var t;document.querySelectorAll(`.${this._tremorClass}`).forEach(t=>{t.classList.remove(this._tremorClass)}),null==(t=this._tremorStyle)||t.remove(),this._tremorStyle=null}async _startStage1(){var t,e,i,n;null==(e=(t=this.config.callbacks).onStageStart)||e.call(t,"stage1-intro"),null==(i=this.hud)||i.update(this.state,this.fsm.label),null==(n=this.eggRenderer)||n.startRenderLoop();const s=new C(this.config,this.script,this.input,this.bus);this.activeStage=s,await s.start(),this.fsm.transitionTo("stage1-active")}async _startStage2(){var t,e,i;null==(e=(t=this.config.callbacks).onStageStart)||e.call(t,"stage2-intro"),null==(i=this.hud)||i.update(this.state,this.fsm.label);const n=new R(this.config,this.script,this.input,this.bus);this.activeStage=n,await n.start(),this.fsm.transitionTo("stage2-active")}async _startStage3(){var t,e,i;null==(e=(t=this.config.callbacks).onStageStart)||e.call(t,"stage3-intro"),null==(i=this.hud)||i.update(this.state,this.fsm.label);const n=new P(this.config,this.script,this.input,this.bus);this.activeStage=n,await n.start(),this.fsm.transitionTo("stage3-active"),this.pageBreather=new I,this.pageBreather.start()}_startGameLoop(){this._running||(this._running=!0,this._lastFrameTime=performance.now(),this._gameLoop())}_handleEggReveal(t){var e,i,n,s;this.state.eggs[t].found=!0,this.state.eggs[t].foundTime=Date.now(),this.state.eggsFound++,null==(e=this.eggRenderer)||e.revealEgg(t),null==(i=this.hud)||i.flashEggFound(t),null==(s=(n=this.config.callbacks).onEggFound)||s.call(n,t)}async _handleStageSuccess(t){var e,i,n,s,r,a,o;if(this.activeStage){const t=this.activeStage.getResult();this.scoring.recordStageResult(t),this.activeStage.cleanup(),this.activeStage=null,null==(i=(e=this.config.callbacks).onStageComplete)||i.call(e,this.fsm.state,t)}const l=0===t?this.script.stage1Success:1===t?this.script.stage2Success:this.script.stage3Success;await(null==(n=this.narrative)?void 0:n.showSequence(l,4500)),await this._wait(3e3),null==(s=this.narrative)||s.clear(),await this._wait(800),this.threeRenderer?this.threeRenderer.enableInteraction(t):(null==(r=this.eggRenderer)||r.collectEgg(t),null==(a=this.shrine)||a.fillSlot(t),await this._wait(1500),t<2?null==(o=this.shrine)||o.activateSlot(t):(await this._wait(1e3),this.fsm.transitionTo("finale")))}_onShrineEggClick(t){var e;null==(e=this.shrine)||e.deactivateSlot(t),0===t?this.fsm.transitionTo("stage2-intro"):1===t&&this.fsm.transitionTo("stage3-intro")}async _onEggLongPressCollect(t){var e,i,n,s,r;null==(e=this.eggRenderer)||e.collectEgg(t),null==(i=this.shrine)||i.fillSlot(t),2===t&&(null==(n=this.pageBreather)||n.destroy(),this.pageBreather=null),null==(s=this.narrative)||s.showCelebration(["egg found — well done","another one — you're getting closer","all three — remarkable"][t]??"egg collected"),await this._wait(3500),null==(r=this.narrative)||r.clear(),await this._wait(900),t<2?0===t?this.fsm.transitionTo("stage2-intro"):this.fsm.transitionTo("stage3-intro"):(await this._wait(800),this.fsm.transitionTo("finale"))}_handleStageProgress(t){const e=this.fsm.state;this.threeRenderer&&"stage3-active"!==e&&this.threeRenderer.showProgressParticles(t);const i=Date.now();t>this._lastReactProgress+.03&&i-this._lastPageReactTime>8e3&&(this._lastPageReactTime=i,this._lastReactProgress=t,this.pageReactor||(this.pageReactor=new L),this.pageReactor.react()),t<this._lastReactProgress-.1&&(this._lastReactProgress=t)}async _startFinale(){var t,e,i,n,s,r;null==(e=(t=this.config.callbacks).onFinaleStart)||e.call(t),null==(i=this.shrine)||i.hideAll(),await this._wait(1e3),null==(n=this.eggRenderer)||n.startFinale(),await(null==(s=this.narrative)?void 0:s.showSequence(this.script.finale,5e3)),null==(r=this.narrative)||r.clear(),await this._wait(4e3),this.fsm.transitionTo("results")}_showResults(){var t,e,i;const n=this.input.snapshot,s=this.scoring.computeFinalScore({totalClicks:n.totalClicks,totalScrolls:n.totalScrolls,totalKeyPresses:n.totalKeyPresses,totalDistance:n.totalDistance,maxVelocity:n.maxVelocity});this.threeRenderer&&this.threeRenderer.setFestiveEggSeed(s.eggSeed),this.persistence.saveScore(s),this.persistence.clearProgress(),this.config.scoring.leaderboardAdapter&&this.config.scoring.leaderboardAdapter.submitScore(s).catch(()=>{}),null==(t=this.eggRenderer)||t.stopRenderLoop(),this.results=new S(this.config),this.results.show(s,()=>{this.destroy()}),null==(i=(e=this.config.callbacks).onComplete)||i.call(e,s)}async _initEggRenderer(){const t=this.config.renderer;if("3d"===t||"auto"===t){if(this.threeRenderer=new y(this.config),await this.threeRenderer.init())return void(this.eggRenderer=this.threeRenderer);this.threeRenderer=null}this.fallbackRenderer=new x(this.config),await this.fallbackRenderer.init(),this.eggRenderer=this.fallbackRenderer}_cleanup(){var t,e,i,n,s,r,a,o;this._running=!1,this._updateRaf&&cancelAnimationFrame(this._updateRaf),null==(t=this.hiddenEntry)||t.cleanup(),null==(e=this.activeStage)||e.cleanup(),this.activeStage=null,null==(i=this.shrine)||i.reset(),null==(n=this.narrative)||n.clear(),null==(s=this.overlay)||s.hide(),this._lastPageReactTime=0,this._lastReactProgress=0,this._stopAnticipationTremor(),null==(r=this.pageReactor)||r.destroy(),this.pageReactor=null,null==(a=this.pageBreather)||a.destroy(),this.pageBreather=null,null==(o=this.results)||o.destroy(),this.results=null,this.threeRenderer&&this.threeRenderer.resetForRestart()}_wait(t){return new Promise(e=>setTimeout(e,t))}}let N=null;const U={async init(t={}){N&&(N.destroy(),N=null);const e=function(t={}){var e,i,n,r,c,u,d,p,m,f,g,_,v,y,x,M,b,S;const w="undefined"!=typeof window&&(null==(e=window.matchMedia)?void 0:e.call(window,"(prefers-reduced-motion: reduce)").matches);return{theme:function(t){if(!t||"auto"===t||"light"===t||"dark"===t)return{...s};const e=["overlayBg","textColor","textSecondary","accent","accentGlow","hudBg","hudText"],i={};for(const n of e)n in t&&"string"==typeof t[n]&&(i[n]=t[n]);return{...s,...i}}(t.theme),hiddenEntry:{mode:(null==(i=t.hiddenEntry)?void 0:i.mode)??"auto",selector:h(null==(n=t.hiddenEntry)?void 0:n.selector),excludeSelectors:[...a,...((null==(r=t.hiddenEntry)?void 0:r.excludeSelectors)??[]).filter(t=>"string"==typeof t&&t.length<200)]},hud:"boolean"==typeof t.hud?{enabled:t.hud,position:"top-left"}:{enabled:(null==(c=t.hud)?void 0:c.enabled)??!0,position:(null==(u=t.hud)?void 0:u.position)??"top-left"},shrine:"boolean"==typeof t.shrine?{enabled:t.shrine,position:"bottom-right"}:{enabled:(null==(d=t.shrine)?void 0:d.enabled)??!0,position:(null==(p=t.shrine)?void 0:p.position)??"bottom-right"},sounds:t.sounds??!1,stageDurations:{stillnessMs:o(null==(m=t.stageDurations)?void 0:m.stillnessMs,2e4),motionMs:o(null==(f=t.stageDurations)?void 0:f.motionMs,2e4),rhythmCycles:l(null==(g=t.stageDurations)?void 0:g.rhythmCycles,3,1,50)},renderer:t.renderer??"auto",scoring:{enableLocal:(null==(_=t.scoring)?void 0:_.enableLocal)??!0,leaderboardAdapter:null==(v=t.scoring)?void 0:v.leaderboardAdapter},accessibility:{reducedMotion:"auto"===(null==(y=t.accessibility)?void 0:y.reducedMotion)?w:(null==(x=t.accessibility)?void 0:x.reducedMotion)??w,highContrast:(null==(M=t.accessibility)?void 0:M.highContrast)??!1,disableHiddenEntry:(null==(b=t.accessibility)?void 0:b.disableHiddenEntry)??!1,subtitlesLog:(null==(S=t.accessibility)?void 0:S.subtitlesLog)??!1},callbacks:t.callbacks??{}}}(t),i=(r=t.narrative)?{...n,...r}:{...n};var r;N=new D(e,i),await N.init()},pause(){null==N||N.pause()},resume(){null==N||N.resume()},async restart(){await(null==N?void 0:N.restart())},destroy(){null==N||N.destroy(),N=null}};if("undefined"!=typeof window&&"undefined"!=typeof document&&(void 0!==globalThis.EasterEggQuest||(null==(i=null==(e=document.currentScript)?void 0:e.getAttribute("src"))?void 0:i.includes("easter-egg-quest")))){const t=()=>U.init();"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}const O="160",F=0,B=1,z=2,k=100,V=101,G=102,H=200,W=201,q=202,X=203,j=204,Y=205,Z=206,J=207,K=208,$=209,Q=210,tt=211,et=212,it=213,nt=214,st="attached",rt="detached",at=300,ot=301,lt=302,ht=303,ct=304,ut=306,dt=1e3,pt=1001,mt=1002,ft=1003,gt=1004,_t=1005,vt=1006,yt=1007,xt=1008,Mt=1009,bt=1012,St=1013,wt=1014,Tt=1015,Et=1016,At=1017,Ct=1018,Rt=1020,Pt=1023,Lt=1026,It=1027,Dt=1029,Nt=1031,Ut=1033,Ot=33776,Ft=33777,Bt=33778,zt=33779,kt=35840,Vt=35841,Gt=35842,Ht=35843,Wt=36196,qt=37492,Xt=37496,jt=37808,Yt=37809,Zt=37810,Jt=37811,Kt=37812,$t=37813,Qt=37814,te=37815,ee=37816,ie=37817,ne=37818,se=37819,re=37820,ae=37821,oe=36492,le=36494,he=36495,ce=36284,ue=36285,de=36286,pe=2300,me=2301,fe=2302,ge=2400,_e=2401,ve=2402,ye=2501,xe=3e3,Me=3001,be="",Se="srgb",we="srgb-linear",Te="display-p3",Ee="display-p3-linear",Ae="linear",Ce="srgb",Re="rec709",Pe="p3",Le=7680,Ie=512,De=513,Ne=514,Ue=515,Oe=516,Fe=517,Be=518,ze=519,ke=35044,Ve="300 es",Ge=1035,He=2e3,We=2001;class qe{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const i=this._listeners;void 0===i[t]&&(i[t]=[]),-1===i[t].indexOf(e)&&i[t].push(e)}hasEventListener(t,e){if(void 0===this._listeners)return!1;const i=this._listeners;return void 0!==i[t]&&-1!==i[t].indexOf(e)}removeEventListener(t,e){if(void 0===this._listeners)return;const i=this._listeners[t];if(void 0!==i){const t=i.indexOf(e);-1!==t&&i.splice(t,1)}}dispatchEvent(t){if(void 0===this._listeners)return;const e=this._listeners[t.type];if(void 0!==e){t.target=this;const i=e.slice(0);for(let e=0,n=i.length;e<n;e++)i[e].call(this,t);t.target=null}}}const Xe=["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 je=1234567;const Ye=Math.PI/180,Ze=180/Math.PI;function Je(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,i=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return(Xe[255&t]+Xe[t>>8&255]+Xe[t>>16&255]+Xe[t>>24&255]+"-"+Xe[255&e]+Xe[e>>8&255]+"-"+Xe[e>>16&15|64]+Xe[e>>24&255]+"-"+Xe[63&i|128]+Xe[i>>8&255]+"-"+Xe[i>>16&255]+Xe[i>>24&255]+Xe[255&n]+Xe[n>>8&255]+Xe[n>>16&255]+Xe[n>>24&255]).toLowerCase()}function Ke(t,e,i){return Math.max(e,Math.min(i,t))}function $e(t,e){return(t%e+e)%e}function Qe(t,e,i){return(1-i)*t+i*e}function ti(t){return!(t&t-1)&&0!==t}function ei(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function ii(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function ni(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}const si={DEG2RAD:Ye,RAD2DEG:Ze,generateUUID:Je,clamp:Ke,euclideanModulo:$e,mapLinear:(t,e,i,n,s)=>n+(t-e)*(s-n)/(i-e),inverseLerp:(t,e,i)=>t!==e?(i-t)/(e-t):0,lerp:Qe,damp:(t,e,i,n)=>Qe(t,e,1-Math.exp(-i*n)),pingpong:(t,e=1)=>e-Math.abs($e(t,2*e)-e),smoothstep:(t,e,i)=>t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t),smootherstep:(t,e,i)=>t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*t*(t*(6*t-15)+10),randInt:(t,e)=>t+Math.floor(Math.random()*(e-t+1)),randFloat:(t,e)=>t+Math.random()*(e-t),randFloatSpread:t=>t*(.5-Math.random()),seededRandom(t){void 0!==t&&(je=t);let e=je+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296},degToRad:t=>t*Ye,radToDeg:t=>t*Ze,isPowerOfTwo:ti,ceilPowerOfTwo:t=>Math.pow(2,Math.ceil(Math.log(t)/Math.LN2)),floorPowerOfTwo:ei,setQuaternionFromProperEuler(t,e,i,n,s){const r=Math.cos,a=Math.sin,o=r(i/2),l=a(i/2),h=r((e+n)/2),c=a((e+n)/2),u=r((e-n)/2),d=a((e-n)/2),p=r((n-e)/2),m=a((n-e)/2);switch(s){case"XYX":t.set(o*c,l*u,l*d,o*h);break;case"YZY":t.set(l*d,o*c,l*u,o*h);break;case"ZXZ":t.set(l*u,l*d,o*c,o*h);break;case"XZX":t.set(o*c,l*m,l*p,o*h);break;case"YXY":t.set(l*p,o*c,l*m,o*h);break;case"ZYZ":t.set(l*m,l*p,o*c,o*h)}},normalize:ni,denormalize:ii};class ri{constructor(t=0,e=0){ri.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,i=this.y,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[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 i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}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(0===e)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(Ke(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,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 i=Math.cos(e),n=Math.sin(e),s=this.x-t.x,r=this.y-t.y;return this.x=s*i-r*n+t.x,this.y=s*n+r*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ai{constructor(t,e,i,n,s,r,a,o,l){ai.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,i,n,s,r,a,o,l)}set(t,e,i,n,s,r,a,o,l){const h=this.elements;return h[0]=t,h[1]=n,h[2]=a,h[3]=e,h[4]=s,h[5]=o,h[6]=i,h[7]=r,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.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 i=t.elements,n=e.elements,s=this.elements,r=i[0],a=i[3],o=i[6],l=i[1],h=i[4],c=i[7],u=i[2],d=i[5],p=i[8],m=n[0],f=n[3],g=n[6],_=n[1],v=n[4],y=n[7],x=n[2],M=n[5],b=n[8];return s[0]=r*m+a*_+o*x,s[3]=r*f+a*v+o*M,s[6]=r*g+a*y+o*b,s[1]=l*m+h*_+c*x,s[4]=l*f+h*v+c*M,s[7]=l*g+h*y+c*b,s[2]=u*m+d*_+p*x,s[5]=u*f+d*v+p*M,s[8]=u*g+d*y+p*b,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],i=t[1],n=t[2],s=t[3],r=t[4],a=t[5],o=t[6],l=t[7],h=t[8];return e*r*h-e*a*l-i*s*h+i*a*o+n*s*l-n*r*o}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],a=t[5],o=t[6],l=t[7],h=t[8],c=h*r-a*l,u=a*o-h*s,d=l*s-r*o,p=e*c+i*u+n*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return t[0]=c*m,t[1]=(n*l-h*i)*m,t[2]=(a*i-n*r)*m,t[3]=u*m,t[4]=(h*e-n*o)*m,t[5]=(n*s-a*e)*m,t[6]=d*m,t[7]=(i*o-l*e)*m,t[8]=(r*e-i*s)*m,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,i,n,s,r,a){const o=Math.cos(s),l=Math.sin(s);return this.set(i*o,i*l,-i*(o*r+l*a)+r+t,-n*l,n*o,-n*(-l*r+o*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(oi.makeScale(t,e)),this}rotate(t){return this.premultiply(oi.makeRotation(-t)),this}translate(t,e){return this.premultiply(oi.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),i=Math.sin(t);return this.set(e,-i,0,i,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,i=t.elements;for(let n=0;n<9;n++)if(e[n]!==i[n])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const oi=new ai;function li(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}const hi={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function ci(t,e){return new hi[t](e)}function ui(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function di(){const t=ui("canvas");return t.style.display="block",t}const pi={};function mi(t){t in pi||(pi[t]=!0)}const fi=(new ai).set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),gi=(new ai).set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),_i={[we]:{transfer:Ae,primaries:Re,toReference:t=>t,fromReference:t=>t},[Se]:{transfer:Ce,primaries:Re,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[Ee]:{transfer:Ae,primaries:Pe,toReference:t=>t.applyMatrix3(gi),fromReference:t=>t.applyMatrix3(fi)},[Te]:{transfer:Ce,primaries:Pe,toReference:t=>t.convertSRGBToLinear().applyMatrix3(gi),fromReference:t=>t.applyMatrix3(fi).convertLinearToSRGB()}},vi=new Set([we,Ee]),yi={enabled:!0,_workingColorSpace:we,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(t){if(!vi.has(t))throw new Error(`Unsupported working color space, "${t}".`);this._workingColorSpace=t},convert(t,e,i){if(!1===this.enabled||e===i||!e||!i)return t;const n=_i[e].toReference;return(0,_i[i].fromReference)(n(t))},fromWorkingColorSpace(t,e){return this.convert(t,this._workingColorSpace,e)},toWorkingColorSpace(t,e){return this.convert(t,e,this._workingColorSpace)},getPrimaries:t=>_i[t].primaries,getTransfer:t=>t===be?Ae:_i[t].transfer};function xi(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function Mi(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}let bi;class Si{static getDataURL(t){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===bi&&(bi=ui("canvas")),bi.width=t.width,bi.height=t.height;const i=bi.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),e=bi}return e.width>2048||e.height>2048?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}static sRGBToLinear(t){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=ui("canvas");e.width=t.width,e.height=t.height;const i=e.getContext("2d");i.drawImage(t,0,0,t.width,t.height);const n=i.getImageData(0,0,t.width,t.height),s=n.data;for(let t=0;t<s.length;t++)s[t]=255*xi(s[t]/255);return i.putImageData(n,0,0),e}if(t.data){const e=t.data.slice(0);for(let t=0;t<e.length;t++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[t]=Math.floor(255*xi(e[t]/255)):e[t]=xi(e[t]);return{data:e,width:t.width,height:t.height}}return t}}let wi=0;class Ti{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:wi++}),this.uuid=Je(),this.data=t,this.version=0}set needsUpdate(t){!0===t&&this.version++}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.images[this.uuid])return t.images[this.uuid];const i={uuid:this.uuid,url:""},n=this.data;if(null!==n){let t;if(Array.isArray(n)){t=[];for(let e=0,i=n.length;e<i;e++)n[e].isDataTexture?t.push(Ei(n[e].image)):t.push(Ei(n[e]))}else t=Ei(n);i.url=t}return e||(t.images[this.uuid]=i),i}}function Ei(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?Si.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:{}}let Ai=0;class Ci extends qe{constructor(t=Ci.DEFAULT_IMAGE,e=Ci.DEFAULT_MAPPING,i=1001,n=1001,s=1006,r=1008,a=1023,o=1009,l=Ci.DEFAULT_ANISOTROPY,h=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Ai++}),this.uuid=Je(),this.name="",this.source=new Ti(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=s,this.minFilter=r,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=o,this.offset=new ri(0,0),this.repeat=new ri(1,1),this.center=new ri(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ai,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,"string"==typeof h?this.colorSpace=h:(mi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=h===Me?Se:be),this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}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=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const i={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&&(i.userData=this.userData),e||(t.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==at)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case dt:t.x=t.x-Math.floor(t.x);break;case pt:t.x=t.x<0?0:1;break;case mt:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case dt:t.y=t.y-Math.floor(t.y);break;case pt:t.y=t.y<0?0:1;break;case mt:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return mi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Se?Me:xe}set encoding(t){mi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=t===Me?Se:be}}Ci.DEFAULT_IMAGE=null,Ci.DEFAULT_MAPPING=at,Ci.DEFAULT_ANISOTROPY=1;class Ri{constructor(t=0,e=0,i=0,n=1){Ri.prototype.isVector4=!0,this.x=t,this.y=e,this.z=i,this.w=n}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,i,n){return this.x=t,this.y=e,this.z=i,this.w=n,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=void 0!==t.w?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,i=this.y,n=this.z,s=this.w,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*n+r[12]*s,this.y=r[1]*e+r[5]*i+r[9]*n+r[13]*s,this.z=r[2]*e+r[6]*i+r[10]*n+r[14]*s,this.w=r[3]*e+r[7]*i+r[11]*n+r[15]*s,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,i,n,s;const r=.01,a=.1,o=t.elements,l=o[0],h=o[4],c=o[8],u=o[1],d=o[5],p=o[9],m=o[2],f=o[6],g=o[10];if(Math.abs(h-u)<r&&Math.abs(c-m)<r&&Math.abs(p-f)<r){if(Math.abs(h+u)<a&&Math.abs(c+m)<a&&Math.abs(p+f)<a&&Math.abs(l+d+g-3)<a)return this.set(1,0,0,0),this;e=Math.PI;const t=(l+1)/2,o=(d+1)/2,_=(g+1)/2,v=(h+u)/4,y=(c+m)/4,x=(p+f)/4;return t>o&&t>_?t<r?(i=0,n=.707106781,s=.707106781):(i=Math.sqrt(t),n=v/i,s=y/i):o>_?o<r?(i=.707106781,n=0,s=.707106781):(n=Math.sqrt(o),i=v/n,s=x/n):_<r?(i=.707106781,n=.707106781,s=0):(s=Math.sqrt(_),i=y/s,n=x/s),this.set(i,n,s,e),this}let _=Math.sqrt((f-p)*(f-p)+(c-m)*(c-m)+(u-h)*(u-h));return Math.abs(_)<.001&&(_=1),this.x=(f-p)/_,this.y=(c-m)/_,this.z=(u-h)/_,this.w=Math.acos((l+d+g-1)/2),this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this.w=t.w+(e.w-t.w)*i,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 Pi extends qe{constructor(t=1,e=1,i={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new Ri(0,0,t,e),this.scissorTest=!1,this.viewport=new Ri(0,0,t,e);const n={width:t,height:e,depth:1};void 0!==i.encoding&&(mi("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),i.colorSpace=i.encoding===Me?Se:be),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:vt,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},i),this.texture=new Ci(n,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=i.generateMipmaps,this.texture.internalFormat=i.internalFormat,this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.depthTexture=i.depthTexture,this.samples=i.samples}setSize(t,e,i=1){this.width===t&&this.height===e&&this.depth===i||(this.width=t,this.height=e,this.depth=i,this.texture.image.width=t,this.texture.image.height=e,this.texture.image.depth=i,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.texture=t.texture.clone(),this.texture.isRenderTargetTexture=!0;const e=Object.assign({},t.texture.image);return this.texture.source=new Ti(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,null!==t.depthTexture&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Li extends Pi{constructor(t=1,e=1,i={}){super(t,e,i),this.isWebGLRenderTarget=!0}}class Ii extends Ci{constructor(t=null,e=1,i=1,n=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:i,depth:n},this.magFilter=ft,this.minFilter=ft,this.wrapR=pt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Di extends Ci{constructor(t=null,e=1,i=1,n=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:i,depth:n},this.magFilter=ft,this.minFilter=ft,this.wrapR=pt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ni{constructor(t=0,e=0,i=0,n=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=i,this._w=n}static slerpFlat(t,e,i,n,s,r,a){let o=i[n+0],l=i[n+1],h=i[n+2],c=i[n+3];const u=s[r+0],d=s[r+1],p=s[r+2],m=s[r+3];if(0===a)return t[e+0]=o,t[e+1]=l,t[e+2]=h,void(t[e+3]=c);if(1===a)return t[e+0]=u,t[e+1]=d,t[e+2]=p,void(t[e+3]=m);if(c!==m||o!==u||l!==d||h!==p){let t=1-a;const e=o*u+l*d+h*p+c*m,i=e>=0?1:-1,n=1-e*e;if(n>Number.EPSILON){const s=Math.sqrt(n),r=Math.atan2(s,e*i);t=Math.sin(t*r)/s,a=Math.sin(a*r)/s}const s=a*i;if(o=o*t+u*s,l=l*t+d*s,h=h*t+p*s,c=c*t+m*s,t===1-a){const t=1/Math.sqrt(o*o+l*l+h*h+c*c);o*=t,l*=t,h*=t,c*=t}}t[e]=o,t[e+1]=l,t[e+2]=h,t[e+3]=c}static multiplyQuaternionsFlat(t,e,i,n,s,r){const a=i[n],o=i[n+1],l=i[n+2],h=i[n+3],c=s[r],u=s[r+1],d=s[r+2],p=s[r+3];return t[e]=a*p+h*c+o*d-l*u,t[e+1]=o*p+h*u+l*c-a*d,t[e+2]=l*p+h*d+a*u-o*c,t[e+3]=h*p-a*c-o*u-l*d,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,i,n){return this._x=t,this._y=e,this._z=i,this._w=n,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 i=t._x,n=t._y,s=t._z,r=t._order,a=Math.cos,o=Math.sin,l=a(i/2),h=a(n/2),c=a(s/2),u=o(i/2),d=o(n/2),p=o(s/2);switch(r){case"XYZ":this._x=u*h*c+l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c-u*d*p;break;case"YXZ":this._x=u*h*c+l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c+u*d*p;break;case"ZXY":this._x=u*h*c-l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c-u*d*p;break;case"ZYX":this._x=u*h*c-l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c+u*d*p;break;case"YZX":this._x=u*h*c+l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c-u*d*p;break;case"XZY":this._x=u*h*c-l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c+u*d*p}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,n=Math.sin(i);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],n=e[4],s=e[8],r=e[1],a=e[5],o=e[9],l=e[2],h=e[6],c=e[10],u=i+a+c;if(u>0){const t=.5/Math.sqrt(u+1);this._w=.25/t,this._x=(h-o)*t,this._y=(s-l)*t,this._z=(r-n)*t}else if(i>a&&i>c){const t=2*Math.sqrt(1+i-a-c);this._w=(h-o)/t,this._x=.25*t,this._y=(n+r)/t,this._z=(s+l)/t}else if(a>c){const t=2*Math.sqrt(1+a-i-c);this._w=(s-l)/t,this._x=(n+r)/t,this._y=.25*t,this._z=(o+h)/t}else{const t=2*Math.sqrt(1+c-i-a);this._w=(r-n)/t,this._x=(s+l)/t,this._y=(o+h)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<Number.EPSILON?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(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=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Ke(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(0===i)return this;const n=Math.min(1,e/i);return this.slerp(t,n),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 0===t?(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 i=t._x,n=t._y,s=t._z,r=t._w,a=e._x,o=e._y,l=e._z,h=e._w;return this._x=i*h+r*a+n*l-s*o,this._y=n*h+r*o+s*a-i*l,this._z=s*h+r*l+i*o-n*a,this._w=r*h-i*a-n*o-s*l,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const i=this._x,n=this._y,s=this._z,r=this._w;let a=r*t._w+i*t._x+n*t._y+s*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=r,this._x=i,this._y=n,this._z=s,this;const o=1-a*a;if(o<=Number.EPSILON){const t=1-e;return this._w=t*r+e*this._w,this._x=t*i+e*this._x,this._y=t*n+e*this._y,this._z=t*s+e*this._z,this.normalize(),this}const l=Math.sqrt(o),h=Math.atan2(l,a),c=Math.sin((1-e)*h)/l,u=Math.sin(e*h)/l;return this._w=r*c+this._w*u,this._x=i*c+this._x*u,this._y=n*c+this._y*u,this._z=s*c+this._z*u,this._onChangeCallback(),this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=Math.random(),e=Math.sqrt(1-t),i=Math.sqrt(t),n=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(e*Math.cos(n),i*Math.sin(s),i*Math.cos(s),e*Math.sin(n))}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 Ui{constructor(t=0,e=0,i=0){Ui.prototype.isVector3=!0,this.x=t,this.y=e,this.z=i}set(t,e,i){return void 0===i&&(i=this.z),this.x=t,this.y=e,this.z=i,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(Fi.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Fi.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,n=this.z,s=t.elements;return this.x=s[0]*e+s[3]*i+s[6]*n,this.y=s[1]*e+s[4]*i+s[7]*n,this.z=s[2]*e+s[5]*i+s[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,s=t.elements,r=1/(s[3]*e+s[7]*i+s[11]*n+s[15]);return this.x=(s[0]*e+s[4]*i+s[8]*n+s[12])*r,this.y=(s[1]*e+s[5]*i+s[9]*n+s[13])*r,this.z=(s[2]*e+s[6]*i+s[10]*n+s[14])*r,this}applyQuaternion(t){const e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,a=t.z,o=t.w,l=2*(r*n-a*i),h=2*(a*e-s*n),c=2*(s*i-r*e);return this.x=e+o*l+r*c-a*h,this.y=i+o*h+a*l-s*c,this.z=n+o*c+s*h-r*l,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,i=this.y,n=this.z,s=t.elements;return this.x=s[0]*e+s[4]*i+s[8]*n,this.y=s[1]*e+s[5]*i+s[9]*n,this.z=s[2]*e+s[6]*i+s[10]*n,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 i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,n=t.y,s=t.z,r=e.x,a=e.y,o=e.z;return this.x=n*o-s*a,this.y=s*r-i*o,this.z=i*a-n*r,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return Oi.copy(this).projectOnVector(t),this.sub(Oi)}reflect(t){return this.sub(Oi.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(Ke(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return e*e+i*i+n*n}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,i){const n=Math.sin(e)*t;return this.x=n*Math.sin(i),this.y=Math.cos(e)*t,this.z=n*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,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(),i=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=n,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}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=2*(Math.random()-.5),e=Math.random()*Math.PI*2,i=Math.sqrt(1-t**2);return this.x=i*Math.cos(e),this.y=i*Math.sin(e),this.z=t,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Oi=new Ui,Fi=new Ni;class Bi{constructor(t=new Ui(1/0,1/0,1/0),e=new Ui(-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,i=t.length;e<i;e+=3)this.expandByPoint(ki.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,i=t.count;e<i;e++)this.expandByPoint(ki.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=ki.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),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 i=t.geometry;if(void 0!==i){const n=i.getAttribute("position");if(!0===e&&void 0!==n&&!0!==t.isInstancedMesh)for(let e=0,i=n.count;e<i;e++)!0===t.isMesh?t.getVertexPosition(e,ki):ki.fromBufferAttribute(n,e),ki.applyMatrix4(t.matrixWorld),this.expandByPoint(ki);else void 0!==t.boundingBox?(null===t.boundingBox&&t.computeBoundingBox(),Vi.copy(t.boundingBox)):(null===i.boundingBox&&i.computeBoundingBox(),Vi.copy(i.boundingBox)),Vi.applyMatrix4(t.matrixWorld),this.union(Vi)}const n=t.children;for(let s=0,r=n.length;s<r;s++)this.expandByObject(n[s],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,ki),ki.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Yi),Zi.subVectors(this.max,Yi),Gi.subVectors(t.a,Yi),Hi.subVectors(t.b,Yi),Wi.subVectors(t.c,Yi),qi.subVectors(Hi,Gi),Xi.subVectors(Wi,Hi),ji.subVectors(Gi,Wi);let e=[0,-qi.z,qi.y,0,-Xi.z,Xi.y,0,-ji.z,ji.y,qi.z,0,-qi.x,Xi.z,0,-Xi.x,ji.z,0,-ji.x,-qi.y,qi.x,0,-Xi.y,Xi.x,0,-ji.y,ji.x,0];return!!$i(e,Gi,Hi,Wi,Zi)&&(e=[1,0,0,0,1,0,0,0,1],!!$i(e,Gi,Hi,Wi,Zi)&&(Ji.crossVectors(qi,Xi),e=[Ji.x,Ji.y,Ji.z],$i(e,Gi,Hi,Wi,Zi)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,ki).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(ki).length()),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()||(zi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),zi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),zi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),zi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),zi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),zi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),zi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),zi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(zi)),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 zi=[new Ui,new Ui,new Ui,new Ui,new Ui,new Ui,new Ui,new Ui],ki=new Ui,Vi=new Bi,Gi=new Ui,Hi=new Ui,Wi=new Ui,qi=new Ui,Xi=new Ui,ji=new Ui,Yi=new Ui,Zi=new Ui,Ji=new Ui,Ki=new Ui;function $i(t,e,i,n,s){for(let r=0,a=t.length-3;r<=a;r+=3){Ki.fromArray(t,r);const a=s.x*Math.abs(Ki.x)+s.y*Math.abs(Ki.y)+s.z*Math.abs(Ki.z),o=e.dot(Ki),l=i.dot(Ki),h=n.dot(Ki);if(Math.max(-Math.max(o,l,h),Math.min(o,l,h))>a)return!1}return!0}const Qi=new Bi,tn=new Ui,en=new Ui;class nn{constructor(t=new Ui,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 i=this.center;void 0!==e?i.copy(e):Qi.setFromPoints(t).getCenter(i);let n=0;for(let s=0,r=t.length;s<r;s++)n=Math.max(n,i.distanceToSquared(t[s]));return this.radius=Math.sqrt(n),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 i=this.center.distanceToSquared(t);return e.copy(t),i>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;tn.subVectors(t,this.center);const e=tn.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),i=.5*(t-this.radius);this.center.addScaledVector(tn,i/t),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):(en.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(tn.copy(t.center).add(en)),this.expandByPoint(tn.copy(t.center).sub(en))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const sn=new Ui,rn=new Ui,an=new Ui,on=new Ui,ln=new Ui,hn=new Ui,cn=new Ui;class un{constructor(t=new Ui,e=new Ui(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,sn)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const i=e.dot(this.direction);return i<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=sn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(sn.copy(this.origin).addScaledVector(this.direction,e),sn.distanceToSquared(t))}distanceSqToSegment(t,e,i,n){rn.copy(t).add(e).multiplyScalar(.5),an.copy(e).sub(t).normalize(),on.copy(this.origin).sub(rn);const s=.5*t.distanceTo(e),r=-this.direction.dot(an),a=on.dot(this.direction),o=-on.dot(an),l=on.lengthSq(),h=Math.abs(1-r*r);let c,u,d,p;if(h>0)if(c=r*o-a,u=r*a-o,p=s*h,c>=0)if(u>=-p)if(u<=p){const t=1/h;c*=t,u*=t,d=c*(c+r*u+2*a)+u*(r*c+u+2*o)+l}else u=s,c=Math.max(0,-(r*u+a)),d=-c*c+u*(u+2*o)+l;else u=-s,c=Math.max(0,-(r*u+a)),d=-c*c+u*(u+2*o)+l;else u<=-p?(c=Math.max(0,-(-r*s+a)),u=c>0?-s:Math.min(Math.max(-s,-o),s),d=-c*c+u*(u+2*o)+l):u<=p?(c=0,u=Math.min(Math.max(-s,-o),s),d=u*(u+2*o)+l):(c=Math.max(0,-(r*s+a)),u=c>0?s:Math.min(Math.max(-s,-o),s),d=-c*c+u*(u+2*o)+l);else u=r>0?-s:s,c=Math.max(0,-(r*u+a)),d=-c*c+u*(u+2*o)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,c),n&&n.copy(rn).addScaledVector(an,u),d}intersectSphere(t,e){sn.subVectors(t.center,this.origin);const i=sn.dot(this.direction),n=sn.dot(sn)-i*i,s=t.radius*t.radius;if(n>s)return null;const r=Math.sqrt(s-n),a=i-r,o=i+r;return o<0?null:a<0?this.at(o,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){const i=this.distanceToPlane(t);return null===i?null:this.at(i,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let i,n,s,r,a,o;const l=1/this.direction.x,h=1/this.direction.y,c=1/this.direction.z,u=this.origin;return l>=0?(i=(t.min.x-u.x)*l,n=(t.max.x-u.x)*l):(i=(t.max.x-u.x)*l,n=(t.min.x-u.x)*l),h>=0?(s=(t.min.y-u.y)*h,r=(t.max.y-u.y)*h):(s=(t.max.y-u.y)*h,r=(t.min.y-u.y)*h),i>r||s>n?null:((s>i||isNaN(i))&&(i=s),(r<n||isNaN(n))&&(n=r),c>=0?(a=(t.min.z-u.z)*c,o=(t.max.z-u.z)*c):(a=(t.max.z-u.z)*c,o=(t.min.z-u.z)*c),i>o||a>n?null:((a>i||i!=i)&&(i=a),(o<n||n!=n)&&(n=o),n<0?null:this.at(i>=0?i:n,e)))}intersectsBox(t){return null!==this.intersectBox(t,sn)}intersectTriangle(t,e,i,n,s){ln.subVectors(e,t),hn.subVectors(i,t),cn.crossVectors(ln,hn);let r,a=this.direction.dot(cn);if(a>0){if(n)return null;r=1}else{if(!(a<0))return null;r=-1,a=-a}on.subVectors(this.origin,t);const o=r*this.direction.dot(hn.crossVectors(on,hn));if(o<0)return null;const l=r*this.direction.dot(ln.cross(on));if(l<0)return null;if(o+l>a)return null;const h=-r*on.dot(cn);return h<0?null:this.at(h/a,s)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class dn{constructor(t,e,i,n,s,r,a,o,l,h,c,u,d,p,m,f){dn.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,i,n,s,r,a,o,l,h,c,u,d,p,m,f)}set(t,e,i,n,s,r,a,o,l,h,c,u,d,p,m,f){const g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=n,g[1]=s,g[5]=r,g[9]=a,g[13]=o,g[2]=l,g[6]=h,g[10]=c,g[14]=u,g[3]=d,g[7]=p,g[11]=m,g[15]=f,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 dn).fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[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,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,i=t.elements,n=1/pn.setFromMatrixColumn(t,0).length(),s=1/pn.setFromMatrixColumn(t,1).length(),r=1/pn.setFromMatrixColumn(t,2).length();return e[0]=i[0]*n,e[1]=i[1]*n,e[2]=i[2]*n,e[3]=0,e[4]=i[4]*s,e[5]=i[5]*s,e[6]=i[6]*s,e[7]=0,e[8]=i[8]*r,e[9]=i[9]*r,e[10]=i[10]*r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,i=t.x,n=t.y,s=t.z,r=Math.cos(i),a=Math.sin(i),o=Math.cos(n),l=Math.sin(n),h=Math.cos(s),c=Math.sin(s);if("XYZ"===t.order){const t=r*h,i=r*c,n=a*h,s=a*c;e[0]=o*h,e[4]=-o*c,e[8]=l,e[1]=i+n*l,e[5]=t-s*l,e[9]=-a*o,e[2]=s-t*l,e[6]=n+i*l,e[10]=r*o}else if("YXZ"===t.order){const t=o*h,i=o*c,n=l*h,s=l*c;e[0]=t+s*a,e[4]=n*a-i,e[8]=r*l,e[1]=r*c,e[5]=r*h,e[9]=-a,e[2]=i*a-n,e[6]=s+t*a,e[10]=r*o}else if("ZXY"===t.order){const t=o*h,i=o*c,n=l*h,s=l*c;e[0]=t-s*a,e[4]=-r*c,e[8]=n+i*a,e[1]=i+n*a,e[5]=r*h,e[9]=s-t*a,e[2]=-r*l,e[6]=a,e[10]=r*o}else if("ZYX"===t.order){const t=r*h,i=r*c,n=a*h,s=a*c;e[0]=o*h,e[4]=n*l-i,e[8]=t*l+s,e[1]=o*c,e[5]=s*l+t,e[9]=i*l-n,e[2]=-l,e[6]=a*o,e[10]=r*o}else if("YZX"===t.order){const t=r*o,i=r*l,n=a*o,s=a*l;e[0]=o*h,e[4]=s-t*c,e[8]=n*c+i,e[1]=c,e[5]=r*h,e[9]=-a*h,e[2]=-l*h,e[6]=i*c+n,e[10]=t-s*c}else if("XZY"===t.order){const t=r*o,i=r*l,n=a*o,s=a*l;e[0]=o*h,e[4]=-c,e[8]=l*h,e[1]=t*c+s,e[5]=r*h,e[9]=i*c-n,e[2]=n*c-i,e[6]=a*h,e[10]=s*c+t}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(fn,t,gn)}lookAt(t,e,i){const n=this.elements;return yn.subVectors(t,e),0===yn.lengthSq()&&(yn.z=1),yn.normalize(),_n.crossVectors(i,yn),0===_n.lengthSq()&&(1===Math.abs(i.z)?yn.x+=1e-4:yn.z+=1e-4,yn.normalize(),_n.crossVectors(i,yn)),_n.normalize(),vn.crossVectors(yn,_n),n[0]=_n.x,n[4]=vn.x,n[8]=yn.x,n[1]=_n.y,n[5]=vn.y,n[9]=yn.y,n[2]=_n.z,n[6]=vn.z,n[10]=yn.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,s=this.elements,r=i[0],a=i[4],o=i[8],l=i[12],h=i[1],c=i[5],u=i[9],d=i[13],p=i[2],m=i[6],f=i[10],g=i[14],_=i[3],v=i[7],y=i[11],x=i[15],M=n[0],b=n[4],S=n[8],w=n[12],T=n[1],E=n[5],A=n[9],C=n[13],R=n[2],P=n[6],L=n[10],I=n[14],D=n[3],N=n[7],U=n[11],O=n[15];return s[0]=r*M+a*T+o*R+l*D,s[4]=r*b+a*E+o*P+l*N,s[8]=r*S+a*A+o*L+l*U,s[12]=r*w+a*C+o*I+l*O,s[1]=h*M+c*T+u*R+d*D,s[5]=h*b+c*E+u*P+d*N,s[9]=h*S+c*A+u*L+d*U,s[13]=h*w+c*C+u*I+d*O,s[2]=p*M+m*T+f*R+g*D,s[6]=p*b+m*E+f*P+g*N,s[10]=p*S+m*A+f*L+g*U,s[14]=p*w+m*C+f*I+g*O,s[3]=_*M+v*T+y*R+x*D,s[7]=_*b+v*E+y*P+x*N,s[11]=_*S+v*A+y*L+x*U,s[15]=_*w+v*C+y*I+x*O,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],i=t[4],n=t[8],s=t[12],r=t[1],a=t[5],o=t[9],l=t[13],h=t[2],c=t[6],u=t[10],d=t[14];return t[3]*(+s*o*c-n*l*c-s*a*u+i*l*u+n*a*d-i*o*d)+t[7]*(+e*o*d-e*l*u+s*r*u-n*r*d+n*l*h-s*o*h)+t[11]*(+e*l*c-e*a*d-s*r*c+i*r*d+s*a*h-i*l*h)+t[15]*(-n*a*h-e*o*c+e*a*u+n*r*c-i*r*u+i*o*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,i){const n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],a=t[5],o=t[6],l=t[7],h=t[8],c=t[9],u=t[10],d=t[11],p=t[12],m=t[13],f=t[14],g=t[15],_=c*f*l-m*u*l+m*o*d-a*f*d-c*o*g+a*u*g,v=p*u*l-h*f*l-p*o*d+r*f*d+h*o*g-r*u*g,y=h*m*l-p*c*l+p*a*d-r*m*d-h*a*g+r*c*g,x=p*c*o-h*m*o-p*a*u+r*m*u+h*a*f-r*c*f,M=e*_+i*v+n*y+s*x;if(0===M)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const b=1/M;return t[0]=_*b,t[1]=(m*u*s-c*f*s-m*n*d+i*f*d+c*n*g-i*u*g)*b,t[2]=(a*f*s-m*o*s+m*n*l-i*f*l-a*n*g+i*o*g)*b,t[3]=(c*o*s-a*u*s-c*n*l+i*u*l+a*n*d-i*o*d)*b,t[4]=v*b,t[5]=(h*f*s-p*u*s+p*n*d-e*f*d-h*n*g+e*u*g)*b,t[6]=(p*o*s-r*f*s-p*n*l+e*f*l+r*n*g-e*o*g)*b,t[7]=(r*u*s-h*o*s+h*n*l-e*u*l-r*n*d+e*o*d)*b,t[8]=y*b,t[9]=(p*c*s-h*m*s-p*i*d+e*m*d+h*i*g-e*c*g)*b,t[10]=(r*m*s-p*a*s+p*i*l-e*m*l-r*i*g+e*a*g)*b,t[11]=(h*a*s-r*c*s-h*i*l+e*c*l+r*i*d-e*a*d)*b,t[12]=x*b,t[13]=(h*m*n-p*c*n+p*i*u-e*m*u-h*i*f+e*c*f)*b,t[14]=(p*a*n-r*m*n-p*i*o+e*m*o+r*i*f-e*a*f)*b,t[15]=(r*c*n-h*a*n+h*i*o-e*c*o-r*i*u+e*a*u)*b,this}scale(t){const e=this.elements,i=t.x,n=t.y,s=t.z;return e[0]*=i,e[4]*=n,e[8]*=s,e[1]*=i,e[5]*=n,e[9]*=s,e[2]*=i,e[6]*=n,e[10]*=s,e[3]*=i,e[7]*=n,e[11]*=s,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,n))}makeTranslation(t,e,i){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,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),n=Math.sin(e),s=1-i,r=t.x,a=t.y,o=t.z,l=s*r,h=s*a;return this.set(l*r+i,l*a-n*o,l*o+n*a,0,l*a+n*o,h*a+i,h*o-n*r,0,l*o-n*a,h*o+n*r,s*o*o+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,n,s,r){return this.set(1,i,s,0,t,1,r,0,e,n,1,0,0,0,0,1),this}compose(t,e,i){const n=this.elements,s=e._x,r=e._y,a=e._z,o=e._w,l=s+s,h=r+r,c=a+a,u=s*l,d=s*h,p=s*c,m=r*h,f=r*c,g=a*c,_=o*l,v=o*h,y=o*c,x=i.x,M=i.y,b=i.z;return n[0]=(1-(m+g))*x,n[1]=(d+y)*x,n[2]=(p-v)*x,n[3]=0,n[4]=(d-y)*M,n[5]=(1-(u+g))*M,n[6]=(f+_)*M,n[7]=0,n[8]=(p+v)*b,n[9]=(f-_)*b,n[10]=(1-(u+m))*b,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,i){const n=this.elements;let s=pn.set(n[0],n[1],n[2]).length();const r=pn.set(n[4],n[5],n[6]).length(),a=pn.set(n[8],n[9],n[10]).length();this.determinant()<0&&(s=-s),t.x=n[12],t.y=n[13],t.z=n[14],mn.copy(this);const o=1/s,l=1/r,h=1/a;return mn.elements[0]*=o,mn.elements[1]*=o,mn.elements[2]*=o,mn.elements[4]*=l,mn.elements[5]*=l,mn.elements[6]*=l,mn.elements[8]*=h,mn.elements[9]*=h,mn.elements[10]*=h,e.setFromRotationMatrix(mn),i.x=s,i.y=r,i.z=a,this}makePerspective(t,e,i,n,s,r,a=2e3){const o=this.elements,l=2*s/(e-t),h=2*s/(i-n),c=(e+t)/(e-t),u=(i+n)/(i-n);let d,p;if(a===He)d=-(r+s)/(r-s),p=-2*r*s/(r-s);else{if(a!==We)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);d=-r/(r-s),p=-r*s/(r-s)}return o[0]=l,o[4]=0,o[8]=c,o[12]=0,o[1]=0,o[5]=h,o[9]=u,o[13]=0,o[2]=0,o[6]=0,o[10]=d,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,i,n,s,r,a=2e3){const o=this.elements,l=1/(e-t),h=1/(i-n),c=1/(r-s),u=(e+t)*l,d=(i+n)*h;let p,m;if(a===He)p=(r+s)*c,m=-2*c;else{if(a!==We)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);p=s*c,m=-1*c}return o[0]=2*l,o[4]=0,o[8]=0,o[12]=-u,o[1]=0,o[5]=2*h,o[9]=0,o[13]=-d,o[2]=0,o[6]=0,o[10]=m,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let n=0;n<16;n++)if(e[n]!==i[n])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}const pn=new Ui,mn=new dn,fn=new Ui(0,0,0),gn=new Ui(1,1,1),_n=new Ui,vn=new Ui,yn=new Ui,xn=new dn,Mn=new Ni;class bn{constructor(t=0,e=0,i=0,n=bn.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=n}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,i,n=this._order){return this._x=t,this._y=e,this._z=i,this._order=n,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,i=!0){const n=t.elements,s=n[0],r=n[4],a=n[8],o=n[1],l=n[5],h=n[9],c=n[2],u=n[6],d=n[10];switch(e){case"XYZ":this._y=Math.asin(Ke(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-r,s)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Ke(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-c,s),this._z=0);break;case"ZXY":this._x=Math.asin(Ke(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-r,l)):(this._y=0,this._z=Math.atan2(o,s));break;case"ZYX":this._y=Math.asin(-Ke(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,s)):(this._x=0,this._z=Math.atan2(-r,l));break;case"YZX":this._z=Math.asin(Ke(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-c,s)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-Ke(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-h,d),this._y=0)}return this._order=e,!0===i&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return xn.makeRotationFromQuaternion(t),this.setFromRotationMatrix(xn,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Mn.setFromEuler(this),this.setFromQuaternion(Mn,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],void 0!==t[3]&&(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}}bn.DEFAULT_ORDER="XYZ";class Sn{constructor(){this.mask=1}set(t){this.mask=1<<t>>>0}enable(t){this.mask|=1<<t}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t}disable(t){this.mask&=~(1<<t)}disableAll(){this.mask=0}test(t){return 0!==(this.mask&t.mask)}isEnabled(t){return!!(this.mask&1<<t)}}let wn=0;const Tn=new Ui,En=new Ni,An=new dn,Cn=new Ui,Rn=new Ui,Pn=new Ui,Ln=new Ni,In=new Ui(1,0,0),Dn=new Ui(0,1,0),Nn=new Ui(0,0,1),Un={type:"added"},On={type:"removed"};class Fn extends qe{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:wn++}),this.uuid=Je(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Fn.DEFAULT_UP.clone();const t=new Ui,e=new bn,i=new Ni,n=new Ui(1,1,1);e._onChange(function(){i.setFromEuler(e,!1)}),i._onChange(function(){e.setFromQuaternion(i,void 0,!1)}),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new dn},normalMatrix:{value:new ai}}),this.matrix=new dn,this.matrixWorld=new dn,this.matrixAutoUpdate=Fn.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Fn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Sn,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 En.setFromAxisAngle(t,e),this.quaternion.multiply(En),this}rotateOnWorldAxis(t,e){return En.setFromAxisAngle(t,e),this.quaternion.premultiply(En),this}rotateX(t){return this.rotateOnAxis(In,t)}rotateY(t){return this.rotateOnAxis(Dn,t)}rotateZ(t){return this.rotateOnAxis(Nn,t)}translateOnAxis(t,e){return Tn.copy(t).applyQuaternion(this.quaternion),this.position.add(Tn.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(In,t)}translateY(t){return this.translateOnAxis(Dn,t)}translateZ(t){return this.translateOnAxis(Nn,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(An.copy(this.matrixWorld).invert())}lookAt(t,e,i){t.isVector3?Cn.copy(t):Cn.set(t,e,i);const n=this.parent;this.updateWorldMatrix(!0,!1),Rn.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?An.lookAt(Rn,Cn,this.up):An.lookAt(Cn,Rn,this.up),this.quaternion.setFromRotationMatrix(An),n&&(An.extractRotation(n.matrixWorld),En.setFromRotationMatrix(An),this.quaternion.premultiply(En.invert()))}add(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return t===this||t&&t.isObject3D&&(null!==t.parent&&t.parent.remove(t),t.parent=this,this.children.push(t),t.dispatchEvent(Un)),this}remove(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.remove(arguments[t]);return this}const e=this.children.indexOf(t);return-1!==e&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(On)),this}removeFromParent(){const t=this.parent;return null!==t&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),An.copy(this.matrixWorld).invert(),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),An.multiply(t.parent.matrixWorld)),t.applyMatrix4(An),this.add(t),t.updateWorldMatrix(!1,!0),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 i=0,n=this.children.length;i<n;i++){const n=this.children[i].getObjectByProperty(t,e);if(void 0!==n)return n}}getObjectsByProperty(t,e,i=[]){this[t]===e&&i.push(this);const n=this.children;for(let s=0,r=n.length;s<r;s++)n[s].getObjectsByProperty(t,e,i);return i}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Rn,t,Pn),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Rn,Ln,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 i=0,n=e.length;i<n;i++)e[i].traverse(t)}traverseVisible(t){if(!1===this.visible)return;t(this);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].traverseVisible(t)}traverseAncestors(t){const e=this.parent;null!==e&&(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)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let i=0,n=e.length;i<n;i++){const n=e[i];!0!==n.matrixWorldAutoUpdate&&!0!==t||n.updateMatrixWorld(t)}}updateWorldMatrix(t,e){const i=this.parent;if(!0===t&&null!==i&&!0===i.matrixWorldAutoUpdate&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===e){const t=this.children;for(let e=0,i=t.length;e<i;e++){const i=t[e];!0===i.matrixWorldAutoUpdate&&i.updateWorldMatrix(!1,!0)}}}toJSON(t){const e=void 0===t||"string"==typeof t,i={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const n={};function s(e,i){return void 0===e[i.uuid]&&(e[i.uuid]=i.toJSON(t)),i.uuid}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),!0===this.castShadow&&(n.castShadow=!0),!0===this.receiveShadow&&(n.receiveShadow=!0),!1===this.visible&&(n.visible=!1),!1===this.frustumCulled&&(n.frustumCulled=!1),0!==this.renderOrder&&(n.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),n.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(n.matrixAutoUpdate=!1),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(n.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(n.type="BatchedMesh",n.perObjectFrustumCulled=this.perObjectFrustumCulled,n.sortObjects=this.sortObjects,n.drawRanges=this._drawRanges,n.reservedRanges=this._reservedRanges,n.visibility=this._visibility,n.active=this._active,n.bounds=this._bounds.map(t=>({boxInitialized:t.boxInitialized,boxMin:t.box.min.toArray(),boxMax:t.box.max.toArray(),sphereInitialized:t.sphereInitialized,sphereRadius:t.sphere.radius,sphereCenter:t.sphere.center.toArray()})),n.maxGeometryCount=this._maxGeometryCount,n.maxVertexCount=this._maxVertexCount,n.maxIndexCount=this._maxIndexCount,n.geometryInitialized=this._geometryInitialized,n.geometryCount=this._geometryCount,n.matricesTexture=this._matricesTexture.toJSON(t),null!==this.boundingSphere&&(n.boundingSphere={center:n.boundingSphere.center.toArray(),radius:n.boundingSphere.radius}),null!==this.boundingBox&&(n.boundingBox={min:n.boundingBox.min.toArray(),max:n.boundingBox.max.toArray()})),this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(n.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=s(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const i=e.shapes;if(Array.isArray(i))for(let e=0,n=i.length;e<n;e++){const n=i[e];s(t.shapes,n)}else s(t.shapes,i)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(s(t.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const e=[];for(let i=0,n=this.material.length;i<n;i++)e.push(s(t.materials,this.material[i]));n.material=e}else n.material=s(t.materials,this.material);if(this.children.length>0){n.children=[];for(let e=0;e<this.children.length;e++)n.children.push(this.children[e].toJSON(t).object)}if(this.animations.length>0){n.animations=[];for(let e=0;e<this.animations.length;e++){const i=this.animations[e];n.animations.push(s(t.animations,i))}}if(e){const e=r(t.geometries),n=r(t.materials),s=r(t.textures),a=r(t.images),o=r(t.shapes),l=r(t.skeletons),h=r(t.animations),c=r(t.nodes);e.length>0&&(i.geometries=e),n.length>0&&(i.materials=n),s.length>0&&(i.textures=s),a.length>0&&(i.images=a),o.length>0&&(i.shapes=o),l.length>0&&(i.skeletons=l),h.length>0&&(i.animations=h),c.length>0&&(i.nodes=c)}return i.object=n,i;function r(t){const e=[];for(const i in t){const n=t[i];delete n.metadata,e.push(n)}return e}}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)),!0===e)for(let i=0;i<t.children.length;i++){const e=t.children[i];this.add(e.clone())}return this}}Fn.DEFAULT_UP=new Ui(0,1,0),Fn.DEFAULT_MATRIX_AUTO_UPDATE=!0,Fn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Bn=new Ui,zn=new Ui,kn=new Ui,Vn=new Ui,Gn=new Ui,Hn=new Ui,Wn=new Ui,qn=new Ui,Xn=new Ui,jn=new Ui;let Yn=!1;class Zn{constructor(t=new Ui,e=new Ui,i=new Ui){this.a=t,this.b=e,this.c=i}static getNormal(t,e,i,n){n.subVectors(i,e),Bn.subVectors(t,e),n.cross(Bn);const s=n.lengthSq();return s>0?n.multiplyScalar(1/Math.sqrt(s)):n.set(0,0,0)}static getBarycoord(t,e,i,n,s){Bn.subVectors(n,e),zn.subVectors(i,e),kn.subVectors(t,e);const r=Bn.dot(Bn),a=Bn.dot(zn),o=Bn.dot(kn),l=zn.dot(zn),h=zn.dot(kn),c=r*l-a*a;if(0===c)return s.set(0,0,0),null;const u=1/c,d=(l*o-a*h)*u,p=(r*h-a*o)*u;return s.set(1-d-p,p,d)}static containsPoint(t,e,i,n){return null!==this.getBarycoord(t,e,i,n,Vn)&&Vn.x>=0&&Vn.y>=0&&Vn.x+Vn.y<=1}static getUV(t,e,i,n,s,r,a,o){return!1===Yn&&(Yn=!0),this.getInterpolation(t,e,i,n,s,r,a,o)}static getInterpolation(t,e,i,n,s,r,a,o){return null===this.getBarycoord(t,e,i,n,Vn)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(s,Vn.x),o.addScaledVector(r,Vn.y),o.addScaledVector(a,Vn.z),o)}static isFrontFacing(t,e,i,n){return Bn.subVectors(i,e),zn.subVectors(t,e),Bn.cross(zn).dot(n)<0}set(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this}setFromPointsAndIndices(t,e,i,n){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[n]),this}setFromAttributeAndIndices(t,e,i,n){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,i),this.c.fromBufferAttribute(t,n),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 Bn.subVectors(this.c,this.b),zn.subVectors(this.a,this.b),.5*Bn.cross(zn).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Zn.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Zn.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,i,n,s){return!1===Yn&&(Yn=!0),Zn.getInterpolation(t,this.a,this.b,this.c,e,i,n,s)}getInterpolation(t,e,i,n,s){return Zn.getInterpolation(t,this.a,this.b,this.c,e,i,n,s)}containsPoint(t){return Zn.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Zn.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const i=this.a,n=this.b,s=this.c;let r,a;Gn.subVectors(n,i),Hn.subVectors(s,i),qn.subVectors(t,i);const o=Gn.dot(qn),l=Hn.dot(qn);if(o<=0&&l<=0)return e.copy(i);Xn.subVectors(t,n);const h=Gn.dot(Xn),c=Hn.dot(Xn);if(h>=0&&c<=h)return e.copy(n);const u=o*c-h*l;if(u<=0&&o>=0&&h<=0)return r=o/(o-h),e.copy(i).addScaledVector(Gn,r);jn.subVectors(t,s);const d=Gn.dot(jn),p=Hn.dot(jn);if(p>=0&&d<=p)return e.copy(s);const m=d*l-o*p;if(m<=0&&l>=0&&p<=0)return a=l/(l-p),e.copy(i).addScaledVector(Hn,a);const f=h*p-d*c;if(f<=0&&c-h>=0&&d-p>=0)return Wn.subVectors(s,n),a=(c-h)/(c-h+(d-p)),e.copy(n).addScaledVector(Wn,a);const g=1/(f+m+u);return r=m*g,a=u*g,e.copy(i).addScaledVector(Gn,r).addScaledVector(Hn,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Jn={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},Kn={h:0,s:0,l:0},$n={h:0,s:0,l:0};function Qn(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+6*(e-t)*(2/3-i):t}class ts{constructor(t,e,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,i)}set(t,e,i){if(void 0===e&&void 0===i){const e=t;e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e)}else this.setRGB(t,e,i);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Se){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,yi.toWorkingColorSpace(this,e),this}setRGB(t,e,i,n=yi.workingColorSpace){return this.r=t,this.g=e,this.b=i,yi.toWorkingColorSpace(this,n),this}setHSL(t,e,i,n=yi.workingColorSpace){if(t=$e(t,1),e=Ke(e,0,1),i=Ke(i,0,1),0===e)this.r=this.g=this.b=i;else{const n=i<=.5?i*(1+e):i+e-i*e,s=2*i-n;this.r=Qn(s,n,t+1/3),this.g=Qn(s,n,t),this.b=Qn(s,n,t-1/3)}return yi.toWorkingColorSpace(this,n),this}setStyle(t,e=Se){function i(t){void 0!==t&&parseFloat(t)}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(t)){let t;const s=n[1],r=n[2];switch(s){case"rgb":case"rgba":if(t=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return i(t[4]),this.setRGB(Math.min(255,parseInt(t[1],10))/255,Math.min(255,parseInt(t[2],10))/255,Math.min(255,parseInt(t[3],10))/255,e);if(t=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return i(t[4]),this.setRGB(Math.min(100,parseInt(t[1],10))/100,Math.min(100,parseInt(t[2],10))/100,Math.min(100,parseInt(t[3],10))/100,e);break;case"hsl":case"hsla":if(t=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return i(t[4]),this.setHSL(parseFloat(t[1])/360,parseFloat(t[2])/100,parseFloat(t[3])/100,e)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){const t=n[1],i=t.length;if(3===i)return this.setRGB(parseInt(t.charAt(0),16)/15,parseInt(t.charAt(1),16)/15,parseInt(t.charAt(2),16)/15,e);if(6===i)return this.setHex(parseInt(t,16),e)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Se){const i=Jn[t.toLowerCase()];return void 0!==i&&this.setHex(i,e),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=xi(t.r),this.g=xi(t.g),this.b=xi(t.b),this}copyLinearToSRGB(t){return this.r=Mi(t.r),this.g=Mi(t.g),this.b=Mi(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Se){return yi.fromWorkingColorSpace(es.copy(this),t),65536*Math.round(Ke(255*es.r,0,255))+256*Math.round(Ke(255*es.g,0,255))+Math.round(Ke(255*es.b,0,255))}getHexString(t=Se){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=yi.workingColorSpace){yi.fromWorkingColorSpace(es.copy(this),e);const i=es.r,n=es.g,s=es.b,r=Math.max(i,n,s),a=Math.min(i,n,s);let o,l;const h=(a+r)/2;if(a===r)o=0,l=0;else{const t=r-a;switch(l=h<=.5?t/(r+a):t/(2-r-a),r){case i:o=(n-s)/t+(n<s?6:0);break;case n:o=(s-i)/t+2;break;case s:o=(i-n)/t+4}o/=6}return t.h=o,t.s=l,t.l=h,t}getRGB(t,e=yi.workingColorSpace){return yi.fromWorkingColorSpace(es.copy(this),e),t.r=es.r,t.g=es.g,t.b=es.b,t}getStyle(t=Se){yi.fromWorkingColorSpace(es.copy(this),t);const e=es.r,i=es.g,n=es.b;return t!==Se?`color(${t} ${e.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(255*e)},${Math.round(255*i)},${Math.round(255*n)})`}offsetHSL(t,e,i){return this.getHSL(Kn),this.setHSL(Kn.h+t,Kn.s+e,Kn.l+i)}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,i){return this.r=t.r+(e.r-t.r)*i,this.g=t.g+(e.g-t.g)*i,this.b=t.b+(e.b-t.b)*i,this}lerpHSL(t,e){this.getHSL(Kn),t.getHSL($n);const i=Qe(Kn.h,$n.h,e),n=Qe(Kn.s,$n.s,e),s=Qe(Kn.l,$n.l,e);return this.setHSL(i,n,s),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,i=this.g,n=this.b,s=t.elements;return this.r=s[0]*e+s[3]*i+s[6]*n,this.g=s[1]*e+s[4]*i+s[7]*n,this.b=s[2]*e+s[5]*i+s[8]*n,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 es=new ts;ts.NAMES=Jn;let is=0;class ns extends qe{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:is++}),this.uuid=Je(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=j,this.blendDst=Y,this.blendEquation=k,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ts(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Le,this.stencilZFail=Le,this.stencilZPass=Le,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const i=t[e];if(void 0===i)continue;const n=this[e];void 0!==n&&(n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[e]=i)}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function n(t){const e=[];for(const i in t){const n=t[i];delete n.metadata,e.push(n)}return e}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),void 0!==this.sheen&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearcoat&&(i.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.iridescence&&(i.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(i.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),void 0!==this.anisotropy&&(i.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(t).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(i.combine=this.combine)),void 0!==this.envMapIntensity&&(i.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(i.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(i.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(i.size=this.size),null!==this.shadowSide&&(i.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(i.blending=this.blending),0!==this.side&&(i.side=this.side),!0===this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=!0),this.blendSrc!==j&&(i.blendSrc=this.blendSrc),this.blendDst!==Y&&(i.blendDst=this.blendDst),this.blendEquation!==k&&(i.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(i.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(i.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(i.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(i.depthFunc=this.depthFunc),!1===this.depthTest&&(i.depthTest=this.depthTest),!1===this.depthWrite&&(i.depthWrite=this.depthWrite),!1===this.colorWrite&&(i.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(i.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(i.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(i.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Le&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Le&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Le&&(i.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(i.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(i.rotation=this.rotation),!0===this.polygonOffset&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.alphaHash&&(i.alphaHash=!0),!0===this.alphaToCoverage&&(i.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=!0),!0===this.forceSinglePass&&(i.forceSinglePass=!0),!0===this.wireframe&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(i.flatShading=!0),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),!1===this.fog&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData),e){const e=n(t.textures),s=n(t.images);e.length>0&&(i.textures=e),s.length>0&&(i.images=s)}return i}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 i=null;if(null!==e){const t=e.length;i=new Array(t);for(let n=0;n!==t;++n)i[n]=e[n].clone()}return this.clippingPlanes=i,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){!0===t&&this.version++}}class ss extends ns{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ts(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const rs=as();function as(){const t=new ArrayBuffer(4),e=new Float32Array(t),i=new Uint32Array(t),n=new Uint32Array(512),s=new Uint32Array(512);for(let l=0;l<256;++l){const t=l-127;t<-27?(n[l]=0,n[256|l]=32768,s[l]=24,s[256|l]=24):t<-14?(n[l]=1024>>-t-14,n[256|l]=1024>>-t-14|32768,s[l]=-t-1,s[256|l]=-t-1):t<=15?(n[l]=t+15<<10,n[256|l]=t+15<<10|32768,s[l]=13,s[256|l]=13):t<128?(n[l]=31744,n[256|l]=64512,s[l]=24,s[256|l]=24):(n[l]=31744,n[256|l]=64512,s[l]=13,s[256|l]=13)}const r=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let t=l<<13,e=0;for(;!(8388608&t);)t<<=1,e-=8388608;t&=-8388609,e+=947912704,r[l]=t|e}for(let l=1024;l<2048;++l)r[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)32!==l&&(o[l]=1024);return{floatView:e,uint32View:i,baseTable:n,shiftTable:s,mantissaTable:r,exponentTable:a,offsetTable:o}}function os(t){Math.abs(t),t=Ke(t,-65504,65504),rs.floatView[0]=t;const e=rs.uint32View[0],i=e>>23&511;return rs.baseTable[i]+((8388607&e)>>rs.shiftTable[i])}function ls(t){const e=t>>10;return rs.uint32View[0]=rs.mantissaTable[rs.offsetTable[e]+(1023&t)]+rs.exponentTable[e],rs.floatView[0]}const hs={toHalfFloat:os,fromHalfFloat:ls},cs=new Ui,us=new ri;class ds{constructor(t,e,i=!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=void 0!==t?t.length/e:0,this.normalized=i,this.usage=ke,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Tt,this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}get updateRange(){return this._updateRange}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,i){t*=this.itemSize,i*=e.itemSize;for(let n=0,s=this.itemSize;n<s;n++)this.array[t+n]=e.array[i+n];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(2===this.itemSize)for(let e=0,i=this.count;e<i;e++)us.fromBufferAttribute(this,e),us.applyMatrix3(t),this.setXY(e,us.x,us.y);else if(3===this.itemSize)for(let e=0,i=this.count;e<i;e++)cs.fromBufferAttribute(this,e),cs.applyMatrix3(t),this.setXYZ(e,cs.x,cs.y,cs.z);return this}applyMatrix4(t){for(let e=0,i=this.count;e<i;e++)cs.fromBufferAttribute(this,e),cs.applyMatrix4(t),this.setXYZ(e,cs.x,cs.y,cs.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)cs.fromBufferAttribute(this,e),cs.applyNormalMatrix(t),this.setXYZ(e,cs.x,cs.y,cs.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)cs.fromBufferAttribute(this,e),cs.transformDirection(t),this.setXYZ(e,cs.x,cs.y,cs.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let i=this.array[t*this.itemSize+e];return this.normalized&&(i=ii(i,this.array)),i}setComponent(t,e,i){return this.normalized&&(i=ni(i,this.array)),this.array[t*this.itemSize+e]=i,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=ii(e,this.array)),e}setX(t,e){return this.normalized&&(e=ni(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=ii(e,this.array)),e}setY(t,e){return this.normalized&&(e=ni(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=ii(e,this.array)),e}setZ(t,e){return this.normalized&&(e=ni(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=ii(e,this.array)),e}setW(t,e){return this.normalized&&(e=ni(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=ni(e,this.array),i=ni(i,this.array)),this.array[t+0]=e,this.array[t+1]=i,this}setXYZ(t,e,i,n){return t*=this.itemSize,this.normalized&&(e=ni(e,this.array),i=ni(i,this.array),n=ni(n,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this}setXYZW(t,e,i,n,s){return t*=this.itemSize,this.normalized&&(e=ni(e,this.array),i=ni(i,this.array),n=ni(n,this.array),s=ni(s,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this.array[t+3]=s,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!==ke&&(t.usage=this.usage),t}}class ps extends ds{constructor(t,e,i){super(new Uint16Array(t),e,i)}}class ms extends ds{constructor(t,e,i){super(new Uint32Array(t),e,i)}}class fs extends ds{constructor(t,e,i){super(new Float32Array(t),e,i)}}let gs=0;const _s=new dn,vs=new Fn,ys=new Ui,xs=new Bi,Ms=new Bi,bs=new Ui;class Ss extends qe{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:gs++}),this.uuid=Je(),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(li(t)?ms:ps)(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 void 0!==this.attributes[t]}addGroup(t,e,i=0){this.groups.push({start:t,count:e,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const i=this.attributes.normal;if(void 0!==i){const e=(new ai).getNormalMatrix(t);i.applyNormalMatrix(e),i.needsUpdate=!0}const n=this.attributes.tangent;return void 0!==n&&(n.transformDirection(t),n.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(t){return _s.makeRotationFromQuaternion(t),this.applyMatrix4(_s),this}rotateX(t){return _s.makeRotationX(t),this.applyMatrix4(_s),this}rotateY(t){return _s.makeRotationY(t),this.applyMatrix4(_s),this}rotateZ(t){return _s.makeRotationZ(t),this.applyMatrix4(_s),this}translate(t,e,i){return _s.makeTranslation(t,e,i),this.applyMatrix4(_s),this}scale(t,e,i){return _s.makeScale(t,e,i),this.applyMatrix4(_s),this}lookAt(t){return vs.lookAt(t),vs.updateMatrix(),this.applyMatrix4(vs.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ys).negate(),this.translate(ys.x,ys.y,ys.z),this}setFromPoints(t){const e=[];for(let i=0,n=t.length;i<n;i++){const n=t[i];e.push(n.x,n.y,n.z||0)}return this.setAttribute("position",new fs(e,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Bi);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)this.boundingBox.set(new Ui(-1/0,-1/0,-1/0),new Ui(1/0,1/0,1/0));else{if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,i=e.length;t<i;t++){const i=e[t];xs.setFromBufferAttribute(i),this.morphTargetsRelative?(bs.addVectors(this.boundingBox.min,xs.min),this.boundingBox.expandByPoint(bs),bs.addVectors(this.boundingBox.max,xs.max),this.boundingBox.expandByPoint(bs)):(this.boundingBox.expandByPoint(xs.min),this.boundingBox.expandByPoint(xs.max))}}else this.boundingBox.makeEmpty();isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z)}}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new nn);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)this.boundingSphere.set(new Ui,1/0);else if(t){const i=this.boundingSphere.center;if(xs.setFromBufferAttribute(t),e)for(let t=0,s=e.length;t<s;t++){const i=e[t];Ms.setFromBufferAttribute(i),this.morphTargetsRelative?(bs.addVectors(xs.min,Ms.min),xs.expandByPoint(bs),bs.addVectors(xs.max,Ms.max),xs.expandByPoint(bs)):(xs.expandByPoint(Ms.min),xs.expandByPoint(Ms.max))}xs.getCenter(i);let n=0;for(let e=0,s=t.count;e<s;e++)bs.fromBufferAttribute(t,e),n=Math.max(n,i.distanceToSquared(bs));if(e)for(let s=0,r=e.length;s<r;s++){const r=e[s],a=this.morphTargetsRelative;for(let e=0,s=r.count;e<s;e++)bs.fromBufferAttribute(r,e),a&&(ys.fromBufferAttribute(t,e),bs.add(ys)),n=Math.max(n,i.distanceToSquared(bs))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)}}computeTangents(){const t=this.index,e=this.attributes;if(null===t||void 0===e.position||void 0===e.normal||void 0===e.uv)return;const i=t.array,n=e.position.array,s=e.normal.array,r=e.uv.array,a=n.length/3;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new ds(new Float32Array(4*a),4));const o=this.getAttribute("tangent").array,l=[],h=[];for(let T=0;T<a;T++)l[T]=new Ui,h[T]=new Ui;const c=new Ui,u=new Ui,d=new Ui,p=new ri,m=new ri,f=new ri,g=new Ui,_=new Ui;function v(t,e,i){c.fromArray(n,3*t),u.fromArray(n,3*e),d.fromArray(n,3*i),p.fromArray(r,2*t),m.fromArray(r,2*e),f.fromArray(r,2*i),u.sub(c),d.sub(c),m.sub(p),f.sub(p);const s=1/(m.x*f.y-f.x*m.y);isFinite(s)&&(g.copy(u).multiplyScalar(f.y).addScaledVector(d,-m.y).multiplyScalar(s),_.copy(d).multiplyScalar(m.x).addScaledVector(u,-f.x).multiplyScalar(s),l[t].add(g),l[e].add(g),l[i].add(g),h[t].add(_),h[e].add(_),h[i].add(_))}let y=this.groups;0===y.length&&(y=[{start:0,count:i.length}]);for(let T=0,E=y.length;T<E;++T){const t=y[T],e=t.start;for(let n=e,s=e+t.count;n<s;n+=3)v(i[n+0],i[n+1],i[n+2])}const x=new Ui,M=new Ui,b=new Ui,S=new Ui;function w(t){b.fromArray(s,3*t),S.copy(b);const e=l[t];x.copy(e),x.sub(b.multiplyScalar(b.dot(e))).normalize(),M.crossVectors(S,e);const i=M.dot(h[t])<0?-1:1;o[4*t]=x.x,o[4*t+1]=x.y,o[4*t+2]=x.z,o[4*t+3]=i}for(let T=0,E=y.length;T<E;++T){const t=y[T],e=t.start;for(let n=e,s=e+t.count;n<s;n+=3)w(i[n+0]),w(i[n+1]),w(i[n+2])}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(void 0!==e){let i=this.getAttribute("normal");if(void 0===i)i=new ds(new Float32Array(3*e.count),3),this.setAttribute("normal",i);else for(let t=0,e=i.count;t<e;t++)i.setXYZ(t,0,0,0);const n=new Ui,s=new Ui,r=new Ui,a=new Ui,o=new Ui,l=new Ui,h=new Ui,c=new Ui;if(t)for(let u=0,d=t.count;u<d;u+=3){const d=t.getX(u+0),p=t.getX(u+1),m=t.getX(u+2);n.fromBufferAttribute(e,d),s.fromBufferAttribute(e,p),r.fromBufferAttribute(e,m),h.subVectors(r,s),c.subVectors(n,s),h.cross(c),a.fromBufferAttribute(i,d),o.fromBufferAttribute(i,p),l.fromBufferAttribute(i,m),a.add(h),o.add(h),l.add(h),i.setXYZ(d,a.x,a.y,a.z),i.setXYZ(p,o.x,o.y,o.z),i.setXYZ(m,l.x,l.y,l.z)}else for(let t=0,u=e.count;t<u;t+=3)n.fromBufferAttribute(e,t+0),s.fromBufferAttribute(e,t+1),r.fromBufferAttribute(e,t+2),h.subVectors(r,s),c.subVectors(n,s),h.cross(c),i.setXYZ(t+0,h.x,h.y,h.z),i.setXYZ(t+1,h.x,h.y,h.z),i.setXYZ(t+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,i=t.count;e<i;e++)bs.fromBufferAttribute(t,e),bs.normalize(),t.setXYZ(e,bs.x,bs.y,bs.z)}toNonIndexed(){function t(t,e){const i=t.array,n=t.itemSize,s=t.normalized,r=new i.constructor(e.length*n);let a=0,o=0;for(let l=0,h=e.length;l<h;l++){a=t.isInterleavedBufferAttribute?e[l]*t.data.stride+t.offset:e[l]*n;for(let t=0;t<n;t++)r[o++]=i[a++]}return new ds(r,n,s)}if(null===this.index)return this;const e=new Ss,i=this.index.array,n=this.attributes;for(const a in n){const s=t(n[a],i);e.setAttribute(a,s)}const s=this.morphAttributes;for(const a in s){const n=[],r=s[a];for(let e=0,s=r.length;e<s;e++){const s=t(r[e],i);n.push(s)}e.morphAttributes[a]=n}e.morphTargetsRelative=this.morphTargetsRelative;const r=this.groups;for(let a=0,o=r.length;a<o;a++){const t=r[a];e.addGroup(t.start,t.count,t.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),void 0!==this.parameters){const e=this.parameters;for(const i in e)void 0!==e[i]&&(t[i]=e[i]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const i=this.attributes;for(const o in i){const e=i[o];t.data.attributes[o]=e.toJSON(t.data)}const n={};let s=!1;for(const o in this.morphAttributes){const e=this.morphAttributes[o],i=[];for(let n=0,s=e.length;n<s;n++){const s=e[n];i.push(s.toJSON(t.data))}i.length>0&&(n[o]=i,s=!0)}s&&(t.data.morphAttributes=n,t.data.morphTargetsRelative=this.morphTargetsRelative);const r=this.groups;r.length>0&&(t.data.groups=JSON.parse(JSON.stringify(r)));const a=this.boundingSphere;return null!==a&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return(new this.constructor).copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const i=t.index;null!==i&&this.setIndex(i.clone(e));const n=t.attributes;for(const l in n){const t=n[l];this.setAttribute(l,t.clone(e))}const s=t.morphAttributes;for(const l in s){const t=[],i=s[l];for(let n=0,s=i.length;n<s;n++)t.push(i[n].clone(e));this.morphAttributes[l]=t}this.morphTargetsRelative=t.morphTargetsRelative;const r=t.groups;for(let l=0,h=r.length;l<h;l++){const t=r[l];this.addGroup(t.start,t.count,t.materialIndex)}const a=t.boundingBox;null!==a&&(this.boundingBox=a.clone());const o=t.boundingSphere;return null!==o&&(this.boundingSphere=o.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const ws=new dn,Ts=new un,Es=new nn,As=new Ui,Cs=new Ui,Rs=new Ui,Ps=new Ui,Ls=new Ui,Is=new Ui,Ds=new ri,Ns=new ri,Us=new ri,Os=new Ui,Fs=new Ui,Bs=new Ui,zs=new Ui,ks=new Ui;class Vs extends Fn{constructor(t=new Ss,e=new ss){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),void 0!==t.morphTargetInfluences&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;t<e;t++){const e=i[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}getVertexPosition(t,e){const i=this.geometry,n=i.attributes.position,s=i.morphAttributes.position,r=i.morphTargetsRelative;e.fromBufferAttribute(n,t);const a=this.morphTargetInfluences;if(s&&a){Is.set(0,0,0);for(let i=0,n=s.length;i<n;i++){const n=a[i],o=s[i];0!==n&&(Ls.fromBufferAttribute(o,t),r?Is.addScaledVector(Ls,n):Is.addScaledVector(Ls.sub(e),n))}e.add(Is)}return e}raycast(t,e){const i=this.geometry,n=this.material,s=this.matrixWorld;if(void 0!==n){if(null===i.boundingSphere&&i.computeBoundingSphere(),Es.copy(i.boundingSphere),Es.applyMatrix4(s),Ts.copy(t.ray).recast(t.near),!1===Es.containsPoint(Ts.origin)){if(null===Ts.intersectSphere(Es,As))return;if(Ts.origin.distanceToSquared(As)>(t.far-t.near)**2)return}ws.copy(s).invert(),Ts.copy(t.ray).applyMatrix4(ws),null!==i.boundingBox&&!1===Ts.intersectsBox(i.boundingBox)||this._computeIntersections(t,e,Ts)}}_computeIntersections(t,e,i){let n;const s=this.geometry,r=this.material,a=s.index,o=s.attributes.position,l=s.attributes.uv,h=s.attributes.uv1,c=s.attributes.normal,u=s.groups,d=s.drawRange;if(null!==a)if(Array.isArray(r))for(let p=0,m=u.length;p<m;p++){const s=u[p],o=r[s.materialIndex];for(let r=Math.max(s.start,d.start),u=Math.min(a.count,Math.min(s.start+s.count,d.start+d.count));r<u;r+=3)n=Gs(this,o,t,i,l,h,c,a.getX(r),a.getX(r+1),a.getX(r+2)),n&&(n.faceIndex=Math.floor(r/3),n.face.materialIndex=s.materialIndex,e.push(n))}else for(let p=Math.max(0,d.start),m=Math.min(a.count,d.start+d.count);p<m;p+=3)n=Gs(this,r,t,i,l,h,c,a.getX(p),a.getX(p+1),a.getX(p+2)),n&&(n.faceIndex=Math.floor(p/3),e.push(n));else if(void 0!==o)if(Array.isArray(r))for(let p=0,m=u.length;p<m;p++){const s=u[p],a=r[s.materialIndex];for(let r=Math.max(s.start,d.start),u=Math.min(o.count,Math.min(s.start+s.count,d.start+d.count));r<u;r+=3)n=Gs(this,a,t,i,l,h,c,r,r+1,r+2),n&&(n.faceIndex=Math.floor(r/3),n.face.materialIndex=s.materialIndex,e.push(n))}else for(let p=Math.max(0,d.start),m=Math.min(o.count,d.start+d.count);p<m;p+=3)n=Gs(this,r,t,i,l,h,c,p,p+1,p+2),n&&(n.faceIndex=Math.floor(p/3),e.push(n))}}function Gs(t,e,i,n,s,r,a,o,l,h){t.getVertexPosition(o,Cs),t.getVertexPosition(l,Rs),t.getVertexPosition(h,Ps);const c=function(t,e,i,n,s,r,a,o){let l;if(l=1===e.side?n.intersectTriangle(a,r,s,!0,o):n.intersectTriangle(s,r,a,0===e.side,o),null===l)return null;ks.copy(o),ks.applyMatrix4(t.matrixWorld);const h=i.ray.origin.distanceTo(ks);return h<i.near||h>i.far?null:{distance:h,point:ks.clone(),object:t}}(t,e,i,n,Cs,Rs,Ps,zs);if(c){s&&(Ds.fromBufferAttribute(s,o),Ns.fromBufferAttribute(s,l),Us.fromBufferAttribute(s,h),c.uv=Zn.getInterpolation(zs,Cs,Rs,Ps,Ds,Ns,Us,new ri)),r&&(Ds.fromBufferAttribute(r,o),Ns.fromBufferAttribute(r,l),Us.fromBufferAttribute(r,h),c.uv1=Zn.getInterpolation(zs,Cs,Rs,Ps,Ds,Ns,Us,new ri),c.uv2=c.uv1),a&&(Os.fromBufferAttribute(a,o),Fs.fromBufferAttribute(a,l),Bs.fromBufferAttribute(a,h),c.normal=Zn.getInterpolation(zs,Cs,Rs,Ps,Os,Fs,Bs,new Ui),c.normal.dot(n.direction)>0&&c.normal.multiplyScalar(-1));const t={a:o,b:l,c:h,normal:new Ui,materialIndex:0};Zn.getNormal(Cs,Rs,Ps,t.normal),c.face=t}return c}class Hs extends Ss{constructor(t=1,e=1,i=1,n=1,s=1,r=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:n,heightSegments:s,depthSegments:r};const a=this;n=Math.floor(n),s=Math.floor(s),r=Math.floor(r);const o=[],l=[],h=[],c=[];let u=0,d=0;function p(t,e,i,n,s,r,p,m,f,g,_){const v=r/f,y=p/g,x=r/2,M=p/2,b=m/2,S=f+1,w=g+1;let T=0,E=0;const A=new Ui;for(let a=0;a<w;a++){const r=a*y-M;for(let o=0;o<S;o++){const u=o*v-x;A[t]=u*n,A[e]=r*s,A[i]=b,l.push(A.x,A.y,A.z),A[t]=0,A[e]=0,A[i]=m>0?1:-1,h.push(A.x,A.y,A.z),c.push(o/f),c.push(1-a/g),T+=1}}for(let a=0;a<g;a++)for(let t=0;t<f;t++){const e=u+t+S*a,i=u+t+S*(a+1),n=u+(t+1)+S*(a+1),s=u+(t+1)+S*a;o.push(e,i,s),o.push(i,n,s),E+=6}a.addGroup(d,E,_),d+=E,u+=T}p("z","y","x",-1,-1,i,e,t,r,s,0),p("z","y","x",1,-1,i,e,-t,r,s,1),p("x","z","y",1,1,t,i,e,n,r,2),p("x","z","y",1,-1,t,i,-e,n,r,3),p("x","y","z",1,-1,t,e,i,n,s,4),p("x","y","z",-1,-1,t,e,-i,n,s,5),this.setIndex(o),this.setAttribute("position",new fs(l,3)),this.setAttribute("normal",new fs(h,3)),this.setAttribute("uv",new fs(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Hs(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function Ws(t){const e={};for(const i in t){e[i]={};for(const n in t[i]){const s=t[i][n];s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)?s.isRenderTargetTexture?e[i][n]=null:e[i][n]=s.clone():Array.isArray(s)?e[i][n]=s.slice():e[i][n]=s}}return e}function qs(t){const e={};for(let i=0;i<t.length;i++){const n=Ws(t[i]);for(const t in n)e[t]=n[t]}return e}function Xs(t){return null===t.getRenderTarget()?t.outputColorSpace:yi.workingColorSpace}const js={clone:Ws,merge:qs};class Ys extends ns{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1,clipCullDistance:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==t&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Ws(t.uniforms),this.uniformsGroups=function(t){const e=[];for(let i=0;i<t.length;i++)e.push(t[i].clone());return e}(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 n in this.uniforms){const i=this.uniforms[n].value;i&&i.isTexture?e.uniforms[n]={type:"t",value:i.toJSON(t).uuid}:i&&i.isColor?e.uniforms[n]={type:"c",value:i.getHex()}:i&&i.isVector2?e.uniforms[n]={type:"v2",value:i.toArray()}:i&&i.isVector3?e.uniforms[n]={type:"v3",value:i.toArray()}:i&&i.isVector4?e.uniforms[n]={type:"v4",value:i.toArray()}:i&&i.isMatrix3?e.uniforms[n]={type:"m3",value:i.toArray()}:i&&i.isMatrix4?e.uniforms[n]={type:"m4",value:i.toArray()}:e.uniforms[n]={value:i}}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 i={};for(const n in this.extensions)!0===this.extensions[n]&&(i[n]=!0);return Object.keys(i).length>0&&(e.extensions=i),e}}class Zs extends Fn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new dn,this.projectionMatrix=new dn,this.projectionMatrixInverse=new dn,this.coordinateSystem=He}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)}}class Js extends Zs{constructor(t=50,e=1,i=.1,n=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=i,this.far=n,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=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=2*Ze*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*Ye*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*Ze*Math.atan(Math.tan(.5*Ye*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(t,e,i,n,s,r){this.aspect=t/e,null===this.view&&(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=i,this.view.offsetY=n,this.view.width=s,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*Ye*this.fov)/this.zoom,i=2*e,n=this.aspect*i,s=-.5*n;const r=this.view;if(null!==this.view&&this.view.enabled){const t=r.fullWidth,a=r.fullHeight;s+=r.offsetX*n/t,e-=r.offsetY*i/a,n*=r.width/t,i*=r.height/a}const a=this.filmOffset;0!==a&&(s+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+n,e,e-i,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,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const Ks=-90;class $s extends Fn{constructor(t,e,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const n=new Js(Ks,1,t,e);n.layers=this.layers,this.add(n);const s=new Js(Ks,1,t,e);s.layers=this.layers,this.add(s);const r=new Js(Ks,1,t,e);r.layers=this.layers,this.add(r);const a=new Js(Ks,1,t,e);a.layers=this.layers,this.add(a);const o=new Js(Ks,1,t,e);o.layers=this.layers,this.add(o);const l=new Js(Ks,1,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[i,n,s,r,a,o]=e;for(const l of e)this.remove(l);if(t===He)i.up.set(0,1,0),i.lookAt(1,0,0),n.up.set(0,1,0),n.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),r.up.set(0,0,1),r.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(t!==We)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);i.up.set(0,-1,0),i.lookAt(-1,0,0),n.up.set(0,-1,0),n.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),r.up.set(0,0,-1),r.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const l of e)this.add(l),l.updateMatrixWorld()}update(t,e){null===this.parent&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:n}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[s,r,a,o,l,h]=this.children,c=t.getRenderTarget(),u=t.getActiveCubeFace(),d=t.getActiveMipmapLevel(),p=t.xr.enabled;t.xr.enabled=!1;const m=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,t.setRenderTarget(i,0,n),t.render(e,s),t.setRenderTarget(i,1,n),t.render(e,r),t.setRenderTarget(i,2,n),t.render(e,a),t.setRenderTarget(i,3,n),t.render(e,o),t.setRenderTarget(i,4,n),t.render(e,l),i.texture.generateMipmaps=m,t.setRenderTarget(i,5,n),t.render(e,h),t.setRenderTarget(c,u,d),t.xr.enabled=p,i.texture.needsPMREMUpdate=!0}}class Qs extends Ci{constructor(t,e,i,n,s,r,a,o,l,h){super(t=void 0!==t?t:[],e=void 0!==e?e:ot,i,n,s,r,a,o,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class tr extends Li{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const i={width:t,height:t,depth:1},n=[i,i,i,i,i,i];void 0!==e.encoding&&(mi("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),e.colorSpace=e.encoding===Me?Se:be),this.texture=new Qs(n,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=void 0!==e.generateMipmaps&&e.generateMipmaps,this.texture.minFilter=void 0!==e.minFilter?e.minFilter:vt}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 i=new Hs(5,5,5),n=new Ys({name:"CubemapFromEquirect",uniforms:Ws({tEquirect:{value:null}}),vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",side:1,blending:0});n.uniforms.tEquirect.value=e;const s=new Vs(i,n),r=e.minFilter;return e.minFilter===xt&&(e.minFilter=vt),new $s(1,10,this).update(t,s),e.minFilter=r,s.geometry.dispose(),s.material.dispose(),this}clear(t,e,i,n){const s=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,i,n);t.setRenderTarget(s)}}const er=new Ui,ir=new Ui,nr=new ai;class sr{constructor(t=new Ui(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,i,n){return this.normal.set(t,e,i),this.constant=n,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,i){const n=er.subVectors(i,e).cross(ir.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(n,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 i=t.delta(er),n=this.normal.dot(i);if(0===n)return 0===this.distanceToPoint(t.start)?e.copy(t.start):null;const s=-(t.start.dot(this.normal)+this.constant)/n;return s<0||s>1?null:e.copy(t.start).addScaledVector(i,s)}intersectsLine(t){const e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<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 i=e||nr.getNormalMatrix(t),n=this.coplanarPoint(er).applyMatrix4(t),s=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(s),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const rr=new nn,ar=new Ui;class or{constructor(t=new sr,e=new sr,i=new sr,n=new sr,s=new sr,r=new sr){this.planes=[t,e,i,n,s,r]}set(t,e,i,n,s,r){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(i),a[3].copy(n),a[4].copy(s),a[5].copy(r),this}copy(t){const e=this.planes;for(let i=0;i<6;i++)e[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t,e=2e3){const i=this.planes,n=t.elements,s=n[0],r=n[1],a=n[2],o=n[3],l=n[4],h=n[5],c=n[6],u=n[7],d=n[8],p=n[9],m=n[10],f=n[11],g=n[12],_=n[13],v=n[14],y=n[15];if(i[0].setComponents(o-s,u-l,f-d,y-g).normalize(),i[1].setComponents(o+s,u+l,f+d,y+g).normalize(),i[2].setComponents(o+r,u+h,f+p,y+_).normalize(),i[3].setComponents(o-r,u-h,f-p,y-_).normalize(),i[4].setComponents(o-a,u-c,f-m,y-v).normalize(),e===He)i[5].setComponents(o+a,u+c,f+m,y+v).normalize();else{if(e!==We)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);i[5].setComponents(a,c,m,v).normalize()}return this}intersectsObject(t){if(void 0!==t.boundingSphere)null===t.boundingSphere&&t.computeBoundingSphere(),rr.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;null===e.boundingSphere&&e.computeBoundingSphere(),rr.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(rr)}intersectsSprite(t){return rr.center.set(0,0,0),rr.radius=.7071067811865476,rr.applyMatrix4(t.matrixWorld),this.intersectsSphere(rr)}intersectsSphere(t){const e=this.planes,i=t.center,n=-t.radius;for(let s=0;s<6;s++)if(e[s].distanceToPoint(i)<n)return!1;return!0}intersectsBox(t){const e=this.planes;for(let i=0;i<6;i++){const n=e[i];if(ar.x=n.normal.x>0?t.max.x:t.min.x,ar.y=n.normal.y>0?t.max.y:t.min.y,ar.z=n.normal.z>0?t.max.z:t.min.z,n.distanceToPoint(ar)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function lr(){let t=null,e=!1,i=null,n=null;function s(e,r){i(e,r),n=t.requestAnimationFrame(s)}return{start(){!0!==e&&null!==i&&(n=t.requestAnimationFrame(s),e=!0)},stop(){t.cancelAnimationFrame(n),e=!1},setAnimationLoop(t){i=t},setContext(e){t=e}}}function hr(t,e){const i=e.isWebGL2,n=new WeakMap;return{get:t=>(t.isInterleavedBufferAttribute&&(t=t.data),n.get(t)),remove(e){e.isInterleavedBufferAttribute&&(e=e.data);const i=n.get(e);i&&(t.deleteBuffer(i.buffer),n.delete(e))},update(e,s){if(e.isGLBufferAttribute){const t=n.get(e);return void((!t||t.version<e.version)&&n.set(e,{buffer:e.buffer,type:e.type,bytesPerElement:e.elementSize,version:e.version}))}e.isInterleavedBufferAttribute&&(e=e.data);const r=n.get(e);if(void 0===r)n.set(e,function(e,n){const s=e.array,r=e.usage,a=s.byteLength,o=t.createBuffer();let l;if(t.bindBuffer(n,o),t.bufferData(n,s,r),e.onUploadCallback(),s instanceof Float32Array)l=t.FLOAT;else if(s instanceof Uint16Array)if(e.isFloat16BufferAttribute){if(!i)throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");l=t.HALF_FLOAT}else l=t.UNSIGNED_SHORT;else if(s instanceof Int16Array)l=t.SHORT;else if(s instanceof Uint32Array)l=t.UNSIGNED_INT;else if(s instanceof Int32Array)l=t.INT;else if(s instanceof Int8Array)l=t.BYTE;else if(s instanceof Uint8Array)l=t.UNSIGNED_BYTE;else{if(!(s instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+s);l=t.UNSIGNED_BYTE}return{buffer:o,type:l,bytesPerElement:s.BYTES_PER_ELEMENT,version:e.version,size:a}}(e,s));else if(r.version<e.version){if(r.size!==e.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.");!function(e,n,s){const r=n.array,a=n._updateRange,o=n.updateRanges;if(t.bindBuffer(s,e),-1===a.count&&0===o.length&&t.bufferSubData(s,0,r),0!==o.length){for(let e=0,n=o.length;e<n;e++){const n=o[e];i?t.bufferSubData(s,n.start*r.BYTES_PER_ELEMENT,r,n.start,n.count):t.bufferSubData(s,n.start*r.BYTES_PER_ELEMENT,r.subarray(n.start,n.start+n.count))}n.clearUpdateRanges()}-1!==a.count&&(i?t.bufferSubData(s,a.offset*r.BYTES_PER_ELEMENT,r,a.offset,a.count):t.bufferSubData(s,a.offset*r.BYTES_PER_ELEMENT,r.subarray(a.offset,a.offset+a.count)),a.count=-1),n.onUploadCallback()}(r.buffer,e,s),r.version=e.version}}}}class cr extends Ss{constructor(t=1,e=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:i,heightSegments:n};const s=t/2,r=e/2,a=Math.floor(i),o=Math.floor(n),l=a+1,h=o+1,c=t/a,u=e/o,d=[],p=[],m=[],f=[];for(let g=0;g<h;g++){const t=g*u-r;for(let e=0;e<l;e++){const i=e*c-s;p.push(i,-t,0),m.push(0,0,1),f.push(e/a),f.push(1-g/o)}}for(let g=0;g<o;g++)for(let t=0;t<a;t++){const e=t+l*g,i=t+l*(g+1),n=t+1+l*(g+1),s=t+1+l*g;d.push(e,i,s),d.push(i,n,s)}this.setIndex(d),this.setAttribute("position",new fs(p,3)),this.setAttribute("normal",new fs(m,3)),this.setAttribute("uv",new fs(f,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new cr(t.width,t.height,t.widthSegments,t.heightSegments)}}const ur={alphahash_fragment:"#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n\tattribute float batchId;\n\tuniform highp sampler2D batchingTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",batching_vertex:"#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( batchId );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n\t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"\nconst mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(\n\tvec3( 0.8224621, 0.177538, 0.0 ),\n\tvec3( 0.0331941, 0.9668058, 0.0 ),\n\tvec3( 0.0170827, 0.0723974, 0.9105199 )\n);\nconst mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.2249401, - 0.2249404, 0.0 ),\n\tvec3( - 0.0420569, 1.0420571, 0.0 ),\n\tvec3( - 0.0196376, - 0.0786361, 1.0982735 )\n);\nvec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );\n}\nvec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );\n}\nvec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn 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 );\n}\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn sRGBTransferOETF( value );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( LEGACY_LIGHTS )\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#else\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = 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 );\n\t\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec2 packDepthToRG( in highp float v ) {\n\treturn packDepthToRGBA( v ).yx;\n}\nfloat unpackRGToDepth( const in highp vec2 v ) {\n\treturn unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor *= toneMappingExposure;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\treturn color;\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",depth_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}"},dr={common:{diffuse:{value:new ts(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ai},alphaMap:{value:null},alphaMapTransform:{value:new ai},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ai}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ai}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ai}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ai},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ai},normalScale:{value:new ri(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ai},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ai}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ai}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ai}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ts(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new ts(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ai},alphaTest:{value:0},uvTransform:{value:new ai}},sprite:{diffuse:{value:new ts(16777215)},opacity:{value:1},center:{value:new ri(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ai},alphaMap:{value:null},alphaMapTransform:{value:new ai},alphaTest:{value:0}}},pr={basic:{uniforms:qs([dr.common,dr.specularmap,dr.envmap,dr.aomap,dr.lightmap,dr.fog]),vertexShader:ur.meshbasic_vert,fragmentShader:ur.meshbasic_frag},lambert:{uniforms:qs([dr.common,dr.specularmap,dr.envmap,dr.aomap,dr.lightmap,dr.emissivemap,dr.bumpmap,dr.normalmap,dr.displacementmap,dr.fog,dr.lights,{emissive:{value:new ts(0)}}]),vertexShader:ur.meshlambert_vert,fragmentShader:ur.meshlambert_frag},phong:{uniforms:qs([dr.common,dr.specularmap,dr.envmap,dr.aomap,dr.lightmap,dr.emissivemap,dr.bumpmap,dr.normalmap,dr.displacementmap,dr.fog,dr.lights,{emissive:{value:new ts(0)},specular:{value:new ts(1118481)},shininess:{value:30}}]),vertexShader:ur.meshphong_vert,fragmentShader:ur.meshphong_frag},standard:{uniforms:qs([dr.common,dr.envmap,dr.aomap,dr.lightmap,dr.emissivemap,dr.bumpmap,dr.normalmap,dr.displacementmap,dr.roughnessmap,dr.metalnessmap,dr.fog,dr.lights,{emissive:{value:new ts(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ur.meshphysical_vert,fragmentShader:ur.meshphysical_frag},toon:{uniforms:qs([dr.common,dr.aomap,dr.lightmap,dr.emissivemap,dr.bumpmap,dr.normalmap,dr.displacementmap,dr.gradientmap,dr.fog,dr.lights,{emissive:{value:new ts(0)}}]),vertexShader:ur.meshtoon_vert,fragmentShader:ur.meshtoon_frag},matcap:{uniforms:qs([dr.common,dr.bumpmap,dr.normalmap,dr.displacementmap,dr.fog,{matcap:{value:null}}]),vertexShader:ur.meshmatcap_vert,fragmentShader:ur.meshmatcap_frag},points:{uniforms:qs([dr.points,dr.fog]),vertexShader:ur.points_vert,fragmentShader:ur.points_frag},dashed:{uniforms:qs([dr.common,dr.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ur.linedashed_vert,fragmentShader:ur.linedashed_frag},depth:{uniforms:qs([dr.common,dr.displacementmap]),vertexShader:ur.depth_vert,fragmentShader:ur.depth_frag},normal:{uniforms:qs([dr.common,dr.bumpmap,dr.normalmap,dr.displacementmap,{opacity:{value:1}}]),vertexShader:ur.meshnormal_vert,fragmentShader:ur.meshnormal_frag},sprite:{uniforms:qs([dr.sprite,dr.fog]),vertexShader:ur.sprite_vert,fragmentShader:ur.sprite_frag},background:{uniforms:{uvTransform:{value:new ai},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ur.background_vert,fragmentShader:ur.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:ur.backgroundCube_vert,fragmentShader:ur.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ur.cube_vert,fragmentShader:ur.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ur.equirect_vert,fragmentShader:ur.equirect_frag},distanceRGBA:{uniforms:qs([dr.common,dr.displacementmap,{referencePosition:{value:new Ui},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ur.distanceRGBA_vert,fragmentShader:ur.distanceRGBA_frag},shadow:{uniforms:qs([dr.lights,dr.fog,{color:{value:new ts(0)},opacity:{value:1}}]),vertexShader:ur.shadow_vert,fragmentShader:ur.shadow_frag}};pr.physical={uniforms:qs([pr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ai},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ai},clearcoatNormalScale:{value:new ri(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ai},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ai},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ai},sheen:{value:0},sheenColor:{value:new ts(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ai},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ai},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ai},transmissionSamplerSize:{value:new ri},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ai},attenuationDistance:{value:0},attenuationColor:{value:new ts(0)},specularColor:{value:new ts(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ai},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ai},anisotropyVector:{value:new ri},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ai}}]),vertexShader:ur.meshphysical_vert,fragmentShader:ur.meshphysical_frag};const mr={r:0,b:0,g:0};function fr(t,e,i,n,s,r,a){const o=new ts(0);let l,h,c=!0===r?0:1,u=null,d=0,p=null;function m(e,i){e.getRGB(mr,Xs(t)),n.buffers.color.setClear(mr.r,mr.g,mr.b,i,a)}return{getClearColor:()=>o,setClearColor(t,e=1){o.set(t),c=e,m(o,c)},getClearAlpha:()=>c,setClearAlpha(t){c=t,m(o,c)},render(r,f){let g=!1,_=!0===f.isScene?f.background:null;_&&_.isTexture&&(_=(f.backgroundBlurriness>0?i:e).get(_)),null===_?m(o,c):_&&_.isColor&&(m(_,1),g=!0);const v=t.xr.getEnvironmentBlendMode();"additive"===v?n.buffers.color.setClear(0,0,0,1,a):"alpha-blend"===v&&n.buffers.color.setClear(0,0,0,0,a),(t.autoClear||g)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),_&&(_.isCubeTexture||_.mapping===ut)?(void 0===h&&(h=new Vs(new Hs(1,1,1),new Ys({name:"BackgroundCubeMaterial",uniforms:Ws(pr.backgroundCube.uniforms),vertexShader:pr.backgroundCube.vertexShader,fragmentShader:pr.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(t,e,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(h.material,"envMap",{get(){return this.uniforms.envMap.value}}),s.update(h)),h.material.uniforms.envMap.value=_,h.material.uniforms.flipEnvMap.value=_.isCubeTexture&&!1===_.isRenderTargetTexture?-1:1,h.material.uniforms.backgroundBlurriness.value=f.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=f.backgroundIntensity,h.material.toneMapped=yi.getTransfer(_.colorSpace)!==Ce,u===_&&d===_.version&&p===t.toneMapping||(h.material.needsUpdate=!0,u=_,d=_.version,p=t.toneMapping),h.layers.enableAll(),r.unshift(h,h.geometry,h.material,0,0,null)):_&&_.isTexture&&(void 0===l&&(l=new Vs(new cr(2,2),new Ys({name:"BackgroundMaterial",uniforms:Ws(pr.background.uniforms),vertexShader:pr.background.vertexShader,fragmentShader:pr.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get(){return this.uniforms.t2D.value}}),s.update(l)),l.material.uniforms.t2D.value=_,l.material.uniforms.backgroundIntensity.value=f.backgroundIntensity,l.material.toneMapped=yi.getTransfer(_.colorSpace)!==Ce,!0===_.matrixAutoUpdate&&_.updateMatrix(),l.material.uniforms.uvTransform.value.copy(_.matrix),u===_&&d===_.version&&p===t.toneMapping||(l.material.needsUpdate=!0,u=_,d=_.version,p=t.toneMapping),l.layers.enableAll(),r.unshift(l,l.geometry,l.material,0,0,null))}}}function gr(t,e,i,n){const s=t.getParameter(t.MAX_VERTEX_ATTRIBS),r=n.isWebGL2?null:e.get("OES_vertex_array_object"),a=n.isWebGL2||null!==r,o={},l=p(null);let h=l,c=!1;function u(e){return n.isWebGL2?t.bindVertexArray(e):r.bindVertexArrayOES(e)}function d(e){return n.isWebGL2?t.deleteVertexArray(e):r.deleteVertexArrayOES(e)}function p(t){const e=[],i=[],n=[];for(let r=0;r<s;r++)e[r]=0,i[r]=0,n[r]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:e,enabledAttributes:i,attributeDivisors:n,object:t,attributes:{},index:null}}function m(){const t=h.newAttributes;for(let e=0,i=t.length;e<i;e++)t[e]=0}function f(t){g(t,0)}function g(i,s){const r=h.newAttributes,a=h.enabledAttributes,o=h.attributeDivisors;r[i]=1,0===a[i]&&(t.enableVertexAttribArray(i),a[i]=1),o[i]!==s&&((n.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](i,s),o[i]=s)}function _(){const e=h.newAttributes,i=h.enabledAttributes;for(let n=0,s=i.length;n<s;n++)i[n]!==e[n]&&(t.disableVertexAttribArray(n),i[n]=0)}function v(e,i,n,s,r,a,o){!0===o?t.vertexAttribIPointer(e,i,n,r,a):t.vertexAttribPointer(e,i,n,s,r,a)}function y(){x(),c=!0,h!==l&&(h=l,u(h.object))}function x(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup(s,l,d,y,x){let M=!1;if(a){const e=function(e,i,s){const a=!0===s.wireframe;let l=o[e.id];void 0===l&&(l={},o[e.id]=l);let h=l[i.id];void 0===h&&(h={},l[i.id]=h);let c=h[a];return void 0===c&&(c=p(n.isWebGL2?t.createVertexArray():r.createVertexArrayOES()),h[a]=c),c}(y,d,l);h!==e&&(h=e,u(h.object)),M=function(t,e,i,n){const s=h.attributes,r=e.attributes;let a=0;const o=i.getAttributes();for(const l in o)if(o[l].location>=0){const e=s[l];let i=r[l];if(void 0===i&&("instanceMatrix"===l&&t.instanceMatrix&&(i=t.instanceMatrix),"instanceColor"===l&&t.instanceColor&&(i=t.instanceColor)),void 0===e)return!0;if(e.attribute!==i)return!0;if(i&&e.data!==i.data)return!0;a++}return h.attributesNum!==a||h.index!==n}(s,y,d,x),M&&function(t,e,i,n){const s={},r=e.attributes;let a=0;const o=i.getAttributes();for(const l in o)if(o[l].location>=0){let e=r[l];void 0===e&&("instanceMatrix"===l&&t.instanceMatrix&&(e=t.instanceMatrix),"instanceColor"===l&&t.instanceColor&&(e=t.instanceColor));const i={};i.attribute=e,e&&e.data&&(i.data=e.data),s[l]=i,a++}h.attributes=s,h.attributesNum=a,h.index=n}(s,y,d,x)}else{const t=!0===l.wireframe;h.geometry===y.id&&h.program===d.id&&h.wireframe===t||(h.geometry=y.id,h.program=d.id,h.wireframe=t,M=!0)}null!==x&&i.update(x,t.ELEMENT_ARRAY_BUFFER),(M||c)&&(c=!1,function(s,r,a,o){if(!1===n.isWebGL2&&(s.isInstancedMesh||o.isInstancedBufferGeometry)&&null===e.get("ANGLE_instanced_arrays"))return;m();const l=o.attributes,h=a.getAttributes(),c=r.defaultAttributeValues;for(const e in h){const r=h[e];if(r.location>=0){let a=l[e];if(void 0===a&&("instanceMatrix"===e&&s.instanceMatrix&&(a=s.instanceMatrix),"instanceColor"===e&&s.instanceColor&&(a=s.instanceColor)),void 0!==a){const e=a.normalized,l=a.itemSize,h=i.get(a);if(void 0===h)continue;const c=h.buffer,u=h.type,d=h.bytesPerElement,p=!0===n.isWebGL2&&(u===t.INT||u===t.UNSIGNED_INT||a.gpuType===St);if(a.isInterleavedBufferAttribute){const i=a.data,n=i.stride,h=a.offset;if(i.isInstancedInterleavedBuffer){for(let t=0;t<r.locationSize;t++)g(r.location+t,i.meshPerAttribute);!0!==s.isInstancedMesh&&void 0===o._maxInstanceCount&&(o._maxInstanceCount=i.meshPerAttribute*i.count)}else for(let t=0;t<r.locationSize;t++)f(r.location+t);t.bindBuffer(t.ARRAY_BUFFER,c);for(let t=0;t<r.locationSize;t++)v(r.location+t,l/r.locationSize,u,e,n*d,(h+l/r.locationSize*t)*d,p)}else{if(a.isInstancedBufferAttribute){for(let t=0;t<r.locationSize;t++)g(r.location+t,a.meshPerAttribute);!0!==s.isInstancedMesh&&void 0===o._maxInstanceCount&&(o._maxInstanceCount=a.meshPerAttribute*a.count)}else for(let t=0;t<r.locationSize;t++)f(r.location+t);t.bindBuffer(t.ARRAY_BUFFER,c);for(let t=0;t<r.locationSize;t++)v(r.location+t,l/r.locationSize,u,e,l*d,l/r.locationSize*t*d,p)}}else if(void 0!==c){const i=c[e];if(void 0!==i)switch(i.length){case 2:t.vertexAttrib2fv(r.location,i);break;case 3:t.vertexAttrib3fv(r.location,i);break;case 4:t.vertexAttrib4fv(r.location,i);break;default:t.vertexAttrib1fv(r.location,i)}}}}_()}(s,l,d,y),null!==x&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,i.get(x).buffer))},reset:y,resetDefaultState:x,dispose(){y();for(const t in o){const e=o[t];for(const t in e){const i=e[t];for(const t in i)d(i[t].object),delete i[t];delete e[t]}delete o[t]}},releaseStatesOfGeometry(t){if(void 0===o[t.id])return;const e=o[t.id];for(const i in e){const t=e[i];for(const e in t)d(t[e].object),delete t[e];delete e[i]}delete o[t.id]},releaseStatesOfProgram(t){for(const e in o){const i=o[e];if(void 0===i[t.id])continue;const n=i[t.id];for(const t in n)d(n[t].object),delete n[t];delete i[t.id]}},initAttributes:m,enableAttribute:f,disableUnusedAttributes:_}}function _r(t,e,i,n){const s=n.isWebGL2;let r;this.setMode=function(t){r=t},this.render=function(e,n){t.drawArrays(r,e,n),i.update(n,r,1)},this.renderInstances=function(n,a,o){if(0===o)return;let l,h;if(s)l=t,h="drawArraysInstanced";else if(l=e.get("ANGLE_instanced_arrays"),h="drawArraysInstancedANGLE",null===l)return;l[h](r,n,a,o),i.update(a,r,o)},this.renderMultiDraw=function(t,n,s){if(0===s)return;const a=e.get("WEBGL_multi_draw");if(null===a)for(let e=0;e<s;e++)this.render(t[e],n[e]);else{a.multiDrawArraysWEBGL(r,t,0,n,0,s);let e=0;for(let t=0;t<s;t++)e+=n[t];i.update(e,r,1)}}}function vr(t,e,i){let n;function s(e){if("highp"===e){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const r="undefined"!=typeof WebGL2RenderingContext&&"WebGL2RenderingContext"===t.constructor.name;let a=void 0!==i.precision?i.precision:"highp";const o=s(a);o!==a&&(a=o);const l=r||e.has("WEBGL_draw_buffers"),h=!0===i.logarithmicDepthBuffer,c=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),u=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),d=t.getParameter(t.MAX_TEXTURE_SIZE),p=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),m=t.getParameter(t.MAX_VERTEX_ATTRIBS),f=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),g=t.getParameter(t.MAX_VARYING_VECTORS),_=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),v=u>0,y=r||e.has("OES_texture_float"),x=v&&y,M=r?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:r,drawBuffers:l,getMaxAnisotropy(){if(void 0!==n)return n;if(!0===e.has("EXT_texture_filter_anisotropic")){const i=e.get("EXT_texture_filter_anisotropic");n=t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n},getMaxPrecision:s,precision:a,logarithmicDepthBuffer:h,maxTextures:c,maxVertexTextures:u,maxTextureSize:d,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:f,maxVaryings:g,maxFragmentUniforms:_,vertexTextures:v,floatFragmentTextures:y,floatVertexTextures:x,maxSamples:M}}function yr(t){const e=this;let i=null,n=0,s=!1,r=!1;const a=new sr,o=new ai,l={value:null,needsUpdate:!1};function h(t,i,n,s){const r=null!==t?t.length:0;let h=null;if(0!==r){if(h=l.value,!0!==s||null===h){const e=n+4*r,s=i.matrixWorldInverse;o.getNormalMatrix(s),(null===h||h.length<e)&&(h=new Float32Array(e));for(let i=0,l=n;i!==r;++i,l+=4)a.copy(t[i]).applyMatrix4(s,o),a.normal.toArray(h,l),h[l+3]=a.constant}l.value=h,l.needsUpdate=!0}return e.numPlanes=r,e.numIntersection=0,h}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(t,e){const i=0!==t.length||e||0!==n||s;return s=e,n=t.length,i},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(t,e){i=h(t,e,0)},this.setState=function(a,o,c){const u=a.clippingPlanes,d=a.clipIntersection,p=a.clipShadows,m=t.get(a);if(!s||null===u||0===u.length||r&&!p)r?h(null):(l.value!==i&&(l.value=i,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0);else{const t=r?0:n,e=4*t;let s=m.clippingState||null;l.value=s,s=h(u,o,e,c);for(let n=0;n!==e;++n)s[n]=i[n];m.clippingState=s,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=t}}}function xr(t){let e=new WeakMap;function i(t,e){return e===ht?t.mapping=ot:e===ct&&(t.mapping=lt),t}function n(t){const i=t.target;i.removeEventListener("dispose",n);const s=e.get(i);void 0!==s&&(e.delete(i),s.dispose())}return{get(s){if(s&&s.isTexture){const r=s.mapping;if(r===ht||r===ct){if(e.has(s))return i(e.get(s).texture,s.mapping);{const r=s.image;if(r&&r.height>0){const a=new tr(r.height/2);return a.fromEquirectangularTexture(t,s),e.set(s,a),s.addEventListener("dispose",n),i(a.texture,s.mapping)}return null}}}return s},dispose(){e=new WeakMap}}}class Mr extends Zs{constructor(t=-1,e=1,i=1,n=-1,s=.1,r=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=i,this.bottom=n,this.near=s,this.far=r,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=null===t.view?null:Object.assign({},t.view),this}setViewOffset(t,e,i,n,s,r){null===this.view&&(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=i,this.view.offsetY=n,this.view.width=s,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let s=i-t,r=i+t,a=n+e,o=n-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=t*this.view.offsetX,r=s+t*this.view.width,a-=e*this.view.offsetY,o=a-e*this.view.height}this.projectionMatrix.makeOrthographic(s,r,a,o,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,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}const br=[.125,.215,.35,.446,.526,.582],Sr=new Mr,wr=new ts;let Tr=null,Er=0,Ar=0;const Cr=(1+Math.sqrt(5))/2,Rr=1/Cr,Pr=[new Ui(1,1,1),new Ui(-1,1,1),new Ui(1,1,-1),new Ui(-1,1,-1),new Ui(0,Cr,Rr),new Ui(0,Cr,-Rr),new Ui(Rr,0,Cr),new Ui(-Rr,0,Cr),new Ui(Cr,Rr,0),new Ui(-Cr,Rr,0)];class Lr{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,i=.1,n=100){Tr=this._renderer.getRenderTarget(),Er=this._renderer.getActiveCubeFace(),Ar=this._renderer.getActiveMipmapLevel(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(t,i,n,s),e>0&&this._blur(s,0,0,e),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Ur(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Nr(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(Tr,Er,Ar),t.scissorTest=!1,Dr(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===ot||t.mapping===lt?this._setSize(0===t.image.length?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Tr=this._renderer.getRenderTarget(),Er=this._renderer.getActiveCubeFace(),Ar=this._renderer.getActiveMipmapLevel();const i=e||this._allocateTargets();return this._textureToCubeUV(t,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,i={magFilter:vt,minFilter:vt,generateMipmaps:!1,type:Et,format:Pt,colorSpace:we,depthBuffer:!1},n=Ir(t,e,i);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=Ir(t,e,i);const{_lodMax:n}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=function(t){const e=[],i=[],n=[];let s=t;const r=t-4+1+br.length;for(let a=0;a<r;a++){const r=Math.pow(2,s);i.push(r);let o=1/r;a>t-4?o=br[a-t+4-1]:0===a&&(o=0),n.push(o);const l=1/(r-2),h=-l,c=1+l,u=[h,h,c,h,c,c,h,h,c,c,h,c],d=6,p=6,m=3,f=2,g=1,_=new Float32Array(m*p*d),v=new Float32Array(f*p*d),y=new Float32Array(g*p*d);for(let t=0;t<d;t++){const e=t%3*2/3-1,i=t>2?0:-1,n=[e,i,0,e+2/3,i,0,e+2/3,i+1,0,e,i,0,e+2/3,i+1,0,e,i+1,0];_.set(n,m*p*t),v.set(u,f*p*t);const s=[t,t,t,t,t,t];y.set(s,g*p*t)}const x=new Ss;x.setAttribute("position",new ds(_,m)),x.setAttribute("uv",new ds(v,f)),x.setAttribute("faceIndex",new ds(y,g)),e.push(x),s>4&&s--}return{lodPlanes:e,sizeLods:i,sigmas:n}}(n)),this._blurMaterial=function(t,e,i){const n=new Float32Array(20),s=new Ui(0,1,0);return new Ys({name:"SphericalGaussianBlur",defines:{n:20,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}(n,t,e)}return n}_compileMaterial(t){const e=new Vs(this._lodPlanes[0],t);this._renderer.compile(e,Sr)}_sceneToCubeUV(t,e,i,n){const s=new Js(90,1,e,i),r=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear,h=o.toneMapping;o.getClearColor(wr),o.toneMapping=0,o.autoClear=!1;const c=new ss({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),u=new Vs(new Hs,c);let d=!1;const p=t.background;p?p.isColor&&(c.color.copy(p),t.background=null,d=!0):(c.color.copy(wr),d=!0);for(let m=0;m<6;m++){const e=m%3;0===e?(s.up.set(0,r[m],0),s.lookAt(a[m],0,0)):1===e?(s.up.set(0,0,r[m]),s.lookAt(0,a[m],0)):(s.up.set(0,r[m],0),s.lookAt(0,0,a[m]));const i=this._cubeSize;Dr(n,e*i,m>2?i:0,i,i),o.setRenderTarget(n),d&&o.render(u,s),o.render(t,s)}u.geometry.dispose(),u.material.dispose(),o.toneMapping=h,o.autoClear=l,t.background=p}_textureToCubeUV(t,e){const i=this._renderer,n=t.mapping===ot||t.mapping===lt;n?(null===this._cubemapMaterial&&(this._cubemapMaterial=Ur()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===t.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=Nr());const s=n?this._cubemapMaterial:this._equirectMaterial,r=new Vs(this._lodPlanes[0],s);s.uniforms.envMap.value=t;const a=this._cubeSize;Dr(e,0,0,3*a,2*a),i.setRenderTarget(e),i.render(r,Sr)}_applyPMREM(t){const e=this._renderer,i=e.autoClear;e.autoClear=!1;for(let n=1;n<this._lodPlanes.length;n++){const e=Math.sqrt(this._sigmas[n]*this._sigmas[n]-this._sigmas[n-1]*this._sigmas[n-1]),i=Pr[(n-1)%Pr.length];this._blur(t,n-1,n,e,i)}e.autoClear=i}_blur(t,e,i,n,s){const r=this._pingPongRenderTarget;this._halfBlur(t,r,e,i,n,"latitudinal",s),this._halfBlur(r,t,i,i,n,"longitudinal",s)}_halfBlur(t,e,i,n,s,r,a){const o=this._renderer,l=this._blurMaterial,h=new Vs(this._lodPlanes[n],l),c=l.uniforms,u=this._sizeLods[i]-1,d=isFinite(s)?Math.PI/(2*u):2*Math.PI/39,p=s/d,m=isFinite(s)?1+Math.floor(3*p):20,f=[];let g=0;for(let y=0;y<20;++y){const t=y/p,e=Math.exp(-t*t/2);f.push(e),0===y?g+=e:y<m&&(g+=2*e)}for(let y=0;y<f.length;y++)f[y]=f[y]/g;c.envMap.value=t.texture,c.samples.value=m,c.weights.value=f,c.latitudinal.value="latitudinal"===r,a&&(c.poleAxis.value=a);const{_lodMax:_}=this;c.dTheta.value=d,c.mipInt.value=_-i;const v=this._sizeLods[n];Dr(e,3*v*(n>_-4?n-_+4:0),4*(this._cubeSize-v),3*v,2*v),o.setRenderTarget(e),o.render(h,Sr)}}function Ir(t,e,i){const n=new Li(t,e,i);return n.texture.mapping=ut,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Dr(t,e,i,n,s){t.viewport.set(e,i,n,s),t.scissor.set(e,i,n,s)}function Nr(){return new Ys({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Ur(){return new Ys({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Or(t){let e=new WeakMap,i=null;function n(t){const i=t.target;i.removeEventListener("dispose",n);const s=e.get(i);void 0!==s&&(e.delete(i),s.dispose())}return{get(s){if(s&&s.isTexture){const r=s.mapping,a=r===ht||r===ct,o=r===ot||r===lt;if(a||o){if(s.isRenderTargetTexture&&!0===s.needsPMREMUpdate){s.needsPMREMUpdate=!1;let n=e.get(s);return null===i&&(i=new Lr(t)),n=a?i.fromEquirectangular(s,n):i.fromCubemap(s,n),e.set(s,n),n.texture}if(e.has(s))return e.get(s).texture;{const r=s.image;if(a&&r&&r.height>0||o&&r&&function(t){let e=0;for(let i=0;i<6;i++)void 0!==t[i]&&e++;return 6===e}(r)){null===i&&(i=new Lr(t));const r=a?i.fromEquirectangular(s):i.fromCubemap(s);return e.set(s,r),s.addEventListener("dispose",n),r.texture}return null}}}return s},dispose(){e=new WeakMap,null!==i&&(i.dispose(),i=null)}}}function Fr(t){const e={};function i(i){if(void 0!==e[i])return e[i];let n;switch(i){case"WEBGL_depth_texture":n=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:n=t.getExtension(i)}return e[i]=n,n}return{has:t=>null!==i(t),init(t){t.isWebGL2?(i("EXT_color_buffer_float"),i("WEBGL_clip_cull_distance")):(i("WEBGL_depth_texture"),i("OES_texture_float"),i("OES_texture_half_float"),i("OES_texture_half_float_linear"),i("OES_standard_derivatives"),i("OES_element_index_uint"),i("OES_vertex_array_object"),i("ANGLE_instanced_arrays")),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float"),i("WEBGL_multisampled_render_to_texture")},get(t){return i(t)}}}function Br(t,e,i,n){const s={},r=new WeakMap;function a(t){const o=t.target;null!==o.index&&e.remove(o.index);for(const i in o.attributes)e.remove(o.attributes[i]);for(const i in o.morphAttributes){const t=o.morphAttributes[i];for(let i=0,n=t.length;i<n;i++)e.remove(t[i])}o.removeEventListener("dispose",a),delete s[o.id];const l=r.get(o);l&&(e.remove(l),r.delete(o)),n.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,i.memory.geometries--}function o(t){const i=[],n=t.index,s=t.attributes.position;let a=0;if(null!==n){const t=n.array;a=n.version;for(let e=0,n=t.length;e<n;e+=3){const n=t[e+0],s=t[e+1],r=t[e+2];i.push(n,s,s,r,r,n)}}else{if(void 0===s)return;{const t=s.array;a=s.version;for(let e=0,n=t.length/3-1;e<n;e+=3){const t=e+0,n=e+1,s=e+2;i.push(t,n,n,s,s,t)}}}const o=new(li(i)?ms:ps)(i,1);o.version=a;const l=r.get(t);l&&e.remove(l),r.set(t,o)}return{get:(t,e)=>(!0===s[e.id]||(e.addEventListener("dispose",a),s[e.id]=!0,i.memory.geometries++),e),update(i){const n=i.attributes;for(const r in n)e.update(n[r],t.ARRAY_BUFFER);const s=i.morphAttributes;for(const r in s){const i=s[r];for(let n=0,s=i.length;n<s;n++)e.update(i[n],t.ARRAY_BUFFER)}},getWireframeAttribute(t){const e=r.get(t);if(e){const i=t.index;null!==i&&e.version<i.version&&o(t)}else o(t);return r.get(t)}}}function zr(t,e,i,n){const s=n.isWebGL2;let r,a,o;this.setMode=function(t){r=t},this.setIndex=function(t){a=t.type,o=t.bytesPerElement},this.render=function(e,n){t.drawElements(r,n,a,e*o),i.update(n,r,1)},this.renderInstances=function(n,l,h){if(0===h)return;let c,u;if(s)c=t,u="drawElementsInstanced";else if(c=e.get("ANGLE_instanced_arrays"),u="drawElementsInstancedANGLE",null===c)return;c[u](r,l,a,n*o,h),i.update(l,r,h)},this.renderMultiDraw=function(t,n,s){if(0===s)return;const l=e.get("WEBGL_multi_draw");if(null===l)for(let e=0;e<s;e++)this.render(t[e]/o,n[e]);else{l.multiDrawElementsWEBGL(r,n,0,a,t,0,s);let e=0;for(let t=0;t<s;t++)e+=n[t];i.update(e,r,1)}}}function kr(t){const e={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:e,programs:null,autoReset:!0,reset(){e.calls=0,e.triangles=0,e.points=0,e.lines=0},update(i,n,s){switch(e.calls++,n){case t.TRIANGLES:e.triangles+=s*(i/3);break;case t.LINES:e.lines+=s*(i/2);break;case t.LINE_STRIP:e.lines+=s*(i-1);break;case t.LINE_LOOP:e.lines+=s*i;break;case t.POINTS:e.points+=s*i}}}}function Vr(t,e){return t[0]-e[0]}function Gr(t,e){return Math.abs(e[1])-Math.abs(t[1])}function Hr(t,e,i){const n={},s=new Float32Array(8),r=new WeakMap,a=new Ri,o=[];for(let l=0;l<8;l++)o[l]=[l,0];return{update(l,h,c){const u=l.morphTargetInfluences;if(!0===e.isWebGL2){const n=h.morphAttributes.position||h.morphAttributes.normal||h.morphAttributes.color,s=void 0!==n?n.length:0;let o=r.get(h);if(void 0===o||o.count!==s){let t=function(){_.dispose(),r.delete(h),h.removeEventListener("dispose",t)};void 0!==o&&o.texture.dispose();const i=void 0!==h.morphAttributes.position,n=void 0!==h.morphAttributes.normal,l=void 0!==h.morphAttributes.color,c=h.morphAttributes.position||[],u=h.morphAttributes.normal||[],d=h.morphAttributes.color||[];let p=0;!0===i&&(p=1),!0===n&&(p=2),!0===l&&(p=3);let m=h.attributes.position.count*p,f=1;m>e.maxTextureSize&&(f=Math.ceil(m/e.maxTextureSize),m=e.maxTextureSize);const g=new Float32Array(m*f*4*s),_=new Ii(g,m,f,s);_.type=Tt,_.needsUpdate=!0;const v=4*p;for(let e=0;e<s;e++){const t=c[e],s=u[e],r=d[e],o=m*f*4*e;for(let e=0;e<t.count;e++){const h=e*v;!0===i&&(a.fromBufferAttribute(t,e),g[o+h+0]=a.x,g[o+h+1]=a.y,g[o+h+2]=a.z,g[o+h+3]=0),!0===n&&(a.fromBufferAttribute(s,e),g[o+h+4]=a.x,g[o+h+5]=a.y,g[o+h+6]=a.z,g[o+h+7]=0),!0===l&&(a.fromBufferAttribute(r,e),g[o+h+8]=a.x,g[o+h+9]=a.y,g[o+h+10]=a.z,g[o+h+11]=4===r.itemSize?a.w:1)}}o={count:s,texture:_,size:new ri(m,f)},r.set(h,o),h.addEventListener("dispose",t)}let l=0;for(let t=0;t<u.length;t++)l+=u[t];const d=h.morphTargetsRelative?1:1-l;c.getUniforms().setValue(t,"morphTargetBaseInfluence",d),c.getUniforms().setValue(t,"morphTargetInfluences",u),c.getUniforms().setValue(t,"morphTargetsTexture",o.texture,i),c.getUniforms().setValue(t,"morphTargetsTextureSize",o.size)}else{const e=void 0===u?0:u.length;let i=n[h.id];if(void 0===i||i.length!==e){i=[];for(let t=0;t<e;t++)i[t]=[t,0];n[h.id]=i}for(let t=0;t<e;t++){const e=i[t];e[0]=t,e[1]=u[t]}i.sort(Gr);for(let t=0;t<8;t++)t<e&&i[t][1]?(o[t][0]=i[t][0],o[t][1]=i[t][1]):(o[t][0]=Number.MAX_SAFE_INTEGER,o[t][1]=0);o.sort(Vr);const r=h.morphAttributes.position,a=h.morphAttributes.normal;let l=0;for(let t=0;t<8;t++){const e=o[t],i=e[0],n=e[1];i!==Number.MAX_SAFE_INTEGER&&n?(r&&h.getAttribute("morphTarget"+t)!==r[i]&&h.setAttribute("morphTarget"+t,r[i]),a&&h.getAttribute("morphNormal"+t)!==a[i]&&h.setAttribute("morphNormal"+t,a[i]),s[t]=n,l+=n):(r&&!0===h.hasAttribute("morphTarget"+t)&&h.deleteAttribute("morphTarget"+t),a&&!0===h.hasAttribute("morphNormal"+t)&&h.deleteAttribute("morphNormal"+t),s[t]=0)}const d=h.morphTargetsRelative?1:1-l;c.getUniforms().setValue(t,"morphTargetBaseInfluence",d),c.getUniforms().setValue(t,"morphTargetInfluences",s)}}}}function Wr(t,e,i,n){let s=new WeakMap;function r(t){const e=t.target;e.removeEventListener("dispose",r),i.remove(e.instanceMatrix),null!==e.instanceColor&&i.remove(e.instanceColor)}return{update(a){const o=n.render.frame,l=a.geometry,h=e.get(a,l);if(s.get(h)!==o&&(e.update(h),s.set(h,o)),a.isInstancedMesh&&(!1===a.hasEventListener("dispose",r)&&a.addEventListener("dispose",r),s.get(a)!==o&&(i.update(a.instanceMatrix,t.ARRAY_BUFFER),null!==a.instanceColor&&i.update(a.instanceColor,t.ARRAY_BUFFER),s.set(a,o))),a.isSkinnedMesh){const t=a.skeleton;s.get(t)!==o&&(t.update(),s.set(t,o))}return h},dispose(){s=new WeakMap}}}class qr extends Ci{constructor(t,e,i,n,s,r,a,o,l,h){if((h=void 0!==h?h:Lt)!==Lt&&h!==It)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===i&&h===Lt&&(i=wt),void 0===i&&h===It&&(i=Rt),super(null,n,s,r,a,o,h,i,l),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=void 0!==a?a:ft,this.minFilter=void 0!==o?o:ft,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 null!==this.compareFunction&&(e.compareFunction=this.compareFunction),e}}const Xr=new Ci,jr=new qr(1,1);jr.compareFunction=515;const Yr=new Ii,Zr=new Di,Jr=new Qs,Kr=[],$r=[],Qr=new Float32Array(16),ta=new Float32Array(9),ea=new Float32Array(4);function ia(t,e,i){const n=t[0];if(n<=0||n>0)return t;const s=e*i;let r=Kr[s];if(void 0===r&&(r=new Float32Array(s),Kr[s]=r),0!==e){n.toArray(r,0);for(let n=1,s=0;n!==e;++n)s+=i,t[n].toArray(r,s)}return r}function na(t,e){if(t.length!==e.length)return!1;for(let i=0,n=t.length;i<n;i++)if(t[i]!==e[i])return!1;return!0}function sa(t,e){for(let i=0,n=e.length;i<n;i++)t[i]=e[i]}function ra(t,e){let i=$r[e];void 0===i&&(i=new Int32Array(e),$r[e]=i);for(let n=0;n!==e;++n)i[n]=t.allocateTextureUnit();return i}function aa(t,e){const i=this.cache;i[0]!==e&&(t.uniform1f(this.addr,e),i[0]=e)}function oa(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2f(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(na(i,e))return;t.uniform2fv(this.addr,e),sa(i,e)}}function la(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3f(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else if(void 0!==e.r)i[0]===e.r&&i[1]===e.g&&i[2]===e.b||(t.uniform3f(this.addr,e.r,e.g,e.b),i[0]=e.r,i[1]=e.g,i[2]=e.b);else{if(na(i,e))return;t.uniform3fv(this.addr,e),sa(i,e)}}function ha(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(na(i,e))return;t.uniform4fv(this.addr,e),sa(i,e)}}function ca(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(na(i,e))return;t.uniformMatrix2fv(this.addr,!1,e),sa(i,e)}else{if(na(i,n))return;ea.set(n),t.uniformMatrix2fv(this.addr,!1,ea),sa(i,n)}}function ua(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(na(i,e))return;t.uniformMatrix3fv(this.addr,!1,e),sa(i,e)}else{if(na(i,n))return;ta.set(n),t.uniformMatrix3fv(this.addr,!1,ta),sa(i,n)}}function da(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(na(i,e))return;t.uniformMatrix4fv(this.addr,!1,e),sa(i,e)}else{if(na(i,n))return;Qr.set(n),t.uniformMatrix4fv(this.addr,!1,Qr),sa(i,n)}}function pa(t,e){const i=this.cache;i[0]!==e&&(t.uniform1i(this.addr,e),i[0]=e)}function ma(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2i(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(na(i,e))return;t.uniform2iv(this.addr,e),sa(i,e)}}function fa(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3i(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else{if(na(i,e))return;t.uniform3iv(this.addr,e),sa(i,e)}}function ga(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(na(i,e))return;t.uniform4iv(this.addr,e),sa(i,e)}}function _a(t,e){const i=this.cache;i[0]!==e&&(t.uniform1ui(this.addr,e),i[0]=e)}function va(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2ui(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(na(i,e))return;t.uniform2uiv(this.addr,e),sa(i,e)}}function ya(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3ui(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else{if(na(i,e))return;t.uniform3uiv(this.addr,e),sa(i,e)}}function xa(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(na(i,e))return;t.uniform4uiv(this.addr,e),sa(i,e)}}function Ma(t,e,i){const n=this.cache,s=i.allocateTextureUnit();n[0]!==s&&(t.uniform1i(this.addr,s),n[0]=s);const r=this.type===t.SAMPLER_2D_SHADOW?jr:Xr;i.setTexture2D(e||r,s)}function ba(t,e,i){const n=this.cache,s=i.allocateTextureUnit();n[0]!==s&&(t.uniform1i(this.addr,s),n[0]=s),i.setTexture3D(e||Zr,s)}function Sa(t,e,i){const n=this.cache,s=i.allocateTextureUnit();n[0]!==s&&(t.uniform1i(this.addr,s),n[0]=s),i.setTextureCube(e||Jr,s)}function wa(t,e,i){const n=this.cache,s=i.allocateTextureUnit();n[0]!==s&&(t.uniform1i(this.addr,s),n[0]=s),i.setTexture2DArray(e||Yr,s)}function Ta(t,e){t.uniform1fv(this.addr,e)}function Ea(t,e){const i=ia(e,this.size,2);t.uniform2fv(this.addr,i)}function Aa(t,e){const i=ia(e,this.size,3);t.uniform3fv(this.addr,i)}function Ca(t,e){const i=ia(e,this.size,4);t.uniform4fv(this.addr,i)}function Ra(t,e){const i=ia(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,i)}function Pa(t,e){const i=ia(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,i)}function La(t,e){const i=ia(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,i)}function Ia(t,e){t.uniform1iv(this.addr,e)}function Da(t,e){t.uniform2iv(this.addr,e)}function Na(t,e){t.uniform3iv(this.addr,e)}function Ua(t,e){t.uniform4iv(this.addr,e)}function Oa(t,e){t.uniform1uiv(this.addr,e)}function Fa(t,e){t.uniform2uiv(this.addr,e)}function Ba(t,e){t.uniform3uiv(this.addr,e)}function za(t,e){t.uniform4uiv(this.addr,e)}function ka(t,e,i){const n=this.cache,s=e.length,r=ra(i,s);na(n,r)||(t.uniform1iv(this.addr,r),sa(n,r));for(let a=0;a!==s;++a)i.setTexture2D(e[a]||Xr,r[a])}function Va(t,e,i){const n=this.cache,s=e.length,r=ra(i,s);na(n,r)||(t.uniform1iv(this.addr,r),sa(n,r));for(let a=0;a!==s;++a)i.setTexture3D(e[a]||Zr,r[a])}function Ga(t,e,i){const n=this.cache,s=e.length,r=ra(i,s);na(n,r)||(t.uniform1iv(this.addr,r),sa(n,r));for(let a=0;a!==s;++a)i.setTextureCube(e[a]||Jr,r[a])}function Ha(t,e,i){const n=this.cache,s=e.length,r=ra(i,s);na(n,r)||(t.uniform1iv(this.addr,r),sa(n,r));for(let a=0;a!==s;++a)i.setTexture2DArray(e[a]||Yr,r[a])}class Wa{constructor(t,e,i){this.id=t,this.addr=i,this.cache=[],this.type=e.type,this.setValue=function(t){switch(t){case 5126:return aa;case 35664:return oa;case 35665:return la;case 35666:return ha;case 35674:return ca;case 35675:return ua;case 35676:return da;case 5124:case 35670:return pa;case 35667:case 35671:return ma;case 35668:case 35672:return fa;case 35669:case 35673:return ga;case 5125:return _a;case 36294:return va;case 36295:return ya;case 36296:return xa;case 35678:case 36198:case 36298:case 36306:case 35682:return Ma;case 35679:case 36299:case 36307:return ba;case 35680:case 36300:case 36308:case 36293:return Sa;case 36289:case 36303:case 36311:case 36292:return wa}}(e.type)}}class qa{constructor(t,e,i){this.id=t,this.addr=i,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=function(t){switch(t){case 5126:return Ta;case 35664:return Ea;case 35665:return Aa;case 35666:return Ca;case 35674:return Ra;case 35675:return Pa;case 35676:return La;case 5124:case 35670:return Ia;case 35667:case 35671:return Da;case 35668:case 35672:return Na;case 35669:case 35673:return Ua;case 5125:return Oa;case 36294:return Fa;case 36295:return Ba;case 36296:return za;case 35678:case 36198:case 36298:case 36306:case 35682:return ka;case 35679:case 36299:case 36307:return Va;case 35680:case 36300:case 36308:case 36293:return Ga;case 36289:case 36303:case 36311:case 36292:return Ha}}(e.type)}}class Xa{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,i){const n=this.seq;for(let s=0,r=n.length;s!==r;++s){const r=n[s];r.setValue(t,e[r.id],i)}}}const ja=/(\w+)(\])?(\[|\.)?/g;function Ya(t,e){t.seq.push(e),t.map[e.id]=e}function Za(t,e,i){const n=t.name,s=n.length;for(ja.lastIndex=0;;){const r=ja.exec(n),a=ja.lastIndex;let o=r[1];const l="]"===r[2],h=r[3];if(l&&(o|=0),void 0===h||"["===h&&a+2===s){Ya(i,void 0===h?new Wa(o,t,e):new qa(o,t,e));break}{let t=i.map[o];void 0===t&&(t=new Xa(o),Ya(i,t)),i=t}}}class Ja{constructor(t,e){this.seq=[],this.map={};const i=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let n=0;n<i;++n){const i=t.getActiveUniform(e,n);Za(i,t.getUniformLocation(e,i.name),this)}}setValue(t,e,i,n){const s=this.map[e];void 0!==s&&s.setValue(t,i,n)}setOptional(t,e,i){const n=e[i];void 0!==n&&this.setValue(t,i,n)}static upload(t,e,i,n){for(let s=0,r=e.length;s!==r;++s){const r=e[s],a=i[r.id];!1!==a.needsUpdate&&r.setValue(t,a.value,n)}}static seqWithValue(t,e){const i=[];for(let n=0,s=t.length;n!==s;++n){const s=t[n];s.id in e&&i.push(s)}return i}}function Ka(t,e,i){const n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),n}let $a=0;function Qa(t,e,i){const n=t.getShaderParameter(e,t.COMPILE_STATUS),s=t.getShaderInfoLog(e).trim();if(n&&""===s)return"";const r=/ERROR: 0:(\d+)/.exec(s);if(r){const n=parseInt(r[1]);return i.toUpperCase()+"\n\n"+s+"\n\n"+function(t,e){const i=t.split("\n"),n=[],s=Math.max(e-6,0),r=Math.min(e+6,i.length);for(let a=s;a<r;a++){const t=a+1;n.push(`${t===e?">":" "} ${t}: ${i[a]}`)}return n.join("\n")}(t.getShaderSource(e),n)}return s}function to(t,e){const i=function(t){const e=yi.getPrimaries(yi.workingColorSpace),i=yi.getPrimaries(t);let n;switch(e===i?n="":e===Pe&&i===Re?n="LinearDisplayP3ToLinearSRGB":e===Re&&i===Pe&&(n="LinearSRGBToLinearDisplayP3"),t){case we:case Ee:return[n,"LinearTransferOETF"];case Se:case Te:return[n,"sRGBTransferOETF"];default:return[n,"LinearTransferOETF"]}}(e);return`vec4 ${t}( vec4 value ) { return ${i[0]}( ${i[1]}( value ) ); }`}function eo(t,e){let i;switch(e){case 1:default:i="Linear";break;case 2:i="Reinhard";break;case 3:i="OptimizedCineon";break;case 4:i="ACESFilmic";break;case 6:i="AgX";break;case 5:i="Custom"}return"vec3 "+t+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}function io(t){return""!==t}function no(t,e){const i=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,i).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function so(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const ro=/^[ \t]*#include +<([\w\d./]+)>/gm;function ao(t){return t.replace(ro,lo)}const oo=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function lo(t,e){let i=ur[e];if(void 0===i){const t=oo.get(e);if(void 0===t)throw new Error("Can not resolve #include <"+e+">");i=ur[t]}return ao(i)}const ho=/#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 co(t){return t.replace(ho,uo)}function uo(t,e,i,n){let s="";for(let r=parseInt(e);r<parseInt(i);r++)s+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function po(t){let e="precision "+t.precision+" float;\nprecision "+t.precision+" int;";return"highp"===t.precision?e+="\n#define HIGH_PRECISION":"mediump"===t.precision?e+="\n#define MEDIUM_PRECISION":"lowp"===t.precision&&(e+="\n#define LOW_PRECISION"),e}function mo(t,e,i,n){const s=t.getContext(),r=i.defines;let a=i.vertexShader,o=i.fragmentShader;const l=function(t){let e="SHADOWMAP_TYPE_BASIC";return 1===t.shadowMapType?e="SHADOWMAP_TYPE_PCF":2===t.shadowMapType?e="SHADOWMAP_TYPE_PCF_SOFT":3===t.shadowMapType&&(e="SHADOWMAP_TYPE_VSM"),e}(i),h=function(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case ot:case lt:e="ENVMAP_TYPE_CUBE";break;case ut:e="ENVMAP_TYPE_CUBE_UV"}return e}(i),c=function(t){let e="ENVMAP_MODE_REFLECTION";return t.envMap&&t.envMapMode===lt&&(e="ENVMAP_MODE_REFRACTION"),e}(i),u=function(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case 0:e="ENVMAP_BLENDING_MULTIPLY";break;case 1:e="ENVMAP_BLENDING_MIX";break;case 2:e="ENVMAP_BLENDING_ADD"}return e}(i),d=function(t){const e=t.envMapCubeUVHeight;if(null===e)return null;const i=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,i),112)),texelHeight:n,maxMip:i}}(i),p=i.isWebGL2?"":function(t){return[t.extensionDerivatives||t.envMapCubeUVHeight||t.bumpMap||t.normalMapTangentSpace||t.clearcoatNormalMap||t.flatShading||"physical"===t.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(t.extensionFragDepth||t.logarithmicDepthBuffer)&&t.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",t.extensionDrawBuffers&&t.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(t.extensionShaderTextureLOD||t.envMap||t.transmission)&&t.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(io).join("\n")}(i),m=function(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":""].filter(io).join("\n")}(i),f=function(t){const e=[];for(const i in t){const n=t[i];!1!==n&&e.push("#define "+i+" "+n)}return e.join("\n")}(r),g=s.createProgram();let _,v,y=i.glslVersion?"#version "+i.glslVersion+"\n":"";i.isRawShaderMaterial?(_=["#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,f].filter(io).join("\n"),_.length>0&&(_+="\n"),v=[p,"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,f].filter(io).join("\n"),v.length>0&&(v+="\n")):(_=[po(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,f,i.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",i.batching?"#define USE_BATCHING":"",i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+c:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.displacementMap?"#define USE_DISPLACEMENTMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.mapUv?"#define MAP_UV "+i.mapUv:"",i.alphaMapUv?"#define ALPHAMAP_UV "+i.alphaMapUv:"",i.lightMapUv?"#define LIGHTMAP_UV "+i.lightMapUv:"",i.aoMapUv?"#define AOMAP_UV "+i.aoMapUv:"",i.emissiveMapUv?"#define EMISSIVEMAP_UV "+i.emissiveMapUv:"",i.bumpMapUv?"#define BUMPMAP_UV "+i.bumpMapUv:"",i.normalMapUv?"#define NORMALMAP_UV "+i.normalMapUv:"",i.displacementMapUv?"#define DISPLACEMENTMAP_UV "+i.displacementMapUv:"",i.metalnessMapUv?"#define METALNESSMAP_UV "+i.metalnessMapUv:"",i.roughnessMapUv?"#define ROUGHNESSMAP_UV "+i.roughnessMapUv:"",i.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+i.anisotropyMapUv:"",i.clearcoatMapUv?"#define CLEARCOATMAP_UV "+i.clearcoatMapUv:"",i.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+i.clearcoatNormalMapUv:"",i.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+i.clearcoatRoughnessMapUv:"",i.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+i.iridescenceMapUv:"",i.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+i.iridescenceThicknessMapUv:"",i.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+i.sheenColorMapUv:"",i.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+i.sheenRoughnessMapUv:"",i.specularMapUv?"#define SPECULARMAP_UV "+i.specularMapUv:"",i.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+i.specularColorMapUv:"",i.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+i.specularIntensityMapUv:"",i.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+i.transmissionMapUv:"",i.thicknessMapUv?"#define THICKNESSMAP_UV "+i.thicknessMapUv:"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&!1===i.flatShading?"#define USE_MORPHNORMALS":"",i.morphColors&&i.isWebGL2?"#define USE_MORPHCOLORS":"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+i.morphTextureStride:"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_COUNT "+i.morphTargetsCount:"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+l:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.useLegacyLights?"#define LEGACY_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(io).join("\n"),v=[p,po(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,f,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+h:"",i.envMap?"#define "+c:"",i.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":"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoat?"#define USE_CLEARCOAT":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescence?"#define USE_IRIDESCENCE":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaTest?"#define USE_ALPHATEST":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.sheen?"#define USE_SHEEN":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+l:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.useLegacyLights?"#define LEGACY_LIGHTS":"",i.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==i.toneMapping?"#define TONE_MAPPING":"",0!==i.toneMapping?ur.tonemapping_pars_fragment:"",0!==i.toneMapping?eo("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",ur.colorspace_pars_fragment,to("linearToOutputTexel",i.outputColorSpace),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(io).join("\n")),a=ao(a),a=no(a,i),a=so(a,i),o=ao(o),o=no(o,i),o=so(o,i),a=co(a),o=co(o),i.isWebGL2&&!0!==i.isRawShaderMaterial&&(y="#version 300 es\n",_=[m,"precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+_,v=["precision mediump sampler2DArray;","#define varying in",i.glslVersion===Ve?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===Ve?"":"#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("\n")+"\n"+v);const x=y+_+a,M=y+v+o,b=Ka(s,s.VERTEX_SHADER,x),S=Ka(s,s.FRAGMENT_SHADER,M);function w(e){if(t.debug.checkShaderErrors){const i=s.getProgramInfoLog(g).trim(),n=s.getShaderInfoLog(b).trim(),r=s.getShaderInfoLog(S).trim();let a=!0,o=!0;!1===s.getProgramParameter(g,s.LINK_STATUS)?(a=!1,"function"==typeof t.debug.onShaderError?t.debug.onShaderError(s,g,b,S):(Qa(s,b,"vertex"),Qa(s,S,"fragment"))):""!==i||""!==n&&""!==r||(o=!1),o&&(e.diagnostics={runnable:a,programLog:i,vertexShader:{log:n,prefix:_},fragmentShader:{log:r,prefix:v}})}s.deleteShader(b),s.deleteShader(S),T=new Ja(s,g),E=function(t,e){const i={},n=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){const n=t.getActiveAttrib(e,s),r=n.name;let a=1;n.type===t.FLOAT_MAT2&&(a=2),n.type===t.FLOAT_MAT3&&(a=3),n.type===t.FLOAT_MAT4&&(a=4),i[r]={type:n.type,location:t.getAttribLocation(e,r),locationSize:a}}return i}(s,g)}let T,E;s.attachShader(g,b),s.attachShader(g,S),void 0!==i.index0AttributeName?s.bindAttribLocation(g,0,i.index0AttributeName):!0===i.morphTargets&&s.bindAttribLocation(g,0,"position"),s.linkProgram(g),this.getUniforms=function(){return void 0===T&&w(this),T},this.getAttributes=function(){return void 0===E&&w(this),E};let A=!1===i.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===A&&(A=s.getProgramParameter(g,37297)),A},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(g),this.program=void 0},this.type=i.shaderType,this.name=i.shaderName,this.id=$a++,this.cacheKey=e,this.usedTimes=1,this.program=g,this.vertexShader=b,this.fragmentShader=S,this}let fo=0;class go{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,i=t.fragmentShader,n=this._getShaderStage(e),s=this._getShaderStage(i),r=this._getShaderCacheForMaterial(t);return!1===r.has(n)&&(r.add(n),n.usedTimes++),!1===r.has(s)&&(r.add(s),s.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const i of e)i.usedTimes--,0===i.usedTimes&&this.shaderCache.delete(i.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 i=e.get(t);return void 0===i&&(i=new Set,e.set(t,i)),i}_getShaderStage(t){const e=this.shaderCache;let i=e.get(t);return void 0===i&&(i=new _o(t),e.set(t,i)),i}}class _o{constructor(t){this.id=fo++,this.code=t,this.usedTimes=0}}function vo(t,e,i,n,s,r,a){const o=new Sn,l=new go,h=[],c=s.isWebGL2,u=s.logarithmicDepthBuffer,d=s.vertexTextures;let p=s.precision;const m={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 f(t){return 0===t?"uv":`uv${t}`}return{getParameters(r,o,h,g,_){const v=g.fog,y=_.geometry,x=r.isMeshStandardMaterial?g.environment:null,M=(r.isMeshStandardMaterial?i:e).get(r.envMap||x),b=M&&M.mapping===ut?M.image.height:null,S=m[r.type];null!==r.precision&&(p=s.getMaxPrecision(r.precision),r.precision);const w=y.morphAttributes.position||y.morphAttributes.normal||y.morphAttributes.color,T=void 0!==w?w.length:0;let E,A,C,R,P=0;if(void 0!==y.morphAttributes.position&&(P=1),void 0!==y.morphAttributes.normal&&(P=2),void 0!==y.morphAttributes.color&&(P=3),S){const t=pr[S];E=t.vertexShader,A=t.fragmentShader}else E=r.vertexShader,A=r.fragmentShader,l.update(r),C=l.getVertexShaderID(r),R=l.getFragmentShaderID(r);const L=t.getRenderTarget(),I=!0===_.isInstancedMesh,D=!0===_.isBatchedMesh,N=!!r.map,U=!!r.matcap,O=!!M,F=!!r.aoMap,B=!!r.lightMap,z=!!r.bumpMap,k=!!r.normalMap,V=!!r.displacementMap,G=!!r.emissiveMap,H=!!r.metalnessMap,W=!!r.roughnessMap,q=r.anisotropy>0,X=r.clearcoat>0,j=r.iridescence>0,Y=r.sheen>0,Z=r.transmission>0,J=q&&!!r.anisotropyMap,K=X&&!!r.clearcoatMap,$=X&&!!r.clearcoatNormalMap,Q=X&&!!r.clearcoatRoughnessMap,tt=j&&!!r.iridescenceMap,et=j&&!!r.iridescenceThicknessMap,it=Y&&!!r.sheenColorMap,nt=Y&&!!r.sheenRoughnessMap,st=!!r.specularMap,rt=!!r.specularColorMap,at=!!r.specularIntensityMap,ot=Z&&!!r.transmissionMap,lt=Z&&!!r.thicknessMap,ht=!!r.gradientMap,ct=!!r.alphaMap,dt=r.alphaTest>0,pt=!!r.alphaHash,mt=!!r.extensions,ft=!!y.attributes.uv1,gt=!!y.attributes.uv2,_t=!!y.attributes.uv3;let vt=0;return r.toneMapped&&(null!==L&&!0!==L.isXRRenderTarget||(vt=t.toneMapping)),{isWebGL2:c,shaderID:S,shaderType:r.type,shaderName:r.name,vertexShader:E,fragmentShader:A,defines:r.defines,customVertexShaderID:C,customFragmentShaderID:R,isRawShaderMaterial:!0===r.isRawShaderMaterial,glslVersion:r.glslVersion,precision:p,batching:D,instancing:I,instancingColor:I&&null!==_.instanceColor,supportsVertexTextures:d,outputColorSpace:null===L?t.outputColorSpace:!0===L.isXRRenderTarget?L.texture.colorSpace:we,map:N,matcap:U,envMap:O,envMapMode:O&&M.mapping,envMapCubeUVHeight:b,aoMap:F,lightMap:B,bumpMap:z,normalMap:k,displacementMap:d&&V,emissiveMap:G,normalMapObjectSpace:k&&1===r.normalMapType,normalMapTangentSpace:k&&0===r.normalMapType,metalnessMap:H,roughnessMap:W,anisotropy:q,anisotropyMap:J,clearcoat:X,clearcoatMap:K,clearcoatNormalMap:$,clearcoatRoughnessMap:Q,iridescence:j,iridescenceMap:tt,iridescenceThicknessMap:et,sheen:Y,sheenColorMap:it,sheenRoughnessMap:nt,specularMap:st,specularColorMap:rt,specularIntensityMap:at,transmission:Z,transmissionMap:ot,thicknessMap:lt,gradientMap:ht,opaque:!1===r.transparent&&1===r.blending,alphaMap:ct,alphaTest:dt,alphaHash:pt,combine:r.combine,mapUv:N&&f(r.map.channel),aoMapUv:F&&f(r.aoMap.channel),lightMapUv:B&&f(r.lightMap.channel),bumpMapUv:z&&f(r.bumpMap.channel),normalMapUv:k&&f(r.normalMap.channel),displacementMapUv:V&&f(r.displacementMap.channel),emissiveMapUv:G&&f(r.emissiveMap.channel),metalnessMapUv:H&&f(r.metalnessMap.channel),roughnessMapUv:W&&f(r.roughnessMap.channel),anisotropyMapUv:J&&f(r.anisotropyMap.channel),clearcoatMapUv:K&&f(r.clearcoatMap.channel),clearcoatNormalMapUv:$&&f(r.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Q&&f(r.clearcoatRoughnessMap.channel),iridescenceMapUv:tt&&f(r.iridescenceMap.channel),iridescenceThicknessMapUv:et&&f(r.iridescenceThicknessMap.channel),sheenColorMapUv:it&&f(r.sheenColorMap.channel),sheenRoughnessMapUv:nt&&f(r.sheenRoughnessMap.channel),specularMapUv:st&&f(r.specularMap.channel),specularColorMapUv:rt&&f(r.specularColorMap.channel),specularIntensityMapUv:at&&f(r.specularIntensityMap.channel),transmissionMapUv:ot&&f(r.transmissionMap.channel),thicknessMapUv:lt&&f(r.thicknessMap.channel),alphaMapUv:ct&&f(r.alphaMap.channel),vertexTangents:!!y.attributes.tangent&&(k||q),vertexColors:r.vertexColors,vertexAlphas:!0===r.vertexColors&&!!y.attributes.color&&4===y.attributes.color.itemSize,vertexUv1s:ft,vertexUv2s:gt,vertexUv3s:_t,pointsUvs:!0===_.isPoints&&!!y.attributes.uv&&(N||ct),fog:!!v,useFog:!0===r.fog,fogExp2:v&&v.isFogExp2,flatShading:!0===r.flatShading,sizeAttenuation:!0===r.sizeAttenuation,logarithmicDepthBuffer:u,skinning:!0===_.isSkinnedMesh,morphTargets:void 0!==y.morphAttributes.position,morphNormals:void 0!==y.morphAttributes.normal,morphColors:void 0!==y.morphAttributes.color,morphTargetsCount:T,morphTextureStride:P,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:r.dithering,shadowMapEnabled:t.shadowMap.enabled&&h.length>0,shadowMapType:t.shadowMap.type,toneMapping:vt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:N&&!0===r.map.isVideoTexture&&yi.getTransfer(r.map.colorSpace)===Ce,premultipliedAlpha:r.premultipliedAlpha,doubleSided:2===r.side,flipSided:1===r.side,useDepthPacking:r.depthPacking>=0,depthPacking:r.depthPacking||0,index0AttributeName:r.index0AttributeName,extensionDerivatives:mt&&!0===r.extensions.derivatives,extensionFragDepth:mt&&!0===r.extensions.fragDepth,extensionDrawBuffers:mt&&!0===r.extensions.drawBuffers,extensionShaderTextureLOD:mt&&!0===r.extensions.shaderTextureLOD,extensionClipCullDistance:mt&&r.extensions.clipCullDistance&&n.has("WEBGL_clip_cull_distance"),rendererExtensionFragDepth:c||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:c||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:c||n.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:r.customProgramCacheKey()}},getProgramCacheKey(e){const i=[];if(e.shaderID?i.push(e.shaderID):(i.push(e.customVertexShaderID),i.push(e.customFragmentShaderID)),void 0!==e.defines)for(const t in e.defines)i.push(t),i.push(e.defines[t]);return!1===e.isRawShaderMaterial&&(function(t,e){t.push(e.precision),t.push(e.outputColorSpace),t.push(e.envMapMode),t.push(e.envMapCubeUVHeight),t.push(e.mapUv),t.push(e.alphaMapUv),t.push(e.lightMapUv),t.push(e.aoMapUv),t.push(e.bumpMapUv),t.push(e.normalMapUv),t.push(e.displacementMapUv),t.push(e.emissiveMapUv),t.push(e.metalnessMapUv),t.push(e.roughnessMapUv),t.push(e.anisotropyMapUv),t.push(e.clearcoatMapUv),t.push(e.clearcoatNormalMapUv),t.push(e.clearcoatRoughnessMapUv),t.push(e.iridescenceMapUv),t.push(e.iridescenceThicknessMapUv),t.push(e.sheenColorMapUv),t.push(e.sheenRoughnessMapUv),t.push(e.specularMapUv),t.push(e.specularColorMapUv),t.push(e.specularIntensityMapUv),t.push(e.transmissionMapUv),t.push(e.thicknessMapUv),t.push(e.combine),t.push(e.fogExp2),t.push(e.sizeAttenuation),t.push(e.morphTargetsCount),t.push(e.morphAttributeCount),t.push(e.numDirLights),t.push(e.numPointLights),t.push(e.numSpotLights),t.push(e.numSpotLightMaps),t.push(e.numHemiLights),t.push(e.numRectAreaLights),t.push(e.numDirLightShadows),t.push(e.numPointLightShadows),t.push(e.numSpotLightShadows),t.push(e.numSpotLightShadowsWithMaps),t.push(e.numLightProbes),t.push(e.shadowMapType),t.push(e.toneMapping),t.push(e.numClippingPlanes),t.push(e.numClipIntersection),t.push(e.depthPacking)}(i,e),function(t,e){o.disableAll(),e.isWebGL2&&o.enable(0),e.supportsVertexTextures&&o.enable(1),e.instancing&&o.enable(2),e.instancingColor&&o.enable(3),e.matcap&&o.enable(4),e.envMap&&o.enable(5),e.normalMapObjectSpace&&o.enable(6),e.normalMapTangentSpace&&o.enable(7),e.clearcoat&&o.enable(8),e.iridescence&&o.enable(9),e.alphaTest&&o.enable(10),e.vertexColors&&o.enable(11),e.vertexAlphas&&o.enable(12),e.vertexUv1s&&o.enable(13),e.vertexUv2s&&o.enable(14),e.vertexUv3s&&o.enable(15),e.vertexTangents&&o.enable(16),e.anisotropy&&o.enable(17),e.alphaHash&&o.enable(18),e.batching&&o.enable(19),t.push(o.mask),o.disableAll(),e.fog&&o.enable(0),e.useFog&&o.enable(1),e.flatShading&&o.enable(2),e.logarithmicDepthBuffer&&o.enable(3),e.skinning&&o.enable(4),e.morphTargets&&o.enable(5),e.morphNormals&&o.enable(6),e.morphColors&&o.enable(7),e.premultipliedAlpha&&o.enable(8),e.shadowMapEnabled&&o.enable(9),e.useLegacyLights&&o.enable(10),e.doubleSided&&o.enable(11),e.flipSided&&o.enable(12),e.useDepthPacking&&o.enable(13),e.dithering&&o.enable(14),e.transmission&&o.enable(15),e.sheen&&o.enable(16),e.opaque&&o.enable(17),e.pointsUvs&&o.enable(18),e.decodeVideoTexture&&o.enable(19),t.push(o.mask)}(i,e),i.push(t.outputColorSpace)),i.push(e.customProgramCacheKey),i.join()},getUniforms(t){const e=m[t.type];let i;if(e){const t=pr[e];i=js.clone(t.uniforms)}else i=t.uniforms;return i},acquireProgram(e,i){let n;for(let t=0,s=h.length;t<s;t++){const e=h[t];if(e.cacheKey===i){n=e,++n.usedTimes;break}}return void 0===n&&(n=new mo(t,i,e,r),h.push(n)),n},releaseProgram(t){if(0===--t.usedTimes){const e=h.indexOf(t);h[e]=h[h.length-1],h.pop(),t.destroy()}},releaseShaderCache(t){l.remove(t)},programs:h,dispose(){l.dispose()}}}function yo(){let t=new WeakMap;return{get(e){let i=t.get(e);return void 0===i&&(i={},t.set(e,i)),i},remove(e){t.delete(e)},update(e,i,n){t.get(e)[i]=n},dispose(){t=new WeakMap}}}function xo(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function Mo(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function bo(){const t=[];let e=0;const i=[],n=[],s=[];function r(i,n,s,r,a,o){let l=t[e];return void 0===l?(l={id:i.id,object:i,geometry:n,material:s,groupOrder:r,renderOrder:i.renderOrder,z:a,group:o},t[e]=l):(l.id=i.id,l.object=i,l.geometry=n,l.material=s,l.groupOrder=r,l.renderOrder=i.renderOrder,l.z=a,l.group=o),e++,l}return{opaque:i,transmissive:n,transparent:s,init(){e=0,i.length=0,n.length=0,s.length=0},push(t,e,a,o,l,h){const c=r(t,e,a,o,l,h);a.transmission>0?n.push(c):!0===a.transparent?s.push(c):i.push(c)},unshift(t,e,a,o,l,h){const c=r(t,e,a,o,l,h);a.transmission>0?n.unshift(c):!0===a.transparent?s.unshift(c):i.unshift(c)},finish(){for(let i=e,n=t.length;i<n;i++){const e=t[i];if(null===e.id)break;e.id=null,e.object=null,e.geometry=null,e.material=null,e.group=null}},sort(t,e){i.length>1&&i.sort(t||xo),n.length>1&&n.sort(e||Mo),s.length>1&&s.sort(e||Mo)}}}function So(){let t=new WeakMap;return{get(e,i){const n=t.get(e);let s;return void 0===n?(s=new bo,t.set(e,[s])):i>=n.length?(s=new bo,n.push(s)):s=n[i],s},dispose(){t=new WeakMap}}}function wo(){const t={};return{get(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":i={direction:new Ui,color:new ts};break;case"SpotLight":i={position:new Ui,direction:new Ui,color:new ts,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new Ui,color:new ts,distance:0,decay:0};break;case"HemisphereLight":i={direction:new Ui,skyColor:new ts,groundColor:new ts};break;case"RectAreaLight":i={color:new ts,position:new Ui,halfWidth:new Ui,halfHeight:new Ui}}return t[e.id]=i,i}}}let To=0;function Eo(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function Ao(t,e){const i=new wo,n=function(){const t={};return{get(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":case"SpotLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ri};break;case"PointLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ri,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=i,i}}}(),s={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 l=0;l<9;l++)s.probe.push(new Ui);const r=new Ui,a=new dn,o=new dn;return{setup(r,a){let o=0,l=0,h=0;for(let t=0;t<9;t++)s.probe[t].set(0,0,0);let c=0,u=0,d=0,p=0,m=0,f=0,g=0,_=0,v=0,y=0,x=0;r.sort(Eo);const M=!0===a?Math.PI:1;for(let t=0,e=r.length;t<e;t++){const e=r[t],a=e.color,b=e.intensity,S=e.distance,w=e.shadow&&e.shadow.map?e.shadow.map.texture:null;if(e.isAmbientLight)o+=a.r*b*M,l+=a.g*b*M,h+=a.b*b*M;else if(e.isLightProbe){for(let t=0;t<9;t++)s.probe[t].addScaledVector(e.sh.coefficients[t],b);x++}else if(e.isDirectionalLight){const t=i.get(e);if(t.color.copy(e.color).multiplyScalar(e.intensity*M),e.castShadow){const t=e.shadow,i=n.get(e);i.shadowBias=t.bias,i.shadowNormalBias=t.normalBias,i.shadowRadius=t.radius,i.shadowMapSize=t.mapSize,s.directionalShadow[c]=i,s.directionalShadowMap[c]=w,s.directionalShadowMatrix[c]=e.shadow.matrix,f++}s.directional[c]=t,c++}else if(e.isSpotLight){const t=i.get(e);t.position.setFromMatrixPosition(e.matrixWorld),t.color.copy(a).multiplyScalar(b*M),t.distance=S,t.coneCos=Math.cos(e.angle),t.penumbraCos=Math.cos(e.angle*(1-e.penumbra)),t.decay=e.decay,s.spot[d]=t;const r=e.shadow;if(e.map&&(s.spotLightMap[v]=e.map,v++,r.updateMatrices(e),e.castShadow&&y++),s.spotLightMatrix[d]=r.matrix,e.castShadow){const t=n.get(e);t.shadowBias=r.bias,t.shadowNormalBias=r.normalBias,t.shadowRadius=r.radius,t.shadowMapSize=r.mapSize,s.spotShadow[d]=t,s.spotShadowMap[d]=w,_++}d++}else if(e.isRectAreaLight){const t=i.get(e);t.color.copy(a).multiplyScalar(b),t.halfWidth.set(.5*e.width,0,0),t.halfHeight.set(0,.5*e.height,0),s.rectArea[p]=t,p++}else if(e.isPointLight){const t=i.get(e);if(t.color.copy(e.color).multiplyScalar(e.intensity*M),t.distance=e.distance,t.decay=e.decay,e.castShadow){const t=e.shadow,i=n.get(e);i.shadowBias=t.bias,i.shadowNormalBias=t.normalBias,i.shadowRadius=t.radius,i.shadowMapSize=t.mapSize,i.shadowCameraNear=t.camera.near,i.shadowCameraFar=t.camera.far,s.pointShadow[u]=i,s.pointShadowMap[u]=w,s.pointShadowMatrix[u]=e.shadow.matrix,g++}s.point[u]=t,u++}else if(e.isHemisphereLight){const t=i.get(e);t.skyColor.copy(e.color).multiplyScalar(b*M),t.groundColor.copy(e.groundColor).multiplyScalar(b*M),s.hemi[m]=t,m++}}p>0&&(e.isWebGL2?!0===t.has("OES_texture_float_linear")?(s.rectAreaLTC1=dr.LTC_FLOAT_1,s.rectAreaLTC2=dr.LTC_FLOAT_2):(s.rectAreaLTC1=dr.LTC_HALF_1,s.rectAreaLTC2=dr.LTC_HALF_2):!0===t.has("OES_texture_float_linear")?(s.rectAreaLTC1=dr.LTC_FLOAT_1,s.rectAreaLTC2=dr.LTC_FLOAT_2):!0===t.has("OES_texture_half_float_linear")&&(s.rectAreaLTC1=dr.LTC_HALF_1,s.rectAreaLTC2=dr.LTC_HALF_2)),s.ambient[0]=o,s.ambient[1]=l,s.ambient[2]=h;const b=s.hash;b.directionalLength===c&&b.pointLength===u&&b.spotLength===d&&b.rectAreaLength===p&&b.hemiLength===m&&b.numDirectionalShadows===f&&b.numPointShadows===g&&b.numSpotShadows===_&&b.numSpotMaps===v&&b.numLightProbes===x||(s.directional.length=c,s.spot.length=d,s.rectArea.length=p,s.point.length=u,s.hemi.length=m,s.directionalShadow.length=f,s.directionalShadowMap.length=f,s.pointShadow.length=g,s.pointShadowMap.length=g,s.spotShadow.length=_,s.spotShadowMap.length=_,s.directionalShadowMatrix.length=f,s.pointShadowMatrix.length=g,s.spotLightMatrix.length=_+v-y,s.spotLightMap.length=v,s.numSpotLightShadowsWithMaps=y,s.numLightProbes=x,b.directionalLength=c,b.pointLength=u,b.spotLength=d,b.rectAreaLength=p,b.hemiLength=m,b.numDirectionalShadows=f,b.numPointShadows=g,b.numSpotShadows=_,b.numSpotMaps=v,b.numLightProbes=x,s.version=To++)},setupView(t,e){let i=0,n=0,l=0,h=0,c=0;const u=e.matrixWorldInverse;for(let d=0,p=t.length;d<p;d++){const e=t[d];if(e.isDirectionalLight){const t=s.directional[i];t.direction.setFromMatrixPosition(e.matrixWorld),r.setFromMatrixPosition(e.target.matrixWorld),t.direction.sub(r),t.direction.transformDirection(u),i++}else if(e.isSpotLight){const t=s.spot[l];t.position.setFromMatrixPosition(e.matrixWorld),t.position.applyMatrix4(u),t.direction.setFromMatrixPosition(e.matrixWorld),r.setFromMatrixPosition(e.target.matrixWorld),t.direction.sub(r),t.direction.transformDirection(u),l++}else if(e.isRectAreaLight){const t=s.rectArea[h];t.position.setFromMatrixPosition(e.matrixWorld),t.position.applyMatrix4(u),o.identity(),a.copy(e.matrixWorld),a.premultiply(u),o.extractRotation(a),t.halfWidth.set(.5*e.width,0,0),t.halfHeight.set(0,.5*e.height,0),t.halfWidth.applyMatrix4(o),t.halfHeight.applyMatrix4(o),h++}else if(e.isPointLight){const t=s.point[n];t.position.setFromMatrixPosition(e.matrixWorld),t.position.applyMatrix4(u),n++}else if(e.isHemisphereLight){const t=s.hemi[c];t.direction.setFromMatrixPosition(e.matrixWorld),t.direction.transformDirection(u),c++}}},state:s}}function Co(t,e){const i=new Ao(t,e),n=[],s=[],r={lightsArray:n,shadowsArray:s,lights:i};return{init(){n.length=0,s.length=0},state:r,setupLights(t){i.setup(n,t)},setupLightsView(t){i.setupView(n,t)},pushLight(t){n.push(t)},pushShadow(t){s.push(t)}}}function Ro(t,e){let i=new WeakMap;return{get(n,s=0){const r=i.get(n);let a;return void 0===r?(a=new Co(t,e),i.set(n,[a])):s>=r.length?(a=new Co(t,e),r.push(a)):a=r[s],a},dispose(){i=new WeakMap}}}class Po extends ns{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,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 Lo extends ns{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}}function Io(t,e,i){let n=new or;const s=new ri,r=new ri,a=new Ri,o=new Po({depthPacking:3201}),l=new Lo,h={},c=i.maxTextureSize,u={[F]:1,[B]:0,[z]:2},d=new Ys({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ri},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const m=new Ss;m.setAttribute("position",new ds(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const f=new Vs(m,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let _=this.type;function v(i,n){const r=e.update(f);d.defines.VSM_SAMPLES!==i.blurSamples&&(d.defines.VSM_SAMPLES=i.blurSamples,p.defines.VSM_SAMPLES=i.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),null===i.mapPass&&(i.mapPass=new Li(s.x,s.y)),d.uniforms.shadow_pass.value=i.map.texture,d.uniforms.resolution.value=i.mapSize,d.uniforms.radius.value=i.radius,t.setRenderTarget(i.mapPass),t.clear(),t.renderBufferDirect(n,null,r,d,f,null),p.uniforms.shadow_pass.value=i.mapPass.texture,p.uniforms.resolution.value=i.mapSize,p.uniforms.radius.value=i.radius,t.setRenderTarget(i.map),t.clear(),t.renderBufferDirect(n,null,r,p,f,null)}function y(e,i,n,s){let r=null;const a=!0===n.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(void 0!==a)r=a;else if(r=!0===n.isPointLight?l:o,t.localClippingEnabled&&!0===i.clipShadows&&Array.isArray(i.clippingPlanes)&&0!==i.clippingPlanes.length||i.displacementMap&&0!==i.displacementScale||i.alphaMap&&i.alphaTest>0||i.map&&i.alphaTest>0){const t=r.uuid,e=i.uuid;let n=h[t];void 0===n&&(n={},h[t]=n);let s=n[e];void 0===s&&(s=r.clone(),n[e]=s,i.addEventListener("dispose",M)),r=s}return r.visible=i.visible,r.wireframe=i.wireframe,r.side=3===s?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:u[i.side],r.alphaMap=i.alphaMap,r.alphaTest=i.alphaTest,r.map=i.map,r.clipShadows=i.clipShadows,r.clippingPlanes=i.clippingPlanes,r.clipIntersection=i.clipIntersection,r.displacementMap=i.displacementMap,r.displacementScale=i.displacementScale,r.displacementBias=i.displacementBias,r.wireframeLinewidth=i.wireframeLinewidth,r.linewidth=i.linewidth,!0===n.isPointLight&&!0===r.isMeshDistanceMaterial&&(t.properties.get(r).light=n),r}function x(i,s,r,a,o){if(!1===i.visible)return;if(i.layers.test(s.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&3===o)&&(!i.frustumCulled||n.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,i.matrixWorld);const n=e.update(i),l=i.material;if(Array.isArray(l)){const e=n.groups;for(let h=0,c=e.length;h<c;h++){const c=e[h],u=l[c.materialIndex];if(u&&u.visible){const e=y(i,u,a,o);i.onBeforeShadow(t,i,s,r,n,e,c),t.renderBufferDirect(r,null,n,e,i,c),i.onAfterShadow(t,i,s,r,n,e,c)}}}else if(l.visible){const e=y(i,l,a,o);i.onBeforeShadow(t,i,s,r,n,e,null),t.renderBufferDirect(r,null,n,e,i,null),i.onAfterShadow(t,i,s,r,n,e,null)}}const l=i.children;for(let t=0,e=l.length;t<e;t++)x(l[t],s,r,a,o)}function M(t){t.target.removeEventListener("dispose",M);for(const e in h){const i=h[e],n=t.target.uuid;n in i&&(i[n].dispose(),delete i[n])}}this.render=function(e,i,o){if(!1===g.enabled)return;if(!1===g.autoUpdate&&!1===g.needsUpdate)return;if(0===e.length)return;const l=t.getRenderTarget(),h=t.getActiveCubeFace(),u=t.getActiveMipmapLevel(),d=t.state;d.setBlending(0),d.buffers.color.setClear(1,1,1,1),d.buffers.depth.setTest(!0),d.setScissorTest(!1);const p=3!==_&&3===this.type,m=3===_&&3!==this.type;for(let f=0,g=e.length;f<g;f++){const l=e[f],h=l.shadow;if(void 0===h)continue;if(!1===h.autoUpdate&&!1===h.needsUpdate)continue;s.copy(h.mapSize);const u=h.getFrameExtents();if(s.multiply(u),r.copy(h.mapSize),(s.x>c||s.y>c)&&(s.x>c&&(r.x=Math.floor(c/u.x),s.x=r.x*u.x,h.mapSize.x=r.x),s.y>c&&(r.y=Math.floor(c/u.y),s.y=r.y*u.y,h.mapSize.y=r.y)),null===h.map||!0===p||!0===m){const t=3!==this.type?{minFilter:ft,magFilter:ft}:{};null!==h.map&&h.map.dispose(),h.map=new Li(s.x,s.y,t),h.map.texture.name=l.name+".shadowMap",h.camera.updateProjectionMatrix()}t.setRenderTarget(h.map),t.clear();const g=h.getViewportCount();for(let t=0;t<g;t++){const e=h.getViewport(t);a.set(r.x*e.x,r.y*e.y,r.x*e.z,r.y*e.w),d.viewport(a),h.updateMatrices(l,t),n=h.getFrustum(),x(i,o,h.camera,l,this.type)}!0!==h.isPointLightShadow&&3===this.type&&v(h,o),h.needsUpdate=!1}_=this.type,g.needsUpdate=!1,t.setRenderTarget(l,h,u)}}function Do(t,e,i){const n=i.isWebGL2,s=new function(){let e=!1;const i=new Ri;let n=null;const s=new Ri(0,0,0,0);return{setMask(i){n===i||e||(t.colorMask(i,i,i,i),n=i)},setLocked(t){e=t},setClear(e,n,r,a,o){!0===o&&(e*=a,n*=a,r*=a),i.set(e,n,r,a),!1===s.equals(i)&&(t.clearColor(e,n,r,a),s.copy(i))},reset(){e=!1,n=null,s.set(-1,0,0,0)}}},r=new function(){let e=!1,i=null,n=null,s=null;return{setTest(e){e?at(t.DEPTH_TEST):ot(t.DEPTH_TEST)},setMask(n){i===n||e||(t.depthMask(n),i=n)},setFunc(e){if(n!==e){switch(e){case 0:t.depthFunc(t.NEVER);break;case 1:t.depthFunc(t.ALWAYS);break;case 2:t.depthFunc(t.LESS);break;case 3:default:t.depthFunc(t.LEQUAL);break;case 4:t.depthFunc(t.EQUAL);break;case 5:t.depthFunc(t.GEQUAL);break;case 6:t.depthFunc(t.GREATER);break;case 7:t.depthFunc(t.NOTEQUAL)}n=e}},setLocked(t){e=t},setClear(e){s!==e&&(t.clearDepth(e),s=e)},reset(){e=!1,i=null,n=null,s=null}}},a=new function(){let e=!1,i=null,n=null,s=null,r=null,a=null,o=null,l=null,h=null;return{setTest(i){e||(i?at(t.STENCIL_TEST):ot(t.STENCIL_TEST))},setMask(n){i===n||e||(t.stencilMask(n),i=n)},setFunc(e,i,a){n===e&&s===i&&r===a||(t.stencilFunc(e,i,a),n=e,s=i,r=a)},setOp(e,i,n){a===e&&o===i&&l===n||(t.stencilOp(e,i,n),a=e,o=i,l=n)},setLocked(t){e=t},setClear(e){h!==e&&(t.clearStencil(e),h=e)},reset(){e=!1,i=null,n=null,s=null,r=null,a=null,o=null,l=null,h=null}}},o=new WeakMap,l=new WeakMap;let h={},c={},u=new WeakMap,d=[],p=null,m=!1,f=null,g=null,_=null,v=null,y=null,x=null,M=null,b=new ts(0,0,0),S=0,w=!1,T=null,E=null,A=null,C=null,R=null;const P=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let L=!1,I=0;const D=t.getParameter(t.VERSION);-1!==D.indexOf("WebGL")?(I=parseFloat(/^WebGL (\d)/.exec(D)[1]),L=I>=1):-1!==D.indexOf("OpenGL ES")&&(I=parseFloat(/^OpenGL ES (\d)/.exec(D)[1]),L=I>=2);let N=null,U={};const O=t.getParameter(t.SCISSOR_BOX),F=t.getParameter(t.VIEWPORT),B=(new Ri).fromArray(O),z=(new Ri).fromArray(F);function st(e,i,s,r){const a=new Uint8Array(4),o=t.createTexture();t.bindTexture(e,o),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let l=0;l<s;l++)!n||e!==t.TEXTURE_3D&&e!==t.TEXTURE_2D_ARRAY?t.texImage2D(i+l,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,a):t.texImage3D(i,0,t.RGBA,1,1,r,0,t.RGBA,t.UNSIGNED_BYTE,a);return o}const rt={};function at(e){!0!==h[e]&&(t.enable(e),h[e]=!0)}function ot(e){!1!==h[e]&&(t.disable(e),h[e]=!1)}rt[t.TEXTURE_2D]=st(t.TEXTURE_2D,t.TEXTURE_2D,1),rt[t.TEXTURE_CUBE_MAP]=st(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),n&&(rt[t.TEXTURE_2D_ARRAY]=st(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),rt[t.TEXTURE_3D]=st(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),s.setClear(0,0,0,1),r.setClear(1),a.setClear(0),at(t.DEPTH_TEST),r.setFunc(3),ut(!1),dt(1),at(t.CULL_FACE),ct(0);const lt={[k]:t.FUNC_ADD,[V]:t.FUNC_SUBTRACT,[G]:t.FUNC_REVERSE_SUBTRACT};if(n)lt[103]=t.MIN,lt[104]=t.MAX;else{const t=e.get("EXT_blend_minmax");null!==t&&(lt[103]=t.MIN_EXT,lt[104]=t.MAX_EXT)}const ht={[H]:t.ZERO,[W]:t.ONE,[q]:t.SRC_COLOR,[j]:t.SRC_ALPHA,[Q]:t.SRC_ALPHA_SATURATE,[K]:t.DST_COLOR,[Z]:t.DST_ALPHA,[X]:t.ONE_MINUS_SRC_COLOR,[Y]:t.ONE_MINUS_SRC_ALPHA,[$]:t.ONE_MINUS_DST_COLOR,[J]:t.ONE_MINUS_DST_ALPHA,[tt]:t.CONSTANT_COLOR,[et]:t.ONE_MINUS_CONSTANT_COLOR,[it]:t.CONSTANT_ALPHA,[nt]:t.ONE_MINUS_CONSTANT_ALPHA};function ct(e,i,n,s,r,a,o,l,h,c){if(0!==e){if(!1===m&&(at(t.BLEND),m=!0),5===e)r=r||i,a=a||n,o=o||s,i===g&&r===y||(t.blendEquationSeparate(lt[i],lt[r]),g=i,y=r),n===_&&s===v&&a===x&&o===M||(t.blendFuncSeparate(ht[n],ht[s],ht[a],ht[o]),_=n,v=s,x=a,M=o),!1!==l.equals(b)&&h===S||(t.blendColor(l.r,l.g,l.b,h),b.copy(l),S=h),f=e,w=!1;else if(e!==f||c!==w){if(g===k&&y===k||(t.blendEquation(t.FUNC_ADD),g=k,y=k),c)switch(e){case 1:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFunc(t.ONE,t.ONE);break;case 3:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case 4:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA)}else switch(e){case 1:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case 3:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case 4:t.blendFunc(t.ZERO,t.SRC_COLOR)}_=null,v=null,x=null,M=null,b.set(0,0,0),S=0,f=e,w=c}}else!0===m&&(ot(t.BLEND),m=!1)}function ut(e){T!==e&&(e?t.frontFace(t.CW):t.frontFace(t.CCW),T=e)}function dt(e){0!==e?(at(t.CULL_FACE),e!==E&&(1===e?t.cullFace(t.BACK):2===e?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):ot(t.CULL_FACE),E=e}function pt(e,i,n){e?(at(t.POLYGON_OFFSET_FILL),C===i&&R===n||(t.polygonOffset(i,n),C=i,R=n)):ot(t.POLYGON_OFFSET_FILL)}return{buffers:{color:s,depth:r,stencil:a},enable:at,disable:ot,bindFramebuffer:(e,i)=>c[e]!==i&&(t.bindFramebuffer(e,i),c[e]=i,n&&(e===t.DRAW_FRAMEBUFFER&&(c[t.FRAMEBUFFER]=i),e===t.FRAMEBUFFER&&(c[t.DRAW_FRAMEBUFFER]=i)),!0),drawBuffers(n,s){let r=d,a=!1;if(n)if(r=u.get(s),void 0===r&&(r=[],u.set(s,r)),n.isWebGLMultipleRenderTargets){const e=n.texture;if(r.length!==e.length||r[0]!==t.COLOR_ATTACHMENT0){for(let i=0,n=e.length;i<n;i++)r[i]=t.COLOR_ATTACHMENT0+i;r.length=e.length,a=!0}}else r[0]!==t.COLOR_ATTACHMENT0&&(r[0]=t.COLOR_ATTACHMENT0,a=!0);else r[0]!==t.BACK&&(r[0]=t.BACK,a=!0);a&&(i.isWebGL2?t.drawBuffers(r):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(r))},useProgram:e=>p!==e&&(t.useProgram(e),p=e,!0),setBlending:ct,setMaterial(e,i){2===e.side?ot(t.CULL_FACE):at(t.CULL_FACE);let n=1===e.side;i&&(n=!n),ut(n),1===e.blending&&!1===e.transparent?ct(0):ct(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.blendColor,e.blendAlpha,e.premultipliedAlpha),r.setFunc(e.depthFunc),r.setTest(e.depthTest),r.setMask(e.depthWrite),s.setMask(e.colorWrite);const o=e.stencilWrite;a.setTest(o),o&&(a.setMask(e.stencilWriteMask),a.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),a.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),pt(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage?at(t.SAMPLE_ALPHA_TO_COVERAGE):ot(t.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:ut,setCullFace:dt,setLineWidth(e){e!==A&&(L&&t.lineWidth(e),A=e)},setPolygonOffset:pt,setScissorTest(e){e?at(t.SCISSOR_TEST):ot(t.SCISSOR_TEST)},activeTexture(e){void 0===e&&(e=t.TEXTURE0+P-1),N!==e&&(t.activeTexture(e),N=e)},bindTexture(e,i,n){void 0===n&&(n=null===N?t.TEXTURE0+P-1:N);let s=U[n];void 0===s&&(s={type:void 0,texture:void 0},U[n]=s),s.type===e&&s.texture===i||(N!==n&&(t.activeTexture(n),N=n),t.bindTexture(e,i||rt[e]),s.type=e,s.texture=i)},unbindTexture(){const e=U[N];void 0!==e&&void 0!==e.type&&(t.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D(){try{t.compressedTexImage2D.apply(t,arguments)}catch(e){}},compressedTexImage3D(){try{t.compressedTexImage3D.apply(t,arguments)}catch(e){}},texImage2D(){try{t.texImage2D.apply(t,arguments)}catch(e){}},texImage3D(){try{t.texImage3D.apply(t,arguments)}catch(e){}},updateUBOMapping(e,i){let n=l.get(i);void 0===n&&(n=new WeakMap,l.set(i,n));let s=n.get(e);void 0===s&&(s=t.getUniformBlockIndex(i,e.name),n.set(e,s))},uniformBlockBinding(e,i){const n=l.get(i).get(e);o.get(i)!==n&&(t.uniformBlockBinding(i,n,e.__bindingPointIndex),o.set(i,n))},texStorage2D(){try{t.texStorage2D.apply(t,arguments)}catch(e){}},texStorage3D(){try{t.texStorage3D.apply(t,arguments)}catch(e){}},texSubImage2D(){try{t.texSubImage2D.apply(t,arguments)}catch(e){}},texSubImage3D(){try{t.texSubImage3D.apply(t,arguments)}catch(e){}},compressedTexSubImage2D(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(e){}},compressedTexSubImage3D(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(e){}},scissor(e){!1===B.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),B.copy(e))},viewport(e){!1===z.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),z.copy(e))},reset(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),!0===n&&(t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null)),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),h={},N=null,U={},c={},u=new WeakMap,d=[],p=null,m=!1,f=null,g=null,_=null,v=null,y=null,x=null,M=null,b=new ts(0,0,0),S=0,w=!1,T=null,E=null,A=null,C=null,R=null,B.set(0,0,t.canvas.width,t.canvas.height),z.set(0,0,t.canvas.width,t.canvas.height),s.reset(),r.reset(),a.reset()}}}function No(t,e,i,n,s,r,a){const o=s.isWebGL2,l=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,h="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),c=new WeakMap;let u;const d=new WeakMap;let p=!1;try{p="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(z){}function m(t,e){return p?new OffscreenCanvas(t,e):ui("canvas")}function f(t,e,i,n){let s=1;if((t.width>n||t.height>n)&&(s=n/Math.max(t.width,t.height)),s<1||!0===e){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const n=e?ei:Math.floor,r=n(s*t.width),a=n(s*t.height);void 0===u&&(u=m(r,a));const o=i?m(r,a):u;return o.width=r,o.height=a,o.getContext("2d").drawImage(t,0,0,r,a),o}return t}return t}function g(t){return ti(t.width)&&ti(t.height)}function _(t,e){return t.generateMipmaps&&e&&t.minFilter!==ft&&t.minFilter!==vt}function v(e){t.generateMipmap(e)}function y(i,n,s,r,a=!1){if(!1===o)return n;if(null!==i&&void 0!==t[i])return t[i];let l=n;if(n===t.RED&&(s===t.FLOAT&&(l=t.R32F),s===t.HALF_FLOAT&&(l=t.R16F),s===t.UNSIGNED_BYTE&&(l=t.R8)),n===t.RED_INTEGER&&(s===t.UNSIGNED_BYTE&&(l=t.R8UI),s===t.UNSIGNED_SHORT&&(l=t.R16UI),s===t.UNSIGNED_INT&&(l=t.R32UI),s===t.BYTE&&(l=t.R8I),s===t.SHORT&&(l=t.R16I),s===t.INT&&(l=t.R32I)),n===t.RG&&(s===t.FLOAT&&(l=t.RG32F),s===t.HALF_FLOAT&&(l=t.RG16F),s===t.UNSIGNED_BYTE&&(l=t.RG8)),n===t.RGBA){const e=a?Ae:yi.getTransfer(r);s===t.FLOAT&&(l=t.RGBA32F),s===t.HALF_FLOAT&&(l=t.RGBA16F),s===t.UNSIGNED_BYTE&&(l=e===Ce?t.SRGB8_ALPHA8:t.RGBA8),s===t.UNSIGNED_SHORT_4_4_4_4&&(l=t.RGBA4),s===t.UNSIGNED_SHORT_5_5_5_1&&(l=t.RGB5_A1)}return l!==t.R16F&&l!==t.R32F&&l!==t.RG16F&&l!==t.RG32F&&l!==t.RGBA16F&&l!==t.RGBA32F||e.get("EXT_color_buffer_float"),l}function x(t,e,i){return!0===_(t,i)||t.isFramebufferTexture&&t.minFilter!==ft&&t.minFilter!==vt?Math.log2(Math.max(e.width,e.height))+1:void 0!==t.mipmaps&&t.mipmaps.length>0?t.mipmaps.length:t.isCompressedTexture&&Array.isArray(t.image)?e.mipmaps.length:1}function M(e){return e===ft||e===gt||e===_t?t.NEAREST:t.LINEAR}function b(t){const e=t.target;e.removeEventListener("dispose",b),function(t){const e=n.get(t);if(void 0===e.__webglInit)return;const i=t.source,s=d.get(i);if(s){const n=s[e.__cacheKey];n.usedTimes--,0===n.usedTimes&&w(t),0===Object.keys(s).length&&d.delete(i)}n.remove(t)}(e),e.isVideoTexture&&c.delete(e)}function S(e){const i=e.target;i.removeEventListener("dispose",S),function(e){const i=e.texture,s=n.get(e),r=n.get(i);if(void 0!==r.__webglTexture&&(t.deleteTexture(r.__webglTexture),a.memory.textures--),e.depthTexture&&e.depthTexture.dispose(),e.isWebGLCubeRenderTarget)for(let n=0;n<6;n++){if(Array.isArray(s.__webglFramebuffer[n]))for(let e=0;e<s.__webglFramebuffer[n].length;e++)t.deleteFramebuffer(s.__webglFramebuffer[n][e]);else t.deleteFramebuffer(s.__webglFramebuffer[n]);s.__webglDepthbuffer&&t.deleteRenderbuffer(s.__webglDepthbuffer[n])}else{if(Array.isArray(s.__webglFramebuffer))for(let e=0;e<s.__webglFramebuffer.length;e++)t.deleteFramebuffer(s.__webglFramebuffer[e]);else t.deleteFramebuffer(s.__webglFramebuffer);if(s.__webglDepthbuffer&&t.deleteRenderbuffer(s.__webglDepthbuffer),s.__webglMultisampledFramebuffer&&t.deleteFramebuffer(s.__webglMultisampledFramebuffer),s.__webglColorRenderbuffer)for(let e=0;e<s.__webglColorRenderbuffer.length;e++)s.__webglColorRenderbuffer[e]&&t.deleteRenderbuffer(s.__webglColorRenderbuffer[e]);s.__webglDepthRenderbuffer&&t.deleteRenderbuffer(s.__webglDepthRenderbuffer)}if(e.isWebGLMultipleRenderTargets)for(let o=0,l=i.length;o<l;o++){const e=n.get(i[o]);e.__webglTexture&&(t.deleteTexture(e.__webglTexture),a.memory.textures--),n.remove(i[o])}n.remove(i),n.remove(e)}(i)}function w(e){const i=n.get(e);t.deleteTexture(i.__webglTexture);const s=e.source;delete d.get(s)[i.__cacheKey],a.memory.textures--}let T=0;function E(e,s){const r=n.get(e);if(e.isVideoTexture&&function(t){const e=a.render.frame;c.get(t)!==e&&(c.set(t,e),t.update())}(e),!1===e.isRenderTargetTexture&&e.version>0&&r.__version!==e.version){const t=e.image;if(null===t);else if(!1!==t.complete)return void I(r,e,s)}i.bindTexture(t.TEXTURE_2D,r.__webglTexture,t.TEXTURE0+s)}const A={[dt]:t.REPEAT,[pt]:t.CLAMP_TO_EDGE,[mt]:t.MIRRORED_REPEAT},C={[ft]:t.NEAREST,[gt]:t.NEAREST_MIPMAP_NEAREST,[_t]:t.NEAREST_MIPMAP_LINEAR,[vt]:t.LINEAR,[yt]:t.LINEAR_MIPMAP_NEAREST,[xt]:t.LINEAR_MIPMAP_LINEAR},R={[Ie]:t.NEVER,[ze]:t.ALWAYS,[De]:t.LESS,[Ue]:t.LEQUAL,[Ne]:t.EQUAL,[Be]:t.GEQUAL,[Oe]:t.GREATER,[Fe]:t.NOTEQUAL};function P(i,r,a){if(a?(t.texParameteri(i,t.TEXTURE_WRAP_S,A[r.wrapS]),t.texParameteri(i,t.TEXTURE_WRAP_T,A[r.wrapT]),i!==t.TEXTURE_3D&&i!==t.TEXTURE_2D_ARRAY||t.texParameteri(i,t.TEXTURE_WRAP_R,A[r.wrapR]),t.texParameteri(i,t.TEXTURE_MAG_FILTER,C[r.magFilter]),t.texParameteri(i,t.TEXTURE_MIN_FILTER,C[r.minFilter])):(t.texParameteri(i,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(i,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),i!==t.TEXTURE_3D&&i!==t.TEXTURE_2D_ARRAY||t.texParameteri(i,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),r.wrapS!==pt||r.wrapT,t.texParameteri(i,t.TEXTURE_MAG_FILTER,M(r.magFilter)),t.texParameteri(i,t.TEXTURE_MIN_FILTER,M(r.minFilter)),r.minFilter!==ft&&r.minFilter),r.compareFunction&&(t.texParameteri(i,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(i,t.TEXTURE_COMPARE_FUNC,R[r.compareFunction])),!0===e.has("EXT_texture_filter_anisotropic")){const a=e.get("EXT_texture_filter_anisotropic");if(r.magFilter===ft)return;if(r.minFilter!==_t&&r.minFilter!==xt)return;if(r.type===Tt&&!1===e.has("OES_texture_float_linear"))return;if(!1===o&&r.type===Et&&!1===e.has("OES_texture_half_float_linear"))return;(r.anisotropy>1||n.get(r).__currentAnisotropy)&&(t.texParameterf(i,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(r.anisotropy,s.getMaxAnisotropy())),n.get(r).__currentAnisotropy=r.anisotropy)}}function L(e,i){let n=!1;void 0===e.__webglInit&&(e.__webglInit=!0,i.addEventListener("dispose",b));const s=i.source;let r=d.get(s);void 0===r&&(r={},d.set(s,r));const o=function(t){const e=[];return e.push(t.wrapS),e.push(t.wrapT),e.push(t.wrapR||0),e.push(t.magFilter),e.push(t.minFilter),e.push(t.anisotropy),e.push(t.internalFormat),e.push(t.format),e.push(t.type),e.push(t.generateMipmaps),e.push(t.premultiplyAlpha),e.push(t.flipY),e.push(t.unpackAlignment),e.push(t.colorSpace),e.join()}(i);if(o!==e.__cacheKey){void 0===r[o]&&(r[o]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,n=!0),r[o].usedTimes++;const s=r[e.__cacheKey];void 0!==s&&(r[e.__cacheKey].usedTimes--,0===s.usedTimes&&w(i)),e.__cacheKey=o,e.__webglTexture=r[o].texture}return n}function I(e,a,l){let h=t.TEXTURE_2D;(a.isDataArrayTexture||a.isCompressedArrayTexture)&&(h=t.TEXTURE_2D_ARRAY),a.isData3DTexture&&(h=t.TEXTURE_3D);const c=L(e,a),u=a.source;i.bindTexture(h,e.__webglTexture,t.TEXTURE0+l);const d=n.get(u);if(u.version!==d.__version||!0===c){i.activeTexture(t.TEXTURE0+l);const e=yi.getPrimaries(yi.workingColorSpace),n=a.colorSpace===be?null:yi.getPrimaries(a.colorSpace),p=a.colorSpace===be||e===n?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,p);const m=function(t){return!o&&(t.wrapS!==pt||t.wrapT!==pt||t.minFilter!==ft&&t.minFilter!==vt)}(a)&&!1===g(a.image);let M=f(a.image,m,!1,s.maxTextureSize);M=B(a,M);const b=g(M)||o,S=r.convert(a.format,a.colorSpace);let w,T=r.convert(a.type),E=y(a.internalFormat,S,T,a.colorSpace,a.isVideoTexture);P(h,a,b);const A=a.mipmaps,C=o&&!0!==a.isVideoTexture&&E!==Wt,R=void 0===d.__version||!0===c,L=x(a,M,b);if(a.isDepthTexture)E=t.DEPTH_COMPONENT,o?E=a.type===Tt?t.DEPTH_COMPONENT32F:a.type===wt?t.DEPTH_COMPONENT24:a.type===Rt?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT16:a.type,a.format===Lt&&E===t.DEPTH_COMPONENT&&a.type!==bt&&a.type!==wt&&(a.type=wt,T=r.convert(a.type)),a.format===It&&E===t.DEPTH_COMPONENT&&(E=t.DEPTH_STENCIL,a.type!==Rt&&(a.type=Rt,T=r.convert(a.type))),R&&(C?i.texStorage2D(t.TEXTURE_2D,1,E,M.width,M.height):i.texImage2D(t.TEXTURE_2D,0,E,M.width,M.height,0,S,T,null));else if(a.isDataTexture)if(A.length>0&&b){C&&R&&i.texStorage2D(t.TEXTURE_2D,L,E,A[0].width,A[0].height);for(let e=0,n=A.length;e<n;e++)w=A[e],C?i.texSubImage2D(t.TEXTURE_2D,e,0,0,w.width,w.height,S,T,w.data):i.texImage2D(t.TEXTURE_2D,e,E,w.width,w.height,0,S,T,w.data);a.generateMipmaps=!1}else C?(R&&i.texStorage2D(t.TEXTURE_2D,L,E,M.width,M.height),i.texSubImage2D(t.TEXTURE_2D,0,0,0,M.width,M.height,S,T,M.data)):i.texImage2D(t.TEXTURE_2D,0,E,M.width,M.height,0,S,T,M.data);else if(a.isCompressedTexture)if(a.isCompressedArrayTexture){C&&R&&i.texStorage3D(t.TEXTURE_2D_ARRAY,L,E,A[0].width,A[0].height,M.depth);for(let e=0,n=A.length;e<n;e++)w=A[e],a.format!==Pt?null!==S&&(C?i.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,w.width,w.height,M.depth,S,w.data,0,0):i.compressedTexImage3D(t.TEXTURE_2D_ARRAY,e,E,w.width,w.height,M.depth,0,w.data,0,0)):C?i.texSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,w.width,w.height,M.depth,S,T,w.data):i.texImage3D(t.TEXTURE_2D_ARRAY,e,E,w.width,w.height,M.depth,0,S,T,w.data)}else{C&&R&&i.texStorage2D(t.TEXTURE_2D,L,E,A[0].width,A[0].height);for(let e=0,n=A.length;e<n;e++)w=A[e],a.format!==Pt?null!==S&&(C?i.compressedTexSubImage2D(t.TEXTURE_2D,e,0,0,w.width,w.height,S,w.data):i.compressedTexImage2D(t.TEXTURE_2D,e,E,w.width,w.height,0,w.data)):C?i.texSubImage2D(t.TEXTURE_2D,e,0,0,w.width,w.height,S,T,w.data):i.texImage2D(t.TEXTURE_2D,e,E,w.width,w.height,0,S,T,w.data)}else if(a.isDataArrayTexture)C?(R&&i.texStorage3D(t.TEXTURE_2D_ARRAY,L,E,M.width,M.height,M.depth),i.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,M.width,M.height,M.depth,S,T,M.data)):i.texImage3D(t.TEXTURE_2D_ARRAY,0,E,M.width,M.height,M.depth,0,S,T,M.data);else if(a.isData3DTexture)C?(R&&i.texStorage3D(t.TEXTURE_3D,L,E,M.width,M.height,M.depth),i.texSubImage3D(t.TEXTURE_3D,0,0,0,0,M.width,M.height,M.depth,S,T,M.data)):i.texImage3D(t.TEXTURE_3D,0,E,M.width,M.height,M.depth,0,S,T,M.data);else if(a.isFramebufferTexture){if(R)if(C)i.texStorage2D(t.TEXTURE_2D,L,E,M.width,M.height);else{let e=M.width,n=M.height;for(let s=0;s<L;s++)i.texImage2D(t.TEXTURE_2D,s,E,e,n,0,S,T,null),e>>=1,n>>=1}}else if(A.length>0&&b){C&&R&&i.texStorage2D(t.TEXTURE_2D,L,E,A[0].width,A[0].height);for(let e=0,n=A.length;e<n;e++)w=A[e],C?i.texSubImage2D(t.TEXTURE_2D,e,0,0,S,T,w):i.texImage2D(t.TEXTURE_2D,e,E,S,T,w);a.generateMipmaps=!1}else C?(R&&i.texStorage2D(t.TEXTURE_2D,L,E,M.width,M.height),i.texSubImage2D(t.TEXTURE_2D,0,0,0,S,T,M)):i.texImage2D(t.TEXTURE_2D,0,E,S,T,M);_(a,b)&&v(h),d.__version=u.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}function D(e,s,a,o,h,c){const u=r.convert(a.format,a.colorSpace),d=r.convert(a.type),p=y(a.internalFormat,u,d,a.colorSpace);if(!n.get(s).__hasExternalTextures){const e=Math.max(1,s.width>>c),n=Math.max(1,s.height>>c);h===t.TEXTURE_3D||h===t.TEXTURE_2D_ARRAY?i.texImage3D(h,c,p,e,n,s.depth,0,u,d,null):i.texImage2D(h,c,p,e,n,0,u,d,null)}i.bindFramebuffer(t.FRAMEBUFFER,e),F(s)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,o,h,n.get(a).__webglTexture,0,O(s)):(h===t.TEXTURE_2D||h>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&h<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,o,h,n.get(a).__webglTexture,c),i.bindFramebuffer(t.FRAMEBUFFER,null)}function N(e,i,n){if(t.bindRenderbuffer(t.RENDERBUFFER,e),i.depthBuffer&&!i.stencilBuffer){let s=!0===o?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(n||F(i)){const e=i.depthTexture;e&&e.isDepthTexture&&(e.type===Tt?s=t.DEPTH_COMPONENT32F:e.type===wt&&(s=t.DEPTH_COMPONENT24));const n=O(i);F(i)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,n,s,i.width,i.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,n,s,i.width,i.height)}else t.renderbufferStorage(t.RENDERBUFFER,s,i.width,i.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e)}else if(i.depthBuffer&&i.stencilBuffer){const s=O(i);n&&!1===F(i)?t.renderbufferStorageMultisample(t.RENDERBUFFER,s,t.DEPTH24_STENCIL8,i.width,i.height):F(i)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,s,t.DEPTH24_STENCIL8,i.width,i.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,i.width,i.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e)}else{const e=!0===i.isWebGLMultipleRenderTargets?i.texture:[i.texture];for(let s=0;s<e.length;s++){const a=e[s],o=r.convert(a.format,a.colorSpace),h=r.convert(a.type),c=y(a.internalFormat,o,h,a.colorSpace),u=O(i);n&&!1===F(i)?t.renderbufferStorageMultisample(t.RENDERBUFFER,u,c,i.width,i.height):F(i)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,u,c,i.width,i.height):t.renderbufferStorage(t.RENDERBUFFER,c,i.width,i.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function U(e){const s=n.get(e),r=!0===e.isWebGLCubeRenderTarget;if(e.depthTexture&&!s.__autoAllocateDepthBuffer){if(r)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,s){if(s&&s.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(t.FRAMEBUFFER,e),!s.depthTexture||!s.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");n.get(s.depthTexture).__webglTexture&&s.depthTexture.image.width===s.width&&s.depthTexture.image.height===s.height||(s.depthTexture.image.width=s.width,s.depthTexture.image.height=s.height,s.depthTexture.needsUpdate=!0),E(s.depthTexture,0);const r=n.get(s.depthTexture).__webglTexture,a=O(s);if(s.depthTexture.format===Lt)F(s)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,r,0,a):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,r,0);else{if(s.depthTexture.format!==It)throw new Error("Unknown depthTexture format");F(s)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,r,0,a):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,r,0)}}(s.__webglFramebuffer,e)}else if(r){s.__webglDepthbuffer=[];for(let n=0;n<6;n++)i.bindFramebuffer(t.FRAMEBUFFER,s.__webglFramebuffer[n]),s.__webglDepthbuffer[n]=t.createRenderbuffer(),N(s.__webglDepthbuffer[n],e,!1)}else i.bindFramebuffer(t.FRAMEBUFFER,s.__webglFramebuffer),s.__webglDepthbuffer=t.createRenderbuffer(),N(s.__webglDepthbuffer,e,!1);i.bindFramebuffer(t.FRAMEBUFFER,null)}function O(t){return Math.min(s.maxSamples,t.samples)}function F(t){const i=n.get(t);return o&&t.samples>0&&!0===e.has("WEBGL_multisampled_render_to_texture")&&!1!==i.__useRenderToTexture}function B(t,i){const n=t.colorSpace,s=t.format;return t.type,!0===t.isCompressedTexture||!0===t.isVideoTexture||t.format===Ge||n!==we&&n!==be&&yi.getTransfer(n)===Ce&&!1===o&&(!0===e.has("EXT_sRGB")&&s===Pt?(t.format=Ge,t.minFilter=vt,t.generateMipmaps=!1):i=Si.sRGBToLinear(i)),i}this.allocateTextureUnit=function(){const t=T;return s.maxTextures,T+=1,t},this.resetTextureUnits=function(){T=0},this.setTexture2D=E,this.setTexture2DArray=function(e,s){const r=n.get(e);e.version>0&&r.__version!==e.version?I(r,e,s):i.bindTexture(t.TEXTURE_2D_ARRAY,r.__webglTexture,t.TEXTURE0+s)},this.setTexture3D=function(e,s){const r=n.get(e);e.version>0&&r.__version!==e.version?I(r,e,s):i.bindTexture(t.TEXTURE_3D,r.__webglTexture,t.TEXTURE0+s)},this.setTextureCube=function(e,a){const l=n.get(e);e.version>0&&l.__version!==e.version?function(e,a,l){if(6!==a.image.length)return;const h=L(e,a),c=a.source;i.bindTexture(t.TEXTURE_CUBE_MAP,e.__webglTexture,t.TEXTURE0+l);const u=n.get(c);if(c.version!==u.__version||!0===h){i.activeTexture(t.TEXTURE0+l);const e=yi.getPrimaries(yi.workingColorSpace),n=a.colorSpace===be?null:yi.getPrimaries(a.colorSpace),d=a.colorSpace===be||e===n?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);const p=a.isCompressedTexture||a.image[0].isCompressedTexture,m=a.image[0]&&a.image[0].isDataTexture,M=[];for(let t=0;t<6;t++)M[t]=p||m?m?a.image[t].image:a.image[t]:f(a.image[t],!1,!0,s.maxCubemapSize),M[t]=B(a,M[t]);const b=M[0],S=g(b)||o,w=r.convert(a.format,a.colorSpace),T=r.convert(a.type),E=y(a.internalFormat,w,T,a.colorSpace),A=o&&!0!==a.isVideoTexture,C=void 0===u.__version||!0===h;let R,L=x(a,b,S);if(P(t.TEXTURE_CUBE_MAP,a,S),p){A&&C&&i.texStorage2D(t.TEXTURE_CUBE_MAP,L,E,b.width,b.height);for(let e=0;e<6;e++){R=M[e].mipmaps;for(let n=0;n<R.length;n++){const s=R[n];a.format!==Pt?null!==w&&(A?i.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,0,0,s.width,s.height,w,s.data):i.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,E,s.width,s.height,0,s.data)):A?i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,0,0,s.width,s.height,w,T,s.data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,E,s.width,s.height,0,w,T,s.data)}}}else{R=a.mipmaps,A&&C&&(R.length>0&&L++,i.texStorage2D(t.TEXTURE_CUBE_MAP,L,E,M[0].width,M[0].height));for(let e=0;e<6;e++)if(m){A?i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,M[e].width,M[e].height,w,T,M[e].data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,E,M[e].width,M[e].height,0,w,T,M[e].data);for(let n=0;n<R.length;n++){const s=R[n].image[e].image;A?i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,0,0,s.width,s.height,w,T,s.data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,E,s.width,s.height,0,w,T,s.data)}}else{A?i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,w,T,M[e]):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,E,w,T,M[e]);for(let n=0;n<R.length;n++){const s=R[n];A?i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,0,0,w,T,s.image[e]):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,E,w,T,s.image[e])}}}_(a,S)&&v(t.TEXTURE_CUBE_MAP),u.__version=c.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}(l,e,a):i.bindTexture(t.TEXTURE_CUBE_MAP,l.__webglTexture,t.TEXTURE0+a)},this.rebindTextures=function(e,i,s){const r=n.get(e);void 0!==i&&D(r.__webglFramebuffer,e,e.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),void 0!==s&&U(e)},this.setupRenderTarget=function(e){const l=e.texture,h=n.get(e),c=n.get(l);e.addEventListener("dispose",S),!0!==e.isWebGLMultipleRenderTargets&&(void 0===c.__webglTexture&&(c.__webglTexture=t.createTexture()),c.__version=l.version,a.memory.textures++);const u=!0===e.isWebGLCubeRenderTarget,d=!0===e.isWebGLMultipleRenderTargets,p=g(e)||o;if(u){h.__webglFramebuffer=[];for(let e=0;e<6;e++)if(o&&l.mipmaps&&l.mipmaps.length>0){h.__webglFramebuffer[e]=[];for(let i=0;i<l.mipmaps.length;i++)h.__webglFramebuffer[e][i]=t.createFramebuffer()}else h.__webglFramebuffer[e]=t.createFramebuffer()}else{if(o&&l.mipmaps&&l.mipmaps.length>0){h.__webglFramebuffer=[];for(let e=0;e<l.mipmaps.length;e++)h.__webglFramebuffer[e]=t.createFramebuffer()}else h.__webglFramebuffer=t.createFramebuffer();if(d&&s.drawBuffers){const i=e.texture;for(let e=0,s=i.length;e<s;e++){const s=n.get(i[e]);void 0===s.__webglTexture&&(s.__webglTexture=t.createTexture(),a.memory.textures++)}}if(o&&e.samples>0&&!1===F(e)){const n=d?l:[l];h.__webglMultisampledFramebuffer=t.createFramebuffer(),h.__webglColorRenderbuffer=[],i.bindFramebuffer(t.FRAMEBUFFER,h.__webglMultisampledFramebuffer);for(let i=0;i<n.length;i++){const s=n[i];h.__webglColorRenderbuffer[i]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,h.__webglColorRenderbuffer[i]);const a=r.convert(s.format,s.colorSpace),o=r.convert(s.type),l=y(s.internalFormat,a,o,s.colorSpace,!0===e.isXRRenderTarget),c=O(e);t.renderbufferStorageMultisample(t.RENDERBUFFER,c,l,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+i,t.RENDERBUFFER,h.__webglColorRenderbuffer[i])}t.bindRenderbuffer(t.RENDERBUFFER,null),e.depthBuffer&&(h.__webglDepthRenderbuffer=t.createRenderbuffer(),N(h.__webglDepthRenderbuffer,e,!0)),i.bindFramebuffer(t.FRAMEBUFFER,null)}}if(u){i.bindTexture(t.TEXTURE_CUBE_MAP,c.__webglTexture),P(t.TEXTURE_CUBE_MAP,l,p);for(let i=0;i<6;i++)if(o&&l.mipmaps&&l.mipmaps.length>0)for(let n=0;n<l.mipmaps.length;n++)D(h.__webglFramebuffer[i][n],e,l,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+i,n);else D(h.__webglFramebuffer[i],e,l,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+i,0);_(l,p)&&v(t.TEXTURE_CUBE_MAP),i.unbindTexture()}else if(d){const s=e.texture;for(let r=0,a=s.length;r<a;r++){const a=s[r],o=n.get(a);i.bindTexture(t.TEXTURE_2D,o.__webglTexture),P(t.TEXTURE_2D,a,p),D(h.__webglFramebuffer,e,a,t.COLOR_ATTACHMENT0+r,t.TEXTURE_2D,0),_(a,p)&&v(t.TEXTURE_2D)}i.unbindTexture()}else{let n=t.TEXTURE_2D;if((e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&o&&(n=e.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),i.bindTexture(n,c.__webglTexture),P(n,l,p),o&&l.mipmaps&&l.mipmaps.length>0)for(let i=0;i<l.mipmaps.length;i++)D(h.__webglFramebuffer[i],e,l,t.COLOR_ATTACHMENT0,n,i);else D(h.__webglFramebuffer,e,l,t.COLOR_ATTACHMENT0,n,0);_(l,p)&&v(n),i.unbindTexture()}e.depthBuffer&&U(e)},this.updateRenderTargetMipmap=function(e){const s=g(e)||o,r=!0===e.isWebGLMultipleRenderTargets?e.texture:[e.texture];for(let a=0,o=r.length;a<o;a++){const o=r[a];if(_(o,s)){const s=e.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,r=n.get(o).__webglTexture;i.bindTexture(s,r),v(s),i.unbindTexture()}}},this.updateMultisampleRenderTarget=function(e){if(o&&e.samples>0&&!1===F(e)){const s=e.isWebGLMultipleRenderTargets?e.texture:[e.texture],r=e.width,a=e.height;let o=t.COLOR_BUFFER_BIT;const l=[],c=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,u=n.get(e),d=!0===e.isWebGLMultipleRenderTargets;if(d)for(let e=0;e<s.length;e++)i.bindFramebuffer(t.FRAMEBUFFER,u.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,null),i.bindFramebuffer(t.FRAMEBUFFER,u.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,null,0);i.bindFramebuffer(t.READ_FRAMEBUFFER,u.__webglMultisampledFramebuffer),i.bindFramebuffer(t.DRAW_FRAMEBUFFER,u.__webglFramebuffer);for(let i=0;i<s.length;i++){l.push(t.COLOR_ATTACHMENT0+i),e.depthBuffer&&l.push(c);const p=void 0!==u.__ignoreDepthValues&&u.__ignoreDepthValues;if(!1===p&&(e.depthBuffer&&(o|=t.DEPTH_BUFFER_BIT),e.stencilBuffer&&(o|=t.STENCIL_BUFFER_BIT)),d&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,u.__webglColorRenderbuffer[i]),!0===p&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[c]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[c])),d){const e=n.get(s[i]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0)}t.blitFramebuffer(0,0,r,a,0,0,r,a,o,t.NEAREST),h&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,l)}if(i.bindFramebuffer(t.READ_FRAMEBUFFER,null),i.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),d)for(let e=0;e<s.length;e++){i.bindFramebuffer(t.FRAMEBUFFER,u.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,u.__webglColorRenderbuffer[e]);const r=n.get(s[e]).__webglTexture;i.bindFramebuffer(t.FRAMEBUFFER,u.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,r,0)}i.bindFramebuffer(t.DRAW_FRAMEBUFFER,u.__webglMultisampledFramebuffer)}},this.setupDepthRenderbuffer=U,this.setupFrameBufferTexture=D,this.useMultisampledRTT=F}function Uo(t,e,i){const n=i.isWebGL2;return{convert(i,s=""){let r;const a=yi.getTransfer(s);if(i===Mt)return t.UNSIGNED_BYTE;if(i===At)return t.UNSIGNED_SHORT_4_4_4_4;if(i===Ct)return t.UNSIGNED_SHORT_5_5_5_1;if(1010===i)return t.BYTE;if(1011===i)return t.SHORT;if(i===bt)return t.UNSIGNED_SHORT;if(i===St)return t.INT;if(i===wt)return t.UNSIGNED_INT;if(i===Tt)return t.FLOAT;if(i===Et)return n?t.HALF_FLOAT:(r=e.get("OES_texture_half_float"),null!==r?r.HALF_FLOAT_OES:null);if(1021===i)return t.ALPHA;if(i===Pt)return t.RGBA;if(1024===i)return t.LUMINANCE;if(1025===i)return t.LUMINANCE_ALPHA;if(i===Lt)return t.DEPTH_COMPONENT;if(i===It)return t.DEPTH_STENCIL;if(i===Ge)return r=e.get("EXT_sRGB"),null!==r?r.SRGB_ALPHA_EXT:null;if(1028===i)return t.RED;if(i===Dt)return t.RED_INTEGER;if(1030===i)return t.RG;if(i===Nt)return t.RG_INTEGER;if(i===Ut)return t.RGBA_INTEGER;if(i===Ot||i===Ft||i===Bt||i===zt)if(a===Ce){if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),null===r)return null;if(i===Ot)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Ft)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Bt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===zt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(r=e.get("WEBGL_compressed_texture_s3tc"),null===r)return null;if(i===Ot)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Ft)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Bt)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===zt)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(i===kt||i===Vt||i===Gt||i===Ht){if(r=e.get("WEBGL_compressed_texture_pvrtc"),null===r)return null;if(i===kt)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Vt)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Gt)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Ht)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(i===Wt)return r=e.get("WEBGL_compressed_texture_etc1"),null!==r?r.COMPRESSED_RGB_ETC1_WEBGL:null;if(i===qt||i===Xt){if(r=e.get("WEBGL_compressed_texture_etc"),null===r)return null;if(i===qt)return a===Ce?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===Xt)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}if(i===jt||i===Yt||i===Zt||i===Jt||i===Kt||i===$t||i===Qt||i===te||i===ee||i===ie||i===ne||i===se||i===re||i===ae){if(r=e.get("WEBGL_compressed_texture_astc"),null===r)return null;if(i===jt)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Yt)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Zt)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Jt)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Kt)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===$t)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Qt)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===te)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===ee)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===ie)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===ne)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===se)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===re)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===ae)return a===Ce?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}if(i===oe||i===le||i===he){if(r=e.get("EXT_texture_compression_bptc"),null===r)return null;if(i===oe)return a===Ce?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===le)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===he)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(36283===i||i===ce||i===ue||i===de){if(r=e.get("EXT_texture_compression_rgtc"),null===r)return null;if(i===oe)return r.COMPRESSED_RED_RGTC1_EXT;if(i===ce)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===ue)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===de)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return i===Rt?n?t.UNSIGNED_INT_24_8:(r=e.get("WEBGL_depth_texture"),null!==r?r.UNSIGNED_INT_24_8_WEBGL:null):void 0!==t[i]?t[i]:null}}}class Oo extends Js{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}class Fo extends Fn{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Bo={type:"move"};class zo{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new Fo,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new Fo,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Ui,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Ui),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new Fo,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Ui,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Ui),this._grip}dispatchEvent(t){return null!==this._targetRay&&this._targetRay.dispatchEvent(t),null!==this._grip&&this._grip.dispatchEvent(t),null!==this._hand&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const i of t.hand.values())this._getHandJoint(e,i)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(t,e,i){let n=null,s=null,r=null;const a=this._targetRay,o=this._grip,l=this._hand;if(t&&"visible-blurred"!==e.session.visibilityState){if(l&&t.hand){r=!0;for(const r of t.hand.values()){const t=e.getJointPose(r,i),n=this._getHandJoint(l,r);null!==t&&(n.matrix.fromArray(t.transform.matrix),n.matrix.decompose(n.position,n.rotation,n.scale),n.matrixWorldNeedsUpdate=!0,n.jointRadius=t.radius),n.visible=null!==t}const n=l.joints["index-finger-tip"],s=l.joints["thumb-tip"],a=n.position.distanceTo(s.position),o=.02,h=.005;l.inputState.pinching&&a>o+h?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&a<=o-h&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==o&&t.gripSpace&&(s=e.getPose(t.gripSpace,i),null!==s&&(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));null!==a&&(n=e.getPose(t.targetRaySpace,i),null===n&&null!==s&&(n=s),null!==n&&(a.matrix.fromArray(n.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,n.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(n.linearVelocity)):a.hasLinearVelocity=!1,n.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(n.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Bo)))}return null!==a&&(a.visible=null!==n),null!==o&&(o.visible=null!==s),null!==l&&(l.visible=null!==r),this}_getHandJoint(t,e){if(void 0===t.joints[e.jointName]){const i=new Fo;i.matrixAutoUpdate=!1,i.visible=!1,t.joints[e.jointName]=i,t.add(i)}return t.joints[e.jointName]}}class ko extends qe{constructor(t,e){super();const i=this;let n=null,s=1,r=null,a="local-floor",o=1,l=null,h=null,c=null,u=null,d=null,p=null;const m=e.getContextAttributes();let f=null,g=null;const _=[],v=[],y=new ri;let x=null;const M=new Js;M.layers.enable(1),M.viewport=new Ri;const b=new Js;b.layers.enable(2),b.viewport=new Ri;const S=[M,b],w=new Oo;w.layers.enable(1),w.layers.enable(2);let T=null,E=null;function A(t){const e=v.indexOf(t.inputSource);if(-1===e)return;const i=_[e];void 0!==i&&(i.update(t.inputSource,t.frame,l||r),i.dispatchEvent({type:t.type,data:t.inputSource}))}function C(){n.removeEventListener("select",A),n.removeEventListener("selectstart",A),n.removeEventListener("selectend",A),n.removeEventListener("squeeze",A),n.removeEventListener("squeezestart",A),n.removeEventListener("squeezeend",A),n.removeEventListener("end",C),n.removeEventListener("inputsourceschange",R);for(let t=0;t<_.length;t++){const e=v[t];null!==e&&(v[t]=null,_[t].disconnect(e))}T=null,E=null,t.setRenderTarget(f),d=null,u=null,c=null,n=null,g=null,N.stop(),i.isPresenting=!1,t.setPixelRatio(x),t.setSize(y.width,y.height,!1),i.dispatchEvent({type:"sessionend"})}function R(t){for(let e=0;e<t.removed.length;e++){const i=t.removed[e],n=v.indexOf(i);n>=0&&(v[n]=null,_[n].disconnect(i))}for(let e=0;e<t.added.length;e++){const i=t.added[e];let n=v.indexOf(i);if(-1===n){for(let t=0;t<_.length;t++){if(t>=v.length){v.push(i),n=t;break}if(null===v[t]){v[t]=i,n=t;break}}if(-1===n)break}const s=_[n];s&&s.connect(i)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=_[t];return void 0===e&&(e=new zo,_[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=_[t];return void 0===e&&(e=new zo,_[t]=e),e.getGripSpace()},this.getHand=function(t){let e=_[t];return void 0===e&&(e=new zo,_[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){s=t,i.isPresenting},this.setReferenceSpaceType=function(t){a=t,i.isPresenting},this.getReferenceSpace=function(){return l||r},this.setReferenceSpace=function(t){l=t},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return c},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(h){if(n=h,null!==n){if(f=t.getRenderTarget(),n.addEventListener("select",A),n.addEventListener("selectstart",A),n.addEventListener("selectend",A),n.addEventListener("squeeze",A),n.addEventListener("squeezestart",A),n.addEventListener("squeezeend",A),n.addEventListener("end",C),n.addEventListener("inputsourceschange",R),!0!==m.xrCompatible&&await e.makeXRCompatible(),x=t.getPixelRatio(),t.getSize(y),void 0===n.renderState.layers||!1===t.capabilities.isWebGL2){const i={antialias:void 0!==n.renderState.layers||m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(n,e,i),n.updateRenderState({baseLayer:d}),t.setPixelRatio(1),t.setSize(d.framebufferWidth,d.framebufferHeight,!1),g=new Li(d.framebufferWidth,d.framebufferHeight,{format:Pt,type:Mt,colorSpace:t.outputColorSpace,stencilBuffer:m.stencil})}else{let i=null,r=null,a=null;m.depth&&(a=m.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,i=m.stencil?It:Lt,r=m.stencil?Rt:wt);const o={colorFormat:e.RGBA8,depthFormat:a,scaleFactor:s};c=new XRWebGLBinding(n,e),u=c.createProjectionLayer(o),n.updateRenderState({layers:[u]}),t.setPixelRatio(1),t.setSize(u.textureWidth,u.textureHeight,!1),g=new Li(u.textureWidth,u.textureHeight,{format:Pt,type:Mt,depthTexture:new qr(u.textureWidth,u.textureHeight,r,void 0,void 0,void 0,void 0,void 0,void 0,i),stencilBuffer:m.stencil,colorSpace:t.outputColorSpace,samples:m.antialias?4:0}),t.properties.get(g).__ignoreDepthValues=u.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(o),l=null,r=await n.requestReferenceSpace(a),N.setContext(n),N.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==n)return n.environmentBlendMode};const P=new Ui,L=new Ui;function I(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.copy(t.matrixWorld).invert()}this.updateCamera=function(t){if(null===n)return;w.near=b.near=M.near=t.near,w.far=b.far=M.far=t.far,T===w.near&&E===w.far||(n.updateRenderState({depthNear:w.near,depthFar:w.far}),T=w.near,E=w.far);const e=t.parent,i=w.cameras;I(w,e);for(let n=0;n<i.length;n++)I(i[n],e);2===i.length?function(t,e,i){P.setFromMatrixPosition(e.matrixWorld),L.setFromMatrixPosition(i.matrixWorld);const n=P.distanceTo(L),s=e.projectionMatrix.elements,r=i.projectionMatrix.elements,a=s[14]/(s[10]-1),o=s[14]/(s[10]+1),l=(s[9]+1)/s[5],h=(s[9]-1)/s[5],c=(s[8]-1)/s[0],u=(r[8]+1)/r[0],d=a*c,p=a*u,m=n/(-c+u),f=m*-c;e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(f),t.translateZ(m),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.copy(t.matrixWorld).invert();const g=a+m,_=o+m,v=d-f,y=p+(n-f),x=l*o/_*g,M=h*o/_*g;t.projectionMatrix.makePerspective(v,y,x,M,g,_),t.projectionMatrixInverse.copy(t.projectionMatrix).invert()}(w,M,b):w.projectionMatrix.copy(M.projectionMatrix),function(t,e,i){null===i?t.matrix.copy(e.matrixWorld):(t.matrix.copy(i.matrixWorld),t.matrix.invert(),t.matrix.multiply(e.matrixWorld)),t.matrix.decompose(t.position,t.quaternion,t.scale),t.updateMatrixWorld(!0),t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse),t.isPerspectiveCamera&&(t.fov=2*Ze*Math.atan(1/t.projectionMatrix.elements[5]),t.zoom=1)}(t,w,e)},this.getCamera=function(){return w},this.getFoveation=function(){if(null!==u||null!==d)return o},this.setFoveation=function(t){o=t,null!==u&&(u.fixedFoveation=t),null!==d&&void 0!==d.fixedFoveation&&(d.fixedFoveation=t)};let D=null;const N=new lr;N.setAnimationLoop(function(e,n){if(h=n.getViewerPose(l||r),p=n,null!==h){const e=h.views;null!==d&&(t.setRenderTargetFramebuffer(g,d.framebuffer),t.setRenderTarget(g));let i=!1;e.length!==w.cameras.length&&(w.cameras.length=0,i=!0);for(let n=0;n<e.length;n++){const s=e[n];let r=null;if(null!==d)r=d.getViewport(s);else{const e=c.getViewSubImage(u,s);r=e.viewport,0===n&&(t.setRenderTargetTextures(g,e.colorTexture,u.ignoreDepthValues?void 0:e.depthStencilTexture),t.setRenderTarget(g))}let a=S[n];void 0===a&&(a=new Js,a.layers.enable(n),a.viewport=new Ri,S[n]=a),a.matrix.fromArray(s.transform.matrix),a.matrix.decompose(a.position,a.quaternion,a.scale),a.projectionMatrix.fromArray(s.projectionMatrix),a.projectionMatrixInverse.copy(a.projectionMatrix).invert(),a.viewport.set(r.x,r.y,r.width,r.height),0===n&&(w.matrix.copy(a.matrix),w.matrix.decompose(w.position,w.quaternion,w.scale)),!0===i&&w.cameras.push(a)}}for(let t=0;t<_.length;t++){const e=v[t],i=_[t];null!==e&&void 0!==i&&i.update(e,n,l||r)}D&&D(e,n),n.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:n}),p=null}),this.setAnimationLoop=function(t){D=t},this.dispose=function(){}}}function Vo(t,e){function i(t,e){!0===t.matrixAutoUpdate&&t.updateMatrix(),e.value.copy(t.matrix)}function n(n,s){n.opacity.value=s.opacity,s.color&&n.diffuse.value.copy(s.color),s.emissive&&n.emissive.value.copy(s.emissive).multiplyScalar(s.emissiveIntensity),s.map&&(n.map.value=s.map,i(s.map,n.mapTransform)),s.alphaMap&&(n.alphaMap.value=s.alphaMap,i(s.alphaMap,n.alphaMapTransform)),s.bumpMap&&(n.bumpMap.value=s.bumpMap,i(s.bumpMap,n.bumpMapTransform),n.bumpScale.value=s.bumpScale,1===s.side&&(n.bumpScale.value*=-1)),s.normalMap&&(n.normalMap.value=s.normalMap,i(s.normalMap,n.normalMapTransform),n.normalScale.value.copy(s.normalScale),1===s.side&&n.normalScale.value.negate()),s.displacementMap&&(n.displacementMap.value=s.displacementMap,i(s.displacementMap,n.displacementMapTransform),n.displacementScale.value=s.displacementScale,n.displacementBias.value=s.displacementBias),s.emissiveMap&&(n.emissiveMap.value=s.emissiveMap,i(s.emissiveMap,n.emissiveMapTransform)),s.specularMap&&(n.specularMap.value=s.specularMap,i(s.specularMap,n.specularMapTransform)),s.alphaTest>0&&(n.alphaTest.value=s.alphaTest);const r=e.get(s).envMap;if(r&&(n.envMap.value=r,n.flipEnvMap.value=r.isCubeTexture&&!1===r.isRenderTargetTexture?-1:1,n.reflectivity.value=s.reflectivity,n.ior.value=s.ior,n.refractionRatio.value=s.refractionRatio),s.lightMap){n.lightMap.value=s.lightMap;const e=!0===t._useLegacyLights?Math.PI:1;n.lightMapIntensity.value=s.lightMapIntensity*e,i(s.lightMap,n.lightMapTransform)}s.aoMap&&(n.aoMap.value=s.aoMap,n.aoMapIntensity.value=s.aoMapIntensity,i(s.aoMap,n.aoMapTransform))}return{refreshFogUniforms(e,i){i.color.getRGB(e.fogColor.value,Xs(t)),i.isFog?(e.fogNear.value=i.near,e.fogFar.value=i.far):i.isFogExp2&&(e.fogDensity.value=i.density)},refreshMaterialUniforms(t,s,r,a,o){s.isMeshBasicMaterial||s.isMeshLambertMaterial?n(t,s):s.isMeshToonMaterial?(n(t,s),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(t,s)):s.isMeshPhongMaterial?(n(t,s),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4)}(t,s)):s.isMeshStandardMaterial?(n(t,s),function(t,n){t.metalness.value=n.metalness,n.metalnessMap&&(t.metalnessMap.value=n.metalnessMap,i(n.metalnessMap,t.metalnessMapTransform)),t.roughness.value=n.roughness,n.roughnessMap&&(t.roughnessMap.value=n.roughnessMap,i(n.roughnessMap,t.roughnessMapTransform)),e.get(n).envMap&&(t.envMapIntensity.value=n.envMapIntensity)}(t,s),s.isMeshPhysicalMaterial&&function(t,e,n){t.ior.value=e.ior,e.sheen>0&&(t.sheenColor.value.copy(e.sheenColor).multiplyScalar(e.sheen),t.sheenRoughness.value=e.sheenRoughness,e.sheenColorMap&&(t.sheenColorMap.value=e.sheenColorMap,i(e.sheenColorMap,t.sheenColorMapTransform)),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap,i(e.sheenRoughnessMap,t.sheenRoughnessMapTransform))),e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap,i(e.clearcoatMap,t.clearcoatMapTransform)),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap,i(e.clearcoatRoughnessMap,t.clearcoatRoughnessMapTransform)),e.clearcoatNormalMap&&(t.clearcoatNormalMap.value=e.clearcoatNormalMap,i(e.clearcoatNormalMap,t.clearcoatNormalMapTransform),t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),1===e.side&&t.clearcoatNormalScale.value.negate())),e.iridescence>0&&(t.iridescence.value=e.iridescence,t.iridescenceIOR.value=e.iridescenceIOR,t.iridescenceThicknessMinimum.value=e.iridescenceThicknessRange[0],t.iridescenceThicknessMaximum.value=e.iridescenceThicknessRange[1],e.iridescenceMap&&(t.iridescenceMap.value=e.iridescenceMap,i(e.iridescenceMap,t.iridescenceMapTransform)),e.iridescenceThicknessMap&&(t.iridescenceThicknessMap.value=e.iridescenceThicknessMap,i(e.iridescenceThicknessMap,t.iridescenceThicknessMapTransform))),e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=n.texture,t.transmissionSamplerSize.value.set(n.width,n.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap,i(e.transmissionMap,t.transmissionMapTransform)),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap,i(e.thicknessMap,t.thicknessMapTransform)),t.attenuationDistance.value=e.attenuationDistance,t.attenuationColor.value.copy(e.attenuationColor)),e.anisotropy>0&&(t.anisotropyVector.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation)),e.anisotropyMap&&(t.anisotropyMap.value=e.anisotropyMap,i(e.anisotropyMap,t.anisotropyMapTransform))),t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap,i(e.specularColorMap,t.specularColorMapTransform)),e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap,i(e.specularIntensityMap,t.specularIntensityMapTransform))}(t,s,o)):s.isMeshMatcapMaterial?(n(t,s),function(t,e){e.matcap&&(t.matcap.value=e.matcap)}(t,s)):s.isMeshDepthMaterial?n(t,s):s.isMeshDistanceMaterial?(n(t,s),function(t,i){const n=e.get(i).light;t.referencePosition.value.setFromMatrixPosition(n.matrixWorld),t.nearDistance.value=n.shadow.camera.near,t.farDistance.value=n.shadow.camera.far}(t,s)):s.isMeshNormalMaterial?n(t,s):s.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,e.map&&(t.map.value=e.map,i(e.map,t.mapTransform))}(t,s),s.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,s)):s.isPointsMaterial?function(t,e,n,s){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*n,t.scale.value=.5*s,e.map&&(t.map.value=e.map,i(e.map,t.uvTransform)),e.alphaMap&&(t.alphaMap.value=e.alphaMap,i(e.alphaMap,t.alphaMapTransform)),e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,s,r,a):s.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map,i(e.map,t.mapTransform)),e.alphaMap&&(t.alphaMap.value=e.alphaMap,i(e.alphaMap,t.alphaMapTransform)),e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,s):s.isShadowMaterial?(t.color.value.copy(s.color),t.opacity.value=s.opacity):s.isShaderMaterial&&(s.uniformsNeedUpdate=!1)}}}function Go(t,e,i,n){let s={},r={},a=[];const o=i.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(t,e,i,n){const s=t.value,r=e+"_"+i;if(void 0===n[r])return n[r]="number"==typeof s||"boolean"==typeof s?s:s.clone(),!0;{const t=n[r];if("number"==typeof s||"boolean"==typeof s){if(t!==s)return n[r]=s,!0}else if(!1===t.equals(s))return t.copy(s),!0}return!1}function h(t){const e={boundary:0,storage:0};return"number"==typeof t||"boolean"==typeof t?(e.boundary=4,e.storage=4):t.isVector2?(e.boundary=8,e.storage=8):t.isVector3||t.isColor?(e.boundary=16,e.storage=12):t.isVector4?(e.boundary=16,e.storage=16):t.isMatrix3?(e.boundary=48,e.storage=48):t.isMatrix4?(e.boundary=64,e.storage=64):t.isTexture,e}function c(e){const i=e.target;i.removeEventListener("dispose",c);const n=a.indexOf(i.__bindingPointIndex);a.splice(n,1),t.deleteBuffer(s[i.id]),delete s[i.id],delete r[i.id]}return{bind(t,e){const i=e.program;n.uniformBlockBinding(t,i)},update(i,u){let d=s[i.id];void 0===d&&(function(t){const e=t.uniforms;let i=0;for(let s=0,r=e.length;s<r;s++){const t=Array.isArray(e[s])?e[s]:[e[s]];for(let e=0,n=t.length;e<n;e++){const n=t[e],s=Array.isArray(n.value)?n.value:[n.value];for(let t=0,e=s.length;t<e;t++){const e=h(s[t]),r=i%16;0!==r&&16-r<e.boundary&&(i+=16-r),n.__data=new Float32Array(e.storage/Float32Array.BYTES_PER_ELEMENT),n.__offset=i,i+=e.storage}}}const n=i%16;n>0&&(i+=16-n),t.__size=i,t.__cache={}}(i),d=function(e){const i=function(){for(let t=0;t<o;t++)if(-1===a.indexOf(t))return a.push(t),t;return 0}();e.__bindingPointIndex=i;const n=t.createBuffer(),s=e.__size,r=e.usage;return t.bindBuffer(t.UNIFORM_BUFFER,n),t.bufferData(t.UNIFORM_BUFFER,s,r),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,i,n),n}(i),s[i.id]=d,i.addEventListener("dispose",c));const p=u.program;n.updateUBOMapping(i,p);const m=e.render.frame;r[i.id]!==m&&(function(e){const i=s[e.id],n=e.uniforms,r=e.__cache;t.bindBuffer(t.UNIFORM_BUFFER,i);for(let s=0,a=n.length;s<a;s++){const e=Array.isArray(n[s])?n[s]:[n[s]];for(let i=0,n=e.length;i<n;i++){const n=e[i];if(!0===l(n,s,i,r)){const e=n.__offset,i=Array.isArray(n.value)?n.value:[n.value];let s=0;for(let r=0;r<i.length;r++){const a=i[r],o=h(a);"number"==typeof a||"boolean"==typeof a?(n.__data[0]=a,t.bufferSubData(t.UNIFORM_BUFFER,e+s,n.__data)):a.isMatrix3?(n.__data[0]=a.elements[0],n.__data[1]=a.elements[1],n.__data[2]=a.elements[2],n.__data[3]=0,n.__data[4]=a.elements[3],n.__data[5]=a.elements[4],n.__data[6]=a.elements[5],n.__data[7]=0,n.__data[8]=a.elements[6],n.__data[9]=a.elements[7],n.__data[10]=a.elements[8],n.__data[11]=0):(a.toArray(n.__data,s),s+=o.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,e,n.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}(i),r[i.id]=m)},dispose(){for(const e in s)t.deleteBuffer(s[e]);a=[],s={},r={}}}}class Ho{constructor(t={}){const{canvas:e=di(),context:i=null,depth:n=!0,stencil:s=!0,alpha:r=!1,antialias:a=!1,premultipliedAlpha:o=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:c=!1}=t;let u;this.isWebGLRenderer=!0,u=null!==i?i.getContextAttributes().alpha:r;const d=new Uint32Array(4),p=new Int32Array(4);let m=null,f=null;const g=[],_=[];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=Se,this._useLegacyLights=!1,this.toneMapping=0,this.toneMappingExposure=1;const v=this;let y=!1,x=0,M=0,b=null,S=-1,w=null;const T=new Ri,E=new Ri;let A=null;const C=new ts(0);let R=0,P=e.width,L=e.height,I=1,D=null,N=null;const U=new Ri(0,0,P,L),F=new Ri(0,0,P,L);let B=!1;const z=new or;let k=!1,V=!1,G=null;const H=new dn,W=new ri,q=new Ui,X={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function j(){return null===b?I:1}let Y,Z,J,K,$,Q,tt,et,it,nt,st,rt,at,ot,lt,ht,ct,ut,dt,pt,mt,ft,gt,_t,vt=i;function yt(t,i){for(let n=0;n<t.length;n++){const s=t[n],r=e.getContext(s,i);if(null!==r)return r}return null}try{const t={alpha:!0,depth:n,stencil:s,antialias:a,premultipliedAlpha:o,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:c};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${O}`),e.addEventListener("webglcontextlost",It,!1),e.addEventListener("webglcontextrestored",Ot,!1),e.addEventListener("webglcontextcreationerror",Ft,!1),null===vt){const e=["webgl2","webgl","experimental-webgl"];if(!0===v.isWebGL1Renderer&&e.shift(),vt=yt(e,t),null===vt)throw yt(e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}"undefined"!=typeof WebGLRenderingContext&&WebGLRenderingContext,void 0===vt.getShaderPrecisionFormat&&(vt.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(Kt){throw Kt}function St(){Y=new Fr(vt),Z=new vr(vt,Y,t),Y.init(Z),ft=new Uo(vt,Y,Z),J=new Do(vt,Y,Z),K=new kr(vt),$=new yo,Q=new No(vt,Y,J,$,Z,ft,K),tt=new xr(v),et=new Or(v),it=new hr(vt,Z),gt=new gr(vt,Y,it,Z),nt=new Br(vt,it,K,gt),st=new Wr(vt,nt,it,K),dt=new Hr(vt,Z,Q),ht=new yr($),rt=new vo(v,tt,et,Y,Z,gt,ht),at=new Vo(v,$),ot=new So,lt=new Ro(Y,Z),ut=new fr(v,tt,et,J,st,u,o),ct=new Io(v,st,Z),_t=new Go(vt,K,Z,J),pt=new _r(vt,Y,K,Z),mt=new zr(vt,Y,K,Z),K.programs=rt.programs,v.capabilities=Z,v.extensions=Y,v.properties=$,v.renderLists=ot,v.shadowMap=ct,v.state=J,v.info=K}St();const Lt=new ko(v,vt);function It(t){t.preventDefault(),y=!0}function Ot(){y=!1;const t=K.autoReset,e=ct.enabled,i=ct.autoUpdate,n=ct.needsUpdate,s=ct.type;St(),K.autoReset=t,ct.enabled=e,ct.autoUpdate=i,ct.needsUpdate=n,ct.type=s}function Ft(t){}function Bt(t){const e=t.target;e.removeEventListener("dispose",Bt),function(t){(function(t){const e=$.get(t).programs;void 0!==e&&(e.forEach(function(t){rt.releaseProgram(t)}),t.isShaderMaterial&&rt.releaseShaderCache(t))})(t),$.remove(t)}(e)}function zt(t,e,i){!0===t.transparent&&2===t.side&&!1===t.forceSinglePass?(t.side=1,t.needsUpdate=!0,Yt(t,e,i),t.side=0,t.needsUpdate=!0,Yt(t,e,i),t.side=2):Yt(t,e,i)}this.xr=Lt,this.getContext=function(){return vt},this.getContextAttributes=function(){return vt.getContextAttributes()},this.forceContextLoss=function(){const t=Y.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){const t=Y.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return I},this.setPixelRatio=function(t){void 0!==t&&(I=t,this.setSize(P,L,!1))},this.getSize=function(t){return t.set(P,L)},this.setSize=function(t,i,n=!0){Lt.isPresenting||(P=t,L=i,e.width=Math.floor(t*I),e.height=Math.floor(i*I),!0===n&&(e.style.width=t+"px",e.style.height=i+"px"),this.setViewport(0,0,t,i))},this.getDrawingBufferSize=function(t){return t.set(P*I,L*I).floor()},this.setDrawingBufferSize=function(t,i,n){P=t,L=i,I=n,e.width=Math.floor(t*n),e.height=Math.floor(i*n),this.setViewport(0,0,t,i)},this.getCurrentViewport=function(t){return t.copy(T)},this.getViewport=function(t){return t.copy(U)},this.setViewport=function(t,e,i,n){t.isVector4?U.set(t.x,t.y,t.z,t.w):U.set(t,e,i,n),J.viewport(T.copy(U).multiplyScalar(I).floor())},this.getScissor=function(t){return t.copy(F)},this.setScissor=function(t,e,i,n){t.isVector4?F.set(t.x,t.y,t.z,t.w):F.set(t,e,i,n),J.scissor(E.copy(F).multiplyScalar(I).floor())},this.getScissorTest=function(){return B},this.setScissorTest=function(t){J.setScissorTest(B=t)},this.setOpaqueSort=function(t){D=t},this.setTransparentSort=function(t){N=t},this.getClearColor=function(t){return t.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(t=!0,e=!0,i=!0){let n=0;if(t){let t=!1;if(null!==b){const e=b.texture.format;t=e===Ut||e===Nt||e===Dt}if(t){const t=b.texture.type,e=t===Mt||t===wt||t===bt||t===Rt||t===At||t===Ct,i=ut.getClearColor(),n=ut.getClearAlpha(),s=i.r,r=i.g,a=i.b;e?(d[0]=s,d[1]=r,d[2]=a,d[3]=n,vt.clearBufferuiv(vt.COLOR,0,d)):(p[0]=s,p[1]=r,p[2]=a,p[3]=n,vt.clearBufferiv(vt.COLOR,0,p))}else n|=vt.COLOR_BUFFER_BIT}e&&(n|=vt.DEPTH_BUFFER_BIT),i&&(n|=vt.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),vt.clear(n)},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",It,!1),e.removeEventListener("webglcontextrestored",Ot,!1),e.removeEventListener("webglcontextcreationerror",Ft,!1),ot.dispose(),lt.dispose(),$.dispose(),tt.dispose(),et.dispose(),st.dispose(),gt.dispose(),_t.dispose(),rt.dispose(),Lt.dispose(),Lt.removeEventListener("sessionstart",Vt),Lt.removeEventListener("sessionend",Gt),G&&(G.dispose(),G=null),Ht.stop()},this.renderBufferDirect=function(t,e,i,n,s,r){null===e&&(e=X);const a=s.isMesh&&s.matrixWorld.determinant()<0,o=function(t,e,i,n,s){!0!==e.isScene&&(e=X),Q.resetTextureUnits();const r=e.fog,a=n.isMeshStandardMaterial?e.environment:null,o=null===b?v.outputColorSpace:!0===b.isXRRenderTarget?b.texture.colorSpace:we,l=(n.isMeshStandardMaterial?et:tt).get(n.envMap||a),h=!0===n.vertexColors&&!!i.attributes.color&&4===i.attributes.color.itemSize,c=!!i.attributes.tangent&&(!!n.normalMap||n.anisotropy>0),u=!!i.morphAttributes.position,d=!!i.morphAttributes.normal,p=!!i.morphAttributes.color;let m=0;n.toneMapped&&(null!==b&&!0!==b.isXRRenderTarget||(m=v.toneMapping));const g=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,_=void 0!==g?g.length:0,y=$.get(n),x=f.state.lights;if(!0===k&&(!0===V||t!==w)){const e=t===w&&n.id===S;ht.setState(n,t,e)}let M=!1;n.version===y.__version?y.needsLights&&y.lightsStateVersion!==x.state.version||y.outputColorSpace!==o||s.isBatchedMesh&&!1===y.batching?M=!0:s.isBatchedMesh||!0!==y.batching?s.isInstancedMesh&&!1===y.instancing?M=!0:s.isInstancedMesh||!0!==y.instancing?s.isSkinnedMesh&&!1===y.skinning?M=!0:s.isSkinnedMesh||!0!==y.skinning?s.isInstancedMesh&&!0===y.instancingColor&&null===s.instanceColor||s.isInstancedMesh&&!1===y.instancingColor&&null!==s.instanceColor||y.envMap!==l||!0===n.fog&&y.fog!==r?M=!0:void 0===y.numClippingPlanes||y.numClippingPlanes===ht.numPlanes&&y.numIntersection===ht.numIntersection?(y.vertexAlphas!==h||y.vertexTangents!==c||y.morphTargets!==u||y.morphNormals!==d||y.morphColors!==p||y.toneMapping!==m||!0===Z.isWebGL2&&y.morphTargetsCount!==_)&&(M=!0):M=!0:M=!0:M=!0:M=!0:(M=!0,y.__version=n.version);let T=y.currentProgram;!0===M&&(T=Yt(n,e,s));let E=!1,A=!1,C=!1;const R=T.getUniforms(),P=y.uniforms;if(J.useProgram(T.program)&&(E=!0,A=!0,C=!0),n.id!==S&&(S=n.id,A=!0),E||w!==t){R.setValue(vt,"projectionMatrix",t.projectionMatrix),R.setValue(vt,"viewMatrix",t.matrixWorldInverse);const e=R.map.cameraPosition;void 0!==e&&e.setValue(vt,q.setFromMatrixPosition(t.matrixWorld)),Z.logarithmicDepthBuffer&&R.setValue(vt,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&R.setValue(vt,"isOrthographic",!0===t.isOrthographicCamera),w!==t&&(w=t,A=!0,C=!0)}if(s.isSkinnedMesh){R.setOptional(vt,s,"bindMatrix"),R.setOptional(vt,s,"bindMatrixInverse");const t=s.skeleton;t&&Z.floatVertexTextures&&(null===t.boneTexture&&t.computeBoneTexture(),R.setValue(vt,"boneTexture",t.boneTexture,Q))}s.isBatchedMesh&&(R.setOptional(vt,s,"batchingTexture"),R.setValue(vt,"batchingTexture",s._matricesTexture,Q));const D=i.morphAttributes;var N,U;if((void 0!==D.position||void 0!==D.normal||void 0!==D.color&&!0===Z.isWebGL2)&&dt.update(s,i,T),(A||y.receiveShadow!==s.receiveShadow)&&(y.receiveShadow=s.receiveShadow,R.setValue(vt,"receiveShadow",s.receiveShadow)),n.isMeshGouraudMaterial&&null!==n.envMap&&(P.envMap.value=l,P.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1),A&&(R.setValue(vt,"toneMappingExposure",v.toneMappingExposure),y.needsLights&&(U=C,(N=P).ambientLightColor.needsUpdate=U,N.lightProbe.needsUpdate=U,N.directionalLights.needsUpdate=U,N.directionalLightShadows.needsUpdate=U,N.pointLights.needsUpdate=U,N.pointLightShadows.needsUpdate=U,N.spotLights.needsUpdate=U,N.spotLightShadows.needsUpdate=U,N.rectAreaLights.needsUpdate=U,N.hemisphereLights.needsUpdate=U),r&&!0===n.fog&&at.refreshFogUniforms(P,r),at.refreshMaterialUniforms(P,n,I,L,G),Ja.upload(vt,Zt(y),P,Q)),n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(Ja.upload(vt,Zt(y),P,Q),n.uniformsNeedUpdate=!1),n.isSpriteMaterial&&R.setValue(vt,"center",s.center),R.setValue(vt,"modelViewMatrix",s.modelViewMatrix),R.setValue(vt,"normalMatrix",s.normalMatrix),R.setValue(vt,"modelMatrix",s.matrixWorld),n.isShaderMaterial||n.isRawShaderMaterial){const t=n.uniformsGroups;for(let e=0,i=t.length;e<i;e++)if(Z.isWebGL2){const i=t[e];_t.update(i,T),_t.bind(i,T)}}return T}(t,e,i,n,s);J.setMaterial(n,a);let l=i.index,h=1;if(!0===n.wireframe){if(l=nt.getWireframeAttribute(i),void 0===l)return;h=2}const c=i.drawRange,u=i.attributes.position;let d=c.start*h,p=(c.start+c.count)*h;null!==r&&(d=Math.max(d,r.start*h),p=Math.min(p,(r.start+r.count)*h)),null!==l?(d=Math.max(d,0),p=Math.min(p,l.count)):null!=u&&(d=Math.max(d,0),p=Math.min(p,u.count));const m=p-d;if(m<0||m===1/0)return;let g;gt.setup(s,n,o,i,l);let _=pt;if(null!==l&&(g=it.get(l),_=mt,_.setIndex(g)),s.isMesh)!0===n.wireframe?(J.setLineWidth(n.wireframeLinewidth*j()),_.setMode(vt.LINES)):_.setMode(vt.TRIANGLES);else if(s.isLine){let t=n.linewidth;void 0===t&&(t=1),J.setLineWidth(t*j()),s.isLineSegments?_.setMode(vt.LINES):s.isLineLoop?_.setMode(vt.LINE_LOOP):_.setMode(vt.LINE_STRIP)}else s.isPoints?_.setMode(vt.POINTS):s.isSprite&&_.setMode(vt.TRIANGLES);if(s.isBatchedMesh)_.renderMultiDraw(s._multiDrawStarts,s._multiDrawCounts,s._multiDrawCount);else if(s.isInstancedMesh)_.renderInstances(d,m,s.count);else if(i.isInstancedBufferGeometry){const t=void 0!==i._maxInstanceCount?i._maxInstanceCount:1/0,e=Math.min(i.instanceCount,t);_.renderInstances(d,m,e)}else _.render(d,m)},this.compile=function(t,e,i=null){null===i&&(i=t),f=lt.get(i),f.init(),_.push(f),i.traverseVisible(function(t){t.isLight&&t.layers.test(e.layers)&&(f.pushLight(t),t.castShadow&&f.pushShadow(t))}),t!==i&&t.traverseVisible(function(t){t.isLight&&t.layers.test(e.layers)&&(f.pushLight(t),t.castShadow&&f.pushShadow(t))}),f.setupLights(v._useLegacyLights);const n=new Set;return t.traverse(function(t){const e=t.material;if(e)if(Array.isArray(e))for(let s=0;s<e.length;s++){const r=e[s];zt(r,i,t),n.add(r)}else zt(e,i,t),n.add(e)}),_.pop(),f=null,n},this.compileAsync=function(t,e,i=null){const n=this.compile(t,e,i);return new Promise(e=>{function i(){n.forEach(function(t){$.get(t).currentProgram.isReady()&&n.delete(t)}),0!==n.size?setTimeout(i,10):e(t)}null!==Y.get("KHR_parallel_shader_compile")?i():setTimeout(i,10)})};let kt=null;function Vt(){Ht.stop()}function Gt(){Ht.start()}const Ht=new lr;function Wt(t,e,i,n){if(!1===t.visible)return;if(t.layers.test(e.layers))if(t.isGroup)i=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLight)f.pushLight(t),t.castShadow&&f.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||z.intersectsSprite(t)){n&&q.setFromMatrixPosition(t.matrixWorld).applyMatrix4(H);const e=st.update(t),s=t.material;s.visible&&m.push(t,e,s,i,q.z,null)}}else if((t.isMesh||t.isLine||t.isPoints)&&(!t.frustumCulled||z.intersectsObject(t))){const e=st.update(t),s=t.material;if(n&&(void 0!==t.boundingSphere?(null===t.boundingSphere&&t.computeBoundingSphere(),q.copy(t.boundingSphere.center)):(null===e.boundingSphere&&e.computeBoundingSphere(),q.copy(e.boundingSphere.center)),q.applyMatrix4(t.matrixWorld).applyMatrix4(H)),Array.isArray(s)){const n=e.groups;for(let r=0,a=n.length;r<a;r++){const a=n[r],o=s[a.materialIndex];o&&o.visible&&m.push(t,e,o,i,q.z,a)}}else s.visible&&m.push(t,e,s,i,q.z,null)}const s=t.children;for(let r=0,a=s.length;r<a;r++)Wt(s[r],e,i,n)}function qt(t,e,i,n){const s=t.opaque,r=t.transmissive,a=t.transparent;f.setupLightsView(i),!0===k&&ht.setGlobalState(v.clippingPlanes,i),r.length>0&&function(t,e,i,n){if(null!==(!0===i.isScene?i.overrideMaterial:null))return;const s=Z.isWebGL2;null===G&&(G=new Li(1,1,{generateMipmaps:!0,type:Y.has("EXT_color_buffer_half_float")?Et:Mt,minFilter:xt,samples:s?4:0})),v.getDrawingBufferSize(W),s?G.setSize(W.x,W.y):G.setSize(ei(W.x),ei(W.y));const r=v.getRenderTarget();v.setRenderTarget(G),v.getClearColor(C),R=v.getClearAlpha(),R<1&&v.setClearColor(16777215,.5),v.clear();const a=v.toneMapping;v.toneMapping=0,Xt(t,i,n),Q.updateMultisampleRenderTarget(G),Q.updateRenderTargetMipmap(G);let o=!1;for(let l=0,h=e.length;l<h;l++){const t=e[l],s=t.object,r=t.geometry,a=t.material,h=t.group;if(2===a.side&&s.layers.test(n.layers)){const t=a.side;a.side=1,a.needsUpdate=!0,jt(s,i,n,r,a,h),a.side=t,a.needsUpdate=!0,o=!0}}!0===o&&(Q.updateMultisampleRenderTarget(G),Q.updateRenderTargetMipmap(G)),v.setRenderTarget(r),v.setClearColor(C,R),v.toneMapping=a}(s,r,e,i),n&&J.viewport(T.copy(n)),s.length>0&&Xt(s,e,i),r.length>0&&Xt(r,e,i),a.length>0&&Xt(a,e,i),J.buffers.depth.setTest(!0),J.buffers.depth.setMask(!0),J.buffers.color.setMask(!0),J.setPolygonOffset(!1)}function Xt(t,e,i){const n=!0===e.isScene?e.overrideMaterial:null;for(let s=0,r=t.length;s<r;s++){const r=t[s],a=r.object,o=r.geometry,l=null===n?r.material:n,h=r.group;a.layers.test(i.layers)&&jt(a,e,i,o,l,h)}}function jt(t,e,i,n,s,r){t.onBeforeRender(v,e,i,n,s,r),t.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),s.onBeforeRender(v,e,i,n,t,r),!0===s.transparent&&2===s.side&&!1===s.forceSinglePass?(s.side=1,s.needsUpdate=!0,v.renderBufferDirect(i,e,n,s,t,r),s.side=0,s.needsUpdate=!0,v.renderBufferDirect(i,e,n,s,t,r),s.side=2):v.renderBufferDirect(i,e,n,s,t,r),t.onAfterRender(v,e,i,n,s,r)}function Yt(t,e,i){!0!==e.isScene&&(e=X);const n=$.get(t),s=f.state.lights,r=f.state.shadowsArray,a=s.state.version,o=rt.getParameters(t,s.state,r,e,i),l=rt.getProgramCacheKey(o);let h=n.programs;n.environment=t.isMeshStandardMaterial?e.environment:null,n.fog=e.fog,n.envMap=(t.isMeshStandardMaterial?et:tt).get(t.envMap||n.environment),void 0===h&&(t.addEventListener("dispose",Bt),h=new Map,n.programs=h);let c=h.get(l);if(void 0!==c){if(n.currentProgram===c&&n.lightsStateVersion===a)return Jt(t,o),c}else o.uniforms=rt.getUniforms(t),t.onBuild(i,o,v),t.onBeforeCompile(o,v),c=rt.acquireProgram(o,l),h.set(l,c),n.uniforms=o.uniforms;const u=n.uniforms;return(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(u.clippingPlanes=ht.uniform),Jt(t,o),n.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshToonMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),n.lightsStateVersion=a,n.needsLights&&(u.ambientLightColor.value=s.state.ambient,u.lightProbe.value=s.state.probe,u.directionalLights.value=s.state.directional,u.directionalLightShadows.value=s.state.directionalShadow,u.spotLights.value=s.state.spot,u.spotLightShadows.value=s.state.spotShadow,u.rectAreaLights.value=s.state.rectArea,u.ltc_1.value=s.state.rectAreaLTC1,u.ltc_2.value=s.state.rectAreaLTC2,u.pointLights.value=s.state.point,u.pointLightShadows.value=s.state.pointShadow,u.hemisphereLights.value=s.state.hemi,u.directionalShadowMap.value=s.state.directionalShadowMap,u.directionalShadowMatrix.value=s.state.directionalShadowMatrix,u.spotShadowMap.value=s.state.spotShadowMap,u.spotLightMatrix.value=s.state.spotLightMatrix,u.spotLightMap.value=s.state.spotLightMap,u.pointShadowMap.value=s.state.pointShadowMap,u.pointShadowMatrix.value=s.state.pointShadowMatrix),n.currentProgram=c,n.uniformsList=null,c}function Zt(t){if(null===t.uniformsList){const e=t.currentProgram.getUniforms();t.uniformsList=Ja.seqWithValue(e.seq,t.uniforms)}return t.uniformsList}function Jt(t,e){const i=$.get(t);i.outputColorSpace=e.outputColorSpace,i.batching=e.batching,i.instancing=e.instancing,i.instancingColor=e.instancingColor,i.skinning=e.skinning,i.morphTargets=e.morphTargets,i.morphNormals=e.morphNormals,i.morphColors=e.morphColors,i.morphTargetsCount=e.morphTargetsCount,i.numClippingPlanes=e.numClippingPlanes,i.numIntersection=e.numClipIntersection,i.vertexAlphas=e.vertexAlphas,i.vertexTangents=e.vertexTangents,i.toneMapping=e.toneMapping}Ht.setAnimationLoop(function(t){kt&&kt(t)}),"undefined"!=typeof self&&Ht.setContext(self),this.setAnimationLoop=function(t){kt=t,Lt.setAnimationLoop(t),null===t?Ht.stop():Ht.start()},Lt.addEventListener("sessionstart",Vt),Lt.addEventListener("sessionend",Gt),this.render=function(t,e){if(void 0!==e&&!0!==e.isCamera)return;if(!0===y)return;!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),null===e.parent&&!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),!0===Lt.enabled&&!0===Lt.isPresenting&&(!0===Lt.cameraAutoUpdate&&Lt.updateCamera(e),e=Lt.getCamera()),!0===t.isScene&&t.onBeforeRender(v,t,e,b),f=lt.get(t,_.length),f.init(),_.push(f),H.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),z.setFromProjectionMatrix(H),V=this.localClippingEnabled,k=ht.init(this.clippingPlanes,V),m=ot.get(t,g.length),m.init(),g.push(m),Wt(t,e,0,v.sortObjects),m.finish(),!0===v.sortObjects&&m.sort(D,N),this.info.render.frame++,!0===k&&ht.beginShadows();const i=f.state.shadowsArray;if(ct.render(i,t,e),!0===k&&ht.endShadows(),!0===this.info.autoReset&&this.info.reset(),ut.render(m,t),f.setupLights(v._useLegacyLights),e.isArrayCamera){const i=e.cameras;for(let e=0,n=i.length;e<n;e++){const n=i[e];qt(m,t,n,n.viewport)}}else qt(m,t,e);null!==b&&(Q.updateMultisampleRenderTarget(b),Q.updateRenderTargetMipmap(b)),!0===t.isScene&&t.onAfterRender(v,t,e),gt.resetDefaultState(),S=-1,w=null,_.pop(),f=_.length>0?_[_.length-1]:null,g.pop(),m=g.length>0?g[g.length-1]:null},this.getActiveCubeFace=function(){return x},this.getActiveMipmapLevel=function(){return M},this.getRenderTarget=function(){return b},this.setRenderTargetTextures=function(t,e,i){$.get(t.texture).__webglTexture=e,$.get(t.depthTexture).__webglTexture=i;const n=$.get(t);n.__hasExternalTextures=!0,n.__hasExternalTextures&&(n.__autoAllocateDepthBuffer=void 0===i,n.__autoAllocateDepthBuffer||!0===Y.has("WEBGL_multisampled_render_to_texture")&&(n.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(t,e){const i=$.get(t);i.__webglFramebuffer=e,i.__useDefaultFramebuffer=void 0===e},this.setRenderTarget=function(t,e=0,i=0){b=t,x=e,M=i;let n=!0,s=null,r=!1,a=!1;if(t){const o=$.get(t);void 0!==o.__useDefaultFramebuffer?(J.bindFramebuffer(vt.FRAMEBUFFER,null),n=!1):void 0===o.__webglFramebuffer?Q.setupRenderTarget(t):o.__hasExternalTextures&&Q.rebindTextures(t,$.get(t.texture).__webglTexture,$.get(t.depthTexture).__webglTexture);const l=t.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(a=!0);const h=$.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(s=Array.isArray(h[e])?h[e][i]:h[e],r=!0):s=Z.isWebGL2&&t.samples>0&&!1===Q.useMultisampledRTT(t)?$.get(t).__webglMultisampledFramebuffer:Array.isArray(h)?h[i]:h,T.copy(t.viewport),E.copy(t.scissor),A=t.scissorTest}else T.copy(U).multiplyScalar(I).floor(),E.copy(F).multiplyScalar(I).floor(),A=B;if(J.bindFramebuffer(vt.FRAMEBUFFER,s)&&Z.drawBuffers&&n&&J.drawBuffers(t,s),J.viewport(T),J.scissor(E),J.setScissorTest(A),r){const n=$.get(t.texture);vt.framebufferTexture2D(vt.FRAMEBUFFER,vt.COLOR_ATTACHMENT0,vt.TEXTURE_CUBE_MAP_POSITIVE_X+e,n.__webglTexture,i)}else if(a){const n=$.get(t.texture),s=e||0;vt.framebufferTextureLayer(vt.FRAMEBUFFER,vt.COLOR_ATTACHMENT0,n.__webglTexture,i||0,s)}S=-1},this.readRenderTargetPixels=function(t,e,i,n,s,r,a){if(!t||!t.isWebGLRenderTarget)return;let o=$.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){J.bindFramebuffer(vt.FRAMEBUFFER,o);try{const a=t.texture,o=a.format,l=a.type;if(o!==Pt&&ft.convert(o)!==vt.getParameter(vt.IMPLEMENTATION_COLOR_READ_FORMAT))return;const h=l===Et&&(Y.has("EXT_color_buffer_half_float")||Z.isWebGL2&&Y.has("EXT_color_buffer_float"));if(!(l===Mt||ft.convert(l)===vt.getParameter(vt.IMPLEMENTATION_COLOR_READ_TYPE)||l===Tt&&(Z.isWebGL2||Y.has("OES_texture_float")||Y.has("WEBGL_color_buffer_float"))||h))return;e>=0&&e<=t.width-n&&i>=0&&i<=t.height-s&&vt.readPixels(e,i,n,s,ft.convert(o),ft.convert(l),r)}finally{const t=null!==b?$.get(b).__webglFramebuffer:null;J.bindFramebuffer(vt.FRAMEBUFFER,t)}}},this.copyFramebufferToTexture=function(t,e,i=0){const n=Math.pow(2,-i),s=Math.floor(e.image.width*n),r=Math.floor(e.image.height*n);Q.setTexture2D(e,0),vt.copyTexSubImage2D(vt.TEXTURE_2D,i,0,0,t.x,t.y,s,r),J.unbindTexture()},this.copyTextureToTexture=function(t,e,i,n=0){const s=e.image.width,r=e.image.height,a=ft.convert(i.format),o=ft.convert(i.type);Q.setTexture2D(i,0),vt.pixelStorei(vt.UNPACK_FLIP_Y_WEBGL,i.flipY),vt.pixelStorei(vt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),vt.pixelStorei(vt.UNPACK_ALIGNMENT,i.unpackAlignment),e.isDataTexture?vt.texSubImage2D(vt.TEXTURE_2D,n,t.x,t.y,s,r,a,o,e.image.data):e.isCompressedTexture?vt.compressedTexSubImage2D(vt.TEXTURE_2D,n,t.x,t.y,e.mipmaps[0].width,e.mipmaps[0].height,a,e.mipmaps[0].data):vt.texSubImage2D(vt.TEXTURE_2D,n,t.x,t.y,a,o,e.image),0===n&&i.generateMipmaps&&vt.generateMipmap(vt.TEXTURE_2D),J.unbindTexture()},this.copyTextureToTexture3D=function(t,e,i,n,s=0){if(v.isWebGL1Renderer)return;const r=t.max.x-t.min.x+1,a=t.max.y-t.min.y+1,o=t.max.z-t.min.z+1,l=ft.convert(n.format),h=ft.convert(n.type);let c;if(n.isData3DTexture)Q.setTexture3D(n,0),c=vt.TEXTURE_3D;else{if(!n.isDataArrayTexture&&!n.isCompressedArrayTexture)return;Q.setTexture2DArray(n,0),c=vt.TEXTURE_2D_ARRAY}vt.pixelStorei(vt.UNPACK_FLIP_Y_WEBGL,n.flipY),vt.pixelStorei(vt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),vt.pixelStorei(vt.UNPACK_ALIGNMENT,n.unpackAlignment);const u=vt.getParameter(vt.UNPACK_ROW_LENGTH),d=vt.getParameter(vt.UNPACK_IMAGE_HEIGHT),p=vt.getParameter(vt.UNPACK_SKIP_PIXELS),m=vt.getParameter(vt.UNPACK_SKIP_ROWS),f=vt.getParameter(vt.UNPACK_SKIP_IMAGES),g=i.isCompressedTexture?i.mipmaps[s]:i.image;vt.pixelStorei(vt.UNPACK_ROW_LENGTH,g.width),vt.pixelStorei(vt.UNPACK_IMAGE_HEIGHT,g.height),vt.pixelStorei(vt.UNPACK_SKIP_PIXELS,t.min.x),vt.pixelStorei(vt.UNPACK_SKIP_ROWS,t.min.y),vt.pixelStorei(vt.UNPACK_SKIP_IMAGES,t.min.z),i.isDataTexture||i.isData3DTexture?vt.texSubImage3D(c,s,e.x,e.y,e.z,r,a,o,l,h,g.data):i.isCompressedArrayTexture?vt.compressedTexSubImage3D(c,s,e.x,e.y,e.z,r,a,o,l,g.data):vt.texSubImage3D(c,s,e.x,e.y,e.z,r,a,o,l,h,g),vt.pixelStorei(vt.UNPACK_ROW_LENGTH,u),vt.pixelStorei(vt.UNPACK_IMAGE_HEIGHT,d),vt.pixelStorei(vt.UNPACK_SKIP_PIXELS,p),vt.pixelStorei(vt.UNPACK_SKIP_ROWS,m),vt.pixelStorei(vt.UNPACK_SKIP_IMAGES,f),0===s&&n.generateMipmaps&&vt.generateMipmap(c),J.unbindTexture()},this.initTexture=function(t){t.isCubeTexture?Q.setTextureCube(t,0):t.isData3DTexture?Q.setTexture3D(t,0):t.isDataArrayTexture||t.isCompressedArrayTexture?Q.setTexture2DArray(t,0):Q.setTexture2D(t,0),J.unbindTexture()},this.resetState=function(){x=0,M=0,b=null,J.reset(),gt.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return He}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=t===Te?"display-p3":"srgb",e.unpackColorSpace=yi.workingColorSpace===Ee?"display-p3":"srgb"}get outputEncoding(){return this.outputColorSpace===Se?Me:xe}set outputEncoding(t){this.outputColorSpace=t===Me?Se:we}get useLegacyLights(){return this._useLegacyLights}set useLegacyLights(t){this._useLegacyLights=t}}class Wo extends Ho{}Wo.prototype.isWebGL1Renderer=!0;class qo{constructor(t,e=25e-5){this.isFogExp2=!0,this.name="",this.color=new ts(t),this.density=e}clone(){return new qo(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class Xo{constructor(t,e=1,i=1e3){this.isFog=!0,this.name="",this.color=new ts(t),this.near=e,this.far=i}clone(){return new Xo(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class jo extends Fn{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return null!==this.fog&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(e.object.backgroundIntensity=this.backgroundIntensity),e}}class Yo{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=ke,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Je()}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}get updateRange(){return this._updateRange}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.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,i){t*=this.stride,i*=e.stride;for(let n=0,s=this.stride;n<s;n++)this.array[t+n]=e.array[i+n];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=Je()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(e,this.stride);return i.setUsage(this.usage),i}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=Je()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Zo=new Ui;class Jo{constructor(t,e,i,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=i,this.normalized=n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,i=this.data.count;e<i;e++)Zo.fromBufferAttribute(this,e),Zo.applyMatrix4(t),this.setXYZ(e,Zo.x,Zo.y,Zo.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)Zo.fromBufferAttribute(this,e),Zo.applyNormalMatrix(t),this.setXYZ(e,Zo.x,Zo.y,Zo.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)Zo.fromBufferAttribute(this,e),Zo.transformDirection(t),this.setXYZ(e,Zo.x,Zo.y,Zo.z);return this}setX(t,e){return this.normalized&&(e=ni(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=ni(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=ni(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=ni(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=ii(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=ii(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=ii(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=ii(e,this.array)),e}setXY(t,e,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=ni(e,this.array),i=ni(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this}setXYZ(t,e,i,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=ni(e,this.array),i=ni(i,this.array),n=ni(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=n,this}setXYZW(t,e,i,n,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=ni(e,this.array),i=ni(i,this.array),n=ni(n,this.array),s=ni(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=n,this.data.array[t+3]=s,this}clone(t){if(void 0===t){const t=[];for(let e=0;e<this.count;e++){const i=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[i+e])}return new ds(new this.array.constructor(t),this.itemSize,this.normalized)}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Jo(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(void 0===t){const t=[];for(let e=0;e<this.count;e++){const i=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[i+e])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class Ko extends ns{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new ts(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}let $o;const Qo=new Ui,tl=new Ui,el=new Ui,il=new ri,nl=new ri,sl=new dn,rl=new Ui,al=new Ui,ol=new Ui,ll=new ri,hl=new ri,cl=new ri;class ul extends Fn{constructor(t=new Ko){if(super(),this.isSprite=!0,this.type="Sprite",void 0===$o){$o=new Ss;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),e=new Yo(t,5);$o.setIndex([0,1,2,0,2,3]),$o.setAttribute("position",new Jo(e,3,0,!1)),$o.setAttribute("uv",new Jo(e,2,3,!1))}this.geometry=$o,this.material=t,this.center=new ri(.5,.5)}raycast(t,e){t.camera,tl.setFromMatrixScale(this.matrixWorld),sl.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),el.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&tl.multiplyScalar(-el.z);const i=this.material.rotation;let n,s;0!==i&&(s=Math.cos(i),n=Math.sin(i));const r=this.center;dl(rl.set(-.5,-.5,0),el,r,tl,n,s),dl(al.set(.5,-.5,0),el,r,tl,n,s),dl(ol.set(.5,.5,0),el,r,tl,n,s),ll.set(0,0),hl.set(1,0),cl.set(1,1);let a=t.ray.intersectTriangle(rl,al,ol,!1,Qo);if(null===a&&(dl(al.set(-.5,.5,0),el,r,tl,n,s),hl.set(0,1),a=t.ray.intersectTriangle(rl,ol,al,!1,Qo),null===a))return;const o=t.ray.origin.distanceTo(Qo);o<t.near||o>t.far||e.push({distance:o,point:Qo.clone(),uv:Zn.getInterpolation(Qo,rl,al,ol,ll,hl,cl,new ri),face:null,object:this})}copy(t,e){return super.copy(t,e),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}}function dl(t,e,i,n,s,r){il.subVectors(t,i).addScalar(.5).multiply(n),void 0!==s?(nl.x=r*il.x-s*il.y,nl.y=s*il.x+r*il.y):nl.copy(il),t.copy(e),t.x+=nl.x,t.y+=nl.y,t.applyMatrix4(sl)}const pl=new Ui,ml=new Ui;class fl extends Fn{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const e=t.levels;for(let i=0,n=e.length;i<n;i++){const t=e[i];this.addLevel(t.object.clone(),t.distance,t.hysteresis)}return this.autoUpdate=t.autoUpdate,this}addLevel(t,e=0,i=0){e=Math.abs(e);const n=this.levels;let s;for(s=0;s<n.length&&!(e<n[s].distance);s++);return n.splice(s,0,{distance:e,hysteresis:i,object:t}),this.add(t),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(t){const e=this.levels;if(e.length>0){let i,n;for(i=1,n=e.length;i<n;i++){let n=e[i].distance;if(e[i].object.visible&&(n-=n*e[i].hysteresis),t<n)break}return e[i-1].object}return null}raycast(t,e){if(this.levels.length>0){pl.setFromMatrixPosition(this.matrixWorld);const i=t.ray.origin.distanceTo(pl);this.getObjectForDistance(i).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){pl.setFromMatrixPosition(t.matrixWorld),ml.setFromMatrixPosition(this.matrixWorld);const i=pl.distanceTo(ml)/t.zoom;let n,s;for(e[0].object.visible=!0,n=1,s=e.length;n<s;n++){let t=e[n].distance;if(e[n].object.visible&&(t-=t*e[n].hysteresis),!(i>=t))break;e[n-1].object.visible=!1,e[n].object.visible=!0}for(this._currentLevel=n-1;n<s;n++)e[n].object.visible=!1}}toJSON(t){const e=super.toJSON(t);!1===this.autoUpdate&&(e.object.autoUpdate=!1),e.object.levels=[];const i=this.levels;for(let n=0,s=i.length;n<s;n++){const t=i[n];e.object.levels.push({object:t.object.uuid,distance:t.distance,hysteresis:t.hysteresis})}return e}}const gl=new Ui,_l=new Ri,vl=new Ri,yl=new Ui,xl=new dn,Ml=new Ui,bl=new nn,Sl=new dn,wl=new un;class Tl extends Vs{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=st,this.bindMatrix=new dn,this.bindMatrixInverse=new dn,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;null===this.boundingBox&&(this.boundingBox=new Bi),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let i=0;i<e.count;i++)this.getVertexPosition(i,Ml),this.boundingBox.expandByPoint(Ml)}computeBoundingSphere(){const t=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new nn),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let i=0;i<e.count;i++)this.getVertexPosition(i,Ml),this.boundingSphere.expandByPoint(Ml)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){const i=this.material,n=this.matrixWorld;void 0!==i&&(null===this.boundingSphere&&this.computeBoundingSphere(),bl.copy(this.boundingSphere),bl.applyMatrix4(n),!1!==t.ray.intersectsSphere(bl)&&(Sl.copy(n).invert(),wl.copy(t.ray).applyMatrix4(Sl),null!==this.boundingBox&&!1===wl.intersectsBox(this.boundingBox)||this._computeIntersections(t,e,wl)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,void 0===e&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const t=new Ri,e=this.geometry.attributes.skinWeight;for(let i=0,n=e.count;i<n;i++){t.fromBufferAttribute(e,i);const n=1/t.manhattanLength();n!==1/0?t.multiplyScalar(n):t.set(1,0,0,0),e.setXYZW(i,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===st?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===rt&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}applyBoneTransform(t,e){const i=this.skeleton,n=this.geometry;_l.fromBufferAttribute(n.attributes.skinIndex,t),vl.fromBufferAttribute(n.attributes.skinWeight,t),gl.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let s=0;s<4;s++){const t=vl.getComponent(s);if(0!==t){const n=_l.getComponent(s);xl.multiplyMatrices(i.bones[n].matrixWorld,i.boneInverses[n]),e.addScaledVector(yl.copy(gl).applyMatrix4(xl),t)}}return e.applyMatrix4(this.bindMatrixInverse)}boneTransform(t,e){return this.applyBoneTransform(t,e)}}class El extends Fn{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Al extends Ci{constructor(t=null,e=1,i=1,n,s,r,a,o,l=1003,h=1003,c,u){super(null,r,a,o,l,h,n,s,c,u),this.isDataTexture=!0,this.image={data:t,width:e,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Cl=new dn,Rl=new dn;class Pl{constructor(t=[],e=[]){this.uuid=Je(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(16*t.length),0===e.length)this.calculateInverses();else if(t.length!==e.length){this.boneInverses=[];for(let t=0,e=this.bones.length;t<e;t++)this.boneInverses.push(new dn)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const e=new dn;this.bones[t]&&e.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(e)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&e.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&(e.parent&&e.parent.isBone?(e.matrix.copy(e.parent.matrixWorld).invert(),e.matrix.multiply(e.matrixWorld)):e.matrix.copy(e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale))}}update(){const t=this.bones,e=this.boneInverses,i=this.boneMatrices,n=this.boneTexture;for(let s=0,r=t.length;s<r;s++){const n=t[s]?t[s].matrixWorld:Rl;Cl.multiplyMatrices(n,e[s]),Cl.toArray(i,16*s)}null!==n&&(n.needsUpdate=!0)}clone(){return new Pl(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(4*this.bones.length);t=4*Math.ceil(t/4),t=Math.max(t,4);const e=new Float32Array(t*t*4);e.set(this.boneMatrices);const i=new Al(e,t,t,Pt,Tt);return i.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=i,this}getBoneByName(t){for(let e=0,i=this.bones.length;e<i;e++){const i=this.bones[e];if(i.name===t)return i}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let i=0,n=t.bones.length;i<n;i++){let n=e[t.bones[i]];void 0===n&&(n=new El),this.bones.push(n),this.boneInverses.push((new dn).fromArray(t.boneInverses[i]))}return this.init(),this}toJSON(){const t={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,i=this.boneInverses;for(let n=0,s=e.length;n<s;n++){const s=e[n];t.bones.push(s.uuid);const r=i[n];t.boneInverses.push(r.toArray())}return t}}class Ll extends ds{constructor(t,e,i,n=1){super(t,e,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}const Il=new dn,Dl=new dn,Nl=[],Ul=new Bi,Ol=new dn,Fl=new Vs,Bl=new nn;class zl extends Vs{constructor(t,e,i){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new Ll(new Float32Array(16*i),16),this.instanceColor=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let n=0;n<i;n++)this.setMatrixAt(n,Ol)}computeBoundingBox(){const t=this.geometry,e=this.count;null===this.boundingBox&&(this.boundingBox=new Bi),null===t.boundingBox&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<e;i++)this.getMatrixAt(i,Il),Ul.copy(t.boundingBox).applyMatrix4(Il),this.boundingBox.union(Ul)}computeBoundingSphere(){const t=this.geometry,e=this.count;null===this.boundingSphere&&(this.boundingSphere=new nn),null===t.boundingSphere&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<e;i++)this.getMatrixAt(i,Il),Bl.copy(t.boundingSphere).applyMatrix4(Il),this.boundingSphere.union(Bl)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),null!==t.instanceColor&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){e.fromArray(this.instanceColor.array,3*t)}getMatrixAt(t,e){e.fromArray(this.instanceMatrix.array,16*t)}raycast(t,e){const i=this.matrixWorld,n=this.count;if(Fl.geometry=this.geometry,Fl.material=this.material,void 0!==Fl.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),Bl.copy(this.boundingSphere),Bl.applyMatrix4(i),!1!==t.ray.intersectsSphere(Bl)))for(let s=0;s<n;s++){this.getMatrixAt(s,Il),Dl.multiplyMatrices(i,Il),Fl.matrixWorld=Dl,Fl.raycast(t,Nl);for(let t=0,i=Nl.length;t<i;t++){const i=Nl[t];i.instanceId=s,i.object=this,e.push(i)}Nl.length=0}}setColorAt(t,e){null===this.instanceColor&&(this.instanceColor=new Ll(new Float32Array(3*this.instanceMatrix.count),3)),e.toArray(this.instanceColor.array,3*t)}setMatrixAt(t,e){e.toArray(this.instanceMatrix.array,16*t)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}function kl(t,e){return t.z-e.z}function Vl(t,e){return e.z-t.z}class Gl{constructor(){this.index=0,this.pool=[],this.list=[]}push(t,e){const i=this.pool,n=this.list;this.index>=i.length&&i.push({start:-1,count:-1,z:-1});const s=i[this.index];n.push(s),this.index++,s.start=t.start,s.count=t.count,s.z=e}reset(){this.list.length=0,this.index=0}}const Hl="batchId",Wl=new dn,ql=new dn,Xl=new dn,jl=new dn,Yl=new or,Zl=new Bi,Jl=new nn,Kl=new Ui,$l=new Gl,Ql=new Vs,th=[];function eh(t,e,i=0){const n=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const s=t.count;for(let r=0;r<s;r++)for(let s=0;s<n;s++)e.setComponent(r+i,s,t.getComponent(r,s))}else e.array.set(t.array,i*n);e.needsUpdate=!0}class ih extends Vs{get maxGeometryCount(){return this._maxGeometryCount}constructor(t,e,i=2*e,n){super(new Ss,n),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawRanges=[],this._reservedRanges=[],this._visibility=[],this._active=[],this._bounds=[],this._maxGeometryCount=t,this._maxVertexCount=e,this._maxIndexCount=i,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(t),this._multiDrawStarts=new Int32Array(t),this._multiDrawCount=0,this._visibilityChanged=!0,this._matricesTexture=null,this._initMatricesTexture()}_initMatricesTexture(){let t=Math.sqrt(4*this._maxGeometryCount);t=4*Math.ceil(t/4),t=Math.max(t,4);const e=new Float32Array(t*t*4),i=new Al(e,t,t,Pt,Tt);this._matricesTexture=i}_initializeGeometry(t){const e=this.geometry,i=this._maxVertexCount,n=this._maxGeometryCount,s=this._maxIndexCount;if(!1===this._geometryInitialized){for(const n in t.attributes){const s=t.getAttribute(n),{array:r,itemSize:a,normalized:o}=s,l=new r.constructor(i*a),h=new s.constructor(l,a,o);h.setUsage(s.usage),e.setAttribute(n,h)}if(null!==t.getIndex()){const t=i>65536?new Uint32Array(s):new Uint16Array(s);e.setIndex(new ds(t,1))}const r=n>65536?new Uint32Array(i):new Uint16Array(i);e.setAttribute(Hl,new ds(r,1)),this._geometryInitialized=!0}}_validateGeometry(t){if(t.getAttribute(Hl))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Hl}"`);const e=this.geometry;if(Boolean(t.getIndex())!==Boolean(e.getIndex()))throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const i in e.attributes){if(i===Hl)continue;if(!t.hasAttribute(i))throw new Error(`BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const n=t.getAttribute(i),s=e.getAttribute(i);if(n.itemSize!==s.itemSize||n.normalized!==s.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Bi);const t=this._geometryCount,e=this.boundingBox,i=this._active;e.makeEmpty();for(let n=0;n<t;n++)!1!==i[n]&&(this.getMatrixAt(n,Wl),this.getBoundingBoxAt(n,Zl).applyMatrix4(Wl),e.union(Zl))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new nn);const t=this._geometryCount,e=this.boundingSphere,i=this._active;e.makeEmpty();for(let n=0;n<t;n++)!1!==i[n]&&(this.getMatrixAt(n,Wl),this.getBoundingSphereAt(n,Jl).applyMatrix4(Wl),e.union(Jl))}addGeometry(t,e=-1,i=-1){if(this._initializeGeometry(t),this._validateGeometry(t),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");const n={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let s=null;const r=this._reservedRanges,a=this._drawRanges,o=this._bounds;0!==this._geometryCount&&(s=r[r.length-1]),n.vertexCount=-1===e?t.getAttribute("position").count:e,n.vertexStart=null===s?0:s.vertexStart+s.vertexCount;const l=t.getIndex(),h=null!==l;if(h&&(n.indexCount=-1===i?l.count:i,n.indexStart=null===s?0:s.indexStart+s.indexCount),-1!==n.indexStart&&n.indexStart+n.indexCount>this._maxIndexCount||n.vertexStart+n.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const c=this._visibility,u=this._active,d=this._matricesTexture,p=this._matricesTexture.image.data;c.push(!0),u.push(!0);const m=this._geometryCount;this._geometryCount++,Xl.toArray(p,16*m),d.needsUpdate=!0,r.push(n),a.push({start:h?n.indexStart:n.vertexStart,count:-1}),o.push({boxInitialized:!1,box:new Bi,sphereInitialized:!1,sphere:new nn});const f=this.geometry.getAttribute(Hl);for(let g=0;g<n.vertexCount;g++)f.setX(n.vertexStart+g,m);return f.needsUpdate=!0,this.setGeometryAt(m,t),m}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);const i=this.geometry,n=null!==i.getIndex(),s=i.getIndex(),r=e.getIndex(),a=this._reservedRanges[t];if(n&&r.count>a.indexCount||e.attributes.position.count>a.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const o=a.vertexStart,l=a.vertexCount;for(const d in i.attributes){if(d===Hl)continue;const t=e.getAttribute(d),n=i.getAttribute(d);eh(t,n,o);const s=t.itemSize;for(let e=t.count,i=l;e<i;e++){const t=o+e;for(let e=0;e<s;e++)n.setComponent(t,e,0)}n.needsUpdate=!0}if(n){const t=a.indexStart;for(let e=0;e<r.count;e++)s.setX(t+e,o+r.getX(e));for(let e=r.count,i=a.indexCount;e<i;e++)s.setX(t+e,o);s.needsUpdate=!0}const h=this._bounds[t];null!==e.boundingBox?(h.box.copy(e.boundingBox),h.boxInitialized=!0):h.boxInitialized=!1,null!==e.boundingSphere?(h.sphere.copy(e.boundingSphere),h.sphereInitialized=!0):h.sphereInitialized=!1;const c=this._drawRanges[t],u=e.getAttribute("position");return c.count=n?r.count:u.count,this._visibilityChanged=!0,t}deleteGeometry(t){const e=this._active;return t>=e.length||!1===e[t]||(e[t]=!1,this._visibilityChanged=!0),this}getBoundingBoxAt(t,e){if(!1===this._active[t])return this;const i=this._bounds[t],n=i.box,s=this.geometry;if(!1===i.boxInitialized){n.makeEmpty();const e=s.index,r=s.attributes.position,a=this._drawRanges[t];for(let t=a.start,i=a.start+a.count;t<i;t++){let i=t;e&&(i=e.getX(i)),n.expandByPoint(Kl.fromBufferAttribute(r,i))}i.boxInitialized=!0}return e.copy(n),e}getBoundingSphereAt(t,e){if(!1===this._active[t])return this;const i=this._bounds[t],n=i.sphere,s=this.geometry;if(!1===i.sphereInitialized){n.makeEmpty(),this.getBoundingBoxAt(t,Zl),Zl.getCenter(n.center);const e=s.index,r=s.attributes.position,a=this._drawRanges[t];let o=0;for(let t=a.start,i=a.start+a.count;t<i;t++){let i=t;e&&(i=e.getX(i)),Kl.fromBufferAttribute(r,i),o=Math.max(o,n.center.distanceToSquared(Kl))}n.radius=Math.sqrt(o),i.sphereInitialized=!0}return e.copy(n),e}setMatrixAt(t,e){const i=this._active,n=this._matricesTexture,s=this._matricesTexture.image.data;return t>=this._geometryCount||!1===i[t]||(e.toArray(s,16*t),n.needsUpdate=!0),this}getMatrixAt(t,e){const i=this._active,n=this._matricesTexture.image.data;return t>=this._geometryCount||!1===i[t]?null:e.fromArray(n,16*t)}setVisibleAt(t,e){const i=this._visibility,n=this._active;return t>=this._geometryCount||!1===n[t]||i[t]===e||(i[t]=e,this._visibilityChanged=!0),this}getVisibleAt(t){const e=this._visibility,i=this._active;return!(t>=this._geometryCount||!1===i[t])&&e[t]}raycast(t,e){const i=this._visibility,n=this._active,s=this._drawRanges,r=this._geometryCount,a=this.matrixWorld,o=this.geometry;Ql.material=this.material,Ql.geometry.index=o.index,Ql.geometry.attributes=o.attributes,null===Ql.geometry.boundingBox&&(Ql.geometry.boundingBox=new Bi),null===Ql.geometry.boundingSphere&&(Ql.geometry.boundingSphere=new nn);for(let l=0;l<r;l++){if(!i[l]||!n[l])continue;const r=s[l];Ql.geometry.setDrawRange(r.start,r.count),this.getMatrixAt(l,Ql.matrixWorld).premultiply(a),this.getBoundingBoxAt(l,Ql.geometry.boundingBox),this.getBoundingSphereAt(l,Ql.geometry.boundingSphere),Ql.raycast(t,th);for(let t=0,i=th.length;t<i;t++){const i=th[t];i.object=this,i.batchId=l,e.push(i)}th.length=0}Ql.material=null,Ql.geometry.index=null,Ql.geometry.attributes={},Ql.geometry.setDrawRange(0,1/0)}copy(t){return super.copy(t),this.geometry=t.geometry.clone(),this.perObjectFrustumCulled=t.perObjectFrustumCulled,this.sortObjects=t.sortObjects,this.boundingBox=null!==t.boundingBox?t.boundingBox.clone():null,this.boundingSphere=null!==t.boundingSphere?t.boundingSphere.clone():null,this._drawRanges=t._drawRanges.map(t=>({...t})),this._reservedRanges=t._reservedRanges.map(t=>({...t})),this._visibility=t._visibility.slice(),this._active=t._active.slice(),this._bounds=t._bounds.map(t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.sphere.clone()})),this._maxGeometryCount=t._maxGeometryCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._geometryCount=t._geometryCount,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(t,e,i,n,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const r=n.getIndex(),a=null===r?1:r.array.BYTES_PER_ELEMENT,o=this._visibility,l=this._multiDrawStarts,h=this._multiDrawCounts,c=this._drawRanges,u=this.perObjectFrustumCulled;u&&(jl.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),Yl.setFromProjectionMatrix(jl,t.isWebGPURenderer?We:He));let d=0;if(this.sortObjects){ql.copy(this.matrixWorld).invert(),Kl.setFromMatrixPosition(i.matrixWorld).applyMatrix4(ql);for(let i=0,n=o.length;i<n;i++)if(o[i]){this.getMatrixAt(i,Wl),this.getBoundingSphereAt(i,Jl).applyMatrix4(Wl);let t=!1;if(u&&(t=!Yl.intersectsSphere(Jl)),!t){const t=Kl.distanceTo(Jl.center);$l.push(c[i],t)}}const t=$l.list,e=this.customSort;null===e?t.sort(s.transparent?Vl:kl):e.call(this,t,i);for(let i=0,n=t.length;i<n;i++){const e=t[i];l[d]=e.start*a,h[d]=e.count,d++}$l.reset()}else for(let p=0,m=o.length;p<m;p++)if(o[p]){let t=!1;if(u&&(this.getMatrixAt(p,Wl),this.getBoundingSphereAt(p,Jl).applyMatrix4(Wl),t=!Yl.intersectsSphere(Jl)),!t){const t=c[p];l[d]=t.start*a,h[d]=t.count,d++}}this._multiDrawCount=d,this._visibilityChanged=!1}onBeforeShadow(t,e,i,n,s,r){this.onBeforeRender(t,null,n,s,r)}}class nh extends ns{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ts(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const sh=new Ui,rh=new Ui,ah=new dn,oh=new un,lh=new nn;class hh extends Fn{constructor(t=new Ss,e=new nh){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,i=[0];for(let t=1,n=e.count;t<n;t++)sh.fromBufferAttribute(e,t-1),rh.fromBufferAttribute(e,t),i[t]=i[t-1],i[t]+=sh.distanceTo(rh);t.setAttribute("lineDistance",new fs(i,1))}return this}raycast(t,e){const i=this.geometry,n=this.matrixWorld,s=t.params.Line.threshold,r=i.drawRange;if(null===i.boundingSphere&&i.computeBoundingSphere(),lh.copy(i.boundingSphere),lh.applyMatrix4(n),lh.radius+=s,!1===t.ray.intersectsSphere(lh))return;ah.copy(n).invert(),oh.copy(t.ray).applyMatrix4(ah);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=new Ui,h=new Ui,c=new Ui,u=new Ui,d=this.isLineSegments?2:1,p=i.index,m=i.attributes.position;if(null!==p)for(let f=Math.max(0,r.start),g=Math.min(p.count,r.start+r.count)-1;f<g;f+=d){const i=p.getX(f),n=p.getX(f+1);if(l.fromBufferAttribute(m,i),h.fromBufferAttribute(m,n),oh.distanceSqToSegment(l,h,u,c)>o)continue;u.applyMatrix4(this.matrixWorld);const s=t.ray.origin.distanceTo(u);s<t.near||s>t.far||e.push({distance:s,point:c.clone().applyMatrix4(this.matrixWorld),index:f,face:null,faceIndex:null,object:this})}else for(let f=Math.max(0,r.start),g=Math.min(m.count,r.start+r.count)-1;f<g;f+=d){if(l.fromBufferAttribute(m,f),h.fromBufferAttribute(m,f+1),oh.distanceSqToSegment(l,h,u,c)>o)continue;u.applyMatrix4(this.matrixWorld);const i=t.ray.origin.distanceTo(u);i<t.near||i>t.far||e.push({distance:i,point:c.clone().applyMatrix4(this.matrixWorld),index:f,face:null,faceIndex:null,object:this})}}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;t<e;t++){const e=i[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}}const ch=new Ui,uh=new Ui;class dh extends hh{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,i=[];for(let t=0,n=e.count;t<n;t+=2)ch.fromBufferAttribute(e,t),uh.fromBufferAttribute(e,t+1),i[t]=0===t?0:i[t-1],i[t+1]=i[t]+ch.distanceTo(uh);t.setAttribute("lineDistance",new fs(i,1))}return this}}class ph extends hh{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}}class mh extends ns{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new ts(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}const fh=new dn,gh=new un,_h=new nn,vh=new Ui;class yh extends Fn{constructor(t=new Ss,e=new mh){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){const i=this.geometry,n=this.matrixWorld,s=t.params.Points.threshold,r=i.drawRange;if(null===i.boundingSphere&&i.computeBoundingSphere(),_h.copy(i.boundingSphere),_h.applyMatrix4(n),_h.radius+=s,!1===t.ray.intersectsSphere(_h))return;fh.copy(n).invert(),gh.copy(t.ray).applyMatrix4(fh);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=i.index,h=i.attributes.position;if(null!==l)for(let c=Math.max(0,r.start),u=Math.min(l.count,r.start+r.count);c<u;c++){const i=l.getX(c);vh.fromBufferAttribute(h,i),xh(vh,i,o,n,t,e,this)}else for(let c=Math.max(0,r.start),u=Math.min(h.count,r.start+r.count);c<u;c++)vh.fromBufferAttribute(h,c),xh(vh,c,o,n,t,e,this)}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;t<e;t++){const e=i[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}}function xh(t,e,i,n,s,r,a){const o=gh.distanceSqToPoint(t);if(o<i){const i=new Ui;gh.closestPointToPoint(t,i),i.applyMatrix4(n);const l=s.ray.origin.distanceTo(i);if(l<s.near||l>s.far)return;r.push({distance:l,distanceToRay:Math.sqrt(o),point:i,index:e,face:null,object:a})}}class Mh extends Ci{constructor(t,e,i,n,s,r,a,o,l,h,c,u){super(null,r,a,o,l,h,n,s,c,u),this.isCompressedTexture=!0,this.image={width:e,height:i},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}class bh{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return null}getPointAt(t,e){const i=this.getUtoTmapping(t);return this.getPoint(i,e)}getPoints(t=5){const e=[];for(let i=0;i<=t;i++)e.push(this.getPoint(i/t));return e}getSpacedPoints(t=5){const e=[];for(let i=0;i<=t;i++)e.push(this.getPointAt(i/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 i,n=this.getPoint(0),s=0;e.push(0);for(let r=1;r<=t;r++)i=this.getPoint(r/t),s+=i.distanceTo(n),e.push(s),n=i;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){const i=this.getLengths();let n=0;const s=i.length;let r;r=e||t*i[s-1];let a,o=0,l=s-1;for(;o<=l;)if(n=Math.floor(o+(l-o)/2),a=i[n]-r,a<0)o=n+1;else{if(!(a>0)){l=n;break}l=n-1}if(n=l,i[n]===r)return n/(s-1);const h=i[n];return(n+(r-h)/(i[n+1]-h))/(s-1)}getTangent(t,e){const i=1e-4;let n=t-i,s=t+i;n<0&&(n=0),s>1&&(s=1);const r=this.getPoint(n),a=this.getPoint(s),o=e||(r.isVector2?new ri:new Ui);return o.copy(a).sub(r).normalize(),o}getTangentAt(t,e){const i=this.getUtoTmapping(t);return this.getTangent(i,e)}computeFrenetFrames(t,e){const i=new Ui,n=[],s=[],r=[],a=new Ui,o=new dn;for(let d=0;d<=t;d++){const e=d/t;n[d]=this.getTangentAt(e,new Ui)}s[0]=new Ui,r[0]=new Ui;let l=Number.MAX_VALUE;const h=Math.abs(n[0].x),c=Math.abs(n[0].y),u=Math.abs(n[0].z);h<=l&&(l=h,i.set(1,0,0)),c<=l&&(l=c,i.set(0,1,0)),u<=l&&i.set(0,0,1),a.crossVectors(n[0],i).normalize(),s[0].crossVectors(n[0],a),r[0].crossVectors(n[0],s[0]);for(let d=1;d<=t;d++){if(s[d]=s[d-1].clone(),r[d]=r[d-1].clone(),a.crossVectors(n[d-1],n[d]),a.length()>Number.EPSILON){a.normalize();const t=Math.acos(Ke(n[d-1].dot(n[d]),-1,1));s[d].applyMatrix4(o.makeRotationAxis(a,t))}r[d].crossVectors(n[d],s[d])}if(!0===e){let e=Math.acos(Ke(s[0].dot(s[t]),-1,1));e/=t,n[0].dot(a.crossVectors(s[0],s[t]))>0&&(e=-e);for(let i=1;i<=t;i++)s[i].applyMatrix4(o.makeRotationAxis(n[i],e*i)),r[i].crossVectors(n[i],s[i])}return{tangents:n,normals:s,binormals:r}}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 Sh extends bh{constructor(t=0,e=0,i=1,n=1,s=0,r=2*Math.PI,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=i,this.yRadius=n,this.aStartAngle=s,this.aEndAngle=r,this.aClockwise=a,this.aRotation=o}getPoint(t,e){const i=e||new ri,n=2*Math.PI;let s=this.aEndAngle-this.aStartAngle;const r=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=n;for(;s>n;)s-=n;s<Number.EPSILON&&(s=r?0:n),!0!==this.aClockwise||r||(s===n?s=-n:s-=n);const a=this.aStartAngle+t*s;let o=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(0!==this.aRotation){const t=Math.cos(this.aRotation),e=Math.sin(this.aRotation),i=o-this.aX,n=l-this.aY;o=i*t-n*e+this.aX,l=i*e+n*t+this.aY}return i.set(o,l)}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 wh extends Sh{constructor(t,e,i,n,s,r){super(t,e,i,i,n,s,r),this.isArcCurve=!0,this.type="ArcCurve"}}function Th(){let t=0,e=0,i=0,n=0;function s(s,r,a,o){t=s,e=a,i=-3*s+3*r-2*a-o,n=2*s-2*r+a+o}return{initCatmullRom(t,e,i,n,r){s(e,i,r*(i-t),r*(n-e))},initNonuniformCatmullRom(t,e,i,n,r,a,o){let l=(e-t)/r-(i-t)/(r+a)+(i-e)/a,h=(i-e)/a-(n-e)/(a+o)+(n-i)/o;l*=a,h*=a,s(e,i,l,h)},calc(s){const r=s*s;return t+e*s+i*r+n*r*s}}}const Eh=new Ui,Ah=new Th,Ch=new Th,Rh=new Th;class Ph extends bh{constructor(t=[],e=!1,i="centripetal",n=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=i,this.tension=n}getPoint(t,e=new Ui){const i=e,n=this.points,s=n.length,r=(s-(this.closed?0:1))*t;let a,o,l=Math.floor(r),h=r-l;this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/s)+1)*s:0===h&&l===s-1&&(l=s-2,h=1),this.closed||l>0?a=n[(l-1)%s]:(Eh.subVectors(n[0],n[1]).add(n[0]),a=Eh);const c=n[l%s],u=n[(l+1)%s];if(this.closed||l+2<s?o=n[(l+2)%s]:(Eh.subVectors(n[s-1],n[s-2]).add(n[s-1]),o=Eh),"centripetal"===this.curveType||"chordal"===this.curveType){const t="chordal"===this.curveType?.5:.25;let e=Math.pow(a.distanceToSquared(c),t),i=Math.pow(c.distanceToSquared(u),t),n=Math.pow(u.distanceToSquared(o),t);i<1e-4&&(i=1),e<1e-4&&(e=i),n<1e-4&&(n=i),Ah.initNonuniformCatmullRom(a.x,c.x,u.x,o.x,e,i,n),Ch.initNonuniformCatmullRom(a.y,c.y,u.y,o.y,e,i,n),Rh.initNonuniformCatmullRom(a.z,c.z,u.z,o.z,e,i,n)}else"catmullrom"===this.curveType&&(Ah.initCatmullRom(a.x,c.x,u.x,o.x,this.tension),Ch.initCatmullRom(a.y,c.y,u.y,o.y,this.tension),Rh.initCatmullRom(a.z,c.z,u.z,o.z,this.tension));return i.set(Ah.calc(h),Ch.calc(h),Rh.calc(h)),i}copy(t){super.copy(t),this.points=[];for(let e=0,i=t.points.length;e<i;e++){const i=t.points[e];this.points.push(i.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,i=this.points.length;e<i;e++){const i=this.points[e];t.points.push(i.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,i=t.points.length;e<i;e++){const i=t.points[e];this.points.push((new Ui).fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function Lh(t,e,i,n,s){const r=.5*(n-e),a=.5*(s-i),o=t*t;return(2*i-2*n+r+a)*t*o+(-3*i+3*n-2*r-a)*o+r*t+i}function Ih(t,e,i,n){return function(t,e){const i=1-t;return i*i*e}(t,e)+function(t,e){return 2*(1-t)*t*e}(t,i)+function(t,e){return t*t*e}(t,n)}function Dh(t,e,i,n,s){return function(t,e){const i=1-t;return i*i*i*e}(t,e)+function(t,e){const i=1-t;return 3*i*i*t*e}(t,i)+function(t,e){return 3*(1-t)*t*t*e}(t,n)+function(t,e){return t*t*t*e}(t,s)}class Nh extends bh{constructor(t=new ri,e=new ri,i=new ri,n=new ri){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=i,this.v3=n}getPoint(t,e=new ri){const i=e,n=this.v0,s=this.v1,r=this.v2,a=this.v3;return i.set(Dh(t,n.x,s.x,r.x,a.x),Dh(t,n.y,s.y,r.y,a.y)),i}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 Uh extends bh{constructor(t=new Ui,e=new Ui,i=new Ui,n=new Ui){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=i,this.v3=n}getPoint(t,e=new Ui){const i=e,n=this.v0,s=this.v1,r=this.v2,a=this.v3;return i.set(Dh(t,n.x,s.x,r.x,a.x),Dh(t,n.y,s.y,r.y,a.y),Dh(t,n.z,s.z,r.z,a.z)),i}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 Oh extends bh{constructor(t=new ri,e=new ri){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new ri){const i=e;return 1===t?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(t).add(this.v1)),i}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new ri){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 Fh extends bh{constructor(t=new Ui,e=new Ui){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new Ui){const i=e;return 1===t?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(t).add(this.v1)),i}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new Ui){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 Bh extends bh{constructor(t=new ri,e=new ri,i=new ri){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=i}getPoint(t,e=new ri){const i=e,n=this.v0,s=this.v1,r=this.v2;return i.set(Ih(t,n.x,s.x,r.x),Ih(t,n.y,s.y,r.y)),i}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 zh extends bh{constructor(t=new Ui,e=new Ui,i=new Ui){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=i}getPoint(t,e=new Ui){const i=e,n=this.v0,s=this.v1,r=this.v2;return i.set(Ih(t,n.x,s.x,r.x),Ih(t,n.y,s.y,r.y),Ih(t,n.z,s.z,r.z)),i}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 kh extends bh{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new ri){const i=e,n=this.points,s=(n.length-1)*t,r=Math.floor(s),a=s-r,o=n[0===r?r:r-1],l=n[r],h=n[r>n.length-2?n.length-1:r+1],c=n[r>n.length-3?n.length-1:r+2];return i.set(Lh(a,o.x,l.x,h.x,c.x),Lh(a,o.y,l.y,h.y,c.y)),i}copy(t){super.copy(t),this.points=[];for(let e=0,i=t.points.length;e<i;e++){const i=t.points[e];this.points.push(i.clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,i=this.points.length;e<i;e++){const i=this.points[e];t.points.push(i.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,i=t.points.length;e<i;e++){const i=t.points[e];this.points.push((new ri).fromArray(i))}return this}}var Vh=Object.freeze({__proto__:null,ArcCurve:wh,CatmullRomCurve3:Ph,CubicBezierCurve:Nh,CubicBezierCurve3:Uh,EllipseCurve:Sh,LineCurve:Oh,LineCurve3:Fh,QuadraticBezierCurve:Bh,QuadraticBezierCurve3:zh,SplineCurve:kh});class Gh extends bh{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 i=!0===t.isVector2?"LineCurve":"LineCurve3";this.curves.push(new Vh[i](e,t))}return this}getPoint(t,e){const i=t*this.getLength(),n=this.getCurveLengths();let s=0;for(;s<n.length;){if(n[s]>=i){const t=n[s]-i,r=this.curves[s],a=r.getLength(),o=0===a?0:1-t/a;return r.getPointAt(o,e)}s++}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 i=0,n=this.curves.length;i<n;i++)e+=this.curves[i].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let i=0;i<=t;i++)e.push(this.getPoint(i/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[];let i;for(let n=0,s=this.curves;n<s.length;n++){const r=s[n],a=r.isEllipseCurve?2*t:r.isLineCurve||r.isLineCurve3?1:r.isSplineCurve?t*r.points.length:t,o=r.getPoints(a);for(let t=0;t<o.length;t++){const n=o[t];i&&i.equals(n)||(e.push(n),i=n)}}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,i=t.curves.length;e<i;e++){const i=t.curves[e];this.curves.push(i.clone())}return this.autoClose=t.autoClose,this}toJSON(){const t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,i=this.curves.length;e<i;e++){const i=this.curves[e];t.curves.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,i=t.curves.length;e<i;e++){const i=t.curves[e];this.curves.push((new Vh[i.type]).fromJSON(i))}return this}}class Hh extends Gh{constructor(t){super(),this.type="Path",this.currentPoint=new ri,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,i=t.length;e<i;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 i=new Oh(this.currentPoint.clone(),new ri(t,e));return this.curves.push(i),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,i,n){const s=new Bh(this.currentPoint.clone(),new ri(t,e),new ri(i,n));return this.curves.push(s),this.currentPoint.set(i,n),this}bezierCurveTo(t,e,i,n,s,r){const a=new Nh(this.currentPoint.clone(),new ri(t,e),new ri(i,n),new ri(s,r));return this.curves.push(a),this.currentPoint.set(s,r),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),i=new kh(e);return this.curves.push(i),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,i,n,s,r){const a=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(t+a,e+o,i,n,s,r),this}absarc(t,e,i,n,s,r){return this.absellipse(t,e,i,i,n,s,r),this}ellipse(t,e,i,n,s,r,a,o){const l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(t+l,e+h,i,n,s,r,a,o),this}absellipse(t,e,i,n,s,r,a,o){const l=new Sh(t,e,i,n,s,r,a,o);if(this.curves.length>0){const t=l.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(l);const h=l.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 Wh extends Ss{constructor(t=[new ri(0,-.5),new ri(.5,0),new ri(0,.5)],e=12,i=0,n=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:i,phiLength:n},e=Math.floor(e),n=Ke(n,0,2*Math.PI);const s=[],r=[],a=[],o=[],l=[],h=1/e,c=new Ui,u=new ri,d=new Ui,p=new Ui,m=new Ui;let f=0,g=0;for(let _=0;_<=t.length-1;_++)switch(_){case 0:f=t[_+1].x-t[_].x,g=t[_+1].y-t[_].y,d.x=1*g,d.y=-f,d.z=0*g,m.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case t.length-1:o.push(m.x,m.y,m.z);break;default:f=t[_+1].x-t[_].x,g=t[_+1].y-t[_].y,d.x=1*g,d.y=-f,d.z=0*g,p.copy(d),d.x+=m.x,d.y+=m.y,d.z+=m.z,d.normalize(),o.push(d.x,d.y,d.z),m.copy(p)}for(let _=0;_<=e;_++){const s=i+_*h*n,d=Math.sin(s),p=Math.cos(s);for(let i=0;i<=t.length-1;i++){c.x=t[i].x*d,c.y=t[i].y,c.z=t[i].x*p,r.push(c.x,c.y,c.z),u.x=_/e,u.y=i/(t.length-1),a.push(u.x,u.y);const n=o[3*i+0]*d,s=o[3*i+1],h=o[3*i+0]*p;l.push(n,s,h)}}for(let _=0;_<e;_++)for(let e=0;e<t.length-1;e++){const i=e+_*t.length,n=i,r=i+t.length,a=i+t.length+1,o=i+1;s.push(n,r,o),s.push(a,o,r)}this.setIndex(s),this.setAttribute("position",new fs(r,3)),this.setAttribute("uv",new fs(a,2)),this.setAttribute("normal",new fs(l,3))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Wh(t.points,t.segments,t.phiStart,t.phiLength)}}class qh extends Wh{constructor(t=1,e=1,i=4,n=8){const s=new Hh;s.absarc(0,-e/2,t,1.5*Math.PI,0),s.absarc(0,e/2,t,0,.5*Math.PI),super(s.getPoints(i),n),this.type="CapsuleGeometry",this.parameters={radius:t,length:e,capSegments:i,radialSegments:n}}static fromJSON(t){return new qh(t.radius,t.length,t.capSegments,t.radialSegments)}}class Xh extends Ss{constructor(t=1,e=32,i=0,n=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:i,thetaLength:n},e=Math.max(3,e);const s=[],r=[],a=[],o=[],l=new Ui,h=new ri;r.push(0,0,0),a.push(0,0,1),o.push(.5,.5);for(let c=0,u=3;c<=e;c++,u+=3){const s=i+c/e*n;l.x=t*Math.cos(s),l.y=t*Math.sin(s),r.push(l.x,l.y,l.z),a.push(0,0,1),h.x=(r[u]/t+1)/2,h.y=(r[u+1]/t+1)/2,o.push(h.x,h.y)}for(let c=1;c<=e;c++)s.push(c,c+1,0);this.setIndex(s),this.setAttribute("position",new fs(r,3)),this.setAttribute("normal",new fs(a,3)),this.setAttribute("uv",new fs(o,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Xh(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class jh extends Ss{constructor(t=1,e=1,i=1,n=32,s=1,r=!1,a=0,o=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:i,radialSegments:n,heightSegments:s,openEnded:r,thetaStart:a,thetaLength:o};const l=this;n=Math.floor(n),s=Math.floor(s);const h=[],c=[],u=[],d=[];let p=0;const m=[],f=i/2;let g=0;function _(i){const s=p,r=new ri,m=new Ui;let _=0;const v=!0===i?t:e,y=!0===i?1:-1;for(let t=1;t<=n;t++)c.push(0,f*y,0),u.push(0,y,0),d.push(.5,.5),p++;const x=p;for(let t=0;t<=n;t++){const e=t/n*o+a,i=Math.cos(e),s=Math.sin(e);m.x=v*s,m.y=f*y,m.z=v*i,c.push(m.x,m.y,m.z),u.push(0,y,0),r.x=.5*i+.5,r.y=.5*s*y+.5,d.push(r.x,r.y),p++}for(let t=0;t<n;t++){const e=s+t,n=x+t;!0===i?h.push(n,n+1,e):h.push(n+1,n,e),_+=3}l.addGroup(g,_,!0===i?1:2),g+=_}!function(){const r=new Ui,_=new Ui;let v=0;const y=(e-t)/i;for(let l=0;l<=s;l++){const h=[],g=l/s,v=g*(e-t)+t;for(let t=0;t<=n;t++){const e=t/n,s=e*o+a,l=Math.sin(s),m=Math.cos(s);_.x=v*l,_.y=-g*i+f,_.z=v*m,c.push(_.x,_.y,_.z),r.set(l,y,m).normalize(),u.push(r.x,r.y,r.z),d.push(e,1-g),h.push(p++)}m.push(h)}for(let t=0;t<n;t++)for(let e=0;e<s;e++){const i=m[e][t],n=m[e+1][t],s=m[e+1][t+1],r=m[e][t+1];h.push(i,n,r),h.push(n,s,r),v+=6}l.addGroup(g,v,0),g+=v}(),!1===r&&(t>0&&_(!0),e>0&&_(!1)),this.setIndex(h),this.setAttribute("position",new fs(c,3)),this.setAttribute("normal",new fs(u,3)),this.setAttribute("uv",new fs(d,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new jh(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Yh extends jh{constructor(t=1,e=1,i=32,n=1,s=!1,r=0,a=2*Math.PI){super(0,t,e,i,n,s,r,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:i,heightSegments:n,openEnded:s,thetaStart:r,thetaLength:a}}static fromJSON(t){return new Yh(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Zh extends Ss{constructor(t=[],e=[],i=1,n=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:i,detail:n};const s=[],r=[];function a(t,e,i,n){const s=n+1,r=[];for(let a=0;a<=s;a++){r[a]=[];const n=t.clone().lerp(i,a/s),o=e.clone().lerp(i,a/s),l=s-a;for(let t=0;t<=l;t++)r[a][t]=0===t&&a===s?n:n.clone().lerp(o,t/l)}for(let a=0;a<s;a++)for(let t=0;t<2*(s-a)-1;t++){const e=Math.floor(t/2);t%2==0?(o(r[a][e+1]),o(r[a+1][e]),o(r[a][e])):(o(r[a][e+1]),o(r[a+1][e+1]),o(r[a+1][e]))}}function o(t){s.push(t.x,t.y,t.z)}function l(e,i){const n=3*e;i.x=t[n+0],i.y=t[n+1],i.z=t[n+2]}function h(t,e,i,n){n<0&&1===t.x&&(r[e]=t.x-1),0===i.x&&0===i.z&&(r[e]=n/2/Math.PI+.5)}function c(t){return Math.atan2(t.z,-t.x)}function u(t){return Math.atan2(-t.y,Math.sqrt(t.x*t.x+t.z*t.z))}!function(t){const i=new Ui,n=new Ui,s=new Ui;for(let r=0;r<e.length;r+=3)l(e[r+0],i),l(e[r+1],n),l(e[r+2],s),a(i,n,s,t)}(n),function(t){const e=new Ui;for(let i=0;i<s.length;i+=3)e.x=s[i+0],e.y=s[i+1],e.z=s[i+2],e.normalize().multiplyScalar(t),s[i+0]=e.x,s[i+1]=e.y,s[i+2]=e.z}(i),function(){const t=new Ui;for(let e=0;e<s.length;e+=3){t.x=s[e+0],t.y=s[e+1],t.z=s[e+2];const i=c(t)/2/Math.PI+.5,n=u(t)/Math.PI+.5;r.push(i,1-n)}(function(){const t=new Ui,e=new Ui,i=new Ui,n=new Ui,a=new ri,o=new ri,l=new ri;for(let u=0,d=0;u<s.length;u+=9,d+=6){t.set(s[u+0],s[u+1],s[u+2]),e.set(s[u+3],s[u+4],s[u+5]),i.set(s[u+6],s[u+7],s[u+8]),a.set(r[d+0],r[d+1]),o.set(r[d+2],r[d+3]),l.set(r[d+4],r[d+5]),n.copy(t).add(e).add(i).divideScalar(3);const p=c(n);h(a,d+0,t,p),h(o,d+2,e,p),h(l,d+4,i,p)}})(),function(){for(let t=0;t<r.length;t+=6){const e=r[t+0],i=r[t+2],n=r[t+4],s=Math.max(e,i,n),a=Math.min(e,i,n);s>.9&&a<.1&&(e<.2&&(r[t+0]+=1),i<.2&&(r[t+2]+=1),n<.2&&(r[t+4]+=1))}}()}(),this.setAttribute("position",new fs(s,3)),this.setAttribute("normal",new fs(s.slice(),3)),this.setAttribute("uv",new fs(r,2)),0===n?this.computeVertexNormals():this.normalizeNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Zh(t.vertices,t.indices,t.radius,t.details)}}class Jh extends Zh{constructor(t=1,e=0){const i=(1+Math.sqrt(5))/2,n=1/i;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-n,-i,0,-n,i,0,n,-i,0,n,i,-n,-i,0,-n,i,0,n,-i,0,n,i,0,-i,0,-n,i,0,-n,-i,0,n,i,0,n],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Jh(t.radius,t.detail)}}const Kh=new Ui,$h=new Ui,Qh=new Ui,tc=new Zn;class ec extends Ss{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},null!==t){const i=4,n=Math.pow(10,i),s=Math.cos(Ye*e),r=t.getIndex(),a=t.getAttribute("position"),o=r?r.count:a.count,l=[0,0,0],h=["a","b","c"],c=new Array(3),u={},d=[];for(let t=0;t<o;t+=3){r?(l[0]=r.getX(t),l[1]=r.getX(t+1),l[2]=r.getX(t+2)):(l[0]=t,l[1]=t+1,l[2]=t+2);const{a:e,b:i,c:o}=tc;if(e.fromBufferAttribute(a,l[0]),i.fromBufferAttribute(a,l[1]),o.fromBufferAttribute(a,l[2]),tc.getNormal(Qh),c[0]=`${Math.round(e.x*n)},${Math.round(e.y*n)},${Math.round(e.z*n)}`,c[1]=`${Math.round(i.x*n)},${Math.round(i.y*n)},${Math.round(i.z*n)}`,c[2]=`${Math.round(o.x*n)},${Math.round(o.y*n)},${Math.round(o.z*n)}`,c[0]!==c[1]&&c[1]!==c[2]&&c[2]!==c[0])for(let t=0;t<3;t++){const e=(t+1)%3,i=c[t],n=c[e],r=tc[h[t]],a=tc[h[e]],o=`${i}_${n}`,p=`${n}_${i}`;p in u&&u[p]?(Qh.dot(u[p].normal)<=s&&(d.push(r.x,r.y,r.z),d.push(a.x,a.y,a.z)),u[p]=null):o in u||(u[o]={index0:l[t],index1:l[e],normal:Qh.clone()})}}for(const t in u)if(u[t]){const{index0:e,index1:i}=u[t];Kh.fromBufferAttribute(a,e),$h.fromBufferAttribute(a,i),d.push(Kh.x,Kh.y,Kh.z),d.push($h.x,$h.y,$h.z)}this.setAttribute("position",new fs(d,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}class ic extends Hh{constructor(t){super(t),this.uuid=Je(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let i=0,n=this.holes.length;i<n;i++)e[i]=this.holes[i].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,i=t.holes.length;e<i;e++){const i=t.holes[e];this.holes.push(i.clone())}return this}toJSON(){const t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,i=this.holes.length;e<i;e++){const i=this.holes[e];t.holes.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,i=t.holes.length;e<i;e++){const i=t.holes[e];this.holes.push((new Hh).fromJSON(i))}return this}}function nc(t,e,i,n,s){let r,a;if(s===function(t,e,i,n){let s=0;for(let r=e,a=i-n;r<i;r+=n)s+=(t[a]-t[r])*(t[r+1]+t[a+1]),a=r;return s}(t,e,i,n)>0)for(r=e;r<i;r+=n)a=wc(r,t[r],t[r+1],a);else for(r=i-n;r>=e;r-=n)a=wc(r,t[r],t[r+1],a);return a&&vc(a,a.next)&&(Tc(a),a=a.next),a}function sc(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!vc(n,n.next)&&0!==_c(n.prev,n,n.next))n=n.next;else{if(Tc(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function rc(t,e,i,n,s,r,a){if(!t)return;!a&&r&&function(t,e,i,n){let s=t;do{0===s.z&&(s.z=pc(s.x,s.y,e,i,n)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,function(t){let e,i,n,s,r,a,o,l,h=1;do{for(i=t,t=null,r=null,a=0;i;){for(a++,n=i,o=0,e=0;e<h&&(o++,n=n.nextZ,n);e++);for(l=h;o>0||l>0&&n;)0!==o&&(0===l||!n||i.z<=n.z)?(s=i,i=i.nextZ,o--):(s=n,n=n.nextZ,l--),r?r.nextZ=s:t=s,s.prevZ=r,r=s;i=n}r.nextZ=null,h*=2}while(a>1)}(s)}(t,n,s,r);let o,l,h=t;for(;t.prev!==t.next;)if(o=t.prev,l=t.next,r?oc(t,n,s,r):ac(t))e.push(o.i/i|0),e.push(t.i/i|0),e.push(l.i/i|0),Tc(t),t=l.next,h=l.next;else if((t=l)===h){a?1===a?rc(t=lc(sc(t),e,i),e,i,n,s,r,2):2===a&&hc(t,e,i,n,s,r):rc(sc(t),e,i,n,s,r,1);break}}function ac(t){const e=t.prev,i=t,n=t.next;if(_c(e,i,n)>=0)return!1;const s=e.x,r=i.x,a=n.x,o=e.y,l=i.y,h=n.y,c=s<r?s<a?s:a:r<a?r:a,u=o<l?o<h?o:h:l<h?l:h,d=s>r?s>a?s:a:r>a?r:a,p=o>l?o>h?o:h:l>h?l:h;let m=n.next;for(;m!==e;){if(m.x>=c&&m.x<=d&&m.y>=u&&m.y<=p&&fc(s,o,r,l,a,h,m.x,m.y)&&_c(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function oc(t,e,i,n){const s=t.prev,r=t,a=t.next;if(_c(s,r,a)>=0)return!1;const o=s.x,l=r.x,h=a.x,c=s.y,u=r.y,d=a.y,p=o<l?o<h?o:h:l<h?l:h,m=c<u?c<d?c:d:u<d?u:d,f=o>l?o>h?o:h:l>h?l:h,g=c>u?c>d?c:d:u>d?u:d,_=pc(p,m,e,i,n),v=pc(f,g,e,i,n);let y=t.prevZ,x=t.nextZ;for(;y&&y.z>=_&&x&&x.z<=v;){if(y.x>=p&&y.x<=f&&y.y>=m&&y.y<=g&&y!==s&&y!==a&&fc(o,c,l,u,h,d,y.x,y.y)&&_c(y.prev,y,y.next)>=0)return!1;if(y=y.prevZ,x.x>=p&&x.x<=f&&x.y>=m&&x.y<=g&&x!==s&&x!==a&&fc(o,c,l,u,h,d,x.x,x.y)&&_c(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=f&&y.y>=m&&y.y<=g&&y!==s&&y!==a&&fc(o,c,l,u,h,d,y.x,y.y)&&_c(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;x&&x.z<=v;){if(x.x>=p&&x.x<=f&&x.y>=m&&x.y<=g&&x!==s&&x!==a&&fc(o,c,l,u,h,d,x.x,x.y)&&_c(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function lc(t,e,i){let n=t;do{const s=n.prev,r=n.next.next;!vc(s,r)&&yc(s,n,n.next,r)&&bc(s,r)&&bc(r,s)&&(e.push(s.i/i|0),e.push(n.i/i|0),e.push(r.i/i|0),Tc(n),Tc(n.next),n=t=r),n=n.next}while(n!==t);return sc(n)}function hc(t,e,i,n,s,r){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&gc(a,t)){let o=Sc(a,t);return a=sc(a,a.next),o=sc(o,o.next),rc(a,e,i,n,s,r,0),void rc(o,e,i,n,s,r,0)}t=t.next}a=a.next}while(a!==t)}function cc(t,e){return t.x-e.x}function uc(t,e){const i=function(t,e){let i,n=e,s=-1/0;const r=t.x,a=t.y;do{if(a<=n.y&&a>=n.next.y&&n.next.y!==n.y){const t=n.x+(a-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(t<=r&&t>s&&(s=t,i=n.x<n.next.x?n:n.next,t===r))return i}n=n.next}while(n!==e);if(!i)return null;const o=i,l=i.x,h=i.y;let c,u=1/0;n=i;do{r>=n.x&&n.x>=l&&r!==n.x&&fc(a<h?r:s,a,l,h,a<h?s:r,a,n.x,n.y)&&(c=Math.abs(a-n.y)/(r-n.x),bc(n,t)&&(c<u||c===u&&(n.x>i.x||n.x===i.x&&dc(i,n)))&&(i=n,u=c)),n=n.next}while(n!==o);return i}(t,e);if(!i)return e;const n=Sc(i,t);return sc(n,n.next),sc(i,i.next)}function dc(t,e){return _c(t.prev,t,e.prev)<0&&_c(e.next,t,t.next)<0}function pc(t,e,i,n,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*s|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*s|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function mc(t){let e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function fc(t,e,i,n,s,r,a,o){return(s-a)*(e-o)>=(t-a)*(r-o)&&(t-a)*(n-o)>=(i-a)*(e-o)&&(i-a)*(r-o)>=(s-a)*(n-o)}function gc(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&yc(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(bc(t,e)&&bc(e,t)&&function(t,e){let i=t,n=!1;const s=(t.x+e.x)/2,r=(t.y+e.y)/2;do{i.y>r!=i.next.y>r&&i.next.y!==i.y&&s<(i.next.x-i.x)*(r-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)&&(_c(t.prev,t,e.prev)||_c(t,e.prev,e))||vc(t,e)&&_c(t.prev,t,t.next)>0&&_c(e.prev,e,e.next)>0)}function _c(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function vc(t,e){return t.x===e.x&&t.y===e.y}function yc(t,e,i,n){const s=Mc(_c(t,e,i)),r=Mc(_c(t,e,n)),a=Mc(_c(i,n,t)),o=Mc(_c(i,n,e));return s!==r&&a!==o||!(0!==s||!xc(t,i,e))||!(0!==r||!xc(t,n,e))||!(0!==a||!xc(i,t,n))||!(0!==o||!xc(i,e,n))}function xc(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function Mc(t){return t>0?1:t<0?-1:0}function bc(t,e){return _c(t.prev,t,t.next)<0?_c(t,e,t.next)>=0&&_c(t,t.prev,e)>=0:_c(t,e,t.prev)<0||_c(t,t.next,e)<0}function Sc(t,e){const i=new Ec(t.i,t.x,t.y),n=new Ec(e.i,e.x,e.y),s=t.next,r=e.prev;return t.next=e,e.prev=t,i.next=s,s.prev=i,n.next=i,i.prev=n,r.next=n,n.prev=r,n}function wc(t,e,i,n){const s=new Ec(t,e,i);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function Tc(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Ec(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}class Ac{static area(t){const e=t.length;let i=0;for(let n=e-1,s=0;s<e;n=s++)i+=t[n].x*t[s].y-t[s].x*t[n].y;return.5*i}static isClockWise(t){return Ac.area(t)<0}static triangulateShape(t,e){const i=[],n=[],s=[];Cc(t),Rc(i,t);let r=t.length;e.forEach(Cc);for(let o=0;o<e.length;o++)n.push(r),r+=e[o].length,Rc(i,e[o]);const a=function(t,e,i=2){const n=e&&e.length,s=n?e[0]*i:t.length;let r=nc(t,0,s,i,!0);const a=[];if(!r||r.next===r.prev)return a;let o,l,h,c,u,d,p;if(n&&(r=function(t,e,i,n){const s=[];let r,a,o,l,h;for(r=0,a=e.length;r<a;r++)o=e[r]*n,l=r<a-1?e[r+1]*n:t.length,h=nc(t,o,l,n,!1),h===h.next&&(h.steiner=!0),s.push(mc(h));for(s.sort(cc),r=0;r<s.length;r++)i=uc(s[r],i);return i}(t,e,r,i)),t.length>80*i){o=h=t[0],l=c=t[1];for(let e=i;e<s;e+=i)u=t[e],d=t[e+1],u<o&&(o=u),d<l&&(l=d),u>h&&(h=u),d>c&&(c=d);p=Math.max(h-o,c-l),p=0!==p?32767/p:0}return rc(r,a,i,o,l,p,0),a}(i,n);for(let o=0;o<a.length;o+=3)s.push(a.slice(o,o+3));return s}}function Cc(t){const e=t.length;e>2&&t[e-1].equals(t[0])&&t.pop()}function Rc(t,e){for(let i=0;i<e.length;i++)t.push(e[i].x),t.push(e[i].y)}class Pc extends Ss{constructor(t=new ic([new ri(.5,.5),new ri(-.5,.5),new ri(-.5,-.5),new ri(.5,-.5)]),e={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];const i=this,n=[],s=[];for(let a=0,o=t.length;a<o;a++)r(t[a]);function r(t){const r=[],a=void 0!==e.curveSegments?e.curveSegments:12,o=void 0!==e.steps?e.steps:1,l=void 0!==e.depth?e.depth:1;let h=void 0===e.bevelEnabled||e.bevelEnabled,c=void 0!==e.bevelThickness?e.bevelThickness:.2,u=void 0!==e.bevelSize?e.bevelSize:c-.1,d=void 0!==e.bevelOffset?e.bevelOffset:0,p=void 0!==e.bevelSegments?e.bevelSegments:3;const m=e.extrudePath,f=void 0!==e.UVGenerator?e.UVGenerator:Lc;let g,_,v,y,x,M=!1;m&&(g=m.getSpacedPoints(o),M=!0,h=!1,_=m.computeFrenetFrames(o,!1),v=new Ui,y=new Ui,x=new Ui),h||(p=0,c=0,u=0,d=0);const b=t.extractPoints(a);let S=b.shape;const w=b.holes;if(!Ac.isClockWise(S)){S=S.reverse();for(let t=0,e=w.length;t<e;t++){const e=w[t];Ac.isClockWise(e)&&(w[t]=e.reverse())}}const T=Ac.triangulateShape(S,w),E=S;for(let e=0,i=w.length;e<i;e++){const t=w[e];S=S.concat(t)}function A(t,e,i){return t.clone().addScaledVector(e,i)}const C=S.length,R=T.length;function P(t,e,i){let n,s,r;const a=t.x-e.x,o=t.y-e.y,l=i.x-t.x,h=i.y-t.y,c=a*a+o*o,u=a*h-o*l;if(Math.abs(u)>Number.EPSILON){const u=Math.sqrt(c),d=Math.sqrt(l*l+h*h),p=e.x-o/u,m=e.y+a/u,f=((i.x-h/d-p)*h-(i.y+l/d-m)*l)/(a*h-o*l);n=p+a*f-t.x,s=m+o*f-t.y;const g=n*n+s*s;if(g<=2)return new ri(n,s);r=Math.sqrt(g/2)}else{let t=!1;a>Number.EPSILON?l>Number.EPSILON&&(t=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(t=!0):Math.sign(o)===Math.sign(h)&&(t=!0),t?(n=-o,s=a,r=Math.sqrt(c)):(n=a,s=o,r=Math.sqrt(c/2))}return new ri(n/r,s/r)}const L=[];for(let e=0,i=E.length,n=i-1,s=e+1;e<i;e++,n++,s++)n===i&&(n=0),s===i&&(s=0),L[e]=P(E[e],E[n],E[s]);const I=[];let D,N=L.concat();for(let e=0,i=w.length;e<i;e++){const t=w[e];D=[];for(let e=0,i=t.length,n=i-1,s=e+1;e<i;e++,n++,s++)n===i&&(n=0),s===i&&(s=0),D[e]=P(t[e],t[n],t[s]);I.push(D),N=N.concat(D)}for(let e=0;e<p;e++){const t=e/p,i=c*Math.cos(t*Math.PI/2),n=u*Math.sin(t*Math.PI/2)+d;for(let e=0,s=E.length;e<s;e++){const t=A(E[e],L[e],n);F(t.x,t.y,-i)}for(let e=0,s=w.length;e<s;e++){const t=w[e];D=I[e];for(let e=0,s=t.length;e<s;e++){const s=A(t[e],D[e],n);F(s.x,s.y,-i)}}}const U=u+d;for(let e=0;e<C;e++){const t=h?A(S[e],N[e],U):S[e];M?(y.copy(_.normals[0]).multiplyScalar(t.x),v.copy(_.binormals[0]).multiplyScalar(t.y),x.copy(g[0]).add(y).add(v),F(x.x,x.y,x.z)):F(t.x,t.y,0)}for(let e=1;e<=o;e++)for(let t=0;t<C;t++){const i=h?A(S[t],N[t],U):S[t];M?(y.copy(_.normals[e]).multiplyScalar(i.x),v.copy(_.binormals[e]).multiplyScalar(i.y),x.copy(g[e]).add(y).add(v),F(x.x,x.y,x.z)):F(i.x,i.y,l/o*e)}for(let e=p-1;e>=0;e--){const t=e/p,i=c*Math.cos(t*Math.PI/2),n=u*Math.sin(t*Math.PI/2)+d;for(let e=0,s=E.length;e<s;e++){const t=A(E[e],L[e],n);F(t.x,t.y,l+i)}for(let e=0,s=w.length;e<s;e++){const t=w[e];D=I[e];for(let e=0,s=t.length;e<s;e++){const s=A(t[e],D[e],n);M?F(s.x,s.y+g[o-1].y,g[o-1].x+i):F(s.x,s.y,l+i)}}}function O(t,e){let i=t.length;for(;--i>=0;){const n=i;let s=i-1;s<0&&(s=t.length-1);for(let t=0,i=o+2*p;t<i;t++){const i=C*t,r=C*(t+1);z(e+n+i,e+s+i,e+s+r,e+n+r)}}}function F(t,e,i){r.push(t),r.push(e),r.push(i)}function B(t,e,s){k(t),k(e),k(s);const r=n.length/3,a=f.generateTopUV(i,n,r-3,r-2,r-1);V(a[0]),V(a[1]),V(a[2])}function z(t,e,s,r){k(t),k(e),k(r),k(e),k(s),k(r);const a=n.length/3,o=f.generateSideWallUV(i,n,a-6,a-3,a-2,a-1);V(o[0]),V(o[1]),V(o[3]),V(o[1]),V(o[2]),V(o[3])}function k(t){n.push(r[3*t+0]),n.push(r[3*t+1]),n.push(r[3*t+2])}function V(t){s.push(t.x),s.push(t.y)}!function(){const t=n.length/3;if(h){let t=0,e=C*t;for(let i=0;i<R;i++){const t=T[i];B(t[2]+e,t[1]+e,t[0]+e)}t=o+2*p,e=C*t;for(let i=0;i<R;i++){const t=T[i];B(t[0]+e,t[1]+e,t[2]+e)}}else{for(let t=0;t<R;t++){const e=T[t];B(e[2],e[1],e[0])}for(let t=0;t<R;t++){const e=T[t];B(e[0]+C*o,e[1]+C*o,e[2]+C*o)}}i.addGroup(t,n.length/3-t,0)}(),function(){const t=n.length/3;let e=0;O(E,e),e+=E.length;for(let i=0,n=w.length;i<n;i++){const t=w[i];O(t,e),e+=t.length}i.addGroup(t,n.length/3-t,1)}()}this.setAttribute("position",new fs(n,3)),this.setAttribute("uv",new fs(s,2)),this.computeVertexNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return function(t,e,i){if(i.shapes=[],Array.isArray(t))for(let n=0,s=t.length;n<s;n++){const e=t[n];i.shapes.push(e.uuid)}else i.shapes.push(t.uuid);return i.options=Object.assign({},e),void 0!==e.extrudePath&&(i.options.extrudePath=e.extrudePath.toJSON()),i}(this.parameters.shapes,this.parameters.options,t)}static fromJSON(t,e){const i=[];for(let s=0,r=t.shapes.length;s<r;s++){const n=e[t.shapes[s]];i.push(n)}const n=t.options.extrudePath;return void 0!==n&&(t.options.extrudePath=(new Vh[n.type]).fromJSON(n)),new Pc(i,t.options)}}const Lc={generateTopUV(t,e,i,n,s){const r=e[3*i],a=e[3*i+1],o=e[3*n],l=e[3*n+1],h=e[3*s],c=e[3*s+1];return[new ri(r,a),new ri(o,l),new ri(h,c)]},generateSideWallUV(t,e,i,n,s,r){const a=e[3*i],o=e[3*i+1],l=e[3*i+2],h=e[3*n],c=e[3*n+1],u=e[3*n+2],d=e[3*s],p=e[3*s+1],m=e[3*s+2],f=e[3*r],g=e[3*r+1],_=e[3*r+2];return Math.abs(o-c)<Math.abs(a-h)?[new ri(a,1-l),new ri(h,1-u),new ri(d,1-m),new ri(f,1-_)]:[new ri(o,1-l),new ri(c,1-u),new ri(p,1-m),new ri(g,1-_)]}};class Ic extends Zh{constructor(t=1,e=0){const i=(1+Math.sqrt(5))/2;super([-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],[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],t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Ic(t.radius,t.detail)}}class Dc extends Zh{constructor(t=1,e=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],t,e),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Dc(t.radius,t.detail)}}class Nc extends Ss{constructor(t=.5,e=1,i=32,n=1,s=0,r=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:i,phiSegments:n,thetaStart:s,thetaLength:r},i=Math.max(3,i);const a=[],o=[],l=[],h=[];let c=t;const u=(e-t)/(n=Math.max(1,n)),d=new Ui,p=new ri;for(let m=0;m<=n;m++){for(let t=0;t<=i;t++){const n=s+t/i*r;d.x=c*Math.cos(n),d.y=c*Math.sin(n),o.push(d.x,d.y,d.z),l.push(0,0,1),p.x=(d.x/e+1)/2,p.y=(d.y/e+1)/2,h.push(p.x,p.y)}c+=u}for(let m=0;m<n;m++){const t=m*(i+1);for(let e=0;e<i;e++){const n=e+t,s=n,r=n+i+1,o=n+i+2,l=n+1;a.push(s,r,l),a.push(r,o,l)}}this.setIndex(a),this.setAttribute("position",new fs(o,3)),this.setAttribute("normal",new fs(l,3)),this.setAttribute("uv",new fs(h,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Nc(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}}class Uc extends Ss{constructor(t=new ic([new ri(0,.5),new ri(-.5,-.5),new ri(.5,-.5)]),e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};const i=[],n=[],s=[],r=[];let a=0,o=0;if(!1===Array.isArray(t))l(t);else for(let h=0;h<t.length;h++)l(t[h]),this.addGroup(a,o,h),a+=o,o=0;function l(t){const a=n.length/3,l=t.extractPoints(e);let h=l.shape;const c=l.holes;!1===Ac.isClockWise(h)&&(h=h.reverse());for(let e=0,i=c.length;e<i;e++){const t=c[e];!0===Ac.isClockWise(t)&&(c[e]=t.reverse())}const u=Ac.triangulateShape(h,c);for(let e=0,i=c.length;e<i;e++){const t=c[e];h=h.concat(t)}for(let e=0,i=h.length;e<i;e++){const t=h[e];n.push(t.x,t.y,0),s.push(0,0,1),r.push(t.x,t.y)}for(let e=0,n=u.length;e<n;e++){const t=u[e],n=t[0]+a,s=t[1]+a,r=t[2]+a;i.push(n,s,r),o+=3}}this.setIndex(i),this.setAttribute("position",new fs(n,3)),this.setAttribute("normal",new fs(s,3)),this.setAttribute("uv",new fs(r,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return function(t,e){if(e.shapes=[],Array.isArray(t))for(let i=0,n=t.length;i<n;i++){const n=t[i];e.shapes.push(n.uuid)}else e.shapes.push(t.uuid);return e}(this.parameters.shapes,t)}static fromJSON(t,e){const i=[];for(let n=0,s=t.shapes.length;n<s;n++){const s=e[t.shapes[n]];i.push(s)}return new Uc(i,t.curveSegments)}}class Oc extends Ss{constructor(t=1,e=32,i=16,n=0,s=2*Math.PI,r=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:i,phiStart:n,phiLength:s,thetaStart:r,thetaLength:a},e=Math.max(3,Math.floor(e)),i=Math.max(2,Math.floor(i));const o=Math.min(r+a,Math.PI);let l=0;const h=[],c=new Ui,u=new Ui,d=[],p=[],m=[],f=[];for(let g=0;g<=i;g++){const d=[],_=g/i;let v=0;0===g&&0===r?v=.5/e:g===i&&o===Math.PI&&(v=-.5/e);for(let i=0;i<=e;i++){const o=i/e;c.x=-t*Math.cos(n+o*s)*Math.sin(r+_*a),c.y=t*Math.cos(r+_*a),c.z=t*Math.sin(n+o*s)*Math.sin(r+_*a),p.push(c.x,c.y,c.z),u.copy(c).normalize(),m.push(u.x,u.y,u.z),f.push(o+v,1-_),d.push(l++)}h.push(d)}for(let g=0;g<i;g++)for(let t=0;t<e;t++){const e=h[g][t+1],n=h[g][t],s=h[g+1][t],a=h[g+1][t+1];(0!==g||r>0)&&d.push(e,n,a),(g!==i-1||o<Math.PI)&&d.push(n,s,a)}this.setIndex(d),this.setAttribute("position",new fs(p,3)),this.setAttribute("normal",new fs(m,3)),this.setAttribute("uv",new fs(f,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Oc(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class Fc extends Zh{constructor(t=1,e=0){super([1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],t,e),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Fc(t.radius,t.detail)}}class Bc extends Ss{constructor(t=1,e=.4,i=12,n=48,s=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:i,tubularSegments:n,arc:s},i=Math.floor(i),n=Math.floor(n);const r=[],a=[],o=[],l=[],h=new Ui,c=new Ui,u=new Ui;for(let d=0;d<=i;d++)for(let r=0;r<=n;r++){const p=r/n*s,m=d/i*Math.PI*2;c.x=(t+e*Math.cos(m))*Math.cos(p),c.y=(t+e*Math.cos(m))*Math.sin(p),c.z=e*Math.sin(m),a.push(c.x,c.y,c.z),h.x=t*Math.cos(p),h.y=t*Math.sin(p),u.subVectors(c,h).normalize(),o.push(u.x,u.y,u.z),l.push(r/n),l.push(d/i)}for(let d=1;d<=i;d++)for(let t=1;t<=n;t++){const e=(n+1)*d+t-1,i=(n+1)*(d-1)+t-1,s=(n+1)*(d-1)+t,a=(n+1)*d+t;r.push(e,i,a),r.push(i,s,a)}this.setIndex(r),this.setAttribute("position",new fs(a,3)),this.setAttribute("normal",new fs(o,3)),this.setAttribute("uv",new fs(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Bc(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class zc extends Ss{constructor(t=1,e=.4,i=64,n=8,s=2,r=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:i,radialSegments:n,p:s,q:r},i=Math.floor(i),n=Math.floor(n);const a=[],o=[],l=[],h=[],c=new Ui,u=new Ui,d=new Ui,p=new Ui,m=new Ui,f=new Ui,g=new Ui;for(let v=0;v<=i;++v){const a=v/i*s*Math.PI*2;_(a,s,r,t,d),_(a+.01,s,r,t,p),f.subVectors(p,d),g.addVectors(p,d),m.crossVectors(f,g),g.crossVectors(m,f),m.normalize(),g.normalize();for(let t=0;t<=n;++t){const s=t/n*Math.PI*2,r=-e*Math.cos(s),a=e*Math.sin(s);c.x=d.x+(r*g.x+a*m.x),c.y=d.y+(r*g.y+a*m.y),c.z=d.z+(r*g.z+a*m.z),o.push(c.x,c.y,c.z),u.subVectors(c,d).normalize(),l.push(u.x,u.y,u.z),h.push(v/i),h.push(t/n)}}for(let v=1;v<=i;v++)for(let t=1;t<=n;t++){const e=(n+1)*(v-1)+(t-1),i=(n+1)*v+(t-1),s=(n+1)*v+t,r=(n+1)*(v-1)+t;a.push(e,i,r),a.push(i,s,r)}function _(t,e,i,n,s){const r=Math.cos(t),a=Math.sin(t),o=i/e*t,l=Math.cos(o);s.x=n*(2+l)*.5*r,s.y=n*(2+l)*a*.5,s.z=n*Math.sin(o)*.5}this.setIndex(a),this.setAttribute("position",new fs(o,3)),this.setAttribute("normal",new fs(l,3)),this.setAttribute("uv",new fs(h,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new zc(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}}class kc extends Ss{constructor(t=new zh(new Ui(-1,-1,0),new Ui(-1,1,0),new Ui(1,1,0)),e=64,i=1,n=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:i,radialSegments:n,closed:s};const r=t.computeFrenetFrames(e,s);this.tangents=r.tangents,this.normals=r.normals,this.binormals=r.binormals;const a=new Ui,o=new Ui,l=new ri;let h=new Ui;const c=[],u=[],d=[],p=[];function m(s){h=t.getPointAt(s/e,h);const l=r.normals[s],d=r.binormals[s];for(let t=0;t<=n;t++){const e=t/n*Math.PI*2,s=Math.sin(e),r=-Math.cos(e);o.x=r*l.x+s*d.x,o.y=r*l.y+s*d.y,o.z=r*l.z+s*d.z,o.normalize(),u.push(o.x,o.y,o.z),a.x=h.x+i*o.x,a.y=h.y+i*o.y,a.z=h.z+i*o.z,c.push(a.x,a.y,a.z)}}!function(){for(let t=0;t<e;t++)m(t);m(!1===s?e:0),function(){for(let t=0;t<=e;t++)for(let i=0;i<=n;i++)l.x=t/e,l.y=i/n,d.push(l.x,l.y)}(),function(){for(let t=1;t<=e;t++)for(let e=1;e<=n;e++){const i=(n+1)*(t-1)+(e-1),s=(n+1)*t+(e-1),r=(n+1)*t+e,a=(n+1)*(t-1)+e;p.push(i,s,a),p.push(s,r,a)}}()}(),this.setIndex(p),this.setAttribute("position",new fs(c,3)),this.setAttribute("normal",new fs(u,3)),this.setAttribute("uv",new fs(d,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return t.path=this.parameters.path.toJSON(),t}static fromJSON(t){return new kc((new Vh[t.path.type]).fromJSON(t.path),t.tubularSegments,t.radius,t.radialSegments,t.closed)}}class Vc extends Ss{constructor(t=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:t},null!==t){const e=[],i=new Set,n=new Ui,s=new Ui;if(null!==t.index){const r=t.attributes.position,a=t.index;let o=t.groups;0===o.length&&(o=[{start:0,count:a.count,materialIndex:0}]);for(let t=0,l=o.length;t<l;++t){const l=o[t],h=l.start;for(let t=h,o=h+l.count;t<o;t+=3)for(let l=0;l<3;l++){const o=a.getX(t+l),h=a.getX(t+(l+1)%3);n.fromBufferAttribute(r,o),s.fromBufferAttribute(r,h),!0===Gc(n,s,i)&&(e.push(n.x,n.y,n.z),e.push(s.x,s.y,s.z))}}}else{const r=t.attributes.position;for(let t=0,a=r.count/3;t<a;t++)for(let o=0;o<3;o++){const a=3*t+o,l=3*t+(o+1)%3;n.fromBufferAttribute(r,a),s.fromBufferAttribute(r,l),!0===Gc(n,s,i)&&(e.push(n.x,n.y,n.z),e.push(s.x,s.y,s.z))}}this.setAttribute("position",new fs(e,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}function Gc(t,e,i){const n=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`,s=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`;return!0!==i.has(n)&&!0!==i.has(s)&&(i.add(n),i.add(s),!0)}var Hc=Object.freeze({__proto__:null,BoxGeometry:Hs,CapsuleGeometry:qh,CircleGeometry:Xh,ConeGeometry:Yh,CylinderGeometry:jh,DodecahedronGeometry:Jh,EdgesGeometry:ec,ExtrudeGeometry:Pc,IcosahedronGeometry:Ic,LatheGeometry:Wh,OctahedronGeometry:Dc,PlaneGeometry:cr,PolyhedronGeometry:Zh,RingGeometry:Nc,ShapeGeometry:Uc,SphereGeometry:Oc,TetrahedronGeometry:Fc,TorusGeometry:Bc,TorusKnotGeometry:zc,TubeGeometry:kc,WireframeGeometry:Vc});class Wc extends ns{constructor(t){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new ts(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 qc extends Ys{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Xc extends ns{constructor(t){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new ts(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 ts(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ri(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,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.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 jc extends Xc{constructor(t){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new ri(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get(){return Ke(2.5*(this.ior-1)/(this.ior+1),0,1)},set(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new ts(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new ts(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new ts(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class Yc extends ns{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new ts(16777215),this.specular=new ts(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ts(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ri(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,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.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Zc extends ns{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ts(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ts(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ri(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,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.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class Jc extends ns{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ri(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 Kc extends ns{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ts(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ts(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ri(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(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.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.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class $c extends ns{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ts(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ri(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,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.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Qc extends nh{constructor(t){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}function tu(t,e,i){return!t||!i&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)}function eu(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function iu(t){const e=t.length,i=new Array(e);for(let n=0;n!==e;++n)i[n]=n;return i.sort(function(e,i){return t[e]-t[i]}),i}function nu(t,e,i){const n=t.length,s=new t.constructor(n);for(let r=0,a=0;a!==n;++r){const n=i[r]*e;for(let i=0;i!==e;++i)s[a++]=t[n+i]}return s}function su(t,e,i,n){let s=1,r=t[0];for(;void 0!==r&&void 0===r[n];)r=t[s++];if(void 0===r)return;let a=r[n];if(void 0!==a)if(Array.isArray(a))do{a=r[n],void 0!==a&&(e.push(r.time),i.push.apply(i,a)),r=t[s++]}while(void 0!==r);else if(void 0!==a.toArray)do{a=r[n],void 0!==a&&(e.push(r.time),a.toArray(i,i.length)),r=t[s++]}while(void 0!==r);else do{a=r[n],void 0!==a&&(e.push(r.time),i.push(a)),r=t[s++]}while(void 0!==r)}const ru={convertArray:tu,isTypedArray:eu,getKeyframeOrder:iu,sortedArray:nu,flattenJSON:su,subclip(t,e,i,n,s=30){const r=t.clone();r.name=e;const a=[];for(let l=0;l<r.tracks.length;++l){const t=r.tracks[l],e=t.getValueSize(),o=[],h=[];for(let r=0;r<t.times.length;++r){const a=t.times[r]*s;if(!(a<i||a>=n)){o.push(t.times[r]);for(let i=0;i<e;++i)h.push(t.values[r*e+i])}}0!==o.length&&(t.times=tu(o,t.times.constructor),t.values=tu(h,t.values.constructor),a.push(t))}r.tracks=a;let o=1/0;for(let l=0;l<r.tracks.length;++l)o>r.tracks[l].times[0]&&(o=r.tracks[l].times[0]);for(let l=0;l<r.tracks.length;++l)r.tracks[l].shift(-1*o);return r.resetDuration(),r},makeClipAdditive(t,e=0,i=t,n=30){n<=0&&(n=30);const s=i.tracks.length,r=e/n;for(let a=0;a<s;++a){const e=i.tracks[a],n=e.ValueTypeName;if("bool"===n||"string"===n)continue;const s=t.tracks.find(function(t){return t.name===e.name&&t.ValueTypeName===n});if(void 0===s)continue;let o=0;const l=e.getValueSize();e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(o=l/3);let h=0;const c=s.getValueSize();s.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=c/3);const u=e.times.length-1;let d;if(r<=e.times[0]){const t=o,i=l-o;d=e.values.slice(t,i)}else if(r>=e.times[u]){const t=u*l+o,i=t+l-o;d=e.values.slice(t,i)}else{const t=e.createInterpolant(),i=o,n=l-o;t.evaluate(r),d=t.resultBuffer.slice(i,n)}"quaternion"===n&&(new Ni).fromArray(d).normalize().conjugate().toArray(d);const p=s.times.length;for(let t=0;t<p;++t){const e=t*c+h;if("quaternion"===n)Ni.multiplyQuaternionsFlat(s.values,e,d,0,s.values,e);else{const t=c-2*h;for(let i=0;i<t;++i)s.values[e+i]-=d[i]}}}return t.blendMode=ye,t}};class au{constructor(t,e,i,n){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==n?n:new e.constructor(i),this.sampleValues=e,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let i=this._cachedIndex,n=e[i],s=e[i-1];t:{e:{let r;i:{n:if(!(t<n)){for(let r=i+2;;){if(void 0===n){if(t<s)break n;return i=e.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===r)break;if(s=n,n=e[++i],t<n)break e}r=e.length;break i}if(!(t>=s)){const a=e[1];t<a&&(i=2,s=a);for(let r=i-2;;){if(void 0===s)return this._cachedIndex=0,this.copySampleValue_(0);if(i===r)break;if(n=s,s=e[--i-1],t>=s)break e}r=i,i=0;break i}break t}for(;i<r;){const n=i+r>>>1;t<e[n]?r=n:i=n+1}if(n=e[i],s=e[i-1],void 0===s)return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===n)return i=e.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,n)}return this.interpolate_(i,s,t,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){const e=this.resultBuffer,i=this.sampleValues,n=this.valueSize,s=t*n;for(let r=0;r!==n;++r)e[r]=i[s+r];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class ou extends au{constructor(t,e,i,n){super(t,e,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:ge,endingEnd:ge}}intervalChanged_(t,e,i){const n=this.parameterPositions;let s=t-2,r=t+1,a=n[s],o=n[r];if(void 0===a)switch(this.getSettings_().endingStart){case _e:s=t,a=2*e-i;break;case ve:s=n.length-2,a=e+n[s]-n[s+1];break;default:s=t,a=i}if(void 0===o)switch(this.getSettings_().endingEnd){case _e:r=t,o=2*i-e;break;case ve:r=1,o=i+n[1]-n[0];break;default:r=t-1,o=e}const l=.5*(i-e),h=this.valueSize;this._weightPrev=l/(e-a),this._weightNext=l/(o-i),this._offsetPrev=s*h,this._offsetNext=r*h}interpolate_(t,e,i,n){const s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=t*a,l=o-a,h=this._offsetPrev,c=this._offsetNext,u=this._weightPrev,d=this._weightNext,p=(i-e)/(n-e),m=p*p,f=m*p,g=-u*f+2*u*m-u*p,_=(1+u)*f+(-1.5-2*u)*m+(-.5+u)*p+1,v=(-1-d)*f+(1.5+d)*m+.5*p,y=d*f-d*m;for(let x=0;x!==a;++x)s[x]=g*r[h+x]+_*r[l+x]+v*r[o+x]+y*r[c+x];return s}}class lu extends au{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t,e,i,n){const s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=t*a,l=o-a,h=(i-e)/(n-e),c=1-h;for(let u=0;u!==a;++u)s[u]=r[l+u]*c+r[o+u]*h;return s}}class hu extends au{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t){return this.copySampleValue_(t-1)}}class cu{constructor(t,e,i,n){if(void 0===t)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===e||0===e.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=tu(e,this.TimeBufferType),this.values=tu(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let i;if(e.toJSON!==this.toJSON)i=e.toJSON(t);else{i={name:t.name,times:tu(t.times,Array),values:tu(t.values,Array)};const e=t.getInterpolation();e!==t.DefaultInterpolation&&(i.interpolation=e)}return i.type=t.ValueTypeName,i}InterpolantFactoryMethodDiscrete(t){return new hu(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new lu(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new ou(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case pe:e=this.InterpolantFactoryMethodDiscrete;break;case me:e=this.InterpolantFactoryMethodLinear;break;case fe:e=this.InterpolantFactoryMethodSmooth}if(void 0===e){const e="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(t===this.DefaultInterpolation)throw new Error(e);this.setInterpolation(this.DefaultInterpolation)}return this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return pe;case this.InterpolantFactoryMethodLinear:return me;case this.InterpolantFactoryMethodSmooth:return fe}}getValueSize(){return this.values.length/this.times.length}shift(t){if(0!==t){const e=this.times;for(let i=0,n=e.length;i!==n;++i)e[i]+=t}return this}scale(t){if(1!==t){const e=this.times;for(let i=0,n=e.length;i!==n;++i)e[i]*=t}return this}trim(t,e){const i=this.times,n=i.length;let s=0,r=n-1;for(;s!==n&&i[s]<t;)++s;for(;-1!==r&&i[r]>e;)--r;if(++r,0!==s||r!==n){s>=r&&(r=Math.max(r,1),s=r-1);const t=this.getValueSize();this.times=i.slice(s,r),this.values=this.values.slice(s*t,r*t)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!==0&&(t=!1);const i=this.times,n=this.values,s=i.length;0===s&&(t=!1);let r=null;for(let a=0;a!==s;a++){const e=i[a];if("number"==typeof e&&isNaN(e)){t=!1;break}if(null!==r&&r>e){t=!1;break}r=e}if(void 0!==n&&eu(n))for(let a=0,o=n.length;a!==o;++a){const e=n[a];if(isNaN(e)){t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),i=this.getValueSize(),n=this.getInterpolation()===fe,s=t.length-1;let r=1;for(let a=1;a<s;++a){let s=!1;const o=t[a];if(o!==t[a+1]&&(1!==a||o!==t[0]))if(n)s=!0;else{const t=a*i,n=t-i,r=t+i;for(let a=0;a!==i;++a){const i=e[t+a];if(i!==e[n+a]||i!==e[r+a]){s=!0;break}}}if(s){if(a!==r){t[r]=t[a];const n=a*i,s=r*i;for(let t=0;t!==i;++t)e[s+t]=e[n+t]}++r}}if(s>0){t[r]=t[s];for(let t=s*i,n=r*i,a=0;a!==i;++a)e[n+a]=e[t+a];++r}return r!==t.length?(this.times=t.slice(0,r),this.values=e.slice(0,r*i)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),i=new(0,this.constructor)(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}}cu.prototype.TimeBufferType=Float32Array,cu.prototype.ValueBufferType=Float32Array,cu.prototype.DefaultInterpolation=me;class uu extends cu{}uu.prototype.ValueTypeName="bool",uu.prototype.ValueBufferType=Array,uu.prototype.DefaultInterpolation=pe,uu.prototype.InterpolantFactoryMethodLinear=void 0,uu.prototype.InterpolantFactoryMethodSmooth=void 0;class du extends cu{}du.prototype.ValueTypeName="color";class pu extends cu{}pu.prototype.ValueTypeName="number";class mu extends au{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t,e,i,n){const s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=(i-e)/(n-e);let l=t*a;for(let h=l+a;l!==h;l+=4)Ni.slerpFlat(s,0,r,l-a,r,l,o);return s}}class fu extends cu{InterpolantFactoryMethodLinear(t){return new mu(this.times,this.values,this.getValueSize(),t)}}fu.prototype.ValueTypeName="quaternion",fu.prototype.DefaultInterpolation=me,fu.prototype.InterpolantFactoryMethodSmooth=void 0;class gu extends cu{}gu.prototype.ValueTypeName="string",gu.prototype.ValueBufferType=Array,gu.prototype.DefaultInterpolation=pe,gu.prototype.InterpolantFactoryMethodLinear=void 0,gu.prototype.InterpolantFactoryMethodSmooth=void 0;class _u extends cu{}_u.prototype.ValueTypeName="vector";class vu{constructor(t,e=-1,i,n=2500){this.name=t,this.tracks=i,this.duration=e,this.blendMode=n,this.uuid=Je(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],i=t.tracks,n=1/(t.fps||1);for(let r=0,a=i.length;r!==a;++r)e.push(yu(i[r]).scale(n));const s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s}static toJSON(t){const e=[],i=t.tracks,n={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let s=0,r=i.length;s!==r;++s)e.push(cu.toJSON(i[s]));return n}static CreateFromMorphTargetSequence(t,e,i,n){const s=e.length,r=[];for(let a=0;a<s;a++){let t=[],o=[];t.push((a+s-1)%s,a,(a+1)%s),o.push(0,1,0);const l=iu(t);t=nu(t,1,l),o=nu(o,1,l),n||0!==t[0]||(t.push(s),o.push(o[0])),r.push(new pu(".morphTargetInfluences["+e[a].name+"]",t,o).scale(1/i))}return new this(t,-1,r)}static findByName(t,e){let i=t;if(!Array.isArray(t)){const e=t;i=e.geometry&&e.geometry.animations||e.animations}for(let n=0;n<i.length;n++)if(i[n].name===e)return i[n];return null}static CreateClipsFromMorphTargetSequences(t,e,i){const n={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,o=t.length;a<o;a++){const e=t[a],i=e.name.match(s);if(i&&i.length>1){const t=i[1];let s=n[t];s||(n[t]=s=[]),s.push(e)}}const r=[];for(const a in n)r.push(this.CreateFromMorphTargetSequence(a,n[a],e,i));return r}static parseAnimation(t,e){if(!t)return null;const i=function(t,e,i,n,s){if(0!==i.length){const r=[],a=[];su(i,r,a,n),0!==r.length&&s.push(new t(e,r,a))}},n=[],s=t.name||"default",r=t.fps||30,a=t.blendMode;let o=t.length||-1;const l=t.hierarchy||[];for(let h=0;h<l.length;h++){const t=l[h].keys;if(t&&0!==t.length)if(t[0].morphTargets){const e={};let i;for(i=0;i<t.length;i++)if(t[i].morphTargets)for(let n=0;n<t[i].morphTargets.length;n++)e[t[i].morphTargets[n]]=-1;for(const s in e){const e=[],r=[];for(let n=0;n!==t[i].morphTargets.length;++n){const n=t[i];e.push(n.time),r.push(n.morphTarget===s?1:0)}n.push(new pu(".morphTargetInfluence["+s+"]",e,r))}o=e.length*r}else{const s=".bones["+e[h].name+"]";i(_u,s+".position",t,"pos",n),i(fu,s+".quaternion",t,"rot",n),i(_u,s+".scale",t,"scl",n)}}return 0===n.length?null:new this(s,o,n,a)}resetDuration(){let t=0;for(let e=0,i=this.tracks.length;e!==i;++e){const i=this.tracks[e];t=Math.max(t,i.times[i.times.length-1])}return this.duration=t,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){const t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function yu(t){if(void 0===t.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return pu;case"vector":case"vector2":case"vector3":case"vector4":return _u;case"color":return du;case"quaternion":return fu;case"bool":case"boolean":return uu;case"string":return gu}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}(t.type);if(void 0===t.times){const e=[],i=[];su(t.keys,e,i,"value"),t.times=e,t.values=i}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)}const xu={enabled:!1,files:{},add(t,e){!1!==this.enabled&&(this.files[t]=e)},get(t){if(!1!==this.enabled)return this.files[t]},remove(t){delete this.files[t]},clear(){this.files={}}};class Mu{constructor(t,e,i){const n=this;let s,r=!1,a=0,o=0;const l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=i,this.itemStart=function(t){o++,!1===r&&void 0!==n.onStart&&n.onStart(t,a,o),r=!0},this.itemEnd=function(t){a++,void 0!==n.onProgress&&n.onProgress(t,a,o),a===o&&(r=!1,void 0!==n.onLoad&&n.onLoad())},this.itemError=function(t){void 0!==n.onError&&n.onError(t)},this.resolveURL=function(t){return s?s(t):t},this.setURLModifier=function(t){return s=t,this},this.addHandler=function(t,e){return l.push(t,e),this},this.removeHandler=function(t){const e=l.indexOf(t);return-1!==e&&l.splice(e,2),this},this.getHandler=function(t){for(let e=0,i=l.length;e<i;e+=2){const i=l[e],n=l[e+1];if(i.global&&(i.lastIndex=0),i.test(t))return n}return null}}}const bu=new Mu;class Su{constructor(t){this.manager=void 0!==t?t:bu,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){const i=this;return new Promise(function(n,s){i.load(t,n,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}}Su.DEFAULT_MATERIAL_NAME="__DEFAULT";const wu={};class Tu extends Error{constructor(t,e){super(t),this.response=e}}class Eu extends Su{constructor(t){super(t)}load(t,e,i,n){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const s=xu.get(t);if(void 0!==s)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(void 0!==wu[t])return void wu[t].push({onLoad:e,onProgress:i,onError:n});wu[t]=[],wu[t].push({onLoad:e,onProgress:i,onError:n});const r=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,o=this.responseType;fetch(r).then(e=>{if(200===e.status||0===e.status){if(e.status,"undefined"==typeof ReadableStream||void 0===e.body||void 0===e.body.getReader)return e;const i=wu[t],n=e.body.getReader(),s=e.headers.get("Content-Length")||e.headers.get("X-File-Size"),r=s?parseInt(s):0,a=0!==r;let o=0;const l=new ReadableStream({start(t){!function e(){n.read().then(({done:n,value:s})=>{if(n)t.close();else{o+=s.byteLength;const n=new ProgressEvent("progress",{lengthComputable:a,loaded:o,total:r});for(let t=0,e=i.length;t<e;t++){const e=i[t];e.onProgress&&e.onProgress(n)}t.enqueue(s),e()}})}()}});return new Response(l)}throw new Tu(`fetch for "${e.url}" responded with ${e.status}: ${e.statusText}`,e)}).then(t=>{switch(o){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"document":return t.text().then(t=>(new DOMParser).parseFromString(t,a));case"json":return t.json();default:if(void 0===a)return t.text();{const e=/charset="?([^;"\s]*)"?/i.exec(a),i=e&&e[1]?e[1].toLowerCase():void 0,n=new TextDecoder(i);return t.arrayBuffer().then(t=>n.decode(t))}}}).then(e=>{xu.add(t,e);const i=wu[t];delete wu[t];for(let t=0,n=i.length;t<n;t++){const n=i[t];n.onLoad&&n.onLoad(e)}}).catch(e=>{const i=wu[t];if(void 0===i)throw this.manager.itemError(t),e;delete wu[t];for(let t=0,n=i.length;t<n;t++){const n=i[t];n.onError&&n.onError(e)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class Au extends Su{constructor(t){super(t)}load(t,e,i,n){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,r=xu.get(t);if(void 0!==r)return s.manager.itemStart(t),setTimeout(function(){e&&e(r),s.manager.itemEnd(t)},0),r;const a=ui("img");function o(){h(),xu.add(t,this),e&&e(this),s.manager.itemEnd(t)}function l(e){h(),n&&n(e),s.manager.itemError(t),s.manager.itemEnd(t)}function h(){a.removeEventListener("load",o,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",o,!1),a.addEventListener("error",l,!1),"data:"!==t.slice(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(t),a.src=t,a}}class Cu extends Fn{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new ts(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,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}class Ru extends Cu{constructor(t,e,i){super(t,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Fn.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ts(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}}const Pu=new dn,Lu=new Ui,Iu=new Ui;class Du{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ri(512,512),this.map=null,this.mapPass=null,this.matrix=new dn,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new or,this._frameExtents=new ri(1,1),this._viewportCount=1,this._viewports=[new Ri(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,i=this.matrix;Lu.setFromMatrixPosition(t.matrixWorld),e.position.copy(Lu),Iu.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(Iu),e.updateMatrixWorld(),Pu.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Pu),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Pu)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const t={};return 0!==this.bias&&(t.bias=this.bias),0!==this.normalBias&&(t.normalBias=this.normalBias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class Nu extends Du{constructor(){super(new Js(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){const e=this.camera,i=2*Ze*t.angle*this.focus,n=this.mapSize.width/this.mapSize.height,s=t.distance||e.far;i===e.fov&&n===e.aspect&&s===e.far||(e.fov=i,e.aspect=n,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class Uu extends Cu{constructor(t,e,i=0,n=Math.PI/3,s=0,r=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Fn.DEFAULT_UP),this.updateMatrix(),this.target=new Fn,this.distance=i,this.angle=n,this.penumbra=s,this.decay=r,this.map=null,this.shadow=new Nu}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}const Ou=new dn,Fu=new Ui,Bu=new Ui;class zu extends Du{constructor(){super(new Js(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new ri(4,2),this._viewportCount=6,this._viewports=[new Ri(2,1,1,1),new Ri(0,1,1,1),new Ri(3,1,1,1),new Ri(1,1,1,1),new Ri(3,0,1,1),new Ri(1,0,1,1)],this._cubeDirections=[new Ui(1,0,0),new Ui(-1,0,0),new Ui(0,0,1),new Ui(0,0,-1),new Ui(0,1,0),new Ui(0,-1,0)],this._cubeUps=[new Ui(0,1,0),new Ui(0,1,0),new Ui(0,1,0),new Ui(0,1,0),new Ui(0,0,1),new Ui(0,0,-1)]}updateMatrices(t,e=0){const i=this.camera,n=this.matrix,s=t.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),Fu.setFromMatrixPosition(t.matrixWorld),i.position.copy(Fu),Bu.copy(i.position),Bu.add(this._cubeDirections[e]),i.up.copy(this._cubeUps[e]),i.lookAt(Bu),i.updateMatrixWorld(),n.makeTranslation(-Fu.x,-Fu.y,-Fu.z),Ou.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ou)}}class ku extends Cu{constructor(t,e,i=0,n=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=n,this.shadow=new zu}get power(){return 4*this.intensity*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 Vu extends Du{constructor(){super(new Mr(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Gu extends Cu{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Fn.DEFAULT_UP),this.updateMatrix(),this.target=new Fn,this.shadow=new Vu}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class Hu extends Cu{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class Wu extends Cu{constructor(t,e,i=10,n=10){super(t,e),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,this.height=n}get power(){return this.intensity*this.width*this.height*Math.PI}set power(t){this.intensity=t/(this.width*this.height*Math.PI)}copy(t){return super.copy(t),this.width=t.width,this.height=t.height,this}toJSON(t){const e=super.toJSON(t);return e.object.width=this.width,e.object.height=this.height,e}}class qu{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new Ui)}set(t){for(let e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this}zero(){for(let t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this}getAt(t,e){const i=t.x,n=t.y,s=t.z,r=this.coefficients;return e.copy(r[0]).multiplyScalar(.282095),e.addScaledVector(r[1],.488603*n),e.addScaledVector(r[2],.488603*s),e.addScaledVector(r[3],.488603*i),e.addScaledVector(r[4],i*n*1.092548),e.addScaledVector(r[5],n*s*1.092548),e.addScaledVector(r[6],.315392*(3*s*s-1)),e.addScaledVector(r[7],i*s*1.092548),e.addScaledVector(r[8],.546274*(i*i-n*n)),e}getIrradianceAt(t,e){const i=t.x,n=t.y,s=t.z,r=this.coefficients;return e.copy(r[0]).multiplyScalar(.886227),e.addScaledVector(r[1],1.023328*n),e.addScaledVector(r[2],1.023328*s),e.addScaledVector(r[3],1.023328*i),e.addScaledVector(r[4],.858086*i*n),e.addScaledVector(r[5],.858086*n*s),e.addScaledVector(r[6],.743125*s*s-.247708),e.addScaledVector(r[7],.858086*i*s),e.addScaledVector(r[8],.429043*(i*i-n*n)),e}add(t){for(let e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this}addScaledSH(t,e){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(t.coefficients[i],e);return this}scale(t){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this}lerp(t,e){for(let i=0;i<9;i++)this.coefficients[i].lerp(t.coefficients[i],e);return this}equals(t){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0}copy(t){return this.set(t.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(t,e=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].fromArray(t,e+3*n);return this}toArray(t=[],e=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].toArray(t,e+3*n);return t}static getBasisAt(t,e){const i=t.x,n=t.y,s=t.z;e[0]=.282095,e[1]=.488603*n,e[2]=.488603*s,e[3]=.488603*i,e[4]=1.092548*i*n,e[5]=1.092548*n*s,e[6]=.315392*(3*s*s-1),e[7]=1.092548*i*s,e[8]=.546274*(i*i-n*n)}}class Xu extends Cu{constructor(t=new qu,e=1){super(void 0,e),this.isLightProbe=!0,this.sh=t}copy(t){return super.copy(t),this.sh.copy(t.sh),this}fromJSON(t){return this.intensity=t.intensity,this.sh.fromArray(t.sh),this}toJSON(t){const e=super.toJSON(t);return e.object.sh=this.sh.toArray(),e}}class ju extends Su{constructor(t){super(t),this.textures={}}load(t,e,i,n){const s=this,r=new Eu(s.manager);r.setPath(s.path),r.setRequestHeader(s.requestHeader),r.setWithCredentials(s.withCredentials),r.load(t,function(i){try{e(s.parse(JSON.parse(i)))}catch(r){n&&n(r),s.manager.itemError(t)}},i,n)}parse(t){const e=this.textures;function i(t){return e[t],e[t]}const n=ju.createMaterialFromType(t.type);if(void 0!==t.uuid&&(n.uuid=t.uuid),void 0!==t.name&&(n.name=t.name),void 0!==t.color&&void 0!==n.color&&n.color.setHex(t.color),void 0!==t.roughness&&(n.roughness=t.roughness),void 0!==t.metalness&&(n.metalness=t.metalness),void 0!==t.sheen&&(n.sheen=t.sheen),void 0!==t.sheenColor&&(n.sheenColor=(new ts).setHex(t.sheenColor)),void 0!==t.sheenRoughness&&(n.sheenRoughness=t.sheenRoughness),void 0!==t.emissive&&void 0!==n.emissive&&n.emissive.setHex(t.emissive),void 0!==t.specular&&void 0!==n.specular&&n.specular.setHex(t.specular),void 0!==t.specularIntensity&&(n.specularIntensity=t.specularIntensity),void 0!==t.specularColor&&void 0!==n.specularColor&&n.specularColor.setHex(t.specularColor),void 0!==t.shininess&&(n.shininess=t.shininess),void 0!==t.clearcoat&&(n.clearcoat=t.clearcoat),void 0!==t.clearcoatRoughness&&(n.clearcoatRoughness=t.clearcoatRoughness),void 0!==t.iridescence&&(n.iridescence=t.iridescence),void 0!==t.iridescenceIOR&&(n.iridescenceIOR=t.iridescenceIOR),void 0!==t.iridescenceThicknessRange&&(n.iridescenceThicknessRange=t.iridescenceThicknessRange),void 0!==t.transmission&&(n.transmission=t.transmission),void 0!==t.thickness&&(n.thickness=t.thickness),void 0!==t.attenuationDistance&&(n.attenuationDistance=t.attenuationDistance),void 0!==t.attenuationColor&&void 0!==n.attenuationColor&&n.attenuationColor.setHex(t.attenuationColor),void 0!==t.anisotropy&&(n.anisotropy=t.anisotropy),void 0!==t.anisotropyRotation&&(n.anisotropyRotation=t.anisotropyRotation),void 0!==t.fog&&(n.fog=t.fog),void 0!==t.flatShading&&(n.flatShading=t.flatShading),void 0!==t.blending&&(n.blending=t.blending),void 0!==t.combine&&(n.combine=t.combine),void 0!==t.side&&(n.side=t.side),void 0!==t.shadowSide&&(n.shadowSide=t.shadowSide),void 0!==t.opacity&&(n.opacity=t.opacity),void 0!==t.transparent&&(n.transparent=t.transparent),void 0!==t.alphaTest&&(n.alphaTest=t.alphaTest),void 0!==t.alphaHash&&(n.alphaHash=t.alphaHash),void 0!==t.depthFunc&&(n.depthFunc=t.depthFunc),void 0!==t.depthTest&&(n.depthTest=t.depthTest),void 0!==t.depthWrite&&(n.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(n.colorWrite=t.colorWrite),void 0!==t.blendSrc&&(n.blendSrc=t.blendSrc),void 0!==t.blendDst&&(n.blendDst=t.blendDst),void 0!==t.blendEquation&&(n.blendEquation=t.blendEquation),void 0!==t.blendSrcAlpha&&(n.blendSrcAlpha=t.blendSrcAlpha),void 0!==t.blendDstAlpha&&(n.blendDstAlpha=t.blendDstAlpha),void 0!==t.blendEquationAlpha&&(n.blendEquationAlpha=t.blendEquationAlpha),void 0!==t.blendColor&&void 0!==n.blendColor&&n.blendColor.setHex(t.blendColor),void 0!==t.blendAlpha&&(n.blendAlpha=t.blendAlpha),void 0!==t.stencilWriteMask&&(n.stencilWriteMask=t.stencilWriteMask),void 0!==t.stencilFunc&&(n.stencilFunc=t.stencilFunc),void 0!==t.stencilRef&&(n.stencilRef=t.stencilRef),void 0!==t.stencilFuncMask&&(n.stencilFuncMask=t.stencilFuncMask),void 0!==t.stencilFail&&(n.stencilFail=t.stencilFail),void 0!==t.stencilZFail&&(n.stencilZFail=t.stencilZFail),void 0!==t.stencilZPass&&(n.stencilZPass=t.stencilZPass),void 0!==t.stencilWrite&&(n.stencilWrite=t.stencilWrite),void 0!==t.wireframe&&(n.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(n.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(n.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(n.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.rotation&&(n.rotation=t.rotation),void 0!==t.linewidth&&(n.linewidth=t.linewidth),void 0!==t.dashSize&&(n.dashSize=t.dashSize),void 0!==t.gapSize&&(n.gapSize=t.gapSize),void 0!==t.scale&&(n.scale=t.scale),void 0!==t.polygonOffset&&(n.polygonOffset=t.polygonOffset),void 0!==t.polygonOffsetFactor&&(n.polygonOffsetFactor=t.polygonOffsetFactor),void 0!==t.polygonOffsetUnits&&(n.polygonOffsetUnits=t.polygonOffsetUnits),void 0!==t.dithering&&(n.dithering=t.dithering),void 0!==t.alphaToCoverage&&(n.alphaToCoverage=t.alphaToCoverage),void 0!==t.premultipliedAlpha&&(n.premultipliedAlpha=t.premultipliedAlpha),void 0!==t.forceSinglePass&&(n.forceSinglePass=t.forceSinglePass),void 0!==t.visible&&(n.visible=t.visible),void 0!==t.toneMapped&&(n.toneMapped=t.toneMapped),void 0!==t.userData&&(n.userData=t.userData),void 0!==t.vertexColors&&("number"==typeof t.vertexColors?n.vertexColors=t.vertexColors>0:n.vertexColors=t.vertexColors),void 0!==t.uniforms)for(const s in t.uniforms){const e=t.uniforms[s];switch(n.uniforms[s]={},e.type){case"t":n.uniforms[s].value=i(e.value);break;case"c":n.uniforms[s].value=(new ts).setHex(e.value);break;case"v2":n.uniforms[s].value=(new ri).fromArray(e.value);break;case"v3":n.uniforms[s].value=(new Ui).fromArray(e.value);break;case"v4":n.uniforms[s].value=(new Ri).fromArray(e.value);break;case"m3":n.uniforms[s].value=(new ai).fromArray(e.value);break;case"m4":n.uniforms[s].value=(new dn).fromArray(e.value);break;default:n.uniforms[s].value=e.value}}if(void 0!==t.defines&&(n.defines=t.defines),void 0!==t.vertexShader&&(n.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(n.fragmentShader=t.fragmentShader),void 0!==t.glslVersion&&(n.glslVersion=t.glslVersion),void 0!==t.extensions)for(const s in t.extensions)n.extensions[s]=t.extensions[s];if(void 0!==t.lights&&(n.lights=t.lights),void 0!==t.clipping&&(n.clipping=t.clipping),void 0!==t.size&&(n.size=t.size),void 0!==t.sizeAttenuation&&(n.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(n.map=i(t.map)),void 0!==t.matcap&&(n.matcap=i(t.matcap)),void 0!==t.alphaMap&&(n.alphaMap=i(t.alphaMap)),void 0!==t.bumpMap&&(n.bumpMap=i(t.bumpMap)),void 0!==t.bumpScale&&(n.bumpScale=t.bumpScale),void 0!==t.normalMap&&(n.normalMap=i(t.normalMap)),void 0!==t.normalMapType&&(n.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),n.normalScale=(new ri).fromArray(e)}return void 0!==t.displacementMap&&(n.displacementMap=i(t.displacementMap)),void 0!==t.displacementScale&&(n.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(n.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(n.roughnessMap=i(t.roughnessMap)),void 0!==t.metalnessMap&&(n.metalnessMap=i(t.metalnessMap)),void 0!==t.emissiveMap&&(n.emissiveMap=i(t.emissiveMap)),void 0!==t.emissiveIntensity&&(n.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(n.specularMap=i(t.specularMap)),void 0!==t.specularIntensityMap&&(n.specularIntensityMap=i(t.specularIntensityMap)),void 0!==t.specularColorMap&&(n.specularColorMap=i(t.specularColorMap)),void 0!==t.envMap&&(n.envMap=i(t.envMap)),void 0!==t.envMapIntensity&&(n.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(n.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(n.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(n.lightMap=i(t.lightMap)),void 0!==t.lightMapIntensity&&(n.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(n.aoMap=i(t.aoMap)),void 0!==t.aoMapIntensity&&(n.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(n.gradientMap=i(t.gradientMap)),void 0!==t.clearcoatMap&&(n.clearcoatMap=i(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(n.clearcoatRoughnessMap=i(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(n.clearcoatNormalMap=i(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(n.clearcoatNormalScale=(new ri).fromArray(t.clearcoatNormalScale)),void 0!==t.iridescenceMap&&(n.iridescenceMap=i(t.iridescenceMap)),void 0!==t.iridescenceThicknessMap&&(n.iridescenceThicknessMap=i(t.iridescenceThicknessMap)),void 0!==t.transmissionMap&&(n.transmissionMap=i(t.transmissionMap)),void 0!==t.thicknessMap&&(n.thicknessMap=i(t.thicknessMap)),void 0!==t.anisotropyMap&&(n.anisotropyMap=i(t.anisotropyMap)),void 0!==t.sheenColorMap&&(n.sheenColorMap=i(t.sheenColorMap)),void 0!==t.sheenRoughnessMap&&(n.sheenRoughnessMap=i(t.sheenRoughnessMap)),n}setTextures(t){return this.textures=t,this}static createMaterialFromType(t){return new{ShadowMaterial:Wc,SpriteMaterial:Ko,RawShaderMaterial:qc,ShaderMaterial:Ys,PointsMaterial:mh,MeshPhysicalMaterial:jc,MeshStandardMaterial:Xc,MeshPhongMaterial:Yc,MeshToonMaterial:Zc,MeshNormalMaterial:Jc,MeshLambertMaterial:Kc,MeshDepthMaterial:Po,MeshDistanceMaterial:Lo,MeshBasicMaterial:ss,MeshMatcapMaterial:$c,LineDashedMaterial:Qc,LineBasicMaterial:nh,Material:ns}[t]}}class Yu{static decodeText(t){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);let e="";for(let n=0,s=t.length;n<s;n++)e+=String.fromCharCode(t[n]);try{return decodeURIComponent(escape(e))}catch(i){return e}}static extractUrlBase(t){const e=t.lastIndexOf("/");return-1===e?"./":t.slice(0,e+1)}static resolveURL(t,e){return"string"!=typeof t||""===t?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}}class Zu extends Ss{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){const t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}}class Ju extends Su{constructor(t){super(t)}load(t,e,i,n){const s=this,r=new Eu(s.manager);r.setPath(s.path),r.setRequestHeader(s.requestHeader),r.setWithCredentials(s.withCredentials),r.load(t,function(i){try{e(s.parse(JSON.parse(i)))}catch(r){n&&n(r),s.manager.itemError(t)}},i,n)}parse(t){const e={},i={};function n(t,n){if(void 0!==e[n])return e[n];const s=t.interleavedBuffers[n],r=function(t,e){if(void 0!==i[e])return i[e];const n=t.arrayBuffers[e],s=new Uint32Array(n).buffer;return i[e]=s,s}(t,s.buffer),a=ci(s.type,r),o=new Yo(a,s.stride);return o.uuid=s.uuid,e[n]=o,o}const s=t.isInstancedBufferGeometry?new Zu:new Ss,r=t.data.index;if(void 0!==r){const t=ci(r.type,r.array);s.setIndex(new ds(t,1))}const a=t.data.attributes;for(const c in a){const e=a[c];let i;if(e.isInterleavedBufferAttribute){const s=n(t.data,e.data);i=new Jo(s,e.itemSize,e.offset,e.normalized)}else{const t=ci(e.type,e.array);i=new(e.isInstancedBufferAttribute?Ll:ds)(t,e.itemSize,e.normalized)}void 0!==e.name&&(i.name=e.name),void 0!==e.usage&&i.setUsage(e.usage),s.setAttribute(c,i)}const o=t.data.morphAttributes;if(o)for(const c in o){const e=o[c],i=[];for(let s=0,r=e.length;s<r;s++){const r=e[s];let a;if(r.isInterleavedBufferAttribute){const e=n(t.data,r.data);a=new Jo(e,r.itemSize,r.offset,r.normalized)}else{const t=ci(r.type,r.array);a=new ds(t,r.itemSize,r.normalized)}void 0!==r.name&&(a.name=r.name),i.push(a)}s.morphAttributes[c]=i}t.data.morphTargetsRelative&&(s.morphTargetsRelative=!0);const l=t.data.groups||t.data.drawcalls||t.data.offsets;if(void 0!==l)for(let c=0,u=l.length;c!==u;++c){const t=l[c];s.addGroup(t.start,t.count,t.materialIndex)}const h=t.data.boundingSphere;if(void 0!==h){const t=new Ui;void 0!==h.center&&t.fromArray(h.center),s.boundingSphere=new nn(t,h.radius)}return t.name&&(s.name=t.name),t.userData&&(s.userData=t.userData),s}}const Ku={UVMapping:at,CubeReflectionMapping:ot,CubeRefractionMapping:lt,EquirectangularReflectionMapping:ht,EquirectangularRefractionMapping:ct,CubeUVReflectionMapping:ut},$u={RepeatWrapping:dt,ClampToEdgeWrapping:pt,MirroredRepeatWrapping:mt},Qu={NearestFilter:ft,NearestMipmapNearestFilter:gt,NearestMipmapLinearFilter:_t,LinearFilter:vt,LinearMipmapNearestFilter:yt,LinearMipmapLinearFilter:xt};let td;class ed{static getContext(){return void 0===td&&(td=new(window.AudioContext||window.webkitAudioContext)),td}static setContext(t){td=t}}const id=new dn,nd=new dn,sd=new dn;class rd{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=ad(),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=ad();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function ad(){return("undefined"==typeof performance?Date:performance).now()}const od=new Ui,ld=new Ni,hd=new Ui,cd=new Ui;class ud extends Fn{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(!0===this.isPlaying)return;if(!1===this.hasPlaybackControl)return;this._startedAt=this.context.currentTime+t;const e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(!1!==this.hasPlaybackControl)return this._progress=0,null!==this.source&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].connect(this.filters[t]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(!1!==this._connected){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].disconnect(this.filters[t]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(t){return t||(t=[]),!0===this._connected?(this.disconnect(),this.filters=t.slice(),this.connect()):this.filters=t.slice(),this}setDetune(t){if(this.detune=t,void 0!==this.source.detune)return!0===this.isPlaying&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(t){return this.setFilters(t?[t]:[])}setPlaybackRate(t){if(!1!==this.hasPlaybackControl)return this.playbackRate=t,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return!1!==this.hasPlaybackControl&&this.loop}setLoop(t){if(!1!==this.hasPlaybackControl)return this.loop=t,!0===this.isPlaying&&(this.source.loop=this.loop),this}setLoopStart(t){return this.loopStart=t,this}setLoopEnd(t){return this.loopEnd=t,this}getVolume(){return this.gain.gain.value}setVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}}const dd=new Ui,pd=new Ni,md=new Ui,fd=new Ui;class gd{constructor(t,e,i){let n,s,r;switch(this.binding=t,this.valueSize=i,e){case"quaternion":n=this._slerp,s=this._slerpAdditive,r=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*i),this._workIndex=5;break;case"string":case"bool":n=this._select,s=this._select,r=this._setAdditiveIdentityOther,this.buffer=new Array(5*i);break;default:n=this._lerp,s=this._lerpAdditive,r=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*i)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=s,this._setIdentity=r,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){const i=this.buffer,n=this.valueSize,s=t*n+n;let r=this.cumulativeWeight;if(0===r){for(let t=0;t!==n;++t)i[s+t]=i[t];r=e}else{r+=e;const t=e/r;this._mixBufferRegion(i,s,0,t,n)}this.cumulativeWeight=r}accumulateAdditive(t){const e=this.buffer,i=this.valueSize,n=i*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(e,n,0,t,i),this.cumulativeWeightAdditive+=t}apply(t){const e=this.valueSize,i=this.buffer,n=t*e+e,s=this.cumulativeWeight,r=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const t=e*this._origIndex;this._mixBufferRegion(i,n,t,1-s,e)}r>0&&this._mixBufferRegionAdditive(i,n,this._addIndex*e,1,e);for(let o=e,l=e+e;o!==l;++o)if(i[o]!==i[o+e]){a.setValue(i,n);break}}saveOriginalState(){const t=this.binding,e=this.buffer,i=this.valueSize,n=i*this._origIndex;t.getValue(e,n);for(let s=i,r=n;s!==r;++s)e[s]=e[n+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=3*this.valueSize;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let i=t;i<e;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[e+i]=this.buffer[t+i]}_select(t,e,i,n,s){if(n>=.5)for(let r=0;r!==s;++r)t[e+r]=t[i+r]}_slerp(t,e,i,n){Ni.slerpFlat(t,e,t,e,t,i,n)}_slerpAdditive(t,e,i,n,s){const r=this._workIndex*s;Ni.multiplyQuaternionsFlat(t,r,t,e,t,i),Ni.slerpFlat(t,e,t,e,t,r,n)}_lerp(t,e,i,n,s){const r=1-n;for(let a=0;a!==s;++a){const s=e+a;t[s]=t[s]*r+t[i+a]*n}}_lerpAdditive(t,e,i,n,s){for(let r=0;r!==s;++r){const s=e+r;t[s]=t[s]+t[i+r]*n}}}const _d="\\[\\]\\.:\\/",vd=new RegExp("["+_d+"]","g"),yd="[^"+_d+"]",xd="[^"+_d.replace("\\.","")+"]",Md=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",yd)+/(WCOD+)?/.source.replace("WCOD",xd)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",yd)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",yd)+"$"),bd=["material","materials","bones","map"];class Sd{constructor(t,e,i){this.path=e,this.parsedPath=i||Sd.parseTrackName(e),this.node=Sd.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,i){return t&&t.isAnimationObjectGroup?new Sd.Composite(t,e,i):new Sd(t,e,i)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(vd,"")}static parseTrackName(t){const e=Md.exec(t);if(null===e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const i={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==n&&-1!==n){const t=i.nodeName.substring(n+1);-1!==bd.indexOf(t)&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=t)}if(null===i.propertyName||0===i.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return i}static findNode(t,e){if(void 0===e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const i=t.skeleton.getBoneByName(e);if(void 0!==i)return i}if(t.children){const i=function(t){for(let n=0;n<t.length;n++){const s=t[n];if(s.name===e||s.uuid===e)return s;const r=i(s.children);if(r)return r}return null},n=i(t.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)t[e++]=i[n]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=t[e++]}_setValue_array_setNeedsUpdate(t,e){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node;const e=this.parsedPath,i=e.objectName,n=e.propertyName;let s=e.propertyIndex;if(t||(t=Sd.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t)return;if(i){let n=e.objectIndex;switch(i){case"materials":if(!t.material)return;if(!t.material.materials)return;t=t.material.materials;break;case"bones":if(!t.skeleton)return;t=t.skeleton.bones;for(let e=0;e<t.length;e++)if(t[e].name===n){n=e;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material)return;if(!t.material.map)return;t=t.material.map;break;default:if(void 0===t[i])return;t=t[i]}if(void 0!==n){if(void 0===t[n])return;t=t[n]}}const r=t[n];if(void 0===r)return void e.nodeName;let a=this.Versioning.None;this.targetObject=t,void 0!==t.needsUpdate?a=this.Versioning.NeedsUpdate:void 0!==t.matrixWorldNeedsUpdate&&(a=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(void 0!==s){if("morphTargetInfluences"===n){if(!t.geometry)return;if(!t.geometry.morphAttributes)return;void 0!==t.morphTargetDictionary[s]&&(s=t.morphTargetDictionary[s])}o=this.BindingType.ArrayElement,this.resolvedProperty=r,this.propertyIndex=s}else void 0!==r.fromArray&&void 0!==r.toArray?(o=this.BindingType.HasFromToArray,this.resolvedProperty=r):Array.isArray(r)?(o=this.BindingType.EntireArray,this.resolvedProperty=r):this.propertyName=n;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Sd.Composite=class{constructor(t,e,i){const n=i||Sd.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,n)}getValue(t,e){this.bind();const i=this._targetGroup.nCachedObjects_,n=this._bindings[i];void 0!==n&&n.getValue(t,e)}setValue(t,e){const i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,s=i.length;n!==s;++n)i[n].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].unbind()}},Sd.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Sd.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Sd.prototype.GetterByBindingType=[Sd.prototype._getValue_direct,Sd.prototype._getValue_array,Sd.prototype._getValue_arrayElement,Sd.prototype._getValue_toArray],Sd.prototype.SetterByBindingTypeAndVersioning=[[Sd.prototype._setValue_direct,Sd.prototype._setValue_direct_setNeedsUpdate,Sd.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Sd.prototype._setValue_array,Sd.prototype._setValue_array_setNeedsUpdate,Sd.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Sd.prototype._setValue_arrayElement,Sd.prototype._setValue_arrayElement_setNeedsUpdate,Sd.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Sd.prototype._setValue_fromArray,Sd.prototype._setValue_fromArray_setNeedsUpdate,Sd.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class wd{constructor(t,e,i=null,n=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=i,this.blendMode=n;const s=e.tracks,r=s.length,a=new Array(r),o={endingStart:ge,endingEnd:ge};for(let l=0;l!==r;++l){const t=s[l].createInterpolant(null);a[l]=t,t.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(r),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,i){if(t.fadeOut(e),this.fadeIn(e),i){const i=this._clip.duration,n=t._clip.duration,s=n/i,r=i/n;t.warp(1,s,e),this.warp(r,1,e)}return this}crossFadeTo(t,e,i){return t.crossFadeFrom(this,e,i)}stopFading(){const t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,i){const n=this._mixer,s=n.time,r=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=n._lendControlInterpolant(),this._timeScaleInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=s,o[1]=s+i,l[0]=t/r,l[1]=e/r,this}stopWarping(){const t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,i,n){if(!this.enabled)return void this._updateWeight(t);const s=this._startTime;if(null!==s){const n=(t-s)*i;n<0||0===i?e=0:(this._startTime=null,e=i*n)}e*=this._updateTimeScale(t);const r=this._updateTime(e),a=this._updateWeight(t);if(a>0){const t=this._interpolants,e=this._propertyBindings;if(this.blendMode===ye)for(let i=0,n=t.length;i!==n;++i)t[i].evaluate(r),e[i].accumulateAdditive(a);else for(let i=0,s=t.length;i!==s;++i)t[i].evaluate(r),e[i].accumulate(n,a)}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const i=this._weightInterpolant;if(null!==i){const n=i.evaluate(t)[0];e*=n,t>i.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const i=this._timeScaleInterpolant;null!==i&&(e*=i.evaluate(t)[0],t>i.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e))}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,i=this.loop;let n=this.time+t,s=this._loopCount;const r=2202===i;if(0===t)return-1===s||!r||1&~s?n:e-n;if(2200===i){-1===s&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(n>=e)n=e;else{if(!(n<0)){this.time=n;break t}n=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===s&&(t>=0?(s=0,this._setEndings(!0,0===this.repetitions,r)):this._setEndings(0===this.repetitions,!0,r)),n>=e||n<0){const i=Math.floor(n/e);n-=e*i,s+=Math.abs(i);const a=this.repetitions-s;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=t>0?e:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===a){const e=t<0;this._setEndings(e,!e,r)}else this._setEndings(!1,!1,r);this._loopCount=s,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:i})}}else this.time=n;if(r&&!(1&~s))return e-n}return n}_setEndings(t,e,i){const n=this._interpolantSettings;i?(n.endingStart=_e,n.endingEnd=_e):(n.endingStart=t?this.zeroSlopeAtStart?_e:ge:ve,n.endingEnd=e?this.zeroSlopeAtEnd?_e:ge:ve)}_scheduleFading(t,e,i){const n=this._mixer,s=n.time;let r=this._weightInterpolant;null===r&&(r=n._lendControlInterpolant(),this._weightInterpolant=r);const a=r.parameterPositions,o=r.sampleValues;return a[0]=s,o[0]=e,a[1]=s+t,o[1]=i,this}}const Td=new Float32Array(1);class Ed{constructor(t){this.value=t}clone(){return new Ed(void 0===this.value.clone?this.value:this.value.clone())}}let Ad=0;function Cd(t,e){return t.distance-e.distance}function Rd(t,e,i,n){if(t.layers.test(e.layers)&&t.raycast(e,i),!0===n){const n=t.children;for(let t=0,s=n.length;t<s;t++)Rd(n[t],e,i,!0)}}const Pd=new ri,Ld=new Ui,Id=new Ui,Dd=new Ui,Nd=new Ui,Ud=new dn,Od=new dn;function Fd(t){const e=[];!0===t.isBone&&e.push(t);for(let i=0;i<t.children.length;i++)e.push.apply(e,Fd(t.children[i]));return e}const Bd=new Ui,zd=new ts,kd=new ts,Vd=new Ui,Gd=new Ui,Hd=new Ui,Wd=new Ui,qd=new Zs;function Xd(t,e,i,n,s,r,a){Wd.set(s,r,a).unproject(n);const o=e[t];if(void 0!==o){const t=i.getAttribute("position");for(let e=0,i=o.length;e<i;e++)t.setXYZ(o[e],Wd.x,Wd.y,Wd.z)}}const jd=new Bi,Yd=new Ui;let Zd,Jd;"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:O}})),"undefined"!=typeof window&&(window.__THREE__||(window.__THREE__=O));const Kd=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:4,AddEquation:k,AddOperation:2,AdditiveAnimationBlendMode:ye,AdditiveBlending:2,AgXToneMapping:6,AlphaFormat:1021,AlwaysCompare:519,AlwaysDepth:1,AlwaysStencilFunc:519,AmbientLight:Hu,AnimationAction:wd,AnimationClip:vu,AnimationLoader:class extends Su{constructor(t){super(t)}load(t,e,i,n){const s=this,r=new Eu(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(t,function(i){try{e(s.parse(JSON.parse(i)))}catch(r){n&&n(r),s.manager.itemError(t)}},i,n)}parse(t){const e=[];for(let i=0;i<t.length;i++){const n=vu.parse(t[i]);e.push(n)}return e}},AnimationMixer:class extends qe{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const i=t._localRoot||this._root,n=t._clip.tracks,s=n.length,r=t._propertyBindings,a=t._interpolants,o=i.uuid,l=this._bindingsByRootAndName;let h=l[o];void 0===h&&(h={},l[o]=h);for(let c=0;c!==s;++c){const t=n[c],s=t.name;let l=h[s];if(void 0!==l)++l.referenceCount,r[c]=l;else{if(l=r[c],void 0!==l){null===l._cacheIndex&&(++l.referenceCount,this._addInactiveBinding(l,o,s));continue}const n=e&&e._propertyBindings[c].binding.parsedPath;l=new gd(Sd.create(i,s,n),t.ValueTypeName,t.getValueSize()),++l.referenceCount,this._addInactiveBinding(l,o,s),r[c]=l}a[c].resultBuffer=l.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,i=t._clip.uuid,n=this._actionsByClip[i];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,i,e)}const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0===i.useCount++&&(this._lendBinding(i),i.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0===--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return null!==e&&e<this._nActiveActions}_addInactiveAction(t,e,i){const n=this._actions,s=this._actionsByClip;let r=s[e];if(void 0===r)r={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,s[e]=r;else{const e=r.knownActions;t._byClipCacheIndex=e.length,e.push(t)}t._cacheIndex=n.length,n.push(t),r.actionByRoot[i]=t}_removeInactiveAction(t){const e=this._actions,i=e[e.length-1],n=t._cacheIndex;i._cacheIndex=n,e[n]=i,e.pop(),t._cacheIndex=null;const s=t._clip.uuid,r=this._actionsByClip,a=r[s],o=a.knownActions,l=o[o.length-1],h=t._byClipCacheIndex;l._byClipCacheIndex=h,o[h]=l,o.pop(),t._byClipCacheIndex=null,delete a.actionByRoot[(t._localRoot||this._root).uuid],0===o.length&&delete r[s],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){const e=t._propertyBindings;for(let i=0,n=e.length;i!==n;++i){const t=e[i];0===--t.referenceCount&&this._removeInactiveBinding(t)}}_lendAction(t){const e=this._actions,i=t._cacheIndex,n=this._nActiveActions++,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_takeBackAction(t){const e=this._actions,i=t._cacheIndex,n=--this._nActiveActions,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_addInactiveBinding(t,e,i){const n=this._bindingsByRootAndName,s=this._bindings;let r=n[e];void 0===r&&(r={},n[e]=r),r[i]=t,t._cacheIndex=s.length,s.push(t)}_removeInactiveBinding(t){const e=this._bindings,i=t.binding,n=i.rootNode.uuid,s=i.path,r=this._bindingsByRootAndName,a=r[n],o=e[e.length-1],l=t._cacheIndex;o._cacheIndex=l,e[l]=o,e.pop(),delete a[s],0===Object.keys(a).length&&delete r[n]}_lendBinding(t){const e=this._bindings,i=t._cacheIndex,n=this._nActiveBindings++,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_takeBackBinding(t){const e=this._bindings,i=t._cacheIndex,n=--this._nActiveBindings,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_lendControlInterpolant(){const t=this._controlInterpolants,e=this._nActiveControlInterpolants++;let i=t[e];return void 0===i&&(i=new lu(new Float32Array(2),new Float32Array(2),1,Td),i.__cacheIndex=e,t[e]=i),i}_takeBackControlInterpolant(t){const e=this._controlInterpolants,i=t.__cacheIndex,n=--this._nActiveControlInterpolants,s=e[n];t.__cacheIndex=n,e[n]=t,s.__cacheIndex=i,e[i]=s}clipAction(t,e,i){const n=e||this._root,s=n.uuid;let r="string"==typeof t?vu.findByName(n,t):t;const a=null!==r?r.uuid:t,o=this._actionsByClip[a];let l=null;if(void 0===i&&(i=null!==r?r.blendMode:2500),void 0!==o){const t=o.actionByRoot[s];if(void 0!==t&&t.blendMode===i)return t;l=o.knownActions[0],null===r&&(r=l._clip)}if(null===r)return null;const h=new wd(this,r,e,i);return this._bindAction(h,l),this._addInactiveAction(h,a,s),h}existingAction(t,e){const i=e||this._root,n=i.uuid,s="string"==typeof t?vu.findByName(i,t):t,r=s?s.uuid:t,a=this._actionsByClip[r];return void 0!==a&&a.actionByRoot[n]||null}stopAllAction(){const t=this._actions;for(let e=this._nActiveActions-1;e>=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,i=this._nActiveActions,n=this.time+=t,s=Math.sign(t),r=this._accuIndex^=1;for(let l=0;l!==i;++l)e[l]._update(n,t,s,r);const a=this._bindings,o=this._nActiveBindings;for(let l=0;l!==o;++l)a[l].apply(r);return this}setTime(t){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){const e=this._actions,i=t.uuid,n=this._actionsByClip,s=n[i];if(void 0!==s){const t=s.knownActions;for(let i=0,n=t.length;i!==n;++i){const n=t[i];this._deactivateAction(n);const s=n._cacheIndex,r=e[e.length-1];n._cacheIndex=null,n._byClipCacheIndex=null,r._cacheIndex=s,e[s]=r,e.pop(),this._removeInactiveBindingsForAction(n)}delete n[i]}}uncacheRoot(t){const e=t.uuid,i=this._actionsByClip;for(const s in i){const t=i[s].actionByRoot[e];void 0!==t&&(this._deactivateAction(t),this._removeInactiveAction(t))}const n=this._bindingsByRootAndName[e];if(void 0!==n)for(const s in n){const t=n[s];t.restoreOriginalState(),this._removeInactiveBinding(t)}}uncacheAction(t,e){const i=this.existingAction(t,e);null!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}},AnimationObjectGroup:class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Je(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const t={};this._indicesByUUID=t;for(let i=0,n=arguments.length;i!==n;++i)t[arguments[i].uuid]=i;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}add(){const t=this._objects,e=this._indicesByUUID,i=this._paths,n=this._parsedPaths,s=this._bindings,r=s.length;let a,o=t.length,l=this.nCachedObjects_;for(let h=0,c=arguments.length;h!==c;++h){const c=arguments[h],u=c.uuid;let d=e[u];if(void 0===d){d=o++,e[u]=d,t.push(c);for(let t=0,e=r;t!==e;++t)s[t].push(new Sd(c,i[t],n[t]))}else if(d<l){a=t[d];const o=--l,h=t[o];e[h.uuid]=d,t[d]=h,e[u]=o,t[o]=c;for(let t=0,e=r;t!==e;++t){const e=s[t],r=e[o];let a=e[d];e[d]=r,void 0===a&&(a=new Sd(c,i[t],n[t])),e[o]=a}}else t[d]}this.nCachedObjects_=l}remove(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,n=i.length;let s=this.nCachedObjects_;for(let r=0,a=arguments.length;r!==a;++r){const a=arguments[r],o=a.uuid,l=e[o];if(void 0!==l&&l>=s){const r=s++,h=t[r];e[h.uuid]=l,t[l]=h,e[o]=r,t[r]=a;for(let t=0,e=n;t!==e;++t){const e=i[t],n=e[r],s=e[l];e[l]=n,e[r]=s}}}this.nCachedObjects_=s}uncache(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,n=i.length;let s=this.nCachedObjects_,r=t.length;for(let a=0,o=arguments.length;a!==o;++a){const o=arguments[a].uuid,l=e[o];if(void 0!==l)if(delete e[o],l<s){const a=--s,o=t[a],h=--r,c=t[h];e[o.uuid]=l,t[l]=o,e[c.uuid]=a,t[a]=c,t.pop();for(let t=0,e=n;t!==e;++t){const e=i[t],n=e[a],s=e[h];e[l]=n,e[a]=s,e.pop()}}else{const s=--r,a=t[s];s>0&&(e[a.uuid]=l),t[l]=a,t.pop();for(let t=0,e=n;t!==e;++t){const e=i[t];e[l]=e[s],e.pop()}}}this.nCachedObjects_=s}subscribe_(t,e){const i=this._bindingsIndicesByPath;let n=i[t];const s=this._bindings;if(void 0!==n)return s[n];const r=this._paths,a=this._parsedPaths,o=this._objects,l=o.length,h=this.nCachedObjects_,c=new Array(l);n=s.length,i[t]=n,r.push(t),a.push(e),s.push(c);for(let u=h,d=o.length;u!==d;++u){const i=o[u];c[u]=new Sd(i,t,e)}return c}unsubscribe_(t){const e=this._bindingsIndicesByPath,i=e[t];if(void 0!==i){const n=this._paths,s=this._parsedPaths,r=this._bindings,a=r.length-1,o=r[a];e[t[a]]=i,r[i]=o,r.pop(),s[i]=s[a],s.pop(),n[i]=n[a],n.pop()}}},AnimationUtils:ru,ArcCurve:wh,ArrayCamera:Oo,ArrowHelper:class extends Fn{constructor(t=new Ui(0,0,1),e=new Ui(0,0,0),i=1,n=16776960,s=.2*i,r=.2*s){super(),this.type="ArrowHelper",void 0===Zd&&(Zd=new Ss,Zd.setAttribute("position",new fs([0,0,0,0,1,0],3)),Jd=new jh(0,.5,1,5,1),Jd.translate(0,-.5,0)),this.position.copy(e),this.line=new hh(Zd,new nh({color:n,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Vs(Jd,new ss({color:n,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(i,s,r)}setDirection(t){if(t.y>.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{Yd.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(Yd,e)}}setLength(t,e=.2*t,i=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(i,e,i),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},AttachedBindMode:st,Audio:ud,AudioAnalyser:class{constructor(t,e=2048){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=e,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let t=0;const e=this.getFrequencyData();for(let i=0;i<e.length;i++)t+=e[i];return t/e.length}},AudioContext:ed,AudioListener:class extends Fn{constructor(){super(),this.type="AudioListener",this.context=ed.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new rd}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(od,ld,hd),cd.set(0,0,-1).applyQuaternion(ld),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(od.x,t),e.positionY.linearRampToValueAtTime(od.y,t),e.positionZ.linearRampToValueAtTime(od.z,t),e.forwardX.linearRampToValueAtTime(cd.x,t),e.forwardY.linearRampToValueAtTime(cd.y,t),e.forwardZ.linearRampToValueAtTime(cd.z,t),e.upX.linearRampToValueAtTime(i.x,t),e.upY.linearRampToValueAtTime(i.y,t),e.upZ.linearRampToValueAtTime(i.z,t)}else e.setPosition(od.x,od.y,od.z),e.setOrientation(cd.x,cd.y,cd.z,i.x,i.y,i.z)}},AudioLoader:class extends Su{constructor(t){super(t)}load(t,e,i,n){const s=this,r=new Eu(this.manager);function a(e){n&&n(e),s.manager.itemError(t)}r.setResponseType("arraybuffer"),r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(t,function(t){try{const i=t.slice(0);ed.getContext().decodeAudioData(i,function(t){e(t)}).catch(a)}catch(i){a(i)}},i,n)}},AxesHelper:class extends dh{constructor(t=1){const e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],i=new Ss;i.setAttribute("position",new fs(e,3)),i.setAttribute("color",new fs([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(i,new nh({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(t,e,i){const n=new ts,s=this.geometry.attributes.color.array;return n.set(t),n.toArray(s,0),n.toArray(s,3),n.set(e),n.toArray(s,6),n.toArray(s,9),n.set(i),n.toArray(s,12),n.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},BackSide:1,BasicDepthPacking:3200,BasicShadowMap:0,BatchedMesh:ih,Bone:El,BooleanKeyframeTrack:uu,Box2:class{constructor(t=new ri(1/0,1/0),e=new ri(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=Pd.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}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=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(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}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Pd).distanceTo(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}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)}},Box3:Bi,Box3Helper:class extends dh{constructor(t,e=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new Ss;n.setIndex(new ds(i,1)),n.setAttribute("position",new fs([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(n,new nh({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){const e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}},BoxGeometry:Hs,BoxHelper:class extends dh{constructor(t,e=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new Float32Array(24),s=new Ss;s.setIndex(new ds(i,1)),s.setAttribute("position",new ds(n,3)),super(s,new nh({color:e,toneMapped:!1})),this.object=t,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(t){if(void 0!==this.object&&jd.setFromObject(this.object),jd.isEmpty())return;const e=jd.min,i=jd.max,n=this.geometry.attributes.position,s=n.array;s[0]=i.x,s[1]=i.y,s[2]=i.z,s[3]=e.x,s[4]=i.y,s[5]=i.z,s[6]=e.x,s[7]=e.y,s[8]=i.z,s[9]=i.x,s[10]=e.y,s[11]=i.z,s[12]=i.x,s[13]=i.y,s[14]=e.z,s[15]=e.x,s[16]=i.y,s[17]=e.z,s[18]=e.x,s[19]=e.y,s[20]=e.z,s[21]=i.x,s[22]=e.y,s[23]=e.z,n.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(t){return this.object=t,this.update(),this}copy(t,e){return super.copy(t,e),this.object=t.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}},BufferAttribute:ds,BufferGeometry:Ss,BufferGeometryLoader:Ju,ByteType:1010,Cache:xu,Camera:Zs,CameraHelper:class extends dh{constructor(t){const e=new Ss,i=new nh({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],s=[],r={};function a(t,e){o(t),o(e)}function o(t){n.push(0,0,0),s.push(0,0,0),void 0===r[t]&&(r[t]=[]),r[t].push(n.length/3-1)}a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4"),e.setAttribute("position",new fs(n,3)),e.setAttribute("color",new fs(s,3)),super(e,i),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=r,this.update();const l=new ts(16755200),h=new ts(16711680),c=new ts(43775),u=new ts(16777215),d=new ts(3355443);this.setColors(l,h,c,u,d)}setColors(t,e,i,n,s){const r=this.geometry.getAttribute("color");r.setXYZ(0,t.r,t.g,t.b),r.setXYZ(1,t.r,t.g,t.b),r.setXYZ(2,t.r,t.g,t.b),r.setXYZ(3,t.r,t.g,t.b),r.setXYZ(4,t.r,t.g,t.b),r.setXYZ(5,t.r,t.g,t.b),r.setXYZ(6,t.r,t.g,t.b),r.setXYZ(7,t.r,t.g,t.b),r.setXYZ(8,t.r,t.g,t.b),r.setXYZ(9,t.r,t.g,t.b),r.setXYZ(10,t.r,t.g,t.b),r.setXYZ(11,t.r,t.g,t.b),r.setXYZ(12,t.r,t.g,t.b),r.setXYZ(13,t.r,t.g,t.b),r.setXYZ(14,t.r,t.g,t.b),r.setXYZ(15,t.r,t.g,t.b),r.setXYZ(16,t.r,t.g,t.b),r.setXYZ(17,t.r,t.g,t.b),r.setXYZ(18,t.r,t.g,t.b),r.setXYZ(19,t.r,t.g,t.b),r.setXYZ(20,t.r,t.g,t.b),r.setXYZ(21,t.r,t.g,t.b),r.setXYZ(22,t.r,t.g,t.b),r.setXYZ(23,t.r,t.g,t.b),r.setXYZ(24,e.r,e.g,e.b),r.setXYZ(25,e.r,e.g,e.b),r.setXYZ(26,e.r,e.g,e.b),r.setXYZ(27,e.r,e.g,e.b),r.setXYZ(28,e.r,e.g,e.b),r.setXYZ(29,e.r,e.g,e.b),r.setXYZ(30,e.r,e.g,e.b),r.setXYZ(31,e.r,e.g,e.b),r.setXYZ(32,i.r,i.g,i.b),r.setXYZ(33,i.r,i.g,i.b),r.setXYZ(34,i.r,i.g,i.b),r.setXYZ(35,i.r,i.g,i.b),r.setXYZ(36,i.r,i.g,i.b),r.setXYZ(37,i.r,i.g,i.b),r.setXYZ(38,n.r,n.g,n.b),r.setXYZ(39,n.r,n.g,n.b),r.setXYZ(40,s.r,s.g,s.b),r.setXYZ(41,s.r,s.g,s.b),r.setXYZ(42,s.r,s.g,s.b),r.setXYZ(43,s.r,s.g,s.b),r.setXYZ(44,s.r,s.g,s.b),r.setXYZ(45,s.r,s.g,s.b),r.setXYZ(46,s.r,s.g,s.b),r.setXYZ(47,s.r,s.g,s.b),r.setXYZ(48,s.r,s.g,s.b),r.setXYZ(49,s.r,s.g,s.b),r.needsUpdate=!0}update(){const t=this.geometry,e=this.pointMap;qd.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Xd("c",e,t,qd,0,0,-1),Xd("t",e,t,qd,0,0,1),Xd("n1",e,t,qd,-1,-1,-1),Xd("n2",e,t,qd,1,-1,-1),Xd("n3",e,t,qd,-1,1,-1),Xd("n4",e,t,qd,1,1,-1),Xd("f1",e,t,qd,-1,-1,1),Xd("f2",e,t,qd,1,-1,1),Xd("f3",e,t,qd,-1,1,1),Xd("f4",e,t,qd,1,1,1),Xd("u1",e,t,qd,.7,1.1,-1),Xd("u2",e,t,qd,-.7,1.1,-1),Xd("u3",e,t,qd,0,2,-1),Xd("cf1",e,t,qd,-1,0,1),Xd("cf2",e,t,qd,1,0,1),Xd("cf3",e,t,qd,0,-1,1),Xd("cf4",e,t,qd,0,1,1),Xd("cn1",e,t,qd,-1,0,-1),Xd("cn2",e,t,qd,1,0,-1),Xd("cn3",e,t,qd,0,-1,-1),Xd("cn4",e,t,qd,0,1,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},CanvasTexture:class extends Ci{constructor(t,e,i,n,s,r,a,o,l){super(t,e,i,n,s,r,a,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},CapsuleGeometry:qh,CatmullRomCurve3:Ph,CineonToneMapping:3,CircleGeometry:Xh,ClampToEdgeWrapping:pt,Clock:rd,Color:ts,ColorKeyframeTrack:du,ColorManagement:yi,CompressedArrayTexture:class extends Mh{constructor(t,e,i,n,s,r){super(t,e,i,s,r),this.isCompressedArrayTexture=!0,this.image.depth=n,this.wrapR=pt}},CompressedCubeTexture:class extends Mh{constructor(t,e,i){super(void 0,t[0].width,t[0].height,e,i,ot),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}},CompressedTexture:Mh,CompressedTextureLoader:class extends Su{constructor(t){super(t)}load(t,e,i,n){const s=this,r=[],a=new Mh,o=new Eu(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(s.withCredentials);let l=0;function h(h){o.load(t[h],function(t){const i=s.parse(t,!0);r[h]={width:i.width,height:i.height,format:i.format,mipmaps:i.mipmaps},l+=1,6===l&&(1===i.mipmapCount&&(a.minFilter=vt),a.image=r,a.format=i.format,a.needsUpdate=!0,e&&e(a))},i,n)}if(Array.isArray(t))for(let c=0,u=t.length;c<u;++c)h(c);else o.load(t,function(t){const i=s.parse(t,!0);if(i.isCubemap){const t=i.mipmaps.length/i.mipmapCount;for(let e=0;e<t;e++){r[e]={mipmaps:[]};for(let t=0;t<i.mipmapCount;t++)r[e].mipmaps.push(i.mipmaps[e*i.mipmapCount+t]),r[e].format=i.format,r[e].width=i.width,r[e].height=i.height}a.image=r}else a.image.width=i.width,a.image.height=i.height,a.mipmaps=i.mipmaps;1===i.mipmapCount&&(a.minFilter=vt),a.format=i.format,a.needsUpdate=!0,e&&e(a)},i,n);return a}},ConeGeometry:Yh,ConstantAlphaFactor:213,ConstantColorFactor:211,CubeCamera:$s,CubeReflectionMapping:ot,CubeRefractionMapping:lt,CubeTexture:Qs,CubeTextureLoader:class extends Su{constructor(t){super(t)}load(t,e,i,n){const s=new Qs;s.colorSpace=Se;const r=new Au(this.manager);r.setCrossOrigin(this.crossOrigin),r.setPath(this.path);let a=0;function o(i){r.load(t[i],function(t){s.images[i]=t,a++,6===a&&(s.needsUpdate=!0,e&&e(s))},void 0,n)}for(let l=0;l<t.length;++l)o(l);return s}},CubeUVReflectionMapping:ut,CubicBezierCurve:Nh,CubicBezierCurve3:Uh,CubicInterpolant:ou,CullFaceBack:1,CullFaceFront:2,CullFaceFrontBack:3,CullFaceNone:0,Curve:bh,CurvePath:Gh,CustomBlending:5,CustomToneMapping:5,CylinderGeometry:jh,Cylindrical:class{constructor(t=1,e=0,i=0){return this.radius=t,this.theta=e,this.y=i,this}set(t,e,i){return this.radius=t,this.theta=e,this.y=i,this}copy(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,i){return this.radius=Math.sqrt(t*t+i*i),this.theta=Math.atan2(t,i),this.y=e,this}clone(){return(new this.constructor).copy(this)}},Data3DTexture:Di,DataArrayTexture:Ii,DataTexture:Al,DataTextureLoader:class extends Su{constructor(t){super(t)}load(t,e,i,n){const s=this,r=new Al,a=new Eu(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(s.withCredentials),a.load(t,function(t){let i;try{i=s.parse(t)}catch(a){if(void 0===n)return;n(a)}void 0!==i.image?r.image=i.image:void 0!==i.data&&(r.image.width=i.width,r.image.height=i.height,r.image.data=i.data),r.wrapS=void 0!==i.wrapS?i.wrapS:pt,r.wrapT=void 0!==i.wrapT?i.wrapT:pt,r.magFilter=void 0!==i.magFilter?i.magFilter:vt,r.minFilter=void 0!==i.minFilter?i.minFilter:vt,r.anisotropy=void 0!==i.anisotropy?i.anisotropy:1,void 0!==i.colorSpace?r.colorSpace=i.colorSpace:void 0!==i.encoding&&(r.encoding=i.encoding),void 0!==i.flipY&&(r.flipY=i.flipY),void 0!==i.format&&(r.format=i.format),void 0!==i.type&&(r.type=i.type),void 0!==i.mipmaps&&(r.mipmaps=i.mipmaps,r.minFilter=xt),1===i.mipmapCount&&(r.minFilter=vt),void 0!==i.generateMipmaps&&(r.generateMipmaps=i.generateMipmaps),r.needsUpdate=!0,e&&e(r,i)},i,n),r}},DataUtils:hs,DecrementStencilOp:7683,DecrementWrapStencilOp:34056,DefaultLoadingManager:bu,DepthFormat:Lt,DepthStencilFormat:It,DepthTexture:qr,DetachedBindMode:rt,DirectionalLight:Gu,DirectionalLightHelper:class extends Fn{constructor(t,e,i){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",void 0===e&&(e=1);let n=new Ss;n.setAttribute("position",new fs([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));const s=new nh({fog:!1,toneMapped:!1});this.lightPlane=new hh(n,s),this.add(this.lightPlane),n=new Ss,n.setAttribute("position",new fs([0,0,0,0,0,1],3)),this.targetLine=new hh(n,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Vd.setFromMatrixPosition(this.light.matrixWorld),Gd.setFromMatrixPosition(this.light.target.matrixWorld),Hd.subVectors(Gd,Vd),this.lightPlane.lookAt(Gd),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Gd),this.targetLine.scale.z=Hd.length()}},DiscreteInterpolant:hu,DisplayP3ColorSpace:Te,DodecahedronGeometry:Jh,DoubleSide:2,DstAlphaFactor:206,DstColorFactor:208,DynamicCopyUsage:35050,DynamicDrawUsage:35048,DynamicReadUsage:35049,EdgesGeometry:ec,EllipseCurve:Sh,EqualCompare:514,EqualDepth:4,EqualStencilFunc:514,EquirectangularReflectionMapping:ht,EquirectangularRefractionMapping:ct,Euler:bn,EventDispatcher:qe,ExtrudeGeometry:Pc,FileLoader:Eu,Float16BufferAttribute:class extends ds{constructor(t,e,i){super(new Uint16Array(t),e,i),this.isFloat16BufferAttribute=!0}getX(t){let e=ls(this.array[t*this.itemSize]);return this.normalized&&(e=ii(e,this.array)),e}setX(t,e){return this.normalized&&(e=ni(e,this.array)),this.array[t*this.itemSize]=os(e),this}getY(t){let e=ls(this.array[t*this.itemSize+1]);return this.normalized&&(e=ii(e,this.array)),e}setY(t,e){return this.normalized&&(e=ni(e,this.array)),this.array[t*this.itemSize+1]=os(e),this}getZ(t){let e=ls(this.array[t*this.itemSize+2]);return this.normalized&&(e=ii(e,this.array)),e}setZ(t,e){return this.normalized&&(e=ni(e,this.array)),this.array[t*this.itemSize+2]=os(e),this}getW(t){let e=ls(this.array[t*this.itemSize+3]);return this.normalized&&(e=ii(e,this.array)),e}setW(t,e){return this.normalized&&(e=ni(e,this.array)),this.array[t*this.itemSize+3]=os(e),this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=ni(e,this.array),i=ni(i,this.array)),this.array[t+0]=os(e),this.array[t+1]=os(i),this}setXYZ(t,e,i,n){return t*=this.itemSize,this.normalized&&(e=ni(e,this.array),i=ni(i,this.array),n=ni(n,this.array)),this.array[t+0]=os(e),this.array[t+1]=os(i),this.array[t+2]=os(n),this}setXYZW(t,e,i,n,s){return t*=this.itemSize,this.normalized&&(e=ni(e,this.array),i=ni(i,this.array),n=ni(n,this.array),s=ni(s,this.array)),this.array[t+0]=os(e),this.array[t+1]=os(i),this.array[t+2]=os(n),this.array[t+3]=os(s),this}},Float32BufferAttribute:fs,Float64BufferAttribute:class extends ds{constructor(t,e,i){super(new Float64Array(t),e,i)}},FloatType:Tt,Fog:Xo,FogExp2:qo,FramebufferTexture:class extends Ci{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=ft,this.minFilter=ft,this.generateMipmaps=!1,this.needsUpdate=!0}},FrontSide:0,Frustum:or,GLBufferAttribute:class{constructor(t,e,i,n,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=t,this.type=e,this.itemSize=i,this.elementSize=n,this.count=s,this.version=0}set needsUpdate(t){!0===t&&this.version++}setBuffer(t){return this.buffer=t,this}setType(t,e){return this.type=t,this.elementSize=e,this}setItemSize(t){return this.itemSize=t,this}setCount(t){return this.count=t,this}},GLSL1:"100",GLSL3:Ve,GreaterCompare:516,GreaterDepth:6,GreaterEqualCompare:518,GreaterEqualDepth:5,GreaterEqualStencilFunc:518,GreaterStencilFunc:516,GridHelper:class extends dh{constructor(t=10,e=10,i=4473924,n=8947848){i=new ts(i),n=new ts(n);const s=e/2,r=t/e,a=t/2,o=[],l=[];for(let c=0,u=0,d=-a;c<=e;c++,d+=r){o.push(-a,0,d,a,0,d),o.push(d,0,-a,d,0,a);const t=c===s?i:n;t.toArray(l,u),u+=3,t.toArray(l,u),u+=3,t.toArray(l,u),u+=3,t.toArray(l,u),u+=3}const h=new Ss;h.setAttribute("position",new fs(o,3)),h.setAttribute("color",new fs(l,3)),super(h,new nh({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},Group:Fo,HalfFloatType:Et,HemisphereLight:Ru,HemisphereLightHelper:class extends Fn{constructor(t,e,i){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";const n=new Dc(e);n.rotateY(.5*Math.PI),this.material=new ss({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const s=n.getAttribute("position"),r=new Float32Array(3*s.count);n.setAttribute("color",new ds(r,3)),this.add(new Vs(n,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const t=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const e=t.geometry.getAttribute("color");zd.copy(this.light.color),kd.copy(this.light.groundColor);for(let t=0,i=e.count;t<i;t++){const n=t<i/2?zd:kd;e.setXYZ(t,n.r,n.g,n.b)}e.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),t.lookAt(Bd.setFromMatrixPosition(this.light.matrixWorld).negate())}},IcosahedronGeometry:Ic,ImageBitmapLoader:class extends Su{constructor(t){super(t),this.isImageBitmapLoader=!0,this.options={premultiplyAlpha:"none"}}setOptions(t){return this.options=t,this}load(t,e,i,n){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,r=xu.get(t);if(void 0!==r)return s.manager.itemStart(t),r.then?void r.then(i=>{e&&e(i),s.manager.itemEnd(t)}).catch(t=>{n&&n(t)}):(setTimeout(function(){e&&e(r),s.manager.itemEnd(t)},0),r);const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader;const o=fetch(t,a).then(function(t){return t.blob()}).then(function(t){return createImageBitmap(t,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(i){return xu.add(t,i),e&&e(i),s.manager.itemEnd(t),i}).catch(function(e){n&&n(e),xu.remove(t),s.manager.itemError(t),s.manager.itemEnd(t)});xu.add(t,o),s.manager.itemStart(t)}},ImageLoader:Au,ImageUtils:Si,IncrementStencilOp:7682,IncrementWrapStencilOp:34055,InstancedBufferAttribute:Ll,InstancedBufferGeometry:Zu,InstancedInterleavedBuffer:class extends Yo{constructor(t,e,i=1){super(t,e),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}clone(t){const e=super.clone(t);return e.meshPerAttribute=this.meshPerAttribute,e}toJSON(t){const e=super.toJSON(t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}},InstancedMesh:zl,Int16BufferAttribute:class extends ds{constructor(t,e,i){super(new Int16Array(t),e,i)}},Int32BufferAttribute:class extends ds{constructor(t,e,i){super(new Int32Array(t),e,i)}},Int8BufferAttribute:class extends ds{constructor(t,e,i){super(new Int8Array(t),e,i)}},IntType:St,InterleavedBuffer:Yo,InterleavedBufferAttribute:Jo,Interpolant:au,InterpolateDiscrete:pe,InterpolateLinear:me,InterpolateSmooth:fe,InvertStencilOp:5386,KeepStencilOp:Le,KeyframeTrack:cu,LOD:fl,LatheGeometry:Wh,Layers:Sn,LessCompare:513,LessDepth:2,LessEqualCompare:515,LessEqualDepth:3,LessEqualStencilFunc:515,LessStencilFunc:513,Light:Cu,LightProbe:Xu,Line:hh,Line3:class{constructor(t=new Ui,e=new Ui){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){Ld.subVectors(t,this.start),Id.subVectors(this.end,this.start);const i=Id.dot(Id);let n=Id.dot(Ld)/i;return e&&(n=Ke(n,0,1)),n}closestPointToPoint(t,e,i){const n=this.closestPointToPointParameter(t,e);return this.delta(i).multiplyScalar(n).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}},LineBasicMaterial:nh,LineCurve:Oh,LineCurve3:Fh,LineDashedMaterial:Qc,LineLoop:ph,LineSegments:dh,LinearDisplayP3ColorSpace:Ee,LinearEncoding:xe,LinearFilter:vt,LinearInterpolant:lu,LinearMipMapLinearFilter:1008,LinearMipMapNearestFilter:1007,LinearMipmapLinearFilter:xt,LinearMipmapNearestFilter:yt,LinearSRGBColorSpace:we,LinearToneMapping:1,LinearTransfer:Ae,Loader:Su,LoaderUtils:Yu,LoadingManager:Mu,LoopOnce:2200,LoopPingPong:2202,LoopRepeat:2201,LuminanceAlphaFormat:1025,LuminanceFormat:1024,MOUSE:{LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Material:ns,MaterialLoader:ju,MathUtils:si,Matrix3:ai,Matrix4:dn,MaxEquation:104,Mesh:Vs,MeshBasicMaterial:ss,MeshDepthMaterial:Po,MeshDistanceMaterial:Lo,MeshLambertMaterial:Kc,MeshMatcapMaterial:$c,MeshNormalMaterial:Jc,MeshPhongMaterial:Yc,MeshPhysicalMaterial:jc,MeshStandardMaterial:Xc,MeshToonMaterial:Zc,MinEquation:103,MirroredRepeatWrapping:mt,MixOperation:1,MultiplyBlending:4,MultiplyOperation:0,NearestFilter:ft,NearestMipMapLinearFilter:1005,NearestMipMapNearestFilter:1004,NearestMipmapLinearFilter:_t,NearestMipmapNearestFilter:gt,NeverCompare:512,NeverDepth:0,NeverStencilFunc:512,NoBlending:0,NoColorSpace:be,NoToneMapping:0,NormalAnimationBlendMode:2500,NormalBlending:1,NotEqualCompare:517,NotEqualDepth:7,NotEqualStencilFunc:517,NumberKeyframeTrack:pu,Object3D:Fn,ObjectLoader:class extends Su{constructor(t){super(t)}load(t,e,i,n){const s=this,r=""===this.path?Yu.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||r;const a=new Eu(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(i){let r=null;try{r=JSON.parse(i)}catch(o){return void(void 0!==n&&n(o))}const a=r.metadata;void 0!==a&&void 0!==a.type&&"geometry"!==a.type.toLowerCase()?s.parse(r,e):void 0!==n&&n(new Error("THREE.ObjectLoader: Can't load "+t))},i,n)}async loadAsync(t,e){const i=""===this.path?Yu.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||i;const n=new Eu(this.manager);n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials);const s=await n.loadAsync(t,e),r=JSON.parse(s),a=r.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())throw new Error("THREE.ObjectLoader: Can't load "+t);return await this.parseAsync(r)}parse(t,e){const i=this.parseAnimations(t.animations),n=this.parseShapes(t.shapes),s=this.parseGeometries(t.geometries,n),r=this.parseImages(t.images,function(){void 0!==e&&e(l)}),a=this.parseTextures(t.textures,r),o=this.parseMaterials(t.materials,a),l=this.parseObject(t.object,s,o,a,i),h=this.parseSkeletons(t.skeletons,l);if(this.bindSkeletons(l,h),void 0!==e){let t=!1;for(const e in r)if(r[e].data instanceof HTMLImageElement){t=!0;break}!1===t&&e(l)}return l}async parseAsync(t){const e=this.parseAnimations(t.animations),i=this.parseShapes(t.shapes),n=this.parseGeometries(t.geometries,i),s=await this.parseImagesAsync(t.images),r=this.parseTextures(t.textures,s),a=this.parseMaterials(t.materials,r),o=this.parseObject(t.object,n,a,r,e),l=this.parseSkeletons(t.skeletons,o);return this.bindSkeletons(o,l),o}parseShapes(t){const e={};if(void 0!==t)for(let i=0,n=t.length;i<n;i++){const n=(new ic).fromJSON(t[i]);e[n.uuid]=n}return e}parseSkeletons(t,e){const i={},n={};if(e.traverse(function(t){t.isBone&&(n[t.uuid]=t)}),void 0!==t)for(let s=0,r=t.length;s<r;s++){const e=(new Pl).fromJSON(t[s],n);i[e.uuid]=e}return i}parseGeometries(t,e){const i={};if(void 0!==t){const n=new Ju;for(let s=0,r=t.length;s<r;s++){let r;const a=t[s];switch(a.type){case"BufferGeometry":case"InstancedBufferGeometry":r=n.parse(a);break;default:a.type in Hc&&(r=Hc[a.type].fromJSON(a,e))}r.uuid=a.uuid,void 0!==a.name&&(r.name=a.name),void 0!==a.userData&&(r.userData=a.userData),i[a.uuid]=r}}return i}parseMaterials(t,e){const i={},n={};if(void 0!==t){const s=new ju;s.setTextures(e);for(let e=0,r=t.length;e<r;e++){const r=t[e];void 0===i[r.uuid]&&(i[r.uuid]=s.parse(r)),n[r.uuid]=i[r.uuid]}}return n}parseAnimations(t){const e={};if(void 0!==t)for(let i=0;i<t.length;i++){const n=t[i],s=vu.parse(n);e[s.uuid]=s}return e}parseImages(t,e){const i=this,n={};let s;function r(t){if("string"==typeof t){const e=t;return function(t){return i.manager.itemStart(t),s.load(t,function(){i.manager.itemEnd(t)},void 0,function(){i.manager.itemError(t),i.manager.itemEnd(t)})}(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(e)?e:i.resourcePath+e)}return t.data?{data:ci(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){const i=new Mu(e);s=new Au(i),s.setCrossOrigin(this.crossOrigin);for(let e=0,s=t.length;e<s;e++){const i=t[e],s=i.url;if(Array.isArray(s)){const t=[];for(let e=0,i=s.length;e<i;e++){const i=r(s[e]);null!==i&&(i instanceof HTMLImageElement?t.push(i):t.push(new Al(i.data,i.width,i.height)))}n[i.uuid]=new Ti(t)}else{const t=r(i.url);n[i.uuid]=new Ti(t)}}}return n}async parseImagesAsync(t){const e=this,i={};let n;async function s(t){if("string"==typeof t){const i=t,s=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(i)?i:e.resourcePath+i;return await n.loadAsync(s)}return t.data?{data:ci(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){n=new Au(this.manager),n.setCrossOrigin(this.crossOrigin);for(let e=0,n=t.length;e<n;e++){const n=t[e],r=n.url;if(Array.isArray(r)){const t=[];for(let e=0,i=r.length;e<i;e++){const i=r[e],n=await s(i);null!==n&&(n instanceof HTMLImageElement?t.push(n):t.push(new Al(n.data,n.width,n.height)))}i[n.uuid]=new Ti(t)}else{const t=await s(n.url);i[n.uuid]=new Ti(t)}}}return i}parseTextures(t,e){function i(t,e){return"number"==typeof t?t:e[t]}const n={};if(void 0!==t)for(let s=0,r=t.length;s<r;s++){const r=t[s];r.image,e[r.image];const a=e[r.image],o=a.data;let l;Array.isArray(o)?(l=new Qs,6===o.length&&(l.needsUpdate=!0)):(l=o&&o.data?new Al:new Ci,o&&(l.needsUpdate=!0)),l.source=a,l.uuid=r.uuid,void 0!==r.name&&(l.name=r.name),void 0!==r.mapping&&(l.mapping=i(r.mapping,Ku)),void 0!==r.channel&&(l.channel=r.channel),void 0!==r.offset&&l.offset.fromArray(r.offset),void 0!==r.repeat&&l.repeat.fromArray(r.repeat),void 0!==r.center&&l.center.fromArray(r.center),void 0!==r.rotation&&(l.rotation=r.rotation),void 0!==r.wrap&&(l.wrapS=i(r.wrap[0],$u),l.wrapT=i(r.wrap[1],$u)),void 0!==r.format&&(l.format=r.format),void 0!==r.internalFormat&&(l.internalFormat=r.internalFormat),void 0!==r.type&&(l.type=r.type),void 0!==r.colorSpace&&(l.colorSpace=r.colorSpace),void 0!==r.encoding&&(l.encoding=r.encoding),void 0!==r.minFilter&&(l.minFilter=i(r.minFilter,Qu)),void 0!==r.magFilter&&(l.magFilter=i(r.magFilter,Qu)),void 0!==r.anisotropy&&(l.anisotropy=r.anisotropy),void 0!==r.flipY&&(l.flipY=r.flipY),void 0!==r.generateMipmaps&&(l.generateMipmaps=r.generateMipmaps),void 0!==r.premultiplyAlpha&&(l.premultiplyAlpha=r.premultiplyAlpha),void 0!==r.unpackAlignment&&(l.unpackAlignment=r.unpackAlignment),void 0!==r.compareFunction&&(l.compareFunction=r.compareFunction),void 0!==r.userData&&(l.userData=r.userData),n[r.uuid]=l}return n}parseObject(t,e,i,n,s){let r,a,o;function l(t){return e[t],e[t]}function h(t){if(void 0!==t){if(Array.isArray(t)){const e=[];for(let n=0,s=t.length;n<s;n++){const s=t[n];i[s],e.push(i[s])}return e}return i[t],i[t]}}function c(t){return n[t],n[t]}switch(t.type){case"Scene":r=new jo,void 0!==t.background&&(Number.isInteger(t.background)?r.background=new ts(t.background):r.background=c(t.background)),void 0!==t.environment&&(r.environment=c(t.environment)),void 0!==t.fog&&("Fog"===t.fog.type?r.fog=new Xo(t.fog.color,t.fog.near,t.fog.far):"FogExp2"===t.fog.type&&(r.fog=new qo(t.fog.color,t.fog.density)),""!==t.fog.name&&(r.fog.name=t.fog.name)),void 0!==t.backgroundBlurriness&&(r.backgroundBlurriness=t.backgroundBlurriness),void 0!==t.backgroundIntensity&&(r.backgroundIntensity=t.backgroundIntensity);break;case"PerspectiveCamera":r=new Js(t.fov,t.aspect,t.near,t.far),void 0!==t.focus&&(r.focus=t.focus),void 0!==t.zoom&&(r.zoom=t.zoom),void 0!==t.filmGauge&&(r.filmGauge=t.filmGauge),void 0!==t.filmOffset&&(r.filmOffset=t.filmOffset),void 0!==t.view&&(r.view=Object.assign({},t.view));break;case"OrthographicCamera":r=new Mr(t.left,t.right,t.top,t.bottom,t.near,t.far),void 0!==t.zoom&&(r.zoom=t.zoom),void 0!==t.view&&(r.view=Object.assign({},t.view));break;case"AmbientLight":r=new Hu(t.color,t.intensity);break;case"DirectionalLight":r=new Gu(t.color,t.intensity);break;case"PointLight":r=new ku(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":r=new Wu(t.color,t.intensity,t.width,t.height);break;case"SpotLight":r=new Uu(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay);break;case"HemisphereLight":r=new Ru(t.color,t.groundColor,t.intensity);break;case"LightProbe":r=(new Xu).fromJSON(t);break;case"SkinnedMesh":a=l(t.geometry),o=h(t.material),r=new Tl(a,o),void 0!==t.bindMode&&(r.bindMode=t.bindMode),void 0!==t.bindMatrix&&r.bindMatrix.fromArray(t.bindMatrix),void 0!==t.skeleton&&(r.skeleton=t.skeleton);break;case"Mesh":a=l(t.geometry),o=h(t.material),r=new Vs(a,o);break;case"InstancedMesh":a=l(t.geometry),o=h(t.material);const e=t.count,i=t.instanceMatrix,n=t.instanceColor;r=new zl(a,o,e),r.instanceMatrix=new Ll(new Float32Array(i.array),16),void 0!==n&&(r.instanceColor=new Ll(new Float32Array(n.array),n.itemSize));break;case"BatchedMesh":a=l(t.geometry),o=h(t.material),r=new ih(t.maxGeometryCount,t.maxVertexCount,t.maxIndexCount,o),r.geometry=a,r.perObjectFrustumCulled=t.perObjectFrustumCulled,r.sortObjects=t.sortObjects,r._drawRanges=t.drawRanges,r._reservedRanges=t.reservedRanges,r._visibility=t.visibility,r._active=t.active,r._bounds=t.bounds.map(t=>{const e=new Bi;e.min.fromArray(t.boxMin),e.max.fromArray(t.boxMax);const i=new nn;return i.radius=t.sphereRadius,i.center.fromArray(t.sphereCenter),{boxInitialized:t.boxInitialized,box:e,sphereInitialized:t.sphereInitialized,sphere:i}}),r._maxGeometryCount=t.maxGeometryCount,r._maxVertexCount=t.maxVertexCount,r._maxIndexCount=t.maxIndexCount,r._geometryInitialized=t.geometryInitialized,r._geometryCount=t.geometryCount,r._matricesTexture=c(t.matricesTexture.uuid);break;case"LOD":r=new fl;break;case"Line":r=new hh(l(t.geometry),h(t.material));break;case"LineLoop":r=new ph(l(t.geometry),h(t.material));break;case"LineSegments":r=new dh(l(t.geometry),h(t.material));break;case"PointCloud":case"Points":r=new yh(l(t.geometry),h(t.material));break;case"Sprite":r=new ul(h(t.material));break;case"Group":r=new Fo;break;case"Bone":r=new El;break;default:r=new Fn}if(r.uuid=t.uuid,void 0!==t.name&&(r.name=t.name),void 0!==t.matrix?(r.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(r.matrixAutoUpdate=t.matrixAutoUpdate),r.matrixAutoUpdate&&r.matrix.decompose(r.position,r.quaternion,r.scale)):(void 0!==t.position&&r.position.fromArray(t.position),void 0!==t.rotation&&r.rotation.fromArray(t.rotation),void 0!==t.quaternion&&r.quaternion.fromArray(t.quaternion),void 0!==t.scale&&r.scale.fromArray(t.scale)),void 0!==t.up&&r.up.fromArray(t.up),void 0!==t.castShadow&&(r.castShadow=t.castShadow),void 0!==t.receiveShadow&&(r.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.bias&&(r.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(r.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(r.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&r.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(r.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(r.visible=t.visible),void 0!==t.frustumCulled&&(r.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(r.renderOrder=t.renderOrder),void 0!==t.userData&&(r.userData=t.userData),void 0!==t.layers&&(r.layers.mask=t.layers),void 0!==t.children){const a=t.children;for(let t=0;t<a.length;t++)r.add(this.parseObject(a[t],e,i,n,s))}if(void 0!==t.animations){const e=t.animations;for(let t=0;t<e.length;t++){const i=e[t];r.animations.push(s[i])}}if("LOD"===t.type){void 0!==t.autoUpdate&&(r.autoUpdate=t.autoUpdate);const e=t.levels;for(let t=0;t<e.length;t++){const i=e[t],n=r.getObjectByProperty("uuid",i.object);void 0!==n&&r.addLevel(n,i.distance,i.hysteresis)}}return r}bindSkeletons(t,e){0!==Object.keys(e).length&&t.traverse(function(t){if(!0===t.isSkinnedMesh&&void 0!==t.skeleton){const i=e[t.skeleton];void 0===i||t.bind(i,t.bindMatrix)}})}},ObjectSpaceNormalMap:1,OctahedronGeometry:Dc,OneFactor:201,OneMinusConstantAlphaFactor:214,OneMinusConstantColorFactor:212,OneMinusDstAlphaFactor:207,OneMinusDstColorFactor:209,OneMinusSrcAlphaFactor:Y,OneMinusSrcColorFactor:203,OrthographicCamera:Mr,P3Primaries:Pe,PCFShadowMap:1,PCFSoftShadowMap:2,PMREMGenerator:Lr,Path:Hh,PerspectiveCamera:Js,Plane:sr,PlaneGeometry:cr,PlaneHelper:class extends hh{constructor(t,e=1,i=16776960){const n=i,s=new Ss;s.setAttribute("position",new fs([1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),s.computeBoundingSphere(),super(s,new nh({color:n,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e;const r=new Ss;r.setAttribute("position",new fs([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),r.computeBoundingSphere(),this.add(new Vs(r,new ss({color:n,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(t){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(t)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}},PointLight:ku,PointLightHelper:class extends Vs{constructor(t,e,i){super(new Oc(e,4,2),new ss({wireframe:!0,fog:!1,toneMapped:!1})),this.light=t,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},Points:yh,PointsMaterial:mh,PolarGridHelper:class extends dh{constructor(t=10,e=16,i=8,n=64,s=4473924,r=8947848){s=new ts(s),r=new ts(r);const a=[],o=[];if(e>1)for(let h=0;h<e;h++){const i=h/e*2*Math.PI,n=Math.sin(i)*t,l=Math.cos(i)*t;a.push(0,0,0),a.push(n,0,l);const c=1&h?s:r;o.push(c.r,c.g,c.b),o.push(c.r,c.g,c.b)}for(let h=0;h<i;h++){const e=1&h?s:r,l=t-t/i*h;for(let t=0;t<n;t++){let i=t/n*2*Math.PI,s=Math.sin(i)*l,r=Math.cos(i)*l;a.push(s,0,r),o.push(e.r,e.g,e.b),i=(t+1)/n*2*Math.PI,s=Math.sin(i)*l,r=Math.cos(i)*l,a.push(s,0,r),o.push(e.r,e.g,e.b)}}const l=new Ss;l.setAttribute("position",new fs(a,3)),l.setAttribute("color",new fs(o,3)),super(l,new nh({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},PolyhedronGeometry:Zh,PositionalAudio:class extends ud{constructor(t){super(t),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(t){return this.panner.refDistance=t,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(t){return this.panner.rolloffFactor=t,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(t){return this.panner.distanceModel=t,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(t){return this.panner.maxDistance=t,this}setDirectionalCone(t,e,i){return this.panner.coneInnerAngle=t,this.panner.coneOuterAngle=e,this.panner.coneOuterGain=i,this}updateMatrixWorld(t){if(super.updateMatrixWorld(t),!0===this.hasPlaybackControl&&!1===this.isPlaying)return;this.matrixWorld.decompose(dd,pd,md),fd.set(0,0,1).applyQuaternion(pd);const e=this.panner;if(e.positionX){const t=this.context.currentTime+this.listener.timeDelta;e.positionX.linearRampToValueAtTime(dd.x,t),e.positionY.linearRampToValueAtTime(dd.y,t),e.positionZ.linearRampToValueAtTime(dd.z,t),e.orientationX.linearRampToValueAtTime(fd.x,t),e.orientationY.linearRampToValueAtTime(fd.y,t),e.orientationZ.linearRampToValueAtTime(fd.z,t)}else e.setPosition(dd.x,dd.y,dd.z),e.setOrientation(fd.x,fd.y,fd.z)}},PropertyBinding:Sd,PropertyMixer:gd,QuadraticBezierCurve:Bh,QuadraticBezierCurve3:zh,Quaternion:Ni,QuaternionKeyframeTrack:fu,QuaternionLinearInterpolant:mu,RED_GREEN_RGTC2_Format:ue,RED_RGTC1_Format:36283,REVISION:O,RGBADepthPacking:3201,RGBAFormat:Pt,RGBAIntegerFormat:Ut,RGBA_ASTC_10x10_Format:se,RGBA_ASTC_10x5_Format:ee,RGBA_ASTC_10x6_Format:ie,RGBA_ASTC_10x8_Format:ne,RGBA_ASTC_12x10_Format:re,RGBA_ASTC_12x12_Format:ae,RGBA_ASTC_4x4_Format:jt,RGBA_ASTC_5x4_Format:Yt,RGBA_ASTC_5x5_Format:Zt,RGBA_ASTC_6x5_Format:Jt,RGBA_ASTC_6x6_Format:Kt,RGBA_ASTC_8x5_Format:$t,RGBA_ASTC_8x6_Format:Qt,RGBA_ASTC_8x8_Format:te,RGBA_BPTC_Format:oe,RGBA_ETC2_EAC_Format:Xt,RGBA_PVRTC_2BPPV1_Format:Ht,RGBA_PVRTC_4BPPV1_Format:Gt,RGBA_S3TC_DXT1_Format:Ft,RGBA_S3TC_DXT3_Format:Bt,RGBA_S3TC_DXT5_Format:zt,RGB_BPTC_SIGNED_Format:le,RGB_BPTC_UNSIGNED_Format:he,RGB_ETC1_Format:Wt,RGB_ETC2_Format:qt,RGB_PVRTC_2BPPV1_Format:Vt,RGB_PVRTC_4BPPV1_Format:kt,RGB_S3TC_DXT1_Format:Ot,RGFormat:1030,RGIntegerFormat:Nt,RawShaderMaterial:qc,Ray:un,Raycaster:class{constructor(t,e,i=0,n=1/0){this.ray=new un(t,e),this.near=i,this.far=n,this.camera=null,this.layers=new Sn,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)}intersectObject(t,e=!0,i=[]){return Rd(t,this,i,e),i.sort(Cd),i}intersectObjects(t,e=!0,i=[]){for(let n=0,s=t.length;n<s;n++)Rd(t[n],this,i,e);return i.sort(Cd),i}},Rec709Primaries:Re,RectAreaLight:Wu,RedFormat:1028,RedIntegerFormat:Dt,ReinhardToneMapping:2,RenderTarget:Pi,RepeatWrapping:dt,ReplaceStencilOp:7681,ReverseSubtractEquation:102,RingGeometry:Nc,SIGNED_RED_GREEN_RGTC2_Format:de,SIGNED_RED_RGTC1_Format:ce,SRGBColorSpace:Se,SRGBTransfer:Ce,Scene:jo,ShaderChunk:ur,ShaderLib:pr,ShaderMaterial:Ys,ShadowMaterial:Wc,Shape:ic,ShapeGeometry:Uc,ShapePath:class{constructor(){this.type="ShapePath",this.color=new ts,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new Hh,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,i,n){return this.currentPath.quadraticCurveTo(t,e,i,n),this}bezierCurveTo(t,e,i,n,s,r){return this.currentPath.bezierCurveTo(t,e,i,n,s,r),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(t,e){const i=e.length;let n=!1;for(let s=i-1,r=0;r<i;s=r++){let i=e[s],a=e[r],o=a.x-i.x,l=a.y-i.y;if(Math.abs(l)>Number.EPSILON){if(l<0&&(i=e[r],o=-o,a=e[s],l=-l),t.y<i.y||t.y>a.y)continue;if(t.y===i.y){if(t.x===i.x)return!0}else{const e=l*(t.x-i.x)-o*(t.y-i.y);if(0===e)return!0;if(e<0)continue;n=!n}}else{if(t.y!==i.y)continue;if(a.x<=t.x&&t.x<=i.x||i.x<=t.x&&t.x<=a.x)return!0}}return n}const i=Ac.isClockWise,n=this.subPaths;if(0===n.length)return[];let s,r,a;const o=[];if(1===n.length)return r=n[0],a=new ic,a.curves=r.curves,o.push(a),o;let l=!i(n[0].getPoints());l=t?!l:l;const h=[],c=[];let u,d,p=[],m=0;c[m]=void 0,p[m]=[];for(let f=0,g=n.length;f<g;f++)r=n[f],u=r.getPoints(),s=i(u),s=t?!s:s,s?(!l&&c[m]&&m++,c[m]={s:new ic,p:u},c[m].s.curves=r.curves,l&&m++,p[m]=[]):p[m].push({h:r,p:u[0]});if(!c[0])return function(t){const e=[];for(let i=0,n=t.length;i<n;i++){const n=t[i],s=new ic;s.curves=n.curves,e.push(s)}return e}(n);if(c.length>1){let t=!1,i=0;for(let e=0,n=c.length;e<n;e++)h[e]=[];for(let n=0,s=c.length;n<s;n++){const s=p[n];for(let r=0;r<s.length;r++){const a=s[r];let o=!0;for(let s=0;s<c.length;s++)e(a.p,c[s].p)&&(n!==s&&i++,o?(o=!1,h[s].push(a)):t=!0);o&&h[n].push(a)}}i>0&&!1===t&&(p=h)}for(let f=0,g=c.length;f<g;f++){a=c[f].s,o.push(a),d=p[f];for(let t=0,e=d.length;t<e;t++)a.holes.push(d[t].h)}return o}},ShapeUtils:Ac,ShortType:1011,Skeleton:Pl,SkeletonHelper:class extends dh{constructor(t){const e=Fd(t),i=new Ss,n=[],s=[],r=new ts(0,0,1),a=new ts(0,1,0);for(let o=0;o<e.length;o++){const t=e[o];t.parent&&t.parent.isBone&&(n.push(0,0,0),n.push(0,0,0),s.push(r.r,r.g,r.b),s.push(a.r,a.g,a.b))}i.setAttribute("position",new fs(n,3)),i.setAttribute("color",new fs(s,3)),super(i,new nh({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(t){const e=this.bones,i=this.geometry,n=i.getAttribute("position");Od.copy(this.root.matrixWorld).invert();for(let s=0,r=0;s<e.length;s++){const t=e[s];t.parent&&t.parent.isBone&&(Ud.multiplyMatrices(Od,t.matrixWorld),Nd.setFromMatrixPosition(Ud),n.setXYZ(r,Nd.x,Nd.y,Nd.z),Ud.multiplyMatrices(Od,t.parent.matrixWorld),Nd.setFromMatrixPosition(Ud),n.setXYZ(r+1,Nd.x,Nd.y,Nd.z),r+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(t)}dispose(){this.geometry.dispose(),this.material.dispose()}},SkinnedMesh:Tl,Source:Ti,Sphere:nn,SphereGeometry:Oc,Spherical:class{constructor(t=1,e=0,i=0){return this.radius=t,this.phi=e,this.theta=i,this}set(t,e,i){return this.radius=t,this.phi=e,this.theta=i,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){const t=1e-6;return this.phi=Math.max(t,Math.min(Math.PI-t,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,i){return this.radius=Math.sqrt(t*t+e*e+i*i),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,i),this.phi=Math.acos(Ke(e/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}},SphericalHarmonics3:qu,SplineCurve:kh,SpotLight:Uu,SpotLightHelper:class extends Fn{constructor(t,e){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const i=new Ss,n=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let r=0,a=1,o=32;r<o;r++,a++){const t=r/o*Math.PI*2,e=a/o*Math.PI*2;n.push(Math.cos(t),Math.sin(t),1,Math.cos(e),Math.sin(e),1)}i.setAttribute("position",new fs(n,3));const s=new nh({fog:!1,toneMapped:!1});this.cone=new dh(i,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);const t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),Dd.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Dd),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},Sprite:ul,SpriteMaterial:Ko,SrcAlphaFactor:j,SrcAlphaSaturateFactor:210,SrcColorFactor:202,StaticCopyUsage:35046,StaticDrawUsage:ke,StaticReadUsage:35045,StereoCamera:class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Js,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Js,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,sd.copy(t.projectionMatrix);const i=e.eyeSep/2,n=i*e.near/e.focus,s=e.near*Math.tan(Ye*e.fov*.5)/e.zoom;let r,a;nd.elements[12]=-i,id.elements[12]=i,r=-s*e.aspect+n,a=s*e.aspect+n,sd.elements[0]=2*e.near/(a-r),sd.elements[8]=(a+r)/(a-r),this.cameraL.projectionMatrix.copy(sd),r=-s*e.aspect-n,a=s*e.aspect-n,sd.elements[0]=2*e.near/(a-r),sd.elements[8]=(a+r)/(a-r),this.cameraR.projectionMatrix.copy(sd)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(nd),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(id)}},StreamCopyUsage:35042,StreamDrawUsage:35040,StreamReadUsage:35041,StringKeyframeTrack:gu,SubtractEquation:101,SubtractiveBlending:3,TOUCH:{ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},TangentSpaceNormalMap:0,TetrahedronGeometry:Fc,Texture:Ci,TextureLoader:class extends Su{constructor(t){super(t)}load(t,e,i,n){const s=new Ci,r=new Au(this.manager);return r.setCrossOrigin(this.crossOrigin),r.setPath(this.path),r.load(t,function(t){s.image=t,s.needsUpdate=!0,void 0!==e&&e(s)},i,n),s}},TorusGeometry:Bc,TorusKnotGeometry:zc,Triangle:Zn,TriangleFanDrawMode:2,TriangleStripDrawMode:1,TrianglesDrawMode:0,TubeGeometry:kc,TwoPassDoubleSide:2,UVMapping:at,Uint16BufferAttribute:ps,Uint32BufferAttribute:ms,Uint8BufferAttribute:class extends ds{constructor(t,e,i){super(new Uint8Array(t),e,i)}},Uint8ClampedBufferAttribute:class extends ds{constructor(t,e,i){super(new Uint8ClampedArray(t),e,i)}},Uniform:Ed,UniformsGroup:class extends qe{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:Ad++}),this.name="",this.usage=ke,this.uniforms=[]}add(t){return this.uniforms.push(t),this}remove(t){const e=this.uniforms.indexOf(t);return-1!==e&&this.uniforms.splice(e,1),this}setName(t){return this.name=t,this}setUsage(t){return this.usage=t,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(t){this.name=t.name,this.usage=t.usage;const e=t.uniforms;this.uniforms.length=0;for(let i=0,n=e.length;i<n;i++){const t=Array.isArray(e[i])?e[i]:[e[i]];for(let e=0;e<t.length;e++)this.uniforms.push(t[e].clone())}return this}clone(){return(new this.constructor).copy(this)}},UniformsLib:dr,UniformsUtils:js,UnsignedByteType:Mt,UnsignedInt248Type:Rt,UnsignedIntType:wt,UnsignedShort4444Type:At,UnsignedShort5551Type:Ct,UnsignedShortType:bt,VSMShadowMap:3,Vector2:ri,Vector3:Ui,Vector4:Ri,VectorKeyframeTrack:_u,VideoTexture:class extends Ci{constructor(t,e,i,n,s,r,a,o,l){super(t,e,i,n,s,r,a,o,l),this.isVideoTexture=!0,this.minFilter=void 0!==r?r:vt,this.magFilter=void 0!==s?s:vt,this.generateMipmaps=!1;const h=this;"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(function e(){h.needsUpdate=!0,t.requestVideoFrameCallback(e)})}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;0=="requestVideoFrameCallback"in t&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},WebGL1Renderer:Wo,WebGL3DRenderTarget:class extends Li{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new Di(null,t,e,i),this.texture.isRenderTargetTexture=!0}},WebGLArrayRenderTarget:class extends Li{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new Ii(null,t,e,i),this.texture.isRenderTargetTexture=!0}},WebGLCoordinateSystem:He,WebGLCubeRenderTarget:tr,WebGLMultipleRenderTargets:class extends Li{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isWebGLMultipleRenderTargets=!0;const s=this.texture;this.texture=[];for(let r=0;r<i;r++)this.texture[r]=s.clone(),this.texture[r].isRenderTargetTexture=!0}setSize(t,e,i=1){if(this.width!==t||this.height!==e||this.depth!==i){this.width=t,this.height=e,this.depth=i;for(let n=0,s=this.texture.length;n<s;n++)this.texture[n].image.width=t,this.texture[n].image.height=e,this.texture[n].image.depth=i;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}copy(t){this.dispose(),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.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,null!==t.depthTexture&&(this.depthTexture=t.depthTexture.clone()),this.texture.length=0;for(let e=0,i=t.texture.length;e<i;e++)this.texture[e]=t.texture[e].clone(),this.texture[e].isRenderTargetTexture=!0;return this}},WebGLRenderTarget:Li,WebGLRenderer:Ho,WebGLUtils:Uo,WebGPUCoordinateSystem:We,WireframeGeometry:Vc,WrapAroundEnding:ve,ZeroCurvatureEnding:ge,ZeroFactor:200,ZeroSlopeEnding:_e,ZeroStencilOp:0,_SRGBAFormat:Ge,createCanvasElement:di,sRGBEncoding:Me},Symbol.toStringTag,{value:"Module"}));t.EasterEggQuest=U,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})},"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).EasterEggQuest={});