easter-egg-quest 1.0.24 → 1.0.26
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(()=>$d)}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())}}burstRhythmParticles(t,e){if(!this.THREE||!this.scene)return;const i=this.THREE,n=Math.min(14,6+Math.floor(6*t)+Math.min(3,Math.floor(e)));for(let s=0;s<n;s++){const t=2*Math.PI*s/n+.35*(Math.random()-.5),e=.45+2.15*Math.random(),r=Math.cos(t)*e,a=-2.95-.75*Math.random(),o=.036+.038*Math.random(),l=this._createMiniEggGeo(i,o),h=this._createMiniEggMat(i,.18+.12*Math.random()),c=new i.Mesh(l,h);c.position.set(r,a,.8*Math.random()-1),c.rotation.set(Math.random()*Math.PI,Math.random()*Math.PI,Math.random()*Math.PI),this.scene.add(c),this._ambientParticles.push({mesh:c,life:1.7+.45*Math.random(),vy:.85+.65*Math.random(),fadeIn:!0})}for(;this._ambientParticles.length>120;){const t=this._ambientParticles.shift();if(!t)break;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",t=>{var e;t.preventDefault(),t.stopPropagation(),null==(e=this._onFinish)||e.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",A="eeq_completed";class C{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{}}markCompleted(){if(this._enabled)try{localStorage.setItem(A,"1"),localStorage.removeItem(E)}catch{}}isCompleted(){if(!this._enabled)return!1;try{return"1"===localStorage.getItem(A)}catch{return!1}}}class R{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 P{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 L{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],n=e[this._lastPhaseCount+1];if(!t||!n)break;{const e=this._evaluateCycle(t,n);this._totalCycles++,e?(this._goodCycles++,this._lastGoodCycleAt=Date.now(),this.bus.emit("rhythm:cycle",{progress:Math.min(1,this._goodCycles/i),cycles: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),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 I{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 D{constructor(){this._active=!1,this._intensity=0,this._targetIntensity=0,this._rafId=0,this._overlay=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)})`}}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,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;this._active&&(this._active=!1,cancelAnimationFrame(this._rafId),null==(t=this._overlay)||t.remove(),this._overlay=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 N{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 C(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;if(this.persistence.isCompleted())return void(this._destroyed=!0);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:cycle",t=>{this.threeRenderer&&this.threeRenderer.burstRhythmParticles(t.progress,t.cycles)}),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.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;if(!this.persistence.isCompleted()){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 R(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 P(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 L(this.config,this.script,this.input,this.bus);this.activeStage=n,await n.start(),this.fsm.transitionTo("stage3-active"),this.pageBreather=new D,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 I),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.persistence.markCompleted(),this.destroy(),this._reloadPage()}),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))}_reloadPage(){try{return void window.location.reload()}catch{}try{window.location.assign(window.location.href)}catch{}}}let U=null;const O={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,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;U=new N(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=()=>O.init();"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}const F="160",B=0,z=1,k=2,V=100,G=101,H=102,W=200,q=201,X=202,j=203,Y=204,Z=205,J=206,K=207,$=208,Q=209,tt=210,et=211,it=212,nt=213,st=214,rt="attached",at="detached",ot=300,lt=301,ht=302,ct=303,ut=304,dt=306,pt=1e3,mt=1001,ft=1002,gt=1003,_t=1004,vt=1005,yt=1006,xt=1007,Mt=1008,bt=1009,St=1012,wt=1013,Tt=1014,Et=1015,At=1016,Ct=1017,Rt=1018,Pt=1020,Lt=1023,It=1026,Dt=1027,Nt=1029,Ut=1031,Ot=1033,Ft=33776,Bt=33777,zt=33778,kt=33779,Vt=35840,Gt=35841,Ht=35842,Wt=35843,qt=36196,Xt=37492,jt=37496,Yt=37808,Zt=37809,Jt=37810,Kt=37811,$t=37812,Qt=37813,te=37814,ee=37815,ie=37816,ne=37817,se=37818,re=37819,ae=37820,oe=37821,le=36492,he=36494,ce=36495,ue=36284,de=36285,pe=36286,me=2300,fe=2301,ge=2302,_e=2400,ve=2401,ye=2402,xe=2501,Me=3e3,be=3001,Se="",we="srgb",Te="srgb-linear",Ee="display-p3",Ae="display-p3-linear",Ce="linear",Re="srgb",Pe="rec709",Le="p3",Ie=7680,De=512,Ne=513,Ue=514,Oe=515,Fe=516,Be=517,ze=518,ke=519,Ve=35044,Ge="300 es",He=1035,We=2e3,qe=2001;class Xe{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 je=["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 Ye=1234567;const Ze=Math.PI/180,Je=180/Math.PI;function Ke(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,i=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return(je[255&t]+je[t>>8&255]+je[t>>16&255]+je[t>>24&255]+"-"+je[255&e]+je[e>>8&255]+"-"+je[e>>16&15|64]+je[e>>24&255]+"-"+je[63&i|128]+je[i>>8&255]+"-"+je[i>>16&255]+je[i>>24&255]+je[255&n]+je[n>>8&255]+je[n>>16&255]+je[n>>24&255]).toLowerCase()}function $e(t,e,i){return Math.max(e,Math.min(i,t))}function Qe(t,e){return(t%e+e)%e}function ti(t,e,i){return(1-i)*t+i*e}function ei(t){return!(t&t-1)&&0!==t}function ii(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function ni(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 si(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 ri={DEG2RAD:Ze,RAD2DEG:Je,generateUUID:Ke,clamp:$e,euclideanModulo:Qe,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:ti,damp:(t,e,i,n)=>ti(t,e,1-Math.exp(-i*n)),pingpong:(t,e=1)=>e-Math.abs(Qe(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&&(Ye=t);let e=Ye+=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*Ze,radToDeg:t=>t*Je,isPowerOfTwo:ei,ceilPowerOfTwo:t=>Math.pow(2,Math.ceil(Math.log(t)/Math.LN2)),floorPowerOfTwo:ii,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:si,denormalize:ni};class ai{constructor(t=0,e=0){ai.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($e(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 oi{constructor(t,e,i,n,s,r,a,o,l){oi.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(li.makeScale(t,e)),this}rotate(t){return this.premultiply(li.makeRotation(-t)),this}translate(t,e){return this.premultiply(li.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 li=new oi;function hi(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}const ci={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function ui(t,e){return new ci[t](e)}function di(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function pi(){const t=di("canvas");return t.style.display="block",t}const mi={};function fi(t){t in mi||(mi[t]=!0)}const gi=(new oi).set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),_i=(new oi).set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),vi={[Te]:{transfer:Ce,primaries:Pe,toReference:t=>t,fromReference:t=>t},[we]:{transfer:Re,primaries:Pe,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[Ae]:{transfer:Ce,primaries:Le,toReference:t=>t.applyMatrix3(_i),fromReference:t=>t.applyMatrix3(gi)},[Ee]:{transfer:Re,primaries:Le,toReference:t=>t.convertSRGBToLinear().applyMatrix3(_i),fromReference:t=>t.applyMatrix3(gi).convertLinearToSRGB()}},yi=new Set([Te,Ae]),xi={enabled:!0,_workingColorSpace:Te,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(t){if(!yi.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=vi[e].toReference;return(0,vi[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=>vi[t].primaries,getTransfer:t=>t===Se?Ce:vi[t].transfer};function Mi(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function bi(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}let Si;class wi{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===Si&&(Si=di("canvas")),Si.width=t.width,Si.height=t.height;const i=Si.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),e=Si}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=di("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*Mi(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*Mi(e[t]/255)):e[t]=Mi(e[t]);return{data:e,width:t.width,height:t.height}}return t}}let Ti=0;class Ei{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Ti++}),this.uuid=Ke(),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(Ai(n[e].image)):t.push(Ai(n[e]))}else t=Ai(n);i.url=t}return e||(t.images[this.uuid]=i),i}}function Ai(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?wi.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:{}}let Ci=0;class Ri extends Xe{constructor(t=Ri.DEFAULT_IMAGE,e=Ri.DEFAULT_MAPPING,i=1001,n=1001,s=1006,r=1008,a=1023,o=1009,l=Ri.DEFAULT_ANISOTROPY,h=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Ci++}),this.uuid=Ke(),this.name="",this.source=new Ei(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 ai(0,0),this.repeat=new ai(1,1),this.center=new ai(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new oi,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,"string"==typeof h?this.colorSpace=h:(fi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=h===be?we:Se),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!==ot)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case pt:t.x=t.x-Math.floor(t.x);break;case mt:t.x=t.x<0?0:1;break;case ft: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 pt:t.y=t.y-Math.floor(t.y);break;case mt:t.y=t.y<0?0:1;break;case ft: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 fi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===we?be:Me}set encoding(t){fi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=t===be?we:Se}}Ri.DEFAULT_IMAGE=null,Ri.DEFAULT_MAPPING=ot,Ri.DEFAULT_ANISOTROPY=1;class Pi{constructor(t=0,e=0,i=0,n=1){Pi.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 Li extends Xe{constructor(t=1,e=1,i={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new Pi(0,0,t,e),this.scissorTest=!1,this.viewport=new Pi(0,0,t,e);const n={width:t,height:e,depth:1};void 0!==i.encoding&&(fi("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),i.colorSpace=i.encoding===be?we:Se),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:yt,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},i),this.texture=new Ri(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 Ei(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 Ii extends Li{constructor(t=1,e=1,i={}){super(t,e,i),this.isWebGLRenderTarget=!0}}class Di extends Ri{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=gt,this.minFilter=gt,this.wrapR=mt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ni extends Ri{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=gt,this.minFilter=gt,this.wrapR=mt,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($e(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 Oi{constructor(t=0,e=0,i=0){Oi.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(Bi.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Bi.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 Fi.copy(this).projectOnVector(t),this.sub(Fi)}reflect(t){return this.sub(Fi.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($e(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 Fi=new Oi,Bi=new Ui;class zi{constructor(t=new Oi(1/0,1/0,1/0),e=new Oi(-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(Vi.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,i=t.count;e<i;e++)this.expandByPoint(Vi.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=Vi.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,Vi):Vi.fromBufferAttribute(n,e),Vi.applyMatrix4(t.matrixWorld),this.expandByPoint(Vi);else void 0!==t.boundingBox?(null===t.boundingBox&&t.computeBoundingBox(),Gi.copy(t.boundingBox)):(null===i.boundingBox&&i.computeBoundingBox(),Gi.copy(i.boundingBox)),Gi.applyMatrix4(t.matrixWorld),this.union(Gi)}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,Vi),Vi.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(Zi),Ji.subVectors(this.max,Zi),Hi.subVectors(t.a,Zi),Wi.subVectors(t.b,Zi),qi.subVectors(t.c,Zi),Xi.subVectors(Wi,Hi),ji.subVectors(qi,Wi),Yi.subVectors(Hi,qi);let e=[0,-Xi.z,Xi.y,0,-ji.z,ji.y,0,-Yi.z,Yi.y,Xi.z,0,-Xi.x,ji.z,0,-ji.x,Yi.z,0,-Yi.x,-Xi.y,Xi.x,0,-ji.y,ji.x,0,-Yi.y,Yi.x,0];return!!Qi(e,Hi,Wi,qi,Ji)&&(e=[1,0,0,0,1,0,0,0,1],!!Qi(e,Hi,Wi,qi,Ji)&&(Ki.crossVectors(Xi,ji),e=[Ki.x,Ki.y,Ki.z],Qi(e,Hi,Wi,qi,Ji)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Vi).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(Vi).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()||(ki[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),ki[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),ki[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),ki[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),ki[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),ki[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),ki[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),ki[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(ki)),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 ki=[new Oi,new Oi,new Oi,new Oi,new Oi,new Oi,new Oi,new Oi],Vi=new Oi,Gi=new zi,Hi=new Oi,Wi=new Oi,qi=new Oi,Xi=new Oi,ji=new Oi,Yi=new Oi,Zi=new Oi,Ji=new Oi,Ki=new Oi,$i=new Oi;function Qi(t,e,i,n,s){for(let r=0,a=t.length-3;r<=a;r+=3){$i.fromArray(t,r);const a=s.x*Math.abs($i.x)+s.y*Math.abs($i.y)+s.z*Math.abs($i.z),o=e.dot($i),l=i.dot($i),h=n.dot($i);if(Math.max(-Math.max(o,l,h),Math.min(o,l,h))>a)return!1}return!0}const tn=new zi,en=new Oi,nn=new Oi;class sn{constructor(t=new Oi,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):tn.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;en.subVectors(t,this.center);const e=en.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),i=.5*(t-this.radius);this.center.addScaledVector(en,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):(nn.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(en.copy(t.center).add(nn)),this.expandByPoint(en.copy(t.center).sub(nn))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const rn=new Oi,an=new Oi,on=new Oi,ln=new Oi,hn=new Oi,cn=new Oi,un=new Oi;class dn{constructor(t=new Oi,e=new Oi(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,rn)),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=rn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(rn.copy(this.origin).addScaledVector(this.direction,e),rn.distanceToSquared(t))}distanceSqToSegment(t,e,i,n){an.copy(t).add(e).multiplyScalar(.5),on.copy(e).sub(t).normalize(),ln.copy(this.origin).sub(an);const s=.5*t.distanceTo(e),r=-this.direction.dot(on),a=ln.dot(this.direction),o=-ln.dot(on),l=ln.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(an).addScaledVector(on,u),d}intersectSphere(t,e){rn.subVectors(t.center,this.origin);const i=rn.dot(this.direction),n=rn.dot(rn)-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,rn)}intersectTriangle(t,e,i,n,s){hn.subVectors(e,t),cn.subVectors(i,t),un.crossVectors(hn,cn);let r,a=this.direction.dot(un);if(a>0){if(n)return null;r=1}else{if(!(a<0))return null;r=-1,a=-a}ln.subVectors(this.origin,t);const o=r*this.direction.dot(cn.crossVectors(ln,cn));if(o<0)return null;const l=r*this.direction.dot(hn.cross(ln));if(l<0)return null;if(o+l>a)return null;const h=-r*ln.dot(un);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 pn{constructor(t,e,i,n,s,r,a,o,l,h,c,u,d,p,m,f){pn.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 pn).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/mn.setFromMatrixColumn(t,0).length(),s=1/mn.setFromMatrixColumn(t,1).length(),r=1/mn.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(gn,t,_n)}lookAt(t,e,i){const n=this.elements;return xn.subVectors(t,e),0===xn.lengthSq()&&(xn.z=1),xn.normalize(),vn.crossVectors(i,xn),0===vn.lengthSq()&&(1===Math.abs(i.z)?xn.x+=1e-4:xn.z+=1e-4,xn.normalize(),vn.crossVectors(i,xn)),vn.normalize(),yn.crossVectors(xn,vn),n[0]=vn.x,n[4]=yn.x,n[8]=xn.x,n[1]=vn.y,n[5]=yn.y,n[9]=xn.y,n[2]=vn.z,n[6]=yn.z,n[10]=xn.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=mn.set(n[0],n[1],n[2]).length();const r=mn.set(n[4],n[5],n[6]).length(),a=mn.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],fn.copy(this);const o=1/s,l=1/r,h=1/a;return fn.elements[0]*=o,fn.elements[1]*=o,fn.elements[2]*=o,fn.elements[4]*=l,fn.elements[5]*=l,fn.elements[6]*=l,fn.elements[8]*=h,fn.elements[9]*=h,fn.elements[10]*=h,e.setFromRotationMatrix(fn),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===We)d=-(r+s)/(r-s),p=-2*r*s/(r-s);else{if(a!==qe)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===We)p=(r+s)*c,m=-2*c;else{if(a!==qe)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 mn=new Oi,fn=new pn,gn=new Oi(0,0,0),_n=new Oi(1,1,1),vn=new Oi,yn=new Oi,xn=new Oi,Mn=new pn,bn=new Ui;class Sn{constructor(t=0,e=0,i=0,n=Sn.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($e(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(-$e(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($e(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(-$e(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($e(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(-$e(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 Mn.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Mn,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return bn.setFromEuler(this),this.setFromQuaternion(bn,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}}Sn.DEFAULT_ORDER="XYZ";class wn{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 Tn=0;const En=new Oi,An=new Ui,Cn=new pn,Rn=new Oi,Pn=new Oi,Ln=new Oi,In=new Ui,Dn=new Oi(1,0,0),Nn=new Oi(0,1,0),Un=new Oi(0,0,1),On={type:"added"},Fn={type:"removed"};class Bn extends Xe{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Tn++}),this.uuid=Ke(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Bn.DEFAULT_UP.clone();const t=new Oi,e=new Sn,i=new Ui,n=new Oi(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 pn},normalMatrix:{value:new oi}}),this.matrix=new pn,this.matrixWorld=new pn,this.matrixAutoUpdate=Bn.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Bn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new wn,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 An.setFromAxisAngle(t,e),this.quaternion.multiply(An),this}rotateOnWorldAxis(t,e){return An.setFromAxisAngle(t,e),this.quaternion.premultiply(An),this}rotateX(t){return this.rotateOnAxis(Dn,t)}rotateY(t){return this.rotateOnAxis(Nn,t)}rotateZ(t){return this.rotateOnAxis(Un,t)}translateOnAxis(t,e){return En.copy(t).applyQuaternion(this.quaternion),this.position.add(En.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Dn,t)}translateY(t){return this.translateOnAxis(Nn,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(Cn.copy(this.matrixWorld).invert())}lookAt(t,e,i){t.isVector3?Rn.copy(t):Rn.set(t,e,i);const n=this.parent;this.updateWorldMatrix(!0,!1),Pn.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Cn.lookAt(Pn,Rn,this.up):Cn.lookAt(Rn,Pn,this.up),this.quaternion.setFromRotationMatrix(Cn),n&&(Cn.extractRotation(n.matrixWorld),An.setFromRotationMatrix(Cn),this.quaternion.premultiply(An.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(On)),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(Fn)),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),Cn.copy(this.matrixWorld).invert(),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),Cn.multiply(t.parent.matrixWorld)),t.applyMatrix4(Cn),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(Pn,t,Ln),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Pn,In,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}}Bn.DEFAULT_UP=new Oi(0,1,0),Bn.DEFAULT_MATRIX_AUTO_UPDATE=!0,Bn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const zn=new Oi,kn=new Oi,Vn=new Oi,Gn=new Oi,Hn=new Oi,Wn=new Oi,qn=new Oi,Xn=new Oi,jn=new Oi,Yn=new Oi;let Zn=!1;class Jn{constructor(t=new Oi,e=new Oi,i=new Oi){this.a=t,this.b=e,this.c=i}static getNormal(t,e,i,n){n.subVectors(i,e),zn.subVectors(t,e),n.cross(zn);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){zn.subVectors(n,e),kn.subVectors(i,e),Vn.subVectors(t,e);const r=zn.dot(zn),a=zn.dot(kn),o=zn.dot(Vn),l=kn.dot(kn),h=kn.dot(Vn),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,Gn)&&Gn.x>=0&&Gn.y>=0&&Gn.x+Gn.y<=1}static getUV(t,e,i,n,s,r,a,o){return!1===Zn&&(Zn=!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,Gn)?(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,Gn.x),o.addScaledVector(r,Gn.y),o.addScaledVector(a,Gn.z),o)}static isFrontFacing(t,e,i,n){return zn.subVectors(i,e),kn.subVectors(t,e),zn.cross(kn).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 zn.subVectors(this.c,this.b),kn.subVectors(this.a,this.b),.5*zn.cross(kn).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Jn.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Jn.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,i,n,s){return!1===Zn&&(Zn=!0),Jn.getInterpolation(t,this.a,this.b,this.c,e,i,n,s)}getInterpolation(t,e,i,n,s){return Jn.getInterpolation(t,this.a,this.b,this.c,e,i,n,s)}containsPoint(t){return Jn.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Jn.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;Hn.subVectors(n,i),Wn.subVectors(s,i),Xn.subVectors(t,i);const o=Hn.dot(Xn),l=Wn.dot(Xn);if(o<=0&&l<=0)return e.copy(i);jn.subVectors(t,n);const h=Hn.dot(jn),c=Wn.dot(jn);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(Hn,r);Yn.subVectors(t,s);const d=Hn.dot(Yn),p=Wn.dot(Yn);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(Wn,a);const f=h*p-d*c;if(f<=0&&c-h>=0&&d-p>=0)return qn.subVectors(s,n),a=(c-h)/(c-h+(d-p)),e.copy(n).addScaledVector(qn,a);const g=1/(f+m+u);return r=m*g,a=u*g,e.copy(i).addScaledVector(Hn,r).addScaledVector(Wn,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Kn={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},$n={h:0,s:0,l:0},Qn={h:0,s:0,l:0};function ts(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 es{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=we){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,xi.toWorkingColorSpace(this,e),this}setRGB(t,e,i,n=xi.workingColorSpace){return this.r=t,this.g=e,this.b=i,xi.toWorkingColorSpace(this,n),this}setHSL(t,e,i,n=xi.workingColorSpace){if(t=Qe(t,1),e=$e(e,0,1),i=$e(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=ts(s,n,t+1/3),this.g=ts(s,n,t),this.b=ts(s,n,t-1/3)}return xi.toWorkingColorSpace(this,n),this}setStyle(t,e=we){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=we){const i=Kn[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=Mi(t.r),this.g=Mi(t.g),this.b=Mi(t.b),this}copyLinearToSRGB(t){return this.r=bi(t.r),this.g=bi(t.g),this.b=bi(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=we){return xi.fromWorkingColorSpace(is.copy(this),t),65536*Math.round($e(255*is.r,0,255))+256*Math.round($e(255*is.g,0,255))+Math.round($e(255*is.b,0,255))}getHexString(t=we){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=xi.workingColorSpace){xi.fromWorkingColorSpace(is.copy(this),e);const i=is.r,n=is.g,s=is.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=xi.workingColorSpace){return xi.fromWorkingColorSpace(is.copy(this),e),t.r=is.r,t.g=is.g,t.b=is.b,t}getStyle(t=we){xi.fromWorkingColorSpace(is.copy(this),t);const e=is.r,i=is.g,n=is.b;return t!==we?`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($n),this.setHSL($n.h+t,$n.s+e,$n.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($n),t.getHSL(Qn);const i=ti($n.h,Qn.h,e),n=ti($n.s,Qn.s,e),s=ti($n.l,Qn.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 is=new es;es.NAMES=Kn;let ns=0;class ss extends Xe{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ns++}),this.uuid=Ke(),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=Y,this.blendDst=Z,this.blendEquation=V,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new es(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=Ie,this.stencilZFail=Ie,this.stencilZPass=Ie,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!==Y&&(i.blendSrc=this.blendSrc),this.blendDst!==Z&&(i.blendDst=this.blendDst),this.blendEquation!==V&&(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!==Ie&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Ie&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Ie&&(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 rs extends ss{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new es(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 as=os();function os(){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 ls(t){Math.abs(t),t=$e(t,-65504,65504),as.floatView[0]=t;const e=as.uint32View[0],i=e>>23&511;return as.baseTable[i]+((8388607&e)>>as.shiftTable[i])}function hs(t){const e=t>>10;return as.uint32View[0]=as.mantissaTable[as.offsetTable[e]+(1023&t)]+as.exponentTable[e],as.floatView[0]}const cs={toHalfFloat:ls,fromHalfFloat:hs},us=new Oi,ds=new ai;class ps{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=Ve,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Et,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++)ds.fromBufferAttribute(this,e),ds.applyMatrix3(t),this.setXY(e,ds.x,ds.y);else if(3===this.itemSize)for(let e=0,i=this.count;e<i;e++)us.fromBufferAttribute(this,e),us.applyMatrix3(t),this.setXYZ(e,us.x,us.y,us.z);return this}applyMatrix4(t){for(let e=0,i=this.count;e<i;e++)us.fromBufferAttribute(this,e),us.applyMatrix4(t),this.setXYZ(e,us.x,us.y,us.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)us.fromBufferAttribute(this,e),us.applyNormalMatrix(t),this.setXYZ(e,us.x,us.y,us.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)us.fromBufferAttribute(this,e),us.transformDirection(t),this.setXYZ(e,us.x,us.y,us.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=ni(i,this.array)),i}setComponent(t,e,i){return this.normalized&&(i=si(i,this.array)),this.array[t*this.itemSize+e]=i,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=ni(e,this.array)),e}setX(t,e){return this.normalized&&(e=si(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=ni(e,this.array)),e}setY(t,e){return this.normalized&&(e=si(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=ni(e,this.array)),e}setZ(t,e){return this.normalized&&(e=si(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=ni(e,this.array)),e}setW(t,e){return this.normalized&&(e=si(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=si(e,this.array),i=si(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=si(e,this.array),i=si(i,this.array),n=si(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=si(e,this.array),i=si(i,this.array),n=si(n,this.array),s=si(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!==Ve&&(t.usage=this.usage),t}}class ms extends ps{constructor(t,e,i){super(new Uint16Array(t),e,i)}}class fs extends ps{constructor(t,e,i){super(new Uint32Array(t),e,i)}}class gs extends ps{constructor(t,e,i){super(new Float32Array(t),e,i)}}let _s=0;const vs=new pn,ys=new Bn,xs=new Oi,Ms=new zi,bs=new zi,Ss=new Oi;class ws extends Xe{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:_s++}),this.uuid=Ke(),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(hi(t)?fs:ms)(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 oi).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 vs.makeRotationFromQuaternion(t),this.applyMatrix4(vs),this}rotateX(t){return vs.makeRotationX(t),this.applyMatrix4(vs),this}rotateY(t){return vs.makeRotationY(t),this.applyMatrix4(vs),this}rotateZ(t){return vs.makeRotationZ(t),this.applyMatrix4(vs),this}translate(t,e,i){return vs.makeTranslation(t,e,i),this.applyMatrix4(vs),this}scale(t,e,i){return vs.makeScale(t,e,i),this.applyMatrix4(vs),this}lookAt(t){return ys.lookAt(t),ys.updateMatrix(),this.applyMatrix4(ys.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(xs).negate(),this.translate(xs.x,xs.y,xs.z),this}setFromPoints(t){const e=[];for(let 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 gs(e,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new zi);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)this.boundingBox.set(new Oi(-1/0,-1/0,-1/0),new Oi(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];Ms.setFromBufferAttribute(i),this.morphTargetsRelative?(Ss.addVectors(this.boundingBox.min,Ms.min),this.boundingBox.expandByPoint(Ss),Ss.addVectors(this.boundingBox.max,Ms.max),this.boundingBox.expandByPoint(Ss)):(this.boundingBox.expandByPoint(Ms.min),this.boundingBox.expandByPoint(Ms.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 sn);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)this.boundingSphere.set(new Oi,1/0);else if(t){const i=this.boundingSphere.center;if(Ms.setFromBufferAttribute(t),e)for(let t=0,s=e.length;t<s;t++){const i=e[t];bs.setFromBufferAttribute(i),this.morphTargetsRelative?(Ss.addVectors(Ms.min,bs.min),Ms.expandByPoint(Ss),Ss.addVectors(Ms.max,bs.max),Ms.expandByPoint(Ss)):(Ms.expandByPoint(bs.min),Ms.expandByPoint(bs.max))}Ms.getCenter(i);let n=0;for(let e=0,s=t.count;e<s;e++)Ss.fromBufferAttribute(t,e),n=Math.max(n,i.distanceToSquared(Ss));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++)Ss.fromBufferAttribute(r,e),a&&(xs.fromBufferAttribute(t,e),Ss.add(xs)),n=Math.max(n,i.distanceToSquared(Ss))}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 ps(new Float32Array(4*a),4));const o=this.getAttribute("tangent").array,l=[],h=[];for(let T=0;T<a;T++)l[T]=new Oi,h[T]=new Oi;const c=new Oi,u=new Oi,d=new Oi,p=new ai,m=new ai,f=new ai,g=new Oi,_=new Oi;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 Oi,M=new Oi,b=new Oi,S=new Oi;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 ps(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 Oi,s=new Oi,r=new Oi,a=new Oi,o=new Oi,l=new Oi,h=new Oi,c=new Oi;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++)Ss.fromBufferAttribute(t,e),Ss.normalize(),t.setXYZ(e,Ss.x,Ss.y,Ss.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 ps(r,n,s)}if(null===this.index)return this;const e=new ws,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 Ts=new pn,Es=new dn,As=new sn,Cs=new Oi,Rs=new Oi,Ps=new Oi,Ls=new Oi,Is=new Oi,Ds=new Oi,Ns=new ai,Us=new ai,Os=new ai,Fs=new Oi,Bs=new Oi,zs=new Oi,ks=new Oi,Vs=new Oi;class Gs extends Bn{constructor(t=new ws,e=new rs){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){Ds.set(0,0,0);for(let i=0,n=s.length;i<n;i++){const n=a[i],o=s[i];0!==n&&(Is.fromBufferAttribute(o,t),r?Ds.addScaledVector(Is,n):Ds.addScaledVector(Is.sub(e),n))}e.add(Ds)}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(),As.copy(i.boundingSphere),As.applyMatrix4(s),Es.copy(t.ray).recast(t.near),!1===As.containsPoint(Es.origin)){if(null===Es.intersectSphere(As,Cs))return;if(Es.origin.distanceToSquared(Cs)>(t.far-t.near)**2)return}Ts.copy(s).invert(),Es.copy(t.ray).applyMatrix4(Ts),null!==i.boundingBox&&!1===Es.intersectsBox(i.boundingBox)||this._computeIntersections(t,e,Es)}}_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=Hs(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=Hs(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=Hs(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=Hs(this,r,t,i,l,h,c,p,p+1,p+2),n&&(n.faceIndex=Math.floor(p/3),e.push(n))}}function Hs(t,e,i,n,s,r,a,o,l,h){t.getVertexPosition(o,Rs),t.getVertexPosition(l,Ps),t.getVertexPosition(h,Ls);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;Vs.copy(o),Vs.applyMatrix4(t.matrixWorld);const h=i.ray.origin.distanceTo(Vs);return h<i.near||h>i.far?null:{distance:h,point:Vs.clone(),object:t}}(t,e,i,n,Rs,Ps,Ls,ks);if(c){s&&(Ns.fromBufferAttribute(s,o),Us.fromBufferAttribute(s,l),Os.fromBufferAttribute(s,h),c.uv=Jn.getInterpolation(ks,Rs,Ps,Ls,Ns,Us,Os,new ai)),r&&(Ns.fromBufferAttribute(r,o),Us.fromBufferAttribute(r,l),Os.fromBufferAttribute(r,h),c.uv1=Jn.getInterpolation(ks,Rs,Ps,Ls,Ns,Us,Os,new ai),c.uv2=c.uv1),a&&(Fs.fromBufferAttribute(a,o),Bs.fromBufferAttribute(a,l),zs.fromBufferAttribute(a,h),c.normal=Jn.getInterpolation(ks,Rs,Ps,Ls,Fs,Bs,zs,new Oi),c.normal.dot(n.direction)>0&&c.normal.multiplyScalar(-1));const t={a:o,b:l,c:h,normal:new Oi,materialIndex:0};Jn.getNormal(Rs,Ps,Ls,t.normal),c.face=t}return c}class Ws extends ws{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 Oi;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 gs(l,3)),this.setAttribute("normal",new gs(h,3)),this.setAttribute("uv",new gs(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ws(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function qs(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 Xs(t){const e={};for(let i=0;i<t.length;i++){const n=qs(t[i]);for(const t in n)e[t]=n[t]}return e}function js(t){return null===t.getRenderTarget()?t.outputColorSpace:xi.workingColorSpace}const Ys={clone:qs,merge:Xs};class Zs extends ss{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=qs(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 Js extends Bn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new pn,this.projectionMatrix=new pn,this.projectionMatrixInverse=new pn,this.coordinateSystem=We}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 Ks extends Js{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*Je*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*Ze*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*Je*Math.atan(Math.tan(.5*Ze*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*Ze*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 $s=-90;class Qs extends Bn{constructor(t,e,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const n=new Ks($s,1,t,e);n.layers=this.layers,this.add(n);const s=new Ks($s,1,t,e);s.layers=this.layers,this.add(s);const r=new Ks($s,1,t,e);r.layers=this.layers,this.add(r);const a=new Ks($s,1,t,e);a.layers=this.layers,this.add(a);const o=new Ks($s,1,t,e);o.layers=this.layers,this.add(o);const l=new Ks($s,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===We)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!==qe)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 tr extends Ri{constructor(t,e,i,n,s,r,a,o,l,h){super(t=void 0!==t?t:[],e=void 0!==e?e:lt,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 er extends Ii{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&&(fi("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),e.colorSpace=e.encoding===be?we:Se),this.texture=new tr(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:yt}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 Ws(5,5,5),n=new Zs({name:"CubemapFromEquirect",uniforms:qs({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 Gs(i,n),r=e.minFilter;return e.minFilter===Mt&&(e.minFilter=yt),new Qs(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 ir=new Oi,nr=new Oi,sr=new oi;class rr{constructor(t=new Oi(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=ir.subVectors(i,e).cross(nr.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(ir),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||sr.getNormalMatrix(t),n=this.coplanarPoint(ir).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 ar=new sn,or=new Oi;class lr{constructor(t=new rr,e=new rr,i=new rr,n=new rr,s=new rr,r=new rr){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===We)i[5].setComponents(o+a,u+c,f+m,y+v).normalize();else{if(e!==qe)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(),ar.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;null===e.boundingSphere&&e.computeBoundingSphere(),ar.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(ar)}intersectsSprite(t){return ar.center.set(0,0,0),ar.radius=.7071067811865476,ar.applyMatrix4(t.matrixWorld),this.intersectsSphere(ar)}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(or.x=n.normal.x>0?t.max.x:t.min.x,or.y=n.normal.y>0?t.max.y:t.min.y,or.z=n.normal.z>0?t.max.z:t.min.z,n.distanceToPoint(or)<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 hr(){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 cr(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 ur extends ws{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 gs(p,3)),this.setAttribute("normal",new gs(m,3)),this.setAttribute("uv",new gs(f,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ur(t.width,t.height,t.widthSegments,t.heightSegments)}}const dr={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}"},pr={common:{diffuse:{value:new es(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new oi},alphaMap:{value:null},alphaMapTransform:{value:new oi},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new oi}},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 oi}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new oi}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new oi},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new oi},normalScale:{value:new ai(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new oi},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new oi}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new oi}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new oi}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new es(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 es(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new oi},alphaTest:{value:0},uvTransform:{value:new oi}},sprite:{diffuse:{value:new es(16777215)},opacity:{value:1},center:{value:new ai(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new oi},alphaMap:{value:null},alphaMapTransform:{value:new oi},alphaTest:{value:0}}},mr={basic:{uniforms:Xs([pr.common,pr.specularmap,pr.envmap,pr.aomap,pr.lightmap,pr.fog]),vertexShader:dr.meshbasic_vert,fragmentShader:dr.meshbasic_frag},lambert:{uniforms:Xs([pr.common,pr.specularmap,pr.envmap,pr.aomap,pr.lightmap,pr.emissivemap,pr.bumpmap,pr.normalmap,pr.displacementmap,pr.fog,pr.lights,{emissive:{value:new es(0)}}]),vertexShader:dr.meshlambert_vert,fragmentShader:dr.meshlambert_frag},phong:{uniforms:Xs([pr.common,pr.specularmap,pr.envmap,pr.aomap,pr.lightmap,pr.emissivemap,pr.bumpmap,pr.normalmap,pr.displacementmap,pr.fog,pr.lights,{emissive:{value:new es(0)},specular:{value:new es(1118481)},shininess:{value:30}}]),vertexShader:dr.meshphong_vert,fragmentShader:dr.meshphong_frag},standard:{uniforms:Xs([pr.common,pr.envmap,pr.aomap,pr.lightmap,pr.emissivemap,pr.bumpmap,pr.normalmap,pr.displacementmap,pr.roughnessmap,pr.metalnessmap,pr.fog,pr.lights,{emissive:{value:new es(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:dr.meshphysical_vert,fragmentShader:dr.meshphysical_frag},toon:{uniforms:Xs([pr.common,pr.aomap,pr.lightmap,pr.emissivemap,pr.bumpmap,pr.normalmap,pr.displacementmap,pr.gradientmap,pr.fog,pr.lights,{emissive:{value:new es(0)}}]),vertexShader:dr.meshtoon_vert,fragmentShader:dr.meshtoon_frag},matcap:{uniforms:Xs([pr.common,pr.bumpmap,pr.normalmap,pr.displacementmap,pr.fog,{matcap:{value:null}}]),vertexShader:dr.meshmatcap_vert,fragmentShader:dr.meshmatcap_frag},points:{uniforms:Xs([pr.points,pr.fog]),vertexShader:dr.points_vert,fragmentShader:dr.points_frag},dashed:{uniforms:Xs([pr.common,pr.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:dr.linedashed_vert,fragmentShader:dr.linedashed_frag},depth:{uniforms:Xs([pr.common,pr.displacementmap]),vertexShader:dr.depth_vert,fragmentShader:dr.depth_frag},normal:{uniforms:Xs([pr.common,pr.bumpmap,pr.normalmap,pr.displacementmap,{opacity:{value:1}}]),vertexShader:dr.meshnormal_vert,fragmentShader:dr.meshnormal_frag},sprite:{uniforms:Xs([pr.sprite,pr.fog]),vertexShader:dr.sprite_vert,fragmentShader:dr.sprite_frag},background:{uniforms:{uvTransform:{value:new oi},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:dr.background_vert,fragmentShader:dr.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:dr.backgroundCube_vert,fragmentShader:dr.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:dr.cube_vert,fragmentShader:dr.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:dr.equirect_vert,fragmentShader:dr.equirect_frag},distanceRGBA:{uniforms:Xs([pr.common,pr.displacementmap,{referencePosition:{value:new Oi},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:dr.distanceRGBA_vert,fragmentShader:dr.distanceRGBA_frag},shadow:{uniforms:Xs([pr.lights,pr.fog,{color:{value:new es(0)},opacity:{value:1}}]),vertexShader:dr.shadow_vert,fragmentShader:dr.shadow_frag}};mr.physical={uniforms:Xs([mr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new oi},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new oi},clearcoatNormalScale:{value:new ai(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new oi},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new oi},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new oi},sheen:{value:0},sheenColor:{value:new es(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new oi},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new oi},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new oi},transmissionSamplerSize:{value:new ai},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new oi},attenuationDistance:{value:0},attenuationColor:{value:new es(0)},specularColor:{value:new es(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new oi},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new oi},anisotropyVector:{value:new ai},anisotropyMap:{value:null},anisotropyMapTransform:{value:new oi}}]),vertexShader:dr.meshphysical_vert,fragmentShader:dr.meshphysical_frag};const fr={r:0,b:0,g:0};function gr(t,e,i,n,s,r,a){const o=new es(0);let l,h,c=!0===r?0:1,u=null,d=0,p=null;function m(e,i){e.getRGB(fr,js(t)),n.buffers.color.setClear(fr.r,fr.g,fr.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===dt)?(void 0===h&&(h=new Gs(new Ws(1,1,1),new Zs({name:"BackgroundCubeMaterial",uniforms:qs(mr.backgroundCube.uniforms),vertexShader:mr.backgroundCube.vertexShader,fragmentShader:mr.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=xi.getTransfer(_.colorSpace)!==Re,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 Gs(new ur(2,2),new Zs({name:"BackgroundMaterial",uniforms:qs(mr.background.uniforms),vertexShader:mr.background.vertexShader,fragmentShader:mr.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=xi.getTransfer(_.colorSpace)!==Re,!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 _r(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===wt);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 vr(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 yr(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 xr(t){const e=this;let i=null,n=0,s=!1,r=!1;const a=new rr,o=new oi,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 Mr(t){let e=new WeakMap;function i(t,e){return e===ct?t.mapping=lt:e===ut&&(t.mapping=ht),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===ct||r===ut){if(e.has(s))return i(e.get(s).texture,s.mapping);{const r=s.image;if(r&&r.height>0){const a=new er(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 br extends Js{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 Sr=[.125,.215,.35,.446,.526,.582],wr=new br,Tr=new es;let Er=null,Ar=0,Cr=0;const Rr=(1+Math.sqrt(5))/2,Pr=1/Rr,Lr=[new Oi(1,1,1),new Oi(-1,1,1),new Oi(1,1,-1),new Oi(-1,1,-1),new Oi(0,Rr,Pr),new Oi(0,Rr,-Pr),new Oi(Pr,0,Rr),new Oi(-Pr,0,Rr),new Oi(Rr,Pr,0),new Oi(-Rr,Pr,0)];class Ir{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){Er=this._renderer.getRenderTarget(),Ar=this._renderer.getActiveCubeFace(),Cr=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=Or(),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(Er,Ar,Cr),t.scissorTest=!1,Nr(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===lt||t.mapping===ht?this._setSize(0===t.image.length?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Er=this._renderer.getRenderTarget(),Ar=this._renderer.getActiveCubeFace(),Cr=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:yt,minFilter:yt,generateMipmaps:!1,type:At,format:Lt,colorSpace:Te,depthBuffer:!1},n=Dr(t,e,i);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=Dr(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+Sr.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=Sr[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 ws;x.setAttribute("position",new ps(_,m)),x.setAttribute("uv",new ps(v,f)),x.setAttribute("faceIndex",new ps(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 Oi(0,1,0);return new Zs({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 Gs(this._lodPlanes[0],t);this._renderer.compile(e,wr)}_sceneToCubeUV(t,e,i,n){const s=new Ks(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(Tr),o.toneMapping=0,o.autoClear=!1;const c=new rs({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),u=new Gs(new Ws,c);let d=!1;const p=t.background;p?p.isColor&&(c.color.copy(p),t.background=null,d=!0):(c.color.copy(Tr),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;Nr(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===lt||t.mapping===ht;n?(null===this._cubemapMaterial&&(this._cubemapMaterial=Or()),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 Gs(this._lodPlanes[0],s);s.uniforms.envMap.value=t;const a=this._cubeSize;Nr(e,0,0,3*a,2*a),i.setRenderTarget(e),i.render(r,wr)}_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=Lr[(n-1)%Lr.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 Gs(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];Nr(e,3*v*(n>_-4?n-_+4:0),4*(this._cubeSize-v),3*v,2*v),o.setRenderTarget(e),o.render(h,wr)}}function Dr(t,e,i){const n=new Ii(t,e,i);return n.texture.mapping=dt,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Nr(t,e,i,n,s){t.viewport.set(e,i,n,s),t.scissor.set(e,i,n,s)}function Ur(){return new Zs({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 Or(){return new Zs({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 Fr(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===ct||r===ut,o=r===lt||r===ht;if(a||o){if(s.isRenderTargetTexture&&!0===s.needsPMREMUpdate){s.needsPMREMUpdate=!1;let n=e.get(s);return null===i&&(i=new Ir(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 Ir(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 Br(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 zr(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(hi(i)?fs:ms)(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 kr(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 Vr(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 Gr(t,e){return t[0]-e[0]}function Hr(t,e){return Math.abs(e[1])-Math.abs(t[1])}function Wr(t,e,i){const n={},s=new Float32Array(8),r=new WeakMap,a=new Pi,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 Di(g,m,f,s);_.type=Et,_.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 ai(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(Hr);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(Gr);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 qr(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 Xr extends Ri{constructor(t,e,i,n,s,r,a,o,l,h){if((h=void 0!==h?h:It)!==It&&h!==Dt)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===i&&h===It&&(i=Tt),void 0===i&&h===Dt&&(i=Pt),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:gt,this.minFilter=void 0!==o?o:gt,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 jr=new Ri,Yr=new Xr(1,1);Yr.compareFunction=515;const Zr=new Di,Jr=new Ni,Kr=new tr,$r=[],Qr=[],ta=new Float32Array(16),ea=new Float32Array(9),ia=new Float32Array(4);function na(t,e,i){const n=t[0];if(n<=0||n>0)return t;const s=e*i;let r=$r[s];if(void 0===r&&(r=new Float32Array(s),$r[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 sa(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 ra(t,e){for(let i=0,n=e.length;i<n;i++)t[i]=e[i]}function aa(t,e){let i=Qr[e];void 0===i&&(i=new Int32Array(e),Qr[e]=i);for(let n=0;n!==e;++n)i[n]=t.allocateTextureUnit();return i}function oa(t,e){const i=this.cache;i[0]!==e&&(t.uniform1f(this.addr,e),i[0]=e)}function la(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(sa(i,e))return;t.uniform2fv(this.addr,e),ra(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||(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(sa(i,e))return;t.uniform3fv(this.addr,e),ra(i,e)}}function ca(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(sa(i,e))return;t.uniform4fv(this.addr,e),ra(i,e)}}function ua(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(sa(i,e))return;t.uniformMatrix2fv(this.addr,!1,e),ra(i,e)}else{if(sa(i,n))return;ia.set(n),t.uniformMatrix2fv(this.addr,!1,ia),ra(i,n)}}function da(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(sa(i,e))return;t.uniformMatrix3fv(this.addr,!1,e),ra(i,e)}else{if(sa(i,n))return;ea.set(n),t.uniformMatrix3fv(this.addr,!1,ea),ra(i,n)}}function pa(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(sa(i,e))return;t.uniformMatrix4fv(this.addr,!1,e),ra(i,e)}else{if(sa(i,n))return;ta.set(n),t.uniformMatrix4fv(this.addr,!1,ta),ra(i,n)}}function ma(t,e){const i=this.cache;i[0]!==e&&(t.uniform1i(this.addr,e),i[0]=e)}function fa(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(sa(i,e))return;t.uniform2iv(this.addr,e),ra(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||(t.uniform3i(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else{if(sa(i,e))return;t.uniform3iv(this.addr,e),ra(i,e)}}function _a(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(sa(i,e))return;t.uniform4iv(this.addr,e),ra(i,e)}}function va(t,e){const i=this.cache;i[0]!==e&&(t.uniform1ui(this.addr,e),i[0]=e)}function ya(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(sa(i,e))return;t.uniform2uiv(this.addr,e),ra(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||(t.uniform3ui(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else{if(sa(i,e))return;t.uniform3uiv(this.addr,e),ra(i,e)}}function Ma(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(sa(i,e))return;t.uniform4uiv(this.addr,e),ra(i,e)}}function ba(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?Yr:jr;i.setTexture2D(e||r,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.setTexture3D(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.setTextureCube(e||Kr,s)}function Ta(t,e,i){const n=this.cache,s=i.allocateTextureUnit();n[0]!==s&&(t.uniform1i(this.addr,s),n[0]=s),i.setTexture2DArray(e||Zr,s)}function Ea(t,e){t.uniform1fv(this.addr,e)}function Aa(t,e){const i=na(e,this.size,2);t.uniform2fv(this.addr,i)}function Ca(t,e){const i=na(e,this.size,3);t.uniform3fv(this.addr,i)}function Ra(t,e){const i=na(e,this.size,4);t.uniform4fv(this.addr,i)}function Pa(t,e){const i=na(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,i)}function La(t,e){const i=na(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,i)}function Ia(t,e){const i=na(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,i)}function Da(t,e){t.uniform1iv(this.addr,e)}function Na(t,e){t.uniform2iv(this.addr,e)}function Ua(t,e){t.uniform3iv(this.addr,e)}function Oa(t,e){t.uniform4iv(this.addr,e)}function Fa(t,e){t.uniform1uiv(this.addr,e)}function Ba(t,e){t.uniform2uiv(this.addr,e)}function za(t,e){t.uniform3uiv(this.addr,e)}function ka(t,e){t.uniform4uiv(this.addr,e)}function Va(t,e,i){const n=this.cache,s=e.length,r=aa(i,s);sa(n,r)||(t.uniform1iv(this.addr,r),ra(n,r));for(let a=0;a!==s;++a)i.setTexture2D(e[a]||jr,r[a])}function Ga(t,e,i){const n=this.cache,s=e.length,r=aa(i,s);sa(n,r)||(t.uniform1iv(this.addr,r),ra(n,r));for(let a=0;a!==s;++a)i.setTexture3D(e[a]||Jr,r[a])}function Ha(t,e,i){const n=this.cache,s=e.length,r=aa(i,s);sa(n,r)||(t.uniform1iv(this.addr,r),ra(n,r));for(let a=0;a!==s;++a)i.setTextureCube(e[a]||Kr,r[a])}function Wa(t,e,i){const n=this.cache,s=e.length,r=aa(i,s);sa(n,r)||(t.uniform1iv(this.addr,r),ra(n,r));for(let a=0;a!==s;++a)i.setTexture2DArray(e[a]||Zr,r[a])}class qa{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 oa;case 35664:return la;case 35665:return ha;case 35666:return ca;case 35674:return ua;case 35675:return da;case 35676:return pa;case 5124:case 35670:return ma;case 35667:case 35671:return fa;case 35668:case 35672:return ga;case 35669:case 35673:return _a;case 5125:return va;case 36294:return ya;case 36295:return xa;case 36296:return Ma;case 35678:case 36198:case 36298:case 36306:case 35682:return ba;case 35679:case 36299:case 36307:return Sa;case 35680:case 36300:case 36308:case 36293:return wa;case 36289:case 36303:case 36311:case 36292:return Ta}}(e.type)}}class Xa{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 Ea;case 35664:return Aa;case 35665:return Ca;case 35666:return Ra;case 35674:return Pa;case 35675:return La;case 35676:return Ia;case 5124:case 35670:return Da;case 35667:case 35671:return Na;case 35668:case 35672:return Ua;case 35669:case 35673:return Oa;case 5125:return Fa;case 36294:return Ba;case 36295:return za;case 36296:return ka;case 35678:case 36198:case 36298:case 36306:case 35682:return Va;case 35679:case 36299:case 36307:return Ga;case 35680:case 36300:case 36308:case 36293:return Ha;case 36289:case 36303:case 36311:case 36292:return Wa}}(e.type)}}class ja{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 Ya=/(\w+)(\])?(\[|\.)?/g;function Za(t,e){t.seq.push(e),t.map[e.id]=e}function Ja(t,e,i){const n=t.name,s=n.length;for(Ya.lastIndex=0;;){const r=Ya.exec(n),a=Ya.lastIndex;let o=r[1];const l="]"===r[2],h=r[3];if(l&&(o|=0),void 0===h||"["===h&&a+2===s){Za(i,void 0===h?new qa(o,t,e):new Xa(o,t,e));break}{let t=i.map[o];void 0===t&&(t=new ja(o),Za(i,t)),i=t}}}class Ka{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);Ja(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 $a(t,e,i){const n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),n}let Qa=0;function to(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 eo(t,e){const i=function(t){const e=xi.getPrimaries(xi.workingColorSpace),i=xi.getPrimaries(t);let n;switch(e===i?n="":e===Le&&i===Pe?n="LinearDisplayP3ToLinearSRGB":e===Pe&&i===Le&&(n="LinearSRGBToLinearDisplayP3"),t){case Te:case Ae:return[n,"LinearTransferOETF"];case we:case Ee:return[n,"sRGBTransferOETF"];default:return[n,"LinearTransferOETF"]}}(e);return`vec4 ${t}( vec4 value ) { return ${i[0]}( ${i[1]}( value ) ); }`}function io(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 no(t){return""!==t}function so(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 ro(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const ao=/^[ \t]*#include +<([\w\d./]+)>/gm;function oo(t){return t.replace(ao,ho)}const lo=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function ho(t,e){let i=dr[e];if(void 0===i){const t=lo.get(e);if(void 0===t)throw new Error("Can not resolve #include <"+e+">");i=dr[t]}return oo(i)}const co=/#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 uo(t){return t.replace(co,po)}function po(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 mo(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 fo(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 lt:case ht:e="ENVMAP_TYPE_CUBE";break;case dt:e="ENVMAP_TYPE_CUBE_UV"}return e}(i),c=function(t){let e="ENVMAP_MODE_REFLECTION";return t.envMap&&t.envMapMode===ht&&(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(no).join("\n")}(i),m=function(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":""].filter(no).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(no).join("\n"),_.length>0&&(_+="\n"),v=[p,"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,f].filter(no).join("\n"),v.length>0&&(v+="\n")):(_=[mo(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(no).join("\n"),v=[p,mo(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?dr.tonemapping_pars_fragment:"",0!==i.toneMapping?io("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",dr.colorspace_pars_fragment,eo("linearToOutputTexel",i.outputColorSpace),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(no).join("\n")),a=oo(a),a=so(a,i),a=ro(a,i),o=oo(o),o=so(o,i),o=ro(o,i),a=uo(a),o=uo(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===Ge?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===Ge?"":"#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=$a(s,s.VERTEX_SHADER,x),S=$a(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):(to(s,b,"vertex"),to(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 Ka(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=Qa++,this.cacheKey=e,this.usedTimes=1,this.program=g,this.vertexShader=b,this.fragmentShader=S,this}let go=0;class _o{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 vo(t),e.set(t,i)),i}}class vo{constructor(t){this.id=go++,this.code=t,this.usedTimes=0}}function yo(t,e,i,n,s,r,a){const o=new wn,l=new _o,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===dt?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=mr[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,ut=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:Te,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:ut,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&&xi.getTransfer(r.map.colorSpace)===Re,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=mr[e];i=Ys.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 fo(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 xo(){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 Mo(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 bo(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 So(){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||Mo),n.length>1&&n.sort(e||bo),s.length>1&&s.sort(e||bo)}}}function wo(){let t=new WeakMap;return{get(e,i){const n=t.get(e);let s;return void 0===n?(s=new So,t.set(e,[s])):i>=n.length?(s=new So,n.push(s)):s=n[i],s},dispose(){t=new WeakMap}}}function To(){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 Oi,color:new es};break;case"SpotLight":i={position:new Oi,direction:new Oi,color:new es,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new Oi,color:new es,distance:0,decay:0};break;case"HemisphereLight":i={direction:new Oi,skyColor:new es,groundColor:new es};break;case"RectAreaLight":i={color:new es,position:new Oi,halfWidth:new Oi,halfHeight:new Oi}}return t[e.id]=i,i}}}let Eo=0;function Ao(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function Co(t,e){const i=new To,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 ai};break;case"PointLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ai,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 Oi);const r=new Oi,a=new pn,o=new pn;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(Ao);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=pr.LTC_FLOAT_1,s.rectAreaLTC2=pr.LTC_FLOAT_2):(s.rectAreaLTC1=pr.LTC_HALF_1,s.rectAreaLTC2=pr.LTC_HALF_2):!0===t.has("OES_texture_float_linear")?(s.rectAreaLTC1=pr.LTC_FLOAT_1,s.rectAreaLTC2=pr.LTC_FLOAT_2):!0===t.has("OES_texture_half_float_linear")&&(s.rectAreaLTC1=pr.LTC_HALF_1,s.rectAreaLTC2=pr.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=Eo++)},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 Ro(t,e){const i=new Co(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 Po(t,e){let i=new WeakMap;return{get(n,s=0){const r=i.get(n);let a;return void 0===r?(a=new Ro(t,e),i.set(n,[a])):s>=r.length?(a=new Ro(t,e),r.push(a)):a=r[s],a},dispose(){i=new WeakMap}}}class Lo extends ss{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 Io extends ss{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 Do(t,e,i){let n=new lr;const s=new ai,r=new ai,a=new Pi,o=new Lo({depthPacking:3201}),l=new Io,h={},c=i.maxTextureSize,u={[B]:1,[z]:0,[k]:2},d=new Zs({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ai},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 ws;m.setAttribute("position",new ps(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const f=new Gs(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 Ii(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:gt,magFilter:gt}:{};null!==h.map&&h.map.dispose(),h.map=new Ii(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 No(t,e,i){const n=i.isWebGL2,s=new function(){let e=!1;const i=new Pi;let n=null;const s=new Pi(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 es(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 Pi).fromArray(O),z=(new Pi).fromArray(F);function k(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]=k(t.TEXTURE_2D,t.TEXTURE_2D,1),rt[t.TEXTURE_CUBE_MAP]=k(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),n&&(rt[t.TEXTURE_2D_ARRAY]=k(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),rt[t.TEXTURE_3D]=k(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={[V]:t.FUNC_ADD,[G]:t.FUNC_SUBTRACT,[H]: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={[W]:t.ZERO,[q]:t.ONE,[X]:t.SRC_COLOR,[Y]:t.SRC_ALPHA,[tt]:t.SRC_ALPHA_SATURATE,[$]:t.DST_COLOR,[J]:t.DST_ALPHA,[j]:t.ONE_MINUS_SRC_COLOR,[Z]:t.ONE_MINUS_SRC_ALPHA,[Q]:t.ONE_MINUS_DST_COLOR,[K]:t.ONE_MINUS_DST_ALPHA,[et]:t.CONSTANT_COLOR,[it]:t.ONE_MINUS_CONSTANT_COLOR,[nt]:t.CONSTANT_ALPHA,[st]: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===V&&y===V||(t.blendEquation(t.FUNC_ADD),g=V,y=V),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 es(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):di("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?ii: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 ei(t.width)&&ei(t.height)}function _(t,e){return t.generateMipmaps&&e&&t.minFilter!==gt&&t.minFilter!==yt}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?Ce:xi.getTransfer(r);s===t.FLOAT&&(l=t.RGBA32F),s===t.HALF_FLOAT&&(l=t.RGBA16F),s===t.UNSIGNED_BYTE&&(l=e===Re?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!==gt&&t.minFilter!==yt?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===gt||e===_t||e===vt?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={[pt]:t.REPEAT,[mt]:t.CLAMP_TO_EDGE,[ft]:t.MIRRORED_REPEAT},C={[gt]:t.NEAREST,[_t]:t.NEAREST_MIPMAP_NEAREST,[vt]:t.NEAREST_MIPMAP_LINEAR,[yt]:t.LINEAR,[xt]:t.LINEAR_MIPMAP_NEAREST,[Mt]:t.LINEAR_MIPMAP_LINEAR},R={[De]:t.NEVER,[ke]:t.ALWAYS,[Ne]:t.LESS,[Oe]:t.LEQUAL,[Ue]:t.EQUAL,[ze]:t.GEQUAL,[Fe]:t.GREATER,[Be]: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!==mt||r.wrapT,t.texParameteri(i,t.TEXTURE_MAG_FILTER,M(r.magFilter)),t.texParameteri(i,t.TEXTURE_MIN_FILTER,M(r.minFilter)),r.minFilter!==gt&&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===gt)return;if(r.minFilter!==vt&&r.minFilter!==Mt)return;if(r.type===Et&&!1===e.has("OES_texture_float_linear"))return;if(!1===o&&r.type===At&&!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=xi.getPrimaries(xi.workingColorSpace),n=a.colorSpace===Se?null:xi.getPrimaries(a.colorSpace),p=a.colorSpace===Se||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!==mt||t.wrapT!==mt||t.minFilter!==gt&&t.minFilter!==yt)}(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!==qt,R=void 0===d.__version||!0===c,L=x(a,M,b);if(a.isDepthTexture)E=t.DEPTH_COMPONENT,o?E=a.type===Et?t.DEPTH_COMPONENT32F:a.type===Tt?t.DEPTH_COMPONENT24:a.type===Pt?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT16:a.type,a.format===It&&E===t.DEPTH_COMPONENT&&a.type!==St&&a.type!==Tt&&(a.type=Tt,T=r.convert(a.type)),a.format===Dt&&E===t.DEPTH_COMPONENT&&(E=t.DEPTH_STENCIL,a.type!==Pt&&(a.type=Pt,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!==Lt?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!==Lt?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===Et?s=t.DEPTH_COMPONENT32F:e.type===Tt&&(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===It)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!==Dt)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===He||n!==Te&&n!==Se&&xi.getTransfer(n)===Re&&!1===o&&(!0===e.has("EXT_sRGB")&&s===Lt?(t.format=He,t.minFilter=yt,t.generateMipmaps=!1):i=wi.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=xi.getPrimaries(xi.workingColorSpace),n=a.colorSpace===Se?null:xi.getPrimaries(a.colorSpace),d=a.colorSpace===Se||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!==Lt?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 Oo(t,e,i){const n=i.isWebGL2;return{convert(i,s=""){let r;const a=xi.getTransfer(s);if(i===bt)return t.UNSIGNED_BYTE;if(i===Ct)return t.UNSIGNED_SHORT_4_4_4_4;if(i===Rt)return t.UNSIGNED_SHORT_5_5_5_1;if(1010===i)return t.BYTE;if(1011===i)return t.SHORT;if(i===St)return t.UNSIGNED_SHORT;if(i===wt)return t.INT;if(i===Tt)return t.UNSIGNED_INT;if(i===Et)return t.FLOAT;if(i===At)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===Lt)return t.RGBA;if(1024===i)return t.LUMINANCE;if(1025===i)return t.LUMINANCE_ALPHA;if(i===It)return t.DEPTH_COMPONENT;if(i===Dt)return t.DEPTH_STENCIL;if(i===He)return r=e.get("EXT_sRGB"),null!==r?r.SRGB_ALPHA_EXT:null;if(1028===i)return t.RED;if(i===Nt)return t.RED_INTEGER;if(1030===i)return t.RG;if(i===Ut)return t.RG_INTEGER;if(i===Ot)return t.RGBA_INTEGER;if(i===Ft||i===Bt||i===zt||i===kt)if(a===Re){if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),null===r)return null;if(i===Ft)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Bt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===zt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===kt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(r=e.get("WEBGL_compressed_texture_s3tc"),null===r)return null;if(i===Ft)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Bt)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===zt)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===kt)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(i===Vt||i===Gt||i===Ht||i===Wt){if(r=e.get("WEBGL_compressed_texture_pvrtc"),null===r)return null;if(i===Vt)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Gt)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Ht)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Wt)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(i===qt)return r=e.get("WEBGL_compressed_texture_etc1"),null!==r?r.COMPRESSED_RGB_ETC1_WEBGL:null;if(i===Xt||i===jt){if(r=e.get("WEBGL_compressed_texture_etc"),null===r)return null;if(i===Xt)return a===Re?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===jt)return a===Re?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}if(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||i===oe){if(r=e.get("WEBGL_compressed_texture_astc"),null===r)return null;if(i===Yt)return a===Re?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Zt)return a===Re?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Jt)return a===Re?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Kt)return a===Re?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===$t)return a===Re?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Qt)return a===Re?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===te)return a===Re?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===ee)return a===Re?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===ie)return a===Re?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===ne)return a===Re?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===se)return a===Re?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===re)return a===Re?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===ae)return a===Re?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===oe)return a===Re?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}if(i===le||i===he||i===ce){if(r=e.get("EXT_texture_compression_bptc"),null===r)return null;if(i===le)return a===Re?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===he)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===ce)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(36283===i||i===ue||i===de||i===pe){if(r=e.get("EXT_texture_compression_rgtc"),null===r)return null;if(i===le)return r.COMPRESSED_RED_RGTC1_EXT;if(i===ue)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===de)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===pe)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return i===Pt?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 Fo extends Ks{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}class Bo extends Bn{constructor(){super(),this.isGroup=!0,this.type="Group"}}const zo={type:"move"};class ko{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new Bo,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 Bo,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Oi,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Oi),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new Bo,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Oi,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Oi),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(zo)))}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 Bo;i.matrixAutoUpdate=!1,i.visible=!1,t.joints[e.jointName]=i,t.add(i)}return t.joints[e.jointName]}}class Vo extends Xe{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 ai;let x=null;const M=new Ks;M.layers.enable(1),M.viewport=new Pi;const b=new Ks;b.layers.enable(2),b.viewport=new Pi;const S=[M,b],w=new Fo;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 ko,_[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=_[t];return void 0===e&&(e=new ko,_[t]=e),e.getGripSpace()},this.getHand=function(t){let e=_[t];return void 0===e&&(e=new ko,_[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 Ii(d.framebufferWidth,d.framebufferHeight,{format:Lt,type:bt,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?Dt:It,r=m.stencil?Pt:Tt);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 Ii(u.textureWidth,u.textureHeight,{format:Lt,type:bt,depthTexture:new Xr(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 Oi,L=new Oi;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*Je*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 hr;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 Ks,a.layers.enable(n),a.viewport=new Pi,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 Go(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,js(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 Ho(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 Wo{constructor(t={}){const{canvas:e=pi(),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=we,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 Pi,E=new Pi;let A=null;const C=new es(0);let R=0,P=e.width,L=e.height,I=1,D=null,N=null;const U=new Pi(0,0,P,L),O=new Pi(0,0,P,L);let B=!1;const z=new lr;let k=!1,V=!1,G=null;const H=new pn,W=new ai,q=new Oi,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${F}`),e.addEventListener("webglcontextlost",It,!1),e.addEventListener("webglcontextrestored",Dt,!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 xt(){Y=new Br(vt),Z=new yr(vt,Y,t),Y.init(Z),ft=new Oo(vt,Y,Z),J=new No(vt,Y,Z),K=new Vr(vt),$=new xo,Q=new Uo(vt,Y,J,$,Z,ft,K),tt=new Mr(v),et=new Fr(v),it=new cr(vt,Z),gt=new _r(vt,Y,it,Z),nt=new zr(vt,it,K,gt),st=new qr(vt,nt,it,K),dt=new Wr(vt,Z,Q),ht=new xr($),rt=new yo(v,tt,et,Y,Z,gt,ht),at=new Go(v,$),ot=new wo,lt=new Po(Y,Z),ut=new gr(v,tt,et,J,st,u,o),ct=new Do(v,st,Z),_t=new Ho(vt,K,Z,J),pt=new vr(vt,Y,K,Z),mt=new kr(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}xt();const wt=new Vo(v,vt);function It(t){t.preventDefault(),y=!0}function Dt(){y=!1;const t=K.autoReset,e=ct.enabled,i=ct.autoUpdate,n=ct.needsUpdate,s=ct.type;xt(),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=wt,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){wt.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(O)},this.setScissor=function(t,e,i,n){t.isVector4?O.set(t.x,t.y,t.z,t.w):O.set(t,e,i,n),J.scissor(E.copy(O).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===Ot||e===Ut||e===Nt}if(t){const t=b.texture.type,e=t===bt||t===Tt||t===St||t===Pt||t===Ct||t===Rt,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",Dt,!1),e.removeEventListener("webglcontextcreationerror",Ft,!1),ot.dispose(),lt.dispose(),$.dispose(),tt.dispose(),et.dispose(),st.dispose(),gt.dispose(),_t.dispose(),rt.dispose(),wt.dispose(),wt.removeEventListener("sessionstart",Vt),wt.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:Te,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),Ka.upload(vt,Zt(y),P,Q)),n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(Ka.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 hr;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 Ii(1,1,{generateMipmaps:!0,type:Y.has("EXT_color_buffer_half_float")?At:bt,minFilter:Mt,samples:s?4:0})),v.getDrawingBufferSize(W),s?G.setSize(W.x,W.y):G.setSize(ii(W.x),ii(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=Ka.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,wt.setAnimationLoop(t),null===t?Ht.stop():Ht.start()},wt.addEventListener("sessionstart",Vt),wt.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===wt.enabled&&!0===wt.isPresenting&&(!0===wt.cameraAutoUpdate&&wt.updateCamera(e),e=wt.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(O).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!==Lt&&ft.convert(o)!==vt.getParameter(vt.IMPLEMENTATION_COLOR_READ_FORMAT))return;const h=l===At&&(Y.has("EXT_color_buffer_half_float")||Z.isWebGL2&&Y.has("EXT_color_buffer_float"));if(!(l===bt||ft.convert(l)===vt.getParameter(vt.IMPLEMENTATION_COLOR_READ_TYPE)||l===Et&&(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 We}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=t===Ee?"display-p3":"srgb",e.unpackColorSpace=xi.workingColorSpace===Ae?"display-p3":"srgb"}get outputEncoding(){return this.outputColorSpace===we?be:Me}set outputEncoding(t){this.outputColorSpace=t===be?we:Te}get useLegacyLights(){return this._useLegacyLights}set useLegacyLights(t){this._useLegacyLights=t}}class qo extends Wo{}qo.prototype.isWebGL1Renderer=!0;class Xo{constructor(t,e=25e-5){this.isFogExp2=!0,this.name="",this.color=new es(t),this.density=e}clone(){return new Xo(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class jo{constructor(t,e=1,i=1e3){this.isFog=!0,this.name="",this.color=new es(t),this.near=e,this.far=i}clone(){return new jo(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Yo extends Bn{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 Zo{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=Ve,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Ke()}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=Ke()),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=Ke()),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 Jo=new Oi;class Ko{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++)Jo.fromBufferAttribute(this,e),Jo.applyMatrix4(t),this.setXYZ(e,Jo.x,Jo.y,Jo.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)Jo.fromBufferAttribute(this,e),Jo.applyNormalMatrix(t),this.setXYZ(e,Jo.x,Jo.y,Jo.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)Jo.fromBufferAttribute(this,e),Jo.transformDirection(t),this.setXYZ(e,Jo.x,Jo.y,Jo.z);return this}setX(t,e){return this.normalized&&(e=si(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=si(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=si(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=si(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=ni(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=ni(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=ni(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=ni(e,this.array)),e}setXY(t,e,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=si(e,this.array),i=si(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=si(e,this.array),i=si(i,this.array),n=si(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=si(e,this.array),i=si(i,this.array),n=si(n,this.array),s=si(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 ps(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 Ko(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 $o extends ss{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new es(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 Qo;const tl=new Oi,el=new Oi,il=new Oi,nl=new ai,sl=new ai,rl=new pn,al=new Oi,ol=new Oi,ll=new Oi,hl=new ai,cl=new ai,ul=new ai;class dl extends Bn{constructor(t=new $o){if(super(),this.isSprite=!0,this.type="Sprite",void 0===Qo){Qo=new ws;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 Zo(t,5);Qo.setIndex([0,1,2,0,2,3]),Qo.setAttribute("position",new Ko(e,3,0,!1)),Qo.setAttribute("uv",new Ko(e,2,3,!1))}this.geometry=Qo,this.material=t,this.center=new ai(.5,.5)}raycast(t,e){t.camera,el.setFromMatrixScale(this.matrixWorld),rl.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),il.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&el.multiplyScalar(-il.z);const i=this.material.rotation;let n,s;0!==i&&(s=Math.cos(i),n=Math.sin(i));const r=this.center;pl(al.set(-.5,-.5,0),il,r,el,n,s),pl(ol.set(.5,-.5,0),il,r,el,n,s),pl(ll.set(.5,.5,0),il,r,el,n,s),hl.set(0,0),cl.set(1,0),ul.set(1,1);let a=t.ray.intersectTriangle(al,ol,ll,!1,tl);if(null===a&&(pl(ol.set(-.5,.5,0),il,r,el,n,s),cl.set(0,1),a=t.ray.intersectTriangle(al,ll,ol,!1,tl),null===a))return;const o=t.ray.origin.distanceTo(tl);o<t.near||o>t.far||e.push({distance:o,point:tl.clone(),uv:Jn.getInterpolation(tl,al,ol,ll,hl,cl,ul,new ai),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 pl(t,e,i,n,s,r){nl.subVectors(t,i).addScalar(.5).multiply(n),void 0!==s?(sl.x=r*nl.x-s*nl.y,sl.y=s*nl.x+r*nl.y):sl.copy(nl),t.copy(e),t.x+=sl.x,t.y+=sl.y,t.applyMatrix4(rl)}const ml=new Oi,fl=new Oi;class gl extends Bn{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){ml.setFromMatrixPosition(this.matrixWorld);const i=t.ray.origin.distanceTo(ml);this.getObjectForDistance(i).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){ml.setFromMatrixPosition(t.matrixWorld),fl.setFromMatrixPosition(this.matrixWorld);const i=ml.distanceTo(fl)/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 _l=new Oi,vl=new Pi,yl=new Pi,xl=new Oi,Ml=new pn,bl=new Oi,Sl=new sn,wl=new pn,Tl=new dn;class El extends Gs{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=rt,this.bindMatrix=new pn,this.bindMatrixInverse=new pn,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;null===this.boundingBox&&(this.boundingBox=new zi),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let i=0;i<e.count;i++)this.getVertexPosition(i,bl),this.boundingBox.expandByPoint(bl)}computeBoundingSphere(){const t=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new sn),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let i=0;i<e.count;i++)this.getVertexPosition(i,bl),this.boundingSphere.expandByPoint(bl)}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(),Sl.copy(this.boundingSphere),Sl.applyMatrix4(n),!1!==t.ray.intersectsSphere(Sl)&&(wl.copy(n).invert(),Tl.copy(t.ray).applyMatrix4(wl),null!==this.boundingBox&&!1===Tl.intersectsBox(this.boundingBox)||this._computeIntersections(t,e,Tl)))}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 Pi,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===rt?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===at&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}applyBoneTransform(t,e){const i=this.skeleton,n=this.geometry;vl.fromBufferAttribute(n.attributes.skinIndex,t),yl.fromBufferAttribute(n.attributes.skinWeight,t),_l.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let s=0;s<4;s++){const t=yl.getComponent(s);if(0!==t){const n=vl.getComponent(s);Ml.multiplyMatrices(i.bones[n].matrixWorld,i.boneInverses[n]),e.addScaledVector(xl.copy(_l).applyMatrix4(Ml),t)}}return e.applyMatrix4(this.bindMatrixInverse)}boneTransform(t,e){return this.applyBoneTransform(t,e)}}class Al extends Bn{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Cl extends Ri{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 Rl=new pn,Pl=new pn;class Ll{constructor(t=[],e=[]){this.uuid=Ke(),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 pn)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const e=new pn;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:Pl;Rl.multiplyMatrices(n,e[s]),Rl.toArray(i,16*s)}null!==n&&(n.needsUpdate=!0)}clone(){return new Ll(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 Cl(e,t,t,Lt,Et);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 Al),this.bones.push(n),this.boneInverses.push((new pn).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 Il extends ps{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 Dl=new pn,Nl=new pn,Ul=[],Ol=new zi,Fl=new pn,Bl=new Gs,zl=new sn;class kl extends Gs{constructor(t,e,i){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new Il(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,Fl)}computeBoundingBox(){const t=this.geometry,e=this.count;null===this.boundingBox&&(this.boundingBox=new zi),null===t.boundingBox&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<e;i++)this.getMatrixAt(i,Dl),Ol.copy(t.boundingBox).applyMatrix4(Dl),this.boundingBox.union(Ol)}computeBoundingSphere(){const t=this.geometry,e=this.count;null===this.boundingSphere&&(this.boundingSphere=new sn),null===t.boundingSphere&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<e;i++)this.getMatrixAt(i,Dl),zl.copy(t.boundingSphere).applyMatrix4(Dl),this.boundingSphere.union(zl)}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(Bl.geometry=this.geometry,Bl.material=this.material,void 0!==Bl.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),zl.copy(this.boundingSphere),zl.applyMatrix4(i),!1!==t.ray.intersectsSphere(zl)))for(let s=0;s<n;s++){this.getMatrixAt(s,Dl),Nl.multiplyMatrices(i,Dl),Bl.matrixWorld=Nl,Bl.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 Il(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 Vl(t,e){return t.z-e.z}function Gl(t,e){return e.z-t.z}class Hl{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 Wl="batchId",ql=new pn,Xl=new pn,jl=new pn,Yl=new pn,Zl=new lr,Jl=new zi,Kl=new sn,$l=new Oi,Ql=new Hl,th=new Gs,eh=[];function ih(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 nh extends Gs{get maxGeometryCount(){return this._maxGeometryCount}constructor(t,e,i=2*e,n){super(new ws,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 Cl(e,t,t,Lt,Et);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 ps(t,1))}const r=n>65536?new Uint32Array(i):new Uint16Array(i);e.setAttribute(Wl,new ps(r,1)),this._geometryInitialized=!0}}_validateGeometry(t){if(t.getAttribute(Wl))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Wl}"`);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===Wl)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 zi);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,ql),this.getBoundingBoxAt(n,Jl).applyMatrix4(ql),e.union(Jl))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new sn);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,ql),this.getBoundingSphereAt(n,Kl).applyMatrix4(ql),e.union(Kl))}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++,jl.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 zi,sphereInitialized:!1,sphere:new sn});const f=this.geometry.getAttribute(Wl);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===Wl)continue;const t=e.getAttribute(d),n=i.getAttribute(d);ih(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($l.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,Jl),Jl.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)),$l.fromBufferAttribute(r,i),o=Math.max(o,n.center.distanceToSquared($l))}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;th.material=this.material,th.geometry.index=o.index,th.geometry.attributes=o.attributes,null===th.geometry.boundingBox&&(th.geometry.boundingBox=new zi),null===th.geometry.boundingSphere&&(th.geometry.boundingSphere=new sn);for(let l=0;l<r;l++){if(!i[l]||!n[l])continue;const r=s[l];th.geometry.setDrawRange(r.start,r.count),this.getMatrixAt(l,th.matrixWorld).premultiply(a),this.getBoundingBoxAt(l,th.geometry.boundingBox),this.getBoundingSphereAt(l,th.geometry.boundingSphere),th.raycast(t,eh);for(let t=0,i=eh.length;t<i;t++){const i=eh[t];i.object=this,i.batchId=l,e.push(i)}eh.length=0}th.material=null,th.geometry.index=null,th.geometry.attributes={},th.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&&(Yl.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),Zl.setFromProjectionMatrix(Yl,t.isWebGPURenderer?qe:We));let d=0;if(this.sortObjects){Xl.copy(this.matrixWorld).invert(),$l.setFromMatrixPosition(i.matrixWorld).applyMatrix4(Xl);for(let i=0,n=o.length;i<n;i++)if(o[i]){this.getMatrixAt(i,ql),this.getBoundingSphereAt(i,Kl).applyMatrix4(ql);let t=!1;if(u&&(t=!Zl.intersectsSphere(Kl)),!t){const t=$l.distanceTo(Kl.center);Ql.push(c[i],t)}}const t=Ql.list,e=this.customSort;null===e?t.sort(s.transparent?Gl:Vl):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++}Ql.reset()}else for(let p=0,m=o.length;p<m;p++)if(o[p]){let t=!1;if(u&&(this.getMatrixAt(p,ql),this.getBoundingSphereAt(p,Kl).applyMatrix4(ql),t=!Zl.intersectsSphere(Kl)),!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 sh extends ss{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new es(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 rh=new Oi,ah=new Oi,oh=new pn,lh=new dn,hh=new sn;class ch extends Bn{constructor(t=new ws,e=new sh){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++)rh.fromBufferAttribute(e,t-1),ah.fromBufferAttribute(e,t),i[t]=i[t-1],i[t]+=rh.distanceTo(ah);t.setAttribute("lineDistance",new gs(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(),hh.copy(i.boundingSphere),hh.applyMatrix4(n),hh.radius+=s,!1===t.ray.intersectsSphere(hh))return;oh.copy(n).invert(),lh.copy(t.ray).applyMatrix4(oh);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=new Oi,h=new Oi,c=new Oi,u=new Oi,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),lh.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),lh.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 uh=new Oi,dh=new Oi;class ph extends ch{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)uh.fromBufferAttribute(e,t),dh.fromBufferAttribute(e,t+1),i[t]=0===t?0:i[t-1],i[t+1]=i[t]+uh.distanceTo(dh);t.setAttribute("lineDistance",new gs(i,1))}return this}}class mh extends ch{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}}class fh extends ss{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new es(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 gh=new pn,_h=new dn,vh=new sn,yh=new Oi;class xh extends Bn{constructor(t=new ws,e=new fh){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(),vh.copy(i.boundingSphere),vh.applyMatrix4(n),vh.radius+=s,!1===t.ray.intersectsSphere(vh))return;gh.copy(n).invert(),_h.copy(t.ray).applyMatrix4(gh);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);yh.fromBufferAttribute(h,i),Mh(yh,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++)yh.fromBufferAttribute(h,c),Mh(yh,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 Mh(t,e,i,n,s,r,a){const o=_h.distanceSqToPoint(t);if(o<i){const i=new Oi;_h.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 bh extends Ri{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 Sh{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 ai:new Oi);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 Oi,n=[],s=[],r=[],a=new Oi,o=new pn;for(let d=0;d<=t;d++){const e=d/t;n[d]=this.getTangentAt(e,new Oi)}s[0]=new Oi,r[0]=new Oi;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($e(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($e(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 wh extends Sh{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 ai,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 Th extends wh{constructor(t,e,i,n,s,r){super(t,e,i,i,n,s,r),this.isArcCurve=!0,this.type="ArcCurve"}}function Eh(){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 Ah=new Oi,Ch=new Eh,Rh=new Eh,Ph=new Eh;class Lh extends Sh{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 Oi){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]:(Ah.subVectors(n[0],n[1]).add(n[0]),a=Ah);const c=n[l%s],u=n[(l+1)%s];if(this.closed||l+2<s?o=n[(l+2)%s]:(Ah.subVectors(n[s-1],n[s-2]).add(n[s-1]),o=Ah),"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),Ch.initNonuniformCatmullRom(a.x,c.x,u.x,o.x,e,i,n),Rh.initNonuniformCatmullRom(a.y,c.y,u.y,o.y,e,i,n),Ph.initNonuniformCatmullRom(a.z,c.z,u.z,o.z,e,i,n)}else"catmullrom"===this.curveType&&(Ch.initCatmullRom(a.x,c.x,u.x,o.x,this.tension),Rh.initCatmullRom(a.y,c.y,u.y,o.y,this.tension),Ph.initCatmullRom(a.z,c.z,u.z,o.z,this.tension));return i.set(Ch.calc(h),Rh.calc(h),Ph.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 Oi).fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function Ih(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 Dh(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 Nh(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 Sh{constructor(t=new ai,e=new ai,i=new ai,n=new ai){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=i,this.v3=n}getPoint(t,e=new ai){const i=e,n=this.v0,s=this.v1,r=this.v2,a=this.v3;return i.set(Nh(t,n.x,s.x,r.x,a.x),Nh(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 Oh extends Sh{constructor(t=new Oi,e=new Oi,i=new Oi,n=new Oi){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=i,this.v3=n}getPoint(t,e=new Oi){const i=e,n=this.v0,s=this.v1,r=this.v2,a=this.v3;return i.set(Nh(t,n.x,s.x,r.x,a.x),Nh(t,n.y,s.y,r.y,a.y),Nh(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 Fh extends Sh{constructor(t=new ai,e=new ai){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new ai){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 ai){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 Sh{constructor(t=new Oi,e=new Oi){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new Oi){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 Oi){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 zh extends Sh{constructor(t=new ai,e=new ai,i=new ai){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=i}getPoint(t,e=new ai){const i=e,n=this.v0,s=this.v1,r=this.v2;return i.set(Dh(t,n.x,s.x,r.x),Dh(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 kh extends Sh{constructor(t=new Oi,e=new Oi,i=new Oi){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=i}getPoint(t,e=new Oi){const i=e,n=this.v0,s=this.v1,r=this.v2;return i.set(Dh(t,n.x,s.x,r.x),Dh(t,n.y,s.y,r.y),Dh(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 Vh extends Sh{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new ai){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(Ih(a,o.x,l.x,h.x,c.x),Ih(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 ai).fromArray(i))}return this}}var Gh=Object.freeze({__proto__:null,ArcCurve:Th,CatmullRomCurve3:Lh,CubicBezierCurve:Uh,CubicBezierCurve3:Oh,EllipseCurve:wh,LineCurve:Fh,LineCurve3:Bh,QuadraticBezierCurve:zh,QuadraticBezierCurve3:kh,SplineCurve:Vh});class Hh extends Sh{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 Gh[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 Gh[i.type]).fromJSON(i))}return this}}class Wh extends Hh{constructor(t){super(),this.type="Path",this.currentPoint=new ai,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 Fh(this.currentPoint.clone(),new ai(t,e));return this.curves.push(i),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,i,n){const s=new zh(this.currentPoint.clone(),new ai(t,e),new ai(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 ai(t,e),new ai(i,n),new ai(s,r));return this.curves.push(a),this.currentPoint.set(s,r),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),i=new Vh(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 wh(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 qh extends ws{constructor(t=[new ai(0,-.5),new ai(.5,0),new ai(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=$e(n,0,2*Math.PI);const s=[],r=[],a=[],o=[],l=[],h=1/e,c=new Oi,u=new ai,d=new Oi,p=new Oi,m=new Oi;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 gs(r,3)),this.setAttribute("uv",new gs(a,2)),this.setAttribute("normal",new gs(l,3))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new qh(t.points,t.segments,t.phiStart,t.phiLength)}}class Xh extends qh{constructor(t=1,e=1,i=4,n=8){const s=new Wh;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 Xh(t.radius,t.length,t.capSegments,t.radialSegments)}}class jh extends ws{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 Oi,h=new ai;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 gs(r,3)),this.setAttribute("normal",new gs(a,3)),this.setAttribute("uv",new gs(o,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new jh(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class Yh extends ws{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 ai,m=new Oi;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 Oi,_=new Oi;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 gs(c,3)),this.setAttribute("normal",new gs(u,3)),this.setAttribute("uv",new gs(d,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Yh(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Zh extends Yh{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 Zh(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Jh extends ws{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 Oi,n=new Oi,s=new Oi;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 Oi;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 Oi;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 Oi,e=new Oi,i=new Oi,n=new Oi,a=new ai,o=new ai,l=new ai;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 gs(s,3)),this.setAttribute("normal",new gs(s.slice(),3)),this.setAttribute("uv",new gs(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 Jh(t.vertices,t.indices,t.radius,t.details)}}class Kh extends Jh{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 Kh(t.radius,t.detail)}}const $h=new Oi,Qh=new Oi,tc=new Oi,ec=new Jn;class ic extends ws{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(Ze*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}=ec;if(e.fromBufferAttribute(a,l[0]),i.fromBufferAttribute(a,l[1]),o.fromBufferAttribute(a,l[2]),ec.getNormal(tc),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=ec[h[t]],a=ec[h[e]],o=`${i}_${n}`,p=`${n}_${i}`;p in u&&u[p]?(tc.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:tc.clone()})}}for(const t in u)if(u[t]){const{index0:e,index1:i}=u[t];$h.fromBufferAttribute(a,e),Qh.fromBufferAttribute(a,i),d.push($h.x,$h.y,$h.z),d.push(Qh.x,Qh.y,Qh.z)}this.setAttribute("position",new gs(d,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}class nc extends Wh{constructor(t){super(t),this.uuid=Ke(),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 Wh).fromJSON(i))}return this}}function sc(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=Tc(r,t[r],t[r+1],a);else for(r=i-n;r>=e;r-=n)a=Tc(r,t[r],t[r+1],a);return a&&yc(a,a.next)&&(Ec(a),a=a.next),a}function rc(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!yc(n,n.next)&&0!==vc(n.prev,n,n.next))n=n.next;else{if(Ec(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function ac(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=mc(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?lc(t,n,s,r):oc(t))e.push(o.i/i|0),e.push(t.i/i|0),e.push(l.i/i|0),Ec(t),t=l.next,h=l.next;else if((t=l)===h){a?1===a?ac(t=hc(rc(t),e,i),e,i,n,s,r,2):2===a&&cc(t,e,i,n,s,r):ac(rc(t),e,i,n,s,r,1);break}}function oc(t){const e=t.prev,i=t,n=t.next;if(vc(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&&gc(s,o,r,l,a,h,m.x,m.y)&&vc(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function lc(t,e,i,n){const s=t.prev,r=t,a=t.next;if(vc(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,_=mc(p,m,e,i,n),v=mc(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&&gc(o,c,l,u,h,d,y.x,y.y)&&vc(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&&gc(o,c,l,u,h,d,x.x,x.y)&&vc(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&&gc(o,c,l,u,h,d,y.x,y.y)&&vc(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&&gc(o,c,l,u,h,d,x.x,x.y)&&vc(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function hc(t,e,i){let n=t;do{const s=n.prev,r=n.next.next;!yc(s,r)&&xc(s,n,n.next,r)&&Sc(s,r)&&Sc(r,s)&&(e.push(s.i/i|0),e.push(n.i/i|0),e.push(r.i/i|0),Ec(n),Ec(n.next),n=t=r),n=n.next}while(n!==t);return rc(n)}function cc(t,e,i,n,s,r){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&_c(a,t)){let o=wc(a,t);return a=rc(a,a.next),o=rc(o,o.next),ac(a,e,i,n,s,r,0),void ac(o,e,i,n,s,r,0)}t=t.next}a=a.next}while(a!==t)}function uc(t,e){return t.x-e.x}function dc(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&&gc(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),Sc(n,t)&&(c<u||c===u&&(n.x>i.x||n.x===i.x&&pc(i,n)))&&(i=n,u=c)),n=n.next}while(n!==o);return i}(t,e);if(!i)return e;const n=wc(i,t);return rc(n,n.next),rc(i,i.next)}function pc(t,e){return vc(t.prev,t,e.prev)<0&&vc(e.next,t,t.next)<0}function mc(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 fc(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 gc(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 _c(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&&xc(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(Sc(t,e)&&Sc(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)&&(vc(t.prev,t,e.prev)||vc(t,e.prev,e))||yc(t,e)&&vc(t.prev,t,t.next)>0&&vc(e.prev,e,e.next)>0)}function vc(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function yc(t,e){return t.x===e.x&&t.y===e.y}function xc(t,e,i,n){const s=bc(vc(t,e,i)),r=bc(vc(t,e,n)),a=bc(vc(i,n,t)),o=bc(vc(i,n,e));return s!==r&&a!==o||!(0!==s||!Mc(t,i,e))||!(0!==r||!Mc(t,n,e))||!(0!==a||!Mc(i,t,n))||!(0!==o||!Mc(i,e,n))}function Mc(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 bc(t){return t>0?1:t<0?-1:0}function Sc(t,e){return vc(t.prev,t,t.next)<0?vc(t,e,t.next)>=0&&vc(t,t.prev,e)>=0:vc(t,e,t.prev)<0||vc(t,t.next,e)<0}function wc(t,e){const i=new Ac(t.i,t.x,t.y),n=new Ac(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 Tc(t,e,i,n){const s=new Ac(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 Ec(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 Ac(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 Cc{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 Cc.area(t)<0}static triangulateShape(t,e){const i=[],n=[],s=[];Rc(t),Pc(i,t);let r=t.length;e.forEach(Rc);for(let o=0;o<e.length;o++)n.push(r),r+=e[o].length,Pc(i,e[o]);const a=function(t,e,i=2){const n=e&&e.length,s=n?e[0]*i:t.length;let r=sc(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=sc(t,o,l,n,!1),h===h.next&&(h.steiner=!0),s.push(fc(h));for(s.sort(uc),r=0;r<s.length;r++)i=dc(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 ac(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 Rc(t){const e=t.length;e>2&&t[e-1].equals(t[0])&&t.pop()}function Pc(t,e){for(let i=0;i<e.length;i++)t.push(e[i].x),t.push(e[i].y)}class Lc extends ws{constructor(t=new nc([new ai(.5,.5),new ai(-.5,.5),new ai(-.5,-.5),new ai(.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:Ic;let g,_,v,y,x,M=!1;m&&(g=m.getSpacedPoints(o),M=!0,h=!1,_=m.computeFrenetFrames(o,!1),v=new Oi,y=new Oi,x=new Oi),h||(p=0,c=0,u=0,d=0);const b=t.extractPoints(a);let S=b.shape;const w=b.holes;if(!Cc.isClockWise(S)){S=S.reverse();for(let t=0,e=w.length;t<e;t++){const e=w[t];Cc.isClockWise(e)&&(w[t]=e.reverse())}}const T=Cc.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 ai(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 ai(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 gs(n,3)),this.setAttribute("uv",new gs(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 Gh[n.type]).fromJSON(n)),new Lc(i,t.options)}}const Ic={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 ai(r,a),new ai(o,l),new ai(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 ai(a,1-l),new ai(h,1-u),new ai(d,1-m),new ai(f,1-_)]:[new ai(o,1-l),new ai(c,1-u),new ai(p,1-m),new ai(g,1-_)]}};class Dc extends Jh{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 Dc(t.radius,t.detail)}}class Nc extends Jh{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 Nc(t.radius,t.detail)}}class Uc extends ws{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 Oi,p=new ai;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 gs(o,3)),this.setAttribute("normal",new gs(l,3)),this.setAttribute("uv",new gs(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 Oc extends ws{constructor(t=new nc([new ai(0,.5),new ai(-.5,-.5),new ai(.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===Cc.isClockWise(h)&&(h=h.reverse());for(let e=0,i=c.length;e<i;e++){const t=c[e];!0===Cc.isClockWise(t)&&(c[e]=t.reverse())}const u=Cc.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 gs(n,3)),this.setAttribute("normal",new gs(s,3)),this.setAttribute("uv",new gs(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 Oc(i,t.curveSegments)}}class Fc extends ws{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 Oi,u=new Oi,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 gs(p,3)),this.setAttribute("normal",new gs(m,3)),this.setAttribute("uv",new gs(f,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Fc(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class Bc extends Jh{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 Bc(t.radius,t.detail)}}class zc extends ws{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 Oi,c=new Oi,u=new Oi;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 gs(a,3)),this.setAttribute("normal",new gs(o,3)),this.setAttribute("uv",new gs(l,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.radialSegments,t.tubularSegments,t.arc)}}class kc extends ws{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 Oi,u=new Oi,d=new Oi,p=new Oi,m=new Oi,f=new Oi,g=new Oi;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 gs(o,3)),this.setAttribute("normal",new gs(l,3)),this.setAttribute("uv",new gs(h,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new kc(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}}class Vc extends ws{constructor(t=new kh(new Oi(-1,-1,0),new Oi(-1,1,0),new Oi(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 Oi,o=new Oi,l=new ai;let h=new Oi;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 gs(c,3)),this.setAttribute("normal",new gs(u,3)),this.setAttribute("uv",new gs(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 Vc((new Gh[t.path.type]).fromJSON(t.path),t.tubularSegments,t.radius,t.radialSegments,t.closed)}}class Gc extends ws{constructor(t=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:t},null!==t){const e=[],i=new Set,n=new Oi,s=new Oi;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===Hc(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===Hc(n,s,i)&&(e.push(n.x,n.y,n.z),e.push(s.x,s.y,s.z))}}this.setAttribute("position",new gs(e,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}function Hc(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 Wc=Object.freeze({__proto__:null,BoxGeometry:Ws,CapsuleGeometry:Xh,CircleGeometry:jh,ConeGeometry:Zh,CylinderGeometry:Yh,DodecahedronGeometry:Kh,EdgesGeometry:ic,ExtrudeGeometry:Lc,IcosahedronGeometry:Dc,LatheGeometry:qh,OctahedronGeometry:Nc,PlaneGeometry:ur,PolyhedronGeometry:Jh,RingGeometry:Uc,ShapeGeometry:Oc,SphereGeometry:Fc,TetrahedronGeometry:Bc,TorusGeometry:zc,TorusKnotGeometry:kc,TubeGeometry:Vc,WireframeGeometry:Gc});class qc extends ss{constructor(t){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new es(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 Xc extends Zs{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class jc extends ss{constructor(t){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new es(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 es(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ai(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 Yc extends jc{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 ai(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get(){return $e(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 es(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 es(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new es(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 Zc extends ss{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new es(16777215),this.specular=new es(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new es(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ai(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 Jc extends ss{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new es(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new es(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ai(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 Kc extends ss{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ai(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 $c extends ss{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new es(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new es(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ai(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 Qc extends ss{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new es(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ai(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 tu extends sh{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 eu(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 iu(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function nu(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 su(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 ru(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 au={convertArray:eu,isTypedArray:iu,getKeyframeOrder:nu,sortedArray:su,flattenJSON:ru,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=eu(o,t.times.constructor),t.values=eu(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=xe,t}};class ou{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 lu extends ou{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:_e,endingEnd:_e}}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 ve:s=t,a=2*e-i;break;case ye: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 ve:r=t,o=2*i-e;break;case ye: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 hu extends ou{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 cu extends ou{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t){return this.copySampleValue_(t-1)}}class uu{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=eu(e,this.TimeBufferType),this.values=eu(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:eu(t.times,Array),values:eu(t.values,Array)};const e=t.getInterpolation();e!==t.DefaultInterpolation&&(i.interpolation=e)}return i.type=t.ValueTypeName,i}InterpolantFactoryMethodDiscrete(t){return new cu(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new hu(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new lu(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case me:e=this.InterpolantFactoryMethodDiscrete;break;case fe:e=this.InterpolantFactoryMethodLinear;break;case ge: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 me;case this.InterpolantFactoryMethodLinear:return fe;case this.InterpolantFactoryMethodSmooth:return ge}}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&&iu(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()===ge,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}}uu.prototype.TimeBufferType=Float32Array,uu.prototype.ValueBufferType=Float32Array,uu.prototype.DefaultInterpolation=fe;class du extends uu{}du.prototype.ValueTypeName="bool",du.prototype.ValueBufferType=Array,du.prototype.DefaultInterpolation=me,du.prototype.InterpolantFactoryMethodLinear=void 0,du.prototype.InterpolantFactoryMethodSmooth=void 0;class pu extends uu{}pu.prototype.ValueTypeName="color";class mu extends uu{}mu.prototype.ValueTypeName="number";class fu extends ou{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 gu extends uu{InterpolantFactoryMethodLinear(t){return new fu(this.times,this.values,this.getValueSize(),t)}}gu.prototype.ValueTypeName="quaternion",gu.prototype.DefaultInterpolation=fe,gu.prototype.InterpolantFactoryMethodSmooth=void 0;class _u extends uu{}_u.prototype.ValueTypeName="string",_u.prototype.ValueBufferType=Array,_u.prototype.DefaultInterpolation=me,_u.prototype.InterpolantFactoryMethodLinear=void 0,_u.prototype.InterpolantFactoryMethodSmooth=void 0;class vu extends uu{}vu.prototype.ValueTypeName="vector";class yu{constructor(t,e=-1,i,n=2500){this.name=t,this.tracks=i,this.duration=e,this.blendMode=n,this.uuid=Ke(),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(xu(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(uu.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=nu(t);t=su(t,1,l),o=su(o,1,l),n||0!==t[0]||(t.push(s),o.push(o[0])),r.push(new mu(".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=[];ru(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 mu(".morphTargetInfluence["+s+"]",e,r))}o=e.length*r}else{const s=".bones["+e[h].name+"]";i(vu,s+".position",t,"pos",n),i(gu,s+".quaternion",t,"rot",n),i(vu,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 xu(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 mu;case"vector":case"vector2":case"vector3":case"vector4":return vu;case"color":return pu;case"quaternion":return gu;case"bool":case"boolean":return du;case"string":return _u}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}(t.type);if(void 0===t.times){const e=[],i=[];ru(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 Mu={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 bu{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 Su=new bu;class wu{constructor(t){this.manager=void 0!==t?t:Su,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}}wu.DEFAULT_MATERIAL_NAME="__DEFAULT";const Tu={};class Eu extends Error{constructor(t,e){super(t),this.response=e}}class Au extends wu{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=Mu.get(t);if(void 0!==s)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(void 0!==Tu[t])return void Tu[t].push({onLoad:e,onProgress:i,onError:n});Tu[t]=[],Tu[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=Tu[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 Eu(`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=>{Mu.add(t,e);const i=Tu[t];delete Tu[t];for(let t=0,n=i.length;t<n;t++){const n=i[t];n.onLoad&&n.onLoad(e)}}).catch(e=>{const i=Tu[t];if(void 0===i)throw this.manager.itemError(t),e;delete Tu[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 Cu extends wu{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=Mu.get(t);if(void 0!==r)return s.manager.itemStart(t),setTimeout(function(){e&&e(r),s.manager.itemEnd(t)},0),r;const a=di("img");function o(){h(),Mu.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 Ru extends Bn{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new es(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 Pu extends Ru{constructor(t,e,i){super(t,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Bn.DEFAULT_UP),this.updateMatrix(),this.groundColor=new es(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}}const Lu=new pn,Iu=new Oi,Du=new Oi;class Nu{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ai(512,512),this.map=null,this.mapPass=null,this.matrix=new pn,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new lr,this._frameExtents=new ai(1,1),this._viewportCount=1,this._viewports=[new Pi(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,i=this.matrix;Iu.setFromMatrixPosition(t.matrixWorld),e.position.copy(Iu),Du.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(Du),e.updateMatrixWorld(),Lu.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Lu),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Lu)}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 Nu{constructor(){super(new Ks(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){const e=this.camera,i=2*Je*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 Ou extends Ru{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(Bn.DEFAULT_UP),this.updateMatrix(),this.target=new Bn,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 Fu=new pn,Bu=new Oi,zu=new Oi;class ku extends Nu{constructor(){super(new Ks(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new ai(4,2),this._viewportCount=6,this._viewports=[new Pi(2,1,1,1),new Pi(0,1,1,1),new Pi(3,1,1,1),new Pi(1,1,1,1),new Pi(3,0,1,1),new Pi(1,0,1,1)],this._cubeDirections=[new Oi(1,0,0),new Oi(-1,0,0),new Oi(0,0,1),new Oi(0,0,-1),new Oi(0,1,0),new Oi(0,-1,0)],this._cubeUps=[new Oi(0,1,0),new Oi(0,1,0),new Oi(0,1,0),new Oi(0,1,0),new Oi(0,0,1),new Oi(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()),Bu.setFromMatrixPosition(t.matrixWorld),i.position.copy(Bu),zu.copy(i.position),zu.add(this._cubeDirections[e]),i.up.copy(this._cubeUps[e]),i.lookAt(zu),i.updateMatrixWorld(),n.makeTranslation(-Bu.x,-Bu.y,-Bu.z),Fu.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Fu)}}class Vu extends Ru{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 ku}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 Gu extends Nu{constructor(){super(new br(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Hu extends Ru{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Bn.DEFAULT_UP),this.updateMatrix(),this.target=new Bn,this.shadow=new Gu}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class Wu extends Ru{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class qu extends Ru{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 Xu{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new Oi)}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 ju extends Ru{constructor(t=new Xu,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 Yu extends wu{constructor(t){super(t),this.textures={}}load(t,e,i,n){const s=this,r=new Au(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=Yu.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 es).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 es).setHex(e.value);break;case"v2":n.uniforms[s].value=(new ai).fromArray(e.value);break;case"v3":n.uniforms[s].value=(new Oi).fromArray(e.value);break;case"v4":n.uniforms[s].value=(new Pi).fromArray(e.value);break;case"m3":n.uniforms[s].value=(new oi).fromArray(e.value);break;case"m4":n.uniforms[s].value=(new pn).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 ai).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 ai).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:qc,SpriteMaterial:$o,RawShaderMaterial:Xc,ShaderMaterial:Zs,PointsMaterial:fh,MeshPhysicalMaterial:Yc,MeshStandardMaterial:jc,MeshPhongMaterial:Zc,MeshToonMaterial:Jc,MeshNormalMaterial:Kc,MeshLambertMaterial:$c,MeshDepthMaterial:Lo,MeshDistanceMaterial:Io,MeshBasicMaterial:rs,MeshMatcapMaterial:Qc,LineDashedMaterial:tu,LineBasicMaterial:sh,Material:ss}[t]}}class Zu{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 Ju extends ws{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 Ku extends wu{constructor(t){super(t)}load(t,e,i,n){const s=this,r=new Au(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=ui(s.type,r),o=new Zo(a,s.stride);return o.uuid=s.uuid,e[n]=o,o}const s=t.isInstancedBufferGeometry?new Ju:new ws,r=t.data.index;if(void 0!==r){const t=ui(r.type,r.array);s.setIndex(new ps(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 Ko(s,e.itemSize,e.offset,e.normalized)}else{const t=ui(e.type,e.array);i=new(e.isInstancedBufferAttribute?Il:ps)(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 Ko(e,r.itemSize,r.offset,r.normalized)}else{const t=ui(r.type,r.array);a=new ps(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 Oi;void 0!==h.center&&t.fromArray(h.center),s.boundingSphere=new sn(t,h.radius)}return t.name&&(s.name=t.name),t.userData&&(s.userData=t.userData),s}}const $u={UVMapping:ot,CubeReflectionMapping:lt,CubeRefractionMapping:ht,EquirectangularReflectionMapping:ct,EquirectangularRefractionMapping:ut,CubeUVReflectionMapping:dt},Qu={RepeatWrapping:pt,ClampToEdgeWrapping:mt,MirroredRepeatWrapping:ft},td={NearestFilter:gt,NearestMipmapNearestFilter:_t,NearestMipmapLinearFilter:vt,LinearFilter:yt,LinearMipmapNearestFilter:xt,LinearMipmapLinearFilter:Mt};let ed;class id{static getContext(){return void 0===ed&&(ed=new(window.AudioContext||window.webkitAudioContext)),ed}static setContext(t){ed=t}}const nd=new pn,sd=new pn,rd=new pn;class ad{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=od(),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=od();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function od(){return("undefined"==typeof performance?Date:performance).now()}const ld=new Oi,hd=new Ui,cd=new Oi,ud=new Oi;class dd extends Bn{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 pd=new Oi,md=new Ui,fd=new Oi,gd=new Oi;class _d{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 vd="\\[\\]\\.:\\/",yd=new RegExp("["+vd+"]","g"),xd="[^"+vd+"]",Md="[^"+vd.replace("\\.","")+"]",bd=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",xd)+/(WCOD+)?/.source.replace("WCOD",Md)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",xd)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",xd)+"$"),Sd=["material","materials","bones","map"];class wd{constructor(t,e,i){this.path=e,this.parsedPath=i||wd.parseTrackName(e),this.node=wd.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 wd.Composite(t,e,i):new wd(t,e,i)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(yd,"")}static parseTrackName(t){const e=bd.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!==Sd.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=wd.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}}wd.Composite=class{constructor(t,e,i){const n=i||wd.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()}},wd.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},wd.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},wd.prototype.GetterByBindingType=[wd.prototype._getValue_direct,wd.prototype._getValue_array,wd.prototype._getValue_arrayElement,wd.prototype._getValue_toArray],wd.prototype.SetterByBindingTypeAndVersioning=[[wd.prototype._setValue_direct,wd.prototype._setValue_direct_setNeedsUpdate,wd.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[wd.prototype._setValue_array,wd.prototype._setValue_array_setNeedsUpdate,wd.prototype._setValue_array_setMatrixWorldNeedsUpdate],[wd.prototype._setValue_arrayElement,wd.prototype._setValue_arrayElement_setNeedsUpdate,wd.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[wd.prototype._setValue_fromArray,wd.prototype._setValue_fromArray_setNeedsUpdate,wd.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Td{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:_e,endingEnd:_e};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===xe)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=ve,n.endingEnd=ve):(n.endingStart=t?this.zeroSlopeAtStart?ve:_e:ye,n.endingEnd=e?this.zeroSlopeAtEnd?ve:_e:ye)}_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 Ed=new Float32Array(1);class Ad{constructor(t){this.value=t}clone(){return new Ad(void 0===this.value.clone?this.value:this.value.clone())}}let Cd=0;function Rd(t,e){return t.distance-e.distance}function Pd(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++)Pd(n[t],e,i,!0)}}const Ld=new ai,Id=new Oi,Dd=new Oi,Nd=new Oi,Ud=new Oi,Od=new pn,Fd=new pn;function Bd(t){const e=[];!0===t.isBone&&e.push(t);for(let i=0;i<t.children.length;i++)e.push.apply(e,Bd(t.children[i]));return e}const zd=new Oi,kd=new es,Vd=new es,Gd=new Oi,Hd=new Oi,Wd=new Oi,qd=new Oi,Xd=new Js;function jd(t,e,i,n,s,r,a){qd.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],qd.x,qd.y,qd.z)}}const Yd=new zi,Zd=new Oi;let Jd,Kd;"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:F}})),"undefined"!=typeof window&&(window.__THREE__||(window.__THREE__=F));const $d=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:4,AddEquation:V,AddOperation:2,AdditiveAnimationBlendMode:xe,AdditiveBlending:2,AgXToneMapping:6,AlphaFormat:1021,AlwaysCompare:519,AlwaysDepth:1,AlwaysStencilFunc:519,AmbientLight:Wu,AnimationAction:Td,AnimationClip:yu,AnimationLoader:class extends wu{constructor(t){super(t)}load(t,e,i,n){const s=this,r=new Au(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=yu.parse(t[i]);e.push(n)}return e}},AnimationMixer:class extends Xe{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 _d(wd.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 hu(new Float32Array(2),new Float32Array(2),1,Ed),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?yu.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 Td(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?yu.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=Ke(),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 wd(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 wd(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 wd(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:au,ArcCurve:Th,ArrayCamera:Fo,ArrowHelper:class extends Bn{constructor(t=new Oi(0,0,1),e=new Oi(0,0,0),i=1,n=16776960,s=.2*i,r=.2*s){super(),this.type="ArrowHelper",void 0===Jd&&(Jd=new ws,Jd.setAttribute("position",new gs([0,0,0,0,1,0],3)),Kd=new Yh(0,.5,1,5,1),Kd.translate(0,-.5,0)),this.position.copy(e),this.line=new ch(Jd,new sh({color:n,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Gs(Kd,new rs({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{Zd.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(Zd,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:rt,Audio:dd,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:id,AudioListener:class extends Bn{constructor(){super(),this.type="AudioListener",this.context=id.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new ad}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(ld,hd,cd),ud.set(0,0,-1).applyQuaternion(hd),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(ld.x,t),e.positionY.linearRampToValueAtTime(ld.y,t),e.positionZ.linearRampToValueAtTime(ld.z,t),e.forwardX.linearRampToValueAtTime(ud.x,t),e.forwardY.linearRampToValueAtTime(ud.y,t),e.forwardZ.linearRampToValueAtTime(ud.z,t),e.upX.linearRampToValueAtTime(i.x,t),e.upY.linearRampToValueAtTime(i.y,t),e.upZ.linearRampToValueAtTime(i.z,t)}else e.setPosition(ld.x,ld.y,ld.z),e.setOrientation(ud.x,ud.y,ud.z,i.x,i.y,i.z)}},AudioLoader:class extends wu{constructor(t){super(t)}load(t,e,i,n){const s=this,r=new Au(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);id.getContext().decodeAudioData(i,function(t){e(t)}).catch(a)}catch(i){a(i)}},i,n)}},AxesHelper:class extends ph{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 ws;i.setAttribute("position",new gs(e,3)),i.setAttribute("color",new gs([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(i,new sh({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(t,e,i){const n=new es,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:nh,Bone:Al,BooleanKeyframeTrack:du,Box2:class{constructor(t=new ai(1/0,1/0),e=new ai(-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=Ld.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,Ld).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:zi,Box3Helper:class extends ph{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 ws;n.setIndex(new ps(i,1)),n.setAttribute("position",new gs([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 sh({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:Ws,BoxHelper:class extends ph{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 ws;s.setIndex(new ps(i,1)),s.setAttribute("position",new ps(n,3)),super(s,new sh({color:e,toneMapped:!1})),this.object=t,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(t){if(void 0!==this.object&&Yd.setFromObject(this.object),Yd.isEmpty())return;const e=Yd.min,i=Yd.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:ps,BufferGeometry:ws,BufferGeometryLoader:Ku,ByteType:1010,Cache:Mu,Camera:Js,CameraHelper:class extends ph{constructor(t){const e=new ws,i=new sh({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 gs(n,3)),e.setAttribute("color",new gs(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 es(16755200),h=new es(16711680),c=new es(43775),u=new es(16777215),d=new es(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;Xd.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),jd("c",e,t,Xd,0,0,-1),jd("t",e,t,Xd,0,0,1),jd("n1",e,t,Xd,-1,-1,-1),jd("n2",e,t,Xd,1,-1,-1),jd("n3",e,t,Xd,-1,1,-1),jd("n4",e,t,Xd,1,1,-1),jd("f1",e,t,Xd,-1,-1,1),jd("f2",e,t,Xd,1,-1,1),jd("f3",e,t,Xd,-1,1,1),jd("f4",e,t,Xd,1,1,1),jd("u1",e,t,Xd,.7,1.1,-1),jd("u2",e,t,Xd,-.7,1.1,-1),jd("u3",e,t,Xd,0,2,-1),jd("cf1",e,t,Xd,-1,0,1),jd("cf2",e,t,Xd,1,0,1),jd("cf3",e,t,Xd,0,-1,1),jd("cf4",e,t,Xd,0,1,1),jd("cn1",e,t,Xd,-1,0,-1),jd("cn2",e,t,Xd,1,0,-1),jd("cn3",e,t,Xd,0,-1,-1),jd("cn4",e,t,Xd,0,1,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},CanvasTexture:class extends Ri{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:Xh,CatmullRomCurve3:Lh,CineonToneMapping:3,CircleGeometry:jh,ClampToEdgeWrapping:mt,Clock:ad,Color:es,ColorKeyframeTrack:pu,ColorManagement:xi,CompressedArrayTexture:class extends bh{constructor(t,e,i,n,s,r){super(t,e,i,s,r),this.isCompressedArrayTexture=!0,this.image.depth=n,this.wrapR=mt}},CompressedCubeTexture:class extends bh{constructor(t,e,i){super(void 0,t[0].width,t[0].height,e,i,lt),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}},CompressedTexture:bh,CompressedTextureLoader:class extends wu{constructor(t){super(t)}load(t,e,i,n){const s=this,r=[],a=new bh,o=new Au(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=yt),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=yt),a.format=i.format,a.needsUpdate=!0,e&&e(a)},i,n);return a}},ConeGeometry:Zh,ConstantAlphaFactor:213,ConstantColorFactor:211,CubeCamera:Qs,CubeReflectionMapping:lt,CubeRefractionMapping:ht,CubeTexture:tr,CubeTextureLoader:class extends wu{constructor(t){super(t)}load(t,e,i,n){const s=new tr;s.colorSpace=we;const r=new Cu(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:dt,CubicBezierCurve:Uh,CubicBezierCurve3:Oh,CubicInterpolant:lu,CullFaceBack:1,CullFaceFront:2,CullFaceFrontBack:3,CullFaceNone:0,Curve:Sh,CurvePath:Hh,CustomBlending:5,CustomToneMapping:5,CylinderGeometry:Yh,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:Ni,DataArrayTexture:Di,DataTexture:Cl,DataTextureLoader:class extends wu{constructor(t){super(t)}load(t,e,i,n){const s=this,r=new Cl,a=new Au(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:mt,r.wrapT=void 0!==i.wrapT?i.wrapT:mt,r.magFilter=void 0!==i.magFilter?i.magFilter:yt,r.minFilter=void 0!==i.minFilter?i.minFilter:yt,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=Mt),1===i.mipmapCount&&(r.minFilter=yt),void 0!==i.generateMipmaps&&(r.generateMipmaps=i.generateMipmaps),r.needsUpdate=!0,e&&e(r,i)},i,n),r}},DataUtils:cs,DecrementStencilOp:7683,DecrementWrapStencilOp:34056,DefaultLoadingManager:Su,DepthFormat:It,DepthStencilFormat:Dt,DepthTexture:Xr,DetachedBindMode:at,DirectionalLight:Hu,DirectionalLightHelper:class extends Bn{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 ws;n.setAttribute("position",new gs([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));const s=new sh({fog:!1,toneMapped:!1});this.lightPlane=new ch(n,s),this.add(this.lightPlane),n=new ws,n.setAttribute("position",new gs([0,0,0,0,0,1],3)),this.targetLine=new ch(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),Gd.setFromMatrixPosition(this.light.matrixWorld),Hd.setFromMatrixPosition(this.light.target.matrixWorld),Wd.subVectors(Hd,Gd),this.lightPlane.lookAt(Hd),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(Hd),this.targetLine.scale.z=Wd.length()}},DiscreteInterpolant:cu,DisplayP3ColorSpace:Ee,DodecahedronGeometry:Kh,DoubleSide:2,DstAlphaFactor:206,DstColorFactor:208,DynamicCopyUsage:35050,DynamicDrawUsage:35048,DynamicReadUsage:35049,EdgesGeometry:ic,EllipseCurve:wh,EqualCompare:514,EqualDepth:4,EqualStencilFunc:514,EquirectangularReflectionMapping:ct,EquirectangularRefractionMapping:ut,Euler:Sn,EventDispatcher:Xe,ExtrudeGeometry:Lc,FileLoader:Au,Float16BufferAttribute:class extends ps{constructor(t,e,i){super(new Uint16Array(t),e,i),this.isFloat16BufferAttribute=!0}getX(t){let e=hs(this.array[t*this.itemSize]);return this.normalized&&(e=ni(e,this.array)),e}setX(t,e){return this.normalized&&(e=si(e,this.array)),this.array[t*this.itemSize]=ls(e),this}getY(t){let e=hs(this.array[t*this.itemSize+1]);return this.normalized&&(e=ni(e,this.array)),e}setY(t,e){return this.normalized&&(e=si(e,this.array)),this.array[t*this.itemSize+1]=ls(e),this}getZ(t){let e=hs(this.array[t*this.itemSize+2]);return this.normalized&&(e=ni(e,this.array)),e}setZ(t,e){return this.normalized&&(e=si(e,this.array)),this.array[t*this.itemSize+2]=ls(e),this}getW(t){let e=hs(this.array[t*this.itemSize+3]);return this.normalized&&(e=ni(e,this.array)),e}setW(t,e){return this.normalized&&(e=si(e,this.array)),this.array[t*this.itemSize+3]=ls(e),this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=si(e,this.array),i=si(i,this.array)),this.array[t+0]=ls(e),this.array[t+1]=ls(i),this}setXYZ(t,e,i,n){return t*=this.itemSize,this.normalized&&(e=si(e,this.array),i=si(i,this.array),n=si(n,this.array)),this.array[t+0]=ls(e),this.array[t+1]=ls(i),this.array[t+2]=ls(n),this}setXYZW(t,e,i,n,s){return t*=this.itemSize,this.normalized&&(e=si(e,this.array),i=si(i,this.array),n=si(n,this.array),s=si(s,this.array)),this.array[t+0]=ls(e),this.array[t+1]=ls(i),this.array[t+2]=ls(n),this.array[t+3]=ls(s),this}},Float32BufferAttribute:gs,Float64BufferAttribute:class extends ps{constructor(t,e,i){super(new Float64Array(t),e,i)}},FloatType:Et,Fog:jo,FogExp2:Xo,FramebufferTexture:class extends Ri{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=gt,this.minFilter=gt,this.generateMipmaps=!1,this.needsUpdate=!0}},FrontSide:0,Frustum:lr,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:Ge,GreaterCompare:516,GreaterDepth:6,GreaterEqualCompare:518,GreaterEqualDepth:5,GreaterEqualStencilFunc:518,GreaterStencilFunc:516,GridHelper:class extends ph{constructor(t=10,e=10,i=4473924,n=8947848){i=new es(i),n=new es(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 ws;h.setAttribute("position",new gs(o,3)),h.setAttribute("color",new gs(l,3)),super(h,new sh({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},Group:Bo,HalfFloatType:At,HemisphereLight:Pu,HemisphereLightHelper:class extends Bn{constructor(t,e,i){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";const n=new Nc(e);n.rotateY(.5*Math.PI),this.material=new rs({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 ps(r,3)),this.add(new Gs(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");kd.copy(this.light.color),Vd.copy(this.light.groundColor);for(let t=0,i=e.count;t<i;t++){const n=t<i/2?kd:Vd;e.setXYZ(t,n.r,n.g,n.b)}e.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),t.lookAt(zd.setFromMatrixPosition(this.light.matrixWorld).negate())}},IcosahedronGeometry:Dc,ImageBitmapLoader:class extends wu{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=Mu.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 Mu.add(t,i),e&&e(i),s.manager.itemEnd(t),i}).catch(function(e){n&&n(e),Mu.remove(t),s.manager.itemError(t),s.manager.itemEnd(t)});Mu.add(t,o),s.manager.itemStart(t)}},ImageLoader:Cu,ImageUtils:wi,IncrementStencilOp:7682,IncrementWrapStencilOp:34055,InstancedBufferAttribute:Il,InstancedBufferGeometry:Ju,InstancedInterleavedBuffer:class extends Zo{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:kl,Int16BufferAttribute:class extends ps{constructor(t,e,i){super(new Int16Array(t),e,i)}},Int32BufferAttribute:class extends ps{constructor(t,e,i){super(new Int32Array(t),e,i)}},Int8BufferAttribute:class extends ps{constructor(t,e,i){super(new Int8Array(t),e,i)}},IntType:wt,InterleavedBuffer:Zo,InterleavedBufferAttribute:Ko,Interpolant:ou,InterpolateDiscrete:me,InterpolateLinear:fe,InterpolateSmooth:ge,InvertStencilOp:5386,KeepStencilOp:Ie,KeyframeTrack:uu,LOD:gl,LatheGeometry:qh,Layers:wn,LessCompare:513,LessDepth:2,LessEqualCompare:515,LessEqualDepth:3,LessEqualStencilFunc:515,LessStencilFunc:513,Light:Ru,LightProbe:ju,Line:ch,Line3:class{constructor(t=new Oi,e=new Oi){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){Id.subVectors(t,this.start),Dd.subVectors(this.end,this.start);const i=Dd.dot(Dd);let n=Dd.dot(Id)/i;return e&&(n=$e(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:sh,LineCurve:Fh,LineCurve3:Bh,LineDashedMaterial:tu,LineLoop:mh,LineSegments:ph,LinearDisplayP3ColorSpace:Ae,LinearEncoding:Me,LinearFilter:yt,LinearInterpolant:hu,LinearMipMapLinearFilter:1008,LinearMipMapNearestFilter:1007,LinearMipmapLinearFilter:Mt,LinearMipmapNearestFilter:xt,LinearSRGBColorSpace:Te,LinearToneMapping:1,LinearTransfer:Ce,Loader:wu,LoaderUtils:Zu,LoadingManager:bu,LoopOnce:2200,LoopPingPong:2202,LoopRepeat:2201,LuminanceAlphaFormat:1025,LuminanceFormat:1024,MOUSE:{LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Material:ss,MaterialLoader:Yu,MathUtils:ri,Matrix3:oi,Matrix4:pn,MaxEquation:104,Mesh:Gs,MeshBasicMaterial:rs,MeshDepthMaterial:Lo,MeshDistanceMaterial:Io,MeshLambertMaterial:$c,MeshMatcapMaterial:Qc,MeshNormalMaterial:Kc,MeshPhongMaterial:Zc,MeshPhysicalMaterial:Yc,MeshStandardMaterial:jc,MeshToonMaterial:Jc,MinEquation:103,MirroredRepeatWrapping:ft,MixOperation:1,MultiplyBlending:4,MultiplyOperation:0,NearestFilter:gt,NearestMipMapLinearFilter:1005,NearestMipMapNearestFilter:1004,NearestMipmapLinearFilter:vt,NearestMipmapNearestFilter:_t,NeverCompare:512,NeverDepth:0,NeverStencilFunc:512,NoBlending:0,NoColorSpace:Se,NoToneMapping:0,NormalAnimationBlendMode:2500,NormalBlending:1,NotEqualCompare:517,NotEqualDepth:7,NotEqualStencilFunc:517,NumberKeyframeTrack:mu,Object3D:Bn,ObjectLoader:class extends wu{constructor(t){super(t)}load(t,e,i,n){const s=this,r=""===this.path?Zu.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||r;const a=new Au(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?Zu.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||i;const n=new Au(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 nc).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 Ll).fromJSON(t[s],n);i[e.uuid]=e}return i}parseGeometries(t,e){const i={};if(void 0!==t){const n=new Ku;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 Wc&&(r=Wc[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 Yu;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=yu.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:ui(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){const i=new bu(e);s=new Cu(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 Cl(i.data,i.width,i.height)))}n[i.uuid]=new Ei(t)}else{const t=r(i.url);n[i.uuid]=new Ei(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:ui(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){n=new Cu(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 Cl(n.data,n.width,n.height)))}i[n.uuid]=new Ei(t)}else{const t=await s(n.url);i[n.uuid]=new Ei(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 tr,6===o.length&&(l.needsUpdate=!0)):(l=o&&o.data?new Cl:new Ri,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,$u)),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],Qu),l.wrapT=i(r.wrap[1],Qu)),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,td)),void 0!==r.magFilter&&(l.magFilter=i(r.magFilter,td)),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 Yo,void 0!==t.background&&(Number.isInteger(t.background)?r.background=new es(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 jo(t.fog.color,t.fog.near,t.fog.far):"FogExp2"===t.fog.type&&(r.fog=new Xo(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 Ks(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 br(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 Wu(t.color,t.intensity);break;case"DirectionalLight":r=new Hu(t.color,t.intensity);break;case"PointLight":r=new Vu(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":r=new qu(t.color,t.intensity,t.width,t.height);break;case"SpotLight":r=new Ou(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay);break;case"HemisphereLight":r=new Pu(t.color,t.groundColor,t.intensity);break;case"LightProbe":r=(new ju).fromJSON(t);break;case"SkinnedMesh":a=l(t.geometry),o=h(t.material),r=new El(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 Gs(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 kl(a,o,e),r.instanceMatrix=new Il(new Float32Array(i.array),16),void 0!==n&&(r.instanceColor=new Il(new Float32Array(n.array),n.itemSize));break;case"BatchedMesh":a=l(t.geometry),o=h(t.material),r=new nh(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 zi;e.min.fromArray(t.boxMin),e.max.fromArray(t.boxMax);const i=new sn;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 gl;break;case"Line":r=new ch(l(t.geometry),h(t.material));break;case"LineLoop":r=new mh(l(t.geometry),h(t.material));break;case"LineSegments":r=new ph(l(t.geometry),h(t.material));break;case"PointCloud":case"Points":r=new xh(l(t.geometry),h(t.material));break;case"Sprite":r=new dl(h(t.material));break;case"Group":r=new Bo;break;case"Bone":r=new Al;break;default:r=new Bn}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:Nc,OneFactor:201,OneMinusConstantAlphaFactor:214,OneMinusConstantColorFactor:212,OneMinusDstAlphaFactor:207,OneMinusDstColorFactor:209,OneMinusSrcAlphaFactor:Z,OneMinusSrcColorFactor:203,OrthographicCamera:br,P3Primaries:Le,PCFShadowMap:1,PCFSoftShadowMap:2,PMREMGenerator:Ir,Path:Wh,PerspectiveCamera:Ks,Plane:rr,PlaneGeometry:ur,PlaneHelper:class extends ch{constructor(t,e=1,i=16776960){const n=i,s=new ws;s.setAttribute("position",new gs([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 sh({color:n,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e;const r=new ws;r.setAttribute("position",new gs([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),r.computeBoundingSphere(),this.add(new Gs(r,new rs({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:Vu,PointLightHelper:class extends Gs{constructor(t,e,i){super(new Fc(e,4,2),new rs({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:xh,PointsMaterial:fh,PolarGridHelper:class extends ph{constructor(t=10,e=16,i=8,n=64,s=4473924,r=8947848){s=new es(s),r=new es(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 ws;l.setAttribute("position",new gs(a,3)),l.setAttribute("color",new gs(o,3)),super(l,new sh({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},PolyhedronGeometry:Jh,PositionalAudio:class extends dd{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(pd,md,fd),gd.set(0,0,1).applyQuaternion(md);const e=this.panner;if(e.positionX){const t=this.context.currentTime+this.listener.timeDelta;e.positionX.linearRampToValueAtTime(pd.x,t),e.positionY.linearRampToValueAtTime(pd.y,t),e.positionZ.linearRampToValueAtTime(pd.z,t),e.orientationX.linearRampToValueAtTime(gd.x,t),e.orientationY.linearRampToValueAtTime(gd.y,t),e.orientationZ.linearRampToValueAtTime(gd.z,t)}else e.setPosition(pd.x,pd.y,pd.z),e.setOrientation(gd.x,gd.y,gd.z)}},PropertyBinding:wd,PropertyMixer:_d,QuadraticBezierCurve:zh,QuadraticBezierCurve3:kh,Quaternion:Ui,QuaternionKeyframeTrack:gu,QuaternionLinearInterpolant:fu,RED_GREEN_RGTC2_Format:de,RED_RGTC1_Format:36283,REVISION:F,RGBADepthPacking:3201,RGBAFormat:Lt,RGBAIntegerFormat:Ot,RGBA_ASTC_10x10_Format:re,RGBA_ASTC_10x5_Format:ie,RGBA_ASTC_10x6_Format:ne,RGBA_ASTC_10x8_Format:se,RGBA_ASTC_12x10_Format:ae,RGBA_ASTC_12x12_Format:oe,RGBA_ASTC_4x4_Format:Yt,RGBA_ASTC_5x4_Format:Zt,RGBA_ASTC_5x5_Format:Jt,RGBA_ASTC_6x5_Format:Kt,RGBA_ASTC_6x6_Format:$t,RGBA_ASTC_8x5_Format:Qt,RGBA_ASTC_8x6_Format:te,RGBA_ASTC_8x8_Format:ee,RGBA_BPTC_Format:le,RGBA_ETC2_EAC_Format:jt,RGBA_PVRTC_2BPPV1_Format:Wt,RGBA_PVRTC_4BPPV1_Format:Ht,RGBA_S3TC_DXT1_Format:Bt,RGBA_S3TC_DXT3_Format:zt,RGBA_S3TC_DXT5_Format:kt,RGB_BPTC_SIGNED_Format:he,RGB_BPTC_UNSIGNED_Format:ce,RGB_ETC1_Format:qt,RGB_ETC2_Format:Xt,RGB_PVRTC_2BPPV1_Format:Gt,RGB_PVRTC_4BPPV1_Format:Vt,RGB_S3TC_DXT1_Format:Ft,RGFormat:1030,RGIntegerFormat:Ut,RawShaderMaterial:Xc,Ray:dn,Raycaster:class{constructor(t,e,i=0,n=1/0){this.ray=new dn(t,e),this.near=i,this.far=n,this.camera=null,this.layers=new wn,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 Pd(t,this,i,e),i.sort(Rd),i}intersectObjects(t,e=!0,i=[]){for(let n=0,s=t.length;n<s;n++)Pd(t[n],this,i,e);return i.sort(Rd),i}},Rec709Primaries:Pe,RectAreaLight:qu,RedFormat:1028,RedIntegerFormat:Nt,ReinhardToneMapping:2,RenderTarget:Li,RepeatWrapping:pt,ReplaceStencilOp:7681,ReverseSubtractEquation:102,RingGeometry:Uc,SIGNED_RED_GREEN_RGTC2_Format:pe,SIGNED_RED_RGTC1_Format:ue,SRGBColorSpace:we,SRGBTransfer:Re,Scene:Yo,ShaderChunk:dr,ShaderLib:mr,ShaderMaterial:Zs,ShadowMaterial:qc,Shape:nc,ShapeGeometry:Oc,ShapePath:class{constructor(){this.type="ShapePath",this.color=new es,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new Wh,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=Cc.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 nc,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 nc,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 nc;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:Cc,ShortType:1011,Skeleton:Ll,SkeletonHelper:class extends ph{constructor(t){const e=Bd(t),i=new ws,n=[],s=[],r=new es(0,0,1),a=new es(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 gs(n,3)),i.setAttribute("color",new gs(s,3)),super(i,new sh({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");Fd.copy(this.root.matrixWorld).invert();for(let s=0,r=0;s<e.length;s++){const t=e[s];t.parent&&t.parent.isBone&&(Od.multiplyMatrices(Fd,t.matrixWorld),Ud.setFromMatrixPosition(Od),n.setXYZ(r,Ud.x,Ud.y,Ud.z),Od.multiplyMatrices(Fd,t.parent.matrixWorld),Ud.setFromMatrixPosition(Od),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:El,Source:Ei,Sphere:sn,SphereGeometry:Fc,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($e(e/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}},SphericalHarmonics3:Xu,SplineCurve:Vh,SpotLight:Ou,SpotLightHelper:class extends Bn{constructor(t,e){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const i=new ws,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 gs(n,3));const s=new sh({fog:!1,toneMapped:!1});this.cone=new ph(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),Nd.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Nd),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},Sprite:dl,SpriteMaterial:$o,SrcAlphaFactor:Y,SrcAlphaSaturateFactor:210,SrcColorFactor:202,StaticCopyUsage:35046,StaticDrawUsage:Ve,StaticReadUsage:35045,StereoCamera:class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Ks,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Ks,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,rd.copy(t.projectionMatrix);const i=e.eyeSep/2,n=i*e.near/e.focus,s=e.near*Math.tan(Ze*e.fov*.5)/e.zoom;let r,a;sd.elements[12]=-i,nd.elements[12]=i,r=-s*e.aspect+n,a=s*e.aspect+n,rd.elements[0]=2*e.near/(a-r),rd.elements[8]=(a+r)/(a-r),this.cameraL.projectionMatrix.copy(rd),r=-s*e.aspect-n,a=s*e.aspect-n,rd.elements[0]=2*e.near/(a-r),rd.elements[8]=(a+r)/(a-r),this.cameraR.projectionMatrix.copy(rd)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(sd),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(nd)}},StreamCopyUsage:35042,StreamDrawUsage:35040,StreamReadUsage:35041,StringKeyframeTrack:_u,SubtractEquation:101,SubtractiveBlending:3,TOUCH:{ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},TangentSpaceNormalMap:0,TetrahedronGeometry:Bc,Texture:Ri,TextureLoader:class extends wu{constructor(t){super(t)}load(t,e,i,n){const s=new Ri,r=new Cu(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:zc,TorusKnotGeometry:kc,Triangle:Jn,TriangleFanDrawMode:2,TriangleStripDrawMode:1,TrianglesDrawMode:0,TubeGeometry:Vc,TwoPassDoubleSide:2,UVMapping:ot,Uint16BufferAttribute:ms,Uint32BufferAttribute:fs,Uint8BufferAttribute:class extends ps{constructor(t,e,i){super(new Uint8Array(t),e,i)}},Uint8ClampedBufferAttribute:class extends ps{constructor(t,e,i){super(new Uint8ClampedArray(t),e,i)}},Uniform:Ad,UniformsGroup:class extends Xe{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:Cd++}),this.name="",this.usage=Ve,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:pr,UniformsUtils:Ys,UnsignedByteType:bt,UnsignedInt248Type:Pt,UnsignedIntType:Tt,UnsignedShort4444Type:Ct,UnsignedShort5551Type:Rt,UnsignedShortType:St,VSMShadowMap:3,Vector2:ai,Vector3:Oi,Vector4:Pi,VectorKeyframeTrack:vu,VideoTexture:class extends Ri{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:yt,this.magFilter=void 0!==s?s:yt,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:qo,WebGL3DRenderTarget:class extends Ii{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new Ni(null,t,e,i),this.texture.isRenderTargetTexture=!0}},WebGLArrayRenderTarget:class extends Ii{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new Di(null,t,e,i),this.texture.isRenderTargetTexture=!0}},WebGLCoordinateSystem:We,WebGLCubeRenderTarget:er,WebGLMultipleRenderTargets:class extends Ii{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:Ii,WebGLRenderer:Wo,WebGLUtils:Oo,WebGPUCoordinateSystem:qe,WireframeGeometry:Gc,WrapAroundEnding:ye,ZeroCurvatureEnding:_e,ZeroFactor:200,ZeroSlopeEnding:ve,ZeroStencilOp:0,_SRGBAFormat:He,createCanvasElement:pi,sRGBEncoding:be},Symbol.toStringTag,{value:"Module"}));t.EasterEggQuest=O,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=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}function g(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 _{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._replacedTextNode=null,this._replacedTextContent="",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(),this._restoreReplacedText(),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=this._shuffleCandidates(c,h).concat(this._shuffleCandidates(u,h+17)),p=d.map(t=>{var e;return`${t.tagName}:${((null==(e=t.textContent)?void 0:e.trim())??"").slice(0,30)}`}),m=d.filter((t,e)=>!o.has(p[e]));0===m.length&&(o.clear(),a=[]);const f=m.length>0?[...m,...d.filter((t,e)=>o.has(p[e]))]:d;for(const g of f){const e=g;if(!this._canHostInjectedTrigger(e))continue;const i=this._replaceTextCandidate(e);if(!i)continue;const a=n.indexOf(g);if(a>=0){o.add(s[a]);try{localStorage.setItem(r,JSON.stringify([...o].slice(-20)))}catch{}}return this._injectedElement=i,this.targetElement=i,this._attachToElement(i),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(!f(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||!this._canHostInjectedTrigger(t))})}_shuffleCandidates(t,e){if(t.length<2)return[...t];const i=[...t];let n=(e||1)^65535&Date.now();const s=()=>(n^=n<<13,n^=n>>>17,n^=n<<5,(n>>>0)%1e4/1e4);for(let r=i.length-1;r>0;r--){const t=Math.floor(s()*(r+1));[i[r],i[t]]=[i[t],i[r]]}return i}_canHostInjectedTrigger(t){const e=getComputedStyle(t),i=e.textOverflow,n=e.whiteSpace,s=e.overflowX,r=e.overflow;return!("ellipsis"===i||"nowrap"===n&&["hidden","clip"].includes(s||r)||t.scrollWidth>t.clientWidth+2&&t.clientWidth>0||t.scrollHeight>t.clientHeight+2&&t.clientHeight>0&&"nowrap"===n)}_isTriggerClipped(t,e){if(!document.body.contains(e))return!0;const i=t.getBoundingClientRect(),n=e.getBoundingClientRect(),s=getComputedStyle(t),r=["hidden","clip"].includes(s.overflowX||s.overflow),a=["hidden","clip"].includes(s.overflowY||s.overflow);return t.scrollWidth>t.clientWidth+2&&t.clientWidth>0||"ellipsis"===s.textOverflow||!!(r&&n.right>i.right-1)||!!(r&&n.left<i.left+1)||!!(a&&n.bottom>i.bottom-1)||!!(a&&n.top<i.top+1)}_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._restoreReplacedText(),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=this._shuffleCandidates(i.map(t=>t.parentElement).filter(t=>!!t),Date.now()).map(t=>i.find(e=>e.parentElement===t)).filter(t=>!!t);for(const a of r){const i=a.textContent??"",n=a.parentElement;if(!n)continue;const s=[];for(let t=1;t<i.length-1;t++)" "===i[t]&&s.push(t);if(s.length<2)continue;const r=Math.floor(.2*s.length),o=Math.ceil(.8*s.length),l=this._shuffleNumbers(s.slice(r,Math.max(r+1,o)));for(const h of l){const s=i.slice(0,h),r=i.slice(h),o=t.getBoundingClientRect(),l=document.createTextNode(r);this._applyTriggerTypography(e,n),a.textContent=s,n.insertBefore(e,a.nextSibling),n.insertBefore(l,e.nextSibling);const c=t.getBoundingClientRect();if(!(Math.abs(c.height-o.height)>8||Math.abs(c.width-o.width)>24||this._isTriggerClipped(t,e)))return!0;e.remove(),l.remove(),a.textContent=i}}return!1}_shuffleNumbers(t){const e=[...t];for(let i=e.length-1;i>0;i--){const t=Math.floor(Math.random()*(i+1));[e[i],e[t]]=[e[t],e[i]]}return e}_replaceTextCandidate(t){const e=this._findReplacementTextTarget(t);if(!e)return null;const i=document.createElement("span");i.textContent="start hunt",i.setAttribute("data-eeq","trigger"),i.classList.add("eeq-inline-trigger"),this._applyTriggerTypography(i,e.parent);const n=t.getBoundingClientRect();e.textNode.textContent="",e.parent.insertBefore(i,e.textNode.nextSibling);const s=t.getBoundingClientRect();return Math.abs(s.height-n.height)>6||Math.abs(s.width-n.width)>20||this._isTriggerClipped(t,i)?(i.remove(),e.textNode.textContent=e.text,null):(this._replacedTextNode=e.textNode,this._replacedTextContent=e.text,i)}_findReplacementTextTarget(t){const e=[],i=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,{acceptNode:t=>{const e=t.parentElement,i=this._normalizeComparableText(t.textContent??"");return e&&0!==i.length?e.closest("[data-eeq], script, style, noscript")?NodeFilter.FILTER_REJECT:f(e)?Math.abs(i.length-10)>10?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT:NodeFilter.FILTER_REJECT}});let n=i.nextNode();for(;n;){const t=n,s=t.parentElement,r=t.textContent??"";s&&e.push({textNode:t,parent:s,text:r}),n=i.nextNode()}return e.length?this._shuffleTextTargets(e)[0]??null:null}_shuffleTextTargets(t){const e=[...t];for(let i=e.length-1;i>0;i--){const t=Math.floor(Math.random()*(i+1));[e[i],e[t]]=[e[t],e[i]]}return e}_normalizeComparableText(t){return t.replace(/\s+/g," ").trim()}_restoreReplacedText(){this._replacedTextNode&&(this._replacedTextNode.textContent=this._replacedTextContent),this._replacedTextNode=null,this._replacedTextContent=""}_applyTriggerTypography(t,e){const i=getComputedStyle(e);t.style.cssText=`\n font-family: ${i.fontFamily};\n font-size: ${i.fontSize};\n font-weight: ${i.fontWeight};\n font-style: ${i.fontStyle};\n line-height: ${i.lineHeight};\n letter-spacing: ${i.letterSpacing};\n text-transform: ${i.textTransform};\n color: ${i.color};\n cursor: pointer;\n white-space: nowrap;\n transition: color 0.18s ease;\n `}_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 .eeq-inline-trigger:hover {\n color: ${this.config.theme.accent};\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 v{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 y{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 x{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(()=>Qd)}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())}}burstRhythmParticles(t,e){if(!this.THREE||!this.scene)return;const i=this.THREE,n=Math.min(14,6+Math.floor(6*t)+Math.min(3,Math.floor(e)));for(let s=0;s<n;s++){const t=2*Math.PI*s/n+.35*(Math.random()-.5),e=.45+2.15*Math.random(),r=Math.cos(t)*e,a=-2.95-.75*Math.random(),o=.036+.038*Math.random(),l=this._createMiniEggGeo(i,o),h=this._createMiniEggMat(i,.18+.12*Math.random()),c=new i.Mesh(l,h);c.position.set(r,a,.8*Math.random()-1),c.rotation.set(Math.random()*Math.PI,Math.random()*Math.PI,Math.random()*Math.PI),this.scene.add(c),this._ambientParticles.push({mesh:c,life:1.7+.45*Math.random(),vy:.85+.65*Math.random(),fadeIn:!0})}for(;this._ambientParticles.length>120;){const t=this._ambientParticles.shift();if(!t)break;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 M{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 b{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 S=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",t=>{var e;t.preventDefault(),t.stopPropagation(),null==(e=this._onFinish)||e.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=g(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=g(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(g(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 `}};S.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 w=S;class T{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 E="eeq_scores",A="eeq_progress",C="eeq_completed";class R{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(E,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(E)}catch{}}_loadAll(){try{const t=localStorage.getItem(E);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(A,JSON.stringify(t))}catch{}}loadProgress(){if(!this._enabled)return null;try{const t=localStorage.getItem(A);return t?JSON.parse(t):null}catch{return null}}clearProgress(){try{localStorage.removeItem(A)}catch{}}markCompleted(){if(this._enabled)try{localStorage.setItem(C,"1"),localStorage.removeItem(A)}catch{}}isCompleted(){if(!this._enabled)return!1;try{return"1"===localStorage.getItem(C)}catch{return!1}}}class P{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 L{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 I{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],n=e[this._lastPhaseCount+1];if(!t||!n)break;{const e=this._evaluateCycle(t,n);this._totalCycles++,e?(this._goodCycles++,this._lastGoodCycleAt=Date.now(),this.bus.emit("rhythm:cycle",{progress:Math.min(1,this._goodCycles/i),cycles: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),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 D{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 N{constructor(){this._active=!1,this._intensity=0,this._targetIntensity=0,this._rafId=0,this._overlay=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)})`}}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,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;this._active&&(this._active=!1,cancelAnimationFrame(this._rafId),null==(t=this._overlay)||t.remove(),this._overlay=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 U{constructor(t,e){this.bus=new c,this.fsm=new d,this.input=new m,this.scoring=new T,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 R(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;if(this.persistence.isCompleted())return void(this._destroyed=!0);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:cycle",t=>{this.threeRenderer&&this.threeRenderer.burstRhythmParticles(t.progress,t.cycles)}),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.fadeOutAmbientParticles()}),this.overlay=new b(this.config),this.overlay.mount(),this.narrative=new v(this.config),this.narrative.mount(),this.shrine=new y(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;if(!this.persistence.isCompleted()){try{if("1"===localStorage.getItem("eeq_optout"))return}catch{}this.state.startTime=Date.now(),null==(t=this.hud)||t.startTimer(),this.hiddenEntry=new _(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 P(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 L(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 I(this.config,this.script,this.input,this.bus);this.activeStage=n,await n.start(),this.fsm.transitionTo("stage3-active"),this.pageBreather=new N,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 D),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 w(this.config),this.results.show(s,()=>{this.persistence.markCompleted(),this.destroy(),this._reloadPage()}),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 x(this.config),await this.threeRenderer.init())return void(this.eggRenderer=this.threeRenderer);this.threeRenderer=null}this.fallbackRenderer=new M(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))}_reloadPage(){try{return void window.location.reload()}catch{}try{window.location.assign(window.location.href)}catch{}}}let O=null;const F={async init(t={}){O&&(O.destroy(),O=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;O=new U(e,i),await O.init()},pause(){null==O||O.pause()},resume(){null==O||O.resume()},async restart(){await(null==O?void 0:O.restart())},destroy(){null==O||O.destroy(),O=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=()=>F.init();"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}const B="160",z=0,k=1,V=2,G=100,H=101,W=102,q=200,X=201,j=202,Y=203,Z=204,J=205,K=206,$=207,Q=208,tt=209,et=210,it=211,nt=212,st=213,rt=214,at="attached",ot="detached",lt=300,ht=301,ct=302,ut=303,dt=304,pt=306,mt=1e3,ft=1001,gt=1002,_t=1003,vt=1004,yt=1005,xt=1006,Mt=1007,bt=1008,St=1009,wt=1012,Tt=1013,Et=1014,At=1015,Ct=1016,Rt=1017,Pt=1018,Lt=1020,It=1023,Dt=1026,Nt=1027,Ut=1029,Ot=1031,Ft=1033,Bt=33776,zt=33777,kt=33778,Vt=33779,Gt=35840,Ht=35841,Wt=35842,qt=35843,Xt=36196,jt=37492,Yt=37496,Zt=37808,Jt=37809,Kt=37810,$t=37811,Qt=37812,te=37813,ee=37814,ie=37815,ne=37816,se=37817,re=37818,ae=37819,oe=37820,le=37821,he=36492,ce=36494,ue=36495,de=36284,pe=36285,me=36286,fe=2300,ge=2301,_e=2302,ve=2400,ye=2401,xe=2402,Me=2501,be=3e3,Se=3001,we="",Te="srgb",Ee="srgb-linear",Ae="display-p3",Ce="display-p3-linear",Re="linear",Pe="srgb",Le="rec709",Ie="p3",De=7680,Ne=512,Ue=513,Oe=514,Fe=515,Be=516,ze=517,ke=518,Ve=519,Ge=35044,He="300 es",We=1035,qe=2e3,Xe=2001;class je{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 Ye=["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 Ze=1234567;const Je=Math.PI/180,Ke=180/Math.PI;function $e(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,i=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return(Ye[255&t]+Ye[t>>8&255]+Ye[t>>16&255]+Ye[t>>24&255]+"-"+Ye[255&e]+Ye[e>>8&255]+"-"+Ye[e>>16&15|64]+Ye[e>>24&255]+"-"+Ye[63&i|128]+Ye[i>>8&255]+"-"+Ye[i>>16&255]+Ye[i>>24&255]+Ye[255&n]+Ye[n>>8&255]+Ye[n>>16&255]+Ye[n>>24&255]).toLowerCase()}function Qe(t,e,i){return Math.max(e,Math.min(i,t))}function ti(t,e){return(t%e+e)%e}function ei(t,e,i){return(1-i)*t+i*e}function ii(t){return!(t&t-1)&&0!==t}function ni(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function si(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 ri(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 ai={DEG2RAD:Je,RAD2DEG:Ke,generateUUID:$e,clamp:Qe,euclideanModulo:ti,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:ei,damp:(t,e,i,n)=>ei(t,e,1-Math.exp(-i*n)),pingpong:(t,e=1)=>e-Math.abs(ti(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&&(Ze=t);let e=Ze+=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*Je,radToDeg:t=>t*Ke,isPowerOfTwo:ii,ceilPowerOfTwo:t=>Math.pow(2,Math.ceil(Math.log(t)/Math.LN2)),floorPowerOfTwo:ni,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:ri,denormalize:si};class oi{constructor(t=0,e=0){oi.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(Qe(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 li{constructor(t,e,i,n,s,r,a,o,l){li.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(hi.makeScale(t,e)),this}rotate(t){return this.premultiply(hi.makeRotation(-t)),this}translate(t,e){return this.premultiply(hi.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 hi=new li;function ci(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}const ui={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function di(t,e){return new ui[t](e)}function pi(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function mi(){const t=pi("canvas");return t.style.display="block",t}const fi={};function gi(t){t in fi||(fi[t]=!0)}const _i=(new li).set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),vi=(new li).set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),yi={[Ee]:{transfer:Re,primaries:Le,toReference:t=>t,fromReference:t=>t},[Te]:{transfer:Pe,primaries:Le,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[Ce]:{transfer:Re,primaries:Ie,toReference:t=>t.applyMatrix3(vi),fromReference:t=>t.applyMatrix3(_i)},[Ae]:{transfer:Pe,primaries:Ie,toReference:t=>t.convertSRGBToLinear().applyMatrix3(vi),fromReference:t=>t.applyMatrix3(_i).convertLinearToSRGB()}},xi=new Set([Ee,Ce]),Mi={enabled:!0,_workingColorSpace:Ee,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(t){if(!xi.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=yi[e].toReference;return(0,yi[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=>yi[t].primaries,getTransfer:t=>t===we?Re:yi[t].transfer};function bi(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function Si(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}let wi;class Ti{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===wi&&(wi=pi("canvas")),wi.width=t.width,wi.height=t.height;const i=wi.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),e=wi}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=pi("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*bi(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*bi(e[t]/255)):e[t]=bi(e[t]);return{data:e,width:t.width,height:t.height}}return t}}let Ei=0;class Ai{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Ei++}),this.uuid=$e(),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(Ci(n[e].image)):t.push(Ci(n[e]))}else t=Ci(n);i.url=t}return e||(t.images[this.uuid]=i),i}}function Ci(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?Ti.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:{}}let Ri=0;class Pi extends je{constructor(t=Pi.DEFAULT_IMAGE,e=Pi.DEFAULT_MAPPING,i=1001,n=1001,s=1006,r=1008,a=1023,o=1009,l=Pi.DEFAULT_ANISOTROPY,h=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Ri++}),this.uuid=$e(),this.name="",this.source=new Ai(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 oi(0,0),this.repeat=new oi(1,1),this.center=new oi(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new li,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,"string"==typeof h?this.colorSpace=h:(gi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=h===Se?Te:we),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!==lt)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case mt:t.x=t.x-Math.floor(t.x);break;case ft:t.x=t.x<0?0:1;break;case gt: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 mt:t.y=t.y-Math.floor(t.y);break;case ft:t.y=t.y<0?0:1;break;case gt: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 gi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Te?Se:be}set encoding(t){gi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=t===Se?Te:we}}Pi.DEFAULT_IMAGE=null,Pi.DEFAULT_MAPPING=lt,Pi.DEFAULT_ANISOTROPY=1;class Li{constructor(t=0,e=0,i=0,n=1){Li.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 Ii extends je{constructor(t=1,e=1,i={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new Li(0,0,t,e),this.scissorTest=!1,this.viewport=new Li(0,0,t,e);const n={width:t,height:e,depth:1};void 0!==i.encoding&&(gi("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),i.colorSpace=i.encoding===Se?Te:we),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:xt,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},i),this.texture=new Pi(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 Ai(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 Di extends Ii{constructor(t=1,e=1,i={}){super(t,e,i),this.isWebGLRenderTarget=!0}}class Ni extends Pi{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=_t,this.minFilter=_t,this.wrapR=ft,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ui extends Pi{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=_t,this.minFilter=_t,this.wrapR=ft,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Oi{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(Qe(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 Fi{constructor(t=0,e=0,i=0){Fi.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(zi.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(zi.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 Bi.copy(this).projectOnVector(t),this.sub(Bi)}reflect(t){return this.sub(Bi.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(Qe(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 Bi=new Fi,zi=new Oi;class ki{constructor(t=new Fi(1/0,1/0,1/0),e=new Fi(-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(Gi.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,i=t.count;e<i;e++)this.expandByPoint(Gi.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=Gi.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,Gi):Gi.fromBufferAttribute(n,e),Gi.applyMatrix4(t.matrixWorld),this.expandByPoint(Gi);else void 0!==t.boundingBox?(null===t.boundingBox&&t.computeBoundingBox(),Hi.copy(t.boundingBox)):(null===i.boundingBox&&i.computeBoundingBox(),Hi.copy(i.boundingBox)),Hi.applyMatrix4(t.matrixWorld),this.union(Hi)}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,Gi),Gi.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(Ji),Ki.subVectors(this.max,Ji),Wi.subVectors(t.a,Ji),qi.subVectors(t.b,Ji),Xi.subVectors(t.c,Ji),ji.subVectors(qi,Wi),Yi.subVectors(Xi,qi),Zi.subVectors(Wi,Xi);let e=[0,-ji.z,ji.y,0,-Yi.z,Yi.y,0,-Zi.z,Zi.y,ji.z,0,-ji.x,Yi.z,0,-Yi.x,Zi.z,0,-Zi.x,-ji.y,ji.x,0,-Yi.y,Yi.x,0,-Zi.y,Zi.x,0];return!!tn(e,Wi,qi,Xi,Ki)&&(e=[1,0,0,0,1,0,0,0,1],!!tn(e,Wi,qi,Xi,Ki)&&($i.crossVectors(ji,Yi),e=[$i.x,$i.y,$i.z],tn(e,Wi,qi,Xi,Ki)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Gi).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(Gi).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()||(Vi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Vi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Vi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Vi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Vi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Vi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Vi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Vi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Vi)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const Vi=[new Fi,new Fi,new Fi,new Fi,new Fi,new Fi,new Fi,new Fi],Gi=new Fi,Hi=new ki,Wi=new Fi,qi=new Fi,Xi=new Fi,ji=new Fi,Yi=new Fi,Zi=new Fi,Ji=new Fi,Ki=new Fi,$i=new Fi,Qi=new Fi;function tn(t,e,i,n,s){for(let r=0,a=t.length-3;r<=a;r+=3){Qi.fromArray(t,r);const a=s.x*Math.abs(Qi.x)+s.y*Math.abs(Qi.y)+s.z*Math.abs(Qi.z),o=e.dot(Qi),l=i.dot(Qi),h=n.dot(Qi);if(Math.max(-Math.max(o,l,h),Math.min(o,l,h))>a)return!1}return!0}const en=new ki,nn=new Fi,sn=new Fi;class rn{constructor(t=new Fi,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):en.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;nn.subVectors(t,this.center);const e=nn.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),i=.5*(t-this.radius);this.center.addScaledVector(nn,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):(sn.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(nn.copy(t.center).add(sn)),this.expandByPoint(nn.copy(t.center).sub(sn))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const an=new Fi,on=new Fi,ln=new Fi,hn=new Fi,cn=new Fi,un=new Fi,dn=new Fi;class pn{constructor(t=new Fi,e=new Fi(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,an)),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=an.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(an.copy(this.origin).addScaledVector(this.direction,e),an.distanceToSquared(t))}distanceSqToSegment(t,e,i,n){on.copy(t).add(e).multiplyScalar(.5),ln.copy(e).sub(t).normalize(),hn.copy(this.origin).sub(on);const s=.5*t.distanceTo(e),r=-this.direction.dot(ln),a=hn.dot(this.direction),o=-hn.dot(ln),l=hn.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(on).addScaledVector(ln,u),d}intersectSphere(t,e){an.subVectors(t.center,this.origin);const i=an.dot(this.direction),n=an.dot(an)-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,an)}intersectTriangle(t,e,i,n,s){cn.subVectors(e,t),un.subVectors(i,t),dn.crossVectors(cn,un);let r,a=this.direction.dot(dn);if(a>0){if(n)return null;r=1}else{if(!(a<0))return null;r=-1,a=-a}hn.subVectors(this.origin,t);const o=r*this.direction.dot(un.crossVectors(hn,un));if(o<0)return null;const l=r*this.direction.dot(cn.cross(hn));if(l<0)return null;if(o+l>a)return null;const h=-r*hn.dot(dn);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 mn{constructor(t,e,i,n,s,r,a,o,l,h,c,u,d,p,m,f){mn.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 mn).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/fn.setFromMatrixColumn(t,0).length(),s=1/fn.setFromMatrixColumn(t,1).length(),r=1/fn.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(_n,t,vn)}lookAt(t,e,i){const n=this.elements;return Mn.subVectors(t,e),0===Mn.lengthSq()&&(Mn.z=1),Mn.normalize(),yn.crossVectors(i,Mn),0===yn.lengthSq()&&(1===Math.abs(i.z)?Mn.x+=1e-4:Mn.z+=1e-4,Mn.normalize(),yn.crossVectors(i,Mn)),yn.normalize(),xn.crossVectors(Mn,yn),n[0]=yn.x,n[4]=xn.x,n[8]=Mn.x,n[1]=yn.y,n[5]=xn.y,n[9]=Mn.y,n[2]=yn.z,n[6]=xn.z,n[10]=Mn.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=fn.set(n[0],n[1],n[2]).length();const r=fn.set(n[4],n[5],n[6]).length(),a=fn.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],gn.copy(this);const o=1/s,l=1/r,h=1/a;return gn.elements[0]*=o,gn.elements[1]*=o,gn.elements[2]*=o,gn.elements[4]*=l,gn.elements[5]*=l,gn.elements[6]*=l,gn.elements[8]*=h,gn.elements[9]*=h,gn.elements[10]*=h,e.setFromRotationMatrix(gn),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===qe)d=-(r+s)/(r-s),p=-2*r*s/(r-s);else{if(a!==Xe)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===qe)p=(r+s)*c,m=-2*c;else{if(a!==Xe)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 fn=new Fi,gn=new mn,_n=new Fi(0,0,0),vn=new Fi(1,1,1),yn=new Fi,xn=new Fi,Mn=new Fi,bn=new mn,Sn=new Oi;class wn{constructor(t=0,e=0,i=0,n=wn.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(Qe(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(-Qe(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(Qe(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(-Qe(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(Qe(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(-Qe(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 bn.makeRotationFromQuaternion(t),this.setFromRotationMatrix(bn,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Sn.setFromEuler(this),this.setFromQuaternion(Sn,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}}wn.DEFAULT_ORDER="XYZ";class Tn{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 En=0;const An=new Fi,Cn=new Oi,Rn=new mn,Pn=new Fi,Ln=new Fi,In=new Fi,Dn=new Oi,Nn=new Fi(1,0,0),Un=new Fi(0,1,0),On=new Fi(0,0,1),Fn={type:"added"},Bn={type:"removed"};class zn extends je{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:En++}),this.uuid=$e(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=zn.DEFAULT_UP.clone();const t=new Fi,e=new wn,i=new Oi,n=new Fi(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 mn},normalMatrix:{value:new li}}),this.matrix=new mn,this.matrixWorld=new mn,this.matrixAutoUpdate=zn.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=zn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Tn,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 Cn.setFromAxisAngle(t,e),this.quaternion.multiply(Cn),this}rotateOnWorldAxis(t,e){return Cn.setFromAxisAngle(t,e),this.quaternion.premultiply(Cn),this}rotateX(t){return this.rotateOnAxis(Nn,t)}rotateY(t){return this.rotateOnAxis(Un,t)}rotateZ(t){return this.rotateOnAxis(On,t)}translateOnAxis(t,e){return An.copy(t).applyQuaternion(this.quaternion),this.position.add(An.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Nn,t)}translateY(t){return this.translateOnAxis(Un,t)}translateZ(t){return this.translateOnAxis(On,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Rn.copy(this.matrixWorld).invert())}lookAt(t,e,i){t.isVector3?Pn.copy(t):Pn.set(t,e,i);const n=this.parent;this.updateWorldMatrix(!0,!1),Ln.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Rn.lookAt(Ln,Pn,this.up):Rn.lookAt(Pn,Ln,this.up),this.quaternion.setFromRotationMatrix(Rn),n&&(Rn.extractRotation(n.matrixWorld),Cn.setFromRotationMatrix(Rn),this.quaternion.premultiply(Cn.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(Fn)),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(Bn)),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),Rn.copy(this.matrixWorld).invert(),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),Rn.multiply(t.parent.matrixWorld)),t.applyMatrix4(Rn),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(Ln,t,In),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ln,Dn,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}}zn.DEFAULT_UP=new Fi(0,1,0),zn.DEFAULT_MATRIX_AUTO_UPDATE=!0,zn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const kn=new Fi,Vn=new Fi,Gn=new Fi,Hn=new Fi,Wn=new Fi,qn=new Fi,Xn=new Fi,jn=new Fi,Yn=new Fi,Zn=new Fi;let Jn=!1;class Kn{constructor(t=new Fi,e=new Fi,i=new Fi){this.a=t,this.b=e,this.c=i}static getNormal(t,e,i,n){n.subVectors(i,e),kn.subVectors(t,e),n.cross(kn);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){kn.subVectors(n,e),Vn.subVectors(i,e),Gn.subVectors(t,e);const r=kn.dot(kn),a=kn.dot(Vn),o=kn.dot(Gn),l=Vn.dot(Vn),h=Vn.dot(Gn),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,Hn)&&Hn.x>=0&&Hn.y>=0&&Hn.x+Hn.y<=1}static getUV(t,e,i,n,s,r,a,o){return!1===Jn&&(Jn=!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,Hn)?(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,Hn.x),o.addScaledVector(r,Hn.y),o.addScaledVector(a,Hn.z),o)}static isFrontFacing(t,e,i,n){return kn.subVectors(i,e),Vn.subVectors(t,e),kn.cross(Vn).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 kn.subVectors(this.c,this.b),Vn.subVectors(this.a,this.b),.5*kn.cross(Vn).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Kn.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Kn.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,i,n,s){return!1===Jn&&(Jn=!0),Kn.getInterpolation(t,this.a,this.b,this.c,e,i,n,s)}getInterpolation(t,e,i,n,s){return Kn.getInterpolation(t,this.a,this.b,this.c,e,i,n,s)}containsPoint(t){return Kn.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Kn.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;Wn.subVectors(n,i),qn.subVectors(s,i),jn.subVectors(t,i);const o=Wn.dot(jn),l=qn.dot(jn);if(o<=0&&l<=0)return e.copy(i);Yn.subVectors(t,n);const h=Wn.dot(Yn),c=qn.dot(Yn);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(Wn,r);Zn.subVectors(t,s);const d=Wn.dot(Zn),p=qn.dot(Zn);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(qn,a);const f=h*p-d*c;if(f<=0&&c-h>=0&&d-p>=0)return Xn.subVectors(s,n),a=(c-h)/(c-h+(d-p)),e.copy(n).addScaledVector(Xn,a);const g=1/(f+m+u);return r=m*g,a=u*g,e.copy(i).addScaledVector(Wn,r).addScaledVector(qn,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const $n={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},Qn={h:0,s:0,l:0},ts={h:0,s:0,l:0};function es(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 is{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=Te){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,Mi.toWorkingColorSpace(this,e),this}setRGB(t,e,i,n=Mi.workingColorSpace){return this.r=t,this.g=e,this.b=i,Mi.toWorkingColorSpace(this,n),this}setHSL(t,e,i,n=Mi.workingColorSpace){if(t=ti(t,1),e=Qe(e,0,1),i=Qe(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=es(s,n,t+1/3),this.g=es(s,n,t),this.b=es(s,n,t-1/3)}return Mi.toWorkingColorSpace(this,n),this}setStyle(t,e=Te){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=Te){const i=$n[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=bi(t.r),this.g=bi(t.g),this.b=bi(t.b),this}copyLinearToSRGB(t){return this.r=Si(t.r),this.g=Si(t.g),this.b=Si(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Te){return Mi.fromWorkingColorSpace(ns.copy(this),t),65536*Math.round(Qe(255*ns.r,0,255))+256*Math.round(Qe(255*ns.g,0,255))+Math.round(Qe(255*ns.b,0,255))}getHexString(t=Te){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Mi.workingColorSpace){Mi.fromWorkingColorSpace(ns.copy(this),e);const i=ns.r,n=ns.g,s=ns.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=Mi.workingColorSpace){return Mi.fromWorkingColorSpace(ns.copy(this),e),t.r=ns.r,t.g=ns.g,t.b=ns.b,t}getStyle(t=Te){Mi.fromWorkingColorSpace(ns.copy(this),t);const e=ns.r,i=ns.g,n=ns.b;return t!==Te?`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(Qn),this.setHSL(Qn.h+t,Qn.s+e,Qn.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(Qn),t.getHSL(ts);const i=ei(Qn.h,ts.h,e),n=ei(Qn.s,ts.s,e),s=ei(Qn.l,ts.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 ns=new is;is.NAMES=$n;let ss=0;class rs extends je{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ss++}),this.uuid=$e(),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=Z,this.blendDst=J,this.blendEquation=G,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new is(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=De,this.stencilZFail=De,this.stencilZPass=De,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!==Z&&(i.blendSrc=this.blendSrc),this.blendDst!==J&&(i.blendDst=this.blendDst),this.blendEquation!==G&&(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!==De&&(i.stencilFail=this.stencilFail),this.stencilZFail!==De&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==De&&(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 as extends rs{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new is(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 os=ls();function ls(){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 hs(t){Math.abs(t),t=Qe(t,-65504,65504),os.floatView[0]=t;const e=os.uint32View[0],i=e>>23&511;return os.baseTable[i]+((8388607&e)>>os.shiftTable[i])}function cs(t){const e=t>>10;return os.uint32View[0]=os.mantissaTable[os.offsetTable[e]+(1023&t)]+os.exponentTable[e],os.floatView[0]}const us={toHalfFloat:hs,fromHalfFloat:cs},ds=new Fi,ps=new oi;class ms{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=Ge,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=At,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++)ps.fromBufferAttribute(this,e),ps.applyMatrix3(t),this.setXY(e,ps.x,ps.y);else if(3===this.itemSize)for(let e=0,i=this.count;e<i;e++)ds.fromBufferAttribute(this,e),ds.applyMatrix3(t),this.setXYZ(e,ds.x,ds.y,ds.z);return this}applyMatrix4(t){for(let e=0,i=this.count;e<i;e++)ds.fromBufferAttribute(this,e),ds.applyMatrix4(t),this.setXYZ(e,ds.x,ds.y,ds.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)ds.fromBufferAttribute(this,e),ds.applyNormalMatrix(t),this.setXYZ(e,ds.x,ds.y,ds.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)ds.fromBufferAttribute(this,e),ds.transformDirection(t),this.setXYZ(e,ds.x,ds.y,ds.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=si(i,this.array)),i}setComponent(t,e,i){return this.normalized&&(i=ri(i,this.array)),this.array[t*this.itemSize+e]=i,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=si(e,this.array)),e}setX(t,e){return this.normalized&&(e=ri(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=si(e,this.array)),e}setY(t,e){return this.normalized&&(e=ri(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=si(e,this.array)),e}setZ(t,e){return this.normalized&&(e=ri(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=si(e,this.array)),e}setW(t,e){return this.normalized&&(e=ri(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=ri(e,this.array),i=ri(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=ri(e,this.array),i=ri(i,this.array),n=ri(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=ri(e,this.array),i=ri(i,this.array),n=ri(n,this.array),s=ri(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!==Ge&&(t.usage=this.usage),t}}class fs extends ms{constructor(t,e,i){super(new Uint16Array(t),e,i)}}class gs extends ms{constructor(t,e,i){super(new Uint32Array(t),e,i)}}class _s extends ms{constructor(t,e,i){super(new Float32Array(t),e,i)}}let vs=0;const ys=new mn,xs=new zn,Ms=new Fi,bs=new ki,Ss=new ki,ws=new Fi;class Ts extends je{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:vs++}),this.uuid=$e(),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(ci(t)?gs:fs)(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 li).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 ys.makeRotationFromQuaternion(t),this.applyMatrix4(ys),this}rotateX(t){return ys.makeRotationX(t),this.applyMatrix4(ys),this}rotateY(t){return ys.makeRotationY(t),this.applyMatrix4(ys),this}rotateZ(t){return ys.makeRotationZ(t),this.applyMatrix4(ys),this}translate(t,e,i){return ys.makeTranslation(t,e,i),this.applyMatrix4(ys),this}scale(t,e,i){return ys.makeScale(t,e,i),this.applyMatrix4(ys),this}lookAt(t){return xs.lookAt(t),xs.updateMatrix(),this.applyMatrix4(xs.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ms).negate(),this.translate(Ms.x,Ms.y,Ms.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 _s(e,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new ki);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)this.boundingBox.set(new Fi(-1/0,-1/0,-1/0),new Fi(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];bs.setFromBufferAttribute(i),this.morphTargetsRelative?(ws.addVectors(this.boundingBox.min,bs.min),this.boundingBox.expandByPoint(ws),ws.addVectors(this.boundingBox.max,bs.max),this.boundingBox.expandByPoint(ws)):(this.boundingBox.expandByPoint(bs.min),this.boundingBox.expandByPoint(bs.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 rn);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)this.boundingSphere.set(new Fi,1/0);else if(t){const i=this.boundingSphere.center;if(bs.setFromBufferAttribute(t),e)for(let t=0,s=e.length;t<s;t++){const i=e[t];Ss.setFromBufferAttribute(i),this.morphTargetsRelative?(ws.addVectors(bs.min,Ss.min),bs.expandByPoint(ws),ws.addVectors(bs.max,Ss.max),bs.expandByPoint(ws)):(bs.expandByPoint(Ss.min),bs.expandByPoint(Ss.max))}bs.getCenter(i);let n=0;for(let e=0,s=t.count;e<s;e++)ws.fromBufferAttribute(t,e),n=Math.max(n,i.distanceToSquared(ws));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++)ws.fromBufferAttribute(r,e),a&&(Ms.fromBufferAttribute(t,e),ws.add(Ms)),n=Math.max(n,i.distanceToSquared(ws))}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 ms(new Float32Array(4*a),4));const o=this.getAttribute("tangent").array,l=[],h=[];for(let T=0;T<a;T++)l[T]=new Fi,h[T]=new Fi;const c=new Fi,u=new Fi,d=new Fi,p=new oi,m=new oi,f=new oi,g=new Fi,_=new Fi;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 Fi,M=new Fi,b=new Fi,S=new Fi;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 ms(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 Fi,s=new Fi,r=new Fi,a=new Fi,o=new Fi,l=new Fi,h=new Fi,c=new Fi;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++)ws.fromBufferAttribute(t,e),ws.normalize(),t.setXYZ(e,ws.x,ws.y,ws.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 ms(r,n,s)}if(null===this.index)return this;const e=new Ts,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 Es=new mn,As=new pn,Cs=new rn,Rs=new Fi,Ps=new Fi,Ls=new Fi,Is=new Fi,Ds=new Fi,Ns=new Fi,Us=new oi,Os=new oi,Fs=new oi,Bs=new Fi,zs=new Fi,ks=new Fi,Vs=new Fi,Gs=new Fi;class Hs extends zn{constructor(t=new Ts,e=new as){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){Ns.set(0,0,0);for(let i=0,n=s.length;i<n;i++){const n=a[i],o=s[i];0!==n&&(Ds.fromBufferAttribute(o,t),r?Ns.addScaledVector(Ds,n):Ns.addScaledVector(Ds.sub(e),n))}e.add(Ns)}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(),Cs.copy(i.boundingSphere),Cs.applyMatrix4(s),As.copy(t.ray).recast(t.near),!1===Cs.containsPoint(As.origin)){if(null===As.intersectSphere(Cs,Rs))return;if(As.origin.distanceToSquared(Rs)>(t.far-t.near)**2)return}Es.copy(s).invert(),As.copy(t.ray).applyMatrix4(Es),null!==i.boundingBox&&!1===As.intersectsBox(i.boundingBox)||this._computeIntersections(t,e,As)}}_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=Ws(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=Ws(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=Ws(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=Ws(this,r,t,i,l,h,c,p,p+1,p+2),n&&(n.faceIndex=Math.floor(p/3),e.push(n))}}function Ws(t,e,i,n,s,r,a,o,l,h){t.getVertexPosition(o,Ps),t.getVertexPosition(l,Ls),t.getVertexPosition(h,Is);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;Gs.copy(o),Gs.applyMatrix4(t.matrixWorld);const h=i.ray.origin.distanceTo(Gs);return h<i.near||h>i.far?null:{distance:h,point:Gs.clone(),object:t}}(t,e,i,n,Ps,Ls,Is,Vs);if(c){s&&(Us.fromBufferAttribute(s,o),Os.fromBufferAttribute(s,l),Fs.fromBufferAttribute(s,h),c.uv=Kn.getInterpolation(Vs,Ps,Ls,Is,Us,Os,Fs,new oi)),r&&(Us.fromBufferAttribute(r,o),Os.fromBufferAttribute(r,l),Fs.fromBufferAttribute(r,h),c.uv1=Kn.getInterpolation(Vs,Ps,Ls,Is,Us,Os,Fs,new oi),c.uv2=c.uv1),a&&(Bs.fromBufferAttribute(a,o),zs.fromBufferAttribute(a,l),ks.fromBufferAttribute(a,h),c.normal=Kn.getInterpolation(Vs,Ps,Ls,Is,Bs,zs,ks,new Fi),c.normal.dot(n.direction)>0&&c.normal.multiplyScalar(-1));const t={a:o,b:l,c:h,normal:new Fi,materialIndex:0};Kn.getNormal(Ps,Ls,Is,t.normal),c.face=t}return c}class qs extends Ts{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 Fi;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 _s(l,3)),this.setAttribute("normal",new _s(h,3)),this.setAttribute("uv",new _s(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new qs(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function Xs(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 js(t){const e={};for(let i=0;i<t.length;i++){const n=Xs(t[i]);for(const t in n)e[t]=n[t]}return e}function Ys(t){return null===t.getRenderTarget()?t.outputColorSpace:Mi.workingColorSpace}const Zs={clone:Xs,merge:js};class Js extends rs{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=Xs(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 Ks extends zn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new mn,this.projectionMatrix=new mn,this.projectionMatrixInverse=new mn,this.coordinateSystem=qe}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 $s extends Ks{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*Ke*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*Je*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*Ke*Math.atan(Math.tan(.5*Je*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*Je*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 Qs=-90;class tr extends zn{constructor(t,e,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const n=new $s(Qs,1,t,e);n.layers=this.layers,this.add(n);const s=new $s(Qs,1,t,e);s.layers=this.layers,this.add(s);const r=new $s(Qs,1,t,e);r.layers=this.layers,this.add(r);const a=new $s(Qs,1,t,e);a.layers=this.layers,this.add(a);const o=new $s(Qs,1,t,e);o.layers=this.layers,this.add(o);const l=new $s(Qs,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===qe)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!==Xe)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 er extends Pi{constructor(t,e,i,n,s,r,a,o,l,h){super(t=void 0!==t?t:[],e=void 0!==e?e:ht,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 ir extends Di{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&&(gi("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),e.colorSpace=e.encoding===Se?Te:we),this.texture=new er(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:xt}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 qs(5,5,5),n=new Js({name:"CubemapFromEquirect",uniforms:Xs({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 Hs(i,n),r=e.minFilter;return e.minFilter===bt&&(e.minFilter=xt),new tr(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 nr=new Fi,sr=new Fi,rr=new li;class ar{constructor(t=new Fi(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=nr.subVectors(i,e).cross(sr.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(nr),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||rr.getNormalMatrix(t),n=this.coplanarPoint(nr).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 or=new rn,lr=new Fi;class hr{constructor(t=new ar,e=new ar,i=new ar,n=new ar,s=new ar,r=new ar){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===qe)i[5].setComponents(o+a,u+c,f+m,y+v).normalize();else{if(e!==Xe)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(),or.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;null===e.boundingSphere&&e.computeBoundingSphere(),or.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(or)}intersectsSprite(t){return or.center.set(0,0,0),or.radius=.7071067811865476,or.applyMatrix4(t.matrixWorld),this.intersectsSphere(or)}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(lr.x=n.normal.x>0?t.max.x:t.min.x,lr.y=n.normal.y>0?t.max.y:t.min.y,lr.z=n.normal.z>0?t.max.z:t.min.z,n.distanceToPoint(lr)<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 cr(){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 ur(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 dr extends Ts{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 _s(p,3)),this.setAttribute("normal",new _s(m,3)),this.setAttribute("uv",new _s(f,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new dr(t.width,t.height,t.widthSegments,t.heightSegments)}}const pr={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}"},mr={common:{diffuse:{value:new is(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new li},alphaMap:{value:null},alphaMapTransform:{value:new li},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new li}},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 li}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new li}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new li},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new li},normalScale:{value:new oi(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new li},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new li}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new li}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new li}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new is(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 is(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new li},alphaTest:{value:0},uvTransform:{value:new li}},sprite:{diffuse:{value:new is(16777215)},opacity:{value:1},center:{value:new oi(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new li},alphaMap:{value:null},alphaMapTransform:{value:new li},alphaTest:{value:0}}},fr={basic:{uniforms:js([mr.common,mr.specularmap,mr.envmap,mr.aomap,mr.lightmap,mr.fog]),vertexShader:pr.meshbasic_vert,fragmentShader:pr.meshbasic_frag},lambert:{uniforms:js([mr.common,mr.specularmap,mr.envmap,mr.aomap,mr.lightmap,mr.emissivemap,mr.bumpmap,mr.normalmap,mr.displacementmap,mr.fog,mr.lights,{emissive:{value:new is(0)}}]),vertexShader:pr.meshlambert_vert,fragmentShader:pr.meshlambert_frag},phong:{uniforms:js([mr.common,mr.specularmap,mr.envmap,mr.aomap,mr.lightmap,mr.emissivemap,mr.bumpmap,mr.normalmap,mr.displacementmap,mr.fog,mr.lights,{emissive:{value:new is(0)},specular:{value:new is(1118481)},shininess:{value:30}}]),vertexShader:pr.meshphong_vert,fragmentShader:pr.meshphong_frag},standard:{uniforms:js([mr.common,mr.envmap,mr.aomap,mr.lightmap,mr.emissivemap,mr.bumpmap,mr.normalmap,mr.displacementmap,mr.roughnessmap,mr.metalnessmap,mr.fog,mr.lights,{emissive:{value:new is(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:pr.meshphysical_vert,fragmentShader:pr.meshphysical_frag},toon:{uniforms:js([mr.common,mr.aomap,mr.lightmap,mr.emissivemap,mr.bumpmap,mr.normalmap,mr.displacementmap,mr.gradientmap,mr.fog,mr.lights,{emissive:{value:new is(0)}}]),vertexShader:pr.meshtoon_vert,fragmentShader:pr.meshtoon_frag},matcap:{uniforms:js([mr.common,mr.bumpmap,mr.normalmap,mr.displacementmap,mr.fog,{matcap:{value:null}}]),vertexShader:pr.meshmatcap_vert,fragmentShader:pr.meshmatcap_frag},points:{uniforms:js([mr.points,mr.fog]),vertexShader:pr.points_vert,fragmentShader:pr.points_frag},dashed:{uniforms:js([mr.common,mr.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:pr.linedashed_vert,fragmentShader:pr.linedashed_frag},depth:{uniforms:js([mr.common,mr.displacementmap]),vertexShader:pr.depth_vert,fragmentShader:pr.depth_frag},normal:{uniforms:js([mr.common,mr.bumpmap,mr.normalmap,mr.displacementmap,{opacity:{value:1}}]),vertexShader:pr.meshnormal_vert,fragmentShader:pr.meshnormal_frag},sprite:{uniforms:js([mr.sprite,mr.fog]),vertexShader:pr.sprite_vert,fragmentShader:pr.sprite_frag},background:{uniforms:{uvTransform:{value:new li},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:pr.background_vert,fragmentShader:pr.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:pr.backgroundCube_vert,fragmentShader:pr.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:pr.cube_vert,fragmentShader:pr.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:pr.equirect_vert,fragmentShader:pr.equirect_frag},distanceRGBA:{uniforms:js([mr.common,mr.displacementmap,{referencePosition:{value:new Fi},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:pr.distanceRGBA_vert,fragmentShader:pr.distanceRGBA_frag},shadow:{uniforms:js([mr.lights,mr.fog,{color:{value:new is(0)},opacity:{value:1}}]),vertexShader:pr.shadow_vert,fragmentShader:pr.shadow_frag}};fr.physical={uniforms:js([fr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new li},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new li},clearcoatNormalScale:{value:new oi(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new li},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new li},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new li},sheen:{value:0},sheenColor:{value:new is(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new li},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new li},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new li},transmissionSamplerSize:{value:new oi},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new li},attenuationDistance:{value:0},attenuationColor:{value:new is(0)},specularColor:{value:new is(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new li},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new li},anisotropyVector:{value:new oi},anisotropyMap:{value:null},anisotropyMapTransform:{value:new li}}]),vertexShader:pr.meshphysical_vert,fragmentShader:pr.meshphysical_frag};const gr={r:0,b:0,g:0};function _r(t,e,i,n,s,r,a){const o=new is(0);let l,h,c=!0===r?0:1,u=null,d=0,p=null;function m(e,i){e.getRGB(gr,Ys(t)),n.buffers.color.setClear(gr.r,gr.g,gr.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===pt)?(void 0===h&&(h=new Hs(new qs(1,1,1),new Js({name:"BackgroundCubeMaterial",uniforms:Xs(fr.backgroundCube.uniforms),vertexShader:fr.backgroundCube.vertexShader,fragmentShader:fr.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=Mi.getTransfer(_.colorSpace)!==Pe,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 Hs(new dr(2,2),new Js({name:"BackgroundMaterial",uniforms:Xs(fr.background.uniforms),vertexShader:fr.background.vertexShader,fragmentShader:fr.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=Mi.getTransfer(_.colorSpace)!==Pe,!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 vr(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===Tt);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 yr(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 xr(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 Mr(t){const e=this;let i=null,n=0,s=!1,r=!1;const a=new ar,o=new li,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 br(t){let e=new WeakMap;function i(t,e){return e===ut?t.mapping=ht:e===dt&&(t.mapping=ct),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===ut||r===dt){if(e.has(s))return i(e.get(s).texture,s.mapping);{const r=s.image;if(r&&r.height>0){const a=new ir(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 Sr extends Ks{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 wr=[.125,.215,.35,.446,.526,.582],Tr=new Sr,Er=new is;let Ar=null,Cr=0,Rr=0;const Pr=(1+Math.sqrt(5))/2,Lr=1/Pr,Ir=[new Fi(1,1,1),new Fi(-1,1,1),new Fi(1,1,-1),new Fi(-1,1,-1),new Fi(0,Pr,Lr),new Fi(0,Pr,-Lr),new Fi(Lr,0,Pr),new Fi(-Lr,0,Pr),new Fi(Pr,Lr,0),new Fi(-Pr,Lr,0)];class Dr{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){Ar=this._renderer.getRenderTarget(),Cr=this._renderer.getActiveCubeFace(),Rr=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=Fr(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Or(),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(Ar,Cr,Rr),t.scissorTest=!1,Ur(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===ht||t.mapping===ct?this._setSize(0===t.image.length?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Ar=this._renderer.getRenderTarget(),Cr=this._renderer.getActiveCubeFace(),Rr=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:xt,minFilter:xt,generateMipmaps:!1,type:Ct,format:It,colorSpace:Ee,depthBuffer:!1},n=Nr(t,e,i);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=Nr(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+wr.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=wr[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 Ts;x.setAttribute("position",new ms(_,m)),x.setAttribute("uv",new ms(v,f)),x.setAttribute("faceIndex",new ms(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 Fi(0,1,0);return new Js({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 Hs(this._lodPlanes[0],t);this._renderer.compile(e,Tr)}_sceneToCubeUV(t,e,i,n){const s=new $s(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(Er),o.toneMapping=0,o.autoClear=!1;const c=new as({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),u=new Hs(new qs,c);let d=!1;const p=t.background;p?p.isColor&&(c.color.copy(p),t.background=null,d=!0):(c.color.copy(Er),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;Ur(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===ht||t.mapping===ct;n?(null===this._cubemapMaterial&&(this._cubemapMaterial=Fr()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===t.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=Or());const s=n?this._cubemapMaterial:this._equirectMaterial,r=new Hs(this._lodPlanes[0],s);s.uniforms.envMap.value=t;const a=this._cubeSize;Ur(e,0,0,3*a,2*a),i.setRenderTarget(e),i.render(r,Tr)}_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=Ir[(n-1)%Ir.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 Hs(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];Ur(e,3*v*(n>_-4?n-_+4:0),4*(this._cubeSize-v),3*v,2*v),o.setRenderTarget(e),o.render(h,Tr)}}function Nr(t,e,i){const n=new Di(t,e,i);return n.texture.mapping=pt,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Ur(t,e,i,n,s){t.viewport.set(e,i,n,s),t.scissor.set(e,i,n,s)}function Or(){return new Js({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 Fr(){return new Js({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 Br(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===ut||r===dt,o=r===ht||r===ct;if(a||o){if(s.isRenderTargetTexture&&!0===s.needsPMREMUpdate){s.needsPMREMUpdate=!1;let n=e.get(s);return null===i&&(i=new Dr(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 Dr(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 zr(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 kr(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(ci(i)?gs:fs)(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 Vr(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 Gr(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 Hr(t,e){return t[0]-e[0]}function Wr(t,e){return Math.abs(e[1])-Math.abs(t[1])}function qr(t,e,i){const n={},s=new Float32Array(8),r=new WeakMap,a=new Li,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 Ni(g,m,f,s);_.type=At,_.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 oi(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(Wr);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(Hr);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 Xr(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 jr extends Pi{constructor(t,e,i,n,s,r,a,o,l,h){if((h=void 0!==h?h:Dt)!==Dt&&h!==Nt)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===i&&h===Dt&&(i=Et),void 0===i&&h===Nt&&(i=Lt),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:_t,this.minFilter=void 0!==o?o:_t,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 Yr=new Pi,Zr=new jr(1,1);Zr.compareFunction=515;const Jr=new Ni,Kr=new Ui,$r=new er,Qr=[],ta=[],ea=new Float32Array(16),ia=new Float32Array(9),na=new Float32Array(4);function sa(t,e,i){const n=t[0];if(n<=0||n>0)return t;const s=e*i;let r=Qr[s];if(void 0===r&&(r=new Float32Array(s),Qr[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 ra(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 aa(t,e){for(let i=0,n=e.length;i<n;i++)t[i]=e[i]}function oa(t,e){let i=ta[e];void 0===i&&(i=new Int32Array(e),ta[e]=i);for(let n=0;n!==e;++n)i[n]=t.allocateTextureUnit();return i}function la(t,e){const i=this.cache;i[0]!==e&&(t.uniform1f(this.addr,e),i[0]=e)}function ha(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(ra(i,e))return;t.uniform2fv(this.addr,e),aa(i,e)}}function ca(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(ra(i,e))return;t.uniform3fv(this.addr,e),aa(i,e)}}function ua(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(ra(i,e))return;t.uniform4fv(this.addr,e),aa(i,e)}}function da(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(ra(i,e))return;t.uniformMatrix2fv(this.addr,!1,e),aa(i,e)}else{if(ra(i,n))return;na.set(n),t.uniformMatrix2fv(this.addr,!1,na),aa(i,n)}}function pa(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(ra(i,e))return;t.uniformMatrix3fv(this.addr,!1,e),aa(i,e)}else{if(ra(i,n))return;ia.set(n),t.uniformMatrix3fv(this.addr,!1,ia),aa(i,n)}}function ma(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(ra(i,e))return;t.uniformMatrix4fv(this.addr,!1,e),aa(i,e)}else{if(ra(i,n))return;ea.set(n),t.uniformMatrix4fv(this.addr,!1,ea),aa(i,n)}}function fa(t,e){const i=this.cache;i[0]!==e&&(t.uniform1i(this.addr,e),i[0]=e)}function ga(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(ra(i,e))return;t.uniform2iv(this.addr,e),aa(i,e)}}function _a(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(ra(i,e))return;t.uniform3iv(this.addr,e),aa(i,e)}}function va(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(ra(i,e))return;t.uniform4iv(this.addr,e),aa(i,e)}}function ya(t,e){const i=this.cache;i[0]!==e&&(t.uniform1ui(this.addr,e),i[0]=e)}function xa(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(ra(i,e))return;t.uniform2uiv(this.addr,e),aa(i,e)}}function Ma(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(ra(i,e))return;t.uniform3uiv(this.addr,e),aa(i,e)}}function ba(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(ra(i,e))return;t.uniform4uiv(this.addr,e),aa(i,e)}}function Sa(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?Zr:Yr;i.setTexture2D(e||r,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.setTexture3D(e||Kr,s)}function Ta(t,e,i){const n=this.cache,s=i.allocateTextureUnit();n[0]!==s&&(t.uniform1i(this.addr,s),n[0]=s),i.setTextureCube(e||$r,s)}function Ea(t,e,i){const n=this.cache,s=i.allocateTextureUnit();n[0]!==s&&(t.uniform1i(this.addr,s),n[0]=s),i.setTexture2DArray(e||Jr,s)}function Aa(t,e){t.uniform1fv(this.addr,e)}function Ca(t,e){const i=sa(e,this.size,2);t.uniform2fv(this.addr,i)}function Ra(t,e){const i=sa(e,this.size,3);t.uniform3fv(this.addr,i)}function Pa(t,e){const i=sa(e,this.size,4);t.uniform4fv(this.addr,i)}function La(t,e){const i=sa(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,i)}function Ia(t,e){const i=sa(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,i)}function Da(t,e){const i=sa(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,i)}function Na(t,e){t.uniform1iv(this.addr,e)}function Ua(t,e){t.uniform2iv(this.addr,e)}function Oa(t,e){t.uniform3iv(this.addr,e)}function Fa(t,e){t.uniform4iv(this.addr,e)}function Ba(t,e){t.uniform1uiv(this.addr,e)}function za(t,e){t.uniform2uiv(this.addr,e)}function ka(t,e){t.uniform3uiv(this.addr,e)}function Va(t,e){t.uniform4uiv(this.addr,e)}function Ga(t,e,i){const n=this.cache,s=e.length,r=oa(i,s);ra(n,r)||(t.uniform1iv(this.addr,r),aa(n,r));for(let a=0;a!==s;++a)i.setTexture2D(e[a]||Yr,r[a])}function Ha(t,e,i){const n=this.cache,s=e.length,r=oa(i,s);ra(n,r)||(t.uniform1iv(this.addr,r),aa(n,r));for(let a=0;a!==s;++a)i.setTexture3D(e[a]||Kr,r[a])}function Wa(t,e,i){const n=this.cache,s=e.length,r=oa(i,s);ra(n,r)||(t.uniform1iv(this.addr,r),aa(n,r));for(let a=0;a!==s;++a)i.setTextureCube(e[a]||$r,r[a])}function qa(t,e,i){const n=this.cache,s=e.length,r=oa(i,s);ra(n,r)||(t.uniform1iv(this.addr,r),aa(n,r));for(let a=0;a!==s;++a)i.setTexture2DArray(e[a]||Jr,r[a])}class Xa{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 la;case 35664:return ha;case 35665:return ca;case 35666:return ua;case 35674:return da;case 35675:return pa;case 35676:return ma;case 5124:case 35670:return fa;case 35667:case 35671:return ga;case 35668:case 35672:return _a;case 35669:case 35673:return va;case 5125:return ya;case 36294:return xa;case 36295:return Ma;case 36296:return ba;case 35678:case 36198:case 36298:case 36306:case 35682:return Sa;case 35679:case 36299:case 36307:return wa;case 35680:case 36300:case 36308:case 36293:return Ta;case 36289:case 36303:case 36311:case 36292:return Ea}}(e.type)}}class ja{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 Aa;case 35664:return Ca;case 35665:return Ra;case 35666:return Pa;case 35674:return La;case 35675:return Ia;case 35676:return Da;case 5124:case 35670:return Na;case 35667:case 35671:return Ua;case 35668:case 35672:return Oa;case 35669:case 35673:return Fa;case 5125:return Ba;case 36294:return za;case 36295:return ka;case 36296:return Va;case 35678:case 36198:case 36298:case 36306:case 35682:return Ga;case 35679:case 36299:case 36307:return Ha;case 35680:case 36300:case 36308:case 36293:return Wa;case 36289:case 36303:case 36311:case 36292:return qa}}(e.type)}}class Ya{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 Za=/(\w+)(\])?(\[|\.)?/g;function Ja(t,e){t.seq.push(e),t.map[e.id]=e}function Ka(t,e,i){const n=t.name,s=n.length;for(Za.lastIndex=0;;){const r=Za.exec(n),a=Za.lastIndex;let o=r[1];const l="]"===r[2],h=r[3];if(l&&(o|=0),void 0===h||"["===h&&a+2===s){Ja(i,void 0===h?new Xa(o,t,e):new ja(o,t,e));break}{let t=i.map[o];void 0===t&&(t=new Ya(o),Ja(i,t)),i=t}}}class $a{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);Ka(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 Qa(t,e,i){const n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),n}let to=0;function eo(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 io(t,e){const i=function(t){const e=Mi.getPrimaries(Mi.workingColorSpace),i=Mi.getPrimaries(t);let n;switch(e===i?n="":e===Ie&&i===Le?n="LinearDisplayP3ToLinearSRGB":e===Le&&i===Ie&&(n="LinearSRGBToLinearDisplayP3"),t){case Ee:case Ce:return[n,"LinearTransferOETF"];case Te:case Ae:return[n,"sRGBTransferOETF"];default:return[n,"LinearTransferOETF"]}}(e);return`vec4 ${t}( vec4 value ) { return ${i[0]}( ${i[1]}( value ) ); }`}function no(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 so(t){return""!==t}function ro(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 ao(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const oo=/^[ \t]*#include +<([\w\d./]+)>/gm;function lo(t){return t.replace(oo,co)}const ho=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function co(t,e){let i=pr[e];if(void 0===i){const t=ho.get(e);if(void 0===t)throw new Error("Can not resolve #include <"+e+">");i=pr[t]}return lo(i)}const uo=/#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 po(t){return t.replace(uo,mo)}function mo(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 fo(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 go(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 ht:case ct:e="ENVMAP_TYPE_CUBE";break;case pt:e="ENVMAP_TYPE_CUBE_UV"}return e}(i),c=function(t){let e="ENVMAP_MODE_REFLECTION";return t.envMap&&t.envMapMode===ct&&(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(so).join("\n")}(i),m=function(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":""].filter(so).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(so).join("\n"),_.length>0&&(_+="\n"),v=[p,"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,f].filter(so).join("\n"),v.length>0&&(v+="\n")):(_=[fo(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(so).join("\n"),v=[p,fo(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?pr.tonemapping_pars_fragment:"",0!==i.toneMapping?no("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",pr.colorspace_pars_fragment,io("linearToOutputTexel",i.outputColorSpace),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(so).join("\n")),a=lo(a),a=ro(a,i),a=ao(a,i),o=lo(o),o=ro(o,i),o=ao(o,i),a=po(a),o=po(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===He?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===He?"":"#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=Qa(s,s.VERTEX_SHADER,x),S=Qa(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):(eo(s,b,"vertex"),eo(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 $a(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=to++,this.cacheKey=e,this.usedTimes=1,this.program=g,this.vertexShader=b,this.fragmentShader=S,this}let _o=0;class vo{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 yo(t),e.set(t,i)),i}}class yo{constructor(t){this.id=_o++,this.code=t,this.usedTimes=0}}function xo(t,e,i,n,s,r,a){const o=new Tn,l=new vo,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===pt?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=fr[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,ut=r.alphaTest>0,dt=!!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:Ee,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:ut,alphaHash:dt,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&&Mi.getTransfer(r.map.colorSpace)===Pe,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=fr[e];i=Zs.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 go(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 Mo(){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 bo(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 So(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 wo(){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||bo),n.length>1&&n.sort(e||So),s.length>1&&s.sort(e||So)}}}function To(){let t=new WeakMap;return{get(e,i){const n=t.get(e);let s;return void 0===n?(s=new wo,t.set(e,[s])):i>=n.length?(s=new wo,n.push(s)):s=n[i],s},dispose(){t=new WeakMap}}}function Eo(){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 Fi,color:new is};break;case"SpotLight":i={position:new Fi,direction:new Fi,color:new is,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new Fi,color:new is,distance:0,decay:0};break;case"HemisphereLight":i={direction:new Fi,skyColor:new is,groundColor:new is};break;case"RectAreaLight":i={color:new is,position:new Fi,halfWidth:new Fi,halfHeight:new Fi}}return t[e.id]=i,i}}}let Ao=0;function Co(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function Ro(t,e){const i=new Eo,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 oi};break;case"PointLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new oi,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 Fi);const r=new Fi,a=new mn,o=new mn;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(Co);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=mr.LTC_FLOAT_1,s.rectAreaLTC2=mr.LTC_FLOAT_2):(s.rectAreaLTC1=mr.LTC_HALF_1,s.rectAreaLTC2=mr.LTC_HALF_2):!0===t.has("OES_texture_float_linear")?(s.rectAreaLTC1=mr.LTC_FLOAT_1,s.rectAreaLTC2=mr.LTC_FLOAT_2):!0===t.has("OES_texture_half_float_linear")&&(s.rectAreaLTC1=mr.LTC_HALF_1,s.rectAreaLTC2=mr.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=Ao++)},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 Po(t,e){const i=new Ro(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 Lo(t,e){let i=new WeakMap;return{get(n,s=0){const r=i.get(n);let a;return void 0===r?(a=new Po(t,e),i.set(n,[a])):s>=r.length?(a=new Po(t,e),r.push(a)):a=r[s],a},dispose(){i=new WeakMap}}}class Io extends rs{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 Do extends rs{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 No(t,e,i){let n=new hr;const s=new oi,r=new oi,a=new Li,o=new Io({depthPacking:3201}),l=new Do,h={},c=i.maxTextureSize,u={[z]:1,[k]:0,[V]:2},d=new Js({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new oi},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 Ts;m.setAttribute("position",new ms(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const f=new Hs(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 Di(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:_t,magFilter:_t}:{};null!==h.map&&h.map.dispose(),h.map=new Di(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 Uo(t,e,i){const n=i.isWebGL2,s=new function(){let e=!1;const i=new Li;let n=null;const s=new Li(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 is(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 Li).fromArray(O),z=(new Li).fromArray(F);function k(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 V={};function at(e){!0!==h[e]&&(t.enable(e),h[e]=!0)}function ot(e){!1!==h[e]&&(t.disable(e),h[e]=!1)}V[t.TEXTURE_2D]=k(t.TEXTURE_2D,t.TEXTURE_2D,1),V[t.TEXTURE_CUBE_MAP]=k(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),n&&(V[t.TEXTURE_2D_ARRAY]=k(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),V[t.TEXTURE_3D]=k(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={[G]:t.FUNC_ADD,[H]:t.FUNC_SUBTRACT,[W]: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={[q]:t.ZERO,[X]:t.ONE,[j]:t.SRC_COLOR,[Z]:t.SRC_ALPHA,[et]:t.SRC_ALPHA_SATURATE,[Q]:t.DST_COLOR,[K]:t.DST_ALPHA,[Y]:t.ONE_MINUS_SRC_COLOR,[J]:t.ONE_MINUS_SRC_ALPHA,[tt]:t.ONE_MINUS_DST_COLOR,[$]:t.ONE_MINUS_DST_ALPHA,[it]:t.CONSTANT_COLOR,[nt]:t.ONE_MINUS_CONSTANT_COLOR,[st]:t.CONSTANT_ALPHA,[rt]: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===G&&y===G||(t.blendEquation(t.FUNC_ADD),g=G,y=G),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||V[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 is(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 Oo(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):pi("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?ni: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 ii(t.width)&&ii(t.height)}function _(t,e){return t.generateMipmaps&&e&&t.minFilter!==_t&&t.minFilter!==xt}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?Re:Mi.getTransfer(r);s===t.FLOAT&&(l=t.RGBA32F),s===t.HALF_FLOAT&&(l=t.RGBA16F),s===t.UNSIGNED_BYTE&&(l=e===Pe?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!==_t&&t.minFilter!==xt?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===_t||e===vt||e===yt?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={[mt]:t.REPEAT,[ft]:t.CLAMP_TO_EDGE,[gt]:t.MIRRORED_REPEAT},C={[_t]:t.NEAREST,[vt]:t.NEAREST_MIPMAP_NEAREST,[yt]:t.NEAREST_MIPMAP_LINEAR,[xt]:t.LINEAR,[Mt]:t.LINEAR_MIPMAP_NEAREST,[bt]:t.LINEAR_MIPMAP_LINEAR},R={[Ne]:t.NEVER,[Ve]:t.ALWAYS,[Ue]:t.LESS,[Fe]:t.LEQUAL,[Oe]:t.EQUAL,[ke]:t.GEQUAL,[Be]:t.GREATER,[ze]: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!==ft||r.wrapT,t.texParameteri(i,t.TEXTURE_MAG_FILTER,M(r.magFilter)),t.texParameteri(i,t.TEXTURE_MIN_FILTER,M(r.minFilter)),r.minFilter!==_t&&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===_t)return;if(r.minFilter!==yt&&r.minFilter!==bt)return;if(r.type===At&&!1===e.has("OES_texture_float_linear"))return;if(!1===o&&r.type===Ct&&!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=Mi.getPrimaries(Mi.workingColorSpace),n=a.colorSpace===we?null:Mi.getPrimaries(a.colorSpace),p=a.colorSpace===we||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!==ft||t.wrapT!==ft||t.minFilter!==_t&&t.minFilter!==xt)}(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!==Xt,R=void 0===d.__version||!0===c,L=x(a,M,b);if(a.isDepthTexture)E=t.DEPTH_COMPONENT,o?E=a.type===At?t.DEPTH_COMPONENT32F:a.type===Et?t.DEPTH_COMPONENT24:a.type===Lt?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT16:a.type,a.format===Dt&&E===t.DEPTH_COMPONENT&&a.type!==wt&&a.type!==Et&&(a.type=Et,T=r.convert(a.type)),a.format===Nt&&E===t.DEPTH_COMPONENT&&(E=t.DEPTH_STENCIL,a.type!==Lt&&(a.type=Lt,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!==It?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!==It?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===At?s=t.DEPTH_COMPONENT32F:e.type===Et&&(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===Dt)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!==Nt)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===We||n!==Ee&&n!==we&&Mi.getTransfer(n)===Pe&&!1===o&&(!0===e.has("EXT_sRGB")&&s===It?(t.format=We,t.minFilter=xt,t.generateMipmaps=!1):i=Ti.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=Mi.getPrimaries(Mi.workingColorSpace),n=a.colorSpace===we?null:Mi.getPrimaries(a.colorSpace),d=a.colorSpace===we||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!==It?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 Fo(t,e,i){const n=i.isWebGL2;return{convert(i,s=""){let r;const a=Mi.getTransfer(s);if(i===St)return t.UNSIGNED_BYTE;if(i===Rt)return t.UNSIGNED_SHORT_4_4_4_4;if(i===Pt)return t.UNSIGNED_SHORT_5_5_5_1;if(1010===i)return t.BYTE;if(1011===i)return t.SHORT;if(i===wt)return t.UNSIGNED_SHORT;if(i===Tt)return t.INT;if(i===Et)return t.UNSIGNED_INT;if(i===At)return t.FLOAT;if(i===Ct)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===It)return t.RGBA;if(1024===i)return t.LUMINANCE;if(1025===i)return t.LUMINANCE_ALPHA;if(i===Dt)return t.DEPTH_COMPONENT;if(i===Nt)return t.DEPTH_STENCIL;if(i===We)return r=e.get("EXT_sRGB"),null!==r?r.SRGB_ALPHA_EXT:null;if(1028===i)return t.RED;if(i===Ut)return t.RED_INTEGER;if(1030===i)return t.RG;if(i===Ot)return t.RG_INTEGER;if(i===Ft)return t.RGBA_INTEGER;if(i===Bt||i===zt||i===kt||i===Vt)if(a===Pe){if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),null===r)return null;if(i===Bt)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===zt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===kt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Vt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(r=e.get("WEBGL_compressed_texture_s3tc"),null===r)return null;if(i===Bt)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===zt)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===kt)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Vt)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(i===Gt||i===Ht||i===Wt||i===qt){if(r=e.get("WEBGL_compressed_texture_pvrtc"),null===r)return null;if(i===Gt)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Ht)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Wt)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===qt)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(i===Xt)return r=e.get("WEBGL_compressed_texture_etc1"),null!==r?r.COMPRESSED_RGB_ETC1_WEBGL:null;if(i===jt||i===Yt){if(r=e.get("WEBGL_compressed_texture_etc"),null===r)return null;if(i===jt)return a===Pe?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===Yt)return a===Pe?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}if(i===Zt||i===Jt||i===Kt||i===$t||i===Qt||i===te||i===ee||i===ie||i===ne||i===se||i===re||i===ae||i===oe||i===le){if(r=e.get("WEBGL_compressed_texture_astc"),null===r)return null;if(i===Zt)return a===Pe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Jt)return a===Pe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Kt)return a===Pe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===$t)return a===Pe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Qt)return a===Pe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===te)return a===Pe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===ee)return a===Pe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===ie)return a===Pe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===ne)return a===Pe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===se)return a===Pe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===re)return a===Pe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===ae)return a===Pe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===oe)return a===Pe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===le)return a===Pe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}if(i===he||i===ce||i===ue){if(r=e.get("EXT_texture_compression_bptc"),null===r)return null;if(i===he)return a===Pe?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===ce)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===ue)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(36283===i||i===de||i===pe||i===me){if(r=e.get("EXT_texture_compression_rgtc"),null===r)return null;if(i===he)return r.COMPRESSED_RED_RGTC1_EXT;if(i===de)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===pe)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===me)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return i===Lt?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 Bo extends $s{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}class zo extends zn{constructor(){super(),this.isGroup=!0,this.type="Group"}}const ko={type:"move"};class Vo{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new zo,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 zo,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Fi,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Fi),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new zo,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Fi,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Fi),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(ko)))}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 zo;i.matrixAutoUpdate=!1,i.visible=!1,t.joints[e.jointName]=i,t.add(i)}return t.joints[e.jointName]}}class Go extends je{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 oi;let x=null;const M=new $s;M.layers.enable(1),M.viewport=new Li;const b=new $s;b.layers.enable(2),b.viewport=new Li;const S=[M,b],w=new Bo;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 Vo,_[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=_[t];return void 0===e&&(e=new Vo,_[t]=e),e.getGripSpace()},this.getHand=function(t){let e=_[t];return void 0===e&&(e=new Vo,_[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 Di(d.framebufferWidth,d.framebufferHeight,{format:It,type:St,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?Nt:Dt,r=m.stencil?Lt:Et);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 Di(u.textureWidth,u.textureHeight,{format:It,type:St,depthTexture:new jr(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 Fi,L=new Fi;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*Ke*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 cr;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 $s,a.layers.enable(n),a.viewport=new Li,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 Ho(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,Ys(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 Wo(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 qo{constructor(t={}){const{canvas:e=mi(),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=Te,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 Li,E=new Li;let A=null;const C=new is(0);let R=0,P=e.width,L=e.height,I=1,D=null,N=null;const U=new Li(0,0,P,L),O=new Li(0,0,P,L);let F=!1;const z=new hr;let k=!1,V=!1,G=null;const H=new mn,W=new oi,q=new Fi,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${B}`),e.addEventListener("webglcontextlost",Tt,!1),e.addEventListener("webglcontextrestored",Dt,!1),e.addEventListener("webglcontextcreationerror",Nt,!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 xt(){Y=new zr(vt),Z=new xr(vt,Y,t),Y.init(Z),ft=new Fo(vt,Y,Z),J=new Uo(vt,Y,Z),K=new Gr(vt),$=new Mo,Q=new Oo(vt,Y,J,$,Z,ft,K),tt=new br(v),et=new Br(v),it=new ur(vt,Z),gt=new vr(vt,Y,it,Z),nt=new kr(vt,it,K,gt),st=new Xr(vt,nt,it,K),dt=new qr(vt,Z,Q),ht=new Mr($),rt=new xo(v,tt,et,Y,Z,gt,ht),at=new Ho(v,$),ot=new To,lt=new Lo(Y,Z),ut=new _r(v,tt,et,J,st,u,o),ct=new No(v,st,Z),_t=new Wo(vt,K,Z,J),pt=new yr(vt,Y,K,Z),mt=new Vr(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}xt();const Mt=new Go(v,vt);function Tt(t){t.preventDefault(),y=!0}function Dt(){y=!1;const t=K.autoReset,e=ct.enabled,i=ct.autoUpdate,n=ct.needsUpdate,s=ct.type;xt(),K.autoReset=t,ct.enabled=e,ct.autoUpdate=i,ct.needsUpdate=n,ct.type=s}function Nt(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=Mt,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){Mt.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(O)},this.setScissor=function(t,e,i,n){t.isVector4?O.set(t.x,t.y,t.z,t.w):O.set(t,e,i,n),J.scissor(E.copy(O).multiplyScalar(I).floor())},this.getScissorTest=function(){return F},this.setScissorTest=function(t){J.setScissorTest(F=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===Ft||e===Ot||e===Ut}if(t){const t=b.texture.type,e=t===St||t===Et||t===wt||t===Lt||t===Rt||t===Pt,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",Tt,!1),e.removeEventListener("webglcontextrestored",Dt,!1),e.removeEventListener("webglcontextcreationerror",Nt,!1),ot.dispose(),lt.dispose(),$.dispose(),tt.dispose(),et.dispose(),st.dispose(),gt.dispose(),_t.dispose(),rt.dispose(),Mt.dispose(),Mt.removeEventListener("sessionstart",Vt),Mt.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:Ee,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),$a.upload(vt,Zt(y),P,Q)),n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&($a.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 cr;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 Di(1,1,{generateMipmaps:!0,type:Y.has("EXT_color_buffer_half_float")?Ct:St,minFilter:bt,samples:s?4:0})),v.getDrawingBufferSize(W),s?G.setSize(W.x,W.y):G.setSize(ni(W.x),ni(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=$a.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,Mt.setAnimationLoop(t),null===t?Ht.stop():Ht.start()},Mt.addEventListener("sessionstart",Vt),Mt.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===Mt.enabled&&!0===Mt.isPresenting&&(!0===Mt.cameraAutoUpdate&&Mt.updateCamera(e),e=Mt.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(O).multiplyScalar(I).floor(),A=F;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!==It&&ft.convert(o)!==vt.getParameter(vt.IMPLEMENTATION_COLOR_READ_FORMAT))return;const h=l===Ct&&(Y.has("EXT_color_buffer_half_float")||Z.isWebGL2&&Y.has("EXT_color_buffer_float"));if(!(l===St||ft.convert(l)===vt.getParameter(vt.IMPLEMENTATION_COLOR_READ_TYPE)||l===At&&(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 qe}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=t===Ae?"display-p3":"srgb",e.unpackColorSpace=Mi.workingColorSpace===Ce?"display-p3":"srgb"}get outputEncoding(){return this.outputColorSpace===Te?Se:be}set outputEncoding(t){this.outputColorSpace=t===Se?Te:Ee}get useLegacyLights(){return this._useLegacyLights}set useLegacyLights(t){this._useLegacyLights=t}}class Xo extends qo{}Xo.prototype.isWebGL1Renderer=!0;class jo{constructor(t,e=25e-5){this.isFogExp2=!0,this.name="",this.color=new is(t),this.density=e}clone(){return new jo(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class Yo{constructor(t,e=1,i=1e3){this.isFog=!0,this.name="",this.color=new is(t),this.near=e,this.far=i}clone(){return new Yo(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Zo extends zn{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 Jo{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=Ge,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=$e()}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=$e()),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=$e()),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 Ko=new Fi;class $o{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++)Ko.fromBufferAttribute(this,e),Ko.applyMatrix4(t),this.setXYZ(e,Ko.x,Ko.y,Ko.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)Ko.fromBufferAttribute(this,e),Ko.applyNormalMatrix(t),this.setXYZ(e,Ko.x,Ko.y,Ko.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)Ko.fromBufferAttribute(this,e),Ko.transformDirection(t),this.setXYZ(e,Ko.x,Ko.y,Ko.z);return this}setX(t,e){return this.normalized&&(e=ri(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=ri(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=ri(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=ri(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=si(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=si(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=si(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=si(e,this.array)),e}setXY(t,e,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=ri(e,this.array),i=ri(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=ri(e,this.array),i=ri(i,this.array),n=ri(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=ri(e,this.array),i=ri(i,this.array),n=ri(n,this.array),s=ri(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 ms(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 $o(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 Qo extends rs{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new is(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 tl;const el=new Fi,il=new Fi,nl=new Fi,sl=new oi,rl=new oi,al=new mn,ol=new Fi,ll=new Fi,hl=new Fi,cl=new oi,ul=new oi,dl=new oi;class pl extends zn{constructor(t=new Qo){if(super(),this.isSprite=!0,this.type="Sprite",void 0===tl){tl=new Ts;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 Jo(t,5);tl.setIndex([0,1,2,0,2,3]),tl.setAttribute("position",new $o(e,3,0,!1)),tl.setAttribute("uv",new $o(e,2,3,!1))}this.geometry=tl,this.material=t,this.center=new oi(.5,.5)}raycast(t,e){t.camera,il.setFromMatrixScale(this.matrixWorld),al.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),nl.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&il.multiplyScalar(-nl.z);const i=this.material.rotation;let n,s;0!==i&&(s=Math.cos(i),n=Math.sin(i));const r=this.center;ml(ol.set(-.5,-.5,0),nl,r,il,n,s),ml(ll.set(.5,-.5,0),nl,r,il,n,s),ml(hl.set(.5,.5,0),nl,r,il,n,s),cl.set(0,0),ul.set(1,0),dl.set(1,1);let a=t.ray.intersectTriangle(ol,ll,hl,!1,el);if(null===a&&(ml(ll.set(-.5,.5,0),nl,r,il,n,s),ul.set(0,1),a=t.ray.intersectTriangle(ol,hl,ll,!1,el),null===a))return;const o=t.ray.origin.distanceTo(el);o<t.near||o>t.far||e.push({distance:o,point:el.clone(),uv:Kn.getInterpolation(el,ol,ll,hl,cl,ul,dl,new oi),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 ml(t,e,i,n,s,r){sl.subVectors(t,i).addScalar(.5).multiply(n),void 0!==s?(rl.x=r*sl.x-s*sl.y,rl.y=s*sl.x+r*sl.y):rl.copy(sl),t.copy(e),t.x+=rl.x,t.y+=rl.y,t.applyMatrix4(al)}const fl=new Fi,gl=new Fi;class _l extends zn{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){fl.setFromMatrixPosition(this.matrixWorld);const i=t.ray.origin.distanceTo(fl);this.getObjectForDistance(i).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){fl.setFromMatrixPosition(t.matrixWorld),gl.setFromMatrixPosition(this.matrixWorld);const i=fl.distanceTo(gl)/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 vl=new Fi,yl=new Li,xl=new Li,Ml=new Fi,bl=new mn,Sl=new Fi,wl=new rn,Tl=new mn,El=new pn;class Al extends Hs{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=at,this.bindMatrix=new mn,this.bindMatrixInverse=new mn,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;null===this.boundingBox&&(this.boundingBox=new ki),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let i=0;i<e.count;i++)this.getVertexPosition(i,Sl),this.boundingBox.expandByPoint(Sl)}computeBoundingSphere(){const t=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new rn),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let i=0;i<e.count;i++)this.getVertexPosition(i,Sl),this.boundingSphere.expandByPoint(Sl)}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(),wl.copy(this.boundingSphere),wl.applyMatrix4(n),!1!==t.ray.intersectsSphere(wl)&&(Tl.copy(n).invert(),El.copy(t.ray).applyMatrix4(Tl),null!==this.boundingBox&&!1===El.intersectsBox(this.boundingBox)||this._computeIntersections(t,e,El)))}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 Li,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===at?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===ot&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}applyBoneTransform(t,e){const i=this.skeleton,n=this.geometry;yl.fromBufferAttribute(n.attributes.skinIndex,t),xl.fromBufferAttribute(n.attributes.skinWeight,t),vl.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let s=0;s<4;s++){const t=xl.getComponent(s);if(0!==t){const n=yl.getComponent(s);bl.multiplyMatrices(i.bones[n].matrixWorld,i.boneInverses[n]),e.addScaledVector(Ml.copy(vl).applyMatrix4(bl),t)}}return e.applyMatrix4(this.bindMatrixInverse)}boneTransform(t,e){return this.applyBoneTransform(t,e)}}class Cl extends zn{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Rl extends Pi{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 Pl=new mn,Ll=new mn;class Il{constructor(t=[],e=[]){this.uuid=$e(),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 mn)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const e=new mn;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:Ll;Pl.multiplyMatrices(n,e[s]),Pl.toArray(i,16*s)}null!==n&&(n.needsUpdate=!0)}clone(){return new Il(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 Rl(e,t,t,It,At);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 Cl),this.bones.push(n),this.boneInverses.push((new mn).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 Dl extends ms{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 Nl=new mn,Ul=new mn,Ol=[],Fl=new ki,Bl=new mn,zl=new Hs,kl=new rn;class Vl extends Hs{constructor(t,e,i){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new Dl(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,Bl)}computeBoundingBox(){const t=this.geometry,e=this.count;null===this.boundingBox&&(this.boundingBox=new ki),null===t.boundingBox&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<e;i++)this.getMatrixAt(i,Nl),Fl.copy(t.boundingBox).applyMatrix4(Nl),this.boundingBox.union(Fl)}computeBoundingSphere(){const t=this.geometry,e=this.count;null===this.boundingSphere&&(this.boundingSphere=new rn),null===t.boundingSphere&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<e;i++)this.getMatrixAt(i,Nl),kl.copy(t.boundingSphere).applyMatrix4(Nl),this.boundingSphere.union(kl)}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(zl.geometry=this.geometry,zl.material=this.material,void 0!==zl.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),kl.copy(this.boundingSphere),kl.applyMatrix4(i),!1!==t.ray.intersectsSphere(kl)))for(let s=0;s<n;s++){this.getMatrixAt(s,Nl),Ul.multiplyMatrices(i,Nl),zl.matrixWorld=Ul,zl.raycast(t,Ol);for(let t=0,i=Ol.length;t<i;t++){const i=Ol[t];i.instanceId=s,i.object=this,e.push(i)}Ol.length=0}}setColorAt(t,e){null===this.instanceColor&&(this.instanceColor=new Dl(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 Gl(t,e){return t.z-e.z}function Hl(t,e){return e.z-t.z}class Wl{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 ql="batchId",Xl=new mn,jl=new mn,Yl=new mn,Zl=new mn,Jl=new hr,Kl=new ki,$l=new rn,Ql=new Fi,th=new Wl,eh=new Hs,ih=[];function nh(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 sh extends Hs{get maxGeometryCount(){return this._maxGeometryCount}constructor(t,e,i=2*e,n){super(new Ts,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 Rl(e,t,t,It,At);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 ms(t,1))}const r=n>65536?new Uint32Array(i):new Uint16Array(i);e.setAttribute(ql,new ms(r,1)),this._geometryInitialized=!0}}_validateGeometry(t){if(t.getAttribute(ql))throw new Error(`BatchedMesh: Geometry cannot use attribute "${ql}"`);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===ql)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 ki);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,Xl),this.getBoundingBoxAt(n,Kl).applyMatrix4(Xl),e.union(Kl))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new rn);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,Xl),this.getBoundingSphereAt(n,$l).applyMatrix4(Xl),e.union($l))}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++,Yl.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 ki,sphereInitialized:!1,sphere:new rn});const f=this.geometry.getAttribute(ql);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===ql)continue;const t=e.getAttribute(d),n=i.getAttribute(d);nh(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(Ql.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,Kl),Kl.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)),Ql.fromBufferAttribute(r,i),o=Math.max(o,n.center.distanceToSquared(Ql))}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;eh.material=this.material,eh.geometry.index=o.index,eh.geometry.attributes=o.attributes,null===eh.geometry.boundingBox&&(eh.geometry.boundingBox=new ki),null===eh.geometry.boundingSphere&&(eh.geometry.boundingSphere=new rn);for(let l=0;l<r;l++){if(!i[l]||!n[l])continue;const r=s[l];eh.geometry.setDrawRange(r.start,r.count),this.getMatrixAt(l,eh.matrixWorld).premultiply(a),this.getBoundingBoxAt(l,eh.geometry.boundingBox),this.getBoundingSphereAt(l,eh.geometry.boundingSphere),eh.raycast(t,ih);for(let t=0,i=ih.length;t<i;t++){const i=ih[t];i.object=this,i.batchId=l,e.push(i)}ih.length=0}eh.material=null,eh.geometry.index=null,eh.geometry.attributes={},eh.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&&(Zl.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),Jl.setFromProjectionMatrix(Zl,t.isWebGPURenderer?Xe:qe));let d=0;if(this.sortObjects){jl.copy(this.matrixWorld).invert(),Ql.setFromMatrixPosition(i.matrixWorld).applyMatrix4(jl);for(let i=0,n=o.length;i<n;i++)if(o[i]){this.getMatrixAt(i,Xl),this.getBoundingSphereAt(i,$l).applyMatrix4(Xl);let t=!1;if(u&&(t=!Jl.intersectsSphere($l)),!t){const t=Ql.distanceTo($l.center);th.push(c[i],t)}}const t=th.list,e=this.customSort;null===e?t.sort(s.transparent?Hl:Gl):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++}th.reset()}else for(let p=0,m=o.length;p<m;p++)if(o[p]){let t=!1;if(u&&(this.getMatrixAt(p,Xl),this.getBoundingSphereAt(p,$l).applyMatrix4(Xl),t=!Jl.intersectsSphere($l)),!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 rh extends rs{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new is(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 ah=new Fi,oh=new Fi,lh=new mn,hh=new pn,ch=new rn;class uh extends zn{constructor(t=new Ts,e=new rh){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++)ah.fromBufferAttribute(e,t-1),oh.fromBufferAttribute(e,t),i[t]=i[t-1],i[t]+=ah.distanceTo(oh);t.setAttribute("lineDistance",new _s(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(),ch.copy(i.boundingSphere),ch.applyMatrix4(n),ch.radius+=s,!1===t.ray.intersectsSphere(ch))return;lh.copy(n).invert(),hh.copy(t.ray).applyMatrix4(lh);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=new Fi,h=new Fi,c=new Fi,u=new Fi,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),hh.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),hh.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 dh=new Fi,ph=new Fi;class mh extends uh{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)dh.fromBufferAttribute(e,t),ph.fromBufferAttribute(e,t+1),i[t]=0===t?0:i[t-1],i[t+1]=i[t]+dh.distanceTo(ph);t.setAttribute("lineDistance",new _s(i,1))}return this}}class fh extends uh{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}}class gh extends rs{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new is(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 _h=new mn,vh=new pn,yh=new rn,xh=new Fi;class Mh extends zn{constructor(t=new Ts,e=new gh){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(),yh.copy(i.boundingSphere),yh.applyMatrix4(n),yh.radius+=s,!1===t.ray.intersectsSphere(yh))return;_h.copy(n).invert(),vh.copy(t.ray).applyMatrix4(_h);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);xh.fromBufferAttribute(h,i),bh(xh,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++)xh.fromBufferAttribute(h,c),bh(xh,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 bh(t,e,i,n,s,r,a){const o=vh.distanceSqToPoint(t);if(o<i){const i=new Fi;vh.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 Sh extends Pi{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 wh{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 oi:new Fi);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 Fi,n=[],s=[],r=[],a=new Fi,o=new mn;for(let d=0;d<=t;d++){const e=d/t;n[d]=this.getTangentAt(e,new Fi)}s[0]=new Fi,r[0]=new Fi;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(Qe(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(Qe(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 Th extends wh{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 oi,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 Eh extends Th{constructor(t,e,i,n,s,r){super(t,e,i,i,n,s,r),this.isArcCurve=!0,this.type="ArcCurve"}}function Ah(){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 Ch=new Fi,Rh=new Ah,Ph=new Ah,Lh=new Ah;class Ih extends wh{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 Fi){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]:(Ch.subVectors(n[0],n[1]).add(n[0]),a=Ch);const c=n[l%s],u=n[(l+1)%s];if(this.closed||l+2<s?o=n[(l+2)%s]:(Ch.subVectors(n[s-1],n[s-2]).add(n[s-1]),o=Ch),"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),Rh.initNonuniformCatmullRom(a.x,c.x,u.x,o.x,e,i,n),Ph.initNonuniformCatmullRom(a.y,c.y,u.y,o.y,e,i,n),Lh.initNonuniformCatmullRom(a.z,c.z,u.z,o.z,e,i,n)}else"catmullrom"===this.curveType&&(Rh.initCatmullRom(a.x,c.x,u.x,o.x,this.tension),Ph.initCatmullRom(a.y,c.y,u.y,o.y,this.tension),Lh.initCatmullRom(a.z,c.z,u.z,o.z,this.tension));return i.set(Rh.calc(h),Ph.calc(h),Lh.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 Fi).fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function Dh(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 Nh(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 Uh(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 Oh extends wh{constructor(t=new oi,e=new oi,i=new oi,n=new oi){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=i,this.v3=n}getPoint(t,e=new oi){const i=e,n=this.v0,s=this.v1,r=this.v2,a=this.v3;return i.set(Uh(t,n.x,s.x,r.x,a.x),Uh(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 Fh extends wh{constructor(t=new Fi,e=new Fi,i=new Fi,n=new Fi){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=i,this.v3=n}getPoint(t,e=new Fi){const i=e,n=this.v0,s=this.v1,r=this.v2,a=this.v3;return i.set(Uh(t,n.x,s.x,r.x,a.x),Uh(t,n.y,s.y,r.y,a.y),Uh(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 Bh extends wh{constructor(t=new oi,e=new oi){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new oi){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 oi){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 zh extends wh{constructor(t=new Fi,e=new Fi){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new Fi){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 Fi){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 kh extends wh{constructor(t=new oi,e=new oi,i=new oi){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=i}getPoint(t,e=new oi){const i=e,n=this.v0,s=this.v1,r=this.v2;return i.set(Nh(t,n.x,s.x,r.x),Nh(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 Vh extends wh{constructor(t=new Fi,e=new Fi,i=new Fi){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=i}getPoint(t,e=new Fi){const i=e,n=this.v0,s=this.v1,r=this.v2;return i.set(Nh(t,n.x,s.x,r.x),Nh(t,n.y,s.y,r.y),Nh(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 Gh extends wh{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new oi){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(Dh(a,o.x,l.x,h.x,c.x),Dh(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 oi).fromArray(i))}return this}}var Hh=Object.freeze({__proto__:null,ArcCurve:Eh,CatmullRomCurve3:Ih,CubicBezierCurve:Oh,CubicBezierCurve3:Fh,EllipseCurve:Th,LineCurve:Bh,LineCurve3:zh,QuadraticBezierCurve:kh,QuadraticBezierCurve3:Vh,SplineCurve:Gh});class Wh extends wh{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 Hh[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 Hh[i.type]).fromJSON(i))}return this}}class qh extends Wh{constructor(t){super(),this.type="Path",this.currentPoint=new oi,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 Bh(this.currentPoint.clone(),new oi(t,e));return this.curves.push(i),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,i,n){const s=new kh(this.currentPoint.clone(),new oi(t,e),new oi(i,n));return this.curves.push(s),this.currentPoint.set(i,n),this}bezierCurveTo(t,e,i,n,s,r){const a=new Oh(this.currentPoint.clone(),new oi(t,e),new oi(i,n),new oi(s,r));return this.curves.push(a),this.currentPoint.set(s,r),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),i=new Gh(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 Th(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 Xh extends Ts{constructor(t=[new oi(0,-.5),new oi(.5,0),new oi(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=Qe(n,0,2*Math.PI);const s=[],r=[],a=[],o=[],l=[],h=1/e,c=new Fi,u=new oi,d=new Fi,p=new Fi,m=new Fi;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 _s(r,3)),this.setAttribute("uv",new _s(a,2)),this.setAttribute("normal",new _s(l,3))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Xh(t.points,t.segments,t.phiStart,t.phiLength)}}class jh extends Xh{constructor(t=1,e=1,i=4,n=8){const s=new qh;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 jh(t.radius,t.length,t.capSegments,t.radialSegments)}}class Yh extends Ts{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 Fi,h=new oi;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 _s(r,3)),this.setAttribute("normal",new _s(a,3)),this.setAttribute("uv",new _s(o,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Yh(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class Zh extends Ts{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 oi,m=new Fi;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 Fi,_=new Fi;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 _s(c,3)),this.setAttribute("normal",new _s(u,3)),this.setAttribute("uv",new _s(d,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Zh(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Jh extends Zh{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 Jh(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Kh extends Ts{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 Fi,n=new Fi,s=new Fi;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 Fi;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 Fi;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 Fi,e=new Fi,i=new Fi,n=new Fi,a=new oi,o=new oi,l=new oi;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 _s(s,3)),this.setAttribute("normal",new _s(s.slice(),3)),this.setAttribute("uv",new _s(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 Kh(t.vertices,t.indices,t.radius,t.details)}}class $h extends Kh{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 $h(t.radius,t.detail)}}const Qh=new Fi,tc=new Fi,ec=new Fi,ic=new Kn;class nc extends Ts{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(Je*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}=ic;if(e.fromBufferAttribute(a,l[0]),i.fromBufferAttribute(a,l[1]),o.fromBufferAttribute(a,l[2]),ic.getNormal(ec),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=ic[h[t]],a=ic[h[e]],o=`${i}_${n}`,p=`${n}_${i}`;p in u&&u[p]?(ec.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:ec.clone()})}}for(const t in u)if(u[t]){const{index0:e,index1:i}=u[t];Qh.fromBufferAttribute(a,e),tc.fromBufferAttribute(a,i),d.push(Qh.x,Qh.y,Qh.z),d.push(tc.x,tc.y,tc.z)}this.setAttribute("position",new _s(d,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}class sc extends qh{constructor(t){super(t),this.uuid=$e(),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 qh).fromJSON(i))}return this}}function rc(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=Ec(r,t[r],t[r+1],a);else for(r=i-n;r>=e;r-=n)a=Ec(r,t[r],t[r+1],a);return a&&xc(a,a.next)&&(Ac(a),a=a.next),a}function ac(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!xc(n,n.next)&&0!==yc(n.prev,n,n.next))n=n.next;else{if(Ac(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function oc(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=fc(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?hc(t,n,s,r):lc(t))e.push(o.i/i|0),e.push(t.i/i|0),e.push(l.i/i|0),Ac(t),t=l.next,h=l.next;else if((t=l)===h){a?1===a?oc(t=cc(ac(t),e,i),e,i,n,s,r,2):2===a&&uc(t,e,i,n,s,r):oc(ac(t),e,i,n,s,r,1);break}}function lc(t){const e=t.prev,i=t,n=t.next;if(yc(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&&_c(s,o,r,l,a,h,m.x,m.y)&&yc(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function hc(t,e,i,n){const s=t.prev,r=t,a=t.next;if(yc(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,_=fc(p,m,e,i,n),v=fc(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&&_c(o,c,l,u,h,d,y.x,y.y)&&yc(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&&_c(o,c,l,u,h,d,x.x,x.y)&&yc(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&&_c(o,c,l,u,h,d,y.x,y.y)&&yc(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&&_c(o,c,l,u,h,d,x.x,x.y)&&yc(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function cc(t,e,i){let n=t;do{const s=n.prev,r=n.next.next;!xc(s,r)&&Mc(s,n,n.next,r)&&wc(s,r)&&wc(r,s)&&(e.push(s.i/i|0),e.push(n.i/i|0),e.push(r.i/i|0),Ac(n),Ac(n.next),n=t=r),n=n.next}while(n!==t);return ac(n)}function uc(t,e,i,n,s,r){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&vc(a,t)){let o=Tc(a,t);return a=ac(a,a.next),o=ac(o,o.next),oc(a,e,i,n,s,r,0),void oc(o,e,i,n,s,r,0)}t=t.next}a=a.next}while(a!==t)}function dc(t,e){return t.x-e.x}function pc(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&&_c(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),wc(n,t)&&(c<u||c===u&&(n.x>i.x||n.x===i.x&&mc(i,n)))&&(i=n,u=c)),n=n.next}while(n!==o);return i}(t,e);if(!i)return e;const n=Tc(i,t);return ac(n,n.next),ac(i,i.next)}function mc(t,e){return yc(t.prev,t,e.prev)<0&&yc(e.next,t,t.next)<0}function fc(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 gc(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 _c(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 vc(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&&Mc(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(wc(t,e)&&wc(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)&&(yc(t.prev,t,e.prev)||yc(t,e.prev,e))||xc(t,e)&&yc(t.prev,t,t.next)>0&&yc(e.prev,e,e.next)>0)}function yc(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function xc(t,e){return t.x===e.x&&t.y===e.y}function Mc(t,e,i,n){const s=Sc(yc(t,e,i)),r=Sc(yc(t,e,n)),a=Sc(yc(i,n,t)),o=Sc(yc(i,n,e));return s!==r&&a!==o||!(0!==s||!bc(t,i,e))||!(0!==r||!bc(t,n,e))||!(0!==a||!bc(i,t,n))||!(0!==o||!bc(i,e,n))}function bc(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 Sc(t){return t>0?1:t<0?-1:0}function wc(t,e){return yc(t.prev,t,t.next)<0?yc(t,e,t.next)>=0&&yc(t,t.prev,e)>=0:yc(t,e,t.prev)<0||yc(t,t.next,e)<0}function Tc(t,e){const i=new Cc(t.i,t.x,t.y),n=new Cc(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 Ec(t,e,i,n){const s=new Cc(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 Ac(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 Cc(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 Rc{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 Rc.area(t)<0}static triangulateShape(t,e){const i=[],n=[],s=[];Pc(t),Lc(i,t);let r=t.length;e.forEach(Pc);for(let o=0;o<e.length;o++)n.push(r),r+=e[o].length,Lc(i,e[o]);const a=function(t,e,i=2){const n=e&&e.length,s=n?e[0]*i:t.length;let r=rc(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=rc(t,o,l,n,!1),h===h.next&&(h.steiner=!0),s.push(gc(h));for(s.sort(dc),r=0;r<s.length;r++)i=pc(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 oc(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 Pc(t){const e=t.length;e>2&&t[e-1].equals(t[0])&&t.pop()}function Lc(t,e){for(let i=0;i<e.length;i++)t.push(e[i].x),t.push(e[i].y)}class Ic extends Ts{constructor(t=new sc([new oi(.5,.5),new oi(-.5,.5),new oi(-.5,-.5),new oi(.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:Dc;let g,_,v,y,x,M=!1;m&&(g=m.getSpacedPoints(o),M=!0,h=!1,_=m.computeFrenetFrames(o,!1),v=new Fi,y=new Fi,x=new Fi),h||(p=0,c=0,u=0,d=0);const b=t.extractPoints(a);let S=b.shape;const w=b.holes;if(!Rc.isClockWise(S)){S=S.reverse();for(let t=0,e=w.length;t<e;t++){const e=w[t];Rc.isClockWise(e)&&(w[t]=e.reverse())}}const T=Rc.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 oi(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 oi(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 _s(n,3)),this.setAttribute("uv",new _s(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 Hh[n.type]).fromJSON(n)),new Ic(i,t.options)}}const Dc={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 oi(r,a),new oi(o,l),new oi(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 oi(a,1-l),new oi(h,1-u),new oi(d,1-m),new oi(f,1-_)]:[new oi(o,1-l),new oi(c,1-u),new oi(p,1-m),new oi(g,1-_)]}};class Nc extends Kh{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 Nc(t.radius,t.detail)}}class Uc extends Kh{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 Uc(t.radius,t.detail)}}class Oc extends Ts{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 Fi,p=new oi;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 _s(o,3)),this.setAttribute("normal",new _s(l,3)),this.setAttribute("uv",new _s(h,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Oc(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}}class Fc extends Ts{constructor(t=new sc([new oi(0,.5),new oi(-.5,-.5),new oi(.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===Rc.isClockWise(h)&&(h=h.reverse());for(let e=0,i=c.length;e<i;e++){const t=c[e];!0===Rc.isClockWise(t)&&(c[e]=t.reverse())}const u=Rc.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 _s(n,3)),this.setAttribute("normal",new _s(s,3)),this.setAttribute("uv",new _s(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 Fc(i,t.curveSegments)}}class Bc extends Ts{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 Fi,u=new Fi,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 _s(p,3)),this.setAttribute("normal",new _s(m,3)),this.setAttribute("uv",new _s(f,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Bc(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class zc extends Kh{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 zc(t.radius,t.detail)}}class kc extends Ts{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 Fi,c=new Fi,u=new Fi;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 _s(a,3)),this.setAttribute("normal",new _s(o,3)),this.setAttribute("uv",new _s(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new kc(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class Vc extends Ts{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 Fi,u=new Fi,d=new Fi,p=new Fi,m=new Fi,f=new Fi,g=new Fi;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 _s(o,3)),this.setAttribute("normal",new _s(l,3)),this.setAttribute("uv",new _s(h,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Vc(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}}class Gc extends Ts{constructor(t=new Vh(new Fi(-1,-1,0),new Fi(-1,1,0),new Fi(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 Fi,o=new Fi,l=new oi;let h=new Fi;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 _s(c,3)),this.setAttribute("normal",new _s(u,3)),this.setAttribute("uv",new _s(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 Gc((new Hh[t.path.type]).fromJSON(t.path),t.tubularSegments,t.radius,t.radialSegments,t.closed)}}class Hc extends Ts{constructor(t=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:t},null!==t){const e=[],i=new Set,n=new Fi,s=new Fi;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===Wc(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===Wc(n,s,i)&&(e.push(n.x,n.y,n.z),e.push(s.x,s.y,s.z))}}this.setAttribute("position",new _s(e,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}function Wc(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 qc=Object.freeze({__proto__:null,BoxGeometry:qs,CapsuleGeometry:jh,CircleGeometry:Yh,ConeGeometry:Jh,CylinderGeometry:Zh,DodecahedronGeometry:$h,EdgesGeometry:nc,ExtrudeGeometry:Ic,IcosahedronGeometry:Nc,LatheGeometry:Xh,OctahedronGeometry:Uc,PlaneGeometry:dr,PolyhedronGeometry:Kh,RingGeometry:Oc,ShapeGeometry:Fc,SphereGeometry:Bc,TetrahedronGeometry:zc,TorusGeometry:kc,TorusKnotGeometry:Vc,TubeGeometry:Gc,WireframeGeometry:Hc});class Xc extends rs{constructor(t){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new is(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 jc extends Js{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Yc extends rs{constructor(t){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new is(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 is(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new oi(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 Zc extends Yc{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 oi(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get(){return Qe(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 is(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 is(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new is(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 Jc extends rs{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new is(16777215),this.specular=new is(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new is(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new oi(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 Kc extends rs{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new is(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new is(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new oi(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 $c extends rs{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new oi(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 Qc extends rs{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new is(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new is(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new oi(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 tu extends rs{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new is(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new oi(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 eu extends rh{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 iu(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 nu(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function su(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 ru(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 au(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 ou={convertArray:iu,isTypedArray:nu,getKeyframeOrder:su,sortedArray:ru,flattenJSON:au,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=iu(o,t.times.constructor),t.values=iu(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 Oi).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)Oi.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=Me,t}};class lu{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 hu extends lu{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:ve,endingEnd:ve}}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 ye:s=t,a=2*e-i;break;case xe: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 ye:r=t,o=2*i-e;break;case xe: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 cu extends lu{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 uu extends lu{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t){return this.copySampleValue_(t-1)}}class du{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=iu(e,this.TimeBufferType),this.values=iu(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:iu(t.times,Array),values:iu(t.values,Array)};const e=t.getInterpolation();e!==t.DefaultInterpolation&&(i.interpolation=e)}return i.type=t.ValueTypeName,i}InterpolantFactoryMethodDiscrete(t){return new uu(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new cu(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new hu(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case fe:e=this.InterpolantFactoryMethodDiscrete;break;case ge:e=this.InterpolantFactoryMethodLinear;break;case _e: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 fe;case this.InterpolantFactoryMethodLinear:return ge;case this.InterpolantFactoryMethodSmooth:return _e}}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&&nu(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()===_e,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}}du.prototype.TimeBufferType=Float32Array,du.prototype.ValueBufferType=Float32Array,du.prototype.DefaultInterpolation=ge;class pu extends du{}pu.prototype.ValueTypeName="bool",pu.prototype.ValueBufferType=Array,pu.prototype.DefaultInterpolation=fe,pu.prototype.InterpolantFactoryMethodLinear=void 0,pu.prototype.InterpolantFactoryMethodSmooth=void 0;class mu extends du{}mu.prototype.ValueTypeName="color";class fu extends du{}fu.prototype.ValueTypeName="number";class gu extends lu{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)Oi.slerpFlat(s,0,r,l-a,r,l,o);return s}}class _u extends du{InterpolantFactoryMethodLinear(t){return new gu(this.times,this.values,this.getValueSize(),t)}}_u.prototype.ValueTypeName="quaternion",_u.prototype.DefaultInterpolation=ge,_u.prototype.InterpolantFactoryMethodSmooth=void 0;class vu extends du{}vu.prototype.ValueTypeName="string",vu.prototype.ValueBufferType=Array,vu.prototype.DefaultInterpolation=fe,vu.prototype.InterpolantFactoryMethodLinear=void 0,vu.prototype.InterpolantFactoryMethodSmooth=void 0;class yu extends du{}yu.prototype.ValueTypeName="vector";class xu{constructor(t,e=-1,i,n=2500){this.name=t,this.tracks=i,this.duration=e,this.blendMode=n,this.uuid=$e(),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(Mu(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(du.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=su(t);t=ru(t,1,l),o=ru(o,1,l),n||0!==t[0]||(t.push(s),o.push(o[0])),r.push(new fu(".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=[];au(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 fu(".morphTargetInfluence["+s+"]",e,r))}o=e.length*r}else{const s=".bones["+e[h].name+"]";i(yu,s+".position",t,"pos",n),i(_u,s+".quaternion",t,"rot",n),i(yu,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 Mu(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 fu;case"vector":case"vector2":case"vector3":case"vector4":return yu;case"color":return mu;case"quaternion":return _u;case"bool":case"boolean":return pu;case"string":return vu}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}(t.type);if(void 0===t.times){const e=[],i=[];au(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 bu={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 Su{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 wu=new Su;class Tu{constructor(t){this.manager=void 0!==t?t:wu,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}}Tu.DEFAULT_MATERIAL_NAME="__DEFAULT";const Eu={};class Au extends Error{constructor(t,e){super(t),this.response=e}}class Cu extends Tu{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=bu.get(t);if(void 0!==s)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(void 0!==Eu[t])return void Eu[t].push({onLoad:e,onProgress:i,onError:n});Eu[t]=[],Eu[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=Eu[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 Au(`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=>{bu.add(t,e);const i=Eu[t];delete Eu[t];for(let t=0,n=i.length;t<n;t++){const n=i[t];n.onLoad&&n.onLoad(e)}}).catch(e=>{const i=Eu[t];if(void 0===i)throw this.manager.itemError(t),e;delete Eu[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 Ru extends Tu{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=bu.get(t);if(void 0!==r)return s.manager.itemStart(t),setTimeout(function(){e&&e(r),s.manager.itemEnd(t)},0),r;const a=pi("img");function o(){h(),bu.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 Pu extends zn{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new is(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 Lu extends Pu{constructor(t,e,i){super(t,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(zn.DEFAULT_UP),this.updateMatrix(),this.groundColor=new is(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}}const Iu=new mn,Du=new Fi,Nu=new Fi;class Uu{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new oi(512,512),this.map=null,this.mapPass=null,this.matrix=new mn,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new hr,this._frameExtents=new oi(1,1),this._viewportCount=1,this._viewports=[new Li(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,i=this.matrix;Du.setFromMatrixPosition(t.matrixWorld),e.position.copy(Du),Nu.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(Nu),e.updateMatrixWorld(),Iu.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Iu),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Iu)}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 Ou extends Uu{constructor(){super(new $s(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){const e=this.camera,i=2*Ke*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 Fu extends Pu{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(zn.DEFAULT_UP),this.updateMatrix(),this.target=new zn,this.distance=i,this.angle=n,this.penumbra=s,this.decay=r,this.map=null,this.shadow=new Ou}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 Bu=new mn,zu=new Fi,ku=new Fi;class Vu extends Uu{constructor(){super(new $s(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new oi(4,2),this._viewportCount=6,this._viewports=[new Li(2,1,1,1),new Li(0,1,1,1),new Li(3,1,1,1),new Li(1,1,1,1),new Li(3,0,1,1),new Li(1,0,1,1)],this._cubeDirections=[new Fi(1,0,0),new Fi(-1,0,0),new Fi(0,0,1),new Fi(0,0,-1),new Fi(0,1,0),new Fi(0,-1,0)],this._cubeUps=[new Fi(0,1,0),new Fi(0,1,0),new Fi(0,1,0),new Fi(0,1,0),new Fi(0,0,1),new Fi(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()),zu.setFromMatrixPosition(t.matrixWorld),i.position.copy(zu),ku.copy(i.position),ku.add(this._cubeDirections[e]),i.up.copy(this._cubeUps[e]),i.lookAt(ku),i.updateMatrixWorld(),n.makeTranslation(-zu.x,-zu.y,-zu.z),Bu.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Bu)}}class Gu extends Pu{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 Vu}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 Hu extends Uu{constructor(){super(new Sr(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Wu extends Pu{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(zn.DEFAULT_UP),this.updateMatrix(),this.target=new zn,this.shadow=new Hu}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class qu extends Pu{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class Xu extends Pu{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 ju{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new Fi)}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 Yu extends Pu{constructor(t=new ju,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 Zu extends Tu{constructor(t){super(t),this.textures={}}load(t,e,i,n){const s=this,r=new Cu(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=Zu.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 is).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 is).setHex(e.value);break;case"v2":n.uniforms[s].value=(new oi).fromArray(e.value);break;case"v3":n.uniforms[s].value=(new Fi).fromArray(e.value);break;case"v4":n.uniforms[s].value=(new Li).fromArray(e.value);break;case"m3":n.uniforms[s].value=(new li).fromArray(e.value);break;case"m4":n.uniforms[s].value=(new mn).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 oi).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 oi).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:Xc,SpriteMaterial:Qo,RawShaderMaterial:jc,ShaderMaterial:Js,PointsMaterial:gh,MeshPhysicalMaterial:Zc,MeshStandardMaterial:Yc,MeshPhongMaterial:Jc,MeshToonMaterial:Kc,MeshNormalMaterial:$c,MeshLambertMaterial:Qc,MeshDepthMaterial:Io,MeshDistanceMaterial:Do,MeshBasicMaterial:as,MeshMatcapMaterial:tu,LineDashedMaterial:eu,LineBasicMaterial:rh,Material:rs}[t]}}class Ju{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 Ku extends Ts{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 $u extends Tu{constructor(t){super(t)}load(t,e,i,n){const s=this,r=new Cu(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=di(s.type,r),o=new Jo(a,s.stride);return o.uuid=s.uuid,e[n]=o,o}const s=t.isInstancedBufferGeometry?new Ku:new Ts,r=t.data.index;if(void 0!==r){const t=di(r.type,r.array);s.setIndex(new ms(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 $o(s,e.itemSize,e.offset,e.normalized)}else{const t=di(e.type,e.array);i=new(e.isInstancedBufferAttribute?Dl:ms)(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 $o(e,r.itemSize,r.offset,r.normalized)}else{const t=di(r.type,r.array);a=new ms(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 Fi;void 0!==h.center&&t.fromArray(h.center),s.boundingSphere=new rn(t,h.radius)}return t.name&&(s.name=t.name),t.userData&&(s.userData=t.userData),s}}const Qu={UVMapping:lt,CubeReflectionMapping:ht,CubeRefractionMapping:ct,EquirectangularReflectionMapping:ut,EquirectangularRefractionMapping:dt,CubeUVReflectionMapping:pt},td={RepeatWrapping:mt,ClampToEdgeWrapping:ft,MirroredRepeatWrapping:gt},ed={NearestFilter:_t,NearestMipmapNearestFilter:vt,NearestMipmapLinearFilter:yt,LinearFilter:xt,LinearMipmapNearestFilter:Mt,LinearMipmapLinearFilter:bt};let id;class nd{static getContext(){return void 0===id&&(id=new(window.AudioContext||window.webkitAudioContext)),id}static setContext(t){id=t}}const sd=new mn,rd=new mn,ad=new mn;class od{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=ld(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=ld();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function ld(){return("undefined"==typeof performance?Date:performance).now()}const hd=new Fi,cd=new Oi,ud=new Fi,dd=new Fi;class pd extends zn{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 md=new Fi,fd=new Oi,gd=new Fi,_d=new Fi;class vd{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){Oi.slerpFlat(t,e,t,e,t,i,n)}_slerpAdditive(t,e,i,n,s){const r=this._workIndex*s;Oi.multiplyQuaternionsFlat(t,r,t,e,t,i),Oi.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 yd="\\[\\]\\.:\\/",xd=new RegExp("["+yd+"]","g"),Md="[^"+yd+"]",bd="[^"+yd.replace("\\.","")+"]",Sd=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",Md)+/(WCOD+)?/.source.replace("WCOD",bd)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Md)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Md)+"$"),wd=["material","materials","bones","map"];class Td{constructor(t,e,i){this.path=e,this.parsedPath=i||Td.parseTrackName(e),this.node=Td.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 Td.Composite(t,e,i):new Td(t,e,i)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(xd,"")}static parseTrackName(t){const e=Sd.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!==wd.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=Td.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}}Td.Composite=class{constructor(t,e,i){const n=i||Td.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()}},Td.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Td.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Td.prototype.GetterByBindingType=[Td.prototype._getValue_direct,Td.prototype._getValue_array,Td.prototype._getValue_arrayElement,Td.prototype._getValue_toArray],Td.prototype.SetterByBindingTypeAndVersioning=[[Td.prototype._setValue_direct,Td.prototype._setValue_direct_setNeedsUpdate,Td.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Td.prototype._setValue_array,Td.prototype._setValue_array_setNeedsUpdate,Td.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Td.prototype._setValue_arrayElement,Td.prototype._setValue_arrayElement_setNeedsUpdate,Td.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Td.prototype._setValue_fromArray,Td.prototype._setValue_fromArray_setNeedsUpdate,Td.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Ed{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:ve,endingEnd:ve};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===Me)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=ye,n.endingEnd=ye):(n.endingStart=t?this.zeroSlopeAtStart?ye:ve:xe,n.endingEnd=e?this.zeroSlopeAtEnd?ye:ve:xe)}_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 Ad=new Float32Array(1);class Cd{constructor(t){this.value=t}clone(){return new Cd(void 0===this.value.clone?this.value:this.value.clone())}}let Rd=0;function Pd(t,e){return t.distance-e.distance}function Ld(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++)Ld(n[t],e,i,!0)}}const Id=new oi,Dd=new Fi,Nd=new Fi,Ud=new Fi,Od=new Fi,Fd=new mn,Bd=new mn;function zd(t){const e=[];!0===t.isBone&&e.push(t);for(let i=0;i<t.children.length;i++)e.push.apply(e,zd(t.children[i]));return e}const kd=new Fi,Vd=new is,Gd=new is,Hd=new Fi,Wd=new Fi,qd=new Fi,Xd=new Fi,jd=new Ks;function Yd(t,e,i,n,s,r,a){Xd.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],Xd.x,Xd.y,Xd.z)}}const Zd=new ki,Jd=new Fi;let Kd,$d;"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:B}})),"undefined"!=typeof window&&(window.__THREE__||(window.__THREE__=B));const Qd=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:4,AddEquation:G,AddOperation:2,AdditiveAnimationBlendMode:Me,AdditiveBlending:2,AgXToneMapping:6,AlphaFormat:1021,AlwaysCompare:519,AlwaysDepth:1,AlwaysStencilFunc:519,AmbientLight:qu,AnimationAction:Ed,AnimationClip:xu,AnimationLoader:class extends Tu{constructor(t){super(t)}load(t,e,i,n){const s=this,r=new Cu(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=xu.parse(t[i]);e.push(n)}return e}},AnimationMixer:class extends je{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 vd(Td.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 cu(new Float32Array(2),new Float32Array(2),1,Ad),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?xu.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 Ed(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?xu.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=$e(),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 Td(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 Td(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 Td(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:ou,ArcCurve:Eh,ArrayCamera:Bo,ArrowHelper:class extends zn{constructor(t=new Fi(0,0,1),e=new Fi(0,0,0),i=1,n=16776960,s=.2*i,r=.2*s){super(),this.type="ArrowHelper",void 0===Kd&&(Kd=new Ts,Kd.setAttribute("position",new _s([0,0,0,0,1,0],3)),$d=new Zh(0,.5,1,5,1),$d.translate(0,-.5,0)),this.position.copy(e),this.line=new uh(Kd,new rh({color:n,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Hs($d,new as({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{Jd.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(Jd,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:at,Audio:pd,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:nd,AudioListener:class extends zn{constructor(){super(),this.type="AudioListener",this.context=nd.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new od}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(hd,cd,ud),dd.set(0,0,-1).applyQuaternion(cd),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(hd.x,t),e.positionY.linearRampToValueAtTime(hd.y,t),e.positionZ.linearRampToValueAtTime(hd.z,t),e.forwardX.linearRampToValueAtTime(dd.x,t),e.forwardY.linearRampToValueAtTime(dd.y,t),e.forwardZ.linearRampToValueAtTime(dd.z,t),e.upX.linearRampToValueAtTime(i.x,t),e.upY.linearRampToValueAtTime(i.y,t),e.upZ.linearRampToValueAtTime(i.z,t)}else e.setPosition(hd.x,hd.y,hd.z),e.setOrientation(dd.x,dd.y,dd.z,i.x,i.y,i.z)}},AudioLoader:class extends Tu{constructor(t){super(t)}load(t,e,i,n){const s=this,r=new Cu(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);nd.getContext().decodeAudioData(i,function(t){e(t)}).catch(a)}catch(i){a(i)}},i,n)}},AxesHelper:class extends mh{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 Ts;i.setAttribute("position",new _s(e,3)),i.setAttribute("color",new _s([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(i,new rh({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(t,e,i){const n=new is,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:sh,Bone:Cl,BooleanKeyframeTrack:pu,Box2:class{constructor(t=new oi(1/0,1/0),e=new oi(-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=Id.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,Id).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:ki,Box3Helper:class extends mh{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 Ts;n.setIndex(new ms(i,1)),n.setAttribute("position",new _s([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 rh({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:qs,BoxHelper:class extends mh{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 Ts;s.setIndex(new ms(i,1)),s.setAttribute("position",new ms(n,3)),super(s,new rh({color:e,toneMapped:!1})),this.object=t,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(t){if(void 0!==this.object&&Zd.setFromObject(this.object),Zd.isEmpty())return;const e=Zd.min,i=Zd.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:ms,BufferGeometry:Ts,BufferGeometryLoader:$u,ByteType:1010,Cache:bu,Camera:Ks,CameraHelper:class extends mh{constructor(t){const e=new Ts,i=new rh({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 _s(n,3)),e.setAttribute("color",new _s(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 is(16755200),h=new is(16711680),c=new is(43775),u=new is(16777215),d=new is(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;jd.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Yd("c",e,t,jd,0,0,-1),Yd("t",e,t,jd,0,0,1),Yd("n1",e,t,jd,-1,-1,-1),Yd("n2",e,t,jd,1,-1,-1),Yd("n3",e,t,jd,-1,1,-1),Yd("n4",e,t,jd,1,1,-1),Yd("f1",e,t,jd,-1,-1,1),Yd("f2",e,t,jd,1,-1,1),Yd("f3",e,t,jd,-1,1,1),Yd("f4",e,t,jd,1,1,1),Yd("u1",e,t,jd,.7,1.1,-1),Yd("u2",e,t,jd,-.7,1.1,-1),Yd("u3",e,t,jd,0,2,-1),Yd("cf1",e,t,jd,-1,0,1),Yd("cf2",e,t,jd,1,0,1),Yd("cf3",e,t,jd,0,-1,1),Yd("cf4",e,t,jd,0,1,1),Yd("cn1",e,t,jd,-1,0,-1),Yd("cn2",e,t,jd,1,0,-1),Yd("cn3",e,t,jd,0,-1,-1),Yd("cn4",e,t,jd,0,1,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},CanvasTexture:class extends Pi{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:jh,CatmullRomCurve3:Ih,CineonToneMapping:3,CircleGeometry:Yh,ClampToEdgeWrapping:ft,Clock:od,Color:is,ColorKeyframeTrack:mu,ColorManagement:Mi,CompressedArrayTexture:class extends Sh{constructor(t,e,i,n,s,r){super(t,e,i,s,r),this.isCompressedArrayTexture=!0,this.image.depth=n,this.wrapR=ft}},CompressedCubeTexture:class extends Sh{constructor(t,e,i){super(void 0,t[0].width,t[0].height,e,i,ht),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}},CompressedTexture:Sh,CompressedTextureLoader:class extends Tu{constructor(t){super(t)}load(t,e,i,n){const s=this,r=[],a=new Sh,o=new Cu(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=xt),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=xt),a.format=i.format,a.needsUpdate=!0,e&&e(a)},i,n);return a}},ConeGeometry:Jh,ConstantAlphaFactor:213,ConstantColorFactor:211,CubeCamera:tr,CubeReflectionMapping:ht,CubeRefractionMapping:ct,CubeTexture:er,CubeTextureLoader:class extends Tu{constructor(t){super(t)}load(t,e,i,n){const s=new er;s.colorSpace=Te;const r=new Ru(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:pt,CubicBezierCurve:Oh,CubicBezierCurve3:Fh,CubicInterpolant:hu,CullFaceBack:1,CullFaceFront:2,CullFaceFrontBack:3,CullFaceNone:0,Curve:wh,CurvePath:Wh,CustomBlending:5,CustomToneMapping:5,CylinderGeometry:Zh,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:Ui,DataArrayTexture:Ni,DataTexture:Rl,DataTextureLoader:class extends Tu{constructor(t){super(t)}load(t,e,i,n){const s=this,r=new Rl,a=new Cu(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:ft,r.wrapT=void 0!==i.wrapT?i.wrapT:ft,r.magFilter=void 0!==i.magFilter?i.magFilter:xt,r.minFilter=void 0!==i.minFilter?i.minFilter:xt,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=bt),1===i.mipmapCount&&(r.minFilter=xt),void 0!==i.generateMipmaps&&(r.generateMipmaps=i.generateMipmaps),r.needsUpdate=!0,e&&e(r,i)},i,n),r}},DataUtils:us,DecrementStencilOp:7683,DecrementWrapStencilOp:34056,DefaultLoadingManager:wu,DepthFormat:Dt,DepthStencilFormat:Nt,DepthTexture:jr,DetachedBindMode:ot,DirectionalLight:Wu,DirectionalLightHelper:class extends zn{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 Ts;n.setAttribute("position",new _s([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));const s=new rh({fog:!1,toneMapped:!1});this.lightPlane=new uh(n,s),this.add(this.lightPlane),n=new Ts,n.setAttribute("position",new _s([0,0,0,0,0,1],3)),this.targetLine=new uh(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),Hd.setFromMatrixPosition(this.light.matrixWorld),Wd.setFromMatrixPosition(this.light.target.matrixWorld),qd.subVectors(Wd,Hd),this.lightPlane.lookAt(Wd),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(Wd),this.targetLine.scale.z=qd.length()}},DiscreteInterpolant:uu,DisplayP3ColorSpace:Ae,DodecahedronGeometry:$h,DoubleSide:2,DstAlphaFactor:206,DstColorFactor:208,DynamicCopyUsage:35050,DynamicDrawUsage:35048,DynamicReadUsage:35049,EdgesGeometry:nc,EllipseCurve:Th,EqualCompare:514,EqualDepth:4,EqualStencilFunc:514,EquirectangularReflectionMapping:ut,EquirectangularRefractionMapping:dt,Euler:wn,EventDispatcher:je,ExtrudeGeometry:Ic,FileLoader:Cu,Float16BufferAttribute:class extends ms{constructor(t,e,i){super(new Uint16Array(t),e,i),this.isFloat16BufferAttribute=!0}getX(t){let e=cs(this.array[t*this.itemSize]);return this.normalized&&(e=si(e,this.array)),e}setX(t,e){return this.normalized&&(e=ri(e,this.array)),this.array[t*this.itemSize]=hs(e),this}getY(t){let e=cs(this.array[t*this.itemSize+1]);return this.normalized&&(e=si(e,this.array)),e}setY(t,e){return this.normalized&&(e=ri(e,this.array)),this.array[t*this.itemSize+1]=hs(e),this}getZ(t){let e=cs(this.array[t*this.itemSize+2]);return this.normalized&&(e=si(e,this.array)),e}setZ(t,e){return this.normalized&&(e=ri(e,this.array)),this.array[t*this.itemSize+2]=hs(e),this}getW(t){let e=cs(this.array[t*this.itemSize+3]);return this.normalized&&(e=si(e,this.array)),e}setW(t,e){return this.normalized&&(e=ri(e,this.array)),this.array[t*this.itemSize+3]=hs(e),this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=ri(e,this.array),i=ri(i,this.array)),this.array[t+0]=hs(e),this.array[t+1]=hs(i),this}setXYZ(t,e,i,n){return t*=this.itemSize,this.normalized&&(e=ri(e,this.array),i=ri(i,this.array),n=ri(n,this.array)),this.array[t+0]=hs(e),this.array[t+1]=hs(i),this.array[t+2]=hs(n),this}setXYZW(t,e,i,n,s){return t*=this.itemSize,this.normalized&&(e=ri(e,this.array),i=ri(i,this.array),n=ri(n,this.array),s=ri(s,this.array)),this.array[t+0]=hs(e),this.array[t+1]=hs(i),this.array[t+2]=hs(n),this.array[t+3]=hs(s),this}},Float32BufferAttribute:_s,Float64BufferAttribute:class extends ms{constructor(t,e,i){super(new Float64Array(t),e,i)}},FloatType:At,Fog:Yo,FogExp2:jo,FramebufferTexture:class extends Pi{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=_t,this.minFilter=_t,this.generateMipmaps=!1,this.needsUpdate=!0}},FrontSide:0,Frustum:hr,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:He,GreaterCompare:516,GreaterDepth:6,GreaterEqualCompare:518,GreaterEqualDepth:5,GreaterEqualStencilFunc:518,GreaterStencilFunc:516,GridHelper:class extends mh{constructor(t=10,e=10,i=4473924,n=8947848){i=new is(i),n=new is(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 Ts;h.setAttribute("position",new _s(o,3)),h.setAttribute("color",new _s(l,3)),super(h,new rh({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},Group:zo,HalfFloatType:Ct,HemisphereLight:Lu,HemisphereLightHelper:class extends zn{constructor(t,e,i){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";const n=new Uc(e);n.rotateY(.5*Math.PI),this.material=new as({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 ms(r,3)),this.add(new Hs(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");Vd.copy(this.light.color),Gd.copy(this.light.groundColor);for(let t=0,i=e.count;t<i;t++){const n=t<i/2?Vd:Gd;e.setXYZ(t,n.r,n.g,n.b)}e.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),t.lookAt(kd.setFromMatrixPosition(this.light.matrixWorld).negate())}},IcosahedronGeometry:Nc,ImageBitmapLoader:class extends Tu{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=bu.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 bu.add(t,i),e&&e(i),s.manager.itemEnd(t),i}).catch(function(e){n&&n(e),bu.remove(t),s.manager.itemError(t),s.manager.itemEnd(t)});bu.add(t,o),s.manager.itemStart(t)}},ImageLoader:Ru,ImageUtils:Ti,IncrementStencilOp:7682,IncrementWrapStencilOp:34055,InstancedBufferAttribute:Dl,InstancedBufferGeometry:Ku,InstancedInterleavedBuffer:class extends Jo{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:Vl,Int16BufferAttribute:class extends ms{constructor(t,e,i){super(new Int16Array(t),e,i)}},Int32BufferAttribute:class extends ms{constructor(t,e,i){super(new Int32Array(t),e,i)}},Int8BufferAttribute:class extends ms{constructor(t,e,i){super(new Int8Array(t),e,i)}},IntType:Tt,InterleavedBuffer:Jo,InterleavedBufferAttribute:$o,Interpolant:lu,InterpolateDiscrete:fe,InterpolateLinear:ge,InterpolateSmooth:_e,InvertStencilOp:5386,KeepStencilOp:De,KeyframeTrack:du,LOD:_l,LatheGeometry:Xh,Layers:Tn,LessCompare:513,LessDepth:2,LessEqualCompare:515,LessEqualDepth:3,LessEqualStencilFunc:515,LessStencilFunc:513,Light:Pu,LightProbe:Yu,Line:uh,Line3:class{constructor(t=new Fi,e=new Fi){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){Dd.subVectors(t,this.start),Nd.subVectors(this.end,this.start);const i=Nd.dot(Nd);let n=Nd.dot(Dd)/i;return e&&(n=Qe(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:rh,LineCurve:Bh,LineCurve3:zh,LineDashedMaterial:eu,LineLoop:fh,LineSegments:mh,LinearDisplayP3ColorSpace:Ce,LinearEncoding:be,LinearFilter:xt,LinearInterpolant:cu,LinearMipMapLinearFilter:1008,LinearMipMapNearestFilter:1007,LinearMipmapLinearFilter:bt,LinearMipmapNearestFilter:Mt,LinearSRGBColorSpace:Ee,LinearToneMapping:1,LinearTransfer:Re,Loader:Tu,LoaderUtils:Ju,LoadingManager:Su,LoopOnce:2200,LoopPingPong:2202,LoopRepeat:2201,LuminanceAlphaFormat:1025,LuminanceFormat:1024,MOUSE:{LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Material:rs,MaterialLoader:Zu,MathUtils:ai,Matrix3:li,Matrix4:mn,MaxEquation:104,Mesh:Hs,MeshBasicMaterial:as,MeshDepthMaterial:Io,MeshDistanceMaterial:Do,MeshLambertMaterial:Qc,MeshMatcapMaterial:tu,MeshNormalMaterial:$c,MeshPhongMaterial:Jc,MeshPhysicalMaterial:Zc,MeshStandardMaterial:Yc,MeshToonMaterial:Kc,MinEquation:103,MirroredRepeatWrapping:gt,MixOperation:1,MultiplyBlending:4,MultiplyOperation:0,NearestFilter:_t,NearestMipMapLinearFilter:1005,NearestMipMapNearestFilter:1004,NearestMipmapLinearFilter:yt,NearestMipmapNearestFilter:vt,NeverCompare:512,NeverDepth:0,NeverStencilFunc:512,NoBlending:0,NoColorSpace:we,NoToneMapping:0,NormalAnimationBlendMode:2500,NormalBlending:1,NotEqualCompare:517,NotEqualDepth:7,NotEqualStencilFunc:517,NumberKeyframeTrack:fu,Object3D:zn,ObjectLoader:class extends Tu{constructor(t){super(t)}load(t,e,i,n){const s=this,r=""===this.path?Ju.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||r;const a=new Cu(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?Ju.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||i;const n=new Cu(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 sc).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 Il).fromJSON(t[s],n);i[e.uuid]=e}return i}parseGeometries(t,e){const i={};if(void 0!==t){const n=new $u;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 qc&&(r=qc[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 Zu;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=xu.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:di(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){const i=new Su(e);s=new Ru(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 Rl(i.data,i.width,i.height)))}n[i.uuid]=new Ai(t)}else{const t=r(i.url);n[i.uuid]=new Ai(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:di(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){n=new Ru(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 Rl(n.data,n.width,n.height)))}i[n.uuid]=new Ai(t)}else{const t=await s(n.url);i[n.uuid]=new Ai(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 er,6===o.length&&(l.needsUpdate=!0)):(l=o&&o.data?new Rl:new Pi,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,Qu)),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],td),l.wrapT=i(r.wrap[1],td)),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,ed)),void 0!==r.magFilter&&(l.magFilter=i(r.magFilter,ed)),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 Zo,void 0!==t.background&&(Number.isInteger(t.background)?r.background=new is(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 Yo(t.fog.color,t.fog.near,t.fog.far):"FogExp2"===t.fog.type&&(r.fog=new jo(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 $s(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 Sr(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 qu(t.color,t.intensity);break;case"DirectionalLight":r=new Wu(t.color,t.intensity);break;case"PointLight":r=new Gu(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":r=new Xu(t.color,t.intensity,t.width,t.height);break;case"SpotLight":r=new Fu(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay);break;case"HemisphereLight":r=new Lu(t.color,t.groundColor,t.intensity);break;case"LightProbe":r=(new Yu).fromJSON(t);break;case"SkinnedMesh":a=l(t.geometry),o=h(t.material),r=new Al(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 Hs(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 Vl(a,o,e),r.instanceMatrix=new Dl(new Float32Array(i.array),16),void 0!==n&&(r.instanceColor=new Dl(new Float32Array(n.array),n.itemSize));break;case"BatchedMesh":a=l(t.geometry),o=h(t.material),r=new sh(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 ki;e.min.fromArray(t.boxMin),e.max.fromArray(t.boxMax);const i=new rn;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 _l;break;case"Line":r=new uh(l(t.geometry),h(t.material));break;case"LineLoop":r=new fh(l(t.geometry),h(t.material));break;case"LineSegments":r=new mh(l(t.geometry),h(t.material));break;case"PointCloud":case"Points":r=new Mh(l(t.geometry),h(t.material));break;case"Sprite":r=new pl(h(t.material));break;case"Group":r=new zo;break;case"Bone":r=new Cl;break;default:r=new zn}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:Uc,OneFactor:201,OneMinusConstantAlphaFactor:214,OneMinusConstantColorFactor:212,OneMinusDstAlphaFactor:207,OneMinusDstColorFactor:209,OneMinusSrcAlphaFactor:J,OneMinusSrcColorFactor:203,OrthographicCamera:Sr,P3Primaries:Ie,PCFShadowMap:1,PCFSoftShadowMap:2,PMREMGenerator:Dr,Path:qh,PerspectiveCamera:$s,Plane:ar,PlaneGeometry:dr,PlaneHelper:class extends uh{constructor(t,e=1,i=16776960){const n=i,s=new Ts;s.setAttribute("position",new _s([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 rh({color:n,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e;const r=new Ts;r.setAttribute("position",new _s([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),r.computeBoundingSphere(),this.add(new Hs(r,new as({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:Gu,PointLightHelper:class extends Hs{constructor(t,e,i){super(new Bc(e,4,2),new as({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:Mh,PointsMaterial:gh,PolarGridHelper:class extends mh{constructor(t=10,e=16,i=8,n=64,s=4473924,r=8947848){s=new is(s),r=new is(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 Ts;l.setAttribute("position",new _s(a,3)),l.setAttribute("color",new _s(o,3)),super(l,new rh({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},PolyhedronGeometry:Kh,PositionalAudio:class extends pd{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(md,fd,gd),_d.set(0,0,1).applyQuaternion(fd);const e=this.panner;if(e.positionX){const t=this.context.currentTime+this.listener.timeDelta;e.positionX.linearRampToValueAtTime(md.x,t),e.positionY.linearRampToValueAtTime(md.y,t),e.positionZ.linearRampToValueAtTime(md.z,t),e.orientationX.linearRampToValueAtTime(_d.x,t),e.orientationY.linearRampToValueAtTime(_d.y,t),e.orientationZ.linearRampToValueAtTime(_d.z,t)}else e.setPosition(md.x,md.y,md.z),e.setOrientation(_d.x,_d.y,_d.z)}},PropertyBinding:Td,PropertyMixer:vd,QuadraticBezierCurve:kh,QuadraticBezierCurve3:Vh,Quaternion:Oi,QuaternionKeyframeTrack:_u,QuaternionLinearInterpolant:gu,RED_GREEN_RGTC2_Format:pe,RED_RGTC1_Format:36283,REVISION:B,RGBADepthPacking:3201,RGBAFormat:It,RGBAIntegerFormat:Ft,RGBA_ASTC_10x10_Format:ae,RGBA_ASTC_10x5_Format:ne,RGBA_ASTC_10x6_Format:se,RGBA_ASTC_10x8_Format:re,RGBA_ASTC_12x10_Format:oe,RGBA_ASTC_12x12_Format:le,RGBA_ASTC_4x4_Format:Zt,RGBA_ASTC_5x4_Format:Jt,RGBA_ASTC_5x5_Format:Kt,RGBA_ASTC_6x5_Format:$t,RGBA_ASTC_6x6_Format:Qt,RGBA_ASTC_8x5_Format:te,RGBA_ASTC_8x6_Format:ee,RGBA_ASTC_8x8_Format:ie,RGBA_BPTC_Format:he,RGBA_ETC2_EAC_Format:Yt,RGBA_PVRTC_2BPPV1_Format:qt,RGBA_PVRTC_4BPPV1_Format:Wt,RGBA_S3TC_DXT1_Format:zt,RGBA_S3TC_DXT3_Format:kt,RGBA_S3TC_DXT5_Format:Vt,RGB_BPTC_SIGNED_Format:ce,RGB_BPTC_UNSIGNED_Format:ue,RGB_ETC1_Format:Xt,RGB_ETC2_Format:jt,RGB_PVRTC_2BPPV1_Format:Ht,RGB_PVRTC_4BPPV1_Format:Gt,RGB_S3TC_DXT1_Format:Bt,RGFormat:1030,RGIntegerFormat:Ot,RawShaderMaterial:jc,Ray:pn,Raycaster:class{constructor(t,e,i=0,n=1/0){this.ray=new pn(t,e),this.near=i,this.far=n,this.camera=null,this.layers=new Tn,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 Ld(t,this,i,e),i.sort(Pd),i}intersectObjects(t,e=!0,i=[]){for(let n=0,s=t.length;n<s;n++)Ld(t[n],this,i,e);return i.sort(Pd),i}},Rec709Primaries:Le,RectAreaLight:Xu,RedFormat:1028,RedIntegerFormat:Ut,ReinhardToneMapping:2,RenderTarget:Ii,RepeatWrapping:mt,ReplaceStencilOp:7681,ReverseSubtractEquation:102,RingGeometry:Oc,SIGNED_RED_GREEN_RGTC2_Format:me,SIGNED_RED_RGTC1_Format:de,SRGBColorSpace:Te,SRGBTransfer:Pe,Scene:Zo,ShaderChunk:pr,ShaderLib:fr,ShaderMaterial:Js,ShadowMaterial:Xc,Shape:sc,ShapeGeometry:Fc,ShapePath:class{constructor(){this.type="ShapePath",this.color=new is,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new qh,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=Rc.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 sc,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 sc,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 sc;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:Rc,ShortType:1011,Skeleton:Il,SkeletonHelper:class extends mh{constructor(t){const e=zd(t),i=new Ts,n=[],s=[],r=new is(0,0,1),a=new is(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 _s(n,3)),i.setAttribute("color",new _s(s,3)),super(i,new rh({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");Bd.copy(this.root.matrixWorld).invert();for(let s=0,r=0;s<e.length;s++){const t=e[s];t.parent&&t.parent.isBone&&(Fd.multiplyMatrices(Bd,t.matrixWorld),Od.setFromMatrixPosition(Fd),n.setXYZ(r,Od.x,Od.y,Od.z),Fd.multiplyMatrices(Bd,t.parent.matrixWorld),Od.setFromMatrixPosition(Fd),n.setXYZ(r+1,Od.x,Od.y,Od.z),r+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(t)}dispose(){this.geometry.dispose(),this.material.dispose()}},SkinnedMesh:Al,Source:Ai,Sphere:rn,SphereGeometry:Bc,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(Qe(e/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}},SphericalHarmonics3:ju,SplineCurve:Gh,SpotLight:Fu,SpotLightHelper:class extends zn{constructor(t,e){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const i=new Ts,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 _s(n,3));const s=new rh({fog:!1,toneMapped:!1});this.cone=new mh(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),Ud.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Ud),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},Sprite:pl,SpriteMaterial:Qo,SrcAlphaFactor:Z,SrcAlphaSaturateFactor:210,SrcColorFactor:202,StaticCopyUsage:35046,StaticDrawUsage:Ge,StaticReadUsage:35045,StereoCamera:class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new $s,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new $s,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,ad.copy(t.projectionMatrix);const i=e.eyeSep/2,n=i*e.near/e.focus,s=e.near*Math.tan(Je*e.fov*.5)/e.zoom;let r,a;rd.elements[12]=-i,sd.elements[12]=i,r=-s*e.aspect+n,a=s*e.aspect+n,ad.elements[0]=2*e.near/(a-r),ad.elements[8]=(a+r)/(a-r),this.cameraL.projectionMatrix.copy(ad),r=-s*e.aspect-n,a=s*e.aspect-n,ad.elements[0]=2*e.near/(a-r),ad.elements[8]=(a+r)/(a-r),this.cameraR.projectionMatrix.copy(ad)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(rd),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(sd)}},StreamCopyUsage:35042,StreamDrawUsage:35040,StreamReadUsage:35041,StringKeyframeTrack:vu,SubtractEquation:101,SubtractiveBlending:3,TOUCH:{ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},TangentSpaceNormalMap:0,TetrahedronGeometry:zc,Texture:Pi,TextureLoader:class extends Tu{constructor(t){super(t)}load(t,e,i,n){const s=new Pi,r=new Ru(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:kc,TorusKnotGeometry:Vc,Triangle:Kn,TriangleFanDrawMode:2,TriangleStripDrawMode:1,TrianglesDrawMode:0,TubeGeometry:Gc,TwoPassDoubleSide:2,UVMapping:lt,Uint16BufferAttribute:fs,Uint32BufferAttribute:gs,Uint8BufferAttribute:class extends ms{constructor(t,e,i){super(new Uint8Array(t),e,i)}},Uint8ClampedBufferAttribute:class extends ms{constructor(t,e,i){super(new Uint8ClampedArray(t),e,i)}},Uniform:Cd,UniformsGroup:class extends je{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:Rd++}),this.name="",this.usage=Ge,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:mr,UniformsUtils:Zs,UnsignedByteType:St,UnsignedInt248Type:Lt,UnsignedIntType:Et,UnsignedShort4444Type:Rt,UnsignedShort5551Type:Pt,UnsignedShortType:wt,VSMShadowMap:3,Vector2:oi,Vector3:Fi,Vector4:Li,VectorKeyframeTrack:yu,VideoTexture:class extends Pi{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:xt,this.magFilter=void 0!==s?s:xt,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:Xo,WebGL3DRenderTarget:class extends Di{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new Ui(null,t,e,i),this.texture.isRenderTargetTexture=!0}},WebGLArrayRenderTarget:class extends Di{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new Ni(null,t,e,i),this.texture.isRenderTargetTexture=!0}},WebGLCoordinateSystem:qe,WebGLCubeRenderTarget:ir,WebGLMultipleRenderTargets:class extends Di{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:Di,WebGLRenderer:qo,WebGLUtils:Fo,WebGPUCoordinateSystem:Xe,WireframeGeometry:Hc,WrapAroundEnding:xe,ZeroCurvatureEnding:ve,ZeroFactor:200,ZeroSlopeEnding:ye,ZeroStencilOp:0,_SRGBAFormat:We,createCanvasElement:mi,sRGBEncoding:Se},Symbol.toStringTag,{value:"Module"}));t.EasterEggQuest=F,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={});
|