@albi_scando/as-design-system-threejs-lib 1.1.13 → 1.1.14

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.
@@ -17,7 +17,7 @@
17
17
  </svg>`}.CUSTOM_CROSSHAIR)}`;const xa={ANY:"any",NONE:"none"},Bl={KEY_DOWN:"keydown"},Ki={CLICK:"click"},Gc=`<button part="button">
18
18
  <slot></slot>
19
19
  </button>
20
- `,Hc="*{box-sizing:border-box}:where(button,input[type=button],input[type=submit],input[type=reset]),:where(input[type=file])::file-selector-button{cursor:pointer;-webkit-user-select:none;user-select:none;font-size:var(--font-size-sm);font-weight:var(--font-weight-semibold);font-family:var(--font-family-base);letter-spacing:var(--letter-spacing-wide);line-height:var(--line-height-normal);padding-block:var(--button-padding-block-md);padding-inline:var(--button-padding-inline-md);display:inline-flex;justify-content:center;align-items:center;text-align:center;gap:var(--gap-sm);background:var(--color-bg-secondary);color:var(--color-text-primary);border:var(--border-width-1) solid var(--color-border-secondary);border-radius:var(--border-radius-lg);box-shadow:var(--shadow-sm);transition:background var(--transition-fast),border-color var(--transition-fast),box-shadow var(--transition-fast),transform var(--transition-fast),filter var(--transition-fast)}:where(button,input[type=button],input[type=submit],input[type=reset])>.material-symbols-outlined{font-size:var(--font-size-xl);font-family:Material Symbols Outlined;line-height:1}:where(button,input[type=button],input[type=submit],input[type=reset])[disabled]{opacity:.35;cursor:not-allowed;box-shadow:none}:where(button,input[type=button],input[type=submit],input[type=reset]):where(:not(:disabled):hover){background:var(--color-hover-bg-secondary);border-color:var(--color-hover-border-secondary);box-shadow:var(--shadow-md);transform:translateY(-1px)}:where(button,input[type=button],input[type=submit],input[type=reset]):where(:not(:disabled):active){background:var(--color-hover-bg-secondary);border-color:var(--color-hover-border-secondary);box-shadow:var(--shadow-sm);transform:translateY(0)}:where(button,input[type=button],input[type=submit],input[type=reset]):focus-visible{outline:2px solid var(--color-primary);outline-offset:3px}:where(input[type=file]){inline-size:100%;max-inline-size:max-content;background-color:var(--color-bg-secondary)}",Ul=new CSSStyleSheet;Ul.replaceSync(Hc);class Ht extends HTMLElement{static autofocusAttribute="autofocus";static commandAttribute="command";static commandforAttribute="commandfor";static disabledAttribute="disabled";static nameAttribute="name";static titleAttribute="title";static typeAttribute="type";static valueAttribute="value";constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot?.adoptedStyleSheets.push(Ul)}static get observedAttributes(){return[Ht.autofocusAttribute,Ht.commandAttribute,Ht.commandforAttribute,Ht.disabledAttribute,Ht.nameAttribute,Ht.titleAttribute,Ht.typeAttribute,Ht.valueAttribute]}get buttonElement(){return this.shadowRoot?.querySelector("button")}get autofocus(){return this.hasAttribute(Ht.autofocusAttribute)}set autofocus(t){t?this.setAttribute(Ht.autofocusAttribute,Ae):this.removeAttribute(Ht.autofocusAttribute)}get command(){return this.getAttribute(Ht.commandAttribute)??Ae}set command(t){this.setAttribute(Ht.commandAttribute,t)}get commandfor(){return this.getAttribute(Ht.commandforAttribute)??Ae}set commandfor(t){t!==Ae?this.setAttribute(Ht.commandforAttribute,t):this.removeAttribute(Ht.commandforAttribute)}get disabled(){return this.hasAttribute(Ht.disabledAttribute)}set disabled(t){t?this.setAttribute(Ht.disabledAttribute,Ae):this.removeAttribute(Ht.disabledAttribute)}get name(){return this.getAttribute(Ht.nameAttribute)??Ae}set name(t){t!==Ae?this.setAttribute(Ht.nameAttribute,t):this.removeAttribute(Ht.nameAttribute)}get headline(){return this.getAttribute(Ht.titleAttribute)??Ae}set headline(t){t!==Ae?this.setAttribute(Ht.titleAttribute,t):this.removeAttribute(Ht.titleAttribute)}get type(){return this.getAttribute(Ht.typeAttribute)??"button"}set type(t){t!==Ae?this.setAttribute(Ht.typeAttribute,t):this.removeAttribute(Ht.typeAttribute)}get value(){return this.getAttribute(Ht.valueAttribute)??"button"}set value(t){t!==Ae?this.setAttribute(Ht.valueAttribute,t):this.removeAttribute(Ht.valueAttribute)}connectedCallback(){this._render(),this._addEventListeners()}disconnectedCallback(){this._removeEventListeners()}attributeChangedCallback(t,e,i){i!==e&&this._syncAttribute(t)}_render(){this.shadowRoot!==null&&(this.shadowRoot.innerHTML=Gc,this._syncAttributes())}_addEventListeners(){this.buttonElement.addEventListener(Ki.CLICK,this._handleClick)}_removeEventListeners(){this.buttonElement.addEventListener(Ki.CLICK,this._handleClick)}_handleClick=()=>{if(this.command===Ae||this.commandfor===Ae)return;let t=document.getElementById(this.commandfor);if(t??=this._findElementInShadowDOM(this.commandfor),t===null)return;const e=t;switch(this.command){case Ol.SHOW_MODAL:e.showModal?.();break;case Ol.CLOSE:e.close?.();break}};_findElementInShadowDOM(t){const e=`#${CSS.escape(t)}`;let i=this.querySelector(e);if(i!==null||(i=this._searchInShadowRootsOfChildren(this,e),i!==null))return i;let n=this.parentElement;for(;n!==null;){if(i=n.querySelector(e),i!==null||(i=this._searchInShadowRootsOfChildren(n,e),i!==null))return i;const s=n.parentElement;if(s!==null)n=s;else{const a=n.getRootNode();if(a instanceof ShadowRoot&&a.host!==null)n=a.host;else break}}return null}_searchInShadowRootsOfChildren(t,e){const i=t.children;for(const n of i){if(n.shadowRoot!==null){const a=n.shadowRoot.querySelector(e);if(a!==null)return a;const o=this._searchInShadowRootsOfChildren(n.shadowRoot,e);if(o!==null)return o}const s=this._searchInShadowRootsOfChildren(n,e);if(s!==null)return s}return null}_syncAttribute(t){const e=this.buttonElement;e!==null&&(this.hasAttribute(t)?e.setAttribute(t,this.getAttribute(t)??Ae):e.removeAttribute(t))}_syncAttributes(){Ht.observedAttributes.forEach(t=>{this._syncAttribute(t)})}}const zl=Object.freeze(Object.defineProperty({__proto__:null,BaseButtonComponent:Ht,selector:kc},Symbol.toStringTag,{value:"Module"}));new CSSStyleSheet().replaceSync("*{box-sizing:border-box}button[part=button]{background:var(--color-warning);font-weight:var(--font-weight-medium);padding-block:var(--button-padding-block-md);padding-inline:var(--button-padding-inline-md);border-radius:var(--border-radius-lg);border:none;box-shadow:var(--shadow-md);transition:all var(--transition-base);cursor:pointer;display:flex;align-items:center;justify-content:center;gap:var(--gap-sm)}button[part=button]:hover{filter:brightness(1.2)}");const kl="undo-button";new CSSStyleSheet().replaceSync("*{box-sizing:border-box}button[part=button]{background:var(--color-success);font-weight:var(--font-weight-medium);padding-block:var(--button-padding-block-md);padding-inline:var(--button-padding-inline-md);border-radius:var(--border-radius-lg);border:none;box-shadow:var(--shadow-md);transition:all var(--transition-base);cursor:pointer;display:flex;align-items:center;justify-content:center;gap:var(--gap-sm)}button[part=button]:hover{filter:brightness(1.2)}");const Gl="confirm-button";new CSSStyleSheet().replaceSync("*{box-sizing:border-box}button[part=button]{border:none;background:transparent}button[part=button]:not(:disabled):hover{transform:scale(1.2)}"),new CSSStyleSheet().replaceSync("*{box-sizing:border-box}button[part=button]{border:none;background:transparent}button[part=button]:not(:disabled):hover{transform:scale(1.2)}");const Vc=`<dialog part="dialog">
20
+ `,Hc="*{box-sizing:border-box}:host{display:inline-flex;vertical-align:middle}:where(button,input[type=button],input[type=submit],input[type=reset]),:where(input[type=file])::file-selector-button{cursor:pointer;-webkit-user-select:none;user-select:none;font-size:var(--font-size-sm);font-weight:var(--font-weight-semibold);font-family:var(--font-family-base);letter-spacing:var(--letter-spacing-wide);line-height:var(--line-height-normal);padding-block:var(--button-padding-block-md);padding-inline:var(--button-padding-inline-md);display:inline-flex;justify-content:center;align-items:center;text-align:center;gap:var(--gap-sm);background:var(--color-bg-secondary);color:var(--color-text-primary);border:var(--border-width-1) solid var(--color-border-secondary);border-radius:var(--border-radius-lg);box-shadow:var(--shadow-sm);transition:background var(--transition-fast),border-color var(--transition-fast),box-shadow var(--transition-fast),transform var(--transition-fast),filter var(--transition-fast)}:where(button,input[type=button],input[type=submit],input[type=reset])>.material-symbols-outlined{font-size:var(--font-size-xl);font-family:Material Symbols Outlined;line-height:1}:where(button,input[type=button],input[type=submit],input[type=reset])[disabled]{opacity:.35;cursor:not-allowed;box-shadow:none}:where(button,input[type=button],input[type=submit],input[type=reset]):where(:not(:disabled):hover){background:var(--color-hover-bg-secondary);border-color:var(--color-hover-border-secondary);box-shadow:var(--shadow-md)}:where(button,input[type=button],input[type=submit],input[type=reset]):where(:not(:disabled):active){background:var(--color-hover-bg-secondary);border-color:var(--color-hover-border-secondary);box-shadow:var(--shadow-sm)}:where(button,input[type=button],input[type=submit],input[type=reset]):focus-visible{outline:2px solid var(--color-primary);outline-offset:3px}:where(input[type=file]){inline-size:100%;max-inline-size:max-content;background-color:var(--color-bg-secondary)}",Ul=new CSSStyleSheet;Ul.replaceSync(Hc);class zt extends HTMLElement{static autofocusAttribute="autofocus";static commandAttribute="command";static commandforAttribute="commandfor";static disabledAttribute="disabled";static nameAttribute="name";static titleAttribute="title";static typeAttribute="type";static valueAttribute="value";constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot?.adoptedStyleSheets.push(Ul)}static get observedAttributes(){return[zt.autofocusAttribute,zt.commandAttribute,zt.commandforAttribute,zt.disabledAttribute,zt.nameAttribute,zt.titleAttribute,zt.typeAttribute,zt.valueAttribute]}get buttonElement(){return this.shadowRoot?.querySelector("button")}get autofocus(){return this.hasAttribute(zt.autofocusAttribute)}set autofocus(t){t?this.setAttribute(zt.autofocusAttribute,Ae):this.removeAttribute(zt.autofocusAttribute)}get command(){return this.getAttribute(zt.commandAttribute)??Ae}set command(t){this.setAttribute(zt.commandAttribute,t)}get commandfor(){return this.getAttribute(zt.commandforAttribute)??Ae}set commandfor(t){t!==Ae?this.setAttribute(zt.commandforAttribute,t):this.removeAttribute(zt.commandforAttribute)}get disabled(){return this.hasAttribute(zt.disabledAttribute)}set disabled(t){t?this.setAttribute(zt.disabledAttribute,Ae):this.removeAttribute(zt.disabledAttribute)}get name(){return this.getAttribute(zt.nameAttribute)??Ae}set name(t){t!==Ae?this.setAttribute(zt.nameAttribute,t):this.removeAttribute(zt.nameAttribute)}get headline(){return this.getAttribute(zt.titleAttribute)??Ae}set headline(t){t!==Ae?this.setAttribute(zt.titleAttribute,t):this.removeAttribute(zt.titleAttribute)}get type(){return this.getAttribute(zt.typeAttribute)??"button"}set type(t){t!==Ae?this.setAttribute(zt.typeAttribute,t):this.removeAttribute(zt.typeAttribute)}get value(){return this.getAttribute(zt.valueAttribute)??"button"}set value(t){t!==Ae?this.setAttribute(zt.valueAttribute,t):this.removeAttribute(zt.valueAttribute)}connectedCallback(){this._render(),this._addEventListeners()}disconnectedCallback(){this._removeEventListeners()}attributeChangedCallback(t,e,i){i!==e&&this._syncAttribute(t)}_render(){this.shadowRoot!==null&&(this.shadowRoot.innerHTML=Gc,this._syncAttributes())}_addEventListeners(){this.buttonElement?.addEventListener(Ki.CLICK,this._handleClick)}_removeEventListeners(){this.buttonElement?.removeEventListener(Ki.CLICK,this._handleClick)}_handleClick=()=>{if(this.command===Ae||this.commandfor===Ae)return;let t=document.getElementById(this.commandfor);if(t??=this._findElementInShadowDOM(this.commandfor),t===null)return;const e=t;switch(this.command){case Ol.SHOW_MODAL:e.showModal?.();break;case Ol.CLOSE:e.close?.();break}};_findElementInShadowDOM(t){const e=`#${CSS.escape(t)}`;let i=this.querySelector(e);if(i!==null||(i=this._searchInShadowRootsOfChildren(this,e),i!==null))return i;let n=this.parentElement;for(;n!==null;){if(i=n.querySelector(e),i!==null||(i=this._searchInShadowRootsOfChildren(n,e),i!==null))return i;const s=n.parentElement;if(s!==null)n=s;else{const a=n.getRootNode();if(a instanceof ShadowRoot&&a.host!==null)n=a.host;else break}}return null}_searchInShadowRootsOfChildren(t,e){const i=t.children;for(const n of i){if(n.shadowRoot!==null){const a=n.shadowRoot.querySelector(e);if(a!==null)return a;const o=this._searchInShadowRootsOfChildren(n.shadowRoot,e);if(o!==null)return o}const s=this._searchInShadowRootsOfChildren(n,e);if(s!==null)return s}return null}_syncAttribute(t){const e=this.buttonElement;e!==null&&(t===zt.commandAttribute||t===zt.commandforAttribute||(this.hasAttribute(t)?e.setAttribute(t,this.getAttribute(t)??Ae):e.removeAttribute(t)))}_syncAttributes(){zt.observedAttributes.forEach(t=>{this._syncAttribute(t)})}}const zl=Object.freeze(Object.defineProperty({__proto__:null,BaseButtonComponent:zt,selector:kc},Symbol.toStringTag,{value:"Module"}));new CSSStyleSheet().replaceSync("*{box-sizing:border-box}:host{display:inline-flex;vertical-align:middle}button[part=button]{background:var(--color-warning);font-weight:var(--font-weight-medium);padding-block:var(--button-padding-block-md);padding-inline:var(--button-padding-inline-md);border-radius:var(--border-radius-lg);border:none;box-shadow:var(--shadow-md);transition:all var(--transition-base);cursor:pointer;display:flex;align-items:center;justify-content:center;gap:var(--gap-sm)}button[part=button]:hover{filter:brightness(1.2)}");const kl="undo-button";new CSSStyleSheet().replaceSync("*{box-sizing:border-box}:host{position:relative;display:inline-flex;vertical-align:middle}.tooltip{position:absolute;top:auto;bottom:calc(100% + .5rem);left:50%;right:auto;transform:translate(-50%);width:max-content;height:auto;padding:var(--spacing-1) var(--spacing-2);background-color:var(--color-bg-tertiary, #1e1e2e);color:var(--color-text-primary);font-family:var(--font-family-base);font-size:var(--font-size-xs);border-radius:var(--border-radius-md);box-shadow:var(--shadow-lg);white-space:nowrap;pointer-events:none;opacity:0;visibility:hidden;transition:opacity var(--transition-fast),visibility var(--transition-fast);z-index:10000;margin:0}button[part=button]{background:var(--color-error);border:none;border-radius:var(--border-radius-md);padding:var(--spacing-2);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;aspect-ratio:1;transition:all var(--transition-base);box-shadow:var(--shadow-md);position:relative}button[part=button]:hover{filter:brightness(1.2)}:host(:hover) .tooltip{opacity:1;visibility:visible}"),new CSSStyleSheet().replaceSync("*{box-sizing:border-box}:host{display:inline-flex;vertical-align:middle}button[part=button]{background:var(--color-success);font-weight:var(--font-weight-medium);padding-block:var(--button-padding-block-md);padding-inline:var(--button-padding-inline-md);border-radius:var(--border-radius-lg);border:none;box-shadow:var(--shadow-md);transition:all var(--transition-base);cursor:pointer;display:flex;align-items:center;justify-content:center;gap:var(--gap-sm)}button[part=button]:hover{filter:brightness(1.2)}");const Gl="confirm-button";new CSSStyleSheet().replaceSync("*{box-sizing:border-box}:host{display:inline-flex;vertical-align:middle}button[part=button]{border:none;background:transparent}button[part=button]:not(:disabled):hover{transform:scale(1.2)}"),new CSSStyleSheet().replaceSync("*{box-sizing:border-box}:host{display:inline-flex;vertical-align:middle}button[part=button]{border:none;background:transparent}button[part=button]:not(:disabled):hover{transform:scale(1.2)}");const Vc=`<dialog part="dialog">
21
21
  <slot></slot>
22
22
  </dialog>
23
23
  `,Wc="*{box-sizing:border-box}dialog{background-color:var(--color-bg-primary);color:var(--color-text-primary);border:var(--border-width-1) solid var(--color-border-secondary);border-radius:var(--border-radius-xl);padding:var(--spacing-4);font-family:var(--font-family-base);line-height:var(--line-height-normal);font-size:var(--font-size-sm);box-shadow:var(--shadow-2xl);-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);animation:slideIn var(--transition-base) cubic-bezier(.34,1.56,.64,1) forwards}dialog.closing{animation:slideOut var(--transition-base) cubic-bezier(.34,1.56,.64,1) forwards}dialog::backdrop{background:var(--window-backdrop);-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);animation:fadeIn var(--transition-base) ease-out forwards}dialog.closing::backdrop{animation:fadeOut var(--transition-base) ease-out forwards}@keyframes slideIn{0%{opacity:0;transform:scale(.95) translateY(-20px)}to{opacity:1;transform:scale(1) translateY(0)}}@keyframes slideOut{0%{opacity:1;transform:scale(1) translateY(0)}to{opacity:0;transform:scale(.95) translateY(-20px)}}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes fadeOut{0%{opacity:1}to{opacity:0}}",Hl=new CSSStyleSheet;Hl.replaceSync(Wc);class Cn extends HTMLElement{static closedByAttribute="closedby";_closedBy=xa.ANY;constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot?.adoptedStyleSheets.push(Hl)}static get observedAttributes(){return[Cn.closedByAttribute]}get dialogElement(){return this.shadowRoot?.querySelector("dialog")}get command(){return this.getAttribute(Cn.closedByAttribute)??xa.ANY}get closedBy(){return this._closedBy}set closedBy(t){this._closedBy=t,this.setAttribute(Cn.closedByAttribute,t)}connectedCallback(){this._render(),this._addEventListeners()}disconnectedCallback(){this._removeEventListeners()}attributeChangedCallback(t,e,i){this.dialogElement!=null&&i!==e&&this._syncAttribute(t)}_addEventListeners(){}_removeEventListeners(){}_render(){this.shadowRoot!==null&&(this.shadowRoot.innerHTML=Vc,this._syncAttributes())}_syncAttribute(t){const e=this.dialogElement;e!=null&&(this.hasAttribute(t)===!0?e.setAttribute(t,this.getAttribute(t)??Ae):e.removeAttribute(t))}_syncAttributes(){Cn.observedAttributes.forEach(t=>{this._syncAttribute(t)})}show(){this.dialogElement.show()}showModal(){this.dialogElement.showModal()}close(t){const e=this.dialogElement;e.classList.add("closing"),setTimeout(()=>{e.close(t),e.classList.remove("closing")},300)}}const Yc=`<dialog part="dialog">
@@ -52,7 +52,7 @@
52
52
 
53
53
  <next-button class="nav-next" part="nav-next-button"></next-button>
54
54
  </div>
55
- `,Kc="*{box-sizing:border-box}:host{display:block;width:100%}.bar-menu-container{display:flex;align-items:center;justify-content:space-between;height:100%;gap:var(--gap-sm);padding:var(--spacing-1);background:var(--color-bg-primary);border-radius:var(--border-radius-full);border:var(--border-width-2) solid var(--color-border-secondary);box-shadow:var(--shadow-sm);margin:0 auto}.bar-menu-container .nav-prev,.bar-menu-container .nav-next{flex-shrink:0;opacity:0;visibility:hidden;pointer-events:none;transition:opacity .2s ease-in-out,visibility .2s ease-in-out}.bar-menu-container .nav-prev.visible,.bar-menu-container .nav-next.visible{opacity:1;visibility:visible;pointer-events:auto}.bar-menu-container .nav-prev::part(button),.bar-menu-container .nav-next::part(button){background-color:transparent;box-shadow:none}.bar-menu-container .buttons-wrapper{display:grid;grid-template-columns:repeat(var(--bar-menu-visible-count, 3),1fr);grid-auto-rows:max-content;align-items:center;justify-items:center;gap:var(--gap-sm);overflow:hidden;position:relative;width:auto}::slotted(*){display:none;flex-shrink:0;will-change:opacity,transform;contain:layout style paint;opacity:0;transform:scale(.8)}::slotted(.animating){transition:opacity .4s cubic-bezier(.34,1.56,.64,1),transform .4s cubic-bezier(.34,1.56,.64,1)}::slotted(.visible-button){display:inline-flex!important;pointer-events:auto;opacity:1;transform:scale(1)}",Xl=new CSSStyleSheet;Xl.replaceSync(Kc);class ni extends HTMLElement{static _visibleCountAttribute="visible-count";static _cyclicalNavigationAttribute="cyclical-navigation";_currentIndex=0;_visibleCount=3;_cyclicalNavigation=!1;_MIN_VISIBLE=1;_MAX_VISIBLE=5;_slotElement=null;_navPrevButton=null;_navNextButton=null;_buttonsWrapper=null;_slotChangeListener=null;_keyDownListener=null;constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot?.adoptedStyleSheets.push(Xl)}static get observedAttributes(){return[ni._visibleCountAttribute,ni._cyclicalNavigationAttribute]}get visibleButtons(){const t=this.getAttribute(ni._visibleCountAttribute);if(t!==null&&t!==Ae){const e=parseInt(t,10);return Math.max(this._MIN_VISIBLE,Math.min(this._MAX_VISIBLE,e))}return this._visibleCount}set visibleButtons(t){const e=Math.max(this._MIN_VISIBLE,Math.min(this._MAX_VISIBLE,t));this.setAttribute(ni._visibleCountAttribute,String(e))}get cyclicalNavigation(){return this.hasAttribute(ni._cyclicalNavigationAttribute)}set cyclicalNavigation(t){t?this.setAttribute(ni._cyclicalNavigationAttribute,Ae):this.removeAttribute(ni._cyclicalNavigationAttribute)}connectedCallback(){this._render(),this._cacheElements(),this._setupSlotListener(),this._setupKeyboardListener(),this._updateButtonVisibility()}disconnectedCallback(){this._removeSlotListener(),this._removeKeyboardListener()}attributeChangedCallback(t,e,i){t===ni._visibleCountAttribute?(this._visibleCount=this.visibleButtons,this._buttonsWrapper!==null&&this._buttonsWrapper.style.setProperty("--bar-menu-visible-count",String(this.visibleButtons)),this._updateButtonVisibility()):t===ni._cyclicalNavigationAttribute&&(this._cyclicalNavigation=this.cyclicalNavigation,this._updateButtonVisibility())}_render(){this.shadowRoot!==null&&(this.shadowRoot.innerHTML=qc)}_cacheElements(){this._slotElement=this.shadowRoot?.querySelector("slot")??null,this._navPrevButton=this.shadowRoot?.querySelector(".nav-prev")??null,this._navNextButton=this.shadowRoot?.querySelector(".nav-next")??null,this._buttonsWrapper=this.shadowRoot?.querySelector(".buttons-wrapper")??null,this._buttonsWrapper!==null&&this._buttonsWrapper.style.setProperty("--bar-menu-visible-count",String(this.visibleButtons)),this._navPrevButton!==null&&(this._navPrevButton.setAttribute("aria-label","Previous"),this._navPrevButton.addEventListener(Ki.CLICK,()=>{this._scrollPrevious()})),this._navNextButton!==null&&(this._navNextButton.setAttribute("aria-label","Next"),this._navNextButton.addEventListener(Ki.CLICK,()=>{this._scrollNext()}))}_setupSlotListener(){this._slotElement!==null&&(this._slotChangeListener=()=>{this._currentIndex=0,this._updateButtonVisibility()},this._slotElement.addEventListener("slotchange",this._slotChangeListener))}_removeSlotListener(){this._slotElement!==null&&this._slotChangeListener!==null&&this._slotElement.removeEventListener("slotchange",this._slotChangeListener)}_setupKeyboardListener(){this._keyDownListener=t=>{t.key==="ArrowLeft"?(t.preventDefault(),this._scrollPrevious()):t.key==="ArrowRight"&&(t.preventDefault(),this._scrollNext())},this.addEventListener(Bl.KEY_DOWN,this._keyDownListener)}_removeKeyboardListener(){this._keyDownListener!==null&&this.removeEventListener(Bl.KEY_DOWN,this._keyDownListener)}_getSlottedButtons(){return this._slotElement===null?[]:this._slotElement.assignedElements()}_updateButtonVisibility(t){const e=this._getSlottedButtons(),i=e.length,n=this.visibleButtons,s=this._currentIndex,a=Math.min(s+n,i);e.forEach((o,A)=>{const l=A>=s&&A<a,h=o;l||(o.classList.remove("visible-button"),o.classList.remove("animating"),h.style.display="none")}),t!==void 0?(e[0]?.offsetHeight,e.forEach((o,A)=>{if(A>=s&&A<a){const l=o;l.style.display="inline-flex",o.classList.add("animating");const h=A%this.visibleButtons*50;l.style.transitionDelay=`${h}ms`}}),e[0]?.offsetHeight,e.forEach((o,A)=>{A>=s&&A<a&&o.classList.add("visible-button")}),setTimeout(()=>{e.forEach(o=>{o.classList.remove("animating"),o.style.transitionDelay=Ae})},400)):e.forEach((o,A)=>{const l=A>=s&&A<a,h=o;l&&(h.style.display="inline-flex",o.classList.add("visible-button"))}),this._updateNavigationButtons(i,n)}_updateNavigationButtons(t,e){const i=t>e,n=this._currentIndex+e<t,s=this._currentIndex===0,a=!n;this._navPrevButton!==null&&(i?(this._navPrevButton.classList.add("visible"),this._navPrevButton.disabled=!this._cyclicalNavigation&&s):this._navPrevButton.classList.remove("visible")),this._navNextButton!==null&&(i?(this._navNextButton.classList.add("visible"),this._navNextButton.disabled=!this._cyclicalNavigation&&a):this._navNextButton.classList.remove("visible"))}_scrollPrevious(){const t=this._getSlottedButtons().length,e=this.visibleButtons;this._currentIndex>0?(this._currentIndex=Math.max(0,this._currentIndex-e),this._updateButtonVisibility("previous")):this._cyclicalNavigation&&t>e&&(this._currentIndex=Math.max(0,t-e),this._updateButtonVisibility("previous"))}_scrollNext(){const t=this._getSlottedButtons().length,e=this.visibleButtons,i=this._currentIndex+e;i<t?(this._currentIndex=i,this._updateButtonVisibility("next")):this._cyclicalNavigation&&t>e&&(this._currentIndex=0,this._updateButtonVisibility("next"))}scrollToButton(t){const e=this._getSlottedButtons().length,i=this.visibleButtons;t>=0&&t<e&&(this._currentIndex=Math.max(0,Math.min(t,e-i)),this._updateButtonVisibility())}getVisibleButtons(){return this._getSlottedButtons().filter(t=>t.classList.contains("visible-button"))}getAllButtons(){return this._getSlottedButtons()}getCurrentIndex(){return this._currentIndex}}const $c="bar-menu",tu=Object.freeze(Object.defineProperty({__proto__:null,BarMenuComponent:ni,selector:$c},Symbol.toStringTag,{value:"Module"}));new CSSStyleSheet().replaceSync("*{box-sizing:border-box}:host{display:inline-flex;align-items:center;justify-content:center}.spinner{display:inline-flex;align-items:center;justify-content:center}.spinner-ring{width:var(--spinner-size, 2rem);height:var(--spinner-size, 2rem);border:3px solid var(--color-border-primary);border-top-color:var(--color-primary);border-radius:var(--border-radius-full);animation:spin var(--transition-slow) linear infinite}:host([size=sm]) .spinner-ring{width:1rem;height:1rem;border-width:2px}:host([size=md]) .spinner-ring{width:2rem;height:2rem;border-width:3px}:host([size=lg]) .spinner-ring{width:3rem;height:3rem;border-width:4px}:host([variant=primary]) .spinner-ring{border-top-color:var(--color-primary)}:host([variant=success]) .spinner-ring{border-top-color:var(--color-success)}:host([variant=warning]) .spinner-ring{border-top-color:var(--color-warning)}:host([variant=error]) .spinner-ring{border-top-color:var(--color-error)}@keyframes spin{to{transform:rotate(360deg)}}"),new CSSStyleSheet().replaceSync("*{box-sizing:border-box}:host{display:block;width:100%}.progress-container{display:flex;flex-direction:column;gap:var(--gap-xs)}.progress-track{width:100%;height:.5rem;background-color:var(--color-bg-secondary);border-radius:var(--border-radius-full);overflow:hidden;border:1px solid var(--color-border-primary)}:host([size=sm]) .progress-track{height:.25rem}:host([size=md]) .progress-track{height:.5rem}:host([size=lg]) .progress-track{height:1rem}.progress-fill{height:100%;width:0%;background:var(--color-primary);border-radius:var(--border-radius-full);transition:width var(--transition-base) ease}:host([variant=success]) .progress-fill{background:var(--color-success)}:host([variant=warning]) .progress-fill{background:var(--color-warning)}:host([variant=error]) .progress-fill{background:var(--color-error)}:host([variant=info]) .progress-fill{background:var(--color-info)}:host([indeterminate]) .progress-fill{width:40%!important;animation:indeterminate var(--transition-slow) ease-in-out infinite}.progress-label{font-family:var(--font-family-base);font-size:var(--font-size-xs);color:var(--color-text-secondary);align-self:flex-end}:host(:not([show-label])) .progress-label{display:none}@keyframes indeterminate{0%{transform:translate(-100%)}to{transform:translate(350%)}}"),new CSSStyleSheet().replaceSync("*{box-sizing:border-box}:host{display:block;width:100%}.skeleton{background:linear-gradient(90deg,var(--color-bg-secondary) 25%,var(--color-bg-tertiary) 50%,var(--color-bg-secondary) 75%);background-size:200% 100%;border-radius:var(--border-radius-md);animation:shimmer 1.5s infinite;min-height:1rem;width:100%}:host([shape=circle]) .skeleton{border-radius:var(--border-radius-full);width:var(--skeleton-size, 3rem);height:var(--skeleton-size, 3rem)}:host([shape=text]) .skeleton{border-radius:var(--border-radius-sm);height:1em}:host([shape=rect]) .skeleton{border-radius:var(--border-radius-md)}:host([width=full]){width:100%}:host([width=half]){width:50%}:host([width=quarter]){width:25%}:host([width=three-quarters]){width:75%}@keyframes shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}"),new CSSStyleSheet().replaceSync('*{box-sizing:border-box}:host{display:block}.card{background:var(--color-bg-secondary);border:1px solid var(--color-border-primary);border-radius:var(--border-radius-xl);box-shadow:var(--shadow-md);overflow:hidden;transition:box-shadow var(--transition-fast),transform var(--transition-fast),border-color var(--transition-fast);font-family:var(--font-family-base);color:var(--color-text-primary);position:relative}.card:before{content:"";display:block;height:2px;background:linear-gradient(90deg,var(--color-primary) 0%,var(--color-primary-light) 100%);opacity:0;transition:opacity var(--transition-fast)}:host([hoverable]) .card:hover{box-shadow:var(--shadow-xl);transform:translateY(-3px);border-color:var(--color-border-secondary)}:host([hoverable]) .card:hover:before{opacity:1}:host([variant=outlined]) .card{background:transparent;box-shadow:none;border:var(--border-width-2) solid var(--color-border-secondary)}:host([variant=elevated]) .card{background:var(--color-bg-primary);box-shadow:var(--shadow-xl);border:none}:host([variant=filled]) .card{background:var(--color-bg-secondary);border:none;box-shadow:none}.card-body{padding:var(--spacing-4) var(--spacing-5)}::slotted([slot=header]){display:block;padding:var(--spacing-5) var(--spacing-5) var(--spacing-2);font-size:var(--font-size-lg);font-weight:var(--font-weight-bold);color:var(--color-text-primary);letter-spacing:var(--letter-spacing-tight)}::slotted([slot=footer]){display:block;padding:var(--spacing-3) var(--spacing-5) var(--spacing-4);font-size:var(--font-size-sm);color:var(--color-text-secondary);border-top:1px solid var(--color-border-primary)}'),new CSSStyleSheet().replaceSync("*{box-sizing:border-box}:host{display:inline-flex}.badge{display:inline-flex;align-items:center;justify-content:center;gap:var(--gap-xs);padding-block:.2em;padding-inline:.6em;border-radius:var(--border-radius-full);font-family:var(--font-family-base);font-size:var(--font-size-xs);font-weight:var(--font-weight-semibold);line-height:1.4;white-space:nowrap;background-color:var(--color-primary);color:#fff;border:1px solid transparent}:host([variant=secondary]) .badge{background-color:var(--color-bg-secondary);color:var(--color-text-primary);border-color:var(--color-border-primary)}:host([variant=success]) .badge{background-color:var(--color-success);color:#fff}:host([variant=warning]) .badge{background-color:var(--color-warning);color:#1a1a1a}:host([variant=error]) .badge{background-color:var(--color-error);color:#fff}:host([variant=info]) .badge{background-color:var(--color-info);color:#fff}:host([variant=outline]) .badge{background-color:transparent;color:var(--color-primary);border-color:var(--color-primary)}:host([size=sm]) .badge{font-size:.65rem;padding-block:.1em;padding-inline:.4em}:host([size=lg]) .badge{font-size:var(--font-size-sm);padding-block:.3em;padding-inline:.8em}:host([dot]) .badge{width:.5rem;height:.5rem;padding:0;font-size:0}"),new CSSStyleSheet().replaceSync('@charset "UTF-8";*{box-sizing:border-box}:host{display:block}:host([hidden]){display:none}.alert{display:flex;align-items:center;gap:var(--gap-sm);padding:var(--spacing-3) var(--spacing-4);border-radius:var(--border-radius-lg);border-left:4px solid var(--color-primary);background-color:var(--color-bg-secondary);color:var(--color-text-primary);font-family:var(--font-family-base);font-size:var(--font-size-sm);line-height:var(--line-height-normal);animation:alertIn var(--transition-fast) ease-out}:host([variant=success]) .alert{border-left-color:#22c55e;background-color:#1a3f1f;color:#d1fae5}:host([variant=warning]) .alert{border-left-color:#facc15;background-color:#3f3011;color:#e0c600}:host([variant=error]) .alert{border-left-color:#dc2626;background-color:color-mix(in srgb,#dc2626 10%,var(--color-bg-primary))}:host([variant=info]) .alert{border-left-color:#9d4edd;background-color:color-mix(in srgb,#9d4edd 25%,var(--color-bg-primary));color:var(--color-text-primary)}.alert-icon{font-size:var(--font-size-lg);flex-shrink:0;display:flex;align-items:center;justify-content:center;min-width:1.25em;height:1.25em}:host([variant=success]) .alert-icon:before{content:"✓"}:host([variant=warning]) .alert-icon:before{content:"⚠"}:host([variant=error]) .alert-icon:before{content:"✕"}:host([variant=info]) .alert-icon:before{content:"ℹ"}.alert-content{flex:1;min-width:0}::slotted([slot=title]){display:block;font-weight:var(--font-weight-semibold);font-size:var(--font-size-md);margin-bottom:var(--spacing-1)}.alert-close{flex-shrink:0;background:transparent;border:none;cursor:pointer;padding:var(--spacing-1);border-radius:var(--border-radius-sm);color:var(--color-text-secondary);font-size:var(--font-size-md);line-height:1;display:flex;align-items:center;justify-content:center;transition:background var(--transition-fast),color var(--transition-fast)}.alert-close:hover{background:var(--color-hover-bg-secondary);color:var(--color-text-primary)}:host(:not([dismissible])) .alert-close{display:none}@keyframes alertIn{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}'),new CSSStyleSheet().replaceSync("*{box-sizing:border-box}:host{display:inline-flex}.tag{display:inline-flex;align-items:center;gap:var(--gap-xs);padding-block:.25em;padding-inline:.75em;border-radius:var(--border-radius-full);font-family:var(--font-family-base);font-size:var(--font-size-sm);font-weight:var(--font-weight-medium);background-color:var(--color-bg-secondary);color:var(--color-text-primary);border:1px solid var(--color-border-primary);transition:all var(--transition-fast)}:host([variant=primary]) .tag{background-color:var(--color-primary);color:#fff;border-color:transparent}:host([variant=success]) .tag{background-color:var(--color-success);color:#fff;border-color:transparent}:host([variant=warning]) .tag{background-color:var(--color-warning);color:#1a1a1a;border-color:transparent}:host([variant=error]) .tag{background-color:var(--color-error);color:#fff;border-color:transparent}:host([size=sm]) .tag{font-size:var(--font-size-xs);padding-block:.15em;padding-inline:.5em}:host([size=lg]) .tag{font-size:var(--font-size-md);padding-block:.35em;padding-inline:1em}.tag-remove{display:none;background:transparent;border:none;cursor:pointer;padding:0;font-size:.75em;color:inherit;opacity:.7;line-height:1;border-radius:var(--border-radius-full);transition:opacity var(--transition-fast)}:host([removable]) .tag-remove{display:inline-flex;align-items:center;justify-content:center}.tag-remove:hover{opacity:1}"),new CSSStyleSheet().replaceSync("*{box-sizing:border-box}:host{display:inline-flex}.avatar{position:relative;display:inline-flex;align-items:center;justify-content:center;width:2.5rem;height:2.5rem;border-radius:var(--border-radius-full);background-color:var(--color-primary);color:#fff;font-family:var(--font-family-base);font-weight:var(--font-weight-semibold);font-size:var(--font-size-sm);overflow:hidden;-webkit-user-select:none;user-select:none;flex-shrink:0}:host([size=xs]) .avatar{width:1.5rem;height:1.5rem;font-size:var(--font-size-xs)}:host([size=sm]) .avatar{width:2rem;height:2rem;font-size:var(--font-size-xs)}:host([size=md]) .avatar{width:2.5rem;height:2.5rem;font-size:var(--font-size-sm)}:host([size=lg]) .avatar{width:3.5rem;height:3.5rem;font-size:var(--font-size-lg)}:host([size=xl]) .avatar{width:5rem;height:5rem;font-size:var(--font-size-2xl)}:host([shape=square]) .avatar{border-radius:var(--border-radius-md)}:host([shape=rounded]) .avatar{border-radius:var(--border-radius-lg)}:host([color=secondary]) .avatar{background-color:var(--color-bg-secondary);color:var(--color-text-primary);border:1px solid var(--color-border-primary)}:host([color=success]) .avatar{background-color:var(--color-success)}:host([color=warning]) .avatar{background-color:var(--color-warning);color:#1a1a1a}:host([color=error]) .avatar{background-color:var(--color-error)}.avatar-image{width:100%;height:100%;object-fit:cover;display:none;border-radius:inherit}.avatar-initials{display:none;line-height:1}.avatar-icon{display:flex;font-size:1.2em;line-height:1}:host([src]) .avatar-image{display:block}:host([src]) .avatar-initials{display:none}:host([src]) .avatar-icon{display:none}:host([initials]:not([src])) .avatar-initials{display:block}:host([initials]:not([src])) .avatar-icon{display:none}"),new CSSStyleSheet().replaceSync("*{box-sizing:border-box}:host{position:relative;display:inline-flex;align-items:center}.tooltip{position:absolute;z-index:var(--z-index-tooltip, 1070);bottom:calc(100% + .5rem);left:50%;transform:translate(-50%);padding:var(--spacing-1) var(--spacing-2);background-color:var(--color-bg-tertiary, #1e1e2e);color:var(--color-text-primary);font-family:var(--font-family-base);font-size:var(--font-size-xs);line-height:var(--line-height-normal);border-radius:var(--border-radius-md);box-shadow:var(--shadow-lg);white-space:nowrap;pointer-events:none;opacity:0;visibility:hidden;transition:opacity var(--transition-fast),visibility var(--transition-fast);max-width:16rem;white-space:normal;text-align:center}:host([placement=bottom]) .tooltip{bottom:auto;top:calc(100% + .5rem)}:host([placement=left]) .tooltip{bottom:auto;left:auto;right:calc(100% + .5rem);top:50%;transform:translateY(-50%)}:host([placement=right]) .tooltip{bottom:auto;left:calc(100% + .5rem);top:50%;transform:translateY(-50%)}:host([open]) .tooltip,:host(:hover) .tooltip,:host(:focus-within) .tooltip{opacity:1;visibility:visible}:host([follow-cursor]) .tooltip{position:fixed;bottom:auto;left:0;top:0;transform:none}:host([follow-cursor]) .tooltip{opacity:1;visibility:visible}"),new CSSStyleSheet().replaceSync("*{box-sizing:border-box}:host{display:block;width:100%}.input-wrapper{display:flex;flex-direction:column;gap:var(--gap-xs);font-family:var(--font-family-base)}.input-label{font-size:var(--font-size-sm);font-weight:var(--font-weight-medium);color:var(--color-text-primary)}.input-label:empty{display:none}.input-container{display:flex;align-items:center;background-color:var(--color-bg-primary);border:1px solid var(--color-border-primary);border-radius:var(--border-radius-md);transition:border-color var(--transition-fast),box-shadow var(--transition-fast);overflow:hidden}.input-container:focus-within{border-color:var(--color-primary);box-shadow:0 0 0 3px color-mix(in srgb,var(--color-primary) 20%,transparent);outline:none}:host([state=error]) .input-container{border-color:#dc2626;box-shadow:none}:host([state=error]) .input-container:focus-within{box-shadow:0 0 0 3px color-mix(in srgb,#dc2626 20%,transparent)}:host([state=success]) .input-container{border-color:var(--color-success)}.input{flex:1;min-width:0;padding:var(--spacing-2) var(--spacing-3);background:transparent;border:none;outline:none;font-family:var(--font-family-base);font-size:var(--font-size-sm);color:var(--color-text-primary);line-height:var(--line-height-normal)}.input::placeholder{color:var(--color-text-secondary);opacity:.7}.input:disabled{opacity:.5;cursor:not-allowed}:host([size=sm]) .input{padding:var(--spacing-1) var(--spacing-2);font-size:var(--font-size-xs)}:host([size=lg]) .input{padding:var(--spacing-3) var(--spacing-4);font-size:var(--font-size-md)}.input-helper{font-size:var(--font-size-xs);color:var(--color-text-secondary)}.input-helper:empty{display:none}:host([state=error]) .input-helper{color:#dc2626}:host([state=success]) .input-helper{color:var(--color-success)}::slotted([slot=prefix]),::slotted([slot=suffix]){display:flex;align-items:center;padding-inline:var(--spacing-2);color:var(--color-text-secondary);font-size:var(--font-size-sm);flex-shrink:0}"),new CSSStyleSheet().replaceSync("*{box-sizing:border-box}:host{display:inline-flex}.toggle-wrapper{display:inline-flex;align-items:center;gap:var(--gap-sm);cursor:pointer;-webkit-user-select:none;user-select:none;font-family:var(--font-family-base);font-size:var(--font-size-sm);color:var(--color-text-primary)}.toggle-input{position:absolute;opacity:0;width:0;height:0}.toggle-track{position:relative;display:inline-flex;align-items:center;width:2.75rem;height:1.5rem;border-radius:var(--border-radius-full);background-color:var(--color-border-primary);transition:background-color var(--transition-fast);flex-shrink:0}.toggle-input:checked+.toggle-track{background-color:var(--color-primary)}.toggle-thumb{position:absolute;left:3px;width:1.125rem;height:1.125rem;border-radius:var(--border-radius-full);background-color:#fff;box-shadow:var(--shadow-sm);transition:transform var(--transition-fast)}.toggle-input:checked+.toggle-track .toggle-thumb{transform:translate(1.25rem)}.toggle-input:focus-visible+.toggle-track{outline:2px solid var(--color-primary);outline-offset:2px}.toggle-input:disabled+.toggle-track{opacity:.4;cursor:not-allowed}:host([disabled]) .toggle-wrapper{cursor:not-allowed;opacity:.5}:host([size=sm]) .toggle-track{width:2rem;height:1.125rem}:host([size=sm]) .toggle-thumb{width:.875rem;height:.875rem}:host([size=sm]) .toggle-input:checked+.toggle-track .toggle-thumb{transform:translate(.875rem)}:host([size=lg]) .toggle-track{width:3.5rem;height:2rem}:host([size=lg]) .toggle-thumb{width:1.5rem;height:1.5rem}:host([size=lg]) .toggle-input:checked+.toggle-track .toggle-thumb{transform:translate(1.5rem)}:host([variant=success]) .toggle-input:checked+.toggle-track{background-color:var(--color-success)}:host([variant=warning]) .toggle-input:checked+.toggle-track{background-color:var(--color-warning)}:host([variant=error]) .toggle-input:checked+.toggle-track{background-color:var(--color-error)}.toggle-label:empty{display:none}");const He="srgb",Zl="srgb-linear",Jl="linear",Ea="srgb";function eu(r){for(let t=r.length-1;t>=0;--t)if(r[t]>=65535)return!0;return!1}function jl(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}const Ql={};function ql(r){const t=r[0];if(typeof t=="string"&&t.startsWith("TSL:")){const e=r[1];e&&e.isStackTrace?r[0]+=" "+e.getLocation():r[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return r}function be(...r){r=ql(r);const t="THREE."+r.shift();{const e=r[0];e&&e.isStackTrace?console.warn(e.getError(t)):console.warn(t,...r)}}function vn(...r){r=ql(r);const t="THREE."+r.shift();{const e=r[0];e&&e.isStackTrace?console.error(e.getError(t)):console.error(t,...r)}}function Kl(...r){const t=r.join(" ");t in Ql||(Ql[t]=!0,be(...r))}class pr{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[t]===void 0&&(i[t]=[]),i[t].indexOf(e)===-1&&i[t].push(e)}hasEventListener(t,e){const i=this._listeners;return i===void 0?!1:i[t]!==void 0&&i[t].indexOf(e)!==-1}removeEventListener(t,e){const i=this._listeners;if(i===void 0)return;const n=i[t];if(n!==void 0){const s=n.indexOf(e);s!==-1&&n.splice(s,1)}}dispatchEvent(t){const e=this._listeners;if(e===void 0)return;const i=e[t.type];if(i!==void 0){t.target=this;const n=i.slice(0);for(let s=0,a=n.length;s<a;s++)n[s].call(this,t);t.target=null}}}const Me=["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"];function zs(){const r=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Me[r&255]+Me[r>>8&255]+Me[r>>16&255]+Me[r>>24&255]+"-"+Me[t&255]+Me[t>>8&255]+"-"+Me[t>>16&15|64]+Me[t>>24&255]+"-"+Me[e&63|128]+Me[e>>8&255]+"-"+Me[e>>16&255]+Me[e>>24&255]+Me[i&255]+Me[i>>8&255]+Me[i>>16&255]+Me[i>>24&255]).toLowerCase()}function kt(r,t,e){return Math.max(t,Math.min(e,r))}function iu(r,t){return(r%t+t)%t}function Sa(r,t,e){return(1-e)*r+e*t}function ks(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function Be(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}class Ve{constructor(t=0,e=0){Ve.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=kt(this.x,t.x,e.x),this.y=kt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=kt(this.x,t,e),this.y=kt(this.y,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(kt(i,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(kt(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,a=this.y-t.y;return this.x=s*i-a*n+t.x,this.y=s*n+a*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Gs{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,a,o){let A=i[n+0],l=i[n+1],h=i[n+2],c=i[n+3],u=s[a+0],d=s[a+1],p=s[a+2],m=s[a+3];if(c!==m||A!==u||l!==d||h!==p){let g=A*u+l*d+h*p+c*m;g<0&&(u=-u,d=-d,p=-p,m=-m,g=-g);let f=1-o;if(g<.9995){const b=Math.acos(g),S=Math.sin(b);f=Math.sin(f*b)/S,o=Math.sin(o*b)/S,A=A*f+u*o,l=l*f+d*o,h=h*f+p*o,c=c*f+m*o}else{A=A*f+u*o,l=l*f+d*o,h=h*f+p*o,c=c*f+m*o;const b=1/Math.sqrt(A*A+l*l+h*h+c*c);A*=b,l*=b,h*=b,c*=b}}t[e]=A,t[e+1]=l,t[e+2]=h,t[e+3]=c}static multiplyQuaternionsFlat(t,e,i,n,s,a){const o=i[n],A=i[n+1],l=i[n+2],h=i[n+3],c=s[a],u=s[a+1],d=s[a+2],p=s[a+3];return t[e]=o*p+h*c+A*d-l*u,t[e+1]=A*p+h*u+l*c-o*d,t[e+2]=l*p+h*d+o*u-A*c,t[e+3]=h*p-o*c-A*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,a=t._order,o=Math.cos,A=Math.sin,l=o(i/2),h=o(n/2),c=o(s/2),u=A(i/2),d=A(n/2),p=A(s/2);switch(a){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;break;default:be("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&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],a=e[1],o=e[5],A=e[9],l=e[2],h=e[6],c=e[10],u=i+o+c;if(u>0){const d=.5/Math.sqrt(u+1);this._w=.25/d,this._x=(h-A)*d,this._y=(s-l)*d,this._z=(a-n)*d}else if(i>o&&i>c){const d=2*Math.sqrt(1+i-o-c);this._w=(h-A)/d,this._x=.25*d,this._y=(n+a)/d,this._z=(s+l)/d}else if(o>c){const d=2*Math.sqrt(1+o-i-c);this._w=(s-l)/d,this._x=(n+a)/d,this._y=.25*d,this._z=(A+h)/d}else{const d=2*Math.sqrt(1+c-i-o);this._w=(a-n)/d,this._x=(s+l)/d,this._y=(A+h)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<1e-8?(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(kt(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(i===0)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 t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const i=t._x,n=t._y,s=t._z,a=t._w,o=e._x,A=e._y,l=e._z,h=e._w;return this._x=i*h+a*o+n*l-s*A,this._y=n*h+a*A+s*o-i*l,this._z=s*h+a*l+i*A-n*o,this._w=a*h-i*o-n*A-s*l,this._onChangeCallback(),this}slerp(t,e){let i=t._x,n=t._y,s=t._z,a=t._w,o=this.dot(t);o<0&&(i=-i,n=-n,s=-s,a=-a,o=-o);let A=1-e;if(o<.9995){const l=Math.acos(o),h=Math.sin(l);A=Math.sin(A*l)/h,e=Math.sin(e*l)/h,this._x=this._x*A+i*e,this._y=this._y*A+n*e,this._z=this._z*A+s*e,this._w=this._w*A+a*e,this._onChangeCallback()}else this._x=this._x*A+i*e,this._y=this._y*A+n*e,this._z=this._z*A+s*e,this._w=this._w*A+a*e,this.normalize();return this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),n=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(n*Math.sin(t),n*Math.cos(t),s*Math.sin(e),s*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class V{constructor(t=0,e=0,i=0){V.prototype.isVector3=!0,this.x=t,this.y=e,this.z=i}set(t,e,i){return i===void 0&&(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($l.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion($l.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,a=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])*a,this.y=(s[1]*e+s[5]*i+s[9]*n+s[13])*a,this.z=(s[2]*e+s[6]*i+s[10]*n+s[14])*a,this}applyQuaternion(t){const e=this.x,i=this.y,n=this.z,s=t.x,a=t.y,o=t.z,A=t.w,l=2*(a*n-o*i),h=2*(o*e-s*n),c=2*(s*i-a*e);return this.x=e+A*l+a*c-o*h,this.y=i+A*h+o*l-s*c,this.z=n+A*c+s*h-a*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=kt(this.x,t.x,e.x),this.y=kt(this.y,t.y,e.y),this.z=kt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=kt(this.x,t,e),this.y=kt(this.y,t,e),this.z=kt(this.z,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(kt(i,t,e))}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,a=e.x,o=e.y,A=e.z;return this.x=n*A-s*o,this.y=s*a-i*A,this.z=i*o-n*a,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return ya.copy(this).projectOnVector(t),this.sub(ya)}reflect(t){return this.sub(ya.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(kt(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,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,i=Math.sqrt(1-e*e);return this.x=i*Math.cos(t),this.y=e,this.z=i*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const ya=new V,$l=new Gs;class tn{constructor(t,e,i,n,s,a,o,A,l){tn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,i,n,s,a,o,A,l)}set(t,e,i,n,s,a,o,A,l){const h=this.elements;return h[0]=t,h[1]=n,h[2]=o,h[3]=e,h[4]=s,h[5]=A,h[6]=i,h[7]=a,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,a=i[0],o=i[3],A=i[6],l=i[1],h=i[4],c=i[7],u=i[2],d=i[5],p=i[8],m=n[0],g=n[3],f=n[6],b=n[1],S=n[4],v=n[7],T=n[2],w=n[5],R=n[8];return s[0]=a*m+o*b+A*T,s[3]=a*g+o*S+A*w,s[6]=a*f+o*v+A*R,s[1]=l*m+h*b+c*T,s[4]=l*g+h*S+c*w,s[7]=l*f+h*v+c*R,s[2]=u*m+d*b+p*T,s[5]=u*g+d*S+p*w,s[8]=u*f+d*v+p*R,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],a=t[4],o=t[5],A=t[6],l=t[7],h=t[8];return e*a*h-e*o*l-i*s*h+i*o*A+n*s*l-n*a*A}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],s=t[3],a=t[4],o=t[5],A=t[6],l=t[7],h=t[8],c=h*a-o*l,u=o*A-h*s,d=l*s-a*A,p=e*c+i*u+n*d;if(p===0)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]=(o*i-n*a)*m,t[3]=u*m,t[4]=(h*e-n*A)*m,t[5]=(n*s-o*e)*m,t[6]=d*m,t[7]=(i*A-l*e)*m,t[8]=(a*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,a,o){const A=Math.cos(s),l=Math.sin(s);return this.set(i*A,i*l,-i*(A*a+l*o)+a+t,-n*l,n*A,-n*(-l*a+A*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(ba.makeScale(t,e)),this}rotate(t){return this.premultiply(ba.makeRotation(-t)),this}translate(t,e){return this.premultiply(ba.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 ba=new tn,tA=new tn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),eA=new tn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function nu(){const r={enabled:!0,workingColorSpace:Zl,spaces:{},convert:function(n,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Ea&&(n.r=Di(n.r),n.g=Di(n.g),n.b=Di(n.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(n.applyMatrix3(this.spaces[s].toXYZ),n.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Ea&&(n.r=Jn(n.r),n.g=Jn(n.g),n.b=Jn(n.b))),n},workingToColorSpace:function(n,s){return this.convert(n,this.workingColorSpace,s)},colorSpaceToWorking:function(n,s){return this.convert(n,s,this.workingColorSpace)},getPrimaries:function(n){return this.spaces[n].primaries},getTransfer:function(n){return n===""?Jl:this.spaces[n].transfer},getToneMappingMode:function(n){return this.spaces[n].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(n,s=this.workingColorSpace){return n.fromArray(this.spaces[s].luminanceCoefficients)},define:function(n){Object.assign(this.spaces,n)},_getMatrix:function(n,s,a){return n.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(n){return this.spaces[n].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(n=this.workingColorSpace){return this.spaces[n].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(n,s){return Kl("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),r.workingToColorSpace(n,s)},toWorkingColorSpace:function(n,s){return Kl("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),r.colorSpaceToWorking(n,s)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],i=[.3127,.329];return r.define({[Zl]:{primaries:t,whitePoint:i,transfer:Jl,toXYZ:tA,fromXYZ:eA,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:He},outputColorSpaceConfig:{drawingBufferColorSpace:He}},[He]:{primaries:t,whitePoint:i,transfer:Ea,toXYZ:tA,fromXYZ:eA,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:He}}}),r}const si=nu();function Di(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function Jn(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let jn;class su{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let i;if(t instanceof HTMLCanvasElement)i=t;else{jn===void 0&&(jn=jl("canvas")),jn.width=t.width,jn.height=t.height;const n=jn.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),i=jn}return i.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=jl("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 a=0;a<s.length;a++)s[a]=Di(s[a]/255)*255;return i.putImageData(n,0,0),e}else if(t.data){const e=t.data.slice(0);for(let i=0;i<e.length;i++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[i]=Math.floor(Di(e[i]/255)*255):e[i]=Di(e[i]);return{data:e,width:t.width,height:t.height}}else return be("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let ru=0;class au{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:ru++}),this.uuid=zs(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):typeof VideoFrame<"u"&&e instanceof VideoFrame?t.set(e.displayHeight,e.displayWidth,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const i={uuid:this.uuid,url:""},n=this.data;if(n!==null){let s;if(Array.isArray(n)){s=[];for(let a=0,o=n.length;a<o;a++)n[a].isDataTexture?s.push(Ma(n[a].image)):s.push(Ma(n[a]))}else s=Ma(n);i.url=s}return e||(t.images[this.uuid]=i),i}}function Ma(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?su.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(be("Texture: Unable to serialize Texture."),{})}let ou=0;const wa=new V;class Ii extends pr{constructor(t=Ii.DEFAULT_IMAGE,e=Ii.DEFAULT_MAPPING,i=1001,n=1001,s=1006,a=1008,o=1023,A=1009,l=Ii.DEFAULT_ANISOTROPY,h=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:ou++}),this.uuid=zs(),this.name="",this.source=new au(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=s,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=A,this.offset=new Ve(0,0),this.repeat=new Ve(1,1),this.center=new Ve(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new tn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(wa).x}get height(){return this.source.getSize(wa).y}get depth(){return this.source.getSize(wa).z}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)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}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.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const i=t[e];if(i===void 0){be(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const n=this[e];if(n===void 0){be(`Texture.setValues(): property '${e}' does not exist.`);continue}n&&i&&n.isVector2&&i.isVector2||n&&i&&n.isVector3&&i.isVector3||n&&i&&n.isMatrix3&&i.isMatrix3?n.copy(i):this[e]=i}}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const i={metadata:{version:4.7,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!==300)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case 1e3:t.x=t.x-Math.floor(t.x);break;case 1001:t.x=t.x<0?0:1;break;case 1002:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case 1e3:t.y=t.y-Math.floor(t.y);break;case 1001:t.y=t.y<0?0:1;break;case 1002:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}Ii.DEFAULT_IMAGE=null,Ii.DEFAULT_MAPPING=300,Ii.DEFAULT_ANISOTROPY=1;class Hs{constructor(t=0,e=0,i=0,n=1){Hs.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=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,s=this.w,a=t.elements;return this.x=a[0]*e+a[4]*i+a[8]*n+a[12]*s,this.y=a[1]*e+a[5]*i+a[9]*n+a[13]*s,this.z=a[2]*e+a[6]*i+a[10]*n+a[14]*s,this.w=a[3]*e+a[7]*i+a[11]*n+a[15]*s,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,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 a=t.elements,o=a[0],A=a[4],l=a[8],h=a[1],c=a[5],u=a[9],d=a[2],p=a[6],m=a[10];if(Math.abs(A-h)<.01&&Math.abs(l-d)<.01&&Math.abs(u-p)<.01){if(Math.abs(A+h)<.1&&Math.abs(l+d)<.1&&Math.abs(u+p)<.1&&Math.abs(o+c+m-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const f=(o+1)/2,b=(c+1)/2,S=(m+1)/2,v=(A+h)/4,T=(l+d)/4,w=(u+p)/4;return f>b&&f>S?f<.01?(i=0,n=.707106781,s=.707106781):(i=Math.sqrt(f),n=v/i,s=T/i):b>S?b<.01?(i=.707106781,n=0,s=.707106781):(n=Math.sqrt(b),i=v/n,s=w/n):S<.01?(i=.707106781,n=.707106781,s=0):(s=Math.sqrt(S),i=T/s,n=w/s),this.set(i,n,s,e),this}let g=Math.sqrt((p-u)*(p-u)+(l-d)*(l-d)+(h-A)*(h-A));return Math.abs(g)<.001&&(g=1),this.x=(p-u)/g,this.y=(l-d)/g,this.z=(h-A)/g,this.w=Math.acos((o+c+m-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=kt(this.x,t.x,e.x),this.y=kt(this.y,t.y,e.y),this.z=kt(this.z,t.z,e.z),this.w=kt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=kt(this.x,t,e),this.y=kt(this.y,t,e),this.z=kt(this.z,t,e),this.w=kt(this.w,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(kt(i,t,e))}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 ri{constructor(t,e,i,n,s,a,o,A,l,h,c,u,d,p,m,g){ri.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,i,n,s,a,o,A,l,h,c,u,d,p,m,g)}set(t,e,i,n,s,a,o,A,l,h,c,u,d,p,m,g){const f=this.elements;return f[0]=t,f[4]=e,f[8]=i,f[12]=n,f[1]=s,f[5]=a,f[9]=o,f[13]=A,f[2]=l,f[6]=h,f[10]=c,f[14]=u,f[3]=d,f[7]=p,f[11]=m,f[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new ri().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 this.determinant()===0?(t.set(1,0,0),e.set(0,1,0),i.set(0,0,1),this):(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){if(t.determinant()===0)return this.identity();const e=this.elements,i=t.elements,n=1/Qn.setFromMatrixColumn(t,0).length(),s=1/Qn.setFromMatrixColumn(t,1).length(),a=1/Qn.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]*a,e[9]=i[9]*a,e[10]=i[10]*a,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,a=Math.cos(i),o=Math.sin(i),A=Math.cos(n),l=Math.sin(n),h=Math.cos(s),c=Math.sin(s);if(t.order==="XYZ"){const u=a*h,d=a*c,p=o*h,m=o*c;e[0]=A*h,e[4]=-A*c,e[8]=l,e[1]=d+p*l,e[5]=u-m*l,e[9]=-o*A,e[2]=m-u*l,e[6]=p+d*l,e[10]=a*A}else if(t.order==="YXZ"){const u=A*h,d=A*c,p=l*h,m=l*c;e[0]=u+m*o,e[4]=p*o-d,e[8]=a*l,e[1]=a*c,e[5]=a*h,e[9]=-o,e[2]=d*o-p,e[6]=m+u*o,e[10]=a*A}else if(t.order==="ZXY"){const u=A*h,d=A*c,p=l*h,m=l*c;e[0]=u-m*o,e[4]=-a*c,e[8]=p+d*o,e[1]=d+p*o,e[5]=a*h,e[9]=m-u*o,e[2]=-a*l,e[6]=o,e[10]=a*A}else if(t.order==="ZYX"){const u=a*h,d=a*c,p=o*h,m=o*c;e[0]=A*h,e[4]=p*l-d,e[8]=u*l+m,e[1]=A*c,e[5]=m*l+u,e[9]=d*l-p,e[2]=-l,e[6]=o*A,e[10]=a*A}else if(t.order==="YZX"){const u=a*A,d=a*l,p=o*A,m=o*l;e[0]=A*h,e[4]=m-u*c,e[8]=p*c+d,e[1]=c,e[5]=a*h,e[9]=-o*h,e[2]=-l*h,e[6]=d*c+p,e[10]=u-m*c}else if(t.order==="XZY"){const u=a*A,d=a*l,p=o*A,m=o*l;e[0]=A*h,e[4]=-c,e[8]=l*h,e[1]=u*c+m,e[5]=a*h,e[9]=d*c-p,e[2]=p*c-d,e[6]=o*h,e[10]=m*c+u}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(lu,t,Au)}lookAt(t,e,i){const n=this.elements;return We.subVectors(t,e),We.lengthSq()===0&&(We.z=1),We.normalize(),en.crossVectors(i,We),en.lengthSq()===0&&(Math.abs(i.z)===1?We.x+=1e-4:We.z+=1e-4,We.normalize(),en.crossVectors(i,We)),en.normalize(),mr.crossVectors(We,en),n[0]=en.x,n[4]=mr.x,n[8]=We.x,n[1]=en.y,n[5]=mr.y,n[9]=We.y,n[2]=en.z,n[6]=mr.z,n[10]=We.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,a=i[0],o=i[4],A=i[8],l=i[12],h=i[1],c=i[5],u=i[9],d=i[13],p=i[2],m=i[6],g=i[10],f=i[14],b=i[3],S=i[7],v=i[11],T=i[15],w=n[0],R=n[4],P=n[8],E=n[12],x=n[1],M=n[5],z=n[9],O=n[13],U=n[2],W=n[6],Y=n[10],$=n[14],H=n[3],rt=n[7],At=n[11],mt=n[15];return s[0]=a*w+o*x+A*U+l*H,s[4]=a*R+o*M+A*W+l*rt,s[8]=a*P+o*z+A*Y+l*At,s[12]=a*E+o*O+A*$+l*mt,s[1]=h*w+c*x+u*U+d*H,s[5]=h*R+c*M+u*W+d*rt,s[9]=h*P+c*z+u*Y+d*At,s[13]=h*E+c*O+u*$+d*mt,s[2]=p*w+m*x+g*U+f*H,s[6]=p*R+m*M+g*W+f*rt,s[10]=p*P+m*z+g*Y+f*At,s[14]=p*E+m*O+g*$+f*mt,s[3]=b*w+S*x+v*U+T*H,s[7]=b*R+S*M+v*W+T*rt,s[11]=b*P+S*z+v*Y+T*At,s[15]=b*E+S*O+v*$+T*mt,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],a=t[1],o=t[5],A=t[9],l=t[13],h=t[2],c=t[6],u=t[10],d=t[14],p=t[3],m=t[7],g=t[11],f=t[15],b=A*d-l*u,S=o*d-l*c,v=o*u-A*c,T=a*d-l*h,w=a*u-A*h,R=a*c-o*h;return e*(m*b-g*S+f*v)-i*(p*b-g*T+f*w)+n*(p*S-m*T+f*R)-s*(p*v-m*w+g*R)}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],a=t[4],o=t[5],A=t[6],l=t[7],h=t[8],c=t[9],u=t[10],d=t[11],p=t[12],m=t[13],g=t[14],f=t[15],b=e*o-i*a,S=e*A-n*a,v=e*l-s*a,T=i*A-n*o,w=i*l-s*o,R=n*l-s*A,P=h*m-c*p,E=h*g-u*p,x=h*f-d*p,M=c*g-u*m,z=c*f-d*m,O=u*f-d*g,U=b*O-S*z+v*M+T*x-w*E+R*P;if(U===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const W=1/U;return t[0]=(o*O-A*z+l*M)*W,t[1]=(n*z-i*O-s*M)*W,t[2]=(m*R-g*w+f*T)*W,t[3]=(u*w-c*R-d*T)*W,t[4]=(A*x-a*O-l*E)*W,t[5]=(e*O-n*x+s*E)*W,t[6]=(g*v-p*R-f*S)*W,t[7]=(h*R-u*v+d*S)*W,t[8]=(a*z-o*x+l*P)*W,t[9]=(i*x-e*z-s*P)*W,t[10]=(p*w-m*v+f*b)*W,t[11]=(c*v-h*w-d*b)*W,t[12]=(o*E-a*M-A*P)*W,t[13]=(e*M-i*E+n*P)*W,t[14]=(m*S-p*T-g*b)*W,t[15]=(h*T-c*S+u*b)*W,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,a=t.x,o=t.y,A=t.z,l=s*a,h=s*o;return this.set(l*a+i,l*o-n*A,l*A+n*o,0,l*o+n*A,h*o+i,h*A-n*a,0,l*A-n*o,h*A+n*a,s*A*A+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,a){return this.set(1,i,s,0,t,1,a,0,e,n,1,0,0,0,0,1),this}compose(t,e,i){const n=this.elements,s=e._x,a=e._y,o=e._z,A=e._w,l=s+s,h=a+a,c=o+o,u=s*l,d=s*h,p=s*c,m=a*h,g=a*c,f=o*c,b=A*l,S=A*h,v=A*c,T=i.x,w=i.y,R=i.z;return n[0]=(1-(m+f))*T,n[1]=(d+v)*T,n[2]=(p-S)*T,n[3]=0,n[4]=(d-v)*w,n[5]=(1-(u+f))*w,n[6]=(g+b)*w,n[7]=0,n[8]=(p+S)*R,n[9]=(g-b)*R,n[10]=(1-(u+m))*R,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;t.x=n[12],t.y=n[13],t.z=n[14];const s=this.determinant();if(s===0)return i.set(1,1,1),e.identity(),this;let a=Qn.set(n[0],n[1],n[2]).length();const o=Qn.set(n[4],n[5],n[6]).length(),A=Qn.set(n[8],n[9],n[10]).length();s<0&&(a=-a),ai.copy(this);const l=1/a,h=1/o,c=1/A;return ai.elements[0]*=l,ai.elements[1]*=l,ai.elements[2]*=l,ai.elements[4]*=h,ai.elements[5]*=h,ai.elements[6]*=h,ai.elements[8]*=c,ai.elements[9]*=c,ai.elements[10]*=c,e.setFromRotationMatrix(ai),i.x=a,i.y=o,i.z=A,this}makePerspective(t,e,i,n,s,a,o=2e3,A=!1){const l=this.elements,h=2*s/(e-t),c=2*s/(i-n),u=(e+t)/(e-t),d=(i+n)/(i-n);let p,m;if(A)p=s/(a-s),m=a*s/(a-s);else if(o===2e3)p=-(a+s)/(a-s),m=-2*a*s/(a-s);else if(o===2001)p=-a/(a-s),m=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=c,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,i,n,s,a,o=2e3,A=!1){const l=this.elements,h=2/(e-t),c=2/(i-n),u=-(e+t)/(e-t),d=-(i+n)/(i-n);let p,m;if(A)p=1/(a-s),m=a/(a-s);else if(o===2e3)p=-2/(a-s),m=-(a+s)/(a-s);else if(o===2001)p=-1/(a-s),m=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=0,l[12]=u,l[1]=0,l[5]=c,l[9]=0,l[13]=d,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=0,l[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 Qn=new V,ai=new ri,lu=new V(0,0,0),Au=new V(1,1,1),en=new V,mr=new V,We=new V,iA=new ri,nA=new Gs;class qn{constructor(t=0,e=0,i=0,n=qn.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],a=n[4],o=n[8],A=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(kt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-kt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(A,l)):(this._y=Math.atan2(-c,s),this._z=0);break;case"ZXY":this._x=Math.asin(kt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(A,s));break;case"ZYX":this._y=Math.asin(-kt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(A,s)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(kt(A,-1,1)),Math.abs(A)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-c,s)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-kt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,d),this._y=0);break;default:be("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,i===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return iA.makeRotationFromQuaternion(t),this.setFromRotationMatrix(iA,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return nA.setFromEuler(this),this.setFromQuaternion(nA,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}qn.DEFAULT_ORDER="XYZ";class hu{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let cu=0;const sA=new V,Kn=new Gs,Ni=new ri,Ir=new V,Vs=new V,uu=new V,du=new Gs,rA=new V(1,0,0),aA=new V(0,1,0),oA=new V(0,0,1),lA={type:"added"},fu={type:"removed"},$n={type:"childadded",child:null},Ta={type:"childremoved",child:null};class qe extends pr{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:cu++}),this.uuid=zs(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=qe.DEFAULT_UP.clone();const t=new V,e=new qn,i=new Gs,n=new V(1,1,1);function s(){i.setFromEuler(e,!1)}function a(){e.setFromQuaternion(i,void 0,!1)}e._onChange(s),i._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new ri},normalMatrix:{value:new tn}}),this.matrix=new ri,this.matrixWorld=new ri,this.matrixAutoUpdate=qe.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=qe.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new hu,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}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 Kn.setFromAxisAngle(t,e),this.quaternion.multiply(Kn),this}rotateOnWorldAxis(t,e){return Kn.setFromAxisAngle(t,e),this.quaternion.premultiply(Kn),this}rotateX(t){return this.rotateOnAxis(rA,t)}rotateY(t){return this.rotateOnAxis(aA,t)}rotateZ(t){return this.rotateOnAxis(oA,t)}translateOnAxis(t,e){return sA.copy(t).applyQuaternion(this.quaternion),this.position.add(sA.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(rA,t)}translateY(t){return this.translateOnAxis(aA,t)}translateZ(t){return this.translateOnAxis(oA,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Ni.copy(this.matrixWorld).invert())}lookAt(t,e,i){t.isVector3?Ir.copy(t):Ir.set(t,e,i);const n=this.parent;this.updateWorldMatrix(!0,!1),Vs.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ni.lookAt(Vs,Ir,this.up):Ni.lookAt(Ir,Vs,this.up),this.quaternion.setFromRotationMatrix(Ni),n&&(Ni.extractRotation(n.matrixWorld),Kn.setFromRotationMatrix(Ni),this.quaternion.premultiply(Kn.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(vn("Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(lA),$n.child=t,this.dispatchEvent($n),$n.child=null):vn("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(fu),Ta.child=t,this.dispatchEvent(Ta),Ta.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),Ni.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),Ni.multiply(t.parent.matrixWorld)),t.applyMatrix4(Ni),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(lA),$n.child=t,this.dispatchEvent($n),$n.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let i=0,n=this.children.length;i<n;i++){const s=this.children[i].getObjectByProperty(t,e);if(s!==void 0)return s}}getObjectsByProperty(t,e,i=[]){this[t]===e&&i.push(this);const n=this.children;for(let s=0,a=n.length;s<a;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(Vs,t,uu),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Vs,du,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(this.visible===!1)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;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const t=this.pivot;if(t!==null){const e=t.x,i=t.y,n=t.z,s=this.matrix.elements;s[12]+=e-s[0]*e-s[4]*i-s[8]*n,s[13]+=i-s[1]*e-s[5]*i-s[9]*n,s[14]+=n-s[2]*e-s[6]*i-s[10]*n}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].updateMatrixWorld(t)}updateWorldMatrix(t,e){const i=this.parent;if(t===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){const n=this.children;for(let s=0,a=n.length;s<a;s++)n[s].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",i={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const n={};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.castShadow===!0&&(n.castShadow=!0),this.receiveShadow===!0&&(n.receiveShadow=!0),this.visible===!1&&(n.visible=!1),this.frustumCulled===!1&&(n.frustumCulled=!1),this.renderOrder!==0&&(n.renderOrder=this.renderOrder),this.static!==!1&&(n.static=this.static),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(),this.pivot!==null&&(n.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(n.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(n.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(n.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(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.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),n.instanceInfo=this._instanceInfo.map(o=>({...o})),n.availableInstanceIds=this._availableInstanceIds.slice(),n.availableGeometryIds=this._availableGeometryIds.slice(),n.nextIndexStart=this._nextIndexStart,n.nextVertexStart=this._nextVertexStart,n.geometryCount=this._geometryCount,n.maxInstanceCount=this._maxInstanceCount,n.maxVertexCount=this._maxVertexCount,n.maxIndexCount=this._maxIndexCount,n.geometryInitialized=this._geometryInitialized,n.matricesTexture=this._matricesTexture.toJSON(t),n.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(n.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(n.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(n.boundingBox=this.boundingBox.toJSON()));function s(o,A){return o[A.uuid]===void 0&&(o[A.uuid]=A.toJSON(t)),A.uuid}if(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&&this.environment.isRenderTargetTexture!==!0&&(n.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=s(t.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const A=o.shapes;if(Array.isArray(A))for(let l=0,h=A.length;l<h;l++){const c=A[l];s(t.shapes,c)}else s(t.shapes,A)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(t.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let A=0,l=this.material.length;A<l;A++)o.push(s(t.materials,this.material[A]));n.material=o}else n.material=s(t.materials,this.material);if(this.children.length>0){n.children=[];for(let o=0;o<this.children.length;o++)n.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){n.animations=[];for(let o=0;o<this.animations.length;o++){const A=this.animations[o];n.animations.push(s(t.animations,A))}}if(e){const o=a(t.geometries),A=a(t.materials),l=a(t.textures),h=a(t.images),c=a(t.shapes),u=a(t.skeletons),d=a(t.animations),p=a(t.nodes);o.length>0&&(i.geometries=o),A.length>0&&(i.materials=A),l.length>0&&(i.textures=l),h.length>0&&(i.images=h),c.length>0&&(i.shapes=c),u.length>0&&(i.skeletons=u),d.length>0&&(i.animations=d),p.length>0&&(i.nodes=p)}return i.object=n,i;function a(o){const A=[];for(const l in o){const h=o[l];delete h.metadata,A.push(h)}return A}}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),t.pivot!==null&&(this.pivot=t.pivot.clone()),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.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let i=0;i<t.children.length;i++){const n=t.children[i];this.add(n.clone())}return this}}qe.DEFAULT_UP=new V(0,1,0),qe.DEFAULT_MATRIX_AUTO_UPDATE=!0,qe.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const AA={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},nn={h:0,s:0,l:0},Cr={h:0,s:0,l:0};function Ra(r,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?r+(t-r)*6*e:e<1/2?t:e<2/3?r+(t-r)*6*(2/3-e):r}class sn{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(e===void 0&&i===void 0){const n=t;n&&n.isColor?this.copy(n):typeof n=="number"?this.setHex(n):typeof n=="string"&&this.setStyle(n)}else this.setRGB(t,e,i);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=He){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,si.colorSpaceToWorking(this,e),this}setRGB(t,e,i,n=si.workingColorSpace){return this.r=t,this.g=e,this.b=i,si.colorSpaceToWorking(this,n),this}setHSL(t,e,i,n=si.workingColorSpace){if(t=iu(t,1),e=kt(e,0,1),i=kt(i,0,1),e===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+e):i+e-i*e,a=2*i-s;this.r=Ra(a,s,t+1/3),this.g=Ra(a,s,t),this.b=Ra(a,s,t-1/3)}return si.colorSpaceToWorking(this,n),this}setStyle(t,e=He){function i(s){s!==void 0&&parseFloat(s)<1&&be("Color: Alpha component of "+t+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(t)){let s;const a=n[1],o=n[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,e);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,e);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:be("Color: Unknown color model "+t)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){const s=n[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(s,16),e);be("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=He){const i=AA[t.toLowerCase()];return i!==void 0?this.setHex(i,e):be("Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=Di(t.r),this.g=Di(t.g),this.b=Di(t.b),this}copyLinearToSRGB(t){return this.r=Jn(t.r),this.g=Jn(t.g),this.b=Jn(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=He){return si.workingToColorSpace(we.copy(this),t),Math.round(kt(we.r*255,0,255))*65536+Math.round(kt(we.g*255,0,255))*256+Math.round(kt(we.b*255,0,255))}getHexString(t=He){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=si.workingColorSpace){si.workingToColorSpace(we.copy(this),e);const i=we.r,n=we.g,s=we.b,a=Math.max(i,n,s),o=Math.min(i,n,s);let A,l;const h=(o+a)/2;if(o===a)A=0,l=0;else{const c=a-o;switch(l=h<=.5?c/(a+o):c/(2-a-o),a){case i:A=(n-s)/c+(n<s?6:0);break;case n:A=(s-i)/c+2;break;case s:A=(i-n)/c+4;break}A/=6}return t.h=A,t.s=l,t.l=h,t}getRGB(t,e=si.workingColorSpace){return si.workingToColorSpace(we.copy(this),e),t.r=we.r,t.g=we.g,t.b=we.b,t}getStyle(t=He){si.workingToColorSpace(we.copy(this),t);const e=we.r,i=we.g,n=we.b;return t!==He?`color(${t} ${e.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(i*255)},${Math.round(n*255)})`}offsetHSL(t,e,i){return this.getHSL(nn),this.setHSL(nn.h+t,nn.s+e,nn.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(nn),t.getHSL(Cr);const i=Sa(nn.h,Cr.h,e),n=Sa(nn.s,Cr.s,e),s=Sa(nn.l,Cr.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 we=new sn;sn.NAMES=AA;const oi=new V,Fi=new V,_a=new V,Oi=new V,ts=new V,es=new V,hA=new V,Pa=new V,La=new V,Da=new V,Na=new Hs,Fa=new Hs,Oa=new Hs;class li{constructor(t=new V,e=new V,i=new V){this.a=t,this.b=e,this.c=i}static getNormal(t,e,i,n){n.subVectors(i,e),oi.subVectors(t,e),n.cross(oi);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){oi.subVectors(n,e),Fi.subVectors(i,e),_a.subVectors(t,e);const a=oi.dot(oi),o=oi.dot(Fi),A=oi.dot(_a),l=Fi.dot(Fi),h=Fi.dot(_a),c=a*l-o*o;if(c===0)return s.set(0,0,0),null;const u=1/c,d=(l*A-o*h)*u,p=(a*h-o*A)*u;return s.set(1-d-p,p,d)}static containsPoint(t,e,i,n){return this.getBarycoord(t,e,i,n,Oi)===null?!1:Oi.x>=0&&Oi.y>=0&&Oi.x+Oi.y<=1}static getInterpolation(t,e,i,n,s,a,o,A){return this.getBarycoord(t,e,i,n,Oi)===null?(A.x=0,A.y=0,"z"in A&&(A.z=0),"w"in A&&(A.w=0),null):(A.setScalar(0),A.addScaledVector(s,Oi.x),A.addScaledVector(a,Oi.y),A.addScaledVector(o,Oi.z),A)}static getInterpolatedAttribute(t,e,i,n,s,a){return Na.setScalar(0),Fa.setScalar(0),Oa.setScalar(0),Na.fromBufferAttribute(t,e),Fa.fromBufferAttribute(t,i),Oa.fromBufferAttribute(t,n),a.setScalar(0),a.addScaledVector(Na,s.x),a.addScaledVector(Fa,s.y),a.addScaledVector(Oa,s.z),a}static isFrontFacing(t,e,i,n){return oi.subVectors(i,e),Fi.subVectors(t,e),oi.cross(Fi).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 oi.subVectors(this.c,this.b),Fi.subVectors(this.a,this.b),oi.cross(Fi).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return li.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return li.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,i,n,s){return li.getInterpolation(t,this.a,this.b,this.c,e,i,n,s)}containsPoint(t){return li.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return li.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 a,o;ts.subVectors(n,i),es.subVectors(s,i),Pa.subVectors(t,i);const A=ts.dot(Pa),l=es.dot(Pa);if(A<=0&&l<=0)return e.copy(i);La.subVectors(t,n);const h=ts.dot(La),c=es.dot(La);if(h>=0&&c<=h)return e.copy(n);const u=A*c-h*l;if(u<=0&&A>=0&&h<=0)return a=A/(A-h),e.copy(i).addScaledVector(ts,a);Da.subVectors(t,s);const d=ts.dot(Da),p=es.dot(Da);if(p>=0&&d<=p)return e.copy(s);const m=d*l-A*p;if(m<=0&&l>=0&&p<=0)return o=l/(l-p),e.copy(i).addScaledVector(es,o);const g=h*p-d*c;if(g<=0&&c-h>=0&&d-p>=0)return hA.subVectors(s,n),o=(c-h)/(c-h+(d-p)),e.copy(n).addScaledVector(hA,o);const f=1/(g+m+u);return a=m*f,o=u*f,e.copy(i).addScaledVector(ts,a).addScaledVector(es,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}class Ws{constructor(t=new V(1/0,1/0,1/0),e=new V(-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(Ai.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,i=t.count;e<i;e++)this.expandByPoint(Ai.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=Ai.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(i!==void 0){const s=i.getAttribute("position");if(e===!0&&s!==void 0&&t.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)t.isMesh===!0?t.getVertexPosition(a,Ai):Ai.fromBufferAttribute(s,a),Ai.applyMatrix4(t.matrixWorld),this.expandByPoint(Ai);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),vr.copy(t.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),vr.copy(i.boundingBox)),vr.applyMatrix4(t.matrixWorld),this.union(vr)}const n=t.children;for(let s=0,a=n.length;s<a;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,Ai),Ai.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(Ys),xr.subVectors(this.max,Ys),is.subVectors(t.a,Ys),ns.subVectors(t.b,Ys),ss.subVectors(t.c,Ys),rn.subVectors(ns,is),an.subVectors(ss,ns),xn.subVectors(is,ss);let e=[0,-rn.z,rn.y,0,-an.z,an.y,0,-xn.z,xn.y,rn.z,0,-rn.x,an.z,0,-an.x,xn.z,0,-xn.x,-rn.y,rn.x,0,-an.y,an.x,0,-xn.y,xn.x,0];return!Ba(e,is,ns,ss,xr)||(e=[1,0,0,0,1,0,0,0,1],!Ba(e,is,ns,ss,xr))?!1:(Er.crossVectors(rn,an),e=[Er.x,Er.y,Er.z],Ba(e,is,ns,ss,xr))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Ai).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Ai).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(Bi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Bi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Bi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Bi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Bi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Bi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Bi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Bi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Bi),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)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}}const Bi=[new V,new V,new V,new V,new V,new V,new V,new V],Ai=new V,vr=new Ws,is=new V,ns=new V,ss=new V,rn=new V,an=new V,xn=new V,Ys=new V,xr=new V,Er=new V,En=new V;function Ba(r,t,e,i,n){for(let s=0,a=r.length-3;s<=a;s+=3){En.fromArray(r,s);const o=n.x*Math.abs(En.x)+n.y*Math.abs(En.y)+n.z*Math.abs(En.z),A=t.dot(En),l=e.dot(En),h=i.dot(En);if(Math.max(-Math.max(A,l,h),Math.min(A,l,h))>o)return!1}return!0}const pe=new V,Sr=new Ve;let gu=0;class Sn{constructor(t,e,i=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:gu++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=i,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,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(this.itemSize===2)for(let e=0,i=this.count;e<i;e++)Sr.fromBufferAttribute(this,e),Sr.applyMatrix3(t),this.setXY(e,Sr.x,Sr.y);else if(this.itemSize===3)for(let e=0,i=this.count;e<i;e++)pe.fromBufferAttribute(this,e),pe.applyMatrix3(t),this.setXYZ(e,pe.x,pe.y,pe.z);return this}applyMatrix4(t){for(let e=0,i=this.count;e<i;e++)pe.fromBufferAttribute(this,e),pe.applyMatrix4(t),this.setXYZ(e,pe.x,pe.y,pe.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)pe.fromBufferAttribute(this,e),pe.applyNormalMatrix(t),this.setXYZ(e,pe.x,pe.y,pe.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)pe.fromBufferAttribute(this,e),pe.transformDirection(t),this.setXYZ(e,pe.x,pe.y,pe.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=ks(i,this.array)),i}setComponent(t,e,i){return this.normalized&&(i=Be(i,this.array)),this.array[t*this.itemSize+e]=i,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=ks(e,this.array)),e}setX(t,e){return this.normalized&&(e=Be(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=ks(e,this.array)),e}setY(t,e){return this.normalized&&(e=Be(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=ks(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Be(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=ks(e,this.array)),e}setW(t,e){return this.normalized&&(e=Be(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=Be(e,this.array),i=Be(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=Be(e,this.array),i=Be(i,this.array),n=Be(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=Be(e,this.array),i=Be(i,this.array),n=Be(n,this.array),s=Be(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!==35044&&(t.usage=this.usage),t}}class pu extends Sn{constructor(t,e,i){super(new Uint16Array(t),e,i)}}class mu extends Sn{constructor(t,e,i){super(new Uint32Array(t),e,i)}}class yn extends Sn{constructor(t,e,i){super(new Float32Array(t),e,i)}}const Iu=new Ws,Xs=new V,Ua=new V;class cA{constructor(t=new V,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;e!==void 0?i.copy(e):Iu.setFromPoints(t).getCenter(i);let n=0;for(let s=0,a=t.length;s<a;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;Xs.subVectors(t,this.center);const e=Xs.lengthSq();if(e>this.radius*this.radius){const i=Math.sqrt(e),n=(i-this.radius)*.5;this.center.addScaledVector(Xs,n/i),this.radius+=n}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(Ua.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Xs.copy(t.center).add(Ua)),this.expandByPoint(Xs.copy(t.center).sub(Ua))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}}let Cu=0;const Ke=new ri,za=new qe,rs=new V,Ye=new Ws,Zs=new Ws,xe=new V;class as extends pr{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Cu++}),this.uuid=zs(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,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(eu(t)?mu:pu)(t,1):this.index=t,this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,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;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const s=new tn().getNormalMatrix(t);i.applyNormalMatrix(s),i.needsUpdate=!0}const n=this.attributes.tangent;return n!==void 0&&(n.transformDirection(t),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return Ke.makeRotationFromQuaternion(t),this.applyMatrix4(Ke),this}rotateX(t){return Ke.makeRotationX(t),this.applyMatrix4(Ke),this}rotateY(t){return Ke.makeRotationY(t),this.applyMatrix4(Ke),this}rotateZ(t){return Ke.makeRotationZ(t),this.applyMatrix4(Ke),this}translate(t,e,i){return Ke.makeTranslation(t,e,i),this.applyMatrix4(Ke),this}scale(t,e,i){return Ke.makeScale(t,e,i),this.applyMatrix4(Ke),this}lookAt(t){return za.lookAt(t),za.updateMatrix(),this.applyMatrix4(za.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(rs).negate(),this.translate(rs.x,rs.y,rs.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const i=[];for(let n=0,s=t.length;n<s;n++){const a=t[n];i.push(a.x,a.y,a.z||0)}this.setAttribute("position",new yn(i,3))}else{const i=Math.min(t.length,e.count);for(let n=0;n<i;n++){const s=t[n];e.setXYZ(n,s.x,s.y,s.z||0)}t.length>e.count&&be("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ws);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){vn("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new V(-1/0,-1/0,-1/0),new V(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let i=0,n=e.length;i<n;i++){const s=e[i];Ye.setFromBufferAttribute(s),this.morphTargetsRelative?(xe.addVectors(this.boundingBox.min,Ye.min),this.boundingBox.expandByPoint(xe),xe.addVectors(this.boundingBox.max,Ye.max),this.boundingBox.expandByPoint(xe)):(this.boundingBox.expandByPoint(Ye.min),this.boundingBox.expandByPoint(Ye.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&vn('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new cA);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){vn("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new V,1/0);return}if(t){const i=this.boundingSphere.center;if(Ye.setFromBufferAttribute(t),e)for(let s=0,a=e.length;s<a;s++){const o=e[s];Zs.setFromBufferAttribute(o),this.morphTargetsRelative?(xe.addVectors(Ye.min,Zs.min),Ye.expandByPoint(xe),xe.addVectors(Ye.max,Zs.max),Ye.expandByPoint(xe)):(Ye.expandByPoint(Zs.min),Ye.expandByPoint(Zs.max))}Ye.getCenter(i);let n=0;for(let s=0,a=t.count;s<a;s++)xe.fromBufferAttribute(t,s),n=Math.max(n,i.distanceToSquared(xe));if(e)for(let s=0,a=e.length;s<a;s++){const o=e[s],A=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)xe.fromBufferAttribute(o,l),A&&(rs.fromBufferAttribute(t,l),xe.add(rs)),n=Math.max(n,i.distanceToSquared(xe))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&vn('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){vn("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=e.position,n=e.normal,s=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Sn(new Float32Array(4*i.count),4));const a=this.getAttribute("tangent"),o=[],A=[];for(let P=0;P<i.count;P++)o[P]=new V,A[P]=new V;const l=new V,h=new V,c=new V,u=new Ve,d=new Ve,p=new Ve,m=new V,g=new V;function f(P,E,x){l.fromBufferAttribute(i,P),h.fromBufferAttribute(i,E),c.fromBufferAttribute(i,x),u.fromBufferAttribute(s,P),d.fromBufferAttribute(s,E),p.fromBufferAttribute(s,x),h.sub(l),c.sub(l),d.sub(u),p.sub(u);const M=1/(d.x*p.y-p.x*d.y);isFinite(M)&&(m.copy(h).multiplyScalar(p.y).addScaledVector(c,-d.y).multiplyScalar(M),g.copy(c).multiplyScalar(d.x).addScaledVector(h,-p.x).multiplyScalar(M),o[P].add(m),o[E].add(m),o[x].add(m),A[P].add(g),A[E].add(g),A[x].add(g))}let b=this.groups;b.length===0&&(b=[{start:0,count:t.count}]);for(let P=0,E=b.length;P<E;++P){const x=b[P],M=x.start,z=x.count;for(let O=M,U=M+z;O<U;O+=3)f(t.getX(O+0),t.getX(O+1),t.getX(O+2))}const S=new V,v=new V,T=new V,w=new V;function R(P){T.fromBufferAttribute(n,P),w.copy(T);const E=o[P];S.copy(E),S.sub(T.multiplyScalar(T.dot(E))).normalize(),v.crossVectors(w,E);const x=v.dot(A[P])<0?-1:1;a.setXYZW(P,S.x,S.y,S.z,x)}for(let P=0,E=b.length;P<E;++P){const x=b[P],M=x.start,z=x.count;for(let O=M,U=M+z;O<U;O+=3)R(t.getX(O+0)),R(t.getX(O+1)),R(t.getX(O+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new Sn(new Float32Array(e.count*3),3),this.setAttribute("normal",i);else for(let u=0,d=i.count;u<d;u++)i.setXYZ(u,0,0,0);const n=new V,s=new V,a=new V,o=new V,A=new V,l=new V,h=new V,c=new V;if(t)for(let u=0,d=t.count;u<d;u+=3){const p=t.getX(u+0),m=t.getX(u+1),g=t.getX(u+2);n.fromBufferAttribute(e,p),s.fromBufferAttribute(e,m),a.fromBufferAttribute(e,g),h.subVectors(a,s),c.subVectors(n,s),h.cross(c),o.fromBufferAttribute(i,p),A.fromBufferAttribute(i,m),l.fromBufferAttribute(i,g),o.add(h),A.add(h),l.add(h),i.setXYZ(p,o.x,o.y,o.z),i.setXYZ(m,A.x,A.y,A.z),i.setXYZ(g,l.x,l.y,l.z)}else for(let u=0,d=e.count;u<d;u+=3)n.fromBufferAttribute(e,u+0),s.fromBufferAttribute(e,u+1),a.fromBufferAttribute(e,u+2),h.subVectors(a,s),c.subVectors(n,s),h.cross(c),i.setXYZ(u+0,h.x,h.y,h.z),i.setXYZ(u+1,h.x,h.y,h.z),i.setXYZ(u+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++)xe.fromBufferAttribute(t,e),xe.normalize(),t.setXYZ(e,xe.x,xe.y,xe.z)}toNonIndexed(){function t(o,A){const l=o.array,h=o.itemSize,c=o.normalized,u=new l.constructor(A.length*h);let d=0,p=0;for(let m=0,g=A.length;m<g;m++){o.isInterleavedBufferAttribute?d=A[m]*o.data.stride+o.offset:d=A[m]*h;for(let f=0;f<h;f++)u[p++]=l[d++]}return new Sn(u,h,c)}if(this.index===null)return be("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new as,i=this.index.array,n=this.attributes;for(const o in n){const A=n[o],l=t(A,i);e.setAttribute(o,l)}const s=this.morphAttributes;for(const o in s){const A=[],l=s[o];for(let h=0,c=l.length;h<c;h++){const u=l[h],d=t(u,i);A.push(d)}e.morphAttributes[o]=A}e.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,A=a.length;o<A;o++){const l=a[o];e.addGroup(l.start,l.count,l.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const A=this.parameters;for(const l in A)A[l]!==void 0&&(t[l]=A[l]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const i=this.attributes;for(const A in i){const l=i[A];t.data.attributes[A]=l.toJSON(t.data)}const n={};let s=!1;for(const A in this.morphAttributes){const l=this.morphAttributes[A],h=[];for(let c=0,u=l.length;c<u;c++){const d=l[c];h.push(d.toJSON(t.data))}h.length>0&&(n[A]=h,s=!0)}s&&(t.data.morphAttributes=n,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(t.data.boundingSphere=o.toJSON()),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;i!==null&&this.setIndex(i.clone());const n=t.attributes;for(const l in n){const h=n[l];this.setAttribute(l,h.clone(e))}const s=t.morphAttributes;for(const l in s){const h=[],c=s[l];for(let u=0,d=c.length;u<d;u++)h.push(c[u].clone(e));this.morphAttributes[l]=h}this.morphTargetsRelative=t.morphTargetsRelative;const a=t.groups;for(let l=0,h=a.length;l<h;l++){const c=a[l];this.addGroup(c.start,c.count,c.materialIndex)}const o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());const A=t.boundingSphere;return A!==null&&(this.boundingSphere=A.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}let vu=0;class ka extends pr{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:vu++}),this.uuid=zs(),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=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new sn(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=7680,this.stencilZFail=7680,this.stencilZPass=7680,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.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const i=t[e];if(i===void 0){be(`Material: parameter '${e}' has value of undefined.`);continue}const n=this[e];if(n===void 0){be(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[e]=i}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(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()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(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),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(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,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==1&&(i.blending=this.blending),this.side!==0&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==204&&(i.blendSrc=this.blendSrc),this.blendDst!==205&&(i.blendDst=this.blendDst),this.blendEquation!==100&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==3&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==519&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==7680&&(i.stencilFail=this.stencilFail),this.stencilZFail!==7680&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==7680&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function n(s){const a=[];for(const o in s){const A=s[o];delete A.metadata,a.push(A)}return a}if(e){const s=n(t.textures),a=n(t.images);s.length>0&&(i.textures=s),a.length>0&&(i.images=a)}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(e!==null){const n=e.length;i=new Array(n);for(let s=0;s!==n;++s)i[s]=e[s].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.allowOverride=t.allowOverride,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}}const Ui=new V,Ga=new V,yr=new V,on=new V,Ha=new V,br=new V,Va=new V;class xu{constructor(t=new V,e=new V(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,Ui)),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=Ui.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Ui.copy(this.origin).addScaledVector(this.direction,e),Ui.distanceToSquared(t))}distanceSqToSegment(t,e,i,n){Ga.copy(t).add(e).multiplyScalar(.5),yr.copy(e).sub(t).normalize(),on.copy(this.origin).sub(Ga);const s=t.distanceTo(e)*.5,a=-this.direction.dot(yr),o=on.dot(this.direction),A=-on.dot(yr),l=on.lengthSq(),h=Math.abs(1-a*a);let c,u,d,p;if(h>0)if(c=a*A-o,u=a*o-A,p=s*h,c>=0)if(u>=-p)if(u<=p){const m=1/h;c*=m,u*=m,d=c*(c+a*u+2*o)+u*(a*c+u+2*A)+l}else u=s,c=Math.max(0,-(a*u+o)),d=-c*c+u*(u+2*A)+l;else u=-s,c=Math.max(0,-(a*u+o)),d=-c*c+u*(u+2*A)+l;else u<=-p?(c=Math.max(0,-(-a*s+o)),u=c>0?-s:Math.min(Math.max(-s,-A),s),d=-c*c+u*(u+2*A)+l):u<=p?(c=0,u=Math.min(Math.max(-s,-A),s),d=u*(u+2*A)+l):(c=Math.max(0,-(a*s+o)),u=c>0?s:Math.min(Math.max(-s,-A),s),d=-c*c+u*(u+2*A)+l);else u=a>0?-s:s,c=Math.max(0,-(a*u+o)),d=-c*c+u*(u+2*A)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,c),n&&n.copy(Ga).addScaledVector(yr,u),d}intersectSphere(t,e){Ui.subVectors(t.center,this.origin);const i=Ui.dot(this.direction),n=Ui.dot(Ui)-i*i,s=t.radius*t.radius;if(n>s)return null;const a=Math.sqrt(s-n),o=i-a,A=i+a;return A<0?null:o<0?this.at(A,e):this.at(o,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){const i=this.distanceToPlane(t);return i===null?null:this.at(i,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let i,n,s,a,o,A;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,a=(t.max.y-u.y)*h):(s=(t.max.y-u.y)*h,a=(t.min.y-u.y)*h),i>a||s>n||((s>i||isNaN(i))&&(i=s),(a<n||isNaN(n))&&(n=a),c>=0?(o=(t.min.z-u.z)*c,A=(t.max.z-u.z)*c):(o=(t.max.z-u.z)*c,A=(t.min.z-u.z)*c),i>A||o>n)||((o>i||i!==i)&&(i=o),(A<n||n!==n)&&(n=A),n<0)?null:this.at(i>=0?i:n,e)}intersectsBox(t){return this.intersectBox(t,Ui)!==null}intersectTriangle(t,e,i,n,s){Ha.subVectors(e,t),br.subVectors(i,t),Va.crossVectors(Ha,br);let a=this.direction.dot(Va),o;if(a>0){if(n)return null;o=1}else if(a<0)o=-1,a=-a;else return null;on.subVectors(this.origin,t);const A=o*this.direction.dot(br.crossVectors(on,br));if(A<0)return null;const l=o*this.direction.dot(Ha.cross(on));if(l<0||A+l>a)return null;const h=-o*on.dot(Va);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 Eu extends ka{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new sn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new qn,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.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const uA=new ri,bn=new xu,Mr=new cA,dA=new V,wr=new V,Tr=new V,Rr=new V,Wa=new V,_r=new V,fA=new V,Pr=new V;class gA extends qe{constructor(t=new as,e=new Eu){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const i=t[e[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,s=i.length;n<s;n++){const a=i[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=n}}}}getVertexPosition(t,e){const i=this.geometry,n=i.attributes.position,s=i.morphAttributes.position,a=i.morphTargetsRelative;e.fromBufferAttribute(n,t);const o=this.morphTargetInfluences;if(s&&o){_r.set(0,0,0);for(let A=0,l=s.length;A<l;A++){const h=o[A],c=s[A];h!==0&&(Wa.fromBufferAttribute(c,t),a?_r.addScaledVector(Wa,h):_r.addScaledVector(Wa.sub(e),h))}e.add(_r)}return e}raycast(t,e){const i=this.geometry,n=this.material,s=this.matrixWorld;n!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Mr.copy(i.boundingSphere),Mr.applyMatrix4(s),bn.copy(t.ray).recast(t.near),!(Mr.containsPoint(bn.origin)===!1&&(bn.intersectSphere(Mr,dA)===null||bn.origin.distanceToSquared(dA)>(t.far-t.near)**2))&&(uA.copy(s).invert(),bn.copy(t.ray).applyMatrix4(uA),!(i.boundingBox!==null&&bn.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(t,e,bn)))}_computeIntersections(t,e,i){let n;const s=this.geometry,a=this.material,o=s.index,A=s.attributes.position,l=s.attributes.uv,h=s.attributes.uv1,c=s.attributes.normal,u=s.groups,d=s.drawRange;if(o!==null)if(Array.isArray(a))for(let p=0,m=u.length;p<m;p++){const g=u[p],f=a[g.materialIndex],b=Math.max(g.start,d.start),S=Math.min(o.count,Math.min(g.start+g.count,d.start+d.count));for(let v=b,T=S;v<T;v+=3){const w=o.getX(v),R=o.getX(v+1),P=o.getX(v+2);n=Lr(this,f,t,i,l,h,c,w,R,P),n&&(n.faceIndex=Math.floor(v/3),n.face.materialIndex=g.materialIndex,e.push(n))}}else{const p=Math.max(0,d.start),m=Math.min(o.count,d.start+d.count);for(let g=p,f=m;g<f;g+=3){const b=o.getX(g),S=o.getX(g+1),v=o.getX(g+2);n=Lr(this,a,t,i,l,h,c,b,S,v),n&&(n.faceIndex=Math.floor(g/3),e.push(n))}}else if(A!==void 0)if(Array.isArray(a))for(let p=0,m=u.length;p<m;p++){const g=u[p],f=a[g.materialIndex],b=Math.max(g.start,d.start),S=Math.min(A.count,Math.min(g.start+g.count,d.start+d.count));for(let v=b,T=S;v<T;v+=3){const w=v,R=v+1,P=v+2;n=Lr(this,f,t,i,l,h,c,w,R,P),n&&(n.faceIndex=Math.floor(v/3),n.face.materialIndex=g.materialIndex,e.push(n))}}else{const p=Math.max(0,d.start),m=Math.min(A.count,d.start+d.count);for(let g=p,f=m;g<f;g+=3){const b=g,S=g+1,v=g+2;n=Lr(this,a,t,i,l,h,c,b,S,v),n&&(n.faceIndex=Math.floor(g/3),e.push(n))}}}}function Su(r,t,e,i,n,s,a,o){let A;if(t.side===1?A=i.intersectTriangle(a,s,n,!0,o):A=i.intersectTriangle(n,s,a,t.side===0,o),A===null)return null;Pr.copy(o),Pr.applyMatrix4(r.matrixWorld);const l=e.ray.origin.distanceTo(Pr);return l<e.near||l>e.far?null:{distance:l,point:Pr.clone(),object:r}}function Lr(r,t,e,i,n,s,a,o,A,l){r.getVertexPosition(o,wr),r.getVertexPosition(A,Tr),r.getVertexPosition(l,Rr);const h=Su(r,t,e,i,wr,Tr,Rr,fA);if(h){const c=new V;li.getBarycoord(fA,wr,Tr,Rr,c),n&&(h.uv=li.getInterpolatedAttribute(n,o,A,l,c,new Ve)),s&&(h.uv1=li.getInterpolatedAttribute(s,o,A,l,c,new Ve)),a&&(h.normal=li.getInterpolatedAttribute(a,o,A,l,c,new V),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const u={a:o,b:A,c:l,normal:new V,materialIndex:0};li.getNormal(wr,Tr,Rr,u.normal),h.face=u,h.barycoord=c}return h}class yu extends Ii{constructor(t=null,e=1,i=1,n,s,a,o,A,l=1003,h=1003,c,u){super(null,a,o,A,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}}class Mn extends as{constructor(t=1,e=1,i=1,n=32,s=1,a=!1,o=0,A=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:i,radialSegments:n,heightSegments:s,openEnded:a,thetaStart:o,thetaLength:A};const l=this;n=Math.floor(n),s=Math.floor(s);const h=[],c=[],u=[],d=[];let p=0;const m=[],g=i/2;let f=0;b(),a===!1&&(t>0&&S(!0),e>0&&S(!1)),this.setIndex(h),this.setAttribute("position",new yn(c,3)),this.setAttribute("normal",new yn(u,3)),this.setAttribute("uv",new yn(d,2));function b(){const v=new V,T=new V;let w=0;const R=(e-t)/i;for(let P=0;P<=s;P++){const E=[],x=P/s,M=x*(e-t)+t;for(let z=0;z<=n;z++){const O=z/n,U=O*A+o,W=Math.sin(U),Y=Math.cos(U);T.x=M*W,T.y=-x*i+g,T.z=M*Y,c.push(T.x,T.y,T.z),v.set(W,R,Y).normalize(),u.push(v.x,v.y,v.z),d.push(O,1-x),E.push(p++)}m.push(E)}for(let P=0;P<n;P++)for(let E=0;E<s;E++){const x=m[E][P],M=m[E+1][P],z=m[E+1][P+1],O=m[E][P+1];(t>0||E!==0)&&(h.push(x,M,O),w+=3),(e>0||E!==s-1)&&(h.push(M,z,O),w+=3)}l.addGroup(f,w,0),f+=w}function S(v){const T=p,w=new Ve,R=new V;let P=0;const E=v===!0?t:e,x=v===!0?1:-1;for(let z=1;z<=n;z++)c.push(0,g*x,0),u.push(0,x,0),d.push(.5,.5),p++;const M=p;for(let z=0;z<=n;z++){const O=z/n*A+o,U=Math.cos(O),W=Math.sin(O);R.x=E*W,R.y=g*x,R.z=E*U,c.push(R.x,R.y,R.z),u.push(0,x,0),w.x=U*.5+.5,w.y=W*.5*x+.5,d.push(w.x,w.y),p++}for(let z=0;z<n;z++){const O=T+z,U=M+z;v===!0?h.push(U,U+1,O):h.push(U+1,U,O),P+=3}l.addGroup(f,P,v===!0?1:2),f+=P}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Mn(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}function bu(r){const t={};for(const e in r){t[e]={};for(const i in r[e]){const n=r[e][i];n&&(n.isColor||n.isMatrix3||n.isMatrix4||n.isVector2||n.isVector3||n.isVector4||n.isTexture||n.isQuaternion)?n.isRenderTargetTexture?(be("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][i]=null):t[e][i]=n.clone():Array.isArray(n)?t[e][i]=n.slice():t[e][i]=n}}return t}function Mu(r){const t=[];for(let e=0;e<r.length;e++)t.push(r[e].clone());return t}var wu=`void main() {
55
+ `,Kc="*{box-sizing:border-box}:host{display:block;width:100%}.bar-menu-container{display:flex;align-items:center;justify-content:space-between;height:100%;gap:var(--gap-sm);padding:var(--spacing-1);background:var(--color-bg-primary);border-radius:var(--border-radius-full);border:var(--border-width-2) solid var(--color-border-secondary);box-shadow:var(--shadow-sm);margin:0 auto}.bar-menu-container .nav-prev,.bar-menu-container .nav-next{flex-shrink:0;opacity:0;visibility:hidden;pointer-events:none;transition:opacity .2s ease-in-out,visibility .2s ease-in-out}.bar-menu-container .nav-prev.visible,.bar-menu-container .nav-next.visible{opacity:1;visibility:visible;pointer-events:auto}.bar-menu-container .nav-prev::part(button),.bar-menu-container .nav-next::part(button){background-color:transparent;box-shadow:none}.bar-menu-container .buttons-wrapper{display:grid;grid-template-columns:repeat(var(--bar-menu-visible-count, 3),1fr);grid-auto-rows:max-content;align-items:center;justify-items:center;gap:var(--gap-sm);overflow:hidden;position:relative;width:auto}::slotted(*){display:none;flex-shrink:0;will-change:opacity,transform;contain:layout style paint;opacity:0;transform:scale(.8)}::slotted(.animating){transition:opacity .4s cubic-bezier(.34,1.56,.64,1),transform .4s cubic-bezier(.34,1.56,.64,1)}::slotted(.visible-button){display:inline-flex!important;pointer-events:auto;opacity:1;transform:scale(1)}",Xl=new CSSStyleSheet;Xl.replaceSync(Kc);class ni extends HTMLElement{static _visibleCountAttribute="visible-count";static _cyclicalNavigationAttribute="cyclical-navigation";_currentIndex=0;_visibleCount=3;_cyclicalNavigation=!1;_MIN_VISIBLE=1;_MAX_VISIBLE=5;_slotElement=null;_navPrevButton=null;_navNextButton=null;_buttonsWrapper=null;_slotChangeListener=null;_keyDownListener=null;constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot?.adoptedStyleSheets.push(Xl)}static get observedAttributes(){return[ni._visibleCountAttribute,ni._cyclicalNavigationAttribute]}get visibleButtons(){const t=this.getAttribute(ni._visibleCountAttribute);if(t!==null&&t!==Ae){const e=parseInt(t,10);return Math.max(this._MIN_VISIBLE,Math.min(this._MAX_VISIBLE,e))}return this._visibleCount}set visibleButtons(t){const e=Math.max(this._MIN_VISIBLE,Math.min(this._MAX_VISIBLE,t));this.setAttribute(ni._visibleCountAttribute,String(e))}get cyclicalNavigation(){return this.hasAttribute(ni._cyclicalNavigationAttribute)}set cyclicalNavigation(t){t?this.setAttribute(ni._cyclicalNavigationAttribute,Ae):this.removeAttribute(ni._cyclicalNavigationAttribute)}connectedCallback(){this._render(),this._cacheElements(),this._setupSlotListener(),this._setupKeyboardListener(),this._updateButtonVisibility()}disconnectedCallback(){this._removeSlotListener(),this._removeKeyboardListener()}attributeChangedCallback(t,e,i){t===ni._visibleCountAttribute?(this._visibleCount=this.visibleButtons,this._buttonsWrapper!==null&&this._buttonsWrapper.style.setProperty("--bar-menu-visible-count",String(this.visibleButtons)),this._updateButtonVisibility()):t===ni._cyclicalNavigationAttribute&&(this._cyclicalNavigation=this.cyclicalNavigation,this._updateButtonVisibility())}_render(){this.shadowRoot!==null&&(this.shadowRoot.innerHTML=qc)}_cacheElements(){this._slotElement=this.shadowRoot?.querySelector("slot")??null,this._navPrevButton=this.shadowRoot?.querySelector(".nav-prev")??null,this._navNextButton=this.shadowRoot?.querySelector(".nav-next")??null,this._buttonsWrapper=this.shadowRoot?.querySelector(".buttons-wrapper")??null,this._buttonsWrapper!==null&&this._buttonsWrapper.style.setProperty("--bar-menu-visible-count",String(this.visibleButtons)),this._navPrevButton!==null&&(this._navPrevButton.setAttribute("aria-label","Previous"),this._navPrevButton.addEventListener(Ki.CLICK,()=>{this._scrollPrevious()})),this._navNextButton!==null&&(this._navNextButton.setAttribute("aria-label","Next"),this._navNextButton.addEventListener(Ki.CLICK,()=>{this._scrollNext()}))}_setupSlotListener(){this._slotElement!==null&&(this._slotChangeListener=()=>{this._currentIndex=0,this._updateButtonVisibility()},this._slotElement.addEventListener("slotchange",this._slotChangeListener))}_removeSlotListener(){this._slotElement!==null&&this._slotChangeListener!==null&&this._slotElement.removeEventListener("slotchange",this._slotChangeListener)}_setupKeyboardListener(){this._keyDownListener=t=>{t.key==="ArrowLeft"?(t.preventDefault(),this._scrollPrevious()):t.key==="ArrowRight"&&(t.preventDefault(),this._scrollNext())},this.addEventListener(Bl.KEY_DOWN,this._keyDownListener)}_removeKeyboardListener(){this._keyDownListener!==null&&this.removeEventListener(Bl.KEY_DOWN,this._keyDownListener)}_getSlottedButtons(){return this._slotElement===null?[]:this._slotElement.assignedElements()}_updateButtonVisibility(t){const e=this._getSlottedButtons(),i=e.length,n=this.visibleButtons,s=this._currentIndex,a=Math.min(s+n,i);e.forEach((o,A)=>{const l=A>=s&&A<a,h=o;l||(o.classList.remove("visible-button"),o.classList.remove("animating"),h.style.display="none")}),t!==void 0?(e[0]?.offsetHeight,e.forEach((o,A)=>{if(A>=s&&A<a){const l=o;l.style.display="inline-flex",o.classList.add("animating");const h=A%this.visibleButtons*50;l.style.transitionDelay=`${h}ms`}}),e[0]?.offsetHeight,e.forEach((o,A)=>{A>=s&&A<a&&o.classList.add("visible-button")}),setTimeout(()=>{e.forEach(o=>{o.classList.remove("animating"),o.style.transitionDelay=Ae})},400)):e.forEach((o,A)=>{const l=A>=s&&A<a,h=o;l&&(h.style.display="inline-flex",o.classList.add("visible-button"))}),this._updateNavigationButtons(i,n)}_updateNavigationButtons(t,e){const i=t>e,n=this._currentIndex+e<t,s=this._currentIndex===0,a=!n;this._navPrevButton!==null&&(i?(this._navPrevButton.classList.add("visible"),this._navPrevButton.disabled=!this._cyclicalNavigation&&s):this._navPrevButton.classList.remove("visible")),this._navNextButton!==null&&(i?(this._navNextButton.classList.add("visible"),this._navNextButton.disabled=!this._cyclicalNavigation&&a):this._navNextButton.classList.remove("visible"))}_scrollPrevious(){const t=this._getSlottedButtons().length,e=this.visibleButtons;this._currentIndex>0?(this._currentIndex=Math.max(0,this._currentIndex-e),this._updateButtonVisibility("previous")):this._cyclicalNavigation&&t>e&&(this._currentIndex=Math.max(0,t-e),this._updateButtonVisibility("previous"))}_scrollNext(){const t=this._getSlottedButtons().length,e=this.visibleButtons,i=this._currentIndex+e;i<t?(this._currentIndex=i,this._updateButtonVisibility("next")):this._cyclicalNavigation&&t>e&&(this._currentIndex=0,this._updateButtonVisibility("next"))}scrollToButton(t){const e=this._getSlottedButtons().length,i=this.visibleButtons;t>=0&&t<e&&(this._currentIndex=Math.max(0,Math.min(t,e-i)),this._updateButtonVisibility())}getVisibleButtons(){return this._getSlottedButtons().filter(t=>t.classList.contains("visible-button"))}getAllButtons(){return this._getSlottedButtons()}getCurrentIndex(){return this._currentIndex}}const $c="bar-menu",tu=Object.freeze(Object.defineProperty({__proto__:null,BarMenuComponent:ni,selector:$c},Symbol.toStringTag,{value:"Module"}));new CSSStyleSheet().replaceSync("*{box-sizing:border-box}:host{display:inline-flex;align-items:center;justify-content:center}.spinner{display:inline-flex;align-items:center;justify-content:center}.spinner-ring{width:var(--spinner-size, 2rem);height:var(--spinner-size, 2rem);border:3px solid var(--color-border-primary);border-top-color:var(--color-primary);border-radius:var(--border-radius-full);animation:spin var(--transition-slow) linear infinite}:host([size=sm]) .spinner-ring{width:1rem;height:1rem;border-width:2px}:host([size=md]) .spinner-ring{width:2rem;height:2rem;border-width:3px}:host([size=lg]) .spinner-ring{width:3rem;height:3rem;border-width:4px}:host([variant=primary]) .spinner-ring{border-top-color:var(--color-primary)}:host([variant=success]) .spinner-ring{border-top-color:var(--color-success)}:host([variant=warning]) .spinner-ring{border-top-color:var(--color-warning)}:host([variant=error]) .spinner-ring{border-top-color:var(--color-error)}@keyframes spin{to{transform:rotate(360deg)}}"),new CSSStyleSheet().replaceSync("*{box-sizing:border-box}:host{display:block;width:100%}.progress-container{display:flex;flex-direction:column;gap:var(--gap-xs)}.progress-track{width:100%;height:.5rem;background-color:var(--color-bg-secondary);border-radius:var(--border-radius-full);overflow:hidden;border:1px solid var(--color-border-primary)}:host([size=sm]) .progress-track{height:.25rem}:host([size=md]) .progress-track{height:.5rem}:host([size=lg]) .progress-track{height:1rem}.progress-fill{height:100%;width:0%;background:var(--color-primary);border-radius:var(--border-radius-full);transition:width var(--transition-base) ease}:host([variant=success]) .progress-fill{background:var(--color-success)}:host([variant=warning]) .progress-fill{background:var(--color-warning)}:host([variant=error]) .progress-fill{background:var(--color-error)}:host([variant=info]) .progress-fill{background:var(--color-info)}:host([indeterminate]) .progress-fill{width:40%!important;animation:indeterminate var(--transition-slow) ease-in-out infinite}.progress-label{font-family:var(--font-family-base);font-size:var(--font-size-xs);color:var(--color-text-secondary);align-self:flex-end}:host(:not([show-label])) .progress-label{display:none}@keyframes indeterminate{0%{transform:translate(-100%)}to{transform:translate(350%)}}"),new CSSStyleSheet().replaceSync("*{box-sizing:border-box}:host{display:block;width:100%}.skeleton{background:linear-gradient(90deg,var(--color-bg-secondary) 25%,var(--color-bg-tertiary) 50%,var(--color-bg-secondary) 75%);background-size:200% 100%;border-radius:var(--border-radius-md);animation:shimmer 1.5s infinite;min-height:1rem;width:100%}:host([shape=circle]) .skeleton{border-radius:var(--border-radius-full);width:var(--skeleton-size, 3rem);height:var(--skeleton-size, 3rem)}:host([shape=text]) .skeleton{border-radius:var(--border-radius-sm);height:1em}:host([shape=rect]) .skeleton{border-radius:var(--border-radius-md)}:host([width=full]){width:100%}:host([width=half]){width:50%}:host([width=quarter]){width:25%}:host([width=three-quarters]){width:75%}@keyframes shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}"),new CSSStyleSheet().replaceSync(":host{display:block}:host(:not([loading])),:host([loading=false]){display:none}.cv-viewer__loader{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:32px;padding:48px;background:#1a1a1a;transition:opacity .4s ease;z-index:2}.cv-viewer__loader--hidden{opacity:0;pointer-events:none}.cv-viewer__loader-pulse{display:flex;flex-direction:column;gap:14px;width:min(520px,80%)}.cv-viewer__loader-bar{height:12px;border-radius:2px;background:linear-gradient(90deg,#ffffff0a 25%,#ffffff1a,#ffffff0a 75%);background-size:200% 100%;animation:shimmer 1.8s infinite}@keyframes shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}"),new CSSStyleSheet().replaceSync('*{box-sizing:border-box}:host{display:block}.card{background:var(--color-bg-secondary);border:1px solid var(--color-border-primary);border-radius:var(--border-radius-xl);box-shadow:var(--shadow-md);overflow:hidden;transition:box-shadow var(--transition-fast),transform var(--transition-fast),border-color var(--transition-fast);font-family:var(--font-family-base);color:var(--color-text-primary);position:relative}.card:before{content:"";display:block;height:2px;background:linear-gradient(90deg,var(--color-primary) 0%,var(--color-primary-light) 100%);opacity:0;transition:opacity var(--transition-fast)}:host([hoverable]) .card:hover{box-shadow:var(--shadow-xl);transform:translateY(-3px);border-color:var(--color-border-secondary)}:host([hoverable]) .card:hover:before{opacity:1}:host([variant=outlined]) .card{background:transparent;box-shadow:none;border:var(--border-width-2) solid var(--color-border-secondary)}:host([variant=elevated]) .card{background:var(--color-bg-primary);box-shadow:var(--shadow-xl);border:none}:host([variant=filled]) .card{background:var(--color-bg-secondary);border:none;box-shadow:none}.card-body{padding:var(--spacing-4) var(--spacing-5)}::slotted([slot=header]){display:block;padding:var(--spacing-5) var(--spacing-5) var(--spacing-2);font-size:var(--font-size-lg);font-weight:var(--font-weight-bold);color:var(--color-text-primary);letter-spacing:var(--letter-spacing-tight)}::slotted([slot=footer]){display:block;padding:var(--spacing-3) var(--spacing-5) var(--spacing-4);font-size:var(--font-size-sm);color:var(--color-text-secondary);border-top:1px solid var(--color-border-primary)}'),new CSSStyleSheet().replaceSync("*{box-sizing:border-box}:host{display:inline-flex}.badge{display:inline-flex;align-items:center;justify-content:center;gap:var(--gap-xs);padding-block:.2em;padding-inline:.6em;border-radius:var(--border-radius-full);font-family:var(--font-family-base);font-size:var(--font-size-xs);font-weight:var(--font-weight-semibold);line-height:1.4;white-space:nowrap;background-color:var(--color-primary);color:#fff;border:1px solid transparent}:host([variant=secondary]) .badge{background-color:var(--color-bg-secondary);color:var(--color-text-primary);border-color:var(--color-border-primary)}:host([variant=success]) .badge{background-color:var(--color-success);color:#fff}:host([variant=warning]) .badge{background-color:var(--color-warning);color:#1a1a1a}:host([variant=error]) .badge{background-color:var(--color-error);color:#fff}:host([variant=info]) .badge{background-color:var(--color-info);color:#fff}:host([variant=outline]) .badge{background-color:transparent;color:var(--color-primary);border-color:var(--color-primary)}:host([size=sm]) .badge{font-size:.65rem;padding-block:.1em;padding-inline:.4em}:host([size=lg]) .badge{font-size:var(--font-size-sm);padding-block:.3em;padding-inline:.8em}:host([dot]) .badge{width:.5rem;height:.5rem;padding:0;font-size:0}"),new CSSStyleSheet().replaceSync('@charset "UTF-8";*{box-sizing:border-box}:host{display:block}:host([hidden]){display:none}.alert{display:flex;align-items:center;gap:var(--gap-sm);padding:var(--spacing-3);border-radius:var(--border-radius-lg);border-left:4px solid var(--color-primary);background-color:var(--color-bg-secondary);color:var(--color-text-primary);font-family:var(--font-family-base);font-size:var(--font-size-sm);line-height:var(--line-height-normal);animation:alertIn var(--transition-fast) ease-out}:host([variant=success]) .alert{border-left-color:#22c55e;background-color:#1a3f1f;color:#d1fae5}:host([variant=warning]) .alert{border-left-color:#facc15;background-color:#3f3011;color:#e0c600}:host([variant=error]) .alert{border-left-color:#dc2626;background-color:color-mix(in srgb,#dc2626 10%,var(--color-bg-primary))}:host([variant=info]) .alert{border-left-color:var(--color-primary);background-color:color-mix(in srgb,var(--color-primary) 15%,var(--color-bg-primary));color:var(--color-text-primary)}.alert-icon{font-size:var(--font-size-lg);flex-shrink:0;display:flex;align-items:center;justify-content:center;min-width:1.25em;height:1.25em}:host([variant=success]) .alert-icon:before{content:"✓"}:host([variant=warning]) .alert-icon:before{content:"⚠"}:host([variant=error]) .alert-icon:before{content:"✕"}:host([variant=info]) .alert-icon:before{content:"ℹ"}.alert-content{flex:1;min-width:0;padding:0 var(--gap-sm);border-left:1px solid}::slotted([slot=title]){display:block;font-weight:var(--font-weight-semibold);font-size:var(--font-size-md);margin-bottom:var(--spacing-1)}.alert-close{flex-shrink:0;background:transparent;border:none;cursor:pointer;padding:var(--spacing-1);border-radius:var(--border-radius-sm);color:var(--color-text-secondary);font-size:var(--font-size-md);line-height:1;display:flex;align-items:center;justify-content:center;transition:background var(--transition-fast),color var(--transition-fast)}.alert-close:hover{background:var(--color-hover-bg-secondary);color:var(--color-text-primary)}:host(:not([dismissible])) .alert-close{display:none}@keyframes alertIn{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}'),new CSSStyleSheet().replaceSync("*{box-sizing:border-box}:host{display:inline-flex}.tag{display:inline-flex;align-items:center;gap:var(--gap-xs);padding-block:.25em;padding-inline:.75em;border-radius:var(--border-radius-full);font-family:var(--font-family-base);font-size:var(--font-size-sm);font-weight:var(--font-weight-medium);background-color:var(--color-bg-secondary);color:var(--color-text-primary);border:1px solid var(--color-border-primary);transition:all var(--transition-fast)}:host([variant=primary]) .tag{background-color:var(--color-primary);color:#fff;border-color:transparent}:host([variant=success]) .tag{background-color:var(--color-success);color:#fff;border-color:transparent}:host([variant=warning]) .tag{background-color:var(--color-warning);color:#1a1a1a;border-color:transparent}:host([variant=error]) .tag{background-color:var(--color-error);color:#fff;border-color:transparent}:host([size=sm]) .tag{font-size:var(--font-size-xs);padding-block:.15em;padding-inline:.5em}:host([size=lg]) .tag{font-size:var(--font-size-md);padding-block:.35em;padding-inline:1em}.tag-remove{display:none;background:transparent;border:none;cursor:pointer;padding:0;font-size:.75em;color:inherit;opacity:.7;line-height:1;border-radius:var(--border-radius-full);transition:opacity var(--transition-fast)}:host([removable]) .tag-remove{display:inline-flex;align-items:center;justify-content:center}.tag-remove:hover{opacity:1}"),new CSSStyleSheet().replaceSync("*{box-sizing:border-box}:host{display:inline-flex}.avatar{position:relative;display:inline-flex;align-items:center;justify-content:center;width:2.5rem;height:2.5rem;border-radius:var(--border-radius-full);background-color:var(--color-primary);color:#fff;font-family:var(--font-family-base);font-weight:var(--font-weight-semibold);font-size:var(--font-size-sm);overflow:hidden;-webkit-user-select:none;user-select:none;flex-shrink:0}:host([size=xs]) .avatar{width:1.5rem;height:1.5rem;font-size:var(--font-size-xs)}:host([size=sm]) .avatar{width:2rem;height:2rem;font-size:var(--font-size-xs)}:host([size=md]) .avatar{width:2.5rem;height:2.5rem;font-size:var(--font-size-sm)}:host([size=lg]) .avatar{width:3.5rem;height:3.5rem;font-size:var(--font-size-lg)}:host([size=xl]) .avatar{width:5rem;height:5rem;font-size:var(--font-size-2xl)}:host([shape=square]) .avatar{border-radius:var(--border-radius-md)}:host([shape=rounded]) .avatar{border-radius:var(--border-radius-lg)}:host([color=secondary]) .avatar{background-color:var(--color-bg-secondary);color:var(--color-text-primary);border:1px solid var(--color-border-primary)}:host([color=success]) .avatar{background-color:var(--color-success)}:host([color=warning]) .avatar{background-color:var(--color-warning);color:#1a1a1a}:host([color=error]) .avatar{background-color:var(--color-error)}.avatar-image{width:100%;height:100%;object-fit:cover;display:none;border-radius:inherit}.avatar-initials{display:none;line-height:1}.avatar-icon{display:flex;font-size:1.2em;line-height:1}:host([src]) .avatar-image{display:block}:host([src]) .avatar-initials{display:none}:host([src]) .avatar-icon{display:none}:host([initials]:not([src])) .avatar-initials{display:block}:host([initials]:not([src])) .avatar-icon{display:none}"),new CSSStyleSheet().replaceSync("*{box-sizing:border-box}:host{position:relative;display:inline-flex;align-items:center}.tooltip{position:absolute;z-index:var(--z-index-tooltip, 1070);bottom:calc(100% + .5rem);left:50%;transform:translate(-50%);padding:var(--spacing-1) var(--spacing-2);background-color:var(--color-bg-tertiary, #1e1e2e);color:var(--color-text-primary);font-family:var(--font-family-base);font-size:var(--font-size-xs);line-height:var(--line-height-normal);border-radius:var(--border-radius-md);box-shadow:var(--shadow-lg);white-space:nowrap;pointer-events:none;opacity:0;visibility:hidden;transition:opacity var(--transition-fast),visibility var(--transition-fast);max-width:16rem;white-space:normal;text-align:center}:host([placement=bottom]) .tooltip{bottom:auto;top:calc(100% + .5rem)}:host([placement=left]) .tooltip{bottom:auto;left:auto;right:calc(100% + .5rem);top:50%;transform:translateY(-50%)}:host([placement=right]) .tooltip{bottom:auto;left:calc(100% + .5rem);top:50%;transform:translateY(-50%)}:host([open]) .tooltip,:host(:hover) .tooltip,:host(:focus-within) .tooltip{opacity:1;visibility:visible}:host([follow-cursor]) .tooltip{position:fixed;bottom:auto;left:0;top:0;transform:none}:host([follow-cursor]) .tooltip{opacity:1;visibility:visible}"),new CSSStyleSheet().replaceSync("*{box-sizing:border-box}:host{display:block;width:100%}.input-wrapper{display:flex;flex-direction:column;gap:var(--gap-xs);font-family:var(--font-family-base)}.input-label{font-size:var(--font-size-sm);font-weight:var(--font-weight-medium);color:var(--color-text-primary)}.input-label:empty{display:none}.input-container{display:flex;align-items:center;background-color:var(--color-bg-primary);border:1px solid var(--color-border-primary);border-radius:var(--border-radius-md);transition:border-color var(--transition-fast),box-shadow var(--transition-fast);overflow:hidden}.input-container:focus-within{border-color:var(--color-primary);box-shadow:0 0 0 3px color-mix(in srgb,var(--color-primary) 20%,transparent);outline:none}:host([state=error]) .input-container{border-color:#dc2626;box-shadow:none}:host([state=error]) .input-container:focus-within{box-shadow:0 0 0 3px color-mix(in srgb,#dc2626 20%,transparent)}:host([state=success]) .input-container{border-color:var(--color-success)}.input{flex:1;min-width:0;padding:var(--spacing-2) var(--spacing-3);background:transparent;border:none;outline:none;font-family:var(--font-family-base);font-size:var(--font-size-sm);color:var(--color-text-primary);line-height:var(--line-height-normal)}.input::placeholder{color:var(--color-text-secondary);opacity:.7}.input:disabled{opacity:.5;cursor:not-allowed}:host([size=sm]) .input{padding:var(--spacing-1) var(--spacing-2);font-size:var(--font-size-xs)}:host([size=lg]) .input{padding:var(--spacing-3) var(--spacing-4);font-size:var(--font-size-md)}.input-helper{font-size:var(--font-size-xs);color:var(--color-text-secondary)}.input-helper:empty{display:none}:host([state=error]) .input-helper{color:#dc2626}:host([state=success]) .input-helper{color:var(--color-success)}::slotted([slot=prefix]),::slotted([slot=suffix]){display:flex;align-items:center;padding-inline:var(--spacing-2);color:var(--color-text-secondary);font-size:var(--font-size-sm);flex-shrink:0}"),new CSSStyleSheet().replaceSync("*{box-sizing:border-box}:host{display:inline-flex}.toggle-wrapper{display:inline-flex;align-items:center;gap:var(--gap-sm);cursor:pointer;-webkit-user-select:none;user-select:none;font-family:var(--font-family-base);font-size:var(--font-size-sm);color:var(--color-text-primary)}.toggle-input{position:absolute;opacity:0;width:0;height:0}.toggle-track{position:relative;display:inline-flex;align-items:center;width:2.75rem;height:1.5rem;border-radius:var(--border-radius-full);background-color:var(--color-border-primary);transition:background-color var(--transition-fast);flex-shrink:0}.toggle-input:checked+.toggle-track{background-color:var(--color-primary)}.toggle-thumb{position:absolute;left:3px;width:1.125rem;height:1.125rem;border-radius:var(--border-radius-full);background-color:#fff;box-shadow:var(--shadow-sm);transition:transform var(--transition-fast)}.toggle-input:checked+.toggle-track .toggle-thumb{transform:translate(1.25rem)}.toggle-input:focus-visible+.toggle-track{outline:2px solid var(--color-primary);outline-offset:2px}.toggle-input:disabled+.toggle-track{opacity:.4;cursor:not-allowed}:host([disabled]) .toggle-wrapper{cursor:not-allowed;opacity:.5}:host([size=sm]) .toggle-track{width:2rem;height:1.125rem}:host([size=sm]) .toggle-thumb{width:.875rem;height:.875rem}:host([size=sm]) .toggle-input:checked+.toggle-track .toggle-thumb{transform:translate(.875rem)}:host([size=lg]) .toggle-track{width:3.5rem;height:2rem}:host([size=lg]) .toggle-thumb{width:1.5rem;height:1.5rem}:host([size=lg]) .toggle-input:checked+.toggle-track .toggle-thumb{transform:translate(1.5rem)}:host([variant=success]) .toggle-input:checked+.toggle-track{background-color:var(--color-success)}:host([variant=warning]) .toggle-input:checked+.toggle-track{background-color:var(--color-warning)}:host([variant=error]) .toggle-input:checked+.toggle-track{background-color:var(--color-error)}.toggle-label:empty{display:none}");const He="srgb",Zl="srgb-linear",Jl="linear",Ea="srgb";function eu(r){for(let t=r.length-1;t>=0;--t)if(r[t]>=65535)return!0;return!1}function jl(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}const Ql={};function ql(r){const t=r[0];if(typeof t=="string"&&t.startsWith("TSL:")){const e=r[1];e&&e.isStackTrace?r[0]+=" "+e.getLocation():r[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return r}function be(...r){r=ql(r);const t="THREE."+r.shift();{const e=r[0];e&&e.isStackTrace?console.warn(e.getError(t)):console.warn(t,...r)}}function vn(...r){r=ql(r);const t="THREE."+r.shift();{const e=r[0];e&&e.isStackTrace?console.error(e.getError(t)):console.error(t,...r)}}function Kl(...r){const t=r.join(" ");t in Ql||(Ql[t]=!0,be(...r))}class pr{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[t]===void 0&&(i[t]=[]),i[t].indexOf(e)===-1&&i[t].push(e)}hasEventListener(t,e){const i=this._listeners;return i===void 0?!1:i[t]!==void 0&&i[t].indexOf(e)!==-1}removeEventListener(t,e){const i=this._listeners;if(i===void 0)return;const n=i[t];if(n!==void 0){const s=n.indexOf(e);s!==-1&&n.splice(s,1)}}dispatchEvent(t){const e=this._listeners;if(e===void 0)return;const i=e[t.type];if(i!==void 0){t.target=this;const n=i.slice(0);for(let s=0,a=n.length;s<a;s++)n[s].call(this,t);t.target=null}}}const Me=["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"];function zs(){const r=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Me[r&255]+Me[r>>8&255]+Me[r>>16&255]+Me[r>>24&255]+"-"+Me[t&255]+Me[t>>8&255]+"-"+Me[t>>16&15|64]+Me[t>>24&255]+"-"+Me[e&63|128]+Me[e>>8&255]+"-"+Me[e>>16&255]+Me[e>>24&255]+Me[i&255]+Me[i>>8&255]+Me[i>>16&255]+Me[i>>24&255]).toLowerCase()}function Gt(r,t,e){return Math.max(t,Math.min(e,r))}function iu(r,t){return(r%t+t)%t}function Sa(r,t,e){return(1-e)*r+e*t}function ks(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function Be(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}class Ve{constructor(t=0,e=0){Ve.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=Gt(this.x,t.x,e.x),this.y=Gt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Gt(this.x,t,e),this.y=Gt(this.y,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Gt(i,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(Gt(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,a=this.y-t.y;return this.x=s*i-a*n+t.x,this.y=s*n+a*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Gs{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,a,o){let A=i[n+0],l=i[n+1],h=i[n+2],c=i[n+3],u=s[a+0],d=s[a+1],p=s[a+2],m=s[a+3];if(c!==m||A!==u||l!==d||h!==p){let g=A*u+l*d+h*p+c*m;g<0&&(u=-u,d=-d,p=-p,m=-m,g=-g);let f=1-o;if(g<.9995){const b=Math.acos(g),S=Math.sin(b);f=Math.sin(f*b)/S,o=Math.sin(o*b)/S,A=A*f+u*o,l=l*f+d*o,h=h*f+p*o,c=c*f+m*o}else{A=A*f+u*o,l=l*f+d*o,h=h*f+p*o,c=c*f+m*o;const b=1/Math.sqrt(A*A+l*l+h*h+c*c);A*=b,l*=b,h*=b,c*=b}}t[e]=A,t[e+1]=l,t[e+2]=h,t[e+3]=c}static multiplyQuaternionsFlat(t,e,i,n,s,a){const o=i[n],A=i[n+1],l=i[n+2],h=i[n+3],c=s[a],u=s[a+1],d=s[a+2],p=s[a+3];return t[e]=o*p+h*c+A*d-l*u,t[e+1]=A*p+h*u+l*c-o*d,t[e+2]=l*p+h*d+o*u-A*c,t[e+3]=h*p-o*c-A*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,a=t._order,o=Math.cos,A=Math.sin,l=o(i/2),h=o(n/2),c=o(s/2),u=A(i/2),d=A(n/2),p=A(s/2);switch(a){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;break;default:be("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&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],a=e[1],o=e[5],A=e[9],l=e[2],h=e[6],c=e[10],u=i+o+c;if(u>0){const d=.5/Math.sqrt(u+1);this._w=.25/d,this._x=(h-A)*d,this._y=(s-l)*d,this._z=(a-n)*d}else if(i>o&&i>c){const d=2*Math.sqrt(1+i-o-c);this._w=(h-A)/d,this._x=.25*d,this._y=(n+a)/d,this._z=(s+l)/d}else if(o>c){const d=2*Math.sqrt(1+o-i-c);this._w=(s-l)/d,this._x=(n+a)/d,this._y=.25*d,this._z=(A+h)/d}else{const d=2*Math.sqrt(1+c-i-o);this._w=(a-n)/d,this._x=(s+l)/d,this._y=(A+h)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<1e-8?(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(Gt(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(i===0)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 t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const i=t._x,n=t._y,s=t._z,a=t._w,o=e._x,A=e._y,l=e._z,h=e._w;return this._x=i*h+a*o+n*l-s*A,this._y=n*h+a*A+s*o-i*l,this._z=s*h+a*l+i*A-n*o,this._w=a*h-i*o-n*A-s*l,this._onChangeCallback(),this}slerp(t,e){let i=t._x,n=t._y,s=t._z,a=t._w,o=this.dot(t);o<0&&(i=-i,n=-n,s=-s,a=-a,o=-o);let A=1-e;if(o<.9995){const l=Math.acos(o),h=Math.sin(l);A=Math.sin(A*l)/h,e=Math.sin(e*l)/h,this._x=this._x*A+i*e,this._y=this._y*A+n*e,this._z=this._z*A+s*e,this._w=this._w*A+a*e,this._onChangeCallback()}else this._x=this._x*A+i*e,this._y=this._y*A+n*e,this._z=this._z*A+s*e,this._w=this._w*A+a*e,this.normalize();return this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),n=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(n*Math.sin(t),n*Math.cos(t),s*Math.sin(e),s*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class V{constructor(t=0,e=0,i=0){V.prototype.isVector3=!0,this.x=t,this.y=e,this.z=i}set(t,e,i){return i===void 0&&(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($l.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion($l.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,a=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])*a,this.y=(s[1]*e+s[5]*i+s[9]*n+s[13])*a,this.z=(s[2]*e+s[6]*i+s[10]*n+s[14])*a,this}applyQuaternion(t){const e=this.x,i=this.y,n=this.z,s=t.x,a=t.y,o=t.z,A=t.w,l=2*(a*n-o*i),h=2*(o*e-s*n),c=2*(s*i-a*e);return this.x=e+A*l+a*c-o*h,this.y=i+A*h+o*l-s*c,this.z=n+A*c+s*h-a*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=Gt(this.x,t.x,e.x),this.y=Gt(this.y,t.y,e.y),this.z=Gt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Gt(this.x,t,e),this.y=Gt(this.y,t,e),this.z=Gt(this.z,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Gt(i,t,e))}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,a=e.x,o=e.y,A=e.z;return this.x=n*A-s*o,this.y=s*a-i*A,this.z=i*o-n*a,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return ya.copy(this).projectOnVector(t),this.sub(ya)}reflect(t){return this.sub(ya.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(Gt(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,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,i=Math.sqrt(1-e*e);return this.x=i*Math.cos(t),this.y=e,this.z=i*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const ya=new V,$l=new Gs;class tn{constructor(t,e,i,n,s,a,o,A,l){tn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,i,n,s,a,o,A,l)}set(t,e,i,n,s,a,o,A,l){const h=this.elements;return h[0]=t,h[1]=n,h[2]=o,h[3]=e,h[4]=s,h[5]=A,h[6]=i,h[7]=a,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,a=i[0],o=i[3],A=i[6],l=i[1],h=i[4],c=i[7],u=i[2],d=i[5],p=i[8],m=n[0],g=n[3],f=n[6],b=n[1],S=n[4],v=n[7],T=n[2],w=n[5],R=n[8];return s[0]=a*m+o*b+A*T,s[3]=a*g+o*S+A*w,s[6]=a*f+o*v+A*R,s[1]=l*m+h*b+c*T,s[4]=l*g+h*S+c*w,s[7]=l*f+h*v+c*R,s[2]=u*m+d*b+p*T,s[5]=u*g+d*S+p*w,s[8]=u*f+d*v+p*R,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],a=t[4],o=t[5],A=t[6],l=t[7],h=t[8];return e*a*h-e*o*l-i*s*h+i*o*A+n*s*l-n*a*A}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],s=t[3],a=t[4],o=t[5],A=t[6],l=t[7],h=t[8],c=h*a-o*l,u=o*A-h*s,d=l*s-a*A,p=e*c+i*u+n*d;if(p===0)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]=(o*i-n*a)*m,t[3]=u*m,t[4]=(h*e-n*A)*m,t[5]=(n*s-o*e)*m,t[6]=d*m,t[7]=(i*A-l*e)*m,t[8]=(a*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,a,o){const A=Math.cos(s),l=Math.sin(s);return this.set(i*A,i*l,-i*(A*a+l*o)+a+t,-n*l,n*A,-n*(-l*a+A*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(ba.makeScale(t,e)),this}rotate(t){return this.premultiply(ba.makeRotation(-t)),this}translate(t,e){return this.premultiply(ba.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 ba=new tn,tA=new tn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),eA=new tn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function nu(){const r={enabled:!0,workingColorSpace:Zl,spaces:{},convert:function(n,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Ea&&(n.r=Di(n.r),n.g=Di(n.g),n.b=Di(n.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(n.applyMatrix3(this.spaces[s].toXYZ),n.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Ea&&(n.r=Jn(n.r),n.g=Jn(n.g),n.b=Jn(n.b))),n},workingToColorSpace:function(n,s){return this.convert(n,this.workingColorSpace,s)},colorSpaceToWorking:function(n,s){return this.convert(n,s,this.workingColorSpace)},getPrimaries:function(n){return this.spaces[n].primaries},getTransfer:function(n){return n===""?Jl:this.spaces[n].transfer},getToneMappingMode:function(n){return this.spaces[n].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(n,s=this.workingColorSpace){return n.fromArray(this.spaces[s].luminanceCoefficients)},define:function(n){Object.assign(this.spaces,n)},_getMatrix:function(n,s,a){return n.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(n){return this.spaces[n].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(n=this.workingColorSpace){return this.spaces[n].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(n,s){return Kl("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),r.workingToColorSpace(n,s)},toWorkingColorSpace:function(n,s){return Kl("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),r.colorSpaceToWorking(n,s)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],i=[.3127,.329];return r.define({[Zl]:{primaries:t,whitePoint:i,transfer:Jl,toXYZ:tA,fromXYZ:eA,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:He},outputColorSpaceConfig:{drawingBufferColorSpace:He}},[He]:{primaries:t,whitePoint:i,transfer:Ea,toXYZ:tA,fromXYZ:eA,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:He}}}),r}const si=nu();function Di(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function Jn(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let jn;class su{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let i;if(t instanceof HTMLCanvasElement)i=t;else{jn===void 0&&(jn=jl("canvas")),jn.width=t.width,jn.height=t.height;const n=jn.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),i=jn}return i.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=jl("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 a=0;a<s.length;a++)s[a]=Di(s[a]/255)*255;return i.putImageData(n,0,0),e}else if(t.data){const e=t.data.slice(0);for(let i=0;i<e.length;i++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[i]=Math.floor(Di(e[i]/255)*255):e[i]=Di(e[i]);return{data:e,width:t.width,height:t.height}}else return be("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let ru=0;class au{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:ru++}),this.uuid=zs(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):typeof VideoFrame<"u"&&e instanceof VideoFrame?t.set(e.displayHeight,e.displayWidth,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const i={uuid:this.uuid,url:""},n=this.data;if(n!==null){let s;if(Array.isArray(n)){s=[];for(let a=0,o=n.length;a<o;a++)n[a].isDataTexture?s.push(Ma(n[a].image)):s.push(Ma(n[a]))}else s=Ma(n);i.url=s}return e||(t.images[this.uuid]=i),i}}function Ma(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?su.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(be("Texture: Unable to serialize Texture."),{})}let ou=0;const wa=new V;class Ii extends pr{constructor(t=Ii.DEFAULT_IMAGE,e=Ii.DEFAULT_MAPPING,i=1001,n=1001,s=1006,a=1008,o=1023,A=1009,l=Ii.DEFAULT_ANISOTROPY,h=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:ou++}),this.uuid=zs(),this.name="",this.source=new au(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=s,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=A,this.offset=new Ve(0,0),this.repeat=new Ve(1,1),this.center=new Ve(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new tn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(wa).x}get height(){return this.source.getSize(wa).y}get depth(){return this.source.getSize(wa).z}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)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}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.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const i=t[e];if(i===void 0){be(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const n=this[e];if(n===void 0){be(`Texture.setValues(): property '${e}' does not exist.`);continue}n&&i&&n.isVector2&&i.isVector2||n&&i&&n.isVector3&&i.isVector3||n&&i&&n.isMatrix3&&i.isMatrix3?n.copy(i):this[e]=i}}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const i={metadata:{version:4.7,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!==300)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case 1e3:t.x=t.x-Math.floor(t.x);break;case 1001:t.x=t.x<0?0:1;break;case 1002:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case 1e3:t.y=t.y-Math.floor(t.y);break;case 1001:t.y=t.y<0?0:1;break;case 1002:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}Ii.DEFAULT_IMAGE=null,Ii.DEFAULT_MAPPING=300,Ii.DEFAULT_ANISOTROPY=1;class Hs{constructor(t=0,e=0,i=0,n=1){Hs.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=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,s=this.w,a=t.elements;return this.x=a[0]*e+a[4]*i+a[8]*n+a[12]*s,this.y=a[1]*e+a[5]*i+a[9]*n+a[13]*s,this.z=a[2]*e+a[6]*i+a[10]*n+a[14]*s,this.w=a[3]*e+a[7]*i+a[11]*n+a[15]*s,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,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 a=t.elements,o=a[0],A=a[4],l=a[8],h=a[1],c=a[5],u=a[9],d=a[2],p=a[6],m=a[10];if(Math.abs(A-h)<.01&&Math.abs(l-d)<.01&&Math.abs(u-p)<.01){if(Math.abs(A+h)<.1&&Math.abs(l+d)<.1&&Math.abs(u+p)<.1&&Math.abs(o+c+m-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const f=(o+1)/2,b=(c+1)/2,S=(m+1)/2,v=(A+h)/4,T=(l+d)/4,w=(u+p)/4;return f>b&&f>S?f<.01?(i=0,n=.707106781,s=.707106781):(i=Math.sqrt(f),n=v/i,s=T/i):b>S?b<.01?(i=.707106781,n=0,s=.707106781):(n=Math.sqrt(b),i=v/n,s=w/n):S<.01?(i=.707106781,n=.707106781,s=0):(s=Math.sqrt(S),i=T/s,n=w/s),this.set(i,n,s,e),this}let g=Math.sqrt((p-u)*(p-u)+(l-d)*(l-d)+(h-A)*(h-A));return Math.abs(g)<.001&&(g=1),this.x=(p-u)/g,this.y=(l-d)/g,this.z=(h-A)/g,this.w=Math.acos((o+c+m-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Gt(this.x,t.x,e.x),this.y=Gt(this.y,t.y,e.y),this.z=Gt(this.z,t.z,e.z),this.w=Gt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=Gt(this.x,t,e),this.y=Gt(this.y,t,e),this.z=Gt(this.z,t,e),this.w=Gt(this.w,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Gt(i,t,e))}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 ri{constructor(t,e,i,n,s,a,o,A,l,h,c,u,d,p,m,g){ri.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,i,n,s,a,o,A,l,h,c,u,d,p,m,g)}set(t,e,i,n,s,a,o,A,l,h,c,u,d,p,m,g){const f=this.elements;return f[0]=t,f[4]=e,f[8]=i,f[12]=n,f[1]=s,f[5]=a,f[9]=o,f[13]=A,f[2]=l,f[6]=h,f[10]=c,f[14]=u,f[3]=d,f[7]=p,f[11]=m,f[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new ri().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 this.determinant()===0?(t.set(1,0,0),e.set(0,1,0),i.set(0,0,1),this):(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){if(t.determinant()===0)return this.identity();const e=this.elements,i=t.elements,n=1/Qn.setFromMatrixColumn(t,0).length(),s=1/Qn.setFromMatrixColumn(t,1).length(),a=1/Qn.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]*a,e[9]=i[9]*a,e[10]=i[10]*a,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,a=Math.cos(i),o=Math.sin(i),A=Math.cos(n),l=Math.sin(n),h=Math.cos(s),c=Math.sin(s);if(t.order==="XYZ"){const u=a*h,d=a*c,p=o*h,m=o*c;e[0]=A*h,e[4]=-A*c,e[8]=l,e[1]=d+p*l,e[5]=u-m*l,e[9]=-o*A,e[2]=m-u*l,e[6]=p+d*l,e[10]=a*A}else if(t.order==="YXZ"){const u=A*h,d=A*c,p=l*h,m=l*c;e[0]=u+m*o,e[4]=p*o-d,e[8]=a*l,e[1]=a*c,e[5]=a*h,e[9]=-o,e[2]=d*o-p,e[6]=m+u*o,e[10]=a*A}else if(t.order==="ZXY"){const u=A*h,d=A*c,p=l*h,m=l*c;e[0]=u-m*o,e[4]=-a*c,e[8]=p+d*o,e[1]=d+p*o,e[5]=a*h,e[9]=m-u*o,e[2]=-a*l,e[6]=o,e[10]=a*A}else if(t.order==="ZYX"){const u=a*h,d=a*c,p=o*h,m=o*c;e[0]=A*h,e[4]=p*l-d,e[8]=u*l+m,e[1]=A*c,e[5]=m*l+u,e[9]=d*l-p,e[2]=-l,e[6]=o*A,e[10]=a*A}else if(t.order==="YZX"){const u=a*A,d=a*l,p=o*A,m=o*l;e[0]=A*h,e[4]=m-u*c,e[8]=p*c+d,e[1]=c,e[5]=a*h,e[9]=-o*h,e[2]=-l*h,e[6]=d*c+p,e[10]=u-m*c}else if(t.order==="XZY"){const u=a*A,d=a*l,p=o*A,m=o*l;e[0]=A*h,e[4]=-c,e[8]=l*h,e[1]=u*c+m,e[5]=a*h,e[9]=d*c-p,e[2]=p*c-d,e[6]=o*h,e[10]=m*c+u}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(lu,t,Au)}lookAt(t,e,i){const n=this.elements;return We.subVectors(t,e),We.lengthSq()===0&&(We.z=1),We.normalize(),en.crossVectors(i,We),en.lengthSq()===0&&(Math.abs(i.z)===1?We.x+=1e-4:We.z+=1e-4,We.normalize(),en.crossVectors(i,We)),en.normalize(),mr.crossVectors(We,en),n[0]=en.x,n[4]=mr.x,n[8]=We.x,n[1]=en.y,n[5]=mr.y,n[9]=We.y,n[2]=en.z,n[6]=mr.z,n[10]=We.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,a=i[0],o=i[4],A=i[8],l=i[12],h=i[1],c=i[5],u=i[9],d=i[13],p=i[2],m=i[6],g=i[10],f=i[14],b=i[3],S=i[7],v=i[11],T=i[15],w=n[0],R=n[4],P=n[8],E=n[12],x=n[1],M=n[5],z=n[9],O=n[13],U=n[2],W=n[6],Y=n[10],$=n[14],H=n[3],rt=n[7],At=n[11],mt=n[15];return s[0]=a*w+o*x+A*U+l*H,s[4]=a*R+o*M+A*W+l*rt,s[8]=a*P+o*z+A*Y+l*At,s[12]=a*E+o*O+A*$+l*mt,s[1]=h*w+c*x+u*U+d*H,s[5]=h*R+c*M+u*W+d*rt,s[9]=h*P+c*z+u*Y+d*At,s[13]=h*E+c*O+u*$+d*mt,s[2]=p*w+m*x+g*U+f*H,s[6]=p*R+m*M+g*W+f*rt,s[10]=p*P+m*z+g*Y+f*At,s[14]=p*E+m*O+g*$+f*mt,s[3]=b*w+S*x+v*U+T*H,s[7]=b*R+S*M+v*W+T*rt,s[11]=b*P+S*z+v*Y+T*At,s[15]=b*E+S*O+v*$+T*mt,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],a=t[1],o=t[5],A=t[9],l=t[13],h=t[2],c=t[6],u=t[10],d=t[14],p=t[3],m=t[7],g=t[11],f=t[15],b=A*d-l*u,S=o*d-l*c,v=o*u-A*c,T=a*d-l*h,w=a*u-A*h,R=a*c-o*h;return e*(m*b-g*S+f*v)-i*(p*b-g*T+f*w)+n*(p*S-m*T+f*R)-s*(p*v-m*w+g*R)}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],a=t[4],o=t[5],A=t[6],l=t[7],h=t[8],c=t[9],u=t[10],d=t[11],p=t[12],m=t[13],g=t[14],f=t[15],b=e*o-i*a,S=e*A-n*a,v=e*l-s*a,T=i*A-n*o,w=i*l-s*o,R=n*l-s*A,P=h*m-c*p,E=h*g-u*p,x=h*f-d*p,M=c*g-u*m,z=c*f-d*m,O=u*f-d*g,U=b*O-S*z+v*M+T*x-w*E+R*P;if(U===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const W=1/U;return t[0]=(o*O-A*z+l*M)*W,t[1]=(n*z-i*O-s*M)*W,t[2]=(m*R-g*w+f*T)*W,t[3]=(u*w-c*R-d*T)*W,t[4]=(A*x-a*O-l*E)*W,t[5]=(e*O-n*x+s*E)*W,t[6]=(g*v-p*R-f*S)*W,t[7]=(h*R-u*v+d*S)*W,t[8]=(a*z-o*x+l*P)*W,t[9]=(i*x-e*z-s*P)*W,t[10]=(p*w-m*v+f*b)*W,t[11]=(c*v-h*w-d*b)*W,t[12]=(o*E-a*M-A*P)*W,t[13]=(e*M-i*E+n*P)*W,t[14]=(m*S-p*T-g*b)*W,t[15]=(h*T-c*S+u*b)*W,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,a=t.x,o=t.y,A=t.z,l=s*a,h=s*o;return this.set(l*a+i,l*o-n*A,l*A+n*o,0,l*o+n*A,h*o+i,h*A-n*a,0,l*A-n*o,h*A+n*a,s*A*A+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,a){return this.set(1,i,s,0,t,1,a,0,e,n,1,0,0,0,0,1),this}compose(t,e,i){const n=this.elements,s=e._x,a=e._y,o=e._z,A=e._w,l=s+s,h=a+a,c=o+o,u=s*l,d=s*h,p=s*c,m=a*h,g=a*c,f=o*c,b=A*l,S=A*h,v=A*c,T=i.x,w=i.y,R=i.z;return n[0]=(1-(m+f))*T,n[1]=(d+v)*T,n[2]=(p-S)*T,n[3]=0,n[4]=(d-v)*w,n[5]=(1-(u+f))*w,n[6]=(g+b)*w,n[7]=0,n[8]=(p+S)*R,n[9]=(g-b)*R,n[10]=(1-(u+m))*R,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;t.x=n[12],t.y=n[13],t.z=n[14];const s=this.determinant();if(s===0)return i.set(1,1,1),e.identity(),this;let a=Qn.set(n[0],n[1],n[2]).length();const o=Qn.set(n[4],n[5],n[6]).length(),A=Qn.set(n[8],n[9],n[10]).length();s<0&&(a=-a),ai.copy(this);const l=1/a,h=1/o,c=1/A;return ai.elements[0]*=l,ai.elements[1]*=l,ai.elements[2]*=l,ai.elements[4]*=h,ai.elements[5]*=h,ai.elements[6]*=h,ai.elements[8]*=c,ai.elements[9]*=c,ai.elements[10]*=c,e.setFromRotationMatrix(ai),i.x=a,i.y=o,i.z=A,this}makePerspective(t,e,i,n,s,a,o=2e3,A=!1){const l=this.elements,h=2*s/(e-t),c=2*s/(i-n),u=(e+t)/(e-t),d=(i+n)/(i-n);let p,m;if(A)p=s/(a-s),m=a*s/(a-s);else if(o===2e3)p=-(a+s)/(a-s),m=-2*a*s/(a-s);else if(o===2001)p=-a/(a-s),m=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=c,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,i,n,s,a,o=2e3,A=!1){const l=this.elements,h=2/(e-t),c=2/(i-n),u=-(e+t)/(e-t),d=-(i+n)/(i-n);let p,m;if(A)p=1/(a-s),m=a/(a-s);else if(o===2e3)p=-2/(a-s),m=-(a+s)/(a-s);else if(o===2001)p=-1/(a-s),m=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=0,l[12]=u,l[1]=0,l[5]=c,l[9]=0,l[13]=d,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=0,l[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 Qn=new V,ai=new ri,lu=new V(0,0,0),Au=new V(1,1,1),en=new V,mr=new V,We=new V,iA=new ri,nA=new Gs;class qn{constructor(t=0,e=0,i=0,n=qn.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],a=n[4],o=n[8],A=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(Gt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Gt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(A,l)):(this._y=Math.atan2(-c,s),this._z=0);break;case"ZXY":this._x=Math.asin(Gt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(A,s));break;case"ZYX":this._y=Math.asin(-Gt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(A,s)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(Gt(A,-1,1)),Math.abs(A)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-c,s)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-Gt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,d),this._y=0);break;default:be("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,i===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return iA.makeRotationFromQuaternion(t),this.setFromRotationMatrix(iA,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return nA.setFromEuler(this),this.setFromQuaternion(nA,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}qn.DEFAULT_ORDER="XYZ";class hu{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let cu=0;const sA=new V,Kn=new Gs,Ni=new ri,Ir=new V,Vs=new V,uu=new V,du=new Gs,rA=new V(1,0,0),aA=new V(0,1,0),oA=new V(0,0,1),lA={type:"added"},fu={type:"removed"},$n={type:"childadded",child:null},Ta={type:"childremoved",child:null};class qe extends pr{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:cu++}),this.uuid=zs(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=qe.DEFAULT_UP.clone();const t=new V,e=new qn,i=new Gs,n=new V(1,1,1);function s(){i.setFromEuler(e,!1)}function a(){e.setFromQuaternion(i,void 0,!1)}e._onChange(s),i._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new ri},normalMatrix:{value:new tn}}),this.matrix=new ri,this.matrixWorld=new ri,this.matrixAutoUpdate=qe.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=qe.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new hu,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}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 Kn.setFromAxisAngle(t,e),this.quaternion.multiply(Kn),this}rotateOnWorldAxis(t,e){return Kn.setFromAxisAngle(t,e),this.quaternion.premultiply(Kn),this}rotateX(t){return this.rotateOnAxis(rA,t)}rotateY(t){return this.rotateOnAxis(aA,t)}rotateZ(t){return this.rotateOnAxis(oA,t)}translateOnAxis(t,e){return sA.copy(t).applyQuaternion(this.quaternion),this.position.add(sA.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(rA,t)}translateY(t){return this.translateOnAxis(aA,t)}translateZ(t){return this.translateOnAxis(oA,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Ni.copy(this.matrixWorld).invert())}lookAt(t,e,i){t.isVector3?Ir.copy(t):Ir.set(t,e,i);const n=this.parent;this.updateWorldMatrix(!0,!1),Vs.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ni.lookAt(Vs,Ir,this.up):Ni.lookAt(Ir,Vs,this.up),this.quaternion.setFromRotationMatrix(Ni),n&&(Ni.extractRotation(n.matrixWorld),Kn.setFromRotationMatrix(Ni),this.quaternion.premultiply(Kn.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(vn("Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(lA),$n.child=t,this.dispatchEvent($n),$n.child=null):vn("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(fu),Ta.child=t,this.dispatchEvent(Ta),Ta.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),Ni.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),Ni.multiply(t.parent.matrixWorld)),t.applyMatrix4(Ni),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(lA),$n.child=t,this.dispatchEvent($n),$n.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let i=0,n=this.children.length;i<n;i++){const s=this.children[i].getObjectByProperty(t,e);if(s!==void 0)return s}}getObjectsByProperty(t,e,i=[]){this[t]===e&&i.push(this);const n=this.children;for(let s=0,a=n.length;s<a;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(Vs,t,uu),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Vs,du,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(this.visible===!1)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;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const t=this.pivot;if(t!==null){const e=t.x,i=t.y,n=t.z,s=this.matrix.elements;s[12]+=e-s[0]*e-s[4]*i-s[8]*n,s[13]+=i-s[1]*e-s[5]*i-s[9]*n,s[14]+=n-s[2]*e-s[6]*i-s[10]*n}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].updateMatrixWorld(t)}updateWorldMatrix(t,e){const i=this.parent;if(t===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){const n=this.children;for(let s=0,a=n.length;s<a;s++)n[s].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",i={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const n={};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.castShadow===!0&&(n.castShadow=!0),this.receiveShadow===!0&&(n.receiveShadow=!0),this.visible===!1&&(n.visible=!1),this.frustumCulled===!1&&(n.frustumCulled=!1),this.renderOrder!==0&&(n.renderOrder=this.renderOrder),this.static!==!1&&(n.static=this.static),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(),this.pivot!==null&&(n.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(n.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(n.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(n.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(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.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),n.instanceInfo=this._instanceInfo.map(o=>({...o})),n.availableInstanceIds=this._availableInstanceIds.slice(),n.availableGeometryIds=this._availableGeometryIds.slice(),n.nextIndexStart=this._nextIndexStart,n.nextVertexStart=this._nextVertexStart,n.geometryCount=this._geometryCount,n.maxInstanceCount=this._maxInstanceCount,n.maxVertexCount=this._maxVertexCount,n.maxIndexCount=this._maxIndexCount,n.geometryInitialized=this._geometryInitialized,n.matricesTexture=this._matricesTexture.toJSON(t),n.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(n.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(n.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(n.boundingBox=this.boundingBox.toJSON()));function s(o,A){return o[A.uuid]===void 0&&(o[A.uuid]=A.toJSON(t)),A.uuid}if(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&&this.environment.isRenderTargetTexture!==!0&&(n.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=s(t.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const A=o.shapes;if(Array.isArray(A))for(let l=0,h=A.length;l<h;l++){const c=A[l];s(t.shapes,c)}else s(t.shapes,A)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(t.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let A=0,l=this.material.length;A<l;A++)o.push(s(t.materials,this.material[A]));n.material=o}else n.material=s(t.materials,this.material);if(this.children.length>0){n.children=[];for(let o=0;o<this.children.length;o++)n.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){n.animations=[];for(let o=0;o<this.animations.length;o++){const A=this.animations[o];n.animations.push(s(t.animations,A))}}if(e){const o=a(t.geometries),A=a(t.materials),l=a(t.textures),h=a(t.images),c=a(t.shapes),u=a(t.skeletons),d=a(t.animations),p=a(t.nodes);o.length>0&&(i.geometries=o),A.length>0&&(i.materials=A),l.length>0&&(i.textures=l),h.length>0&&(i.images=h),c.length>0&&(i.shapes=c),u.length>0&&(i.skeletons=u),d.length>0&&(i.animations=d),p.length>0&&(i.nodes=p)}return i.object=n,i;function a(o){const A=[];for(const l in o){const h=o[l];delete h.metadata,A.push(h)}return A}}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),t.pivot!==null&&(this.pivot=t.pivot.clone()),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.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let i=0;i<t.children.length;i++){const n=t.children[i];this.add(n.clone())}return this}}qe.DEFAULT_UP=new V(0,1,0),qe.DEFAULT_MATRIX_AUTO_UPDATE=!0,qe.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const AA={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},nn={h:0,s:0,l:0},Cr={h:0,s:0,l:0};function Ra(r,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?r+(t-r)*6*e:e<1/2?t:e<2/3?r+(t-r)*6*(2/3-e):r}class sn{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(e===void 0&&i===void 0){const n=t;n&&n.isColor?this.copy(n):typeof n=="number"?this.setHex(n):typeof n=="string"&&this.setStyle(n)}else this.setRGB(t,e,i);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=He){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,si.colorSpaceToWorking(this,e),this}setRGB(t,e,i,n=si.workingColorSpace){return this.r=t,this.g=e,this.b=i,si.colorSpaceToWorking(this,n),this}setHSL(t,e,i,n=si.workingColorSpace){if(t=iu(t,1),e=Gt(e,0,1),i=Gt(i,0,1),e===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+e):i+e-i*e,a=2*i-s;this.r=Ra(a,s,t+1/3),this.g=Ra(a,s,t),this.b=Ra(a,s,t-1/3)}return si.colorSpaceToWorking(this,n),this}setStyle(t,e=He){function i(s){s!==void 0&&parseFloat(s)<1&&be("Color: Alpha component of "+t+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(t)){let s;const a=n[1],o=n[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,e);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,e);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:be("Color: Unknown color model "+t)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){const s=n[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(s,16),e);be("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=He){const i=AA[t.toLowerCase()];return i!==void 0?this.setHex(i,e):be("Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=Di(t.r),this.g=Di(t.g),this.b=Di(t.b),this}copyLinearToSRGB(t){return this.r=Jn(t.r),this.g=Jn(t.g),this.b=Jn(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=He){return si.workingToColorSpace(we.copy(this),t),Math.round(Gt(we.r*255,0,255))*65536+Math.round(Gt(we.g*255,0,255))*256+Math.round(Gt(we.b*255,0,255))}getHexString(t=He){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=si.workingColorSpace){si.workingToColorSpace(we.copy(this),e);const i=we.r,n=we.g,s=we.b,a=Math.max(i,n,s),o=Math.min(i,n,s);let A,l;const h=(o+a)/2;if(o===a)A=0,l=0;else{const c=a-o;switch(l=h<=.5?c/(a+o):c/(2-a-o),a){case i:A=(n-s)/c+(n<s?6:0);break;case n:A=(s-i)/c+2;break;case s:A=(i-n)/c+4;break}A/=6}return t.h=A,t.s=l,t.l=h,t}getRGB(t,e=si.workingColorSpace){return si.workingToColorSpace(we.copy(this),e),t.r=we.r,t.g=we.g,t.b=we.b,t}getStyle(t=He){si.workingToColorSpace(we.copy(this),t);const e=we.r,i=we.g,n=we.b;return t!==He?`color(${t} ${e.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(i*255)},${Math.round(n*255)})`}offsetHSL(t,e,i){return this.getHSL(nn),this.setHSL(nn.h+t,nn.s+e,nn.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(nn),t.getHSL(Cr);const i=Sa(nn.h,Cr.h,e),n=Sa(nn.s,Cr.s,e),s=Sa(nn.l,Cr.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 we=new sn;sn.NAMES=AA;const oi=new V,Fi=new V,_a=new V,Oi=new V,ts=new V,es=new V,hA=new V,Pa=new V,La=new V,Da=new V,Na=new Hs,Fa=new Hs,Oa=new Hs;class li{constructor(t=new V,e=new V,i=new V){this.a=t,this.b=e,this.c=i}static getNormal(t,e,i,n){n.subVectors(i,e),oi.subVectors(t,e),n.cross(oi);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){oi.subVectors(n,e),Fi.subVectors(i,e),_a.subVectors(t,e);const a=oi.dot(oi),o=oi.dot(Fi),A=oi.dot(_a),l=Fi.dot(Fi),h=Fi.dot(_a),c=a*l-o*o;if(c===0)return s.set(0,0,0),null;const u=1/c,d=(l*A-o*h)*u,p=(a*h-o*A)*u;return s.set(1-d-p,p,d)}static containsPoint(t,e,i,n){return this.getBarycoord(t,e,i,n,Oi)===null?!1:Oi.x>=0&&Oi.y>=0&&Oi.x+Oi.y<=1}static getInterpolation(t,e,i,n,s,a,o,A){return this.getBarycoord(t,e,i,n,Oi)===null?(A.x=0,A.y=0,"z"in A&&(A.z=0),"w"in A&&(A.w=0),null):(A.setScalar(0),A.addScaledVector(s,Oi.x),A.addScaledVector(a,Oi.y),A.addScaledVector(o,Oi.z),A)}static getInterpolatedAttribute(t,e,i,n,s,a){return Na.setScalar(0),Fa.setScalar(0),Oa.setScalar(0),Na.fromBufferAttribute(t,e),Fa.fromBufferAttribute(t,i),Oa.fromBufferAttribute(t,n),a.setScalar(0),a.addScaledVector(Na,s.x),a.addScaledVector(Fa,s.y),a.addScaledVector(Oa,s.z),a}static isFrontFacing(t,e,i,n){return oi.subVectors(i,e),Fi.subVectors(t,e),oi.cross(Fi).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 oi.subVectors(this.c,this.b),Fi.subVectors(this.a,this.b),oi.cross(Fi).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return li.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return li.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,i,n,s){return li.getInterpolation(t,this.a,this.b,this.c,e,i,n,s)}containsPoint(t){return li.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return li.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 a,o;ts.subVectors(n,i),es.subVectors(s,i),Pa.subVectors(t,i);const A=ts.dot(Pa),l=es.dot(Pa);if(A<=0&&l<=0)return e.copy(i);La.subVectors(t,n);const h=ts.dot(La),c=es.dot(La);if(h>=0&&c<=h)return e.copy(n);const u=A*c-h*l;if(u<=0&&A>=0&&h<=0)return a=A/(A-h),e.copy(i).addScaledVector(ts,a);Da.subVectors(t,s);const d=ts.dot(Da),p=es.dot(Da);if(p>=0&&d<=p)return e.copy(s);const m=d*l-A*p;if(m<=0&&l>=0&&p<=0)return o=l/(l-p),e.copy(i).addScaledVector(es,o);const g=h*p-d*c;if(g<=0&&c-h>=0&&d-p>=0)return hA.subVectors(s,n),o=(c-h)/(c-h+(d-p)),e.copy(n).addScaledVector(hA,o);const f=1/(g+m+u);return a=m*f,o=u*f,e.copy(i).addScaledVector(ts,a).addScaledVector(es,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}class Ws{constructor(t=new V(1/0,1/0,1/0),e=new V(-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(Ai.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,i=t.count;e<i;e++)this.expandByPoint(Ai.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=Ai.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(i!==void 0){const s=i.getAttribute("position");if(e===!0&&s!==void 0&&t.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)t.isMesh===!0?t.getVertexPosition(a,Ai):Ai.fromBufferAttribute(s,a),Ai.applyMatrix4(t.matrixWorld),this.expandByPoint(Ai);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),vr.copy(t.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),vr.copy(i.boundingBox)),vr.applyMatrix4(t.matrixWorld),this.union(vr)}const n=t.children;for(let s=0,a=n.length;s<a;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,Ai),Ai.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(Ys),xr.subVectors(this.max,Ys),is.subVectors(t.a,Ys),ns.subVectors(t.b,Ys),ss.subVectors(t.c,Ys),rn.subVectors(ns,is),an.subVectors(ss,ns),xn.subVectors(is,ss);let e=[0,-rn.z,rn.y,0,-an.z,an.y,0,-xn.z,xn.y,rn.z,0,-rn.x,an.z,0,-an.x,xn.z,0,-xn.x,-rn.y,rn.x,0,-an.y,an.x,0,-xn.y,xn.x,0];return!Ba(e,is,ns,ss,xr)||(e=[1,0,0,0,1,0,0,0,1],!Ba(e,is,ns,ss,xr))?!1:(Er.crossVectors(rn,an),e=[Er.x,Er.y,Er.z],Ba(e,is,ns,ss,xr))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Ai).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Ai).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(Bi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Bi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Bi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Bi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Bi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Bi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Bi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Bi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Bi),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)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}}const Bi=[new V,new V,new V,new V,new V,new V,new V,new V],Ai=new V,vr=new Ws,is=new V,ns=new V,ss=new V,rn=new V,an=new V,xn=new V,Ys=new V,xr=new V,Er=new V,En=new V;function Ba(r,t,e,i,n){for(let s=0,a=r.length-3;s<=a;s+=3){En.fromArray(r,s);const o=n.x*Math.abs(En.x)+n.y*Math.abs(En.y)+n.z*Math.abs(En.z),A=t.dot(En),l=e.dot(En),h=i.dot(En);if(Math.max(-Math.max(A,l,h),Math.min(A,l,h))>o)return!1}return!0}const pe=new V,Sr=new Ve;let gu=0;class Sn{constructor(t,e,i=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:gu++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=i,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,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(this.itemSize===2)for(let e=0,i=this.count;e<i;e++)Sr.fromBufferAttribute(this,e),Sr.applyMatrix3(t),this.setXY(e,Sr.x,Sr.y);else if(this.itemSize===3)for(let e=0,i=this.count;e<i;e++)pe.fromBufferAttribute(this,e),pe.applyMatrix3(t),this.setXYZ(e,pe.x,pe.y,pe.z);return this}applyMatrix4(t){for(let e=0,i=this.count;e<i;e++)pe.fromBufferAttribute(this,e),pe.applyMatrix4(t),this.setXYZ(e,pe.x,pe.y,pe.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)pe.fromBufferAttribute(this,e),pe.applyNormalMatrix(t),this.setXYZ(e,pe.x,pe.y,pe.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)pe.fromBufferAttribute(this,e),pe.transformDirection(t),this.setXYZ(e,pe.x,pe.y,pe.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=ks(i,this.array)),i}setComponent(t,e,i){return this.normalized&&(i=Be(i,this.array)),this.array[t*this.itemSize+e]=i,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=ks(e,this.array)),e}setX(t,e){return this.normalized&&(e=Be(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=ks(e,this.array)),e}setY(t,e){return this.normalized&&(e=Be(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=ks(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Be(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=ks(e,this.array)),e}setW(t,e){return this.normalized&&(e=Be(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=Be(e,this.array),i=Be(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=Be(e,this.array),i=Be(i,this.array),n=Be(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=Be(e,this.array),i=Be(i,this.array),n=Be(n,this.array),s=Be(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!==35044&&(t.usage=this.usage),t}}class pu extends Sn{constructor(t,e,i){super(new Uint16Array(t),e,i)}}class mu extends Sn{constructor(t,e,i){super(new Uint32Array(t),e,i)}}class yn extends Sn{constructor(t,e,i){super(new Float32Array(t),e,i)}}const Iu=new Ws,Xs=new V,Ua=new V;class cA{constructor(t=new V,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;e!==void 0?i.copy(e):Iu.setFromPoints(t).getCenter(i);let n=0;for(let s=0,a=t.length;s<a;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;Xs.subVectors(t,this.center);const e=Xs.lengthSq();if(e>this.radius*this.radius){const i=Math.sqrt(e),n=(i-this.radius)*.5;this.center.addScaledVector(Xs,n/i),this.radius+=n}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(Ua.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Xs.copy(t.center).add(Ua)),this.expandByPoint(Xs.copy(t.center).sub(Ua))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}}let Cu=0;const Ke=new ri,za=new qe,rs=new V,Ye=new Ws,Zs=new Ws,xe=new V;class as extends pr{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Cu++}),this.uuid=zs(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,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(eu(t)?mu:pu)(t,1):this.index=t,this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,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;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const s=new tn().getNormalMatrix(t);i.applyNormalMatrix(s),i.needsUpdate=!0}const n=this.attributes.tangent;return n!==void 0&&(n.transformDirection(t),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return Ke.makeRotationFromQuaternion(t),this.applyMatrix4(Ke),this}rotateX(t){return Ke.makeRotationX(t),this.applyMatrix4(Ke),this}rotateY(t){return Ke.makeRotationY(t),this.applyMatrix4(Ke),this}rotateZ(t){return Ke.makeRotationZ(t),this.applyMatrix4(Ke),this}translate(t,e,i){return Ke.makeTranslation(t,e,i),this.applyMatrix4(Ke),this}scale(t,e,i){return Ke.makeScale(t,e,i),this.applyMatrix4(Ke),this}lookAt(t){return za.lookAt(t),za.updateMatrix(),this.applyMatrix4(za.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(rs).negate(),this.translate(rs.x,rs.y,rs.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const i=[];for(let n=0,s=t.length;n<s;n++){const a=t[n];i.push(a.x,a.y,a.z||0)}this.setAttribute("position",new yn(i,3))}else{const i=Math.min(t.length,e.count);for(let n=0;n<i;n++){const s=t[n];e.setXYZ(n,s.x,s.y,s.z||0)}t.length>e.count&&be("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ws);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){vn("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new V(-1/0,-1/0,-1/0),new V(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let i=0,n=e.length;i<n;i++){const s=e[i];Ye.setFromBufferAttribute(s),this.morphTargetsRelative?(xe.addVectors(this.boundingBox.min,Ye.min),this.boundingBox.expandByPoint(xe),xe.addVectors(this.boundingBox.max,Ye.max),this.boundingBox.expandByPoint(xe)):(this.boundingBox.expandByPoint(Ye.min),this.boundingBox.expandByPoint(Ye.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&vn('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new cA);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){vn("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new V,1/0);return}if(t){const i=this.boundingSphere.center;if(Ye.setFromBufferAttribute(t),e)for(let s=0,a=e.length;s<a;s++){const o=e[s];Zs.setFromBufferAttribute(o),this.morphTargetsRelative?(xe.addVectors(Ye.min,Zs.min),Ye.expandByPoint(xe),xe.addVectors(Ye.max,Zs.max),Ye.expandByPoint(xe)):(Ye.expandByPoint(Zs.min),Ye.expandByPoint(Zs.max))}Ye.getCenter(i);let n=0;for(let s=0,a=t.count;s<a;s++)xe.fromBufferAttribute(t,s),n=Math.max(n,i.distanceToSquared(xe));if(e)for(let s=0,a=e.length;s<a;s++){const o=e[s],A=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)xe.fromBufferAttribute(o,l),A&&(rs.fromBufferAttribute(t,l),xe.add(rs)),n=Math.max(n,i.distanceToSquared(xe))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&vn('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){vn("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=e.position,n=e.normal,s=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Sn(new Float32Array(4*i.count),4));const a=this.getAttribute("tangent"),o=[],A=[];for(let P=0;P<i.count;P++)o[P]=new V,A[P]=new V;const l=new V,h=new V,c=new V,u=new Ve,d=new Ve,p=new Ve,m=new V,g=new V;function f(P,E,x){l.fromBufferAttribute(i,P),h.fromBufferAttribute(i,E),c.fromBufferAttribute(i,x),u.fromBufferAttribute(s,P),d.fromBufferAttribute(s,E),p.fromBufferAttribute(s,x),h.sub(l),c.sub(l),d.sub(u),p.sub(u);const M=1/(d.x*p.y-p.x*d.y);isFinite(M)&&(m.copy(h).multiplyScalar(p.y).addScaledVector(c,-d.y).multiplyScalar(M),g.copy(c).multiplyScalar(d.x).addScaledVector(h,-p.x).multiplyScalar(M),o[P].add(m),o[E].add(m),o[x].add(m),A[P].add(g),A[E].add(g),A[x].add(g))}let b=this.groups;b.length===0&&(b=[{start:0,count:t.count}]);for(let P=0,E=b.length;P<E;++P){const x=b[P],M=x.start,z=x.count;for(let O=M,U=M+z;O<U;O+=3)f(t.getX(O+0),t.getX(O+1),t.getX(O+2))}const S=new V,v=new V,T=new V,w=new V;function R(P){T.fromBufferAttribute(n,P),w.copy(T);const E=o[P];S.copy(E),S.sub(T.multiplyScalar(T.dot(E))).normalize(),v.crossVectors(w,E);const x=v.dot(A[P])<0?-1:1;a.setXYZW(P,S.x,S.y,S.z,x)}for(let P=0,E=b.length;P<E;++P){const x=b[P],M=x.start,z=x.count;for(let O=M,U=M+z;O<U;O+=3)R(t.getX(O+0)),R(t.getX(O+1)),R(t.getX(O+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new Sn(new Float32Array(e.count*3),3),this.setAttribute("normal",i);else for(let u=0,d=i.count;u<d;u++)i.setXYZ(u,0,0,0);const n=new V,s=new V,a=new V,o=new V,A=new V,l=new V,h=new V,c=new V;if(t)for(let u=0,d=t.count;u<d;u+=3){const p=t.getX(u+0),m=t.getX(u+1),g=t.getX(u+2);n.fromBufferAttribute(e,p),s.fromBufferAttribute(e,m),a.fromBufferAttribute(e,g),h.subVectors(a,s),c.subVectors(n,s),h.cross(c),o.fromBufferAttribute(i,p),A.fromBufferAttribute(i,m),l.fromBufferAttribute(i,g),o.add(h),A.add(h),l.add(h),i.setXYZ(p,o.x,o.y,o.z),i.setXYZ(m,A.x,A.y,A.z),i.setXYZ(g,l.x,l.y,l.z)}else for(let u=0,d=e.count;u<d;u+=3)n.fromBufferAttribute(e,u+0),s.fromBufferAttribute(e,u+1),a.fromBufferAttribute(e,u+2),h.subVectors(a,s),c.subVectors(n,s),h.cross(c),i.setXYZ(u+0,h.x,h.y,h.z),i.setXYZ(u+1,h.x,h.y,h.z),i.setXYZ(u+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++)xe.fromBufferAttribute(t,e),xe.normalize(),t.setXYZ(e,xe.x,xe.y,xe.z)}toNonIndexed(){function t(o,A){const l=o.array,h=o.itemSize,c=o.normalized,u=new l.constructor(A.length*h);let d=0,p=0;for(let m=0,g=A.length;m<g;m++){o.isInterleavedBufferAttribute?d=A[m]*o.data.stride+o.offset:d=A[m]*h;for(let f=0;f<h;f++)u[p++]=l[d++]}return new Sn(u,h,c)}if(this.index===null)return be("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new as,i=this.index.array,n=this.attributes;for(const o in n){const A=n[o],l=t(A,i);e.setAttribute(o,l)}const s=this.morphAttributes;for(const o in s){const A=[],l=s[o];for(let h=0,c=l.length;h<c;h++){const u=l[h],d=t(u,i);A.push(d)}e.morphAttributes[o]=A}e.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,A=a.length;o<A;o++){const l=a[o];e.addGroup(l.start,l.count,l.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const A=this.parameters;for(const l in A)A[l]!==void 0&&(t[l]=A[l]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const i=this.attributes;for(const A in i){const l=i[A];t.data.attributes[A]=l.toJSON(t.data)}const n={};let s=!1;for(const A in this.morphAttributes){const l=this.morphAttributes[A],h=[];for(let c=0,u=l.length;c<u;c++){const d=l[c];h.push(d.toJSON(t.data))}h.length>0&&(n[A]=h,s=!0)}s&&(t.data.morphAttributes=n,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(t.data.boundingSphere=o.toJSON()),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;i!==null&&this.setIndex(i.clone());const n=t.attributes;for(const l in n){const h=n[l];this.setAttribute(l,h.clone(e))}const s=t.morphAttributes;for(const l in s){const h=[],c=s[l];for(let u=0,d=c.length;u<d;u++)h.push(c[u].clone(e));this.morphAttributes[l]=h}this.morphTargetsRelative=t.morphTargetsRelative;const a=t.groups;for(let l=0,h=a.length;l<h;l++){const c=a[l];this.addGroup(c.start,c.count,c.materialIndex)}const o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());const A=t.boundingSphere;return A!==null&&(this.boundingSphere=A.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}let vu=0;class ka extends pr{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:vu++}),this.uuid=zs(),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=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new sn(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=7680,this.stencilZFail=7680,this.stencilZPass=7680,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.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const i=t[e];if(i===void 0){be(`Material: parameter '${e}' has value of undefined.`);continue}const n=this[e];if(n===void 0){be(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[e]=i}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(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()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(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),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(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,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==1&&(i.blending=this.blending),this.side!==0&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==204&&(i.blendSrc=this.blendSrc),this.blendDst!==205&&(i.blendDst=this.blendDst),this.blendEquation!==100&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==3&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==519&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==7680&&(i.stencilFail=this.stencilFail),this.stencilZFail!==7680&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==7680&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function n(s){const a=[];for(const o in s){const A=s[o];delete A.metadata,a.push(A)}return a}if(e){const s=n(t.textures),a=n(t.images);s.length>0&&(i.textures=s),a.length>0&&(i.images=a)}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(e!==null){const n=e.length;i=new Array(n);for(let s=0;s!==n;++s)i[s]=e[s].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.allowOverride=t.allowOverride,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}}const Ui=new V,Ga=new V,yr=new V,on=new V,Ha=new V,br=new V,Va=new V;class xu{constructor(t=new V,e=new V(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,Ui)),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=Ui.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Ui.copy(this.origin).addScaledVector(this.direction,e),Ui.distanceToSquared(t))}distanceSqToSegment(t,e,i,n){Ga.copy(t).add(e).multiplyScalar(.5),yr.copy(e).sub(t).normalize(),on.copy(this.origin).sub(Ga);const s=t.distanceTo(e)*.5,a=-this.direction.dot(yr),o=on.dot(this.direction),A=-on.dot(yr),l=on.lengthSq(),h=Math.abs(1-a*a);let c,u,d,p;if(h>0)if(c=a*A-o,u=a*o-A,p=s*h,c>=0)if(u>=-p)if(u<=p){const m=1/h;c*=m,u*=m,d=c*(c+a*u+2*o)+u*(a*c+u+2*A)+l}else u=s,c=Math.max(0,-(a*u+o)),d=-c*c+u*(u+2*A)+l;else u=-s,c=Math.max(0,-(a*u+o)),d=-c*c+u*(u+2*A)+l;else u<=-p?(c=Math.max(0,-(-a*s+o)),u=c>0?-s:Math.min(Math.max(-s,-A),s),d=-c*c+u*(u+2*A)+l):u<=p?(c=0,u=Math.min(Math.max(-s,-A),s),d=u*(u+2*A)+l):(c=Math.max(0,-(a*s+o)),u=c>0?s:Math.min(Math.max(-s,-A),s),d=-c*c+u*(u+2*A)+l);else u=a>0?-s:s,c=Math.max(0,-(a*u+o)),d=-c*c+u*(u+2*A)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,c),n&&n.copy(Ga).addScaledVector(yr,u),d}intersectSphere(t,e){Ui.subVectors(t.center,this.origin);const i=Ui.dot(this.direction),n=Ui.dot(Ui)-i*i,s=t.radius*t.radius;if(n>s)return null;const a=Math.sqrt(s-n),o=i-a,A=i+a;return A<0?null:o<0?this.at(A,e):this.at(o,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){const i=this.distanceToPlane(t);return i===null?null:this.at(i,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let i,n,s,a,o,A;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,a=(t.max.y-u.y)*h):(s=(t.max.y-u.y)*h,a=(t.min.y-u.y)*h),i>a||s>n||((s>i||isNaN(i))&&(i=s),(a<n||isNaN(n))&&(n=a),c>=0?(o=(t.min.z-u.z)*c,A=(t.max.z-u.z)*c):(o=(t.max.z-u.z)*c,A=(t.min.z-u.z)*c),i>A||o>n)||((o>i||i!==i)&&(i=o),(A<n||n!==n)&&(n=A),n<0)?null:this.at(i>=0?i:n,e)}intersectsBox(t){return this.intersectBox(t,Ui)!==null}intersectTriangle(t,e,i,n,s){Ha.subVectors(e,t),br.subVectors(i,t),Va.crossVectors(Ha,br);let a=this.direction.dot(Va),o;if(a>0){if(n)return null;o=1}else if(a<0)o=-1,a=-a;else return null;on.subVectors(this.origin,t);const A=o*this.direction.dot(br.crossVectors(on,br));if(A<0)return null;const l=o*this.direction.dot(Ha.cross(on));if(l<0||A+l>a)return null;const h=-o*on.dot(Va);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 Eu extends ka{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new sn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new qn,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.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const uA=new ri,bn=new xu,Mr=new cA,dA=new V,wr=new V,Tr=new V,Rr=new V,Wa=new V,_r=new V,fA=new V,Pr=new V;class gA extends qe{constructor(t=new as,e=new Eu){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const i=t[e[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,s=i.length;n<s;n++){const a=i[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=n}}}}getVertexPosition(t,e){const i=this.geometry,n=i.attributes.position,s=i.morphAttributes.position,a=i.morphTargetsRelative;e.fromBufferAttribute(n,t);const o=this.morphTargetInfluences;if(s&&o){_r.set(0,0,0);for(let A=0,l=s.length;A<l;A++){const h=o[A],c=s[A];h!==0&&(Wa.fromBufferAttribute(c,t),a?_r.addScaledVector(Wa,h):_r.addScaledVector(Wa.sub(e),h))}e.add(_r)}return e}raycast(t,e){const i=this.geometry,n=this.material,s=this.matrixWorld;n!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Mr.copy(i.boundingSphere),Mr.applyMatrix4(s),bn.copy(t.ray).recast(t.near),!(Mr.containsPoint(bn.origin)===!1&&(bn.intersectSphere(Mr,dA)===null||bn.origin.distanceToSquared(dA)>(t.far-t.near)**2))&&(uA.copy(s).invert(),bn.copy(t.ray).applyMatrix4(uA),!(i.boundingBox!==null&&bn.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(t,e,bn)))}_computeIntersections(t,e,i){let n;const s=this.geometry,a=this.material,o=s.index,A=s.attributes.position,l=s.attributes.uv,h=s.attributes.uv1,c=s.attributes.normal,u=s.groups,d=s.drawRange;if(o!==null)if(Array.isArray(a))for(let p=0,m=u.length;p<m;p++){const g=u[p],f=a[g.materialIndex],b=Math.max(g.start,d.start),S=Math.min(o.count,Math.min(g.start+g.count,d.start+d.count));for(let v=b,T=S;v<T;v+=3){const w=o.getX(v),R=o.getX(v+1),P=o.getX(v+2);n=Lr(this,f,t,i,l,h,c,w,R,P),n&&(n.faceIndex=Math.floor(v/3),n.face.materialIndex=g.materialIndex,e.push(n))}}else{const p=Math.max(0,d.start),m=Math.min(o.count,d.start+d.count);for(let g=p,f=m;g<f;g+=3){const b=o.getX(g),S=o.getX(g+1),v=o.getX(g+2);n=Lr(this,a,t,i,l,h,c,b,S,v),n&&(n.faceIndex=Math.floor(g/3),e.push(n))}}else if(A!==void 0)if(Array.isArray(a))for(let p=0,m=u.length;p<m;p++){const g=u[p],f=a[g.materialIndex],b=Math.max(g.start,d.start),S=Math.min(A.count,Math.min(g.start+g.count,d.start+d.count));for(let v=b,T=S;v<T;v+=3){const w=v,R=v+1,P=v+2;n=Lr(this,f,t,i,l,h,c,w,R,P),n&&(n.faceIndex=Math.floor(v/3),n.face.materialIndex=g.materialIndex,e.push(n))}}else{const p=Math.max(0,d.start),m=Math.min(A.count,d.start+d.count);for(let g=p,f=m;g<f;g+=3){const b=g,S=g+1,v=g+2;n=Lr(this,a,t,i,l,h,c,b,S,v),n&&(n.faceIndex=Math.floor(g/3),e.push(n))}}}}function Su(r,t,e,i,n,s,a,o){let A;if(t.side===1?A=i.intersectTriangle(a,s,n,!0,o):A=i.intersectTriangle(n,s,a,t.side===0,o),A===null)return null;Pr.copy(o),Pr.applyMatrix4(r.matrixWorld);const l=e.ray.origin.distanceTo(Pr);return l<e.near||l>e.far?null:{distance:l,point:Pr.clone(),object:r}}function Lr(r,t,e,i,n,s,a,o,A,l){r.getVertexPosition(o,wr),r.getVertexPosition(A,Tr),r.getVertexPosition(l,Rr);const h=Su(r,t,e,i,wr,Tr,Rr,fA);if(h){const c=new V;li.getBarycoord(fA,wr,Tr,Rr,c),n&&(h.uv=li.getInterpolatedAttribute(n,o,A,l,c,new Ve)),s&&(h.uv1=li.getInterpolatedAttribute(s,o,A,l,c,new Ve)),a&&(h.normal=li.getInterpolatedAttribute(a,o,A,l,c,new V),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const u={a:o,b:A,c:l,normal:new V,materialIndex:0};li.getNormal(wr,Tr,Rr,u.normal),h.face=u,h.barycoord=c}return h}class yu extends Ii{constructor(t=null,e=1,i=1,n,s,a,o,A,l=1003,h=1003,c,u){super(null,a,o,A,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}}class Mn extends as{constructor(t=1,e=1,i=1,n=32,s=1,a=!1,o=0,A=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:i,radialSegments:n,heightSegments:s,openEnded:a,thetaStart:o,thetaLength:A};const l=this;n=Math.floor(n),s=Math.floor(s);const h=[],c=[],u=[],d=[];let p=0;const m=[],g=i/2;let f=0;b(),a===!1&&(t>0&&S(!0),e>0&&S(!1)),this.setIndex(h),this.setAttribute("position",new yn(c,3)),this.setAttribute("normal",new yn(u,3)),this.setAttribute("uv",new yn(d,2));function b(){const v=new V,T=new V;let w=0;const R=(e-t)/i;for(let P=0;P<=s;P++){const E=[],x=P/s,M=x*(e-t)+t;for(let z=0;z<=n;z++){const O=z/n,U=O*A+o,W=Math.sin(U),Y=Math.cos(U);T.x=M*W,T.y=-x*i+g,T.z=M*Y,c.push(T.x,T.y,T.z),v.set(W,R,Y).normalize(),u.push(v.x,v.y,v.z),d.push(O,1-x),E.push(p++)}m.push(E)}for(let P=0;P<n;P++)for(let E=0;E<s;E++){const x=m[E][P],M=m[E+1][P],z=m[E+1][P+1],O=m[E][P+1];(t>0||E!==0)&&(h.push(x,M,O),w+=3),(e>0||E!==s-1)&&(h.push(M,z,O),w+=3)}l.addGroup(f,w,0),f+=w}function S(v){const T=p,w=new Ve,R=new V;let P=0;const E=v===!0?t:e,x=v===!0?1:-1;for(let z=1;z<=n;z++)c.push(0,g*x,0),u.push(0,x,0),d.push(.5,.5),p++;const M=p;for(let z=0;z<=n;z++){const O=z/n*A+o,U=Math.cos(O),W=Math.sin(O);R.x=E*W,R.y=g*x,R.z=E*U,c.push(R.x,R.y,R.z),u.push(0,x,0),w.x=U*.5+.5,w.y=W*.5*x+.5,d.push(w.x,w.y),p++}for(let z=0;z<n;z++){const O=T+z,U=M+z;v===!0?h.push(U,U+1,O):h.push(U+1,U,O),P+=3}l.addGroup(f,P,v===!0?1:2),f+=P}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Mn(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}function bu(r){const t={};for(const e in r){t[e]={};for(const i in r[e]){const n=r[e][i];n&&(n.isColor||n.isMatrix3||n.isMatrix4||n.isVector2||n.isVector3||n.isVector4||n.isTexture||n.isQuaternion)?n.isRenderTargetTexture?(be("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][i]=null):t[e][i]=n.clone():Array.isArray(n)?t[e][i]=n.slice():t[e][i]=n}}return t}function Mu(r){const t=[];for(let e=0;e<r.length;e++)t.push(r[e].clone());return t}var wu=`void main() {
56
56
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
57
57
  }`,Tu=`void main() {
58
58
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
@@ -121,7 +121,7 @@ void main() {
121
121
  #elif DEPTH_PACKING == 3203
122
122
  gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
123
123
  #endif
124
- }`,mA={depth_vert:_u,depth_frag:Pu};class Lu extends as{constructor(t=(n,s,a)=>a.set(n,s,Math.cos(n)*Math.sin(s)),e=8,i=8){super(),this.type="ParametricGeometry",this.parameters={func:t,slices:e,stacks:i};const n=[],s=[],a=[],o=[],A=1e-5,l=new V,h=new V,c=new V,u=new V,d=new V,p=e+1;for(let m=0;m<=i;m++){const g=m/i;for(let f=0;f<=e;f++){const b=f/e;t(b,g,h),s.push(h.x,h.y,h.z),b-A>=0?(t(b-A,g,c),u.subVectors(h,c)):(t(b+A,g,c),u.subVectors(c,h)),g-A>=0?(t(b,g-A,c),d.subVectors(h,c)):(t(b,g+A,c),d.subVectors(c,h)),l.crossVectors(u,d).normalize(),a.push(l.x,l.y,l.z),o.push(b,g)}}for(let m=0;m<i;m++)for(let g=0;g<e;g++){const f=m*p+g,b=m*p+g+1,S=(m+1)*p+g+1,v=(m+1)*p+g;n.push(f,b,v),n.push(b,S,v)}this.setIndex(n),this.setAttribute("position",new yn(s,3)),this.setAttribute("normal",new yn(a,3)),this.setAttribute("uv",new yn(o,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}const Ya=new V;class wn{p1;p2;restDistance;constructor(t,e,i){this.p1=t,this.p2=e,this.restDistance=i}resolve(){const t=this.p1,e=this.p2,i=this.restDistance;Ya.subVectors(e.position,t.position);const n=Ya.length();if(n===0)return;const s=Ya.multiplyScalar((1-i/n)/2);t.position.add(s),e.position.sub(s)}}const IA=2,Du=.03,Nu=1-Du,Fu=.12,Ou=1.225;class Bu{position;previous;original;mass;inverseMass;acceleration;tmp;constructor(t,e){this.position=t.clone(),this.previous=t.clone(),this.original=t.clone(),this.mass=e,this.inverseMass=1/e,this.acceleration=new V,this.tmp=new V}applyForce(t){this.acceleration.addScaledVector(t,this.inverseMass)}integrate(t){const e=this.tmp.subVectors(this.position,this.previous).multiplyScalar(Nu).add(this.position).addScaledVector(this.acceleration,t);this.tmp=this.previous,this.previous=this.position,this.position=e,this.acceleration.set(0,0,0)}}class Uu{xSegments;ySegments;restDistance;width;height;particles;constraints;particleAt;geometry;constructor(t,e,i,n){const s=i*t,a=i*e,o=[],A=[],l=(m,g)=>o[m+g*(t+1)],h=(m,g,f)=>{f.set(m*s,g*a,0)},c=new V,u=n/((e+1)*(t+1));for(let m=0;m<=e;m++)for(let g=0;g<=t;g++)h(g/t,m/e,c),o.push(new Bu(c,u));for(let m=0;m<e;m++)for(let g=0;g<t;g++)A.push(new wn(l(g,m),l(g,m+1),i),new wn(l(g,m),l(g+1,m),i));for(let m=t,g=0;g<e;g++)A.push(new wn(l(m,g),l(m,g+1),i));for(let m=e,g=0;g<t;g++)A.push(new wn(l(g,m),l(g+1,m),i));const d=Math.sqrt(i*i*2);for(let m=0;m<e;m++)for(let g=0;g<t;g++)A.push(new wn(l(g,m),l(g+1,m+1),d),new wn(l(g+1,m),l(g,m+1),d));const p=new Lu(h,t,e);p.getAttribute("position").setUsage(35040),this.xSegments=t,this.ySegments=e,this.restDistance=i,this.width=s,this.height=a,this.particles=o,this.constraints=A,this.particleAt=l,this.geometry=p}reset(){for(const t of this.particles)t.previous.copy(t.position.copy(t.original))}simulate(t){const e=this.particles,i=this.constraints,n=Math.pow(t,2);for(let s=0,a=e.length;s<a;s++)e[s].integrate(n);for(let s=0,a=IA;s<a;s++)for(let o=0,A=i.length;o<A;o++)i[o].resolve()}render(){const t=this.particles,e=this.geometry,i=e.getAttribute("position"),n=i.array;for(let s=0,a=t.length;s<a;s++){const o=t[s].position,A=s*3;n[A]=o.x,n[A+1]=o.y,n[A+2]=o.z}i.needsUpdate=!0,e.computeVertexNormals()}}function zu(r){const{width:t,height:e,mass:i,restDistance:n}=r;return new Uu(Math.max(1,Math.round(t/n)),Math.max(1,Math.round(e/n)),n,i*t*e)}function CA(r,t,e){const i=r*t,n=new Uint8Array(4*i),s=Math.floor(e.r*255),a=Math.floor(e.g*255),o=Math.floor(e.b*255),A=255;for(let h=0;h<i;h++){const c=h*4;n[c]=s,n[c+1]=a,n[c+2]=o,n[c+3]=A}const l=new yu(n,r,t,1023,1009);return l.needsUpdate=!0,l}const ku=CA(1,1,new sn(16777215));function Gu(r,t){const e=r.geometry;let i=ku,n;const s=o=>(o.needsUpdate=!0,o.anisotropy=16,o.minFilter=1006,o.magFilter=1006,o.wrapS=1001,o.wrapT=1001,o),a=(o,A)=>{o.colorSpace=He;const l=new pA({alphaTest:.5,color:16777215,metalness:.08,roughness:.86,side:A,map:o}),h=new gA(e,l);return h.castShadow=!0,h.customDepthMaterial=new Ru({uniforms:{textureMap:{value:o}},vertexShader:mA.depth_vert,fragmentShader:mA.depth_frag,side:A,lights:!1,defines:{DEPTH_PACKING:"3200"}}),h.position.set(0,-r.height,0),h};return t?.texture instanceof Ii?(i=s(t.texture),t.backSideTexture instanceof Ii&&(n=s(t.backSideTexture))):t?.texture!==void 0&&console.error("FlagWaver.Flag: options.texture must be an instance of THREE.Texture."),[a(i,n!==void 0?0:2),n!==void 0?a(n,1):null]}const he={TOP:"top",LEFT:"left",BOTTOM:"bottom",RIGHT:"right"},Hu=(()=>{const r={edges:[],spacing:1};function t(e,i,n,s){const{xSegments:a,ySegments:o,particleAt:A}=e,{spacing:l}=s;switch(n){case he.TOP:for(let h=0;h<=a;h+=l)i.push(A(h,o));break;case he.LEFT:for(let h=0;h<=o;h+=l)i.push(A(0,h));break;case he.BOTTOM:for(let h=0;h<=a;h+=l)i.push(A(h,0));break;case he.RIGHT:for(let h=0;h<=o;h+=l)i.push(A(a,h));break}}return function(e,i,n={}){const s={...r,...n},{edges:a}=s;if(typeof a=="string")t(e,i,a,s);else if(Array.isArray(a)&&a.length>0)for(let o=0,A=a.length;o<A;o++)t(e,i,a[o],s)}})(),vA=1.2,Dr=new V;class xA extends wn{resolve(){const t=this.p1,e=this.p2,i=this.restDistance*vA;Dr.subVectors(t.position,e.position);const n=Dr.length()/vA;Dr.normalize();const s=Dr.multiplyScalar(n-i);n>i&&e.position.add(s)}}function EA(r){if(Array.isArray(r))for(const t of r)SA(t);else SA(r)}function SA(r){r.map?.dispose(),r.dispose()}const Vu=CA(1,1,new sn(16777215));class Js{cloth;pins;lengthConstraints;mesh;mesh2;object;static defaults={width:1.8,height:1.2,mass:.11,restDistance:1.2/10,rigidness:1,texture:Vu,backSideTexture:void 0,pin:{edges:[he.LEFT],spacing:1}};constructor(t={}){const e={...Js.defaults,...t};this.cloth=zu(e),this.pins=[],this.lengthConstraints=[];const[i,n]=Gu(this.cloth,e);this.mesh=i,this.mesh2=n,this.object=new qe,this.object.add(this.mesh),this.mesh2!==null&&this.object.add(this.mesh2),this.pin(e.pin)}destroy(){EA(this.mesh.material),this.mesh.geometry.dispose(),this.mesh.customDepthMaterial?.dispose(),this.mesh2!==null&&(EA(this.mesh2.material),this.mesh2.customDepthMaterial?.dispose())}pin(t){Hu(this.cloth,this.pins,t)}unpin(){this.pins=[]}setLengthConstraints(t){const{xSegments:e,ySegments:i,restDistance:n,particleAt:s}=this.cloth,a=[];if(t===he.LEFT)for(let o=0;o<=i;o++)for(let A=0;A<e;A++)a.push(new xA(s(A,o),s(A+1,o),n));else if(t===he.TOP)for(let o=0;o<=e;o++)for(let A=i;A>0;A--)a.push(new xA(s(o,A),s(o,A-1),n));this.lengthConstraints=a}reset(){this.cloth.reset()}simulate(t){const e=this.pins,i=this.lengthConstraints;this.cloth.simulate(t);for(const n of e)n.previous.copy(n.position.copy(n.original));for(let n=0;n<IA;n++)for(const s of i)s.resolve()}render(){this.cloth.render()}setTexture(t){t.needsUpdate=!0,t.anisotropy=16,t.minFilter=1006,t.magFilter=1006,t.wrapS=1001,t.wrapT=1001,t.colorSpace=He;const e=this.mesh.material;e.map!==null&&e.map!==void 0&&(e.map=t,e.needsUpdate=!0);const i=this.mesh.customDepthMaterial;if(i!=null){const n=i;n.uniforms!=null&&n.uniforms.textureMap!=null&&(n.uniforms.textureMap.value=t)}if(this.mesh2!=null){const n=this.mesh2.material;n.map!=null&&(n.map=t,n.needsUpdate=!0);const s=this.mesh2.customDepthMaterial;if(s!=null){const a=s;a.uniforms?.textureMap!=null&&(a.uniforms.textureMap.value=t)}}}}const Tn={CROSSBAR:"CROSSBAR",GALLERY:"GALLERY",HORIZONTAL:"HORIZONTAL",OUTRIGGER:"OUTRIGGER",VERTICAL:"VERTICAL"},js={NONE:"none",TOP_RIGHT:"topright",TOP_LEFT:"topleft"};class zi{top;mesh;object;constructor(t){this.create(t)}static defaults={flagpoleType:Tn.VERTICAL,poleWidth:.076,poleLength:6,poleCapSize:.076*4/3,crossbarWidth:.076*2/3,crossbarLength:1.2,crossbarCapSize:.076*2/3*3/2,poleTopOffset:.1,verticalHoisting:js.TOP_RIGHT};destroy(){this.mesh!==void 0&&((Array.isArray(this.mesh.material)?this.mesh.material:[this.mesh.material]).forEach(t=>{t.dispose()}),this.mesh.geometry.dispose())}create(t){this.destroy();const e=Object.assign({},zi.defaults,t),i=this.buildGeometry(e),n=new pA({color:16711422,metalness:.98,roughness:.55}),s=new gA(i,n);s.receiveShadow=!0,s.castShadow=!0,this.top=new V(0,e.poleLength,0),this.mesh=s,this.object=this.mesh}addFlag(t){t.unpin(),t.pin({edges:[he.LEFT]}),t.setLengthConstraints(he.LEFT),t.object.position.add(this.top)}}function Xa(r,t=!1){const e=r[0].index!==null,i=new Set(Object.keys(r[0].attributes)),n=new Set(Object.keys(r[0].morphAttributes)),s={},a={},o=r[0].morphTargetsRelative,A=new as;let l=0;for(let h=0;h<r.length;++h){const c=r[h];let u=0;if(e!==(c.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const d in c.attributes){if(!i.has(d))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+d+'" attribute exists among all geometries, or in none of them.'),null;s[d]===void 0&&(s[d]=[]),s[d].push(c.attributes[d]),u++}if(u!==i.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(o!==c.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const d in c.morphAttributes){if(!n.has(d))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;a[d]===void 0&&(a[d]=[]),a[d].push(c.morphAttributes[d])}if(t){let d;if(e)d=c.index.count;else if(c.attributes.position!==void 0)d=c.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;A.addGroup(l,d,h),l+=d}}if(e){let h=0;const c=[];for(let u=0;u<r.length;++u){const d=r[u].index;for(let p=0;p<d.count;++p)c.push(d.getX(p)+h);h+=r[u].attributes.position.count}A.setIndex(c)}for(const h in s){const c=yA(s[h]);if(!c)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" attribute."),null;A.setAttribute(h,c)}for(const h in a){const c=a[h][0].length;if(c===0)break;A.morphAttributes=A.morphAttributes||{},A.morphAttributes[h]=[];for(let u=0;u<c;++u){const d=[];for(let m=0;m<a[h].length;++m)d.push(a[h][m][u]);const p=yA(d);if(!p)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;A.morphAttributes[h].push(p)}}return A}function yA(r){let t,e,i,n=-1,s=0;for(let l=0;l<r.length;++l){const h=r[l];if(t===void 0&&(t=h.array.constructor),t!==h.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(e===void 0&&(e=h.itemSize),e!==h.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(i===void 0&&(i=h.normalized),i!==h.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(n===-1&&(n=h.gpuType),n!==h.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=h.count*e}const a=new t(s),o=new Sn(a,e,i);let A=0;for(let l=0;l<r.length;++l){const h=r[l];if(h.isInterleavedBufferAttribute){const c=A/e;for(let u=0,d=h.count;u<d;u++)for(let p=0;p<e;p++){const m=h.getComponent(u,p);o.setComponent(u+c,p,m)}}else a.set(h.array,A);A+=h.count*e}return n!==void 0&&(o.gpuType=n),o}function Qs(r){const t=r.poleWidth/2,e=r.poleLength,i=32,n=r.poleCapSize/2,s=new Mn(t,t,e,i);s.translate(0,r.poleLength/2,0);const a=new Mn(n,n,n,i);return a.translate(0,e+n/2,0),Xa([s,a])}function Wu(r){const t=Qs(r),e=r.poleWidth/2,i=r.poleLength,n=r.crossbarWidth/2,s=r.crossbarLength,a=16,o=r.crossbarCapSize/2,A=r.poleTopOffset,l=new Mn(n,n,s,a);l.rotateZ(Math.PI/2);const h=new Mn(o,o,o,a),c=h.clone(),u=i-A,d=e+n;return h.rotateZ(Math.PI/2),h.translate(-s/2,u,d),c.rotateZ(-Math.PI/2),c.translate(s/2,u,d),l.translate(0,u,d),Xa([t,l,h,c])}function Yu(r){const t=Qs(r),e=r.poleLength,i=r.poleCapSize/2,n=r.crossbarWidth/2,s=r.crossbarLength,a=16,o=new Mn(n,n,s,a);return o.rotateZ(Math.PI/2),o.translate(s/2,e+i-n,0),Xa([t,o])}class bA extends zi{constructor(t={}){super(t)}buildGeometry(t){return Qs(t)}}class Xu{flagpole;flag;object;constructor(t={}){const e={...t},{flagpole:i,flag:n}=e;this.flagpole=i??new bA,this.flag=n??new Js,this.flagpole.addFlag(this.flag),this.object=new qe,this.object.add(this.flagpole.object),this.object.add(this.flag.object)}destroy(){this.destroyChildSubject(this.flagpole),this.destroyChildSubject(this.flag)}destroyChildSubject(t){t!=null&&(this.object.remove(t.object),t.destroy())}reset(){this.flag.reset()}simulate(t){this.flag.simulate(t)}render(){this.flag.render()}setTexture(t){this.flag.setTexture(t)}}function Zu(r){return r===0?.001:r}function Ju(r){return r.x===0&&(r.x=.001),r.y===0&&(r.y=.001),r.z===0&&(r.z=.001),r}const MA={blowFromLeftDirection:r=>r.set(2e3,0,1e3),constantSpeed:r=>r};function ju(r){return .5*Ou*Math.pow(r,2)}class Za{direction;speed;directionFn;speedFn;pressure;static defaults={direction:new V(1,0,0),speed:10,directionFn:MA.blowFromLeftDirection,speedFn:MA.constantSpeed};constructor(t={}){const e={...Za.defaults,...t};this.direction=e.direction.clone(),this.speed=e.speed,this.directionFn=e.directionFn,this.speedFn=e.speedFn,this.pressure=new V}update(){const t=Date.now();this.directionFn(Ju(this.pressure.copy(this.direction)),t).normalize().multiplyScalar(ju(this.speedFn(Zu(this.speed),t)))}}const Nr=new V,wA=new V;function TA(r,t){return Nr.copy(r),t instanceof qe&&(wA.setFromMatrixPosition(t.matrixWorld),Nr.add(wA),t.worldToLocal(Nr)),Nr}const Qu=new V(0,-9.80665,0);function qu(r,t){const e=r.particles,i=TA(Qu,t);for(let n=0,s=e.length;n<s;n++)e[n].acceleration.add(i)}const Fr=new V,RA=new V;function Ku(r){return r<0?0:r>1?1:r}function _A(r){const t=Math.sin(r*12.9898)*43758.5453;return t-Math.floor(t)}function $u(r,t){const e=Ku(t?.randomizeAmount??0);if(e===0)return 1;const i=t?.randomSeed??r?.id??0,n=t?.time??0,s=.5+_A(i)*2,a=_A(i+1e3)*Math.PI*2;return 1+(Math.sin(n*s+a)*.5+Math.sin(n*s*1.7+a*.3)*.3)*e}function td(r,t,e){return Fr.subVectors(e,t),RA.subVectors(r,t),Fr.cross(RA),Fr.normalize(),Fr}function ed(r,t,e,i){const n=r.particles,s=r.geometry.getIndex();if(t==null||s==null)return;const a=r.restDistance*r.restDistance/2,o=$u(e,i),A=TA(t.pressure,e).multiplyScalar(Fu*a/3*o);for(let l=0,h=s.count;l<h;l+=3){const c=s.getX(l),u=s.getX(l+1),d=s.getX(l+2),p=n[c],m=n[u],g=n[d],f=td(p.position,m.position,g.position);f.multiplyScalar(f.dot(A)),p.applyForce(f),m.applyForce(f),g.applyForce(f)}}function id(r){return new Js(r)}function nd(r,t){const e={...r};return Object.entries(t).forEach(([i,n])=>{n!==void 0&&(e[i]=n)}),e}class sd extends zi{verticalHoisting;constructor(t={}){super(t);const e=nd(zi.defaults,t);this.top.set(0,e.poleLength-e.poleTopOffset,e.poleWidth/2+e.crossbarWidth/2),this.verticalHoisting=e.verticalHoisting}buildGeometry(t){return Wu(t)}addFlag(t){switch(t.unpin(),this.verticalHoisting){case js.NONE:t.pin({edges:[he.TOP]}),t.setLengthConstraints(he.TOP),t.object.position.add(this.top),t.object.position.x=-t.cloth.width/2;break;case js.TOP_LEFT:t.pin({edges:[he.LEFT]}),t.setLengthConstraints(he.LEFT),t.object.position.add(this.top),t.object.position.x=-t.cloth.height/2,t.object.rotateZ(Math.PI*3/2),t.object.rotateX(Math.PI);break;case js.TOP_RIGHT:default:t.pin({edges:[he.LEFT]}),t.setLengthConstraints(he.LEFT),t.object.position.add(this.top),t.object.position.x=t.cloth.height/2,t.object.rotateZ(Math.PI*3/2);break}}}class rd extends zi{buildGeometry(t){return Yu(t)}addFlag(t){t.unpin(),t.pin({edges:[he.LEFT,he.TOP]}),t.setLengthConstraints(he.LEFT),t.object.position.add(this.top)}}const ad=new V(0,0,1);class od extends zi{constructor(t={}){super(t),this.top.applyAxisAngle(ad,Math.PI*3/2)}buildGeometry(t){const e=Qs(t);return e.rotateZ(Math.PI*3/2),e}addFlag(t){t.unpin(),t.pin({edges:[he.LEFT]}),t.setLengthConstraints(he.LEFT),t.object.position.add(this.top),t.object.rotateZ(Math.PI*3/2)}}const ld=new V(0,0,1);class Ad extends zi{constructor(t={}){super(t),this.top.applyAxisAngle(ld,Math.PI*7/4)}buildGeometry(t){const e=Qs(t);return e.rotateZ(Math.PI*7/4),e}addFlag(t){t.unpin(),t.pin({edges:[he.LEFT]}),t.setLengthConstraints(he.LEFT),t.object.position.add(this.top),t.object.rotateZ(Math.PI*7/4)}}function hd(r,t){const e=Object.assign({},r);let i;switch(e.flagpoleType){case Tn.HORIZONTAL:i=new od(e);break;case Tn.OUTRIGGER:i=new Ad(e);break;case Tn.CROSSBAR:e.crossbarLength=e.verticalHoisting===js.NONE?t.cloth.width:t.cloth.height,i=new sd(e);break;case Tn.GALLERY:e.crossbarLength=t.cloth.width,i=new rd(e);break;case Tn.VERTICAL:default:i=new bA(e);break}return i}const ki=Object.freeze(Object.defineProperty({__proto__:null,FLAG_POLE_TYPE:Tn,Flag:Js,FlagGroup:Xu,Flagpole:zi,Wind:Za,applyGravityToCloth:qu,applyWindForceToCloth:ed,buildFlag:id,buildFlagpole:hd},Symbol.toStringTag,{value:"Module"}));const Ja="179",cd=0,PA=1,ud=2,LA=1,dd=2,Gi=3,ln=0,Ue=1,Hi=2,An=0,os=1,DA=2,NA=3,FA=4,fd=5,Rn=100,gd=101,pd=102,md=103,Id=104,Cd=200,vd=201,xd=202,Ed=203,ja=204,Qa=205,Sd=206,yd=207,bd=208,Md=209,wd=210,Td=211,Rd=212,_d=213,Pd=214,qa=0,Ka=1,$a=2,ls=3,to=4,eo=5,io=6,no=7,OA=0,Ld=1,Dd=2,hn=0,Nd=1,Fd=2,Od=3,Bd=4,Ud=5,zd=6,kd=7,BA=300,As=301,hs=302,so=303,ro=304,Or=306,ao=1e3,_n=1001,oo=1002,hi=1003,Gd=1004,Br=1005,Ci=1006,lo=1007,Pn=1008,vi=1009,UA=1010,zA=1011,qs=1012,Ao=1013,Ln=1014,Vi=1015,Ks=1016,ho=1017,co=1018,$s=1020,kA=35902,GA=1021,HA=1022,ci=1023,tr=1026,er=1027,VA=1028,uo=1029,WA=1030,fo=1031,go=1033,Ur=33776,zr=33777,kr=33778,Gr=33779,po=35840,mo=35841,Io=35842,Co=35843,vo=36196,xo=37492,Eo=37496,So=37808,yo=37809,bo=37810,Mo=37811,wo=37812,To=37813,Ro=37814,_o=37815,Po=37816,Lo=37817,Do=37818,No=37819,Fo=37820,Oo=37821,Hr=36492,Bo=36494,Uo=36495,YA=36283,zo=36284,ko=36285,Go=36286,Hd=3200,Vd=3201,XA=0,Wd=1,cn="",Pe="srgb",cs="srgb-linear",Vr="linear",Kt="srgb",us=7680,ZA=519,Yd=512,Xd=513,Zd=514,JA=515,Jd=516,jd=517,Qd=518,qd=519,jA=35044,QA="300 es",xi=2e3,Wr=2001;class ds{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[t]===void 0&&(i[t]=[]),i[t].indexOf(e)===-1&&i[t].push(e)}hasEventListener(t,e){const i=this._listeners;return i===void 0?!1:i[t]!==void 0&&i[t].indexOf(e)!==-1}removeEventListener(t,e){const i=this._listeners;if(i===void 0)return;const n=i[t];if(n!==void 0){const s=n.indexOf(e);s!==-1&&n.splice(s,1)}}dispatchEvent(t){const e=this._listeners;if(e===void 0)return;const i=e[t.type];if(i!==void 0){t.target=this;const n=i.slice(0);for(let s=0,a=n.length;s<a;s++)n[s].call(this,t);t.target=null}}}const Te=["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"],Ho=Math.PI/180,Yr=180/Math.PI;function ir(){const r=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Te[r&255]+Te[r>>8&255]+Te[r>>16&255]+Te[r>>24&255]+"-"+Te[t&255]+Te[t>>8&255]+"-"+Te[t>>16&15|64]+Te[t>>24&255]+"-"+Te[e&63|128]+Te[e>>8&255]+"-"+Te[e>>16&255]+Te[e>>24&255]+Te[i&255]+Te[i>>8&255]+Te[i>>16&255]+Te[i>>24&255]).toLowerCase()}function Gt(r,t,e){return Math.max(t,Math.min(e,r))}function Kd(r,t){return(r%t+t)%t}function Vo(r,t,e){return(1-e)*r+e*t}function nr(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function ze(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}class Jt{constructor(t=0,e=0){Jt.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=Gt(this.x,t.x,e.x),this.y=Gt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Gt(this.x,t,e),this.y=Gt(this.y,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Gt(i,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(Gt(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,a=this.y-t.y;return this.x=s*i-a*n+t.x,this.y=s*n+a*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class fs{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,a,o){let A=i[n+0],l=i[n+1],h=i[n+2],c=i[n+3];const u=s[a+0],d=s[a+1],p=s[a+2],m=s[a+3];if(o===0){t[e+0]=A,t[e+1]=l,t[e+2]=h,t[e+3]=c;return}if(o===1){t[e+0]=u,t[e+1]=d,t[e+2]=p,t[e+3]=m;return}if(c!==m||A!==u||l!==d||h!==p){let g=1-o;const f=A*u+l*d+h*p+c*m,b=f>=0?1:-1,S=1-f*f;if(S>Number.EPSILON){const T=Math.sqrt(S),w=Math.atan2(T,f*b);g=Math.sin(g*w)/T,o=Math.sin(o*w)/T}const v=o*b;if(A=A*g+u*v,l=l*g+d*v,h=h*g+p*v,c=c*g+m*v,g===1-o){const T=1/Math.sqrt(A*A+l*l+h*h+c*c);A*=T,l*=T,h*=T,c*=T}}t[e]=A,t[e+1]=l,t[e+2]=h,t[e+3]=c}static multiplyQuaternionsFlat(t,e,i,n,s,a){const o=i[n],A=i[n+1],l=i[n+2],h=i[n+3],c=s[a],u=s[a+1],d=s[a+2],p=s[a+3];return t[e]=o*p+h*c+A*d-l*u,t[e+1]=A*p+h*u+l*c-o*d,t[e+2]=l*p+h*d+o*u-A*c,t[e+3]=h*p-o*c-A*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,a=t._order,o=Math.cos,A=Math.sin,l=o(i/2),h=o(n/2),c=o(s/2),u=A(i/2),d=A(n/2),p=A(s/2);switch(a){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;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&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],a=e[1],o=e[5],A=e[9],l=e[2],h=e[6],c=e[10],u=i+o+c;if(u>0){const d=.5/Math.sqrt(u+1);this._w=.25/d,this._x=(h-A)*d,this._y=(s-l)*d,this._z=(a-n)*d}else if(i>o&&i>c){const d=2*Math.sqrt(1+i-o-c);this._w=(h-A)/d,this._x=.25*d,this._y=(n+a)/d,this._z=(s+l)/d}else if(o>c){const d=2*Math.sqrt(1+o-i-c);this._w=(s-l)/d,this._x=(n+a)/d,this._y=.25*d,this._z=(A+h)/d}else{const d=2*Math.sqrt(1+c-i-o);this._w=(a-n)/d,this._x=(s+l)/d,this._y=(A+h)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<1e-8?(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(Gt(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(i===0)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 t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const i=t._x,n=t._y,s=t._z,a=t._w,o=e._x,A=e._y,l=e._z,h=e._w;return this._x=i*h+a*o+n*l-s*A,this._y=n*h+a*A+s*o-i*l,this._z=s*h+a*l+i*A-n*o,this._w=a*h-i*o-n*A-s*l,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const i=this._x,n=this._y,s=this._z,a=this._w;let o=a*t._w+i*t._x+n*t._y+s*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=i,this._y=n,this._z=s,this;const A=1-o*o;if(A<=Number.EPSILON){const d=1-e;return this._w=d*a+e*this._w,this._x=d*i+e*this._x,this._y=d*n+e*this._y,this._z=d*s+e*this._z,this.normalize(),this}const l=Math.sqrt(A),h=Math.atan2(l,o),c=Math.sin((1-e)*h)/l,u=Math.sin(e*h)/l;return this._w=a*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=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),n=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(n*Math.sin(t),n*Math.cos(t),s*Math.sin(e),s*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class F{constructor(t=0,e=0,i=0){F.prototype.isVector3=!0,this.x=t,this.y=e,this.z=i}set(t,e,i){return i===void 0&&(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(qA.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(qA.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,a=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])*a,this.y=(s[1]*e+s[5]*i+s[9]*n+s[13])*a,this.z=(s[2]*e+s[6]*i+s[10]*n+s[14])*a,this}applyQuaternion(t){const e=this.x,i=this.y,n=this.z,s=t.x,a=t.y,o=t.z,A=t.w,l=2*(a*n-o*i),h=2*(o*e-s*n),c=2*(s*i-a*e);return this.x=e+A*l+a*c-o*h,this.y=i+A*h+o*l-s*c,this.z=n+A*c+s*h-a*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=Gt(this.x,t.x,e.x),this.y=Gt(this.y,t.y,e.y),this.z=Gt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Gt(this.x,t,e),this.y=Gt(this.y,t,e),this.z=Gt(this.z,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Gt(i,t,e))}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,a=e.x,o=e.y,A=e.z;return this.x=n*A-s*o,this.y=s*a-i*A,this.z=i*o-n*a,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return Wo.copy(this).projectOnVector(t),this.sub(Wo)}reflect(t){return this.sub(Wo.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(Gt(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,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,i=Math.sqrt(1-e*e);return this.x=i*Math.cos(t),this.y=e,this.z=i*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Wo=new F,qA=new fs;class Nt{constructor(t,e,i,n,s,a,o,A,l){Nt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,i,n,s,a,o,A,l)}set(t,e,i,n,s,a,o,A,l){const h=this.elements;return h[0]=t,h[1]=n,h[2]=o,h[3]=e,h[4]=s,h[5]=A,h[6]=i,h[7]=a,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,a=i[0],o=i[3],A=i[6],l=i[1],h=i[4],c=i[7],u=i[2],d=i[5],p=i[8],m=n[0],g=n[3],f=n[6],b=n[1],S=n[4],v=n[7],T=n[2],w=n[5],R=n[8];return s[0]=a*m+o*b+A*T,s[3]=a*g+o*S+A*w,s[6]=a*f+o*v+A*R,s[1]=l*m+h*b+c*T,s[4]=l*g+h*S+c*w,s[7]=l*f+h*v+c*R,s[2]=u*m+d*b+p*T,s[5]=u*g+d*S+p*w,s[8]=u*f+d*v+p*R,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],a=t[4],o=t[5],A=t[6],l=t[7],h=t[8];return e*a*h-e*o*l-i*s*h+i*o*A+n*s*l-n*a*A}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],s=t[3],a=t[4],o=t[5],A=t[6],l=t[7],h=t[8],c=h*a-o*l,u=o*A-h*s,d=l*s-a*A,p=e*c+i*u+n*d;if(p===0)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]=(o*i-n*a)*m,t[3]=u*m,t[4]=(h*e-n*A)*m,t[5]=(n*s-o*e)*m,t[6]=d*m,t[7]=(i*A-l*e)*m,t[8]=(a*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,a,o){const A=Math.cos(s),l=Math.sin(s);return this.set(i*A,i*l,-i*(A*a+l*o)+a+t,-n*l,n*A,-n*(-l*a+A*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(Yo.makeScale(t,e)),this}rotate(t){return this.premultiply(Yo.makeRotation(-t)),this}translate(t,e){return this.premultiply(Yo.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 Yo=new Nt;function KA(r){for(let t=r.length-1;t>=0;--t)if(r[t]>=65535)return!0;return!1}function sr(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function $d(){const r=sr("canvas");return r.style.display="block",r}const $A={};function gs(r){r in $A||($A[r]=!0,console.warn(r))}function tf(r,t,e){return new Promise(function(i,n){function s(){switch(r.clientWaitSync(t,r.SYNC_FLUSH_COMMANDS_BIT,0)){case r.WAIT_FAILED:n();break;case r.TIMEOUT_EXPIRED:setTimeout(s,e);break;default:i()}}setTimeout(s,e)})}const th=new Nt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),eh=new Nt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function ef(){const r={enabled:!0,workingColorSpace:cs,spaces:{},convert:function(n,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Kt&&(n.r=Wi(n.r),n.g=Wi(n.g),n.b=Wi(n.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(n.applyMatrix3(this.spaces[s].toXYZ),n.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Kt&&(n.r=ps(n.r),n.g=ps(n.g),n.b=ps(n.b))),n},workingToColorSpace:function(n,s){return this.convert(n,this.workingColorSpace,s)},colorSpaceToWorking:function(n,s){return this.convert(n,s,this.workingColorSpace)},getPrimaries:function(n){return this.spaces[n].primaries},getTransfer:function(n){return n===cn?Vr:this.spaces[n].transfer},getLuminanceCoefficients:function(n,s=this.workingColorSpace){return n.fromArray(this.spaces[s].luminanceCoefficients)},define:function(n){Object.assign(this.spaces,n)},_getMatrix:function(n,s,a){return n.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(n){return this.spaces[n].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(n=this.workingColorSpace){return this.spaces[n].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(n,s){return gs("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),r.workingToColorSpace(n,s)},toWorkingColorSpace:function(n,s){return gs("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),r.colorSpaceToWorking(n,s)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],i=[.3127,.329];return r.define({[cs]:{primaries:t,whitePoint:i,transfer:Vr,toXYZ:th,fromXYZ:eh,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Pe},outputColorSpaceConfig:{drawingBufferColorSpace:Pe}},[Pe]:{primaries:t,whitePoint:i,transfer:Kt,toXYZ:th,fromXYZ:eh,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Pe}}}),r}const Xt=ef();function Wi(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function ps(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let ms;class nf{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let i;if(t instanceof HTMLCanvasElement)i=t;else{ms===void 0&&(ms=sr("canvas")),ms.width=t.width,ms.height=t.height;const n=ms.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),i=ms}return i.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=sr("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 a=0;a<s.length;a++)s[a]=Wi(s[a]/255)*255;return i.putImageData(n,0,0),e}else if(t.data){const e=t.data.slice(0);for(let i=0;i<e.length;i++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[i]=Math.floor(Wi(e[i]/255)*255):e[i]=Wi(e[i]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let sf=0;class Xo{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:sf++}),this.uuid=ir(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):e instanceof VideoFrame?t.set(e.displayHeight,e.displayWidth,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const i={uuid:this.uuid,url:""},n=this.data;if(n!==null){let s;if(Array.isArray(n)){s=[];for(let a=0,o=n.length;a<o;a++)n[a].isDataTexture?s.push(Zo(n[a].image)):s.push(Zo(n[a]))}else s=Zo(n);i.url=s}return e||(t.images[this.uuid]=i),i}}function Zo(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?nf.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let rf=0;const Jo=new F;class Re extends ds{constructor(t=Re.DEFAULT_IMAGE,e=Re.DEFAULT_MAPPING,i=_n,n=_n,s=Ci,a=Pn,o=ci,A=vi,l=Re.DEFAULT_ANISOTROPY,h=cn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:rf++}),this.uuid=ir(),this.name="",this.source=new Xo(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=s,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=A,this.offset=new Jt(0,0),this.repeat=new Jt(1,1),this.center=new Jt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Nt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Jo).x}get height(){return this.source.getSize(Jo).y}get depth(){return this.source.getSize(Jo).z}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)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}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.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const i=t[e];if(i===void 0){console.warn(`THREE.Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const n=this[e];if(n===void 0){console.warn(`THREE.Texture.setValues(): property '${e}' does not exist.`);continue}n&&i&&n.isVector2&&i.isVector2||n&&i&&n.isVector3&&i.isVector3||n&&i&&n.isMatrix3&&i.isMatrix3?n.copy(i):this[e]=i}}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const i={metadata:{version:4.7,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!==BA)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case ao:t.x=t.x-Math.floor(t.x);break;case _n:t.x=t.x<0?0:1;break;case oo:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case ao:t.y=t.y-Math.floor(t.y);break;case _n:t.y=t.y<0?0:1;break;case oo:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}Re.DEFAULT_IMAGE=null,Re.DEFAULT_MAPPING=BA,Re.DEFAULT_ANISOTROPY=1;class ce{constructor(t=0,e=0,i=0,n=1){ce.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=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,s=this.w,a=t.elements;return this.x=a[0]*e+a[4]*i+a[8]*n+a[12]*s,this.y=a[1]*e+a[5]*i+a[9]*n+a[13]*s,this.z=a[2]*e+a[6]*i+a[10]*n+a[14]*s,this.w=a[3]*e+a[7]*i+a[11]*n+a[15]*s,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,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 A=t.elements,l=A[0],h=A[4],c=A[8],u=A[1],d=A[5],p=A[9],m=A[2],g=A[6],f=A[10];if(Math.abs(h-u)<.01&&Math.abs(c-m)<.01&&Math.abs(p-g)<.01){if(Math.abs(h+u)<.1&&Math.abs(c+m)<.1&&Math.abs(p+g)<.1&&Math.abs(l+d+f-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const S=(l+1)/2,v=(d+1)/2,T=(f+1)/2,w=(h+u)/4,R=(c+m)/4,P=(p+g)/4;return S>v&&S>T?S<.01?(i=0,n=.707106781,s=.707106781):(i=Math.sqrt(S),n=w/i,s=R/i):v>T?v<.01?(i=.707106781,n=0,s=.707106781):(n=Math.sqrt(v),i=w/n,s=P/n):T<.01?(i=.707106781,n=.707106781,s=0):(s=Math.sqrt(T),i=R/s,n=P/s),this.set(i,n,s,e),this}let b=Math.sqrt((g-p)*(g-p)+(c-m)*(c-m)+(u-h)*(u-h));return Math.abs(b)<.001&&(b=1),this.x=(g-p)/b,this.y=(c-m)/b,this.z=(u-h)/b,this.w=Math.acos((l+d+f-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Gt(this.x,t.x,e.x),this.y=Gt(this.y,t.y,e.y),this.z=Gt(this.z,t.z,e.z),this.w=Gt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=Gt(this.x,t,e),this.y=Gt(this.y,t,e),this.z=Gt(this.z,t,e),this.w=Gt(this.w,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Gt(i,t,e))}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 af extends ds{constructor(t=1,e=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ci,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},i),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=i.depth,this.scissor=new ce(0,0,t,e),this.scissorTest=!1,this.viewport=new ce(0,0,t,e);const n={width:t,height:e,depth:i.depth},s=new Re(n);this.textures=[];const a=i.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview}_setTextureOptions(t={}){const e={minFilter:Ci,generateMipmaps:!1,flipY:!1,internalFormat:null};t.mapping!==void 0&&(e.mapping=t.mapping),t.wrapS!==void 0&&(e.wrapS=t.wrapS),t.wrapT!==void 0&&(e.wrapT=t.wrapT),t.wrapR!==void 0&&(e.wrapR=t.wrapR),t.magFilter!==void 0&&(e.magFilter=t.magFilter),t.minFilter!==void 0&&(e.minFilter=t.minFilter),t.format!==void 0&&(e.format=t.format),t.type!==void 0&&(e.type=t.type),t.anisotropy!==void 0&&(e.anisotropy=t.anisotropy),t.colorSpace!==void 0&&(e.colorSpace=t.colorSpace),t.flipY!==void 0&&(e.flipY=t.flipY),t.generateMipmaps!==void 0&&(e.generateMipmaps=t.generateMipmaps),t.internalFormat!==void 0&&(e.internalFormat=t.internalFormat);for(let i=0;i<this.textures.length;i++)this.textures[i].setValues(e)}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),t!==null&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}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.textures.length;n<s;n++)this.textures[n].image.width=t,this.textures[n].image.height=e,this.textures[n].image.depth=i,this.textures[n].isArrayTexture=this.textures[n].image.depth>1;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,i=t.textures.length;e<i;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;const n=Object.assign({},t.textures[e].image);this.textures[e].source=new Xo(n)}return this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Dn extends af{constructor(t=1,e=1,i={}){super(t,e,i),this.isWebGLRenderTarget=!0}}class ih extends Re{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=hi,this.minFilter=hi,this.wrapR=_n,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class of extends Re{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=hi,this.minFilter=hi,this.wrapR=_n,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Is{constructor(t=new F(1/0,1/0,1/0),e=new F(-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(ui.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,i=t.count;e<i;e++)this.expandByPoint(ui.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=ui.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(i!==void 0){const s=i.getAttribute("position");if(e===!0&&s!==void 0&&t.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)t.isMesh===!0?t.getVertexPosition(a,ui):ui.fromBufferAttribute(s,a),ui.applyMatrix4(t.matrixWorld),this.expandByPoint(ui);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Xr.copy(t.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Xr.copy(i.boundingBox)),Xr.applyMatrix4(t.matrixWorld),this.union(Xr)}const n=t.children;for(let s=0,a=n.length;s<a;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,ui),ui.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(rr),Zr.subVectors(this.max,rr),Cs.subVectors(t.a,rr),vs.subVectors(t.b,rr),xs.subVectors(t.c,rr),un.subVectors(vs,Cs),dn.subVectors(xs,vs),Nn.subVectors(Cs,xs);let e=[0,-un.z,un.y,0,-dn.z,dn.y,0,-Nn.z,Nn.y,un.z,0,-un.x,dn.z,0,-dn.x,Nn.z,0,-Nn.x,-un.y,un.x,0,-dn.y,dn.x,0,-Nn.y,Nn.x,0];return!jo(e,Cs,vs,xs,Zr)||(e=[1,0,0,0,1,0,0,0,1],!jo(e,Cs,vs,xs,Zr))?!1:(Jr.crossVectors(un,dn),e=[Jr.x,Jr.y,Jr.z],jo(e,Cs,vs,xs,Zr))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,ui).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(ui).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(Yi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Yi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Yi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Yi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Yi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Yi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Yi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Yi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Yi),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)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}}const Yi=[new F,new F,new F,new F,new F,new F,new F,new F],ui=new F,Xr=new Is,Cs=new F,vs=new F,xs=new F,un=new F,dn=new F,Nn=new F,rr=new F,Zr=new F,Jr=new F,Fn=new F;function jo(r,t,e,i,n){for(let s=0,a=r.length-3;s<=a;s+=3){Fn.fromArray(r,s);const o=n.x*Math.abs(Fn.x)+n.y*Math.abs(Fn.y)+n.z*Math.abs(Fn.z),A=t.dot(Fn),l=e.dot(Fn),h=i.dot(Fn);if(Math.max(-Math.max(A,l,h),Math.min(A,l,h))>o)return!1}return!0}const lf=new Is,ar=new F,Qo=new F;class qo{constructor(t=new F,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;e!==void 0?i.copy(e):lf.setFromPoints(t).getCenter(i);let n=0;for(let s=0,a=t.length;s<a;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;ar.subVectors(t,this.center);const e=ar.lengthSq();if(e>this.radius*this.radius){const i=Math.sqrt(e),n=(i-this.radius)*.5;this.center.addScaledVector(ar,n/i),this.radius+=n}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(Qo.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(ar.copy(t.center).add(Qo)),this.expandByPoint(ar.copy(t.center).sub(Qo))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}}const Xi=new F,Ko=new F,jr=new F,fn=new F,$o=new F,Qr=new F,tl=new F;class Af{constructor(t=new F,e=new F(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,Xi)),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=Xi.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Xi.copy(this.origin).addScaledVector(this.direction,e),Xi.distanceToSquared(t))}distanceSqToSegment(t,e,i,n){Ko.copy(t).add(e).multiplyScalar(.5),jr.copy(e).sub(t).normalize(),fn.copy(this.origin).sub(Ko);const s=t.distanceTo(e)*.5,a=-this.direction.dot(jr),o=fn.dot(this.direction),A=-fn.dot(jr),l=fn.lengthSq(),h=Math.abs(1-a*a);let c,u,d,p;if(h>0)if(c=a*A-o,u=a*o-A,p=s*h,c>=0)if(u>=-p)if(u<=p){const m=1/h;c*=m,u*=m,d=c*(c+a*u+2*o)+u*(a*c+u+2*A)+l}else u=s,c=Math.max(0,-(a*u+o)),d=-c*c+u*(u+2*A)+l;else u=-s,c=Math.max(0,-(a*u+o)),d=-c*c+u*(u+2*A)+l;else u<=-p?(c=Math.max(0,-(-a*s+o)),u=c>0?-s:Math.min(Math.max(-s,-A),s),d=-c*c+u*(u+2*A)+l):u<=p?(c=0,u=Math.min(Math.max(-s,-A),s),d=u*(u+2*A)+l):(c=Math.max(0,-(a*s+o)),u=c>0?s:Math.min(Math.max(-s,-A),s),d=-c*c+u*(u+2*A)+l);else u=a>0?-s:s,c=Math.max(0,-(a*u+o)),d=-c*c+u*(u+2*A)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,c),n&&n.copy(Ko).addScaledVector(jr,u),d}intersectSphere(t,e){Xi.subVectors(t.center,this.origin);const i=Xi.dot(this.direction),n=Xi.dot(Xi)-i*i,s=t.radius*t.radius;if(n>s)return null;const a=Math.sqrt(s-n),o=i-a,A=i+a;return A<0?null:o<0?this.at(A,e):this.at(o,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){const i=this.distanceToPlane(t);return i===null?null:this.at(i,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let i,n,s,a,o,A;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,a=(t.max.y-u.y)*h):(s=(t.max.y-u.y)*h,a=(t.min.y-u.y)*h),i>a||s>n||((s>i||isNaN(i))&&(i=s),(a<n||isNaN(n))&&(n=a),c>=0?(o=(t.min.z-u.z)*c,A=(t.max.z-u.z)*c):(o=(t.max.z-u.z)*c,A=(t.min.z-u.z)*c),i>A||o>n)||((o>i||i!==i)&&(i=o),(A<n||n!==n)&&(n=A),n<0)?null:this.at(i>=0?i:n,e)}intersectsBox(t){return this.intersectBox(t,Xi)!==null}intersectTriangle(t,e,i,n,s){$o.subVectors(e,t),Qr.subVectors(i,t),tl.crossVectors($o,Qr);let a=this.direction.dot(tl),o;if(a>0){if(n)return null;o=1}else if(a<0)o=-1,a=-a;else return null;fn.subVectors(this.origin,t);const A=o*this.direction.dot(Qr.crossVectors(fn,Qr));if(A<0)return null;const l=o*this.direction.dot($o.cross(fn));if(l<0||A+l>a)return null;const h=-o*fn.dot(tl);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 de{constructor(t,e,i,n,s,a,o,A,l,h,c,u,d,p,m,g){de.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,i,n,s,a,o,A,l,h,c,u,d,p,m,g)}set(t,e,i,n,s,a,o,A,l,h,c,u,d,p,m,g){const f=this.elements;return f[0]=t,f[4]=e,f[8]=i,f[12]=n,f[1]=s,f[5]=a,f[9]=o,f[13]=A,f[2]=l,f[6]=h,f[10]=c,f[14]=u,f[3]=d,f[7]=p,f[11]=m,f[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new de().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/Es.setFromMatrixColumn(t,0).length(),s=1/Es.setFromMatrixColumn(t,1).length(),a=1/Es.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]*a,e[9]=i[9]*a,e[10]=i[10]*a,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,a=Math.cos(i),o=Math.sin(i),A=Math.cos(n),l=Math.sin(n),h=Math.cos(s),c=Math.sin(s);if(t.order==="XYZ"){const u=a*h,d=a*c,p=o*h,m=o*c;e[0]=A*h,e[4]=-A*c,e[8]=l,e[1]=d+p*l,e[5]=u-m*l,e[9]=-o*A,e[2]=m-u*l,e[6]=p+d*l,e[10]=a*A}else if(t.order==="YXZ"){const u=A*h,d=A*c,p=l*h,m=l*c;e[0]=u+m*o,e[4]=p*o-d,e[8]=a*l,e[1]=a*c,e[5]=a*h,e[9]=-o,e[2]=d*o-p,e[6]=m+u*o,e[10]=a*A}else if(t.order==="ZXY"){const u=A*h,d=A*c,p=l*h,m=l*c;e[0]=u-m*o,e[4]=-a*c,e[8]=p+d*o,e[1]=d+p*o,e[5]=a*h,e[9]=m-u*o,e[2]=-a*l,e[6]=o,e[10]=a*A}else if(t.order==="ZYX"){const u=a*h,d=a*c,p=o*h,m=o*c;e[0]=A*h,e[4]=p*l-d,e[8]=u*l+m,e[1]=A*c,e[5]=m*l+u,e[9]=d*l-p,e[2]=-l,e[6]=o*A,e[10]=a*A}else if(t.order==="YZX"){const u=a*A,d=a*l,p=o*A,m=o*l;e[0]=A*h,e[4]=m-u*c,e[8]=p*c+d,e[1]=c,e[5]=a*h,e[9]=-o*h,e[2]=-l*h,e[6]=d*c+p,e[10]=u-m*c}else if(t.order==="XZY"){const u=a*A,d=a*l,p=o*A,m=o*l;e[0]=A*h,e[4]=-c,e[8]=l*h,e[1]=u*c+m,e[5]=a*h,e[9]=d*c-p,e[2]=p*c-d,e[6]=o*h,e[10]=m*c+u}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(hf,t,cf)}lookAt(t,e,i){const n=this.elements;return Xe.subVectors(t,e),Xe.lengthSq()===0&&(Xe.z=1),Xe.normalize(),gn.crossVectors(i,Xe),gn.lengthSq()===0&&(Math.abs(i.z)===1?Xe.x+=1e-4:Xe.z+=1e-4,Xe.normalize(),gn.crossVectors(i,Xe)),gn.normalize(),qr.crossVectors(Xe,gn),n[0]=gn.x,n[4]=qr.x,n[8]=Xe.x,n[1]=gn.y,n[5]=qr.y,n[9]=Xe.y,n[2]=gn.z,n[6]=qr.z,n[10]=Xe.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,a=i[0],o=i[4],A=i[8],l=i[12],h=i[1],c=i[5],u=i[9],d=i[13],p=i[2],m=i[6],g=i[10],f=i[14],b=i[3],S=i[7],v=i[11],T=i[15],w=n[0],R=n[4],P=n[8],E=n[12],x=n[1],M=n[5],z=n[9],O=n[13],U=n[2],W=n[6],Y=n[10],$=n[14],H=n[3],rt=n[7],At=n[11],mt=n[15];return s[0]=a*w+o*x+A*U+l*H,s[4]=a*R+o*M+A*W+l*rt,s[8]=a*P+o*z+A*Y+l*At,s[12]=a*E+o*O+A*$+l*mt,s[1]=h*w+c*x+u*U+d*H,s[5]=h*R+c*M+u*W+d*rt,s[9]=h*P+c*z+u*Y+d*At,s[13]=h*E+c*O+u*$+d*mt,s[2]=p*w+m*x+g*U+f*H,s[6]=p*R+m*M+g*W+f*rt,s[10]=p*P+m*z+g*Y+f*At,s[14]=p*E+m*O+g*$+f*mt,s[3]=b*w+S*x+v*U+T*H,s[7]=b*R+S*M+v*W+T*rt,s[11]=b*P+S*z+v*Y+T*At,s[15]=b*E+S*O+v*$+T*mt,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],a=t[1],o=t[5],A=t[9],l=t[13],h=t[2],c=t[6],u=t[10],d=t[14],p=t[3],m=t[7],g=t[11],f=t[15];return p*(+s*A*c-n*l*c-s*o*u+i*l*u+n*o*d-i*A*d)+m*(+e*A*d-e*l*u+s*a*u-n*a*d+n*l*h-s*A*h)+g*(+e*l*c-e*o*d-s*a*c+i*a*d+s*o*h-i*l*h)+f*(-n*o*h-e*A*c+e*o*u+n*a*c-i*a*u+i*A*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],a=t[4],o=t[5],A=t[6],l=t[7],h=t[8],c=t[9],u=t[10],d=t[11],p=t[12],m=t[13],g=t[14],f=t[15],b=c*g*l-m*u*l+m*A*d-o*g*d-c*A*f+o*u*f,S=p*u*l-h*g*l-p*A*d+a*g*d+h*A*f-a*u*f,v=h*m*l-p*c*l+p*o*d-a*m*d-h*o*f+a*c*f,T=p*c*A-h*m*A-p*o*u+a*m*u+h*o*g-a*c*g,w=e*b+i*S+n*v+s*T;if(w===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const R=1/w;return t[0]=b*R,t[1]=(m*u*s-c*g*s-m*n*d+i*g*d+c*n*f-i*u*f)*R,t[2]=(o*g*s-m*A*s+m*n*l-i*g*l-o*n*f+i*A*f)*R,t[3]=(c*A*s-o*u*s-c*n*l+i*u*l+o*n*d-i*A*d)*R,t[4]=S*R,t[5]=(h*g*s-p*u*s+p*n*d-e*g*d-h*n*f+e*u*f)*R,t[6]=(p*A*s-a*g*s-p*n*l+e*g*l+a*n*f-e*A*f)*R,t[7]=(a*u*s-h*A*s+h*n*l-e*u*l-a*n*d+e*A*d)*R,t[8]=v*R,t[9]=(p*c*s-h*m*s-p*i*d+e*m*d+h*i*f-e*c*f)*R,t[10]=(a*m*s-p*o*s+p*i*l-e*m*l-a*i*f+e*o*f)*R,t[11]=(h*o*s-a*c*s-h*i*l+e*c*l+a*i*d-e*o*d)*R,t[12]=T*R,t[13]=(h*m*n-p*c*n+p*i*u-e*m*u-h*i*g+e*c*g)*R,t[14]=(p*o*n-a*m*n-p*i*A+e*m*A+a*i*g-e*o*g)*R,t[15]=(a*c*n-h*o*n+h*i*A-e*c*A-a*i*u+e*o*u)*R,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,a=t.x,o=t.y,A=t.z,l=s*a,h=s*o;return this.set(l*a+i,l*o-n*A,l*A+n*o,0,l*o+n*A,h*o+i,h*A-n*a,0,l*A-n*o,h*A+n*a,s*A*A+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,a){return this.set(1,i,s,0,t,1,a,0,e,n,1,0,0,0,0,1),this}compose(t,e,i){const n=this.elements,s=e._x,a=e._y,o=e._z,A=e._w,l=s+s,h=a+a,c=o+o,u=s*l,d=s*h,p=s*c,m=a*h,g=a*c,f=o*c,b=A*l,S=A*h,v=A*c,T=i.x,w=i.y,R=i.z;return n[0]=(1-(m+f))*T,n[1]=(d+v)*T,n[2]=(p-S)*T,n[3]=0,n[4]=(d-v)*w,n[5]=(1-(u+f))*w,n[6]=(g+b)*w,n[7]=0,n[8]=(p+S)*R,n[9]=(g-b)*R,n[10]=(1-(u+m))*R,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=Es.set(n[0],n[1],n[2]).length();const a=Es.set(n[4],n[5],n[6]).length(),o=Es.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],di.copy(this);const l=1/s,h=1/a,c=1/o;return di.elements[0]*=l,di.elements[1]*=l,di.elements[2]*=l,di.elements[4]*=h,di.elements[5]*=h,di.elements[6]*=h,di.elements[8]*=c,di.elements[9]*=c,di.elements[10]*=c,e.setFromRotationMatrix(di),i.x=s,i.y=a,i.z=o,this}makePerspective(t,e,i,n,s,a,o=xi,A=!1){const l=this.elements,h=2*s/(e-t),c=2*s/(i-n),u=(e+t)/(e-t),d=(i+n)/(i-n);let p,m;if(A)p=s/(a-s),m=a*s/(a-s);else if(o===xi)p=-(a+s)/(a-s),m=-2*a*s/(a-s);else if(o===Wr)p=-a/(a-s),m=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=c,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,i,n,s,a,o=xi,A=!1){const l=this.elements,h=2/(e-t),c=2/(i-n),u=-(e+t)/(e-t),d=-(i+n)/(i-n);let p,m;if(A)p=1/(a-s),m=a/(a-s);else if(o===xi)p=-2/(a-s),m=-(a+s)/(a-s);else if(o===Wr)p=-1/(a-s),m=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=0,l[12]=u,l[1]=0,l[5]=c,l[9]=0,l[13]=d,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=0,l[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 Es=new F,di=new de,hf=new F(0,0,0),cf=new F(1,1,1),gn=new F,qr=new F,Xe=new F,nh=new de,sh=new fs;class fi{constructor(t=0,e=0,i=0,n=fi.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],a=n[4],o=n[8],A=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(Gt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Gt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(A,l)):(this._y=Math.atan2(-c,s),this._z=0);break;case"ZXY":this._x=Math.asin(Gt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(A,s));break;case"ZYX":this._y=Math.asin(-Gt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(A,s)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(Gt(A,-1,1)),Math.abs(A)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-c,s)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-Gt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,i===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return nh.makeRotationFromQuaternion(t),this.setFromRotationMatrix(nh,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return sh.setFromEuler(this),this.setFromQuaternion(sh,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}fi.DEFAULT_ORDER="XYZ";class rh{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let uf=0;const ah=new F,Ss=new fs,Zi=new de,Kr=new F,or=new F,df=new F,ff=new fs,oh=new F(1,0,0),lh=new F(0,1,0),Ah=new F(0,0,1),hh={type:"added"},gf={type:"removed"},ys={type:"childadded",child:null},el={type:"childremoved",child:null};class Ee extends ds{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:uf++}),this.uuid=ir(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Ee.DEFAULT_UP.clone();const t=new F,e=new fi,i=new fs,n=new F(1,1,1);function s(){i.setFromEuler(e,!1)}function a(){e.setFromQuaternion(i,void 0,!1)}e._onChange(s),i._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new de},normalMatrix:{value:new Nt}}),this.matrix=new de,this.matrixWorld=new de,this.matrixAutoUpdate=Ee.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Ee.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new rh,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,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 Ss.setFromAxisAngle(t,e),this.quaternion.multiply(Ss),this}rotateOnWorldAxis(t,e){return Ss.setFromAxisAngle(t,e),this.quaternion.premultiply(Ss),this}rotateX(t){return this.rotateOnAxis(oh,t)}rotateY(t){return this.rotateOnAxis(lh,t)}rotateZ(t){return this.rotateOnAxis(Ah,t)}translateOnAxis(t,e){return ah.copy(t).applyQuaternion(this.quaternion),this.position.add(ah.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(oh,t)}translateY(t){return this.translateOnAxis(lh,t)}translateZ(t){return this.translateOnAxis(Ah,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Zi.copy(this.matrixWorld).invert())}lookAt(t,e,i){t.isVector3?Kr.copy(t):Kr.set(t,e,i);const n=this.parent;this.updateWorldMatrix(!0,!1),or.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Zi.lookAt(or,Kr,this.up):Zi.lookAt(Kr,or,this.up),this.quaternion.setFromRotationMatrix(Zi),n&&(Zi.extractRotation(n.matrixWorld),Ss.setFromRotationMatrix(Zi),this.quaternion.premultiply(Ss.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(hh),ys.child=t,this.dispatchEvent(ys),ys.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(gf),el.child=t,this.dispatchEvent(el),el.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),Zi.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),Zi.multiply(t.parent.matrixWorld)),t.applyMatrix4(Zi),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(hh),ys.child=t,this.dispatchEvent(ys),ys.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let i=0,n=this.children.length;i<n;i++){const a=this.children[i].getObjectByProperty(t,e);if(a!==void 0)return a}}getObjectsByProperty(t,e,i=[]){this[t]===e&&i.push(this);const n=this.children;for(let s=0,a=n.length;s<a;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(or,t,df),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(or,ff,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(this.visible===!1)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;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].updateMatrixWorld(t)}updateWorldMatrix(t,e){const i=this.parent;if(t===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){const n=this.children;for(let s=0,a=n.length;s<a;s++)n[s].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",i={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const n={};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.castShadow===!0&&(n.castShadow=!0),this.receiveShadow===!0&&(n.receiveShadow=!0),this.visible===!1&&(n.visible=!1),this.frustumCulled===!1&&(n.frustumCulled=!1),this.renderOrder!==0&&(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(),this.matrixAutoUpdate===!1&&(n.matrixAutoUpdate=!1),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(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.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),n.instanceInfo=this._instanceInfo.map(o=>({...o})),n.availableInstanceIds=this._availableInstanceIds.slice(),n.availableGeometryIds=this._availableGeometryIds.slice(),n.nextIndexStart=this._nextIndexStart,n.nextVertexStart=this._nextVertexStart,n.geometryCount=this._geometryCount,n.maxInstanceCount=this._maxInstanceCount,n.maxVertexCount=this._maxVertexCount,n.maxIndexCount=this._maxIndexCount,n.geometryInitialized=this._geometryInitialized,n.matricesTexture=this._matricesTexture.toJSON(t),n.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(n.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(n.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(n.boundingBox=this.boundingBox.toJSON()));function s(o,A){return o[A.uuid]===void 0&&(o[A.uuid]=A.toJSON(t)),A.uuid}if(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&&this.environment.isRenderTargetTexture!==!0&&(n.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=s(t.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const A=o.shapes;if(Array.isArray(A))for(let l=0,h=A.length;l<h;l++){const c=A[l];s(t.shapes,c)}else s(t.shapes,A)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(t.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let A=0,l=this.material.length;A<l;A++)o.push(s(t.materials,this.material[A]));n.material=o}else n.material=s(t.materials,this.material);if(this.children.length>0){n.children=[];for(let o=0;o<this.children.length;o++)n.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){n.animations=[];for(let o=0;o<this.animations.length;o++){const A=this.animations[o];n.animations.push(s(t.animations,A))}}if(e){const o=a(t.geometries),A=a(t.materials),l=a(t.textures),h=a(t.images),c=a(t.shapes),u=a(t.skeletons),d=a(t.animations),p=a(t.nodes);o.length>0&&(i.geometries=o),A.length>0&&(i.materials=A),l.length>0&&(i.textures=l),h.length>0&&(i.images=h),c.length>0&&(i.shapes=c),u.length>0&&(i.skeletons=u),d.length>0&&(i.animations=d),p.length>0&&(i.nodes=p)}return i.object=n,i;function a(o){const A=[];for(const l in o){const h=o[l];delete h.metadata,A.push(h)}return A}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let i=0;i<t.children.length;i++){const n=t.children[i];this.add(n.clone())}return this}}Ee.DEFAULT_UP=new F(0,1,0),Ee.DEFAULT_MATRIX_AUTO_UPDATE=!0,Ee.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const gi=new F,Ji=new F,il=new F,ji=new F,bs=new F,Ms=new F,ch=new F,nl=new F,sl=new F,rl=new F,al=new ce,ol=new ce,ll=new ce;class pi{constructor(t=new F,e=new F,i=new F){this.a=t,this.b=e,this.c=i}static getNormal(t,e,i,n){n.subVectors(i,e),gi.subVectors(t,e),n.cross(gi);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){gi.subVectors(n,e),Ji.subVectors(i,e),il.subVectors(t,e);const a=gi.dot(gi),o=gi.dot(Ji),A=gi.dot(il),l=Ji.dot(Ji),h=Ji.dot(il),c=a*l-o*o;if(c===0)return s.set(0,0,0),null;const u=1/c,d=(l*A-o*h)*u,p=(a*h-o*A)*u;return s.set(1-d-p,p,d)}static containsPoint(t,e,i,n){return this.getBarycoord(t,e,i,n,ji)===null?!1:ji.x>=0&&ji.y>=0&&ji.x+ji.y<=1}static getInterpolation(t,e,i,n,s,a,o,A){return this.getBarycoord(t,e,i,n,ji)===null?(A.x=0,A.y=0,"z"in A&&(A.z=0),"w"in A&&(A.w=0),null):(A.setScalar(0),A.addScaledVector(s,ji.x),A.addScaledVector(a,ji.y),A.addScaledVector(o,ji.z),A)}static getInterpolatedAttribute(t,e,i,n,s,a){return al.setScalar(0),ol.setScalar(0),ll.setScalar(0),al.fromBufferAttribute(t,e),ol.fromBufferAttribute(t,i),ll.fromBufferAttribute(t,n),a.setScalar(0),a.addScaledVector(al,s.x),a.addScaledVector(ol,s.y),a.addScaledVector(ll,s.z),a}static isFrontFacing(t,e,i,n){return gi.subVectors(i,e),Ji.subVectors(t,e),gi.cross(Ji).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 gi.subVectors(this.c,this.b),Ji.subVectors(this.a,this.b),gi.cross(Ji).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return pi.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return pi.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,i,n,s){return pi.getInterpolation(t,this.a,this.b,this.c,e,i,n,s)}containsPoint(t){return pi.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return pi.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 a,o;bs.subVectors(n,i),Ms.subVectors(s,i),nl.subVectors(t,i);const A=bs.dot(nl),l=Ms.dot(nl);if(A<=0&&l<=0)return e.copy(i);sl.subVectors(t,n);const h=bs.dot(sl),c=Ms.dot(sl);if(h>=0&&c<=h)return e.copy(n);const u=A*c-h*l;if(u<=0&&A>=0&&h<=0)return a=A/(A-h),e.copy(i).addScaledVector(bs,a);rl.subVectors(t,s);const d=bs.dot(rl),p=Ms.dot(rl);if(p>=0&&d<=p)return e.copy(s);const m=d*l-A*p;if(m<=0&&l>=0&&p<=0)return o=l/(l-p),e.copy(i).addScaledVector(Ms,o);const g=h*p-d*c;if(g<=0&&c-h>=0&&d-p>=0)return ch.subVectors(s,n),o=(c-h)/(c-h+(d-p)),e.copy(n).addScaledVector(ch,o);const f=1/(g+m+u);return a=m*f,o=u*f,e.copy(i).addScaledVector(bs,a).addScaledVector(Ms,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const uh={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},pn={h:0,s:0,l:0},$r={h:0,s:0,l:0};function Al(r,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?r+(t-r)*6*e:e<1/2?t:e<2/3?r+(t-r)*6*(2/3-e):r}class Vt{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(e===void 0&&i===void 0){const n=t;n&&n.isColor?this.copy(n):typeof n=="number"?this.setHex(n):typeof n=="string"&&this.setStyle(n)}else this.setRGB(t,e,i);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Pe){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Xt.colorSpaceToWorking(this,e),this}setRGB(t,e,i,n=Xt.workingColorSpace){return this.r=t,this.g=e,this.b=i,Xt.colorSpaceToWorking(this,n),this}setHSL(t,e,i,n=Xt.workingColorSpace){if(t=Kd(t,1),e=Gt(e,0,1),i=Gt(i,0,1),e===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+e):i+e-i*e,a=2*i-s;this.r=Al(a,s,t+1/3),this.g=Al(a,s,t),this.b=Al(a,s,t-1/3)}return Xt.colorSpaceToWorking(this,n),this}setStyle(t,e=Pe){function i(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(t)){let s;const a=n[1],o=n[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,e);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,e);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){const s=n[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(s,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Pe){const i=uh[t.toLowerCase()];return i!==void 0?this.setHex(i,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=Wi(t.r),this.g=Wi(t.g),this.b=Wi(t.b),this}copyLinearToSRGB(t){return this.r=ps(t.r),this.g=ps(t.g),this.b=ps(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Pe){return Xt.workingToColorSpace(_e.copy(this),t),Math.round(Gt(_e.r*255,0,255))*65536+Math.round(Gt(_e.g*255,0,255))*256+Math.round(Gt(_e.b*255,0,255))}getHexString(t=Pe){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Xt.workingColorSpace){Xt.workingToColorSpace(_e.copy(this),e);const i=_e.r,n=_e.g,s=_e.b,a=Math.max(i,n,s),o=Math.min(i,n,s);let A,l;const h=(o+a)/2;if(o===a)A=0,l=0;else{const c=a-o;switch(l=h<=.5?c/(a+o):c/(2-a-o),a){case i:A=(n-s)/c+(n<s?6:0);break;case n:A=(s-i)/c+2;break;case s:A=(i-n)/c+4;break}A/=6}return t.h=A,t.s=l,t.l=h,t}getRGB(t,e=Xt.workingColorSpace){return Xt.workingToColorSpace(_e.copy(this),e),t.r=_e.r,t.g=_e.g,t.b=_e.b,t}getStyle(t=Pe){Xt.workingToColorSpace(_e.copy(this),t);const e=_e.r,i=_e.g,n=_e.b;return t!==Pe?`color(${t} ${e.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(i*255)},${Math.round(n*255)})`}offsetHSL(t,e,i){return this.getHSL(pn),this.setHSL(pn.h+t,pn.s+e,pn.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(pn),t.getHSL($r);const i=Vo(pn.h,$r.h,e),n=Vo(pn.s,$r.s,e),s=Vo(pn.l,$r.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 _e=new Vt;Vt.NAMES=uh;let pf=0;class lr extends ds{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:pf++}),this.uuid=ir(),this.name="",this.type="Material",this.blending=os,this.side=ln,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=ja,this.blendDst=Qa,this.blendEquation=Rn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Vt(0,0,0),this.blendAlpha=0,this.depthFunc=ls,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=ZA,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=us,this.stencilZFail=us,this.stencilZPass=us,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const i=t[e];if(i===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const n=this[e];if(n===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[e]=i}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(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()),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(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),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(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,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==os&&(i.blending=this.blending),this.side!==ln&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==ja&&(i.blendSrc=this.blendSrc),this.blendDst!==Qa&&(i.blendDst=this.blendDst),this.blendEquation!==Rn&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==ls&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==ZA&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==us&&(i.stencilFail=this.stencilFail),this.stencilZFail!==us&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==us&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function n(s){const a=[];for(const o in s){const A=s[o];delete A.metadata,a.push(A)}return a}if(e){const s=n(t.textures),a=n(t.images);s.length>0&&(i.textures=s),a.length>0&&(i.images=a)}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(e!==null){const n=e.length;i=new Array(n);for(let s=0;s!==n;++s)i[s]=e[s].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){t===!0&&this.version++}}class hl extends lr{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Vt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new fi,this.combine=OA,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const me=new F,ta=new Jt;let mf=0;class Ei{constructor(t,e,i=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:mf++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=i,this.usage=jA,this.updateRanges=[],this.gpuType=Vi,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,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(this.itemSize===2)for(let e=0,i=this.count;e<i;e++)ta.fromBufferAttribute(this,e),ta.applyMatrix3(t),this.setXY(e,ta.x,ta.y);else if(this.itemSize===3)for(let e=0,i=this.count;e<i;e++)me.fromBufferAttribute(this,e),me.applyMatrix3(t),this.setXYZ(e,me.x,me.y,me.z);return this}applyMatrix4(t){for(let e=0,i=this.count;e<i;e++)me.fromBufferAttribute(this,e),me.applyMatrix4(t),this.setXYZ(e,me.x,me.y,me.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)me.fromBufferAttribute(this,e),me.applyNormalMatrix(t),this.setXYZ(e,me.x,me.y,me.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)me.fromBufferAttribute(this,e),me.transformDirection(t),this.setXYZ(e,me.x,me.y,me.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=nr(i,this.array)),i}setComponent(t,e,i){return this.normalized&&(i=ze(i,this.array)),this.array[t*this.itemSize+e]=i,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=nr(e,this.array)),e}setX(t,e){return this.normalized&&(e=ze(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=nr(e,this.array)),e}setY(t,e){return this.normalized&&(e=ze(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=nr(e,this.array)),e}setZ(t,e){return this.normalized&&(e=ze(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=nr(e,this.array)),e}setW(t,e){return this.normalized&&(e=ze(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=ze(e,this.array),i=ze(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=ze(e,this.array),i=ze(i,this.array),n=ze(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=ze(e,this.array),i=ze(i,this.array),n=ze(n,this.array),s=ze(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!==jA&&(t.usage=this.usage),t}}class dh extends Ei{constructor(t,e,i){super(new Uint16Array(t),e,i)}}class fh extends Ei{constructor(t,e,i){super(new Uint32Array(t),e,i)}}class On extends Ei{constructor(t,e,i){super(new Float32Array(t),e,i)}}let If=0;const $e=new de,cl=new Ee,ws=new F,Ze=new Is,Ar=new Is,Se=new F;class Bn extends ds{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:If++}),this.uuid=ir(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=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(KA(t)?fh:dh)(t,1):this.index=t,this}setIndirect(t){return this.indirect=t,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,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;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const s=new Nt().getNormalMatrix(t);i.applyNormalMatrix(s),i.needsUpdate=!0}const n=this.attributes.tangent;return n!==void 0&&(n.transformDirection(t),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return $e.makeRotationFromQuaternion(t),this.applyMatrix4($e),this}rotateX(t){return $e.makeRotationX(t),this.applyMatrix4($e),this}rotateY(t){return $e.makeRotationY(t),this.applyMatrix4($e),this}rotateZ(t){return $e.makeRotationZ(t),this.applyMatrix4($e),this}translate(t,e,i){return $e.makeTranslation(t,e,i),this.applyMatrix4($e),this}scale(t,e,i){return $e.makeScale(t,e,i),this.applyMatrix4($e),this}lookAt(t){return cl.lookAt(t),cl.updateMatrix(),this.applyMatrix4(cl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ws).negate(),this.translate(ws.x,ws.y,ws.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const i=[];for(let n=0,s=t.length;n<s;n++){const a=t[n];i.push(a.x,a.y,a.z||0)}this.setAttribute("position",new On(i,3))}else{const i=Math.min(t.length,e.count);for(let n=0;n<i;n++){const s=t[n];e.setXYZ(n,s.x,s.y,s.z||0)}t.length>e.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Is);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new F(-1/0,-1/0,-1/0),new F(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let i=0,n=e.length;i<n;i++){const s=e[i];Ze.setFromBufferAttribute(s),this.morphTargetsRelative?(Se.addVectors(this.boundingBox.min,Ze.min),this.boundingBox.expandByPoint(Se),Se.addVectors(this.boundingBox.max,Ze.max),this.boundingBox.expandByPoint(Se)):(this.boundingBox.expandByPoint(Ze.min),this.boundingBox.expandByPoint(Ze.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new qo);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new F,1/0);return}if(t){const i=this.boundingSphere.center;if(Ze.setFromBufferAttribute(t),e)for(let s=0,a=e.length;s<a;s++){const o=e[s];Ar.setFromBufferAttribute(o),this.morphTargetsRelative?(Se.addVectors(Ze.min,Ar.min),Ze.expandByPoint(Se),Se.addVectors(Ze.max,Ar.max),Ze.expandByPoint(Se)):(Ze.expandByPoint(Ar.min),Ze.expandByPoint(Ar.max))}Ze.getCenter(i);let n=0;for(let s=0,a=t.count;s<a;s++)Se.fromBufferAttribute(t,s),n=Math.max(n,i.distanceToSquared(Se));if(e)for(let s=0,a=e.length;s<a;s++){const o=e[s],A=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)Se.fromBufferAttribute(o,l),A&&(ws.fromBufferAttribute(t,l),Se.add(ws)),n=Math.max(n,i.distanceToSquared(Se))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=e.position,n=e.normal,s=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Ei(new Float32Array(4*i.count),4));const a=this.getAttribute("tangent"),o=[],A=[];for(let P=0;P<i.count;P++)o[P]=new F,A[P]=new F;const l=new F,h=new F,c=new F,u=new Jt,d=new Jt,p=new Jt,m=new F,g=new F;function f(P,E,x){l.fromBufferAttribute(i,P),h.fromBufferAttribute(i,E),c.fromBufferAttribute(i,x),u.fromBufferAttribute(s,P),d.fromBufferAttribute(s,E),p.fromBufferAttribute(s,x),h.sub(l),c.sub(l),d.sub(u),p.sub(u);const M=1/(d.x*p.y-p.x*d.y);isFinite(M)&&(m.copy(h).multiplyScalar(p.y).addScaledVector(c,-d.y).multiplyScalar(M),g.copy(c).multiplyScalar(d.x).addScaledVector(h,-p.x).multiplyScalar(M),o[P].add(m),o[E].add(m),o[x].add(m),A[P].add(g),A[E].add(g),A[x].add(g))}let b=this.groups;b.length===0&&(b=[{start:0,count:t.count}]);for(let P=0,E=b.length;P<E;++P){const x=b[P],M=x.start,z=x.count;for(let O=M,U=M+z;O<U;O+=3)f(t.getX(O+0),t.getX(O+1),t.getX(O+2))}const S=new F,v=new F,T=new F,w=new F;function R(P){T.fromBufferAttribute(n,P),w.copy(T);const E=o[P];S.copy(E),S.sub(T.multiplyScalar(T.dot(E))).normalize(),v.crossVectors(w,E);const M=v.dot(A[P])<0?-1:1;a.setXYZW(P,S.x,S.y,S.z,M)}for(let P=0,E=b.length;P<E;++P){const x=b[P],M=x.start,z=x.count;for(let O=M,U=M+z;O<U;O+=3)R(t.getX(O+0)),R(t.getX(O+1)),R(t.getX(O+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new Ei(new Float32Array(e.count*3),3),this.setAttribute("normal",i);else for(let u=0,d=i.count;u<d;u++)i.setXYZ(u,0,0,0);const n=new F,s=new F,a=new F,o=new F,A=new F,l=new F,h=new F,c=new F;if(t)for(let u=0,d=t.count;u<d;u+=3){const p=t.getX(u+0),m=t.getX(u+1),g=t.getX(u+2);n.fromBufferAttribute(e,p),s.fromBufferAttribute(e,m),a.fromBufferAttribute(e,g),h.subVectors(a,s),c.subVectors(n,s),h.cross(c),o.fromBufferAttribute(i,p),A.fromBufferAttribute(i,m),l.fromBufferAttribute(i,g),o.add(h),A.add(h),l.add(h),i.setXYZ(p,o.x,o.y,o.z),i.setXYZ(m,A.x,A.y,A.z),i.setXYZ(g,l.x,l.y,l.z)}else for(let u=0,d=e.count;u<d;u+=3)n.fromBufferAttribute(e,u+0),s.fromBufferAttribute(e,u+1),a.fromBufferAttribute(e,u+2),h.subVectors(a,s),c.subVectors(n,s),h.cross(c),i.setXYZ(u+0,h.x,h.y,h.z),i.setXYZ(u+1,h.x,h.y,h.z),i.setXYZ(u+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++)Se.fromBufferAttribute(t,e),Se.normalize(),t.setXYZ(e,Se.x,Se.y,Se.z)}toNonIndexed(){function t(o,A){const l=o.array,h=o.itemSize,c=o.normalized,u=new l.constructor(A.length*h);let d=0,p=0;for(let m=0,g=A.length;m<g;m++){o.isInterleavedBufferAttribute?d=A[m]*o.data.stride+o.offset:d=A[m]*h;for(let f=0;f<h;f++)u[p++]=l[d++]}return new Ei(u,h,c)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new Bn,i=this.index.array,n=this.attributes;for(const o in n){const A=n[o],l=t(A,i);e.setAttribute(o,l)}const s=this.morphAttributes;for(const o in s){const A=[],l=s[o];for(let h=0,c=l.length;h<c;h++){const u=l[h],d=t(u,i);A.push(d)}e.morphAttributes[o]=A}e.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,A=a.length;o<A;o++){const l=a[o];e.addGroup(l.start,l.count,l.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const A=this.parameters;for(const l in A)A[l]!==void 0&&(t[l]=A[l]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const i=this.attributes;for(const A in i){const l=i[A];t.data.attributes[A]=l.toJSON(t.data)}const n={};let s=!1;for(const A in this.morphAttributes){const l=this.morphAttributes[A],h=[];for(let c=0,u=l.length;c<u;c++){const d=l[c];h.push(d.toJSON(t.data))}h.length>0&&(n[A]=h,s=!0)}s&&(t.data.morphAttributes=n,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(t.data.boundingSphere=o.toJSON()),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;i!==null&&this.setIndex(i.clone());const n=t.attributes;for(const l in n){const h=n[l];this.setAttribute(l,h.clone(e))}const s=t.morphAttributes;for(const l in s){const h=[],c=s[l];for(let u=0,d=c.length;u<d;u++)h.push(c[u].clone(e));this.morphAttributes[l]=h}this.morphTargetsRelative=t.morphTargetsRelative;const a=t.groups;for(let l=0,h=a.length;l<h;l++){const c=a[l];this.addGroup(c.start,c.count,c.materialIndex)}const o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());const A=t.boundingSphere;return A!==null&&(this.boundingSphere=A.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const gh=new de,Un=new Af,ea=new qo,ph=new F,ia=new F,na=new F,sa=new F,ul=new F,ra=new F,mh=new F,aa=new F;class mi extends Ee{constructor(t=new Bn,e=new hl){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,i=Object.keys(e);if(i.length>0){const n=e[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=n.length;s<a;s++){const o=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(t,e){const i=this.geometry,n=i.attributes.position,s=i.morphAttributes.position,a=i.morphTargetsRelative;e.fromBufferAttribute(n,t);const o=this.morphTargetInfluences;if(s&&o){ra.set(0,0,0);for(let A=0,l=s.length;A<l;A++){const h=o[A],c=s[A];h!==0&&(ul.fromBufferAttribute(c,t),a?ra.addScaledVector(ul,h):ra.addScaledVector(ul.sub(e),h))}e.add(ra)}return e}raycast(t,e){const i=this.geometry,n=this.material,s=this.matrixWorld;n!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),ea.copy(i.boundingSphere),ea.applyMatrix4(s),Un.copy(t.ray).recast(t.near),!(ea.containsPoint(Un.origin)===!1&&(Un.intersectSphere(ea,ph)===null||Un.origin.distanceToSquared(ph)>(t.far-t.near)**2))&&(gh.copy(s).invert(),Un.copy(t.ray).applyMatrix4(gh),!(i.boundingBox!==null&&Un.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(t,e,Un)))}_computeIntersections(t,e,i){let n;const s=this.geometry,a=this.material,o=s.index,A=s.attributes.position,l=s.attributes.uv,h=s.attributes.uv1,c=s.attributes.normal,u=s.groups,d=s.drawRange;if(o!==null)if(Array.isArray(a))for(let p=0,m=u.length;p<m;p++){const g=u[p],f=a[g.materialIndex],b=Math.max(g.start,d.start),S=Math.min(o.count,Math.min(g.start+g.count,d.start+d.count));for(let v=b,T=S;v<T;v+=3){const w=o.getX(v),R=o.getX(v+1),P=o.getX(v+2);n=oa(this,f,t,i,l,h,c,w,R,P),n&&(n.faceIndex=Math.floor(v/3),n.face.materialIndex=g.materialIndex,e.push(n))}}else{const p=Math.max(0,d.start),m=Math.min(o.count,d.start+d.count);for(let g=p,f=m;g<f;g+=3){const b=o.getX(g),S=o.getX(g+1),v=o.getX(g+2);n=oa(this,a,t,i,l,h,c,b,S,v),n&&(n.faceIndex=Math.floor(g/3),e.push(n))}}else if(A!==void 0)if(Array.isArray(a))for(let p=0,m=u.length;p<m;p++){const g=u[p],f=a[g.materialIndex],b=Math.max(g.start,d.start),S=Math.min(A.count,Math.min(g.start+g.count,d.start+d.count));for(let v=b,T=S;v<T;v+=3){const w=v,R=v+1,P=v+2;n=oa(this,f,t,i,l,h,c,w,R,P),n&&(n.faceIndex=Math.floor(v/3),n.face.materialIndex=g.materialIndex,e.push(n))}}else{const p=Math.max(0,d.start),m=Math.min(A.count,d.start+d.count);for(let g=p,f=m;g<f;g+=3){const b=g,S=g+1,v=g+2;n=oa(this,a,t,i,l,h,c,b,S,v),n&&(n.faceIndex=Math.floor(g/3),e.push(n))}}}}function Cf(r,t,e,i,n,s,a,o){let A;if(t.side===Ue?A=i.intersectTriangle(a,s,n,!0,o):A=i.intersectTriangle(n,s,a,t.side===ln,o),A===null)return null;aa.copy(o),aa.applyMatrix4(r.matrixWorld);const l=e.ray.origin.distanceTo(aa);return l<e.near||l>e.far?null:{distance:l,point:aa.clone(),object:r}}function oa(r,t,e,i,n,s,a,o,A,l){r.getVertexPosition(o,ia),r.getVertexPosition(A,na),r.getVertexPosition(l,sa);const h=Cf(r,t,e,i,ia,na,sa,mh);if(h){const c=new F;pi.getBarycoord(mh,ia,na,sa,c),n&&(h.uv=pi.getInterpolatedAttribute(n,o,A,l,c,new Jt)),s&&(h.uv1=pi.getInterpolatedAttribute(s,o,A,l,c,new Jt)),a&&(h.normal=pi.getInterpolatedAttribute(a,o,A,l,c,new F),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const u={a:o,b:A,c:l,normal:new F,materialIndex:0};pi.getNormal(ia,na,sa,u.normal),h.face=u,h.barycoord=c}return h}class Ts extends Bn{constructor(t=1,e=1,i=1,n=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:n,heightSegments:s,depthSegments:a};const o=this;n=Math.floor(n),s=Math.floor(s),a=Math.floor(a);const A=[],l=[],h=[],c=[];let u=0,d=0;p("z","y","x",-1,-1,i,e,t,a,s,0),p("z","y","x",1,-1,i,e,-t,a,s,1),p("x","z","y",1,1,t,i,e,n,a,2),p("x","z","y",1,-1,t,i,-e,n,a,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(A),this.setAttribute("position",new On(l,3)),this.setAttribute("normal",new On(h,3)),this.setAttribute("uv",new On(c,2));function p(m,g,f,b,S,v,T,w,R,P,E){const x=v/R,M=T/P,z=v/2,O=T/2,U=w/2,W=R+1,Y=P+1;let $=0,H=0;const rt=new F;for(let At=0;At<Y;At++){const mt=At*M-O;for(let Bt=0;Bt<W;Bt++){const re=Bt*x-z;rt[m]=re*b,rt[g]=mt*S,rt[f]=U,l.push(rt.x,rt.y,rt.z),rt[m]=0,rt[g]=0,rt[f]=w>0?1:-1,h.push(rt.x,rt.y,rt.z),c.push(Bt/R),c.push(1-At/P),$+=1}}for(let At=0;At<P;At++)for(let mt=0;mt<R;mt++){const Bt=u+mt+W*At,re=u+mt+W*(At+1),te=u+(mt+1)+W*(At+1),J=u+(mt+1)+W*At;A.push(Bt,re,J),A.push(re,te,J),H+=6}o.addGroup(d,H,E),d+=H,u+=$}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ts(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function Rs(r){const t={};for(const e in r){t[e]={};for(const i in r[e]){const n=r[e][i];n&&(n.isColor||n.isMatrix3||n.isMatrix4||n.isVector2||n.isVector3||n.isVector4||n.isTexture||n.isQuaternion)?n.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][i]=null):t[e][i]=n.clone():Array.isArray(n)?t[e][i]=n.slice():t[e][i]=n}}return t}function Le(r){const t={};for(let e=0;e<r.length;e++){const i=Rs(r[e]);for(const n in i)t[n]=i[n]}return t}function vf(r){const t=[];for(let e=0;e<r.length;e++)t.push(r[e].clone());return t}function Ih(r){const t=r.getRenderTarget();return t===null?r.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:Xt.workingColorSpace}const xf={clone:Rs,merge:Le};var Ef=`void main() {
124
+ }`,mA={depth_vert:_u,depth_frag:Pu};class Lu extends as{constructor(t=(n,s,a)=>a.set(n,s,Math.cos(n)*Math.sin(s)),e=8,i=8){super(),this.type="ParametricGeometry",this.parameters={func:t,slices:e,stacks:i};const n=[],s=[],a=[],o=[],A=1e-5,l=new V,h=new V,c=new V,u=new V,d=new V,p=e+1;for(let m=0;m<=i;m++){const g=m/i;for(let f=0;f<=e;f++){const b=f/e;t(b,g,h),s.push(h.x,h.y,h.z),b-A>=0?(t(b-A,g,c),u.subVectors(h,c)):(t(b+A,g,c),u.subVectors(c,h)),g-A>=0?(t(b,g-A,c),d.subVectors(h,c)):(t(b,g+A,c),d.subVectors(c,h)),l.crossVectors(u,d).normalize(),a.push(l.x,l.y,l.z),o.push(b,g)}}for(let m=0;m<i;m++)for(let g=0;g<e;g++){const f=m*p+g,b=m*p+g+1,S=(m+1)*p+g+1,v=(m+1)*p+g;n.push(f,b,v),n.push(b,S,v)}this.setIndex(n),this.setAttribute("position",new yn(s,3)),this.setAttribute("normal",new yn(a,3)),this.setAttribute("uv",new yn(o,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}const Ya=new V;class wn{p1;p2;restDistance;constructor(t,e,i){this.p1=t,this.p2=e,this.restDistance=i}resolve(){const t=this.p1,e=this.p2,i=this.restDistance;Ya.subVectors(e.position,t.position);const n=Ya.length();if(n===0)return;const s=Ya.multiplyScalar((1-i/n)/2);t.position.add(s),e.position.sub(s)}}const IA=2,Du=.03,Nu=1-Du,Fu=.12,Ou=1.225;class Bu{position;previous;original;mass;inverseMass;acceleration;tmp;constructor(t,e){this.position=t.clone(),this.previous=t.clone(),this.original=t.clone(),this.mass=e,this.inverseMass=1/e,this.acceleration=new V,this.tmp=new V}applyForce(t){this.acceleration.addScaledVector(t,this.inverseMass)}integrate(t){const e=this.tmp.subVectors(this.position,this.previous).multiplyScalar(Nu).add(this.position).addScaledVector(this.acceleration,t);this.tmp=this.previous,this.previous=this.position,this.position=e,this.acceleration.set(0,0,0)}}class Uu{xSegments;ySegments;restDistance;width;height;particles;constraints;particleAt;geometry;constructor(t,e,i,n){const s=i*t,a=i*e,o=[],A=[],l=(m,g)=>o[m+g*(t+1)],h=(m,g,f)=>{f.set(m*s,g*a,0)},c=new V,u=n/((e+1)*(t+1));for(let m=0;m<=e;m++)for(let g=0;g<=t;g++)h(g/t,m/e,c),o.push(new Bu(c,u));for(let m=0;m<e;m++)for(let g=0;g<t;g++)A.push(new wn(l(g,m),l(g,m+1),i),new wn(l(g,m),l(g+1,m),i));for(let m=t,g=0;g<e;g++)A.push(new wn(l(m,g),l(m,g+1),i));for(let m=e,g=0;g<t;g++)A.push(new wn(l(g,m),l(g+1,m),i));const d=Math.sqrt(i*i*2);for(let m=0;m<e;m++)for(let g=0;g<t;g++)A.push(new wn(l(g,m),l(g+1,m+1),d),new wn(l(g+1,m),l(g,m+1),d));const p=new Lu(h,t,e);p.getAttribute("position").setUsage(35040),this.xSegments=t,this.ySegments=e,this.restDistance=i,this.width=s,this.height=a,this.particles=o,this.constraints=A,this.particleAt=l,this.geometry=p}reset(){for(const t of this.particles)t.previous.copy(t.position.copy(t.original))}simulate(t){const e=this.particles,i=this.constraints,n=Math.pow(t,2);for(let s=0,a=e.length;s<a;s++)e[s].integrate(n);for(let s=0,a=IA;s<a;s++)for(let o=0,A=i.length;o<A;o++)i[o].resolve()}render(){const t=this.particles,e=this.geometry,i=e.getAttribute("position"),n=i.array;for(let s=0,a=t.length;s<a;s++){const o=t[s].position,A=s*3;n[A]=o.x,n[A+1]=o.y,n[A+2]=o.z}i.needsUpdate=!0,e.computeVertexNormals()}}function zu(r){const{width:t,height:e,mass:i,restDistance:n}=r;return new Uu(Math.max(1,Math.round(t/n)),Math.max(1,Math.round(e/n)),n,i*t*e)}function CA(r,t,e){const i=r*t,n=new Uint8Array(4*i),s=Math.floor(e.r*255),a=Math.floor(e.g*255),o=Math.floor(e.b*255),A=255;for(let h=0;h<i;h++){const c=h*4;n[c]=s,n[c+1]=a,n[c+2]=o,n[c+3]=A}const l=new yu(n,r,t,1023,1009);return l.needsUpdate=!0,l}const ku=CA(1,1,new sn(16777215));function Gu(r,t){const e=r.geometry;let i=ku,n;const s=o=>(o.needsUpdate=!0,o.anisotropy=16,o.minFilter=1006,o.magFilter=1006,o.wrapS=1001,o.wrapT=1001,o),a=(o,A)=>{o.colorSpace=He;const l=new pA({alphaTest:.5,color:16777215,metalness:.08,roughness:.86,side:A,map:o}),h=new gA(e,l);return h.castShadow=!0,h.customDepthMaterial=new Ru({uniforms:{textureMap:{value:o}},vertexShader:mA.depth_vert,fragmentShader:mA.depth_frag,side:A,lights:!1,defines:{DEPTH_PACKING:"3200"}}),h.position.set(0,-r.height,0),h};return t?.texture instanceof Ii?(i=s(t.texture),t.backSideTexture instanceof Ii&&(n=s(t.backSideTexture))):t?.texture!==void 0&&console.error("FlagWaver.Flag: options.texture must be an instance of THREE.Texture."),[a(i,n!==void 0?0:2),n!==void 0?a(n,1):null]}const he={TOP:"top",LEFT:"left",BOTTOM:"bottom",RIGHT:"right"},Hu=(()=>{const r={edges:[],spacing:1};function t(e,i,n,s){const{xSegments:a,ySegments:o,particleAt:A}=e,{spacing:l}=s;switch(n){case he.TOP:for(let h=0;h<=a;h+=l)i.push(A(h,o));break;case he.LEFT:for(let h=0;h<=o;h+=l)i.push(A(0,h));break;case he.BOTTOM:for(let h=0;h<=a;h+=l)i.push(A(h,0));break;case he.RIGHT:for(let h=0;h<=o;h+=l)i.push(A(a,h));break}}return function(e,i,n={}){const s={...r,...n},{edges:a}=s;if(typeof a=="string")t(e,i,a,s);else if(Array.isArray(a)&&a.length>0)for(let o=0,A=a.length;o<A;o++)t(e,i,a[o],s)}})(),vA=1.2,Dr=new V;class xA extends wn{resolve(){const t=this.p1,e=this.p2,i=this.restDistance*vA;Dr.subVectors(t.position,e.position);const n=Dr.length()/vA;Dr.normalize();const s=Dr.multiplyScalar(n-i);n>i&&e.position.add(s)}}function EA(r){if(Array.isArray(r))for(const t of r)SA(t);else SA(r)}function SA(r){r.map?.dispose(),r.dispose()}const Vu=CA(1,1,new sn(16777215));class Js{cloth;pins;lengthConstraints;mesh;mesh2;object;static defaults={width:1.8,height:1.2,mass:.11,restDistance:1.2/10,rigidness:1,texture:Vu,backSideTexture:void 0,pin:{edges:[he.LEFT],spacing:1}};constructor(t={}){const e={...Js.defaults,...t};this.cloth=zu(e),this.pins=[],this.lengthConstraints=[];const[i,n]=Gu(this.cloth,e);this.mesh=i,this.mesh2=n,this.object=new qe,this.object.add(this.mesh),this.mesh2!==null&&this.object.add(this.mesh2),this.pin(e.pin)}destroy(){EA(this.mesh.material),this.mesh.geometry.dispose(),this.mesh.customDepthMaterial?.dispose(),this.mesh2!==null&&(EA(this.mesh2.material),this.mesh2.customDepthMaterial?.dispose())}pin(t){Hu(this.cloth,this.pins,t)}unpin(){this.pins=[]}setLengthConstraints(t){const{xSegments:e,ySegments:i,restDistance:n,particleAt:s}=this.cloth,a=[];if(t===he.LEFT)for(let o=0;o<=i;o++)for(let A=0;A<e;A++)a.push(new xA(s(A,o),s(A+1,o),n));else if(t===he.TOP)for(let o=0;o<=e;o++)for(let A=i;A>0;A--)a.push(new xA(s(o,A),s(o,A-1),n));this.lengthConstraints=a}reset(){this.cloth.reset()}simulate(t){const e=this.pins,i=this.lengthConstraints;this.cloth.simulate(t);for(const n of e)n.previous.copy(n.position.copy(n.original));for(let n=0;n<IA;n++)for(const s of i)s.resolve()}render(){this.cloth.render()}setTexture(t){t.needsUpdate=!0,t.anisotropy=16,t.minFilter=1006,t.magFilter=1006,t.wrapS=1001,t.wrapT=1001,t.colorSpace=He;const e=this.mesh.material;e.map!==null&&e.map!==void 0&&(e.map=t,e.needsUpdate=!0);const i=this.mesh.customDepthMaterial;if(i!=null){const n=i;n.uniforms!=null&&n.uniforms.textureMap!=null&&(n.uniforms.textureMap.value=t)}if(this.mesh2!=null){const n=this.mesh2.material;n.map!=null&&(n.map=t,n.needsUpdate=!0);const s=this.mesh2.customDepthMaterial;if(s!=null){const a=s;a.uniforms?.textureMap!=null&&(a.uniforms.textureMap.value=t)}}}}const Tn={CROSSBAR:"CROSSBAR",GALLERY:"GALLERY",HORIZONTAL:"HORIZONTAL",OUTRIGGER:"OUTRIGGER",VERTICAL:"VERTICAL"},js={NONE:"none",TOP_RIGHT:"topright",TOP_LEFT:"topleft"};class zi{top;mesh;object;constructor(t){this.create(t)}static defaults={flagpoleType:Tn.VERTICAL,poleWidth:.076,poleLength:6,poleCapSize:.076*4/3,crossbarWidth:.076*2/3,crossbarLength:1.2,crossbarCapSize:.076*2/3*3/2,poleTopOffset:.1,verticalHoisting:js.TOP_RIGHT};destroy(){this.mesh!==void 0&&((Array.isArray(this.mesh.material)?this.mesh.material:[this.mesh.material]).forEach(t=>{t.dispose()}),this.mesh.geometry.dispose())}create(t){this.destroy();const e=Object.assign({},zi.defaults,t),i=this.buildGeometry(e),n=new pA({color:16711422,metalness:.98,roughness:.55}),s=new gA(i,n);s.receiveShadow=!0,s.castShadow=!0,this.top=new V(0,e.poleLength,0),this.mesh=s,this.object=this.mesh}addFlag(t){t.unpin(),t.pin({edges:[he.LEFT]}),t.setLengthConstraints(he.LEFT),t.object.position.add(this.top)}}function Xa(r,t=!1){const e=r[0].index!==null,i=new Set(Object.keys(r[0].attributes)),n=new Set(Object.keys(r[0].morphAttributes)),s={},a={},o=r[0].morphTargetsRelative,A=new as;let l=0;for(let h=0;h<r.length;++h){const c=r[h];let u=0;if(e!==(c.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const d in c.attributes){if(!i.has(d))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+d+'" attribute exists among all geometries, or in none of them.'),null;s[d]===void 0&&(s[d]=[]),s[d].push(c.attributes[d]),u++}if(u!==i.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(o!==c.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const d in c.morphAttributes){if(!n.has(d))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;a[d]===void 0&&(a[d]=[]),a[d].push(c.morphAttributes[d])}if(t){let d;if(e)d=c.index.count;else if(c.attributes.position!==void 0)d=c.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;A.addGroup(l,d,h),l+=d}}if(e){let h=0;const c=[];for(let u=0;u<r.length;++u){const d=r[u].index;for(let p=0;p<d.count;++p)c.push(d.getX(p)+h);h+=r[u].attributes.position.count}A.setIndex(c)}for(const h in s){const c=yA(s[h]);if(!c)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" attribute."),null;A.setAttribute(h,c)}for(const h in a){const c=a[h][0].length;if(c===0)break;A.morphAttributes=A.morphAttributes||{},A.morphAttributes[h]=[];for(let u=0;u<c;++u){const d=[];for(let m=0;m<a[h].length;++m)d.push(a[h][m][u]);const p=yA(d);if(!p)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;A.morphAttributes[h].push(p)}}return A}function yA(r){let t,e,i,n=-1,s=0;for(let l=0;l<r.length;++l){const h=r[l];if(t===void 0&&(t=h.array.constructor),t!==h.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(e===void 0&&(e=h.itemSize),e!==h.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(i===void 0&&(i=h.normalized),i!==h.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(n===-1&&(n=h.gpuType),n!==h.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=h.count*e}const a=new t(s),o=new Sn(a,e,i);let A=0;for(let l=0;l<r.length;++l){const h=r[l];if(h.isInterleavedBufferAttribute){const c=A/e;for(let u=0,d=h.count;u<d;u++)for(let p=0;p<e;p++){const m=h.getComponent(u,p);o.setComponent(u+c,p,m)}}else a.set(h.array,A);A+=h.count*e}return n!==void 0&&(o.gpuType=n),o}function Qs(r){const t=r.poleWidth/2,e=r.poleLength,i=32,n=r.poleCapSize/2,s=new Mn(t,t,e,i);s.translate(0,r.poleLength/2,0);const a=new Mn(n,n,n,i);return a.translate(0,e+n/2,0),Xa([s,a])}function Wu(r){const t=Qs(r),e=r.poleWidth/2,i=r.poleLength,n=r.crossbarWidth/2,s=r.crossbarLength,a=16,o=r.crossbarCapSize/2,A=r.poleTopOffset,l=new Mn(n,n,s,a);l.rotateZ(Math.PI/2);const h=new Mn(o,o,o,a),c=h.clone(),u=i-A,d=e+n;return h.rotateZ(Math.PI/2),h.translate(-s/2,u,d),c.rotateZ(-Math.PI/2),c.translate(s/2,u,d),l.translate(0,u,d),Xa([t,l,h,c])}function Yu(r){const t=Qs(r),e=r.poleLength,i=r.poleCapSize/2,n=r.crossbarWidth/2,s=r.crossbarLength,a=16,o=new Mn(n,n,s,a);return o.rotateZ(Math.PI/2),o.translate(s/2,e+i-n,0),Xa([t,o])}class bA extends zi{constructor(t={}){super(t)}buildGeometry(t){return Qs(t)}}class Xu{flagpole;flag;object;constructor(t={}){const e={...t},{flagpole:i,flag:n}=e;this.flagpole=i??new bA,this.flag=n??new Js,this.flagpole.addFlag(this.flag),this.object=new qe,this.object.add(this.flagpole.object),this.object.add(this.flag.object)}destroy(){this.destroyChildSubject(this.flagpole),this.destroyChildSubject(this.flag)}destroyChildSubject(t){t!=null&&(this.object.remove(t.object),t.destroy())}reset(){this.flag.reset()}simulate(t){this.flag.simulate(t)}render(){this.flag.render()}setTexture(t){this.flag.setTexture(t)}}function Zu(r){return r===0?.001:r}function Ju(r){return r.x===0&&(r.x=.001),r.y===0&&(r.y=.001),r.z===0&&(r.z=.001),r}const MA={blowFromLeftDirection:r=>r.set(2e3,0,1e3),constantSpeed:r=>r};function ju(r){return .5*Ou*Math.pow(r,2)}class Za{direction;speed;directionFn;speedFn;pressure;static defaults={direction:new V(1,0,0),speed:10,directionFn:MA.blowFromLeftDirection,speedFn:MA.constantSpeed};constructor(t={}){const e={...Za.defaults,...t};this.direction=e.direction.clone(),this.speed=e.speed,this.directionFn=e.directionFn,this.speedFn=e.speedFn,this.pressure=new V}update(){const t=Date.now();this.directionFn(Ju(this.pressure.copy(this.direction)),t).normalize().multiplyScalar(ju(this.speedFn(Zu(this.speed),t)))}}const Nr=new V,wA=new V;function TA(r,t){return Nr.copy(r),t instanceof qe&&(wA.setFromMatrixPosition(t.matrixWorld),Nr.add(wA),t.worldToLocal(Nr)),Nr}const Qu=new V(0,-9.80665,0);function qu(r,t){const e=r.particles,i=TA(Qu,t);for(let n=0,s=e.length;n<s;n++)e[n].acceleration.add(i)}const Fr=new V,RA=new V;function Ku(r){return r<0?0:r>1?1:r}function _A(r){const t=Math.sin(r*12.9898)*43758.5453;return t-Math.floor(t)}function $u(r,t){const e=Ku(t?.randomizeAmount??0);if(e===0)return 1;const i=t?.randomSeed??r?.id??0,n=t?.time??0,s=.5+_A(i)*2,a=_A(i+1e3)*Math.PI*2;return 1+(Math.sin(n*s+a)*.5+Math.sin(n*s*1.7+a*.3)*.3)*e}function td(r,t,e){return Fr.subVectors(e,t),RA.subVectors(r,t),Fr.cross(RA),Fr.normalize(),Fr}function ed(r,t,e,i){const n=r.particles,s=r.geometry.getIndex();if(t==null||s==null)return;const a=r.restDistance*r.restDistance/2,o=$u(e,i),A=TA(t.pressure,e).multiplyScalar(Fu*a/3*o);for(let l=0,h=s.count;l<h;l+=3){const c=s.getX(l),u=s.getX(l+1),d=s.getX(l+2),p=n[c],m=n[u],g=n[d],f=td(p.position,m.position,g.position);f.multiplyScalar(f.dot(A)),p.applyForce(f),m.applyForce(f),g.applyForce(f)}}function id(r){return new Js(r)}function nd(r,t){const e={...r};return Object.entries(t).forEach(([i,n])=>{n!==void 0&&(e[i]=n)}),e}class sd extends zi{verticalHoisting;constructor(t={}){super(t);const e=nd(zi.defaults,t);this.top.set(0,e.poleLength-e.poleTopOffset,e.poleWidth/2+e.crossbarWidth/2),this.verticalHoisting=e.verticalHoisting}buildGeometry(t){return Wu(t)}addFlag(t){switch(t.unpin(),this.verticalHoisting){case js.NONE:t.pin({edges:[he.TOP]}),t.setLengthConstraints(he.TOP),t.object.position.add(this.top),t.object.position.x=-t.cloth.width/2;break;case js.TOP_LEFT:t.pin({edges:[he.LEFT]}),t.setLengthConstraints(he.LEFT),t.object.position.add(this.top),t.object.position.x=-t.cloth.height/2,t.object.rotateZ(Math.PI*3/2),t.object.rotateX(Math.PI);break;case js.TOP_RIGHT:default:t.pin({edges:[he.LEFT]}),t.setLengthConstraints(he.LEFT),t.object.position.add(this.top),t.object.position.x=t.cloth.height/2,t.object.rotateZ(Math.PI*3/2);break}}}class rd extends zi{buildGeometry(t){return Yu(t)}addFlag(t){t.unpin(),t.pin({edges:[he.LEFT,he.TOP]}),t.setLengthConstraints(he.LEFT),t.object.position.add(this.top)}}const ad=new V(0,0,1);class od extends zi{constructor(t={}){super(t),this.top.applyAxisAngle(ad,Math.PI*3/2)}buildGeometry(t){const e=Qs(t);return e.rotateZ(Math.PI*3/2),e}addFlag(t){t.unpin(),t.pin({edges:[he.LEFT]}),t.setLengthConstraints(he.LEFT),t.object.position.add(this.top),t.object.rotateZ(Math.PI*3/2)}}const ld=new V(0,0,1);class Ad extends zi{constructor(t={}){super(t),this.top.applyAxisAngle(ld,Math.PI*7/4)}buildGeometry(t){const e=Qs(t);return e.rotateZ(Math.PI*7/4),e}addFlag(t){t.unpin(),t.pin({edges:[he.LEFT]}),t.setLengthConstraints(he.LEFT),t.object.position.add(this.top),t.object.rotateZ(Math.PI*7/4)}}function hd(r,t){const e=Object.assign({},r);let i;switch(e.flagpoleType){case Tn.HORIZONTAL:i=new od(e);break;case Tn.OUTRIGGER:i=new Ad(e);break;case Tn.CROSSBAR:e.crossbarLength=e.verticalHoisting===js.NONE?t.cloth.width:t.cloth.height,i=new sd(e);break;case Tn.GALLERY:e.crossbarLength=t.cloth.width,i=new rd(e);break;case Tn.VERTICAL:default:i=new bA(e);break}return i}const ki=Object.freeze(Object.defineProperty({__proto__:null,FLAG_POLE_TYPE:Tn,Flag:Js,FlagGroup:Xu,Flagpole:zi,Wind:Za,applyGravityToCloth:qu,applyWindForceToCloth:ed,buildFlag:id,buildFlagpole:hd},Symbol.toStringTag,{value:"Module"}));const Ja="179",cd=0,PA=1,ud=2,LA=1,dd=2,Gi=3,ln=0,Ue=1,Hi=2,An=0,os=1,DA=2,NA=3,FA=4,fd=5,Rn=100,gd=101,pd=102,md=103,Id=104,Cd=200,vd=201,xd=202,Ed=203,ja=204,Qa=205,Sd=206,yd=207,bd=208,Md=209,wd=210,Td=211,Rd=212,_d=213,Pd=214,qa=0,Ka=1,$a=2,ls=3,to=4,eo=5,io=6,no=7,OA=0,Ld=1,Dd=2,hn=0,Nd=1,Fd=2,Od=3,Bd=4,Ud=5,zd=6,kd=7,BA=300,As=301,hs=302,so=303,ro=304,Or=306,ao=1e3,_n=1001,oo=1002,hi=1003,Gd=1004,Br=1005,Ci=1006,lo=1007,Pn=1008,vi=1009,UA=1010,zA=1011,qs=1012,Ao=1013,Ln=1014,Vi=1015,Ks=1016,ho=1017,co=1018,$s=1020,kA=35902,GA=1021,HA=1022,ci=1023,tr=1026,er=1027,VA=1028,uo=1029,WA=1030,fo=1031,go=1033,Ur=33776,zr=33777,kr=33778,Gr=33779,po=35840,mo=35841,Io=35842,Co=35843,vo=36196,xo=37492,Eo=37496,So=37808,yo=37809,bo=37810,Mo=37811,wo=37812,To=37813,Ro=37814,_o=37815,Po=37816,Lo=37817,Do=37818,No=37819,Fo=37820,Oo=37821,Hr=36492,Bo=36494,Uo=36495,YA=36283,zo=36284,ko=36285,Go=36286,Hd=3200,Vd=3201,XA=0,Wd=1,cn="",Pe="srgb",cs="srgb-linear",Vr="linear",Kt="srgb",us=7680,ZA=519,Yd=512,Xd=513,Zd=514,JA=515,Jd=516,jd=517,Qd=518,qd=519,jA=35044,QA="300 es",xi=2e3,Wr=2001;class ds{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[t]===void 0&&(i[t]=[]),i[t].indexOf(e)===-1&&i[t].push(e)}hasEventListener(t,e){const i=this._listeners;return i===void 0?!1:i[t]!==void 0&&i[t].indexOf(e)!==-1}removeEventListener(t,e){const i=this._listeners;if(i===void 0)return;const n=i[t];if(n!==void 0){const s=n.indexOf(e);s!==-1&&n.splice(s,1)}}dispatchEvent(t){const e=this._listeners;if(e===void 0)return;const i=e[t.type];if(i!==void 0){t.target=this;const n=i.slice(0);for(let s=0,a=n.length;s<a;s++)n[s].call(this,t);t.target=null}}}const Te=["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"],Ho=Math.PI/180,Yr=180/Math.PI;function ir(){const r=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Te[r&255]+Te[r>>8&255]+Te[r>>16&255]+Te[r>>24&255]+"-"+Te[t&255]+Te[t>>8&255]+"-"+Te[t>>16&15|64]+Te[t>>24&255]+"-"+Te[e&63|128]+Te[e>>8&255]+"-"+Te[e>>16&255]+Te[e>>24&255]+Te[i&255]+Te[i>>8&255]+Te[i>>16&255]+Te[i>>24&255]).toLowerCase()}function Ht(r,t,e){return Math.max(t,Math.min(e,r))}function Kd(r,t){return(r%t+t)%t}function Vo(r,t,e){return(1-e)*r+e*t}function nr(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function ze(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}class Jt{constructor(t=0,e=0){Jt.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=Ht(this.x,t.x,e.x),this.y=Ht(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Ht(this.x,t,e),this.y=Ht(this.y,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Ht(i,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(Ht(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,a=this.y-t.y;return this.x=s*i-a*n+t.x,this.y=s*n+a*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class fs{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,a,o){let A=i[n+0],l=i[n+1],h=i[n+2],c=i[n+3];const u=s[a+0],d=s[a+1],p=s[a+2],m=s[a+3];if(o===0){t[e+0]=A,t[e+1]=l,t[e+2]=h,t[e+3]=c;return}if(o===1){t[e+0]=u,t[e+1]=d,t[e+2]=p,t[e+3]=m;return}if(c!==m||A!==u||l!==d||h!==p){let g=1-o;const f=A*u+l*d+h*p+c*m,b=f>=0?1:-1,S=1-f*f;if(S>Number.EPSILON){const T=Math.sqrt(S),w=Math.atan2(T,f*b);g=Math.sin(g*w)/T,o=Math.sin(o*w)/T}const v=o*b;if(A=A*g+u*v,l=l*g+d*v,h=h*g+p*v,c=c*g+m*v,g===1-o){const T=1/Math.sqrt(A*A+l*l+h*h+c*c);A*=T,l*=T,h*=T,c*=T}}t[e]=A,t[e+1]=l,t[e+2]=h,t[e+3]=c}static multiplyQuaternionsFlat(t,e,i,n,s,a){const o=i[n],A=i[n+1],l=i[n+2],h=i[n+3],c=s[a],u=s[a+1],d=s[a+2],p=s[a+3];return t[e]=o*p+h*c+A*d-l*u,t[e+1]=A*p+h*u+l*c-o*d,t[e+2]=l*p+h*d+o*u-A*c,t[e+3]=h*p-o*c-A*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,a=t._order,o=Math.cos,A=Math.sin,l=o(i/2),h=o(n/2),c=o(s/2),u=A(i/2),d=A(n/2),p=A(s/2);switch(a){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;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&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],a=e[1],o=e[5],A=e[9],l=e[2],h=e[6],c=e[10],u=i+o+c;if(u>0){const d=.5/Math.sqrt(u+1);this._w=.25/d,this._x=(h-A)*d,this._y=(s-l)*d,this._z=(a-n)*d}else if(i>o&&i>c){const d=2*Math.sqrt(1+i-o-c);this._w=(h-A)/d,this._x=.25*d,this._y=(n+a)/d,this._z=(s+l)/d}else if(o>c){const d=2*Math.sqrt(1+o-i-c);this._w=(s-l)/d,this._x=(n+a)/d,this._y=.25*d,this._z=(A+h)/d}else{const d=2*Math.sqrt(1+c-i-o);this._w=(a-n)/d,this._x=(s+l)/d,this._y=(A+h)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<1e-8?(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(Ht(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(i===0)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 t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const i=t._x,n=t._y,s=t._z,a=t._w,o=e._x,A=e._y,l=e._z,h=e._w;return this._x=i*h+a*o+n*l-s*A,this._y=n*h+a*A+s*o-i*l,this._z=s*h+a*l+i*A-n*o,this._w=a*h-i*o-n*A-s*l,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const i=this._x,n=this._y,s=this._z,a=this._w;let o=a*t._w+i*t._x+n*t._y+s*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=i,this._y=n,this._z=s,this;const A=1-o*o;if(A<=Number.EPSILON){const d=1-e;return this._w=d*a+e*this._w,this._x=d*i+e*this._x,this._y=d*n+e*this._y,this._z=d*s+e*this._z,this.normalize(),this}const l=Math.sqrt(A),h=Math.atan2(l,o),c=Math.sin((1-e)*h)/l,u=Math.sin(e*h)/l;return this._w=a*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=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),n=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(n*Math.sin(t),n*Math.cos(t),s*Math.sin(e),s*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class F{constructor(t=0,e=0,i=0){F.prototype.isVector3=!0,this.x=t,this.y=e,this.z=i}set(t,e,i){return i===void 0&&(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(qA.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(qA.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,a=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])*a,this.y=(s[1]*e+s[5]*i+s[9]*n+s[13])*a,this.z=(s[2]*e+s[6]*i+s[10]*n+s[14])*a,this}applyQuaternion(t){const e=this.x,i=this.y,n=this.z,s=t.x,a=t.y,o=t.z,A=t.w,l=2*(a*n-o*i),h=2*(o*e-s*n),c=2*(s*i-a*e);return this.x=e+A*l+a*c-o*h,this.y=i+A*h+o*l-s*c,this.z=n+A*c+s*h-a*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=Ht(this.x,t.x,e.x),this.y=Ht(this.y,t.y,e.y),this.z=Ht(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Ht(this.x,t,e),this.y=Ht(this.y,t,e),this.z=Ht(this.z,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Ht(i,t,e))}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,a=e.x,o=e.y,A=e.z;return this.x=n*A-s*o,this.y=s*a-i*A,this.z=i*o-n*a,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return Wo.copy(this).projectOnVector(t),this.sub(Wo)}reflect(t){return this.sub(Wo.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(Ht(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,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,i=Math.sqrt(1-e*e);return this.x=i*Math.cos(t),this.y=e,this.z=i*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Wo=new F,qA=new fs;class Nt{constructor(t,e,i,n,s,a,o,A,l){Nt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,i,n,s,a,o,A,l)}set(t,e,i,n,s,a,o,A,l){const h=this.elements;return h[0]=t,h[1]=n,h[2]=o,h[3]=e,h[4]=s,h[5]=A,h[6]=i,h[7]=a,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,a=i[0],o=i[3],A=i[6],l=i[1],h=i[4],c=i[7],u=i[2],d=i[5],p=i[8],m=n[0],g=n[3],f=n[6],b=n[1],S=n[4],v=n[7],T=n[2],w=n[5],R=n[8];return s[0]=a*m+o*b+A*T,s[3]=a*g+o*S+A*w,s[6]=a*f+o*v+A*R,s[1]=l*m+h*b+c*T,s[4]=l*g+h*S+c*w,s[7]=l*f+h*v+c*R,s[2]=u*m+d*b+p*T,s[5]=u*g+d*S+p*w,s[8]=u*f+d*v+p*R,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],a=t[4],o=t[5],A=t[6],l=t[7],h=t[8];return e*a*h-e*o*l-i*s*h+i*o*A+n*s*l-n*a*A}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],s=t[3],a=t[4],o=t[5],A=t[6],l=t[7],h=t[8],c=h*a-o*l,u=o*A-h*s,d=l*s-a*A,p=e*c+i*u+n*d;if(p===0)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]=(o*i-n*a)*m,t[3]=u*m,t[4]=(h*e-n*A)*m,t[5]=(n*s-o*e)*m,t[6]=d*m,t[7]=(i*A-l*e)*m,t[8]=(a*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,a,o){const A=Math.cos(s),l=Math.sin(s);return this.set(i*A,i*l,-i*(A*a+l*o)+a+t,-n*l,n*A,-n*(-l*a+A*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(Yo.makeScale(t,e)),this}rotate(t){return this.premultiply(Yo.makeRotation(-t)),this}translate(t,e){return this.premultiply(Yo.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 Yo=new Nt;function KA(r){for(let t=r.length-1;t>=0;--t)if(r[t]>=65535)return!0;return!1}function sr(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function $d(){const r=sr("canvas");return r.style.display="block",r}const $A={};function gs(r){r in $A||($A[r]=!0,console.warn(r))}function tf(r,t,e){return new Promise(function(i,n){function s(){switch(r.clientWaitSync(t,r.SYNC_FLUSH_COMMANDS_BIT,0)){case r.WAIT_FAILED:n();break;case r.TIMEOUT_EXPIRED:setTimeout(s,e);break;default:i()}}setTimeout(s,e)})}const th=new Nt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),eh=new Nt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function ef(){const r={enabled:!0,workingColorSpace:cs,spaces:{},convert:function(n,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Kt&&(n.r=Wi(n.r),n.g=Wi(n.g),n.b=Wi(n.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(n.applyMatrix3(this.spaces[s].toXYZ),n.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Kt&&(n.r=ps(n.r),n.g=ps(n.g),n.b=ps(n.b))),n},workingToColorSpace:function(n,s){return this.convert(n,this.workingColorSpace,s)},colorSpaceToWorking:function(n,s){return this.convert(n,s,this.workingColorSpace)},getPrimaries:function(n){return this.spaces[n].primaries},getTransfer:function(n){return n===cn?Vr:this.spaces[n].transfer},getLuminanceCoefficients:function(n,s=this.workingColorSpace){return n.fromArray(this.spaces[s].luminanceCoefficients)},define:function(n){Object.assign(this.spaces,n)},_getMatrix:function(n,s,a){return n.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(n){return this.spaces[n].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(n=this.workingColorSpace){return this.spaces[n].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(n,s){return gs("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),r.workingToColorSpace(n,s)},toWorkingColorSpace:function(n,s){return gs("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),r.colorSpaceToWorking(n,s)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],i=[.3127,.329];return r.define({[cs]:{primaries:t,whitePoint:i,transfer:Vr,toXYZ:th,fromXYZ:eh,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Pe},outputColorSpaceConfig:{drawingBufferColorSpace:Pe}},[Pe]:{primaries:t,whitePoint:i,transfer:Kt,toXYZ:th,fromXYZ:eh,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Pe}}}),r}const Xt=ef();function Wi(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function ps(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let ms;class nf{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let i;if(t instanceof HTMLCanvasElement)i=t;else{ms===void 0&&(ms=sr("canvas")),ms.width=t.width,ms.height=t.height;const n=ms.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),i=ms}return i.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=sr("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 a=0;a<s.length;a++)s[a]=Wi(s[a]/255)*255;return i.putImageData(n,0,0),e}else if(t.data){const e=t.data.slice(0);for(let i=0;i<e.length;i++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[i]=Math.floor(Wi(e[i]/255)*255):e[i]=Wi(e[i]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let sf=0;class Xo{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:sf++}),this.uuid=ir(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):e instanceof VideoFrame?t.set(e.displayHeight,e.displayWidth,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const i={uuid:this.uuid,url:""},n=this.data;if(n!==null){let s;if(Array.isArray(n)){s=[];for(let a=0,o=n.length;a<o;a++)n[a].isDataTexture?s.push(Zo(n[a].image)):s.push(Zo(n[a]))}else s=Zo(n);i.url=s}return e||(t.images[this.uuid]=i),i}}function Zo(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?nf.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let rf=0;const Jo=new F;class Re extends ds{constructor(t=Re.DEFAULT_IMAGE,e=Re.DEFAULT_MAPPING,i=_n,n=_n,s=Ci,a=Pn,o=ci,A=vi,l=Re.DEFAULT_ANISOTROPY,h=cn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:rf++}),this.uuid=ir(),this.name="",this.source=new Xo(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=s,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=A,this.offset=new Jt(0,0),this.repeat=new Jt(1,1),this.center=new Jt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Nt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Jo).x}get height(){return this.source.getSize(Jo).y}get depth(){return this.source.getSize(Jo).z}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)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}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.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const i=t[e];if(i===void 0){console.warn(`THREE.Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const n=this[e];if(n===void 0){console.warn(`THREE.Texture.setValues(): property '${e}' does not exist.`);continue}n&&i&&n.isVector2&&i.isVector2||n&&i&&n.isVector3&&i.isVector3||n&&i&&n.isMatrix3&&i.isMatrix3?n.copy(i):this[e]=i}}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const i={metadata:{version:4.7,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!==BA)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case ao:t.x=t.x-Math.floor(t.x);break;case _n:t.x=t.x<0?0:1;break;case oo:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case ao:t.y=t.y-Math.floor(t.y);break;case _n:t.y=t.y<0?0:1;break;case oo:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}Re.DEFAULT_IMAGE=null,Re.DEFAULT_MAPPING=BA,Re.DEFAULT_ANISOTROPY=1;class ce{constructor(t=0,e=0,i=0,n=1){ce.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=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,s=this.w,a=t.elements;return this.x=a[0]*e+a[4]*i+a[8]*n+a[12]*s,this.y=a[1]*e+a[5]*i+a[9]*n+a[13]*s,this.z=a[2]*e+a[6]*i+a[10]*n+a[14]*s,this.w=a[3]*e+a[7]*i+a[11]*n+a[15]*s,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,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 A=t.elements,l=A[0],h=A[4],c=A[8],u=A[1],d=A[5],p=A[9],m=A[2],g=A[6],f=A[10];if(Math.abs(h-u)<.01&&Math.abs(c-m)<.01&&Math.abs(p-g)<.01){if(Math.abs(h+u)<.1&&Math.abs(c+m)<.1&&Math.abs(p+g)<.1&&Math.abs(l+d+f-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const S=(l+1)/2,v=(d+1)/2,T=(f+1)/2,w=(h+u)/4,R=(c+m)/4,P=(p+g)/4;return S>v&&S>T?S<.01?(i=0,n=.707106781,s=.707106781):(i=Math.sqrt(S),n=w/i,s=R/i):v>T?v<.01?(i=.707106781,n=0,s=.707106781):(n=Math.sqrt(v),i=w/n,s=P/n):T<.01?(i=.707106781,n=.707106781,s=0):(s=Math.sqrt(T),i=R/s,n=P/s),this.set(i,n,s,e),this}let b=Math.sqrt((g-p)*(g-p)+(c-m)*(c-m)+(u-h)*(u-h));return Math.abs(b)<.001&&(b=1),this.x=(g-p)/b,this.y=(c-m)/b,this.z=(u-h)/b,this.w=Math.acos((l+d+f-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Ht(this.x,t.x,e.x),this.y=Ht(this.y,t.y,e.y),this.z=Ht(this.z,t.z,e.z),this.w=Ht(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=Ht(this.x,t,e),this.y=Ht(this.y,t,e),this.z=Ht(this.z,t,e),this.w=Ht(this.w,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Ht(i,t,e))}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 af extends ds{constructor(t=1,e=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ci,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},i),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=i.depth,this.scissor=new ce(0,0,t,e),this.scissorTest=!1,this.viewport=new ce(0,0,t,e);const n={width:t,height:e,depth:i.depth},s=new Re(n);this.textures=[];const a=i.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview}_setTextureOptions(t={}){const e={minFilter:Ci,generateMipmaps:!1,flipY:!1,internalFormat:null};t.mapping!==void 0&&(e.mapping=t.mapping),t.wrapS!==void 0&&(e.wrapS=t.wrapS),t.wrapT!==void 0&&(e.wrapT=t.wrapT),t.wrapR!==void 0&&(e.wrapR=t.wrapR),t.magFilter!==void 0&&(e.magFilter=t.magFilter),t.minFilter!==void 0&&(e.minFilter=t.minFilter),t.format!==void 0&&(e.format=t.format),t.type!==void 0&&(e.type=t.type),t.anisotropy!==void 0&&(e.anisotropy=t.anisotropy),t.colorSpace!==void 0&&(e.colorSpace=t.colorSpace),t.flipY!==void 0&&(e.flipY=t.flipY),t.generateMipmaps!==void 0&&(e.generateMipmaps=t.generateMipmaps),t.internalFormat!==void 0&&(e.internalFormat=t.internalFormat);for(let i=0;i<this.textures.length;i++)this.textures[i].setValues(e)}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),t!==null&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}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.textures.length;n<s;n++)this.textures[n].image.width=t,this.textures[n].image.height=e,this.textures[n].image.depth=i,this.textures[n].isArrayTexture=this.textures[n].image.depth>1;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,i=t.textures.length;e<i;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;const n=Object.assign({},t.textures[e].image);this.textures[e].source=new Xo(n)}return this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Dn extends af{constructor(t=1,e=1,i={}){super(t,e,i),this.isWebGLRenderTarget=!0}}class ih extends Re{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=hi,this.minFilter=hi,this.wrapR=_n,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class of extends Re{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=hi,this.minFilter=hi,this.wrapR=_n,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Is{constructor(t=new F(1/0,1/0,1/0),e=new F(-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(ui.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,i=t.count;e<i;e++)this.expandByPoint(ui.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=ui.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(i!==void 0){const s=i.getAttribute("position");if(e===!0&&s!==void 0&&t.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)t.isMesh===!0?t.getVertexPosition(a,ui):ui.fromBufferAttribute(s,a),ui.applyMatrix4(t.matrixWorld),this.expandByPoint(ui);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Xr.copy(t.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Xr.copy(i.boundingBox)),Xr.applyMatrix4(t.matrixWorld),this.union(Xr)}const n=t.children;for(let s=0,a=n.length;s<a;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,ui),ui.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(rr),Zr.subVectors(this.max,rr),Cs.subVectors(t.a,rr),vs.subVectors(t.b,rr),xs.subVectors(t.c,rr),un.subVectors(vs,Cs),dn.subVectors(xs,vs),Nn.subVectors(Cs,xs);let e=[0,-un.z,un.y,0,-dn.z,dn.y,0,-Nn.z,Nn.y,un.z,0,-un.x,dn.z,0,-dn.x,Nn.z,0,-Nn.x,-un.y,un.x,0,-dn.y,dn.x,0,-Nn.y,Nn.x,0];return!jo(e,Cs,vs,xs,Zr)||(e=[1,0,0,0,1,0,0,0,1],!jo(e,Cs,vs,xs,Zr))?!1:(Jr.crossVectors(un,dn),e=[Jr.x,Jr.y,Jr.z],jo(e,Cs,vs,xs,Zr))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,ui).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(ui).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(Yi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Yi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Yi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Yi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Yi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Yi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Yi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Yi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Yi),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)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}}const Yi=[new F,new F,new F,new F,new F,new F,new F,new F],ui=new F,Xr=new Is,Cs=new F,vs=new F,xs=new F,un=new F,dn=new F,Nn=new F,rr=new F,Zr=new F,Jr=new F,Fn=new F;function jo(r,t,e,i,n){for(let s=0,a=r.length-3;s<=a;s+=3){Fn.fromArray(r,s);const o=n.x*Math.abs(Fn.x)+n.y*Math.abs(Fn.y)+n.z*Math.abs(Fn.z),A=t.dot(Fn),l=e.dot(Fn),h=i.dot(Fn);if(Math.max(-Math.max(A,l,h),Math.min(A,l,h))>o)return!1}return!0}const lf=new Is,ar=new F,Qo=new F;class qo{constructor(t=new F,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;e!==void 0?i.copy(e):lf.setFromPoints(t).getCenter(i);let n=0;for(let s=0,a=t.length;s<a;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;ar.subVectors(t,this.center);const e=ar.lengthSq();if(e>this.radius*this.radius){const i=Math.sqrt(e),n=(i-this.radius)*.5;this.center.addScaledVector(ar,n/i),this.radius+=n}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(Qo.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(ar.copy(t.center).add(Qo)),this.expandByPoint(ar.copy(t.center).sub(Qo))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}}const Xi=new F,Ko=new F,jr=new F,fn=new F,$o=new F,Qr=new F,tl=new F;class Af{constructor(t=new F,e=new F(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,Xi)),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=Xi.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Xi.copy(this.origin).addScaledVector(this.direction,e),Xi.distanceToSquared(t))}distanceSqToSegment(t,e,i,n){Ko.copy(t).add(e).multiplyScalar(.5),jr.copy(e).sub(t).normalize(),fn.copy(this.origin).sub(Ko);const s=t.distanceTo(e)*.5,a=-this.direction.dot(jr),o=fn.dot(this.direction),A=-fn.dot(jr),l=fn.lengthSq(),h=Math.abs(1-a*a);let c,u,d,p;if(h>0)if(c=a*A-o,u=a*o-A,p=s*h,c>=0)if(u>=-p)if(u<=p){const m=1/h;c*=m,u*=m,d=c*(c+a*u+2*o)+u*(a*c+u+2*A)+l}else u=s,c=Math.max(0,-(a*u+o)),d=-c*c+u*(u+2*A)+l;else u=-s,c=Math.max(0,-(a*u+o)),d=-c*c+u*(u+2*A)+l;else u<=-p?(c=Math.max(0,-(-a*s+o)),u=c>0?-s:Math.min(Math.max(-s,-A),s),d=-c*c+u*(u+2*A)+l):u<=p?(c=0,u=Math.min(Math.max(-s,-A),s),d=u*(u+2*A)+l):(c=Math.max(0,-(a*s+o)),u=c>0?s:Math.min(Math.max(-s,-A),s),d=-c*c+u*(u+2*A)+l);else u=a>0?-s:s,c=Math.max(0,-(a*u+o)),d=-c*c+u*(u+2*A)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,c),n&&n.copy(Ko).addScaledVector(jr,u),d}intersectSphere(t,e){Xi.subVectors(t.center,this.origin);const i=Xi.dot(this.direction),n=Xi.dot(Xi)-i*i,s=t.radius*t.radius;if(n>s)return null;const a=Math.sqrt(s-n),o=i-a,A=i+a;return A<0?null:o<0?this.at(A,e):this.at(o,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){const i=this.distanceToPlane(t);return i===null?null:this.at(i,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let i,n,s,a,o,A;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,a=(t.max.y-u.y)*h):(s=(t.max.y-u.y)*h,a=(t.min.y-u.y)*h),i>a||s>n||((s>i||isNaN(i))&&(i=s),(a<n||isNaN(n))&&(n=a),c>=0?(o=(t.min.z-u.z)*c,A=(t.max.z-u.z)*c):(o=(t.max.z-u.z)*c,A=(t.min.z-u.z)*c),i>A||o>n)||((o>i||i!==i)&&(i=o),(A<n||n!==n)&&(n=A),n<0)?null:this.at(i>=0?i:n,e)}intersectsBox(t){return this.intersectBox(t,Xi)!==null}intersectTriangle(t,e,i,n,s){$o.subVectors(e,t),Qr.subVectors(i,t),tl.crossVectors($o,Qr);let a=this.direction.dot(tl),o;if(a>0){if(n)return null;o=1}else if(a<0)o=-1,a=-a;else return null;fn.subVectors(this.origin,t);const A=o*this.direction.dot(Qr.crossVectors(fn,Qr));if(A<0)return null;const l=o*this.direction.dot($o.cross(fn));if(l<0||A+l>a)return null;const h=-o*fn.dot(tl);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 de{constructor(t,e,i,n,s,a,o,A,l,h,c,u,d,p,m,g){de.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,i,n,s,a,o,A,l,h,c,u,d,p,m,g)}set(t,e,i,n,s,a,o,A,l,h,c,u,d,p,m,g){const f=this.elements;return f[0]=t,f[4]=e,f[8]=i,f[12]=n,f[1]=s,f[5]=a,f[9]=o,f[13]=A,f[2]=l,f[6]=h,f[10]=c,f[14]=u,f[3]=d,f[7]=p,f[11]=m,f[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new de().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/Es.setFromMatrixColumn(t,0).length(),s=1/Es.setFromMatrixColumn(t,1).length(),a=1/Es.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]*a,e[9]=i[9]*a,e[10]=i[10]*a,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,a=Math.cos(i),o=Math.sin(i),A=Math.cos(n),l=Math.sin(n),h=Math.cos(s),c=Math.sin(s);if(t.order==="XYZ"){const u=a*h,d=a*c,p=o*h,m=o*c;e[0]=A*h,e[4]=-A*c,e[8]=l,e[1]=d+p*l,e[5]=u-m*l,e[9]=-o*A,e[2]=m-u*l,e[6]=p+d*l,e[10]=a*A}else if(t.order==="YXZ"){const u=A*h,d=A*c,p=l*h,m=l*c;e[0]=u+m*o,e[4]=p*o-d,e[8]=a*l,e[1]=a*c,e[5]=a*h,e[9]=-o,e[2]=d*o-p,e[6]=m+u*o,e[10]=a*A}else if(t.order==="ZXY"){const u=A*h,d=A*c,p=l*h,m=l*c;e[0]=u-m*o,e[4]=-a*c,e[8]=p+d*o,e[1]=d+p*o,e[5]=a*h,e[9]=m-u*o,e[2]=-a*l,e[6]=o,e[10]=a*A}else if(t.order==="ZYX"){const u=a*h,d=a*c,p=o*h,m=o*c;e[0]=A*h,e[4]=p*l-d,e[8]=u*l+m,e[1]=A*c,e[5]=m*l+u,e[9]=d*l-p,e[2]=-l,e[6]=o*A,e[10]=a*A}else if(t.order==="YZX"){const u=a*A,d=a*l,p=o*A,m=o*l;e[0]=A*h,e[4]=m-u*c,e[8]=p*c+d,e[1]=c,e[5]=a*h,e[9]=-o*h,e[2]=-l*h,e[6]=d*c+p,e[10]=u-m*c}else if(t.order==="XZY"){const u=a*A,d=a*l,p=o*A,m=o*l;e[0]=A*h,e[4]=-c,e[8]=l*h,e[1]=u*c+m,e[5]=a*h,e[9]=d*c-p,e[2]=p*c-d,e[6]=o*h,e[10]=m*c+u}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(hf,t,cf)}lookAt(t,e,i){const n=this.elements;return Xe.subVectors(t,e),Xe.lengthSq()===0&&(Xe.z=1),Xe.normalize(),gn.crossVectors(i,Xe),gn.lengthSq()===0&&(Math.abs(i.z)===1?Xe.x+=1e-4:Xe.z+=1e-4,Xe.normalize(),gn.crossVectors(i,Xe)),gn.normalize(),qr.crossVectors(Xe,gn),n[0]=gn.x,n[4]=qr.x,n[8]=Xe.x,n[1]=gn.y,n[5]=qr.y,n[9]=Xe.y,n[2]=gn.z,n[6]=qr.z,n[10]=Xe.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,a=i[0],o=i[4],A=i[8],l=i[12],h=i[1],c=i[5],u=i[9],d=i[13],p=i[2],m=i[6],g=i[10],f=i[14],b=i[3],S=i[7],v=i[11],T=i[15],w=n[0],R=n[4],P=n[8],E=n[12],x=n[1],M=n[5],z=n[9],O=n[13],U=n[2],W=n[6],Y=n[10],$=n[14],H=n[3],rt=n[7],At=n[11],mt=n[15];return s[0]=a*w+o*x+A*U+l*H,s[4]=a*R+o*M+A*W+l*rt,s[8]=a*P+o*z+A*Y+l*At,s[12]=a*E+o*O+A*$+l*mt,s[1]=h*w+c*x+u*U+d*H,s[5]=h*R+c*M+u*W+d*rt,s[9]=h*P+c*z+u*Y+d*At,s[13]=h*E+c*O+u*$+d*mt,s[2]=p*w+m*x+g*U+f*H,s[6]=p*R+m*M+g*W+f*rt,s[10]=p*P+m*z+g*Y+f*At,s[14]=p*E+m*O+g*$+f*mt,s[3]=b*w+S*x+v*U+T*H,s[7]=b*R+S*M+v*W+T*rt,s[11]=b*P+S*z+v*Y+T*At,s[15]=b*E+S*O+v*$+T*mt,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],a=t[1],o=t[5],A=t[9],l=t[13],h=t[2],c=t[6],u=t[10],d=t[14],p=t[3],m=t[7],g=t[11],f=t[15];return p*(+s*A*c-n*l*c-s*o*u+i*l*u+n*o*d-i*A*d)+m*(+e*A*d-e*l*u+s*a*u-n*a*d+n*l*h-s*A*h)+g*(+e*l*c-e*o*d-s*a*c+i*a*d+s*o*h-i*l*h)+f*(-n*o*h-e*A*c+e*o*u+n*a*c-i*a*u+i*A*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],a=t[4],o=t[5],A=t[6],l=t[7],h=t[8],c=t[9],u=t[10],d=t[11],p=t[12],m=t[13],g=t[14],f=t[15],b=c*g*l-m*u*l+m*A*d-o*g*d-c*A*f+o*u*f,S=p*u*l-h*g*l-p*A*d+a*g*d+h*A*f-a*u*f,v=h*m*l-p*c*l+p*o*d-a*m*d-h*o*f+a*c*f,T=p*c*A-h*m*A-p*o*u+a*m*u+h*o*g-a*c*g,w=e*b+i*S+n*v+s*T;if(w===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const R=1/w;return t[0]=b*R,t[1]=(m*u*s-c*g*s-m*n*d+i*g*d+c*n*f-i*u*f)*R,t[2]=(o*g*s-m*A*s+m*n*l-i*g*l-o*n*f+i*A*f)*R,t[3]=(c*A*s-o*u*s-c*n*l+i*u*l+o*n*d-i*A*d)*R,t[4]=S*R,t[5]=(h*g*s-p*u*s+p*n*d-e*g*d-h*n*f+e*u*f)*R,t[6]=(p*A*s-a*g*s-p*n*l+e*g*l+a*n*f-e*A*f)*R,t[7]=(a*u*s-h*A*s+h*n*l-e*u*l-a*n*d+e*A*d)*R,t[8]=v*R,t[9]=(p*c*s-h*m*s-p*i*d+e*m*d+h*i*f-e*c*f)*R,t[10]=(a*m*s-p*o*s+p*i*l-e*m*l-a*i*f+e*o*f)*R,t[11]=(h*o*s-a*c*s-h*i*l+e*c*l+a*i*d-e*o*d)*R,t[12]=T*R,t[13]=(h*m*n-p*c*n+p*i*u-e*m*u-h*i*g+e*c*g)*R,t[14]=(p*o*n-a*m*n-p*i*A+e*m*A+a*i*g-e*o*g)*R,t[15]=(a*c*n-h*o*n+h*i*A-e*c*A-a*i*u+e*o*u)*R,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,a=t.x,o=t.y,A=t.z,l=s*a,h=s*o;return this.set(l*a+i,l*o-n*A,l*A+n*o,0,l*o+n*A,h*o+i,h*A-n*a,0,l*A-n*o,h*A+n*a,s*A*A+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,a){return this.set(1,i,s,0,t,1,a,0,e,n,1,0,0,0,0,1),this}compose(t,e,i){const n=this.elements,s=e._x,a=e._y,o=e._z,A=e._w,l=s+s,h=a+a,c=o+o,u=s*l,d=s*h,p=s*c,m=a*h,g=a*c,f=o*c,b=A*l,S=A*h,v=A*c,T=i.x,w=i.y,R=i.z;return n[0]=(1-(m+f))*T,n[1]=(d+v)*T,n[2]=(p-S)*T,n[3]=0,n[4]=(d-v)*w,n[5]=(1-(u+f))*w,n[6]=(g+b)*w,n[7]=0,n[8]=(p+S)*R,n[9]=(g-b)*R,n[10]=(1-(u+m))*R,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=Es.set(n[0],n[1],n[2]).length();const a=Es.set(n[4],n[5],n[6]).length(),o=Es.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],di.copy(this);const l=1/s,h=1/a,c=1/o;return di.elements[0]*=l,di.elements[1]*=l,di.elements[2]*=l,di.elements[4]*=h,di.elements[5]*=h,di.elements[6]*=h,di.elements[8]*=c,di.elements[9]*=c,di.elements[10]*=c,e.setFromRotationMatrix(di),i.x=s,i.y=a,i.z=o,this}makePerspective(t,e,i,n,s,a,o=xi,A=!1){const l=this.elements,h=2*s/(e-t),c=2*s/(i-n),u=(e+t)/(e-t),d=(i+n)/(i-n);let p,m;if(A)p=s/(a-s),m=a*s/(a-s);else if(o===xi)p=-(a+s)/(a-s),m=-2*a*s/(a-s);else if(o===Wr)p=-a/(a-s),m=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=c,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,i,n,s,a,o=xi,A=!1){const l=this.elements,h=2/(e-t),c=2/(i-n),u=-(e+t)/(e-t),d=-(i+n)/(i-n);let p,m;if(A)p=1/(a-s),m=a/(a-s);else if(o===xi)p=-2/(a-s),m=-(a+s)/(a-s);else if(o===Wr)p=-1/(a-s),m=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=0,l[12]=u,l[1]=0,l[5]=c,l[9]=0,l[13]=d,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=0,l[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 Es=new F,di=new de,hf=new F(0,0,0),cf=new F(1,1,1),gn=new F,qr=new F,Xe=new F,nh=new de,sh=new fs;class fi{constructor(t=0,e=0,i=0,n=fi.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],a=n[4],o=n[8],A=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(Ht(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Ht(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(A,l)):(this._y=Math.atan2(-c,s),this._z=0);break;case"ZXY":this._x=Math.asin(Ht(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(A,s));break;case"ZYX":this._y=Math.asin(-Ht(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(A,s)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(Ht(A,-1,1)),Math.abs(A)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-c,s)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-Ht(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,i===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return nh.makeRotationFromQuaternion(t),this.setFromRotationMatrix(nh,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return sh.setFromEuler(this),this.setFromQuaternion(sh,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}fi.DEFAULT_ORDER="XYZ";class rh{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let uf=0;const ah=new F,Ss=new fs,Zi=new de,Kr=new F,or=new F,df=new F,ff=new fs,oh=new F(1,0,0),lh=new F(0,1,0),Ah=new F(0,0,1),hh={type:"added"},gf={type:"removed"},ys={type:"childadded",child:null},el={type:"childremoved",child:null};class Ee extends ds{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:uf++}),this.uuid=ir(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Ee.DEFAULT_UP.clone();const t=new F,e=new fi,i=new fs,n=new F(1,1,1);function s(){i.setFromEuler(e,!1)}function a(){e.setFromQuaternion(i,void 0,!1)}e._onChange(s),i._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new de},normalMatrix:{value:new Nt}}),this.matrix=new de,this.matrixWorld=new de,this.matrixAutoUpdate=Ee.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Ee.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new rh,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,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 Ss.setFromAxisAngle(t,e),this.quaternion.multiply(Ss),this}rotateOnWorldAxis(t,e){return Ss.setFromAxisAngle(t,e),this.quaternion.premultiply(Ss),this}rotateX(t){return this.rotateOnAxis(oh,t)}rotateY(t){return this.rotateOnAxis(lh,t)}rotateZ(t){return this.rotateOnAxis(Ah,t)}translateOnAxis(t,e){return ah.copy(t).applyQuaternion(this.quaternion),this.position.add(ah.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(oh,t)}translateY(t){return this.translateOnAxis(lh,t)}translateZ(t){return this.translateOnAxis(Ah,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Zi.copy(this.matrixWorld).invert())}lookAt(t,e,i){t.isVector3?Kr.copy(t):Kr.set(t,e,i);const n=this.parent;this.updateWorldMatrix(!0,!1),or.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Zi.lookAt(or,Kr,this.up):Zi.lookAt(Kr,or,this.up),this.quaternion.setFromRotationMatrix(Zi),n&&(Zi.extractRotation(n.matrixWorld),Ss.setFromRotationMatrix(Zi),this.quaternion.premultiply(Ss.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(hh),ys.child=t,this.dispatchEvent(ys),ys.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(gf),el.child=t,this.dispatchEvent(el),el.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),Zi.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),Zi.multiply(t.parent.matrixWorld)),t.applyMatrix4(Zi),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(hh),ys.child=t,this.dispatchEvent(ys),ys.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let i=0,n=this.children.length;i<n;i++){const a=this.children[i].getObjectByProperty(t,e);if(a!==void 0)return a}}getObjectsByProperty(t,e,i=[]){this[t]===e&&i.push(this);const n=this.children;for(let s=0,a=n.length;s<a;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(or,t,df),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(or,ff,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(this.visible===!1)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;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].updateMatrixWorld(t)}updateWorldMatrix(t,e){const i=this.parent;if(t===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){const n=this.children;for(let s=0,a=n.length;s<a;s++)n[s].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",i={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const n={};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.castShadow===!0&&(n.castShadow=!0),this.receiveShadow===!0&&(n.receiveShadow=!0),this.visible===!1&&(n.visible=!1),this.frustumCulled===!1&&(n.frustumCulled=!1),this.renderOrder!==0&&(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(),this.matrixAutoUpdate===!1&&(n.matrixAutoUpdate=!1),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(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.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),n.instanceInfo=this._instanceInfo.map(o=>({...o})),n.availableInstanceIds=this._availableInstanceIds.slice(),n.availableGeometryIds=this._availableGeometryIds.slice(),n.nextIndexStart=this._nextIndexStart,n.nextVertexStart=this._nextVertexStart,n.geometryCount=this._geometryCount,n.maxInstanceCount=this._maxInstanceCount,n.maxVertexCount=this._maxVertexCount,n.maxIndexCount=this._maxIndexCount,n.geometryInitialized=this._geometryInitialized,n.matricesTexture=this._matricesTexture.toJSON(t),n.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(n.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(n.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(n.boundingBox=this.boundingBox.toJSON()));function s(o,A){return o[A.uuid]===void 0&&(o[A.uuid]=A.toJSON(t)),A.uuid}if(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&&this.environment.isRenderTargetTexture!==!0&&(n.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=s(t.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const A=o.shapes;if(Array.isArray(A))for(let l=0,h=A.length;l<h;l++){const c=A[l];s(t.shapes,c)}else s(t.shapes,A)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(t.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let A=0,l=this.material.length;A<l;A++)o.push(s(t.materials,this.material[A]));n.material=o}else n.material=s(t.materials,this.material);if(this.children.length>0){n.children=[];for(let o=0;o<this.children.length;o++)n.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){n.animations=[];for(let o=0;o<this.animations.length;o++){const A=this.animations[o];n.animations.push(s(t.animations,A))}}if(e){const o=a(t.geometries),A=a(t.materials),l=a(t.textures),h=a(t.images),c=a(t.shapes),u=a(t.skeletons),d=a(t.animations),p=a(t.nodes);o.length>0&&(i.geometries=o),A.length>0&&(i.materials=A),l.length>0&&(i.textures=l),h.length>0&&(i.images=h),c.length>0&&(i.shapes=c),u.length>0&&(i.skeletons=u),d.length>0&&(i.animations=d),p.length>0&&(i.nodes=p)}return i.object=n,i;function a(o){const A=[];for(const l in o){const h=o[l];delete h.metadata,A.push(h)}return A}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let i=0;i<t.children.length;i++){const n=t.children[i];this.add(n.clone())}return this}}Ee.DEFAULT_UP=new F(0,1,0),Ee.DEFAULT_MATRIX_AUTO_UPDATE=!0,Ee.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const gi=new F,Ji=new F,il=new F,ji=new F,bs=new F,Ms=new F,ch=new F,nl=new F,sl=new F,rl=new F,al=new ce,ol=new ce,ll=new ce;class pi{constructor(t=new F,e=new F,i=new F){this.a=t,this.b=e,this.c=i}static getNormal(t,e,i,n){n.subVectors(i,e),gi.subVectors(t,e),n.cross(gi);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){gi.subVectors(n,e),Ji.subVectors(i,e),il.subVectors(t,e);const a=gi.dot(gi),o=gi.dot(Ji),A=gi.dot(il),l=Ji.dot(Ji),h=Ji.dot(il),c=a*l-o*o;if(c===0)return s.set(0,0,0),null;const u=1/c,d=(l*A-o*h)*u,p=(a*h-o*A)*u;return s.set(1-d-p,p,d)}static containsPoint(t,e,i,n){return this.getBarycoord(t,e,i,n,ji)===null?!1:ji.x>=0&&ji.y>=0&&ji.x+ji.y<=1}static getInterpolation(t,e,i,n,s,a,o,A){return this.getBarycoord(t,e,i,n,ji)===null?(A.x=0,A.y=0,"z"in A&&(A.z=0),"w"in A&&(A.w=0),null):(A.setScalar(0),A.addScaledVector(s,ji.x),A.addScaledVector(a,ji.y),A.addScaledVector(o,ji.z),A)}static getInterpolatedAttribute(t,e,i,n,s,a){return al.setScalar(0),ol.setScalar(0),ll.setScalar(0),al.fromBufferAttribute(t,e),ol.fromBufferAttribute(t,i),ll.fromBufferAttribute(t,n),a.setScalar(0),a.addScaledVector(al,s.x),a.addScaledVector(ol,s.y),a.addScaledVector(ll,s.z),a}static isFrontFacing(t,e,i,n){return gi.subVectors(i,e),Ji.subVectors(t,e),gi.cross(Ji).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 gi.subVectors(this.c,this.b),Ji.subVectors(this.a,this.b),gi.cross(Ji).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return pi.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return pi.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,i,n,s){return pi.getInterpolation(t,this.a,this.b,this.c,e,i,n,s)}containsPoint(t){return pi.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return pi.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 a,o;bs.subVectors(n,i),Ms.subVectors(s,i),nl.subVectors(t,i);const A=bs.dot(nl),l=Ms.dot(nl);if(A<=0&&l<=0)return e.copy(i);sl.subVectors(t,n);const h=bs.dot(sl),c=Ms.dot(sl);if(h>=0&&c<=h)return e.copy(n);const u=A*c-h*l;if(u<=0&&A>=0&&h<=0)return a=A/(A-h),e.copy(i).addScaledVector(bs,a);rl.subVectors(t,s);const d=bs.dot(rl),p=Ms.dot(rl);if(p>=0&&d<=p)return e.copy(s);const m=d*l-A*p;if(m<=0&&l>=0&&p<=0)return o=l/(l-p),e.copy(i).addScaledVector(Ms,o);const g=h*p-d*c;if(g<=0&&c-h>=0&&d-p>=0)return ch.subVectors(s,n),o=(c-h)/(c-h+(d-p)),e.copy(n).addScaledVector(ch,o);const f=1/(g+m+u);return a=m*f,o=u*f,e.copy(i).addScaledVector(bs,a).addScaledVector(Ms,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const uh={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},pn={h:0,s:0,l:0},$r={h:0,s:0,l:0};function Al(r,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?r+(t-r)*6*e:e<1/2?t:e<2/3?r+(t-r)*6*(2/3-e):r}class Vt{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(e===void 0&&i===void 0){const n=t;n&&n.isColor?this.copy(n):typeof n=="number"?this.setHex(n):typeof n=="string"&&this.setStyle(n)}else this.setRGB(t,e,i);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Pe){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Xt.colorSpaceToWorking(this,e),this}setRGB(t,e,i,n=Xt.workingColorSpace){return this.r=t,this.g=e,this.b=i,Xt.colorSpaceToWorking(this,n),this}setHSL(t,e,i,n=Xt.workingColorSpace){if(t=Kd(t,1),e=Ht(e,0,1),i=Ht(i,0,1),e===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+e):i+e-i*e,a=2*i-s;this.r=Al(a,s,t+1/3),this.g=Al(a,s,t),this.b=Al(a,s,t-1/3)}return Xt.colorSpaceToWorking(this,n),this}setStyle(t,e=Pe){function i(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(t)){let s;const a=n[1],o=n[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,e);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,e);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){const s=n[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(s,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Pe){const i=uh[t.toLowerCase()];return i!==void 0?this.setHex(i,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=Wi(t.r),this.g=Wi(t.g),this.b=Wi(t.b),this}copyLinearToSRGB(t){return this.r=ps(t.r),this.g=ps(t.g),this.b=ps(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Pe){return Xt.workingToColorSpace(_e.copy(this),t),Math.round(Ht(_e.r*255,0,255))*65536+Math.round(Ht(_e.g*255,0,255))*256+Math.round(Ht(_e.b*255,0,255))}getHexString(t=Pe){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Xt.workingColorSpace){Xt.workingToColorSpace(_e.copy(this),e);const i=_e.r,n=_e.g,s=_e.b,a=Math.max(i,n,s),o=Math.min(i,n,s);let A,l;const h=(o+a)/2;if(o===a)A=0,l=0;else{const c=a-o;switch(l=h<=.5?c/(a+o):c/(2-a-o),a){case i:A=(n-s)/c+(n<s?6:0);break;case n:A=(s-i)/c+2;break;case s:A=(i-n)/c+4;break}A/=6}return t.h=A,t.s=l,t.l=h,t}getRGB(t,e=Xt.workingColorSpace){return Xt.workingToColorSpace(_e.copy(this),e),t.r=_e.r,t.g=_e.g,t.b=_e.b,t}getStyle(t=Pe){Xt.workingToColorSpace(_e.copy(this),t);const e=_e.r,i=_e.g,n=_e.b;return t!==Pe?`color(${t} ${e.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(i*255)},${Math.round(n*255)})`}offsetHSL(t,e,i){return this.getHSL(pn),this.setHSL(pn.h+t,pn.s+e,pn.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(pn),t.getHSL($r);const i=Vo(pn.h,$r.h,e),n=Vo(pn.s,$r.s,e),s=Vo(pn.l,$r.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 _e=new Vt;Vt.NAMES=uh;let pf=0;class lr extends ds{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:pf++}),this.uuid=ir(),this.name="",this.type="Material",this.blending=os,this.side=ln,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=ja,this.blendDst=Qa,this.blendEquation=Rn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Vt(0,0,0),this.blendAlpha=0,this.depthFunc=ls,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=ZA,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=us,this.stencilZFail=us,this.stencilZPass=us,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const i=t[e];if(i===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const n=this[e];if(n===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[e]=i}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(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()),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(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),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(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,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==os&&(i.blending=this.blending),this.side!==ln&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==ja&&(i.blendSrc=this.blendSrc),this.blendDst!==Qa&&(i.blendDst=this.blendDst),this.blendEquation!==Rn&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==ls&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==ZA&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==us&&(i.stencilFail=this.stencilFail),this.stencilZFail!==us&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==us&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function n(s){const a=[];for(const o in s){const A=s[o];delete A.metadata,a.push(A)}return a}if(e){const s=n(t.textures),a=n(t.images);s.length>0&&(i.textures=s),a.length>0&&(i.images=a)}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(e!==null){const n=e.length;i=new Array(n);for(let s=0;s!==n;++s)i[s]=e[s].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){t===!0&&this.version++}}class hl extends lr{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Vt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new fi,this.combine=OA,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const me=new F,ta=new Jt;let mf=0;class Ei{constructor(t,e,i=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:mf++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=i,this.usage=jA,this.updateRanges=[],this.gpuType=Vi,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,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(this.itemSize===2)for(let e=0,i=this.count;e<i;e++)ta.fromBufferAttribute(this,e),ta.applyMatrix3(t),this.setXY(e,ta.x,ta.y);else if(this.itemSize===3)for(let e=0,i=this.count;e<i;e++)me.fromBufferAttribute(this,e),me.applyMatrix3(t),this.setXYZ(e,me.x,me.y,me.z);return this}applyMatrix4(t){for(let e=0,i=this.count;e<i;e++)me.fromBufferAttribute(this,e),me.applyMatrix4(t),this.setXYZ(e,me.x,me.y,me.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)me.fromBufferAttribute(this,e),me.applyNormalMatrix(t),this.setXYZ(e,me.x,me.y,me.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)me.fromBufferAttribute(this,e),me.transformDirection(t),this.setXYZ(e,me.x,me.y,me.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=nr(i,this.array)),i}setComponent(t,e,i){return this.normalized&&(i=ze(i,this.array)),this.array[t*this.itemSize+e]=i,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=nr(e,this.array)),e}setX(t,e){return this.normalized&&(e=ze(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=nr(e,this.array)),e}setY(t,e){return this.normalized&&(e=ze(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=nr(e,this.array)),e}setZ(t,e){return this.normalized&&(e=ze(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=nr(e,this.array)),e}setW(t,e){return this.normalized&&(e=ze(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=ze(e,this.array),i=ze(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=ze(e,this.array),i=ze(i,this.array),n=ze(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=ze(e,this.array),i=ze(i,this.array),n=ze(n,this.array),s=ze(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!==jA&&(t.usage=this.usage),t}}class dh extends Ei{constructor(t,e,i){super(new Uint16Array(t),e,i)}}class fh extends Ei{constructor(t,e,i){super(new Uint32Array(t),e,i)}}class On extends Ei{constructor(t,e,i){super(new Float32Array(t),e,i)}}let If=0;const $e=new de,cl=new Ee,ws=new F,Ze=new Is,Ar=new Is,Se=new F;class Bn extends ds{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:If++}),this.uuid=ir(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=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(KA(t)?fh:dh)(t,1):this.index=t,this}setIndirect(t){return this.indirect=t,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,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;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const s=new Nt().getNormalMatrix(t);i.applyNormalMatrix(s),i.needsUpdate=!0}const n=this.attributes.tangent;return n!==void 0&&(n.transformDirection(t),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return $e.makeRotationFromQuaternion(t),this.applyMatrix4($e),this}rotateX(t){return $e.makeRotationX(t),this.applyMatrix4($e),this}rotateY(t){return $e.makeRotationY(t),this.applyMatrix4($e),this}rotateZ(t){return $e.makeRotationZ(t),this.applyMatrix4($e),this}translate(t,e,i){return $e.makeTranslation(t,e,i),this.applyMatrix4($e),this}scale(t,e,i){return $e.makeScale(t,e,i),this.applyMatrix4($e),this}lookAt(t){return cl.lookAt(t),cl.updateMatrix(),this.applyMatrix4(cl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ws).negate(),this.translate(ws.x,ws.y,ws.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const i=[];for(let n=0,s=t.length;n<s;n++){const a=t[n];i.push(a.x,a.y,a.z||0)}this.setAttribute("position",new On(i,3))}else{const i=Math.min(t.length,e.count);for(let n=0;n<i;n++){const s=t[n];e.setXYZ(n,s.x,s.y,s.z||0)}t.length>e.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Is);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new F(-1/0,-1/0,-1/0),new F(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let i=0,n=e.length;i<n;i++){const s=e[i];Ze.setFromBufferAttribute(s),this.morphTargetsRelative?(Se.addVectors(this.boundingBox.min,Ze.min),this.boundingBox.expandByPoint(Se),Se.addVectors(this.boundingBox.max,Ze.max),this.boundingBox.expandByPoint(Se)):(this.boundingBox.expandByPoint(Ze.min),this.boundingBox.expandByPoint(Ze.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new qo);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new F,1/0);return}if(t){const i=this.boundingSphere.center;if(Ze.setFromBufferAttribute(t),e)for(let s=0,a=e.length;s<a;s++){const o=e[s];Ar.setFromBufferAttribute(o),this.morphTargetsRelative?(Se.addVectors(Ze.min,Ar.min),Ze.expandByPoint(Se),Se.addVectors(Ze.max,Ar.max),Ze.expandByPoint(Se)):(Ze.expandByPoint(Ar.min),Ze.expandByPoint(Ar.max))}Ze.getCenter(i);let n=0;for(let s=0,a=t.count;s<a;s++)Se.fromBufferAttribute(t,s),n=Math.max(n,i.distanceToSquared(Se));if(e)for(let s=0,a=e.length;s<a;s++){const o=e[s],A=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)Se.fromBufferAttribute(o,l),A&&(ws.fromBufferAttribute(t,l),Se.add(ws)),n=Math.max(n,i.distanceToSquared(Se))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=e.position,n=e.normal,s=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Ei(new Float32Array(4*i.count),4));const a=this.getAttribute("tangent"),o=[],A=[];for(let P=0;P<i.count;P++)o[P]=new F,A[P]=new F;const l=new F,h=new F,c=new F,u=new Jt,d=new Jt,p=new Jt,m=new F,g=new F;function f(P,E,x){l.fromBufferAttribute(i,P),h.fromBufferAttribute(i,E),c.fromBufferAttribute(i,x),u.fromBufferAttribute(s,P),d.fromBufferAttribute(s,E),p.fromBufferAttribute(s,x),h.sub(l),c.sub(l),d.sub(u),p.sub(u);const M=1/(d.x*p.y-p.x*d.y);isFinite(M)&&(m.copy(h).multiplyScalar(p.y).addScaledVector(c,-d.y).multiplyScalar(M),g.copy(c).multiplyScalar(d.x).addScaledVector(h,-p.x).multiplyScalar(M),o[P].add(m),o[E].add(m),o[x].add(m),A[P].add(g),A[E].add(g),A[x].add(g))}let b=this.groups;b.length===0&&(b=[{start:0,count:t.count}]);for(let P=0,E=b.length;P<E;++P){const x=b[P],M=x.start,z=x.count;for(let O=M,U=M+z;O<U;O+=3)f(t.getX(O+0),t.getX(O+1),t.getX(O+2))}const S=new F,v=new F,T=new F,w=new F;function R(P){T.fromBufferAttribute(n,P),w.copy(T);const E=o[P];S.copy(E),S.sub(T.multiplyScalar(T.dot(E))).normalize(),v.crossVectors(w,E);const M=v.dot(A[P])<0?-1:1;a.setXYZW(P,S.x,S.y,S.z,M)}for(let P=0,E=b.length;P<E;++P){const x=b[P],M=x.start,z=x.count;for(let O=M,U=M+z;O<U;O+=3)R(t.getX(O+0)),R(t.getX(O+1)),R(t.getX(O+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new Ei(new Float32Array(e.count*3),3),this.setAttribute("normal",i);else for(let u=0,d=i.count;u<d;u++)i.setXYZ(u,0,0,0);const n=new F,s=new F,a=new F,o=new F,A=new F,l=new F,h=new F,c=new F;if(t)for(let u=0,d=t.count;u<d;u+=3){const p=t.getX(u+0),m=t.getX(u+1),g=t.getX(u+2);n.fromBufferAttribute(e,p),s.fromBufferAttribute(e,m),a.fromBufferAttribute(e,g),h.subVectors(a,s),c.subVectors(n,s),h.cross(c),o.fromBufferAttribute(i,p),A.fromBufferAttribute(i,m),l.fromBufferAttribute(i,g),o.add(h),A.add(h),l.add(h),i.setXYZ(p,o.x,o.y,o.z),i.setXYZ(m,A.x,A.y,A.z),i.setXYZ(g,l.x,l.y,l.z)}else for(let u=0,d=e.count;u<d;u+=3)n.fromBufferAttribute(e,u+0),s.fromBufferAttribute(e,u+1),a.fromBufferAttribute(e,u+2),h.subVectors(a,s),c.subVectors(n,s),h.cross(c),i.setXYZ(u+0,h.x,h.y,h.z),i.setXYZ(u+1,h.x,h.y,h.z),i.setXYZ(u+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++)Se.fromBufferAttribute(t,e),Se.normalize(),t.setXYZ(e,Se.x,Se.y,Se.z)}toNonIndexed(){function t(o,A){const l=o.array,h=o.itemSize,c=o.normalized,u=new l.constructor(A.length*h);let d=0,p=0;for(let m=0,g=A.length;m<g;m++){o.isInterleavedBufferAttribute?d=A[m]*o.data.stride+o.offset:d=A[m]*h;for(let f=0;f<h;f++)u[p++]=l[d++]}return new Ei(u,h,c)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new Bn,i=this.index.array,n=this.attributes;for(const o in n){const A=n[o],l=t(A,i);e.setAttribute(o,l)}const s=this.morphAttributes;for(const o in s){const A=[],l=s[o];for(let h=0,c=l.length;h<c;h++){const u=l[h],d=t(u,i);A.push(d)}e.morphAttributes[o]=A}e.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,A=a.length;o<A;o++){const l=a[o];e.addGroup(l.start,l.count,l.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const A=this.parameters;for(const l in A)A[l]!==void 0&&(t[l]=A[l]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const i=this.attributes;for(const A in i){const l=i[A];t.data.attributes[A]=l.toJSON(t.data)}const n={};let s=!1;for(const A in this.morphAttributes){const l=this.morphAttributes[A],h=[];for(let c=0,u=l.length;c<u;c++){const d=l[c];h.push(d.toJSON(t.data))}h.length>0&&(n[A]=h,s=!0)}s&&(t.data.morphAttributes=n,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(t.data.boundingSphere=o.toJSON()),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;i!==null&&this.setIndex(i.clone());const n=t.attributes;for(const l in n){const h=n[l];this.setAttribute(l,h.clone(e))}const s=t.morphAttributes;for(const l in s){const h=[],c=s[l];for(let u=0,d=c.length;u<d;u++)h.push(c[u].clone(e));this.morphAttributes[l]=h}this.morphTargetsRelative=t.morphTargetsRelative;const a=t.groups;for(let l=0,h=a.length;l<h;l++){const c=a[l];this.addGroup(c.start,c.count,c.materialIndex)}const o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());const A=t.boundingSphere;return A!==null&&(this.boundingSphere=A.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const gh=new de,Un=new Af,ea=new qo,ph=new F,ia=new F,na=new F,sa=new F,ul=new F,ra=new F,mh=new F,aa=new F;class mi extends Ee{constructor(t=new Bn,e=new hl){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,i=Object.keys(e);if(i.length>0){const n=e[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=n.length;s<a;s++){const o=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(t,e){const i=this.geometry,n=i.attributes.position,s=i.morphAttributes.position,a=i.morphTargetsRelative;e.fromBufferAttribute(n,t);const o=this.morphTargetInfluences;if(s&&o){ra.set(0,0,0);for(let A=0,l=s.length;A<l;A++){const h=o[A],c=s[A];h!==0&&(ul.fromBufferAttribute(c,t),a?ra.addScaledVector(ul,h):ra.addScaledVector(ul.sub(e),h))}e.add(ra)}return e}raycast(t,e){const i=this.geometry,n=this.material,s=this.matrixWorld;n!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),ea.copy(i.boundingSphere),ea.applyMatrix4(s),Un.copy(t.ray).recast(t.near),!(ea.containsPoint(Un.origin)===!1&&(Un.intersectSphere(ea,ph)===null||Un.origin.distanceToSquared(ph)>(t.far-t.near)**2))&&(gh.copy(s).invert(),Un.copy(t.ray).applyMatrix4(gh),!(i.boundingBox!==null&&Un.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(t,e,Un)))}_computeIntersections(t,e,i){let n;const s=this.geometry,a=this.material,o=s.index,A=s.attributes.position,l=s.attributes.uv,h=s.attributes.uv1,c=s.attributes.normal,u=s.groups,d=s.drawRange;if(o!==null)if(Array.isArray(a))for(let p=0,m=u.length;p<m;p++){const g=u[p],f=a[g.materialIndex],b=Math.max(g.start,d.start),S=Math.min(o.count,Math.min(g.start+g.count,d.start+d.count));for(let v=b,T=S;v<T;v+=3){const w=o.getX(v),R=o.getX(v+1),P=o.getX(v+2);n=oa(this,f,t,i,l,h,c,w,R,P),n&&(n.faceIndex=Math.floor(v/3),n.face.materialIndex=g.materialIndex,e.push(n))}}else{const p=Math.max(0,d.start),m=Math.min(o.count,d.start+d.count);for(let g=p,f=m;g<f;g+=3){const b=o.getX(g),S=o.getX(g+1),v=o.getX(g+2);n=oa(this,a,t,i,l,h,c,b,S,v),n&&(n.faceIndex=Math.floor(g/3),e.push(n))}}else if(A!==void 0)if(Array.isArray(a))for(let p=0,m=u.length;p<m;p++){const g=u[p],f=a[g.materialIndex],b=Math.max(g.start,d.start),S=Math.min(A.count,Math.min(g.start+g.count,d.start+d.count));for(let v=b,T=S;v<T;v+=3){const w=v,R=v+1,P=v+2;n=oa(this,f,t,i,l,h,c,w,R,P),n&&(n.faceIndex=Math.floor(v/3),n.face.materialIndex=g.materialIndex,e.push(n))}}else{const p=Math.max(0,d.start),m=Math.min(A.count,d.start+d.count);for(let g=p,f=m;g<f;g+=3){const b=g,S=g+1,v=g+2;n=oa(this,a,t,i,l,h,c,b,S,v),n&&(n.faceIndex=Math.floor(g/3),e.push(n))}}}}function Cf(r,t,e,i,n,s,a,o){let A;if(t.side===Ue?A=i.intersectTriangle(a,s,n,!0,o):A=i.intersectTriangle(n,s,a,t.side===ln,o),A===null)return null;aa.copy(o),aa.applyMatrix4(r.matrixWorld);const l=e.ray.origin.distanceTo(aa);return l<e.near||l>e.far?null:{distance:l,point:aa.clone(),object:r}}function oa(r,t,e,i,n,s,a,o,A,l){r.getVertexPosition(o,ia),r.getVertexPosition(A,na),r.getVertexPosition(l,sa);const h=Cf(r,t,e,i,ia,na,sa,mh);if(h){const c=new F;pi.getBarycoord(mh,ia,na,sa,c),n&&(h.uv=pi.getInterpolatedAttribute(n,o,A,l,c,new Jt)),s&&(h.uv1=pi.getInterpolatedAttribute(s,o,A,l,c,new Jt)),a&&(h.normal=pi.getInterpolatedAttribute(a,o,A,l,c,new F),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const u={a:o,b:A,c:l,normal:new F,materialIndex:0};pi.getNormal(ia,na,sa,u.normal),h.face=u,h.barycoord=c}return h}class Ts extends Bn{constructor(t=1,e=1,i=1,n=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:n,heightSegments:s,depthSegments:a};const o=this;n=Math.floor(n),s=Math.floor(s),a=Math.floor(a);const A=[],l=[],h=[],c=[];let u=0,d=0;p("z","y","x",-1,-1,i,e,t,a,s,0),p("z","y","x",1,-1,i,e,-t,a,s,1),p("x","z","y",1,1,t,i,e,n,a,2),p("x","z","y",1,-1,t,i,-e,n,a,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(A),this.setAttribute("position",new On(l,3)),this.setAttribute("normal",new On(h,3)),this.setAttribute("uv",new On(c,2));function p(m,g,f,b,S,v,T,w,R,P,E){const x=v/R,M=T/P,z=v/2,O=T/2,U=w/2,W=R+1,Y=P+1;let $=0,H=0;const rt=new F;for(let At=0;At<Y;At++){const mt=At*M-O;for(let Bt=0;Bt<W;Bt++){const re=Bt*x-z;rt[m]=re*b,rt[g]=mt*S,rt[f]=U,l.push(rt.x,rt.y,rt.z),rt[m]=0,rt[g]=0,rt[f]=w>0?1:-1,h.push(rt.x,rt.y,rt.z),c.push(Bt/R),c.push(1-At/P),$+=1}}for(let At=0;At<P;At++)for(let mt=0;mt<R;mt++){const Bt=u+mt+W*At,re=u+mt+W*(At+1),te=u+(mt+1)+W*(At+1),J=u+(mt+1)+W*At;A.push(Bt,re,J),A.push(re,te,J),H+=6}o.addGroup(d,H,E),d+=H,u+=$}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ts(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function Rs(r){const t={};for(const e in r){t[e]={};for(const i in r[e]){const n=r[e][i];n&&(n.isColor||n.isMatrix3||n.isMatrix4||n.isVector2||n.isVector3||n.isVector4||n.isTexture||n.isQuaternion)?n.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][i]=null):t[e][i]=n.clone():Array.isArray(n)?t[e][i]=n.slice():t[e][i]=n}}return t}function Le(r){const t={};for(let e=0;e<r.length;e++){const i=Rs(r[e]);for(const n in i)t[n]=i[n]}return t}function vf(r){const t=[];for(let e=0;e<r.length;e++)t.push(r[e].clone());return t}function Ih(r){const t=r.getRenderTarget();return t===null?r.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:Xt.workingColorSpace}const xf={clone:Rs,merge:Le};var Ef=`void main() {
125
125
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
126
126
  }`,Sf=`void main() {
127
127
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
@@ -3952,7 +3952,7 @@ void main() {
3952
3952
 
3953
3953
  }
3954
3954
 
3955
- }`;class UI{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){const i=new Ac(t.texture);(t.depthNear!==e.depthNear||t.depthFar!==e.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=i}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,i=new mn({vertexShader:OI,fragmentShader:BI,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new mi(new cr(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class zI extends ds{constructor(t,e){super();const i=this;let n=null,s=1,a=null,o="local-floor",A=1,l=null,h=null,c=null,u=null,d=null,p=null;const m=new UI,g={},f=e.getContextAttributes();let b=null,S=null;const v=[],T=[],w=new Jt;let R=null;const P=new ke;P.viewport=new ce;const E=new ke;E.viewport=new ce;const x=[P,E],M=new kf;let z=null,O=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(J){let ot=v[J];return ot===void 0&&(ot=new dl,v[J]=ot),ot.getTargetRaySpace()},this.getControllerGrip=function(J){let ot=v[J];return ot===void 0&&(ot=new dl,v[J]=ot),ot.getGripSpace()},this.getHand=function(J){let ot=v[J];return ot===void 0&&(ot=new dl,v[J]=ot),ot.getHandSpace()};function U(J){const ot=T.indexOf(J.inputSource);if(ot===-1)return;const nt=v[ot];nt!==void 0&&(nt.update(J.inputSource,J.frame,l||a),nt.dispatchEvent({type:J.type,data:J.inputSource}))}function W(){n.removeEventListener("select",U),n.removeEventListener("selectstart",U),n.removeEventListener("selectend",U),n.removeEventListener("squeeze",U),n.removeEventListener("squeezestart",U),n.removeEventListener("squeezeend",U),n.removeEventListener("end",W),n.removeEventListener("inputsourceschange",Y);for(let J=0;J<v.length;J++){const ot=T[J];ot!==null&&(T[J]=null,v[J].disconnect(ot))}z=null,O=null,m.reset();for(const J in g)delete g[J];t.setRenderTarget(b),d=null,u=null,c=null,n=null,S=null,te.stop(),i.isPresenting=!1,t.setPixelRatio(R),t.setSize(w.width,w.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(J){s=J,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(J){o=J,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(J){l=J},this.getBaseLayer=function(){return u!==null?u:d},this.getBinding=function(){return c},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(J){if(n=J,n!==null){if(b=t.getRenderTarget(),n.addEventListener("select",U),n.addEventListener("selectstart",U),n.addEventListener("selectend",U),n.addEventListener("squeeze",U),n.addEventListener("squeezestart",U),n.addEventListener("squeezeend",U),n.addEventListener("end",W),n.addEventListener("inputsourceschange",Y),f.xrCompatible!==!0&&await e.makeXRCompatible(),R=t.getPixelRatio(),t.getSize(w),typeof XRWebGLBinding<"u"&&(c=new XRWebGLBinding(n,e)),c!==null&&"createProjectionLayer"in XRWebGLBinding.prototype){let nt=null,Mt=null,wt=null;f.depth&&(wt=f.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,nt=f.stencil?er:tr,Mt=f.stencil?$s:Ln);const Lt={colorFormat:e.RGBA8,depthFormat:wt,scaleFactor:s};u=c.createProjectionLayer(Lt),n.updateRenderState({layers:[u]}),t.setPixelRatio(1),t.setSize(u.textureWidth,u.textureHeight,!1),S=new Dn(u.textureWidth,u.textureHeight,{format:ci,type:vi,depthTexture:new bh(u.textureWidth,u.textureHeight,Mt,void 0,void 0,void 0,void 0,void 0,void 0,nt),stencilBuffer:f.stencil,colorSpace:t.outputColorSpace,samples:f.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1})}else{const nt={antialias:f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(n,e,nt),n.updateRenderState({baseLayer:d}),t.setPixelRatio(1),t.setSize(d.framebufferWidth,d.framebufferHeight,!1),S=new Dn(d.framebufferWidth,d.framebufferHeight,{format:ci,type:vi,colorSpace:t.outputColorSpace,stencilBuffer:f.stencil,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}S.isXRRenderTarget=!0,this.setFoveation(A),l=null,a=await n.requestReferenceSpace(o),te.setContext(n),te.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(n!==null)return n.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function Y(J){for(let ot=0;ot<J.removed.length;ot++){const nt=J.removed[ot],Mt=T.indexOf(nt);Mt>=0&&(T[Mt]=null,v[Mt].disconnect(nt))}for(let ot=0;ot<J.added.length;ot++){const nt=J.added[ot];let Mt=T.indexOf(nt);if(Mt===-1){for(let Lt=0;Lt<v.length;Lt++)if(Lt>=T.length){T.push(nt),Mt=Lt;break}else if(T[Lt]===null){T[Lt]=nt,Mt=Lt;break}if(Mt===-1)break}const wt=v[Mt];wt&&wt.connect(nt)}}const $=new F,H=new F;function rt(J,ot,nt){$.setFromMatrixPosition(ot.matrixWorld),H.setFromMatrixPosition(nt.matrixWorld);const Mt=$.distanceTo(H),wt=ot.projectionMatrix.elements,Lt=nt.projectionMatrix.elements,fe=wt[14]/(wt[10]-1),Wt=wt[14]/(wt[10]+1),_=(wt[9]+1)/wt[5],ie=(wt[9]-1)/wt[5],yt=(wt[8]-1)/wt[0],jt=(Lt[8]+1)/Lt[0],Et=fe*yt,ae=fe*jt,ft=Mt/(-yt+jt),Ut=ft*-yt;if(ot.matrixWorld.decompose(J.position,J.quaternion,J.scale),J.translateX(Ut),J.translateZ(ft),J.matrixWorld.compose(J.position,J.quaternion,J.scale),J.matrixWorldInverse.copy(J.matrixWorld).invert(),wt[10]===-1)J.projectionMatrix.copy(ot.projectionMatrix),J.projectionMatrixInverse.copy(ot.projectionMatrixInverse);else{const ye=fe+ft,ge=Wt+ft,y=Et-Ut,I=ae+(Mt-Ut),B=_*Wt/ge*ye,Z=ie*Wt/ge*ye;J.projectionMatrix.makePerspective(y,I,B,Z,ye,ge),J.projectionMatrixInverse.copy(J.projectionMatrix).invert()}}function At(J,ot){ot===null?J.matrixWorld.copy(J.matrix):J.matrixWorld.multiplyMatrices(ot.matrixWorld,J.matrix),J.matrixWorldInverse.copy(J.matrixWorld).invert()}this.updateCamera=function(J){if(n===null)return;let ot=J.near,nt=J.far;m.texture!==null&&(m.depthNear>0&&(ot=m.depthNear),m.depthFar>0&&(nt=m.depthFar)),M.near=E.near=P.near=ot,M.far=E.far=P.far=nt,(z!==M.near||O!==M.far)&&(n.updateRenderState({depthNear:M.near,depthFar:M.far}),z=M.near,O=M.far),M.layers.mask=J.layers.mask|6,P.layers.mask=M.layers.mask&3,E.layers.mask=M.layers.mask&5;const Mt=J.parent,wt=M.cameras;At(M,Mt);for(let Lt=0;Lt<wt.length;Lt++)At(wt[Lt],Mt);wt.length===2?rt(M,P,E):M.projectionMatrix.copy(P.projectionMatrix),mt(J,M,Mt)};function mt(J,ot,nt){nt===null?J.matrix.copy(ot.matrixWorld):(J.matrix.copy(nt.matrixWorld),J.matrix.invert(),J.matrix.multiply(ot.matrixWorld)),J.matrix.decompose(J.position,J.quaternion,J.scale),J.updateMatrixWorld(!0),J.projectionMatrix.copy(ot.projectionMatrix),J.projectionMatrixInverse.copy(ot.projectionMatrixInverse),J.isPerspectiveCamera&&(J.fov=Yr*2*Math.atan(1/J.projectionMatrix.elements[5]),J.zoom=1)}this.getCamera=function(){return M},this.getFoveation=function(){if(!(u===null&&d===null))return A},this.setFoveation=function(J){A=J,u!==null&&(u.fixedFoveation=J),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=J)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(M)},this.getCameraTexture=function(J){return g[J]};let Bt=null;function re(J,ot){if(h=ot.getViewerPose(l||a),p=ot,h!==null){const nt=h.views;d!==null&&(t.setRenderTargetFramebuffer(S,d.framebuffer),t.setRenderTarget(S));let Mt=!1;nt.length!==M.cameras.length&&(M.cameras.length=0,Mt=!0);for(let Wt=0;Wt<nt.length;Wt++){const _=nt[Wt];let ie=null;if(d!==null)ie=d.getViewport(_);else{const jt=c.getViewSubImage(u,_);ie=jt.viewport,Wt===0&&(t.setRenderTargetTextures(S,jt.colorTexture,jt.depthStencilTexture),t.setRenderTarget(S))}let yt=x[Wt];yt===void 0&&(yt=new ke,yt.layers.enable(Wt),yt.viewport=new ce,x[Wt]=yt),yt.matrix.fromArray(_.transform.matrix),yt.matrix.decompose(yt.position,yt.quaternion,yt.scale),yt.projectionMatrix.fromArray(_.projectionMatrix),yt.projectionMatrixInverse.copy(yt.projectionMatrix).invert(),yt.viewport.set(ie.x,ie.y,ie.width,ie.height),Wt===0&&(M.matrix.copy(yt.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),Mt===!0&&M.cameras.push(yt)}const wt=n.enabledFeatures;if(wt&&wt.includes("depth-sensing")&&n.depthUsage=="gpu-optimized"&&c){const Wt=c.getDepthInformation(nt[0]);Wt&&Wt.isValid&&Wt.texture&&m.init(Wt,n.renderState)}if(wt&&wt.includes("camera-access")&&(t.state.unbindTexture(),c))for(let Wt=0;Wt<nt.length;Wt++){const _=nt[Wt].camera;if(_){let ie=g[_];ie||(ie=new Ac,g[_]=ie);const yt=c.getCameraImage(_);ie.sourceTexture=yt}}}for(let nt=0;nt<v.length;nt++){const Mt=T[nt],wt=v[nt];Mt!==null&&wt!==void 0&&wt.update(Mt,ot,l||a)}Bt&&Bt(J,ot),ot.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:ot}),p=null}const te=new Nh;te.setAnimationLoop(re),this.setAnimationLoop=function(J){Bt=J},this.dispose=function(){}}}const Wn=new fi,kI=new de;function GI(r,t){function e(g,f){g.matrixAutoUpdate===!0&&g.updateMatrix(),f.value.copy(g.matrix)}function i(g,f){f.color.getRGB(g.fogColor.value,Ih(r)),f.isFog?(g.fogNear.value=f.near,g.fogFar.value=f.far):f.isFogExp2&&(g.fogDensity.value=f.density)}function n(g,f,b,S,v){f.isMeshBasicMaterial||f.isMeshLambertMaterial?s(g,f):f.isMeshToonMaterial?(s(g,f),c(g,f)):f.isMeshPhongMaterial?(s(g,f),h(g,f)):f.isMeshStandardMaterial?(s(g,f),u(g,f),f.isMeshPhysicalMaterial&&d(g,f,v)):f.isMeshMatcapMaterial?(s(g,f),p(g,f)):f.isMeshDepthMaterial?s(g,f):f.isMeshDistanceMaterial?(s(g,f),m(g,f)):f.isMeshNormalMaterial?s(g,f):f.isLineBasicMaterial?(a(g,f),f.isLineDashedMaterial&&o(g,f)):f.isPointsMaterial?A(g,f,b,S):f.isSpriteMaterial?l(g,f):f.isShadowMaterial?(g.color.value.copy(f.color),g.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function s(g,f){g.opacity.value=f.opacity,f.color&&g.diffuse.value.copy(f.color),f.emissive&&g.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(g.map.value=f.map,e(f.map,g.mapTransform)),f.alphaMap&&(g.alphaMap.value=f.alphaMap,e(f.alphaMap,g.alphaMapTransform)),f.bumpMap&&(g.bumpMap.value=f.bumpMap,e(f.bumpMap,g.bumpMapTransform),g.bumpScale.value=f.bumpScale,f.side===Ue&&(g.bumpScale.value*=-1)),f.normalMap&&(g.normalMap.value=f.normalMap,e(f.normalMap,g.normalMapTransform),g.normalScale.value.copy(f.normalScale),f.side===Ue&&g.normalScale.value.negate()),f.displacementMap&&(g.displacementMap.value=f.displacementMap,e(f.displacementMap,g.displacementMapTransform),g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias),f.emissiveMap&&(g.emissiveMap.value=f.emissiveMap,e(f.emissiveMap,g.emissiveMapTransform)),f.specularMap&&(g.specularMap.value=f.specularMap,e(f.specularMap,g.specularMapTransform)),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest);const b=t.get(f),S=b.envMap,v=b.envMapRotation;S&&(g.envMap.value=S,Wn.copy(v),Wn.x*=-1,Wn.y*=-1,Wn.z*=-1,S.isCubeTexture&&S.isRenderTargetTexture===!1&&(Wn.y*=-1,Wn.z*=-1),g.envMapRotation.value.setFromMatrix4(kI.makeRotationFromEuler(Wn)),g.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=f.reflectivity,g.ior.value=f.ior,g.refractionRatio.value=f.refractionRatio),f.lightMap&&(g.lightMap.value=f.lightMap,g.lightMapIntensity.value=f.lightMapIntensity,e(f.lightMap,g.lightMapTransform)),f.aoMap&&(g.aoMap.value=f.aoMap,g.aoMapIntensity.value=f.aoMapIntensity,e(f.aoMap,g.aoMapTransform))}function a(g,f){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,f.map&&(g.map.value=f.map,e(f.map,g.mapTransform))}function o(g,f){g.dashSize.value=f.dashSize,g.totalSize.value=f.dashSize+f.gapSize,g.scale.value=f.scale}function A(g,f,b,S){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,g.size.value=f.size*b,g.scale.value=S*.5,f.map&&(g.map.value=f.map,e(f.map,g.uvTransform)),f.alphaMap&&(g.alphaMap.value=f.alphaMap,e(f.alphaMap,g.alphaMapTransform)),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest)}function l(g,f){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,g.rotation.value=f.rotation,f.map&&(g.map.value=f.map,e(f.map,g.mapTransform)),f.alphaMap&&(g.alphaMap.value=f.alphaMap,e(f.alphaMap,g.alphaMapTransform)),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest)}function h(g,f){g.specular.value.copy(f.specular),g.shininess.value=Math.max(f.shininess,1e-4)}function c(g,f){f.gradientMap&&(g.gradientMap.value=f.gradientMap)}function u(g,f){g.metalness.value=f.metalness,f.metalnessMap&&(g.metalnessMap.value=f.metalnessMap,e(f.metalnessMap,g.metalnessMapTransform)),g.roughness.value=f.roughness,f.roughnessMap&&(g.roughnessMap.value=f.roughnessMap,e(f.roughnessMap,g.roughnessMapTransform)),f.envMap&&(g.envMapIntensity.value=f.envMapIntensity)}function d(g,f,b){g.ior.value=f.ior,f.sheen>0&&(g.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),g.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(g.sheenColorMap.value=f.sheenColorMap,e(f.sheenColorMap,g.sheenColorMapTransform)),f.sheenRoughnessMap&&(g.sheenRoughnessMap.value=f.sheenRoughnessMap,e(f.sheenRoughnessMap,g.sheenRoughnessMapTransform))),f.clearcoat>0&&(g.clearcoat.value=f.clearcoat,g.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(g.clearcoatMap.value=f.clearcoatMap,e(f.clearcoatMap,g.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,e(f.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(g.clearcoatNormalMap.value=f.clearcoatNormalMap,e(f.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===Ue&&g.clearcoatNormalScale.value.negate())),f.dispersion>0&&(g.dispersion.value=f.dispersion),f.iridescence>0&&(g.iridescence.value=f.iridescence,g.iridescenceIOR.value=f.iridescenceIOR,g.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(g.iridescenceMap.value=f.iridescenceMap,e(f.iridescenceMap,g.iridescenceMapTransform)),f.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=f.iridescenceThicknessMap,e(f.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),f.transmission>0&&(g.transmission.value=f.transmission,g.transmissionSamplerMap.value=b.texture,g.transmissionSamplerSize.value.set(b.width,b.height),f.transmissionMap&&(g.transmissionMap.value=f.transmissionMap,e(f.transmissionMap,g.transmissionMapTransform)),g.thickness.value=f.thickness,f.thicknessMap&&(g.thicknessMap.value=f.thicknessMap,e(f.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=f.attenuationDistance,g.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(g.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(g.anisotropyMap.value=f.anisotropyMap,e(f.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=f.specularIntensity,g.specularColor.value.copy(f.specularColor),f.specularColorMap&&(g.specularColorMap.value=f.specularColorMap,e(f.specularColorMap,g.specularColorMapTransform)),f.specularIntensityMap&&(g.specularIntensityMap.value=f.specularIntensityMap,e(f.specularIntensityMap,g.specularIntensityMapTransform))}function p(g,f){f.matcap&&(g.matcap.value=f.matcap)}function m(g,f){const b=t.get(f).light;g.referencePosition.value.setFromMatrixPosition(b.matrixWorld),g.nearDistance.value=b.shadow.camera.near,g.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:n}}function HI(r,t,e,i){let n={},s={},a=[];const o=r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS);function A(b,S){const v=S.program;i.uniformBlockBinding(b,v)}function l(b,S){let v=n[b.id];v===void 0&&(p(b),v=h(b),n[b.id]=v,b.addEventListener("dispose",g));const T=S.program;i.updateUBOMapping(b,T);const w=t.render.frame;s[b.id]!==w&&(u(b),s[b.id]=w)}function h(b){const S=c();b.__bindingPointIndex=S;const v=r.createBuffer(),T=b.__size,w=b.usage;return r.bindBuffer(r.UNIFORM_BUFFER,v),r.bufferData(r.UNIFORM_BUFFER,T,w),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,S,v),v}function c(){for(let b=0;b<o;b++)if(a.indexOf(b)===-1)return a.push(b),b;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(b){const S=n[b.id],v=b.uniforms,T=b.__cache;r.bindBuffer(r.UNIFORM_BUFFER,S);for(let w=0,R=v.length;w<R;w++){const P=Array.isArray(v[w])?v[w]:[v[w]];for(let E=0,x=P.length;E<x;E++){const M=P[E];if(d(M,w,E,T)===!0){const z=M.__offset,O=Array.isArray(M.value)?M.value:[M.value];let U=0;for(let W=0;W<O.length;W++){const Y=O[W],$=m(Y);typeof Y=="number"||typeof Y=="boolean"?(M.__data[0]=Y,r.bufferSubData(r.UNIFORM_BUFFER,z+U,M.__data)):Y.isMatrix3?(M.__data[0]=Y.elements[0],M.__data[1]=Y.elements[1],M.__data[2]=Y.elements[2],M.__data[3]=0,M.__data[4]=Y.elements[3],M.__data[5]=Y.elements[4],M.__data[6]=Y.elements[5],M.__data[7]=0,M.__data[8]=Y.elements[6],M.__data[9]=Y.elements[7],M.__data[10]=Y.elements[8],M.__data[11]=0):(Y.toArray(M.__data,U),U+=$.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(r.UNIFORM_BUFFER,z,M.__data)}}}r.bindBuffer(r.UNIFORM_BUFFER,null)}function d(b,S,v,T){const w=b.value,R=S+"_"+v;if(T[R]===void 0)return typeof w=="number"||typeof w=="boolean"?T[R]=w:T[R]=w.clone(),!0;{const P=T[R];if(typeof w=="number"||typeof w=="boolean"){if(P!==w)return T[R]=w,!0}else if(P.equals(w)===!1)return P.copy(w),!0}return!1}function p(b){const S=b.uniforms;let v=0;const T=16;for(let R=0,P=S.length;R<P;R++){const E=Array.isArray(S[R])?S[R]:[S[R]];for(let x=0,M=E.length;x<M;x++){const z=E[x],O=Array.isArray(z.value)?z.value:[z.value];for(let U=0,W=O.length;U<W;U++){const Y=O[U],$=m(Y),H=v%T,rt=H%$.boundary,At=H+rt;v+=rt,At!==0&&T-At<$.storage&&(v+=T-At),z.__data=new Float32Array($.storage/Float32Array.BYTES_PER_ELEMENT),z.__offset=v,v+=$.storage}}}const w=v%T;return w>0&&(v+=T-w),b.__size=v,b.__cache={},this}function m(b){const S={boundary:0,storage:0};return typeof b=="number"||typeof b=="boolean"?(S.boundary=4,S.storage=4):b.isVector2?(S.boundary=8,S.storage=8):b.isVector3||b.isColor?(S.boundary=16,S.storage=12):b.isVector4?(S.boundary=16,S.storage=16):b.isMatrix3?(S.boundary=48,S.storage=48):b.isMatrix4?(S.boundary=64,S.storage=64):b.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",b),S}function g(b){const S=b.target;S.removeEventListener("dispose",g);const v=a.indexOf(S.__bindingPointIndex);a.splice(v,1),r.deleteBuffer(n[S.id]),delete n[S.id],delete s[S.id]}function f(){for(const b in n)r.deleteBuffer(n[b]);a=[],n={},s={}}return{bind:A,update:l,dispose:f}}class hc{constructor(t={}){const{canvas:e=$d(),context:i=null,depth:n=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:A=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:c=!1,reversedDepthBuffer:u=!1}=t;this.isWebGLRenderer=!0;let d;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=i.getContextAttributes().alpha}else d=a;const p=new Uint32Array(4),m=new Int32Array(4);let g=null,f=null;const b=[],S=[];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.toneMapping=hn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const v=this;let T=!1;this._outputColorSpace=Pe;let w=0,R=0,P=null,E=-1,x=null;const M=new ce,z=new ce;let O=null;const U=new Vt(0);let W=0,Y=e.width,$=e.height,H=1,rt=null,At=null;const mt=new ce(0,0,Y,$),Bt=new ce(0,0,Y,$);let re=!1;const te=new pl;let J=!1,ot=!1;const nt=new de,Mt=new F,wt=new ce,Lt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let fe=!1;function Wt(){return P===null?H:1}let _=i;function ie(C,D){return e.getContext(C,D)}try{const C={alpha:!0,depth:n,stencil:s,antialias:o,premultipliedAlpha:A,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:c};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${Ja}`),e.addEventListener("webglcontextlost",st,!1),e.addEventListener("webglcontextrestored",dt,!1),e.addEventListener("webglcontextcreationerror",q,!1),_===null){const D="webgl2";if(_=ie(D,C),_===null)throw ie(D)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(C){throw console.error("THREE.WebGLRenderer: "+C.message),C}let yt,jt,Et,ae,ft,Ut,ye,ge,y,I,B,Z,Q,X,xt,it,It,Ct,tt,ct,Rt,vt,lt,Ft;function L(){yt=new $p(_),yt.init(),vt=new FI(_,yt),jt=new Xp(_,yt,t,vt),Et=new DI(_,yt),jt.reversedDepthBuffer&&u&&Et.buffers.depth.setReversed(!0),ae=new im(_),ft=new vI,Ut=new NI(_,yt,Et,ft,jt,vt,ae),ye=new Jp(v),ge=new Kp(v),y=new Hf(_),lt=new Wp(_,y),I=new tm(_,y,ae,lt),B=new sm(_,I,y,ae),tt=new nm(_,jt,Ut),it=new Zp(ft),Z=new CI(v,ye,ge,yt,jt,lt,it),Q=new GI(v,ft),X=new EI,xt=new TI(yt),Ct=new Vp(v,ye,ge,Et,B,d,A),It=new PI(v,B,jt),Ft=new HI(_,ae,jt,Et),ct=new Yp(_,yt,ae),Rt=new em(_,yt,ae),ae.programs=Z.programs,v.capabilities=jt,v.extensions=yt,v.properties=ft,v.renderLists=X,v.shadowMap=It,v.state=Et,v.info=ae}L();const et=new zI(v,_);this.xr=et,this.getContext=function(){return _},this.getContextAttributes=function(){return _.getContextAttributes()},this.forceContextLoss=function(){const C=yt.get("WEBGL_lose_context");C&&C.loseContext()},this.forceContextRestore=function(){const C=yt.get("WEBGL_lose_context");C&&C.restoreContext()},this.getPixelRatio=function(){return H},this.setPixelRatio=function(C){C!==void 0&&(H=C,this.setSize(Y,$,!1))},this.getSize=function(C){return C.set(Y,$)},this.setSize=function(C,D,k=!0){if(et.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}Y=C,$=D,e.width=Math.floor(C*H),e.height=Math.floor(D*H),k===!0&&(e.style.width=C+"px",e.style.height=D+"px"),this.setViewport(0,0,C,D)},this.getDrawingBufferSize=function(C){return C.set(Y*H,$*H).floor()},this.setDrawingBufferSize=function(C,D,k){Y=C,$=D,H=k,e.width=Math.floor(C*k),e.height=Math.floor(D*k),this.setViewport(0,0,C,D)},this.getCurrentViewport=function(C){return C.copy(M)},this.getViewport=function(C){return C.copy(mt)},this.setViewport=function(C,D,k,G){C.isVector4?mt.set(C.x,C.y,C.z,C.w):mt.set(C,D,k,G),Et.viewport(M.copy(mt).multiplyScalar(H).round())},this.getScissor=function(C){return C.copy(Bt)},this.setScissor=function(C,D,k,G){C.isVector4?Bt.set(C.x,C.y,C.z,C.w):Bt.set(C,D,k,G),Et.scissor(z.copy(Bt).multiplyScalar(H).round())},this.getScissorTest=function(){return re},this.setScissorTest=function(C){Et.setScissorTest(re=C)},this.setOpaqueSort=function(C){rt=C},this.setTransparentSort=function(C){At=C},this.getClearColor=function(C){return C.copy(Ct.getClearColor())},this.setClearColor=function(){Ct.setClearColor(...arguments)},this.getClearAlpha=function(){return Ct.getClearAlpha()},this.setClearAlpha=function(){Ct.setClearAlpha(...arguments)},this.clear=function(C=!0,D=!0,k=!0){let G=0;if(C){let N=!1;if(P!==null){const K=P.texture.format;N=K===go||K===fo||K===uo}if(N){const K=P.texture.type,ht=K===vi||K===Ln||K===qs||K===$s||K===ho||K===co,gt=Ct.getClearColor(),ut=Ct.getClearAlpha(),Tt=gt.r,Pt=gt.g,St=gt.b;ht?(p[0]=Tt,p[1]=Pt,p[2]=St,p[3]=ut,_.clearBufferuiv(_.COLOR,0,p)):(m[0]=Tt,m[1]=Pt,m[2]=St,m[3]=ut,_.clearBufferiv(_.COLOR,0,m))}else G|=_.COLOR_BUFFER_BIT}D&&(G|=_.DEPTH_BUFFER_BIT),k&&(G|=_.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),_.clear(G)},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",st,!1),e.removeEventListener("webglcontextrestored",dt,!1),e.removeEventListener("webglcontextcreationerror",q,!1),Ct.dispose(),X.dispose(),xt.dispose(),ft.dispose(),ye.dispose(),ge.dispose(),B.dispose(),lt.dispose(),Ft.dispose(),Z.dispose(),et.dispose(),et.removeEventListener("sessionstart",yi),et.removeEventListener("sessionend",gc),Yn.stop()};function st(C){C.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),T=!0}function dt(){console.log("THREE.WebGLRenderer: Context Restored."),T=!1;const C=ae.autoReset,D=It.enabled,k=It.autoUpdate,G=It.needsUpdate,N=It.type;L(),ae.autoReset=C,It.enabled=D,It.autoUpdate=k,It.needsUpdate=G,It.type=N}function q(C){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",C.statusMessage)}function j(C){const D=C.target;D.removeEventListener("dispose",j),pt(D)}function pt(C){Dt(C),ft.remove(C)}function Dt(C){const D=ft.get(C).programs;D!==void 0&&(D.forEach(function(k){Z.releaseProgram(k)}),C.isShaderMaterial&&Z.releaseShaderCache(C))}this.renderBufferDirect=function(C,D,k,G,N,K){D===null&&(D=Lt);const ht=N.isMesh&&N.matrixWorld.determinant()<0,gt=KI(C,D,k,G,N);Et.setMaterial(G,ht);let ut=k.index,Tt=1;if(G.wireframe===!0){if(ut=I.getWireframeAttribute(k),ut===void 0)return;Tt=2}const Pt=k.drawRange,St=k.attributes.position;let zt=Pt.start*Tt,$t=(Pt.start+Pt.count)*Tt;K!==null&&(zt=Math.max(zt,K.start*Tt),$t=Math.min($t,(K.start+K.count)*Tt)),ut!==null?(zt=Math.max(zt,0),$t=Math.min($t,ut.count)):St!=null&&(zt=Math.max(zt,0),$t=Math.min($t,St.count));const ue=$t-zt;if(ue<0||ue===1/0)return;lt.setup(N,G,gt,k,ut);let se,ee=ct;if(ut!==null&&(se=y.get(ut),ee=Rt,ee.setIndex(se)),N.isMesh)G.wireframe===!0?(Et.setLineWidth(G.wireframeLinewidth*Wt()),ee.setMode(_.LINES)):ee.setMode(_.TRIANGLES);else if(N.isLine){let bt=G.linewidth;bt===void 0&&(bt=1),Et.setLineWidth(bt*Wt()),N.isLineSegments?ee.setMode(_.LINES):N.isLineLoop?ee.setMode(_.LINE_LOOP):ee.setMode(_.LINE_STRIP)}else N.isPoints?ee.setMode(_.POINTS):N.isSprite&&ee.setMode(_.TRIANGLES);if(N.isBatchedMesh)if(N._multiDrawInstances!==null)gs("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),ee.renderMultiDrawInstances(N._multiDrawStarts,N._multiDrawCounts,N._multiDrawCount,N._multiDrawInstances);else if(yt.get("WEBGL_multi_draw"))ee.renderMultiDraw(N._multiDrawStarts,N._multiDrawCounts,N._multiDrawCount);else{const bt=N._multiDrawStarts,oe=N._multiDrawCounts,Zt=N._multiDrawCount,Je=ut?y.get(ut).bytesPerElement:1,Bs=ft.get(G).currentProgram.getUniforms();for(let je=0;je<Zt;je++)Bs.setValue(_,"_gl_DrawID",je),ee.render(bt[je]/Je,oe[je])}else if(N.isInstancedMesh)ee.renderInstances(zt,ue,N.count);else if(k.isInstancedBufferGeometry){const bt=k._maxInstanceCount!==void 0?k._maxInstanceCount:1/0,oe=Math.min(k.instanceCount,bt);ee.renderInstances(zt,ue,oe)}else ee.render(zt,ue)};function ne(C,D,k){C.transparent===!0&&C.side===Hi&&C.forceSinglePass===!1?(C.side=Ue,C.needsUpdate=!0,Ia(C,D,k),C.side=ln,C.needsUpdate=!0,Ia(C,D,k),C.side=Hi):Ia(C,D,k)}this.compile=function(C,D,k=null){k===null&&(k=C),f=xt.get(k),f.init(D),S.push(f),k.traverseVisible(function(N){N.isLight&&N.layers.test(D.layers)&&(f.pushLight(N),N.castShadow&&f.pushShadow(N))}),C!==k&&C.traverseVisible(function(N){N.isLight&&N.layers.test(D.layers)&&(f.pushLight(N),N.castShadow&&f.pushShadow(N))}),f.setupLights();const G=new Set;return C.traverse(function(N){if(!(N.isMesh||N.isPoints||N.isLine||N.isSprite))return;const K=N.material;if(K)if(Array.isArray(K))for(let ht=0;ht<K.length;ht++){const gt=K[ht];ne(gt,k,N),G.add(gt)}else ne(K,k,N),G.add(K)}),f=S.pop(),G},this.compileAsync=function(C,D,k=null){const G=this.compile(C,D,k);return new Promise(N=>{function K(){if(G.forEach(function(ht){ft.get(ht).currentProgram.isReady()&&G.delete(ht)}),G.size===0){N(C);return}setTimeout(K,10)}yt.get("KHR_parallel_shader_compile")!==null?K():setTimeout(K,10)})};let qt=null;function Qi(C){qt&&qt(C)}function yi(){Yn.stop()}function gc(){Yn.start()}const Yn=new Nh;Yn.setAnimationLoop(Qi),typeof self<"u"&&Yn.setContext(self),this.setAnimationLoop=function(C){qt=C,et.setAnimationLoop(C),C===null?Yn.stop():Yn.start()},et.addEventListener("sessionstart",yi),et.addEventListener("sessionend",gc),this.render=function(C,D){if(D!==void 0&&D.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(T===!0)return;if(C.matrixWorldAutoUpdate===!0&&C.updateMatrixWorld(),D.parent===null&&D.matrixWorldAutoUpdate===!0&&D.updateMatrixWorld(),et.enabled===!0&&et.isPresenting===!0&&(et.cameraAutoUpdate===!0&&et.updateCamera(D),D=et.getCamera()),C.isScene===!0&&C.onBeforeRender(v,C,D,P),f=xt.get(C,S.length),f.init(D),S.push(f),nt.multiplyMatrices(D.projectionMatrix,D.matrixWorldInverse),te.setFromProjectionMatrix(nt,xi,D.reversedDepth),ot=this.localClippingEnabled,J=it.init(this.clippingPlanes,ot),g=X.get(C,b.length),g.init(),b.push(g),et.enabled===!0&&et.isPresenting===!0){const K=v.xr.getDepthSensingMesh();K!==null&&Ll(K,D,-1/0,v.sortObjects)}Ll(C,D,0,v.sortObjects),g.finish(),v.sortObjects===!0&&g.sort(rt,At),fe=et.enabled===!1||et.isPresenting===!1||et.hasDepthSensing()===!1,fe&&Ct.addToRenderList(g,C),this.info.render.frame++,J===!0&&it.beginShadows();const k=f.state.shadowsArray;It.render(k,C,D),J===!0&&it.endShadows(),this.info.autoReset===!0&&this.info.reset();const G=g.opaque,N=g.transmissive;if(f.setupLights(),D.isArrayCamera){const K=D.cameras;if(N.length>0)for(let ht=0,gt=K.length;ht<gt;ht++){const ut=K[ht];mc(G,N,C,ut)}fe&&Ct.render(C);for(let ht=0,gt=K.length;ht<gt;ht++){const ut=K[ht];pc(g,C,ut,ut.viewport)}}else N.length>0&&mc(G,N,C,D),fe&&Ct.render(C),pc(g,C,D);P!==null&&R===0&&(Ut.updateMultisampleRenderTarget(P),Ut.updateRenderTargetMipmap(P)),C.isScene===!0&&C.onAfterRender(v,C,D),lt.resetDefaultState(),E=-1,x=null,S.pop(),S.length>0?(f=S[S.length-1],J===!0&&it.setGlobalState(v.clippingPlanes,f.state.camera)):f=null,b.pop(),b.length>0?g=b[b.length-1]:g=null};function Ll(C,D,k,G){if(C.visible===!1)return;if(C.layers.test(D.layers)){if(C.isGroup)k=C.renderOrder;else if(C.isLOD)C.autoUpdate===!0&&C.update(D);else if(C.isLight)f.pushLight(C),C.castShadow&&f.pushShadow(C);else if(C.isSprite){if(!C.frustumCulled||te.intersectsSprite(C)){G&&wt.setFromMatrixPosition(C.matrixWorld).applyMatrix4(nt);const ht=B.update(C),gt=C.material;gt.visible&&g.push(C,ht,gt,k,wt.z,null)}}else if((C.isMesh||C.isLine||C.isPoints)&&(!C.frustumCulled||te.intersectsObject(C))){const ht=B.update(C),gt=C.material;if(G&&(C.boundingSphere!==void 0?(C.boundingSphere===null&&C.computeBoundingSphere(),wt.copy(C.boundingSphere.center)):(ht.boundingSphere===null&&ht.computeBoundingSphere(),wt.copy(ht.boundingSphere.center)),wt.applyMatrix4(C.matrixWorld).applyMatrix4(nt)),Array.isArray(gt)){const ut=ht.groups;for(let Tt=0,Pt=ut.length;Tt<Pt;Tt++){const St=ut[Tt],zt=gt[St.materialIndex];zt&&zt.visible&&g.push(C,ht,zt,k,wt.z,St)}}else gt.visible&&g.push(C,ht,gt,k,wt.z,null)}}const K=C.children;for(let ht=0,gt=K.length;ht<gt;ht++)Ll(K[ht],D,k,G)}function pc(C,D,k,G){const N=C.opaque,K=C.transmissive,ht=C.transparent;f.setupLightsView(k),J===!0&&it.setGlobalState(v.clippingPlanes,k),G&&Et.viewport(M.copy(G)),N.length>0&&ma(N,D,k),K.length>0&&ma(K,D,k),ht.length>0&&ma(ht,D,k),Et.buffers.depth.setTest(!0),Et.buffers.depth.setMask(!0),Et.buffers.color.setMask(!0),Et.setPolygonOffset(!1)}function mc(C,D,k,G){if((k.isScene===!0?k.overrideMaterial:null)!==null)return;f.state.transmissionRenderTarget[G.id]===void 0&&(f.state.transmissionRenderTarget[G.id]=new Dn(1,1,{generateMipmaps:!0,type:yt.has("EXT_color_buffer_half_float")||yt.has("EXT_color_buffer_float")?Ks:vi,minFilter:Pn,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Xt.workingColorSpace}));const K=f.state.transmissionRenderTarget[G.id],ht=G.viewport||M;K.setSize(ht.z*v.transmissionResolutionScale,ht.w*v.transmissionResolutionScale);const gt=v.getRenderTarget(),ut=v.getActiveCubeFace(),Tt=v.getActiveMipmapLevel();v.setRenderTarget(K),v.getClearColor(U),W=v.getClearAlpha(),W<1&&v.setClearColor(16777215,.5),v.clear(),fe&&Ct.render(k);const Pt=v.toneMapping;v.toneMapping=hn;const St=G.viewport;if(G.viewport!==void 0&&(G.viewport=void 0),f.setupLightsView(G),J===!0&&it.setGlobalState(v.clippingPlanes,G),ma(C,k,G),Ut.updateMultisampleRenderTarget(K),Ut.updateRenderTargetMipmap(K),yt.has("WEBGL_multisampled_render_to_texture")===!1){let zt=!1;for(let $t=0,ue=D.length;$t<ue;$t++){const se=D[$t],ee=se.object,bt=se.geometry,oe=se.material,Zt=se.group;if(oe.side===Hi&&ee.layers.test(G.layers)){const Je=oe.side;oe.side=Ue,oe.needsUpdate=!0,Ic(ee,k,G,bt,oe,Zt),oe.side=Je,oe.needsUpdate=!0,zt=!0}}zt===!0&&(Ut.updateMultisampleRenderTarget(K),Ut.updateRenderTargetMipmap(K))}v.setRenderTarget(gt,ut,Tt),v.setClearColor(U,W),St!==void 0&&(G.viewport=St),v.toneMapping=Pt}function ma(C,D,k){const G=D.isScene===!0?D.overrideMaterial:null;for(let N=0,K=C.length;N<K;N++){const ht=C[N],gt=ht.object,ut=ht.geometry,Tt=ht.group;let Pt=ht.material;Pt.allowOverride===!0&&G!==null&&(Pt=G),gt.layers.test(k.layers)&&Ic(gt,D,k,ut,Pt,Tt)}}function Ic(C,D,k,G,N,K){C.onBeforeRender(v,D,k,G,N,K),C.modelViewMatrix.multiplyMatrices(k.matrixWorldInverse,C.matrixWorld),C.normalMatrix.getNormalMatrix(C.modelViewMatrix),N.onBeforeRender(v,D,k,G,C,K),N.transparent===!0&&N.side===Hi&&N.forceSinglePass===!1?(N.side=Ue,N.needsUpdate=!0,v.renderBufferDirect(k,D,G,N,C,K),N.side=ln,N.needsUpdate=!0,v.renderBufferDirect(k,D,G,N,C,K),N.side=Hi):v.renderBufferDirect(k,D,G,N,C,K),C.onAfterRender(v,D,k,G,N,K)}function Ia(C,D,k){D.isScene!==!0&&(D=Lt);const G=ft.get(C),N=f.state.lights,K=f.state.shadowsArray,ht=N.state.version,gt=Z.getParameters(C,N.state,K,D,k),ut=Z.getProgramCacheKey(gt);let Tt=G.programs;G.environment=C.isMeshStandardMaterial?D.environment:null,G.fog=D.fog,G.envMap=(C.isMeshStandardMaterial?ge:ye).get(C.envMap||G.environment),G.envMapRotation=G.environment!==null&&C.envMap===null?D.environmentRotation:C.envMapRotation,Tt===void 0&&(C.addEventListener("dispose",j),Tt=new Map,G.programs=Tt);let Pt=Tt.get(ut);if(Pt!==void 0){if(G.currentProgram===Pt&&G.lightsStateVersion===ht)return vc(C,gt),Pt}else gt.uniforms=Z.getUniforms(C),C.onBeforeCompile(gt,v),Pt=Z.acquireProgram(gt,ut),Tt.set(ut,Pt),G.uniforms=gt.uniforms;const St=G.uniforms;return(!C.isShaderMaterial&&!C.isRawShaderMaterial||C.clipping===!0)&&(St.clippingPlanes=it.uniform),vc(C,gt),G.needsLights=tC(C),G.lightsStateVersion=ht,G.needsLights&&(St.ambientLightColor.value=N.state.ambient,St.lightProbe.value=N.state.probe,St.directionalLights.value=N.state.directional,St.directionalLightShadows.value=N.state.directionalShadow,St.spotLights.value=N.state.spot,St.spotLightShadows.value=N.state.spotShadow,St.rectAreaLights.value=N.state.rectArea,St.ltc_1.value=N.state.rectAreaLTC1,St.ltc_2.value=N.state.rectAreaLTC2,St.pointLights.value=N.state.point,St.pointLightShadows.value=N.state.pointShadow,St.hemisphereLights.value=N.state.hemi,St.directionalShadowMap.value=N.state.directionalShadowMap,St.directionalShadowMatrix.value=N.state.directionalShadowMatrix,St.spotShadowMap.value=N.state.spotShadowMap,St.spotLightMatrix.value=N.state.spotLightMatrix,St.spotLightMap.value=N.state.spotLightMap,St.pointShadowMap.value=N.state.pointShadowMap,St.pointShadowMatrix.value=N.state.pointShadowMatrix),G.currentProgram=Pt,G.uniformsList=null,Pt}function Cc(C){if(C.uniformsList===null){const D=C.currentProgram.getUniforms();C.uniformsList=ua.seqWithValue(D.seq,C.uniforms)}return C.uniformsList}function vc(C,D){const k=ft.get(C);k.outputColorSpace=D.outputColorSpace,k.batching=D.batching,k.batchingColor=D.batchingColor,k.instancing=D.instancing,k.instancingColor=D.instancingColor,k.instancingMorph=D.instancingMorph,k.skinning=D.skinning,k.morphTargets=D.morphTargets,k.morphNormals=D.morphNormals,k.morphColors=D.morphColors,k.morphTargetsCount=D.morphTargetsCount,k.numClippingPlanes=D.numClippingPlanes,k.numIntersection=D.numClipIntersection,k.vertexAlphas=D.vertexAlphas,k.vertexTangents=D.vertexTangents,k.toneMapping=D.toneMapping}function KI(C,D,k,G,N){D.isScene!==!0&&(D=Lt),Ut.resetTextureUnits();const K=D.fog,ht=G.isMeshStandardMaterial?D.environment:null,gt=P===null?v.outputColorSpace:P.isXRRenderTarget===!0?P.texture.colorSpace:cs,ut=(G.isMeshStandardMaterial?ge:ye).get(G.envMap||ht),Tt=G.vertexColors===!0&&!!k.attributes.color&&k.attributes.color.itemSize===4,Pt=!!k.attributes.tangent&&(!!G.normalMap||G.anisotropy>0),St=!!k.morphAttributes.position,zt=!!k.morphAttributes.normal,$t=!!k.morphAttributes.color;let ue=hn;G.toneMapped&&(P===null||P.isXRRenderTarget===!0)&&(ue=v.toneMapping);const se=k.morphAttributes.position||k.morphAttributes.normal||k.morphAttributes.color,ee=se!==void 0?se.length:0,bt=ft.get(G),oe=f.state.lights;if(J===!0&&(ot===!0||C!==x)){const De=C===x&&G.id===E;it.setState(G,C,De)}let Zt=!1;G.version===bt.__version?(bt.needsLights&&bt.lightsStateVersion!==oe.state.version||bt.outputColorSpace!==gt||N.isBatchedMesh&&bt.batching===!1||!N.isBatchedMesh&&bt.batching===!0||N.isBatchedMesh&&bt.batchingColor===!0&&N.colorTexture===null||N.isBatchedMesh&&bt.batchingColor===!1&&N.colorTexture!==null||N.isInstancedMesh&&bt.instancing===!1||!N.isInstancedMesh&&bt.instancing===!0||N.isSkinnedMesh&&bt.skinning===!1||!N.isSkinnedMesh&&bt.skinning===!0||N.isInstancedMesh&&bt.instancingColor===!0&&N.instanceColor===null||N.isInstancedMesh&&bt.instancingColor===!1&&N.instanceColor!==null||N.isInstancedMesh&&bt.instancingMorph===!0&&N.morphTexture===null||N.isInstancedMesh&&bt.instancingMorph===!1&&N.morphTexture!==null||bt.envMap!==ut||G.fog===!0&&bt.fog!==K||bt.numClippingPlanes!==void 0&&(bt.numClippingPlanes!==it.numPlanes||bt.numIntersection!==it.numIntersection)||bt.vertexAlphas!==Tt||bt.vertexTangents!==Pt||bt.morphTargets!==St||bt.morphNormals!==zt||bt.morphColors!==$t||bt.toneMapping!==ue||bt.morphTargetsCount!==ee)&&(Zt=!0):(Zt=!0,bt.__version=G.version);let Je=bt.currentProgram;Zt===!0&&(Je=Ia(G,D,N));let Bs=!1,je=!1,dr=!1;const le=Je.getUniforms(),ti=bt.uniforms;if(Et.useProgram(Je.program)&&(Bs=!0,je=!0,dr=!0),G.id!==E&&(E=G.id,je=!0),Bs||x!==C){Et.buffers.depth.getReversed()&&C.reversedDepth!==!0&&(C._reversedDepth=!0,C.updateProjectionMatrix()),le.setValue(_,"projectionMatrix",C.projectionMatrix),le.setValue(_,"viewMatrix",C.matrixWorldInverse);const Ge=le.map.cameraPosition;Ge!==void 0&&Ge.setValue(_,Mt.setFromMatrixPosition(C.matrixWorld)),jt.logarithmicDepthBuffer&&le.setValue(_,"logDepthBufFC",2/(Math.log(C.far+1)/Math.LN2)),(G.isMeshPhongMaterial||G.isMeshToonMaterial||G.isMeshLambertMaterial||G.isMeshBasicMaterial||G.isMeshStandardMaterial||G.isShaderMaterial)&&le.setValue(_,"isOrthographic",C.isOrthographicCamera===!0),x!==C&&(x=C,je=!0,dr=!0)}if(N.isSkinnedMesh){le.setOptional(_,N,"bindMatrix"),le.setOptional(_,N,"bindMatrixInverse");const De=N.skeleton;De&&(De.boneTexture===null&&De.computeBoneTexture(),le.setValue(_,"boneTexture",De.boneTexture,Ut))}N.isBatchedMesh&&(le.setOptional(_,N,"batchingTexture"),le.setValue(_,"batchingTexture",N._matricesTexture,Ut),le.setOptional(_,N,"batchingIdTexture"),le.setValue(_,"batchingIdTexture",N._indirectTexture,Ut),le.setOptional(_,N,"batchingColorTexture"),N._colorsTexture!==null&&le.setValue(_,"batchingColorTexture",N._colorsTexture,Ut));const ei=k.morphAttributes;if((ei.position!==void 0||ei.normal!==void 0||ei.color!==void 0)&&tt.update(N,k,Je),(je||bt.receiveShadow!==N.receiveShadow)&&(bt.receiveShadow=N.receiveShadow,le.setValue(_,"receiveShadow",N.receiveShadow)),G.isMeshGouraudMaterial&&G.envMap!==null&&(ti.envMap.value=ut,ti.flipEnvMap.value=ut.isCubeTexture&&ut.isRenderTargetTexture===!1?-1:1),G.isMeshStandardMaterial&&G.envMap===null&&D.environment!==null&&(ti.envMapIntensity.value=D.environmentIntensity),je&&(le.setValue(_,"toneMappingExposure",v.toneMappingExposure),bt.needsLights&&$I(ti,dr),K&&G.fog===!0&&Q.refreshFogUniforms(ti,K),Q.refreshMaterialUniforms(ti,G,H,$,f.state.transmissionRenderTarget[C.id]),ua.upload(_,Cc(bt),ti,Ut)),G.isShaderMaterial&&G.uniformsNeedUpdate===!0&&(ua.upload(_,Cc(bt),ti,Ut),G.uniformsNeedUpdate=!1),G.isSpriteMaterial&&le.setValue(_,"center",N.center),le.setValue(_,"modelViewMatrix",N.modelViewMatrix),le.setValue(_,"normalMatrix",N.normalMatrix),le.setValue(_,"modelMatrix",N.matrixWorld),G.isShaderMaterial||G.isRawShaderMaterial){const De=G.uniformsGroups;for(let Ge=0,Dl=De.length;Ge<Dl;Ge++){const Xn=De[Ge];Ft.update(Xn,Je),Ft.bind(Xn,Je)}}return Je}function $I(C,D){C.ambientLightColor.needsUpdate=D,C.lightProbe.needsUpdate=D,C.directionalLights.needsUpdate=D,C.directionalLightShadows.needsUpdate=D,C.pointLights.needsUpdate=D,C.pointLightShadows.needsUpdate=D,C.spotLights.needsUpdate=D,C.spotLightShadows.needsUpdate=D,C.rectAreaLights.needsUpdate=D,C.hemisphereLights.needsUpdate=D}function tC(C){return C.isMeshLambertMaterial||C.isMeshToonMaterial||C.isMeshPhongMaterial||C.isMeshStandardMaterial||C.isShadowMaterial||C.isShaderMaterial&&C.lights===!0}this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return R},this.getRenderTarget=function(){return P},this.setRenderTargetTextures=function(C,D,k){const G=ft.get(C);G.__autoAllocateDepthBuffer=C.resolveDepthBuffer===!1,G.__autoAllocateDepthBuffer===!1&&(G.__useRenderToTexture=!1),ft.get(C.texture).__webglTexture=D,ft.get(C.depthTexture).__webglTexture=G.__autoAllocateDepthBuffer?void 0:k,G.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(C,D){const k=ft.get(C);k.__webglFramebuffer=D,k.__useDefaultFramebuffer=D===void 0};const eC=_.createFramebuffer();this.setRenderTarget=function(C,D=0,k=0){P=C,w=D,R=k;let G=!0,N=null,K=!1,ht=!1;if(C){const ut=ft.get(C);if(ut.__useDefaultFramebuffer!==void 0)Et.bindFramebuffer(_.FRAMEBUFFER,null),G=!1;else if(ut.__webglFramebuffer===void 0)Ut.setupRenderTarget(C);else if(ut.__hasExternalTextures)Ut.rebindTextures(C,ft.get(C.texture).__webglTexture,ft.get(C.depthTexture).__webglTexture);else if(C.depthBuffer){const St=C.depthTexture;if(ut.__boundDepthTexture!==St){if(St!==null&&ft.has(St)&&(C.width!==St.image.width||C.height!==St.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Ut.setupDepthRenderbuffer(C)}}const Tt=C.texture;(Tt.isData3DTexture||Tt.isDataArrayTexture||Tt.isCompressedArrayTexture)&&(ht=!0);const Pt=ft.get(C).__webglFramebuffer;C.isWebGLCubeRenderTarget?(Array.isArray(Pt[D])?N=Pt[D][k]:N=Pt[D],K=!0):C.samples>0&&Ut.useMultisampledRTT(C)===!1?N=ft.get(C).__webglMultisampledFramebuffer:Array.isArray(Pt)?N=Pt[k]:N=Pt,M.copy(C.viewport),z.copy(C.scissor),O=C.scissorTest}else M.copy(mt).multiplyScalar(H).floor(),z.copy(Bt).multiplyScalar(H).floor(),O=re;if(k!==0&&(N=eC),Et.bindFramebuffer(_.FRAMEBUFFER,N)&&G&&Et.drawBuffers(C,N),Et.viewport(M),Et.scissor(z),Et.setScissorTest(O),K){const ut=ft.get(C.texture);_.framebufferTexture2D(_.FRAMEBUFFER,_.COLOR_ATTACHMENT0,_.TEXTURE_CUBE_MAP_POSITIVE_X+D,ut.__webglTexture,k)}else if(ht){const ut=D;for(let Tt=0;Tt<C.textures.length;Tt++){const Pt=ft.get(C.textures[Tt]);_.framebufferTextureLayer(_.FRAMEBUFFER,_.COLOR_ATTACHMENT0+Tt,Pt.__webglTexture,k,ut)}}else if(C!==null&&k!==0){const ut=ft.get(C.texture);_.framebufferTexture2D(_.FRAMEBUFFER,_.COLOR_ATTACHMENT0,_.TEXTURE_2D,ut.__webglTexture,k)}E=-1},this.readRenderTargetPixels=function(C,D,k,G,N,K,ht,gt=0){if(!(C&&C.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ut=ft.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&ht!==void 0&&(ut=ut[ht]),ut){Et.bindFramebuffer(_.FRAMEBUFFER,ut);try{const Tt=C.textures[gt],Pt=Tt.format,St=Tt.type;if(!jt.textureFormatReadable(Pt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!jt.textureTypeReadable(St)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}D>=0&&D<=C.width-G&&k>=0&&k<=C.height-N&&(C.textures.length>1&&_.readBuffer(_.COLOR_ATTACHMENT0+gt),_.readPixels(D,k,G,N,vt.convert(Pt),vt.convert(St),K))}finally{const Tt=P!==null?ft.get(P).__webglFramebuffer:null;Et.bindFramebuffer(_.FRAMEBUFFER,Tt)}}},this.readRenderTargetPixelsAsync=async function(C,D,k,G,N,K,ht,gt=0){if(!(C&&C.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ut=ft.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&ht!==void 0&&(ut=ut[ht]),ut)if(D>=0&&D<=C.width-G&&k>=0&&k<=C.height-N){Et.bindFramebuffer(_.FRAMEBUFFER,ut);const Tt=C.textures[gt],Pt=Tt.format,St=Tt.type;if(!jt.textureFormatReadable(Pt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!jt.textureTypeReadable(St))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const zt=_.createBuffer();_.bindBuffer(_.PIXEL_PACK_BUFFER,zt),_.bufferData(_.PIXEL_PACK_BUFFER,K.byteLength,_.STREAM_READ),C.textures.length>1&&_.readBuffer(_.COLOR_ATTACHMENT0+gt),_.readPixels(D,k,G,N,vt.convert(Pt),vt.convert(St),0);const $t=P!==null?ft.get(P).__webglFramebuffer:null;Et.bindFramebuffer(_.FRAMEBUFFER,$t);const ue=_.fenceSync(_.SYNC_GPU_COMMANDS_COMPLETE,0);return _.flush(),await tf(_,ue,4),_.bindBuffer(_.PIXEL_PACK_BUFFER,zt),_.getBufferSubData(_.PIXEL_PACK_BUFFER,0,K),_.deleteBuffer(zt),_.deleteSync(ue),K}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(C,D=null,k=0){const G=Math.pow(2,-k),N=Math.floor(C.image.width*G),K=Math.floor(C.image.height*G),ht=D!==null?D.x:0,gt=D!==null?D.y:0;Ut.setTexture2D(C,0),_.copyTexSubImage2D(_.TEXTURE_2D,k,0,0,ht,gt,N,K),Et.unbindTexture()};const iC=_.createFramebuffer(),nC=_.createFramebuffer();this.copyTextureToTexture=function(C,D,k=null,G=null,N=0,K=null){K===null&&(N!==0?(gs("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),K=N,N=0):K=0);let ht,gt,ut,Tt,Pt,St,zt,$t,ue;const se=C.isCompressedTexture?C.mipmaps[K]:C.image;if(k!==null)ht=k.max.x-k.min.x,gt=k.max.y-k.min.y,ut=k.isBox3?k.max.z-k.min.z:1,Tt=k.min.x,Pt=k.min.y,St=k.isBox3?k.min.z:0;else{const ei=Math.pow(2,-N);ht=Math.floor(se.width*ei),gt=Math.floor(se.height*ei),C.isDataArrayTexture?ut=se.depth:C.isData3DTexture?ut=Math.floor(se.depth*ei):ut=1,Tt=0,Pt=0,St=0}G!==null?(zt=G.x,$t=G.y,ue=G.z):(zt=0,$t=0,ue=0);const ee=vt.convert(D.format),bt=vt.convert(D.type);let oe;D.isData3DTexture?(Ut.setTexture3D(D,0),oe=_.TEXTURE_3D):D.isDataArrayTexture||D.isCompressedArrayTexture?(Ut.setTexture2DArray(D,0),oe=_.TEXTURE_2D_ARRAY):(Ut.setTexture2D(D,0),oe=_.TEXTURE_2D),_.pixelStorei(_.UNPACK_FLIP_Y_WEBGL,D.flipY),_.pixelStorei(_.UNPACK_PREMULTIPLY_ALPHA_WEBGL,D.premultiplyAlpha),_.pixelStorei(_.UNPACK_ALIGNMENT,D.unpackAlignment);const Zt=_.getParameter(_.UNPACK_ROW_LENGTH),Je=_.getParameter(_.UNPACK_IMAGE_HEIGHT),Bs=_.getParameter(_.UNPACK_SKIP_PIXELS),je=_.getParameter(_.UNPACK_SKIP_ROWS),dr=_.getParameter(_.UNPACK_SKIP_IMAGES);_.pixelStorei(_.UNPACK_ROW_LENGTH,se.width),_.pixelStorei(_.UNPACK_IMAGE_HEIGHT,se.height),_.pixelStorei(_.UNPACK_SKIP_PIXELS,Tt),_.pixelStorei(_.UNPACK_SKIP_ROWS,Pt),_.pixelStorei(_.UNPACK_SKIP_IMAGES,St);const le=C.isDataArrayTexture||C.isData3DTexture,ti=D.isDataArrayTexture||D.isData3DTexture;if(C.isDepthTexture){const ei=ft.get(C),De=ft.get(D),Ge=ft.get(ei.__renderTarget),Dl=ft.get(De.__renderTarget);Et.bindFramebuffer(_.READ_FRAMEBUFFER,Ge.__webglFramebuffer),Et.bindFramebuffer(_.DRAW_FRAMEBUFFER,Dl.__webglFramebuffer);for(let Xn=0;Xn<ut;Xn++)le&&(_.framebufferTextureLayer(_.READ_FRAMEBUFFER,_.COLOR_ATTACHMENT0,ft.get(C).__webglTexture,N,St+Xn),_.framebufferTextureLayer(_.DRAW_FRAMEBUFFER,_.COLOR_ATTACHMENT0,ft.get(D).__webglTexture,K,ue+Xn)),_.blitFramebuffer(Tt,Pt,ht,gt,zt,$t,ht,gt,_.DEPTH_BUFFER_BIT,_.NEAREST);Et.bindFramebuffer(_.READ_FRAMEBUFFER,null),Et.bindFramebuffer(_.DRAW_FRAMEBUFFER,null)}else if(N!==0||C.isRenderTargetTexture||ft.has(C)){const ei=ft.get(C),De=ft.get(D);Et.bindFramebuffer(_.READ_FRAMEBUFFER,iC),Et.bindFramebuffer(_.DRAW_FRAMEBUFFER,nC);for(let Ge=0;Ge<ut;Ge++)le?_.framebufferTextureLayer(_.READ_FRAMEBUFFER,_.COLOR_ATTACHMENT0,ei.__webglTexture,N,St+Ge):_.framebufferTexture2D(_.READ_FRAMEBUFFER,_.COLOR_ATTACHMENT0,_.TEXTURE_2D,ei.__webglTexture,N),ti?_.framebufferTextureLayer(_.DRAW_FRAMEBUFFER,_.COLOR_ATTACHMENT0,De.__webglTexture,K,ue+Ge):_.framebufferTexture2D(_.DRAW_FRAMEBUFFER,_.COLOR_ATTACHMENT0,_.TEXTURE_2D,De.__webglTexture,K),N!==0?_.blitFramebuffer(Tt,Pt,ht,gt,zt,$t,ht,gt,_.COLOR_BUFFER_BIT,_.NEAREST):ti?_.copyTexSubImage3D(oe,K,zt,$t,ue+Ge,Tt,Pt,ht,gt):_.copyTexSubImage2D(oe,K,zt,$t,Tt,Pt,ht,gt);Et.bindFramebuffer(_.READ_FRAMEBUFFER,null),Et.bindFramebuffer(_.DRAW_FRAMEBUFFER,null)}else ti?C.isDataTexture||C.isData3DTexture?_.texSubImage3D(oe,K,zt,$t,ue,ht,gt,ut,ee,bt,se.data):D.isCompressedArrayTexture?_.compressedTexSubImage3D(oe,K,zt,$t,ue,ht,gt,ut,ee,se.data):_.texSubImage3D(oe,K,zt,$t,ue,ht,gt,ut,ee,bt,se):C.isDataTexture?_.texSubImage2D(_.TEXTURE_2D,K,zt,$t,ht,gt,ee,bt,se.data):C.isCompressedTexture?_.compressedTexSubImage2D(_.TEXTURE_2D,K,zt,$t,se.width,se.height,ee,se.data):_.texSubImage2D(_.TEXTURE_2D,K,zt,$t,ht,gt,ee,bt,se);_.pixelStorei(_.UNPACK_ROW_LENGTH,Zt),_.pixelStorei(_.UNPACK_IMAGE_HEIGHT,Je),_.pixelStorei(_.UNPACK_SKIP_PIXELS,Bs),_.pixelStorei(_.UNPACK_SKIP_ROWS,je),_.pixelStorei(_.UNPACK_SKIP_IMAGES,dr),K===0&&D.generateMipmaps&&_.generateMipmap(oe),Et.unbindTexture()},this.copyTextureToTexture3D=function(C,D,k=null,G=null,N=0){return gs('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(C,D,k,G,N)},this.initRenderTarget=function(C){ft.get(C).__webglFramebuffer===void 0&&Ut.setupRenderTarget(C)},this.initTexture=function(C){C.isCubeTexture?Ut.setTextureCube(C,0):C.isData3DTexture?Ut.setTexture3D(C,0):C.isDataArrayTexture||C.isCompressedArrayTexture?Ut.setTexture2DArray(C,0):Ut.setTexture2D(C,0),Et.unbindTexture()},this.resetState=function(){w=0,R=0,P=null,Et.reset(),lt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return xi}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=Xt._getDrawingBufferColorSpace(t),e.unpackColorSpace=Xt._getUnpackColorSpace()}}const cc={LANGUAGE_CHANGE_CONFIRMED:Ca.LANGUAGE_CHANGE_CONFIRMED},VI=new Set([Qt.ENGLISH_UNITED_KINGDOM]),Rl={selected:Qt.ENGLISH_UNITED_KINGDOM,options:VI},fa={OPTIONS:"languages",SELECTED:"selected"},WI=`<section class="root">
3955
+ }`;class UI{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){const i=new Ac(t.texture);(t.depthNear!==e.depthNear||t.depthFar!==e.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=i}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,i=new mn({vertexShader:OI,fragmentShader:BI,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new mi(new cr(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class zI extends ds{constructor(t,e){super();const i=this;let n=null,s=1,a=null,o="local-floor",A=1,l=null,h=null,c=null,u=null,d=null,p=null;const m=new UI,g={},f=e.getContextAttributes();let b=null,S=null;const v=[],T=[],w=new Jt;let R=null;const P=new ke;P.viewport=new ce;const E=new ke;E.viewport=new ce;const x=[P,E],M=new kf;let z=null,O=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(J){let ot=v[J];return ot===void 0&&(ot=new dl,v[J]=ot),ot.getTargetRaySpace()},this.getControllerGrip=function(J){let ot=v[J];return ot===void 0&&(ot=new dl,v[J]=ot),ot.getGripSpace()},this.getHand=function(J){let ot=v[J];return ot===void 0&&(ot=new dl,v[J]=ot),ot.getHandSpace()};function U(J){const ot=T.indexOf(J.inputSource);if(ot===-1)return;const nt=v[ot];nt!==void 0&&(nt.update(J.inputSource,J.frame,l||a),nt.dispatchEvent({type:J.type,data:J.inputSource}))}function W(){n.removeEventListener("select",U),n.removeEventListener("selectstart",U),n.removeEventListener("selectend",U),n.removeEventListener("squeeze",U),n.removeEventListener("squeezestart",U),n.removeEventListener("squeezeend",U),n.removeEventListener("end",W),n.removeEventListener("inputsourceschange",Y);for(let J=0;J<v.length;J++){const ot=T[J];ot!==null&&(T[J]=null,v[J].disconnect(ot))}z=null,O=null,m.reset();for(const J in g)delete g[J];t.setRenderTarget(b),d=null,u=null,c=null,n=null,S=null,te.stop(),i.isPresenting=!1,t.setPixelRatio(R),t.setSize(w.width,w.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(J){s=J,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(J){o=J,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(J){l=J},this.getBaseLayer=function(){return u!==null?u:d},this.getBinding=function(){return c},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(J){if(n=J,n!==null){if(b=t.getRenderTarget(),n.addEventListener("select",U),n.addEventListener("selectstart",U),n.addEventListener("selectend",U),n.addEventListener("squeeze",U),n.addEventListener("squeezestart",U),n.addEventListener("squeezeend",U),n.addEventListener("end",W),n.addEventListener("inputsourceschange",Y),f.xrCompatible!==!0&&await e.makeXRCompatible(),R=t.getPixelRatio(),t.getSize(w),typeof XRWebGLBinding<"u"&&(c=new XRWebGLBinding(n,e)),c!==null&&"createProjectionLayer"in XRWebGLBinding.prototype){let nt=null,Mt=null,wt=null;f.depth&&(wt=f.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,nt=f.stencil?er:tr,Mt=f.stencil?$s:Ln);const Lt={colorFormat:e.RGBA8,depthFormat:wt,scaleFactor:s};u=c.createProjectionLayer(Lt),n.updateRenderState({layers:[u]}),t.setPixelRatio(1),t.setSize(u.textureWidth,u.textureHeight,!1),S=new Dn(u.textureWidth,u.textureHeight,{format:ci,type:vi,depthTexture:new bh(u.textureWidth,u.textureHeight,Mt,void 0,void 0,void 0,void 0,void 0,void 0,nt),stencilBuffer:f.stencil,colorSpace:t.outputColorSpace,samples:f.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1})}else{const nt={antialias:f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(n,e,nt),n.updateRenderState({baseLayer:d}),t.setPixelRatio(1),t.setSize(d.framebufferWidth,d.framebufferHeight,!1),S=new Dn(d.framebufferWidth,d.framebufferHeight,{format:ci,type:vi,colorSpace:t.outputColorSpace,stencilBuffer:f.stencil,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}S.isXRRenderTarget=!0,this.setFoveation(A),l=null,a=await n.requestReferenceSpace(o),te.setContext(n),te.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(n!==null)return n.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function Y(J){for(let ot=0;ot<J.removed.length;ot++){const nt=J.removed[ot],Mt=T.indexOf(nt);Mt>=0&&(T[Mt]=null,v[Mt].disconnect(nt))}for(let ot=0;ot<J.added.length;ot++){const nt=J.added[ot];let Mt=T.indexOf(nt);if(Mt===-1){for(let Lt=0;Lt<v.length;Lt++)if(Lt>=T.length){T.push(nt),Mt=Lt;break}else if(T[Lt]===null){T[Lt]=nt,Mt=Lt;break}if(Mt===-1)break}const wt=v[Mt];wt&&wt.connect(nt)}}const $=new F,H=new F;function rt(J,ot,nt){$.setFromMatrixPosition(ot.matrixWorld),H.setFromMatrixPosition(nt.matrixWorld);const Mt=$.distanceTo(H),wt=ot.projectionMatrix.elements,Lt=nt.projectionMatrix.elements,fe=wt[14]/(wt[10]-1),Wt=wt[14]/(wt[10]+1),_=(wt[9]+1)/wt[5],ie=(wt[9]-1)/wt[5],yt=(wt[8]-1)/wt[0],jt=(Lt[8]+1)/Lt[0],Et=fe*yt,ae=fe*jt,ft=Mt/(-yt+jt),Ut=ft*-yt;if(ot.matrixWorld.decompose(J.position,J.quaternion,J.scale),J.translateX(Ut),J.translateZ(ft),J.matrixWorld.compose(J.position,J.quaternion,J.scale),J.matrixWorldInverse.copy(J.matrixWorld).invert(),wt[10]===-1)J.projectionMatrix.copy(ot.projectionMatrix),J.projectionMatrixInverse.copy(ot.projectionMatrixInverse);else{const ye=fe+ft,ge=Wt+ft,y=Et-Ut,I=ae+(Mt-Ut),B=_*Wt/ge*ye,Z=ie*Wt/ge*ye;J.projectionMatrix.makePerspective(y,I,B,Z,ye,ge),J.projectionMatrixInverse.copy(J.projectionMatrix).invert()}}function At(J,ot){ot===null?J.matrixWorld.copy(J.matrix):J.matrixWorld.multiplyMatrices(ot.matrixWorld,J.matrix),J.matrixWorldInverse.copy(J.matrixWorld).invert()}this.updateCamera=function(J){if(n===null)return;let ot=J.near,nt=J.far;m.texture!==null&&(m.depthNear>0&&(ot=m.depthNear),m.depthFar>0&&(nt=m.depthFar)),M.near=E.near=P.near=ot,M.far=E.far=P.far=nt,(z!==M.near||O!==M.far)&&(n.updateRenderState({depthNear:M.near,depthFar:M.far}),z=M.near,O=M.far),M.layers.mask=J.layers.mask|6,P.layers.mask=M.layers.mask&3,E.layers.mask=M.layers.mask&5;const Mt=J.parent,wt=M.cameras;At(M,Mt);for(let Lt=0;Lt<wt.length;Lt++)At(wt[Lt],Mt);wt.length===2?rt(M,P,E):M.projectionMatrix.copy(P.projectionMatrix),mt(J,M,Mt)};function mt(J,ot,nt){nt===null?J.matrix.copy(ot.matrixWorld):(J.matrix.copy(nt.matrixWorld),J.matrix.invert(),J.matrix.multiply(ot.matrixWorld)),J.matrix.decompose(J.position,J.quaternion,J.scale),J.updateMatrixWorld(!0),J.projectionMatrix.copy(ot.projectionMatrix),J.projectionMatrixInverse.copy(ot.projectionMatrixInverse),J.isPerspectiveCamera&&(J.fov=Yr*2*Math.atan(1/J.projectionMatrix.elements[5]),J.zoom=1)}this.getCamera=function(){return M},this.getFoveation=function(){if(!(u===null&&d===null))return A},this.setFoveation=function(J){A=J,u!==null&&(u.fixedFoveation=J),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=J)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(M)},this.getCameraTexture=function(J){return g[J]};let Bt=null;function re(J,ot){if(h=ot.getViewerPose(l||a),p=ot,h!==null){const nt=h.views;d!==null&&(t.setRenderTargetFramebuffer(S,d.framebuffer),t.setRenderTarget(S));let Mt=!1;nt.length!==M.cameras.length&&(M.cameras.length=0,Mt=!0);for(let Wt=0;Wt<nt.length;Wt++){const _=nt[Wt];let ie=null;if(d!==null)ie=d.getViewport(_);else{const jt=c.getViewSubImage(u,_);ie=jt.viewport,Wt===0&&(t.setRenderTargetTextures(S,jt.colorTexture,jt.depthStencilTexture),t.setRenderTarget(S))}let yt=x[Wt];yt===void 0&&(yt=new ke,yt.layers.enable(Wt),yt.viewport=new ce,x[Wt]=yt),yt.matrix.fromArray(_.transform.matrix),yt.matrix.decompose(yt.position,yt.quaternion,yt.scale),yt.projectionMatrix.fromArray(_.projectionMatrix),yt.projectionMatrixInverse.copy(yt.projectionMatrix).invert(),yt.viewport.set(ie.x,ie.y,ie.width,ie.height),Wt===0&&(M.matrix.copy(yt.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),Mt===!0&&M.cameras.push(yt)}const wt=n.enabledFeatures;if(wt&&wt.includes("depth-sensing")&&n.depthUsage=="gpu-optimized"&&c){const Wt=c.getDepthInformation(nt[0]);Wt&&Wt.isValid&&Wt.texture&&m.init(Wt,n.renderState)}if(wt&&wt.includes("camera-access")&&(t.state.unbindTexture(),c))for(let Wt=0;Wt<nt.length;Wt++){const _=nt[Wt].camera;if(_){let ie=g[_];ie||(ie=new Ac,g[_]=ie);const yt=c.getCameraImage(_);ie.sourceTexture=yt}}}for(let nt=0;nt<v.length;nt++){const Mt=T[nt],wt=v[nt];Mt!==null&&wt!==void 0&&wt.update(Mt,ot,l||a)}Bt&&Bt(J,ot),ot.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:ot}),p=null}const te=new Nh;te.setAnimationLoop(re),this.setAnimationLoop=function(J){Bt=J},this.dispose=function(){}}}const Wn=new fi,kI=new de;function GI(r,t){function e(g,f){g.matrixAutoUpdate===!0&&g.updateMatrix(),f.value.copy(g.matrix)}function i(g,f){f.color.getRGB(g.fogColor.value,Ih(r)),f.isFog?(g.fogNear.value=f.near,g.fogFar.value=f.far):f.isFogExp2&&(g.fogDensity.value=f.density)}function n(g,f,b,S,v){f.isMeshBasicMaterial||f.isMeshLambertMaterial?s(g,f):f.isMeshToonMaterial?(s(g,f),c(g,f)):f.isMeshPhongMaterial?(s(g,f),h(g,f)):f.isMeshStandardMaterial?(s(g,f),u(g,f),f.isMeshPhysicalMaterial&&d(g,f,v)):f.isMeshMatcapMaterial?(s(g,f),p(g,f)):f.isMeshDepthMaterial?s(g,f):f.isMeshDistanceMaterial?(s(g,f),m(g,f)):f.isMeshNormalMaterial?s(g,f):f.isLineBasicMaterial?(a(g,f),f.isLineDashedMaterial&&o(g,f)):f.isPointsMaterial?A(g,f,b,S):f.isSpriteMaterial?l(g,f):f.isShadowMaterial?(g.color.value.copy(f.color),g.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function s(g,f){g.opacity.value=f.opacity,f.color&&g.diffuse.value.copy(f.color),f.emissive&&g.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(g.map.value=f.map,e(f.map,g.mapTransform)),f.alphaMap&&(g.alphaMap.value=f.alphaMap,e(f.alphaMap,g.alphaMapTransform)),f.bumpMap&&(g.bumpMap.value=f.bumpMap,e(f.bumpMap,g.bumpMapTransform),g.bumpScale.value=f.bumpScale,f.side===Ue&&(g.bumpScale.value*=-1)),f.normalMap&&(g.normalMap.value=f.normalMap,e(f.normalMap,g.normalMapTransform),g.normalScale.value.copy(f.normalScale),f.side===Ue&&g.normalScale.value.negate()),f.displacementMap&&(g.displacementMap.value=f.displacementMap,e(f.displacementMap,g.displacementMapTransform),g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias),f.emissiveMap&&(g.emissiveMap.value=f.emissiveMap,e(f.emissiveMap,g.emissiveMapTransform)),f.specularMap&&(g.specularMap.value=f.specularMap,e(f.specularMap,g.specularMapTransform)),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest);const b=t.get(f),S=b.envMap,v=b.envMapRotation;S&&(g.envMap.value=S,Wn.copy(v),Wn.x*=-1,Wn.y*=-1,Wn.z*=-1,S.isCubeTexture&&S.isRenderTargetTexture===!1&&(Wn.y*=-1,Wn.z*=-1),g.envMapRotation.value.setFromMatrix4(kI.makeRotationFromEuler(Wn)),g.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=f.reflectivity,g.ior.value=f.ior,g.refractionRatio.value=f.refractionRatio),f.lightMap&&(g.lightMap.value=f.lightMap,g.lightMapIntensity.value=f.lightMapIntensity,e(f.lightMap,g.lightMapTransform)),f.aoMap&&(g.aoMap.value=f.aoMap,g.aoMapIntensity.value=f.aoMapIntensity,e(f.aoMap,g.aoMapTransform))}function a(g,f){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,f.map&&(g.map.value=f.map,e(f.map,g.mapTransform))}function o(g,f){g.dashSize.value=f.dashSize,g.totalSize.value=f.dashSize+f.gapSize,g.scale.value=f.scale}function A(g,f,b,S){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,g.size.value=f.size*b,g.scale.value=S*.5,f.map&&(g.map.value=f.map,e(f.map,g.uvTransform)),f.alphaMap&&(g.alphaMap.value=f.alphaMap,e(f.alphaMap,g.alphaMapTransform)),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest)}function l(g,f){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,g.rotation.value=f.rotation,f.map&&(g.map.value=f.map,e(f.map,g.mapTransform)),f.alphaMap&&(g.alphaMap.value=f.alphaMap,e(f.alphaMap,g.alphaMapTransform)),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest)}function h(g,f){g.specular.value.copy(f.specular),g.shininess.value=Math.max(f.shininess,1e-4)}function c(g,f){f.gradientMap&&(g.gradientMap.value=f.gradientMap)}function u(g,f){g.metalness.value=f.metalness,f.metalnessMap&&(g.metalnessMap.value=f.metalnessMap,e(f.metalnessMap,g.metalnessMapTransform)),g.roughness.value=f.roughness,f.roughnessMap&&(g.roughnessMap.value=f.roughnessMap,e(f.roughnessMap,g.roughnessMapTransform)),f.envMap&&(g.envMapIntensity.value=f.envMapIntensity)}function d(g,f,b){g.ior.value=f.ior,f.sheen>0&&(g.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),g.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(g.sheenColorMap.value=f.sheenColorMap,e(f.sheenColorMap,g.sheenColorMapTransform)),f.sheenRoughnessMap&&(g.sheenRoughnessMap.value=f.sheenRoughnessMap,e(f.sheenRoughnessMap,g.sheenRoughnessMapTransform))),f.clearcoat>0&&(g.clearcoat.value=f.clearcoat,g.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(g.clearcoatMap.value=f.clearcoatMap,e(f.clearcoatMap,g.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,e(f.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(g.clearcoatNormalMap.value=f.clearcoatNormalMap,e(f.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===Ue&&g.clearcoatNormalScale.value.negate())),f.dispersion>0&&(g.dispersion.value=f.dispersion),f.iridescence>0&&(g.iridescence.value=f.iridescence,g.iridescenceIOR.value=f.iridescenceIOR,g.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(g.iridescenceMap.value=f.iridescenceMap,e(f.iridescenceMap,g.iridescenceMapTransform)),f.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=f.iridescenceThicknessMap,e(f.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),f.transmission>0&&(g.transmission.value=f.transmission,g.transmissionSamplerMap.value=b.texture,g.transmissionSamplerSize.value.set(b.width,b.height),f.transmissionMap&&(g.transmissionMap.value=f.transmissionMap,e(f.transmissionMap,g.transmissionMapTransform)),g.thickness.value=f.thickness,f.thicknessMap&&(g.thicknessMap.value=f.thicknessMap,e(f.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=f.attenuationDistance,g.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(g.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(g.anisotropyMap.value=f.anisotropyMap,e(f.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=f.specularIntensity,g.specularColor.value.copy(f.specularColor),f.specularColorMap&&(g.specularColorMap.value=f.specularColorMap,e(f.specularColorMap,g.specularColorMapTransform)),f.specularIntensityMap&&(g.specularIntensityMap.value=f.specularIntensityMap,e(f.specularIntensityMap,g.specularIntensityMapTransform))}function p(g,f){f.matcap&&(g.matcap.value=f.matcap)}function m(g,f){const b=t.get(f).light;g.referencePosition.value.setFromMatrixPosition(b.matrixWorld),g.nearDistance.value=b.shadow.camera.near,g.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:n}}function HI(r,t,e,i){let n={},s={},a=[];const o=r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS);function A(b,S){const v=S.program;i.uniformBlockBinding(b,v)}function l(b,S){let v=n[b.id];v===void 0&&(p(b),v=h(b),n[b.id]=v,b.addEventListener("dispose",g));const T=S.program;i.updateUBOMapping(b,T);const w=t.render.frame;s[b.id]!==w&&(u(b),s[b.id]=w)}function h(b){const S=c();b.__bindingPointIndex=S;const v=r.createBuffer(),T=b.__size,w=b.usage;return r.bindBuffer(r.UNIFORM_BUFFER,v),r.bufferData(r.UNIFORM_BUFFER,T,w),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,S,v),v}function c(){for(let b=0;b<o;b++)if(a.indexOf(b)===-1)return a.push(b),b;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(b){const S=n[b.id],v=b.uniforms,T=b.__cache;r.bindBuffer(r.UNIFORM_BUFFER,S);for(let w=0,R=v.length;w<R;w++){const P=Array.isArray(v[w])?v[w]:[v[w]];for(let E=0,x=P.length;E<x;E++){const M=P[E];if(d(M,w,E,T)===!0){const z=M.__offset,O=Array.isArray(M.value)?M.value:[M.value];let U=0;for(let W=0;W<O.length;W++){const Y=O[W],$=m(Y);typeof Y=="number"||typeof Y=="boolean"?(M.__data[0]=Y,r.bufferSubData(r.UNIFORM_BUFFER,z+U,M.__data)):Y.isMatrix3?(M.__data[0]=Y.elements[0],M.__data[1]=Y.elements[1],M.__data[2]=Y.elements[2],M.__data[3]=0,M.__data[4]=Y.elements[3],M.__data[5]=Y.elements[4],M.__data[6]=Y.elements[5],M.__data[7]=0,M.__data[8]=Y.elements[6],M.__data[9]=Y.elements[7],M.__data[10]=Y.elements[8],M.__data[11]=0):(Y.toArray(M.__data,U),U+=$.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(r.UNIFORM_BUFFER,z,M.__data)}}}r.bindBuffer(r.UNIFORM_BUFFER,null)}function d(b,S,v,T){const w=b.value,R=S+"_"+v;if(T[R]===void 0)return typeof w=="number"||typeof w=="boolean"?T[R]=w:T[R]=w.clone(),!0;{const P=T[R];if(typeof w=="number"||typeof w=="boolean"){if(P!==w)return T[R]=w,!0}else if(P.equals(w)===!1)return P.copy(w),!0}return!1}function p(b){const S=b.uniforms;let v=0;const T=16;for(let R=0,P=S.length;R<P;R++){const E=Array.isArray(S[R])?S[R]:[S[R]];for(let x=0,M=E.length;x<M;x++){const z=E[x],O=Array.isArray(z.value)?z.value:[z.value];for(let U=0,W=O.length;U<W;U++){const Y=O[U],$=m(Y),H=v%T,rt=H%$.boundary,At=H+rt;v+=rt,At!==0&&T-At<$.storage&&(v+=T-At),z.__data=new Float32Array($.storage/Float32Array.BYTES_PER_ELEMENT),z.__offset=v,v+=$.storage}}}const w=v%T;return w>0&&(v+=T-w),b.__size=v,b.__cache={},this}function m(b){const S={boundary:0,storage:0};return typeof b=="number"||typeof b=="boolean"?(S.boundary=4,S.storage=4):b.isVector2?(S.boundary=8,S.storage=8):b.isVector3||b.isColor?(S.boundary=16,S.storage=12):b.isVector4?(S.boundary=16,S.storage=16):b.isMatrix3?(S.boundary=48,S.storage=48):b.isMatrix4?(S.boundary=64,S.storage=64):b.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",b),S}function g(b){const S=b.target;S.removeEventListener("dispose",g);const v=a.indexOf(S.__bindingPointIndex);a.splice(v,1),r.deleteBuffer(n[S.id]),delete n[S.id],delete s[S.id]}function f(){for(const b in n)r.deleteBuffer(n[b]);a=[],n={},s={}}return{bind:A,update:l,dispose:f}}class hc{constructor(t={}){const{canvas:e=$d(),context:i=null,depth:n=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:A=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:c=!1,reversedDepthBuffer:u=!1}=t;this.isWebGLRenderer=!0;let d;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=i.getContextAttributes().alpha}else d=a;const p=new Uint32Array(4),m=new Int32Array(4);let g=null,f=null;const b=[],S=[];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.toneMapping=hn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const v=this;let T=!1;this._outputColorSpace=Pe;let w=0,R=0,P=null,E=-1,x=null;const M=new ce,z=new ce;let O=null;const U=new Vt(0);let W=0,Y=e.width,$=e.height,H=1,rt=null,At=null;const mt=new ce(0,0,Y,$),Bt=new ce(0,0,Y,$);let re=!1;const te=new pl;let J=!1,ot=!1;const nt=new de,Mt=new F,wt=new ce,Lt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let fe=!1;function Wt(){return P===null?H:1}let _=i;function ie(C,D){return e.getContext(C,D)}try{const C={alpha:!0,depth:n,stencil:s,antialias:o,premultipliedAlpha:A,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:c};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${Ja}`),e.addEventListener("webglcontextlost",st,!1),e.addEventListener("webglcontextrestored",dt,!1),e.addEventListener("webglcontextcreationerror",q,!1),_===null){const D="webgl2";if(_=ie(D,C),_===null)throw ie(D)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(C){throw console.error("THREE.WebGLRenderer: "+C.message),C}let yt,jt,Et,ae,ft,Ut,ye,ge,y,I,B,Z,Q,X,xt,it,It,Ct,tt,ct,Rt,vt,lt,Ft;function L(){yt=new $p(_),yt.init(),vt=new FI(_,yt),jt=new Xp(_,yt,t,vt),Et=new DI(_,yt),jt.reversedDepthBuffer&&u&&Et.buffers.depth.setReversed(!0),ae=new im(_),ft=new vI,Ut=new NI(_,yt,Et,ft,jt,vt,ae),ye=new Jp(v),ge=new Kp(v),y=new Hf(_),lt=new Wp(_,y),I=new tm(_,y,ae,lt),B=new sm(_,I,y,ae),tt=new nm(_,jt,Ut),it=new Zp(ft),Z=new CI(v,ye,ge,yt,jt,lt,it),Q=new GI(v,ft),X=new EI,xt=new TI(yt),Ct=new Vp(v,ye,ge,Et,B,d,A),It=new PI(v,B,jt),Ft=new HI(_,ae,jt,Et),ct=new Yp(_,yt,ae),Rt=new em(_,yt,ae),ae.programs=Z.programs,v.capabilities=jt,v.extensions=yt,v.properties=ft,v.renderLists=X,v.shadowMap=It,v.state=Et,v.info=ae}L();const et=new zI(v,_);this.xr=et,this.getContext=function(){return _},this.getContextAttributes=function(){return _.getContextAttributes()},this.forceContextLoss=function(){const C=yt.get("WEBGL_lose_context");C&&C.loseContext()},this.forceContextRestore=function(){const C=yt.get("WEBGL_lose_context");C&&C.restoreContext()},this.getPixelRatio=function(){return H},this.setPixelRatio=function(C){C!==void 0&&(H=C,this.setSize(Y,$,!1))},this.getSize=function(C){return C.set(Y,$)},this.setSize=function(C,D,k=!0){if(et.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}Y=C,$=D,e.width=Math.floor(C*H),e.height=Math.floor(D*H),k===!0&&(e.style.width=C+"px",e.style.height=D+"px"),this.setViewport(0,0,C,D)},this.getDrawingBufferSize=function(C){return C.set(Y*H,$*H).floor()},this.setDrawingBufferSize=function(C,D,k){Y=C,$=D,H=k,e.width=Math.floor(C*k),e.height=Math.floor(D*k),this.setViewport(0,0,C,D)},this.getCurrentViewport=function(C){return C.copy(M)},this.getViewport=function(C){return C.copy(mt)},this.setViewport=function(C,D,k,G){C.isVector4?mt.set(C.x,C.y,C.z,C.w):mt.set(C,D,k,G),Et.viewport(M.copy(mt).multiplyScalar(H).round())},this.getScissor=function(C){return C.copy(Bt)},this.setScissor=function(C,D,k,G){C.isVector4?Bt.set(C.x,C.y,C.z,C.w):Bt.set(C,D,k,G),Et.scissor(z.copy(Bt).multiplyScalar(H).round())},this.getScissorTest=function(){return re},this.setScissorTest=function(C){Et.setScissorTest(re=C)},this.setOpaqueSort=function(C){rt=C},this.setTransparentSort=function(C){At=C},this.getClearColor=function(C){return C.copy(Ct.getClearColor())},this.setClearColor=function(){Ct.setClearColor(...arguments)},this.getClearAlpha=function(){return Ct.getClearAlpha()},this.setClearAlpha=function(){Ct.setClearAlpha(...arguments)},this.clear=function(C=!0,D=!0,k=!0){let G=0;if(C){let N=!1;if(P!==null){const K=P.texture.format;N=K===go||K===fo||K===uo}if(N){const K=P.texture.type,ht=K===vi||K===Ln||K===qs||K===$s||K===ho||K===co,gt=Ct.getClearColor(),ut=Ct.getClearAlpha(),Tt=gt.r,Pt=gt.g,St=gt.b;ht?(p[0]=Tt,p[1]=Pt,p[2]=St,p[3]=ut,_.clearBufferuiv(_.COLOR,0,p)):(m[0]=Tt,m[1]=Pt,m[2]=St,m[3]=ut,_.clearBufferiv(_.COLOR,0,m))}else G|=_.COLOR_BUFFER_BIT}D&&(G|=_.DEPTH_BUFFER_BIT),k&&(G|=_.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),_.clear(G)},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",st,!1),e.removeEventListener("webglcontextrestored",dt,!1),e.removeEventListener("webglcontextcreationerror",q,!1),Ct.dispose(),X.dispose(),xt.dispose(),ft.dispose(),ye.dispose(),ge.dispose(),B.dispose(),lt.dispose(),Ft.dispose(),Z.dispose(),et.dispose(),et.removeEventListener("sessionstart",yi),et.removeEventListener("sessionend",gc),Yn.stop()};function st(C){C.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),T=!0}function dt(){console.log("THREE.WebGLRenderer: Context Restored."),T=!1;const C=ae.autoReset,D=It.enabled,k=It.autoUpdate,G=It.needsUpdate,N=It.type;L(),ae.autoReset=C,It.enabled=D,It.autoUpdate=k,It.needsUpdate=G,It.type=N}function q(C){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",C.statusMessage)}function j(C){const D=C.target;D.removeEventListener("dispose",j),pt(D)}function pt(C){Dt(C),ft.remove(C)}function Dt(C){const D=ft.get(C).programs;D!==void 0&&(D.forEach(function(k){Z.releaseProgram(k)}),C.isShaderMaterial&&Z.releaseShaderCache(C))}this.renderBufferDirect=function(C,D,k,G,N,K){D===null&&(D=Lt);const ht=N.isMesh&&N.matrixWorld.determinant()<0,gt=KI(C,D,k,G,N);Et.setMaterial(G,ht);let ut=k.index,Tt=1;if(G.wireframe===!0){if(ut=I.getWireframeAttribute(k),ut===void 0)return;Tt=2}const Pt=k.drawRange,St=k.attributes.position;let kt=Pt.start*Tt,$t=(Pt.start+Pt.count)*Tt;K!==null&&(kt=Math.max(kt,K.start*Tt),$t=Math.min($t,(K.start+K.count)*Tt)),ut!==null?(kt=Math.max(kt,0),$t=Math.min($t,ut.count)):St!=null&&(kt=Math.max(kt,0),$t=Math.min($t,St.count));const ue=$t-kt;if(ue<0||ue===1/0)return;lt.setup(N,G,gt,k,ut);let se,ee=ct;if(ut!==null&&(se=y.get(ut),ee=Rt,ee.setIndex(se)),N.isMesh)G.wireframe===!0?(Et.setLineWidth(G.wireframeLinewidth*Wt()),ee.setMode(_.LINES)):ee.setMode(_.TRIANGLES);else if(N.isLine){let bt=G.linewidth;bt===void 0&&(bt=1),Et.setLineWidth(bt*Wt()),N.isLineSegments?ee.setMode(_.LINES):N.isLineLoop?ee.setMode(_.LINE_LOOP):ee.setMode(_.LINE_STRIP)}else N.isPoints?ee.setMode(_.POINTS):N.isSprite&&ee.setMode(_.TRIANGLES);if(N.isBatchedMesh)if(N._multiDrawInstances!==null)gs("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),ee.renderMultiDrawInstances(N._multiDrawStarts,N._multiDrawCounts,N._multiDrawCount,N._multiDrawInstances);else if(yt.get("WEBGL_multi_draw"))ee.renderMultiDraw(N._multiDrawStarts,N._multiDrawCounts,N._multiDrawCount);else{const bt=N._multiDrawStarts,oe=N._multiDrawCounts,Zt=N._multiDrawCount,Je=ut?y.get(ut).bytesPerElement:1,Bs=ft.get(G).currentProgram.getUniforms();for(let je=0;je<Zt;je++)Bs.setValue(_,"_gl_DrawID",je),ee.render(bt[je]/Je,oe[je])}else if(N.isInstancedMesh)ee.renderInstances(kt,ue,N.count);else if(k.isInstancedBufferGeometry){const bt=k._maxInstanceCount!==void 0?k._maxInstanceCount:1/0,oe=Math.min(k.instanceCount,bt);ee.renderInstances(kt,ue,oe)}else ee.render(kt,ue)};function ne(C,D,k){C.transparent===!0&&C.side===Hi&&C.forceSinglePass===!1?(C.side=Ue,C.needsUpdate=!0,Ia(C,D,k),C.side=ln,C.needsUpdate=!0,Ia(C,D,k),C.side=Hi):Ia(C,D,k)}this.compile=function(C,D,k=null){k===null&&(k=C),f=xt.get(k),f.init(D),S.push(f),k.traverseVisible(function(N){N.isLight&&N.layers.test(D.layers)&&(f.pushLight(N),N.castShadow&&f.pushShadow(N))}),C!==k&&C.traverseVisible(function(N){N.isLight&&N.layers.test(D.layers)&&(f.pushLight(N),N.castShadow&&f.pushShadow(N))}),f.setupLights();const G=new Set;return C.traverse(function(N){if(!(N.isMesh||N.isPoints||N.isLine||N.isSprite))return;const K=N.material;if(K)if(Array.isArray(K))for(let ht=0;ht<K.length;ht++){const gt=K[ht];ne(gt,k,N),G.add(gt)}else ne(K,k,N),G.add(K)}),f=S.pop(),G},this.compileAsync=function(C,D,k=null){const G=this.compile(C,D,k);return new Promise(N=>{function K(){if(G.forEach(function(ht){ft.get(ht).currentProgram.isReady()&&G.delete(ht)}),G.size===0){N(C);return}setTimeout(K,10)}yt.get("KHR_parallel_shader_compile")!==null?K():setTimeout(K,10)})};let qt=null;function Qi(C){qt&&qt(C)}function yi(){Yn.stop()}function gc(){Yn.start()}const Yn=new Nh;Yn.setAnimationLoop(Qi),typeof self<"u"&&Yn.setContext(self),this.setAnimationLoop=function(C){qt=C,et.setAnimationLoop(C),C===null?Yn.stop():Yn.start()},et.addEventListener("sessionstart",yi),et.addEventListener("sessionend",gc),this.render=function(C,D){if(D!==void 0&&D.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(T===!0)return;if(C.matrixWorldAutoUpdate===!0&&C.updateMatrixWorld(),D.parent===null&&D.matrixWorldAutoUpdate===!0&&D.updateMatrixWorld(),et.enabled===!0&&et.isPresenting===!0&&(et.cameraAutoUpdate===!0&&et.updateCamera(D),D=et.getCamera()),C.isScene===!0&&C.onBeforeRender(v,C,D,P),f=xt.get(C,S.length),f.init(D),S.push(f),nt.multiplyMatrices(D.projectionMatrix,D.matrixWorldInverse),te.setFromProjectionMatrix(nt,xi,D.reversedDepth),ot=this.localClippingEnabled,J=it.init(this.clippingPlanes,ot),g=X.get(C,b.length),g.init(),b.push(g),et.enabled===!0&&et.isPresenting===!0){const K=v.xr.getDepthSensingMesh();K!==null&&Ll(K,D,-1/0,v.sortObjects)}Ll(C,D,0,v.sortObjects),g.finish(),v.sortObjects===!0&&g.sort(rt,At),fe=et.enabled===!1||et.isPresenting===!1||et.hasDepthSensing()===!1,fe&&Ct.addToRenderList(g,C),this.info.render.frame++,J===!0&&it.beginShadows();const k=f.state.shadowsArray;It.render(k,C,D),J===!0&&it.endShadows(),this.info.autoReset===!0&&this.info.reset();const G=g.opaque,N=g.transmissive;if(f.setupLights(),D.isArrayCamera){const K=D.cameras;if(N.length>0)for(let ht=0,gt=K.length;ht<gt;ht++){const ut=K[ht];mc(G,N,C,ut)}fe&&Ct.render(C);for(let ht=0,gt=K.length;ht<gt;ht++){const ut=K[ht];pc(g,C,ut,ut.viewport)}}else N.length>0&&mc(G,N,C,D),fe&&Ct.render(C),pc(g,C,D);P!==null&&R===0&&(Ut.updateMultisampleRenderTarget(P),Ut.updateRenderTargetMipmap(P)),C.isScene===!0&&C.onAfterRender(v,C,D),lt.resetDefaultState(),E=-1,x=null,S.pop(),S.length>0?(f=S[S.length-1],J===!0&&it.setGlobalState(v.clippingPlanes,f.state.camera)):f=null,b.pop(),b.length>0?g=b[b.length-1]:g=null};function Ll(C,D,k,G){if(C.visible===!1)return;if(C.layers.test(D.layers)){if(C.isGroup)k=C.renderOrder;else if(C.isLOD)C.autoUpdate===!0&&C.update(D);else if(C.isLight)f.pushLight(C),C.castShadow&&f.pushShadow(C);else if(C.isSprite){if(!C.frustumCulled||te.intersectsSprite(C)){G&&wt.setFromMatrixPosition(C.matrixWorld).applyMatrix4(nt);const ht=B.update(C),gt=C.material;gt.visible&&g.push(C,ht,gt,k,wt.z,null)}}else if((C.isMesh||C.isLine||C.isPoints)&&(!C.frustumCulled||te.intersectsObject(C))){const ht=B.update(C),gt=C.material;if(G&&(C.boundingSphere!==void 0?(C.boundingSphere===null&&C.computeBoundingSphere(),wt.copy(C.boundingSphere.center)):(ht.boundingSphere===null&&ht.computeBoundingSphere(),wt.copy(ht.boundingSphere.center)),wt.applyMatrix4(C.matrixWorld).applyMatrix4(nt)),Array.isArray(gt)){const ut=ht.groups;for(let Tt=0,Pt=ut.length;Tt<Pt;Tt++){const St=ut[Tt],kt=gt[St.materialIndex];kt&&kt.visible&&g.push(C,ht,kt,k,wt.z,St)}}else gt.visible&&g.push(C,ht,gt,k,wt.z,null)}}const K=C.children;for(let ht=0,gt=K.length;ht<gt;ht++)Ll(K[ht],D,k,G)}function pc(C,D,k,G){const N=C.opaque,K=C.transmissive,ht=C.transparent;f.setupLightsView(k),J===!0&&it.setGlobalState(v.clippingPlanes,k),G&&Et.viewport(M.copy(G)),N.length>0&&ma(N,D,k),K.length>0&&ma(K,D,k),ht.length>0&&ma(ht,D,k),Et.buffers.depth.setTest(!0),Et.buffers.depth.setMask(!0),Et.buffers.color.setMask(!0),Et.setPolygonOffset(!1)}function mc(C,D,k,G){if((k.isScene===!0?k.overrideMaterial:null)!==null)return;f.state.transmissionRenderTarget[G.id]===void 0&&(f.state.transmissionRenderTarget[G.id]=new Dn(1,1,{generateMipmaps:!0,type:yt.has("EXT_color_buffer_half_float")||yt.has("EXT_color_buffer_float")?Ks:vi,minFilter:Pn,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Xt.workingColorSpace}));const K=f.state.transmissionRenderTarget[G.id],ht=G.viewport||M;K.setSize(ht.z*v.transmissionResolutionScale,ht.w*v.transmissionResolutionScale);const gt=v.getRenderTarget(),ut=v.getActiveCubeFace(),Tt=v.getActiveMipmapLevel();v.setRenderTarget(K),v.getClearColor(U),W=v.getClearAlpha(),W<1&&v.setClearColor(16777215,.5),v.clear(),fe&&Ct.render(k);const Pt=v.toneMapping;v.toneMapping=hn;const St=G.viewport;if(G.viewport!==void 0&&(G.viewport=void 0),f.setupLightsView(G),J===!0&&it.setGlobalState(v.clippingPlanes,G),ma(C,k,G),Ut.updateMultisampleRenderTarget(K),Ut.updateRenderTargetMipmap(K),yt.has("WEBGL_multisampled_render_to_texture")===!1){let kt=!1;for(let $t=0,ue=D.length;$t<ue;$t++){const se=D[$t],ee=se.object,bt=se.geometry,oe=se.material,Zt=se.group;if(oe.side===Hi&&ee.layers.test(G.layers)){const Je=oe.side;oe.side=Ue,oe.needsUpdate=!0,Ic(ee,k,G,bt,oe,Zt),oe.side=Je,oe.needsUpdate=!0,kt=!0}}kt===!0&&(Ut.updateMultisampleRenderTarget(K),Ut.updateRenderTargetMipmap(K))}v.setRenderTarget(gt,ut,Tt),v.setClearColor(U,W),St!==void 0&&(G.viewport=St),v.toneMapping=Pt}function ma(C,D,k){const G=D.isScene===!0?D.overrideMaterial:null;for(let N=0,K=C.length;N<K;N++){const ht=C[N],gt=ht.object,ut=ht.geometry,Tt=ht.group;let Pt=ht.material;Pt.allowOverride===!0&&G!==null&&(Pt=G),gt.layers.test(k.layers)&&Ic(gt,D,k,ut,Pt,Tt)}}function Ic(C,D,k,G,N,K){C.onBeforeRender(v,D,k,G,N,K),C.modelViewMatrix.multiplyMatrices(k.matrixWorldInverse,C.matrixWorld),C.normalMatrix.getNormalMatrix(C.modelViewMatrix),N.onBeforeRender(v,D,k,G,C,K),N.transparent===!0&&N.side===Hi&&N.forceSinglePass===!1?(N.side=Ue,N.needsUpdate=!0,v.renderBufferDirect(k,D,G,N,C,K),N.side=ln,N.needsUpdate=!0,v.renderBufferDirect(k,D,G,N,C,K),N.side=Hi):v.renderBufferDirect(k,D,G,N,C,K),C.onAfterRender(v,D,k,G,N,K)}function Ia(C,D,k){D.isScene!==!0&&(D=Lt);const G=ft.get(C),N=f.state.lights,K=f.state.shadowsArray,ht=N.state.version,gt=Z.getParameters(C,N.state,K,D,k),ut=Z.getProgramCacheKey(gt);let Tt=G.programs;G.environment=C.isMeshStandardMaterial?D.environment:null,G.fog=D.fog,G.envMap=(C.isMeshStandardMaterial?ge:ye).get(C.envMap||G.environment),G.envMapRotation=G.environment!==null&&C.envMap===null?D.environmentRotation:C.envMapRotation,Tt===void 0&&(C.addEventListener("dispose",j),Tt=new Map,G.programs=Tt);let Pt=Tt.get(ut);if(Pt!==void 0){if(G.currentProgram===Pt&&G.lightsStateVersion===ht)return vc(C,gt),Pt}else gt.uniforms=Z.getUniforms(C),C.onBeforeCompile(gt,v),Pt=Z.acquireProgram(gt,ut),Tt.set(ut,Pt),G.uniforms=gt.uniforms;const St=G.uniforms;return(!C.isShaderMaterial&&!C.isRawShaderMaterial||C.clipping===!0)&&(St.clippingPlanes=it.uniform),vc(C,gt),G.needsLights=tC(C),G.lightsStateVersion=ht,G.needsLights&&(St.ambientLightColor.value=N.state.ambient,St.lightProbe.value=N.state.probe,St.directionalLights.value=N.state.directional,St.directionalLightShadows.value=N.state.directionalShadow,St.spotLights.value=N.state.spot,St.spotLightShadows.value=N.state.spotShadow,St.rectAreaLights.value=N.state.rectArea,St.ltc_1.value=N.state.rectAreaLTC1,St.ltc_2.value=N.state.rectAreaLTC2,St.pointLights.value=N.state.point,St.pointLightShadows.value=N.state.pointShadow,St.hemisphereLights.value=N.state.hemi,St.directionalShadowMap.value=N.state.directionalShadowMap,St.directionalShadowMatrix.value=N.state.directionalShadowMatrix,St.spotShadowMap.value=N.state.spotShadowMap,St.spotLightMatrix.value=N.state.spotLightMatrix,St.spotLightMap.value=N.state.spotLightMap,St.pointShadowMap.value=N.state.pointShadowMap,St.pointShadowMatrix.value=N.state.pointShadowMatrix),G.currentProgram=Pt,G.uniformsList=null,Pt}function Cc(C){if(C.uniformsList===null){const D=C.currentProgram.getUniforms();C.uniformsList=ua.seqWithValue(D.seq,C.uniforms)}return C.uniformsList}function vc(C,D){const k=ft.get(C);k.outputColorSpace=D.outputColorSpace,k.batching=D.batching,k.batchingColor=D.batchingColor,k.instancing=D.instancing,k.instancingColor=D.instancingColor,k.instancingMorph=D.instancingMorph,k.skinning=D.skinning,k.morphTargets=D.morphTargets,k.morphNormals=D.morphNormals,k.morphColors=D.morphColors,k.morphTargetsCount=D.morphTargetsCount,k.numClippingPlanes=D.numClippingPlanes,k.numIntersection=D.numClipIntersection,k.vertexAlphas=D.vertexAlphas,k.vertexTangents=D.vertexTangents,k.toneMapping=D.toneMapping}function KI(C,D,k,G,N){D.isScene!==!0&&(D=Lt),Ut.resetTextureUnits();const K=D.fog,ht=G.isMeshStandardMaterial?D.environment:null,gt=P===null?v.outputColorSpace:P.isXRRenderTarget===!0?P.texture.colorSpace:cs,ut=(G.isMeshStandardMaterial?ge:ye).get(G.envMap||ht),Tt=G.vertexColors===!0&&!!k.attributes.color&&k.attributes.color.itemSize===4,Pt=!!k.attributes.tangent&&(!!G.normalMap||G.anisotropy>0),St=!!k.morphAttributes.position,kt=!!k.morphAttributes.normal,$t=!!k.morphAttributes.color;let ue=hn;G.toneMapped&&(P===null||P.isXRRenderTarget===!0)&&(ue=v.toneMapping);const se=k.morphAttributes.position||k.morphAttributes.normal||k.morphAttributes.color,ee=se!==void 0?se.length:0,bt=ft.get(G),oe=f.state.lights;if(J===!0&&(ot===!0||C!==x)){const De=C===x&&G.id===E;it.setState(G,C,De)}let Zt=!1;G.version===bt.__version?(bt.needsLights&&bt.lightsStateVersion!==oe.state.version||bt.outputColorSpace!==gt||N.isBatchedMesh&&bt.batching===!1||!N.isBatchedMesh&&bt.batching===!0||N.isBatchedMesh&&bt.batchingColor===!0&&N.colorTexture===null||N.isBatchedMesh&&bt.batchingColor===!1&&N.colorTexture!==null||N.isInstancedMesh&&bt.instancing===!1||!N.isInstancedMesh&&bt.instancing===!0||N.isSkinnedMesh&&bt.skinning===!1||!N.isSkinnedMesh&&bt.skinning===!0||N.isInstancedMesh&&bt.instancingColor===!0&&N.instanceColor===null||N.isInstancedMesh&&bt.instancingColor===!1&&N.instanceColor!==null||N.isInstancedMesh&&bt.instancingMorph===!0&&N.morphTexture===null||N.isInstancedMesh&&bt.instancingMorph===!1&&N.morphTexture!==null||bt.envMap!==ut||G.fog===!0&&bt.fog!==K||bt.numClippingPlanes!==void 0&&(bt.numClippingPlanes!==it.numPlanes||bt.numIntersection!==it.numIntersection)||bt.vertexAlphas!==Tt||bt.vertexTangents!==Pt||bt.morphTargets!==St||bt.morphNormals!==kt||bt.morphColors!==$t||bt.toneMapping!==ue||bt.morphTargetsCount!==ee)&&(Zt=!0):(Zt=!0,bt.__version=G.version);let Je=bt.currentProgram;Zt===!0&&(Je=Ia(G,D,N));let Bs=!1,je=!1,dr=!1;const le=Je.getUniforms(),ti=bt.uniforms;if(Et.useProgram(Je.program)&&(Bs=!0,je=!0,dr=!0),G.id!==E&&(E=G.id,je=!0),Bs||x!==C){Et.buffers.depth.getReversed()&&C.reversedDepth!==!0&&(C._reversedDepth=!0,C.updateProjectionMatrix()),le.setValue(_,"projectionMatrix",C.projectionMatrix),le.setValue(_,"viewMatrix",C.matrixWorldInverse);const Ge=le.map.cameraPosition;Ge!==void 0&&Ge.setValue(_,Mt.setFromMatrixPosition(C.matrixWorld)),jt.logarithmicDepthBuffer&&le.setValue(_,"logDepthBufFC",2/(Math.log(C.far+1)/Math.LN2)),(G.isMeshPhongMaterial||G.isMeshToonMaterial||G.isMeshLambertMaterial||G.isMeshBasicMaterial||G.isMeshStandardMaterial||G.isShaderMaterial)&&le.setValue(_,"isOrthographic",C.isOrthographicCamera===!0),x!==C&&(x=C,je=!0,dr=!0)}if(N.isSkinnedMesh){le.setOptional(_,N,"bindMatrix"),le.setOptional(_,N,"bindMatrixInverse");const De=N.skeleton;De&&(De.boneTexture===null&&De.computeBoneTexture(),le.setValue(_,"boneTexture",De.boneTexture,Ut))}N.isBatchedMesh&&(le.setOptional(_,N,"batchingTexture"),le.setValue(_,"batchingTexture",N._matricesTexture,Ut),le.setOptional(_,N,"batchingIdTexture"),le.setValue(_,"batchingIdTexture",N._indirectTexture,Ut),le.setOptional(_,N,"batchingColorTexture"),N._colorsTexture!==null&&le.setValue(_,"batchingColorTexture",N._colorsTexture,Ut));const ei=k.morphAttributes;if((ei.position!==void 0||ei.normal!==void 0||ei.color!==void 0)&&tt.update(N,k,Je),(je||bt.receiveShadow!==N.receiveShadow)&&(bt.receiveShadow=N.receiveShadow,le.setValue(_,"receiveShadow",N.receiveShadow)),G.isMeshGouraudMaterial&&G.envMap!==null&&(ti.envMap.value=ut,ti.flipEnvMap.value=ut.isCubeTexture&&ut.isRenderTargetTexture===!1?-1:1),G.isMeshStandardMaterial&&G.envMap===null&&D.environment!==null&&(ti.envMapIntensity.value=D.environmentIntensity),je&&(le.setValue(_,"toneMappingExposure",v.toneMappingExposure),bt.needsLights&&$I(ti,dr),K&&G.fog===!0&&Q.refreshFogUniforms(ti,K),Q.refreshMaterialUniforms(ti,G,H,$,f.state.transmissionRenderTarget[C.id]),ua.upload(_,Cc(bt),ti,Ut)),G.isShaderMaterial&&G.uniformsNeedUpdate===!0&&(ua.upload(_,Cc(bt),ti,Ut),G.uniformsNeedUpdate=!1),G.isSpriteMaterial&&le.setValue(_,"center",N.center),le.setValue(_,"modelViewMatrix",N.modelViewMatrix),le.setValue(_,"normalMatrix",N.normalMatrix),le.setValue(_,"modelMatrix",N.matrixWorld),G.isShaderMaterial||G.isRawShaderMaterial){const De=G.uniformsGroups;for(let Ge=0,Dl=De.length;Ge<Dl;Ge++){const Xn=De[Ge];Ft.update(Xn,Je),Ft.bind(Xn,Je)}}return Je}function $I(C,D){C.ambientLightColor.needsUpdate=D,C.lightProbe.needsUpdate=D,C.directionalLights.needsUpdate=D,C.directionalLightShadows.needsUpdate=D,C.pointLights.needsUpdate=D,C.pointLightShadows.needsUpdate=D,C.spotLights.needsUpdate=D,C.spotLightShadows.needsUpdate=D,C.rectAreaLights.needsUpdate=D,C.hemisphereLights.needsUpdate=D}function tC(C){return C.isMeshLambertMaterial||C.isMeshToonMaterial||C.isMeshPhongMaterial||C.isMeshStandardMaterial||C.isShadowMaterial||C.isShaderMaterial&&C.lights===!0}this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return R},this.getRenderTarget=function(){return P},this.setRenderTargetTextures=function(C,D,k){const G=ft.get(C);G.__autoAllocateDepthBuffer=C.resolveDepthBuffer===!1,G.__autoAllocateDepthBuffer===!1&&(G.__useRenderToTexture=!1),ft.get(C.texture).__webglTexture=D,ft.get(C.depthTexture).__webglTexture=G.__autoAllocateDepthBuffer?void 0:k,G.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(C,D){const k=ft.get(C);k.__webglFramebuffer=D,k.__useDefaultFramebuffer=D===void 0};const eC=_.createFramebuffer();this.setRenderTarget=function(C,D=0,k=0){P=C,w=D,R=k;let G=!0,N=null,K=!1,ht=!1;if(C){const ut=ft.get(C);if(ut.__useDefaultFramebuffer!==void 0)Et.bindFramebuffer(_.FRAMEBUFFER,null),G=!1;else if(ut.__webglFramebuffer===void 0)Ut.setupRenderTarget(C);else if(ut.__hasExternalTextures)Ut.rebindTextures(C,ft.get(C.texture).__webglTexture,ft.get(C.depthTexture).__webglTexture);else if(C.depthBuffer){const St=C.depthTexture;if(ut.__boundDepthTexture!==St){if(St!==null&&ft.has(St)&&(C.width!==St.image.width||C.height!==St.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Ut.setupDepthRenderbuffer(C)}}const Tt=C.texture;(Tt.isData3DTexture||Tt.isDataArrayTexture||Tt.isCompressedArrayTexture)&&(ht=!0);const Pt=ft.get(C).__webglFramebuffer;C.isWebGLCubeRenderTarget?(Array.isArray(Pt[D])?N=Pt[D][k]:N=Pt[D],K=!0):C.samples>0&&Ut.useMultisampledRTT(C)===!1?N=ft.get(C).__webglMultisampledFramebuffer:Array.isArray(Pt)?N=Pt[k]:N=Pt,M.copy(C.viewport),z.copy(C.scissor),O=C.scissorTest}else M.copy(mt).multiplyScalar(H).floor(),z.copy(Bt).multiplyScalar(H).floor(),O=re;if(k!==0&&(N=eC),Et.bindFramebuffer(_.FRAMEBUFFER,N)&&G&&Et.drawBuffers(C,N),Et.viewport(M),Et.scissor(z),Et.setScissorTest(O),K){const ut=ft.get(C.texture);_.framebufferTexture2D(_.FRAMEBUFFER,_.COLOR_ATTACHMENT0,_.TEXTURE_CUBE_MAP_POSITIVE_X+D,ut.__webglTexture,k)}else if(ht){const ut=D;for(let Tt=0;Tt<C.textures.length;Tt++){const Pt=ft.get(C.textures[Tt]);_.framebufferTextureLayer(_.FRAMEBUFFER,_.COLOR_ATTACHMENT0+Tt,Pt.__webglTexture,k,ut)}}else if(C!==null&&k!==0){const ut=ft.get(C.texture);_.framebufferTexture2D(_.FRAMEBUFFER,_.COLOR_ATTACHMENT0,_.TEXTURE_2D,ut.__webglTexture,k)}E=-1},this.readRenderTargetPixels=function(C,D,k,G,N,K,ht,gt=0){if(!(C&&C.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ut=ft.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&ht!==void 0&&(ut=ut[ht]),ut){Et.bindFramebuffer(_.FRAMEBUFFER,ut);try{const Tt=C.textures[gt],Pt=Tt.format,St=Tt.type;if(!jt.textureFormatReadable(Pt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!jt.textureTypeReadable(St)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}D>=0&&D<=C.width-G&&k>=0&&k<=C.height-N&&(C.textures.length>1&&_.readBuffer(_.COLOR_ATTACHMENT0+gt),_.readPixels(D,k,G,N,vt.convert(Pt),vt.convert(St),K))}finally{const Tt=P!==null?ft.get(P).__webglFramebuffer:null;Et.bindFramebuffer(_.FRAMEBUFFER,Tt)}}},this.readRenderTargetPixelsAsync=async function(C,D,k,G,N,K,ht,gt=0){if(!(C&&C.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ut=ft.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&ht!==void 0&&(ut=ut[ht]),ut)if(D>=0&&D<=C.width-G&&k>=0&&k<=C.height-N){Et.bindFramebuffer(_.FRAMEBUFFER,ut);const Tt=C.textures[gt],Pt=Tt.format,St=Tt.type;if(!jt.textureFormatReadable(Pt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!jt.textureTypeReadable(St))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const kt=_.createBuffer();_.bindBuffer(_.PIXEL_PACK_BUFFER,kt),_.bufferData(_.PIXEL_PACK_BUFFER,K.byteLength,_.STREAM_READ),C.textures.length>1&&_.readBuffer(_.COLOR_ATTACHMENT0+gt),_.readPixels(D,k,G,N,vt.convert(Pt),vt.convert(St),0);const $t=P!==null?ft.get(P).__webglFramebuffer:null;Et.bindFramebuffer(_.FRAMEBUFFER,$t);const ue=_.fenceSync(_.SYNC_GPU_COMMANDS_COMPLETE,0);return _.flush(),await tf(_,ue,4),_.bindBuffer(_.PIXEL_PACK_BUFFER,kt),_.getBufferSubData(_.PIXEL_PACK_BUFFER,0,K),_.deleteBuffer(kt),_.deleteSync(ue),K}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(C,D=null,k=0){const G=Math.pow(2,-k),N=Math.floor(C.image.width*G),K=Math.floor(C.image.height*G),ht=D!==null?D.x:0,gt=D!==null?D.y:0;Ut.setTexture2D(C,0),_.copyTexSubImage2D(_.TEXTURE_2D,k,0,0,ht,gt,N,K),Et.unbindTexture()};const iC=_.createFramebuffer(),nC=_.createFramebuffer();this.copyTextureToTexture=function(C,D,k=null,G=null,N=0,K=null){K===null&&(N!==0?(gs("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),K=N,N=0):K=0);let ht,gt,ut,Tt,Pt,St,kt,$t,ue;const se=C.isCompressedTexture?C.mipmaps[K]:C.image;if(k!==null)ht=k.max.x-k.min.x,gt=k.max.y-k.min.y,ut=k.isBox3?k.max.z-k.min.z:1,Tt=k.min.x,Pt=k.min.y,St=k.isBox3?k.min.z:0;else{const ei=Math.pow(2,-N);ht=Math.floor(se.width*ei),gt=Math.floor(se.height*ei),C.isDataArrayTexture?ut=se.depth:C.isData3DTexture?ut=Math.floor(se.depth*ei):ut=1,Tt=0,Pt=0,St=0}G!==null?(kt=G.x,$t=G.y,ue=G.z):(kt=0,$t=0,ue=0);const ee=vt.convert(D.format),bt=vt.convert(D.type);let oe;D.isData3DTexture?(Ut.setTexture3D(D,0),oe=_.TEXTURE_3D):D.isDataArrayTexture||D.isCompressedArrayTexture?(Ut.setTexture2DArray(D,0),oe=_.TEXTURE_2D_ARRAY):(Ut.setTexture2D(D,0),oe=_.TEXTURE_2D),_.pixelStorei(_.UNPACK_FLIP_Y_WEBGL,D.flipY),_.pixelStorei(_.UNPACK_PREMULTIPLY_ALPHA_WEBGL,D.premultiplyAlpha),_.pixelStorei(_.UNPACK_ALIGNMENT,D.unpackAlignment);const Zt=_.getParameter(_.UNPACK_ROW_LENGTH),Je=_.getParameter(_.UNPACK_IMAGE_HEIGHT),Bs=_.getParameter(_.UNPACK_SKIP_PIXELS),je=_.getParameter(_.UNPACK_SKIP_ROWS),dr=_.getParameter(_.UNPACK_SKIP_IMAGES);_.pixelStorei(_.UNPACK_ROW_LENGTH,se.width),_.pixelStorei(_.UNPACK_IMAGE_HEIGHT,se.height),_.pixelStorei(_.UNPACK_SKIP_PIXELS,Tt),_.pixelStorei(_.UNPACK_SKIP_ROWS,Pt),_.pixelStorei(_.UNPACK_SKIP_IMAGES,St);const le=C.isDataArrayTexture||C.isData3DTexture,ti=D.isDataArrayTexture||D.isData3DTexture;if(C.isDepthTexture){const ei=ft.get(C),De=ft.get(D),Ge=ft.get(ei.__renderTarget),Dl=ft.get(De.__renderTarget);Et.bindFramebuffer(_.READ_FRAMEBUFFER,Ge.__webglFramebuffer),Et.bindFramebuffer(_.DRAW_FRAMEBUFFER,Dl.__webglFramebuffer);for(let Xn=0;Xn<ut;Xn++)le&&(_.framebufferTextureLayer(_.READ_FRAMEBUFFER,_.COLOR_ATTACHMENT0,ft.get(C).__webglTexture,N,St+Xn),_.framebufferTextureLayer(_.DRAW_FRAMEBUFFER,_.COLOR_ATTACHMENT0,ft.get(D).__webglTexture,K,ue+Xn)),_.blitFramebuffer(Tt,Pt,ht,gt,kt,$t,ht,gt,_.DEPTH_BUFFER_BIT,_.NEAREST);Et.bindFramebuffer(_.READ_FRAMEBUFFER,null),Et.bindFramebuffer(_.DRAW_FRAMEBUFFER,null)}else if(N!==0||C.isRenderTargetTexture||ft.has(C)){const ei=ft.get(C),De=ft.get(D);Et.bindFramebuffer(_.READ_FRAMEBUFFER,iC),Et.bindFramebuffer(_.DRAW_FRAMEBUFFER,nC);for(let Ge=0;Ge<ut;Ge++)le?_.framebufferTextureLayer(_.READ_FRAMEBUFFER,_.COLOR_ATTACHMENT0,ei.__webglTexture,N,St+Ge):_.framebufferTexture2D(_.READ_FRAMEBUFFER,_.COLOR_ATTACHMENT0,_.TEXTURE_2D,ei.__webglTexture,N),ti?_.framebufferTextureLayer(_.DRAW_FRAMEBUFFER,_.COLOR_ATTACHMENT0,De.__webglTexture,K,ue+Ge):_.framebufferTexture2D(_.DRAW_FRAMEBUFFER,_.COLOR_ATTACHMENT0,_.TEXTURE_2D,De.__webglTexture,K),N!==0?_.blitFramebuffer(Tt,Pt,ht,gt,kt,$t,ht,gt,_.COLOR_BUFFER_BIT,_.NEAREST):ti?_.copyTexSubImage3D(oe,K,kt,$t,ue+Ge,Tt,Pt,ht,gt):_.copyTexSubImage2D(oe,K,kt,$t,Tt,Pt,ht,gt);Et.bindFramebuffer(_.READ_FRAMEBUFFER,null),Et.bindFramebuffer(_.DRAW_FRAMEBUFFER,null)}else ti?C.isDataTexture||C.isData3DTexture?_.texSubImage3D(oe,K,kt,$t,ue,ht,gt,ut,ee,bt,se.data):D.isCompressedArrayTexture?_.compressedTexSubImage3D(oe,K,kt,$t,ue,ht,gt,ut,ee,se.data):_.texSubImage3D(oe,K,kt,$t,ue,ht,gt,ut,ee,bt,se):C.isDataTexture?_.texSubImage2D(_.TEXTURE_2D,K,kt,$t,ht,gt,ee,bt,se.data):C.isCompressedTexture?_.compressedTexSubImage2D(_.TEXTURE_2D,K,kt,$t,se.width,se.height,ee,se.data):_.texSubImage2D(_.TEXTURE_2D,K,kt,$t,ht,gt,ee,bt,se);_.pixelStorei(_.UNPACK_ROW_LENGTH,Zt),_.pixelStorei(_.UNPACK_IMAGE_HEIGHT,Je),_.pixelStorei(_.UNPACK_SKIP_PIXELS,Bs),_.pixelStorei(_.UNPACK_SKIP_ROWS,je),_.pixelStorei(_.UNPACK_SKIP_IMAGES,dr),K===0&&D.generateMipmaps&&_.generateMipmap(oe),Et.unbindTexture()},this.copyTextureToTexture3D=function(C,D,k=null,G=null,N=0){return gs('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(C,D,k,G,N)},this.initRenderTarget=function(C){ft.get(C).__webglFramebuffer===void 0&&Ut.setupRenderTarget(C)},this.initTexture=function(C){C.isCubeTexture?Ut.setTextureCube(C,0):C.isData3DTexture?Ut.setTexture3D(C,0):C.isDataArrayTexture||C.isCompressedArrayTexture?Ut.setTexture2DArray(C,0):Ut.setTexture2D(C,0),Et.unbindTexture()},this.resetState=function(){w=0,R=0,P=null,Et.reset(),lt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return xi}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=Xt._getDrawingBufferColorSpace(t),e.unpackColorSpace=Xt._getUnpackColorSpace()}}const cc={LANGUAGE_CHANGE_CONFIRMED:Ca.LANGUAGE_CHANGE_CONFIRMED},VI=new Set([Qt.ENGLISH_UNITED_KINGDOM]),Rl={selected:Qt.ENGLISH_UNITED_KINGDOM,options:VI},fa={OPTIONS:"languages",SELECTED:"selected"},WI=`<section class="root">
3956
3956
  <canvas></canvas>
3957
3957
  <section class="menu-container">
3958
3958
  <bar-menu visibleButtons="1" cyclicalNavigation="true"></bar-menu>
@@ -3966,13 +3966,6 @@ void main() {
3966
3966
  <canvas></canvas>
3967
3967
  <section class="preview-dialog-container">
3968
3968
  <header-body-footer-dialog class="preview-dialog">
3969
- <section slot="header" class="header">
3970
- <div class="title">Pick your theme</div>
3971
- <span class="subtitle">
3972
- Rotate to preview, then apply to confirm your pick. Six themes, one
3973
- cube... pick yours!
3974
- </span>
3975
- </section>
3976
3969
  <section slot="body" class="body">
3977
3970
  <div class="preview-title title"></div>
3978
3971
  <div class="preview-sub subtitle"></div>
@@ -3985,4 +3978,4 @@ void main() {
3985
3978
  </section>
3986
3979
  <confirmation-dialog id="confirmation-dialog"></confirmation-dialog>
3987
3980
  </section>
3988
- `,jI="*{box-sizing:border-box}:host{display:block;width:100%;height:100%}.root{position:relative;width:100%;height:100%;overflow:hidden}canvas{width:100%;height:100%;display:block;touch-action:none;cursor:grab}canvas.dragging{cursor:grabbing}.preview-dialog-container{position:absolute;bottom:5%;left:50%;width:30%;transform:translate(-50%)}.preview-dialog-container .preview-dialog::part(dialog){position:relative}.preview-dialog-container .preview-dialog .title{font-size:16px;font-weight:700;letter-spacing:.01em}.preview-dialog-container .preview-dialog .subtitle{font-size:12px;opacity:.75}.preview-dialog-container .preview-dialog .footer{display:flex;justify-content:flex-end}@media(max-width:768px){.preview-dialog-container{width:90%}}",fc=new CSSStyleSheet;fc.replaceSync(jI);const QI=3;class Os extends HTMLElement{static textureLoader=new Mh;shadowRoot;static get observedAttributes(){return Object.values(pa)}static CUBE_SIDE_LENGTH=2;options=Pl.options;selected=Pl.selected;selectedTmp=Pl.selected;_renderer;_scene;_camera;_root;_canvas;_resizeObserver;_clock=new Lh;_lastTime=0;_cube;_cubeGeometry;_cubeMaterials=[];_animationFrameId=0;previewDialog=null;_previewTitle;_previewSub;_applyBtn;_confirmationDialog;_isConfirmationDialogOpen=!1;_themeTextures={};_currentFaceThemeId;_isDragging=!1;_lastPointerX=0;_lastPointerY=0;_dragPointerId=null;_rotX=.24;_rotY=.45;_rotZ=0;_idleSeconds=0;_autoSpinEnabled=!1;_autoVelX=0;_autoVelY=0;_isInitialized=!1;_isInitializing=!1;_tmpCamDir=new F;_tmpWorldNormal=new F;constructor(){super(),this.shadowRoot=this.attachShadow({mode:"open"}),this.shadowRoot.adoptedStyleSheets.push(fc)}attributeChangedCallback(t,e,i){if(!(e===i||i==null))switch(t){case pa.OPTIONS:{const n=JSON.parse(i);this.init(new Set(n))}break;case pa.SELECTED:{const n=i;this.select(n)}break}}connectedCallback(){this._isInitialized&&this._animationFrameId===0&&(this._clock.start(),this._animationFrameId=requestAnimationFrame(this._animate))}disconnectedCallback(){cancelAnimationFrame(this._animationFrameId),this._animationFrameId=0,this._unbindEvents(),this._cubeMaterials.forEach(t=>{t.map?.dispose(),t.dispose()}),this._cubeMaterials=[],this._cubeGeometry!=null&&this._cubeGeometry.dispose(),this._scene!=null&&this._scene.clear(),this._renderer!=null&&this._renderer.dispose(),this._resizeObserver!=null&&this._resizeObserver.disconnect(),this._confirmationDialog?.removeEventListener($i.COMPONENT_CUSTOM_MESSAGES.CONFIRMATION_DIALOG_CONFIRM,this._handleConfirmation),this._confirmationDialog?.removeEventListener($i.COMPONENT_CUSTOM_MESSAGES.CONFIRMATION_DIALOG_UNDO,this._handleConfirmationCancel),this.selected!==this.selectedTmp&&Fl(this.selected)}init(t){if(!(this._isInitialized||this._isInitializing)){if(this.options=t,this.options.size===0){console.warn(`${this.constructor.name}: No themes provided`);return}this._isInitializing=!0,this.setupHtmlElements(),this.setupScene(),this.setupUI(),this.setupCube(),this.setupConfirmationDialog(),this.setupApplyButton(),this._bindEvents(),this._isInitialized=!0,this._isInitializing=!1,this._updatePreviewDialog(this.selected),this._syncRotationToSelected(),this._updatePanelPosition(),this.isConnected&&this._animationFrameId===0&&(this._clock.start(),this._animationFrameId=requestAnimationFrame(this._animate))}}setupHtmlElements(){this.shadowRoot.innerHTML=JI,this._root=this.shadowRoot.querySelector(".root")??(()=>{throw new Error(`${this.constructor.name}: root element not found`)})(),this._canvas=this.shadowRoot.querySelector(Nl.CANVAS)??(()=>{throw new Error(`${this.constructor.name}: canvas element not found`)})(),this._confirmationDialog=this.shadowRoot.querySelector($i.selector)??(()=>{throw new Error(`${this.constructor.name}: confirmation-dialog element not found`)})()}setupScene(){const t=this._root.clientWidth!==0?this._root.clientWidth:800,e=this._root.clientHeight!==0?this._root.clientHeight:600;this._renderer=new hc({canvas:this._canvas,antialias:!0,alpha:!0}),this._renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this._renderer.setSize(t,e,!1),this._renderer.setClearColor(0,0),this._scene=new Sh,this._scene.background=new Vt(1710618),this._camera=new ke(44,t/e,.1,100),this._updateCameraForLayout(),this._camera.lookAt(0,0,0),this.resizeHandler()}setupUI(){this.previewDialog=this.shadowRoot.querySelector(".preview-dialog"),this.previewDialog!=null&&setTimeout(()=>{this.previewDialog?.show()}),this._previewTitle=this.shadowRoot.querySelector(".preview-title")??(()=>{throw new Error(`${this.constructor.name}: .preview-title not found`)})(),this._previewSub=this.shadowRoot.querySelector(".preview-sub")??(()=>{throw new Error(`${this.constructor.name}: .preview-sub not found`)})(),this._applyBtn=this.shadowRoot.querySelector(".apply-btn")??(()=>{throw new Error(`${this.constructor.name}: .apply-btn not found`)})()}setupCube(){const t=Object.keys(ga).length;this._cubeMaterials=Array.from({length:t},(e,i)=>{const n=this._getThemeIdForFace(i),s=this._resolveThemeFaceVisual(n),a=new hl({color:"#ece9e4"});return this._setMaterialTexture(a,n,s),a}),this._cubeGeometry=new Ts(Os.CUBE_SIDE_LENGTH,Os.CUBE_SIDE_LENGTH,Os.CUBE_SIDE_LENGTH),this._cube=new mi(this._cubeGeometry,this._cubeMaterials),this._cube.rotation.x=this._rotX,this._cube.rotation.y=this._rotY,this._cube.translateY(1.25),this._scene.add(this._cube)}resizeHandler=()=>{const t=()=>{const e=this._root.clientWidth,i=this._root.clientHeight;e===0||i===0||(this._renderer.setSize(e,i,!1),this._camera.aspect=e/i,this._camera.updateProjectionMatrix(),this._updateCameraForLayout(),this._updatePanelPosition())};this._resizeObserver=new ResizeObserver(t),this._resizeObserver.observe(this._root),t()};setupApplyButton(){this._applyBtn.addEventListener(fr.CLICK,this._handleApplyClick)}setupConfirmationDialog(){this._confirmationDialog.addEventListener($i.COMPONENT_CUSTOM_MESSAGES.CONFIRMATION_DIALOG_CONFIRM,this._handleConfirmation),this._confirmationDialog.addEventListener($i.COMPONENT_CUSTOM_MESSAGES.CONFIRMATION_DIALOG_UNDO,this._handleConfirmationCancel)}select(t){if(this._isInitialized===!1){this.selected=t,this.selectedTmp=t;return}if(this.options.has(t)===!1){console.warn(`${this.constructor.name}: Theme '${t}' not found`);return}t!==this.selected&&(this.selected=t,this.selectedTmp=t,this._syncRotationToSelected(),this._updatePreviewDialog(t),this._stopAutoSpinFromInteraction())}_syncRotationToSelected(){const e=[...this.options].indexOf(this.selected);if(e<0)return;const i=Object.values(ga)[e%Object.keys(ga).length],n=new F(0,0,1),s=new fs;s.setFromUnitVectors(i,n);const a=new fi;a.setFromQuaternion(s),this._rotX=a.x,this._rotY=a.y,this._rotZ=a.z,this._currentFaceThemeId=this.selected}_handleApplyClick=()=>{this._applyTheme()};_applyTheme(){if(this._currentFaceThemeId==null)return;const t=this._resolveThemeFaceVisual(this._currentFaceThemeId);this._confirmationDialog.value=this._currentFaceThemeId,this._confirmationDialog.headline="Apply theme?",this._confirmationDialog.text=`Are you sure you want to apply the theme ${t.name}?`,this._confirmationDialog.showModal(),this._isConfirmationDialogOpen=!0,this._stopAutoSpinFromInteraction()}_updatePreviewDialog(t){const e=this._resolveThemeFaceVisual(t),i=t===this.selected;this._previewTitle.textContent=`${e.icon} ${e.name}`,this._previewSub.textContent=e.description,this._applyBtn.disabled=i,this._applyBtn.textContent=i?"Already active":"Apply",this._applyBtn.title=i?"Already the active theme":"Apply this theme"}_animate=()=>{this._animationFrameId=requestAnimationFrame(this._animate);try{if(!this._isInitialized)return;const t=this._clock.getElapsedTime(),e=t-this._lastTime;this._lastTime=t;const i=Math.min(Math.max(e,0),1/24);!this._isDragging&&!this._isConfirmationDialogOpen&&this._updateIdleAutoSpin(i),this._cube.rotation.x=this._rotX,this._cube.rotation.y=this._rotY,this._cube.rotation.z=this._rotZ;const n=this._getFrontFaceIndex(),s=this._getThemeIdForFace(n);s!==this._currentFaceThemeId&&(this._currentFaceThemeId=s,this._updatePreviewDialog(s),this.selectedTmp=s,Fl(s)),this._renderer.render(this._scene,this._camera)}catch(t){console.error("Animation loop error:",t),cancelAnimationFrame(this._animationFrameId),this._animationFrameId=0}};_updateIdleAutoSpin(t){this._idleSeconds+=t,!this._autoSpinEnabled&&this._idleSeconds>=QI&&(this._autoSpinEnabled=!0,this._autoVelX=.0015,this._autoVelY=.0015*(1+Math.sqrt(5))/2),this._autoSpinEnabled&&(this._rotX+=this._autoVelX,this._rotY+=this._autoVelY,this._rotX>Math.PI/2.2&&(this._autoVelX=-Math.abs(this._autoVelX)),this._rotX<-Math.PI/2.2&&(this._autoVelX=Math.abs(this._autoVelX)))}_getFrontFaceIndex(){this._camera.getWorldDirection(this._tmpCamDir),this._tmpCamDir.negate();const t=Object.values(ga);let e=-1,i=-1/0;for(let n=0;n<t.length;n+=1){this._tmpWorldNormal.copy(t[n]).applyQuaternion(this._cube.quaternion);const s=this._tmpWorldNormal.dot(this._tmpCamDir);s>i&&(i=s,e=n)}return e}_updateCameraForLayout(){this._camera.position.set(0,.9,8),this._camera.lookAt(0,0,0)}_updatePanelPosition(){}_setMaterialTexture(t,e,i){const n=this._themeTextures[e];if(n==null||n.length===0){t.map?.dispose(),t.map=this._createFallbackFaceTexture(i),t.needsUpdate=!0;return}Os.textureLoader.load(n,s=>{s.colorSpace=Pe,s.needsUpdate=!0,t.map?.dispose(),t.map=s,t.needsUpdate=!0},void 0,()=>{t.map?.dispose(),t.map=this._createFallbackFaceTexture(i),t.needsUpdate=!0})}_createFallbackFaceTexture(t){const i=document.createElement("canvas");i.width=768,i.height=768;const n=i.getContext("2d");if(n==null){const o=new yh(i);return o.colorSpace=Pe,o}const s=n.createLinearGradient(0,0,768,768);s.addColorStop(0,"#ece9e4"),s.addColorStop(1,"#ddd9d2"),n.fillStyle=s,n.fillRect(0,0,768,768),n.fillStyle="rgba(0, 0, 0, 0.04)",n.beginPath(),n.roundRect(48,48,672,672,28),n.fill(),n.strokeStyle="#f3f3f3",n.lineWidth=6,n.beginPath(),n.roundRect(48,48,672,672,28),n.stroke(),n.fillStyle="#6366f1",n.fillRect(48,48,672,6),n.fillStyle="#141414",n.font="140px serif",n.textAlign="center",n.textBaseline="middle",n.fillText(t.icon,768/2,768/2-70),n.font="bold 72px sans-serif",n.fillText(t.name,768/2,768/2+80,648);const a=new yh(i);return a.colorSpace=Pe,a.needsUpdate=!0,a}_getThemeIdForFace(t){const e=[...this.options];return e.length===0?Yt.DARK:e[t%e.length]??Yt.DARK}_stopAutoSpinFromInteraction(){this._idleSeconds=0,this._autoSpinEnabled=!1,this._autoVelX=0,this._autoVelY=0}_onPointerDown=t=>{this._isDragging=!0,this._dragPointerId=t.pointerId,this._lastPointerX=t.clientX,this._lastPointerY=t.clientY,this._canvas.classList.add("dragging"),this._stopAutoSpinFromInteraction(),this._canvas.setPointerCapture(t.pointerId)};_onPointerMove=t=>{if(!this._isDragging||this._dragPointerId!==t.pointerId)return;const e=t.clientX-this._lastPointerX,i=t.clientY-this._lastPointerY;this._rotY+=e*.008,this._rotX+=i*.008,this._lastPointerX=t.clientX,this._lastPointerY=t.clientY,this._stopAutoSpinFromInteraction()};_onPointerUp=t=>{this._dragPointerId===t.pointerId&&(this._isDragging=!1,this._dragPointerId=null,this._canvas.classList.remove("dragging"),this._idleSeconds=0)};_bindEvents(){this._canvas.addEventListener(qi.POINTER_DOWN,this._onPointerDown),this._canvas.addEventListener(qi.POINTER_MOVE,this._onPointerMove),this._applyBtn.addEventListener(fr.CLICK,this._handleApplyClick),window.addEventListener(qi.POINTER_UP,this._onPointerUp),window.addEventListener(qi.POINTER_CANCEL,this._onPointerUp)}_unbindEvents(){this._canvas?.removeEventListener(qi.POINTER_DOWN,this._onPointerDown),this._canvas?.removeEventListener(qi.POINTER_MOVE,this._onPointerMove),this._applyBtn?.removeEventListener(fr.CLICK,this._handleApplyClick),window.removeEventListener(qi.POINTER_UP,this._onPointerUp),window.removeEventListener(qi.POINTER_CANCEL,this._onPointerUp)}_handleConfirmation=()=>{this.selectedTmp!==this.selected&&(this.dispatchEvent(new CustomEvent(dc.THEME_CHANGE_CONFIRMED,{detail:{value:this.selectedTmp},bubbles:!0,composed:!0})),this._isConfirmationDialogOpen=!1,this._idleSeconds=0)};_handleConfirmationCancel=()=>{this._isConfirmationDialogOpen=!1};_resolveThemeFaceVisual(t){return Ec.get(t)}}const qI=Object.freeze(Object.defineProperty({__proto__:null,COMPONENT_CUSTOM_MESSAGES:dc,OBSERVED_ATTRIBUTES:pa,ThemePickerComponent:Os,selector:"theme-picker"},Symbol.toStringTag,{value:"Module"}));ii.APPLICATION_NAME=Us,ii.CUSTOM_MESSAGES=Ca,ii.LanguagePicker=XI,ii.THEME_TEXTURES_MAPPER=Bc,ii.ThemePicker=qI,ii.WebComponentsRegistry=xc,Object.defineProperty(ii,Symbol.toStringTag,{value:"Module"})}));
3981
+ `,jI="*{box-sizing:border-box}:host{display:block;width:100%;height:100%}.root{position:relative;width:100%;height:100%;overflow:hidden}canvas{width:100%;height:100%;display:block;touch-action:none;cursor:grab}canvas.dragging{cursor:grabbing}.preview-dialog-container{position:absolute;bottom:5%;left:50%;width:30%;transform:translate(-50%)}.preview-dialog-container .preview-dialog::part(dialog){position:relative}.preview-dialog-container .preview-dialog .footer{display:flex;justify-content:flex-end}@media(max-width:768px){.preview-dialog-container{width:90%}}",fc=new CSSStyleSheet;fc.replaceSync(jI);const QI=3;class Os extends HTMLElement{static textureLoader=new Mh;shadowRoot;static get observedAttributes(){return Object.values(pa)}static CUBE_SIDE_LENGTH=2;options=Pl.options;selected=Pl.selected;selectedTmp=Pl.selected;_renderer;_scene;_camera;_root;_canvas;_resizeObserver;_clock=new Lh;_lastTime=0;_cube;_cubeGeometry;_cubeMaterials=[];_animationFrameId=0;previewDialog=null;_previewTitle;_previewSub;_applyBtn;_confirmationDialog;_isConfirmationDialogOpen=!1;_themeTextures={};_currentFaceThemeId;_isDragging=!1;_lastPointerX=0;_lastPointerY=0;_dragPointerId=null;_rotX=.24;_rotY=.45;_rotZ=0;_idleSeconds=0;_autoSpinEnabled=!1;_autoVelX=0;_autoVelY=0;_isInitialized=!1;_isInitializing=!1;_tmpCamDir=new F;_tmpWorldNormal=new F;constructor(){super(),this.shadowRoot=this.attachShadow({mode:"open"}),this.shadowRoot.adoptedStyleSheets.push(fc)}attributeChangedCallback(t,e,i){if(!(e===i||i==null))switch(t){case pa.OPTIONS:{const n=JSON.parse(i);this.init(new Set(n))}break;case pa.SELECTED:{const n=i;this.select(n)}break}}connectedCallback(){this._isInitialized&&this._animationFrameId===0&&(this._clock.start(),this._animationFrameId=requestAnimationFrame(this._animate))}disconnectedCallback(){cancelAnimationFrame(this._animationFrameId),this._animationFrameId=0,this._unbindEvents(),this._cubeMaterials.forEach(t=>{t.map?.dispose(),t.dispose()}),this._cubeMaterials=[],this._cubeGeometry!=null&&this._cubeGeometry.dispose(),this._scene!=null&&this._scene.clear(),this._renderer!=null&&this._renderer.dispose(),this._resizeObserver!=null&&this._resizeObserver.disconnect(),this._confirmationDialog?.removeEventListener($i.COMPONENT_CUSTOM_MESSAGES.CONFIRMATION_DIALOG_CONFIRM,this._handleConfirmation),this._confirmationDialog?.removeEventListener($i.COMPONENT_CUSTOM_MESSAGES.CONFIRMATION_DIALOG_UNDO,this._handleConfirmationCancel),this.selected!==this.selectedTmp&&Fl(this.selected)}init(t){if(!(this._isInitialized||this._isInitializing)){if(this.options=t,this.options.size===0){console.warn(`${this.constructor.name}: No themes provided`);return}this._isInitializing=!0,this.setupHtmlElements(),this.setupScene(),this.setupUI(),this.setupCube(),this.setupConfirmationDialog(),this.setupApplyButton(),this._bindEvents(),this._isInitialized=!0,this._isInitializing=!1,this._updatePreviewDialog(this.selected),this._syncRotationToSelected(),this._updatePanelPosition(),this.isConnected&&this._animationFrameId===0&&(this._clock.start(),this._animationFrameId=requestAnimationFrame(this._animate))}}setupHtmlElements(){this.shadowRoot.innerHTML=JI,this._root=this.shadowRoot.querySelector(".root")??(()=>{throw new Error(`${this.constructor.name}: root element not found`)})(),this._canvas=this.shadowRoot.querySelector(Nl.CANVAS)??(()=>{throw new Error(`${this.constructor.name}: canvas element not found`)})(),this._confirmationDialog=this.shadowRoot.querySelector($i.selector)??(()=>{throw new Error(`${this.constructor.name}: confirmation-dialog element not found`)})()}setupScene(){const t=this._root.clientWidth!==0?this._root.clientWidth:800,e=this._root.clientHeight!==0?this._root.clientHeight:600;this._renderer=new hc({canvas:this._canvas,antialias:!0,alpha:!0}),this._renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this._renderer.setSize(t,e,!1),this._renderer.setClearColor(0,0),this._scene=new Sh,this._scene.background=new Vt(1710618),this._camera=new ke(44,t/e,.1,100),this._updateCameraForLayout(),this._camera.lookAt(0,0,0),this.resizeHandler()}setupUI(){this.previewDialog=this.shadowRoot.querySelector(".preview-dialog"),this.previewDialog!=null&&setTimeout(()=>{this.previewDialog?.show()}),this._previewTitle=this.shadowRoot.querySelector(".preview-title")??(()=>{throw new Error(`${this.constructor.name}: .preview-title not found`)})(),this._previewSub=this.shadowRoot.querySelector(".preview-sub")??(()=>{throw new Error(`${this.constructor.name}: .preview-sub not found`)})(),this._applyBtn=this.shadowRoot.querySelector(".apply-btn")??(()=>{throw new Error(`${this.constructor.name}: .apply-btn not found`)})()}setupCube(){const t=Object.keys(ga).length;this._cubeMaterials=Array.from({length:t},(e,i)=>{const n=this._getThemeIdForFace(i),s=this._resolveThemeFaceVisual(n),a=new hl({color:"#ece9e4"});return this._setMaterialTexture(a,n,s),a}),this._cubeGeometry=new Ts(Os.CUBE_SIDE_LENGTH,Os.CUBE_SIDE_LENGTH,Os.CUBE_SIDE_LENGTH),this._cube=new mi(this._cubeGeometry,this._cubeMaterials),this._cube.rotation.x=this._rotX,this._cube.rotation.y=this._rotY,this._cube.translateY(1),this._scene.add(this._cube)}resizeHandler=()=>{const t=()=>{const e=this._root.clientWidth,i=this._root.clientHeight;e===0||i===0||(this._renderer.setSize(e,i,!1),this._camera.aspect=e/i,this._camera.updateProjectionMatrix(),this._updateCameraForLayout(),this._updatePanelPosition())};this._resizeObserver=new ResizeObserver(t),this._resizeObserver.observe(this._root),t()};setupApplyButton(){this._applyBtn.addEventListener(fr.CLICK,this._handleApplyClick)}setupConfirmationDialog(){this._confirmationDialog.addEventListener($i.COMPONENT_CUSTOM_MESSAGES.CONFIRMATION_DIALOG_CONFIRM,this._handleConfirmation),this._confirmationDialog.addEventListener($i.COMPONENT_CUSTOM_MESSAGES.CONFIRMATION_DIALOG_UNDO,this._handleConfirmationCancel)}select(t){if(this._isInitialized===!1){this.selected=t,this.selectedTmp=t;return}if(this.options.has(t)===!1){console.warn(`${this.constructor.name}: Theme '${t}' not found`);return}t!==this.selected&&(this.selected=t,this.selectedTmp=t,this._syncRotationToSelected(),this._updatePreviewDialog(t),this._stopAutoSpinFromInteraction())}_syncRotationToSelected(){const e=[...this.options].indexOf(this.selected);if(e<0)return;const i=Object.values(ga)[e%Object.keys(ga).length],n=new F(0,0,1),s=new fs;s.setFromUnitVectors(i,n);const a=new fi;a.setFromQuaternion(s),this._rotX=a.x,this._rotY=a.y,this._rotZ=a.z,this._currentFaceThemeId=this.selected}_handleApplyClick=()=>{this._applyTheme()};_applyTheme(){if(this._currentFaceThemeId==null)return;const t=this._resolveThemeFaceVisual(this._currentFaceThemeId);this._confirmationDialog.value=this._currentFaceThemeId,this._confirmationDialog.headline="Apply theme?",this._confirmationDialog.text=`Are you sure you want to apply the theme ${t.name}?`,this._confirmationDialog.showModal(),this._isConfirmationDialogOpen=!0,this._stopAutoSpinFromInteraction()}_updatePreviewDialog(t){const e=this._resolveThemeFaceVisual(t),i=t===this.selected;this._previewTitle.textContent=`${e.icon} ${e.name}`,this._previewSub.textContent=e.description,this._applyBtn.disabled=i,this._applyBtn.textContent=i?"Already active":"Apply",this._applyBtn.title=i?"Already the active theme":"Apply this theme"}_animate=()=>{this._animationFrameId=requestAnimationFrame(this._animate);try{if(!this._isInitialized)return;const t=this._clock.getElapsedTime(),e=t-this._lastTime;this._lastTime=t;const i=Math.min(Math.max(e,0),1/24);!this._isDragging&&!this._isConfirmationDialogOpen&&this._updateIdleAutoSpin(i),this._cube.rotation.x=this._rotX,this._cube.rotation.y=this._rotY,this._cube.rotation.z=this._rotZ;const n=this._getFrontFaceIndex(),s=this._getThemeIdForFace(n);s!==this._currentFaceThemeId&&(this._currentFaceThemeId=s,this._updatePreviewDialog(s),this.selectedTmp=s,Fl(s)),this._renderer.render(this._scene,this._camera)}catch(t){console.error("Animation loop error:",t),cancelAnimationFrame(this._animationFrameId),this._animationFrameId=0}};_updateIdleAutoSpin(t){this._idleSeconds+=t,!this._autoSpinEnabled&&this._idleSeconds>=QI&&(this._autoSpinEnabled=!0,this._autoVelX=.0015,this._autoVelY=.0015*(1+Math.sqrt(5))/2),this._autoSpinEnabled&&(this._rotX+=this._autoVelX,this._rotY+=this._autoVelY,this._rotX>Math.PI/2.2&&(this._autoVelX=-Math.abs(this._autoVelX)),this._rotX<-Math.PI/2.2&&(this._autoVelX=Math.abs(this._autoVelX)))}_getFrontFaceIndex(){this._camera.getWorldDirection(this._tmpCamDir),this._tmpCamDir.negate();const t=Object.values(ga);let e=-1,i=-1/0;for(let n=0;n<t.length;n+=1){this._tmpWorldNormal.copy(t[n]).applyQuaternion(this._cube.quaternion);const s=this._tmpWorldNormal.dot(this._tmpCamDir);s>i&&(i=s,e=n)}return e}_updateCameraForLayout(){this._camera.position.set(0,.9,8),this._camera.lookAt(0,0,0)}_updatePanelPosition(){}_setMaterialTexture(t,e,i){const n=this._themeTextures[e];if(n==null||n.length===0){t.map?.dispose(),t.map=this._createFallbackFaceTexture(i),t.needsUpdate=!0;return}Os.textureLoader.load(n,s=>{s.colorSpace=Pe,s.needsUpdate=!0,t.map?.dispose(),t.map=s,t.needsUpdate=!0},void 0,()=>{t.map?.dispose(),t.map=this._createFallbackFaceTexture(i),t.needsUpdate=!0})}_createFallbackFaceTexture(t){const i=document.createElement("canvas");i.width=768,i.height=768;const n=i.getContext("2d");if(n==null){const o=new yh(i);return o.colorSpace=Pe,o}const s=n.createLinearGradient(0,0,768,768);s.addColorStop(0,"#ece9e4"),s.addColorStop(1,"#ddd9d2"),n.fillStyle=s,n.fillRect(0,0,768,768),n.fillStyle="rgba(0, 0, 0, 0.04)",n.beginPath(),n.roundRect(48,48,672,672,28),n.fill(),n.strokeStyle="#f3f3f3",n.lineWidth=6,n.beginPath(),n.roundRect(48,48,672,672,28),n.stroke(),n.fillStyle="#6366f1",n.fillRect(48,48,672,6),n.fillStyle="#141414",n.font="140px serif",n.textAlign="center",n.textBaseline="middle",n.fillText(t.icon,768/2,768/2-70),n.font="bold 72px sans-serif",n.fillText(t.name,768/2,768/2+80,648);const a=new yh(i);return a.colorSpace=Pe,a.needsUpdate=!0,a}_getThemeIdForFace(t){const e=[...this.options];return e.length===0?Yt.DARK:e[t%e.length]??Yt.DARK}_stopAutoSpinFromInteraction(){this._idleSeconds=0,this._autoSpinEnabled=!1,this._autoVelX=0,this._autoVelY=0}_onPointerDown=t=>{this._isDragging=!0,this._dragPointerId=t.pointerId,this._lastPointerX=t.clientX,this._lastPointerY=t.clientY,this._canvas.classList.add("dragging"),this._stopAutoSpinFromInteraction(),this._canvas.setPointerCapture(t.pointerId)};_onPointerMove=t=>{if(!this._isDragging||this._dragPointerId!==t.pointerId)return;const e=t.clientX-this._lastPointerX,i=t.clientY-this._lastPointerY;this._rotY+=e*.008,this._rotX+=i*.008,this._lastPointerX=t.clientX,this._lastPointerY=t.clientY,this._stopAutoSpinFromInteraction()};_onPointerUp=t=>{this._dragPointerId===t.pointerId&&(this._isDragging=!1,this._dragPointerId=null,this._canvas.classList.remove("dragging"),this._idleSeconds=0)};_bindEvents(){this._canvas.addEventListener(qi.POINTER_DOWN,this._onPointerDown),this._canvas.addEventListener(qi.POINTER_MOVE,this._onPointerMove),this._applyBtn.addEventListener(fr.CLICK,this._handleApplyClick),window.addEventListener(qi.POINTER_UP,this._onPointerUp),window.addEventListener(qi.POINTER_CANCEL,this._onPointerUp)}_unbindEvents(){this._canvas?.removeEventListener(qi.POINTER_DOWN,this._onPointerDown),this._canvas?.removeEventListener(qi.POINTER_MOVE,this._onPointerMove),this._applyBtn?.removeEventListener(fr.CLICK,this._handleApplyClick),window.removeEventListener(qi.POINTER_UP,this._onPointerUp),window.removeEventListener(qi.POINTER_CANCEL,this._onPointerUp)}_handleConfirmation=()=>{this.selectedTmp!==this.selected&&(this.dispatchEvent(new CustomEvent(dc.THEME_CHANGE_CONFIRMED,{detail:{value:this.selectedTmp},bubbles:!0,composed:!0})),this._isConfirmationDialogOpen=!1,this._idleSeconds=0)};_handleConfirmationCancel=()=>{this._isConfirmationDialogOpen=!1};_resolveThemeFaceVisual(t){return Ec.get(t)}}const qI=Object.freeze(Object.defineProperty({__proto__:null,COMPONENT_CUSTOM_MESSAGES:dc,OBSERVED_ATTRIBUTES:pa,ThemePickerComponent:Os,selector:"theme-picker"},Symbol.toStringTag,{value:"Module"}));ii.APPLICATION_NAME=Us,ii.CUSTOM_MESSAGES=Ca,ii.LanguagePicker=XI,ii.THEME_TEXTURES_MAPPER=Bc,ii.ThemePicker=qI,ii.WebComponentsRegistry=xc,Object.defineProperty(ii,Symbol.toStringTag,{value:"Module"})}));