@avs/go 0.14.72008 → 0.14.72037
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +195 -0
- package/NOTICE +5 -0
- package/README.md +2 -2
- package/dist/avs-element-mixin.d.ts +3 -3
- package/dist/avs-element-mixin.d.ts.map +1 -1
- package/dist/avs-element-mixin.js +1 -1
- package/dist/avs-go-dataviz.d.ts +34 -44
- package/dist/avs-go-dataviz.d.ts.map +1 -1
- package/dist/avs-go-dataviz.js +49 -66
- package/dist/avs-go-dynamic-html.d.ts +1 -1
- package/dist/avs-go-dynamic-html.d.ts.map +1 -1
- package/dist/avs-go-dynamic-html.js +8 -3
- package/dist/avs-go-info.d.ts +1 -1
- package/dist/avs-go-info.d.ts.map +1 -1
- package/dist/avs-go-info.js +7 -2
- package/dist/avs-go.min.js +36 -57
- package/dist/avs-renderer.d.ts +2 -2
- package/dist/avs-renderer.d.ts.map +1 -1
- package/dist/avs-renderer.js +5 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +2 -2
- package/dist/icons.d.ts +1 -1
- package/dist/icons.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/types.d.ts +4 -15
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -18
- package/licenses/lit.BSD-3 +28 -0
- package/{lib/LICENSE-avsthreejs → licenses/three.MIT} +1 -21
- package/package.json +14 -4
- package/demo/data/scene.json +0 -1
- package/demo/img/avs.png +0 -0
- package/demo/jsonView.html +0 -36
- package/dist/avs-go.min.js.LICENSE.txt +0 -61
- package/rollup.config.js +0 -26
- package/src/avs-element-mixin.ts +0 -126
- package/src/avs-go-dataviz.ts +0 -2400
- package/src/avs-go-dynamic-html.ts +0 -138
- package/src/avs-go-info.ts +0 -141
- package/src/avs-renderer.ts +0 -44
- package/src/constants.ts +0 -21
- package/src/icons.ts +0 -29
- package/src/index.ts +0 -23
- package/src/types.ts +0 -160
- package/tsconfig.json +0 -16
package/dist/avs-go.min.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var t,e;t=this,e=function(t){
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
|
-
* Copyright 2018 Advanced Visual Systems Inc.
|
|
4
|
+
* Copyright 2018-2026 Advanced Visual Systems Inc.
|
|
5
5
|
*
|
|
6
6
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
7
|
* you may not use this file except in compliance with the License.
|
|
@@ -18,10 +18,10 @@ var t,e;t=this,e=function(t){
|
|
|
18
18
|
* This product includes software developed at
|
|
19
19
|
* Advanced Visual Systems Inc. (http://www.avs.com)
|
|
20
20
|
*/
|
|
21
|
-
const e=t=>class extends t{_httpRequest(t,e,n,i){t||(this._dispatchErrorEvent("'url' property must point to an instance of AVS/Go server."),n?.());const r="0.14.
|
|
21
|
+
const e=t=>class extends t{_httpRequest(t,e,n,i){t||(this._dispatchErrorEvent("'url' property must point to an instance of AVS/Go server."),n?.());const r="0.14.72037".split("."),a=[parseInt(r[0]),parseInt(r[1]),parseInt(r[2])],s={source:this.localName,model:i,version:a};fetch(t,{method:i?"POST":"GET",headers:{"Content-Type":"application/json"},body:i?JSON.stringify(s):void 0}).then((t=>t.json())).then((t=>{t.error?(this._processServerError(t.error),n?.()):e?.(t)})).catch((t=>{this._dispatchErrorEvent(t),n?.()}))}_processServerError(t){if(!t)return;const e=JSON.parse(decodeURIComponent(t.replace(/\+/g,"%20")));let n="An error occurred on the AVS/Go server";for(const t in e)if(e.hasOwnProperty(t)){""!=n&&(n+="\n "),n+=t+": ";const i=e[t];i===Object(i)?n+=JSON.stringify(i):n+=e[t]}this._dispatchErrorEvent(n)}_dispatchErrorEvent(t){this.dispatchEvent(new CustomEvent("avs-error",{bubbles:!0,composed:!0,detail:t}))}},n=globalThis,i=n.ShadowRoot&&(void 0===n.ShadyCSS||n.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,r=Symbol(),a=new WeakMap;
|
|
22
22
|
/**
|
|
23
23
|
* @license
|
|
24
|
-
* Copyright 2018 Advanced Visual Systems Inc.
|
|
24
|
+
* Copyright 2018-2026 Advanced Visual Systems Inc.
|
|
25
25
|
*
|
|
26
26
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
27
27
|
* you may not use this file except in compliance with the License.
|
|
@@ -37,34 +37,34 @@ const e=t=>class extends t{_httpRequest(t,e,n,i){t||(this._dispatchErrorEvent("'
|
|
|
37
37
|
*
|
|
38
38
|
* This product includes software developed at
|
|
39
39
|
* Advanced Visual Systems Inc. (http://www.avs.com)
|
|
40
|
-
*/let s=class{constructor(t,e,n){if(this._$cssResult$=!0,n!==r)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(i&&void 0===t){const n=void 0!==e&&1===e.length;n&&(t=a.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),n&&a.set(e,t))}return t}toString(){return this.cssText}};const o=i?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const n of t.cssRules)e+=n.cssText;return(t=>new s("string"==typeof t?t:t+"",void 0,r))(e)})(t):t,{is:
|
|
40
|
+
*/let s=class{constructor(t,e,n){if(this._$cssResult$=!0,n!==r)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(i&&void 0===t){const n=void 0!==e&&1===e.length;n&&(t=a.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),n&&a.set(e,t))}return t}toString(){return this.cssText}};const o=(t,...e)=>{const n=1===t.length?t[0]:e.reduce(((e,n,i)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+t[i+1]),t[0]);return new s(n,t,r)},l=i?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const n of t.cssRules)e+=n.cssText;return(t=>new s("string"==typeof t?t:t+"",void 0,r))(e)})(t):t,{is:c,defineProperty:h,getOwnPropertyDescriptor:d,getOwnPropertyNames:u,getOwnPropertySymbols:p,getPrototypeOf:m}=Object,f=globalThis,g=f.trustedTypes,v=g?g.emptyScript:"",_=f.reactiveElementPolyfillSupport,y=(t,e)=>t,x={toAttribute(t,e){switch(e){case Boolean:t=t?v:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let n=t;switch(e){case Boolean:n=null!==t;break;case Number:n=null===t?null:Number(t);break;case Object:case Array:try{n=JSON.parse(t)}catch(t){n=null}}return n}},b=(t,e)=>!c(t,e),S={attribute:!0,type:String,converter:x,reflect:!1,useDefault:!1,hasChanged:b};
|
|
41
41
|
/**
|
|
42
42
|
* @license
|
|
43
43
|
* Copyright 2017 Google LLC
|
|
44
44
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
45
|
-
*/Symbol.metadata??=Symbol("metadata"),
|
|
45
|
+
*/Symbol.metadata??=Symbol("metadata"),f.litPropertyMetadata??=new WeakMap;let M=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=S){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const n=Symbol(),i=this.getPropertyDescriptor(t,n,e);void 0!==i&&h(this.prototype,t,i)}}static getPropertyDescriptor(t,e,n){const{get:i,set:r}=d(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:i,set(e){const a=i?.call(this);r?.call(this,e),this.requestUpdate(t,a,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??S}static _$Ei(){if(this.hasOwnProperty(y("elementProperties")))return;const t=m(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(y("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(y("properties"))){const t=this.properties,e=[...u(t),...p(t)];for(const n of e)this.createProperty(n,t[n])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,n]of e)this.elementProperties.set(t,n)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const n=this._$Eu(t,e);void 0!==n&&this._$Eh.set(n,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const n=new Set(t.flat(1/0).reverse());for(const t of n)e.unshift(l(t))}else void 0!==t&&e.push(l(t));return e}static _$Eu(t,e){const n=e.attribute;return!1===n?void 0:"string"==typeof n?n:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const n of e.keys())this.hasOwnProperty(n)&&(t.set(n,this[n]),delete this[n]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{if(i)t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const i of e){const e=document.createElement("style"),r=n.litNonce;void 0!==r&&e.setAttribute("nonce",r),e.textContent=i.cssText,t.appendChild(e)}})(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,n){this._$AK(t,n)}_$ET(t,e){const n=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,n);if(void 0!==i&&!0===n.reflect){const r=(void 0!==n.converter?.toAttribute?n.converter:x).toAttribute(e,n.type);this._$Em=t,null==r?this.removeAttribute(i):this.setAttribute(i,r),this._$Em=null}}_$AK(t,e){const n=this.constructor,i=n._$Eh.get(t);if(void 0!==i&&this._$Em!==i){const t=n.getPropertyOptions(i),r="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:x;this._$Em=i;const a=r.fromAttribute(e,t.type);this[i]=a??this._$Ej?.get(i)??a,this._$Em=null}}requestUpdate(t,e,n,i=!1,r){if(void 0!==t){const a=this.constructor;if(!1===i&&(r=this[t]),n??=a.getPropertyOptions(t),!((n.hasChanged??b)(r,e)||n.useDefault&&n.reflect&&r===this._$Ej?.get(t)&&!this.hasAttribute(a._$Eu(t,n))))return;this.C(t,e,n)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:n,reflect:i,wrapped:r},a){n&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,a??e??this[t]),!0!==r||void 0!==a)||(this._$AL.has(t)||(this.hasUpdated||n||(e=void 0),this._$AL.set(t,e)),!0===i&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,n]of t){const{wrapped:t}=n,i=this[e];!0!==t||this._$AL.has(e)||void 0===i||this.C(e,void 0,n,i)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$EM()}catch(e){throw t=!1,this._$EM(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach((t=>this._$ET(t,this[t]))),this._$EM()}updated(t){}firstUpdated(t){}};M.elementStyles=[],M.shadowRootOptions={mode:"open"},M[y("elementProperties")]=new Map,M[y("finalized")]=new Map,_?.({ReactiveElement:M}),(f.reactiveElementVersions??=[]).push("2.1.2");
|
|
46
46
|
/**
|
|
47
47
|
* @license
|
|
48
48
|
* Copyright 2017 Google LLC
|
|
49
49
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
50
50
|
*/
|
|
51
|
-
const
|
|
51
|
+
const w=globalThis,E=w.trustedTypes,T=E?E.createPolicy("lit-html",{createHTML:t=>t}):void 0,A="$lit$",C=`lit$${Math.random().toFixed(9).slice(2)}$`,R="?"+C,I=`<${R}>`,P=document,L=()=>P.createComment(""),D=t=>null===t||"object"!=typeof t&&"function"!=typeof t,N=Array.isArray,O="[ \t\n\f\r]",U=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,F=/-->/g,z=/>/g,k=RegExp(`>|${O}(?:([^\\s"'>=/]+)(${O}*=${O}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),B=/'/g,G=/"/g,V=/^(?:script|style|textarea|title)$/i,H=(t=>(e,...n)=>({_$litType$:t,strings:e,values:n}))(1),W=Symbol.for("lit-noChange"),j=Symbol.for("lit-nothing"),X=new WeakMap,q=P.createTreeWalker(P,129);function Y(t,e){if(!N(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==T?T.createHTML(e):e}const Z=(t,e)=>{const n=t.length-1,i=[];let r,a=2===e?"<svg>":3===e?"<math>":"",s=U;for(let e=0;e<n;e++){const n=t[e];let o,l,c=-1,h=0;for(;h<n.length&&(s.lastIndex=h,l=s.exec(n),null!==l);)h=s.lastIndex,s===U?"!--"===l[1]?s=F:void 0!==l[1]?s=z:void 0!==l[2]?(V.test(l[2])&&(r=RegExp("</"+l[2],"g")),s=k):void 0!==l[3]&&(s=k):s===k?">"===l[0]?(s=r??U,c=-1):void 0===l[1]?c=-2:(c=s.lastIndex-l[2].length,o=l[1],s=void 0===l[3]?k:'"'===l[3]?G:B):s===G||s===B?s=k:s===F||s===z?s=U:(s=k,r=void 0);const d=s===k&&t[e+1].startsWith("/>")?" ":"";a+=s===U?n+I:c>=0?(i.push(o),n.slice(0,c)+A+n.slice(c)+C+d):n+C+(-2===c?e:d)}return[Y(t,a+(t[n]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),i]};class ${constructor({strings:t,_$litType$:e},n){let i;this.parts=[];let r=0,a=0;const s=t.length-1,o=this.parts,[l,c]=Z(t,e);if(this.el=$.createElement(l,n),q.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(i=q.nextNode())&&o.length<s;){if(1===i.nodeType){if(i.hasAttributes())for(const t of i.getAttributeNames())if(t.endsWith(A)){const e=c[a++],n=i.getAttribute(t).split(C),s=/([.?@])?(.*)/.exec(e);o.push({type:1,index:r,name:s[2],strings:n,ctor:"."===s[1]?et:"?"===s[1]?nt:"@"===s[1]?it:tt}),i.removeAttribute(t)}else t.startsWith(C)&&(o.push({type:6,index:r}),i.removeAttribute(t));if(V.test(i.tagName)){const t=i.textContent.split(C),e=t.length-1;if(e>0){i.textContent=E?E.emptyScript:"";for(let n=0;n<e;n++)i.append(t[n],L()),q.nextNode(),o.push({type:2,index:++r});i.append(t[e],L())}}}else if(8===i.nodeType)if(i.data===R)o.push({type:2,index:r});else{let t=-1;for(;-1!==(t=i.data.indexOf(C,t+1));)o.push({type:7,index:r}),t+=C.length-1}r++}}static createElement(t,e){const n=P.createElement("template");return n.innerHTML=t,n}}function J(t,e,n=t,i){if(e===W)return e;let r=void 0!==i?n._$Co?.[i]:n._$Cl;const a=D(e)?void 0:e._$litDirective$;return r?.constructor!==a&&(r?._$AO?.(!1),void 0===a?r=void 0:(r=new a(t),r._$AT(t,n,i)),void 0!==i?(n._$Co??=[])[i]=r:n._$Cl=r),void 0!==r&&(e=J(t,r._$AS(t,e.values),r,i)),e}class K{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:n}=this._$AD,i=(t?.creationScope??P).importNode(e,!0);q.currentNode=i;let r=q.nextNode(),a=0,s=0,o=n[0];for(;void 0!==o;){if(a===o.index){let e;2===o.type?e=new Q(r,r.nextSibling,this,t):1===o.type?e=new o.ctor(r,o.name,o.strings,this,t):6===o.type&&(e=new rt(r,this,t)),this._$AV.push(e),o=n[++s]}a!==o?.index&&(r=q.nextNode(),a++)}return q.currentNode=P,i}p(t){let e=0;for(const n of this._$AV)void 0!==n&&(void 0!==n.strings?(n._$AI(t,n,e),e+=n.strings.length-2):n._$AI(t[e])),e++}}class Q{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,n,i){this.type=2,this._$AH=j,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=n,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=J(this,t,e),D(t)?t===j||null==t||""===t?(this._$AH!==j&&this._$AR(),this._$AH=j):t!==this._$AH&&t!==W&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>N(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==j&&D(this._$AH)?this._$AA.nextSibling.data=t:this.T(P.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:n}=t,i="number"==typeof n?this._$AC(t):(void 0===n.el&&(n.el=$.createElement(Y(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===i)this._$AH.p(e);else{const t=new K(i,this),n=t.u(this.options);t.p(e),this.T(n),this._$AH=t}}_$AC(t){let e=X.get(t.strings);return void 0===e&&X.set(t.strings,e=new $(t)),e}k(t){N(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let n,i=0;for(const r of t)i===e.length?e.push(n=new Q(this.O(L()),this.O(L()),this,this.options)):n=e[i],n._$AI(r),i++;i<e.length&&(this._$AR(n&&n._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class tt{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,n,i,r){this.type=1,this._$AH=j,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=r,n.length>2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=j}_$AI(t,e=this,n,i){const r=this.strings;let a=!1;if(void 0===r)t=J(this,t,e,0),a=!D(t)||t!==this._$AH&&t!==W,a&&(this._$AH=t);else{const i=t;let s,o;for(t=r[0],s=0;s<r.length-1;s++)o=J(this,i[n+s],e,s),o===W&&(o=this._$AH[s]),a||=!D(o)||o!==this._$AH[s],o===j?t=j:t!==j&&(t+=(o??"")+r[s+1]),this._$AH[s]=o}a&&!i&&this.j(t)}j(t){t===j?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class et extends tt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===j?void 0:t}}class nt extends tt{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==j)}}class it extends tt{constructor(t,e,n,i,r){super(t,e,n,i,r),this.type=5}_$AI(t,e=this){if((t=J(this,t,e,0)??j)===W)return;const n=this._$AH,i=t===j&&n!==j||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,r=t!==j&&(n===j||i);i&&this.element.removeEventListener(this.name,this,n),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class rt{constructor(t,e,n){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(t){J(this,t)}}const at=w.litHtmlPolyfillSupport;at?.($,Q),(w.litHtmlVersions??=[]).push("3.3.2");const st=globalThis;
|
|
52
52
|
/**
|
|
53
53
|
* @license
|
|
54
54
|
* Copyright 2017 Google LLC
|
|
55
55
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
56
|
-
*/let
|
|
56
|
+
*/let ot=class extends M{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,e,n)=>{const i=n?.renderBefore??e;let r=i._$litPart$;if(void 0===r){const t=n?.renderBefore??null;i._$litPart$=r=new Q(e.insertBefore(L(),t),t,void 0,n??{})}return r._$AI(t),r})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return W}};ot._$litElement$=!0,ot.finalized=!0,st.litElementHydrateSupport?.({LitElement:ot});const lt=st.litElementPolyfillSupport;lt?.({LitElement:ot}),(st.litElementVersions??=[]).push("4.2.2");
|
|
57
57
|
/**
|
|
58
58
|
* @license
|
|
59
59
|
* Copyright 2017 Google LLC
|
|
60
60
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
61
61
|
*/
|
|
62
|
-
const
|
|
62
|
+
const ct=t=>(e,n)=>{void 0!==n?n.addInitializer((()=>{customElements.define(t,e)})):customElements.define(t,e)},ht={attribute:!0,type:String,converter:x,reflect:!1,hasChanged:b},dt=(t=ht,e,n)=>{const{kind:i,metadata:r}=n;let a=globalThis.litPropertyMetadata.get(r);if(void 0===a&&globalThis.litPropertyMetadata.set(r,a=new Map),"setter"===i&&((t=Object.create(t)).wrapped=!0),a.set(n.name,t),"accessor"===i){const{name:i}=n;return{set(n){const r=e.get.call(this);e.set.call(this,n),this.requestUpdate(i,r,t,!0,n)},init(e){return void 0!==e&&this.C(i,void 0,t,e),e}}}if("setter"===i){const{name:i}=n;return function(n){const r=this[i];e.call(this,n),this.requestUpdate(i,r,t,!0,n)}}throw Error("Unsupported decorator location: "+i)};
|
|
63
63
|
/**
|
|
64
64
|
* @license
|
|
65
65
|
* Copyright 2017 Google LLC
|
|
66
66
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
67
|
-
*/function
|
|
67
|
+
*/function ut(t){return(e,n)=>"object"==typeof n?dt(t,e,n):((t,e,n)=>{const i=e.hasOwnProperty(n);return e.constructor.createProperty(n,t),i?Object.getOwnPropertyDescriptor(e,n):void 0})(t,e,n)}
|
|
68
68
|
/**
|
|
69
69
|
* @license
|
|
70
70
|
* Copyright 2017 Google LLC
|
|
@@ -75,31 +75,31 @@ const lt=t=>(e,n)=>{void 0!==n?n.addInitializer((()=>{customElements.define(t,e)
|
|
|
75
75
|
* Copyright 2017 Google LLC
|
|
76
76
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
77
77
|
*/
|
|
78
|
-
const
|
|
78
|
+
const pt=2,mt=t=>(...e)=>({_$litDirective$:t,values:e});class ft{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,n){this._$Ct=t,this._$AM=e,this._$Ci=n}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}
|
|
79
79
|
/**
|
|
80
80
|
* @license
|
|
81
81
|
* Copyright 2017 Google LLC
|
|
82
82
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
83
|
-
*/class
|
|
83
|
+
*/class gt extends ft{constructor(t){if(super(t),this.it=j,t.type!==pt)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===j||null==t)return this._t=void 0,this.it=t;if(t===W)return t;if("string"!=typeof t)throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}}gt.directiveName="unsafeHTML",gt.resultType=1;const vt=mt(gt);
|
|
84
84
|
/**
|
|
85
85
|
* @license
|
|
86
86
|
* Copyright 2017 Google LLC
|
|
87
87
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
88
|
-
*/class
|
|
88
|
+
*/class _t extends gt{}_t.directiveName="unsafeSVG",_t.resultType=2;const yt=mt(_t),xt="184",bt={PAN:2},St=0,Mt=1,wt=2,Et=3,Tt=1,At=3,Ct=0,Rt=1,It=2,Pt=100,Lt=101,Dt=102,Nt=200,Ot=201,Ut=202,Ft=203,zt=204,kt=205,Bt=206,Gt=207,Vt=208,Ht=209,Wt=210,jt=211,Xt=212,qt=213,Yt=214,Zt=0,$t=1,Jt=2,Kt=3,Qt=4,te=5,ee=6,ne=7,ie=0,re=1,ae=2,se=1,oe=2,le=3,ce=4,he=5,de=6,ue=7,pe="attached",me=301,fe=302,ge=303,ve=304,_e=306,ye=1e3,xe=1001,be=1002,Se=1003,Me=1004,we=1005,Ee=1006,Te=1007,Ae=1008,Ce=1009,Re=1010,Ie=1011,Pe=1012,Le=1013,De=1014,Ne=1015,Oe=1016,Ue=1017,Fe=1018,ze=1020,ke=35902,Be=35899,Ge=1023,Ve=1026,He=1027,We=1028,je=1029,Xe=1030,qe=1031,Ye=1033,Ze=33776,$e=33777,Je=33778,Ke=33779,Qe=35840,tn=35841,en=35842,nn=35843,rn=36196,an=37492,sn=37496,on=37488,ln=37489,cn=37490,hn=37491,dn=37808,un=37809,pn=37810,mn=37811,fn=37812,gn=37813,vn=37814,_n=37815,yn=37816,xn=37817,bn=37818,Sn=37819,Mn=37820,wn=37821,En=36492,Tn=36494,An=36495,Cn=36283,Rn=36284,In=36285,Pn=36286,Ln=2300,Dn=2301,Nn=2302,On=2400,Un=2401,Fn=2402,zn=2500,kn="",Bn="srgb",Gn="srgb-linear",Vn="linear",Hn="srgb",Wn=7680,jn=512,Xn=513,qn=514,Yn=515,Zn=516,$n=517,Jn=518,Kn=519,Qn=35044,ti="300 es",ei=2e3,ni=2001,ii={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};
|
|
89
89
|
/**
|
|
90
90
|
* @license
|
|
91
91
|
* Copyright 2010-2026 Three.js Authors
|
|
92
92
|
* SPDX-License-Identifier: MIT
|
|
93
|
-
*/function ii(t,e){return new ni[t](e)}function ri(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function ai(){const t=ri("canvas");return t.style.display="block",t}const si={};function oi(...t){const e="THREE."+t.shift();console.log(e,...t)}function li(t){const e=t[0];if("string"==typeof e&&e.startsWith("TSL:")){const e=t[1];e&&e.isStackTrace?t[0]+=" "+e.getLocation():t[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return t}function ci(...t){const e="THREE."+(t=li(t)).shift();{const n=t[0];n&&n.isStackTrace?console.warn(n.getError(e)):console.warn(e,...t)}}function hi(...t){const e="THREE."+(t=li(t)).shift();{const n=t[0];n&&n.isStackTrace?console.error(n.getError(e)):console.error(e,...t)}}function di(...t){const e=t.join(" ");e in si||(si[e]=!0,ci(...t))}const ui={[Yt]:1,[$t]:6,[Kt]:7,[Jt]:5,[Zt]:0,[te]:2,[ee]:4,[Qt]:3};class pi{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[t]&&(n[t]=[]),-1===n[t].indexOf(e)&&n[t].push(e)}hasEventListener(t,e){const n=this._listeners;return void 0!==n&&void 0!==n[t]&&-1!==n[t].indexOf(e)}removeEventListener(t,e){const n=this._listeners;if(void 0===n)return;const i=n[t];if(void 0!==i){const t=i.indexOf(e);-1!==t&&i.splice(t,1)}}dispatchEvent(t){const e=this._listeners;if(void 0===e)return;const n=e[t.type];if(void 0!==n){t.target=this;const e=n.slice(0);for(let n=0,i=e.length;n<i;n++)e[n].call(this,t);t.target=null}}}const mi=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let fi=1234567;const gi=Math.PI/180,vi=180/Math.PI;function _i(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(mi[255&t]+mi[t>>8&255]+mi[t>>16&255]+mi[t>>24&255]+"-"+mi[255&e]+mi[e>>8&255]+"-"+mi[e>>16&15|64]+mi[e>>24&255]+"-"+mi[63&n|128]+mi[n>>8&255]+"-"+mi[n>>16&255]+mi[n>>24&255]+mi[255&i]+mi[i>>8&255]+mi[i>>16&255]+mi[i>>24&255]).toLowerCase()}function yi(t,e,n){return Math.max(e,Math.min(n,t))}function xi(t,e){return(t%e+e)%e}function bi(t,e,n){return(1-n)*t+n*e}function Si(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function Mi(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}const wi={DEG2RAD:gi,RAD2DEG:vi,generateUUID:_i,clamp:yi,euclideanModulo:xi,mapLinear:function(t,e,n,i,r){return i+(t-e)*(r-i)/(n-e)},inverseLerp:function(t,e,n){return t!==e?(n-t)/(e-t):0},lerp:bi,damp:function(t,e,n,i){return bi(t,e,1-Math.exp(-n*i))},pingpong:function(t,e=1){return e-Math.abs(xi(t,2*e)-e)},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){void 0!==t&&(fi=t);let e=fi+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296},degToRad:function(t){return t*gi},radToDeg:function(t){return t*vi},isPowerOfTwo:function(t){return!(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,e,n,i,r){const a=Math.cos,s=Math.sin,o=a(n/2),l=s(n/2),c=a((e+i)/2),h=s((e+i)/2),d=a((e-i)/2),u=s((e-i)/2),p=a((i-e)/2),m=s((i-e)/2);switch(r){case"XYX":t.set(o*h,l*d,l*u,o*c);break;case"YZY":t.set(l*u,o*h,l*d,o*c);break;case"ZXZ":t.set(l*d,l*u,o*h,o*c);break;case"XZX":t.set(o*h,l*m,l*p,o*c);break;case"YXY":t.set(l*p,o*h,l*m,o*c);break;case"ZYZ":t.set(l*m,l*p,o*h,o*c);break;default:ci("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:Mi,denormalize:Si};class Ei{static{Ei.prototype.isVector2=!0}constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[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=yi(this.x,t.x,e.x),this.y=yi(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=yi(this.x,t,e),this.y=yi(this.y,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(yi(n,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(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(yi(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),i=Math.sin(e),r=this.x-t.x,a=this.y-t.y;return this.x=r*n-a*i+t.x,this.y=r*i+a*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ti{constructor(t=0,e=0,n=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=i}static slerpFlat(t,e,n,i,r,a,s){let o=n[i+0],l=n[i+1],c=n[i+2],h=n[i+3],d=r[a+0],u=r[a+1],p=r[a+2],m=r[a+3];if(h!==m||o!==d||l!==u||c!==p){let t=o*d+l*u+c*p+h*m;t<0&&(d=-d,u=-u,p=-p,m=-m,t=-t);let e=1-s;if(t<.9995){const n=Math.acos(t),i=Math.sin(n);e=Math.sin(e*n)/i,o=o*e+d*(s=Math.sin(s*n)/i),l=l*e+u*s,c=c*e+p*s,h=h*e+m*s}else{o=o*e+d*s,l=l*e+u*s,c=c*e+p*s,h=h*e+m*s;const t=1/Math.sqrt(o*o+l*l+c*c+h*h);o*=t,l*=t,c*=t,h*=t}}t[e]=o,t[e+1]=l,t[e+2]=c,t[e+3]=h}static multiplyQuaternionsFlat(t,e,n,i,r,a){const s=n[i],o=n[i+1],l=n[i+2],c=n[i+3],h=r[a],d=r[a+1],u=r[a+2],p=r[a+3];return t[e]=s*p+c*h+o*u-l*d,t[e+1]=o*p+c*d+l*h-s*u,t[e+2]=l*p+c*u+s*d-o*h,t[e+3]=c*p-s*h-o*d-l*u,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,i=t._y,r=t._z,a=t._order,s=Math.cos,o=Math.sin,l=s(n/2),c=s(i/2),h=s(r/2),d=o(n/2),u=o(i/2),p=o(r/2);switch(a){case"XYZ":this._x=d*c*h+l*u*p,this._y=l*u*h-d*c*p,this._z=l*c*p+d*u*h,this._w=l*c*h-d*u*p;break;case"YXZ":this._x=d*c*h+l*u*p,this._y=l*u*h-d*c*p,this._z=l*c*p-d*u*h,this._w=l*c*h+d*u*p;break;case"ZXY":this._x=d*c*h-l*u*p,this._y=l*u*h+d*c*p,this._z=l*c*p+d*u*h,this._w=l*c*h-d*u*p;break;case"ZYX":this._x=d*c*h-l*u*p,this._y=l*u*h+d*c*p,this._z=l*c*p-d*u*h,this._w=l*c*h+d*u*p;break;case"YZX":this._x=d*c*h+l*u*p,this._y=l*u*h+d*c*p,this._z=l*c*p-d*u*h,this._w=l*c*h-d*u*p;break;case"XZY":this._x=d*c*h-l*u*p,this._y=l*u*h-d*c*p,this._z=l*c*p+d*u*h,this._w=l*c*h+d*u*p;break;default:ci("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[4],r=e[8],a=e[1],s=e[5],o=e[9],l=e[2],c=e[6],h=e[10],d=n+s+h;if(d>0){const t=.5/Math.sqrt(d+1);this._w=.25/t,this._x=(c-o)*t,this._y=(r-l)*t,this._z=(a-i)*t}else if(n>s&&n>h){const t=2*Math.sqrt(1+n-s-h);this._w=(c-o)/t,this._x=.25*t,this._y=(i+a)/t,this._z=(r+l)/t}else if(s>h){const t=2*Math.sqrt(1+s-n-h);this._w=(r-l)/t,this._x=(i+a)/t,this._y=.25*t,this._z=(o+c)/t}else{const t=2*Math.sqrt(1+h-n-s);this._w=(a-i)/t,this._x=(r+l)/t,this._y=(o+c)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(yi(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(0===n)return this;const i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,i=t._y,r=t._z,a=t._w,s=e._x,o=e._y,l=e._z,c=e._w;return this._x=n*c+a*s+i*l-r*o,this._y=i*c+a*o+r*s-n*l,this._z=r*c+a*l+n*o-i*s,this._w=a*c-n*s-i*o-r*l,this._onChangeCallback(),this}slerp(t,e){let n=t._x,i=t._y,r=t._z,a=t._w,s=this.dot(t);s<0&&(n=-n,i=-i,r=-r,a=-a,s=-s);let o=1-e;if(s<.9995){const t=Math.acos(s),l=Math.sin(t);o=Math.sin(o*t)/l,e=Math.sin(e*t)/l,this._x=this._x*o+n*e,this._y=this._y*o+i*e,this._z=this._z*o+r*e,this._w=this._w*o+a*e,this._onChangeCallback()}else this._x=this._x*o+n*e,this._y=this._y*o+i*e,this._z=this._z*o+r*e,this._w=this._w*o+a*e,this.normalize();return this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Ai{static{Ai.prototype.isVector3=!0}constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Ri.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Ri.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=t.elements,a=1/(r[3]*e+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*e+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*e+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,r=t.x,a=t.y,s=t.z,o=t.w,l=2*(a*i-s*n),c=2*(s*e-r*i),h=2*(r*n-a*e);return this.x=e+o*l+a*h-s*c,this.y=n+o*c+s*l-r*h,this.z=i+o*h+r*c-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,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,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=yi(this.x,t.x,e.x),this.y=yi(this.y,t.y,e.y),this.z=yi(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=yi(this.x,t,e),this.y=yi(this.y,t,e),this.z=yi(this.z,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(yi(n,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,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,i=t.y,r=t.z,a=e.x,s=e.y,o=e.z;return this.x=i*o-r*s,this.y=r*a-n*o,this.z=n*s-i*a,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Ci.copy(this).projectOnVector(t),this.sub(Ci)}reflect(t){return this.sub(Ci.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(yi(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=2*Math.random()-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Ci=new Ai,Ri=new Ti;class Ii{static{Ii.prototype.isMatrix3=!0}constructor(t,e,n,i,r,a,s,o,l){this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,n,i,r,a,s,o,l)}set(t,e,n,i,r,a,s,o,l){const c=this.elements;return c[0]=t,c[1]=i,c[2]=s,c[3]=e,c[4]=r,c[5]=o,c[6]=n,c[7]=a,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,a=n[0],s=n[3],o=n[6],l=n[1],c=n[4],h=n[7],d=n[2],u=n[5],p=n[8],m=i[0],f=i[3],g=i[6],v=i[1],_=i[4],y=i[7],x=i[2],b=i[5],S=i[8];return r[0]=a*m+s*v+o*x,r[3]=a*f+s*_+o*b,r[6]=a*g+s*y+o*S,r[1]=l*m+c*v+h*x,r[4]=l*f+c*_+h*b,r[7]=l*g+c*y+h*S,r[2]=d*m+u*v+p*x,r[5]=d*f+u*_+p*b,r[8]=d*g+u*y+p*S,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],s=t[5],o=t[6],l=t[7],c=t[8];return e*a*c-e*s*l-n*r*c+n*s*o+i*r*l-i*a*o}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],s=t[5],o=t[6],l=t[7],c=t[8],h=c*a-s*l,d=s*o-c*r,u=l*r-a*o,p=e*h+n*d+i*u;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return t[0]=h*m,t[1]=(i*l-c*n)*m,t[2]=(s*n-i*a)*m,t[3]=d*m,t[4]=(c*e-i*o)*m,t[5]=(i*r-s*e)*m,t[6]=u*m,t[7]=(n*o-l*e)*m,t[8]=(a*e-n*r)*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,n,i,r,a,s){const o=Math.cos(r),l=Math.sin(r);return this.set(n*o,n*l,-n*(o*a+l*s)+a+t,-i*l,i*o,-i*(-l*a+o*s)+s+e,0,0,1),this}scale(t,e){return this.premultiply(Pi.makeScale(t,e)),this}rotate(t){return this.premultiply(Pi.makeRotation(-t)),this}translate(t,e){return this.premultiply(Pi.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<9;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const Pi=new Ii,Li=(new Ii).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Di=(new Ii).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Ni(){const t={enabled:!0,workingColorSpace:Bn,spaces:{},convert:function(t,e,n){return!1!==this.enabled&&e!==n&&e&&n?(this.spaces[e].transfer===Vn&&(t.r=Ui(t.r),t.g=Ui(t.g),t.b=Ui(t.b)),this.spaces[e].primaries!==this.spaces[n].primaries&&(t.applyMatrix3(this.spaces[e].toXYZ),t.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===Vn&&(t.r=Fi(t.r),t.g=Fi(t.g),t.b=Fi(t.b)),t):t},workingToColorSpace:function(t,e){return this.convert(t,this.workingColorSpace,e)},colorSpaceToWorking:function(t,e){return this.convert(t,e,this.workingColorSpace)},getPrimaries:function(t){return this.spaces[t].primaries},getTransfer:function(t){return t===zn?Gn:this.spaces[t].transfer},getToneMappingMode:function(t){return this.spaces[t].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(t,e=this.workingColorSpace){return t.fromArray(this.spaces[e].luminanceCoefficients)},define:function(t){Object.assign(this.spaces,t)},_getMatrix:function(t,e,n){return t.copy(this.spaces[e].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(t){return this.spaces[t].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(t=this.workingColorSpace){return this.spaces[t].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(e,n){return di("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(e,n)},toWorkingColorSpace:function(e,n){return di("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(e,n)}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],i=[.3127,.329];return t.define({[Bn]:{primaries:e,whitePoint:i,transfer:Gn,toXYZ:Li,fromXYZ:Di,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:kn},outputColorSpaceConfig:{drawingBufferColorSpace:kn}},[kn]:{primaries:e,whitePoint:i,transfer:Vn,toXYZ:Li,fromXYZ:Di,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:kn}}}),t}const Oi=Ni();function Ui(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function Fi(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}let zi;class ki{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{void 0===zi&&(zi=ri("canvas")),zi.width=t.width,zi.height=t.height;const e=zi.getContext("2d");t instanceof ImageData?e.putImageData(t,0,0):e.drawImage(t,0,0,t.width,t.height),n=zi}return n.toDataURL(e)}static sRGBToLinear(t){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=ri("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),r=i.data;for(let t=0;t<r.length;t++)r[t]=255*Ui(r[t]/255);return n.putImageData(i,0,0),e}if(t.data){const e=t.data.slice(0);for(let t=0;t<e.length;t++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[t]=Math.floor(255*Ui(e[t]/255)):e[t]=Ui(e[t]);return{data:e,width:t.width,height:t.height}}return ci("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let Bi=0;class Gi{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Bi++}),this.uuid=_i(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return"undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):"undefined"!=typeof VideoFrame&&e instanceof VideoFrame?t.set(e.displayWidth,e.displayHeight,0):null!==e?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){!0===t&&this.version++}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.images[this.uuid])return t.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(null!==i){let t;if(Array.isArray(i)){t=[];for(let e=0,n=i.length;e<n;e++)i[e].isDataTexture?t.push(Vi(i[e].image)):t.push(Vi(i[e]))}else t=Vi(i);n.url=t}return e||(t.images[this.uuid]=n),n}}function Vi(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?ki.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(ci("Texture: Unable to serialize Texture."),{})}let Hi=0;const Wi=new Ai;class ji extends pi{constructor(t=ji.DEFAULT_IMAGE,e=ji.DEFAULT_MAPPING,n=1001,i=1001,r=1006,a=1008,s=1023,o=Ae,l=ji.DEFAULT_ANISOTROPY,c=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Hi++}),this.uuid=_i(),this.name="",this.source=new Gi(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=a,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=o,this.offset=new Ei(0,0),this.repeat=new Ei(1,1),this.center=new Ei(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ii,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=c,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,this.normalized=!1}get width(){return this.source.getSize(Wi).x}get height(){return this.source.getSize(Wi).y}get depth(){return this.source.getSize(Wi).z}get image(){return this.source.data}set image(t){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.normalized=t.normalized,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 n=t[e];if(void 0===n){ci(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const i=this[e];void 0!==i?i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[e]=n:ci(`Texture.setValues(): property '${e}' does not exist.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const n={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,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(300!==this.mapping)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case _e:t.x=t.x-Math.floor(t.x);break;case ye:t.x=t.x<0?0:1;break;case xe:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case _e:t.y=t.y-Math.floor(t.y);break;case ye:t.y=t.y<0?0:1;break;case xe:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){!0===t&&this.pmremVersion++}}ji.DEFAULT_IMAGE=null,ji.DEFAULT_MAPPING=300,ji.DEFAULT_ANISOTROPY=1;class Xi{static{Xi.prototype.isVector4=!0}constructor(t=0,e=0,n=0,i=1){this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*e+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*e+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*e+a[7]*n+a[11]*i+a[15]*r,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,n,i,r;const a=.01,s=.1,o=t.elements,l=o[0],c=o[4],h=o[8],d=o[1],u=o[5],p=o[9],m=o[2],f=o[6],g=o[10];if(Math.abs(c-d)<a&&Math.abs(h-m)<a&&Math.abs(p-f)<a){if(Math.abs(c+d)<s&&Math.abs(h+m)<s&&Math.abs(p+f)<s&&Math.abs(l+u+g-3)<s)return this.set(1,0,0,0),this;e=Math.PI;const t=(l+1)/2,o=(u+1)/2,v=(g+1)/2,_=(c+d)/4,y=(h+m)/4,x=(p+f)/4;return t>o&&t>v?t<a?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(t),i=_/n,r=y/n):o>v?o<a?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(o),n=_/i,r=x/i):v<a?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(v),n=y/r,i=x/r),this.set(n,i,r,e),this}let v=Math.sqrt((f-p)*(f-p)+(h-m)*(h-m)+(d-c)*(d-c));return Math.abs(v)<.001&&(v=1),this.x=(f-p)/v,this.y=(h-m)/v,this.z=(d-c)/v,this.w=Math.acos((l+u+g-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=yi(this.x,t.x,e.x),this.y=yi(this.y,t.y,e.y),this.z=yi(this.z,t.z,e.z),this.w=yi(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=yi(this.x,t,e),this.y=yi(this.y,t,e),this.z=yi(this.z,t,e),this.w=yi(this.w,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(yi(n,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,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class qi extends pi{constructor(t=1,e=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:we,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=n.depth,this.scissor=new Xi(0,0,t,e),this.scissorTest=!1,this.viewport=new Xi(0,0,t,e),this.textures=[];const i={width:t,height:e,depth:n.depth},r=new ji(i),a=n.count;for(let t=0;t<a;t++)this.textures[t]=r.clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(t={}){const e={minFilter:we,generateMipmaps:!1,flipY:!1,internalFormat:null};void 0!==t.mapping&&(e.mapping=t.mapping),void 0!==t.wrapS&&(e.wrapS=t.wrapS),void 0!==t.wrapT&&(e.wrapT=t.wrapT),void 0!==t.wrapR&&(e.wrapR=t.wrapR),void 0!==t.magFilter&&(e.magFilter=t.magFilter),void 0!==t.minFilter&&(e.minFilter=t.minFilter),void 0!==t.format&&(e.format=t.format),void 0!==t.type&&(e.type=t.type),void 0!==t.anisotropy&&(e.anisotropy=t.anisotropy),void 0!==t.colorSpace&&(e.colorSpace=t.colorSpace),void 0!==t.flipY&&(e.flipY=t.flipY),void 0!==t.generateMipmaps&&(e.generateMipmaps=t.generateMipmaps),void 0!==t.internalFormat&&(e.internalFormat=t.internalFormat);for(let t=0;t<this.textures.length;t++)this.textures[t].setValues(e)}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){null!==this._depthTexture&&(this._depthTexture.renderTarget=null),null!==t&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=t,this.textures[i].image.height=e,this.textures[i].image.depth=n,!0!==this.textures[i].isData3DTexture&&(this.textures[i].isArrayTexture=this.textures[i].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,n=t.textures.length;e<n;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 Gi(n)}return this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,null!==t.depthTexture&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this.multiview=t.multiview,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Yi extends qi{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class Zi extends ji{constructor(t=null,e=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=be,this.minFilter=be,this.wrapR=ye,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class $i extends ji{constructor(t=null,e=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=be,this.minFilter=be,this.wrapR=ye,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ji{static{Ji.prototype.isMatrix4=!0}constructor(t,e,n,i,r,a,s,o,l,c,h,d,u,p,m,f){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,n,i,r,a,s,o,l,c,h,d,u,p,m,f)}set(t,e,n,i,r,a,s,o,l,c,h,d,u,p,m,f){const g=this.elements;return g[0]=t,g[4]=e,g[8]=n,g[12]=i,g[1]=r,g[5]=a,g[9]=s,g[13]=o,g[2]=l,g[6]=c,g[10]=h,g[14]=d,g[3]=u,g[7]=p,g[11]=m,g[15]=f,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new Ji).fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return 0===this.determinant()?(t.set(1,0,0),e.set(0,1,0),n.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){if(0===t.determinant())return this.identity();const e=this.elements,n=t.elements,i=1/Ki.setFromMatrixColumn(t,0).length(),r=1/Ki.setFromMatrixColumn(t,1).length(),a=1/Ki.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,i=t.y,r=t.z,a=Math.cos(n),s=Math.sin(n),o=Math.cos(i),l=Math.sin(i),c=Math.cos(r),h=Math.sin(r);if("XYZ"===t.order){const t=a*c,n=a*h,i=s*c,r=s*h;e[0]=o*c,e[4]=-o*h,e[8]=l,e[1]=n+i*l,e[5]=t-r*l,e[9]=-s*o,e[2]=r-t*l,e[6]=i+n*l,e[10]=a*o}else if("YXZ"===t.order){const t=o*c,n=o*h,i=l*c,r=l*h;e[0]=t+r*s,e[4]=i*s-n,e[8]=a*l,e[1]=a*h,e[5]=a*c,e[9]=-s,e[2]=n*s-i,e[6]=r+t*s,e[10]=a*o}else if("ZXY"===t.order){const t=o*c,n=o*h,i=l*c,r=l*h;e[0]=t-r*s,e[4]=-a*h,e[8]=i+n*s,e[1]=n+i*s,e[5]=a*c,e[9]=r-t*s,e[2]=-a*l,e[6]=s,e[10]=a*o}else if("ZYX"===t.order){const t=a*c,n=a*h,i=s*c,r=s*h;e[0]=o*c,e[4]=i*l-n,e[8]=t*l+r,e[1]=o*h,e[5]=r*l+t,e[9]=n*l-i,e[2]=-l,e[6]=s*o,e[10]=a*o}else if("YZX"===t.order){const t=a*o,n=a*l,i=s*o,r=s*l;e[0]=o*c,e[4]=r-t*h,e[8]=i*h+n,e[1]=h,e[5]=a*c,e[9]=-s*c,e[2]=-l*c,e[6]=n*h+i,e[10]=t-r*h}else if("XZY"===t.order){const t=a*o,n=a*l,i=s*o,r=s*l;e[0]=o*c,e[4]=-h,e[8]=l*c,e[1]=t*h+r,e[5]=a*c,e[9]=n*h-i,e[2]=i*h-n,e[6]=s*c,e[10]=r*h+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(tr,t,er)}lookAt(t,e,n){const i=this.elements;return rr.subVectors(t,e),0===rr.lengthSq()&&(rr.z=1),rr.normalize(),nr.crossVectors(n,rr),0===nr.lengthSq()&&(1===Math.abs(n.z)?rr.x+=1e-4:rr.z+=1e-4,rr.normalize(),nr.crossVectors(n,rr)),nr.normalize(),ir.crossVectors(rr,nr),i[0]=nr.x,i[4]=ir.x,i[8]=rr.x,i[1]=nr.y,i[5]=ir.y,i[9]=rr.y,i[2]=nr.z,i[6]=ir.z,i[10]=rr.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,a=n[0],s=n[4],o=n[8],l=n[12],c=n[1],h=n[5],d=n[9],u=n[13],p=n[2],m=n[6],f=n[10],g=n[14],v=n[3],_=n[7],y=n[11],x=n[15],b=i[0],S=i[4],M=i[8],w=i[12],E=i[1],T=i[5],A=i[9],C=i[13],R=i[2],I=i[6],P=i[10],L=i[14],D=i[3],N=i[7],O=i[11],U=i[15];return r[0]=a*b+s*E+o*R+l*D,r[4]=a*S+s*T+o*I+l*N,r[8]=a*M+s*A+o*P+l*O,r[12]=a*w+s*C+o*L+l*U,r[1]=c*b+h*E+d*R+u*D,r[5]=c*S+h*T+d*I+u*N,r[9]=c*M+h*A+d*P+u*O,r[13]=c*w+h*C+d*L+u*U,r[2]=p*b+m*E+f*R+g*D,r[6]=p*S+m*T+f*I+g*N,r[10]=p*M+m*A+f*P+g*O,r[14]=p*w+m*C+f*L+g*U,r[3]=v*b+_*E+y*R+x*D,r[7]=v*S+_*T+y*I+x*N,r[11]=v*M+_*A+y*P+x*O,r[15]=v*w+_*C+y*L+x*U,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],i=t[8],r=t[12],a=t[1],s=t[5],o=t[9],l=t[13],c=t[2],h=t[6],d=t[10],u=t[14],p=t[3],m=t[7],f=t[11],g=t[15],v=o*u-l*d,_=s*u-l*h,y=s*d-o*h,x=a*u-l*c,b=a*d-o*c,S=a*h-s*c;return e*(m*v-f*_+g*y)-n*(p*v-f*x+g*b)+i*(p*_-m*x+g*S)-r*(p*y-m*b+f*S)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],s=t[5],o=t[6],l=t[7],c=t[8],h=t[9],d=t[10],u=t[11],p=t[12],m=t[13],f=t[14],g=t[15],v=e*s-n*a,_=e*o-i*a,y=e*l-r*a,x=n*o-i*s,b=n*l-r*s,S=i*l-r*o,M=c*m-h*p,w=c*f-d*p,E=c*g-u*p,T=h*f-d*m,A=h*g-u*m,C=d*g-u*f,R=v*C-_*A+y*T+x*E-b*w+S*M;if(0===R)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const I=1/R;return t[0]=(s*C-o*A+l*T)*I,t[1]=(i*A-n*C-r*T)*I,t[2]=(m*S-f*b+g*x)*I,t[3]=(d*b-h*S-u*x)*I,t[4]=(o*E-a*C-l*w)*I,t[5]=(e*C-i*E+r*w)*I,t[6]=(f*y-p*S-g*_)*I,t[7]=(c*S-d*y+u*_)*I,t[8]=(a*A-s*E+l*M)*I,t[9]=(n*E-e*A-r*M)*I,t[10]=(p*b-m*y+g*v)*I,t[11]=(h*y-c*b-u*v)*I,t[12]=(s*w-a*T-o*M)*I,t[13]=(e*T-n*w+i*M)*I,t[14]=(m*_-p*x-f*v)*I,t[15]=(c*x-h*_+d*v)*I,this}scale(t){const e=this.elements,n=t.x,i=t.y,r=t.z;return e[0]*=n,e[4]*=i,e[8]*=r,e[1]*=n,e[5]*=i,e[9]*=r,e[2]*=n,e[6]*=i,e[10]*=r,e[3]*=n,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),i=Math.sin(e),r=1-n,a=t.x,s=t.y,o=t.z,l=r*a,c=r*s;return this.set(l*a+n,l*s-i*o,l*o+i*s,0,l*s+i*o,c*s+n,c*o-i*a,0,l*o-i*s,c*o+i*a,r*o*o+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,r,a){return this.set(1,n,r,0,t,1,a,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){const i=this.elements,r=e._x,a=e._y,s=e._z,o=e._w,l=r+r,c=a+a,h=s+s,d=r*l,u=r*c,p=r*h,m=a*c,f=a*h,g=s*h,v=o*l,_=o*c,y=o*h,x=n.x,b=n.y,S=n.z;return i[0]=(1-(m+g))*x,i[1]=(u+y)*x,i[2]=(p-_)*x,i[3]=0,i[4]=(u-y)*b,i[5]=(1-(d+g))*b,i[6]=(f+v)*b,i[7]=0,i[8]=(p+_)*S,i[9]=(f-v)*S,i[10]=(1-(d+m))*S,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){const i=this.elements;t.x=i[12],t.y=i[13],t.z=i[14];const r=this.determinant();if(0===r)return n.set(1,1,1),e.identity(),this;let a=Ki.set(i[0],i[1],i[2]).length();const s=Ki.set(i[4],i[5],i[6]).length(),o=Ki.set(i[8],i[9],i[10]).length();r<0&&(a=-a),Qi.copy(this);const l=1/a,c=1/s,h=1/o;return Qi.elements[0]*=l,Qi.elements[1]*=l,Qi.elements[2]*=l,Qi.elements[4]*=c,Qi.elements[5]*=c,Qi.elements[6]*=c,Qi.elements[8]*=h,Qi.elements[9]*=h,Qi.elements[10]*=h,e.setFromRotationMatrix(Qi),n.x=a,n.y=s,n.z=o,this}makePerspective(t,e,n,i,r,a,s=2e3,o=!1){const l=this.elements,c=2*r/(e-t),h=2*r/(n-i),d=(e+t)/(e-t),u=(n+i)/(n-i);let p,m;if(o)p=r/(a-r),m=a*r/(a-r);else if(s===ti)p=-(a+r)/(a-r),m=-2*a*r/(a-r);else{if(s!==ei)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+s);p=-a/(a-r),m=-a*r/(a-r)}return l[0]=c,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=h,l[9]=u,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,n,i,r,a,s=2e3,o=!1){const l=this.elements,c=2/(e-t),h=2/(n-i),d=-(e+t)/(e-t),u=-(n+i)/(n-i);let p,m;if(o)p=1/(a-r),m=a/(a-r);else if(s===ti)p=-2/(a-r),m=-(a+r)/(a-r);else{if(s!==ei)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+s);p=-1/(a-r),m=-r/(a-r)}return l[0]=c,l[4]=0,l[8]=0,l[12]=d,l[1]=0,l[5]=h,l[9]=0,l[13]=u,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,n=t.elements;for(let t=0;t<16;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const Ki=new Ai,Qi=new Ji,tr=new Ai(0,0,0),er=new Ai(1,1,1),nr=new Ai,ir=new Ai,rr=new Ai,ar=new Ji,sr=new Ti;class or{constructor(t=0,e=0,n=0,i=or.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const i=t.elements,r=i[0],a=i[4],s=i[8],o=i[1],l=i[5],c=i[9],h=i[2],d=i[6],u=i[10];switch(e){case"XYZ":this._y=Math.asin(yi(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-c,u),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-yi(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(s,u),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(yi(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,u),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-yi(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,u),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(yi(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(s,u));break;case"XZY":this._z=Math.asin(-yi(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(s,r)):(this._x=Math.atan2(-c,u),this._y=0);break;default:ci("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===n&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return ar.makeRotationFromQuaternion(t),this.setFromRotationMatrix(ar,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return sr.setFromEuler(this),this.setFromQuaternion(sr,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}or.DEFAULT_ORDER="XYZ";class lr{constructor(){this.mask=1}set(t){this.mask=1<<t>>>0}enable(t){this.mask|=1<<t}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t}disable(t){this.mask&=~(1<<t)}disableAll(){this.mask=0}test(t){return 0!==(this.mask&t.mask)}isEnabled(t){return!!(this.mask&1<<t)}}let cr=0;const hr=new Ai,dr=new Ti,ur=new Ji,pr=new Ai,mr=new Ai,fr=new Ai,gr=new Ti,vr=new Ai(1,0,0),_r=new Ai(0,1,0),yr=new Ai(0,0,1),xr={type:"added"},br={type:"removed"},Sr={type:"childadded",child:null},Mr={type:"childremoved",child:null};class wr extends pi{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:cr++}),this.uuid=_i(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=wr.DEFAULT_UP.clone();const t=new Ai,e=new or,n=new Ti,i=new Ai(1,1,1);e._onChange((function(){n.setFromEuler(e,!1)})),n._onChange((function(){e.setFromQuaternion(n,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Ji},normalMatrix:{value:new Ii}}),this.matrix=new Ji,this.matrixWorld=new Ji,this.matrixAutoUpdate=wr.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=wr.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new lr,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 dr.setFromAxisAngle(t,e),this.quaternion.multiply(dr),this}rotateOnWorldAxis(t,e){return dr.setFromAxisAngle(t,e),this.quaternion.premultiply(dr),this}rotateX(t){return this.rotateOnAxis(vr,t)}rotateY(t){return this.rotateOnAxis(_r,t)}rotateZ(t){return this.rotateOnAxis(yr,t)}translateOnAxis(t,e){return hr.copy(t).applyQuaternion(this.quaternion),this.position.add(hr.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(vr,t)}translateY(t){return this.translateOnAxis(_r,t)}translateZ(t){return this.translateOnAxis(yr,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(ur.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?pr.copy(t):pr.set(t,e,n);const i=this.parent;this.updateWorldMatrix(!0,!1),mr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ur.lookAt(mr,pr,this.up):ur.lookAt(pr,mr,this.up),this.quaternion.setFromRotationMatrix(ur),i&&(ur.extractRotation(i.matrixWorld),dr.setFromRotationMatrix(ur),this.quaternion.premultiply(dr.invert()))}add(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return t===this?(hi("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(xr),Sr.child=t,this.dispatchEvent(Sr),Sr.child=null):hi("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.remove(arguments[t]);return this}const e=this.children.indexOf(t);return-1!==e&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(br),Mr.child=t,this.dispatchEvent(Mr),Mr.child=null),this}removeFromParent(){const t=this.parent;return null!==t&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),ur.copy(this.matrixWorld).invert(),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),ur.multiply(t.parent.matrixWorld)),t.applyMatrix4(ur),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(xr),Sr.child=t,this.dispatchEvent(Sr),Sr.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,i=this.children.length;n<i;n++){const i=this.children[n].getObjectByProperty(t,e);if(void 0!==i)return i}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const i=this.children;for(let r=0,a=i.length;r<a;r++)i[r].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(mr,t,fr),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(mr,gr,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverse(t)}traverseVisible(t){if(!1===this.visible)return;t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;null!==e&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const t=this.pivot;if(null!==t){const e=t.x,n=t.y,i=t.z,r=this.matrix.elements;r[12]+=e-r[0]*e-r[4]*n-r[8]*i,r[13]+=n-r[1]*e-r[5]*n-r[9]*i,r[14]+=i-r[2]*e-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e){const n=this.parent;if(!0===t&&null!==n&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),!0===e){const t=this.children;for(let e=0,n=t.length;e<n;e++)t[e].updateWorldMatrix(!1,!0)}}toJSON(t){const e=void 0===t||"string"==typeof t,n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};function r(e,n){return void 0===e[n.uuid]&&(e[n.uuid]=n.toJSON(t)),n.uuid}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),!0===this.castShadow&&(i.castShadow=!0),!0===this.receiveShadow&&(i.receiveShadow=!0),!1===this.visible&&(i.visible=!1),!1===this.frustumCulled&&(i.frustumCulled=!1),0!==this.renderOrder&&(i.renderOrder=this.renderOrder),!1!==this.static&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),null!==this.pivot&&(i.pivot=this.pivot.toArray()),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),void 0!==this.morphTargetDictionary&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),void 0!==this.morphTargetInfluences&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map((t=>({...t,boundingBox:t.boundingBox?t.boundingBox.toJSON():void 0,boundingSphere:t.boundingSphere?t.boundingSphere.toJSON():void 0}))),i.instanceInfo=this._instanceInfo.map((t=>({...t}))),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(t),i.indirectTexture=this._indirectTexture.toJSON(t),null!==this._colorsTexture&&(i.colorsTexture=this._colorsTexture.toJSON(t)),null!==this.boundingSphere&&(i.boundingSphere=this.boundingSphere.toJSON()),null!==this.boundingBox&&(i.boundingBox=this.boundingBox.toJSON())),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const n=e.shapes;if(Array.isArray(n))for(let e=0,i=n.length;e<i;e++){const i=n[e];r(t.shapes,i)}else r(t.shapes,n)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const e=[];for(let n=0,i=this.material.length;n<i;n++)e.push(r(t.materials,this.material[n]));i.material=e}else i.material=r(t.materials,this.material);if(this.children.length>0){i.children=[];for(let e=0;e<this.children.length;e++)i.children.push(this.children[e].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let e=0;e<this.animations.length;e++){const n=this.animations[e];i.animations.push(r(t.animations,n))}}if(e){const e=a(t.geometries),i=a(t.materials),r=a(t.textures),s=a(t.images),o=a(t.shapes),l=a(t.skeletons),c=a(t.animations),h=a(t.nodes);e.length>0&&(n.geometries=e),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),s.length>0&&(n.images=s),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c),h.length>0&&(n.nodes=h)}return n.object=i,n;function a(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.pivot=null!==t.pivot?t.pivot.clone():null,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)),!0===e)for(let e=0;e<t.children.length;e++){const n=t.children[e];this.add(n.clone())}return this}}wr.DEFAULT_UP=new Ai(0,1,0),wr.DEFAULT_MATRIX_AUTO_UPDATE=!0,wr.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Er extends wr{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Tr={type:"move"};class Ar{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new Er,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new Er,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Ai,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Ai),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new Er,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Ai,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Ai,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(t){return null!==this._targetRay&&this._targetRay.dispatchEvent(t),null!==this._grip&&this._grip.dispatchEvent(t),null!==this._hand&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(t,e,n){let i=null,r=null,a=null;const s=this._targetRay,o=this._grip,l=this._hand;if(t&&"visible-blurred"!==e.session.visibilityState){if(l&&t.hand){a=!0;for(const i of t.hand.values()){const t=e.getJointPose(i,n),r=this._getHandJoint(l,i);null!==t&&(r.matrix.fromArray(t.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.matrixWorldNeedsUpdate=!0,r.jointRadius=t.radius),r.visible=null!==t}const i=l.joints["index-finger-tip"],r=l.joints["thumb-tip"],s=i.position.distanceTo(r.position),o=.02,c=.005;l.inputState.pinching&&s>o+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&s<=o-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==o&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,o.eventsEnabled&&o.dispatchEvent({type:"gripUpdated",data:t,target:this})));null!==s&&(i=e.getPose(t.targetRaySpace,n),null===i&&null!==r&&(i=r),null!==i&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,this.dispatchEvent(Tr)))}return null!==s&&(s.visible=null!==i),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==a),this}_getHandJoint(t,e){if(void 0===t.joints[e.jointName]){const n=new Er;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}const Cr={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},Rr={h:0,s:0,l:0},Ir={h:0,s:0,l:0};function Pr(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}class Lr{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(void 0===e&&void 0===n){const e=t;e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=kn){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,Oi.colorSpaceToWorking(this,e),this}setRGB(t,e,n,i=Oi.workingColorSpace){return this.r=t,this.g=e,this.b=n,Oi.colorSpaceToWorking(this,i),this}setHSL(t,e,n,i=Oi.workingColorSpace){if(t=xi(t,1),e=yi(e,0,1),n=yi(n,0,1),0===e)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+e):n+e-n*e,r=2*n-i;this.r=Pr(r,i,t+1/3),this.g=Pr(r,i,t),this.b=Pr(r,i,t-1/3)}return Oi.colorSpaceToWorking(this,i),this}setStyle(t,e=kn){function n(e){void 0!==e&&parseFloat(e)<1&&ci("Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const a=i[1],s=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:ci("Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const n=i[1],r=n.length;if(3===r)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,e);if(6===r)return this.setHex(parseInt(n,16),e);ci("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=kn){const n=Cr[t.toLowerCase()];return void 0!==n?this.setHex(n,e):ci("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=Ui(t.r),this.g=Ui(t.g),this.b=Ui(t.b),this}copyLinearToSRGB(t){return this.r=Fi(t.r),this.g=Fi(t.g),this.b=Fi(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=kn){return Oi.workingToColorSpace(Dr.copy(this),t),65536*Math.round(yi(255*Dr.r,0,255))+256*Math.round(yi(255*Dr.g,0,255))+Math.round(yi(255*Dr.b,0,255))}getHexString(t=kn){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Oi.workingColorSpace){Oi.workingToColorSpace(Dr.copy(this),e);const n=Dr.r,i=Dr.g,r=Dr.b,a=Math.max(n,i,r),s=Math.min(n,i,r);let o,l;const c=(s+a)/2;if(s===a)o=0,l=0;else{const t=a-s;switch(l=c<=.5?t/(a+s):t/(2-a-s),a){case n:o=(i-r)/t+(i<r?6:0);break;case i:o=(r-n)/t+2;break;case r:o=(n-i)/t+4}o/=6}return t.h=o,t.s=l,t.l=c,t}getRGB(t,e=Oi.workingColorSpace){return Oi.workingToColorSpace(Dr.copy(this),e),t.r=Dr.r,t.g=Dr.g,t.b=Dr.b,t}getStyle(t=kn){Oi.workingToColorSpace(Dr.copy(this),t);const e=Dr.r,n=Dr.g,i=Dr.b;return t!==kn?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(255*e)},${Math.round(255*n)},${Math.round(255*i)})`}offsetHSL(t,e,n){return this.getHSL(Rr),this.setHSL(Rr.h+t,Rr.s+e,Rr.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(Rr),t.getHSL(Ir);const n=bi(Rr.h,Ir.h,e),i=bi(Rr.s,Ir.s,e),r=bi(Rr.l,Ir.l,e);return this.setHSL(n,i,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,i=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*i,this.g=r[1]*e+r[4]*n+r[7]*i,this.b=r[2]*e+r[5]*n+r[8]*i,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 Dr=new Lr;Lr.NAMES=Cr;class Nr{constructor(t,e=25e-5){this.isFogExp2=!0,this.name="",this.color=new Lr(t),this.density=e}clone(){return new Nr(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class Or{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new Lr(t),this.near=e,this.far=n}clone(){return new Or(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Ur extends wr{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new or,this.environmentIntensity=1,this.environmentRotation=new or,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return null!==this.fog&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}const Fr=new Ai,zr=new Ai,kr=new Ai,Br=new Ai,Gr=new Ai,Vr=new Ai,Hr=new Ai,Wr=new Ai,jr=new Ai,Xr=new Ai,qr=new Xi,Yr=new Xi,Zr=new Xi;class $r{constructor(t=new Ai,e=new Ai,n=new Ai){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){i.subVectors(n,e),Fr.subVectors(t,e),i.cross(Fr);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(t,e,n,i,r){Fr.subVectors(i,e),zr.subVectors(n,e),kr.subVectors(t,e);const a=Fr.dot(Fr),s=Fr.dot(zr),o=Fr.dot(kr),l=zr.dot(zr),c=zr.dot(kr),h=a*l-s*s;if(0===h)return r.set(0,0,0),null;const d=1/h,u=(l*o-s*c)*d,p=(a*c-s*o)*d;return r.set(1-u-p,p,u)}static containsPoint(t,e,n,i){return null!==this.getBarycoord(t,e,n,i,Br)&&Br.x>=0&&Br.y>=0&&Br.x+Br.y<=1}static getInterpolation(t,e,n,i,r,a,s,o){return null===this.getBarycoord(t,e,n,i,Br)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(r,Br.x),o.addScaledVector(a,Br.y),o.addScaledVector(s,Br.z),o)}static getInterpolatedAttribute(t,e,n,i,r,a){return qr.setScalar(0),Yr.setScalar(0),Zr.setScalar(0),qr.fromBufferAttribute(t,e),Yr.fromBufferAttribute(t,n),Zr.fromBufferAttribute(t,i),a.setScalar(0),a.addScaledVector(qr,r.x),a.addScaledVector(Yr,r.y),a.addScaledVector(Zr,r.z),a}static isFrontFacing(t,e,n,i){return Fr.subVectors(n,e),zr.subVectors(t,e),Fr.cross(zr).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),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 Fr.subVectors(this.c,this.b),zr.subVectors(this.a,this.b),.5*Fr.cross(zr).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return $r.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return $r.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,r){return $r.getInterpolation(t,this.a,this.b,this.c,e,n,i,r)}containsPoint(t){return $r.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return $r.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,i=this.b,r=this.c;let a,s;Gr.subVectors(i,n),Vr.subVectors(r,n),Wr.subVectors(t,n);const o=Gr.dot(Wr),l=Vr.dot(Wr);if(o<=0&&l<=0)return e.copy(n);jr.subVectors(t,i);const c=Gr.dot(jr),h=Vr.dot(jr);if(c>=0&&h<=c)return e.copy(i);const d=o*h-c*l;if(d<=0&&o>=0&&c<=0)return a=o/(o-c),e.copy(n).addScaledVector(Gr,a);Xr.subVectors(t,r);const u=Gr.dot(Xr),p=Vr.dot(Xr);if(p>=0&&u<=p)return e.copy(r);const m=u*l-o*p;if(m<=0&&l>=0&&p<=0)return s=l/(l-p),e.copy(n).addScaledVector(Vr,s);const f=c*p-u*h;if(f<=0&&h-c>=0&&u-p>=0)return Hr.subVectors(r,i),s=(h-c)/(h-c+(u-p)),e.copy(i).addScaledVector(Hr,s);const g=1/(f+m+d);return a=m*g,s=d*g,e.copy(n).addScaledVector(Gr,a).addScaledVector(Vr,s)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}class Jr{constructor(t=new Ai(1/0,1/0,1/0),e=new Ai(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(Qr.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(Qr.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=Qr.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(void 0!==n){const i=n.getAttribute("position");if(!0===e&&void 0!==i&&!0!==t.isInstancedMesh)for(let e=0,n=i.count;e<n;e++)!0===t.isMesh?t.getVertexPosition(e,Qr):Qr.fromBufferAttribute(i,e),Qr.applyMatrix4(t.matrixWorld),this.expandByPoint(Qr);else void 0!==t.boundingBox?(null===t.boundingBox&&t.computeBoundingBox(),ta.copy(t.boundingBox)):(null===n.boundingBox&&n.computeBoundingBox(),ta.copy(n.boundingBox)),ta.applyMatrix4(t.matrixWorld),this.union(ta)}const i=t.children;for(let t=0,n=i.length;t<n;t++)this.expandByObject(i[t],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,Qr),Qr.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(oa),la.subVectors(this.max,oa),ea.subVectors(t.a,oa),na.subVectors(t.b,oa),ia.subVectors(t.c,oa),ra.subVectors(na,ea),aa.subVectors(ia,na),sa.subVectors(ea,ia);let e=[0,-ra.z,ra.y,0,-aa.z,aa.y,0,-sa.z,sa.y,ra.z,0,-ra.x,aa.z,0,-aa.x,sa.z,0,-sa.x,-ra.y,ra.x,0,-aa.y,aa.x,0,-sa.y,sa.x,0];return!!da(e,ea,na,ia,la)&&(e=[1,0,0,0,1,0,0,0,1],!!da(e,ea,na,ia,la)&&(ca.crossVectors(ra,aa),e=[ca.x,ca.y,ca.z],da(e,ea,na,ia,la)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Qr).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(Qr).length()),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(Kr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Kr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Kr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Kr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Kr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Kr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Kr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Kr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Kr)),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 Kr=[new Ai,new Ai,new Ai,new Ai,new Ai,new Ai,new Ai,new Ai],Qr=new Ai,ta=new Jr,ea=new Ai,na=new Ai,ia=new Ai,ra=new Ai,aa=new Ai,sa=new Ai,oa=new Ai,la=new Ai,ca=new Ai,ha=new Ai;function da(t,e,n,i,r){for(let a=0,s=t.length-3;a<=s;a+=3){ha.fromArray(t,a);const s=r.x*Math.abs(ha.x)+r.y*Math.abs(ha.y)+r.z*Math.abs(ha.z),o=e.dot(ha),l=n.dot(ha),c=i.dot(ha);if(Math.max(-Math.max(o,l,c),Math.min(o,l,c))>s)return!1}return!0}const ua=new Ai,pa=new Ei;let ma=0;class fa extends pi{constructor(t,e,n=!1){if(super(),Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:ma++}),this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=n,this.usage=Kn,this.updateRanges=[],this.gpuType=De,this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[t+i]=e.array[n+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(2===this.itemSize)for(let e=0,n=this.count;e<n;e++)pa.fromBufferAttribute(this,e),pa.applyMatrix3(t),this.setXY(e,pa.x,pa.y);else if(3===this.itemSize)for(let e=0,n=this.count;e<n;e++)ua.fromBufferAttribute(this,e),ua.applyMatrix3(t),this.setXYZ(e,ua.x,ua.y,ua.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)ua.fromBufferAttribute(this,e),ua.applyMatrix4(t),this.setXYZ(e,ua.x,ua.y,ua.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)ua.fromBufferAttribute(this,e),ua.applyNormalMatrix(t),this.setXYZ(e,ua.x,ua.y,ua.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)ua.fromBufferAttribute(this,e),ua.transformDirection(t),this.setXYZ(e,ua.x,ua.y,ua.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=Si(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=Mi(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Si(e,this.array)),e}setX(t,e){return this.normalized&&(e=Mi(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Si(e,this.array)),e}setY(t,e){return this.normalized&&(e=Mi(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Si(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Mi(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Si(e,this.array)),e}setW(t,e){return this.normalized&&(e=Mi(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=Mi(e,this.array),n=Mi(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=Mi(e,this.array),n=Mi(n,this.array),i=Mi(i,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t*=this.itemSize,this.normalized&&(e=Mi(e,this.array),n=Mi(n,this.array),i=Mi(i,this.array),r=Mi(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(t.name=this.name),this.usage!==Kn&&(t.usage=this.usage),t}dispose(){this.dispatchEvent({type:"dispose"})}}class ga extends fa{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class va extends fa{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class _a extends fa{constructor(t,e,n){super(new Float32Array(t),e,n)}}const ya=new Jr,xa=new Ai,ba=new Ai;class Sa{constructor(t=new Ai,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;void 0!==e?n.copy(e):ya.setFromPoints(t).getCenter(n);let i=0;for(let e=0,r=t.length;e<r;e++)i=Math.max(i,n.distanceToSquared(t[e]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;xa.subVectors(t,this.center);const e=xa.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),n=.5*(t-this.radius);this.center.addScaledVector(xa,n/t),this.radius+=n}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):(ba.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(xa.copy(t.center).add(ba)),this.expandByPoint(xa.copy(t.center).sub(ba))),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 Ma=0;const wa=new Ji,Ea=new wr,Ta=new Ai,Aa=new Jr,Ca=new Jr,Ra=new Ai;class Ia extends pi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ma++}),this.uuid=_i(),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(function(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}(t)?va:ga)(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 void 0!==this.attributes[t]}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const e=(new Ii).getNormalMatrix(t);n.applyNormalMatrix(e),n.needsUpdate=!0}const i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(t),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(t){return wa.makeRotationFromQuaternion(t),this.applyMatrix4(wa),this}rotateX(t){return wa.makeRotationX(t),this.applyMatrix4(wa),this}rotateY(t){return wa.makeRotationY(t),this.applyMatrix4(wa),this}rotateZ(t){return wa.makeRotationZ(t),this.applyMatrix4(wa),this}translate(t,e,n){return wa.makeTranslation(t,e,n),this.applyMatrix4(wa),this}scale(t,e,n){return wa.makeScale(t,e,n),this.applyMatrix4(wa),this}lookAt(t){return Ea.lookAt(t),Ea.updateMatrix(),this.applyMatrix4(Ea.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ta).negate(),this.translate(Ta.x,Ta.y,Ta.z),this}setFromPoints(t){const e=this.getAttribute("position");if(void 0===e){const e=[];for(let n=0,i=t.length;n<i;n++){const i=t[n];e.push(i.x,i.y,i.z||0)}this.setAttribute("position",new _a(e,3))}else{const n=Math.min(t.length,e.count);for(let i=0;i<n;i++){const n=t[i];e.setXYZ(i,n.x,n.y,n.z||0)}t.length>e.count&&ci("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Jr);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return hi("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),void this.boundingBox.set(new Ai(-1/0,-1/0,-1/0),new Ai(1/0,1/0,1/0));if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t<n;t++){const n=e[t];Aa.setFromBufferAttribute(n),this.morphTargetsRelative?(Ra.addVectors(this.boundingBox.min,Aa.min),this.boundingBox.expandByPoint(Ra),Ra.addVectors(this.boundingBox.max,Aa.max),this.boundingBox.expandByPoint(Ra)):(this.boundingBox.expandByPoint(Aa.min),this.boundingBox.expandByPoint(Aa.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&hi('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new Sa);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return hi("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),void this.boundingSphere.set(new Ai,1/0);if(t){const n=this.boundingSphere.center;if(Aa.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t<n;t++){const n=e[t];Ca.setFromBufferAttribute(n),this.morphTargetsRelative?(Ra.addVectors(Aa.min,Ca.min),Aa.expandByPoint(Ra),Ra.addVectors(Aa.max,Ca.max),Aa.expandByPoint(Ra)):(Aa.expandByPoint(Ca.min),Aa.expandByPoint(Ca.max))}Aa.getCenter(n);let i=0;for(let e=0,r=t.count;e<r;e++)Ra.fromBufferAttribute(t,e),i=Math.max(i,n.distanceToSquared(Ra));if(e)for(let r=0,a=e.length;r<a;r++){const a=e[r],s=this.morphTargetsRelative;for(let e=0,r=a.count;e<r;e++)Ra.fromBufferAttribute(a,e),s&&(Ta.fromBufferAttribute(t,e),Ra.add(Ta)),i=Math.max(i,n.distanceToSquared(Ra))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&hi('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(null===t||void 0===e.position||void 0===e.normal||void 0===e.uv)return void hi("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const n=e.position,i=e.normal,r=e.uv;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new fa(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),s=[],o=[];for(let t=0;t<n.count;t++)s[t]=new Ai,o[t]=new Ai;const l=new Ai,c=new Ai,h=new Ai,d=new Ei,u=new Ei,p=new Ei,m=new Ai,f=new Ai;function g(t,e,i){l.fromBufferAttribute(n,t),c.fromBufferAttribute(n,e),h.fromBufferAttribute(n,i),d.fromBufferAttribute(r,t),u.fromBufferAttribute(r,e),p.fromBufferAttribute(r,i),c.sub(l),h.sub(l),u.sub(d),p.sub(d);const a=1/(u.x*p.y-p.x*u.y);isFinite(a)&&(m.copy(c).multiplyScalar(p.y).addScaledVector(h,-u.y).multiplyScalar(a),f.copy(h).multiplyScalar(u.x).addScaledVector(c,-p.x).multiplyScalar(a),s[t].add(m),s[e].add(m),s[i].add(m),o[t].add(f),o[e].add(f),o[i].add(f))}let v=this.groups;0===v.length&&(v=[{start:0,count:t.count}]);for(let e=0,n=v.length;e<n;++e){const n=v[e],i=n.start;for(let e=i,r=i+n.count;e<r;e+=3)g(t.getX(e+0),t.getX(e+1),t.getX(e+2))}const _=new Ai,y=new Ai,x=new Ai,b=new Ai;function S(t){x.fromBufferAttribute(i,t),b.copy(x);const e=s[t];_.copy(e),_.sub(x.multiplyScalar(x.dot(e))).normalize(),y.crossVectors(b,e);const n=y.dot(o[t])<0?-1:1;a.setXYZW(t,_.x,_.y,_.z,n)}for(let e=0,n=v.length;e<n;++e){const n=v[e],i=n.start;for(let e=i,r=i+n.count;e<r;e+=3)S(t.getX(e+0)),S(t.getX(e+1)),S(t.getX(e+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(void 0!==e){let n=this.getAttribute("normal");if(void 0===n)n=new fa(new Float32Array(3*e.count),3),this.setAttribute("normal",n);else for(let t=0,e=n.count;t<e;t++)n.setXYZ(t,0,0,0);const i=new Ai,r=new Ai,a=new Ai,s=new Ai,o=new Ai,l=new Ai,c=new Ai,h=new Ai;if(t)for(let d=0,u=t.count;d<u;d+=3){const u=t.getX(d+0),p=t.getX(d+1),m=t.getX(d+2);i.fromBufferAttribute(e,u),r.fromBufferAttribute(e,p),a.fromBufferAttribute(e,m),c.subVectors(a,r),h.subVectors(i,r),c.cross(h),s.fromBufferAttribute(n,u),o.fromBufferAttribute(n,p),l.fromBufferAttribute(n,m),s.add(c),o.add(c),l.add(c),n.setXYZ(u,s.x,s.y,s.z),n.setXYZ(p,o.x,o.y,o.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let t=0,s=e.count;t<s;t+=3)i.fromBufferAttribute(e,t+0),r.fromBufferAttribute(e,t+1),a.fromBufferAttribute(e,t+2),c.subVectors(a,r),h.subVectors(i,r),c.cross(h),n.setXYZ(t+0,c.x,c.y,c.z),n.setXYZ(t+1,c.x,c.y,c.z),n.setXYZ(t+2,c.x,c.y,c.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)Ra.fromBufferAttribute(t,e),Ra.normalize(),t.setXYZ(e,Ra.x,Ra.y,Ra.z)}toNonIndexed(){function t(t,e){const n=t.array,i=t.itemSize,r=t.normalized,a=new n.constructor(e.length*i);let s=0,o=0;for(let r=0,l=e.length;r<l;r++){s=t.isInterleavedBufferAttribute?e[r]*t.data.stride+t.offset:e[r]*i;for(let t=0;t<i;t++)a[o++]=n[s++]}return new fa(a,i,r)}if(null===this.index)return ci("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new Ia,n=this.index.array,i=this.attributes;for(const r in i){const a=t(i[r],n);e.setAttribute(r,a)}const r=this.morphAttributes;for(const i in r){const a=[],s=r[i];for(let e=0,i=s.length;e<i;e++){const i=t(s[e],n);a.push(i)}e.morphAttributes[i]=a}e.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let t=0,n=a.length;t<n;t++){const n=a[t];e.addGroup(n.start,n.count,n.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),void 0!==this.parameters){const e=this.parameters;for(const n in e)void 0!==e[n]&&(t[n]=e[n]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const e in n){const i=n[e];t.data.attributes[e]=i.toJSON(t.data)}const i={};let r=!1;for(const e in this.morphAttributes){const n=this.morphAttributes[e],a=[];for(let e=0,i=n.length;e<i;e++){const i=n[e];a.push(i.toJSON(t.data))}a.length>0&&(i[e]=a,r=!0)}r&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const s=this.boundingSphere;return null!==s&&(t.data.boundingSphere=s.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 n=t.index;null!==n&&this.setIndex(n.clone());const i=t.attributes;for(const t in i){const n=i[t];this.setAttribute(t,n.clone(e))}const r=t.morphAttributes;for(const t in r){const n=[],i=r[t];for(let t=0,r=i.length;t<r;t++)n.push(i[t].clone(e));this.morphAttributes[t]=n}this.morphTargetsRelative=t.morphTargetsRelative;const a=t.groups;for(let t=0,e=a.length;t<e;t++){const e=a[t];this.addGroup(e.start,e.count,e.materialIndex)}const s=t.boundingBox;null!==s&&(this.boundingBox=s.clone());const o=t.boundingSphere;return null!==o&&(this.boundingSphere=o.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Pa{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=Kn,this.updateRanges=[],this.version=0,this.uuid=_i()}onUploadCallback(){}set needsUpdate(t){!0===t&&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.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,r=this.stride;i<r;i++)this.array[t+i]=e.array[n+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=_i()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=_i()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const La=new Ai;class Da{constructor(t,e,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)La.fromBufferAttribute(this,e),La.applyMatrix4(t),this.setXYZ(e,La.x,La.y,La.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)La.fromBufferAttribute(this,e),La.applyNormalMatrix(t),this.setXYZ(e,La.x,La.y,La.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)La.fromBufferAttribute(this,e),La.transformDirection(t),this.setXYZ(e,La.x,La.y,La.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(n=Si(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=Mi(n,this.array)),this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){return this.normalized&&(e=Mi(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Mi(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Mi(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Mi(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Si(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Si(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Si(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Si(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Mi(e,this.array),n=Mi(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=Mi(e,this.array),n=Mi(n,this.array),i=Mi(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=Mi(e,this.array),n=Mi(n,this.array),i=Mi(i,this.array),r=Mi(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this.data.array[t+3]=r,this}clone(t){if(void 0===t){oi("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const n=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[n+e])}return new fa(new this.array.constructor(t),this.itemSize,this.normalized)}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Da(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(void 0===t){oi("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const n=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[n+e])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let Na,Oa=0;class Ua extends pi{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Oa++}),this.uuid=_i(),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=It,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Lr(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=Hn,this.stencilZFail=Hn,this.stencilZPass=Hn,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(void 0!==t)for(const e in t){const n=t[e];if(void 0===n){ci(`Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n:ci(`Material: '${e}' is not a property of THREE.${this.type}.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};function i(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),void 0!==this.dispersion&&(n.dispersion=this.dispersion),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapRotation&&(n.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),0!==this.side&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),204!==this.blendSrc&&(n.blendSrc=this.blendSrc),205!==this.blendDst&&(n.blendDst=this.blendDst),this.blendEquation!==It&&(n.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(n.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(n.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(n.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(n.depthFunc=this.depthFunc),!1===this.depthTest&&(n.depthTest=this.depthTest),!1===this.depthWrite&&(n.depthWrite=this.depthWrite),!1===this.colorWrite&&(n.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(n.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(n.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(n.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Hn&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Hn&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Hn&&(n.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(n.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=!0),!0===this.alphaToCoverage&&(n.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=!0),!0===this.forceSinglePass&&(n.forceSinglePass=!0),!1===this.allowOverride&&(n.allowOverride=!1),!0===this.wireframe&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),e){const e=i(t.textures),r=i(t.images);e.length>0&&(n.textures=e),r.length>0&&(n.images=r)}return n}clone(){return(new this.constructor).copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(null!==e){const t=e.length;n=new Array(t);for(let i=0;i!==t;++i)n[i]=e[i].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.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){!0===t&&this.version++}}class Fa extends Ua{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Lr(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}const za=new Ai,ka=new Ai,Ba=new Ai,Ga=new Ei,Va=new Ei,Ha=new Ji,Wa=new Ai,ja=new Ai,Xa=new Ai,qa=new Ei,Ya=new Ei,Za=new Ei;class $a extends wr{constructor(t=new Fa){if(super(),this.isSprite=!0,this.type="Sprite",void 0===Na){Na=new Ia;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),e=new Pa(t,5);Na.setIndex([0,1,2,0,2,3]),Na.setAttribute("position",new Da(e,3,0,!1)),Na.setAttribute("uv",new Da(e,2,3,!1))}this.geometry=Na,this.material=t,this.center=new Ei(.5,.5),this.count=1}raycast(t,e){null===t.camera&&hi('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),ka.setFromMatrixScale(this.matrixWorld),Ha.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),Ba.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&ka.multiplyScalar(-Ba.z);const n=this.material.rotation;let i,r;0!==n&&(r=Math.cos(n),i=Math.sin(n));const a=this.center;Ja(Wa.set(-.5,-.5,0),Ba,a,ka,i,r),Ja(ja.set(.5,-.5,0),Ba,a,ka,i,r),Ja(Xa.set(.5,.5,0),Ba,a,ka,i,r),qa.set(0,0),Ya.set(1,0),Za.set(1,1);let s=t.ray.intersectTriangle(Wa,ja,Xa,!1,za);if(null===s&&(Ja(ja.set(-.5,.5,0),Ba,a,ka,i,r),Ya.set(0,1),s=t.ray.intersectTriangle(Wa,Xa,ja,!1,za),null===s))return;const o=t.ray.origin.distanceTo(za);o<t.near||o>t.far||e.push({distance:o,point:za.clone(),uv:$r.getInterpolation(za,Wa,ja,Xa,qa,Ya,Za,new Ei),face:null,object:this})}copy(t,e){return super.copy(t,e),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}}function Ja(t,e,n,i,r,a){Ga.subVectors(t,n).addScalar(.5).multiply(i),void 0!==r?(Va.x=a*Ga.x-r*Ga.y,Va.y=r*Ga.x+a*Ga.y):Va.copy(Ga),t.copy(e),t.x+=Va.x,t.y+=Va.y,t.applyMatrix4(Ha)}const Ka=new Ai,Qa=new Ai;class ts extends wr{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const e=t.levels;for(let t=0,n=e.length;t<n;t++){const n=e[t];this.addLevel(n.object.clone(),n.distance,n.hysteresis)}return this.autoUpdate=t.autoUpdate,this}addLevel(t,e=0,n=0){e=Math.abs(e);const i=this.levels;let r;for(r=0;r<i.length&&!(e<i[r].distance);r++);return i.splice(r,0,{distance:e,hysteresis:n,object:t}),this.add(t),this}removeLevel(t){const e=this.levels;for(let n=0;n<e.length;n++)if(e[n].distance===t){const t=e.splice(n,1);return this.remove(t[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(t){const e=this.levels;if(e.length>0){let n,i;for(n=1,i=e.length;n<i;n++){let i=e[n].distance;if(e[n].object.visible&&(i-=i*e[n].hysteresis),t<i)break}return e[n-1].object}return null}raycast(t,e){if(this.levels.length>0){Ka.setFromMatrixPosition(this.matrixWorld);const n=t.ray.origin.distanceTo(Ka);this.getObjectForDistance(n).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){Ka.setFromMatrixPosition(t.matrixWorld),Qa.setFromMatrixPosition(this.matrixWorld);const n=Ka.distanceTo(Qa)/t.zoom;let i,r;for(e[0].object.visible=!0,i=1,r=e.length;i<r;i++){let t=e[i].distance;if(e[i].object.visible&&(t-=t*e[i].hysteresis),!(n>=t))break;e[i-1].object.visible=!1,e[i].object.visible=!0}for(this._currentLevel=i-1;i<r;i++)e[i].object.visible=!1}}toJSON(t){const e=super.toJSON(t);!1===this.autoUpdate&&(e.object.autoUpdate=!1),e.object.levels=[];const n=this.levels;for(let t=0,i=n.length;t<i;t++){const i=n[t];e.object.levels.push({object:i.object.uuid,distance:i.distance,hysteresis:i.hysteresis})}return e}}const es=new Ai,ns=new Ai,is=new Ai,rs=new Ai,as=new Ai,ss=new Ai,os=new Ai;class ls{constructor(t=new Ai,e=new Ai(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,es)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=es.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(es.copy(this.origin).addScaledVector(this.direction,e),es.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){ns.copy(t).add(e).multiplyScalar(.5),is.copy(e).sub(t).normalize(),rs.copy(this.origin).sub(ns);const r=.5*t.distanceTo(e),a=-this.direction.dot(is),s=rs.dot(this.direction),o=-rs.dot(is),l=rs.lengthSq(),c=Math.abs(1-a*a);let h,d,u,p;if(c>0)if(h=a*o-s,d=a*s-o,p=r*c,h>=0)if(d>=-p)if(d<=p){const t=1/c;h*=t,d*=t,u=h*(h+a*d+2*s)+d*(a*h+d+2*o)+l}else d=r,h=Math.max(0,-(a*d+s)),u=-h*h+d*(d+2*o)+l;else d=-r,h=Math.max(0,-(a*d+s)),u=-h*h+d*(d+2*o)+l;else d<=-p?(h=Math.max(0,-(-a*r+s)),d=h>0?-r:Math.min(Math.max(-r,-o),r),u=-h*h+d*(d+2*o)+l):d<=p?(h=0,d=Math.min(Math.max(-r,-o),r),u=d*(d+2*o)+l):(h=Math.max(0,-(a*r+s)),d=h>0?r:Math.min(Math.max(-r,-o),r),u=-h*h+d*(d+2*o)+l);else d=a>0?-r:r,h=Math.max(0,-(a*d+s)),u=-h*h+d*(d+2*o)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(ns).addScaledVector(is,d),u}intersectSphere(t,e){es.subVectors(t.center,this.origin);const n=es.dot(this.direction),i=es.dot(es)-n*n,r=t.radius*t.radius;if(i>r)return null;const a=Math.sqrt(r-i),s=n-a,o=n+a;return o<0?null:s<0?this.at(o,e):this.at(s,e)}intersectsSphere(t){return!(t.radius<0)&&this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return null===n?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,r,a,s,o;const l=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,d=this.origin;return l>=0?(n=(t.min.x-d.x)*l,i=(t.max.x-d.x)*l):(n=(t.max.x-d.x)*l,i=(t.min.x-d.x)*l),c>=0?(r=(t.min.y-d.y)*c,a=(t.max.y-d.y)*c):(r=(t.max.y-d.y)*c,a=(t.min.y-d.y)*c),n>a||r>i?null:((r>n||isNaN(n))&&(n=r),(a<i||isNaN(i))&&(i=a),h>=0?(s=(t.min.z-d.z)*h,o=(t.max.z-d.z)*h):(s=(t.max.z-d.z)*h,o=(t.min.z-d.z)*h),n>o||s>i?null:((s>n||n!=n)&&(n=s),(o<i||i!=i)&&(i=o),i<0?null:this.at(n>=0?n:i,e)))}intersectsBox(t){return null!==this.intersectBox(t,es)}intersectTriangle(t,e,n,i,r){as.subVectors(e,t),ss.subVectors(n,t),os.crossVectors(as,ss);let a,s=this.direction.dot(os);if(s>0){if(i)return null;a=1}else{if(!(s<0))return null;a=-1,s=-s}rs.subVectors(this.origin,t);const o=a*this.direction.dot(ss.crossVectors(rs,ss));if(o<0)return null;const l=a*this.direction.dot(as.cross(rs));if(l<0)return null;if(o+l>s)return null;const c=-a*rs.dot(os);return c<0?null:this.at(c/s,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class cs extends Ua{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Lr(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 or,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 hs=new Ji,ds=new ls,us=new Sa,ps=new Ai,ms=new Ai,fs=new Ai,gs=new Ai,vs=new Ai,_s=new Ai,ys=new Ai,xs=new Ai;class bs extends wr{constructor(t=new Ia,e=new cs){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),void 0!==t.morphTargetInfluences&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}getVertexPosition(t,e){const n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;e.fromBufferAttribute(i,t);const s=this.morphTargetInfluences;if(r&&s){_s.set(0,0,0);for(let n=0,i=r.length;n<i;n++){const i=s[n],o=r[n];0!==i&&(vs.fromBufferAttribute(o,t),a?_s.addScaledVector(vs,i):_s.addScaledVector(vs.sub(e),i))}e.add(_s)}return e}raycast(t,e){const n=this.geometry,i=this.material,r=this.matrixWorld;if(void 0!==i){if(null===n.boundingSphere&&n.computeBoundingSphere(),us.copy(n.boundingSphere),us.applyMatrix4(r),ds.copy(t.ray).recast(t.near),!1===us.containsPoint(ds.origin)){if(null===ds.intersectSphere(us,ps))return;if(ds.origin.distanceToSquared(ps)>(t.far-t.near)**2)return}hs.copy(r).invert(),ds.copy(t.ray).applyMatrix4(hs),null!==n.boundingBox&&!1===ds.intersectsBox(n.boundingBox)||this._computeIntersections(t,e,ds)}}_computeIntersections(t,e,n){let i;const r=this.geometry,a=this.material,s=r.index,o=r.attributes.position,l=r.attributes.uv,c=r.attributes.uv1,h=r.attributes.normal,d=r.groups,u=r.drawRange;if(null!==s)if(Array.isArray(a))for(let r=0,o=d.length;r<o;r++){const o=d[r],p=a[o.materialIndex];for(let r=Math.max(o.start,u.start),a=Math.min(s.count,Math.min(o.start+o.count,u.start+u.count));r<a;r+=3)i=Ss(this,p,t,n,l,c,h,s.getX(r),s.getX(r+1),s.getX(r+2)),i&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=o.materialIndex,e.push(i))}else for(let r=Math.max(0,u.start),o=Math.min(s.count,u.start+u.count);r<o;r+=3)i=Ss(this,a,t,n,l,c,h,s.getX(r),s.getX(r+1),s.getX(r+2)),i&&(i.faceIndex=Math.floor(r/3),e.push(i));else if(void 0!==o)if(Array.isArray(a))for(let r=0,s=d.length;r<s;r++){const s=d[r],p=a[s.materialIndex];for(let r=Math.max(s.start,u.start),a=Math.min(o.count,Math.min(s.start+s.count,u.start+u.count));r<a;r+=3)i=Ss(this,p,t,n,l,c,h,r,r+1,r+2),i&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=s.materialIndex,e.push(i))}else for(let r=Math.max(0,u.start),s=Math.min(o.count,u.start+u.count);r<s;r+=3)i=Ss(this,a,t,n,l,c,h,r,r+1,r+2),i&&(i.faceIndex=Math.floor(r/3),e.push(i))}}function Ss(t,e,n,i,r,a,s,o,l,c){t.getVertexPosition(o,ms),t.getVertexPosition(l,fs),t.getVertexPosition(c,gs);const h=function(t,e,n,i,r,a,s,o){let l;if(l=1===e.side?i.intersectTriangle(s,a,r,!0,o):i.intersectTriangle(r,a,s,0===e.side,o),null===l)return null;xs.copy(o),xs.applyMatrix4(t.matrixWorld);const c=n.ray.origin.distanceTo(xs);return c<n.near||c>n.far?null:{distance:c,point:xs.clone(),object:t}}(t,e,n,i,ms,fs,gs,ys);if(h){const t=new Ai;$r.getBarycoord(ys,ms,fs,gs,t),r&&(h.uv=$r.getInterpolatedAttribute(r,o,l,c,t,new Ei)),a&&(h.uv1=$r.getInterpolatedAttribute(a,o,l,c,t,new Ei)),s&&(h.normal=$r.getInterpolatedAttribute(s,o,l,c,t,new Ai),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const e={a:o,b:l,c,normal:new Ai,materialIndex:0};$r.getNormal(ms,fs,gs,e.normal),h.face=e,h.barycoord=t}return h}const Ms=new Xi,ws=new Xi,Es=new Xi,Ts=new Xi,As=new Ji,Cs=new Ai,Rs=new Sa,Is=new Ji,Ps=new ls;class Ls extends bs{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=ue,this.bindMatrix=new Ji,this.bindMatrixInverse=new Ji,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;null===this.boundingBox&&(this.boundingBox=new Jr),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let t=0;t<e.count;t++)this.getVertexPosition(t,Cs),this.boundingBox.expandByPoint(Cs)}computeBoundingSphere(){const t=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new Sa),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let t=0;t<e.count;t++)this.getVertexPosition(t,Cs),this.boundingSphere.expandByPoint(Cs)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){const n=this.material,i=this.matrixWorld;void 0!==n&&(null===this.boundingSphere&&this.computeBoundingSphere(),Rs.copy(this.boundingSphere),Rs.applyMatrix4(i),!1!==t.ray.intersectsSphere(Rs)&&(Is.copy(i).invert(),Ps.copy(t.ray).applyMatrix4(Is),null!==this.boundingBox&&!1===Ps.intersectsBox(this.boundingBox)||this._computeIntersections(t,e,Ps)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,void 0===e&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const t=new Xi,e=this.geometry.attributes.skinWeight;for(let n=0,i=e.count;n<i;n++){t.fromBufferAttribute(e,n);const i=1/t.manhattanLength();i!==1/0?t.multiplyScalar(i):t.set(1,0,0,0),e.setXYZW(n,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===ue?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():ci("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){const n=this.skeleton,i=this.geometry;ws.fromBufferAttribute(i.attributes.skinIndex,t),Es.fromBufferAttribute(i.attributes.skinWeight,t),e.isVector4?(Ms.copy(e),e.set(0,0,0,0)):(Ms.set(...e,1),e.set(0,0,0)),Ms.applyMatrix4(this.bindMatrix);for(let t=0;t<4;t++){const i=Es.getComponent(t);if(0!==i){const r=ws.getComponent(t);As.multiplyMatrices(n.bones[r].matrixWorld,n.boneInverses[r]),e.addScaledVector(Ts.copy(Ms).applyMatrix4(As),i)}}return e.isVector4&&(e.w=Ms.w),e.applyMatrix4(this.bindMatrixInverse)}}class Ds extends wr{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Ns extends ji{constructor(t=null,e=1,n=1,i,r,a,s,o,l=1003,c=1003,h,d){super(null,a,s,o,l,c,i,r,h,d),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Os=new Ji,Us=new Ji;class Fs{constructor(t=[],e=[]){this.uuid=_i(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.previousBoneMatrices=null,this.boneTexture=null,this.init()}init(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(16*t.length),0===e.length)this.calculateInverses();else if(t.length!==e.length){ci("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let t=0,e=this.bones.length;t<e;t++)this.boneInverses.push(new Ji)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const e=new Ji;this.bones[t]&&e.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(e)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&e.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&(e.parent&&e.parent.isBone?(e.matrix.copy(e.parent.matrixWorld).invert(),e.matrix.multiply(e.matrixWorld)):e.matrix.copy(e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale))}}update(){const t=this.bones,e=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let i=0,r=t.length;i<r;i++){const r=t[i]?t[i].matrixWorld:Us;Os.multiplyMatrices(r,e[i]),Os.toArray(n,16*i)}null!==i&&(i.needsUpdate=!0)}clone(){return new Fs(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(4*this.bones.length);t=4*Math.ceil(t/4),t=Math.max(t,4);const e=new Float32Array(t*t*4);e.set(this.boneMatrices);const n=new Ns(e,t,t,Be,De);return n.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=n,this}getBoneByName(t){for(let e=0,n=this.bones.length;e<n;e++){const n=this.bones[e];if(n.name===t)return n}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let n=0,i=t.bones.length;n<i;n++){const i=t.bones[n];let r=e[i];void 0===r&&(ci("Skeleton: No bone found with UUID:",i),r=new Ds),this.bones.push(r),this.boneInverses.push((new Ji).fromArray(t.boneInverses[n]))}return this.init(),this}toJSON(){const t={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,n=this.boneInverses;for(let i=0,r=e.length;i<r;i++){const r=e[i];t.bones.push(r.uuid);const a=n[i];t.boneInverses.push(a.toArray())}return t}}class zs extends fa{constructor(t,e,n,i=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}const ks=new Ji,Bs=new Ji,Gs=[],Vs=new Jr,Hs=new Ji,Ws=new bs,js=new Sa;class Xs extends bs{constructor(t,e,n){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new zs(new Float32Array(16*n),16),this.previousInstanceMatrix=null,this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let t=0;t<n;t++)this.setMatrixAt(t,Hs)}computeBoundingBox(){const t=this.geometry,e=this.count;null===this.boundingBox&&(this.boundingBox=new Jr),null===t.boundingBox&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,ks),Vs.copy(t.boundingBox).applyMatrix4(ks),this.boundingBox.union(Vs)}computeBoundingSphere(){const t=this.geometry,e=this.count;null===this.boundingSphere&&(this.boundingSphere=new Sa),null===t.boundingSphere&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,ks),js.copy(t.boundingSphere).applyMatrix4(ks),this.boundingSphere.union(js)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),null!==t.previousInstanceMatrix&&(this.previousInstanceMatrix=t.previousInstanceMatrix.clone()),null!==t.morphTexture&&(this.morphTexture=t.morphTexture.clone()),null!==t.instanceColor&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){return null===this.instanceColor?e.setRGB(1,1,1):e.fromArray(this.instanceColor.array,3*t)}getMatrixAt(t,e){return e.fromArray(this.instanceMatrix.array,16*t)}getMorphAt(t,e){const n=e.morphTargetInfluences,i=this.morphTexture.source.data.data,r=t*(n.length+1)+1;for(let t=0;t<n.length;t++)n[t]=i[r+t]}raycast(t,e){const n=this.matrixWorld,i=this.count;if(Ws.geometry=this.geometry,Ws.material=this.material,void 0!==Ws.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),js.copy(this.boundingSphere),js.applyMatrix4(n),!1!==t.ray.intersectsSphere(js)))for(let r=0;r<i;r++){this.getMatrixAt(r,ks),Bs.multiplyMatrices(n,ks),Ws.matrixWorld=Bs,Ws.raycast(t,Gs);for(let t=0,n=Gs.length;t<n;t++){const n=Gs[t];n.instanceId=r,n.object=this,e.push(n)}Gs.length=0}}setColorAt(t,e){return null===this.instanceColor&&(this.instanceColor=new zs(new Float32Array(3*this.instanceMatrix.count).fill(1),3)),e.toArray(this.instanceColor.array,3*t),this}setMatrixAt(t,e){return e.toArray(this.instanceMatrix.array,16*t),this}setMorphAt(t,e){const n=e.morphTargetInfluences,i=n.length+1;null===this.morphTexture&&(this.morphTexture=new Ns(new Float32Array(i*this.count),i,this.count,He,De));const r=this.morphTexture.source.data.data;let a=0;for(let t=0;t<n.length;t++)a+=n[t];const s=this.geometry.morphTargetsRelative?1:1-a,o=i*t;return r[o]=s,r.set(n,o+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),null!==this.morphTexture&&(this.morphTexture.dispose(),this.morphTexture=null)}}const qs=new Ai,Ys=new Ai,Zs=new Ii;class $s{constructor(t=new Ai(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const i=qs.subVectors(n,e).cross(Ys.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e,n=!0){const i=t.delta(qs),r=this.normal.dot(i);if(0===r)return 0===this.distanceToPoint(t.start)?e.copy(t.start):null;const a=-(t.start.dot(this.normal)+this.constant)/r;return!0===n&&(a<0||a>1)?null:e.copy(t.start).addScaledVector(i,a)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||Zs.getNormalMatrix(t),i=this.coplanarPoint(qs).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const Js=new Sa,Ks=new Ei(.5,.5),Qs=new Ai;class to{constructor(t=new $s,e=new $s,n=new $s,i=new $s,r=new $s,a=new $s){this.planes=[t,e,n,i,r,a]}set(t,e,n,i,r,a){const s=this.planes;return s[0].copy(t),s[1].copy(e),s[2].copy(n),s[3].copy(i),s[4].copy(r),s[5].copy(a),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=2e3,n=!1){const i=this.planes,r=t.elements,a=r[0],s=r[1],o=r[2],l=r[3],c=r[4],h=r[5],d=r[6],u=r[7],p=r[8],m=r[9],f=r[10],g=r[11],v=r[12],_=r[13],y=r[14],x=r[15];if(i[0].setComponents(l-a,u-c,g-p,x-v).normalize(),i[1].setComponents(l+a,u+c,g+p,x+v).normalize(),i[2].setComponents(l+s,u+h,g+m,x+_).normalize(),i[3].setComponents(l-s,u-h,g-m,x-_).normalize(),n)i[4].setComponents(o,d,f,y).normalize(),i[5].setComponents(l-o,u-d,g-f,x-y).normalize();else if(i[4].setComponents(l-o,u-d,g-f,x-y).normalize(),e===ti)i[5].setComponents(l+o,u+d,g+f,x+y).normalize();else{if(e!==ei)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);i[5].setComponents(o,d,f,y).normalize()}return this}intersectsObject(t){if(void 0!==t.boundingSphere)null===t.boundingSphere&&t.computeBoundingSphere(),Js.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;null===e.boundingSphere&&e.computeBoundingSphere(),Js.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Js)}intersectsSprite(t){Js.center.set(0,0,0);const e=Ks.distanceTo(t.center);return Js.radius=.7071067811865476+e,Js.applyMatrix4(t.matrixWorld),this.intersectsSphere(Js)}intersectsSphere(t){const e=this.planes,n=t.center,i=-t.radius;for(let t=0;t<6;t++)if(e[t].distanceToPoint(n)<i)return!1;return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const i=e[n];if(Qs.x=i.normal.x>0?t.max.x:t.min.x,Qs.y=i.normal.y>0?t.max.y:t.min.y,Qs.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(Qs)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}const eo=new Ji,no=new to;class io{constructor(){this.coordinateSystem=ti}intersectsObject(t,e){if(!e.isArrayCamera||0===e.cameras.length)return!1;for(let n=0;n<e.cameras.length;n++){const i=e.cameras[n];if(eo.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),no.setFromProjectionMatrix(eo,i.coordinateSystem,i.reversedDepth),no.intersectsObject(t))return!0}return!1}intersectsSprite(t,e){if(!e||!e.cameras||0===e.cameras.length)return!1;for(let n=0;n<e.cameras.length;n++){const i=e.cameras[n];if(eo.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),no.setFromProjectionMatrix(eo,i.coordinateSystem,i.reversedDepth),no.intersectsSprite(t))return!0}return!1}intersectsSphere(t,e){if(!e||!e.cameras||0===e.cameras.length)return!1;for(let n=0;n<e.cameras.length;n++){const i=e.cameras[n];if(eo.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),no.setFromProjectionMatrix(eo,i.coordinateSystem,i.reversedDepth),no.intersectsSphere(t))return!0}return!1}intersectsBox(t,e){if(!e||!e.cameras||0===e.cameras.length)return!1;for(let n=0;n<e.cameras.length;n++){const i=e.cameras[n];if(eo.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),no.setFromProjectionMatrix(eo,i.coordinateSystem,i.reversedDepth),no.intersectsBox(t))return!0}return!1}containsPoint(t,e){if(!e||!e.cameras||0===e.cameras.length)return!1;for(let n=0;n<e.cameras.length;n++){const i=e.cameras[n];if(eo.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),no.setFromProjectionMatrix(eo,i.coordinateSystem,i.reversedDepth),no.containsPoint(t))return!0}return!1}clone(){return new io}}function ro(t,e){return t-e}function ao(t,e){return t.z-e.z}function so(t,e){return e.z-t.z}class oo{constructor(){this.index=0,this.pool=[],this.list=[]}push(t,e,n,i){const r=this.pool,a=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const s=r[this.index];a.push(s),this.index++,s.start=t,s.count=e,s.z=n,s.index=i}reset(){this.list.length=0,this.index=0}}const lo=new Ji,co=new Lr(1,1,1),ho=new to,uo=new io,po=new Jr,mo=new Sa,fo=new Ai,go=new Ai,vo=new Ai,_o=new oo,yo=new bs,xo=[];function bo(t,e,n=0){const i=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const r=t.count;for(let a=0;a<r;a++)for(let r=0;r<i;r++)e.setComponent(a+n,r,t.getComponent(a,r))}else e.array.set(t.array,n*i);e.needsUpdate=!0}function So(t,e){if(t.constructor!==e.constructor){const n=Math.min(t.length,e.length);for(let i=0;i<n;i++)e[i]=t[i]}else{const n=Math.min(t.length,e.length);e.set(new t.constructor(t.buffer,0,n))}}class Mo extends bs{constructor(t,e,n=2*e,i){super(new Ia,i),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=t,this._maxVertexCount=e,this._maxIndexCount=n,this._multiDrawCounts=new Int32Array(t),this._multiDrawStarts=new Int32Array(t),this._multiDrawCount=0,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}_initMatricesTexture(){let t=Math.sqrt(4*this._maxInstanceCount);t=4*Math.ceil(t/4),t=Math.max(t,4);const e=new Float32Array(t*t*4),n=new Ns(e,t,t,Be,De);this._matricesTexture=n}_initIndirectTexture(){let t=Math.sqrt(this._maxInstanceCount);t=Math.ceil(t);const e=new Uint32Array(t*t),n=new Ns(e,t,t,We,Le);this._indirectTexture=n}_initColorsTexture(){let t=Math.sqrt(this._maxInstanceCount);t=Math.ceil(t);const e=new Float32Array(t*t*4).fill(1),n=new Ns(e,t,t,Be,De);n.colorSpace=Oi.workingColorSpace,this._colorsTexture=n}_initializeGeometry(t){const e=this.geometry,n=this._maxVertexCount,i=this._maxIndexCount;if(!1===this._geometryInitialized){for(const i in t.attributes){const r=t.getAttribute(i),{array:a,itemSize:s,normalized:o}=r,l=new a.constructor(n*s),c=new fa(l,s,o);e.setAttribute(i,c)}if(null!==t.getIndex()){const t=n>65535?new Uint32Array(i):new Uint16Array(i);e.setIndex(new fa(t,1))}this._geometryInitialized=!0}}_validateGeometry(t){const e=this.geometry;if(Boolean(t.getIndex())!==Boolean(e.getIndex()))throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const n in e.attributes){if(!t.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const i=t.getAttribute(n),r=e.getAttribute(n);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(t){const e=this._instanceInfo;if(t<0||t>=e.length||!1===e[t].active)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${t}. Instance is either out of range or has been deleted.`)}validateGeometryId(t){const e=this._geometryInfo;if(t<0||t>=e.length||!1===e[t].active)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${t}. Geometry is either out of range or has been deleted.`)}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Jr);const t=this.boundingBox,e=this._instanceInfo;t.makeEmpty();for(let n=0,i=e.length;n<i;n++){if(!1===e[n].active)continue;const i=e[n].geometryIndex;this.getMatrixAt(n,lo),this.getBoundingBoxAt(i,po).applyMatrix4(lo),t.union(po)}}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new Sa);const t=this.boundingSphere,e=this._instanceInfo;t.makeEmpty();for(let n=0,i=e.length;n<i;n++){if(!1===e[n].active)continue;const i=e[n].geometryIndex;this.getMatrixAt(n,lo),this.getBoundingSphereAt(i,mo).applyMatrix4(lo),t.union(mo)}}addInstance(t){if(this._instanceInfo.length>=this.maxInstanceCount&&0===this._availableInstanceIds.length)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const e={visible:!0,active:!0,geometryIndex:t};let n=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(ro),n=this._availableInstanceIds.shift(),this._instanceInfo[n]=e):(n=this._instanceInfo.length,this._instanceInfo.push(e));const i=this._matricesTexture;lo.identity().toArray(i.image.data,16*n),i.needsUpdate=!0;const r=this._colorsTexture;return r&&(co.toArray(r.image.data,4*n),r.needsUpdate=!0),this._visibilityChanged=!0,n}addGeometry(t,e=-1,n=-1){this._initializeGeometry(t),this._validateGeometry(t);const i={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},r=this._geometryInfo;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=-1===e?t.getAttribute("position").count:e;const a=t.getIndex();if(null!==a&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=-1===n?a.count:n),-1!==i.indexStart&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let s;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(ro),s=this._availableGeometryIds.shift(),r[s]=i):(s=this._geometryCount,this._geometryCount++,r.push(i)),this.setGeometryAt(s,t),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,s}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);const n=this.geometry,i=null!==n.getIndex(),r=n.getIndex(),a=e.getIndex(),s=this._geometryInfo[t];if(i&&a.count>s.reservedIndexCount||e.attributes.position.count>s.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const o=s.vertexStart,l=s.reservedVertexCount;s.vertexCount=e.getAttribute("position").count;for(const t in n.attributes){const i=e.getAttribute(t),r=n.getAttribute(t);bo(i,r,o);const a=i.itemSize;for(let t=i.count,e=l;t<e;t++){const e=o+t;for(let t=0;t<a;t++)r.setComponent(e,t,0)}r.needsUpdate=!0,r.addUpdateRange(o*a,l*a)}if(i){const t=s.indexStart,n=s.reservedIndexCount;s.indexCount=e.getIndex().count;for(let e=0;e<a.count;e++)r.setX(t+e,o+a.getX(e));for(let e=a.count,i=n;e<i;e++)r.setX(t+e,o);r.needsUpdate=!0,r.addUpdateRange(t,s.reservedIndexCount)}return s.start=i?s.indexStart:s.vertexStart,s.count=i?s.indexCount:s.vertexCount,s.boundingBox=null,null!==e.boundingBox&&(s.boundingBox=e.boundingBox.clone()),s.boundingSphere=null,null!==e.boundingSphere&&(s.boundingSphere=e.boundingSphere.clone()),this._visibilityChanged=!0,t}deleteGeometry(t){const e=this._geometryInfo;if(t>=e.length||!1===e[t].active)return this;const n=this._instanceInfo;for(let e=0,i=n.length;e<i;e++)n[e].active&&n[e].geometryIndex===t&&this.deleteInstance(e);return e[t].active=!1,this._availableGeometryIds.push(t),this._visibilityChanged=!0,this}deleteInstance(t){return this.validateInstanceId(t),this._instanceInfo[t].active=!1,this._availableInstanceIds.push(t),this._visibilityChanged=!0,this}optimize(){let t=0,e=0;const n=this._geometryInfo,i=n.map(((t,e)=>e)).sort(((t,e)=>n[t].vertexStart-n[e].vertexStart)),r=this.geometry;for(let a=0,s=n.length;a<s;a++){const s=i[a],o=n[s];if(!1!==o.active){if(null!==r.index){if(o.indexStart!==e){const{indexStart:n,vertexStart:i,reservedIndexCount:a}=o,s=r.index,l=s.array,c=t-i;for(let t=n;t<n+a;t++)l[t]=l[t]+c;s.array.copyWithin(e,n,n+a),s.addUpdateRange(e,a),s.needsUpdate=!0,o.indexStart=e}e+=o.reservedIndexCount}if(o.vertexStart!==t){const{vertexStart:e,reservedVertexCount:n}=o,i=r.attributes;for(const r in i){const a=i[r],{array:s,itemSize:o}=a;s.copyWithin(t*o,e*o,(e+n)*o),a.addUpdateRange(t*o,n*o),a.needsUpdate=!0}o.vertexStart=t}t+=o.reservedVertexCount,o.start=r.index?o.indexStart:o.vertexStart}}return this._nextIndexStart=e,this._nextVertexStart=t,this._visibilityChanged=!0,this}getBoundingBoxAt(t,e){if(t>=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[t];if(null===i.boundingBox){const t=new Jr,e=n.index,r=n.attributes.position;for(let n=i.start,a=i.start+i.count;n<a;n++){let i=n;e&&(i=e.getX(i)),t.expandByPoint(fo.fromBufferAttribute(r,i))}i.boundingBox=t}return e.copy(i.boundingBox),e}getBoundingSphereAt(t,e){if(t>=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[t];if(null===i.boundingSphere){const e=new Sa;this.getBoundingBoxAt(t,po),po.getCenter(e.center);const r=n.index,a=n.attributes.position;let s=0;for(let t=i.start,n=i.start+i.count;t<n;t++){let n=t;r&&(n=r.getX(n)),fo.fromBufferAttribute(a,n),s=Math.max(s,e.center.distanceToSquared(fo))}e.radius=Math.sqrt(s),i.boundingSphere=e}return e.copy(i.boundingSphere),e}setMatrixAt(t,e){this.validateInstanceId(t);const n=this._matricesTexture,i=this._matricesTexture.image.data;return e.toArray(i,16*t),n.needsUpdate=!0,this}getMatrixAt(t,e){return this.validateInstanceId(t),e.fromArray(this._matricesTexture.image.data,16*t)}setColorAt(t,e){return this.validateInstanceId(t),null===this._colorsTexture&&this._initColorsTexture(),e.toArray(this._colorsTexture.image.data,4*t),this._colorsTexture.needsUpdate=!0,this}getColorAt(t,e){return this.validateInstanceId(t),null===this._colorsTexture?e.isVector4?e.set(1,1,1,1):e.setRGB(1,1,1):e.fromArray(this._colorsTexture.image.data,4*t)}setVisibleAt(t,e){return this.validateInstanceId(t),this._instanceInfo[t].visible===e||(this._instanceInfo[t].visible=e,this._visibilityChanged=!0),this}getVisibleAt(t){return this.validateInstanceId(t),this._instanceInfo[t].visible}setGeometryIdAt(t,e){return this.validateInstanceId(t),this.validateGeometryId(e),this._instanceInfo[t].geometryIndex=e,this}getGeometryIdAt(t){return this.validateInstanceId(t),this._instanceInfo[t].geometryIndex}getGeometryRangeAt(t,e={}){this.validateGeometryId(t);const n=this._geometryInfo[t];return e.vertexStart=n.vertexStart,e.vertexCount=n.vertexCount,e.reservedVertexCount=n.reservedVertexCount,e.indexStart=n.indexStart,e.indexCount=n.indexCount,e.reservedIndexCount=n.reservedIndexCount,e.start=n.start,e.count=n.count,e}setInstanceCount(t){const e=this._availableInstanceIds,n=this._instanceInfo;for(e.sort(ro);e[e.length-1]===n.length-1;)n.pop(),e.pop();if(t<n.length)throw new Error(`BatchedMesh: Instance ids outside the range ${t} are being used. Cannot shrink instance count.`);const i=new Int32Array(t),r=new Int32Array(t);So(this._multiDrawCounts,i),So(this._multiDrawStarts,r),this._multiDrawCounts=i,this._multiDrawStarts=r,this._maxInstanceCount=t;const a=this._indirectTexture,s=this._matricesTexture,o=this._colorsTexture;a.dispose(),this._initIndirectTexture(),So(a.image.data,this._indirectTexture.image.data),s.dispose(),this._initMatricesTexture(),So(s.image.data,this._matricesTexture.image.data),o&&(o.dispose(),this._initColorsTexture(),So(o.image.data,this._colorsTexture.image.data))}setGeometrySize(t,e){const n=[...this._geometryInfo].filter((t=>t.active));if(Math.max(...n.map((t=>t.vertexStart+t.reservedVertexCount)))>t)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${e}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map((t=>t.indexStart+t.reservedIndexCount)))>e)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${e}. Cannot shrink further.`);const i=this.geometry;i.dispose(),this._maxVertexCount=t,this._maxIndexCount=e,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Ia,this._initializeGeometry(i));const r=this.geometry;i.index&&So(i.index.array,r.index.array);for(const t in i.attributes)So(i.attributes[t].array,r.attributes[t].array)}raycast(t,e){const n=this._instanceInfo,i=this._geometryInfo,r=this.matrixWorld,a=this.geometry;yo.material=this.material,yo.geometry.index=a.index,yo.geometry.attributes=a.attributes,null===yo.geometry.boundingBox&&(yo.geometry.boundingBox=new Jr),null===yo.geometry.boundingSphere&&(yo.geometry.boundingSphere=new Sa);for(let a=0,s=n.length;a<s;a++){if(!n[a].visible||!n[a].active)continue;const s=n[a].geometryIndex,o=i[s];yo.geometry.setDrawRange(o.start,o.count),this.getMatrixAt(a,yo.matrixWorld).premultiply(r),this.getBoundingBoxAt(s,yo.geometry.boundingBox),this.getBoundingSphereAt(s,yo.geometry.boundingSphere),yo.raycast(t,xo);for(let t=0,n=xo.length;t<n;t++){const n=xo[t];n.object=this,n.batchId=a,e.push(n)}xo.length=0}yo.material=null,yo.geometry.index=null,yo.geometry.attributes={},yo.geometry.setDrawRange(0,1/0)}copy(t){return super.copy(t),this.geometry=t.geometry.clone(),this.perObjectFrustumCulled=t.perObjectFrustumCulled,this.sortObjects=t.sortObjects,this.boundingBox=null!==t.boundingBox?t.boundingBox.clone():null,this.boundingSphere=null!==t.boundingSphere?t.boundingSphere.clone():null,this._geometryInfo=t._geometryInfo.map((t=>({...t,boundingBox:null!==t.boundingBox?t.boundingBox.clone():null,boundingSphere:null!==t.boundingSphere?t.boundingSphere.clone():null}))),this._instanceInfo=t._instanceInfo.map((t=>({...t}))),this._availableInstanceIds=t._availableInstanceIds.slice(),this._availableGeometryIds=t._availableGeometryIds.slice(),this._nextIndexStart=t._nextIndexStart,this._nextVertexStart=t._nextVertexStart,this._geometryCount=t._geometryCount,this._maxInstanceCount=t._maxInstanceCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._indirectTexture=t._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),null!==this._colorsTexture&&(this._colorsTexture=t._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,null!==this._colorsTexture&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(t,e,n,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=i.getIndex();let s=null===a?1:a.array.BYTES_PER_ELEMENT,o=1;r.wireframe&&(o=2,s=i.attributes.position.count>65535?4:2);const l=this._instanceInfo,c=this._multiDrawStarts,h=this._multiDrawCounts,d=this._geometryInfo,u=this.perObjectFrustumCulled,p=this._indirectTexture,m=p.image.data,f=n.isArrayCamera?uo:ho;u&&!n.isArrayCamera&&(lo.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),ho.setFromProjectionMatrix(lo,n.coordinateSystem,n.reversedDepth));let g=0;if(this.sortObjects){lo.copy(this.matrixWorld).invert(),fo.setFromMatrixPosition(n.matrixWorld).applyMatrix4(lo),go.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(lo);for(let t=0,e=l.length;t<e;t++)if(l[t].visible&&l[t].active){const e=l[t].geometryIndex;this.getMatrixAt(t,lo),this.getBoundingSphereAt(e,mo).applyMatrix4(lo);let i=!1;if(u&&(i=!f.intersectsSphere(mo,n)),!i){const n=d[e],i=vo.subVectors(mo.center,fo).dot(go);_o.push(n.start,n.count,i,t)}}const t=_o.list,e=this.customSort;null===e?t.sort(r.transparent?so:ao):e.call(this,t,n);for(let e=0,n=t.length;e<n;e++){const n=t[e];c[g]=n.start*s*o,h[g]=n.count*o,m[g]=n.index,g++}_o.reset()}else for(let t=0,e=l.length;t<e;t++)if(l[t].visible&&l[t].active){const e=l[t].geometryIndex;let i=!1;if(u&&(this.getMatrixAt(t,lo),this.getBoundingSphereAt(e,mo).applyMatrix4(lo),i=!f.intersectsSphere(mo,n)),!i){const n=d[e];c[g]=n.start*s*o,h[g]=n.count*o,m[g]=t,g++}}p.needsUpdate=!0,this._multiDrawCount=g,this._visibilityChanged=!1}onBeforeShadow(t,e,n,i,r,a){this.onBeforeRender(t,null,i,r,a)}}class wo extends Ua{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Lr(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const Eo=new Ai,To=new Ai,Ao=new Ji,Co=new ls,Ro=new Sa,Io=new Ai,Po=new Ai;class Lo extends wr{constructor(t=new Ia,e=new wo){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,n=[0];for(let t=1,i=e.count;t<i;t++)Eo.fromBufferAttribute(e,t-1),To.fromBufferAttribute(e,t),n[t]=n[t-1],n[t]+=Eo.distanceTo(To);t.setAttribute("lineDistance",new _a(n,1))}else ci("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,r=t.params.Line.threshold,a=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),Ro.copy(n.boundingSphere),Ro.applyMatrix4(i),Ro.radius+=r,!1===t.ray.intersectsSphere(Ro))return;Ao.copy(i).invert(),Co.copy(t.ray).applyMatrix4(Ao);const s=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=s*s,l=this.isLineSegments?2:1,c=n.index,h=n.attributes.position;if(null!==c){const n=Math.max(0,a.start),i=Math.min(c.count,a.start+a.count);for(let r=n,a=i-1;r<a;r+=l){const n=c.getX(r),i=c.getX(r+1),a=Do(this,t,Co,o,n,i,r);a&&e.push(a)}if(this.isLineLoop){const r=c.getX(i-1),a=c.getX(n),s=Do(this,t,Co,o,r,a,i-1);s&&e.push(s)}}else{const n=Math.max(0,a.start),i=Math.min(h.count,a.start+a.count);for(let r=n,a=i-1;r<a;r+=l){const n=Do(this,t,Co,o,r,r+1,r);n&&e.push(n)}if(this.isLineLoop){const r=Do(this,t,Co,o,i-1,n,i-1);r&&e.push(r)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}}function Do(t,e,n,i,r,a,s){const o=t.geometry.attributes.position;if(Eo.fromBufferAttribute(o,r),To.fromBufferAttribute(o,a),n.distanceSqToSegment(Eo,To,Io,Po)>i)return;Io.applyMatrix4(t.matrixWorld);const l=e.ray.origin.distanceTo(Io);return l<e.near||l>e.far?void 0:{distance:l,point:Po.clone().applyMatrix4(t.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:t}}const No=new Ai,Oo=new Ai;class Uo extends Lo{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,n=[];for(let t=0,i=e.count;t<i;t+=2)No.fromBufferAttribute(e,t),Oo.fromBufferAttribute(e,t+1),n[t]=0===t?0:n[t-1],n[t+1]=n[t]+No.distanceTo(Oo);t.setAttribute("lineDistance",new _a(n,1))}else ci("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Fo extends Lo{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}}class zo extends Ua{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Lr(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}const ko=new Ji,Bo=new ls,Go=new Sa,Vo=new Ai;class Ho extends wr{constructor(t=new Ia,e=new zo){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,r=t.params.Points.threshold,a=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),Go.copy(n.boundingSphere),Go.applyMatrix4(i),Go.radius+=r,!1===t.ray.intersectsSphere(Go))return;ko.copy(i).invert(),Bo.copy(t.ray).applyMatrix4(ko);const s=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=s*s,l=n.index,c=n.attributes.position;if(null!==l)for(let n=Math.max(0,a.start),r=Math.min(l.count,a.start+a.count);n<r;n++){const r=l.getX(n);Vo.fromBufferAttribute(c,r),Wo(Vo,r,o,i,t,e,this)}else for(let n=Math.max(0,a.start),r=Math.min(c.count,a.start+a.count);n<r;n++)Vo.fromBufferAttribute(c,n),Wo(Vo,n,o,i,t,e,this)}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}}function Wo(t,e,n,i,r,a,s){const o=Bo.distanceSqToPoint(t);if(o<n){const n=new Ai;Bo.closestPointToPoint(t,n),n.applyMatrix4(i);const l=r.ray.origin.distanceTo(n);if(l<r.near||l>r.far)return;a.push({distance:l,distanceToRay:Math.sqrt(o),point:n,index:e,face:null,faceIndex:null,barycoord:null,object:s})}}class jo extends ji{constructor(t=[],e=301,n,i,r,a,s,o,l,c){super(t,e,n,i,r,a,s,o,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class Xo extends ji{constructor(t,e,n=1014,i,r,a,s=1003,o=1003,l,c=1026,h=1){if(c!==Ge&&c!==Ve)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super({width:t,height:e,depth:h},i,r,a,s,o,c,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new Gi(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return null!==this.compareFunction&&(e.compareFunction=this.compareFunction),e}}class qo extends Xo{constructor(t,e=1014,n=301,i,r,a=1003,s=1003,o,l=1026){const c={width:t,height:t,depth:1},h=[c,c,c,c,c,c];super(t,t,e,n,i,r,a,s,o,l),this.image=h,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}}class Yo extends ji{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}}class Zo extends Ia{constructor(t=1,e=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};const s=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);const o=[],l=[],c=[],h=[];let d=0,u=0;function p(t,e,n,i,r,a,p,m,f,g,v){const _=a/f,y=p/g,x=a/2,b=p/2,S=m/2,M=f+1,w=g+1;let E=0,T=0;const A=new Ai;for(let a=0;a<w;a++){const s=a*y-b;for(let o=0;o<M;o++){const d=o*_-x;A[t]=d*i,A[e]=s*r,A[n]=S,l.push(A.x,A.y,A.z),A[t]=0,A[e]=0,A[n]=m>0?1:-1,c.push(A.x,A.y,A.z),h.push(o/f),h.push(1-a/g),E+=1}}for(let t=0;t<g;t++)for(let e=0;e<f;e++){const n=d+e+M*t,i=d+e+M*(t+1),r=d+(e+1)+M*(t+1),a=d+(e+1)+M*t;o.push(n,i,a),o.push(i,r,a),T+=6}s.addGroup(u,T,v),u+=T,d+=E}p("z","y","x",-1,-1,n,e,t,a,r,0),p("z","y","x",1,-1,n,e,-t,a,r,1),p("x","z","y",1,1,t,n,e,i,a,2),p("x","z","y",1,-1,t,n,-e,i,a,3),p("x","y","z",1,-1,t,e,n,i,r,4),p("x","y","z",-1,-1,t,e,-n,i,r,5),this.setIndex(o),this.setAttribute("position",new _a(l,3)),this.setAttribute("normal",new _a(c,3)),this.setAttribute("uv",new _a(h,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Zo(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class $o extends Ia{constructor(t=1,e=1,n=4,i=8,r=1){super(),this.type="CapsuleGeometry",this.parameters={radius:t,height:e,capSegments:n,radialSegments:i,heightSegments:r},e=Math.max(0,e),n=Math.max(1,Math.floor(n)),i=Math.max(3,Math.floor(i)),r=Math.max(1,Math.floor(r));const a=[],s=[],o=[],l=[],c=e/2,h=Math.PI/2*t,d=e,u=2*h+d,p=2*n+r,m=i+1,f=new Ai,g=new Ai;for(let v=0;v<=p;v++){let _=0,y=0,x=0,b=0;if(v<=n){const e=v/n,i=e*Math.PI/2;y=-c-t*Math.cos(i),x=t*Math.sin(i),b=-t*Math.cos(i),_=e*h}else if(v<=n+r){const i=(v-n)/r;y=i*e-c,x=t,b=0,_=h+i*d}else{const e=(v-n-r)/n,i=e*Math.PI/2;y=c+t*Math.sin(i),x=t*Math.cos(i),b=t*Math.sin(i),_=h+d+e*h}const S=Math.max(0,Math.min(1,_/u));let M=0;0===v?M=.5/i:v===p&&(M=-.5/i);for(let t=0;t<=i;t++){const e=t/i,n=e*Math.PI*2,r=Math.sin(n),a=Math.cos(n);g.x=-x*a,g.y=y,g.z=x*r,s.push(g.x,g.y,g.z),f.set(-x*a,b,x*r),f.normalize(),o.push(f.x,f.y,f.z),l.push(e+M,S)}if(v>0){const t=(v-1)*m;for(let e=0;e<i;e++){const n=t+e,i=t+e+1,r=v*m+e,s=v*m+e+1;a.push(n,i,r),a.push(i,s,r)}}}this.setIndex(a),this.setAttribute("position",new _a(s,3)),this.setAttribute("normal",new _a(o,3)),this.setAttribute("uv",new _a(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new $o(t.radius,t.height,t.capSegments,t.radialSegments,t.heightSegments)}}class Jo extends Ia{constructor(t=1,e=32,n=0,i=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:i},e=Math.max(3,e);const r=[],a=[],s=[],o=[],l=new Ai,c=new Ei;a.push(0,0,0),s.push(0,0,1),o.push(.5,.5);for(let r=0,h=3;r<=e;r++,h+=3){const d=n+r/e*i;l.x=t*Math.cos(d),l.y=t*Math.sin(d),a.push(l.x,l.y,l.z),s.push(0,0,1),c.x=(a[h]/t+1)/2,c.y=(a[h+1]/t+1)/2,o.push(c.x,c.y)}for(let t=1;t<=e;t++)r.push(t,t+1,0);this.setIndex(r),this.setAttribute("position",new _a(a,3)),this.setAttribute("normal",new _a(s,3)),this.setAttribute("uv",new _a(o,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Jo(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class Ko extends Ia{constructor(t=1,e=1,n=1,i=32,r=1,a=!1,s=0,o=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:r,openEnded:a,thetaStart:s,thetaLength:o};const l=this;i=Math.floor(i),r=Math.floor(r);const c=[],h=[],d=[],u=[];let p=0;const m=[],f=n/2;let g=0;function v(n){const r=p,a=new Ei,m=new Ai;let v=0;const _=!0===n?t:e,y=!0===n?1:-1;for(let t=1;t<=i;t++)h.push(0,f*y,0),d.push(0,y,0),u.push(.5,.5),p++;const x=p;for(let t=0;t<=i;t++){const e=t/i*o+s,n=Math.cos(e),r=Math.sin(e);m.x=_*r,m.y=f*y,m.z=_*n,h.push(m.x,m.y,m.z),d.push(0,y,0),a.x=.5*n+.5,a.y=.5*r*y+.5,u.push(a.x,a.y),p++}for(let t=0;t<i;t++){const e=r+t,i=x+t;!0===n?c.push(i,i+1,e):c.push(i+1,i,e),v+=3}l.addGroup(g,v,!0===n?1:2),g+=v}!function(){const a=new Ai,v=new Ai;let _=0;const y=(e-t)/n;for(let l=0;l<=r;l++){const c=[],g=l/r,_=g*(e-t)+t;for(let t=0;t<=i;t++){const e=t/i,r=e*o+s,l=Math.sin(r),m=Math.cos(r);v.x=_*l,v.y=-g*n+f,v.z=_*m,h.push(v.x,v.y,v.z),a.set(l,y,m).normalize(),d.push(a.x,a.y,a.z),u.push(e,1-g),c.push(p++)}m.push(c)}for(let n=0;n<i;n++)for(let i=0;i<r;i++){const a=m[i][n],s=m[i+1][n],o=m[i+1][n+1],l=m[i][n+1];(t>0||0!==i)&&(c.push(a,s,l),_+=3),(e>0||i!==r-1)&&(c.push(s,o,l),_+=3)}l.addGroup(g,_,0),g+=_}(),!1===a&&(t>0&&v(!0),e>0&&v(!1)),this.setIndex(c),this.setAttribute("position",new _a(h,3)),this.setAttribute("normal",new _a(d,3)),this.setAttribute("uv",new _a(u,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ko(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Qo extends Ko{constructor(t=1,e=1,n=32,i=1,r=!1,a=0,s=2*Math.PI){super(0,t,e,n,i,r,a,s),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:a,thetaLength:s}}static fromJSON(t){return new Qo(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class tl extends Ia{constructor(t=[],e=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:i};const r=[],a=[];function s(t,e,n,i){const r=i+1,a=[];for(let i=0;i<=r;i++){a[i]=[];const s=t.clone().lerp(n,i/r),o=e.clone().lerp(n,i/r),l=r-i;for(let t=0;t<=l;t++)a[i][t]=0===t&&i===r?s:s.clone().lerp(o,t/l)}for(let t=0;t<r;t++)for(let e=0;e<2*(r-t)-1;e++){const n=Math.floor(e/2);e%2==0?(o(a[t][n+1]),o(a[t+1][n]),o(a[t][n])):(o(a[t][n+1]),o(a[t+1][n+1]),o(a[t+1][n]))}}function o(t){r.push(t.x,t.y,t.z)}function l(e,n){const i=3*e;n.x=t[i+0],n.y=t[i+1],n.z=t[i+2]}function c(t,e,n,i){i<0&&1===t.x&&(a[e]=t.x-1),0===n.x&&0===n.z&&(a[e]=i/2/Math.PI+.5)}function h(t){return Math.atan2(t.z,-t.x)}!function(t){const n=new Ai,i=new Ai,r=new Ai;for(let a=0;a<e.length;a+=3)l(e[a+0],n),l(e[a+1],i),l(e[a+2],r),s(n,i,r,t)}(i),function(t){const e=new Ai;for(let n=0;n<r.length;n+=3)e.x=r[n+0],e.y=r[n+1],e.z=r[n+2],e.normalize().multiplyScalar(t),r[n+0]=e.x,r[n+1]=e.y,r[n+2]=e.z}(n),function(){const t=new Ai;for(let n=0;n<r.length;n+=3){t.x=r[n+0],t.y=r[n+1],t.z=r[n+2];const i=h(t)/2/Math.PI+.5,s=(e=t,Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))/Math.PI+.5);a.push(i,1-s)}var e;(function(){const t=new Ai,e=new Ai,n=new Ai,i=new Ai,s=new Ei,o=new Ei,l=new Ei;for(let d=0,u=0;d<r.length;d+=9,u+=6){t.set(r[d+0],r[d+1],r[d+2]),e.set(r[d+3],r[d+4],r[d+5]),n.set(r[d+6],r[d+7],r[d+8]),s.set(a[u+0],a[u+1]),o.set(a[u+2],a[u+3]),l.set(a[u+4],a[u+5]),i.copy(t).add(e).add(n).divideScalar(3);const p=h(i);c(s,u+0,t,p),c(o,u+2,e,p),c(l,u+4,n,p)}})(),function(){for(let t=0;t<a.length;t+=6){const e=a[t+0],n=a[t+2],i=a[t+4],r=Math.max(e,n,i),s=Math.min(e,n,i);r>.9&&s<.1&&(e<.2&&(a[t+0]+=1),n<.2&&(a[t+2]+=1),i<.2&&(a[t+4]+=1))}}()}(),this.setAttribute("position",new _a(r,3)),this.setAttribute("normal",new _a(r.slice(),3)),this.setAttribute("uv",new _a(a,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new tl(t.vertices,t.indices,t.radius,t.detail)}}class el extends tl{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2,i=1/n;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new el(t.radius,t.detail)}}const nl=new Ai,il=new Ai,rl=new Ai,al=new $r;class sl{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){ci("Curve: .getPoint() not implemented.")}getPointAt(t,e){const n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let n,i=this.getPoint(0),r=0;e.push(0);for(let a=1;a<=t;a++)n=this.getPoint(a/t),r+=n.distanceTo(i),e.push(r),i=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e=null){const n=this.getLengths();let i=0;const r=n.length;let a;a=e||t*n[r-1];let s,o=0,l=r-1;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),s=n[i]-a,s<0)o=i+1;else{if(!(s>0)){l=i;break}l=i-1}if(i=l,n[i]===a)return i/(r-1);const c=n[i];return(i+(a-c)/(n[i+1]-c))/(r-1)}getTangent(t,e){const n=1e-4;let i=t-n,r=t+n;i<0&&(i=0),r>1&&(r=1);const a=this.getPoint(i),s=this.getPoint(r),o=e||(a.isVector2?new Ei:new Ai);return o.copy(s).sub(a).normalize(),o}getTangentAt(t,e){const n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e=!1){const n=new Ai,i=[],r=[],a=[],s=new Ai,o=new Ji;for(let e=0;e<=t;e++){const n=e/t;i[e]=this.getTangentAt(n,new Ai)}r[0]=new Ai,a[0]=new Ai;let l=Number.MAX_VALUE;const c=Math.abs(i[0].x),h=Math.abs(i[0].y),d=Math.abs(i[0].z);c<=l&&(l=c,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),d<=l&&n.set(0,0,1),s.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],s),a[0].crossVectors(i[0],r[0]);for(let e=1;e<=t;e++){if(r[e]=r[e-1].clone(),a[e]=a[e-1].clone(),s.crossVectors(i[e-1],i[e]),s.length()>Number.EPSILON){s.normalize();const t=Math.acos(yi(i[e-1].dot(i[e]),-1,1));r[e].applyMatrix4(o.makeRotationAxis(s,t))}a[e].crossVectors(i[e],r[e])}if(!0===e){let e=Math.acos(yi(r[0].dot(r[t]),-1,1));e/=t,i[0].dot(s.crossVectors(r[0],r[t]))>0&&(e=-e);for(let n=1;n<=t;n++)r[n].applyMatrix4(o.makeRotationAxis(i[n],e*n)),a[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,binormals:a}}clone(){return(new this.constructor).copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class ol extends sl{constructor(t=0,e=0,n=1,i=1,r=0,a=2*Math.PI,s=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=s,this.aRotation=o}getPoint(t,e=new Ei){const n=e,i=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const a=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=i;for(;r>i;)r-=i;r<Number.EPSILON&&(r=a?0:i),!0!==this.aClockwise||a||(r===i?r=-i:r-=i);const s=this.aStartAngle+t*r;let o=this.aX+this.xRadius*Math.cos(s),l=this.aY+this.yRadius*Math.sin(s);if(0!==this.aRotation){const t=Math.cos(this.aRotation),e=Math.sin(this.aRotation),n=o-this.aX,i=l-this.aY;o=n*t-i*e+this.aX,l=n*e+i*t+this.aY}return n.set(o,l)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){const t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}}function ll(){let t=0,e=0,n=0,i=0;function r(r,a,s,o){t=r,e=s,n=-3*r+3*a-2*s-o,i=2*r-2*a+s+o}return{initCatmullRom:function(t,e,n,i,a){r(e,n,a*(n-t),a*(i-e))},initNonuniformCatmullRom:function(t,e,n,i,a,s,o){let l=(e-t)/a-(n-t)/(a+s)+(n-e)/s,c=(n-e)/s-(i-e)/(s+o)+(i-n)/o;l*=s,c*=s,r(e,n,l,c)},calc:function(r){const a=r*r;return t+e*r+n*a+i*(a*r)}}}const cl=new Ai,hl=new Ai,dl=new ll,ul=new ll,pl=new ll;function ml(t,e,n,i,r){const a=.5*(i-e),s=.5*(r-n),o=t*t;return(2*n-2*i+a+s)*(t*o)+(-3*n+3*i-2*a-s)*o+a*t+n}function fl(t,e,n,i){return function(t,e){const n=1-t;return n*n*e}(t,e)+function(t,e){return 2*(1-t)*t*e}(t,n)+function(t,e){return t*t*e}(t,i)}function gl(t,e,n,i,r){return function(t,e){const n=1-t;return n*n*n*e}(t,e)+function(t,e){const n=1-t;return 3*n*n*t*e}(t,n)+function(t,e){return 3*(1-t)*t*t*e}(t,i)+function(t,e){return t*t*t*e}(t,r)}class vl extends sl{constructor(t=new Ei,e=new Ei,n=new Ei,i=new Ei){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new Ei){const n=e,i=this.v0,r=this.v1,a=this.v2,s=this.v3;return n.set(gl(t,i.x,r.x,a.x,s.x),gl(t,i.y,r.y,a.y,s.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class _l extends sl{constructor(t=new Ei,e=new Ei){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new Ei){const n=e;return 1===t?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new Ei){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class yl extends sl{constructor(t=new Ei,e=new Ei,n=new Ei){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new Ei){const n=e,i=this.v0,r=this.v1,a=this.v2;return n.set(fl(t,i.x,r.x,a.x),fl(t,i.y,r.y,a.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class xl extends sl{constructor(t=new Ai,e=new Ai,n=new Ai){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new Ai){const n=e,i=this.v0,r=this.v1,a=this.v2;return n.set(fl(t,i.x,r.x,a.x),fl(t,i.y,r.y,a.y),fl(t,i.z,r.z,a.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class bl extends sl{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new Ei){const n=e,i=this.points,r=(i.length-1)*t,a=Math.floor(r),s=r-a,o=i[0===a?a:a-1],l=i[a],c=i[a>i.length-2?i.length-1:a+1],h=i[a>i.length-3?i.length-1:a+2];return n.set(ml(s,o.x,l.x,c.x,h.x),ml(s,o.y,l.y,c.y,h.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push(n.clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const n=this.points[e];t.points.push(n.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push((new Ei).fromArray(n))}return this}}var Sl=Object.freeze({__proto__:null,ArcCurve:class extends ol{constructor(t,e,n,i,r,a){super(t,e,n,n,i,r,a),this.isArcCurve=!0,this.type="ArcCurve"}},CatmullRomCurve3:class extends sl{constructor(t=[],e=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=i}getPoint(t,e=new Ai){const n=e,i=this.points,r=i.length,a=(r-(this.closed?0:1))*t;let s,o,l=Math.floor(a),c=a-l;this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/r)+1)*r:0===c&&l===r-1&&(l=r-2,c=1),this.closed||l>0?s=i[(l-1)%r]:(hl.subVectors(i[0],i[1]).add(i[0]),s=hl);const h=i[l%r],d=i[(l+1)%r];if(this.closed||l+2<r?o=i[(l+2)%r]:(cl.subVectors(i[r-1],i[r-2]).add(i[r-1]),o=cl),"centripetal"===this.curveType||"chordal"===this.curveType){const t="chordal"===this.curveType?.5:.25;let e=Math.pow(s.distanceToSquared(h),t),n=Math.pow(h.distanceToSquared(d),t),i=Math.pow(d.distanceToSquared(o),t);n<1e-4&&(n=1),e<1e-4&&(e=n),i<1e-4&&(i=n),dl.initNonuniformCatmullRom(s.x,h.x,d.x,o.x,e,n,i),ul.initNonuniformCatmullRom(s.y,h.y,d.y,o.y,e,n,i),pl.initNonuniformCatmullRom(s.z,h.z,d.z,o.z,e,n,i)}else"catmullrom"===this.curveType&&(dl.initCatmullRom(s.x,h.x,d.x,o.x,this.tension),ul.initCatmullRom(s.y,h.y,d.y,o.y,this.tension),pl.initCatmullRom(s.z,h.z,d.z,o.z,this.tension));return n.set(dl.calc(c),ul.calc(c),pl.calc(c)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push(n.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const n=this.points[e];t.points.push(n.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push((new Ai).fromArray(n))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}},CubicBezierCurve:vl,CubicBezierCurve3:class extends sl{constructor(t=new Ai,e=new Ai,n=new Ai,i=new Ai){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new Ai){const n=e,i=this.v0,r=this.v1,a=this.v2,s=this.v3;return n.set(gl(t,i.x,r.x,a.x,s.x),gl(t,i.y,r.y,a.y,s.y),gl(t,i.z,r.z,a.z,s.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},EllipseCurve:ol,LineCurve:_l,LineCurve3:class extends sl{constructor(t=new Ai,e=new Ai){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new Ai){const n=e;return 1===t?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new Ai){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},QuadraticBezierCurve:yl,QuadraticBezierCurve3:xl,SplineCurve:bl});class Ml extends sl{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);if(!t.equals(e)){const n=!0===t.isVector2?"LineCurve":"LineCurve3";this.curves.push(new Sl[n](e,t))}return this}getPoint(t,e){const n=t*this.getLength(),i=this.getCurveLengths();let r=0;for(;r<i.length;){if(i[r]>=n){const t=i[r]-n,a=this.curves[r],s=a.getLength(),o=0===s?0:1-t/s;return a.getPointAt(o,e)}r++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let n=0,i=this.curves.length;n<i;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[];let n;for(let i=0,r=this.curves;i<r.length;i++){const a=r[i],s=a.isEllipseCurve?2*t:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?t*a.points.length:t,o=a.getPoints(s);for(let t=0;t<o.length;t++){const i=o[t];n&&n.equals(i)||(e.push(i),n=i)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const n=t.curves[e];this.curves.push(n.clone())}return this.autoClose=t.autoClose,this}toJSON(){const t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){const n=this.curves[e];t.curves.push(n.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const n=t.curves[e];this.curves.push((new Sl[n.type]).fromJSON(n))}return this}}class wl extends Ml{constructor(t){super(),this.type="Path",this.currentPoint=new Ei,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){const n=new _l(this.currentPoint.clone(),new Ei(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,i){const r=new yl(this.currentPoint.clone(),new Ei(t,e),new Ei(n,i));return this.curves.push(r),this.currentPoint.set(n,i),this}bezierCurveTo(t,e,n,i,r,a){const s=new vl(this.currentPoint.clone(),new Ei(t,e),new Ei(n,i),new Ei(r,a));return this.curves.push(s),this.currentPoint.set(r,a),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),n=new bl(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,i,r,a){const s=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(t+s,e+o,n,i,r,a),this}absarc(t,e,n,i,r,a){return this.absellipse(t,e,n,n,i,r,a),this}ellipse(t,e,n,i,r,a,s,o){const l=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(t+l,e+c,n,i,r,a,s,o),this}absellipse(t,e,n,i,r,a,s,o){const l=new ol(t,e,n,i,r,a,s,o);if(this.curves.length>0){const t=l.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class El extends wl{constructor(t){super(t),this.uuid=_i(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let n=0,i=this.holes.length;n<i;n++)e[n]=this.holes[n].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){const n=t.holes[e];this.holes.push(n.clone())}return this}toJSON(){const t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,n=this.holes.length;e<n;e++){const n=this.holes[e];t.holes.push(n.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){const n=t.holes[e];this.holes.push((new wl).fromJSON(n))}return this}}function Tl(t,e,n=2){const i=e&&e.length,r=i?e[0]*n:t.length;let a=Al(t,0,r,n,!0);const s=[];if(!a||a.next===a.prev)return s;let o,l,c;if(i&&(a=function(t,e,n,i){const r=[];for(let n=0,a=e.length;n<a;n++){const s=Al(t,e[n]*i,n<a-1?e[n+1]*i:t.length,i,!1);s===s.next&&(s.steiner=!0),r.push(zl(s))}r.sort(Nl);for(let t=0;t<r.length;t++)n=Ol(r[t],n);return n}(t,e,a,n)),t.length>80*n){o=t[0],l=t[1];let e=o,i=l;for(let a=n;a<r;a+=n){const n=t[a],r=t[a+1];n<o&&(o=n),r<l&&(l=r),n>e&&(e=n),r>i&&(i=r)}c=Math.max(e-o,i-l),c=0!==c?32767/c:0}return Rl(a,s,n,o,l,c,0),s}function Al(t,e,n,i,r){let a;if(r===function(t,e,n,i){let r=0;for(let a=e,s=n-i;a<n;a+=i)r+=(t[s]-t[a])*(t[a+1]+t[s+1]),s=a;return r}(t,e,n,i)>0)for(let r=e;r<n;r+=i)a=Zl(r/i|0,t[r],t[r+1],a);else for(let r=n-i;r>=e;r-=i)a=Zl(r/i|0,t[r],t[r+1],a);return a&&Hl(a,a.next)&&($l(a),a=a.next),a}function Cl(t,e){if(!t)return t;e||(e=t);let n,i=t;do{if(n=!1,i.steiner||!Hl(i,i.next)&&0!==Vl(i.prev,i,i.next))i=i.next;else{if($l(i),i=e=i.prev,i===i.next)break;n=!0}}while(n||i!==e);return e}function Rl(t,e,n,i,r,a,s){if(!t)return;!s&&a&&function(t,e,n,i){let r=t;do{0===r.z&&(r.z=Fl(r.x,r.y,e,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,n=1;do{let i,r=t;t=null;let a=null;for(e=0;r;){e++;let s=r,o=0;for(let t=0;t<n&&(o++,s=s.nextZ,s);t++);let l=n;for(;o>0||l>0&&s;)0!==o&&(0===l||!s||r.z<=s.z)?(i=r,r=r.nextZ,o--):(i=s,s=s.nextZ,l--),a?a.nextZ=i:t=i,i.prevZ=a,a=i;r=s}a.nextZ=null,n*=2}while(e>1)}(r)}(t,i,r,a);let o=t;for(;t.prev!==t.next;){const l=t.prev,c=t.next;if(a?Pl(t,i,r,a):Il(t))e.push(l.i,t.i,c.i),$l(t),t=c.next,o=c.next;else if((t=c)===o){s?1===s?Rl(t=Ll(Cl(t),e),e,n,i,r,a,2):2===s&&Dl(t,e,n,i,r,a):Rl(Cl(t),e,n,i,r,a,1);break}}}function Il(t){const e=t.prev,n=t,i=t.next;if(Vl(e,n,i)>=0)return!1;const r=e.x,a=n.x,s=i.x,o=e.y,l=n.y,c=i.y,h=Math.min(r,a,s),d=Math.min(o,l,c),u=Math.max(r,a,s),p=Math.max(o,l,c);let m=i.next;for(;m!==e;){if(m.x>=h&&m.x<=u&&m.y>=d&&m.y<=p&&Bl(r,o,a,l,s,c,m.x,m.y)&&Vl(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Pl(t,e,n,i){const r=t.prev,a=t,s=t.next;if(Vl(r,a,s)>=0)return!1;const o=r.x,l=a.x,c=s.x,h=r.y,d=a.y,u=s.y,p=Math.min(o,l,c),m=Math.min(h,d,u),f=Math.max(o,l,c),g=Math.max(h,d,u),v=Fl(p,m,e,n,i),_=Fl(f,g,e,n,i);let y=t.prevZ,x=t.nextZ;for(;y&&y.z>=v&&x&&x.z<=_;){if(y.x>=p&&y.x<=f&&y.y>=m&&y.y<=g&&y!==r&&y!==s&&Bl(o,h,l,d,c,u,y.x,y.y)&&Vl(y.prev,y,y.next)>=0)return!1;if(y=y.prevZ,x.x>=p&&x.x<=f&&x.y>=m&&x.y<=g&&x!==r&&x!==s&&Bl(o,h,l,d,c,u,x.x,x.y)&&Vl(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;y&&y.z>=v;){if(y.x>=p&&y.x<=f&&y.y>=m&&y.y<=g&&y!==r&&y!==s&&Bl(o,h,l,d,c,u,y.x,y.y)&&Vl(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;x&&x.z<=_;){if(x.x>=p&&x.x<=f&&x.y>=m&&x.y<=g&&x!==r&&x!==s&&Bl(o,h,l,d,c,u,x.x,x.y)&&Vl(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function Ll(t,e){let n=t;do{const i=n.prev,r=n.next.next;!Hl(i,r)&&Wl(i,n,n.next,r)&&ql(i,r)&&ql(r,i)&&(e.push(i.i,n.i,r.i),$l(n),$l(n.next),n=t=r),n=n.next}while(n!==t);return Cl(n)}function Dl(t,e,n,i,r,a){let s=t;do{let t=s.next.next;for(;t!==s.prev;){if(s.i!==t.i&&Gl(s,t)){let o=Yl(s,t);return s=Cl(s,s.next),o=Cl(o,o.next),Rl(s,e,n,i,r,a,0),void Rl(o,e,n,i,r,a,0)}t=t.next}s=s.next}while(s!==t)}function Nl(t,e){let n=t.x-e.x;return 0===n&&(n=t.y-e.y,0===n)&&(n=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)),n}function Ol(t,e){const n=function(t,e){let n=e;const i=t.x,r=t.y;let a,s=-1/0;if(Hl(t,n))return n;do{if(Hl(t,n.next))return n.next;if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){const t=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(t<=i&&t>s&&(s=t,a=n.x<n.next.x?n:n.next,t===i))return a}n=n.next}while(n!==e);if(!a)return null;const o=a,l=a.x,c=a.y;let h=1/0;n=a;do{if(i>=n.x&&n.x>=l&&i!==n.x&&kl(r<c?i:s,r,l,c,r<c?s:i,r,n.x,n.y)){const e=Math.abs(r-n.y)/(i-n.x);ql(n,t)&&(e<h||e===h&&(n.x>a.x||n.x===a.x&&Ul(a,n)))&&(a=n,h=e)}n=n.next}while(n!==o);return a}(t,e);if(!n)return e;const i=Yl(n,t);return Cl(i,i.next),Cl(n,n.next)}function Ul(t,e){return Vl(t.prev,t,e.prev)<0&&Vl(e.next,t,t.next)<0}function Fl(t,e,n,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function zl(t){let e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function kl(t,e,n,i,r,a,s,o){return(r-s)*(e-o)>=(t-s)*(a-o)&&(t-s)*(i-o)>=(n-s)*(e-o)&&(n-s)*(a-o)>=(r-s)*(i-o)}function Bl(t,e,n,i,r,a,s,o){return!(t===s&&e===o)&&kl(t,e,n,i,r,a,s,o)}function Gl(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&Wl(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(ql(t,e)&&ql(e,t)&&function(t,e){let n=t,i=!1;const r=(t.x+e.x)/2,a=(t.y+e.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&r<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==t);return i}(t,e)&&(Vl(t.prev,t,e.prev)||Vl(t,e.prev,e))||Hl(t,e)&&Vl(t.prev,t,t.next)>0&&Vl(e.prev,e,e.next)>0)}function Vl(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function Hl(t,e){return t.x===e.x&&t.y===e.y}function Wl(t,e,n,i){const r=Xl(Vl(t,e,n)),a=Xl(Vl(t,e,i)),s=Xl(Vl(n,i,t)),o=Xl(Vl(n,i,e));return r!==a&&s!==o||!(0!==r||!jl(t,n,e))||!(0!==a||!jl(t,i,e))||!(0!==s||!jl(n,t,i))||!(0!==o||!jl(n,e,i))}function jl(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function Xl(t){return t>0?1:t<0?-1:0}function ql(t,e){return Vl(t.prev,t,t.next)<0?Vl(t,e,t.next)>=0&&Vl(t,t.prev,e)>=0:Vl(t,e,t.prev)<0||Vl(t,t.next,e)<0}function Yl(t,e){const n=Jl(t.i,t.x,t.y),i=Jl(e.i,e.x,e.y),r=t.next,a=e.prev;return t.next=e,e.prev=t,n.next=r,r.prev=n,i.next=n,n.prev=i,a.next=i,i.prev=a,i}function Zl(t,e,n,i){const r=Jl(t,e,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function $l(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Jl(t,e,n){return{i:t,x:e,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class Kl{static triangulate(t,e,n=2){return Tl(t,e,n)}}class Ql{static area(t){const e=t.length;let n=0;for(let i=e-1,r=0;r<e;i=r++)n+=t[i].x*t[r].y-t[r].x*t[i].y;return.5*n}static isClockWise(t){return Ql.area(t)<0}static triangulateShape(t,e){const n=[],i=[],r=[];tc(t),ec(n,t);let a=t.length;e.forEach(tc);for(let t=0;t<e.length;t++)i.push(a),a+=e[t].length,ec(n,e[t]);const s=Kl.triangulate(n,i);for(let t=0;t<s.length;t+=3)r.push(s.slice(t,t+3));return r}}function tc(t){const e=t.length;e>2&&t[e-1].equals(t[0])&&t.pop()}function ec(t,e){for(let n=0;n<e.length;n++)t.push(e[n].x),t.push(e[n].y)}class nc extends Ia{constructor(t=new El([new Ei(.5,.5),new Ei(-.5,.5),new Ei(-.5,-.5),new Ei(.5,-.5)]),e={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];const n=this,i=[],r=[];for(let e=0,n=t.length;e<n;e++)a(t[e]);function a(t){const a=[],s=void 0!==e.curveSegments?e.curveSegments:12,o=void 0!==e.steps?e.steps:1,l=void 0!==e.depth?e.depth:1;let c=void 0===e.bevelEnabled||e.bevelEnabled,h=void 0!==e.bevelThickness?e.bevelThickness:.2,d=void 0!==e.bevelSize?e.bevelSize:h-.1,u=void 0!==e.bevelOffset?e.bevelOffset:0,p=void 0!==e.bevelSegments?e.bevelSegments:3;const m=e.extrudePath,f=void 0!==e.UVGenerator?e.UVGenerator:ic;let g,v,_,y,x,b=!1;if(m){g=m.getSpacedPoints(o),b=!0,c=!1;const t=!!m.isCatmullRomCurve3&&m.closed;v=m.computeFrenetFrames(o,t),_=new Ai,y=new Ai,x=new Ai}c||(p=0,h=0,d=0,u=0);const S=t.extractPoints(s);let M=S.shape;const w=S.holes;if(!Ql.isClockWise(M)){M=M.reverse();for(let t=0,e=w.length;t<e;t++){const e=w[t];Ql.isClockWise(e)&&(w[t]=e.reverse())}}function E(t){const e=1e-10*1e-10;let n=t[0];for(let i=1;i<=t.length;i++){const r=i%t.length,a=t[r],s=a.x-n.x,o=a.y-n.y,l=s*s+o*o,c=Math.max(Math.abs(a.x),Math.abs(a.y),Math.abs(n.x),Math.abs(n.y));l<=e*c*c?(t.splice(r,1),i--):n=a}}E(M),w.forEach(E);const T=w.length,A=M;for(let t=0;t<T;t++){const e=w[t];M=M.concat(e)}function C(t,e,n){return e||hi("ExtrudeGeometry: vec does not exist"),t.clone().addScaledVector(e,n)}const R=M.length;function I(t,e,n){let i,r,a;const s=t.x-e.x,o=t.y-e.y,l=n.x-t.x,c=n.y-t.y,h=s*s+o*o,d=s*c-o*l;if(Math.abs(d)>Number.EPSILON){const d=Math.sqrt(h),u=Math.sqrt(l*l+c*c),p=e.x-o/d,m=e.y+s/d,f=((n.x-c/u-p)*c-(n.y+l/u-m)*l)/(s*c-o*l);i=p+s*f-t.x,r=m+o*f-t.y;const g=i*i+r*r;if(g<=2)return new Ei(i,r);a=Math.sqrt(g/2)}else{let t=!1;s>Number.EPSILON?l>Number.EPSILON&&(t=!0):s<-Number.EPSILON?l<-Number.EPSILON&&(t=!0):Math.sign(o)===Math.sign(c)&&(t=!0),t?(i=-o,r=s,a=Math.sqrt(h)):(i=s,r=o,a=Math.sqrt(h/2))}return new Ei(i/a,r/a)}const P=[];for(let t=0,e=A.length,n=e-1,i=t+1;t<e;t++,n++,i++)n===e&&(n=0),i===e&&(i=0),P[t]=I(A[t],A[n],A[i]);const L=[];let D,N,O=P.concat();for(let t=0,e=T;t<e;t++){const e=w[t];D=[];for(let t=0,n=e.length,i=n-1,r=t+1;t<n;t++,i++,r++)i===n&&(i=0),r===n&&(r=0),D[t]=I(e[t],e[i],e[r]);L.push(D),O=O.concat(D)}if(0===p)N=Ql.triangulateShape(A,w);else{const t=[],e=[];for(let n=0;n<p;n++){const i=n/p,r=h*Math.cos(i*Math.PI/2),a=d*Math.sin(i*Math.PI/2)+u;for(let e=0,n=A.length;e<n;e++){const n=C(A[e],P[e],a);k(n.x,n.y,-r),0===i&&t.push(n)}for(let t=0,n=T;t<n;t++){const n=w[t];D=L[t];const s=[];for(let t=0,e=n.length;t<e;t++){const e=C(n[t],D[t],a);k(e.x,e.y,-r),0===i&&s.push(e)}0===i&&e.push(s)}}N=Ql.triangulateShape(t,e)}const U=N.length,F=d+u;for(let t=0;t<R;t++){const e=c?C(M[t],O[t],F):M[t];b?(y.copy(v.normals[0]).multiplyScalar(e.x),_.copy(v.binormals[0]).multiplyScalar(e.y),x.copy(g[0]).add(y).add(_),k(x.x,x.y,x.z)):k(e.x,e.y,0)}for(let t=1;t<=o;t++)for(let e=0;e<R;e++){const n=c?C(M[e],O[e],F):M[e];b?(y.copy(v.normals[t]).multiplyScalar(n.x),_.copy(v.binormals[t]).multiplyScalar(n.y),x.copy(g[t]).add(y).add(_),k(x.x,x.y,x.z)):k(n.x,n.y,l/o*t)}for(let t=p-1;t>=0;t--){const e=t/p,n=h*Math.cos(e*Math.PI/2),i=d*Math.sin(e*Math.PI/2)+u;for(let t=0,e=A.length;t<e;t++){const e=C(A[t],P[t],i);k(e.x,e.y,l+n)}for(let t=0,e=w.length;t<e;t++){const e=w[t];D=L[t];for(let t=0,r=e.length;t<r;t++){const r=C(e[t],D[t],i);b?k(r.x,r.y+g[o-1].y,g[o-1].x+n):k(r.x,r.y,l+n)}}}function z(t,e){let n=t.length;for(;--n>=0;){const i=n;let r=n-1;r<0&&(r=t.length-1);for(let t=0,n=o+2*p;t<n;t++){const n=R*t,a=R*(t+1);G(e+i+n,e+r+n,e+r+a,e+i+a)}}}function k(t,e,n){a.push(t),a.push(e),a.push(n)}function B(t,e,r){V(t),V(e),V(r);const a=i.length/3,s=f.generateTopUV(n,i,a-3,a-2,a-1);H(s[0]),H(s[1]),H(s[2])}function G(t,e,r,a){V(t),V(e),V(a),V(e),V(r),V(a);const s=i.length/3,o=f.generateSideWallUV(n,i,s-6,s-3,s-2,s-1);H(o[0]),H(o[1]),H(o[3]),H(o[1]),H(o[2]),H(o[3])}function V(t){i.push(a[3*t+0]),i.push(a[3*t+1]),i.push(a[3*t+2])}function H(t){r.push(t.x),r.push(t.y)}!function(){const t=i.length/3;if(c){let t=0,e=R*t;for(let t=0;t<U;t++){const n=N[t];B(n[2]+e,n[1]+e,n[0]+e)}t=o+2*p,e=R*t;for(let t=0;t<U;t++){const n=N[t];B(n[0]+e,n[1]+e,n[2]+e)}}else{for(let t=0;t<U;t++){const e=N[t];B(e[2],e[1],e[0])}for(let t=0;t<U;t++){const e=N[t];B(e[0]+R*o,e[1]+R*o,e[2]+R*o)}}n.addGroup(t,i.length/3-t,0)}(),function(){const t=i.length/3;let e=0;z(A,e),e+=A.length;for(let t=0,n=w.length;t<n;t++){const n=w[t];z(n,e),e+=n.length}n.addGroup(t,i.length/3-t,1)}()}this.setAttribute("position",new _a(i,3)),this.setAttribute("uv",new _a(r,2)),this.computeVertexNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return function(t,e,n){if(n.shapes=[],Array.isArray(t))for(let e=0,i=t.length;e<i;e++){const i=t[e];n.shapes.push(i.uuid)}else n.shapes.push(t.uuid);return n.options=Object.assign({},e),void 0!==e.extrudePath&&(n.options.extrudePath=e.extrudePath.toJSON()),n}(this.parameters.shapes,this.parameters.options,t)}static fromJSON(t,e){const n=[];for(let i=0,r=t.shapes.length;i<r;i++){const r=e[t.shapes[i]];n.push(r)}const i=t.options.extrudePath;return void 0!==i&&(t.options.extrudePath=(new Sl[i.type]).fromJSON(i)),new nc(n,t.options)}}const ic={generateTopUV:function(t,e,n,i,r){const a=e[3*n],s=e[3*n+1],o=e[3*i],l=e[3*i+1],c=e[3*r],h=e[3*r+1];return[new Ei(a,s),new Ei(o,l),new Ei(c,h)]},generateSideWallUV:function(t,e,n,i,r,a){const s=e[3*n],o=e[3*n+1],l=e[3*n+2],c=e[3*i],h=e[3*i+1],d=e[3*i+2],u=e[3*r],p=e[3*r+1],m=e[3*r+2],f=e[3*a],g=e[3*a+1],v=e[3*a+2];return Math.abs(o-h)<Math.abs(s-c)?[new Ei(s,1-l),new Ei(c,1-d),new Ei(u,1-m),new Ei(f,1-v)]:[new Ei(o,1-l),new Ei(h,1-d),new Ei(p,1-m),new Ei(g,1-v)]}};class rc extends tl{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2;super([-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new rc(t.radius,t.detail)}}class ac extends Ia{constructor(t=[new Ei(0,-.5),new Ei(.5,0),new Ei(0,.5)],e=12,n=0,i=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:i},e=Math.floor(e),i=yi(i,0,2*Math.PI);const r=[],a=[],s=[],o=[],l=[],c=1/e,h=new Ai,d=new Ei,u=new Ai,p=new Ai,m=new Ai;let f=0,g=0;for(let e=0;e<=t.length-1;e++)switch(e){case 0:f=t[e+1].x-t[e].x,g=t[e+1].y-t[e].y,u.x=1*g,u.y=-f,u.z=0*g,m.copy(u),u.normalize(),o.push(u.x,u.y,u.z);break;case t.length-1:o.push(m.x,m.y,m.z);break;default:f=t[e+1].x-t[e].x,g=t[e+1].y-t[e].y,u.x=1*g,u.y=-f,u.z=0*g,p.copy(u),u.x+=m.x,u.y+=m.y,u.z+=m.z,u.normalize(),o.push(u.x,u.y,u.z),m.copy(p)}for(let r=0;r<=e;r++){const u=n+r*c*i,p=Math.sin(u),m=Math.cos(u);for(let n=0;n<=t.length-1;n++){h.x=t[n].x*p,h.y=t[n].y,h.z=t[n].x*m,a.push(h.x,h.y,h.z),d.x=r/e,d.y=n/(t.length-1),s.push(d.x,d.y);const i=o[3*n+0]*p,c=o[3*n+1],u=o[3*n+0]*m;l.push(i,c,u)}}for(let n=0;n<e;n++)for(let e=0;e<t.length-1;e++){const i=e+n*t.length,a=i,s=i+t.length,o=i+t.length+1,l=i+1;r.push(a,s,l),r.push(o,l,s)}this.setIndex(r),this.setAttribute("position",new _a(a,3)),this.setAttribute("uv",new _a(s,2)),this.setAttribute("normal",new _a(l,3))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ac(t.points,t.segments,t.phiStart,t.phiLength)}}class sc extends tl{constructor(t=1,e=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],t,e),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new sc(t.radius,t.detail)}}class oc extends Ia{constructor(t=1,e=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i};const r=t/2,a=e/2,s=Math.floor(n),o=Math.floor(i),l=s+1,c=o+1,h=t/s,d=e/o,u=[],p=[],m=[],f=[];for(let t=0;t<c;t++){const e=t*d-a;for(let n=0;n<l;n++){const i=n*h-r;p.push(i,-e,0),m.push(0,0,1),f.push(n/s),f.push(1-t/o)}}for(let t=0;t<o;t++)for(let e=0;e<s;e++){const n=e+l*t,i=e+l*(t+1),r=e+1+l*(t+1),a=e+1+l*t;u.push(n,i,a),u.push(i,r,a)}this.setIndex(u),this.setAttribute("position",new _a(p,3)),this.setAttribute("normal",new _a(m,3)),this.setAttribute("uv",new _a(f,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new oc(t.width,t.height,t.widthSegments,t.heightSegments)}}class lc extends Ia{constructor(t=.5,e=1,n=32,i=1,r=0,a=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:n,phiSegments:i,thetaStart:r,thetaLength:a},n=Math.max(3,n);const s=[],o=[],l=[],c=[];let h=t;const d=(e-t)/(i=Math.max(1,i)),u=new Ai,p=new Ei;for(let t=0;t<=i;t++){for(let t=0;t<=n;t++){const i=r+t/n*a;u.x=h*Math.cos(i),u.y=h*Math.sin(i),o.push(u.x,u.y,u.z),l.push(0,0,1),p.x=(u.x/e+1)/2,p.y=(u.y/e+1)/2,c.push(p.x,p.y)}h+=d}for(let t=0;t<i;t++){const e=t*(n+1);for(let t=0;t<n;t++){const i=t+e,r=i,a=i+n+1,o=i+n+2,l=i+1;s.push(r,a,l),s.push(a,o,l)}}this.setIndex(s),this.setAttribute("position",new _a(o,3)),this.setAttribute("normal",new _a(l,3)),this.setAttribute("uv",new _a(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new lc(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}}class cc extends Ia{constructor(t=new El([new Ei(0,.5),new Ei(-.5,-.5),new Ei(.5,-.5)]),e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};const n=[],i=[],r=[],a=[];let s=0,o=0;if(!1===Array.isArray(t))l(t);else for(let e=0;e<t.length;e++)l(t[e]),this.addGroup(s,o,e),s+=o,o=0;function l(t){const s=i.length/3,l=t.extractPoints(e);let c=l.shape;const h=l.holes;!1===Ql.isClockWise(c)&&(c=c.reverse());for(let t=0,e=h.length;t<e;t++){const e=h[t];!0===Ql.isClockWise(e)&&(h[t]=e.reverse())}const d=Ql.triangulateShape(c,h);for(let t=0,e=h.length;t<e;t++){const e=h[t];c=c.concat(e)}for(let t=0,e=c.length;t<e;t++){const e=c[t];i.push(e.x,e.y,0),r.push(0,0,1),a.push(e.x,e.y)}for(let t=0,e=d.length;t<e;t++){const e=d[t],i=e[0]+s,r=e[1]+s,a=e[2]+s;n.push(i,r,a),o+=3}}this.setIndex(n),this.setAttribute("position",new _a(i,3)),this.setAttribute("normal",new _a(r,3)),this.setAttribute("uv",new _a(a,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return function(t,e){if(e.shapes=[],Array.isArray(t))for(let n=0,i=t.length;n<i;n++){const i=t[n];e.shapes.push(i.uuid)}else e.shapes.push(t.uuid);return e}(this.parameters.shapes,t)}static fromJSON(t,e){const n=[];for(let i=0,r=t.shapes.length;i<r;i++){const r=e[t.shapes[i]];n.push(r)}return new cc(n,t.curveSegments)}}class hc extends Ia{constructor(t=1,e=32,n=16,i=0,r=2*Math.PI,a=0,s=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:i,phiLength:r,thetaStart:a,thetaLength:s},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const o=Math.min(a+s,Math.PI);let l=0;const c=[],h=new Ai,d=new Ai,u=[],p=[],m=[],f=[];for(let u=0;u<=n;u++){const g=[],v=u/n;let _=0;0===u&&0===a?_=.5/e:u===n&&o===Math.PI&&(_=-.5/e);for(let n=0;n<=e;n++){const o=n/e;h.x=-t*Math.cos(i+o*r)*Math.sin(a+v*s),h.y=t*Math.cos(a+v*s),h.z=t*Math.sin(i+o*r)*Math.sin(a+v*s),p.push(h.x,h.y,h.z),d.copy(h).normalize(),m.push(d.x,d.y,d.z),f.push(o+_,1-v),g.push(l++)}c.push(g)}for(let t=0;t<n;t++)for(let i=0;i<e;i++){const e=c[t][i+1],r=c[t][i],s=c[t+1][i],l=c[t+1][i+1];(0!==t||a>0)&&u.push(e,r,l),(t!==n-1||o<Math.PI)&&u.push(r,s,l)}this.setIndex(u),this.setAttribute("position",new _a(p,3)),this.setAttribute("normal",new _a(m,3)),this.setAttribute("uv",new _a(f,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new hc(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class dc extends tl{constructor(t=1,e=0){super([1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],t,e),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new dc(t.radius,t.detail)}}class uc extends Ia{constructor(t=1,e=.4,n=12,i=48,r=2*Math.PI,a=0,s=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:n,tubularSegments:i,arc:r,thetaStart:a,thetaLength:s},n=Math.floor(n),i=Math.floor(i);const o=[],l=[],c=[],h=[],d=new Ai,u=new Ai,p=new Ai;for(let o=0;o<=n;o++){const m=a+o/n*s;for(let a=0;a<=i;a++){const s=a/i*r;u.x=(t+e*Math.cos(m))*Math.cos(s),u.y=(t+e*Math.cos(m))*Math.sin(s),u.z=e*Math.sin(m),l.push(u.x,u.y,u.z),d.x=t*Math.cos(s),d.y=t*Math.sin(s),p.subVectors(u,d).normalize(),c.push(p.x,p.y,p.z),h.push(a/i),h.push(o/n)}}for(let t=1;t<=n;t++)for(let e=1;e<=i;e++){const n=(i+1)*t+e-1,r=(i+1)*(t-1)+e-1,a=(i+1)*(t-1)+e,s=(i+1)*t+e;o.push(n,r,s),o.push(r,a,s)}this.setIndex(o),this.setAttribute("position",new _a(l,3)),this.setAttribute("normal",new _a(c,3)),this.setAttribute("uv",new _a(h,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new uc(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class pc extends Ia{constructor(t=1,e=.4,n=64,i=8,r=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:n,radialSegments:i,p:r,q:a},n=Math.floor(n),i=Math.floor(i);const s=[],o=[],l=[],c=[],h=new Ai,d=new Ai,u=new Ai,p=new Ai,m=new Ai,f=new Ai,g=new Ai;for(let s=0;s<=n;++s){const _=s/n*r*Math.PI*2;v(_,r,a,t,u),v(_+.01,r,a,t,p),f.subVectors(p,u),g.addVectors(p,u),m.crossVectors(f,g),g.crossVectors(m,f),m.normalize(),g.normalize();for(let t=0;t<=i;++t){const r=t/i*Math.PI*2,a=-e*Math.cos(r),p=e*Math.sin(r);h.x=u.x+(a*g.x+p*m.x),h.y=u.y+(a*g.y+p*m.y),h.z=u.z+(a*g.z+p*m.z),o.push(h.x,h.y,h.z),d.subVectors(h,u).normalize(),l.push(d.x,d.y,d.z),c.push(s/n),c.push(t/i)}}for(let t=1;t<=n;t++)for(let e=1;e<=i;e++){const n=(i+1)*(t-1)+(e-1),r=(i+1)*t+(e-1),a=(i+1)*t+e,o=(i+1)*(t-1)+e;s.push(n,r,o),s.push(r,a,o)}function v(t,e,n,i,r){const a=Math.cos(t),s=Math.sin(t),o=n/e*t,l=Math.cos(o);r.x=i*(2+l)*.5*a,r.y=i*(2+l)*s*.5,r.z=i*Math.sin(o)*.5}this.setIndex(s),this.setAttribute("position",new _a(o,3)),this.setAttribute("normal",new _a(l,3)),this.setAttribute("uv",new _a(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new pc(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}}class mc extends Ia{constructor(t=new xl(new Ai(-1,-1,0),new Ai(-1,1,0),new Ai(1,1,0)),e=64,n=1,i=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:i,closed:r};const a=t.computeFrenetFrames(e,r);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;const s=new Ai,o=new Ai,l=new Ei;let c=new Ai;const h=[],d=[],u=[],p=[];function m(r){c=t.getPointAt(r/e,c);const l=a.normals[r],u=a.binormals[r];for(let t=0;t<=i;t++){const e=t/i*Math.PI*2,r=Math.sin(e),a=-Math.cos(e);o.x=a*l.x+r*u.x,o.y=a*l.y+r*u.y,o.z=a*l.z+r*u.z,o.normalize(),d.push(o.x,o.y,o.z),s.x=c.x+n*o.x,s.y=c.y+n*o.y,s.z=c.z+n*o.z,h.push(s.x,s.y,s.z)}}!function(){for(let t=0;t<e;t++)m(t);m(!1===r?e:0),function(){for(let t=0;t<=e;t++)for(let n=0;n<=i;n++)l.x=t/e,l.y=n/i,u.push(l.x,l.y)}(),function(){for(let t=1;t<=e;t++)for(let e=1;e<=i;e++){const n=(i+1)*(t-1)+(e-1),r=(i+1)*t+(e-1),a=(i+1)*t+e,s=(i+1)*(t-1)+e;p.push(n,r,s),p.push(r,a,s)}}()}(),this.setIndex(p),this.setAttribute("position",new _a(h,3)),this.setAttribute("normal",new _a(d,3)),this.setAttribute("uv",new _a(u,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return t.path=this.parameters.path.toJSON(),t}static fromJSON(t){return new mc((new Sl[t.path.type]).fromJSON(t.path),t.tubularSegments,t.radius,t.radialSegments,t.closed)}}function fc(t,e,n){const i=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`;return!0!==n.has(i)&&!0!==n.has(r)&&(n.add(i),n.add(r),!0)}var gc=Object.freeze({__proto__:null,BoxGeometry:Zo,CapsuleGeometry:$o,CircleGeometry:Jo,ConeGeometry:Qo,CylinderGeometry:Ko,DodecahedronGeometry:el,EdgesGeometry:class extends Ia{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},null!==t){const n=4,i=Math.pow(10,n),r=Math.cos(gi*e),a=t.getIndex(),s=t.getAttribute("position"),o=a?a.count:s.count,l=[0,0,0],c=["a","b","c"],h=new Array(3),d={},u=[];for(let t=0;t<o;t+=3){a?(l[0]=a.getX(t),l[1]=a.getX(t+1),l[2]=a.getX(t+2)):(l[0]=t,l[1]=t+1,l[2]=t+2);const{a:e,b:n,c:o}=al;if(e.fromBufferAttribute(s,l[0]),n.fromBufferAttribute(s,l[1]),o.fromBufferAttribute(s,l[2]),al.getNormal(rl),h[0]=`${Math.round(e.x*i)},${Math.round(e.y*i)},${Math.round(e.z*i)}`,h[1]=`${Math.round(n.x*i)},${Math.round(n.y*i)},${Math.round(n.z*i)}`,h[2]=`${Math.round(o.x*i)},${Math.round(o.y*i)},${Math.round(o.z*i)}`,h[0]!==h[1]&&h[1]!==h[2]&&h[2]!==h[0])for(let t=0;t<3;t++){const e=(t+1)%3,n=h[t],i=h[e],a=al[c[t]],s=al[c[e]],o=`${n}_${i}`,p=`${i}_${n}`;p in d&&d[p]?(rl.dot(d[p].normal)<=r&&(u.push(a.x,a.y,a.z),u.push(s.x,s.y,s.z)),d[p]=null):o in d||(d[o]={index0:l[t],index1:l[e],normal:rl.clone()})}}for(const t in d)if(d[t]){const{index0:e,index1:n}=d[t];nl.fromBufferAttribute(s,e),il.fromBufferAttribute(s,n),u.push(nl.x,nl.y,nl.z),u.push(il.x,il.y,il.z)}this.setAttribute("position",new _a(u,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}},ExtrudeGeometry:nc,IcosahedronGeometry:rc,LatheGeometry:ac,OctahedronGeometry:sc,PlaneGeometry:oc,PolyhedronGeometry:tl,RingGeometry:lc,ShapeGeometry:cc,SphereGeometry:hc,TetrahedronGeometry:dc,TorusGeometry:uc,TorusKnotGeometry:pc,TubeGeometry:mc,WireframeGeometry:class extends Ia{constructor(t=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:t},null!==t){const e=[],n=new Set,i=new Ai,r=new Ai;if(null!==t.index){const a=t.attributes.position,s=t.index;let o=t.groups;0===o.length&&(o=[{start:0,count:s.count,materialIndex:0}]);for(let t=0,l=o.length;t<l;++t){const l=o[t],c=l.start;for(let t=c,o=c+l.count;t<o;t+=3)for(let o=0;o<3;o++){const l=s.getX(t+o),c=s.getX(t+(o+1)%3);i.fromBufferAttribute(a,l),r.fromBufferAttribute(a,c),!0===fc(i,r,n)&&(e.push(i.x,i.y,i.z),e.push(r.x,r.y,r.z))}}}else{const a=t.attributes.position;for(let t=0,s=a.count/3;t<s;t++)for(let s=0;s<3;s++){const o=3*t+s,l=3*t+(s+1)%3;i.fromBufferAttribute(a,o),r.fromBufferAttribute(a,l),!0===fc(i,r,n)&&(e.push(i.x,i.y,i.z),e.push(r.x,r.y,r.z))}}this.setAttribute("position",new _a(e,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}});class vc extends Ua{constructor(t){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Lr(0),this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.fog=t.fog,this}}function _c(t){const e={};for(const n in t){e[n]={};for(const i in t[n]){const r=t[n][i];if(xc(r))r.isRenderTargetTexture?(ci("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][i]=null):e[n][i]=r.clone();else if(Array.isArray(r))if(xc(r[0])){const t=[];for(let e=0,n=r.length;e<n;e++)t[e]=r[e].clone();e[n][i]=t}else e[n][i]=r.slice();else e[n][i]=r}}return e}function yc(t){const e={};for(let n=0;n<t.length;n++){const i=_c(t[n]);for(const t in i)e[t]=i[t]}return e}function xc(t){return t&&(t.isColor||t.isMatrix3||t.isMatrix4||t.isVector2||t.isVector3||t.isVector4||t.isTexture||t.isQuaternion)}function bc(t){const e=t.getRenderTarget();return null===e?t.outputColorSpace:!0===e.isXRRenderTarget?e.texture.colorSpace:Oi.workingColorSpace}const Sc={clone:_c,merge:yc};class Mc extends Ua{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==t&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=_c(t.uniforms),this.uniformsGroups=function(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this.defaultAttributeValues=Object.assign({},t.defaultAttributeValues),this.index0AttributeName=t.index0AttributeName,this.uniformsNeedUpdate=t.uniformsNeedUpdate,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const n in this.uniforms){const i=this.uniforms[n].value;i&&i.isTexture?e.uniforms[n]={type:"t",value:i.toJSON(t).uuid}:i&&i.isColor?e.uniforms[n]={type:"c",value:i.getHex()}:i&&i.isVector2?e.uniforms[n]={type:"v2",value:i.toArray()}:i&&i.isVector3?e.uniforms[n]={type:"v3",value:i.toArray()}:i&&i.isVector4?e.uniforms[n]={type:"v4",value:i.toArray()}:i&&i.isMatrix3?e.uniforms[n]={type:"m3",value:i.toArray()}:i&&i.isMatrix4?e.uniforms[n]={type:"m4",value:i.toArray()}:e.uniforms[n]={value:i}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const t in this.extensions)!0===this.extensions[t]&&(n[t]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}class wc extends Mc{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Ec extends Ua{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Lr(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Lr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ei(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new or,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Tc extends Ec{constructor(t){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ei(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return yi(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Lr(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Lr(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Lr(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class Ac extends Ua{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Lr(16777215),this.specular=new Lr(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Lr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ei(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new or,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Cc extends Ua{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Lr(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Lr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ei(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class Rc extends Ua{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ei(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class Ic extends Ua{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Lr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Lr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ei(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new or,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Pc extends Ua{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class Lc extends Ua{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}class Dc extends Ua{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Lr(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ei(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Nc extends wo{constructor(t){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}function Oc(t,e){return t&&t.constructor!==e?"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t):t}function Uc(t){const e=t.length,n=new Array(e);for(let t=0;t!==e;++t)n[t]=t;return n.sort((function(e,n){return t[e]-t[n]})),n}function Fc(t,e,n){const i=t.length,r=new t.constructor(i);for(let a=0,s=0;s!==i;++a){const i=n[a]*e;for(let n=0;n!==e;++n)r[s++]=t[i+n]}return r}function zc(t,e,n,i){let r=1,a=t[0];for(;void 0!==a&&void 0===a[i];)a=t[r++];if(void 0===a)return;let s=a[i];if(void 0!==s)if(Array.isArray(s))do{s=a[i],void 0!==s&&(e.push(a.time),n.push(...s)),a=t[r++]}while(void 0!==a);else if(void 0!==s.toArray)do{s=a[i],void 0!==s&&(e.push(a.time),s.toArray(n,n.length)),a=t[r++]}while(void 0!==a);else do{s=a[i],void 0!==s&&(e.push(a.time),n.push(s)),a=t[r++]}while(void 0!==a)}class kc{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let n=this._cachedIndex,i=e[n],r=e[n-1];t:{e:{let a;n:{i:if(!(t<i)){for(let a=n+2;;){if(void 0===i){if(t<r)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(r=i,i=e[++n],t<i)break e}a=e.length;break n}if(t>=r)break t;{const s=e[1];t<s&&(n=2,r=s);for(let a=n-2;;){if(void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(i=r,r=e[--n-1],t>=r)break e}a=n,n=0}}for(;n<a;){const i=n+a>>>1;t<e[i]?a=i:n=i+1}if(i=e[n],r=e[n-1],void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===i)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=t*i;for(let t=0;t!==i;++t)e[t]=n[r+t];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class Bc extends kc{constructor(t,e,n,i){super(t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Nn,endingEnd:Nn}}intervalChanged_(t,e,n){const i=this.parameterPositions;let r=t-2,a=t+1,s=i[r],o=i[a];if(void 0===s)switch(this.getSettings_().endingStart){case On:r=t,s=2*e-n;break;case Un:r=i.length-2,s=e+i[r]-i[r+1];break;default:r=t,s=n}if(void 0===o)switch(this.getSettings_().endingEnd){case On:a=t,o=2*n-e;break;case Un:a=1,o=n+i[1]-i[0];break;default:a=t-1,o=e}const l=.5*(n-e),c=this.valueSize;this._weightPrev=l/(e-s),this._weightNext=l/(o-n),this._offsetPrev=r*c,this._offsetNext=a*c}interpolate_(t,e,n,i){const r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=t*s,l=o-s,c=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,u=this._weightNext,p=(n-e)/(i-e),m=p*p,f=m*p,g=-d*f+2*d*m-d*p,v=(1+d)*f+(-1.5-2*d)*m+(-.5+d)*p+1,_=(-1-u)*f+(1.5+u)*m+.5*p,y=u*f-u*m;for(let t=0;t!==s;++t)r[t]=g*a[c+t]+v*a[l+t]+_*a[o+t]+y*a[h+t];return r}}class Gc extends kc{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=t*s,l=o-s,c=(n-e)/(i-e),h=1-c;for(let t=0;t!==s;++t)r[t]=a[l+t]*h+a[o+t]*c;return r}}class Vc extends kc{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}}class Hc extends kc{interpolate_(t,e,n,i){const r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=t*s,l=o-s,c=this.settings||this.DefaultSettings_,h=c.inTangents,d=c.outTangents;if(!h||!d){const t=(n-e)/(i-e),c=1-t;for(let e=0;e!==s;++e)r[e]=a[l+e]*c+a[o+e]*t;return r}const u=2*s,p=t-1;for(let c=0;c!==s;++c){const s=a[l+c],m=a[o+c],f=p*u+2*c,g=d[f],v=d[f+1],_=t*u+2*c,y=h[_],x=h[_+1];let b,S,M,w,E,T=(n-e)/(i-e);for(let t=0;t<8;t++){b=T*T,S=b*T,M=1-T,w=M*M,E=w*M;const t=E*e+3*w*T*g+3*M*b*y+S*i-n;if(Math.abs(t)<1e-10)break;const r=3*w*(g-e)+6*M*T*(y-g)+3*b*(i-y);if(Math.abs(r)<1e-10)break;T-=t/r,T=Math.max(0,Math.min(1,T))}r[c]=E*s+3*w*T*v+3*M*b*x+S*m}return r}}class Wc{constructor(t,e,n,i){if(void 0===t)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===e||0===e.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=Oc(e,this.TimeBufferType),this.values=Oc(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:Oc(t.times,Array),values:Oc(t.values,Array)};const e=t.getInterpolation();e!==t.DefaultInterpolation&&(n.interpolation=e)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new Vc(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Gc(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new Bc(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodBezier(t){const e=new Hc(this.times,this.values,this.getValueSize(),t);return this.settings&&(e.settings=this.settings),e}setInterpolation(t){let e;switch(t){case Pn:e=this.InterpolantFactoryMethodDiscrete;break;case Ln:e=this.InterpolantFactoryMethodLinear;break;case Dn:e=this.InterpolantFactoryMethodSmooth;break;case 2303:e=this.InterpolantFactoryMethodBezier}if(void 0===e){const e="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(t===this.DefaultInterpolation)throw new Error(e);this.setInterpolation(this.DefaultInterpolation)}return ci("KeyframeTrack:",e),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Pn;case this.InterpolantFactoryMethodLinear:return Ln;case this.InterpolantFactoryMethodSmooth:return Dn;case this.InterpolantFactoryMethodBezier:return 2303}}getValueSize(){return this.values.length/this.times.length}shift(t){if(0!==t){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(1!==t){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t}return this}trim(t,e){const n=this.times,i=n.length;let r=0,a=i-1;for(;r!==i&&n[r]<t;)++r;for(;-1!==a&&n[a]>e;)--a;if(++a,0!==r||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);const t=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*t,a*t)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!==0&&(hi("KeyframeTrack: Invalid value size in track.",this),t=!1);const n=this.times,i=this.values,r=n.length;0===r&&(hi("KeyframeTrack: Track is empty.",this),t=!1);let a=null;for(let e=0;e!==r;e++){const i=n[e];if("number"==typeof i&&isNaN(i)){hi("KeyframeTrack: Time is not a valid number.",this,e,i),t=!1;break}if(null!==a&&a>i){hi("KeyframeTrack: Out of order keys.",this,e,i,a),t=!1;break}a=i}if(void 0!==i&&(s=i,ArrayBuffer.isView(s)&&!(s instanceof DataView)))for(let e=0,n=i.length;e!==n;++e){const n=i[e];if(isNaN(n)){hi("KeyframeTrack: Value is not a valid number.",this,e,n),t=!1;break}}var s;return t}optimize(){const t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===Dn,r=t.length-1;let a=1;for(let s=1;s<r;++s){let r=!1;const o=t[s];if(o!==t[s+1]&&(1!==s||o!==t[0]))if(i)r=!0;else{const t=s*n,i=t-n,a=t+n;for(let s=0;s!==n;++s){const n=e[t+s];if(n!==e[i+s]||n!==e[a+s]){r=!0;break}}}if(r){if(s!==a){t[a]=t[s];const i=s*n,r=a*n;for(let t=0;t!==n;++t)e[r+t]=e[i+t]}++a}}if(r>0){t[a]=t[r];for(let t=r*n,i=a*n,s=0;s!==n;++s)e[i+s]=e[t+s];++a}return a!==t.length?(this.times=t.slice(0,a),this.values=e.slice(0,a*n)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),n=new(0,this.constructor)(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}}Wc.prototype.ValueTypeName="",Wc.prototype.TimeBufferType=Float32Array,Wc.prototype.ValueBufferType=Float32Array,Wc.prototype.DefaultInterpolation=Ln;class jc extends Wc{constructor(t,e,n){super(t,e,n)}}jc.prototype.ValueTypeName="bool",jc.prototype.ValueBufferType=Array,jc.prototype.DefaultInterpolation=Pn,jc.prototype.InterpolantFactoryMethodLinear=void 0,jc.prototype.InterpolantFactoryMethodSmooth=void 0;class Xc extends Wc{constructor(t,e,n,i){super(t,e,n,i)}}Xc.prototype.ValueTypeName="color";class qc extends Wc{constructor(t,e,n,i){super(t,e,n,i)}}qc.prototype.ValueTypeName="number";class Yc extends kc{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=(n-e)/(i-e);let l=t*s;for(let t=l+s;l!==t;l+=4)Ti.slerpFlat(r,0,a,l-s,a,l,o);return r}}class Zc extends Wc{constructor(t,e,n,i){super(t,e,n,i)}InterpolantFactoryMethodLinear(t){return new Yc(this.times,this.values,this.getValueSize(),t)}}Zc.prototype.ValueTypeName="quaternion",Zc.prototype.InterpolantFactoryMethodSmooth=void 0;class $c extends Wc{constructor(t,e,n){super(t,e,n)}}$c.prototype.ValueTypeName="string",$c.prototype.ValueBufferType=Array,$c.prototype.DefaultInterpolation=Pn,$c.prototype.InterpolantFactoryMethodLinear=void 0,$c.prototype.InterpolantFactoryMethodSmooth=void 0;class Jc extends Wc{constructor(t,e,n,i){super(t,e,n,i)}}Jc.prototype.ValueTypeName="vector";class Kc{constructor(t="",e=-1,n=[],i=2500){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=_i(),this.userData={},this.duration<0&&this.resetDuration()}static parse(t){const e=[],n=t.tracks,i=1/(t.fps||1);for(let t=0,r=n.length;t!==r;++t)e.push(Qc(n[t]).scale(i));const r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r.userData=JSON.parse(t.userData||"{}"),r}static toJSON(t){const e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode,userData:JSON.stringify(t.userData)};for(let t=0,i=n.length;t!==i;++t)e.push(Wc.toJSON(n[t]));return i}static CreateFromMorphTargetSequence(t,e,n,i){const r=e.length,a=[];for(let t=0;t<r;t++){let s=[],o=[];s.push((t+r-1)%r,t,(t+1)%r),o.push(0,1,0);const l=Uc(s);s=Fc(s,1,l),o=Fc(o,1,l),i||0!==s[0]||(s.push(r),o.push(o[0])),a.push(new qc(".morphTargetInfluences["+e[t].name+"]",s,o).scale(1/n))}return new this(t,-1,a)}static findByName(t,e){let n=t;if(!Array.isArray(t)){const e=t;n=e.geometry&&e.geometry.animations||e.animations}for(let t=0;t<n.length;t++)if(n[t].name===e)return n[t];return null}static CreateClipsFromMorphTargetSequences(t,e,n){const i={},r=/^([\w-]*?)([\d]+)$/;for(let e=0,n=t.length;e<n;e++){const n=t[e],a=n.name.match(r);if(a&&a.length>1){const t=a[1];let e=i[t];e||(i[t]=e=[]),e.push(n)}}const a=[];for(const t in i)a.push(this.CreateFromMorphTargetSequence(t,i[t],e,n));return a}static parseAnimation(t,e){if(ci("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!t)return hi("AnimationClip: No animation in JSONLoader data."),null;const n=function(t,e,n,i,r){if(0!==n.length){const a=[],s=[];zc(n,a,s,i),0!==a.length&&r.push(new t(e,a,s))}},i=[],r=t.name||"default",a=t.fps||30,s=t.blendMode;let o=t.length||-1;const l=t.hierarchy||[];for(let t=0;t<l.length;t++){const r=l[t].keys;if(r&&0!==r.length)if(r[0].morphTargets){const t={};let e;for(e=0;e<r.length;e++)if(r[e].morphTargets)for(let n=0;n<r[e].morphTargets.length;n++)t[r[e].morphTargets[n]]=-1;for(const n in t){const t=[],a=[];for(let i=0;i!==r[e].morphTargets.length;++i){const i=r[e];t.push(i.time),a.push(i.morphTarget===n?1:0)}i.push(new qc(".morphTargetInfluence["+n+"]",t,a))}o=t.length*a}else{const a=".bones["+e[t].name+"]";n(Jc,a+".position",r,"pos",i),n(Zc,a+".quaternion",r,"rot",i),n(Jc,a+".scale",r,"scl",i)}}return 0===i.length?null:new this(r,o,i,s)}resetDuration(){let t=0;for(let e=0,n=this.tracks.length;e!==n;++e){const n=this.tracks[e];t=Math.max(t,n.times[n.times.length-1])}return this.duration=t,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){const t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());const e=new this.constructor(this.name,this.duration,t,this.blendMode);return e.userData=JSON.parse(JSON.stringify(this.userData)),e}toJSON(){return this.constructor.toJSON(this)}}function Qc(t){if(void 0===t.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return qc;case"vector":case"vector2":case"vector3":case"vector4":return Jc;case"color":return Xc;case"quaternion":return Zc;case"bool":case"boolean":return jc;case"string":return $c}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}(t.type);if(void 0===t.times){const e=[],n=[];zc(t.keys,e,n,"value"),t.times=e,t.values=n}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)}const th={enabled:!1,files:{},add:function(t,e){!1!==this.enabled&&(eh(t)||(this.files[t]=e))},get:function(t){if(!1!==this.enabled&&!eh(t))return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};function eh(t){try{const e=t.slice(t.indexOf(":")+1);return"blob:"===new URL(e).protocol}catch(t){return!1}}class nh{constructor(t,e,n){const i=this;let r,a=!1,s=0,o=0;const l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this._abortController=null,this.itemStart=function(t){o++,!1===a&&void 0!==i.onStart&&i.onStart(t,s,o),a=!0},this.itemEnd=function(t){s++,void 0!==i.onProgress&&i.onProgress(t,s,o),s===o&&(a=!1,void 0!==i.onLoad&&i.onLoad())},this.itemError=function(t){void 0!==i.onError&&i.onError(t)},this.resolveURL=function(t){return r?r(t):t},this.setURLModifier=function(t){return r=t,this},this.addHandler=function(t,e){return l.push(t,e),this},this.removeHandler=function(t){const e=l.indexOf(t);return-1!==e&&l.splice(e,2),this},this.getHandler=function(t){for(let e=0,n=l.length;e<n;e+=2){const n=l[e],i=l[e+1];if(n.global&&(n.lastIndex=0),n.test(t))return i}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const ih=new nh;class rh{constructor(t){this.manager=void 0!==t?t:ih,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(t,e){const n=this;return new Promise((function(i,r){n.load(t,i,e,r)}))}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}abort(){return this}}rh.DEFAULT_MATERIAL_NAME="__DEFAULT";const ah={};class sh extends Error{constructor(t,e){super(t),this.response=e}}class oh extends rh{constructor(t){super(t),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(t,e,n,i){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=th.get(`file:${t}`);if(void 0!==r)return this.manager.itemStart(t),void setTimeout((()=>{e&&e(r),this.manager.itemEnd(t)}),0);if(void 0!==ah[t])return void ah[t].push({onLoad:e,onProgress:n,onError:i});ah[t]=[],ah[t].push({onLoad:e,onProgress:n,onError:i});const a=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:"function"==typeof AbortSignal.any?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),s=this.mimeType,o=this.responseType;fetch(a).then((e=>{if(200===e.status||0===e.status){if(0===e.status&&ci("FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===e.body||void 0===e.body.getReader)return e;const n=ah[t],i=e.body.getReader(),r=e.headers.get("X-File-Size")||e.headers.get("Content-Length"),a=r?parseInt(r):0,s=0!==a;let o=0;const l=new ReadableStream({start(t){!function e(){i.read().then((({done:i,value:r})=>{if(i)t.close();else{o+=r.byteLength;const i=new ProgressEvent("progress",{lengthComputable:s,loaded:o,total:a});for(let t=0,e=n.length;t<e;t++){const e=n[t];e.onProgress&&e.onProgress(i)}t.enqueue(r),e()}}),(e=>{t.error(e)}))}()}});return new Response(l)}throw new sh(`fetch for "${e.url}" responded with ${e.status}: ${e.statusText}`,e)})).then((t=>{switch(o){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"document":return t.text().then((t=>(new DOMParser).parseFromString(t,s)));case"json":return t.json();default:if(""===s)return t.text();{const e=/charset="?([^;"\s]*)"?/i.exec(s),n=e&&e[1]?e[1].toLowerCase():void 0,i=new TextDecoder(n);return t.arrayBuffer().then((t=>i.decode(t)))}}})).then((e=>{th.add(`file:${t}`,e);const n=ah[t];delete ah[t];for(let t=0,i=n.length;t<i;t++){const i=n[t];i.onLoad&&i.onLoad(e)}})).catch((e=>{const n=ah[t];if(void 0===n)throw this.manager.itemError(t),e;delete ah[t];for(let t=0,i=n.length;t<i;t++){const i=n[t];i.onError&&i.onError(e)}this.manager.itemError(t)})).finally((()=>{this.manager.itemEnd(t)})),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const lh=new WeakMap;class ch extends rh{constructor(t){super(t)}load(t,e,n,i){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,a=th.get(`image:${t}`);if(void 0!==a){if(!0===a.complete)r.manager.itemStart(t),setTimeout((function(){e&&e(a),r.manager.itemEnd(t)}),0);else{let t=lh.get(a);void 0===t&&(t=[],lh.set(a,t)),t.push({onLoad:e,onError:i})}return a}const s=ri("img");function o(){c(),e&&e(this);const n=lh.get(this)||[];for(let t=0;t<n.length;t++){const e=n[t];e.onLoad&&e.onLoad(this)}lh.delete(this),r.manager.itemEnd(t)}function l(e){c(),i&&i(e),th.remove(`image:${t}`);const n=lh.get(this)||[];for(let t=0;t<n.length;t++){const i=n[t];i.onError&&i.onError(e)}lh.delete(this),r.manager.itemError(t),r.manager.itemEnd(t)}function c(){s.removeEventListener("load",o,!1),s.removeEventListener("error",l,!1)}return s.addEventListener("load",o,!1),s.addEventListener("error",l,!1),"data:"!==t.slice(0,5)&&void 0!==this.crossOrigin&&(s.crossOrigin=this.crossOrigin),th.add(`image:${t}`,s),r.manager.itemStart(t),s.src=t,s}}class hh extends wr{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Lr(t),this.intensity=e}dispose(){this.dispatchEvent({type:"dispose"})}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,e}}class dh extends hh{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(wr.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Lr(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}toJSON(t){const e=super.toJSON(t);return e.object.groundColor=this.groundColor.getHex(),e}}const uh=new Ji,ph=new Ai,mh=new Ai;class fh{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ei(512,512),this.mapType=Ae,this.map=null,this.mapPass=null,this.matrix=new Ji,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new to,this._frameExtents=new Ei(1,1),this._viewportCount=1,this._viewports=[new Xi(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;ph.setFromMatrixPosition(t.matrixWorld),e.position.copy(ph),mh.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(mh),e.updateMatrixWorld(),uh.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(uh,e.coordinateSystem,e.reversedDepth),e.coordinateSystem===ei||e.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(uh)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.autoUpdate=t.autoUpdate,this.needsUpdate=t.needsUpdate,this.normalBias=t.normalBias,this.blurSamples=t.blurSamples,this.mapSize.copy(t.mapSize),this.biasNode=t.biasNode,this}clone(){return(new this.constructor).copy(this)}toJSON(){const t={};return 1!==this.intensity&&(t.intensity=this.intensity),0!==this.bias&&(t.bias=this.bias),0!==this.normalBias&&(t.normalBias=this.normalBias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}const gh=new Ai,vh=new Ti,_h=new Ai;class yh extends wr{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ji,this.projectionMatrix=new Ji,this.projectionMatrixInverse=new Ji,this.coordinateSystem=ti,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorld.decompose(gh,vh,_h),1===_h.x&&1===_h.y&&1===_h.z?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(gh,vh,_h.set(1,1,1)).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorld.decompose(gh,vh,_h),1===_h.x&&1===_h.y&&1===_h.z?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(gh,vh,_h.set(1,1,1)).invert()}clone(){return(new this.constructor).copy(this)}}const xh=new Ai,bh=new Ei,Sh=new Ei;class Mh extends yh{constructor(t=50,e=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=2*vi*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*gi*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*vi*Math.atan(Math.tan(.5*gi*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){xh.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(xh.x,xh.y).multiplyScalar(-t/xh.z),xh.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(xh.x,xh.y).multiplyScalar(-t/xh.z)}getViewSize(t,e){return this.getViewBounds(t,bh,Sh),e.subVectors(Sh,bh)}setViewOffset(t,e,n,i,r,a){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*gi*this.fov)/this.zoom,n=2*e,i=this.aspect*n,r=-.5*i;const a=this.view;if(null!==this.view&&this.view.enabled){const t=a.fullWidth,s=a.fullHeight;r+=a.offsetX*i/t,e-=a.offsetY*n/s,i*=a.width/t,n*=a.height/s}const s=this.filmOffset;0!==s&&(r+=t*s/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,e,e-n,t,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}class wh extends fh{constructor(){super(new Mh(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(t){const e=this.camera,n=2*vi*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=t.distance||e.far;n===e.fov&&i===e.aspect&&r===e.far||(e.fov=n,e.aspect=i,e.far=r,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class Eh extends hh{constructor(t,e,n=0,i=Math.PI/3,r=0,a=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(wr.DEFAULT_UP),this.updateMatrix(),this.target=new wr,this.distance=n,this.angle=i,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new wh}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.map=t.map,this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.distance=this.distance,e.object.angle=this.angle,e.object.decay=this.decay,e.object.penumbra=this.penumbra,e.object.target=this.target.uuid,this.map&&this.map.isTexture&&(e.object.map=this.map.toJSON(t).uuid),e.object.shadow=this.shadow.toJSON(),e}}class Th extends fh{constructor(){super(new Mh(90,1,.5,500)),this.isPointLightShadow=!0}}class Ah extends hh{constructor(t,e,n=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new Th}get power(){return 4*this.intensity*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.distance=this.distance,e.object.decay=this.decay,e.object.shadow=this.shadow.toJSON(),e}}class Ch extends yh{constructor(t=-1,e=1,n=1,i=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,r,a){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-t,a=n+t,s=i+e,o=i-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=t*this.view.offsetX,a=r+t*this.view.width,s-=e*this.view.offsetY,o=s-e*this.view.height}this.projectionMatrix.makeOrthographic(r,a,s,o,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}class Rh extends fh{constructor(){super(new Ch(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Ih extends hh{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(wr.DEFAULT_UP),this.updateMatrix(),this.target=new wr,this.shadow=new Rh}dispose(){super.dispose(),this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.shadow=this.shadow.toJSON(),e.object.target=this.target.uuid,e}}class Ph extends hh{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class Lh extends hh{constructor(t,e,n=10,i=10){super(t,e),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(t){this.intensity=t/(this.width*this.height*Math.PI)}copy(t){return super.copy(t),this.width=t.width,this.height=t.height,this}toJSON(t){const e=super.toJSON(t);return e.object.width=this.width,e.object.height=this.height,e}}class Dh{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new Ai)}set(t){for(let e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this}zero(){for(let t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this}getAt(t,e){const n=t.x,i=t.y,r=t.z,a=this.coefficients;return e.copy(a[0]).multiplyScalar(.282095),e.addScaledVector(a[1],.488603*i),e.addScaledVector(a[2],.488603*r),e.addScaledVector(a[3],.488603*n),e.addScaledVector(a[4],n*i*1.092548),e.addScaledVector(a[5],i*r*1.092548),e.addScaledVector(a[6],.315392*(3*r*r-1)),e.addScaledVector(a[7],n*r*1.092548),e.addScaledVector(a[8],.546274*(n*n-i*i)),e}getIrradianceAt(t,e){const n=t.x,i=t.y,r=t.z,a=this.coefficients;return e.copy(a[0]).multiplyScalar(.886227),e.addScaledVector(a[1],1.023328*i),e.addScaledVector(a[2],1.023328*r),e.addScaledVector(a[3],1.023328*n),e.addScaledVector(a[4],.858086*n*i),e.addScaledVector(a[5],.858086*i*r),e.addScaledVector(a[6],.743125*r*r-.247708),e.addScaledVector(a[7],.858086*n*r),e.addScaledVector(a[8],.429043*(n*n-i*i)),e}add(t){for(let e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this}addScaledSH(t,e){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(t.coefficients[n],e);return this}scale(t){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this}lerp(t,e){for(let n=0;n<9;n++)this.coefficients[n].lerp(t.coefficients[n],e);return this}equals(t){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0}copy(t){return this.set(t.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(t,e=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(t,e+3*i);return this}toArray(t=[],e=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(t,e+3*i);return t}static getBasisAt(t,e){const n=t.x,i=t.y,r=t.z;e[0]=.282095,e[1]=.488603*i,e[2]=.488603*r,e[3]=.488603*n,e[4]=1.092548*n*i,e[5]=1.092548*i*r,e[6]=.315392*(3*r*r-1),e[7]=1.092548*n*r,e[8]=.546274*(n*n-i*i)}}class Nh extends hh{constructor(t=new Dh,e=1){super(void 0,e),this.isLightProbe=!0,this.sh=t}copy(t){return super.copy(t),this.sh.copy(t.sh),this}toJSON(t){const e=super.toJSON(t);return e.object.sh=this.sh.toArray(),e}}class Oh extends rh{constructor(t){super(t),this.textures={}}load(t,e,n,i){const r=this,a=new oh(r.manager);a.setPath(r.path),a.setRequestHeader(r.requestHeader),a.setWithCredentials(r.withCredentials),a.load(t,(function(n){try{e(r.parse(JSON.parse(n)))}catch(e){i?i(e):hi(e),r.manager.itemError(t)}}),n,i)}parse(t){const e=this.textures;function n(t){return void 0===e[t]&&ci("MaterialLoader: Undefined texture",t),e[t]}const i=this.createMaterialFromType(t.type);if(void 0!==t.uuid&&(i.uuid=t.uuid),void 0!==t.name&&(i.name=t.name),void 0!==t.color&&void 0!==i.color&&i.color.setHex(t.color),void 0!==t.roughness&&(i.roughness=t.roughness),void 0!==t.metalness&&(i.metalness=t.metalness),void 0!==t.sheen&&(i.sheen=t.sheen),void 0!==t.sheenColor&&(i.sheenColor=(new Lr).setHex(t.sheenColor)),void 0!==t.sheenRoughness&&(i.sheenRoughness=t.sheenRoughness),void 0!==t.emissive&&void 0!==i.emissive&&i.emissive.setHex(t.emissive),void 0!==t.specular&&void 0!==i.specular&&i.specular.setHex(t.specular),void 0!==t.specularIntensity&&(i.specularIntensity=t.specularIntensity),void 0!==t.specularColor&&void 0!==i.specularColor&&i.specularColor.setHex(t.specularColor),void 0!==t.shininess&&(i.shininess=t.shininess),void 0!==t.clearcoat&&(i.clearcoat=t.clearcoat),void 0!==t.clearcoatRoughness&&(i.clearcoatRoughness=t.clearcoatRoughness),void 0!==t.dispersion&&(i.dispersion=t.dispersion),void 0!==t.iridescence&&(i.iridescence=t.iridescence),void 0!==t.iridescenceIOR&&(i.iridescenceIOR=t.iridescenceIOR),void 0!==t.iridescenceThicknessRange&&(i.iridescenceThicknessRange=t.iridescenceThicknessRange),void 0!==t.transmission&&(i.transmission=t.transmission),void 0!==t.thickness&&(i.thickness=t.thickness),void 0!==t.attenuationDistance&&(i.attenuationDistance=t.attenuationDistance),void 0!==t.attenuationColor&&void 0!==i.attenuationColor&&i.attenuationColor.setHex(t.attenuationColor),void 0!==t.anisotropy&&(i.anisotropy=t.anisotropy),void 0!==t.anisotropyRotation&&(i.anisotropyRotation=t.anisotropyRotation),void 0!==t.fog&&(i.fog=t.fog),void 0!==t.flatShading&&(i.flatShading=t.flatShading),void 0!==t.blending&&(i.blending=t.blending),void 0!==t.combine&&(i.combine=t.combine),void 0!==t.side&&(i.side=t.side),void 0!==t.shadowSide&&(i.shadowSide=t.shadowSide),void 0!==t.opacity&&(i.opacity=t.opacity),void 0!==t.transparent&&(i.transparent=t.transparent),void 0!==t.alphaTest&&(i.alphaTest=t.alphaTest),void 0!==t.alphaHash&&(i.alphaHash=t.alphaHash),void 0!==t.depthFunc&&(i.depthFunc=t.depthFunc),void 0!==t.depthTest&&(i.depthTest=t.depthTest),void 0!==t.depthWrite&&(i.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(i.colorWrite=t.colorWrite),void 0!==t.blendSrc&&(i.blendSrc=t.blendSrc),void 0!==t.blendDst&&(i.blendDst=t.blendDst),void 0!==t.blendEquation&&(i.blendEquation=t.blendEquation),void 0!==t.blendSrcAlpha&&(i.blendSrcAlpha=t.blendSrcAlpha),void 0!==t.blendDstAlpha&&(i.blendDstAlpha=t.blendDstAlpha),void 0!==t.blendEquationAlpha&&(i.blendEquationAlpha=t.blendEquationAlpha),void 0!==t.blendColor&&void 0!==i.blendColor&&i.blendColor.setHex(t.blendColor),void 0!==t.blendAlpha&&(i.blendAlpha=t.blendAlpha),void 0!==t.stencilWriteMask&&(i.stencilWriteMask=t.stencilWriteMask),void 0!==t.stencilFunc&&(i.stencilFunc=t.stencilFunc),void 0!==t.stencilRef&&(i.stencilRef=t.stencilRef),void 0!==t.stencilFuncMask&&(i.stencilFuncMask=t.stencilFuncMask),void 0!==t.stencilFail&&(i.stencilFail=t.stencilFail),void 0!==t.stencilZFail&&(i.stencilZFail=t.stencilZFail),void 0!==t.stencilZPass&&(i.stencilZPass=t.stencilZPass),void 0!==t.stencilWrite&&(i.stencilWrite=t.stencilWrite),void 0!==t.wireframe&&(i.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(i.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(i.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(i.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.rotation&&(i.rotation=t.rotation),void 0!==t.linewidth&&(i.linewidth=t.linewidth),void 0!==t.dashSize&&(i.dashSize=t.dashSize),void 0!==t.gapSize&&(i.gapSize=t.gapSize),void 0!==t.scale&&(i.scale=t.scale),void 0!==t.polygonOffset&&(i.polygonOffset=t.polygonOffset),void 0!==t.polygonOffsetFactor&&(i.polygonOffsetFactor=t.polygonOffsetFactor),void 0!==t.polygonOffsetUnits&&(i.polygonOffsetUnits=t.polygonOffsetUnits),void 0!==t.dithering&&(i.dithering=t.dithering),void 0!==t.alphaToCoverage&&(i.alphaToCoverage=t.alphaToCoverage),void 0!==t.premultipliedAlpha&&(i.premultipliedAlpha=t.premultipliedAlpha),void 0!==t.forceSinglePass&&(i.forceSinglePass=t.forceSinglePass),void 0!==t.allowOverride&&(i.allowOverride=t.allowOverride),void 0!==t.visible&&(i.visible=t.visible),void 0!==t.toneMapped&&(i.toneMapped=t.toneMapped),void 0!==t.userData&&(i.userData=t.userData),void 0!==t.vertexColors&&("number"==typeof t.vertexColors?i.vertexColors=t.vertexColors>0:i.vertexColors=t.vertexColors),void 0!==t.uniforms)for(const e in t.uniforms){const r=t.uniforms[e];switch(i.uniforms[e]={},r.type){case"t":i.uniforms[e].value=n(r.value);break;case"c":i.uniforms[e].value=(new Lr).setHex(r.value);break;case"v2":i.uniforms[e].value=(new Ei).fromArray(r.value);break;case"v3":i.uniforms[e].value=(new Ai).fromArray(r.value);break;case"v4":i.uniforms[e].value=(new Xi).fromArray(r.value);break;case"m3":i.uniforms[e].value=(new Ii).fromArray(r.value);break;case"m4":i.uniforms[e].value=(new Ji).fromArray(r.value);break;default:i.uniforms[e].value=r.value}}if(void 0!==t.defines&&(i.defines=t.defines),void 0!==t.vertexShader&&(i.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(i.fragmentShader=t.fragmentShader),void 0!==t.glslVersion&&(i.glslVersion=t.glslVersion),void 0!==t.extensions)for(const e in t.extensions)i.extensions[e]=t.extensions[e];if(void 0!==t.lights&&(i.lights=t.lights),void 0!==t.clipping&&(i.clipping=t.clipping),void 0!==t.size&&(i.size=t.size),void 0!==t.sizeAttenuation&&(i.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(i.map=n(t.map)),void 0!==t.matcap&&(i.matcap=n(t.matcap)),void 0!==t.alphaMap&&(i.alphaMap=n(t.alphaMap)),void 0!==t.bumpMap&&(i.bumpMap=n(t.bumpMap)),void 0!==t.bumpScale&&(i.bumpScale=t.bumpScale),void 0!==t.normalMap&&(i.normalMap=n(t.normalMap)),void 0!==t.normalMapType&&(i.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),i.normalScale=(new Ei).fromArray(e)}return void 0!==t.displacementMap&&(i.displacementMap=n(t.displacementMap)),void 0!==t.displacementScale&&(i.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(i.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(i.roughnessMap=n(t.roughnessMap)),void 0!==t.metalnessMap&&(i.metalnessMap=n(t.metalnessMap)),void 0!==t.emissiveMap&&(i.emissiveMap=n(t.emissiveMap)),void 0!==t.emissiveIntensity&&(i.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(i.specularMap=n(t.specularMap)),void 0!==t.specularIntensityMap&&(i.specularIntensityMap=n(t.specularIntensityMap)),void 0!==t.specularColorMap&&(i.specularColorMap=n(t.specularColorMap)),void 0!==t.envMap&&(i.envMap=n(t.envMap)),void 0!==t.envMapRotation&&i.envMapRotation.fromArray(t.envMapRotation),void 0!==t.envMapIntensity&&(i.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(i.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(i.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(i.lightMap=n(t.lightMap)),void 0!==t.lightMapIntensity&&(i.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(i.aoMap=n(t.aoMap)),void 0!==t.aoMapIntensity&&(i.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(i.gradientMap=n(t.gradientMap)),void 0!==t.clearcoatMap&&(i.clearcoatMap=n(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=n(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(i.clearcoatNormalMap=n(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(i.clearcoatNormalScale=(new Ei).fromArray(t.clearcoatNormalScale)),void 0!==t.iridescenceMap&&(i.iridescenceMap=n(t.iridescenceMap)),void 0!==t.iridescenceThicknessMap&&(i.iridescenceThicknessMap=n(t.iridescenceThicknessMap)),void 0!==t.transmissionMap&&(i.transmissionMap=n(t.transmissionMap)),void 0!==t.thicknessMap&&(i.thicknessMap=n(t.thicknessMap)),void 0!==t.anisotropyMap&&(i.anisotropyMap=n(t.anisotropyMap)),void 0!==t.sheenColorMap&&(i.sheenColorMap=n(t.sheenColorMap)),void 0!==t.sheenRoughnessMap&&(i.sheenRoughnessMap=n(t.sheenRoughnessMap)),i}setTextures(t){return this.textures=t,this}createMaterialFromType(t){return Oh.createMaterialFromType(t)}static createMaterialFromType(t){return new{ShadowMaterial:vc,SpriteMaterial:Fa,RawShaderMaterial:wc,ShaderMaterial:Mc,PointsMaterial:zo,MeshPhysicalMaterial:Tc,MeshStandardMaterial:Ec,MeshPhongMaterial:Ac,MeshToonMaterial:Cc,MeshNormalMaterial:Rc,MeshLambertMaterial:Ic,MeshDepthMaterial:Pc,MeshDistanceMaterial:Lc,MeshBasicMaterial:cs,MeshMatcapMaterial:Dc,LineDashedMaterial:Nc,LineBasicMaterial:wo,Material:Ua}[t]}}class Uh{static extractUrlBase(t){const e=t.lastIndexOf("/");return-1===e?"./":t.slice(0,e+1)}static resolveURL(t,e){return"string"!=typeof t||""===t?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}}class Fh extends Ia{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){const t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}}class zh extends rh{constructor(t){super(t)}load(t,e,n,i){const r=this,a=new oh(r.manager);a.setPath(r.path),a.setRequestHeader(r.requestHeader),a.setWithCredentials(r.withCredentials),a.load(t,(function(n){try{e(r.parse(JSON.parse(n)))}catch(e){i?i(e):hi(e),r.manager.itemError(t)}}),n,i)}parse(t){const e={},n={};function i(t,i){if(void 0!==e[i])return e[i];const r=t.interleavedBuffers[i],a=function(t,e){if(void 0!==n[e])return n[e];const i=t.arrayBuffers,r=i[e],a=new Uint32Array(r).buffer;return n[e]=a,a}(t,r.buffer),s=ii(r.type,a),o=new Pa(s,r.stride);return o.uuid=r.uuid,e[i]=o,o}const r=t.isInstancedBufferGeometry?new Fh:new Ia,a=t.data.index;if(void 0!==a){const t=ii(a.type,a.array);r.setIndex(new fa(t,1))}const s=t.data.attributes;for(const e in s){const n=s[e];let a;if(n.isInterleavedBufferAttribute){const e=i(t.data,n.data);a=new Da(e,n.itemSize,n.offset,n.normalized)}else{const t=ii(n.type,n.array);a=new(n.isInstancedBufferAttribute?zs:fa)(t,n.itemSize,n.normalized)}void 0!==n.name&&(a.name=n.name),void 0!==n.usage&&a.setUsage(n.usage),r.setAttribute(e,a)}const o=t.data.morphAttributes;if(o)for(const e in o){const n=o[e],a=[];for(let e=0,r=n.length;e<r;e++){const r=n[e];let s;if(r.isInterleavedBufferAttribute){const e=i(t.data,r.data);s=new Da(e,r.itemSize,r.offset,r.normalized)}else{const t=ii(r.type,r.array);s=new fa(t,r.itemSize,r.normalized)}void 0!==r.name&&(s.name=r.name),a.push(s)}r.morphAttributes[e]=a}t.data.morphTargetsRelative&&(r.morphTargetsRelative=!0);const l=t.data.groups||t.data.drawcalls||t.data.offsets;if(void 0!==l)for(let t=0,e=l.length;t!==e;++t){const e=l[t];r.addGroup(e.start,e.count,e.materialIndex)}const c=t.data.boundingSphere;return void 0!==c&&(r.boundingSphere=(new Sa).fromJSON(c)),t.name&&(r.name=t.name),t.userData&&(r.userData=t.userData),r}}const kh={};class Bh extends rh{constructor(t){super(t)}load(t,e,n,i){const r=this,a=""===this.path?Uh.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||a;const s=new oh(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,(function(n){let a=null;try{a=JSON.parse(n)}catch(e){return void 0!==i&&i(e),void hi("ObjectLoader: Can't parse "+t+".",e.message)}const s=a.metadata;if(void 0===s||void 0===s.type||"geometry"===s.type.toLowerCase())return void 0!==i&&i(new Error("THREE.ObjectLoader: Can't load "+t)),void hi("ObjectLoader: Can't load "+t);r.parse(a,e)}),n,i)}async loadAsync(t,e){const n=""===this.path?Uh.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||n;const i=new oh(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials);const r=await i.loadAsync(t,e);let a;try{a=JSON.parse(r)}catch(e){throw new Error("ObjectLoader: Can't parse "+t+". "+e.message)}const s=a.metadata;if(void 0===s||void 0===s.type||"geometry"===s.type.toLowerCase())throw new Error("THREE.ObjectLoader: Can't load "+t);return await this.parseAsync(a)}parse(t,e){const n=this.parseAnimations(t.animations),i=this.parseShapes(t.shapes),r=this.parseGeometries(t.geometries,i),a=this.parseImages(t.images,(function(){void 0!==e&&e(l)})),s=this.parseTextures(t.textures,a),o=this.parseMaterials(t.materials,s),l=this.parseObject(t.object,r,o,s,n),c=this.parseSkeletons(t.skeletons,l);if(this.bindSkeletons(l,c),this.bindLightTargets(l),void 0!==e){let t=!1;for(const e in a)if(a[e].data instanceof HTMLImageElement){t=!0;break}!1===t&&e(l)}return l}async parseAsync(t){const e=this.parseAnimations(t.animations),n=this.parseShapes(t.shapes),i=this.parseGeometries(t.geometries,n),r=await this.parseImagesAsync(t.images),a=this.parseTextures(t.textures,r),s=this.parseMaterials(t.materials,a),o=this.parseObject(t.object,i,s,a,e),l=this.parseSkeletons(t.skeletons,o);return this.bindSkeletons(o,l),this.bindLightTargets(o),o}static registerGeometry(t,e){kh[t]=e}parseShapes(t){const e={};if(void 0!==t)for(let n=0,i=t.length;n<i;n++){const i=(new El).fromJSON(t[n]);e[i.uuid]=i}return e}parseSkeletons(t,e){const n={},i={};if(e.traverse((function(t){t.isBone&&(i[t.uuid]=t)})),void 0!==t)for(let e=0,r=t.length;e<r;e++){const r=(new Fs).fromJSON(t[e],i);n[r.uuid]=r}return n}parseGeometries(t,e){const n={};if(void 0!==t){const i=new zh;for(let r=0,a=t.length;r<a;r++){let a;const s=t[r];switch(s.type){case"BufferGeometry":case"InstancedBufferGeometry":a=i.parse(s);break;default:s.type in gc?a=gc[s.type].fromJSON(s,e):s.type in kh?a=kh[s.type].fromJSON(s,e):ci(`ObjectLoader: Unknown geometry type "${s.type}". Use .registerGeometry() before starting the deserialization process.`)}a.uuid=s.uuid,void 0!==s.name&&(a.name=s.name),void 0!==s.userData&&(a.userData=s.userData),n[s.uuid]=a}}return n}parseMaterials(t,e){const n={},i={};if(void 0!==t){const r=new Oh;r.setTextures(e);for(let e=0,a=t.length;e<a;e++){const a=t[e];void 0===n[a.uuid]&&(n[a.uuid]=r.parse(a)),i[a.uuid]=n[a.uuid]}}return i}parseAnimations(t){const e={};if(void 0!==t)for(let n=0;n<t.length;n++){const i=t[n],r=Kc.parse(i);e[r.uuid]=r}return e}parseImages(t,e){const n=this,i={};let r;function a(t){if("string"==typeof t){const e=t;return function(t){return n.manager.itemStart(t),r.load(t,(function(){n.manager.itemEnd(t)}),void 0,(function(){n.manager.itemError(t),n.manager.itemEnd(t)}))}(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(e)?e:n.resourcePath+e)}return t.data?{data:ii(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){const n=new nh(e);r=new ch(n),r.setCrossOrigin(this.crossOrigin);for(let e=0,n=t.length;e<n;e++){const n=t[e],r=n.url;if(Array.isArray(r)){const t=[];for(let e=0,n=r.length;e<n;e++){const n=a(r[e]);null!==n&&(n instanceof HTMLImageElement?t.push(n):t.push(new Ns(n.data,n.width,n.height)))}i[n.uuid]=new Gi(t)}else{const t=a(n.url);i[n.uuid]=new Gi(t)}}}return i}async parseImagesAsync(t){const e=this,n={};let i;async function r(t){if("string"==typeof t){const n=t,r=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(n)?n:e.resourcePath+n;return await i.loadAsync(r)}return t.data?{data:ii(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){i=new ch(this.manager),i.setCrossOrigin(this.crossOrigin);for(let e=0,i=t.length;e<i;e++){const i=t[e],a=i.url;if(Array.isArray(a)){const t=[];for(let e=0,n=a.length;e<n;e++){const n=a[e],i=await r(n);null!==i&&(i instanceof HTMLImageElement?t.push(i):t.push(new Ns(i.data,i.width,i.height)))}n[i.uuid]=new Gi(t)}else{const t=await r(i.url);n[i.uuid]=new Gi(t)}}}return n}parseTextures(t,e){function n(t,e){return"number"==typeof t?t:(ci("ObjectLoader.parseTexture: Constant should be in numeric form.",t),e[t])}const i={};if(void 0!==t)for(let r=0,a=t.length;r<a;r++){const a=t[r];void 0===a.image&&ci('ObjectLoader: No "image" specified for',a.uuid),void 0===e[a.image]&&ci("ObjectLoader: Undefined image",a.image);const s=e[a.image],o=s.data;let l;Array.isArray(o)?(l=new jo,6===o.length&&(l.needsUpdate=!0)):(l=o&&o.data?new Ns:new ji,o&&(l.needsUpdate=!0)),l.source=s,l.uuid=a.uuid,void 0!==a.name&&(l.name=a.name),void 0!==a.mapping&&(l.mapping=n(a.mapping,Gh)),void 0!==a.channel&&(l.channel=a.channel),void 0!==a.offset&&l.offset.fromArray(a.offset),void 0!==a.repeat&&l.repeat.fromArray(a.repeat),void 0!==a.center&&l.center.fromArray(a.center),void 0!==a.rotation&&(l.rotation=a.rotation),void 0!==a.wrap&&(l.wrapS=n(a.wrap[0],Vh),l.wrapT=n(a.wrap[1],Vh)),void 0!==a.format&&(l.format=a.format),void 0!==a.internalFormat&&(l.internalFormat=a.internalFormat),void 0!==a.type&&(l.type=a.type),void 0!==a.colorSpace&&(l.colorSpace=a.colorSpace),void 0!==a.minFilter&&(l.minFilter=n(a.minFilter,Hh)),void 0!==a.magFilter&&(l.magFilter=n(a.magFilter,Hh)),void 0!==a.anisotropy&&(l.anisotropy=a.anisotropy),void 0!==a.flipY&&(l.flipY=a.flipY),void 0!==a.generateMipmaps&&(l.generateMipmaps=a.generateMipmaps),void 0!==a.premultiplyAlpha&&(l.premultiplyAlpha=a.premultiplyAlpha),void 0!==a.unpackAlignment&&(l.unpackAlignment=a.unpackAlignment),void 0!==a.compareFunction&&(l.compareFunction=a.compareFunction),void 0!==a.normalized&&(l.normalized=a.normalized),void 0!==a.userData&&(l.userData=a.userData),i[a.uuid]=l}return i}parseObject(t,e,n,i,r){let a,s,o;function l(t){return void 0===e[t]&&ci("ObjectLoader: Undefined geometry",t),e[t]}function c(t){if(void 0!==t){if(Array.isArray(t)){const e=[];for(let i=0,r=t.length;i<r;i++){const r=t[i];void 0===n[r]&&ci("ObjectLoader: Undefined material",r),e.push(n[r])}return e}return void 0===n[t]&&ci("ObjectLoader: Undefined material",t),n[t]}}function h(t){return void 0===i[t]&&ci("ObjectLoader: Undefined texture",t),i[t]}switch(t.type){case"Scene":a=new Ur,void 0!==t.background&&(Number.isInteger(t.background)?a.background=new Lr(t.background):a.background=h(t.background)),void 0!==t.environment&&(a.environment=h(t.environment)),void 0!==t.fog&&("Fog"===t.fog.type?a.fog=new Or(t.fog.color,t.fog.near,t.fog.far):"FogExp2"===t.fog.type&&(a.fog=new Nr(t.fog.color,t.fog.density)),""!==t.fog.name&&(a.fog.name=t.fog.name)),void 0!==t.backgroundBlurriness&&(a.backgroundBlurriness=t.backgroundBlurriness),void 0!==t.backgroundIntensity&&(a.backgroundIntensity=t.backgroundIntensity),void 0!==t.backgroundRotation&&a.backgroundRotation.fromArray(t.backgroundRotation),void 0!==t.environmentIntensity&&(a.environmentIntensity=t.environmentIntensity),void 0!==t.environmentRotation&&a.environmentRotation.fromArray(t.environmentRotation);break;case"PerspectiveCamera":a=new Mh(t.fov,t.aspect,t.near,t.far),void 0!==t.focus&&(a.focus=t.focus),void 0!==t.zoom&&(a.zoom=t.zoom),void 0!==t.filmGauge&&(a.filmGauge=t.filmGauge),void 0!==t.filmOffset&&(a.filmOffset=t.filmOffset),void 0!==t.view&&(a.view=Object.assign({},t.view));break;case"OrthographicCamera":a=new Ch(t.left,t.right,t.top,t.bottom,t.near,t.far),void 0!==t.zoom&&(a.zoom=t.zoom),void 0!==t.view&&(a.view=Object.assign({},t.view));break;case"AmbientLight":a=new Ph(t.color,t.intensity);break;case"DirectionalLight":a=new Ih(t.color,t.intensity),a.target=t.target||"";break;case"PointLight":a=new Ah(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":a=new Lh(t.color,t.intensity,t.width,t.height);break;case"SpotLight":a=new Eh(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay),a.target=t.target||"";break;case"HemisphereLight":a=new dh(t.color,t.groundColor,t.intensity);break;case"LightProbe":const e=(new Dh).fromArray(t.sh);a=new Nh(e,t.intensity);break;case"SkinnedMesh":s=l(t.geometry),o=c(t.material),a=new Ls(s,o),void 0!==t.bindMode&&(a.bindMode=t.bindMode),void 0!==t.bindMatrix&&a.bindMatrix.fromArray(t.bindMatrix),void 0!==t.skeleton&&(a.skeleton=t.skeleton);break;case"Mesh":s=l(t.geometry),o=c(t.material),a=new bs(s,o);break;case"InstancedMesh":s=l(t.geometry),o=c(t.material);const n=t.count,i=t.instanceMatrix,r=t.instanceColor;a=new Xs(s,o,n),a.instanceMatrix=new zs(new Float32Array(i.array),16),void 0!==r&&(a.instanceColor=new zs(new Float32Array(r.array),r.itemSize));break;case"BatchedMesh":s=l(t.geometry),o=c(t.material),a=new Mo(t.maxInstanceCount,t.maxVertexCount,t.maxIndexCount,o),a.geometry=s,a.perObjectFrustumCulled=t.perObjectFrustumCulled,a.sortObjects=t.sortObjects,a._drawRanges=t.drawRanges,a._reservedRanges=t.reservedRanges,a._geometryInfo=t.geometryInfo.map((t=>{let e=null,n=null;return void 0!==t.boundingBox&&(e=(new Jr).fromJSON(t.boundingBox)),void 0!==t.boundingSphere&&(n=(new Sa).fromJSON(t.boundingSphere)),{...t,boundingBox:e,boundingSphere:n}})),a._instanceInfo=t.instanceInfo,a._availableInstanceIds=t._availableInstanceIds,a._availableGeometryIds=t._availableGeometryIds,a._nextIndexStart=t.nextIndexStart,a._nextVertexStart=t.nextVertexStart,a._geometryCount=t.geometryCount,a._maxInstanceCount=t.maxInstanceCount,a._maxVertexCount=t.maxVertexCount,a._maxIndexCount=t.maxIndexCount,a._geometryInitialized=t.geometryInitialized,a._matricesTexture=h(t.matricesTexture.uuid),a._indirectTexture=h(t.indirectTexture.uuid),void 0!==t.colorsTexture&&(a._colorsTexture=h(t.colorsTexture.uuid)),void 0!==t.boundingSphere&&(a.boundingSphere=(new Sa).fromJSON(t.boundingSphere)),void 0!==t.boundingBox&&(a.boundingBox=(new Jr).fromJSON(t.boundingBox));break;case"LOD":a=new ts;break;case"Line":a=new Lo(l(t.geometry),c(t.material));break;case"LineLoop":a=new Fo(l(t.geometry),c(t.material));break;case"LineSegments":a=new Uo(l(t.geometry),c(t.material));break;case"PointCloud":case"Points":a=new Ho(l(t.geometry),c(t.material));break;case"Sprite":a=new $a(c(t.material));break;case"Group":a=new Er;break;case"Bone":a=new Ds;break;default:a=new wr}if(a.uuid=t.uuid,void 0!==t.name&&(a.name=t.name),void 0!==t.matrix?(a.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(a.matrixAutoUpdate=t.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(void 0!==t.position&&a.position.fromArray(t.position),void 0!==t.rotation&&a.rotation.fromArray(t.rotation),void 0!==t.quaternion&&a.quaternion.fromArray(t.quaternion),void 0!==t.scale&&a.scale.fromArray(t.scale)),void 0!==t.up&&a.up.fromArray(t.up),void 0!==t.pivot&&(a.pivot=(new Ai).fromArray(t.pivot)),void 0!==t.morphTargetDictionary&&(a.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),void 0!==t.morphTargetInfluences&&(a.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.castShadow&&(a.castShadow=t.castShadow),void 0!==t.receiveShadow&&(a.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.intensity&&(a.shadow.intensity=t.shadow.intensity),void 0!==t.shadow.bias&&(a.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(a.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(a.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&a.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(a.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(a.visible=t.visible),void 0!==t.frustumCulled&&(a.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(a.renderOrder=t.renderOrder),void 0!==t.static&&(a.static=t.static),void 0!==t.userData&&(a.userData=t.userData),void 0!==t.layers&&(a.layers.mask=t.layers),void 0!==t.children){const s=t.children;for(let t=0;t<s.length;t++)a.add(this.parseObject(s[t],e,n,i,r))}if(void 0!==t.animations){const e=t.animations;for(let t=0;t<e.length;t++){const n=e[t];a.animations.push(r[n])}}if("LOD"===t.type){void 0!==t.autoUpdate&&(a.autoUpdate=t.autoUpdate);const e=t.levels;for(let t=0;t<e.length;t++){const n=e[t],i=a.getObjectByProperty("uuid",n.object);void 0!==i&&a.addLevel(i,n.distance,n.hysteresis)}}return a}bindSkeletons(t,e){0!==Object.keys(e).length&&t.traverse((function(t){if(!0===t.isSkinnedMesh&&void 0!==t.skeleton){const n=e[t.skeleton];void 0===n?ci("ObjectLoader: No skeleton found with UUID:",t.skeleton):t.bind(n,t.bindMatrix)}}))}bindLightTargets(t){t.traverse((function(e){if(e.isDirectionalLight||e.isSpotLight){const n=e.target,i=t.getObjectByProperty("uuid",n);e.target=void 0!==i?i:new wr}}))}}const Gh={UVMapping:300,CubeReflectionMapping:pe,CubeRefractionMapping:me,EquirectangularReflectionMapping:fe,EquirectangularRefractionMapping:ge,CubeUVReflectionMapping:ve},Vh={RepeatWrapping:_e,ClampToEdgeWrapping:ye,MirroredRepeatWrapping:xe},Hh={NearestFilter:be,NearestMipmapNearestFilter:1004,NearestMipmapLinearFilter:Me,LinearFilter:we,LinearMipmapNearestFilter:Ee,LinearMipmapLinearFilter:Te},Wh=-90;class jh extends wr{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Mh(Wh,1,t,e);i.layers=this.layers,this.add(i);const r=new Mh(Wh,1,t,e);r.layers=this.layers,this.add(r);const a=new Mh(Wh,1,t,e);a.layers=this.layers,this.add(a);const s=new Mh(Wh,1,t,e);s.layers=this.layers,this.add(s);const o=new Mh(Wh,1,t,e);o.layers=this.layers,this.add(o);const l=new Mh(Wh,1,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,i,r,a,s,o]=e;for(const t of e)this.remove(t);if(t===ti)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),s.up.set(0,1,0),s.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(t!==ei)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),s.up.set(0,-1,0),s.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const t of e)this.add(t),t.updateMatrixWorld()}update(t,e){null===this.parent&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[r,a,s,o,l,c]=this.children,h=t.getRenderTarget(),d=t.getActiveCubeFace(),u=t.getActiveMipmapLevel(),p=t.xr.enabled;t.xr.enabled=!1;const m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let f=!1;f=!0===t.isWebGLRenderer?t.state.buffers.depth.getReversed():t.reversedDepthBuffer,t.setRenderTarget(n,0,i),f&&!1===t.autoClear&&t.clearDepth(),t.render(e,r),t.setRenderTarget(n,1,i),f&&!1===t.autoClear&&t.clearDepth(),t.render(e,a),t.setRenderTarget(n,2,i),f&&!1===t.autoClear&&t.clearDepth(),t.render(e,s),t.setRenderTarget(n,3,i),f&&!1===t.autoClear&&t.clearDepth(),t.render(e,o),t.setRenderTarget(n,4,i),f&&!1===t.autoClear&&t.clearDepth(),t.render(e,l),n.texture.generateMipmaps=m,t.setRenderTarget(n,5,i),f&&!1===t.autoClear&&t.clearDepth(),t.render(e,c),t.setRenderTarget(h,d,u),t.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class Xh extends Mh{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}}class qh{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(t){this._document=t,void 0!==t.hidden&&(this._pageVisibilityHandler=Yh.bind(this),t.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){null!==this._pageVisibilityHandler&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(t){return this._timescale=t,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(t){return null!==this._pageVisibilityHandler&&!0===this._document.hidden?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(void 0!==t?t:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}}function Yh(){!1===this._document.hidden&&this.reset()}class Zh{constructor(t,e,n){let i,r,a;switch(this.binding=t,this.valueSize=n,e){case"quaternion":i=this._slerp,r=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*n),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(5*n);break;default:i=this._lerp,r=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*n)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){const n=this.buffer,i=this.valueSize,r=t*i+i;let a=this.cumulativeWeight;if(0===a){for(let t=0;t!==i;++t)n[r+t]=n[t];a=e}else{a+=e;const t=e/a;this._mixBufferRegion(n,r,0,t,i)}this.cumulativeWeight=a}accumulateAdditive(t){const e=this.buffer,n=this.valueSize,i=n*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(e,i,0,t,n),this.cumulativeWeightAdditive+=t}apply(t){const e=this.valueSize,n=this.buffer,i=t*e+e,r=this.cumulativeWeight,a=this.cumulativeWeightAdditive,s=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const t=e*this._origIndex;this._mixBufferRegion(n,i,t,1-r,e)}a>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*e,1,e);for(let t=e,r=e+e;t!==r;++t)if(n[t]!==n[t+e]){s.setValue(n,i);break}}saveOriginalState(){const t=this.binding,e=this.buffer,n=this.valueSize,i=n*this._origIndex;t.getValue(e,i);for(let t=n,r=i;t!==r;++t)e[t]=e[i+t%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=3*this.valueSize;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n<e;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[e+n]=this.buffer[t+n]}_select(t,e,n,i,r){if(i>=.5)for(let i=0;i!==r;++i)t[e+i]=t[n+i]}_slerp(t,e,n,i){Ti.slerpFlat(t,e,t,e,t,n,i)}_slerpAdditive(t,e,n,i,r){const a=this._workIndex*r;Ti.multiplyQuaternionsFlat(t,a,t,e,t,n),Ti.slerpFlat(t,e,t,e,t,a,i)}_lerp(t,e,n,i,r){const a=1-i;for(let s=0;s!==r;++s){const r=e+s;t[r]=t[r]*a+t[n+s]*i}}_lerpAdditive(t,e,n,i,r){for(let a=0;a!==r;++a){const r=e+a;t[r]=t[r]+t[n+a]*i}}}const $h="\\[\\]\\.:\\/",Jh=new RegExp("["+$h+"]","g"),Kh="[^"+$h+"]",Qh="[^"+$h.replace("\\.","")+"]",td=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",Kh)+/(WCOD+)?/.source.replace("WCOD",Qh)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Kh)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Kh)+"$"),ed=["material","materials","bones","map"];class nd{constructor(t,e,n){this.path=e,this.parsedPath=n||nd.parseTrackName(e),this.node=nd.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new nd.Composite(t,e,n):new nd(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(Jh,"")}static parseTrackName(t){const e=td.exec(t);if(null===e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const t=n.nodeName.substring(i+1);-1!==ed.indexOf(t)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=t)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(void 0===e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const n=t.skeleton.getBoneByName(e);if(void 0!==n)return n}if(t.children){const n=function(t){for(let i=0;i<t.length;i++){const r=t[i];if(r.name===e||r.uuid===e)return r;const a=n(r.children);if(a)return a}return null},i=n(t.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)t[e++]=n[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node;const e=this.parsedPath,n=e.objectName,i=e.propertyName;let r=e.propertyIndex;if(t||(t=nd.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t)return void ci("PropertyBinding: No target node found for track: "+this.path+".");if(n){let i=e.objectIndex;switch(n){case"materials":if(!t.material)return void hi("PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.materials)return void hi("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);t=t.material.materials;break;case"bones":if(!t.skeleton)return void hi("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);t=t.skeleton.bones;for(let e=0;e<t.length;e++)if(t[e].name===i){i=e;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material)return void hi("PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.map)return void hi("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);t=t.material.map;break;default:if(void 0===t[n])return void hi("PropertyBinding: Can not bind to objectName of node undefined.",this);t=t[n]}if(void 0!==i){if(void 0===t[i])return void hi("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);t=t[i]}}const a=t[i];if(void 0===a)return void hi("PropertyBinding: Trying to update property for track: "+e.nodeName+"."+i+" but it wasn't found.",t);let s=this.Versioning.None;this.targetObject=t,!0===t.isMaterial?s=this.Versioning.NeedsUpdate:!0===t.isObject3D&&(s=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(void 0!==r){if("morphTargetInfluences"===i){if(!t.geometry)return void hi("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!t.geometry.morphAttributes)return void hi("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==t.morphTargetDictionary[r]&&(r=t.morphTargetDictionary[r])}o=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}else void 0!==a.fromArray&&void 0!==a.toArray?(o=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(o=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=i;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][s]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}nd.Composite=class{constructor(t,e,n){const i=n||nd.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];void 0!==i&&i.getValue(t,e)}setValue(t,e){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},nd.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},nd.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},nd.prototype.GetterByBindingType=[nd.prototype._getValue_direct,nd.prototype._getValue_array,nd.prototype._getValue_arrayElement,nd.prototype._getValue_toArray],nd.prototype.SetterByBindingTypeAndVersioning=[[nd.prototype._setValue_direct,nd.prototype._setValue_direct_setNeedsUpdate,nd.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[nd.prototype._setValue_array,nd.prototype._setValue_array_setNeedsUpdate,nd.prototype._setValue_array_setMatrixWorldNeedsUpdate],[nd.prototype._setValue_arrayElement,nd.prototype._setValue_arrayElement_setNeedsUpdate,nd.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[nd.prototype._setValue_fromArray,nd.prototype._setValue_fromArray_setNeedsUpdate,nd.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class id{constructor(){this.isAnimationObjectGroup=!0,this.uuid=_i(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const t={};this._indicesByUUID=t;for(let e=0,n=arguments.length;e!==n;++e)t[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}add(){const t=this._objects,e=this._indicesByUUID,n=this._paths,i=this._parsedPaths,r=this._bindings,a=r.length;let s,o=t.length,l=this.nCachedObjects_;for(let c=0,h=arguments.length;c!==h;++c){const h=arguments[c],d=h.uuid;let u=e[d];if(void 0===u){u=o++,e[d]=u,t.push(h);for(let t=0,e=a;t!==e;++t)r[t].push(new nd(h,n[t],i[t]))}else if(u<l){s=t[u];const o=--l,c=t[o];e[c.uuid]=u,t[u]=c,e[d]=o,t[o]=h;for(let t=0,e=a;t!==e;++t){const e=r[t],a=e[o];let s=e[u];e[u]=a,void 0===s&&(s=new nd(h,n[t],i[t])),e[o]=s}}else t[u]!==s&&hi("AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_;for(let a=0,s=arguments.length;a!==s;++a){const s=arguments[a],o=s.uuid,l=e[o];if(void 0!==l&&l>=r){const a=r++,c=t[a];e[c.uuid]=l,t[l]=c,e[o]=a,t[a]=s;for(let t=0,e=i;t!==e;++t){const e=n[t],i=e[a],r=e[l];e[l]=i,e[a]=r}}}this.nCachedObjects_=r}uncache(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_,a=t.length;for(let s=0,o=arguments.length;s!==o;++s){const o=arguments[s].uuid,l=e[o];if(void 0!==l)if(delete e[o],l<r){const s=--r,o=t[s],c=--a,h=t[c];e[o.uuid]=l,t[l]=o,e[h.uuid]=s,t[s]=h,t.pop();for(let t=0,e=i;t!==e;++t){const e=n[t],i=e[s],r=e[c];e[l]=i,e[s]=r,e.pop()}}else{const r=--a,s=t[r];r>0&&(e[s.uuid]=l),t[l]=s,t.pop();for(let t=0,e=i;t!==e;++t){const e=n[t];e[l]=e[r],e.pop()}}}this.nCachedObjects_=r}subscribe_(t,e){const n=this._bindingsIndicesByPath;let i=n[t];const r=this._bindings;if(void 0!==i)return r[i];const a=this._paths,s=this._parsedPaths,o=this._objects,l=o.length,c=this.nCachedObjects_,h=new Array(l);i=r.length,n[t]=i,a.push(t),s.push(e),r.push(h);for(let n=c,i=o.length;n!==i;++n){const i=o[n];h[n]=new nd(i,t,e)}return h}unsubscribe_(t){const e=this._bindingsIndicesByPath,n=e[t];if(void 0!==n){const i=this._paths,r=this._parsedPaths,a=this._bindings,s=a.length-1,o=a[s];e[t[s]]=n,a[n]=o,a.pop(),r[n]=r[s],r.pop(),i[n]=i[s],i.pop()}}}class rd{constructor(t,e,n=null,i=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=i;const r=e.tracks,a=r.length,s=new Array(a),o={endingStart:Nn,endingEnd:Nn};for(let t=0;t!==a;++t){const e=r[t].createInterpolant(null);s[t]=e,e.settings&&Object.assign(o,e.settings),e.settings=o}this._interpolantSettings=o,this._interpolants=s,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,n=!1){if(t.fadeOut(e),this.fadeIn(e),!0===n){const n=this._clip.duration,i=t._clip.duration,r=i/n,a=n/i;t.warp(1,r,e),this.warp(a,1,e)}return this}crossFadeTo(t,e,n=!1){return t.crossFadeFrom(this,e,n)}stopFading(){const t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,n){const i=this._mixer,r=i.time,a=this.timeScale;let s=this._timeScaleInterpolant;null===s&&(s=i._lendControlInterpolant(),this._timeScaleInterpolant=s);const o=s.parameterPositions,l=s.sampleValues;return o[0]=r,o[1]=r+n,l[0]=t/a,l[1]=e/a,this}stopWarping(){const t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,n,i){if(!this.enabled)return void this._updateWeight(t);const r=this._startTime;if(null!==r){const i=(t-r)*n;i<0||0===n?e=0:(this._startTime=null,e=n*i)}e*=this._updateTimeScale(t);const a=this._updateTime(e),s=this._updateWeight(t);if(s>0){const t=this._interpolants,e=this._propertyBindings;if(2501===this.blendMode)for(let n=0,i=t.length;n!==i;++n)t[n].evaluate(a),e[n].accumulateAdditive(s);else for(let n=0,r=t.length;n!==r;++n)t[n].evaluate(a),e[n].accumulate(i,s)}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const n=this._weightInterpolant;if(null!==n){const i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const n=this._timeScaleInterpolant;null!==n&&(e*=n.evaluate(t)[0],t>n.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e))}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,n=this.loop;let i=this.time+t,r=this._loopCount;const a=2202===n;if(0===t)return-1===r||!a||1&~r?i:e-i;if(2200===n){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(i>=e)i=e;else{if(!(i<0)){this.time=i;break t}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===r&&(t>=0?(r=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),i>=e||i<0){const n=Math.floor(i/e);i-=e*n,r+=Math.abs(n);const s=this.repetitions-r;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=t>0?e:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===s){const e=t<0;this._setEndings(e,!e,a)}else this._setEndings(!1,!1,a);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this._loopCount=r,this.time=i;if(a&&!(1&~r))return e-i}return i}_setEndings(t,e,n){const i=this._interpolantSettings;n?(i.endingStart=On,i.endingEnd=On):(i.endingStart=t?this.zeroSlopeAtStart?On:Nn:Un,i.endingEnd=e?this.zeroSlopeAtEnd?On:Nn:Un)}_scheduleFading(t,e,n){const i=this._mixer,r=i.time;let a=this._weightInterpolant;null===a&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);const s=a.parameterPositions,o=a.sampleValues;return s[0]=r,o[0]=e,s[1]=r+t,o[1]=n,this}}const ad=new Float32Array(1);class sd extends pi{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(t,e){const n=t._localRoot||this._root,i=t._clip.tracks,r=i.length,a=t._propertyBindings,s=t._interpolants,o=n.uuid,l=this._bindingsByRootAndName;let c=l[o];void 0===c&&(c={},l[o]=c);for(let t=0;t!==r;++t){const r=i[t],l=r.name;let h=c[l];if(void 0!==h)++h.referenceCount,a[t]=h;else{if(h=a[t],void 0!==h){null===h._cacheIndex&&(++h.referenceCount,this._addInactiveBinding(h,o,l));continue}const i=e&&e._propertyBindings[t].binding.parsedPath;h=new Zh(nd.create(n,l,i),r.ValueTypeName,r.getValueSize()),++h.referenceCount,this._addInactiveBinding(h,o,l),a[t]=h}s[t].resultBuffer=h.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,n=t._clip.uuid,i=this._actionsByClip[n];this._bindAction(t,i&&i.knownActions[0]),this._addInactiveAction(t,n,e)}const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0===n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0===--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return null!==e&&e<this._nActiveActions}_addInactiveAction(t,e,n){const i=this._actions,r=this._actionsByClip;let a=r[e];if(void 0===a)a={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,r[e]=a;else{const e=a.knownActions;t._byClipCacheIndex=e.length,e.push(t)}t._cacheIndex=i.length,i.push(t),a.actionByRoot[n]=t}_removeInactiveAction(t){const e=this._actions,n=e[e.length-1],i=t._cacheIndex;n._cacheIndex=i,e[i]=n,e.pop(),t._cacheIndex=null;const r=t._clip.uuid,a=this._actionsByClip,s=a[r],o=s.knownActions,l=o[o.length-1],c=t._byClipCacheIndex;l._byClipCacheIndex=c,o[c]=l,o.pop(),t._byClipCacheIndex=null,delete s.actionByRoot[(t._localRoot||this._root).uuid],0===o.length&&delete a[r],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0===--n.referenceCount&&this._removeInactiveBinding(n)}}_lendAction(t){const e=this._actions,n=t._cacheIndex,i=this._nActiveActions++,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_takeBackAction(t){const e=this._actions,n=t._cacheIndex,i=--this._nActiveActions,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_addInactiveBinding(t,e,n){const i=this._bindingsByRootAndName,r=this._bindings;let a=i[e];void 0===a&&(a={},i[e]=a),a[n]=t,t._cacheIndex=r.length,r.push(t)}_removeInactiveBinding(t){const e=this._bindings,n=t.binding,i=n.rootNode.uuid,r=n.path,a=this._bindingsByRootAndName,s=a[i],o=e[e.length-1],l=t._cacheIndex;o._cacheIndex=l,e[l]=o,e.pop(),delete s[r],0===Object.keys(s).length&&delete a[i]}_lendBinding(t){const e=this._bindings,n=t._cacheIndex,i=this._nActiveBindings++,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_takeBackBinding(t){const e=this._bindings,n=t._cacheIndex,i=--this._nActiveBindings,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_lendControlInterpolant(){const t=this._controlInterpolants,e=this._nActiveControlInterpolants++;let n=t[e];return void 0===n&&(n=new Gc(new Float32Array(2),new Float32Array(2),1,ad),n.__cacheIndex=e,t[e]=n),n}_takeBackControlInterpolant(t){const e=this._controlInterpolants,n=t.__cacheIndex,i=--this._nActiveControlInterpolants,r=e[i];t.__cacheIndex=i,e[i]=t,r.__cacheIndex=n,e[n]=r}clipAction(t,e,n){const i=e||this._root,r=i.uuid;let a="string"==typeof t?Kc.findByName(i,t):t;const s=null!==a?a.uuid:t,o=this._actionsByClip[s];let l=null;if(void 0===n&&(n=null!==a?a.blendMode:Fn),void 0!==o){const t=o.actionByRoot[r];if(void 0!==t&&t.blendMode===n)return t;l=o.knownActions[0],null===a&&(a=l._clip)}if(null===a)return null;const c=new rd(this,a,e,n);return this._bindAction(c,l),this._addInactiveAction(c,s,r),c}existingAction(t,e){const n=e||this._root,i=n.uuid,r="string"==typeof t?Kc.findByName(n,t):t,a=r?r.uuid:t,s=this._actionsByClip[a];return void 0!==s&&s.actionByRoot[i]||null}stopAllAction(){const t=this._actions;for(let e=this._nActiveActions-1;e>=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,n=this._nActiveActions,i=this.time+=t,r=Math.sign(t),a=this._accuIndex^=1;for(let s=0;s!==n;++s)e[s]._update(i,t,r,a);const s=this._bindings,o=this._nActiveBindings;for(let t=0;t!==o;++t)s[t].apply(a);return this}setTime(t){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){const e=this._actions,n=t.uuid,i=this._actionsByClip,r=i[n];if(void 0!==r){const t=r.knownActions;for(let n=0,i=t.length;n!==i;++n){const i=t[n];this._deactivateAction(i);const r=i._cacheIndex,a=e[e.length-1];i._cacheIndex=null,i._byClipCacheIndex=null,a._cacheIndex=r,e[r]=a,e.pop(),this._removeInactiveBindingsForAction(i)}delete i[n]}}uncacheRoot(t){const e=t.uuid,n=this._actionsByClip;for(const t in n){const i=n[t].actionByRoot[e];void 0!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}const i=this._bindingsByRootAndName[e];if(void 0!==i)for(const t in i){const e=i[t];e.restoreOriginalState(),this._removeInactiveBinding(e)}}uncacheAction(t,e){const n=this.existingAction(t,e);null!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}}class od extends Pa{constructor(t,e,n=1){super(t,e),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}clone(t){const e=super.clone(t);return e.meshPerAttribute=this.meshPerAttribute,e}toJSON(t){const e=super.toJSON(t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}}const ld=new Ji;class cd{constructor(t,e,n=0,i=1/0){this.ray=new ls(t,e),this.near=n,this.far=i,this.camera=null,this.layers=new lr,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):hi("Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return ld.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(ld),this}intersectObject(t,e=!0,n=[]){return dd(t,this,n,e),n.sort(hd),n}intersectObjects(t,e=!0,n=[]){for(let i=0,r=t.length;i<r;i++)dd(t[i],this,n,e);return n.sort(hd),n}}function hd(t,e){return t.distance-e.distance}function dd(t,e,n,i){let r=!0;if(t.layers.test(e.layers)&&!1===t.raycast(e,n)&&(r=!1),!0===r&&!0===i){const i=t.children;for(let t=0,r=i.length;t<r;t++)dd(i[t],e,n,!0)}}class ud{static{ud.prototype.isMatrix2=!0}constructor(t,e,n,i){this.elements=[1,0,0,1],void 0!==t&&this.set(t,e,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,i){const r=this.elements;return r[0]=t,r[2]=e,r[1]=n,r[3]=i,this}}function pd(t,e,n,i){const r=function(t){switch(t){case Ae:case Ce:return{byteLength:1,components:1};case Ie:case Re:case Ne:return{byteLength:2,components:1};case Oe:case Ue:return{byteLength:2,components:4};case Le:case Pe:case De:return{byteLength:4,components:1};case ze:case ke:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}(i);switch(n){case 1021:return t*e;case He:case We:return t*e/r.components*r.byteLength;case je:case Xe:return t*e*2/r.components*r.byteLength;case 1022:return t*e*3/r.components*r.byteLength;case Be:case qe:return t*e*4/r.components*r.byteLength;case Ye:case Ze:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case $e:case Je:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case Qe:case en:return Math.max(t,16)*Math.max(e,8)/4;case Ke:case tn:return Math.max(t,8)*Math.max(e,8)/2;case nn:case rn:case sn:case on:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case an:case ln:case cn:case hn:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case dn:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case un:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case pn:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case mn:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case fn:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case gn:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case vn:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case _n:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case yn:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case xn:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case bn:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case Sn:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case Mn:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case wn:case En:case Tn:return Math.ceil(t/4)*Math.ceil(e/4)*16;case An:case Cn:return Math.ceil(t/4)*Math.ceil(e/4)*8;case Rn:case In:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}
|
|
93
|
+
*/function ri(t,e){return new ii[t](e)}function ai(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function si(){const t=ai("canvas");return t.style.display="block",t}const oi={};function li(...t){const e="THREE."+t.shift();console.log(e,...t)}function ci(t){const e=t[0];if("string"==typeof e&&e.startsWith("TSL:")){const e=t[1];e&&e.isStackTrace?t[0]+=" "+e.getLocation():t[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return t}function hi(...t){const e="THREE."+(t=ci(t)).shift();{const n=t[0];n&&n.isStackTrace?console.warn(n.getError(e)):console.warn(e,...t)}}function di(...t){const e="THREE."+(t=ci(t)).shift();{const n=t[0];n&&n.isStackTrace?console.error(n.getError(e)):console.error(e,...t)}}function ui(...t){const e=t.join(" ");e in oi||(oi[e]=!0,hi(...t))}const pi={[Zt]:1,[Jt]:6,[Qt]:7,[Kt]:5,[$t]:0,[ee]:2,[ne]:4,[te]:3};class mi{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[t]&&(n[t]=[]),-1===n[t].indexOf(e)&&n[t].push(e)}hasEventListener(t,e){const n=this._listeners;return void 0!==n&&void 0!==n[t]&&-1!==n[t].indexOf(e)}removeEventListener(t,e){const n=this._listeners;if(void 0===n)return;const i=n[t];if(void 0!==i){const t=i.indexOf(e);-1!==t&&i.splice(t,1)}}dispatchEvent(t){const e=this._listeners;if(void 0===e)return;const n=e[t.type];if(void 0!==n){t.target=this;const e=n.slice(0);for(let n=0,i=e.length;n<i;n++)e[n].call(this,t);t.target=null}}}const fi=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let gi=1234567;const vi=Math.PI/180,_i=180/Math.PI;function yi(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(fi[255&t]+fi[t>>8&255]+fi[t>>16&255]+fi[t>>24&255]+"-"+fi[255&e]+fi[e>>8&255]+"-"+fi[e>>16&15|64]+fi[e>>24&255]+"-"+fi[63&n|128]+fi[n>>8&255]+"-"+fi[n>>16&255]+fi[n>>24&255]+fi[255&i]+fi[i>>8&255]+fi[i>>16&255]+fi[i>>24&255]).toLowerCase()}function xi(t,e,n){return Math.max(e,Math.min(n,t))}function bi(t,e){return(t%e+e)%e}function Si(t,e,n){return(1-n)*t+n*e}function Mi(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function wi(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}const Ei={DEG2RAD:vi,RAD2DEG:_i,generateUUID:yi,clamp:xi,euclideanModulo:bi,mapLinear:function(t,e,n,i,r){return i+(t-e)*(r-i)/(n-e)},inverseLerp:function(t,e,n){return t!==e?(n-t)/(e-t):0},lerp:Si,damp:function(t,e,n,i){return Si(t,e,1-Math.exp(-n*i))},pingpong:function(t,e=1){return e-Math.abs(bi(t,2*e)-e)},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){void 0!==t&&(gi=t);let e=gi+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296},degToRad:function(t){return t*vi},radToDeg:function(t){return t*_i},isPowerOfTwo:function(t){return!(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,e,n,i,r){const a=Math.cos,s=Math.sin,o=a(n/2),l=s(n/2),c=a((e+i)/2),h=s((e+i)/2),d=a((e-i)/2),u=s((e-i)/2),p=a((i-e)/2),m=s((i-e)/2);switch(r){case"XYX":t.set(o*h,l*d,l*u,o*c);break;case"YZY":t.set(l*u,o*h,l*d,o*c);break;case"ZXZ":t.set(l*d,l*u,o*h,o*c);break;case"XZX":t.set(o*h,l*m,l*p,o*c);break;case"YXY":t.set(l*p,o*h,l*m,o*c);break;case"ZYZ":t.set(l*m,l*p,o*h,o*c);break;default:hi("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:wi,denormalize:Mi};class Ti{static{Ti.prototype.isVector2=!0}constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[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=xi(this.x,t.x,e.x),this.y=xi(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=xi(this.x,t,e),this.y=xi(this.y,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(xi(n,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(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(xi(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),i=Math.sin(e),r=this.x-t.x,a=this.y-t.y;return this.x=r*n-a*i+t.x,this.y=r*i+a*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ai{constructor(t=0,e=0,n=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=i}static slerpFlat(t,e,n,i,r,a,s){let o=n[i+0],l=n[i+1],c=n[i+2],h=n[i+3],d=r[a+0],u=r[a+1],p=r[a+2],m=r[a+3];if(h!==m||o!==d||l!==u||c!==p){let t=o*d+l*u+c*p+h*m;t<0&&(d=-d,u=-u,p=-p,m=-m,t=-t);let e=1-s;if(t<.9995){const n=Math.acos(t),i=Math.sin(n);e=Math.sin(e*n)/i,o=o*e+d*(s=Math.sin(s*n)/i),l=l*e+u*s,c=c*e+p*s,h=h*e+m*s}else{o=o*e+d*s,l=l*e+u*s,c=c*e+p*s,h=h*e+m*s;const t=1/Math.sqrt(o*o+l*l+c*c+h*h);o*=t,l*=t,c*=t,h*=t}}t[e]=o,t[e+1]=l,t[e+2]=c,t[e+3]=h}static multiplyQuaternionsFlat(t,e,n,i,r,a){const s=n[i],o=n[i+1],l=n[i+2],c=n[i+3],h=r[a],d=r[a+1],u=r[a+2],p=r[a+3];return t[e]=s*p+c*h+o*u-l*d,t[e+1]=o*p+c*d+l*h-s*u,t[e+2]=l*p+c*u+s*d-o*h,t[e+3]=c*p-s*h-o*d-l*u,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,i=t._y,r=t._z,a=t._order,s=Math.cos,o=Math.sin,l=s(n/2),c=s(i/2),h=s(r/2),d=o(n/2),u=o(i/2),p=o(r/2);switch(a){case"XYZ":this._x=d*c*h+l*u*p,this._y=l*u*h-d*c*p,this._z=l*c*p+d*u*h,this._w=l*c*h-d*u*p;break;case"YXZ":this._x=d*c*h+l*u*p,this._y=l*u*h-d*c*p,this._z=l*c*p-d*u*h,this._w=l*c*h+d*u*p;break;case"ZXY":this._x=d*c*h-l*u*p,this._y=l*u*h+d*c*p,this._z=l*c*p+d*u*h,this._w=l*c*h-d*u*p;break;case"ZYX":this._x=d*c*h-l*u*p,this._y=l*u*h+d*c*p,this._z=l*c*p-d*u*h,this._w=l*c*h+d*u*p;break;case"YZX":this._x=d*c*h+l*u*p,this._y=l*u*h+d*c*p,this._z=l*c*p-d*u*h,this._w=l*c*h-d*u*p;break;case"XZY":this._x=d*c*h-l*u*p,this._y=l*u*h-d*c*p,this._z=l*c*p+d*u*h,this._w=l*c*h+d*u*p;break;default:hi("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[4],r=e[8],a=e[1],s=e[5],o=e[9],l=e[2],c=e[6],h=e[10],d=n+s+h;if(d>0){const t=.5/Math.sqrt(d+1);this._w=.25/t,this._x=(c-o)*t,this._y=(r-l)*t,this._z=(a-i)*t}else if(n>s&&n>h){const t=2*Math.sqrt(1+n-s-h);this._w=(c-o)/t,this._x=.25*t,this._y=(i+a)/t,this._z=(r+l)/t}else if(s>h){const t=2*Math.sqrt(1+s-n-h);this._w=(r-l)/t,this._x=(i+a)/t,this._y=.25*t,this._z=(o+c)/t}else{const t=2*Math.sqrt(1+h-n-s);this._w=(a-i)/t,this._x=(r+l)/t,this._y=(o+c)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(xi(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(0===n)return this;const i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,i=t._y,r=t._z,a=t._w,s=e._x,o=e._y,l=e._z,c=e._w;return this._x=n*c+a*s+i*l-r*o,this._y=i*c+a*o+r*s-n*l,this._z=r*c+a*l+n*o-i*s,this._w=a*c-n*s-i*o-r*l,this._onChangeCallback(),this}slerp(t,e){let n=t._x,i=t._y,r=t._z,a=t._w,s=this.dot(t);s<0&&(n=-n,i=-i,r=-r,a=-a,s=-s);let o=1-e;if(s<.9995){const t=Math.acos(s),l=Math.sin(t);o=Math.sin(o*t)/l,e=Math.sin(e*t)/l,this._x=this._x*o+n*e,this._y=this._y*o+i*e,this._z=this._z*o+r*e,this._w=this._w*o+a*e,this._onChangeCallback()}else this._x=this._x*o+n*e,this._y=this._y*o+i*e,this._z=this._z*o+r*e,this._w=this._w*o+a*e,this.normalize();return this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Ci{static{Ci.prototype.isVector3=!0}constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Ii.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Ii.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=t.elements,a=1/(r[3]*e+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*e+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*e+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,r=t.x,a=t.y,s=t.z,o=t.w,l=2*(a*i-s*n),c=2*(s*e-r*i),h=2*(r*n-a*e);return this.x=e+o*l+a*h-s*c,this.y=n+o*c+s*l-r*h,this.z=i+o*h+r*c-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,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,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=xi(this.x,t.x,e.x),this.y=xi(this.y,t.y,e.y),this.z=xi(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=xi(this.x,t,e),this.y=xi(this.y,t,e),this.z=xi(this.z,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(xi(n,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,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,i=t.y,r=t.z,a=e.x,s=e.y,o=e.z;return this.x=i*o-r*s,this.y=r*a-n*o,this.z=n*s-i*a,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Ri.copy(this).projectOnVector(t),this.sub(Ri)}reflect(t){return this.sub(Ri.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(xi(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=2*Math.random()-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Ri=new Ci,Ii=new Ai;class Pi{static{Pi.prototype.isMatrix3=!0}constructor(t,e,n,i,r,a,s,o,l){this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,n,i,r,a,s,o,l)}set(t,e,n,i,r,a,s,o,l){const c=this.elements;return c[0]=t,c[1]=i,c[2]=s,c[3]=e,c[4]=r,c[5]=o,c[6]=n,c[7]=a,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,a=n[0],s=n[3],o=n[6],l=n[1],c=n[4],h=n[7],d=n[2],u=n[5],p=n[8],m=i[0],f=i[3],g=i[6],v=i[1],_=i[4],y=i[7],x=i[2],b=i[5],S=i[8];return r[0]=a*m+s*v+o*x,r[3]=a*f+s*_+o*b,r[6]=a*g+s*y+o*S,r[1]=l*m+c*v+h*x,r[4]=l*f+c*_+h*b,r[7]=l*g+c*y+h*S,r[2]=d*m+u*v+p*x,r[5]=d*f+u*_+p*b,r[8]=d*g+u*y+p*S,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],s=t[5],o=t[6],l=t[7],c=t[8];return e*a*c-e*s*l-n*r*c+n*s*o+i*r*l-i*a*o}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],s=t[5],o=t[6],l=t[7],c=t[8],h=c*a-s*l,d=s*o-c*r,u=l*r-a*o,p=e*h+n*d+i*u;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return t[0]=h*m,t[1]=(i*l-c*n)*m,t[2]=(s*n-i*a)*m,t[3]=d*m,t[4]=(c*e-i*o)*m,t[5]=(i*r-s*e)*m,t[6]=u*m,t[7]=(n*o-l*e)*m,t[8]=(a*e-n*r)*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,n,i,r,a,s){const o=Math.cos(r),l=Math.sin(r);return this.set(n*o,n*l,-n*(o*a+l*s)+a+t,-i*l,i*o,-i*(-l*a+o*s)+s+e,0,0,1),this}scale(t,e){return this.premultiply(Li.makeScale(t,e)),this}rotate(t){return this.premultiply(Li.makeRotation(-t)),this}translate(t,e){return this.premultiply(Li.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<9;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const Li=new Pi,Di=(new Pi).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Ni=(new Pi).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Oi(){const t={enabled:!0,workingColorSpace:Gn,spaces:{},convert:function(t,e,n){return!1!==this.enabled&&e!==n&&e&&n?(this.spaces[e].transfer===Hn&&(t.r=Fi(t.r),t.g=Fi(t.g),t.b=Fi(t.b)),this.spaces[e].primaries!==this.spaces[n].primaries&&(t.applyMatrix3(this.spaces[e].toXYZ),t.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===Hn&&(t.r=zi(t.r),t.g=zi(t.g),t.b=zi(t.b)),t):t},workingToColorSpace:function(t,e){return this.convert(t,this.workingColorSpace,e)},colorSpaceToWorking:function(t,e){return this.convert(t,e,this.workingColorSpace)},getPrimaries:function(t){return this.spaces[t].primaries},getTransfer:function(t){return t===kn?Vn:this.spaces[t].transfer},getToneMappingMode:function(t){return this.spaces[t].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(t,e=this.workingColorSpace){return t.fromArray(this.spaces[e].luminanceCoefficients)},define:function(t){Object.assign(this.spaces,t)},_getMatrix:function(t,e,n){return t.copy(this.spaces[e].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(t){return this.spaces[t].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(t=this.workingColorSpace){return this.spaces[t].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(e,n){return ui("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(e,n)},toWorkingColorSpace:function(e,n){return ui("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(e,n)}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],i=[.3127,.329];return t.define({[Gn]:{primaries:e,whitePoint:i,transfer:Vn,toXYZ:Di,fromXYZ:Ni,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Bn},outputColorSpaceConfig:{drawingBufferColorSpace:Bn}},[Bn]:{primaries:e,whitePoint:i,transfer:Hn,toXYZ:Di,fromXYZ:Ni,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Bn}}}),t}const Ui=Oi();function Fi(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function zi(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}let ki;class Bi{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{void 0===ki&&(ki=ai("canvas")),ki.width=t.width,ki.height=t.height;const e=ki.getContext("2d");t instanceof ImageData?e.putImageData(t,0,0):e.drawImage(t,0,0,t.width,t.height),n=ki}return n.toDataURL(e)}static sRGBToLinear(t){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=ai("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),r=i.data;for(let t=0;t<r.length;t++)r[t]=255*Fi(r[t]/255);return n.putImageData(i,0,0),e}if(t.data){const e=t.data.slice(0);for(let t=0;t<e.length;t++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[t]=Math.floor(255*Fi(e[t]/255)):e[t]=Fi(e[t]);return{data:e,width:t.width,height:t.height}}return hi("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let Gi=0;class Vi{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Gi++}),this.uuid=yi(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return"undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):"undefined"!=typeof VideoFrame&&e instanceof VideoFrame?t.set(e.displayWidth,e.displayHeight,0):null!==e?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){!0===t&&this.version++}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.images[this.uuid])return t.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(null!==i){let t;if(Array.isArray(i)){t=[];for(let e=0,n=i.length;e<n;e++)i[e].isDataTexture?t.push(Hi(i[e].image)):t.push(Hi(i[e]))}else t=Hi(i);n.url=t}return e||(t.images[this.uuid]=n),n}}function Hi(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?Bi.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(hi("Texture: Unable to serialize Texture."),{})}let Wi=0;const ji=new Ci;class Xi extends mi{constructor(t=Xi.DEFAULT_IMAGE,e=Xi.DEFAULT_MAPPING,n=1001,i=1001,r=1006,a=1008,s=1023,o=Ce,l=Xi.DEFAULT_ANISOTROPY,c=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Wi++}),this.uuid=yi(),this.name="",this.source=new Vi(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=a,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=o,this.offset=new Ti(0,0),this.repeat=new Ti(1,1),this.center=new Ti(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Pi,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=c,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,this.normalized=!1}get width(){return this.source.getSize(ji).x}get height(){return this.source.getSize(ji).y}get depth(){return this.source.getSize(ji).z}get image(){return this.source.data}set image(t){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.normalized=t.normalized,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 n=t[e];if(void 0===n){hi(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const i=this[e];void 0!==i?i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[e]=n:hi(`Texture.setValues(): property '${e}' does not exist.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const n={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,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(300!==this.mapping)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case ye:t.x=t.x-Math.floor(t.x);break;case xe:t.x=t.x<0?0:1;break;case be:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case ye:t.y=t.y-Math.floor(t.y);break;case xe:t.y=t.y<0?0:1;break;case be:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){!0===t&&this.pmremVersion++}}Xi.DEFAULT_IMAGE=null,Xi.DEFAULT_MAPPING=300,Xi.DEFAULT_ANISOTROPY=1;class qi{static{qi.prototype.isVector4=!0}constructor(t=0,e=0,n=0,i=1){this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*e+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*e+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*e+a[7]*n+a[11]*i+a[15]*r,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,n,i,r;const a=.01,s=.1,o=t.elements,l=o[0],c=o[4],h=o[8],d=o[1],u=o[5],p=o[9],m=o[2],f=o[6],g=o[10];if(Math.abs(c-d)<a&&Math.abs(h-m)<a&&Math.abs(p-f)<a){if(Math.abs(c+d)<s&&Math.abs(h+m)<s&&Math.abs(p+f)<s&&Math.abs(l+u+g-3)<s)return this.set(1,0,0,0),this;e=Math.PI;const t=(l+1)/2,o=(u+1)/2,v=(g+1)/2,_=(c+d)/4,y=(h+m)/4,x=(p+f)/4;return t>o&&t>v?t<a?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(t),i=_/n,r=y/n):o>v?o<a?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(o),n=_/i,r=x/i):v<a?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(v),n=y/r,i=x/r),this.set(n,i,r,e),this}let v=Math.sqrt((f-p)*(f-p)+(h-m)*(h-m)+(d-c)*(d-c));return Math.abs(v)<.001&&(v=1),this.x=(f-p)/v,this.y=(h-m)/v,this.z=(d-c)/v,this.w=Math.acos((l+u+g-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=xi(this.x,t.x,e.x),this.y=xi(this.y,t.y,e.y),this.z=xi(this.z,t.z,e.z),this.w=xi(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=xi(this.x,t,e),this.y=xi(this.y,t,e),this.z=xi(this.z,t,e),this.w=xi(this.w,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(xi(n,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,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Yi extends mi{constructor(t=1,e=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ee,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=n.depth,this.scissor=new qi(0,0,t,e),this.scissorTest=!1,this.viewport=new qi(0,0,t,e),this.textures=[];const i={width:t,height:e,depth:n.depth},r=new Xi(i),a=n.count;for(let t=0;t<a;t++)this.textures[t]=r.clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(t={}){const e={minFilter:Ee,generateMipmaps:!1,flipY:!1,internalFormat:null};void 0!==t.mapping&&(e.mapping=t.mapping),void 0!==t.wrapS&&(e.wrapS=t.wrapS),void 0!==t.wrapT&&(e.wrapT=t.wrapT),void 0!==t.wrapR&&(e.wrapR=t.wrapR),void 0!==t.magFilter&&(e.magFilter=t.magFilter),void 0!==t.minFilter&&(e.minFilter=t.minFilter),void 0!==t.format&&(e.format=t.format),void 0!==t.type&&(e.type=t.type),void 0!==t.anisotropy&&(e.anisotropy=t.anisotropy),void 0!==t.colorSpace&&(e.colorSpace=t.colorSpace),void 0!==t.flipY&&(e.flipY=t.flipY),void 0!==t.generateMipmaps&&(e.generateMipmaps=t.generateMipmaps),void 0!==t.internalFormat&&(e.internalFormat=t.internalFormat);for(let t=0;t<this.textures.length;t++)this.textures[t].setValues(e)}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){null!==this._depthTexture&&(this._depthTexture.renderTarget=null),null!==t&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=t,this.textures[i].image.height=e,this.textures[i].image.depth=n,!0!==this.textures[i].isData3DTexture&&(this.textures[i].isArrayTexture=this.textures[i].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,n=t.textures.length;e<n;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 Vi(n)}return this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,null!==t.depthTexture&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this.multiview=t.multiview,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Zi extends Yi{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class $i extends Xi{constructor(t=null,e=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=Se,this.minFilter=Se,this.wrapR=xe,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class Ji extends Xi{constructor(t=null,e=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=Se,this.minFilter=Se,this.wrapR=xe,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ki{static{Ki.prototype.isMatrix4=!0}constructor(t,e,n,i,r,a,s,o,l,c,h,d,u,p,m,f){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,n,i,r,a,s,o,l,c,h,d,u,p,m,f)}set(t,e,n,i,r,a,s,o,l,c,h,d,u,p,m,f){const g=this.elements;return g[0]=t,g[4]=e,g[8]=n,g[12]=i,g[1]=r,g[5]=a,g[9]=s,g[13]=o,g[2]=l,g[6]=c,g[10]=h,g[14]=d,g[3]=u,g[7]=p,g[11]=m,g[15]=f,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new Ki).fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return 0===this.determinant()?(t.set(1,0,0),e.set(0,1,0),n.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){if(0===t.determinant())return this.identity();const e=this.elements,n=t.elements,i=1/Qi.setFromMatrixColumn(t,0).length(),r=1/Qi.setFromMatrixColumn(t,1).length(),a=1/Qi.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,i=t.y,r=t.z,a=Math.cos(n),s=Math.sin(n),o=Math.cos(i),l=Math.sin(i),c=Math.cos(r),h=Math.sin(r);if("XYZ"===t.order){const t=a*c,n=a*h,i=s*c,r=s*h;e[0]=o*c,e[4]=-o*h,e[8]=l,e[1]=n+i*l,e[5]=t-r*l,e[9]=-s*o,e[2]=r-t*l,e[6]=i+n*l,e[10]=a*o}else if("YXZ"===t.order){const t=o*c,n=o*h,i=l*c,r=l*h;e[0]=t+r*s,e[4]=i*s-n,e[8]=a*l,e[1]=a*h,e[5]=a*c,e[9]=-s,e[2]=n*s-i,e[6]=r+t*s,e[10]=a*o}else if("ZXY"===t.order){const t=o*c,n=o*h,i=l*c,r=l*h;e[0]=t-r*s,e[4]=-a*h,e[8]=i+n*s,e[1]=n+i*s,e[5]=a*c,e[9]=r-t*s,e[2]=-a*l,e[6]=s,e[10]=a*o}else if("ZYX"===t.order){const t=a*c,n=a*h,i=s*c,r=s*h;e[0]=o*c,e[4]=i*l-n,e[8]=t*l+r,e[1]=o*h,e[5]=r*l+t,e[9]=n*l-i,e[2]=-l,e[6]=s*o,e[10]=a*o}else if("YZX"===t.order){const t=a*o,n=a*l,i=s*o,r=s*l;e[0]=o*c,e[4]=r-t*h,e[8]=i*h+n,e[1]=h,e[5]=a*c,e[9]=-s*c,e[2]=-l*c,e[6]=n*h+i,e[10]=t-r*h}else if("XZY"===t.order){const t=a*o,n=a*l,i=s*o,r=s*l;e[0]=o*c,e[4]=-h,e[8]=l*c,e[1]=t*h+r,e[5]=a*c,e[9]=n*h-i,e[2]=i*h-n,e[6]=s*c,e[10]=r*h+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(er,t,nr)}lookAt(t,e,n){const i=this.elements;return ar.subVectors(t,e),0===ar.lengthSq()&&(ar.z=1),ar.normalize(),ir.crossVectors(n,ar),0===ir.lengthSq()&&(1===Math.abs(n.z)?ar.x+=1e-4:ar.z+=1e-4,ar.normalize(),ir.crossVectors(n,ar)),ir.normalize(),rr.crossVectors(ar,ir),i[0]=ir.x,i[4]=rr.x,i[8]=ar.x,i[1]=ir.y,i[5]=rr.y,i[9]=ar.y,i[2]=ir.z,i[6]=rr.z,i[10]=ar.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,a=n[0],s=n[4],o=n[8],l=n[12],c=n[1],h=n[5],d=n[9],u=n[13],p=n[2],m=n[6],f=n[10],g=n[14],v=n[3],_=n[7],y=n[11],x=n[15],b=i[0],S=i[4],M=i[8],w=i[12],E=i[1],T=i[5],A=i[9],C=i[13],R=i[2],I=i[6],P=i[10],L=i[14],D=i[3],N=i[7],O=i[11],U=i[15];return r[0]=a*b+s*E+o*R+l*D,r[4]=a*S+s*T+o*I+l*N,r[8]=a*M+s*A+o*P+l*O,r[12]=a*w+s*C+o*L+l*U,r[1]=c*b+h*E+d*R+u*D,r[5]=c*S+h*T+d*I+u*N,r[9]=c*M+h*A+d*P+u*O,r[13]=c*w+h*C+d*L+u*U,r[2]=p*b+m*E+f*R+g*D,r[6]=p*S+m*T+f*I+g*N,r[10]=p*M+m*A+f*P+g*O,r[14]=p*w+m*C+f*L+g*U,r[3]=v*b+_*E+y*R+x*D,r[7]=v*S+_*T+y*I+x*N,r[11]=v*M+_*A+y*P+x*O,r[15]=v*w+_*C+y*L+x*U,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],i=t[8],r=t[12],a=t[1],s=t[5],o=t[9],l=t[13],c=t[2],h=t[6],d=t[10],u=t[14],p=t[3],m=t[7],f=t[11],g=t[15],v=o*u-l*d,_=s*u-l*h,y=s*d-o*h,x=a*u-l*c,b=a*d-o*c,S=a*h-s*c;return e*(m*v-f*_+g*y)-n*(p*v-f*x+g*b)+i*(p*_-m*x+g*S)-r*(p*y-m*b+f*S)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],s=t[5],o=t[6],l=t[7],c=t[8],h=t[9],d=t[10],u=t[11],p=t[12],m=t[13],f=t[14],g=t[15],v=e*s-n*a,_=e*o-i*a,y=e*l-r*a,x=n*o-i*s,b=n*l-r*s,S=i*l-r*o,M=c*m-h*p,w=c*f-d*p,E=c*g-u*p,T=h*f-d*m,A=h*g-u*m,C=d*g-u*f,R=v*C-_*A+y*T+x*E-b*w+S*M;if(0===R)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const I=1/R;return t[0]=(s*C-o*A+l*T)*I,t[1]=(i*A-n*C-r*T)*I,t[2]=(m*S-f*b+g*x)*I,t[3]=(d*b-h*S-u*x)*I,t[4]=(o*E-a*C-l*w)*I,t[5]=(e*C-i*E+r*w)*I,t[6]=(f*y-p*S-g*_)*I,t[7]=(c*S-d*y+u*_)*I,t[8]=(a*A-s*E+l*M)*I,t[9]=(n*E-e*A-r*M)*I,t[10]=(p*b-m*y+g*v)*I,t[11]=(h*y-c*b-u*v)*I,t[12]=(s*w-a*T-o*M)*I,t[13]=(e*T-n*w+i*M)*I,t[14]=(m*_-p*x-f*v)*I,t[15]=(c*x-h*_+d*v)*I,this}scale(t){const e=this.elements,n=t.x,i=t.y,r=t.z;return e[0]*=n,e[4]*=i,e[8]*=r,e[1]*=n,e[5]*=i,e[9]*=r,e[2]*=n,e[6]*=i,e[10]*=r,e[3]*=n,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),i=Math.sin(e),r=1-n,a=t.x,s=t.y,o=t.z,l=r*a,c=r*s;return this.set(l*a+n,l*s-i*o,l*o+i*s,0,l*s+i*o,c*s+n,c*o-i*a,0,l*o-i*s,c*o+i*a,r*o*o+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,r,a){return this.set(1,n,r,0,t,1,a,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){const i=this.elements,r=e._x,a=e._y,s=e._z,o=e._w,l=r+r,c=a+a,h=s+s,d=r*l,u=r*c,p=r*h,m=a*c,f=a*h,g=s*h,v=o*l,_=o*c,y=o*h,x=n.x,b=n.y,S=n.z;return i[0]=(1-(m+g))*x,i[1]=(u+y)*x,i[2]=(p-_)*x,i[3]=0,i[4]=(u-y)*b,i[5]=(1-(d+g))*b,i[6]=(f+v)*b,i[7]=0,i[8]=(p+_)*S,i[9]=(f-v)*S,i[10]=(1-(d+m))*S,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){const i=this.elements;t.x=i[12],t.y=i[13],t.z=i[14];const r=this.determinant();if(0===r)return n.set(1,1,1),e.identity(),this;let a=Qi.set(i[0],i[1],i[2]).length();const s=Qi.set(i[4],i[5],i[6]).length(),o=Qi.set(i[8],i[9],i[10]).length();r<0&&(a=-a),tr.copy(this);const l=1/a,c=1/s,h=1/o;return tr.elements[0]*=l,tr.elements[1]*=l,tr.elements[2]*=l,tr.elements[4]*=c,tr.elements[5]*=c,tr.elements[6]*=c,tr.elements[8]*=h,tr.elements[9]*=h,tr.elements[10]*=h,e.setFromRotationMatrix(tr),n.x=a,n.y=s,n.z=o,this}makePerspective(t,e,n,i,r,a,s=2e3,o=!1){const l=this.elements,c=2*r/(e-t),h=2*r/(n-i),d=(e+t)/(e-t),u=(n+i)/(n-i);let p,m;if(o)p=r/(a-r),m=a*r/(a-r);else if(s===ei)p=-(a+r)/(a-r),m=-2*a*r/(a-r);else{if(s!==ni)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+s);p=-a/(a-r),m=-a*r/(a-r)}return l[0]=c,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=h,l[9]=u,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,n,i,r,a,s=2e3,o=!1){const l=this.elements,c=2/(e-t),h=2/(n-i),d=-(e+t)/(e-t),u=-(n+i)/(n-i);let p,m;if(o)p=1/(a-r),m=a/(a-r);else if(s===ei)p=-2/(a-r),m=-(a+r)/(a-r);else{if(s!==ni)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+s);p=-1/(a-r),m=-r/(a-r)}return l[0]=c,l[4]=0,l[8]=0,l[12]=d,l[1]=0,l[5]=h,l[9]=0,l[13]=u,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,n=t.elements;for(let t=0;t<16;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const Qi=new Ci,tr=new Ki,er=new Ci(0,0,0),nr=new Ci(1,1,1),ir=new Ci,rr=new Ci,ar=new Ci,sr=new Ki,or=new Ai;class lr{constructor(t=0,e=0,n=0,i=lr.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const i=t.elements,r=i[0],a=i[4],s=i[8],o=i[1],l=i[5],c=i[9],h=i[2],d=i[6],u=i[10];switch(e){case"XYZ":this._y=Math.asin(xi(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-c,u),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-xi(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(s,u),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(xi(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,u),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-xi(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,u),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(xi(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(s,u));break;case"XZY":this._z=Math.asin(-xi(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(s,r)):(this._x=Math.atan2(-c,u),this._y=0);break;default:hi("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===n&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return sr.makeRotationFromQuaternion(t),this.setFromRotationMatrix(sr,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return or.setFromEuler(this),this.setFromQuaternion(or,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}lr.DEFAULT_ORDER="XYZ";class cr{constructor(){this.mask=1}set(t){this.mask=1<<t>>>0}enable(t){this.mask|=1<<t}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t}disable(t){this.mask&=~(1<<t)}disableAll(){this.mask=0}test(t){return 0!==(this.mask&t.mask)}isEnabled(t){return!!(this.mask&1<<t)}}let hr=0;const dr=new Ci,ur=new Ai,pr=new Ki,mr=new Ci,fr=new Ci,gr=new Ci,vr=new Ai,_r=new Ci(1,0,0),yr=new Ci(0,1,0),xr=new Ci(0,0,1),br={type:"added"},Sr={type:"removed"},Mr={type:"childadded",child:null},wr={type:"childremoved",child:null};class Er extends mi{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:hr++}),this.uuid=yi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Er.DEFAULT_UP.clone();const t=new Ci,e=new lr,n=new Ai,i=new Ci(1,1,1);e._onChange((function(){n.setFromEuler(e,!1)})),n._onChange((function(){e.setFromQuaternion(n,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Ki},normalMatrix:{value:new Pi}}),this.matrix=new Ki,this.matrixWorld=new Ki,this.matrixAutoUpdate=Er.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Er.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new cr,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 ur.setFromAxisAngle(t,e),this.quaternion.multiply(ur),this}rotateOnWorldAxis(t,e){return ur.setFromAxisAngle(t,e),this.quaternion.premultiply(ur),this}rotateX(t){return this.rotateOnAxis(_r,t)}rotateY(t){return this.rotateOnAxis(yr,t)}rotateZ(t){return this.rotateOnAxis(xr,t)}translateOnAxis(t,e){return dr.copy(t).applyQuaternion(this.quaternion),this.position.add(dr.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(_r,t)}translateY(t){return this.translateOnAxis(yr,t)}translateZ(t){return this.translateOnAxis(xr,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(pr.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?mr.copy(t):mr.set(t,e,n);const i=this.parent;this.updateWorldMatrix(!0,!1),fr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?pr.lookAt(fr,mr,this.up):pr.lookAt(mr,fr,this.up),this.quaternion.setFromRotationMatrix(pr),i&&(pr.extractRotation(i.matrixWorld),ur.setFromRotationMatrix(pr),this.quaternion.premultiply(ur.invert()))}add(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return t===this?(di("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(br),Mr.child=t,this.dispatchEvent(Mr),Mr.child=null):di("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.remove(arguments[t]);return this}const e=this.children.indexOf(t);return-1!==e&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Sr),wr.child=t,this.dispatchEvent(wr),wr.child=null),this}removeFromParent(){const t=this.parent;return null!==t&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),pr.copy(this.matrixWorld).invert(),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),pr.multiply(t.parent.matrixWorld)),t.applyMatrix4(pr),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(br),Mr.child=t,this.dispatchEvent(Mr),Mr.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,i=this.children.length;n<i;n++){const i=this.children[n].getObjectByProperty(t,e);if(void 0!==i)return i}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const i=this.children;for(let r=0,a=i.length;r<a;r++)i[r].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(fr,t,gr),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(fr,vr,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverse(t)}traverseVisible(t){if(!1===this.visible)return;t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;null!==e&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const t=this.pivot;if(null!==t){const e=t.x,n=t.y,i=t.z,r=this.matrix.elements;r[12]+=e-r[0]*e-r[4]*n-r[8]*i,r[13]+=n-r[1]*e-r[5]*n-r[9]*i,r[14]+=i-r[2]*e-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e){const n=this.parent;if(!0===t&&null!==n&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),!0===e){const t=this.children;for(let e=0,n=t.length;e<n;e++)t[e].updateWorldMatrix(!1,!0)}}toJSON(t){const e=void 0===t||"string"==typeof t,n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};function r(e,n){return void 0===e[n.uuid]&&(e[n.uuid]=n.toJSON(t)),n.uuid}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),!0===this.castShadow&&(i.castShadow=!0),!0===this.receiveShadow&&(i.receiveShadow=!0),!1===this.visible&&(i.visible=!1),!1===this.frustumCulled&&(i.frustumCulled=!1),0!==this.renderOrder&&(i.renderOrder=this.renderOrder),!1!==this.static&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),null!==this.pivot&&(i.pivot=this.pivot.toArray()),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),void 0!==this.morphTargetDictionary&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),void 0!==this.morphTargetInfluences&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map((t=>({...t,boundingBox:t.boundingBox?t.boundingBox.toJSON():void 0,boundingSphere:t.boundingSphere?t.boundingSphere.toJSON():void 0}))),i.instanceInfo=this._instanceInfo.map((t=>({...t}))),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(t),i.indirectTexture=this._indirectTexture.toJSON(t),null!==this._colorsTexture&&(i.colorsTexture=this._colorsTexture.toJSON(t)),null!==this.boundingSphere&&(i.boundingSphere=this.boundingSphere.toJSON()),null!==this.boundingBox&&(i.boundingBox=this.boundingBox.toJSON())),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const n=e.shapes;if(Array.isArray(n))for(let e=0,i=n.length;e<i;e++){const i=n[e];r(t.shapes,i)}else r(t.shapes,n)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const e=[];for(let n=0,i=this.material.length;n<i;n++)e.push(r(t.materials,this.material[n]));i.material=e}else i.material=r(t.materials,this.material);if(this.children.length>0){i.children=[];for(let e=0;e<this.children.length;e++)i.children.push(this.children[e].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let e=0;e<this.animations.length;e++){const n=this.animations[e];i.animations.push(r(t.animations,n))}}if(e){const e=a(t.geometries),i=a(t.materials),r=a(t.textures),s=a(t.images),o=a(t.shapes),l=a(t.skeletons),c=a(t.animations),h=a(t.nodes);e.length>0&&(n.geometries=e),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),s.length>0&&(n.images=s),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c),h.length>0&&(n.nodes=h)}return n.object=i,n;function a(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.pivot=null!==t.pivot?t.pivot.clone():null,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)),!0===e)for(let e=0;e<t.children.length;e++){const n=t.children[e];this.add(n.clone())}return this}}Er.DEFAULT_UP=new Ci(0,1,0),Er.DEFAULT_MATRIX_AUTO_UPDATE=!0,Er.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Tr extends Er{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Ar={type:"move"};class Cr{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new Tr,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new Tr,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Ci,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Ci),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new Tr,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Ci,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Ci,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(t){return null!==this._targetRay&&this._targetRay.dispatchEvent(t),null!==this._grip&&this._grip.dispatchEvent(t),null!==this._hand&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(t,e,n){let i=null,r=null,a=null;const s=this._targetRay,o=this._grip,l=this._hand;if(t&&"visible-blurred"!==e.session.visibilityState){if(l&&t.hand){a=!0;for(const i of t.hand.values()){const t=e.getJointPose(i,n),r=this._getHandJoint(l,i);null!==t&&(r.matrix.fromArray(t.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.matrixWorldNeedsUpdate=!0,r.jointRadius=t.radius),r.visible=null!==t}const i=l.joints["index-finger-tip"],r=l.joints["thumb-tip"],s=i.position.distanceTo(r.position),o=.02,c=.005;l.inputState.pinching&&s>o+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&s<=o-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==o&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,o.eventsEnabled&&o.dispatchEvent({type:"gripUpdated",data:t,target:this})));null!==s&&(i=e.getPose(t.targetRaySpace,n),null===i&&null!==r&&(i=r),null!==i&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,this.dispatchEvent(Ar)))}return null!==s&&(s.visible=null!==i),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==a),this}_getHandJoint(t,e){if(void 0===t.joints[e.jointName]){const n=new Tr;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}const Rr={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},Ir={h:0,s:0,l:0},Pr={h:0,s:0,l:0};function Lr(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}class Dr{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(void 0===e&&void 0===n){const e=t;e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Bn){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,Ui.colorSpaceToWorking(this,e),this}setRGB(t,e,n,i=Ui.workingColorSpace){return this.r=t,this.g=e,this.b=n,Ui.colorSpaceToWorking(this,i),this}setHSL(t,e,n,i=Ui.workingColorSpace){if(t=bi(t,1),e=xi(e,0,1),n=xi(n,0,1),0===e)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+e):n+e-n*e,r=2*n-i;this.r=Lr(r,i,t+1/3),this.g=Lr(r,i,t),this.b=Lr(r,i,t-1/3)}return Ui.colorSpaceToWorking(this,i),this}setStyle(t,e=Bn){function n(e){void 0!==e&&parseFloat(e)<1&&hi("Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const a=i[1],s=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:hi("Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const n=i[1],r=n.length;if(3===r)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,e);if(6===r)return this.setHex(parseInt(n,16),e);hi("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Bn){const n=Rr[t.toLowerCase()];return void 0!==n?this.setHex(n,e):hi("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=Fi(t.r),this.g=Fi(t.g),this.b=Fi(t.b),this}copyLinearToSRGB(t){return this.r=zi(t.r),this.g=zi(t.g),this.b=zi(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Bn){return Ui.workingToColorSpace(Nr.copy(this),t),65536*Math.round(xi(255*Nr.r,0,255))+256*Math.round(xi(255*Nr.g,0,255))+Math.round(xi(255*Nr.b,0,255))}getHexString(t=Bn){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Ui.workingColorSpace){Ui.workingToColorSpace(Nr.copy(this),e);const n=Nr.r,i=Nr.g,r=Nr.b,a=Math.max(n,i,r),s=Math.min(n,i,r);let o,l;const c=(s+a)/2;if(s===a)o=0,l=0;else{const t=a-s;switch(l=c<=.5?t/(a+s):t/(2-a-s),a){case n:o=(i-r)/t+(i<r?6:0);break;case i:o=(r-n)/t+2;break;case r:o=(n-i)/t+4}o/=6}return t.h=o,t.s=l,t.l=c,t}getRGB(t,e=Ui.workingColorSpace){return Ui.workingToColorSpace(Nr.copy(this),e),t.r=Nr.r,t.g=Nr.g,t.b=Nr.b,t}getStyle(t=Bn){Ui.workingToColorSpace(Nr.copy(this),t);const e=Nr.r,n=Nr.g,i=Nr.b;return t!==Bn?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(255*e)},${Math.round(255*n)},${Math.round(255*i)})`}offsetHSL(t,e,n){return this.getHSL(Ir),this.setHSL(Ir.h+t,Ir.s+e,Ir.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(Ir),t.getHSL(Pr);const n=Si(Ir.h,Pr.h,e),i=Si(Ir.s,Pr.s,e),r=Si(Ir.l,Pr.l,e);return this.setHSL(n,i,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,i=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*i,this.g=r[1]*e+r[4]*n+r[7]*i,this.b=r[2]*e+r[5]*n+r[8]*i,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 Nr=new Dr;Dr.NAMES=Rr;class Or{constructor(t,e=25e-5){this.isFogExp2=!0,this.name="",this.color=new Dr(t),this.density=e}clone(){return new Or(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class Ur{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new Dr(t),this.near=e,this.far=n}clone(){return new Ur(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Fr extends Er{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new lr,this.environmentIntensity=1,this.environmentRotation=new lr,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return null!==this.fog&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}const zr=new Ci,kr=new Ci,Br=new Ci,Gr=new Ci,Vr=new Ci,Hr=new Ci,Wr=new Ci,jr=new Ci,Xr=new Ci,qr=new Ci,Yr=new qi,Zr=new qi,$r=new qi;class Jr{constructor(t=new Ci,e=new Ci,n=new Ci){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){i.subVectors(n,e),zr.subVectors(t,e),i.cross(zr);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(t,e,n,i,r){zr.subVectors(i,e),kr.subVectors(n,e),Br.subVectors(t,e);const a=zr.dot(zr),s=zr.dot(kr),o=zr.dot(Br),l=kr.dot(kr),c=kr.dot(Br),h=a*l-s*s;if(0===h)return r.set(0,0,0),null;const d=1/h,u=(l*o-s*c)*d,p=(a*c-s*o)*d;return r.set(1-u-p,p,u)}static containsPoint(t,e,n,i){return null!==this.getBarycoord(t,e,n,i,Gr)&&Gr.x>=0&&Gr.y>=0&&Gr.x+Gr.y<=1}static getInterpolation(t,e,n,i,r,a,s,o){return null===this.getBarycoord(t,e,n,i,Gr)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(r,Gr.x),o.addScaledVector(a,Gr.y),o.addScaledVector(s,Gr.z),o)}static getInterpolatedAttribute(t,e,n,i,r,a){return Yr.setScalar(0),Zr.setScalar(0),$r.setScalar(0),Yr.fromBufferAttribute(t,e),Zr.fromBufferAttribute(t,n),$r.fromBufferAttribute(t,i),a.setScalar(0),a.addScaledVector(Yr,r.x),a.addScaledVector(Zr,r.y),a.addScaledVector($r,r.z),a}static isFrontFacing(t,e,n,i){return zr.subVectors(n,e),kr.subVectors(t,e),zr.cross(kr).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),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 zr.subVectors(this.c,this.b),kr.subVectors(this.a,this.b),.5*zr.cross(kr).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Jr.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Jr.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,r){return Jr.getInterpolation(t,this.a,this.b,this.c,e,n,i,r)}containsPoint(t){return Jr.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Jr.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,i=this.b,r=this.c;let a,s;Vr.subVectors(i,n),Hr.subVectors(r,n),jr.subVectors(t,n);const o=Vr.dot(jr),l=Hr.dot(jr);if(o<=0&&l<=0)return e.copy(n);Xr.subVectors(t,i);const c=Vr.dot(Xr),h=Hr.dot(Xr);if(c>=0&&h<=c)return e.copy(i);const d=o*h-c*l;if(d<=0&&o>=0&&c<=0)return a=o/(o-c),e.copy(n).addScaledVector(Vr,a);qr.subVectors(t,r);const u=Vr.dot(qr),p=Hr.dot(qr);if(p>=0&&u<=p)return e.copy(r);const m=u*l-o*p;if(m<=0&&l>=0&&p<=0)return s=l/(l-p),e.copy(n).addScaledVector(Hr,s);const f=c*p-u*h;if(f<=0&&h-c>=0&&u-p>=0)return Wr.subVectors(r,i),s=(h-c)/(h-c+(u-p)),e.copy(i).addScaledVector(Wr,s);const g=1/(f+m+d);return a=m*g,s=d*g,e.copy(n).addScaledVector(Vr,a).addScaledVector(Hr,s)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}class Kr{constructor(t=new Ci(1/0,1/0,1/0),e=new Ci(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(ta.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(ta.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=ta.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(void 0!==n){const i=n.getAttribute("position");if(!0===e&&void 0!==i&&!0!==t.isInstancedMesh)for(let e=0,n=i.count;e<n;e++)!0===t.isMesh?t.getVertexPosition(e,ta):ta.fromBufferAttribute(i,e),ta.applyMatrix4(t.matrixWorld),this.expandByPoint(ta);else void 0!==t.boundingBox?(null===t.boundingBox&&t.computeBoundingBox(),ea.copy(t.boundingBox)):(null===n.boundingBox&&n.computeBoundingBox(),ea.copy(n.boundingBox)),ea.applyMatrix4(t.matrixWorld),this.union(ea)}const i=t.children;for(let t=0,n=i.length;t<n;t++)this.expandByObject(i[t],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,ta),ta.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(la),ca.subVectors(this.max,la),na.subVectors(t.a,la),ia.subVectors(t.b,la),ra.subVectors(t.c,la),aa.subVectors(ia,na),sa.subVectors(ra,ia),oa.subVectors(na,ra);let e=[0,-aa.z,aa.y,0,-sa.z,sa.y,0,-oa.z,oa.y,aa.z,0,-aa.x,sa.z,0,-sa.x,oa.z,0,-oa.x,-aa.y,aa.x,0,-sa.y,sa.x,0,-oa.y,oa.x,0];return!!ua(e,na,ia,ra,ca)&&(e=[1,0,0,0,1,0,0,0,1],!!ua(e,na,ia,ra,ca)&&(ha.crossVectors(aa,sa),e=[ha.x,ha.y,ha.z],ua(e,na,ia,ra,ca)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,ta).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(ta).length()),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(Qr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Qr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Qr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Qr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Qr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Qr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Qr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Qr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Qr)),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 Qr=[new Ci,new Ci,new Ci,new Ci,new Ci,new Ci,new Ci,new Ci],ta=new Ci,ea=new Kr,na=new Ci,ia=new Ci,ra=new Ci,aa=new Ci,sa=new Ci,oa=new Ci,la=new Ci,ca=new Ci,ha=new Ci,da=new Ci;function ua(t,e,n,i,r){for(let a=0,s=t.length-3;a<=s;a+=3){da.fromArray(t,a);const s=r.x*Math.abs(da.x)+r.y*Math.abs(da.y)+r.z*Math.abs(da.z),o=e.dot(da),l=n.dot(da),c=i.dot(da);if(Math.max(-Math.max(o,l,c),Math.min(o,l,c))>s)return!1}return!0}const pa=new Ci,ma=new Ti;let fa=0;class ga extends mi{constructor(t,e,n=!1){if(super(),Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:fa++}),this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=n,this.usage=Qn,this.updateRanges=[],this.gpuType=Ne,this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[t+i]=e.array[n+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(2===this.itemSize)for(let e=0,n=this.count;e<n;e++)ma.fromBufferAttribute(this,e),ma.applyMatrix3(t),this.setXY(e,ma.x,ma.y);else if(3===this.itemSize)for(let e=0,n=this.count;e<n;e++)pa.fromBufferAttribute(this,e),pa.applyMatrix3(t),this.setXYZ(e,pa.x,pa.y,pa.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)pa.fromBufferAttribute(this,e),pa.applyMatrix4(t),this.setXYZ(e,pa.x,pa.y,pa.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)pa.fromBufferAttribute(this,e),pa.applyNormalMatrix(t),this.setXYZ(e,pa.x,pa.y,pa.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)pa.fromBufferAttribute(this,e),pa.transformDirection(t),this.setXYZ(e,pa.x,pa.y,pa.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=Mi(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=wi(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Mi(e,this.array)),e}setX(t,e){return this.normalized&&(e=wi(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Mi(e,this.array)),e}setY(t,e){return this.normalized&&(e=wi(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=Mi(e,this.array)),e}setZ(t,e){return this.normalized&&(e=wi(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=Mi(e,this.array)),e}setW(t,e){return this.normalized&&(e=wi(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=wi(e,this.array),n=wi(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=wi(e,this.array),n=wi(n,this.array),i=wi(i,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t*=this.itemSize,this.normalized&&(e=wi(e,this.array),n=wi(n,this.array),i=wi(i,this.array),r=wi(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(t.name=this.name),this.usage!==Qn&&(t.usage=this.usage),t}dispose(){this.dispatchEvent({type:"dispose"})}}class va extends ga{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class _a extends ga{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class ya extends ga{constructor(t,e,n){super(new Float32Array(t),e,n)}}const xa=new Kr,ba=new Ci,Sa=new Ci;class Ma{constructor(t=new Ci,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;void 0!==e?n.copy(e):xa.setFromPoints(t).getCenter(n);let i=0;for(let e=0,r=t.length;e<r;e++)i=Math.max(i,n.distanceToSquared(t[e]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;ba.subVectors(t,this.center);const e=ba.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),n=.5*(t-this.radius);this.center.addScaledVector(ba,n/t),this.radius+=n}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):(Sa.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(ba.copy(t.center).add(Sa)),this.expandByPoint(ba.copy(t.center).sub(Sa))),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 wa=0;const Ea=new Ki,Ta=new Er,Aa=new Ci,Ca=new Kr,Ra=new Kr,Ia=new Ci;class Pa extends mi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:wa++}),this.uuid=yi(),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(function(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}(t)?_a:va)(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 void 0!==this.attributes[t]}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const e=(new Pi).getNormalMatrix(t);n.applyNormalMatrix(e),n.needsUpdate=!0}const i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(t),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(t){return Ea.makeRotationFromQuaternion(t),this.applyMatrix4(Ea),this}rotateX(t){return Ea.makeRotationX(t),this.applyMatrix4(Ea),this}rotateY(t){return Ea.makeRotationY(t),this.applyMatrix4(Ea),this}rotateZ(t){return Ea.makeRotationZ(t),this.applyMatrix4(Ea),this}translate(t,e,n){return Ea.makeTranslation(t,e,n),this.applyMatrix4(Ea),this}scale(t,e,n){return Ea.makeScale(t,e,n),this.applyMatrix4(Ea),this}lookAt(t){return Ta.lookAt(t),Ta.updateMatrix(),this.applyMatrix4(Ta.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Aa).negate(),this.translate(Aa.x,Aa.y,Aa.z),this}setFromPoints(t){const e=this.getAttribute("position");if(void 0===e){const e=[];for(let n=0,i=t.length;n<i;n++){const i=t[n];e.push(i.x,i.y,i.z||0)}this.setAttribute("position",new ya(e,3))}else{const n=Math.min(t.length,e.count);for(let i=0;i<n;i++){const n=t[i];e.setXYZ(i,n.x,n.y,n.z||0)}t.length>e.count&&hi("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Kr);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return di("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),void this.boundingBox.set(new Ci(-1/0,-1/0,-1/0),new Ci(1/0,1/0,1/0));if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t<n;t++){const n=e[t];Ca.setFromBufferAttribute(n),this.morphTargetsRelative?(Ia.addVectors(this.boundingBox.min,Ca.min),this.boundingBox.expandByPoint(Ia),Ia.addVectors(this.boundingBox.max,Ca.max),this.boundingBox.expandByPoint(Ia)):(this.boundingBox.expandByPoint(Ca.min),this.boundingBox.expandByPoint(Ca.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&di('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new Ma);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return di("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),void this.boundingSphere.set(new Ci,1/0);if(t){const n=this.boundingSphere.center;if(Ca.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t<n;t++){const n=e[t];Ra.setFromBufferAttribute(n),this.morphTargetsRelative?(Ia.addVectors(Ca.min,Ra.min),Ca.expandByPoint(Ia),Ia.addVectors(Ca.max,Ra.max),Ca.expandByPoint(Ia)):(Ca.expandByPoint(Ra.min),Ca.expandByPoint(Ra.max))}Ca.getCenter(n);let i=0;for(let e=0,r=t.count;e<r;e++)Ia.fromBufferAttribute(t,e),i=Math.max(i,n.distanceToSquared(Ia));if(e)for(let r=0,a=e.length;r<a;r++){const a=e[r],s=this.morphTargetsRelative;for(let e=0,r=a.count;e<r;e++)Ia.fromBufferAttribute(a,e),s&&(Aa.fromBufferAttribute(t,e),Ia.add(Aa)),i=Math.max(i,n.distanceToSquared(Ia))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&di('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(null===t||void 0===e.position||void 0===e.normal||void 0===e.uv)return void di("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const n=e.position,i=e.normal,r=e.uv;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new ga(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),s=[],o=[];for(let t=0;t<n.count;t++)s[t]=new Ci,o[t]=new Ci;const l=new Ci,c=new Ci,h=new Ci,d=new Ti,u=new Ti,p=new Ti,m=new Ci,f=new Ci;function g(t,e,i){l.fromBufferAttribute(n,t),c.fromBufferAttribute(n,e),h.fromBufferAttribute(n,i),d.fromBufferAttribute(r,t),u.fromBufferAttribute(r,e),p.fromBufferAttribute(r,i),c.sub(l),h.sub(l),u.sub(d),p.sub(d);const a=1/(u.x*p.y-p.x*u.y);isFinite(a)&&(m.copy(c).multiplyScalar(p.y).addScaledVector(h,-u.y).multiplyScalar(a),f.copy(h).multiplyScalar(u.x).addScaledVector(c,-p.x).multiplyScalar(a),s[t].add(m),s[e].add(m),s[i].add(m),o[t].add(f),o[e].add(f),o[i].add(f))}let v=this.groups;0===v.length&&(v=[{start:0,count:t.count}]);for(let e=0,n=v.length;e<n;++e){const n=v[e],i=n.start;for(let e=i,r=i+n.count;e<r;e+=3)g(t.getX(e+0),t.getX(e+1),t.getX(e+2))}const _=new Ci,y=new Ci,x=new Ci,b=new Ci;function S(t){x.fromBufferAttribute(i,t),b.copy(x);const e=s[t];_.copy(e),_.sub(x.multiplyScalar(x.dot(e))).normalize(),y.crossVectors(b,e);const n=y.dot(o[t])<0?-1:1;a.setXYZW(t,_.x,_.y,_.z,n)}for(let e=0,n=v.length;e<n;++e){const n=v[e],i=n.start;for(let e=i,r=i+n.count;e<r;e+=3)S(t.getX(e+0)),S(t.getX(e+1)),S(t.getX(e+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(void 0!==e){let n=this.getAttribute("normal");if(void 0===n)n=new ga(new Float32Array(3*e.count),3),this.setAttribute("normal",n);else for(let t=0,e=n.count;t<e;t++)n.setXYZ(t,0,0,0);const i=new Ci,r=new Ci,a=new Ci,s=new Ci,o=new Ci,l=new Ci,c=new Ci,h=new Ci;if(t)for(let d=0,u=t.count;d<u;d+=3){const u=t.getX(d+0),p=t.getX(d+1),m=t.getX(d+2);i.fromBufferAttribute(e,u),r.fromBufferAttribute(e,p),a.fromBufferAttribute(e,m),c.subVectors(a,r),h.subVectors(i,r),c.cross(h),s.fromBufferAttribute(n,u),o.fromBufferAttribute(n,p),l.fromBufferAttribute(n,m),s.add(c),o.add(c),l.add(c),n.setXYZ(u,s.x,s.y,s.z),n.setXYZ(p,o.x,o.y,o.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let t=0,s=e.count;t<s;t+=3)i.fromBufferAttribute(e,t+0),r.fromBufferAttribute(e,t+1),a.fromBufferAttribute(e,t+2),c.subVectors(a,r),h.subVectors(i,r),c.cross(h),n.setXYZ(t+0,c.x,c.y,c.z),n.setXYZ(t+1,c.x,c.y,c.z),n.setXYZ(t+2,c.x,c.y,c.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)Ia.fromBufferAttribute(t,e),Ia.normalize(),t.setXYZ(e,Ia.x,Ia.y,Ia.z)}toNonIndexed(){function t(t,e){const n=t.array,i=t.itemSize,r=t.normalized,a=new n.constructor(e.length*i);let s=0,o=0;for(let r=0,l=e.length;r<l;r++){s=t.isInterleavedBufferAttribute?e[r]*t.data.stride+t.offset:e[r]*i;for(let t=0;t<i;t++)a[o++]=n[s++]}return new ga(a,i,r)}if(null===this.index)return hi("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new Pa,n=this.index.array,i=this.attributes;for(const r in i){const a=t(i[r],n);e.setAttribute(r,a)}const r=this.morphAttributes;for(const i in r){const a=[],s=r[i];for(let e=0,i=s.length;e<i;e++){const i=t(s[e],n);a.push(i)}e.morphAttributes[i]=a}e.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let t=0,n=a.length;t<n;t++){const n=a[t];e.addGroup(n.start,n.count,n.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),void 0!==this.parameters){const e=this.parameters;for(const n in e)void 0!==e[n]&&(t[n]=e[n]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const e in n){const i=n[e];t.data.attributes[e]=i.toJSON(t.data)}const i={};let r=!1;for(const e in this.morphAttributes){const n=this.morphAttributes[e],a=[];for(let e=0,i=n.length;e<i;e++){const i=n[e];a.push(i.toJSON(t.data))}a.length>0&&(i[e]=a,r=!0)}r&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const s=this.boundingSphere;return null!==s&&(t.data.boundingSphere=s.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 n=t.index;null!==n&&this.setIndex(n.clone());const i=t.attributes;for(const t in i){const n=i[t];this.setAttribute(t,n.clone(e))}const r=t.morphAttributes;for(const t in r){const n=[],i=r[t];for(let t=0,r=i.length;t<r;t++)n.push(i[t].clone(e));this.morphAttributes[t]=n}this.morphTargetsRelative=t.morphTargetsRelative;const a=t.groups;for(let t=0,e=a.length;t<e;t++){const e=a[t];this.addGroup(e.start,e.count,e.materialIndex)}const s=t.boundingBox;null!==s&&(this.boundingBox=s.clone());const o=t.boundingSphere;return null!==o&&(this.boundingSphere=o.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}class La{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=Qn,this.updateRanges=[],this.version=0,this.uuid=yi()}onUploadCallback(){}set needsUpdate(t){!0===t&&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.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,r=this.stride;i<r;i++)this.array[t+i]=e.array[n+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=yi()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=yi()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Da=new Ci;class Na{constructor(t,e,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)Da.fromBufferAttribute(this,e),Da.applyMatrix4(t),this.setXYZ(e,Da.x,Da.y,Da.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Da.fromBufferAttribute(this,e),Da.applyNormalMatrix(t),this.setXYZ(e,Da.x,Da.y,Da.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Da.fromBufferAttribute(this,e),Da.transformDirection(t),this.setXYZ(e,Da.x,Da.y,Da.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(n=Mi(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=wi(n,this.array)),this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){return this.normalized&&(e=wi(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=wi(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=wi(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=wi(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Mi(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Mi(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Mi(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Mi(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=wi(e,this.array),n=wi(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=wi(e,this.array),n=wi(n,this.array),i=wi(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=wi(e,this.array),n=wi(n,this.array),i=wi(i,this.array),r=wi(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this.data.array[t+3]=r,this}clone(t){if(void 0===t){li("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const n=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[n+e])}return new ga(new this.array.constructor(t),this.itemSize,this.normalized)}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Na(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(void 0===t){li("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const n=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[n+e])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let Oa,Ua=0;class Fa extends mi{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Ua++}),this.uuid=yi(),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=Pt,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Dr(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=Wn,this.stencilZFail=Wn,this.stencilZPass=Wn,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(void 0!==t)for(const e in t){const n=t[e];if(void 0===n){hi(`Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n:hi(`Material: '${e}' is not a property of THREE.${this.type}.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};function i(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),void 0!==this.dispersion&&(n.dispersion=this.dispersion),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapRotation&&(n.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),0!==this.side&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),204!==this.blendSrc&&(n.blendSrc=this.blendSrc),205!==this.blendDst&&(n.blendDst=this.blendDst),this.blendEquation!==Pt&&(n.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(n.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(n.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(n.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(n.depthFunc=this.depthFunc),!1===this.depthTest&&(n.depthTest=this.depthTest),!1===this.depthWrite&&(n.depthWrite=this.depthWrite),!1===this.colorWrite&&(n.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(n.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(n.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(n.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Wn&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Wn&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Wn&&(n.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(n.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=!0),!0===this.alphaToCoverage&&(n.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=!0),!0===this.forceSinglePass&&(n.forceSinglePass=!0),!1===this.allowOverride&&(n.allowOverride=!1),!0===this.wireframe&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),e){const e=i(t.textures),r=i(t.images);e.length>0&&(n.textures=e),r.length>0&&(n.images=r)}return n}clone(){return(new this.constructor).copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(null!==e){const t=e.length;n=new Array(t);for(let i=0;i!==t;++i)n[i]=e[i].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.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){!0===t&&this.version++}}class za extends Fa{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Dr(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}const ka=new Ci,Ba=new Ci,Ga=new Ci,Va=new Ti,Ha=new Ti,Wa=new Ki,ja=new Ci,Xa=new Ci,qa=new Ci,Ya=new Ti,Za=new Ti,$a=new Ti;class Ja extends Er{constructor(t=new za){if(super(),this.isSprite=!0,this.type="Sprite",void 0===Oa){Oa=new Pa;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),e=new La(t,5);Oa.setIndex([0,1,2,0,2,3]),Oa.setAttribute("position",new Na(e,3,0,!1)),Oa.setAttribute("uv",new Na(e,2,3,!1))}this.geometry=Oa,this.material=t,this.center=new Ti(.5,.5),this.count=1}raycast(t,e){null===t.camera&&di('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Ba.setFromMatrixScale(this.matrixWorld),Wa.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),Ga.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&Ba.multiplyScalar(-Ga.z);const n=this.material.rotation;let i,r;0!==n&&(r=Math.cos(n),i=Math.sin(n));const a=this.center;Ka(ja.set(-.5,-.5,0),Ga,a,Ba,i,r),Ka(Xa.set(.5,-.5,0),Ga,a,Ba,i,r),Ka(qa.set(.5,.5,0),Ga,a,Ba,i,r),Ya.set(0,0),Za.set(1,0),$a.set(1,1);let s=t.ray.intersectTriangle(ja,Xa,qa,!1,ka);if(null===s&&(Ka(Xa.set(-.5,.5,0),Ga,a,Ba,i,r),Za.set(0,1),s=t.ray.intersectTriangle(ja,qa,Xa,!1,ka),null===s))return;const o=t.ray.origin.distanceTo(ka);o<t.near||o>t.far||e.push({distance:o,point:ka.clone(),uv:Jr.getInterpolation(ka,ja,Xa,qa,Ya,Za,$a,new Ti),face:null,object:this})}copy(t,e){return super.copy(t,e),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}}function Ka(t,e,n,i,r,a){Va.subVectors(t,n).addScalar(.5).multiply(i),void 0!==r?(Ha.x=a*Va.x-r*Va.y,Ha.y=r*Va.x+a*Va.y):Ha.copy(Va),t.copy(e),t.x+=Ha.x,t.y+=Ha.y,t.applyMatrix4(Wa)}const Qa=new Ci,ts=new Ci;class es extends Er{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const e=t.levels;for(let t=0,n=e.length;t<n;t++){const n=e[t];this.addLevel(n.object.clone(),n.distance,n.hysteresis)}return this.autoUpdate=t.autoUpdate,this}addLevel(t,e=0,n=0){e=Math.abs(e);const i=this.levels;let r;for(r=0;r<i.length&&!(e<i[r].distance);r++);return i.splice(r,0,{distance:e,hysteresis:n,object:t}),this.add(t),this}removeLevel(t){const e=this.levels;for(let n=0;n<e.length;n++)if(e[n].distance===t){const t=e.splice(n,1);return this.remove(t[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(t){const e=this.levels;if(e.length>0){let n,i;for(n=1,i=e.length;n<i;n++){let i=e[n].distance;if(e[n].object.visible&&(i-=i*e[n].hysteresis),t<i)break}return e[n-1].object}return null}raycast(t,e){if(this.levels.length>0){Qa.setFromMatrixPosition(this.matrixWorld);const n=t.ray.origin.distanceTo(Qa);this.getObjectForDistance(n).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){Qa.setFromMatrixPosition(t.matrixWorld),ts.setFromMatrixPosition(this.matrixWorld);const n=Qa.distanceTo(ts)/t.zoom;let i,r;for(e[0].object.visible=!0,i=1,r=e.length;i<r;i++){let t=e[i].distance;if(e[i].object.visible&&(t-=t*e[i].hysteresis),!(n>=t))break;e[i-1].object.visible=!1,e[i].object.visible=!0}for(this._currentLevel=i-1;i<r;i++)e[i].object.visible=!1}}toJSON(t){const e=super.toJSON(t);!1===this.autoUpdate&&(e.object.autoUpdate=!1),e.object.levels=[];const n=this.levels;for(let t=0,i=n.length;t<i;t++){const i=n[t];e.object.levels.push({object:i.object.uuid,distance:i.distance,hysteresis:i.hysteresis})}return e}}const ns=new Ci,is=new Ci,rs=new Ci,as=new Ci,ss=new Ci,os=new Ci,ls=new Ci;class cs{constructor(t=new Ci,e=new Ci(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,ns)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=ns.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(ns.copy(this.origin).addScaledVector(this.direction,e),ns.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){is.copy(t).add(e).multiplyScalar(.5),rs.copy(e).sub(t).normalize(),as.copy(this.origin).sub(is);const r=.5*t.distanceTo(e),a=-this.direction.dot(rs),s=as.dot(this.direction),o=-as.dot(rs),l=as.lengthSq(),c=Math.abs(1-a*a);let h,d,u,p;if(c>0)if(h=a*o-s,d=a*s-o,p=r*c,h>=0)if(d>=-p)if(d<=p){const t=1/c;h*=t,d*=t,u=h*(h+a*d+2*s)+d*(a*h+d+2*o)+l}else d=r,h=Math.max(0,-(a*d+s)),u=-h*h+d*(d+2*o)+l;else d=-r,h=Math.max(0,-(a*d+s)),u=-h*h+d*(d+2*o)+l;else d<=-p?(h=Math.max(0,-(-a*r+s)),d=h>0?-r:Math.min(Math.max(-r,-o),r),u=-h*h+d*(d+2*o)+l):d<=p?(h=0,d=Math.min(Math.max(-r,-o),r),u=d*(d+2*o)+l):(h=Math.max(0,-(a*r+s)),d=h>0?r:Math.min(Math.max(-r,-o),r),u=-h*h+d*(d+2*o)+l);else d=a>0?-r:r,h=Math.max(0,-(a*d+s)),u=-h*h+d*(d+2*o)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(is).addScaledVector(rs,d),u}intersectSphere(t,e){ns.subVectors(t.center,this.origin);const n=ns.dot(this.direction),i=ns.dot(ns)-n*n,r=t.radius*t.radius;if(i>r)return null;const a=Math.sqrt(r-i),s=n-a,o=n+a;return o<0?null:s<0?this.at(o,e):this.at(s,e)}intersectsSphere(t){return!(t.radius<0)&&this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return null===n?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,r,a,s,o;const l=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,d=this.origin;return l>=0?(n=(t.min.x-d.x)*l,i=(t.max.x-d.x)*l):(n=(t.max.x-d.x)*l,i=(t.min.x-d.x)*l),c>=0?(r=(t.min.y-d.y)*c,a=(t.max.y-d.y)*c):(r=(t.max.y-d.y)*c,a=(t.min.y-d.y)*c),n>a||r>i?null:((r>n||isNaN(n))&&(n=r),(a<i||isNaN(i))&&(i=a),h>=0?(s=(t.min.z-d.z)*h,o=(t.max.z-d.z)*h):(s=(t.max.z-d.z)*h,o=(t.min.z-d.z)*h),n>o||s>i?null:((s>n||n!=n)&&(n=s),(o<i||i!=i)&&(i=o),i<0?null:this.at(n>=0?n:i,e)))}intersectsBox(t){return null!==this.intersectBox(t,ns)}intersectTriangle(t,e,n,i,r){ss.subVectors(e,t),os.subVectors(n,t),ls.crossVectors(ss,os);let a,s=this.direction.dot(ls);if(s>0){if(i)return null;a=1}else{if(!(s<0))return null;a=-1,s=-s}as.subVectors(this.origin,t);const o=a*this.direction.dot(os.crossVectors(as,os));if(o<0)return null;const l=a*this.direction.dot(ss.cross(as));if(l<0)return null;if(o+l>s)return null;const c=-a*as.dot(ls);return c<0?null:this.at(c/s,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class hs extends Fa{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Dr(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 lr,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 ds=new Ki,us=new cs,ps=new Ma,ms=new Ci,fs=new Ci,gs=new Ci,vs=new Ci,_s=new Ci,ys=new Ci,xs=new Ci,bs=new Ci;class Ss extends Er{constructor(t=new Pa,e=new hs){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),void 0!==t.morphTargetInfluences&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}getVertexPosition(t,e){const n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;e.fromBufferAttribute(i,t);const s=this.morphTargetInfluences;if(r&&s){ys.set(0,0,0);for(let n=0,i=r.length;n<i;n++){const i=s[n],o=r[n];0!==i&&(_s.fromBufferAttribute(o,t),a?ys.addScaledVector(_s,i):ys.addScaledVector(_s.sub(e),i))}e.add(ys)}return e}raycast(t,e){const n=this.geometry,i=this.material,r=this.matrixWorld;if(void 0!==i){if(null===n.boundingSphere&&n.computeBoundingSphere(),ps.copy(n.boundingSphere),ps.applyMatrix4(r),us.copy(t.ray).recast(t.near),!1===ps.containsPoint(us.origin)){if(null===us.intersectSphere(ps,ms))return;if(us.origin.distanceToSquared(ms)>(t.far-t.near)**2)return}ds.copy(r).invert(),us.copy(t.ray).applyMatrix4(ds),null!==n.boundingBox&&!1===us.intersectsBox(n.boundingBox)||this._computeIntersections(t,e,us)}}_computeIntersections(t,e,n){let i;const r=this.geometry,a=this.material,s=r.index,o=r.attributes.position,l=r.attributes.uv,c=r.attributes.uv1,h=r.attributes.normal,d=r.groups,u=r.drawRange;if(null!==s)if(Array.isArray(a))for(let r=0,o=d.length;r<o;r++){const o=d[r],p=a[o.materialIndex];for(let r=Math.max(o.start,u.start),a=Math.min(s.count,Math.min(o.start+o.count,u.start+u.count));r<a;r+=3)i=Ms(this,p,t,n,l,c,h,s.getX(r),s.getX(r+1),s.getX(r+2)),i&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=o.materialIndex,e.push(i))}else for(let r=Math.max(0,u.start),o=Math.min(s.count,u.start+u.count);r<o;r+=3)i=Ms(this,a,t,n,l,c,h,s.getX(r),s.getX(r+1),s.getX(r+2)),i&&(i.faceIndex=Math.floor(r/3),e.push(i));else if(void 0!==o)if(Array.isArray(a))for(let r=0,s=d.length;r<s;r++){const s=d[r],p=a[s.materialIndex];for(let r=Math.max(s.start,u.start),a=Math.min(o.count,Math.min(s.start+s.count,u.start+u.count));r<a;r+=3)i=Ms(this,p,t,n,l,c,h,r,r+1,r+2),i&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=s.materialIndex,e.push(i))}else for(let r=Math.max(0,u.start),s=Math.min(o.count,u.start+u.count);r<s;r+=3)i=Ms(this,a,t,n,l,c,h,r,r+1,r+2),i&&(i.faceIndex=Math.floor(r/3),e.push(i))}}function Ms(t,e,n,i,r,a,s,o,l,c){t.getVertexPosition(o,fs),t.getVertexPosition(l,gs),t.getVertexPosition(c,vs);const h=function(t,e,n,i,r,a,s,o){let l;if(l=1===e.side?i.intersectTriangle(s,a,r,!0,o):i.intersectTriangle(r,a,s,0===e.side,o),null===l)return null;bs.copy(o),bs.applyMatrix4(t.matrixWorld);const c=n.ray.origin.distanceTo(bs);return c<n.near||c>n.far?null:{distance:c,point:bs.clone(),object:t}}(t,e,n,i,fs,gs,vs,xs);if(h){const t=new Ci;Jr.getBarycoord(xs,fs,gs,vs,t),r&&(h.uv=Jr.getInterpolatedAttribute(r,o,l,c,t,new Ti)),a&&(h.uv1=Jr.getInterpolatedAttribute(a,o,l,c,t,new Ti)),s&&(h.normal=Jr.getInterpolatedAttribute(s,o,l,c,t,new Ci),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const e={a:o,b:l,c,normal:new Ci,materialIndex:0};Jr.getNormal(fs,gs,vs,e.normal),h.face=e,h.barycoord=t}return h}const ws=new qi,Es=new qi,Ts=new qi,As=new qi,Cs=new Ki,Rs=new Ci,Is=new Ma,Ps=new Ki,Ls=new cs;class Ds extends Ss{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=pe,this.bindMatrix=new Ki,this.bindMatrixInverse=new Ki,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;null===this.boundingBox&&(this.boundingBox=new Kr),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let t=0;t<e.count;t++)this.getVertexPosition(t,Rs),this.boundingBox.expandByPoint(Rs)}computeBoundingSphere(){const t=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new Ma),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let t=0;t<e.count;t++)this.getVertexPosition(t,Rs),this.boundingSphere.expandByPoint(Rs)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){const n=this.material,i=this.matrixWorld;void 0!==n&&(null===this.boundingSphere&&this.computeBoundingSphere(),Is.copy(this.boundingSphere),Is.applyMatrix4(i),!1!==t.ray.intersectsSphere(Is)&&(Ps.copy(i).invert(),Ls.copy(t.ray).applyMatrix4(Ps),null!==this.boundingBox&&!1===Ls.intersectsBox(this.boundingBox)||this._computeIntersections(t,e,Ls)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,void 0===e&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const t=new qi,e=this.geometry.attributes.skinWeight;for(let n=0,i=e.count;n<i;n++){t.fromBufferAttribute(e,n);const i=1/t.manhattanLength();i!==1/0?t.multiplyScalar(i):t.set(1,0,0,0),e.setXYZW(n,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===pe?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():hi("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){const n=this.skeleton,i=this.geometry;Es.fromBufferAttribute(i.attributes.skinIndex,t),Ts.fromBufferAttribute(i.attributes.skinWeight,t),e.isVector4?(ws.copy(e),e.set(0,0,0,0)):(ws.set(...e,1),e.set(0,0,0)),ws.applyMatrix4(this.bindMatrix);for(let t=0;t<4;t++){const i=Ts.getComponent(t);if(0!==i){const r=Es.getComponent(t);Cs.multiplyMatrices(n.bones[r].matrixWorld,n.boneInverses[r]),e.addScaledVector(As.copy(ws).applyMatrix4(Cs),i)}}return e.isVector4&&(e.w=ws.w),e.applyMatrix4(this.bindMatrixInverse)}}class Ns extends Er{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Os extends Xi{constructor(t=null,e=1,n=1,i,r,a,s,o,l=1003,c=1003,h,d){super(null,a,s,o,l,c,i,r,h,d),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Us=new Ki,Fs=new Ki;class zs{constructor(t=[],e=[]){this.uuid=yi(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.previousBoneMatrices=null,this.boneTexture=null,this.init()}init(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(16*t.length),0===e.length)this.calculateInverses();else if(t.length!==e.length){hi("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let t=0,e=this.bones.length;t<e;t++)this.boneInverses.push(new Ki)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const e=new Ki;this.bones[t]&&e.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(e)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&e.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&(e.parent&&e.parent.isBone?(e.matrix.copy(e.parent.matrixWorld).invert(),e.matrix.multiply(e.matrixWorld)):e.matrix.copy(e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale))}}update(){const t=this.bones,e=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let i=0,r=t.length;i<r;i++){const r=t[i]?t[i].matrixWorld:Fs;Us.multiplyMatrices(r,e[i]),Us.toArray(n,16*i)}null!==i&&(i.needsUpdate=!0)}clone(){return new zs(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(4*this.bones.length);t=4*Math.ceil(t/4),t=Math.max(t,4);const e=new Float32Array(t*t*4);e.set(this.boneMatrices);const n=new Os(e,t,t,Ge,Ne);return n.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=n,this}getBoneByName(t){for(let e=0,n=this.bones.length;e<n;e++){const n=this.bones[e];if(n.name===t)return n}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let n=0,i=t.bones.length;n<i;n++){const i=t.bones[n];let r=e[i];void 0===r&&(hi("Skeleton: No bone found with UUID:",i),r=new Ns),this.bones.push(r),this.boneInverses.push((new Ki).fromArray(t.boneInverses[n]))}return this.init(),this}toJSON(){const t={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,n=this.boneInverses;for(let i=0,r=e.length;i<r;i++){const r=e[i];t.bones.push(r.uuid);const a=n[i];t.boneInverses.push(a.toArray())}return t}}class ks extends ga{constructor(t,e,n,i=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}const Bs=new Ki,Gs=new Ki,Vs=[],Hs=new Kr,Ws=new Ki,js=new Ss,Xs=new Ma;class qs extends Ss{constructor(t,e,n){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new ks(new Float32Array(16*n),16),this.previousInstanceMatrix=null,this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let t=0;t<n;t++)this.setMatrixAt(t,Ws)}computeBoundingBox(){const t=this.geometry,e=this.count;null===this.boundingBox&&(this.boundingBox=new Kr),null===t.boundingBox&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,Bs),Hs.copy(t.boundingBox).applyMatrix4(Bs),this.boundingBox.union(Hs)}computeBoundingSphere(){const t=this.geometry,e=this.count;null===this.boundingSphere&&(this.boundingSphere=new Ma),null===t.boundingSphere&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,Bs),Xs.copy(t.boundingSphere).applyMatrix4(Bs),this.boundingSphere.union(Xs)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),null!==t.previousInstanceMatrix&&(this.previousInstanceMatrix=t.previousInstanceMatrix.clone()),null!==t.morphTexture&&(this.morphTexture=t.morphTexture.clone()),null!==t.instanceColor&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){return null===this.instanceColor?e.setRGB(1,1,1):e.fromArray(this.instanceColor.array,3*t)}getMatrixAt(t,e){return e.fromArray(this.instanceMatrix.array,16*t)}getMorphAt(t,e){const n=e.morphTargetInfluences,i=this.morphTexture.source.data.data,r=t*(n.length+1)+1;for(let t=0;t<n.length;t++)n[t]=i[r+t]}raycast(t,e){const n=this.matrixWorld,i=this.count;if(js.geometry=this.geometry,js.material=this.material,void 0!==js.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),Xs.copy(this.boundingSphere),Xs.applyMatrix4(n),!1!==t.ray.intersectsSphere(Xs)))for(let r=0;r<i;r++){this.getMatrixAt(r,Bs),Gs.multiplyMatrices(n,Bs),js.matrixWorld=Gs,js.raycast(t,Vs);for(let t=0,n=Vs.length;t<n;t++){const n=Vs[t];n.instanceId=r,n.object=this,e.push(n)}Vs.length=0}}setColorAt(t,e){return null===this.instanceColor&&(this.instanceColor=new ks(new Float32Array(3*this.instanceMatrix.count).fill(1),3)),e.toArray(this.instanceColor.array,3*t),this}setMatrixAt(t,e){return e.toArray(this.instanceMatrix.array,16*t),this}setMorphAt(t,e){const n=e.morphTargetInfluences,i=n.length+1;null===this.morphTexture&&(this.morphTexture=new Os(new Float32Array(i*this.count),i,this.count,We,Ne));const r=this.morphTexture.source.data.data;let a=0;for(let t=0;t<n.length;t++)a+=n[t];const s=this.geometry.morphTargetsRelative?1:1-a,o=i*t;return r[o]=s,r.set(n,o+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),null!==this.morphTexture&&(this.morphTexture.dispose(),this.morphTexture=null)}}const Ys=new Ci,Zs=new Ci,$s=new Pi;class Js{constructor(t=new Ci(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const i=Ys.subVectors(n,e).cross(Zs.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e,n=!0){const i=t.delta(Ys),r=this.normal.dot(i);if(0===r)return 0===this.distanceToPoint(t.start)?e.copy(t.start):null;const a=-(t.start.dot(this.normal)+this.constant)/r;return!0===n&&(a<0||a>1)?null:e.copy(t.start).addScaledVector(i,a)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||$s.getNormalMatrix(t),i=this.coplanarPoint(Ys).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const Ks=new Ma,Qs=new Ti(.5,.5),to=new Ci;class eo{constructor(t=new Js,e=new Js,n=new Js,i=new Js,r=new Js,a=new Js){this.planes=[t,e,n,i,r,a]}set(t,e,n,i,r,a){const s=this.planes;return s[0].copy(t),s[1].copy(e),s[2].copy(n),s[3].copy(i),s[4].copy(r),s[5].copy(a),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=2e3,n=!1){const i=this.planes,r=t.elements,a=r[0],s=r[1],o=r[2],l=r[3],c=r[4],h=r[5],d=r[6],u=r[7],p=r[8],m=r[9],f=r[10],g=r[11],v=r[12],_=r[13],y=r[14],x=r[15];if(i[0].setComponents(l-a,u-c,g-p,x-v).normalize(),i[1].setComponents(l+a,u+c,g+p,x+v).normalize(),i[2].setComponents(l+s,u+h,g+m,x+_).normalize(),i[3].setComponents(l-s,u-h,g-m,x-_).normalize(),n)i[4].setComponents(o,d,f,y).normalize(),i[5].setComponents(l-o,u-d,g-f,x-y).normalize();else if(i[4].setComponents(l-o,u-d,g-f,x-y).normalize(),e===ei)i[5].setComponents(l+o,u+d,g+f,x+y).normalize();else{if(e!==ni)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);i[5].setComponents(o,d,f,y).normalize()}return this}intersectsObject(t){if(void 0!==t.boundingSphere)null===t.boundingSphere&&t.computeBoundingSphere(),Ks.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;null===e.boundingSphere&&e.computeBoundingSphere(),Ks.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Ks)}intersectsSprite(t){Ks.center.set(0,0,0);const e=Qs.distanceTo(t.center);return Ks.radius=.7071067811865476+e,Ks.applyMatrix4(t.matrixWorld),this.intersectsSphere(Ks)}intersectsSphere(t){const e=this.planes,n=t.center,i=-t.radius;for(let t=0;t<6;t++)if(e[t].distanceToPoint(n)<i)return!1;return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const i=e[n];if(to.x=i.normal.x>0?t.max.x:t.min.x,to.y=i.normal.y>0?t.max.y:t.min.y,to.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(to)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}const no=new Ki,io=new eo;class ro{constructor(){this.coordinateSystem=ei}intersectsObject(t,e){if(!e.isArrayCamera||0===e.cameras.length)return!1;for(let n=0;n<e.cameras.length;n++){const i=e.cameras[n];if(no.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),io.setFromProjectionMatrix(no,i.coordinateSystem,i.reversedDepth),io.intersectsObject(t))return!0}return!1}intersectsSprite(t,e){if(!e||!e.cameras||0===e.cameras.length)return!1;for(let n=0;n<e.cameras.length;n++){const i=e.cameras[n];if(no.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),io.setFromProjectionMatrix(no,i.coordinateSystem,i.reversedDepth),io.intersectsSprite(t))return!0}return!1}intersectsSphere(t,e){if(!e||!e.cameras||0===e.cameras.length)return!1;for(let n=0;n<e.cameras.length;n++){const i=e.cameras[n];if(no.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),io.setFromProjectionMatrix(no,i.coordinateSystem,i.reversedDepth),io.intersectsSphere(t))return!0}return!1}intersectsBox(t,e){if(!e||!e.cameras||0===e.cameras.length)return!1;for(let n=0;n<e.cameras.length;n++){const i=e.cameras[n];if(no.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),io.setFromProjectionMatrix(no,i.coordinateSystem,i.reversedDepth),io.intersectsBox(t))return!0}return!1}containsPoint(t,e){if(!e||!e.cameras||0===e.cameras.length)return!1;for(let n=0;n<e.cameras.length;n++){const i=e.cameras[n];if(no.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),io.setFromProjectionMatrix(no,i.coordinateSystem,i.reversedDepth),io.containsPoint(t))return!0}return!1}clone(){return new ro}}function ao(t,e){return t-e}function so(t,e){return t.z-e.z}function oo(t,e){return e.z-t.z}class lo{constructor(){this.index=0,this.pool=[],this.list=[]}push(t,e,n,i){const r=this.pool,a=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const s=r[this.index];a.push(s),this.index++,s.start=t,s.count=e,s.z=n,s.index=i}reset(){this.list.length=0,this.index=0}}const co=new Ki,ho=new Dr(1,1,1),uo=new eo,po=new ro,mo=new Kr,fo=new Ma,go=new Ci,vo=new Ci,_o=new Ci,yo=new lo,xo=new Ss,bo=[];function So(t,e,n=0){const i=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const r=t.count;for(let a=0;a<r;a++)for(let r=0;r<i;r++)e.setComponent(a+n,r,t.getComponent(a,r))}else e.array.set(t.array,n*i);e.needsUpdate=!0}function Mo(t,e){if(t.constructor!==e.constructor){const n=Math.min(t.length,e.length);for(let i=0;i<n;i++)e[i]=t[i]}else{const n=Math.min(t.length,e.length);e.set(new t.constructor(t.buffer,0,n))}}class wo extends Ss{constructor(t,e,n=2*e,i){super(new Pa,i),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=t,this._maxVertexCount=e,this._maxIndexCount=n,this._multiDrawCounts=new Int32Array(t),this._multiDrawStarts=new Int32Array(t),this._multiDrawCount=0,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}_initMatricesTexture(){let t=Math.sqrt(4*this._maxInstanceCount);t=4*Math.ceil(t/4),t=Math.max(t,4);const e=new Float32Array(t*t*4),n=new Os(e,t,t,Ge,Ne);this._matricesTexture=n}_initIndirectTexture(){let t=Math.sqrt(this._maxInstanceCount);t=Math.ceil(t);const e=new Uint32Array(t*t),n=new Os(e,t,t,je,De);this._indirectTexture=n}_initColorsTexture(){let t=Math.sqrt(this._maxInstanceCount);t=Math.ceil(t);const e=new Float32Array(t*t*4).fill(1),n=new Os(e,t,t,Ge,Ne);n.colorSpace=Ui.workingColorSpace,this._colorsTexture=n}_initializeGeometry(t){const e=this.geometry,n=this._maxVertexCount,i=this._maxIndexCount;if(!1===this._geometryInitialized){for(const i in t.attributes){const r=t.getAttribute(i),{array:a,itemSize:s,normalized:o}=r,l=new a.constructor(n*s),c=new ga(l,s,o);e.setAttribute(i,c)}if(null!==t.getIndex()){const t=n>65535?new Uint32Array(i):new Uint16Array(i);e.setIndex(new ga(t,1))}this._geometryInitialized=!0}}_validateGeometry(t){const e=this.geometry;if(Boolean(t.getIndex())!==Boolean(e.getIndex()))throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const n in e.attributes){if(!t.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const i=t.getAttribute(n),r=e.getAttribute(n);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(t){const e=this._instanceInfo;if(t<0||t>=e.length||!1===e[t].active)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${t}. Instance is either out of range or has been deleted.`)}validateGeometryId(t){const e=this._geometryInfo;if(t<0||t>=e.length||!1===e[t].active)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${t}. Geometry is either out of range or has been deleted.`)}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Kr);const t=this.boundingBox,e=this._instanceInfo;t.makeEmpty();for(let n=0,i=e.length;n<i;n++){if(!1===e[n].active)continue;const i=e[n].geometryIndex;this.getMatrixAt(n,co),this.getBoundingBoxAt(i,mo).applyMatrix4(co),t.union(mo)}}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new Ma);const t=this.boundingSphere,e=this._instanceInfo;t.makeEmpty();for(let n=0,i=e.length;n<i;n++){if(!1===e[n].active)continue;const i=e[n].geometryIndex;this.getMatrixAt(n,co),this.getBoundingSphereAt(i,fo).applyMatrix4(co),t.union(fo)}}addInstance(t){if(this._instanceInfo.length>=this.maxInstanceCount&&0===this._availableInstanceIds.length)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const e={visible:!0,active:!0,geometryIndex:t};let n=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(ao),n=this._availableInstanceIds.shift(),this._instanceInfo[n]=e):(n=this._instanceInfo.length,this._instanceInfo.push(e));const i=this._matricesTexture;co.identity().toArray(i.image.data,16*n),i.needsUpdate=!0;const r=this._colorsTexture;return r&&(ho.toArray(r.image.data,4*n),r.needsUpdate=!0),this._visibilityChanged=!0,n}addGeometry(t,e=-1,n=-1){this._initializeGeometry(t),this._validateGeometry(t);const i={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},r=this._geometryInfo;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=-1===e?t.getAttribute("position").count:e;const a=t.getIndex();if(null!==a&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=-1===n?a.count:n),-1!==i.indexStart&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let s;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(ao),s=this._availableGeometryIds.shift(),r[s]=i):(s=this._geometryCount,this._geometryCount++,r.push(i)),this.setGeometryAt(s,t),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,s}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);const n=this.geometry,i=null!==n.getIndex(),r=n.getIndex(),a=e.getIndex(),s=this._geometryInfo[t];if(i&&a.count>s.reservedIndexCount||e.attributes.position.count>s.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const o=s.vertexStart,l=s.reservedVertexCount;s.vertexCount=e.getAttribute("position").count;for(const t in n.attributes){const i=e.getAttribute(t),r=n.getAttribute(t);So(i,r,o);const a=i.itemSize;for(let t=i.count,e=l;t<e;t++){const e=o+t;for(let t=0;t<a;t++)r.setComponent(e,t,0)}r.needsUpdate=!0,r.addUpdateRange(o*a,l*a)}if(i){const t=s.indexStart,n=s.reservedIndexCount;s.indexCount=e.getIndex().count;for(let e=0;e<a.count;e++)r.setX(t+e,o+a.getX(e));for(let e=a.count,i=n;e<i;e++)r.setX(t+e,o);r.needsUpdate=!0,r.addUpdateRange(t,s.reservedIndexCount)}return s.start=i?s.indexStart:s.vertexStart,s.count=i?s.indexCount:s.vertexCount,s.boundingBox=null,null!==e.boundingBox&&(s.boundingBox=e.boundingBox.clone()),s.boundingSphere=null,null!==e.boundingSphere&&(s.boundingSphere=e.boundingSphere.clone()),this._visibilityChanged=!0,t}deleteGeometry(t){const e=this._geometryInfo;if(t>=e.length||!1===e[t].active)return this;const n=this._instanceInfo;for(let e=0,i=n.length;e<i;e++)n[e].active&&n[e].geometryIndex===t&&this.deleteInstance(e);return e[t].active=!1,this._availableGeometryIds.push(t),this._visibilityChanged=!0,this}deleteInstance(t){return this.validateInstanceId(t),this._instanceInfo[t].active=!1,this._availableInstanceIds.push(t),this._visibilityChanged=!0,this}optimize(){let t=0,e=0;const n=this._geometryInfo,i=n.map(((t,e)=>e)).sort(((t,e)=>n[t].vertexStart-n[e].vertexStart)),r=this.geometry;for(let a=0,s=n.length;a<s;a++){const s=i[a],o=n[s];if(!1!==o.active){if(null!==r.index){if(o.indexStart!==e){const{indexStart:n,vertexStart:i,reservedIndexCount:a}=o,s=r.index,l=s.array,c=t-i;for(let t=n;t<n+a;t++)l[t]=l[t]+c;s.array.copyWithin(e,n,n+a),s.addUpdateRange(e,a),s.needsUpdate=!0,o.indexStart=e}e+=o.reservedIndexCount}if(o.vertexStart!==t){const{vertexStart:e,reservedVertexCount:n}=o,i=r.attributes;for(const r in i){const a=i[r],{array:s,itemSize:o}=a;s.copyWithin(t*o,e*o,(e+n)*o),a.addUpdateRange(t*o,n*o),a.needsUpdate=!0}o.vertexStart=t}t+=o.reservedVertexCount,o.start=r.index?o.indexStart:o.vertexStart}}return this._nextIndexStart=e,this._nextVertexStart=t,this._visibilityChanged=!0,this}getBoundingBoxAt(t,e){if(t>=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[t];if(null===i.boundingBox){const t=new Kr,e=n.index,r=n.attributes.position;for(let n=i.start,a=i.start+i.count;n<a;n++){let i=n;e&&(i=e.getX(i)),t.expandByPoint(go.fromBufferAttribute(r,i))}i.boundingBox=t}return e.copy(i.boundingBox),e}getBoundingSphereAt(t,e){if(t>=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[t];if(null===i.boundingSphere){const e=new Ma;this.getBoundingBoxAt(t,mo),mo.getCenter(e.center);const r=n.index,a=n.attributes.position;let s=0;for(let t=i.start,n=i.start+i.count;t<n;t++){let n=t;r&&(n=r.getX(n)),go.fromBufferAttribute(a,n),s=Math.max(s,e.center.distanceToSquared(go))}e.radius=Math.sqrt(s),i.boundingSphere=e}return e.copy(i.boundingSphere),e}setMatrixAt(t,e){this.validateInstanceId(t);const n=this._matricesTexture,i=this._matricesTexture.image.data;return e.toArray(i,16*t),n.needsUpdate=!0,this}getMatrixAt(t,e){return this.validateInstanceId(t),e.fromArray(this._matricesTexture.image.data,16*t)}setColorAt(t,e){return this.validateInstanceId(t),null===this._colorsTexture&&this._initColorsTexture(),e.toArray(this._colorsTexture.image.data,4*t),this._colorsTexture.needsUpdate=!0,this}getColorAt(t,e){return this.validateInstanceId(t),null===this._colorsTexture?e.isVector4?e.set(1,1,1,1):e.setRGB(1,1,1):e.fromArray(this._colorsTexture.image.data,4*t)}setVisibleAt(t,e){return this.validateInstanceId(t),this._instanceInfo[t].visible===e||(this._instanceInfo[t].visible=e,this._visibilityChanged=!0),this}getVisibleAt(t){return this.validateInstanceId(t),this._instanceInfo[t].visible}setGeometryIdAt(t,e){return this.validateInstanceId(t),this.validateGeometryId(e),this._instanceInfo[t].geometryIndex=e,this}getGeometryIdAt(t){return this.validateInstanceId(t),this._instanceInfo[t].geometryIndex}getGeometryRangeAt(t,e={}){this.validateGeometryId(t);const n=this._geometryInfo[t];return e.vertexStart=n.vertexStart,e.vertexCount=n.vertexCount,e.reservedVertexCount=n.reservedVertexCount,e.indexStart=n.indexStart,e.indexCount=n.indexCount,e.reservedIndexCount=n.reservedIndexCount,e.start=n.start,e.count=n.count,e}setInstanceCount(t){const e=this._availableInstanceIds,n=this._instanceInfo;for(e.sort(ao);e[e.length-1]===n.length-1;)n.pop(),e.pop();if(t<n.length)throw new Error(`BatchedMesh: Instance ids outside the range ${t} are being used. Cannot shrink instance count.`);const i=new Int32Array(t),r=new Int32Array(t);Mo(this._multiDrawCounts,i),Mo(this._multiDrawStarts,r),this._multiDrawCounts=i,this._multiDrawStarts=r,this._maxInstanceCount=t;const a=this._indirectTexture,s=this._matricesTexture,o=this._colorsTexture;a.dispose(),this._initIndirectTexture(),Mo(a.image.data,this._indirectTexture.image.data),s.dispose(),this._initMatricesTexture(),Mo(s.image.data,this._matricesTexture.image.data),o&&(o.dispose(),this._initColorsTexture(),Mo(o.image.data,this._colorsTexture.image.data))}setGeometrySize(t,e){const n=[...this._geometryInfo].filter((t=>t.active));if(Math.max(...n.map((t=>t.vertexStart+t.reservedVertexCount)))>t)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${e}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map((t=>t.indexStart+t.reservedIndexCount)))>e)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${e}. Cannot shrink further.`);const i=this.geometry;i.dispose(),this._maxVertexCount=t,this._maxIndexCount=e,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Pa,this._initializeGeometry(i));const r=this.geometry;i.index&&Mo(i.index.array,r.index.array);for(const t in i.attributes)Mo(i.attributes[t].array,r.attributes[t].array)}raycast(t,e){const n=this._instanceInfo,i=this._geometryInfo,r=this.matrixWorld,a=this.geometry;xo.material=this.material,xo.geometry.index=a.index,xo.geometry.attributes=a.attributes,null===xo.geometry.boundingBox&&(xo.geometry.boundingBox=new Kr),null===xo.geometry.boundingSphere&&(xo.geometry.boundingSphere=new Ma);for(let a=0,s=n.length;a<s;a++){if(!n[a].visible||!n[a].active)continue;const s=n[a].geometryIndex,o=i[s];xo.geometry.setDrawRange(o.start,o.count),this.getMatrixAt(a,xo.matrixWorld).premultiply(r),this.getBoundingBoxAt(s,xo.geometry.boundingBox),this.getBoundingSphereAt(s,xo.geometry.boundingSphere),xo.raycast(t,bo);for(let t=0,n=bo.length;t<n;t++){const n=bo[t];n.object=this,n.batchId=a,e.push(n)}bo.length=0}xo.material=null,xo.geometry.index=null,xo.geometry.attributes={},xo.geometry.setDrawRange(0,1/0)}copy(t){return super.copy(t),this.geometry=t.geometry.clone(),this.perObjectFrustumCulled=t.perObjectFrustumCulled,this.sortObjects=t.sortObjects,this.boundingBox=null!==t.boundingBox?t.boundingBox.clone():null,this.boundingSphere=null!==t.boundingSphere?t.boundingSphere.clone():null,this._geometryInfo=t._geometryInfo.map((t=>({...t,boundingBox:null!==t.boundingBox?t.boundingBox.clone():null,boundingSphere:null!==t.boundingSphere?t.boundingSphere.clone():null}))),this._instanceInfo=t._instanceInfo.map((t=>({...t}))),this._availableInstanceIds=t._availableInstanceIds.slice(),this._availableGeometryIds=t._availableGeometryIds.slice(),this._nextIndexStart=t._nextIndexStart,this._nextVertexStart=t._nextVertexStart,this._geometryCount=t._geometryCount,this._maxInstanceCount=t._maxInstanceCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._indirectTexture=t._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),null!==this._colorsTexture&&(this._colorsTexture=t._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,null!==this._colorsTexture&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(t,e,n,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=i.getIndex();let s=null===a?1:a.array.BYTES_PER_ELEMENT,o=1;r.wireframe&&(o=2,s=i.attributes.position.count>65535?4:2);const l=this._instanceInfo,c=this._multiDrawStarts,h=this._multiDrawCounts,d=this._geometryInfo,u=this.perObjectFrustumCulled,p=this._indirectTexture,m=p.image.data,f=n.isArrayCamera?po:uo;u&&!n.isArrayCamera&&(co.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),uo.setFromProjectionMatrix(co,n.coordinateSystem,n.reversedDepth));let g=0;if(this.sortObjects){co.copy(this.matrixWorld).invert(),go.setFromMatrixPosition(n.matrixWorld).applyMatrix4(co),vo.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(co);for(let t=0,e=l.length;t<e;t++)if(l[t].visible&&l[t].active){const e=l[t].geometryIndex;this.getMatrixAt(t,co),this.getBoundingSphereAt(e,fo).applyMatrix4(co);let i=!1;if(u&&(i=!f.intersectsSphere(fo,n)),!i){const n=d[e],i=_o.subVectors(fo.center,go).dot(vo);yo.push(n.start,n.count,i,t)}}const t=yo.list,e=this.customSort;null===e?t.sort(r.transparent?oo:so):e.call(this,t,n);for(let e=0,n=t.length;e<n;e++){const n=t[e];c[g]=n.start*s*o,h[g]=n.count*o,m[g]=n.index,g++}yo.reset()}else for(let t=0,e=l.length;t<e;t++)if(l[t].visible&&l[t].active){const e=l[t].geometryIndex;let i=!1;if(u&&(this.getMatrixAt(t,co),this.getBoundingSphereAt(e,fo).applyMatrix4(co),i=!f.intersectsSphere(fo,n)),!i){const n=d[e];c[g]=n.start*s*o,h[g]=n.count*o,m[g]=t,g++}}p.needsUpdate=!0,this._multiDrawCount=g,this._visibilityChanged=!1}onBeforeShadow(t,e,n,i,r,a){this.onBeforeRender(t,null,i,r,a)}}class Eo extends Fa{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Dr(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const To=new Ci,Ao=new Ci,Co=new Ki,Ro=new cs,Io=new Ma,Po=new Ci,Lo=new Ci;class Do extends Er{constructor(t=new Pa,e=new Eo){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,n=[0];for(let t=1,i=e.count;t<i;t++)To.fromBufferAttribute(e,t-1),Ao.fromBufferAttribute(e,t),n[t]=n[t-1],n[t]+=To.distanceTo(Ao);t.setAttribute("lineDistance",new ya(n,1))}else hi("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,r=t.params.Line.threshold,a=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),Io.copy(n.boundingSphere),Io.applyMatrix4(i),Io.radius+=r,!1===t.ray.intersectsSphere(Io))return;Co.copy(i).invert(),Ro.copy(t.ray).applyMatrix4(Co);const s=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=s*s,l=this.isLineSegments?2:1,c=n.index,h=n.attributes.position;if(null!==c){const n=Math.max(0,a.start),i=Math.min(c.count,a.start+a.count);for(let r=n,a=i-1;r<a;r+=l){const n=c.getX(r),i=c.getX(r+1),a=No(this,t,Ro,o,n,i,r);a&&e.push(a)}if(this.isLineLoop){const r=c.getX(i-1),a=c.getX(n),s=No(this,t,Ro,o,r,a,i-1);s&&e.push(s)}}else{const n=Math.max(0,a.start),i=Math.min(h.count,a.start+a.count);for(let r=n,a=i-1;r<a;r+=l){const n=No(this,t,Ro,o,r,r+1,r);n&&e.push(n)}if(this.isLineLoop){const r=No(this,t,Ro,o,i-1,n,i-1);r&&e.push(r)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}}function No(t,e,n,i,r,a,s){const o=t.geometry.attributes.position;if(To.fromBufferAttribute(o,r),Ao.fromBufferAttribute(o,a),n.distanceSqToSegment(To,Ao,Po,Lo)>i)return;Po.applyMatrix4(t.matrixWorld);const l=e.ray.origin.distanceTo(Po);return l<e.near||l>e.far?void 0:{distance:l,point:Lo.clone().applyMatrix4(t.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:t}}const Oo=new Ci,Uo=new Ci;class Fo extends Do{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,n=[];for(let t=0,i=e.count;t<i;t+=2)Oo.fromBufferAttribute(e,t),Uo.fromBufferAttribute(e,t+1),n[t]=0===t?0:n[t-1],n[t+1]=n[t]+Oo.distanceTo(Uo);t.setAttribute("lineDistance",new ya(n,1))}else hi("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class zo extends Do{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}}class ko extends Fa{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Dr(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}const Bo=new Ki,Go=new cs,Vo=new Ma,Ho=new Ci;class Wo extends Er{constructor(t=new Pa,e=new ko){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,r=t.params.Points.threshold,a=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),Vo.copy(n.boundingSphere),Vo.applyMatrix4(i),Vo.radius+=r,!1===t.ray.intersectsSphere(Vo))return;Bo.copy(i).invert(),Go.copy(t.ray).applyMatrix4(Bo);const s=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=s*s,l=n.index,c=n.attributes.position;if(null!==l)for(let n=Math.max(0,a.start),r=Math.min(l.count,a.start+a.count);n<r;n++){const r=l.getX(n);Ho.fromBufferAttribute(c,r),jo(Ho,r,o,i,t,e,this)}else for(let n=Math.max(0,a.start),r=Math.min(c.count,a.start+a.count);n<r;n++)Ho.fromBufferAttribute(c,n),jo(Ho,n,o,i,t,e,this)}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}}function jo(t,e,n,i,r,a,s){const o=Go.distanceSqToPoint(t);if(o<n){const n=new Ci;Go.closestPointToPoint(t,n),n.applyMatrix4(i);const l=r.ray.origin.distanceTo(n);if(l<r.near||l>r.far)return;a.push({distance:l,distanceToRay:Math.sqrt(o),point:n,index:e,face:null,faceIndex:null,barycoord:null,object:s})}}class Xo extends Xi{constructor(t=[],e=301,n,i,r,a,s,o,l,c){super(t,e,n,i,r,a,s,o,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class qo extends Xi{constructor(t,e,n=1014,i,r,a,s=1003,o=1003,l,c=1026,h=1){if(c!==Ve&&c!==He)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super({width:t,height:e,depth:h},i,r,a,s,o,c,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new Vi(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return null!==this.compareFunction&&(e.compareFunction=this.compareFunction),e}}class Yo extends qo{constructor(t,e=1014,n=301,i,r,a=1003,s=1003,o,l=1026){const c={width:t,height:t,depth:1},h=[c,c,c,c,c,c];super(t,t,e,n,i,r,a,s,o,l),this.image=h,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}}class Zo extends Xi{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}}class $o extends Pa{constructor(t=1,e=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};const s=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);const o=[],l=[],c=[],h=[];let d=0,u=0;function p(t,e,n,i,r,a,p,m,f,g,v){const _=a/f,y=p/g,x=a/2,b=p/2,S=m/2,M=f+1,w=g+1;let E=0,T=0;const A=new Ci;for(let a=0;a<w;a++){const s=a*y-b;for(let o=0;o<M;o++){const d=o*_-x;A[t]=d*i,A[e]=s*r,A[n]=S,l.push(A.x,A.y,A.z),A[t]=0,A[e]=0,A[n]=m>0?1:-1,c.push(A.x,A.y,A.z),h.push(o/f),h.push(1-a/g),E+=1}}for(let t=0;t<g;t++)for(let e=0;e<f;e++){const n=d+e+M*t,i=d+e+M*(t+1),r=d+(e+1)+M*(t+1),a=d+(e+1)+M*t;o.push(n,i,a),o.push(i,r,a),T+=6}s.addGroup(u,T,v),u+=T,d+=E}p("z","y","x",-1,-1,n,e,t,a,r,0),p("z","y","x",1,-1,n,e,-t,a,r,1),p("x","z","y",1,1,t,n,e,i,a,2),p("x","z","y",1,-1,t,n,-e,i,a,3),p("x","y","z",1,-1,t,e,n,i,r,4),p("x","y","z",-1,-1,t,e,-n,i,r,5),this.setIndex(o),this.setAttribute("position",new ya(l,3)),this.setAttribute("normal",new ya(c,3)),this.setAttribute("uv",new ya(h,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new $o(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class Jo extends Pa{constructor(t=1,e=1,n=4,i=8,r=1){super(),this.type="CapsuleGeometry",this.parameters={radius:t,height:e,capSegments:n,radialSegments:i,heightSegments:r},e=Math.max(0,e),n=Math.max(1,Math.floor(n)),i=Math.max(3,Math.floor(i)),r=Math.max(1,Math.floor(r));const a=[],s=[],o=[],l=[],c=e/2,h=Math.PI/2*t,d=e,u=2*h+d,p=2*n+r,m=i+1,f=new Ci,g=new Ci;for(let v=0;v<=p;v++){let _=0,y=0,x=0,b=0;if(v<=n){const e=v/n,i=e*Math.PI/2;y=-c-t*Math.cos(i),x=t*Math.sin(i),b=-t*Math.cos(i),_=e*h}else if(v<=n+r){const i=(v-n)/r;y=i*e-c,x=t,b=0,_=h+i*d}else{const e=(v-n-r)/n,i=e*Math.PI/2;y=c+t*Math.sin(i),x=t*Math.cos(i),b=t*Math.sin(i),_=h+d+e*h}const S=Math.max(0,Math.min(1,_/u));let M=0;0===v?M=.5/i:v===p&&(M=-.5/i);for(let t=0;t<=i;t++){const e=t/i,n=e*Math.PI*2,r=Math.sin(n),a=Math.cos(n);g.x=-x*a,g.y=y,g.z=x*r,s.push(g.x,g.y,g.z),f.set(-x*a,b,x*r),f.normalize(),o.push(f.x,f.y,f.z),l.push(e+M,S)}if(v>0){const t=(v-1)*m;for(let e=0;e<i;e++){const n=t+e,i=t+e+1,r=v*m+e,s=v*m+e+1;a.push(n,i,r),a.push(i,s,r)}}}this.setIndex(a),this.setAttribute("position",new ya(s,3)),this.setAttribute("normal",new ya(o,3)),this.setAttribute("uv",new ya(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Jo(t.radius,t.height,t.capSegments,t.radialSegments,t.heightSegments)}}class Ko extends Pa{constructor(t=1,e=32,n=0,i=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:i},e=Math.max(3,e);const r=[],a=[],s=[],o=[],l=new Ci,c=new Ti;a.push(0,0,0),s.push(0,0,1),o.push(.5,.5);for(let r=0,h=3;r<=e;r++,h+=3){const d=n+r/e*i;l.x=t*Math.cos(d),l.y=t*Math.sin(d),a.push(l.x,l.y,l.z),s.push(0,0,1),c.x=(a[h]/t+1)/2,c.y=(a[h+1]/t+1)/2,o.push(c.x,c.y)}for(let t=1;t<=e;t++)r.push(t,t+1,0);this.setIndex(r),this.setAttribute("position",new ya(a,3)),this.setAttribute("normal",new ya(s,3)),this.setAttribute("uv",new ya(o,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ko(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class Qo extends Pa{constructor(t=1,e=1,n=1,i=32,r=1,a=!1,s=0,o=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:r,openEnded:a,thetaStart:s,thetaLength:o};const l=this;i=Math.floor(i),r=Math.floor(r);const c=[],h=[],d=[],u=[];let p=0;const m=[],f=n/2;let g=0;function v(n){const r=p,a=new Ti,m=new Ci;let v=0;const _=!0===n?t:e,y=!0===n?1:-1;for(let t=1;t<=i;t++)h.push(0,f*y,0),d.push(0,y,0),u.push(.5,.5),p++;const x=p;for(let t=0;t<=i;t++){const e=t/i*o+s,n=Math.cos(e),r=Math.sin(e);m.x=_*r,m.y=f*y,m.z=_*n,h.push(m.x,m.y,m.z),d.push(0,y,0),a.x=.5*n+.5,a.y=.5*r*y+.5,u.push(a.x,a.y),p++}for(let t=0;t<i;t++){const e=r+t,i=x+t;!0===n?c.push(i,i+1,e):c.push(i+1,i,e),v+=3}l.addGroup(g,v,!0===n?1:2),g+=v}!function(){const a=new Ci,v=new Ci;let _=0;const y=(e-t)/n;for(let l=0;l<=r;l++){const c=[],g=l/r,_=g*(e-t)+t;for(let t=0;t<=i;t++){const e=t/i,r=e*o+s,l=Math.sin(r),m=Math.cos(r);v.x=_*l,v.y=-g*n+f,v.z=_*m,h.push(v.x,v.y,v.z),a.set(l,y,m).normalize(),d.push(a.x,a.y,a.z),u.push(e,1-g),c.push(p++)}m.push(c)}for(let n=0;n<i;n++)for(let i=0;i<r;i++){const a=m[i][n],s=m[i+1][n],o=m[i+1][n+1],l=m[i][n+1];(t>0||0!==i)&&(c.push(a,s,l),_+=3),(e>0||i!==r-1)&&(c.push(s,o,l),_+=3)}l.addGroup(g,_,0),g+=_}(),!1===a&&(t>0&&v(!0),e>0&&v(!1)),this.setIndex(c),this.setAttribute("position",new ya(h,3)),this.setAttribute("normal",new ya(d,3)),this.setAttribute("uv",new ya(u,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Qo(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class tl extends Qo{constructor(t=1,e=1,n=32,i=1,r=!1,a=0,s=2*Math.PI){super(0,t,e,n,i,r,a,s),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:a,thetaLength:s}}static fromJSON(t){return new tl(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class el extends Pa{constructor(t=[],e=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:i};const r=[],a=[];function s(t,e,n,i){const r=i+1,a=[];for(let i=0;i<=r;i++){a[i]=[];const s=t.clone().lerp(n,i/r),o=e.clone().lerp(n,i/r),l=r-i;for(let t=0;t<=l;t++)a[i][t]=0===t&&i===r?s:s.clone().lerp(o,t/l)}for(let t=0;t<r;t++)for(let e=0;e<2*(r-t)-1;e++){const n=Math.floor(e/2);e%2==0?(o(a[t][n+1]),o(a[t+1][n]),o(a[t][n])):(o(a[t][n+1]),o(a[t+1][n+1]),o(a[t+1][n]))}}function o(t){r.push(t.x,t.y,t.z)}function l(e,n){const i=3*e;n.x=t[i+0],n.y=t[i+1],n.z=t[i+2]}function c(t,e,n,i){i<0&&1===t.x&&(a[e]=t.x-1),0===n.x&&0===n.z&&(a[e]=i/2/Math.PI+.5)}function h(t){return Math.atan2(t.z,-t.x)}!function(t){const n=new Ci,i=new Ci,r=new Ci;for(let a=0;a<e.length;a+=3)l(e[a+0],n),l(e[a+1],i),l(e[a+2],r),s(n,i,r,t)}(i),function(t){const e=new Ci;for(let n=0;n<r.length;n+=3)e.x=r[n+0],e.y=r[n+1],e.z=r[n+2],e.normalize().multiplyScalar(t),r[n+0]=e.x,r[n+1]=e.y,r[n+2]=e.z}(n),function(){const t=new Ci;for(let n=0;n<r.length;n+=3){t.x=r[n+0],t.y=r[n+1],t.z=r[n+2];const i=h(t)/2/Math.PI+.5,s=(e=t,Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))/Math.PI+.5);a.push(i,1-s)}var e;(function(){const t=new Ci,e=new Ci,n=new Ci,i=new Ci,s=new Ti,o=new Ti,l=new Ti;for(let d=0,u=0;d<r.length;d+=9,u+=6){t.set(r[d+0],r[d+1],r[d+2]),e.set(r[d+3],r[d+4],r[d+5]),n.set(r[d+6],r[d+7],r[d+8]),s.set(a[u+0],a[u+1]),o.set(a[u+2],a[u+3]),l.set(a[u+4],a[u+5]),i.copy(t).add(e).add(n).divideScalar(3);const p=h(i);c(s,u+0,t,p),c(o,u+2,e,p),c(l,u+4,n,p)}})(),function(){for(let t=0;t<a.length;t+=6){const e=a[t+0],n=a[t+2],i=a[t+4],r=Math.max(e,n,i),s=Math.min(e,n,i);r>.9&&s<.1&&(e<.2&&(a[t+0]+=1),n<.2&&(a[t+2]+=1),i<.2&&(a[t+4]+=1))}}()}(),this.setAttribute("position",new ya(r,3)),this.setAttribute("normal",new ya(r.slice(),3)),this.setAttribute("uv",new ya(a,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new el(t.vertices,t.indices,t.radius,t.detail)}}class nl extends el{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2,i=1/n;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new nl(t.radius,t.detail)}}const il=new Ci,rl=new Ci,al=new Ci,sl=new Jr;class ol{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){hi("Curve: .getPoint() not implemented.")}getPointAt(t,e){const n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let n,i=this.getPoint(0),r=0;e.push(0);for(let a=1;a<=t;a++)n=this.getPoint(a/t),r+=n.distanceTo(i),e.push(r),i=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e=null){const n=this.getLengths();let i=0;const r=n.length;let a;a=e||t*n[r-1];let s,o=0,l=r-1;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),s=n[i]-a,s<0)o=i+1;else{if(!(s>0)){l=i;break}l=i-1}if(i=l,n[i]===a)return i/(r-1);const c=n[i];return(i+(a-c)/(n[i+1]-c))/(r-1)}getTangent(t,e){const n=1e-4;let i=t-n,r=t+n;i<0&&(i=0),r>1&&(r=1);const a=this.getPoint(i),s=this.getPoint(r),o=e||(a.isVector2?new Ti:new Ci);return o.copy(s).sub(a).normalize(),o}getTangentAt(t,e){const n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e=!1){const n=new Ci,i=[],r=[],a=[],s=new Ci,o=new Ki;for(let e=0;e<=t;e++){const n=e/t;i[e]=this.getTangentAt(n,new Ci)}r[0]=new Ci,a[0]=new Ci;let l=Number.MAX_VALUE;const c=Math.abs(i[0].x),h=Math.abs(i[0].y),d=Math.abs(i[0].z);c<=l&&(l=c,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),d<=l&&n.set(0,0,1),s.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],s),a[0].crossVectors(i[0],r[0]);for(let e=1;e<=t;e++){if(r[e]=r[e-1].clone(),a[e]=a[e-1].clone(),s.crossVectors(i[e-1],i[e]),s.length()>Number.EPSILON){s.normalize();const t=Math.acos(xi(i[e-1].dot(i[e]),-1,1));r[e].applyMatrix4(o.makeRotationAxis(s,t))}a[e].crossVectors(i[e],r[e])}if(!0===e){let e=Math.acos(xi(r[0].dot(r[t]),-1,1));e/=t,i[0].dot(s.crossVectors(r[0],r[t]))>0&&(e=-e);for(let n=1;n<=t;n++)r[n].applyMatrix4(o.makeRotationAxis(i[n],e*n)),a[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,binormals:a}}clone(){return(new this.constructor).copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class ll extends ol{constructor(t=0,e=0,n=1,i=1,r=0,a=2*Math.PI,s=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=s,this.aRotation=o}getPoint(t,e=new Ti){const n=e,i=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const a=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=i;for(;r>i;)r-=i;r<Number.EPSILON&&(r=a?0:i),!0!==this.aClockwise||a||(r===i?r=-i:r-=i);const s=this.aStartAngle+t*r;let o=this.aX+this.xRadius*Math.cos(s),l=this.aY+this.yRadius*Math.sin(s);if(0!==this.aRotation){const t=Math.cos(this.aRotation),e=Math.sin(this.aRotation),n=o-this.aX,i=l-this.aY;o=n*t-i*e+this.aX,l=n*e+i*t+this.aY}return n.set(o,l)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){const t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}}function cl(){let t=0,e=0,n=0,i=0;function r(r,a,s,o){t=r,e=s,n=-3*r+3*a-2*s-o,i=2*r-2*a+s+o}return{initCatmullRom:function(t,e,n,i,a){r(e,n,a*(n-t),a*(i-e))},initNonuniformCatmullRom:function(t,e,n,i,a,s,o){let l=(e-t)/a-(n-t)/(a+s)+(n-e)/s,c=(n-e)/s-(i-e)/(s+o)+(i-n)/o;l*=s,c*=s,r(e,n,l,c)},calc:function(r){const a=r*r;return t+e*r+n*a+i*(a*r)}}}const hl=new Ci,dl=new Ci,ul=new cl,pl=new cl,ml=new cl;function fl(t,e,n,i,r){const a=.5*(i-e),s=.5*(r-n),o=t*t;return(2*n-2*i+a+s)*(t*o)+(-3*n+3*i-2*a-s)*o+a*t+n}function gl(t,e,n,i){return function(t,e){const n=1-t;return n*n*e}(t,e)+function(t,e){return 2*(1-t)*t*e}(t,n)+function(t,e){return t*t*e}(t,i)}function vl(t,e,n,i,r){return function(t,e){const n=1-t;return n*n*n*e}(t,e)+function(t,e){const n=1-t;return 3*n*n*t*e}(t,n)+function(t,e){return 3*(1-t)*t*t*e}(t,i)+function(t,e){return t*t*t*e}(t,r)}class _l extends ol{constructor(t=new Ti,e=new Ti,n=new Ti,i=new Ti){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new Ti){const n=e,i=this.v0,r=this.v1,a=this.v2,s=this.v3;return n.set(vl(t,i.x,r.x,a.x,s.x),vl(t,i.y,r.y,a.y,s.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class yl extends ol{constructor(t=new Ti,e=new Ti){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new Ti){const n=e;return 1===t?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new Ti){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class xl extends ol{constructor(t=new Ti,e=new Ti,n=new Ti){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new Ti){const n=e,i=this.v0,r=this.v1,a=this.v2;return n.set(gl(t,i.x,r.x,a.x),gl(t,i.y,r.y,a.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class bl extends ol{constructor(t=new Ci,e=new Ci,n=new Ci){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new Ci){const n=e,i=this.v0,r=this.v1,a=this.v2;return n.set(gl(t,i.x,r.x,a.x),gl(t,i.y,r.y,a.y),gl(t,i.z,r.z,a.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Sl extends ol{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new Ti){const n=e,i=this.points,r=(i.length-1)*t,a=Math.floor(r),s=r-a,o=i[0===a?a:a-1],l=i[a],c=i[a>i.length-2?i.length-1:a+1],h=i[a>i.length-3?i.length-1:a+2];return n.set(fl(s,o.x,l.x,c.x,h.x),fl(s,o.y,l.y,c.y,h.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push(n.clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const n=this.points[e];t.points.push(n.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push((new Ti).fromArray(n))}return this}}var Ml=Object.freeze({__proto__:null,ArcCurve:class extends ll{constructor(t,e,n,i,r,a){super(t,e,n,n,i,r,a),this.isArcCurve=!0,this.type="ArcCurve"}},CatmullRomCurve3:class extends ol{constructor(t=[],e=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=i}getPoint(t,e=new Ci){const n=e,i=this.points,r=i.length,a=(r-(this.closed?0:1))*t;let s,o,l=Math.floor(a),c=a-l;this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/r)+1)*r:0===c&&l===r-1&&(l=r-2,c=1),this.closed||l>0?s=i[(l-1)%r]:(dl.subVectors(i[0],i[1]).add(i[0]),s=dl);const h=i[l%r],d=i[(l+1)%r];if(this.closed||l+2<r?o=i[(l+2)%r]:(hl.subVectors(i[r-1],i[r-2]).add(i[r-1]),o=hl),"centripetal"===this.curveType||"chordal"===this.curveType){const t="chordal"===this.curveType?.5:.25;let e=Math.pow(s.distanceToSquared(h),t),n=Math.pow(h.distanceToSquared(d),t),i=Math.pow(d.distanceToSquared(o),t);n<1e-4&&(n=1),e<1e-4&&(e=n),i<1e-4&&(i=n),ul.initNonuniformCatmullRom(s.x,h.x,d.x,o.x,e,n,i),pl.initNonuniformCatmullRom(s.y,h.y,d.y,o.y,e,n,i),ml.initNonuniformCatmullRom(s.z,h.z,d.z,o.z,e,n,i)}else"catmullrom"===this.curveType&&(ul.initCatmullRom(s.x,h.x,d.x,o.x,this.tension),pl.initCatmullRom(s.y,h.y,d.y,o.y,this.tension),ml.initCatmullRom(s.z,h.z,d.z,o.z,this.tension));return n.set(ul.calc(c),pl.calc(c),ml.calc(c)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push(n.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const n=this.points[e];t.points.push(n.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push((new Ci).fromArray(n))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}},CubicBezierCurve:_l,CubicBezierCurve3:class extends ol{constructor(t=new Ci,e=new Ci,n=new Ci,i=new Ci){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new Ci){const n=e,i=this.v0,r=this.v1,a=this.v2,s=this.v3;return n.set(vl(t,i.x,r.x,a.x,s.x),vl(t,i.y,r.y,a.y,s.y),vl(t,i.z,r.z,a.z,s.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},EllipseCurve:ll,LineCurve:yl,LineCurve3:class extends ol{constructor(t=new Ci,e=new Ci){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new Ci){const n=e;return 1===t?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new Ci){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},QuadraticBezierCurve:xl,QuadraticBezierCurve3:bl,SplineCurve:Sl});class wl extends ol{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);if(!t.equals(e)){const n=!0===t.isVector2?"LineCurve":"LineCurve3";this.curves.push(new Ml[n](e,t))}return this}getPoint(t,e){const n=t*this.getLength(),i=this.getCurveLengths();let r=0;for(;r<i.length;){if(i[r]>=n){const t=i[r]-n,a=this.curves[r],s=a.getLength(),o=0===s?0:1-t/s;return a.getPointAt(o,e)}r++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let n=0,i=this.curves.length;n<i;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[];let n;for(let i=0,r=this.curves;i<r.length;i++){const a=r[i],s=a.isEllipseCurve?2*t:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?t*a.points.length:t,o=a.getPoints(s);for(let t=0;t<o.length;t++){const i=o[t];n&&n.equals(i)||(e.push(i),n=i)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const n=t.curves[e];this.curves.push(n.clone())}return this.autoClose=t.autoClose,this}toJSON(){const t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){const n=this.curves[e];t.curves.push(n.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const n=t.curves[e];this.curves.push((new Ml[n.type]).fromJSON(n))}return this}}class El extends wl{constructor(t){super(),this.type="Path",this.currentPoint=new Ti,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){const n=new yl(this.currentPoint.clone(),new Ti(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,i){const r=new xl(this.currentPoint.clone(),new Ti(t,e),new Ti(n,i));return this.curves.push(r),this.currentPoint.set(n,i),this}bezierCurveTo(t,e,n,i,r,a){const s=new _l(this.currentPoint.clone(),new Ti(t,e),new Ti(n,i),new Ti(r,a));return this.curves.push(s),this.currentPoint.set(r,a),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),n=new Sl(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,i,r,a){const s=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(t+s,e+o,n,i,r,a),this}absarc(t,e,n,i,r,a){return this.absellipse(t,e,n,n,i,r,a),this}ellipse(t,e,n,i,r,a,s,o){const l=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(t+l,e+c,n,i,r,a,s,o),this}absellipse(t,e,n,i,r,a,s,o){const l=new ll(t,e,n,i,r,a,s,o);if(this.curves.length>0){const t=l.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class Tl extends El{constructor(t){super(t),this.uuid=yi(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let n=0,i=this.holes.length;n<i;n++)e[n]=this.holes[n].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){const n=t.holes[e];this.holes.push(n.clone())}return this}toJSON(){const t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,n=this.holes.length;e<n;e++){const n=this.holes[e];t.holes.push(n.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){const n=t.holes[e];this.holes.push((new El).fromJSON(n))}return this}}function Al(t,e,n=2){const i=e&&e.length,r=i?e[0]*n:t.length;let a=Cl(t,0,r,n,!0);const s=[];if(!a||a.next===a.prev)return s;let o,l,c;if(i&&(a=function(t,e,n,i){const r=[];for(let n=0,a=e.length;n<a;n++){const s=Cl(t,e[n]*i,n<a-1?e[n+1]*i:t.length,i,!1);s===s.next&&(s.steiner=!0),r.push(kl(s))}r.sort(Ol);for(let t=0;t<r.length;t++)n=Ul(r[t],n);return n}(t,e,a,n)),t.length>80*n){o=t[0],l=t[1];let e=o,i=l;for(let a=n;a<r;a+=n){const n=t[a],r=t[a+1];n<o&&(o=n),r<l&&(l=r),n>e&&(e=n),r>i&&(i=r)}c=Math.max(e-o,i-l),c=0!==c?32767/c:0}return Il(a,s,n,o,l,c,0),s}function Cl(t,e,n,i,r){let a;if(r===function(t,e,n,i){let r=0;for(let a=e,s=n-i;a<n;a+=i)r+=(t[s]-t[a])*(t[a+1]+t[s+1]),s=a;return r}(t,e,n,i)>0)for(let r=e;r<n;r+=i)a=$l(r/i|0,t[r],t[r+1],a);else for(let r=n-i;r>=e;r-=i)a=$l(r/i|0,t[r],t[r+1],a);return a&&Wl(a,a.next)&&(Jl(a),a=a.next),a}function Rl(t,e){if(!t)return t;e||(e=t);let n,i=t;do{if(n=!1,i.steiner||!Wl(i,i.next)&&0!==Hl(i.prev,i,i.next))i=i.next;else{if(Jl(i),i=e=i.prev,i===i.next)break;n=!0}}while(n||i!==e);return e}function Il(t,e,n,i,r,a,s){if(!t)return;!s&&a&&function(t,e,n,i){let r=t;do{0===r.z&&(r.z=zl(r.x,r.y,e,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,n=1;do{let i,r=t;t=null;let a=null;for(e=0;r;){e++;let s=r,o=0;for(let t=0;t<n&&(o++,s=s.nextZ,s);t++);let l=n;for(;o>0||l>0&&s;)0!==o&&(0===l||!s||r.z<=s.z)?(i=r,r=r.nextZ,o--):(i=s,s=s.nextZ,l--),a?a.nextZ=i:t=i,i.prevZ=a,a=i;r=s}a.nextZ=null,n*=2}while(e>1)}(r)}(t,i,r,a);let o=t;for(;t.prev!==t.next;){const l=t.prev,c=t.next;if(a?Ll(t,i,r,a):Pl(t))e.push(l.i,t.i,c.i),Jl(t),t=c.next,o=c.next;else if((t=c)===o){s?1===s?Il(t=Dl(Rl(t),e),e,n,i,r,a,2):2===s&&Nl(t,e,n,i,r,a):Il(Rl(t),e,n,i,r,a,1);break}}}function Pl(t){const e=t.prev,n=t,i=t.next;if(Hl(e,n,i)>=0)return!1;const r=e.x,a=n.x,s=i.x,o=e.y,l=n.y,c=i.y,h=Math.min(r,a,s),d=Math.min(o,l,c),u=Math.max(r,a,s),p=Math.max(o,l,c);let m=i.next;for(;m!==e;){if(m.x>=h&&m.x<=u&&m.y>=d&&m.y<=p&&Gl(r,o,a,l,s,c,m.x,m.y)&&Hl(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Ll(t,e,n,i){const r=t.prev,a=t,s=t.next;if(Hl(r,a,s)>=0)return!1;const o=r.x,l=a.x,c=s.x,h=r.y,d=a.y,u=s.y,p=Math.min(o,l,c),m=Math.min(h,d,u),f=Math.max(o,l,c),g=Math.max(h,d,u),v=zl(p,m,e,n,i),_=zl(f,g,e,n,i);let y=t.prevZ,x=t.nextZ;for(;y&&y.z>=v&&x&&x.z<=_;){if(y.x>=p&&y.x<=f&&y.y>=m&&y.y<=g&&y!==r&&y!==s&&Gl(o,h,l,d,c,u,y.x,y.y)&&Hl(y.prev,y,y.next)>=0)return!1;if(y=y.prevZ,x.x>=p&&x.x<=f&&x.y>=m&&x.y<=g&&x!==r&&x!==s&&Gl(o,h,l,d,c,u,x.x,x.y)&&Hl(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;y&&y.z>=v;){if(y.x>=p&&y.x<=f&&y.y>=m&&y.y<=g&&y!==r&&y!==s&&Gl(o,h,l,d,c,u,y.x,y.y)&&Hl(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;x&&x.z<=_;){if(x.x>=p&&x.x<=f&&x.y>=m&&x.y<=g&&x!==r&&x!==s&&Gl(o,h,l,d,c,u,x.x,x.y)&&Hl(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function Dl(t,e){let n=t;do{const i=n.prev,r=n.next.next;!Wl(i,r)&&jl(i,n,n.next,r)&&Yl(i,r)&&Yl(r,i)&&(e.push(i.i,n.i,r.i),Jl(n),Jl(n.next),n=t=r),n=n.next}while(n!==t);return Rl(n)}function Nl(t,e,n,i,r,a){let s=t;do{let t=s.next.next;for(;t!==s.prev;){if(s.i!==t.i&&Vl(s,t)){let o=Zl(s,t);return s=Rl(s,s.next),o=Rl(o,o.next),Il(s,e,n,i,r,a,0),void Il(o,e,n,i,r,a,0)}t=t.next}s=s.next}while(s!==t)}function Ol(t,e){let n=t.x-e.x;return 0===n&&(n=t.y-e.y,0===n)&&(n=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)),n}function Ul(t,e){const n=function(t,e){let n=e;const i=t.x,r=t.y;let a,s=-1/0;if(Wl(t,n))return n;do{if(Wl(t,n.next))return n.next;if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){const t=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(t<=i&&t>s&&(s=t,a=n.x<n.next.x?n:n.next,t===i))return a}n=n.next}while(n!==e);if(!a)return null;const o=a,l=a.x,c=a.y;let h=1/0;n=a;do{if(i>=n.x&&n.x>=l&&i!==n.x&&Bl(r<c?i:s,r,l,c,r<c?s:i,r,n.x,n.y)){const e=Math.abs(r-n.y)/(i-n.x);Yl(n,t)&&(e<h||e===h&&(n.x>a.x||n.x===a.x&&Fl(a,n)))&&(a=n,h=e)}n=n.next}while(n!==o);return a}(t,e);if(!n)return e;const i=Zl(n,t);return Rl(i,i.next),Rl(n,n.next)}function Fl(t,e){return Hl(t.prev,t,e.prev)<0&&Hl(e.next,t,t.next)<0}function zl(t,e,n,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function kl(t){let e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function Bl(t,e,n,i,r,a,s,o){return(r-s)*(e-o)>=(t-s)*(a-o)&&(t-s)*(i-o)>=(n-s)*(e-o)&&(n-s)*(a-o)>=(r-s)*(i-o)}function Gl(t,e,n,i,r,a,s,o){return!(t===s&&e===o)&&Bl(t,e,n,i,r,a,s,o)}function Vl(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&jl(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(Yl(t,e)&&Yl(e,t)&&function(t,e){let n=t,i=!1;const r=(t.x+e.x)/2,a=(t.y+e.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&r<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==t);return i}(t,e)&&(Hl(t.prev,t,e.prev)||Hl(t,e.prev,e))||Wl(t,e)&&Hl(t.prev,t,t.next)>0&&Hl(e.prev,e,e.next)>0)}function Hl(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function Wl(t,e){return t.x===e.x&&t.y===e.y}function jl(t,e,n,i){const r=ql(Hl(t,e,n)),a=ql(Hl(t,e,i)),s=ql(Hl(n,i,t)),o=ql(Hl(n,i,e));return r!==a&&s!==o||!(0!==r||!Xl(t,n,e))||!(0!==a||!Xl(t,i,e))||!(0!==s||!Xl(n,t,i))||!(0!==o||!Xl(n,e,i))}function Xl(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function ql(t){return t>0?1:t<0?-1:0}function Yl(t,e){return Hl(t.prev,t,t.next)<0?Hl(t,e,t.next)>=0&&Hl(t,t.prev,e)>=0:Hl(t,e,t.prev)<0||Hl(t,t.next,e)<0}function Zl(t,e){const n=Kl(t.i,t.x,t.y),i=Kl(e.i,e.x,e.y),r=t.next,a=e.prev;return t.next=e,e.prev=t,n.next=r,r.prev=n,i.next=n,n.prev=i,a.next=i,i.prev=a,i}function $l(t,e,n,i){const r=Kl(t,e,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Jl(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Kl(t,e,n){return{i:t,x:e,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class Ql{static triangulate(t,e,n=2){return Al(t,e,n)}}class tc{static area(t){const e=t.length;let n=0;for(let i=e-1,r=0;r<e;i=r++)n+=t[i].x*t[r].y-t[r].x*t[i].y;return.5*n}static isClockWise(t){return tc.area(t)<0}static triangulateShape(t,e){const n=[],i=[],r=[];ec(t),nc(n,t);let a=t.length;e.forEach(ec);for(let t=0;t<e.length;t++)i.push(a),a+=e[t].length,nc(n,e[t]);const s=Ql.triangulate(n,i);for(let t=0;t<s.length;t+=3)r.push(s.slice(t,t+3));return r}}function ec(t){const e=t.length;e>2&&t[e-1].equals(t[0])&&t.pop()}function nc(t,e){for(let n=0;n<e.length;n++)t.push(e[n].x),t.push(e[n].y)}class ic extends Pa{constructor(t=new Tl([new Ti(.5,.5),new Ti(-.5,.5),new Ti(-.5,-.5),new Ti(.5,-.5)]),e={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];const n=this,i=[],r=[];for(let e=0,n=t.length;e<n;e++)a(t[e]);function a(t){const a=[],s=void 0!==e.curveSegments?e.curveSegments:12,o=void 0!==e.steps?e.steps:1,l=void 0!==e.depth?e.depth:1;let c=void 0===e.bevelEnabled||e.bevelEnabled,h=void 0!==e.bevelThickness?e.bevelThickness:.2,d=void 0!==e.bevelSize?e.bevelSize:h-.1,u=void 0!==e.bevelOffset?e.bevelOffset:0,p=void 0!==e.bevelSegments?e.bevelSegments:3;const m=e.extrudePath,f=void 0!==e.UVGenerator?e.UVGenerator:rc;let g,v,_,y,x,b=!1;if(m){g=m.getSpacedPoints(o),b=!0,c=!1;const t=!!m.isCatmullRomCurve3&&m.closed;v=m.computeFrenetFrames(o,t),_=new Ci,y=new Ci,x=new Ci}c||(p=0,h=0,d=0,u=0);const S=t.extractPoints(s);let M=S.shape;const w=S.holes;if(!tc.isClockWise(M)){M=M.reverse();for(let t=0,e=w.length;t<e;t++){const e=w[t];tc.isClockWise(e)&&(w[t]=e.reverse())}}function E(t){const e=1e-10*1e-10;let n=t[0];for(let i=1;i<=t.length;i++){const r=i%t.length,a=t[r],s=a.x-n.x,o=a.y-n.y,l=s*s+o*o,c=Math.max(Math.abs(a.x),Math.abs(a.y),Math.abs(n.x),Math.abs(n.y));l<=e*c*c?(t.splice(r,1),i--):n=a}}E(M),w.forEach(E);const T=w.length,A=M;for(let t=0;t<T;t++){const e=w[t];M=M.concat(e)}function C(t,e,n){return e||di("ExtrudeGeometry: vec does not exist"),t.clone().addScaledVector(e,n)}const R=M.length;function I(t,e,n){let i,r,a;const s=t.x-e.x,o=t.y-e.y,l=n.x-t.x,c=n.y-t.y,h=s*s+o*o,d=s*c-o*l;if(Math.abs(d)>Number.EPSILON){const d=Math.sqrt(h),u=Math.sqrt(l*l+c*c),p=e.x-o/d,m=e.y+s/d,f=((n.x-c/u-p)*c-(n.y+l/u-m)*l)/(s*c-o*l);i=p+s*f-t.x,r=m+o*f-t.y;const g=i*i+r*r;if(g<=2)return new Ti(i,r);a=Math.sqrt(g/2)}else{let t=!1;s>Number.EPSILON?l>Number.EPSILON&&(t=!0):s<-Number.EPSILON?l<-Number.EPSILON&&(t=!0):Math.sign(o)===Math.sign(c)&&(t=!0),t?(i=-o,r=s,a=Math.sqrt(h)):(i=s,r=o,a=Math.sqrt(h/2))}return new Ti(i/a,r/a)}const P=[];for(let t=0,e=A.length,n=e-1,i=t+1;t<e;t++,n++,i++)n===e&&(n=0),i===e&&(i=0),P[t]=I(A[t],A[n],A[i]);const L=[];let D,N,O=P.concat();for(let t=0,e=T;t<e;t++){const e=w[t];D=[];for(let t=0,n=e.length,i=n-1,r=t+1;t<n;t++,i++,r++)i===n&&(i=0),r===n&&(r=0),D[t]=I(e[t],e[i],e[r]);L.push(D),O=O.concat(D)}if(0===p)N=tc.triangulateShape(A,w);else{const t=[],e=[];for(let n=0;n<p;n++){const i=n/p,r=h*Math.cos(i*Math.PI/2),a=d*Math.sin(i*Math.PI/2)+u;for(let e=0,n=A.length;e<n;e++){const n=C(A[e],P[e],a);k(n.x,n.y,-r),0===i&&t.push(n)}for(let t=0,n=T;t<n;t++){const n=w[t];D=L[t];const s=[];for(let t=0,e=n.length;t<e;t++){const e=C(n[t],D[t],a);k(e.x,e.y,-r),0===i&&s.push(e)}0===i&&e.push(s)}}N=tc.triangulateShape(t,e)}const U=N.length,F=d+u;for(let t=0;t<R;t++){const e=c?C(M[t],O[t],F):M[t];b?(y.copy(v.normals[0]).multiplyScalar(e.x),_.copy(v.binormals[0]).multiplyScalar(e.y),x.copy(g[0]).add(y).add(_),k(x.x,x.y,x.z)):k(e.x,e.y,0)}for(let t=1;t<=o;t++)for(let e=0;e<R;e++){const n=c?C(M[e],O[e],F):M[e];b?(y.copy(v.normals[t]).multiplyScalar(n.x),_.copy(v.binormals[t]).multiplyScalar(n.y),x.copy(g[t]).add(y).add(_),k(x.x,x.y,x.z)):k(n.x,n.y,l/o*t)}for(let t=p-1;t>=0;t--){const e=t/p,n=h*Math.cos(e*Math.PI/2),i=d*Math.sin(e*Math.PI/2)+u;for(let t=0,e=A.length;t<e;t++){const e=C(A[t],P[t],i);k(e.x,e.y,l+n)}for(let t=0,e=w.length;t<e;t++){const e=w[t];D=L[t];for(let t=0,r=e.length;t<r;t++){const r=C(e[t],D[t],i);b?k(r.x,r.y+g[o-1].y,g[o-1].x+n):k(r.x,r.y,l+n)}}}function z(t,e){let n=t.length;for(;--n>=0;){const i=n;let r=n-1;r<0&&(r=t.length-1);for(let t=0,n=o+2*p;t<n;t++){const n=R*t,a=R*(t+1);G(e+i+n,e+r+n,e+r+a,e+i+a)}}}function k(t,e,n){a.push(t),a.push(e),a.push(n)}function B(t,e,r){V(t),V(e),V(r);const a=i.length/3,s=f.generateTopUV(n,i,a-3,a-2,a-1);H(s[0]),H(s[1]),H(s[2])}function G(t,e,r,a){V(t),V(e),V(a),V(e),V(r),V(a);const s=i.length/3,o=f.generateSideWallUV(n,i,s-6,s-3,s-2,s-1);H(o[0]),H(o[1]),H(o[3]),H(o[1]),H(o[2]),H(o[3])}function V(t){i.push(a[3*t+0]),i.push(a[3*t+1]),i.push(a[3*t+2])}function H(t){r.push(t.x),r.push(t.y)}!function(){const t=i.length/3;if(c){let t=0,e=R*t;for(let t=0;t<U;t++){const n=N[t];B(n[2]+e,n[1]+e,n[0]+e)}t=o+2*p,e=R*t;for(let t=0;t<U;t++){const n=N[t];B(n[0]+e,n[1]+e,n[2]+e)}}else{for(let t=0;t<U;t++){const e=N[t];B(e[2],e[1],e[0])}for(let t=0;t<U;t++){const e=N[t];B(e[0]+R*o,e[1]+R*o,e[2]+R*o)}}n.addGroup(t,i.length/3-t,0)}(),function(){const t=i.length/3;let e=0;z(A,e),e+=A.length;for(let t=0,n=w.length;t<n;t++){const n=w[t];z(n,e),e+=n.length}n.addGroup(t,i.length/3-t,1)}()}this.setAttribute("position",new ya(i,3)),this.setAttribute("uv",new ya(r,2)),this.computeVertexNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return function(t,e,n){if(n.shapes=[],Array.isArray(t))for(let e=0,i=t.length;e<i;e++){const i=t[e];n.shapes.push(i.uuid)}else n.shapes.push(t.uuid);return n.options=Object.assign({},e),void 0!==e.extrudePath&&(n.options.extrudePath=e.extrudePath.toJSON()),n}(this.parameters.shapes,this.parameters.options,t)}static fromJSON(t,e){const n=[];for(let i=0,r=t.shapes.length;i<r;i++){const r=e[t.shapes[i]];n.push(r)}const i=t.options.extrudePath;return void 0!==i&&(t.options.extrudePath=(new Ml[i.type]).fromJSON(i)),new ic(n,t.options)}}const rc={generateTopUV:function(t,e,n,i,r){const a=e[3*n],s=e[3*n+1],o=e[3*i],l=e[3*i+1],c=e[3*r],h=e[3*r+1];return[new Ti(a,s),new Ti(o,l),new Ti(c,h)]},generateSideWallUV:function(t,e,n,i,r,a){const s=e[3*n],o=e[3*n+1],l=e[3*n+2],c=e[3*i],h=e[3*i+1],d=e[3*i+2],u=e[3*r],p=e[3*r+1],m=e[3*r+2],f=e[3*a],g=e[3*a+1],v=e[3*a+2];return Math.abs(o-h)<Math.abs(s-c)?[new Ti(s,1-l),new Ti(c,1-d),new Ti(u,1-m),new Ti(f,1-v)]:[new Ti(o,1-l),new Ti(h,1-d),new Ti(p,1-m),new Ti(g,1-v)]}};class ac extends el{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2;super([-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new ac(t.radius,t.detail)}}class sc extends Pa{constructor(t=[new Ti(0,-.5),new Ti(.5,0),new Ti(0,.5)],e=12,n=0,i=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:i},e=Math.floor(e),i=xi(i,0,2*Math.PI);const r=[],a=[],s=[],o=[],l=[],c=1/e,h=new Ci,d=new Ti,u=new Ci,p=new Ci,m=new Ci;let f=0,g=0;for(let e=0;e<=t.length-1;e++)switch(e){case 0:f=t[e+1].x-t[e].x,g=t[e+1].y-t[e].y,u.x=1*g,u.y=-f,u.z=0*g,m.copy(u),u.normalize(),o.push(u.x,u.y,u.z);break;case t.length-1:o.push(m.x,m.y,m.z);break;default:f=t[e+1].x-t[e].x,g=t[e+1].y-t[e].y,u.x=1*g,u.y=-f,u.z=0*g,p.copy(u),u.x+=m.x,u.y+=m.y,u.z+=m.z,u.normalize(),o.push(u.x,u.y,u.z),m.copy(p)}for(let r=0;r<=e;r++){const u=n+r*c*i,p=Math.sin(u),m=Math.cos(u);for(let n=0;n<=t.length-1;n++){h.x=t[n].x*p,h.y=t[n].y,h.z=t[n].x*m,a.push(h.x,h.y,h.z),d.x=r/e,d.y=n/(t.length-1),s.push(d.x,d.y);const i=o[3*n+0]*p,c=o[3*n+1],u=o[3*n+0]*m;l.push(i,c,u)}}for(let n=0;n<e;n++)for(let e=0;e<t.length-1;e++){const i=e+n*t.length,a=i,s=i+t.length,o=i+t.length+1,l=i+1;r.push(a,s,l),r.push(o,l,s)}this.setIndex(r),this.setAttribute("position",new ya(a,3)),this.setAttribute("uv",new ya(s,2)),this.setAttribute("normal",new ya(l,3))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new sc(t.points,t.segments,t.phiStart,t.phiLength)}}class oc extends el{constructor(t=1,e=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],t,e),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new oc(t.radius,t.detail)}}class lc extends Pa{constructor(t=1,e=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i};const r=t/2,a=e/2,s=Math.floor(n),o=Math.floor(i),l=s+1,c=o+1,h=t/s,d=e/o,u=[],p=[],m=[],f=[];for(let t=0;t<c;t++){const e=t*d-a;for(let n=0;n<l;n++){const i=n*h-r;p.push(i,-e,0),m.push(0,0,1),f.push(n/s),f.push(1-t/o)}}for(let t=0;t<o;t++)for(let e=0;e<s;e++){const n=e+l*t,i=e+l*(t+1),r=e+1+l*(t+1),a=e+1+l*t;u.push(n,i,a),u.push(i,r,a)}this.setIndex(u),this.setAttribute("position",new ya(p,3)),this.setAttribute("normal",new ya(m,3)),this.setAttribute("uv",new ya(f,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new lc(t.width,t.height,t.widthSegments,t.heightSegments)}}class cc extends Pa{constructor(t=.5,e=1,n=32,i=1,r=0,a=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:n,phiSegments:i,thetaStart:r,thetaLength:a},n=Math.max(3,n);const s=[],o=[],l=[],c=[];let h=t;const d=(e-t)/(i=Math.max(1,i)),u=new Ci,p=new Ti;for(let t=0;t<=i;t++){for(let t=0;t<=n;t++){const i=r+t/n*a;u.x=h*Math.cos(i),u.y=h*Math.sin(i),o.push(u.x,u.y,u.z),l.push(0,0,1),p.x=(u.x/e+1)/2,p.y=(u.y/e+1)/2,c.push(p.x,p.y)}h+=d}for(let t=0;t<i;t++){const e=t*(n+1);for(let t=0;t<n;t++){const i=t+e,r=i,a=i+n+1,o=i+n+2,l=i+1;s.push(r,a,l),s.push(a,o,l)}}this.setIndex(s),this.setAttribute("position",new ya(o,3)),this.setAttribute("normal",new ya(l,3)),this.setAttribute("uv",new ya(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new cc(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}}class hc extends Pa{constructor(t=new Tl([new Ti(0,.5),new Ti(-.5,-.5),new Ti(.5,-.5)]),e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};const n=[],i=[],r=[],a=[];let s=0,o=0;if(!1===Array.isArray(t))l(t);else for(let e=0;e<t.length;e++)l(t[e]),this.addGroup(s,o,e),s+=o,o=0;function l(t){const s=i.length/3,l=t.extractPoints(e);let c=l.shape;const h=l.holes;!1===tc.isClockWise(c)&&(c=c.reverse());for(let t=0,e=h.length;t<e;t++){const e=h[t];!0===tc.isClockWise(e)&&(h[t]=e.reverse())}const d=tc.triangulateShape(c,h);for(let t=0,e=h.length;t<e;t++){const e=h[t];c=c.concat(e)}for(let t=0,e=c.length;t<e;t++){const e=c[t];i.push(e.x,e.y,0),r.push(0,0,1),a.push(e.x,e.y)}for(let t=0,e=d.length;t<e;t++){const e=d[t],i=e[0]+s,r=e[1]+s,a=e[2]+s;n.push(i,r,a),o+=3}}this.setIndex(n),this.setAttribute("position",new ya(i,3)),this.setAttribute("normal",new ya(r,3)),this.setAttribute("uv",new ya(a,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return function(t,e){if(e.shapes=[],Array.isArray(t))for(let n=0,i=t.length;n<i;n++){const i=t[n];e.shapes.push(i.uuid)}else e.shapes.push(t.uuid);return e}(this.parameters.shapes,t)}static fromJSON(t,e){const n=[];for(let i=0,r=t.shapes.length;i<r;i++){const r=e[t.shapes[i]];n.push(r)}return new hc(n,t.curveSegments)}}class dc extends Pa{constructor(t=1,e=32,n=16,i=0,r=2*Math.PI,a=0,s=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:i,phiLength:r,thetaStart:a,thetaLength:s},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const o=Math.min(a+s,Math.PI);let l=0;const c=[],h=new Ci,d=new Ci,u=[],p=[],m=[],f=[];for(let u=0;u<=n;u++){const g=[],v=u/n;let _=0;0===u&&0===a?_=.5/e:u===n&&o===Math.PI&&(_=-.5/e);for(let n=0;n<=e;n++){const o=n/e;h.x=-t*Math.cos(i+o*r)*Math.sin(a+v*s),h.y=t*Math.cos(a+v*s),h.z=t*Math.sin(i+o*r)*Math.sin(a+v*s),p.push(h.x,h.y,h.z),d.copy(h).normalize(),m.push(d.x,d.y,d.z),f.push(o+_,1-v),g.push(l++)}c.push(g)}for(let t=0;t<n;t++)for(let i=0;i<e;i++){const e=c[t][i+1],r=c[t][i],s=c[t+1][i],l=c[t+1][i+1];(0!==t||a>0)&&u.push(e,r,l),(t!==n-1||o<Math.PI)&&u.push(r,s,l)}this.setIndex(u),this.setAttribute("position",new ya(p,3)),this.setAttribute("normal",new ya(m,3)),this.setAttribute("uv",new ya(f,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new dc(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class uc extends el{constructor(t=1,e=0){super([1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],t,e),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new uc(t.radius,t.detail)}}class pc extends Pa{constructor(t=1,e=.4,n=12,i=48,r=2*Math.PI,a=0,s=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:n,tubularSegments:i,arc:r,thetaStart:a,thetaLength:s},n=Math.floor(n),i=Math.floor(i);const o=[],l=[],c=[],h=[],d=new Ci,u=new Ci,p=new Ci;for(let o=0;o<=n;o++){const m=a+o/n*s;for(let a=0;a<=i;a++){const s=a/i*r;u.x=(t+e*Math.cos(m))*Math.cos(s),u.y=(t+e*Math.cos(m))*Math.sin(s),u.z=e*Math.sin(m),l.push(u.x,u.y,u.z),d.x=t*Math.cos(s),d.y=t*Math.sin(s),p.subVectors(u,d).normalize(),c.push(p.x,p.y,p.z),h.push(a/i),h.push(o/n)}}for(let t=1;t<=n;t++)for(let e=1;e<=i;e++){const n=(i+1)*t+e-1,r=(i+1)*(t-1)+e-1,a=(i+1)*(t-1)+e,s=(i+1)*t+e;o.push(n,r,s),o.push(r,a,s)}this.setIndex(o),this.setAttribute("position",new ya(l,3)),this.setAttribute("normal",new ya(c,3)),this.setAttribute("uv",new ya(h,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new pc(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class mc extends Pa{constructor(t=1,e=.4,n=64,i=8,r=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:n,radialSegments:i,p:r,q:a},n=Math.floor(n),i=Math.floor(i);const s=[],o=[],l=[],c=[],h=new Ci,d=new Ci,u=new Ci,p=new Ci,m=new Ci,f=new Ci,g=new Ci;for(let s=0;s<=n;++s){const _=s/n*r*Math.PI*2;v(_,r,a,t,u),v(_+.01,r,a,t,p),f.subVectors(p,u),g.addVectors(p,u),m.crossVectors(f,g),g.crossVectors(m,f),m.normalize(),g.normalize();for(let t=0;t<=i;++t){const r=t/i*Math.PI*2,a=-e*Math.cos(r),p=e*Math.sin(r);h.x=u.x+(a*g.x+p*m.x),h.y=u.y+(a*g.y+p*m.y),h.z=u.z+(a*g.z+p*m.z),o.push(h.x,h.y,h.z),d.subVectors(h,u).normalize(),l.push(d.x,d.y,d.z),c.push(s/n),c.push(t/i)}}for(let t=1;t<=n;t++)for(let e=1;e<=i;e++){const n=(i+1)*(t-1)+(e-1),r=(i+1)*t+(e-1),a=(i+1)*t+e,o=(i+1)*(t-1)+e;s.push(n,r,o),s.push(r,a,o)}function v(t,e,n,i,r){const a=Math.cos(t),s=Math.sin(t),o=n/e*t,l=Math.cos(o);r.x=i*(2+l)*.5*a,r.y=i*(2+l)*s*.5,r.z=i*Math.sin(o)*.5}this.setIndex(s),this.setAttribute("position",new ya(o,3)),this.setAttribute("normal",new ya(l,3)),this.setAttribute("uv",new ya(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new mc(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}}class fc extends Pa{constructor(t=new bl(new Ci(-1,-1,0),new Ci(-1,1,0),new Ci(1,1,0)),e=64,n=1,i=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:i,closed:r};const a=t.computeFrenetFrames(e,r);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;const s=new Ci,o=new Ci,l=new Ti;let c=new Ci;const h=[],d=[],u=[],p=[];function m(r){c=t.getPointAt(r/e,c);const l=a.normals[r],u=a.binormals[r];for(let t=0;t<=i;t++){const e=t/i*Math.PI*2,r=Math.sin(e),a=-Math.cos(e);o.x=a*l.x+r*u.x,o.y=a*l.y+r*u.y,o.z=a*l.z+r*u.z,o.normalize(),d.push(o.x,o.y,o.z),s.x=c.x+n*o.x,s.y=c.y+n*o.y,s.z=c.z+n*o.z,h.push(s.x,s.y,s.z)}}!function(){for(let t=0;t<e;t++)m(t);m(!1===r?e:0),function(){for(let t=0;t<=e;t++)for(let n=0;n<=i;n++)l.x=t/e,l.y=n/i,u.push(l.x,l.y)}(),function(){for(let t=1;t<=e;t++)for(let e=1;e<=i;e++){const n=(i+1)*(t-1)+(e-1),r=(i+1)*t+(e-1),a=(i+1)*t+e,s=(i+1)*(t-1)+e;p.push(n,r,s),p.push(r,a,s)}}()}(),this.setIndex(p),this.setAttribute("position",new ya(h,3)),this.setAttribute("normal",new ya(d,3)),this.setAttribute("uv",new ya(u,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return t.path=this.parameters.path.toJSON(),t}static fromJSON(t){return new fc((new Ml[t.path.type]).fromJSON(t.path),t.tubularSegments,t.radius,t.radialSegments,t.closed)}}function gc(t,e,n){const i=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`;return!0!==n.has(i)&&!0!==n.has(r)&&(n.add(i),n.add(r),!0)}var vc=Object.freeze({__proto__:null,BoxGeometry:$o,CapsuleGeometry:Jo,CircleGeometry:Ko,ConeGeometry:tl,CylinderGeometry:Qo,DodecahedronGeometry:nl,EdgesGeometry:class extends Pa{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},null!==t){const n=4,i=Math.pow(10,n),r=Math.cos(vi*e),a=t.getIndex(),s=t.getAttribute("position"),o=a?a.count:s.count,l=[0,0,0],c=["a","b","c"],h=new Array(3),d={},u=[];for(let t=0;t<o;t+=3){a?(l[0]=a.getX(t),l[1]=a.getX(t+1),l[2]=a.getX(t+2)):(l[0]=t,l[1]=t+1,l[2]=t+2);const{a:e,b:n,c:o}=sl;if(e.fromBufferAttribute(s,l[0]),n.fromBufferAttribute(s,l[1]),o.fromBufferAttribute(s,l[2]),sl.getNormal(al),h[0]=`${Math.round(e.x*i)},${Math.round(e.y*i)},${Math.round(e.z*i)}`,h[1]=`${Math.round(n.x*i)},${Math.round(n.y*i)},${Math.round(n.z*i)}`,h[2]=`${Math.round(o.x*i)},${Math.round(o.y*i)},${Math.round(o.z*i)}`,h[0]!==h[1]&&h[1]!==h[2]&&h[2]!==h[0])for(let t=0;t<3;t++){const e=(t+1)%3,n=h[t],i=h[e],a=sl[c[t]],s=sl[c[e]],o=`${n}_${i}`,p=`${i}_${n}`;p in d&&d[p]?(al.dot(d[p].normal)<=r&&(u.push(a.x,a.y,a.z),u.push(s.x,s.y,s.z)),d[p]=null):o in d||(d[o]={index0:l[t],index1:l[e],normal:al.clone()})}}for(const t in d)if(d[t]){const{index0:e,index1:n}=d[t];il.fromBufferAttribute(s,e),rl.fromBufferAttribute(s,n),u.push(il.x,il.y,il.z),u.push(rl.x,rl.y,rl.z)}this.setAttribute("position",new ya(u,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}},ExtrudeGeometry:ic,IcosahedronGeometry:ac,LatheGeometry:sc,OctahedronGeometry:oc,PlaneGeometry:lc,PolyhedronGeometry:el,RingGeometry:cc,ShapeGeometry:hc,SphereGeometry:dc,TetrahedronGeometry:uc,TorusGeometry:pc,TorusKnotGeometry:mc,TubeGeometry:fc,WireframeGeometry:class extends Pa{constructor(t=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:t},null!==t){const e=[],n=new Set,i=new Ci,r=new Ci;if(null!==t.index){const a=t.attributes.position,s=t.index;let o=t.groups;0===o.length&&(o=[{start:0,count:s.count,materialIndex:0}]);for(let t=0,l=o.length;t<l;++t){const l=o[t],c=l.start;for(let t=c,o=c+l.count;t<o;t+=3)for(let o=0;o<3;o++){const l=s.getX(t+o),c=s.getX(t+(o+1)%3);i.fromBufferAttribute(a,l),r.fromBufferAttribute(a,c),!0===gc(i,r,n)&&(e.push(i.x,i.y,i.z),e.push(r.x,r.y,r.z))}}}else{const a=t.attributes.position;for(let t=0,s=a.count/3;t<s;t++)for(let s=0;s<3;s++){const o=3*t+s,l=3*t+(s+1)%3;i.fromBufferAttribute(a,o),r.fromBufferAttribute(a,l),!0===gc(i,r,n)&&(e.push(i.x,i.y,i.z),e.push(r.x,r.y,r.z))}}this.setAttribute("position",new ya(e,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}});class _c extends Fa{constructor(t){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Dr(0),this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.fog=t.fog,this}}function yc(t){const e={};for(const n in t){e[n]={};for(const i in t[n]){const r=t[n][i];if(bc(r))r.isRenderTargetTexture?(hi("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][i]=null):e[n][i]=r.clone();else if(Array.isArray(r))if(bc(r[0])){const t=[];for(let e=0,n=r.length;e<n;e++)t[e]=r[e].clone();e[n][i]=t}else e[n][i]=r.slice();else e[n][i]=r}}return e}function xc(t){const e={};for(let n=0;n<t.length;n++){const i=yc(t[n]);for(const t in i)e[t]=i[t]}return e}function bc(t){return t&&(t.isColor||t.isMatrix3||t.isMatrix4||t.isVector2||t.isVector3||t.isVector4||t.isTexture||t.isQuaternion)}function Sc(t){const e=t.getRenderTarget();return null===e?t.outputColorSpace:!0===e.isXRRenderTarget?e.texture.colorSpace:Ui.workingColorSpace}const Mc={clone:yc,merge:xc};class wc extends Fa{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==t&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=yc(t.uniforms),this.uniformsGroups=function(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this.defaultAttributeValues=Object.assign({},t.defaultAttributeValues),this.index0AttributeName=t.index0AttributeName,this.uniformsNeedUpdate=t.uniformsNeedUpdate,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const n in this.uniforms){const i=this.uniforms[n].value;i&&i.isTexture?e.uniforms[n]={type:"t",value:i.toJSON(t).uuid}:i&&i.isColor?e.uniforms[n]={type:"c",value:i.getHex()}:i&&i.isVector2?e.uniforms[n]={type:"v2",value:i.toArray()}:i&&i.isVector3?e.uniforms[n]={type:"v3",value:i.toArray()}:i&&i.isVector4?e.uniforms[n]={type:"v4",value:i.toArray()}:i&&i.isMatrix3?e.uniforms[n]={type:"m3",value:i.toArray()}:i&&i.isMatrix4?e.uniforms[n]={type:"m4",value:i.toArray()}:e.uniforms[n]={value:i}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const t in this.extensions)!0===this.extensions[t]&&(n[t]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}class Ec extends wc{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Tc extends Fa{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Dr(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Dr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ti(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new lr,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Ac extends Tc{constructor(t){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ti(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return xi(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Dr(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Dr(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Dr(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class Cc extends Fa{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Dr(16777215),this.specular=new Dr(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Dr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ti(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new lr,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Rc extends Fa{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Dr(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Dr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ti(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class Ic extends Fa{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ti(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class Pc extends Fa{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Dr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Dr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ti(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new lr,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Lc extends Fa{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class Dc extends Fa{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}class Nc extends Fa{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Dr(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ti(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Oc extends Eo{constructor(t){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}function Uc(t,e){return t&&t.constructor!==e?"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t):t}function Fc(t){const e=t.length,n=new Array(e);for(let t=0;t!==e;++t)n[t]=t;return n.sort((function(e,n){return t[e]-t[n]})),n}function zc(t,e,n){const i=t.length,r=new t.constructor(i);for(let a=0,s=0;s!==i;++a){const i=n[a]*e;for(let n=0;n!==e;++n)r[s++]=t[i+n]}return r}function kc(t,e,n,i){let r=1,a=t[0];for(;void 0!==a&&void 0===a[i];)a=t[r++];if(void 0===a)return;let s=a[i];if(void 0!==s)if(Array.isArray(s))do{s=a[i],void 0!==s&&(e.push(a.time),n.push(...s)),a=t[r++]}while(void 0!==a);else if(void 0!==s.toArray)do{s=a[i],void 0!==s&&(e.push(a.time),s.toArray(n,n.length)),a=t[r++]}while(void 0!==a);else do{s=a[i],void 0!==s&&(e.push(a.time),n.push(s)),a=t[r++]}while(void 0!==a)}class Bc{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let n=this._cachedIndex,i=e[n],r=e[n-1];t:{e:{let a;n:{i:if(!(t<i)){for(let a=n+2;;){if(void 0===i){if(t<r)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(r=i,i=e[++n],t<i)break e}a=e.length;break n}if(t>=r)break t;{const s=e[1];t<s&&(n=2,r=s);for(let a=n-2;;){if(void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(i=r,r=e[--n-1],t>=r)break e}a=n,n=0}}for(;n<a;){const i=n+a>>>1;t<e[i]?a=i:n=i+1}if(i=e[n],r=e[n-1],void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===i)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=t*i;for(let t=0;t!==i;++t)e[t]=n[r+t];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class Gc extends Bc{constructor(t,e,n,i){super(t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:On,endingEnd:On}}intervalChanged_(t,e,n){const i=this.parameterPositions;let r=t-2,a=t+1,s=i[r],o=i[a];if(void 0===s)switch(this.getSettings_().endingStart){case Un:r=t,s=2*e-n;break;case Fn:r=i.length-2,s=e+i[r]-i[r+1];break;default:r=t,s=n}if(void 0===o)switch(this.getSettings_().endingEnd){case Un:a=t,o=2*n-e;break;case Fn:a=1,o=n+i[1]-i[0];break;default:a=t-1,o=e}const l=.5*(n-e),c=this.valueSize;this._weightPrev=l/(e-s),this._weightNext=l/(o-n),this._offsetPrev=r*c,this._offsetNext=a*c}interpolate_(t,e,n,i){const r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=t*s,l=o-s,c=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,u=this._weightNext,p=(n-e)/(i-e),m=p*p,f=m*p,g=-d*f+2*d*m-d*p,v=(1+d)*f+(-1.5-2*d)*m+(-.5+d)*p+1,_=(-1-u)*f+(1.5+u)*m+.5*p,y=u*f-u*m;for(let t=0;t!==s;++t)r[t]=g*a[c+t]+v*a[l+t]+_*a[o+t]+y*a[h+t];return r}}class Vc extends Bc{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=t*s,l=o-s,c=(n-e)/(i-e),h=1-c;for(let t=0;t!==s;++t)r[t]=a[l+t]*h+a[o+t]*c;return r}}class Hc extends Bc{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}}class Wc extends Bc{interpolate_(t,e,n,i){const r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=t*s,l=o-s,c=this.settings||this.DefaultSettings_,h=c.inTangents,d=c.outTangents;if(!h||!d){const t=(n-e)/(i-e),c=1-t;for(let e=0;e!==s;++e)r[e]=a[l+e]*c+a[o+e]*t;return r}const u=2*s,p=t-1;for(let c=0;c!==s;++c){const s=a[l+c],m=a[o+c],f=p*u+2*c,g=d[f],v=d[f+1],_=t*u+2*c,y=h[_],x=h[_+1];let b,S,M,w,E,T=(n-e)/(i-e);for(let t=0;t<8;t++){b=T*T,S=b*T,M=1-T,w=M*M,E=w*M;const t=E*e+3*w*T*g+3*M*b*y+S*i-n;if(Math.abs(t)<1e-10)break;const r=3*w*(g-e)+6*M*T*(y-g)+3*b*(i-y);if(Math.abs(r)<1e-10)break;T-=t/r,T=Math.max(0,Math.min(1,T))}r[c]=E*s+3*w*T*v+3*M*b*x+S*m}return r}}class jc{constructor(t,e,n,i){if(void 0===t)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===e||0===e.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=Uc(e,this.TimeBufferType),this.values=Uc(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:Uc(t.times,Array),values:Uc(t.values,Array)};const e=t.getInterpolation();e!==t.DefaultInterpolation&&(n.interpolation=e)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new Hc(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Vc(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new Gc(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodBezier(t){const e=new Wc(this.times,this.values,this.getValueSize(),t);return this.settings&&(e.settings=this.settings),e}setInterpolation(t){let e;switch(t){case Ln:e=this.InterpolantFactoryMethodDiscrete;break;case Dn:e=this.InterpolantFactoryMethodLinear;break;case Nn:e=this.InterpolantFactoryMethodSmooth;break;case 2303:e=this.InterpolantFactoryMethodBezier}if(void 0===e){const e="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(t===this.DefaultInterpolation)throw new Error(e);this.setInterpolation(this.DefaultInterpolation)}return hi("KeyframeTrack:",e),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Ln;case this.InterpolantFactoryMethodLinear:return Dn;case this.InterpolantFactoryMethodSmooth:return Nn;case this.InterpolantFactoryMethodBezier:return 2303}}getValueSize(){return this.values.length/this.times.length}shift(t){if(0!==t){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(1!==t){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t}return this}trim(t,e){const n=this.times,i=n.length;let r=0,a=i-1;for(;r!==i&&n[r]<t;)++r;for(;-1!==a&&n[a]>e;)--a;if(++a,0!==r||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);const t=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*t,a*t)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!==0&&(di("KeyframeTrack: Invalid value size in track.",this),t=!1);const n=this.times,i=this.values,r=n.length;0===r&&(di("KeyframeTrack: Track is empty.",this),t=!1);let a=null;for(let e=0;e!==r;e++){const i=n[e];if("number"==typeof i&&isNaN(i)){di("KeyframeTrack: Time is not a valid number.",this,e,i),t=!1;break}if(null!==a&&a>i){di("KeyframeTrack: Out of order keys.",this,e,i,a),t=!1;break}a=i}if(void 0!==i&&(s=i,ArrayBuffer.isView(s)&&!(s instanceof DataView)))for(let e=0,n=i.length;e!==n;++e){const n=i[e];if(isNaN(n)){di("KeyframeTrack: Value is not a valid number.",this,e,n),t=!1;break}}var s;return t}optimize(){const t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===Nn,r=t.length-1;let a=1;for(let s=1;s<r;++s){let r=!1;const o=t[s];if(o!==t[s+1]&&(1!==s||o!==t[0]))if(i)r=!0;else{const t=s*n,i=t-n,a=t+n;for(let s=0;s!==n;++s){const n=e[t+s];if(n!==e[i+s]||n!==e[a+s]){r=!0;break}}}if(r){if(s!==a){t[a]=t[s];const i=s*n,r=a*n;for(let t=0;t!==n;++t)e[r+t]=e[i+t]}++a}}if(r>0){t[a]=t[r];for(let t=r*n,i=a*n,s=0;s!==n;++s)e[i+s]=e[t+s];++a}return a!==t.length?(this.times=t.slice(0,a),this.values=e.slice(0,a*n)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),n=new(0,this.constructor)(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}}jc.prototype.ValueTypeName="",jc.prototype.TimeBufferType=Float32Array,jc.prototype.ValueBufferType=Float32Array,jc.prototype.DefaultInterpolation=Dn;class Xc extends jc{constructor(t,e,n){super(t,e,n)}}Xc.prototype.ValueTypeName="bool",Xc.prototype.ValueBufferType=Array,Xc.prototype.DefaultInterpolation=Ln,Xc.prototype.InterpolantFactoryMethodLinear=void 0,Xc.prototype.InterpolantFactoryMethodSmooth=void 0;class qc extends jc{constructor(t,e,n,i){super(t,e,n,i)}}qc.prototype.ValueTypeName="color";class Yc extends jc{constructor(t,e,n,i){super(t,e,n,i)}}Yc.prototype.ValueTypeName="number";class Zc extends Bc{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=(n-e)/(i-e);let l=t*s;for(let t=l+s;l!==t;l+=4)Ai.slerpFlat(r,0,a,l-s,a,l,o);return r}}class $c extends jc{constructor(t,e,n,i){super(t,e,n,i)}InterpolantFactoryMethodLinear(t){return new Zc(this.times,this.values,this.getValueSize(),t)}}$c.prototype.ValueTypeName="quaternion",$c.prototype.InterpolantFactoryMethodSmooth=void 0;class Jc extends jc{constructor(t,e,n){super(t,e,n)}}Jc.prototype.ValueTypeName="string",Jc.prototype.ValueBufferType=Array,Jc.prototype.DefaultInterpolation=Ln,Jc.prototype.InterpolantFactoryMethodLinear=void 0,Jc.prototype.InterpolantFactoryMethodSmooth=void 0;class Kc extends jc{constructor(t,e,n,i){super(t,e,n,i)}}Kc.prototype.ValueTypeName="vector";class Qc{constructor(t="",e=-1,n=[],i=2500){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=yi(),this.userData={},this.duration<0&&this.resetDuration()}static parse(t){const e=[],n=t.tracks,i=1/(t.fps||1);for(let t=0,r=n.length;t!==r;++t)e.push(th(n[t]).scale(i));const r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r.userData=JSON.parse(t.userData||"{}"),r}static toJSON(t){const e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode,userData:JSON.stringify(t.userData)};for(let t=0,i=n.length;t!==i;++t)e.push(jc.toJSON(n[t]));return i}static CreateFromMorphTargetSequence(t,e,n,i){const r=e.length,a=[];for(let t=0;t<r;t++){let s=[],o=[];s.push((t+r-1)%r,t,(t+1)%r),o.push(0,1,0);const l=Fc(s);s=zc(s,1,l),o=zc(o,1,l),i||0!==s[0]||(s.push(r),o.push(o[0])),a.push(new Yc(".morphTargetInfluences["+e[t].name+"]",s,o).scale(1/n))}return new this(t,-1,a)}static findByName(t,e){let n=t;if(!Array.isArray(t)){const e=t;n=e.geometry&&e.geometry.animations||e.animations}for(let t=0;t<n.length;t++)if(n[t].name===e)return n[t];return null}static CreateClipsFromMorphTargetSequences(t,e,n){const i={},r=/^([\w-]*?)([\d]+)$/;for(let e=0,n=t.length;e<n;e++){const n=t[e],a=n.name.match(r);if(a&&a.length>1){const t=a[1];let e=i[t];e||(i[t]=e=[]),e.push(n)}}const a=[];for(const t in i)a.push(this.CreateFromMorphTargetSequence(t,i[t],e,n));return a}static parseAnimation(t,e){if(hi("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!t)return di("AnimationClip: No animation in JSONLoader data."),null;const n=function(t,e,n,i,r){if(0!==n.length){const a=[],s=[];kc(n,a,s,i),0!==a.length&&r.push(new t(e,a,s))}},i=[],r=t.name||"default",a=t.fps||30,s=t.blendMode;let o=t.length||-1;const l=t.hierarchy||[];for(let t=0;t<l.length;t++){const r=l[t].keys;if(r&&0!==r.length)if(r[0].morphTargets){const t={};let e;for(e=0;e<r.length;e++)if(r[e].morphTargets)for(let n=0;n<r[e].morphTargets.length;n++)t[r[e].morphTargets[n]]=-1;for(const n in t){const t=[],a=[];for(let i=0;i!==r[e].morphTargets.length;++i){const i=r[e];t.push(i.time),a.push(i.morphTarget===n?1:0)}i.push(new Yc(".morphTargetInfluence["+n+"]",t,a))}o=t.length*a}else{const a=".bones["+e[t].name+"]";n(Kc,a+".position",r,"pos",i),n($c,a+".quaternion",r,"rot",i),n(Kc,a+".scale",r,"scl",i)}}return 0===i.length?null:new this(r,o,i,s)}resetDuration(){let t=0;for(let e=0,n=this.tracks.length;e!==n;++e){const n=this.tracks[e];t=Math.max(t,n.times[n.times.length-1])}return this.duration=t,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){const t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());const e=new this.constructor(this.name,this.duration,t,this.blendMode);return e.userData=JSON.parse(JSON.stringify(this.userData)),e}toJSON(){return this.constructor.toJSON(this)}}function th(t){if(void 0===t.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Yc;case"vector":case"vector2":case"vector3":case"vector4":return Kc;case"color":return qc;case"quaternion":return $c;case"bool":case"boolean":return Xc;case"string":return Jc}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}(t.type);if(void 0===t.times){const e=[],n=[];kc(t.keys,e,n,"value"),t.times=e,t.values=n}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)}const eh={enabled:!1,files:{},add:function(t,e){!1!==this.enabled&&(nh(t)||(this.files[t]=e))},get:function(t){if(!1!==this.enabled&&!nh(t))return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};function nh(t){try{const e=t.slice(t.indexOf(":")+1);return"blob:"===new URL(e).protocol}catch(t){return!1}}class ih{constructor(t,e,n){const i=this;let r,a=!1,s=0,o=0;const l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this._abortController=null,this.itemStart=function(t){o++,!1===a&&void 0!==i.onStart&&i.onStart(t,s,o),a=!0},this.itemEnd=function(t){s++,void 0!==i.onProgress&&i.onProgress(t,s,o),s===o&&(a=!1,void 0!==i.onLoad&&i.onLoad())},this.itemError=function(t){void 0!==i.onError&&i.onError(t)},this.resolveURL=function(t){return r?r(t):t},this.setURLModifier=function(t){return r=t,this},this.addHandler=function(t,e){return l.push(t,e),this},this.removeHandler=function(t){const e=l.indexOf(t);return-1!==e&&l.splice(e,2),this},this.getHandler=function(t){for(let e=0,n=l.length;e<n;e+=2){const n=l[e],i=l[e+1];if(n.global&&(n.lastIndex=0),n.test(t))return i}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const rh=new ih;class ah{constructor(t){this.manager=void 0!==t?t:rh,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(t,e){const n=this;return new Promise((function(i,r){n.load(t,i,e,r)}))}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}abort(){return this}}ah.DEFAULT_MATERIAL_NAME="__DEFAULT";const sh={};class oh extends Error{constructor(t,e){super(t),this.response=e}}class lh extends ah{constructor(t){super(t),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(t,e,n,i){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=eh.get(`file:${t}`);if(void 0!==r)return this.manager.itemStart(t),void setTimeout((()=>{e&&e(r),this.manager.itemEnd(t)}),0);if(void 0!==sh[t])return void sh[t].push({onLoad:e,onProgress:n,onError:i});sh[t]=[],sh[t].push({onLoad:e,onProgress:n,onError:i});const a=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:"function"==typeof AbortSignal.any?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),s=this.mimeType,o=this.responseType;fetch(a).then((e=>{if(200===e.status||0===e.status){if(0===e.status&&hi("FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===e.body||void 0===e.body.getReader)return e;const n=sh[t],i=e.body.getReader(),r=e.headers.get("X-File-Size")||e.headers.get("Content-Length"),a=r?parseInt(r):0,s=0!==a;let o=0;const l=new ReadableStream({start(t){!function e(){i.read().then((({done:i,value:r})=>{if(i)t.close();else{o+=r.byteLength;const i=new ProgressEvent("progress",{lengthComputable:s,loaded:o,total:a});for(let t=0,e=n.length;t<e;t++){const e=n[t];e.onProgress&&e.onProgress(i)}t.enqueue(r),e()}}),(e=>{t.error(e)}))}()}});return new Response(l)}throw new oh(`fetch for "${e.url}" responded with ${e.status}: ${e.statusText}`,e)})).then((t=>{switch(o){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"document":return t.text().then((t=>(new DOMParser).parseFromString(t,s)));case"json":return t.json();default:if(""===s)return t.text();{const e=/charset="?([^;"\s]*)"?/i.exec(s),n=e&&e[1]?e[1].toLowerCase():void 0,i=new TextDecoder(n);return t.arrayBuffer().then((t=>i.decode(t)))}}})).then((e=>{eh.add(`file:${t}`,e);const n=sh[t];delete sh[t];for(let t=0,i=n.length;t<i;t++){const i=n[t];i.onLoad&&i.onLoad(e)}})).catch((e=>{const n=sh[t];if(void 0===n)throw this.manager.itemError(t),e;delete sh[t];for(let t=0,i=n.length;t<i;t++){const i=n[t];i.onError&&i.onError(e)}this.manager.itemError(t)})).finally((()=>{this.manager.itemEnd(t)})),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const ch=new WeakMap;class hh extends ah{constructor(t){super(t)}load(t,e,n,i){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,a=eh.get(`image:${t}`);if(void 0!==a){if(!0===a.complete)r.manager.itemStart(t),setTimeout((function(){e&&e(a),r.manager.itemEnd(t)}),0);else{let t=ch.get(a);void 0===t&&(t=[],ch.set(a,t)),t.push({onLoad:e,onError:i})}return a}const s=ai("img");function o(){c(),e&&e(this);const n=ch.get(this)||[];for(let t=0;t<n.length;t++){const e=n[t];e.onLoad&&e.onLoad(this)}ch.delete(this),r.manager.itemEnd(t)}function l(e){c(),i&&i(e),eh.remove(`image:${t}`);const n=ch.get(this)||[];for(let t=0;t<n.length;t++){const i=n[t];i.onError&&i.onError(e)}ch.delete(this),r.manager.itemError(t),r.manager.itemEnd(t)}function c(){s.removeEventListener("load",o,!1),s.removeEventListener("error",l,!1)}return s.addEventListener("load",o,!1),s.addEventListener("error",l,!1),"data:"!==t.slice(0,5)&&void 0!==this.crossOrigin&&(s.crossOrigin=this.crossOrigin),eh.add(`image:${t}`,s),r.manager.itemStart(t),s.src=t,s}}class dh extends Er{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Dr(t),this.intensity=e}dispose(){this.dispatchEvent({type:"dispose"})}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,e}}class uh extends dh{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Er.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Dr(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}toJSON(t){const e=super.toJSON(t);return e.object.groundColor=this.groundColor.getHex(),e}}const ph=new Ki,mh=new Ci,fh=new Ci;class gh{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ti(512,512),this.mapType=Ce,this.map=null,this.mapPass=null,this.matrix=new Ki,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new eo,this._frameExtents=new Ti(1,1),this._viewportCount=1,this._viewports=[new qi(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;mh.setFromMatrixPosition(t.matrixWorld),e.position.copy(mh),fh.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(fh),e.updateMatrixWorld(),ph.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ph,e.coordinateSystem,e.reversedDepth),e.coordinateSystem===ni||e.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(ph)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.autoUpdate=t.autoUpdate,this.needsUpdate=t.needsUpdate,this.normalBias=t.normalBias,this.blurSamples=t.blurSamples,this.mapSize.copy(t.mapSize),this.biasNode=t.biasNode,this}clone(){return(new this.constructor).copy(this)}toJSON(){const t={};return 1!==this.intensity&&(t.intensity=this.intensity),0!==this.bias&&(t.bias=this.bias),0!==this.normalBias&&(t.normalBias=this.normalBias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}const vh=new Ci,_h=new Ai,yh=new Ci;class xh extends Er{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ki,this.projectionMatrix=new Ki,this.projectionMatrixInverse=new Ki,this.coordinateSystem=ei,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorld.decompose(vh,_h,yh),1===yh.x&&1===yh.y&&1===yh.z?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(vh,_h,yh.set(1,1,1)).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorld.decompose(vh,_h,yh),1===yh.x&&1===yh.y&&1===yh.z?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(vh,_h,yh.set(1,1,1)).invert()}clone(){return(new this.constructor).copy(this)}}const bh=new Ci,Sh=new Ti,Mh=new Ti;class wh extends xh{constructor(t=50,e=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=2*_i*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*vi*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*_i*Math.atan(Math.tan(.5*vi*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){bh.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(bh.x,bh.y).multiplyScalar(-t/bh.z),bh.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(bh.x,bh.y).multiplyScalar(-t/bh.z)}getViewSize(t,e){return this.getViewBounds(t,Sh,Mh),e.subVectors(Mh,Sh)}setViewOffset(t,e,n,i,r,a){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*vi*this.fov)/this.zoom,n=2*e,i=this.aspect*n,r=-.5*i;const a=this.view;if(null!==this.view&&this.view.enabled){const t=a.fullWidth,s=a.fullHeight;r+=a.offsetX*i/t,e-=a.offsetY*n/s,i*=a.width/t,n*=a.height/s}const s=this.filmOffset;0!==s&&(r+=t*s/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,e,e-n,t,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}class Eh extends gh{constructor(){super(new wh(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(t){const e=this.camera,n=2*_i*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=t.distance||e.far;n===e.fov&&i===e.aspect&&r===e.far||(e.fov=n,e.aspect=i,e.far=r,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class Th extends dh{constructor(t,e,n=0,i=Math.PI/3,r=0,a=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Er.DEFAULT_UP),this.updateMatrix(),this.target=new Er,this.distance=n,this.angle=i,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new Eh}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.map=t.map,this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.distance=this.distance,e.object.angle=this.angle,e.object.decay=this.decay,e.object.penumbra=this.penumbra,e.object.target=this.target.uuid,this.map&&this.map.isTexture&&(e.object.map=this.map.toJSON(t).uuid),e.object.shadow=this.shadow.toJSON(),e}}class Ah extends gh{constructor(){super(new wh(90,1,.5,500)),this.isPointLightShadow=!0}}class Ch extends dh{constructor(t,e,n=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new Ah}get power(){return 4*this.intensity*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.distance=this.distance,e.object.decay=this.decay,e.object.shadow=this.shadow.toJSON(),e}}class Rh extends xh{constructor(t=-1,e=1,n=1,i=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,r,a){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-t,a=n+t,s=i+e,o=i-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=t*this.view.offsetX,a=r+t*this.view.width,s-=e*this.view.offsetY,o=s-e*this.view.height}this.projectionMatrix.makeOrthographic(r,a,s,o,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}class Ih extends gh{constructor(){super(new Rh(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Ph extends dh{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Er.DEFAULT_UP),this.updateMatrix(),this.target=new Er,this.shadow=new Ih}dispose(){super.dispose(),this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.shadow=this.shadow.toJSON(),e.object.target=this.target.uuid,e}}class Lh extends dh{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class Dh extends dh{constructor(t,e,n=10,i=10){super(t,e),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(t){this.intensity=t/(this.width*this.height*Math.PI)}copy(t){return super.copy(t),this.width=t.width,this.height=t.height,this}toJSON(t){const e=super.toJSON(t);return e.object.width=this.width,e.object.height=this.height,e}}class Nh{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new Ci)}set(t){for(let e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this}zero(){for(let t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this}getAt(t,e){const n=t.x,i=t.y,r=t.z,a=this.coefficients;return e.copy(a[0]).multiplyScalar(.282095),e.addScaledVector(a[1],.488603*i),e.addScaledVector(a[2],.488603*r),e.addScaledVector(a[3],.488603*n),e.addScaledVector(a[4],n*i*1.092548),e.addScaledVector(a[5],i*r*1.092548),e.addScaledVector(a[6],.315392*(3*r*r-1)),e.addScaledVector(a[7],n*r*1.092548),e.addScaledVector(a[8],.546274*(n*n-i*i)),e}getIrradianceAt(t,e){const n=t.x,i=t.y,r=t.z,a=this.coefficients;return e.copy(a[0]).multiplyScalar(.886227),e.addScaledVector(a[1],1.023328*i),e.addScaledVector(a[2],1.023328*r),e.addScaledVector(a[3],1.023328*n),e.addScaledVector(a[4],.858086*n*i),e.addScaledVector(a[5],.858086*i*r),e.addScaledVector(a[6],.743125*r*r-.247708),e.addScaledVector(a[7],.858086*n*r),e.addScaledVector(a[8],.429043*(n*n-i*i)),e}add(t){for(let e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this}addScaledSH(t,e){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(t.coefficients[n],e);return this}scale(t){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this}lerp(t,e){for(let n=0;n<9;n++)this.coefficients[n].lerp(t.coefficients[n],e);return this}equals(t){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0}copy(t){return this.set(t.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(t,e=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(t,e+3*i);return this}toArray(t=[],e=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(t,e+3*i);return t}static getBasisAt(t,e){const n=t.x,i=t.y,r=t.z;e[0]=.282095,e[1]=.488603*i,e[2]=.488603*r,e[3]=.488603*n,e[4]=1.092548*n*i,e[5]=1.092548*i*r,e[6]=.315392*(3*r*r-1),e[7]=1.092548*n*r,e[8]=.546274*(n*n-i*i)}}class Oh extends dh{constructor(t=new Nh,e=1){super(void 0,e),this.isLightProbe=!0,this.sh=t}copy(t){return super.copy(t),this.sh.copy(t.sh),this}toJSON(t){const e=super.toJSON(t);return e.object.sh=this.sh.toArray(),e}}class Uh extends ah{constructor(t){super(t),this.textures={}}load(t,e,n,i){const r=this,a=new lh(r.manager);a.setPath(r.path),a.setRequestHeader(r.requestHeader),a.setWithCredentials(r.withCredentials),a.load(t,(function(n){try{e(r.parse(JSON.parse(n)))}catch(e){i?i(e):di(e),r.manager.itemError(t)}}),n,i)}parse(t){const e=this.textures;function n(t){return void 0===e[t]&&hi("MaterialLoader: Undefined texture",t),e[t]}const i=this.createMaterialFromType(t.type);if(void 0!==t.uuid&&(i.uuid=t.uuid),void 0!==t.name&&(i.name=t.name),void 0!==t.color&&void 0!==i.color&&i.color.setHex(t.color),void 0!==t.roughness&&(i.roughness=t.roughness),void 0!==t.metalness&&(i.metalness=t.metalness),void 0!==t.sheen&&(i.sheen=t.sheen),void 0!==t.sheenColor&&(i.sheenColor=(new Dr).setHex(t.sheenColor)),void 0!==t.sheenRoughness&&(i.sheenRoughness=t.sheenRoughness),void 0!==t.emissive&&void 0!==i.emissive&&i.emissive.setHex(t.emissive),void 0!==t.specular&&void 0!==i.specular&&i.specular.setHex(t.specular),void 0!==t.specularIntensity&&(i.specularIntensity=t.specularIntensity),void 0!==t.specularColor&&void 0!==i.specularColor&&i.specularColor.setHex(t.specularColor),void 0!==t.shininess&&(i.shininess=t.shininess),void 0!==t.clearcoat&&(i.clearcoat=t.clearcoat),void 0!==t.clearcoatRoughness&&(i.clearcoatRoughness=t.clearcoatRoughness),void 0!==t.dispersion&&(i.dispersion=t.dispersion),void 0!==t.iridescence&&(i.iridescence=t.iridescence),void 0!==t.iridescenceIOR&&(i.iridescenceIOR=t.iridescenceIOR),void 0!==t.iridescenceThicknessRange&&(i.iridescenceThicknessRange=t.iridescenceThicknessRange),void 0!==t.transmission&&(i.transmission=t.transmission),void 0!==t.thickness&&(i.thickness=t.thickness),void 0!==t.attenuationDistance&&(i.attenuationDistance=t.attenuationDistance),void 0!==t.attenuationColor&&void 0!==i.attenuationColor&&i.attenuationColor.setHex(t.attenuationColor),void 0!==t.anisotropy&&(i.anisotropy=t.anisotropy),void 0!==t.anisotropyRotation&&(i.anisotropyRotation=t.anisotropyRotation),void 0!==t.fog&&(i.fog=t.fog),void 0!==t.flatShading&&(i.flatShading=t.flatShading),void 0!==t.blending&&(i.blending=t.blending),void 0!==t.combine&&(i.combine=t.combine),void 0!==t.side&&(i.side=t.side),void 0!==t.shadowSide&&(i.shadowSide=t.shadowSide),void 0!==t.opacity&&(i.opacity=t.opacity),void 0!==t.transparent&&(i.transparent=t.transparent),void 0!==t.alphaTest&&(i.alphaTest=t.alphaTest),void 0!==t.alphaHash&&(i.alphaHash=t.alphaHash),void 0!==t.depthFunc&&(i.depthFunc=t.depthFunc),void 0!==t.depthTest&&(i.depthTest=t.depthTest),void 0!==t.depthWrite&&(i.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(i.colorWrite=t.colorWrite),void 0!==t.blendSrc&&(i.blendSrc=t.blendSrc),void 0!==t.blendDst&&(i.blendDst=t.blendDst),void 0!==t.blendEquation&&(i.blendEquation=t.blendEquation),void 0!==t.blendSrcAlpha&&(i.blendSrcAlpha=t.blendSrcAlpha),void 0!==t.blendDstAlpha&&(i.blendDstAlpha=t.blendDstAlpha),void 0!==t.blendEquationAlpha&&(i.blendEquationAlpha=t.blendEquationAlpha),void 0!==t.blendColor&&void 0!==i.blendColor&&i.blendColor.setHex(t.blendColor),void 0!==t.blendAlpha&&(i.blendAlpha=t.blendAlpha),void 0!==t.stencilWriteMask&&(i.stencilWriteMask=t.stencilWriteMask),void 0!==t.stencilFunc&&(i.stencilFunc=t.stencilFunc),void 0!==t.stencilRef&&(i.stencilRef=t.stencilRef),void 0!==t.stencilFuncMask&&(i.stencilFuncMask=t.stencilFuncMask),void 0!==t.stencilFail&&(i.stencilFail=t.stencilFail),void 0!==t.stencilZFail&&(i.stencilZFail=t.stencilZFail),void 0!==t.stencilZPass&&(i.stencilZPass=t.stencilZPass),void 0!==t.stencilWrite&&(i.stencilWrite=t.stencilWrite),void 0!==t.wireframe&&(i.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(i.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(i.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(i.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.rotation&&(i.rotation=t.rotation),void 0!==t.linewidth&&(i.linewidth=t.linewidth),void 0!==t.dashSize&&(i.dashSize=t.dashSize),void 0!==t.gapSize&&(i.gapSize=t.gapSize),void 0!==t.scale&&(i.scale=t.scale),void 0!==t.polygonOffset&&(i.polygonOffset=t.polygonOffset),void 0!==t.polygonOffsetFactor&&(i.polygonOffsetFactor=t.polygonOffsetFactor),void 0!==t.polygonOffsetUnits&&(i.polygonOffsetUnits=t.polygonOffsetUnits),void 0!==t.dithering&&(i.dithering=t.dithering),void 0!==t.alphaToCoverage&&(i.alphaToCoverage=t.alphaToCoverage),void 0!==t.premultipliedAlpha&&(i.premultipliedAlpha=t.premultipliedAlpha),void 0!==t.forceSinglePass&&(i.forceSinglePass=t.forceSinglePass),void 0!==t.allowOverride&&(i.allowOverride=t.allowOverride),void 0!==t.visible&&(i.visible=t.visible),void 0!==t.toneMapped&&(i.toneMapped=t.toneMapped),void 0!==t.userData&&(i.userData=t.userData),void 0!==t.vertexColors&&("number"==typeof t.vertexColors?i.vertexColors=t.vertexColors>0:i.vertexColors=t.vertexColors),void 0!==t.uniforms)for(const e in t.uniforms){const r=t.uniforms[e];switch(i.uniforms[e]={},r.type){case"t":i.uniforms[e].value=n(r.value);break;case"c":i.uniforms[e].value=(new Dr).setHex(r.value);break;case"v2":i.uniforms[e].value=(new Ti).fromArray(r.value);break;case"v3":i.uniforms[e].value=(new Ci).fromArray(r.value);break;case"v4":i.uniforms[e].value=(new qi).fromArray(r.value);break;case"m3":i.uniforms[e].value=(new Pi).fromArray(r.value);break;case"m4":i.uniforms[e].value=(new Ki).fromArray(r.value);break;default:i.uniforms[e].value=r.value}}if(void 0!==t.defines&&(i.defines=t.defines),void 0!==t.vertexShader&&(i.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(i.fragmentShader=t.fragmentShader),void 0!==t.glslVersion&&(i.glslVersion=t.glslVersion),void 0!==t.extensions)for(const e in t.extensions)i.extensions[e]=t.extensions[e];if(void 0!==t.lights&&(i.lights=t.lights),void 0!==t.clipping&&(i.clipping=t.clipping),void 0!==t.size&&(i.size=t.size),void 0!==t.sizeAttenuation&&(i.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(i.map=n(t.map)),void 0!==t.matcap&&(i.matcap=n(t.matcap)),void 0!==t.alphaMap&&(i.alphaMap=n(t.alphaMap)),void 0!==t.bumpMap&&(i.bumpMap=n(t.bumpMap)),void 0!==t.bumpScale&&(i.bumpScale=t.bumpScale),void 0!==t.normalMap&&(i.normalMap=n(t.normalMap)),void 0!==t.normalMapType&&(i.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),i.normalScale=(new Ti).fromArray(e)}return void 0!==t.displacementMap&&(i.displacementMap=n(t.displacementMap)),void 0!==t.displacementScale&&(i.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(i.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(i.roughnessMap=n(t.roughnessMap)),void 0!==t.metalnessMap&&(i.metalnessMap=n(t.metalnessMap)),void 0!==t.emissiveMap&&(i.emissiveMap=n(t.emissiveMap)),void 0!==t.emissiveIntensity&&(i.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(i.specularMap=n(t.specularMap)),void 0!==t.specularIntensityMap&&(i.specularIntensityMap=n(t.specularIntensityMap)),void 0!==t.specularColorMap&&(i.specularColorMap=n(t.specularColorMap)),void 0!==t.envMap&&(i.envMap=n(t.envMap)),void 0!==t.envMapRotation&&i.envMapRotation.fromArray(t.envMapRotation),void 0!==t.envMapIntensity&&(i.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(i.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(i.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(i.lightMap=n(t.lightMap)),void 0!==t.lightMapIntensity&&(i.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(i.aoMap=n(t.aoMap)),void 0!==t.aoMapIntensity&&(i.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(i.gradientMap=n(t.gradientMap)),void 0!==t.clearcoatMap&&(i.clearcoatMap=n(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=n(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(i.clearcoatNormalMap=n(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(i.clearcoatNormalScale=(new Ti).fromArray(t.clearcoatNormalScale)),void 0!==t.iridescenceMap&&(i.iridescenceMap=n(t.iridescenceMap)),void 0!==t.iridescenceThicknessMap&&(i.iridescenceThicknessMap=n(t.iridescenceThicknessMap)),void 0!==t.transmissionMap&&(i.transmissionMap=n(t.transmissionMap)),void 0!==t.thicknessMap&&(i.thicknessMap=n(t.thicknessMap)),void 0!==t.anisotropyMap&&(i.anisotropyMap=n(t.anisotropyMap)),void 0!==t.sheenColorMap&&(i.sheenColorMap=n(t.sheenColorMap)),void 0!==t.sheenRoughnessMap&&(i.sheenRoughnessMap=n(t.sheenRoughnessMap)),i}setTextures(t){return this.textures=t,this}createMaterialFromType(t){return Uh.createMaterialFromType(t)}static createMaterialFromType(t){return new{ShadowMaterial:_c,SpriteMaterial:za,RawShaderMaterial:Ec,ShaderMaterial:wc,PointsMaterial:ko,MeshPhysicalMaterial:Ac,MeshStandardMaterial:Tc,MeshPhongMaterial:Cc,MeshToonMaterial:Rc,MeshNormalMaterial:Ic,MeshLambertMaterial:Pc,MeshDepthMaterial:Lc,MeshDistanceMaterial:Dc,MeshBasicMaterial:hs,MeshMatcapMaterial:Nc,LineDashedMaterial:Oc,LineBasicMaterial:Eo,Material:Fa}[t]}}class Fh{static extractUrlBase(t){const e=t.lastIndexOf("/");return-1===e?"./":t.slice(0,e+1)}static resolveURL(t,e){return"string"!=typeof t||""===t?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}}class zh extends Pa{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){const t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}}class kh extends ah{constructor(t){super(t)}load(t,e,n,i){const r=this,a=new lh(r.manager);a.setPath(r.path),a.setRequestHeader(r.requestHeader),a.setWithCredentials(r.withCredentials),a.load(t,(function(n){try{e(r.parse(JSON.parse(n)))}catch(e){i?i(e):di(e),r.manager.itemError(t)}}),n,i)}parse(t){const e={},n={};function i(t,i){if(void 0!==e[i])return e[i];const r=t.interleavedBuffers[i],a=function(t,e){if(void 0!==n[e])return n[e];const i=t.arrayBuffers,r=i[e],a=new Uint32Array(r).buffer;return n[e]=a,a}(t,r.buffer),s=ri(r.type,a),o=new La(s,r.stride);return o.uuid=r.uuid,e[i]=o,o}const r=t.isInstancedBufferGeometry?new zh:new Pa,a=t.data.index;if(void 0!==a){const t=ri(a.type,a.array);r.setIndex(new ga(t,1))}const s=t.data.attributes;for(const e in s){const n=s[e];let a;if(n.isInterleavedBufferAttribute){const e=i(t.data,n.data);a=new Na(e,n.itemSize,n.offset,n.normalized)}else{const t=ri(n.type,n.array);a=new(n.isInstancedBufferAttribute?ks:ga)(t,n.itemSize,n.normalized)}void 0!==n.name&&(a.name=n.name),void 0!==n.usage&&a.setUsage(n.usage),r.setAttribute(e,a)}const o=t.data.morphAttributes;if(o)for(const e in o){const n=o[e],a=[];for(let e=0,r=n.length;e<r;e++){const r=n[e];let s;if(r.isInterleavedBufferAttribute){const e=i(t.data,r.data);s=new Na(e,r.itemSize,r.offset,r.normalized)}else{const t=ri(r.type,r.array);s=new ga(t,r.itemSize,r.normalized)}void 0!==r.name&&(s.name=r.name),a.push(s)}r.morphAttributes[e]=a}t.data.morphTargetsRelative&&(r.morphTargetsRelative=!0);const l=t.data.groups||t.data.drawcalls||t.data.offsets;if(void 0!==l)for(let t=0,e=l.length;t!==e;++t){const e=l[t];r.addGroup(e.start,e.count,e.materialIndex)}const c=t.data.boundingSphere;return void 0!==c&&(r.boundingSphere=(new Ma).fromJSON(c)),t.name&&(r.name=t.name),t.userData&&(r.userData=t.userData),r}}const Bh={};class Gh extends ah{constructor(t){super(t)}load(t,e,n,i){const r=this,a=""===this.path?Fh.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||a;const s=new lh(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,(function(n){let a=null;try{a=JSON.parse(n)}catch(e){return void 0!==i&&i(e),void di("ObjectLoader: Can't parse "+t+".",e.message)}const s=a.metadata;if(void 0===s||void 0===s.type||"geometry"===s.type.toLowerCase())return void 0!==i&&i(new Error("THREE.ObjectLoader: Can't load "+t)),void di("ObjectLoader: Can't load "+t);r.parse(a,e)}),n,i)}async loadAsync(t,e){const n=""===this.path?Fh.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||n;const i=new lh(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials);const r=await i.loadAsync(t,e);let a;try{a=JSON.parse(r)}catch(e){throw new Error("ObjectLoader: Can't parse "+t+". "+e.message)}const s=a.metadata;if(void 0===s||void 0===s.type||"geometry"===s.type.toLowerCase())throw new Error("THREE.ObjectLoader: Can't load "+t);return await this.parseAsync(a)}parse(t,e){const n=this.parseAnimations(t.animations),i=this.parseShapes(t.shapes),r=this.parseGeometries(t.geometries,i),a=this.parseImages(t.images,(function(){void 0!==e&&e(l)})),s=this.parseTextures(t.textures,a),o=this.parseMaterials(t.materials,s),l=this.parseObject(t.object,r,o,s,n),c=this.parseSkeletons(t.skeletons,l);if(this.bindSkeletons(l,c),this.bindLightTargets(l),void 0!==e){let t=!1;for(const e in a)if(a[e].data instanceof HTMLImageElement){t=!0;break}!1===t&&e(l)}return l}async parseAsync(t){const e=this.parseAnimations(t.animations),n=this.parseShapes(t.shapes),i=this.parseGeometries(t.geometries,n),r=await this.parseImagesAsync(t.images),a=this.parseTextures(t.textures,r),s=this.parseMaterials(t.materials,a),o=this.parseObject(t.object,i,s,a,e),l=this.parseSkeletons(t.skeletons,o);return this.bindSkeletons(o,l),this.bindLightTargets(o),o}static registerGeometry(t,e){Bh[t]=e}parseShapes(t){const e={};if(void 0!==t)for(let n=0,i=t.length;n<i;n++){const i=(new Tl).fromJSON(t[n]);e[i.uuid]=i}return e}parseSkeletons(t,e){const n={},i={};if(e.traverse((function(t){t.isBone&&(i[t.uuid]=t)})),void 0!==t)for(let e=0,r=t.length;e<r;e++){const r=(new zs).fromJSON(t[e],i);n[r.uuid]=r}return n}parseGeometries(t,e){const n={};if(void 0!==t){const i=new kh;for(let r=0,a=t.length;r<a;r++){let a;const s=t[r];switch(s.type){case"BufferGeometry":case"InstancedBufferGeometry":a=i.parse(s);break;default:s.type in vc?a=vc[s.type].fromJSON(s,e):s.type in Bh?a=Bh[s.type].fromJSON(s,e):hi(`ObjectLoader: Unknown geometry type "${s.type}". Use .registerGeometry() before starting the deserialization process.`)}a.uuid=s.uuid,void 0!==s.name&&(a.name=s.name),void 0!==s.userData&&(a.userData=s.userData),n[s.uuid]=a}}return n}parseMaterials(t,e){const n={},i={};if(void 0!==t){const r=new Uh;r.setTextures(e);for(let e=0,a=t.length;e<a;e++){const a=t[e];void 0===n[a.uuid]&&(n[a.uuid]=r.parse(a)),i[a.uuid]=n[a.uuid]}}return i}parseAnimations(t){const e={};if(void 0!==t)for(let n=0;n<t.length;n++){const i=t[n],r=Qc.parse(i);e[r.uuid]=r}return e}parseImages(t,e){const n=this,i={};let r;function a(t){if("string"==typeof t){const e=t;return function(t){return n.manager.itemStart(t),r.load(t,(function(){n.manager.itemEnd(t)}),void 0,(function(){n.manager.itemError(t),n.manager.itemEnd(t)}))}(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(e)?e:n.resourcePath+e)}return t.data?{data:ri(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){const n=new ih(e);r=new hh(n),r.setCrossOrigin(this.crossOrigin);for(let e=0,n=t.length;e<n;e++){const n=t[e],r=n.url;if(Array.isArray(r)){const t=[];for(let e=0,n=r.length;e<n;e++){const n=a(r[e]);null!==n&&(n instanceof HTMLImageElement?t.push(n):t.push(new Os(n.data,n.width,n.height)))}i[n.uuid]=new Vi(t)}else{const t=a(n.url);i[n.uuid]=new Vi(t)}}}return i}async parseImagesAsync(t){const e=this,n={};let i;async function r(t){if("string"==typeof t){const n=t,r=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(n)?n:e.resourcePath+n;return await i.loadAsync(r)}return t.data?{data:ri(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){i=new hh(this.manager),i.setCrossOrigin(this.crossOrigin);for(let e=0,i=t.length;e<i;e++){const i=t[e],a=i.url;if(Array.isArray(a)){const t=[];for(let e=0,n=a.length;e<n;e++){const n=a[e],i=await r(n);null!==i&&(i instanceof HTMLImageElement?t.push(i):t.push(new Os(i.data,i.width,i.height)))}n[i.uuid]=new Vi(t)}else{const t=await r(i.url);n[i.uuid]=new Vi(t)}}}return n}parseTextures(t,e){function n(t,e){return"number"==typeof t?t:(hi("ObjectLoader.parseTexture: Constant should be in numeric form.",t),e[t])}const i={};if(void 0!==t)for(let r=0,a=t.length;r<a;r++){const a=t[r];void 0===a.image&&hi('ObjectLoader: No "image" specified for',a.uuid),void 0===e[a.image]&&hi("ObjectLoader: Undefined image",a.image);const s=e[a.image],o=s.data;let l;Array.isArray(o)?(l=new Xo,6===o.length&&(l.needsUpdate=!0)):(l=o&&o.data?new Os:new Xi,o&&(l.needsUpdate=!0)),l.source=s,l.uuid=a.uuid,void 0!==a.name&&(l.name=a.name),void 0!==a.mapping&&(l.mapping=n(a.mapping,Vh)),void 0!==a.channel&&(l.channel=a.channel),void 0!==a.offset&&l.offset.fromArray(a.offset),void 0!==a.repeat&&l.repeat.fromArray(a.repeat),void 0!==a.center&&l.center.fromArray(a.center),void 0!==a.rotation&&(l.rotation=a.rotation),void 0!==a.wrap&&(l.wrapS=n(a.wrap[0],Hh),l.wrapT=n(a.wrap[1],Hh)),void 0!==a.format&&(l.format=a.format),void 0!==a.internalFormat&&(l.internalFormat=a.internalFormat),void 0!==a.type&&(l.type=a.type),void 0!==a.colorSpace&&(l.colorSpace=a.colorSpace),void 0!==a.minFilter&&(l.minFilter=n(a.minFilter,Wh)),void 0!==a.magFilter&&(l.magFilter=n(a.magFilter,Wh)),void 0!==a.anisotropy&&(l.anisotropy=a.anisotropy),void 0!==a.flipY&&(l.flipY=a.flipY),void 0!==a.generateMipmaps&&(l.generateMipmaps=a.generateMipmaps),void 0!==a.premultiplyAlpha&&(l.premultiplyAlpha=a.premultiplyAlpha),void 0!==a.unpackAlignment&&(l.unpackAlignment=a.unpackAlignment),void 0!==a.compareFunction&&(l.compareFunction=a.compareFunction),void 0!==a.normalized&&(l.normalized=a.normalized),void 0!==a.userData&&(l.userData=a.userData),i[a.uuid]=l}return i}parseObject(t,e,n,i,r){let a,s,o;function l(t){return void 0===e[t]&&hi("ObjectLoader: Undefined geometry",t),e[t]}function c(t){if(void 0!==t){if(Array.isArray(t)){const e=[];for(let i=0,r=t.length;i<r;i++){const r=t[i];void 0===n[r]&&hi("ObjectLoader: Undefined material",r),e.push(n[r])}return e}return void 0===n[t]&&hi("ObjectLoader: Undefined material",t),n[t]}}function h(t){return void 0===i[t]&&hi("ObjectLoader: Undefined texture",t),i[t]}switch(t.type){case"Scene":a=new Fr,void 0!==t.background&&(Number.isInteger(t.background)?a.background=new Dr(t.background):a.background=h(t.background)),void 0!==t.environment&&(a.environment=h(t.environment)),void 0!==t.fog&&("Fog"===t.fog.type?a.fog=new Ur(t.fog.color,t.fog.near,t.fog.far):"FogExp2"===t.fog.type&&(a.fog=new Or(t.fog.color,t.fog.density)),""!==t.fog.name&&(a.fog.name=t.fog.name)),void 0!==t.backgroundBlurriness&&(a.backgroundBlurriness=t.backgroundBlurriness),void 0!==t.backgroundIntensity&&(a.backgroundIntensity=t.backgroundIntensity),void 0!==t.backgroundRotation&&a.backgroundRotation.fromArray(t.backgroundRotation),void 0!==t.environmentIntensity&&(a.environmentIntensity=t.environmentIntensity),void 0!==t.environmentRotation&&a.environmentRotation.fromArray(t.environmentRotation);break;case"PerspectiveCamera":a=new wh(t.fov,t.aspect,t.near,t.far),void 0!==t.focus&&(a.focus=t.focus),void 0!==t.zoom&&(a.zoom=t.zoom),void 0!==t.filmGauge&&(a.filmGauge=t.filmGauge),void 0!==t.filmOffset&&(a.filmOffset=t.filmOffset),void 0!==t.view&&(a.view=Object.assign({},t.view));break;case"OrthographicCamera":a=new Rh(t.left,t.right,t.top,t.bottom,t.near,t.far),void 0!==t.zoom&&(a.zoom=t.zoom),void 0!==t.view&&(a.view=Object.assign({},t.view));break;case"AmbientLight":a=new Lh(t.color,t.intensity);break;case"DirectionalLight":a=new Ph(t.color,t.intensity),a.target=t.target||"";break;case"PointLight":a=new Ch(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":a=new Dh(t.color,t.intensity,t.width,t.height);break;case"SpotLight":a=new Th(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay),a.target=t.target||"";break;case"HemisphereLight":a=new uh(t.color,t.groundColor,t.intensity);break;case"LightProbe":const e=(new Nh).fromArray(t.sh);a=new Oh(e,t.intensity);break;case"SkinnedMesh":s=l(t.geometry),o=c(t.material),a=new Ds(s,o),void 0!==t.bindMode&&(a.bindMode=t.bindMode),void 0!==t.bindMatrix&&a.bindMatrix.fromArray(t.bindMatrix),void 0!==t.skeleton&&(a.skeleton=t.skeleton);break;case"Mesh":s=l(t.geometry),o=c(t.material),a=new Ss(s,o);break;case"InstancedMesh":s=l(t.geometry),o=c(t.material);const n=t.count,i=t.instanceMatrix,r=t.instanceColor;a=new qs(s,o,n),a.instanceMatrix=new ks(new Float32Array(i.array),16),void 0!==r&&(a.instanceColor=new ks(new Float32Array(r.array),r.itemSize));break;case"BatchedMesh":s=l(t.geometry),o=c(t.material),a=new wo(t.maxInstanceCount,t.maxVertexCount,t.maxIndexCount,o),a.geometry=s,a.perObjectFrustumCulled=t.perObjectFrustumCulled,a.sortObjects=t.sortObjects,a._drawRanges=t.drawRanges,a._reservedRanges=t.reservedRanges,a._geometryInfo=t.geometryInfo.map((t=>{let e=null,n=null;return void 0!==t.boundingBox&&(e=(new Kr).fromJSON(t.boundingBox)),void 0!==t.boundingSphere&&(n=(new Ma).fromJSON(t.boundingSphere)),{...t,boundingBox:e,boundingSphere:n}})),a._instanceInfo=t.instanceInfo,a._availableInstanceIds=t._availableInstanceIds,a._availableGeometryIds=t._availableGeometryIds,a._nextIndexStart=t.nextIndexStart,a._nextVertexStart=t.nextVertexStart,a._geometryCount=t.geometryCount,a._maxInstanceCount=t.maxInstanceCount,a._maxVertexCount=t.maxVertexCount,a._maxIndexCount=t.maxIndexCount,a._geometryInitialized=t.geometryInitialized,a._matricesTexture=h(t.matricesTexture.uuid),a._indirectTexture=h(t.indirectTexture.uuid),void 0!==t.colorsTexture&&(a._colorsTexture=h(t.colorsTexture.uuid)),void 0!==t.boundingSphere&&(a.boundingSphere=(new Ma).fromJSON(t.boundingSphere)),void 0!==t.boundingBox&&(a.boundingBox=(new Kr).fromJSON(t.boundingBox));break;case"LOD":a=new es;break;case"Line":a=new Do(l(t.geometry),c(t.material));break;case"LineLoop":a=new zo(l(t.geometry),c(t.material));break;case"LineSegments":a=new Fo(l(t.geometry),c(t.material));break;case"PointCloud":case"Points":a=new Wo(l(t.geometry),c(t.material));break;case"Sprite":a=new Ja(c(t.material));break;case"Group":a=new Tr;break;case"Bone":a=new Ns;break;default:a=new Er}if(a.uuid=t.uuid,void 0!==t.name&&(a.name=t.name),void 0!==t.matrix?(a.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(a.matrixAutoUpdate=t.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(void 0!==t.position&&a.position.fromArray(t.position),void 0!==t.rotation&&a.rotation.fromArray(t.rotation),void 0!==t.quaternion&&a.quaternion.fromArray(t.quaternion),void 0!==t.scale&&a.scale.fromArray(t.scale)),void 0!==t.up&&a.up.fromArray(t.up),void 0!==t.pivot&&(a.pivot=(new Ci).fromArray(t.pivot)),void 0!==t.morphTargetDictionary&&(a.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),void 0!==t.morphTargetInfluences&&(a.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.castShadow&&(a.castShadow=t.castShadow),void 0!==t.receiveShadow&&(a.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.intensity&&(a.shadow.intensity=t.shadow.intensity),void 0!==t.shadow.bias&&(a.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(a.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(a.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&a.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(a.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(a.visible=t.visible),void 0!==t.frustumCulled&&(a.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(a.renderOrder=t.renderOrder),void 0!==t.static&&(a.static=t.static),void 0!==t.userData&&(a.userData=t.userData),void 0!==t.layers&&(a.layers.mask=t.layers),void 0!==t.children){const s=t.children;for(let t=0;t<s.length;t++)a.add(this.parseObject(s[t],e,n,i,r))}if(void 0!==t.animations){const e=t.animations;for(let t=0;t<e.length;t++){const n=e[t];a.animations.push(r[n])}}if("LOD"===t.type){void 0!==t.autoUpdate&&(a.autoUpdate=t.autoUpdate);const e=t.levels;for(let t=0;t<e.length;t++){const n=e[t],i=a.getObjectByProperty("uuid",n.object);void 0!==i&&a.addLevel(i,n.distance,n.hysteresis)}}return a}bindSkeletons(t,e){0!==Object.keys(e).length&&t.traverse((function(t){if(!0===t.isSkinnedMesh&&void 0!==t.skeleton){const n=e[t.skeleton];void 0===n?hi("ObjectLoader: No skeleton found with UUID:",t.skeleton):t.bind(n,t.bindMatrix)}}))}bindLightTargets(t){t.traverse((function(e){if(e.isDirectionalLight||e.isSpotLight){const n=e.target,i=t.getObjectByProperty("uuid",n);e.target=void 0!==i?i:new Er}}))}}const Vh={UVMapping:300,CubeReflectionMapping:me,CubeRefractionMapping:fe,EquirectangularReflectionMapping:ge,EquirectangularRefractionMapping:ve,CubeUVReflectionMapping:_e},Hh={RepeatWrapping:ye,ClampToEdgeWrapping:xe,MirroredRepeatWrapping:be},Wh={NearestFilter:Se,NearestMipmapNearestFilter:1004,NearestMipmapLinearFilter:we,LinearFilter:Ee,LinearMipmapNearestFilter:Te,LinearMipmapLinearFilter:Ae},jh=-90;class Xh extends Er{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new wh(jh,1,t,e);i.layers=this.layers,this.add(i);const r=new wh(jh,1,t,e);r.layers=this.layers,this.add(r);const a=new wh(jh,1,t,e);a.layers=this.layers,this.add(a);const s=new wh(jh,1,t,e);s.layers=this.layers,this.add(s);const o=new wh(jh,1,t,e);o.layers=this.layers,this.add(o);const l=new wh(jh,1,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,i,r,a,s,o]=e;for(const t of e)this.remove(t);if(t===ei)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),s.up.set(0,1,0),s.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(t!==ni)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),s.up.set(0,-1,0),s.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const t of e)this.add(t),t.updateMatrixWorld()}update(t,e){null===this.parent&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[r,a,s,o,l,c]=this.children,h=t.getRenderTarget(),d=t.getActiveCubeFace(),u=t.getActiveMipmapLevel(),p=t.xr.enabled;t.xr.enabled=!1;const m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let f=!1;f=!0===t.isWebGLRenderer?t.state.buffers.depth.getReversed():t.reversedDepthBuffer,t.setRenderTarget(n,0,i),f&&!1===t.autoClear&&t.clearDepth(),t.render(e,r),t.setRenderTarget(n,1,i),f&&!1===t.autoClear&&t.clearDepth(),t.render(e,a),t.setRenderTarget(n,2,i),f&&!1===t.autoClear&&t.clearDepth(),t.render(e,s),t.setRenderTarget(n,3,i),f&&!1===t.autoClear&&t.clearDepth(),t.render(e,o),t.setRenderTarget(n,4,i),f&&!1===t.autoClear&&t.clearDepth(),t.render(e,l),n.texture.generateMipmaps=m,t.setRenderTarget(n,5,i),f&&!1===t.autoClear&&t.clearDepth(),t.render(e,c),t.setRenderTarget(h,d,u),t.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class qh extends wh{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}}class Yh{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(t){this._document=t,void 0!==t.hidden&&(this._pageVisibilityHandler=Zh.bind(this),t.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){null!==this._pageVisibilityHandler&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(t){return this._timescale=t,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(t){return null!==this._pageVisibilityHandler&&!0===this._document.hidden?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(void 0!==t?t:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}}function Zh(){!1===this._document.hidden&&this.reset()}class $h{constructor(t,e,n){let i,r,a;switch(this.binding=t,this.valueSize=n,e){case"quaternion":i=this._slerp,r=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*n),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(5*n);break;default:i=this._lerp,r=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*n)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){const n=this.buffer,i=this.valueSize,r=t*i+i;let a=this.cumulativeWeight;if(0===a){for(let t=0;t!==i;++t)n[r+t]=n[t];a=e}else{a+=e;const t=e/a;this._mixBufferRegion(n,r,0,t,i)}this.cumulativeWeight=a}accumulateAdditive(t){const e=this.buffer,n=this.valueSize,i=n*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(e,i,0,t,n),this.cumulativeWeightAdditive+=t}apply(t){const e=this.valueSize,n=this.buffer,i=t*e+e,r=this.cumulativeWeight,a=this.cumulativeWeightAdditive,s=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const t=e*this._origIndex;this._mixBufferRegion(n,i,t,1-r,e)}a>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*e,1,e);for(let t=e,r=e+e;t!==r;++t)if(n[t]!==n[t+e]){s.setValue(n,i);break}}saveOriginalState(){const t=this.binding,e=this.buffer,n=this.valueSize,i=n*this._origIndex;t.getValue(e,i);for(let t=n,r=i;t!==r;++t)e[t]=e[i+t%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=3*this.valueSize;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n<e;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[e+n]=this.buffer[t+n]}_select(t,e,n,i,r){if(i>=.5)for(let i=0;i!==r;++i)t[e+i]=t[n+i]}_slerp(t,e,n,i){Ai.slerpFlat(t,e,t,e,t,n,i)}_slerpAdditive(t,e,n,i,r){const a=this._workIndex*r;Ai.multiplyQuaternionsFlat(t,a,t,e,t,n),Ai.slerpFlat(t,e,t,e,t,a,i)}_lerp(t,e,n,i,r){const a=1-i;for(let s=0;s!==r;++s){const r=e+s;t[r]=t[r]*a+t[n+s]*i}}_lerpAdditive(t,e,n,i,r){for(let a=0;a!==r;++a){const r=e+a;t[r]=t[r]+t[n+a]*i}}}const Jh="\\[\\]\\.:\\/",Kh=new RegExp("["+Jh+"]","g"),Qh="[^"+Jh+"]",td="[^"+Jh.replace("\\.","")+"]",ed=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",Qh)+/(WCOD+)?/.source.replace("WCOD",td)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Qh)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Qh)+"$"),nd=["material","materials","bones","map"];class id{constructor(t,e,n){this.path=e,this.parsedPath=n||id.parseTrackName(e),this.node=id.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new id.Composite(t,e,n):new id(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(Kh,"")}static parseTrackName(t){const e=ed.exec(t);if(null===e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const t=n.nodeName.substring(i+1);-1!==nd.indexOf(t)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=t)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(void 0===e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const n=t.skeleton.getBoneByName(e);if(void 0!==n)return n}if(t.children){const n=function(t){for(let i=0;i<t.length;i++){const r=t[i];if(r.name===e||r.uuid===e)return r;const a=n(r.children);if(a)return a}return null},i=n(t.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)t[e++]=n[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node;const e=this.parsedPath,n=e.objectName,i=e.propertyName;let r=e.propertyIndex;if(t||(t=id.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t)return void hi("PropertyBinding: No target node found for track: "+this.path+".");if(n){let i=e.objectIndex;switch(n){case"materials":if(!t.material)return void di("PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.materials)return void di("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);t=t.material.materials;break;case"bones":if(!t.skeleton)return void di("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);t=t.skeleton.bones;for(let e=0;e<t.length;e++)if(t[e].name===i){i=e;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material)return void di("PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.map)return void di("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);t=t.material.map;break;default:if(void 0===t[n])return void di("PropertyBinding: Can not bind to objectName of node undefined.",this);t=t[n]}if(void 0!==i){if(void 0===t[i])return void di("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);t=t[i]}}const a=t[i];if(void 0===a)return void di("PropertyBinding: Trying to update property for track: "+e.nodeName+"."+i+" but it wasn't found.",t);let s=this.Versioning.None;this.targetObject=t,!0===t.isMaterial?s=this.Versioning.NeedsUpdate:!0===t.isObject3D&&(s=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(void 0!==r){if("morphTargetInfluences"===i){if(!t.geometry)return void di("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!t.geometry.morphAttributes)return void di("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==t.morphTargetDictionary[r]&&(r=t.morphTargetDictionary[r])}o=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}else void 0!==a.fromArray&&void 0!==a.toArray?(o=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(o=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=i;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][s]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}id.Composite=class{constructor(t,e,n){const i=n||id.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];void 0!==i&&i.getValue(t,e)}setValue(t,e){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},id.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},id.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},id.prototype.GetterByBindingType=[id.prototype._getValue_direct,id.prototype._getValue_array,id.prototype._getValue_arrayElement,id.prototype._getValue_toArray],id.prototype.SetterByBindingTypeAndVersioning=[[id.prototype._setValue_direct,id.prototype._setValue_direct_setNeedsUpdate,id.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[id.prototype._setValue_array,id.prototype._setValue_array_setNeedsUpdate,id.prototype._setValue_array_setMatrixWorldNeedsUpdate],[id.prototype._setValue_arrayElement,id.prototype._setValue_arrayElement_setNeedsUpdate,id.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[id.prototype._setValue_fromArray,id.prototype._setValue_fromArray_setNeedsUpdate,id.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class rd{constructor(){this.isAnimationObjectGroup=!0,this.uuid=yi(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const t={};this._indicesByUUID=t;for(let e=0,n=arguments.length;e!==n;++e)t[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}add(){const t=this._objects,e=this._indicesByUUID,n=this._paths,i=this._parsedPaths,r=this._bindings,a=r.length;let s,o=t.length,l=this.nCachedObjects_;for(let c=0,h=arguments.length;c!==h;++c){const h=arguments[c],d=h.uuid;let u=e[d];if(void 0===u){u=o++,e[d]=u,t.push(h);for(let t=0,e=a;t!==e;++t)r[t].push(new id(h,n[t],i[t]))}else if(u<l){s=t[u];const o=--l,c=t[o];e[c.uuid]=u,t[u]=c,e[d]=o,t[o]=h;for(let t=0,e=a;t!==e;++t){const e=r[t],a=e[o];let s=e[u];e[u]=a,void 0===s&&(s=new id(h,n[t],i[t])),e[o]=s}}else t[u]!==s&&di("AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_;for(let a=0,s=arguments.length;a!==s;++a){const s=arguments[a],o=s.uuid,l=e[o];if(void 0!==l&&l>=r){const a=r++,c=t[a];e[c.uuid]=l,t[l]=c,e[o]=a,t[a]=s;for(let t=0,e=i;t!==e;++t){const e=n[t],i=e[a],r=e[l];e[l]=i,e[a]=r}}}this.nCachedObjects_=r}uncache(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_,a=t.length;for(let s=0,o=arguments.length;s!==o;++s){const o=arguments[s].uuid,l=e[o];if(void 0!==l)if(delete e[o],l<r){const s=--r,o=t[s],c=--a,h=t[c];e[o.uuid]=l,t[l]=o,e[h.uuid]=s,t[s]=h,t.pop();for(let t=0,e=i;t!==e;++t){const e=n[t],i=e[s],r=e[c];e[l]=i,e[s]=r,e.pop()}}else{const r=--a,s=t[r];r>0&&(e[s.uuid]=l),t[l]=s,t.pop();for(let t=0,e=i;t!==e;++t){const e=n[t];e[l]=e[r],e.pop()}}}this.nCachedObjects_=r}subscribe_(t,e){const n=this._bindingsIndicesByPath;let i=n[t];const r=this._bindings;if(void 0!==i)return r[i];const a=this._paths,s=this._parsedPaths,o=this._objects,l=o.length,c=this.nCachedObjects_,h=new Array(l);i=r.length,n[t]=i,a.push(t),s.push(e),r.push(h);for(let n=c,i=o.length;n!==i;++n){const i=o[n];h[n]=new id(i,t,e)}return h}unsubscribe_(t){const e=this._bindingsIndicesByPath,n=e[t];if(void 0!==n){const i=this._paths,r=this._parsedPaths,a=this._bindings,s=a.length-1,o=a[s];e[t[s]]=n,a[n]=o,a.pop(),r[n]=r[s],r.pop(),i[n]=i[s],i.pop()}}}class ad{constructor(t,e,n=null,i=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=i;const r=e.tracks,a=r.length,s=new Array(a),o={endingStart:On,endingEnd:On};for(let t=0;t!==a;++t){const e=r[t].createInterpolant(null);s[t]=e,e.settings&&Object.assign(o,e.settings),e.settings=o}this._interpolantSettings=o,this._interpolants=s,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,n=!1){if(t.fadeOut(e),this.fadeIn(e),!0===n){const n=this._clip.duration,i=t._clip.duration,r=i/n,a=n/i;t.warp(1,r,e),this.warp(a,1,e)}return this}crossFadeTo(t,e,n=!1){return t.crossFadeFrom(this,e,n)}stopFading(){const t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,n){const i=this._mixer,r=i.time,a=this.timeScale;let s=this._timeScaleInterpolant;null===s&&(s=i._lendControlInterpolant(),this._timeScaleInterpolant=s);const o=s.parameterPositions,l=s.sampleValues;return o[0]=r,o[1]=r+n,l[0]=t/a,l[1]=e/a,this}stopWarping(){const t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,n,i){if(!this.enabled)return void this._updateWeight(t);const r=this._startTime;if(null!==r){const i=(t-r)*n;i<0||0===n?e=0:(this._startTime=null,e=n*i)}e*=this._updateTimeScale(t);const a=this._updateTime(e),s=this._updateWeight(t);if(s>0){const t=this._interpolants,e=this._propertyBindings;if(2501===this.blendMode)for(let n=0,i=t.length;n!==i;++n)t[n].evaluate(a),e[n].accumulateAdditive(s);else for(let n=0,r=t.length;n!==r;++n)t[n].evaluate(a),e[n].accumulate(i,s)}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const n=this._weightInterpolant;if(null!==n){const i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const n=this._timeScaleInterpolant;null!==n&&(e*=n.evaluate(t)[0],t>n.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e))}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,n=this.loop;let i=this.time+t,r=this._loopCount;const a=2202===n;if(0===t)return-1===r||!a||1&~r?i:e-i;if(2200===n){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(i>=e)i=e;else{if(!(i<0)){this.time=i;break t}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===r&&(t>=0?(r=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),i>=e||i<0){const n=Math.floor(i/e);i-=e*n,r+=Math.abs(n);const s=this.repetitions-r;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=t>0?e:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===s){const e=t<0;this._setEndings(e,!e,a)}else this._setEndings(!1,!1,a);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this._loopCount=r,this.time=i;if(a&&!(1&~r))return e-i}return i}_setEndings(t,e,n){const i=this._interpolantSettings;n?(i.endingStart=Un,i.endingEnd=Un):(i.endingStart=t?this.zeroSlopeAtStart?Un:On:Fn,i.endingEnd=e?this.zeroSlopeAtEnd?Un:On:Fn)}_scheduleFading(t,e,n){const i=this._mixer,r=i.time;let a=this._weightInterpolant;null===a&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);const s=a.parameterPositions,o=a.sampleValues;return s[0]=r,o[0]=e,s[1]=r+t,o[1]=n,this}}const sd=new Float32Array(1);class od extends mi{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(t,e){const n=t._localRoot||this._root,i=t._clip.tracks,r=i.length,a=t._propertyBindings,s=t._interpolants,o=n.uuid,l=this._bindingsByRootAndName;let c=l[o];void 0===c&&(c={},l[o]=c);for(let t=0;t!==r;++t){const r=i[t],l=r.name;let h=c[l];if(void 0!==h)++h.referenceCount,a[t]=h;else{if(h=a[t],void 0!==h){null===h._cacheIndex&&(++h.referenceCount,this._addInactiveBinding(h,o,l));continue}const i=e&&e._propertyBindings[t].binding.parsedPath;h=new $h(id.create(n,l,i),r.ValueTypeName,r.getValueSize()),++h.referenceCount,this._addInactiveBinding(h,o,l),a[t]=h}s[t].resultBuffer=h.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,n=t._clip.uuid,i=this._actionsByClip[n];this._bindAction(t,i&&i.knownActions[0]),this._addInactiveAction(t,n,e)}const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0===n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0===--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return null!==e&&e<this._nActiveActions}_addInactiveAction(t,e,n){const i=this._actions,r=this._actionsByClip;let a=r[e];if(void 0===a)a={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,r[e]=a;else{const e=a.knownActions;t._byClipCacheIndex=e.length,e.push(t)}t._cacheIndex=i.length,i.push(t),a.actionByRoot[n]=t}_removeInactiveAction(t){const e=this._actions,n=e[e.length-1],i=t._cacheIndex;n._cacheIndex=i,e[i]=n,e.pop(),t._cacheIndex=null;const r=t._clip.uuid,a=this._actionsByClip,s=a[r],o=s.knownActions,l=o[o.length-1],c=t._byClipCacheIndex;l._byClipCacheIndex=c,o[c]=l,o.pop(),t._byClipCacheIndex=null,delete s.actionByRoot[(t._localRoot||this._root).uuid],0===o.length&&delete a[r],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0===--n.referenceCount&&this._removeInactiveBinding(n)}}_lendAction(t){const e=this._actions,n=t._cacheIndex,i=this._nActiveActions++,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_takeBackAction(t){const e=this._actions,n=t._cacheIndex,i=--this._nActiveActions,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_addInactiveBinding(t,e,n){const i=this._bindingsByRootAndName,r=this._bindings;let a=i[e];void 0===a&&(a={},i[e]=a),a[n]=t,t._cacheIndex=r.length,r.push(t)}_removeInactiveBinding(t){const e=this._bindings,n=t.binding,i=n.rootNode.uuid,r=n.path,a=this._bindingsByRootAndName,s=a[i],o=e[e.length-1],l=t._cacheIndex;o._cacheIndex=l,e[l]=o,e.pop(),delete s[r],0===Object.keys(s).length&&delete a[i]}_lendBinding(t){const e=this._bindings,n=t._cacheIndex,i=this._nActiveBindings++,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_takeBackBinding(t){const e=this._bindings,n=t._cacheIndex,i=--this._nActiveBindings,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_lendControlInterpolant(){const t=this._controlInterpolants,e=this._nActiveControlInterpolants++;let n=t[e];return void 0===n&&(n=new Vc(new Float32Array(2),new Float32Array(2),1,sd),n.__cacheIndex=e,t[e]=n),n}_takeBackControlInterpolant(t){const e=this._controlInterpolants,n=t.__cacheIndex,i=--this._nActiveControlInterpolants,r=e[i];t.__cacheIndex=i,e[i]=t,r.__cacheIndex=n,e[n]=r}clipAction(t,e,n){const i=e||this._root,r=i.uuid;let a="string"==typeof t?Qc.findByName(i,t):t;const s=null!==a?a.uuid:t,o=this._actionsByClip[s];let l=null;if(void 0===n&&(n=null!==a?a.blendMode:zn),void 0!==o){const t=o.actionByRoot[r];if(void 0!==t&&t.blendMode===n)return t;l=o.knownActions[0],null===a&&(a=l._clip)}if(null===a)return null;const c=new ad(this,a,e,n);return this._bindAction(c,l),this._addInactiveAction(c,s,r),c}existingAction(t,e){const n=e||this._root,i=n.uuid,r="string"==typeof t?Qc.findByName(n,t):t,a=r?r.uuid:t,s=this._actionsByClip[a];return void 0!==s&&s.actionByRoot[i]||null}stopAllAction(){const t=this._actions;for(let e=this._nActiveActions-1;e>=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,n=this._nActiveActions,i=this.time+=t,r=Math.sign(t),a=this._accuIndex^=1;for(let s=0;s!==n;++s)e[s]._update(i,t,r,a);const s=this._bindings,o=this._nActiveBindings;for(let t=0;t!==o;++t)s[t].apply(a);return this}setTime(t){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){const e=this._actions,n=t.uuid,i=this._actionsByClip,r=i[n];if(void 0!==r){const t=r.knownActions;for(let n=0,i=t.length;n!==i;++n){const i=t[n];this._deactivateAction(i);const r=i._cacheIndex,a=e[e.length-1];i._cacheIndex=null,i._byClipCacheIndex=null,a._cacheIndex=r,e[r]=a,e.pop(),this._removeInactiveBindingsForAction(i)}delete i[n]}}uncacheRoot(t){const e=t.uuid,n=this._actionsByClip;for(const t in n){const i=n[t].actionByRoot[e];void 0!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}const i=this._bindingsByRootAndName[e];if(void 0!==i)for(const t in i){const e=i[t];e.restoreOriginalState(),this._removeInactiveBinding(e)}}uncacheAction(t,e){const n=this.existingAction(t,e);null!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}}class ld extends La{constructor(t,e,n=1){super(t,e),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}clone(t){const e=super.clone(t);return e.meshPerAttribute=this.meshPerAttribute,e}toJSON(t){const e=super.toJSON(t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}}const cd=new Ki;class hd{constructor(t,e,n=0,i=1/0){this.ray=new cs(t,e),this.near=n,this.far=i,this.camera=null,this.layers=new cr,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):di("Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return cd.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(cd),this}intersectObject(t,e=!0,n=[]){return ud(t,this,n,e),n.sort(dd),n}intersectObjects(t,e=!0,n=[]){for(let i=0,r=t.length;i<r;i++)ud(t[i],this,n,e);return n.sort(dd),n}}function dd(t,e){return t.distance-e.distance}function ud(t,e,n,i){let r=!0;if(t.layers.test(e.layers)&&!1===t.raycast(e,n)&&(r=!1),!0===r&&!0===i){const i=t.children;for(let t=0,r=i.length;t<r;t++)ud(i[t],e,n,!0)}}class pd{static{pd.prototype.isMatrix2=!0}constructor(t,e,n,i){this.elements=[1,0,0,1],void 0!==t&&this.set(t,e,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,i){const r=this.elements;return r[0]=t,r[2]=e,r[1]=n,r[3]=i,this}}function md(t,e,n,i){const r=function(t){switch(t){case Ce:case Re:return{byteLength:1,components:1};case Pe:case Ie:case Oe:return{byteLength:2,components:1};case Ue:case Fe:return{byteLength:2,components:4};case De:case Le:case Ne:return{byteLength:4,components:1};case ke:case Be:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}(i);switch(n){case 1021:return t*e;case We:case je:return t*e/r.components*r.byteLength;case Xe:case qe:return t*e*2/r.components*r.byteLength;case 1022:return t*e*3/r.components*r.byteLength;case Ge:case Ye:return t*e*4/r.components*r.byteLength;case Ze:case $e:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case Je:case Ke:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case tn:case nn:return Math.max(t,16)*Math.max(e,8)/4;case Qe:case en:return Math.max(t,8)*Math.max(e,8)/2;case rn:case an:case on:case ln:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case sn:case cn:case hn:case dn:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case un:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case pn:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case mn:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case fn:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case gn:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case vn:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case _n:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case yn:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case xn:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case bn:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case Sn:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case Mn:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case wn:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case En:case Tn:case An:return Math.ceil(t/4)*Math.ceil(e/4)*16;case Cn:case Rn:return Math.ceil(t/4)*Math.ceil(e/4)*8;case In:case Pn:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}
|
|
94
94
|
/**
|
|
95
95
|
* @license
|
|
96
96
|
* Copyright 2010-2026 Three.js Authors
|
|
97
97
|
* SPDX-License-Identifier: MIT
|
|
98
98
|
*/
|
|
99
|
-
function md(){let t=null,e=!1,n=null,i=null;function r(e,a){n(e,a),i=t.requestAnimationFrame(r)}return{start:function(){!0!==e&&null!==n&&null!==t&&(i=t.requestAnimationFrame(r),e=!0)},stop:function(){null!==t&&t.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(t){n=t},setContext:function(e){t=e}}}function fd(t){const e=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),e.get(t)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);const i=e.get(n);i&&(t.deleteBuffer(i.buffer),e.delete(n))},update:function(n,i){if(n.isInterleavedBufferAttribute&&(n=n.data),n.isGLBufferAttribute){const t=e.get(n);return void((!t||t.version<n.version)&&e.set(n,{buffer:n.buffer,type:n.type,bytesPerElement:n.elementSize,version:n.version}))}const r=e.get(n);if(void 0===r)e.set(n,function(e,n){const i=e.array,r=e.usage,a=i.byteLength,s=t.createBuffer();let o;if(t.bindBuffer(n,s),t.bufferData(n,i,r),e.onUploadCallback(),i instanceof Float32Array)o=t.FLOAT;else if("undefined"!=typeof Float16Array&&i instanceof Float16Array)o=t.HALF_FLOAT;else if(i instanceof Uint16Array)o=e.isFloat16BufferAttribute?t.HALF_FLOAT:t.UNSIGNED_SHORT;else if(i instanceof Int16Array)o=t.SHORT;else if(i instanceof Uint32Array)o=t.UNSIGNED_INT;else if(i instanceof Int32Array)o=t.INT;else if(i instanceof Int8Array)o=t.BYTE;else if(i instanceof Uint8Array)o=t.UNSIGNED_BYTE;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+i);o=t.UNSIGNED_BYTE}return{buffer:s,type:o,bytesPerElement:i.BYTES_PER_ELEMENT,version:e.version,size:a}}(n,i));else if(r.version<n.version){if(r.size!==n.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");!function(e,n,i){const r=n.array,a=n.updateRanges;if(t.bindBuffer(i,e),0===a.length)t.bufferSubData(i,0,r);else{a.sort(((t,e)=>t.start-e.start));let e=0;for(let t=1;t<a.length;t++){const n=a[e],i=a[t];i.start<=n.start+n.count+1?n.count=Math.max(n.count,i.start+i.count-n.start):(++e,a[e]=i)}a.length=e+1;for(let e=0,n=a.length;e<n;e++){const n=a[e];t.bufferSubData(i,n.start*r.BYTES_PER_ELEMENT,r,n.start,n.count)}n.clearUpdateRanges()}n.onUploadCallback()}(r.buffer,n,i),r.version=n.version}}}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:yt}})),"undefined"!=typeof window&&(window.__THREE__?ci("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=yt);const gd={alphahash_fragment:"#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\t#ifdef ALPHA_TO_COVERAGE\n\tdiffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\tif ( diffuseColor.a < alphaTest ) discard;\n\t#endif\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n\t#if ! defined( GL_ANGLE_multi_draw )\n\t#define gl_DrawID _gl_DrawID\n\tuniform int _gl_DrawID;\n\t#endif\n\tuniform highp sampler2D batchingTexture;\n\tuniform highp usampler2D batchingIdTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n\tfloat getIndirectIndex( const in int i ) {\n\t\tint size = textureSize( batchingIdTexture, 0 ).x;\n\t\tint x = i % size;\n\t\tint y = i / size;\n\t\treturn float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n\t}\n#endif\n#ifdef USE_BATCHING_COLOR\n\tuniform sampler2D batchingColorTexture;\n\tvec4 getBatchingColor( const in float i ) {\n\t\tint size = textureSize( batchingColorTexture, 0 ).x;\n\t\tint j = int( i );\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\treturn texelFetch( batchingColorTexture, ivec2( x, y ), 0 );\n\t}\n#endif",batching_vertex:"#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n\t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec4 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec4( 1.0 );\n#endif\n#ifdef USE_COLOR_ALPHA\n\tvColor *= color;\n#elif defined( USE_COLOR )\n\tvColor.rgb *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.rgb *= instanceColor.rgb;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n\t\temissiveColor = sRGBTransferEOTF( emissiveColor );\n\t#endif\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * reflectVec );\n\t\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t\t#endif\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif\n#include <lightprobes_pars_fragment>",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.metalness = metalnessFactor;\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;\n\tmaterial.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = vec3( 0.04 );\n\tmaterial.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tvec3 diffuseContribution;\n\tvec3 specularColor;\n\tvec3 specularColorBlended;\n\tfloat roughness;\n\tfloat metalness;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t\tvec3 iridescenceFresnelDielectric;\n\t\tvec3 iridescenceFresnelMetallic;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\treturn 0.5 / max( gv + gl, EPSILON );\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColorBlended;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat rInv = 1.0 / ( roughness + 0.1 );\n\tfloat a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n\tfloat b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n\tfloat DG = exp( a * dotNV + b );\n\treturn saturate( DG );\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;\n\tvec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;\n\tvec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;\n\tvec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;\n\tfloat Ess_V = dfgV.x + dfgV.y;\n\tfloat Ess_L = dfgL.x + dfgL.y;\n\tfloat Ems_V = 1.0 - Ess_V;\n\tfloat Ems_L = 1.0 - Ess_L;\n\tvec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;\n\tvec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );\n\tfloat compensationFactor = Ems_V * Ems_L;\n\tvec3 multiScatter = Fms * compensationFactor;\n\treturn singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t\t#ifdef USE_CLEARCOAT\n\t\t\tvec3 Ncc = geometryClearcoatNormal;\n\t\t\tvec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness );\n\t\t\tvec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat );\n\t\t\tvec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat );\n\t\t\tmat3 mInvClearcoat = mat3(\n\t\t\t\tvec3( t1Clearcoat.x, 0, t1Clearcoat.y ),\n\t\t\t\tvec3( 0, 1, 0 ),\n\t\t\t\tvec3( t1Clearcoat.z, 0, t1Clearcoat.w )\n\t\t\t);\n\t\t\tvec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y;\n\t\t\tclearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords );\n\t\t#endif\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n \n \t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n \t\tfloat sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n \t\tfloat sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n \t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n \t\tirradiance *= sheenEnergyComp;\n \n \t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );\n\t#ifdef USE_SHEEN\n\t\tfloat sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n\t\tdiffuse *= sheenEnergyComp;\n\t#endif\n\treflectedLight.indirectDiffuse += diffuse;\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n \t#endif\n\tvec3 singleScatteringDielectric = vec3( 0.0 );\n\tvec3 multiScatteringDielectric = vec3( 0.0 );\n\tvec3 singleScatteringMetallic = vec3( 0.0 );\n\tvec3 multiScatteringMetallic = vec3( 0.0 );\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n\t#endif\n\tvec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n\tvec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n\tvec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n\tvec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tvec3 indirectSpecular = radiance * singleScattering;\n\tindirectSpecular += multiScattering * cosineWeightedIrradiance;\n\tvec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n\t\tindirectSpecular *= sheenEnergyComp;\n\t\tindirectDiffuse *= sheenEnergyComp;\n\t#endif\n\treflectedLight.indirectSpecular += indirectSpecular;\n\treflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n\t\tmaterial.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#ifdef USE_LIGHT_PROBES_GRID\n\t\tvec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz;\n\t\tvec3 probeWorldNormal = inverseTransformDirection( geometryNormal, viewMatrix );\n\t\tirradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal );\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\t#if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG )\n\t\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t\t#endif\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\t#if defined( LAMBERT ) || defined( PHONG )\n\t\tirradiance += iblIrradiance;\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",lightprobes_pars_fragment:"#ifdef USE_LIGHT_PROBES_GRID\nuniform highp sampler3D probesSH;\nuniform vec3 probesMin;\nuniform vec3 probesMax;\nuniform vec3 probesResolution;\nvec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {\n\tvec3 res = probesResolution;\n\tvec3 gridRange = probesMax - probesMin;\n\tvec3 resMinusOne = res - 1.0;\n\tvec3 probeSpacing = gridRange / resMinusOne;\n\tvec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5;\n\tvec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 );\n\tuvw = uvw * resMinusOne / res + 0.5 / res;\n\tfloat nz = res.z;\n\tfloat paddedSlices = nz + 2.0;\n\tfloat atlasDepth = 7.0 * paddedSlices;\n\tfloat uvZBase = uvw.z * nz + 1.0;\n\tvec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) );\n\tvec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) );\n\tvec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) );\n\tvec3 c0 = s0.xyz;\n\tvec3 c1 = vec3( s0.w, s1.xy );\n\tvec3 c2 = vec3( s1.zw, s2.x );\n\tvec3 c3 = s2.yzw;\n\tvec3 c4 = s3.xyz;\n\tvec3 c5 = vec3( s3.w, s4.xy );\n\tvec3 c6 = vec3( s4.zw, s5.x );\n\tvec3 c7 = s5.yzw;\n\tvec3 c8 = s6.xyz;\n\tfloat x = worldNormal.x, y = worldNormal.y, z = worldNormal.z;\n\tvec3 result = c0 * 0.886227;\n\tresult += c1 * 2.0 * 0.511664 * y;\n\tresult += c2 * 2.0 * 0.511664 * z;\n\tresult += c3 * 2.0 * 0.511664 * x;\n\tresult += c4 * 2.0 * 0.429043 * x * y;\n\tresult += c5 * 2.0 * 0.429043 * y * z;\n\tresult += c6 * ( 0.743125 * z * z - 0.247708 );\n\tresult += c7 * 2.0 * 0.429043 * x * z;\n\tresult += c8 * 0.429043 * ( x * x - y * y );\n\treturn max( result, vec3( 0.0 ) );\n}\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#if defined( USE_PACKED_NORMALMAP )\n\t\tmapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) );\n\t#endif\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\n\t\treturn depth * ( far - near ) - far;\n\t#else\n\t\treturn depth * ( near - far ) - near;\n\t#endif\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\t\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\treturn ( near * far ) / ( ( near - far ) * depth - near );\n\t#else\n\t\treturn ( near * far ) / ( ( far - near ) * depth - far );\n\t#endif\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\t#else\n\t\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\t#else\n\t\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\t#elif defined( SHADOWMAP_TYPE_BASIC )\n\t\t\tuniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\tfloat interleavedGradientNoise( vec2 position ) {\n\t\t\treturn fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );\n\t\t}\n\t\tvec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {\n\t\t\tconst float goldenAngle = 2.399963229728653;\n\t\t\tfloat r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );\n\t\t\tfloat theta = float( sampleIndex ) * goldenAngle + phi;\n\t\t\treturn vec2( cos( theta ), sin( theta ) ) * r;\n\t\t}\n\t#endif\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\tfloat getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\tshadowCoord.z += shadowBias;\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\t\tfloat radius = shadowRadius * texelSize.x;\n\t\t\t\tfloat phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )\n\t\t\t\t) * 0.2;\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tshadowCoord.z -= shadowBias;\n\t\t\t#else\n\t\t\t\tshadowCoord.z += shadowBias;\n\t\t\t#endif\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tvec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;\n\t\t\t\tfloat mean = distribution.x;\n\t\t\t\tfloat variance = distribution.y * distribution.y;\n\t\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\t\tfloat hard_shadow = step( mean, shadowCoord.z );\n\t\t\t\t#else\n\t\t\t\t\tfloat hard_shadow = step( shadowCoord.z, mean );\n\t\t\t\t#endif\n\t\t\t\t\n\t\t\t\tif ( hard_shadow == 1.0 ) {\n\t\t\t\t\tshadow = 1.0;\n\t\t\t\t} else {\n\t\t\t\t\tvariance = max( variance, 0.0000001 );\n\t\t\t\t\tfloat d = shadowCoord.z - mean;\n\t\t\t\t\tfloat p_max = variance / ( variance + d * d );\n\t\t\t\t\tp_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );\n\t\t\t\t\tshadow = max( hard_shadow, p_max );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#else\n\t\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tshadowCoord.z -= shadowBias;\n\t\t\t#else\n\t\t\t\tshadowCoord.z += shadowBias;\n\t\t\t#endif\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tfloat depth = texture2D( shadowMap, shadowCoord.xy ).r;\n\t\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\t\tshadow = step( depth, shadowCoord.z );\n\t\t\t\t#else\n\t\t\t\t\tshadow = step( shadowCoord.z, depth );\n\t\t\t\t#endif\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\tfloat getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tvec3 absVec = abs( lightToPosition );\n\t\tfloat viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\t\tif ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tfloat dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\t\tdp -= shadowBias;\n\t\t\t#else\n\t\t\t\tfloat dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\t\tdp += shadowBias;\n\t\t\t#endif\n\t\t\tfloat texelSize = shadowRadius / shadowMapSize.x;\n\t\t\tvec3 absDir = abs( bd3D );\n\t\t\tvec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );\n\t\t\ttangent = normalize( cross( bd3D, tangent ) );\n\t\t\tvec3 bitangent = cross( bd3D, tangent );\n\t\t\tfloat phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n\t\t\tvec2 sample0 = vogelDiskSample( 0, 5, phi );\n\t\t\tvec2 sample1 = vogelDiskSample( 1, 5, phi );\n\t\t\tvec2 sample2 = vogelDiskSample( 2, 5, phi );\n\t\t\tvec2 sample3 = vogelDiskSample( 3, 5, phi );\n\t\t\tvec2 sample4 = vogelDiskSample( 4, 5, phi );\n\t\t\tshadow = (\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) )\n\t\t\t) * 0.2;\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\t#elif defined( SHADOWMAP_TYPE_BASIC )\n\tfloat getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 absVec = abs( lightToPosition );\n\t\tfloat viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\t\tif ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tfloat depth = textureCube( shadowMap, bd3D ).r;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tdepth = 1.0 - depth;\n\t\t\t#endif\n\t\t\tshadow = step( dp, depth );\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\t#endif\n\t#endif\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\t#ifdef HAS_NORMAL\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t#else\n\t\tvec3 shadowWorldNormal = vec3( 0.0 );\n\t#endif\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t#else\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",depth_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\tfloat fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];\n\t#else\n\t\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;\n\t#endif\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}",distance_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distance_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n \n\t\toutgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;\n \n \t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix[ 3 ];\n\tvec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}"},vd={common:{diffuse:{value:new Lr(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ii},alphaMap:{value:null},alphaMapTransform:{value:new Ii},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ii}},envmap:{envMap:{value:null},envMapRotation:{value:new Ii},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ii}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ii}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ii},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ii},normalScale:{value:new Ei(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ii},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ii}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ii}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ii}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Lr(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new Ai},probesMax:{value:new Ai},probesResolution:{value:new Ai}},points:{diffuse:{value:new Lr(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ii},alphaTest:{value:0},uvTransform:{value:new Ii}},sprite:{diffuse:{value:new Lr(16777215)},opacity:{value:1},center:{value:new Ei(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ii},alphaMap:{value:null},alphaMapTransform:{value:new Ii},alphaTest:{value:0}}},_d={basic:{uniforms:yc([vd.common,vd.specularmap,vd.envmap,vd.aomap,vd.lightmap,vd.fog]),vertexShader:gd.meshbasic_vert,fragmentShader:gd.meshbasic_frag},lambert:{uniforms:yc([vd.common,vd.specularmap,vd.envmap,vd.aomap,vd.lightmap,vd.emissivemap,vd.bumpmap,vd.normalmap,vd.displacementmap,vd.fog,vd.lights,{emissive:{value:new Lr(0)},envMapIntensity:{value:1}}]),vertexShader:gd.meshlambert_vert,fragmentShader:gd.meshlambert_frag},phong:{uniforms:yc([vd.common,vd.specularmap,vd.envmap,vd.aomap,vd.lightmap,vd.emissivemap,vd.bumpmap,vd.normalmap,vd.displacementmap,vd.fog,vd.lights,{emissive:{value:new Lr(0)},specular:{value:new Lr(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:gd.meshphong_vert,fragmentShader:gd.meshphong_frag},standard:{uniforms:yc([vd.common,vd.envmap,vd.aomap,vd.lightmap,vd.emissivemap,vd.bumpmap,vd.normalmap,vd.displacementmap,vd.roughnessmap,vd.metalnessmap,vd.fog,vd.lights,{emissive:{value:new Lr(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:gd.meshphysical_vert,fragmentShader:gd.meshphysical_frag},toon:{uniforms:yc([vd.common,vd.aomap,vd.lightmap,vd.emissivemap,vd.bumpmap,vd.normalmap,vd.displacementmap,vd.gradientmap,vd.fog,vd.lights,{emissive:{value:new Lr(0)}}]),vertexShader:gd.meshtoon_vert,fragmentShader:gd.meshtoon_frag},matcap:{uniforms:yc([vd.common,vd.bumpmap,vd.normalmap,vd.displacementmap,vd.fog,{matcap:{value:null}}]),vertexShader:gd.meshmatcap_vert,fragmentShader:gd.meshmatcap_frag},points:{uniforms:yc([vd.points,vd.fog]),vertexShader:gd.points_vert,fragmentShader:gd.points_frag},dashed:{uniforms:yc([vd.common,vd.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:gd.linedashed_vert,fragmentShader:gd.linedashed_frag},depth:{uniforms:yc([vd.common,vd.displacementmap]),vertexShader:gd.depth_vert,fragmentShader:gd.depth_frag},normal:{uniforms:yc([vd.common,vd.bumpmap,vd.normalmap,vd.displacementmap,{opacity:{value:1}}]),vertexShader:gd.meshnormal_vert,fragmentShader:gd.meshnormal_frag},sprite:{uniforms:yc([vd.sprite,vd.fog]),vertexShader:gd.sprite_vert,fragmentShader:gd.sprite_frag},background:{uniforms:{uvTransform:{value:new Ii},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:gd.background_vert,fragmentShader:gd.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ii}},vertexShader:gd.backgroundCube_vert,fragmentShader:gd.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:gd.cube_vert,fragmentShader:gd.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:gd.equirect_vert,fragmentShader:gd.equirect_frag},distance:{uniforms:yc([vd.common,vd.displacementmap,{referencePosition:{value:new Ai},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:gd.distance_vert,fragmentShader:gd.distance_frag},shadow:{uniforms:yc([vd.lights,vd.fog,{color:{value:new Lr(0)},opacity:{value:1}}]),vertexShader:gd.shadow_vert,fragmentShader:gd.shadow_frag}};_d.physical={uniforms:yc([_d.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ii},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ii},clearcoatNormalScale:{value:new Ei(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ii},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ii},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ii},sheen:{value:0},sheenColor:{value:new Lr(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ii},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ii},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ii},transmissionSamplerSize:{value:new Ei},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ii},attenuationDistance:{value:0},attenuationColor:{value:new Lr(0)},specularColor:{value:new Lr(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ii},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ii},anisotropyVector:{value:new Ei},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ii}}]),vertexShader:gd.meshphysical_vert,fragmentShader:gd.meshphysical_frag};const yd={r:0,b:0,g:0},xd=new Ji,bd=new Ii;function Sd(t,e,n,i,r,a){const s=new Lr(0);let o,l,c=!0===r?0:1,h=null,d=0,u=null;function p(t){let n=!0===t.isScene?t.background:null;if(n&&n.isTexture){const i=t.backgroundBlurriness>0;n=e.get(n,i)}return n}function m(e,i){e.getRGB(yd,bc(t)),n.buffers.color.setClear(yd.r,yd.g,yd.b,i,a)}return{getClearColor:function(){return s},setClearColor:function(t,e=1){s.set(t),c=e,m(s,c)},getClearAlpha:function(){return c},setClearAlpha:function(t){c=t,m(s,c)},render:function(e){let i=!1;const r=p(e);null===r?m(s,c):r&&r.isColor&&(m(r,1),i=!0);const o=t.xr.getEnvironmentBlendMode();"additive"===o?n.buffers.color.setClear(0,0,0,1,a):"alpha-blend"===o&&n.buffers.color.setClear(0,0,0,0,a),(t.autoClear||i)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))},addToRenderList:function(e,n){const r=p(n);r&&(r.isCubeTexture||r.mapping===ve)?(void 0===l&&(l=new bs(new Zo(1,1,1),new Mc({name:"BackgroundCubeMaterial",uniforms:_c(_d.backgroundCube.uniforms),vertexShader:_d.backgroundCube.vertexShader,fragmentShader:_d.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(t,e,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l)),l.material.uniforms.envMap.value=r,l.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(xd.makeRotationFromEuler(n.backgroundRotation)).transpose(),r.isCubeTexture&&!1===r.isRenderTargetTexture&&l.material.uniforms.backgroundRotation.value.premultiply(bd),l.material.toneMapped=Oi.getTransfer(r.colorSpace)!==Vn,h===r&&d===r.version&&u===t.toneMapping||(l.material.needsUpdate=!0,h=r,d=r.version,u=t.toneMapping),l.layers.enableAll(),e.unshift(l,l.geometry,l.material,0,0,null)):r&&r.isTexture&&(void 0===o&&(o=new bs(new oc(2,2),new Mc({name:"BackgroundMaterial",uniforms:_c(_d.background.uniforms),vertexShader:_d.background.vertexShader,fragmentShader:_d.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),o.geometry.deleteAttribute("normal"),Object.defineProperty(o.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(o)),o.material.uniforms.t2D.value=r,o.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,o.material.toneMapped=Oi.getTransfer(r.colorSpace)!==Vn,!0===r.matrixAutoUpdate&&r.updateMatrix(),o.material.uniforms.uvTransform.value.copy(r.matrix),h===r&&d===r.version&&u===t.toneMapping||(o.material.needsUpdate=!0,h=r,d=r.version,u=t.toneMapping),o.layers.enableAll(),e.unshift(o,o.geometry,o.material,0,0,null))},dispose:function(){void 0!==l&&(l.geometry.dispose(),l.material.dispose(),l=void 0),void 0!==o&&(o.geometry.dispose(),o.material.dispose(),o=void 0)}}}function Md(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),i={},r=c(null);let a=r,s=!1;function o(e){return t.bindVertexArray(e)}function l(e){return t.deleteVertexArray(e)}function c(t){const e=[],i=[],r=[];for(let t=0;t<n;t++)e[t]=0,i[t]=0,r[t]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:e,enabledAttributes:i,attributeDivisors:r,object:t,attributes:{},index:null}}function h(){const t=a.newAttributes;for(let e=0,n=t.length;e<n;e++)t[e]=0}function d(t){u(t,0)}function u(e,n){const i=a.newAttributes,r=a.enabledAttributes,s=a.attributeDivisors;i[e]=1,0===r[e]&&(t.enableVertexAttribArray(e),r[e]=1),s[e]!==n&&(t.vertexAttribDivisor(e,n),s[e]=n)}function p(){const e=a.newAttributes,n=a.enabledAttributes;for(let i=0,r=n.length;i<r;i++)n[i]!==e[i]&&(t.disableVertexAttribArray(i),n[i]=0)}function m(e,n,i,r,a,s,o){!0===o?t.vertexAttribIPointer(e,n,i,a,s):t.vertexAttribPointer(e,n,i,r,a,s)}function f(){g(),s=!0,a!==r&&(a=r,o(a.object))}function g(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:function(n,r,l,f,g){let v=!1;const _=function(e,n,r,a){const s=!0===a.wireframe;let o=i[n.id];void 0===o&&(o={},i[n.id]=o);const l=!0===e.isInstancedMesh?e.id:0;let h=o[l];void 0===h&&(h={},o[l]=h);let d=h[r.id];void 0===d&&(d={},h[r.id]=d);let u=d[s];return void 0===u&&(u=c(t.createVertexArray()),d[s]=u),u}(n,f,l,r);a!==_&&(a=_,o(a.object)),v=function(t,e,n,i){const r=a.attributes,s=e.attributes;let o=0;const l=n.getAttributes();for(const e in l)if(l[e].location>=0){const n=r[e];let i=s[e];if(void 0===i&&("instanceMatrix"===e&&t.instanceMatrix&&(i=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(i=t.instanceColor)),void 0===n)return!0;if(n.attribute!==i)return!0;if(i&&n.data!==i.data)return!0;o++}return a.attributesNum!==o||a.index!==i}(n,f,l,g),v&&function(t,e,n,i){const r={},s=e.attributes;let o=0;const l=n.getAttributes();for(const e in l)if(l[e].location>=0){let n=s[e];void 0===n&&("instanceMatrix"===e&&t.instanceMatrix&&(n=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(n=t.instanceColor));const i={};i.attribute=n,n&&n.data&&(i.data=n.data),r[e]=i,o++}a.attributes=r,a.attributesNum=o,a.index=i}(n,f,l,g),null!==g&&e.update(g,t.ELEMENT_ARRAY_BUFFER),(v||s)&&(s=!1,function(n,i,r,a){h();const s=a.attributes,o=r.getAttributes(),l=i.defaultAttributeValues;for(const i in o){const r=o[i];if(r.location>=0){let o=s[i];if(void 0===o&&("instanceMatrix"===i&&n.instanceMatrix&&(o=n.instanceMatrix),"instanceColor"===i&&n.instanceColor&&(o=n.instanceColor)),void 0!==o){const i=o.normalized,s=o.itemSize,l=e.get(o);if(void 0===l)continue;const c=l.buffer,h=l.type,p=l.bytesPerElement,f=h===t.INT||h===t.UNSIGNED_INT||o.gpuType===Pe;if(o.isInterleavedBufferAttribute){const e=o.data,l=e.stride,g=o.offset;if(e.isInstancedInterleavedBuffer){for(let t=0;t<r.locationSize;t++)u(r.location+t,e.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===a._maxInstanceCount&&(a._maxInstanceCount=e.meshPerAttribute*e.count)}else for(let t=0;t<r.locationSize;t++)d(r.location+t);t.bindBuffer(t.ARRAY_BUFFER,c);for(let t=0;t<r.locationSize;t++)m(r.location+t,s/r.locationSize,h,i,l*p,(g+s/r.locationSize*t)*p,f)}else{if(o.isInstancedBufferAttribute){for(let t=0;t<r.locationSize;t++)u(r.location+t,o.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===a._maxInstanceCount&&(a._maxInstanceCount=o.meshPerAttribute*o.count)}else for(let t=0;t<r.locationSize;t++)d(r.location+t);t.bindBuffer(t.ARRAY_BUFFER,c);for(let t=0;t<r.locationSize;t++)m(r.location+t,s/r.locationSize,h,i,s*p,s/r.locationSize*t*p,f)}}else if(void 0!==l){const e=l[i];if(void 0!==e)switch(e.length){case 2:t.vertexAttrib2fv(r.location,e);break;case 3:t.vertexAttrib3fv(r.location,e);break;case 4:t.vertexAttrib4fv(r.location,e);break;default:t.vertexAttrib1fv(r.location,e)}}}}p()}(n,r,l,f),null!==g&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(g).buffer))},reset:f,resetDefaultState:g,dispose:function(){f();for(const t in i){const e=i[t];for(const t in e){const n=e[t];for(const t in n){const e=n[t];for(const t in e)l(e[t].object),delete e[t];delete n[t]}}delete i[t]}},releaseStatesOfGeometry:function(t){if(void 0===i[t.id])return;const e=i[t.id];for(const t in e){const n=e[t];for(const t in n){const e=n[t];for(const t in e)l(e[t].object),delete e[t];delete n[t]}}delete i[t.id]},releaseStatesOfObject:function(t){for(const e in i){const n=i[e],r=!0===t.isInstancedMesh?t.id:0,a=n[r];if(void 0!==a){for(const t in a){const e=a[t];for(const t in e)l(e[t].object),delete e[t];delete a[t]}delete n[r],0===Object.keys(n).length&&delete i[e]}}},releaseStatesOfProgram:function(t){for(const e in i){const n=i[e];for(const e in n){const i=n[e];if(void 0===i[t.id])continue;const r=i[t.id];for(const t in r)l(r[t].object),delete r[t];delete i[t.id]}}},initAttributes:h,enableAttribute:d,disableUnusedAttributes:p}}function wd(t,e,n){let i;this.setMode=function(t){i=t},this.render=function(e,r){t.drawArrays(i,e,r),n.update(r,i,1)},this.renderInstances=function(e,r,a){0!==a&&(t.drawArraysInstanced(i,e,r,a),n.update(r,i,a))},this.renderMultiDraw=function(t,r,a){if(0===a)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,t,0,r,0,a);let s=0;for(let t=0;t<a;t++)s+=r[t];n.update(s,i,1)}}function Ed(t,e,n,i){let r;function a(e){if("highp"===e){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let s=void 0!==n.precision?n.precision:"highp";const o=a(s);o!==s&&(ci("WebGLRenderer:",s,"not supported, using",o,"instead."),s=o);const l=!0===n.logarithmicDepthBuffer,c=!0===n.reversedDepthBuffer&&e.has("EXT_clip_control");return!0===n.reversedDepthBuffer&&!1===c&&ci("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer."),{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===e.has("EXT_texture_filter_anisotropic")){const n=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:a,textureFormatReadable:function(e){return e===Be||i.convert(e)===t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(n){const r=n===Ne&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(n!==Ae&&i.convert(n)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&n!==De&&!r)},precision:s,logarithmicDepthBuffer:l,reversedDepthBuffer:c,maxTextures:t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),maxVertexTextures:t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:t.getParameter(t.MAX_TEXTURE_SIZE),maxCubemapSize:t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:t.getParameter(t.MAX_VERTEX_ATTRIBS),maxVertexUniforms:t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:t.getParameter(t.MAX_VARYING_VECTORS),maxFragmentUniforms:t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),maxSamples:t.getParameter(t.MAX_SAMPLES),samples:t.getParameter(t.SAMPLES)}}function Td(t){const e=this;let n=null,i=0,r=!1,a=!1;const s=new $s,o=new Ii,l={value:null,needsUpdate:!1};function c(t,n,i,r){const a=null!==t?t.length:0;let c=null;if(0!==a){if(c=l.value,!0!==r||null===c){const e=i+4*a,r=n.matrixWorldInverse;o.getNormalMatrix(r),(null===c||c.length<e)&&(c=new Float32Array(e));for(let e=0,n=i;e!==a;++e,n+=4)s.copy(t[e]).applyMatrix4(r,o),s.normal.toArray(c,n),c[n+3]=s.constant}l.value=c,l.needsUpdate=!0}return e.numPlanes=a,e.numIntersection=0,c}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(t,e){const n=0!==t.length||e||0!==i||r;return r=e,i=t.length,n},this.beginShadows=function(){a=!0,c(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(t,e){n=c(t,e,0)},this.setState=function(s,o,h){const d=s.clippingPlanes,u=s.clipIntersection,p=s.clipShadows,m=t.get(s);if(!r||null===d||0===d.length||a&&!p)a?c(null):(l.value!==n&&(l.value=n,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0);else{const t=a?0:i,e=4*t;let r=m.clippingState||null;l.value=r,r=c(d,o,e,h);for(let t=0;t!==e;++t)r[t]=n[t];m.clippingState=r,this.numIntersection=u?this.numPlanes:0,this.numPlanes+=t}}}bd.set(-1,0,0,0,1,0,0,0,1);const Ad=[.125,.215,.35,.446,.526,.582],Cd=20,Rd=new Ch,Id=new Lr;let Pd=null,Ld=0,Dd=0,Nd=!1;const Od=new Ai;class Ud{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(t,e=0,n=.1,i=100,r={}){const{size:a=256,position:s=Od}=r;Pd=this._renderer.getRenderTarget(),Ld=this._renderer.getActiveCubeFace(),Dd=this._renderer.getActiveMipmapLevel(),Nd=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const o=this._allocateTargets();return o.depthBuffer=!0,this._sceneToCubeUV(t,n,i,o,s),e>0&&this._blur(o,0,0,e),this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Bd(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=kd(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._ggxMaterial&&this._ggxMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodMeshes.length;t++)this._lodMeshes[t].geometry.dispose()}_cleanup(t){this._renderer.setRenderTarget(Pd,Ld,Dd),this._renderer.xr.enabled=Nd,t.scissorTest=!1,zd(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===pe||t.mapping===me?this._setSize(0===t.image.length?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Pd=this._renderer.getRenderTarget(),Ld=this._renderer.getActiveCubeFace(),Dd=this._renderer.getActiveMipmapLevel(),Nd=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:we,minFilter:we,generateMipmaps:!1,type:Ne,format:Be,colorSpace:Bn,depthBuffer:!1},i=Fd(t,e,n);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=Fd(t,e,n);const{_lodMax:i}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=function(t){const e=[],n=[],i=[];let r=t;const a=t-4+1+Ad.length;for(let s=0;s<a;s++){const a=Math.pow(2,r);e.push(a);let o=1/a;s>t-4?o=Ad[s-t+4-1]:0===s&&(o=0),n.push(o);const l=1/(a-2),c=-l,h=1+l,d=[c,c,h,c,h,h,c,c,h,h,c,h],u=6,p=6,m=3,f=2,g=1,v=new Float32Array(m*p*u),_=new Float32Array(f*p*u),y=new Float32Array(g*p*u);for(let t=0;t<u;t++){const e=t%3*2/3-1,n=t>2?0:-1,i=[e,n,0,e+2/3,n,0,e+2/3,n+1,0,e,n,0,e+2/3,n+1,0,e,n+1,0];v.set(i,m*p*t),_.set(d,f*p*t);const r=[t,t,t,t,t,t];y.set(r,g*p*t)}const x=new Ia;x.setAttribute("position",new fa(v,m)),x.setAttribute("uv",new fa(_,f)),x.setAttribute("faceIndex",new fa(y,g)),i.push(new bs(x,null)),r>4&&r--}return{lodMeshes:i,sizeLods:e,sigmas:n}}(i)),this._blurMaterial=function(t,e,n){const i=new Float32Array(Cd),r=new Ai(0,1,0),a=new Mc({name:"SphericalGaussianBlur",defines:{n:Cd,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1});return a}(i,t,e),this._ggxMaterial=function(t,e,n){const i=new Mc({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:256,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:'\n\n\t\t\tprecision highp float;\n\t\t\tprecision highp int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform float roughness;\n\t\t\tuniform float mipInt;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\t#define PI 3.14159265359\n\n\t\t\t// Van der Corput radical inverse\n\t\t\tfloat radicalInverse_VdC(uint bits) {\n\t\t\t\tbits = (bits << 16u) | (bits >> 16u);\n\t\t\t\tbits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);\n\t\t\t\tbits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);\n\t\t\t\tbits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);\n\t\t\t\tbits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);\n\t\t\t\treturn float(bits) * 2.3283064365386963e-10; // / 0x100000000\n\t\t\t}\n\n\t\t\t// Hammersley sequence\n\t\t\tvec2 hammersley(uint i, uint N) {\n\t\t\t\treturn vec2(float(i) / float(N), radicalInverse_VdC(i));\n\t\t\t}\n\n\t\t\t// GGX VNDF importance sampling (Eric Heitz 2018)\n\t\t\t// "Sampling the GGX Distribution of Visible Normals"\n\t\t\t// https://jcgt.org/published/0007/04/01/\n\t\t\tvec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {\n\t\t\t\tfloat alpha = roughness * roughness;\n\n\t\t\t\t// Section 4.1: Orthonormal basis\n\t\t\t\tvec3 T1 = vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 T2 = cross(V, T1);\n\n\t\t\t\t// Section 4.2: Parameterization of projected area\n\t\t\t\tfloat r = sqrt(Xi.x);\n\t\t\t\tfloat phi = 2.0 * PI * Xi.y;\n\t\t\t\tfloat t1 = r * cos(phi);\n\t\t\t\tfloat t2 = r * sin(phi);\n\t\t\t\tfloat s = 0.5 * (1.0 + V.z);\n\t\t\t\tt2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;\n\n\t\t\t\t// Section 4.3: Reprojection onto hemisphere\n\t\t\t\tvec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V;\n\n\t\t\t\t// Section 3.4: Transform back to ellipsoid configuration\n\t\t\t\treturn normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));\n\t\t\t}\n\n\t\t\tvoid main() {\n\t\t\t\tvec3 N = normalize(vOutputDirection);\n\t\t\t\tvec3 V = N; // Assume view direction equals normal for pre-filtering\n\n\t\t\t\tvec3 prefilteredColor = vec3(0.0);\n\t\t\t\tfloat totalWeight = 0.0;\n\n\t\t\t\t// For very low roughness, just sample the environment directly\n\t\t\t\tif (roughness < 0.001) {\n\t\t\t\t\tgl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Tangent space basis for VNDF sampling\n\t\t\t\tvec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 tangent = normalize(cross(up, N));\n\t\t\t\tvec3 bitangent = cross(N, tangent);\n\n\t\t\t\tfor(uint i = 0u; i < uint(GGX_SAMPLES); i++) {\n\t\t\t\t\tvec2 Xi = hammersley(i, uint(GGX_SAMPLES));\n\n\t\t\t\t\t// For PMREM, V = N, so in tangent space V is always (0, 0, 1)\n\t\t\t\t\tvec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);\n\n\t\t\t\t\t// Transform H back to world space\n\t\t\t\t\tvec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);\n\t\t\t\t\tvec3 L = normalize(2.0 * dot(V, H) * H - V);\n\n\t\t\t\t\tfloat NdotL = max(dot(N, L), 0.0);\n\n\t\t\t\t\tif(NdotL > 0.0) {\n\t\t\t\t\t\t// Sample environment at fixed mip level\n\t\t\t\t\t\t// VNDF importance sampling handles the distribution filtering\n\t\t\t\t\t\tvec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);\n\n\t\t\t\t\t\t// Weight by NdotL for the split-sum approximation\n\t\t\t\t\t\t// VNDF PDF naturally accounts for the visible microfacet distribution\n\t\t\t\t\t\tprefilteredColor += sampleColor * NdotL;\n\t\t\t\t\t\ttotalWeight += NdotL;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (totalWeight > 0.0) {\n\t\t\t\t\tprefilteredColor = prefilteredColor / totalWeight;\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = vec4(prefilteredColor, 1.0);\n\t\t\t}\n\t\t',blending:0,depthTest:!1,depthWrite:!1});return i}(i,t,e)}return i}_compileMaterial(t){const e=new bs(new Ia,t);this._renderer.compile(e,Rd)}_sceneToCubeUV(t,e,n,i,r){const a=new Mh(90,1,e,n),s=[1,-1,1,1,1,1],o=[1,1,1,-1,-1,-1],l=this._renderer,c=l.autoClear,h=l.toneMapping;l.getClearColor(Id),l.toneMapping=0,l.autoClear=!1,l.state.buffers.depth.getReversed()&&(l.setRenderTarget(i),l.clearDepth(),l.setRenderTarget(null)),null===this._backgroundBox&&(this._backgroundBox=new bs(new Zo,new cs({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1})));const d=this._backgroundBox,u=d.material;let p=!1;const m=t.background;m?m.isColor&&(u.color.copy(m),t.background=null,p=!0):(u.color.copy(Id),p=!0);for(let e=0;e<6;e++){const n=e%3;0===n?(a.up.set(0,s[e],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+o[e],r.y,r.z)):1===n?(a.up.set(0,0,s[e]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+o[e],r.z)):(a.up.set(0,s[e],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+o[e]));const c=this._cubeSize;zd(i,n*c,e>2?c:0,c,c),l.setRenderTarget(i),p&&l.render(d,a),l.render(t,a)}l.toneMapping=h,l.autoClear=c,t.background=m}_textureToCubeUV(t,e){const n=this._renderer,i=t.mapping===pe||t.mapping===me;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=Bd()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===t.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=kd());const r=i?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r,r.uniforms.envMap.value=t;const s=this._cubeSize;zd(e,0,0,3*s,2*s),n.setRenderTarget(e),n.render(a,Rd)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const i=this._lodMeshes.length;for(let e=1;e<i;e++)this._applyGGXFilter(t,e-1,e);e.autoClear=n}_applyGGXFilter(t,e,n){const i=this._renderer,r=this._pingPongRenderTarget,a=this._ggxMaterial,s=this._lodMeshes[n];s.material=a;const o=a.uniforms,l=n/(this._lodMeshes.length-1),c=e/(this._lodMeshes.length-1),h=Math.sqrt(l*l-c*c)*(0+1.25*l),{_lodMax:d}=this,u=this._sizeLods[n],p=3*u*(n>d-4?n-d+4:0),m=4*(this._cubeSize-u);o.envMap.value=t.texture,o.roughness.value=h,o.mipInt.value=d-e,zd(r,p,m,3*u,2*u),i.setRenderTarget(r),i.render(s,Rd),o.envMap.value=r.texture,o.roughness.value=0,o.mipInt.value=d-n,zd(t,p,m,3*u,2*u),i.setRenderTarget(t),i.render(s,Rd)}_blur(t,e,n,i,r){const a=this._pingPongRenderTarget;this._halfBlur(t,a,e,n,i,"latitudinal",r),this._halfBlur(a,t,n,n,i,"longitudinal",r)}_halfBlur(t,e,n,i,r,a,s){const o=this._renderer,l=this._blurMaterial;"latitudinal"!==a&&"longitudinal"!==a&&hi("blur direction must be either latitudinal or longitudinal!");const c=this._lodMeshes[i];c.material=l;const h=l.uniforms,d=this._sizeLods[n]-1,u=isFinite(r)?Math.PI/(2*d):2*Math.PI/39,p=r/u,m=isFinite(r)?1+Math.floor(3*p):Cd;m>Cd&&ci(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);const f=[];let g=0;for(let t=0;t<Cd;++t){const e=t/p,n=Math.exp(-e*e/2);f.push(n),0===t?g+=n:t<m&&(g+=2*n)}for(let t=0;t<f.length;t++)f[t]=f[t]/g;h.envMap.value=t.texture,h.samples.value=m,h.weights.value=f,h.latitudinal.value="latitudinal"===a,s&&(h.poleAxis.value=s);const{_lodMax:v}=this;h.dTheta.value=u,h.mipInt.value=v-n;const _=this._sizeLods[i];zd(e,3*_*(i>v-4?i-v+4:0),4*(this._cubeSize-_),3*_,2*_),o.setRenderTarget(e),o.render(c,Rd)}}function Fd(t,e,n){const i=new Yi(t,e,n);return i.texture.mapping=ve,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function zd(t,e,n,i,r){t.viewport.set(e,n,i,r),t.scissor.set(e,n,i,r)}function kd(){return new Mc({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Bd(){return new Mc({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}class Gd extends Yi{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},i=[n,n,n,n,n,n];this.texture=new jo(i),this._setTextureOptions(e),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},i=new Zo(5,5,5),r=new Mc({name:"CubemapFromEquirect",uniforms:_c(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});r.uniforms.tEquirect.value=e;const a=new bs(i,r),s=e.minFilter;return e.minFilter===Te&&(e.minFilter=we),new jh(1,10,this).update(t,a),e.minFilter=s,a.geometry.dispose(),a.material.dispose(),this}clear(t,e=!0,n=!0,i=!0){const r=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,n,i);t.setRenderTarget(r)}}function Vd(t){let e=new WeakMap,n=new WeakMap,i=null;function r(t,e){return e===fe?t.mapping=pe:e===ge&&(t.mapping=me),t}function a(t){const n=t.target;n.removeEventListener("dispose",a);const i=e.get(n);void 0!==i&&(e.delete(n),i.dispose())}function s(t){const e=t.target;e.removeEventListener("dispose",s);const i=n.get(e);void 0!==i&&(n.delete(e),i.dispose())}return{get:function(o,l=!1){return null==o?null:l?function(e){if(e&&e.isTexture){const r=e.mapping,a=r===fe||r===ge,o=r===pe||r===me;if(a||o){let r=n.get(e);const l=void 0!==r?r.texture.pmremVersion:0;if(e.isRenderTargetTexture&&e.pmremVersion!==l)return null===i&&(i=new Ud(t)),r=a?i.fromEquirectangular(e,r):i.fromCubemap(e,r),r.texture.pmremVersion=e.pmremVersion,n.set(e,r),r.texture;if(void 0!==r)return r.texture;{const l=e.image;return a&&l&&l.height>0||o&&l&&function(t){let e=0;const n=6;for(let i=0;i<n;i++)void 0!==t[i]&&e++;return e===n}(l)?(null===i&&(i=new Ud(t)),r=a?i.fromEquirectangular(e):i.fromCubemap(e),r.texture.pmremVersion=e.pmremVersion,n.set(e,r),e.addEventListener("dispose",s),r.texture):null}}}return e}(o):function(n){if(n&&n.isTexture){const i=n.mapping;if(i===fe||i===ge){if(e.has(n))return r(e.get(n).texture,n.mapping);{const i=n.image;if(i&&i.height>0){const s=new Gd(i.height);return s.fromEquirectangularTexture(t,n),e.set(n,s),n.addEventListener("dispose",a),r(s.texture,n.mapping)}return null}}}return n}(o)},dispose:function(){e=new WeakMap,n=new WeakMap,null!==i&&(i.dispose(),i=null)}}}function Hd(t){const e={};function n(n){if(void 0!==e[n])return e[n];const i=t.getExtension(n);return e[n]=i,i}return{has:function(t){return null!==n(t)},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(t){const e=n(t);return null===e&&di("WebGLRenderer: "+t+" extension not supported."),e}}}function Wd(t,e,n,i){const r={},a=new WeakMap;function s(t){const o=t.target;null!==o.index&&e.remove(o.index);for(const t in o.attributes)e.remove(o.attributes[t]);o.removeEventListener("dispose",s),delete r[o.id];const l=a.get(o);l&&(e.remove(l),a.delete(o)),i.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,n.memory.geometries--}function o(t){const n=[],i=t.index,r=t.attributes.position;let s=0;if(void 0===r)return;if(null!==i){const t=i.array;s=i.version;for(let e=0,i=t.length;e<i;e+=3){const i=t[e+0],r=t[e+1],a=t[e+2];n.push(i,r,r,a,a,i)}}else{const t=r.array;s=r.version;for(let e=0,i=t.length/3-1;e<i;e+=3){const t=e+0,i=e+1,r=e+2;n.push(t,i,i,r,r,t)}}const o=new(r.count>=65535?va:ga)(n,1);o.version=s;const l=a.get(t);l&&e.remove(l),a.set(t,o)}return{get:function(t,e){return!0===r[e.id]||(e.addEventListener("dispose",s),r[e.id]=!0,n.memory.geometries++),e},update:function(n){const i=n.attributes;for(const n in i)e.update(i[n],t.ARRAY_BUFFER)},getWireframeAttribute:function(t){const e=a.get(t);if(e){const n=t.index;null!==n&&e.version<n.version&&o(t)}else o(t);return a.get(t)}}}function jd(t,e,n){let i,r,a;this.setMode=function(t){i=t},this.setIndex=function(t){r=t.type,a=t.bytesPerElement},this.render=function(e,s){t.drawElements(i,s,r,e*a),n.update(s,i,1)},this.renderInstances=function(e,s,o){0!==o&&(t.drawElementsInstanced(i,s,r,e*a,o),n.update(s,i,o))},this.renderMultiDraw=function(t,a,s){if(0===s)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,a,0,r,t,0,s);let o=0;for(let t=0;t<s;t++)o+=a[t];n.update(o,i,1)}}function Xd(t){const e={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:e,programs:null,autoReset:!0,reset:function(){e.calls=0,e.triangles=0,e.points=0,e.lines=0},update:function(n,i,r){switch(e.calls++,i){case t.TRIANGLES:e.triangles+=r*(n/3);break;case t.LINES:e.lines+=r*(n/2);break;case t.LINE_STRIP:e.lines+=r*(n-1);break;case t.LINE_LOOP:e.lines+=r*n;break;case t.POINTS:e.points+=r*n;break;default:hi("WebGLInfo: Unknown draw mode:",i)}}}}function qd(t,e,n){const i=new WeakMap,r=new Xi;return{update:function(a,s,o){const l=a.morphTargetInfluences,c=s.morphAttributes.position||s.morphAttributes.normal||s.morphAttributes.color,h=void 0!==c?c.length:0;let d=i.get(s);if(void 0===d||d.count!==h){void 0!==d&&d.texture.dispose();const u=void 0!==s.morphAttributes.position,p=void 0!==s.morphAttributes.normal,m=void 0!==s.morphAttributes.color,f=s.morphAttributes.position||[],g=s.morphAttributes.normal||[],v=s.morphAttributes.color||[];let _=0;!0===u&&(_=1),!0===p&&(_=2),!0===m&&(_=3);let y=s.attributes.position.count*_,x=1;y>e.maxTextureSize&&(x=Math.ceil(y/e.maxTextureSize),y=e.maxTextureSize);const b=new Float32Array(y*x*4*h),S=new Zi(b,y,x,h);S.type=De,S.needsUpdate=!0;const M=4*_;for(let E=0;E<h;E++){const T=f[E],A=g[E],C=v[E],R=y*x*4*E;for(let I=0;I<T.count;I++){const P=I*M;!0===u&&(r.fromBufferAttribute(T,I),b[R+P+0]=r.x,b[R+P+1]=r.y,b[R+P+2]=r.z,b[R+P+3]=0),!0===p&&(r.fromBufferAttribute(A,I),b[R+P+4]=r.x,b[R+P+5]=r.y,b[R+P+6]=r.z,b[R+P+7]=0),!0===m&&(r.fromBufferAttribute(C,I),b[R+P+8]=r.x,b[R+P+9]=r.y,b[R+P+10]=r.z,b[R+P+11]=4===C.itemSize?r.w:1)}}function w(){S.dispose(),i.delete(s),s.removeEventListener("dispose",w)}d={count:h,texture:S,size:new Ei(y,x)},i.set(s,d),s.addEventListener("dispose",w)}if(!0===a.isInstancedMesh&&null!==a.morphTexture)o.getUniforms().setValue(t,"morphTexture",a.morphTexture,n);else{let L=0;for(let N=0;N<l.length;N++)L+=l[N];const D=s.morphTargetsRelative?1:1-L;o.getUniforms().setValue(t,"morphTargetBaseInfluence",D),o.getUniforms().setValue(t,"morphTargetInfluences",l)}o.getUniforms().setValue(t,"morphTargetsTexture",d.texture,n),o.getUniforms().setValue(t,"morphTargetsTextureSize",d.size)}}}function Yd(t,e,n,i,r){let a=new WeakMap;function s(t){const e=t.target;e.removeEventListener("dispose",s),i.releaseStatesOfObject(e),n.remove(e.instanceMatrix),null!==e.instanceColor&&n.remove(e.instanceColor)}return{update:function(i){const o=r.render.frame,l=i.geometry,c=e.get(i,l);if(a.get(c)!==o&&(e.update(c),a.set(c,o)),i.isInstancedMesh&&(!1===i.hasEventListener("dispose",s)&&i.addEventListener("dispose",s),a.get(i)!==o&&(n.update(i.instanceMatrix,t.ARRAY_BUFFER),null!==i.instanceColor&&n.update(i.instanceColor,t.ARRAY_BUFFER),a.set(i,o))),i.isSkinnedMesh){const t=i.skeleton;a.get(t)!==o&&(t.update(),a.set(t,o))}return c},dispose:function(){a=new WeakMap}}}const Zd={[ae]:"LINEAR_TONE_MAPPING",[se]:"REINHARD_TONE_MAPPING",[oe]:"CINEON_TONE_MAPPING",[le]:"ACES_FILMIC_TONE_MAPPING",[he]:"AGX_TONE_MAPPING",[de]:"NEUTRAL_TONE_MAPPING",[ce]:"CUSTOM_TONE_MAPPING"};function $d(t,e,n,i,r){const a=new Yi(e,n,{type:t,depthBuffer:i,stencilBuffer:r,depthTexture:i?new Xo(e,n):void 0}),s=new Yi(e,n,{type:Ne,depthBuffer:!1,stencilBuffer:!1}),o=new Ia;o.setAttribute("position",new _a([-1,3,0,-1,-1,0,3,-1,0],3)),o.setAttribute("uv",new _a([0,2,0,0,2,0],2));const l=new wc({uniforms:{tDiffuse:{value:null}},vertexShader:"\n\t\t\tprecision highp float;\n\n\t\t\tuniform mat4 modelViewMatrix;\n\t\t\tuniform mat4 projectionMatrix;\n\n\t\t\tattribute vec3 position;\n\t\t\tattribute vec2 uv;\n\n\t\t\tvarying vec2 vUv;\n\n\t\t\tvoid main() {\n\t\t\t\tvUv = uv;\n\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t}",fragmentShader:"\n\t\t\tprecision highp float;\n\n\t\t\tuniform sampler2D tDiffuse;\n\n\t\t\tvarying vec2 vUv;\n\n\t\t\t#include <tonemapping_pars_fragment>\n\t\t\t#include <colorspace_pars_fragment>\n\n\t\t\tvoid main() {\n\t\t\t\tgl_FragColor = texture2D( tDiffuse, vUv );\n\n\t\t\t\t#ifdef LINEAR_TONE_MAPPING\n\t\t\t\t\tgl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( REINHARD_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( CINEON_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( ACES_FILMIC_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( AGX_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( NEUTRAL_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( CUSTOM_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );\n\t\t\t\t#endif\n\n\t\t\t\t#ifdef SRGB_TRANSFER\n\t\t\t\t\tgl_FragColor = sRGBTransferOETF( gl_FragColor );\n\t\t\t\t#endif\n\t\t\t}",depthTest:!1,depthWrite:!1}),c=new bs(o,l),h=new Ch(-1,1,1,-1,0,1);let d,u=null,p=null,m=!1,f=null,g=[],v=!1;this.setSize=function(t,e){a.setSize(t,e),s.setSize(t,e);for(let n=0;n<g.length;n++){const i=g[n];i.setSize&&i.setSize(t,e)}},this.setEffects=function(t){g=t,v=g.length>0&&!0===g[0].isRenderPass;const e=a.width,n=a.height;for(let t=0;t<g.length;t++){const i=g[t];i.setSize&&i.setSize(e,n)}},this.begin=function(t,e){if(m)return!1;if(0===t.toneMapping&&0===g.length)return!1;if(f=e,null!==e){const t=e.width,n=e.height;a.width===t&&a.height===n||this.setSize(t,n)}return!1===v&&t.setRenderTarget(a),d=t.toneMapping,t.toneMapping=0,!0},this.hasRenderPass=function(){return v},this.end=function(t,e){t.toneMapping=d,m=!0;let n=a,i=s;for(let r=0;r<g.length;r++){const a=g[r];if(!1!==a.enabled&&(a.render(t,i,n,e),!1!==a.needsSwap)){const t=n;n=i,i=t}}if(u!==t.outputColorSpace||p!==t.toneMapping){u=t.outputColorSpace,p=t.toneMapping,l.defines={},Oi.getTransfer(u)===Vn&&(l.defines.SRGB_TRANSFER="");const e=Zd[p];e&&(l.defines[e]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=n.texture,t.setRenderTarget(f),t.render(c,h),f=null,m=!1},this.isCompositing=function(){return m},this.dispose=function(){a.depthTexture&&a.depthTexture.dispose(),a.dispose(),s.dispose(),o.dispose(),l.dispose()}}const Jd=new ji,Kd=new Xo(1,1),Qd=new Zi,tu=new $i,eu=new jo,nu=[],iu=[],ru=new Float32Array(16),au=new Float32Array(9),su=new Float32Array(4);function ou(t,e,n){const i=t[0];if(i<=0||i>0)return t;const r=e*n;let a=nu[r];if(void 0===a&&(a=new Float32Array(r),nu[r]=a),0!==e){i.toArray(a,0);for(let i=1,r=0;i!==e;++i)r+=n,t[i].toArray(a,r)}return a}function lu(t,e){if(t.length!==e.length)return!1;for(let n=0,i=t.length;n<i;n++)if(t[n]!==e[n])return!1;return!0}function cu(t,e){for(let n=0,i=e.length;n<i;n++)t[n]=e[n]}function hu(t,e){let n=iu[e];void 0===n&&(n=new Int32Array(e),iu[e]=n);for(let i=0;i!==e;++i)n[i]=t.allocateTextureUnit();return n}function du(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function uu(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(lu(n,e))return;t.uniform2fv(this.addr,e),cu(n,e)}}function pu(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(void 0!==e.r)n[0]===e.r&&n[1]===e.g&&n[2]===e.b||(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(lu(n,e))return;t.uniform3fv(this.addr,e),cu(n,e)}}function mu(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(lu(n,e))return;t.uniform4fv(this.addr,e),cu(n,e)}}function fu(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(lu(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),cu(n,e)}else{if(lu(n,i))return;su.set(i),t.uniformMatrix2fv(this.addr,!1,su),cu(n,i)}}function gu(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(lu(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),cu(n,e)}else{if(lu(n,i))return;au.set(i),t.uniformMatrix3fv(this.addr,!1,au),cu(n,i)}}function vu(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(lu(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),cu(n,e)}else{if(lu(n,i))return;ru.set(i),t.uniformMatrix4fv(this.addr,!1,ru),cu(n,i)}}function _u(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function yu(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(lu(n,e))return;t.uniform2iv(this.addr,e),cu(n,e)}}function xu(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(lu(n,e))return;t.uniform3iv(this.addr,e),cu(n,e)}}function bu(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(lu(n,e))return;t.uniform4iv(this.addr,e),cu(n,e)}}function Su(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function Mu(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(lu(n,e))return;t.uniform2uiv(this.addr,e),cu(n,e)}}function wu(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(lu(n,e))return;t.uniform3uiv(this.addr,e),cu(n,e)}}function Eu(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(lu(n,e))return;t.uniform4uiv(this.addr,e),cu(n,e)}}function Tu(t,e,n){const i=this.cache,r=n.allocateTextureUnit();let a;i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),this.type===t.SAMPLER_2D_SHADOW?(Kd.compareFunction=n.isReversedDepthBuffer()?518:515,a=Kd):a=Jd,n.setTexture2D(e||a,r)}function Au(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTexture3D(e||tu,r)}function Cu(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTextureCube(e||eu,r)}function Ru(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTexture2DArray(e||Qd,r)}function Iu(t,e){t.uniform1fv(this.addr,e)}function Pu(t,e){const n=ou(e,this.size,2);t.uniform2fv(this.addr,n)}function Lu(t,e){const n=ou(e,this.size,3);t.uniform3fv(this.addr,n)}function Du(t,e){const n=ou(e,this.size,4);t.uniform4fv(this.addr,n)}function Nu(t,e){const n=ou(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function Ou(t,e){const n=ou(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function Uu(t,e){const n=ou(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function Fu(t,e){t.uniform1iv(this.addr,e)}function zu(t,e){t.uniform2iv(this.addr,e)}function ku(t,e){t.uniform3iv(this.addr,e)}function Bu(t,e){t.uniform4iv(this.addr,e)}function Gu(t,e){t.uniform1uiv(this.addr,e)}function Vu(t,e){t.uniform2uiv(this.addr,e)}function Hu(t,e){t.uniform3uiv(this.addr,e)}function Wu(t,e){t.uniform4uiv(this.addr,e)}function ju(t,e,n){const i=this.cache,r=e.length,a=hu(n,r);let s;lu(i,a)||(t.uniform1iv(this.addr,a),cu(i,a)),s=this.type===t.SAMPLER_2D_SHADOW?Kd:Jd;for(let t=0;t!==r;++t)n.setTexture2D(e[t]||s,a[t])}function Xu(t,e,n){const i=this.cache,r=e.length,a=hu(n,r);lu(i,a)||(t.uniform1iv(this.addr,a),cu(i,a));for(let t=0;t!==r;++t)n.setTexture3D(e[t]||tu,a[t])}function qu(t,e,n){const i=this.cache,r=e.length,a=hu(n,r);lu(i,a)||(t.uniform1iv(this.addr,a),cu(i,a));for(let t=0;t!==r;++t)n.setTextureCube(e[t]||eu,a[t])}function Yu(t,e,n){const i=this.cache,r=e.length,a=hu(n,r);lu(i,a)||(t.uniform1iv(this.addr,a),cu(i,a));for(let t=0;t!==r;++t)n.setTexture2DArray(e[t]||Qd,a[t])}class Zu{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=function(t){switch(t){case 5126:return du;case 35664:return uu;case 35665:return pu;case 35666:return mu;case 35674:return fu;case 35675:return gu;case 35676:return vu;case 5124:case 35670:return _u;case 35667:case 35671:return yu;case 35668:case 35672:return xu;case 35669:case 35673:return bu;case 5125:return Su;case 36294:return Mu;case 36295:return wu;case 36296:return Eu;case 35678:case 36198:case 36298:case 36306:case 35682:return Tu;case 35679:case 36299:case 36307:return Au;case 35680:case 36300:case 36308:case 36293:return Cu;case 36289:case 36303:case 36311:case 36292:return Ru}}(e.type)}}class $u{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=function(t){switch(t){case 5126:return Iu;case 35664:return Pu;case 35665:return Lu;case 35666:return Du;case 35674:return Nu;case 35675:return Ou;case 35676:return Uu;case 5124:case 35670:return Fu;case 35667:case 35671:return zu;case 35668:case 35672:return ku;case 35669:case 35673:return Bu;case 5125:return Gu;case 36294:return Vu;case 36295:return Hu;case 36296:return Wu;case 35678:case 36198:case 36298:case 36306:case 35682:return ju;case 35679:case 36299:case 36307:return Xu;case 35680:case 36300:case 36308:case 36293:return qu;case 36289:case 36303:case 36311:case 36292:return Yu}}(e.type)}}class Ju{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){const i=this.seq;for(let r=0,a=i.length;r!==a;++r){const a=i[r];a.setValue(t,e[a.id],n)}}}const Ku=/(\w+)(\])?(\[|\.)?/g;function Qu(t,e){t.seq.push(e),t.map[e.id]=e}function tp(t,e,n){const i=t.name,r=i.length;for(Ku.lastIndex=0;;){const a=Ku.exec(i),s=Ku.lastIndex;let o=a[1];const l="]"===a[2],c=a[3];if(l&&(o|=0),void 0===c||"["===c&&s+2===r){Qu(n,void 0===c?new Zu(o,t,e):new $u(o,t,e));break}{let t=n.map[o];void 0===t&&(t=new Ju(o),Qu(n,t)),n=t}}}class ep{constructor(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){const n=t.getActiveUniform(e,i);tp(n,t.getUniformLocation(e,n.name),this)}const i=[],r=[];for(const e of this.seq)e.type===t.SAMPLER_2D_SHADOW||e.type===t.SAMPLER_CUBE_SHADOW||e.type===t.SAMPLER_2D_ARRAY_SHADOW?i.push(e):r.push(e);i.length>0&&(this.seq=i.concat(r))}setValue(t,e,n,i){const r=this.map[e];void 0!==r&&r.setValue(t,n,i)}setOptional(t,e,n){const i=e[n];void 0!==i&&this.setValue(t,n,i)}static upload(t,e,n,i){for(let r=0,a=e.length;r!==a;++r){const a=e[r],s=n[a.id];!1!==s.needsUpdate&&a.setValue(t,s.value,i)}}static seqWithValue(t,e){const n=[];for(let i=0,r=t.length;i!==r;++i){const r=t[i];r.id in e&&n.push(r)}return n}}function np(t,e,n){const i=t.createShader(e);return t.shaderSource(i,n),t.compileShader(i),i}let ip=0;const rp=new Ii;function ap(t,e,n){const i=t.getShaderParameter(e,t.COMPILE_STATUS),r=(t.getShaderInfoLog(e)||"").trim();if(i&&""===r)return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const i=parseInt(a[1]);return n.toUpperCase()+"\n\n"+r+"\n\n"+function(t,e){const n=t.split("\n"),i=[],r=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let t=r;t<a;t++){const r=t+1;i.push(`${r===e?">":" "} ${r}: ${n[t]}`)}return i.join("\n")}(t.getShaderSource(e),i)}return r}function sp(t,e){const n=function(t){Oi._getMatrix(rp,Oi.workingColorSpace,t);const e=`mat3( ${rp.elements.map((t=>t.toFixed(4)))} )`;switch(Oi.getTransfer(t)){case Gn:return[e,"LinearTransferOETF"];case Vn:return[e,"sRGBTransferOETF"];default:return ci("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}(e);return[`vec4 ${t}( vec4 value ) {`,`\treturn ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join("\n")}const op={[ae]:"Linear",[se]:"Reinhard",[oe]:"Cineon",[le]:"ACESFilmic",[he]:"AgX",[de]:"Neutral",[ce]:"Custom"};function lp(t,e){const n=op[e];return void 0===n?(ci("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+t+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const cp=new Ai;function hp(){return Oi.getLuminanceCoefficients(cp),["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${cp.x.toFixed(4)}, ${cp.y.toFixed(4)}, ${cp.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")}function dp(t){return""!==t}function up(t,e){const n=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function pp(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const mp=/^[ \t]*#include +<([\w\d./]+)>/gm;function fp(t){return t.replace(mp,vp)}const gp=new Map;function vp(t,e){let n=gd[e];if(void 0===n){const t=gp.get(e);if(void 0===t)throw new Error("Can not resolve #include <"+e+">");n=gd[t],ci('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,t)}return fp(n)}const _p=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function yp(t){return t.replace(_p,xp)}function xp(t,e,n,i){let r="";for(let t=parseInt(e);t<parseInt(n);t++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+t+" ]").replace(/UNROLLED_LOOP_INDEX/g,t);return r}function bp(t){let e=`precision ${t.precision} float;\n\tprecision ${t.precision} int;\n\tprecision ${t.precision} sampler2D;\n\tprecision ${t.precision} samplerCube;\n\tprecision ${t.precision} sampler3D;\n\tprecision ${t.precision} sampler2DArray;\n\tprecision ${t.precision} sampler2DShadow;\n\tprecision ${t.precision} samplerCubeShadow;\n\tprecision ${t.precision} sampler2DArrayShadow;\n\tprecision ${t.precision} isampler2D;\n\tprecision ${t.precision} isampler3D;\n\tprecision ${t.precision} isamplerCube;\n\tprecision ${t.precision} isampler2DArray;\n\tprecision ${t.precision} usampler2D;\n\tprecision ${t.precision} usampler3D;\n\tprecision ${t.precision} usamplerCube;\n\tprecision ${t.precision} usampler2DArray;\n\t`;return"highp"===t.precision?e+="\n#define HIGH_PRECISION":"mediump"===t.precision?e+="\n#define MEDIUM_PRECISION":"lowp"===t.precision&&(e+="\n#define LOW_PRECISION"),e}const Sp={[Et]:"SHADOWMAP_TYPE_PCF",[Tt]:"SHADOWMAP_TYPE_VSM"},Mp={[pe]:"ENVMAP_TYPE_CUBE",[me]:"ENVMAP_TYPE_CUBE",[ve]:"ENVMAP_TYPE_CUBE_UV"},wp={[me]:"ENVMAP_MODE_REFRACTION"},Ep={[ne]:"ENVMAP_BLENDING_MULTIPLY",[ie]:"ENVMAP_BLENDING_MIX",[re]:"ENVMAP_BLENDING_ADD"};function Tp(t,e,n,i){const r=t.getContext(),a=n.defines;let s=n.vertexShader,o=n.fragmentShader;const l=function(t){return Sp[t.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}(n),c=function(t){return!1===t.envMap?"ENVMAP_TYPE_CUBE":Mp[t.envMapMode]||"ENVMAP_TYPE_CUBE"}(n),h=function(t){return!1===t.envMap?"ENVMAP_MODE_REFLECTION":wp[t.envMapMode]||"ENVMAP_MODE_REFLECTION"}(n),d=function(t){return!1===t.envMap?"ENVMAP_BLENDING_NONE":Ep[t.combine]||"ENVMAP_BLENDING_NONE"}(n),u=function(t){const e=t.envMapCubeUVHeight;if(null===e)return null;const n=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}(n),p=function(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(dp).join("\n")}(n),m=function(t){const e=[];for(const n in t){const i=t[n];!1!==i&&e.push("#define "+n+" "+i)}return e.join("\n")}(a),f=r.createProgram();let g,v,_=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(dp).join("\n"),g.length>0&&(g+="\n"),v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(dp).join("\n"),v.length>0&&(v+="\n")):(g=[bp(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+h:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexNormals?"#define HAS_NORMAL":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(dp).join("\n"),v=[bp(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+h:"",n.envMap?"#define "+d:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==n.toneMapping?"#define TONE_MAPPING":"",0!==n.toneMapping?gd.tonemapping_pars_fragment:"",0!==n.toneMapping?lp("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",gd.colorspace_pars_fragment,sp("linearToOutputTexel",n.outputColorSpace),hp(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(dp).join("\n")),s=fp(s),s=up(s,n),s=pp(s,n),o=fp(o),o=up(o,n),o=pp(o,n),s=yp(s),o=yp(o),!0!==n.isRawShaderMaterial&&(_="#version 300 es\n",g=[p,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,v=["#define varying in",n.glslVersion===Qn?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Qn?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+v);const y=_+g+s,x=_+v+o,b=np(r,r.VERTEX_SHADER,y),S=np(r,r.FRAGMENT_SHADER,x);function M(e){if(t.debug.checkShaderErrors){const n=r.getProgramInfoLog(f)||"",i=r.getShaderInfoLog(b)||"",a=r.getShaderInfoLog(S)||"",s=n.trim(),o=i.trim(),l=a.trim();let c=!0,h=!0;if(!1===r.getProgramParameter(f,r.LINK_STATUS))if(c=!1,"function"==typeof t.debug.onShaderError)t.debug.onShaderError(r,f,b,S);else{const t=ap(r,b,"vertex"),n=ap(r,S,"fragment");hi("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(f,r.VALIDATE_STATUS)+"\n\nMaterial Name: "+e.name+"\nMaterial Type: "+e.type+"\n\nProgram Info Log: "+s+"\n"+t+"\n"+n)}else""!==s?ci("WebGLProgram: Program Info Log:",s):""!==o&&""!==l||(h=!1);h&&(e.diagnostics={runnable:c,programLog:s,vertexShader:{log:o,prefix:g},fragmentShader:{log:l,prefix:v}})}r.deleteShader(b),r.deleteShader(S),w=new ep(r,f),E=function(t,e){const n={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const i=t.getActiveAttrib(e,r),a=i.name;let s=1;i.type===t.FLOAT_MAT2&&(s=2),i.type===t.FLOAT_MAT3&&(s=3),i.type===t.FLOAT_MAT4&&(s=4),n[a]={type:i.type,location:t.getAttribLocation(e,a),locationSize:s}}return n}(r,f)}let w,E;r.attachShader(f,b),r.attachShader(f,S),void 0!==n.index0AttributeName?r.bindAttribLocation(f,0,n.index0AttributeName):!0===n.morphTargets&&r.bindAttribLocation(f,0,"position"),r.linkProgram(f),this.getUniforms=function(){return void 0===w&&M(this),w},this.getAttributes=function(){return void 0===E&&M(this),E};let T=!1===n.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===T&&(T=r.getProgramParameter(f,37297)),T},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(f),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=ip++,this.cacheKey=e,this.usedTimes=1,this.program=f,this.vertexShader=b,this.fragmentShader=S,this}let Ap=0;class Cp{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,n=t.fragmentShader,i=this._getShaderStage(e),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(t);return!1===a.has(i)&&(a.add(i),i.usedTimes++),!1===a.has(r)&&(a.add(r),r.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const t of e)t.usedTimes--,0===t.usedTimes&&this.shaderCache.delete(t.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let n=e.get(t);return void 0===n&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return void 0===n&&(n=new Rp(t),e.set(t,n)),n}}class Rp{constructor(t){this.id=Ap++,this.code=t,this.usedTimes=0}}function Ip(t,e,n,i,r,a){const s=new lr,o=new Cp,l=new Set,c=[],h=new Map,d=i.logarithmicDepthBuffer;let u=i.precision;const p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(t){return l.add(t),0===t?"uv":`uv${t}`}return{getParameters:function(r,s,c,h,f,g){const v=h.fog,_=f.geometry,y=r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial?h.environment:null,x=r.isMeshStandardMaterial||r.isMeshLambertMaterial&&!r.envMap||r.isMeshPhongMaterial&&!r.envMap,b=e.get(r.envMap||y,x),S=b&&b.mapping===ve?b.image.height:null,M=p[r.type];null!==r.precision&&(u=i.getMaxPrecision(r.precision),u!==r.precision&&ci("WebGLProgram.getParameters:",r.precision,"not supported, using",u,"instead."));const w=_.morphAttributes.position||_.morphAttributes.normal||_.morphAttributes.color,E=void 0!==w?w.length:0;let T,A,C,R,I=0;if(void 0!==_.morphAttributes.position&&(I=1),void 0!==_.morphAttributes.normal&&(I=2),void 0!==_.morphAttributes.color&&(I=3),M){const t=_d[M];T=t.vertexShader,A=t.fragmentShader}else T=r.vertexShader,A=r.fragmentShader,o.update(r),C=o.getVertexShaderID(r),R=o.getFragmentShaderID(r);const P=t.getRenderTarget(),L=t.state.buffers.depth.getReversed(),D=!0===f.isInstancedMesh,N=!0===f.isBatchedMesh,O=!!r.map,U=!!r.matcap,F=!!b,z=!!r.aoMap,k=!!r.lightMap,B=!!r.bumpMap,G=!!r.normalMap,V=!!r.displacementMap,H=!!r.emissiveMap,W=!!r.metalnessMap,j=!!r.roughnessMap,X=r.anisotropy>0,q=r.clearcoat>0,Y=r.dispersion>0,Z=r.iridescence>0,$=r.sheen>0,J=r.transmission>0,K=X&&!!r.anisotropyMap,Q=q&&!!r.clearcoatMap,tt=q&&!!r.clearcoatNormalMap,et=q&&!!r.clearcoatRoughnessMap,nt=Z&&!!r.iridescenceMap,it=Z&&!!r.iridescenceThicknessMap,rt=$&&!!r.sheenColorMap,at=$&&!!r.sheenRoughnessMap,st=!!r.specularMap,ot=!!r.specularColorMap,lt=!!r.specularIntensityMap,ct=J&&!!r.transmissionMap,ht=J&&!!r.thicknessMap,dt=!!r.gradientMap,ut=!!r.alphaMap,pt=r.alphaTest>0,mt=!!r.alphaHash,ft=!!r.extensions;let gt=0;r.toneMapped&&(null!==P&&!0!==P.isXRRenderTarget||(gt=t.toneMapping));const vt={shaderID:M,shaderType:r.type,shaderName:r.name,vertexShader:T,fragmentShader:A,defines:r.defines,customVertexShaderID:C,customFragmentShaderID:R,isRawShaderMaterial:!0===r.isRawShaderMaterial,glslVersion:r.glslVersion,precision:u,batching:N,batchingColor:N&&null!==f._colorsTexture,instancing:D,instancingColor:D&&null!==f.instanceColor,instancingMorph:D&&null!==f.morphTexture,outputColorSpace:null===P?t.outputColorSpace:!0===P.isXRRenderTarget?P.texture.colorSpace:Oi.workingColorSpace,alphaToCoverage:!!r.alphaToCoverage,map:O,matcap:U,envMap:F,envMapMode:F&&b.mapping,envMapCubeUVHeight:S,aoMap:z,lightMap:k,bumpMap:B,normalMap:G,displacementMap:V,emissiveMap:H,normalMapObjectSpace:G&&1===r.normalMapType,normalMapTangentSpace:G&&0===r.normalMapType,packedNormalMap:G&&0===r.normalMapType&&(_t=r.normalMap.format,_t===je||_t===ln||_t===Rn),metalnessMap:W,roughnessMap:j,anisotropy:X,anisotropyMap:K,clearcoat:q,clearcoatMap:Q,clearcoatNormalMap:tt,clearcoatRoughnessMap:et,dispersion:Y,iridescence:Z,iridescenceMap:nt,iridescenceThicknessMap:it,sheen:$,sheenColorMap:rt,sheenRoughnessMap:at,specularMap:st,specularColorMap:ot,specularIntensityMap:lt,transmission:J,transmissionMap:ct,thicknessMap:ht,gradientMap:dt,opaque:!1===r.transparent&&1===r.blending&&!1===r.alphaToCoverage,alphaMap:ut,alphaTest:pt,alphaHash:mt,combine:r.combine,mapUv:O&&m(r.map.channel),aoMapUv:z&&m(r.aoMap.channel),lightMapUv:k&&m(r.lightMap.channel),bumpMapUv:B&&m(r.bumpMap.channel),normalMapUv:G&&m(r.normalMap.channel),displacementMapUv:V&&m(r.displacementMap.channel),emissiveMapUv:H&&m(r.emissiveMap.channel),metalnessMapUv:W&&m(r.metalnessMap.channel),roughnessMapUv:j&&m(r.roughnessMap.channel),anisotropyMapUv:K&&m(r.anisotropyMap.channel),clearcoatMapUv:Q&&m(r.clearcoatMap.channel),clearcoatNormalMapUv:tt&&m(r.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:et&&m(r.clearcoatRoughnessMap.channel),iridescenceMapUv:nt&&m(r.iridescenceMap.channel),iridescenceThicknessMapUv:it&&m(r.iridescenceThicknessMap.channel),sheenColorMapUv:rt&&m(r.sheenColorMap.channel),sheenRoughnessMapUv:at&&m(r.sheenRoughnessMap.channel),specularMapUv:st&&m(r.specularMap.channel),specularColorMapUv:ot&&m(r.specularColorMap.channel),specularIntensityMapUv:lt&&m(r.specularIntensityMap.channel),transmissionMapUv:ct&&m(r.transmissionMap.channel),thicknessMapUv:ht&&m(r.thicknessMap.channel),alphaMapUv:ut&&m(r.alphaMap.channel),vertexTangents:!!_.attributes.tangent&&(G||X),vertexNormals:!!_.attributes.normal,vertexColors:r.vertexColors,vertexAlphas:!0===r.vertexColors&&!!_.attributes.color&&4===_.attributes.color.itemSize,pointsUvs:!0===f.isPoints&&!!_.attributes.uv&&(O||ut),fog:!!v,useFog:!0===r.fog,fogExp2:!!v&&v.isFogExp2,flatShading:!1===r.wireframe&&(!0===r.flatShading||void 0===_.attributes.normal&&!1===G&&(r.isMeshLambertMaterial||r.isMeshPhongMaterial||r.isMeshStandardMaterial||r.isMeshPhysicalMaterial)),sizeAttenuation:!0===r.sizeAttenuation,logarithmicDepthBuffer:d,reversedDepthBuffer:L,skinning:!0===f.isSkinnedMesh,morphTargets:void 0!==_.morphAttributes.position,morphNormals:void 0!==_.morphAttributes.normal,morphColors:void 0!==_.morphAttributes.color,morphTargetsCount:E,morphTextureStride:I,numDirLights:s.directional.length,numPointLights:s.point.length,numSpotLights:s.spot.length,numSpotLightMaps:s.spotLightMap.length,numRectAreaLights:s.rectArea.length,numHemiLights:s.hemi.length,numDirLightShadows:s.directionalShadowMap.length,numPointLightShadows:s.pointShadowMap.length,numSpotLightShadows:s.spotShadowMap.length,numSpotLightShadowsWithMaps:s.numSpotLightShadowsWithMaps,numLightProbes:s.numLightProbes,numLightProbeGrids:g.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:r.dithering,shadowMapEnabled:t.shadowMap.enabled&&c.length>0,shadowMapType:t.shadowMap.type,toneMapping:gt,decodeVideoTexture:O&&!0===r.map.isVideoTexture&&Oi.getTransfer(r.map.colorSpace)===Vn,decodeVideoTextureEmissive:H&&!0===r.emissiveMap.isVideoTexture&&Oi.getTransfer(r.emissiveMap.colorSpace)===Vn,premultipliedAlpha:r.premultipliedAlpha,doubleSided:2===r.side,flipSided:1===r.side,useDepthPacking:r.depthPacking>=0,depthPacking:r.depthPacking||0,index0AttributeName:r.index0AttributeName,extensionClipCullDistance:ft&&!0===r.extensions.clipCullDistance&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ft&&!0===r.extensions.multiDraw||N)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:r.customProgramCacheKey()};var _t;return vt.vertexUv1s=l.has(1),vt.vertexUv2s=l.has(2),vt.vertexUv3s=l.has(3),l.clear(),vt},getProgramCacheKey:function(e){const n=[];if(e.shaderID?n.push(e.shaderID):(n.push(e.customVertexShaderID),n.push(e.customFragmentShaderID)),void 0!==e.defines)for(const t in e.defines)n.push(t),n.push(e.defines[t]);return!1===e.isRawShaderMaterial&&(function(t,e){t.push(e.precision),t.push(e.outputColorSpace),t.push(e.envMapMode),t.push(e.envMapCubeUVHeight),t.push(e.mapUv),t.push(e.alphaMapUv),t.push(e.lightMapUv),t.push(e.aoMapUv),t.push(e.bumpMapUv),t.push(e.normalMapUv),t.push(e.displacementMapUv),t.push(e.emissiveMapUv),t.push(e.metalnessMapUv),t.push(e.roughnessMapUv),t.push(e.anisotropyMapUv),t.push(e.clearcoatMapUv),t.push(e.clearcoatNormalMapUv),t.push(e.clearcoatRoughnessMapUv),t.push(e.iridescenceMapUv),t.push(e.iridescenceThicknessMapUv),t.push(e.sheenColorMapUv),t.push(e.sheenRoughnessMapUv),t.push(e.specularMapUv),t.push(e.specularColorMapUv),t.push(e.specularIntensityMapUv),t.push(e.transmissionMapUv),t.push(e.thicknessMapUv),t.push(e.combine),t.push(e.fogExp2),t.push(e.sizeAttenuation),t.push(e.morphTargetsCount),t.push(e.morphAttributeCount),t.push(e.numDirLights),t.push(e.numPointLights),t.push(e.numSpotLights),t.push(e.numSpotLightMaps),t.push(e.numHemiLights),t.push(e.numRectAreaLights),t.push(e.numDirLightShadows),t.push(e.numPointLightShadows),t.push(e.numSpotLightShadows),t.push(e.numSpotLightShadowsWithMaps),t.push(e.numLightProbes),t.push(e.shadowMapType),t.push(e.toneMapping),t.push(e.numClippingPlanes),t.push(e.numClipIntersection),t.push(e.depthPacking)}(n,e),function(t,e){s.disableAll(),e.instancing&&s.enable(0),e.instancingColor&&s.enable(1),e.instancingMorph&&s.enable(2),e.matcap&&s.enable(3),e.envMap&&s.enable(4),e.normalMapObjectSpace&&s.enable(5),e.normalMapTangentSpace&&s.enable(6),e.clearcoat&&s.enable(7),e.iridescence&&s.enable(8),e.alphaTest&&s.enable(9),e.vertexColors&&s.enable(10),e.vertexAlphas&&s.enable(11),e.vertexUv1s&&s.enable(12),e.vertexUv2s&&s.enable(13),e.vertexUv3s&&s.enable(14),e.vertexTangents&&s.enable(15),e.anisotropy&&s.enable(16),e.alphaHash&&s.enable(17),e.batching&&s.enable(18),e.dispersion&&s.enable(19),e.batchingColor&&s.enable(20),e.gradientMap&&s.enable(21),e.packedNormalMap&&s.enable(22),e.vertexNormals&&s.enable(23),t.push(s.mask),s.disableAll(),e.fog&&s.enable(0),e.useFog&&s.enable(1),e.flatShading&&s.enable(2),e.logarithmicDepthBuffer&&s.enable(3),e.reversedDepthBuffer&&s.enable(4),e.skinning&&s.enable(5),e.morphTargets&&s.enable(6),e.morphNormals&&s.enable(7),e.morphColors&&s.enable(8),e.premultipliedAlpha&&s.enable(9),e.shadowMapEnabled&&s.enable(10),e.doubleSided&&s.enable(11),e.flipSided&&s.enable(12),e.useDepthPacking&&s.enable(13),e.dithering&&s.enable(14),e.transmission&&s.enable(15),e.sheen&&s.enable(16),e.opaque&&s.enable(17),e.pointsUvs&&s.enable(18),e.decodeVideoTexture&&s.enable(19),e.decodeVideoTextureEmissive&&s.enable(20),e.alphaToCoverage&&s.enable(21),e.numLightProbeGrids>0&&s.enable(22),t.push(s.mask)}(n,e),n.push(t.outputColorSpace)),n.push(e.customProgramCacheKey),n.join()},getUniforms:function(t){const e=p[t.type];let n;if(e){const t=_d[e];n=Sc.clone(t.uniforms)}else n=t.uniforms;return n},acquireProgram:function(e,n){let i=h.get(n);return void 0!==i?++i.usedTimes:(i=new Tp(t,n,e,r),c.push(i),h.set(n,i)),i},releaseProgram:function(t){if(0===--t.usedTimes){const e=c.indexOf(t);c[e]=c[c.length-1],c.pop(),h.delete(t.cacheKey),t.destroy()}},releaseShaderCache:function(t){o.remove(t)},programs:c,dispose:function(){o.dispose()}}}function Pp(){let t=new WeakMap;return{has:function(e){return t.has(e)},get:function(e){let n=t.get(e);return void 0===n&&(n={},t.set(e,n)),n},remove:function(e){t.delete(e)},update:function(e,n,i){t.get(e)[n]=i},dispose:function(){t=new WeakMap}}}function Lp(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.materialVariant!==e.materialVariant?t.materialVariant-e.materialVariant:t.z!==e.z?t.z-e.z:t.id-e.id}function Dp(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function Np(){const t=[];let e=0;const n=[],i=[],r=[];function a(t){let e=0;return t.isInstancedMesh&&(e+=2),t.isSkinnedMesh&&(e+=1),e}function s(n,i,r,s,o,l){let c=t[e];return void 0===c?(c={id:n.id,object:n,geometry:i,material:r,materialVariant:a(n),groupOrder:s,renderOrder:n.renderOrder,z:o,group:l},t[e]=c):(c.id=n.id,c.object=n,c.geometry=i,c.material=r,c.materialVariant=a(n),c.groupOrder=s,c.renderOrder=n.renderOrder,c.z=o,c.group=l),e++,c}return{opaque:n,transmissive:i,transparent:r,init:function(){e=0,n.length=0,i.length=0,r.length=0},push:function(t,e,a,o,l,c){const h=s(t,e,a,o,l,c);a.transmission>0?i.push(h):!0===a.transparent?r.push(h):n.push(h)},unshift:function(t,e,a,o,l,c){const h=s(t,e,a,o,l,c);a.transmission>0?i.unshift(h):!0===a.transparent?r.unshift(h):n.unshift(h)},finish:function(){for(let n=e,i=t.length;n<i;n++){const e=t[n];if(null===e.id)break;e.id=null,e.object=null,e.geometry=null,e.material=null,e.group=null}},sort:function(t,e){n.length>1&&n.sort(t||Lp),i.length>1&&i.sort(e||Dp),r.length>1&&r.sort(e||Dp)}}}function Op(){let t=new WeakMap;return{get:function(e,n){const i=t.get(e);let r;return void 0===i?(r=new Np,t.set(e,[r])):n>=i.length?(r=new Np,i.push(r)):r=i[n],r},dispose:function(){t=new WeakMap}}}function Up(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new Ai,color:new Lr};break;case"SpotLight":n={position:new Ai,direction:new Ai,color:new Lr,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Ai,color:new Lr,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Ai,skyColor:new Lr,groundColor:new Lr};break;case"RectAreaLight":n={color:new Lr,position:new Ai,halfWidth:new Ai,halfHeight:new Ai}}return t[e.id]=n,n}}}let Fp=0;function zp(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function kp(t){const e=new Up,n=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ei};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ei,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=n,n}}}(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let t=0;t<9;t++)i.probe.push(new Ai);const r=new Ai,a=new Ji,s=new Ji;return{setup:function(r){let a=0,s=0,o=0;for(let t=0;t<9;t++)i.probe[t].set(0,0,0);let l=0,c=0,h=0,d=0,u=0,p=0,m=0,f=0,g=0,v=0,_=0;r.sort(zp);for(let t=0,y=r.length;t<y;t++){const y=r[t],x=y.color,b=y.intensity,S=y.distance;let M=null;if(y.shadow&&y.shadow.map&&(M=y.shadow.map.texture.format===je?y.shadow.map.texture:y.shadow.map.depthTexture||y.shadow.map.texture),y.isAmbientLight)a+=x.r*b,s+=x.g*b,o+=x.b*b;else if(y.isLightProbe){for(let t=0;t<9;t++)i.probe[t].addScaledVector(y.sh.coefficients[t],b);_++}else if(y.isDirectionalLight){const t=e.get(y);if(t.color.copy(y.color).multiplyScalar(y.intensity),y.castShadow){const t=y.shadow,e=n.get(y);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,i.directionalShadow[l]=e,i.directionalShadowMap[l]=M,i.directionalShadowMatrix[l]=y.shadow.matrix,p++}i.directional[l]=t,l++}else if(y.isSpotLight){const t=e.get(y);t.position.setFromMatrixPosition(y.matrixWorld),t.color.copy(x).multiplyScalar(b),t.distance=S,t.coneCos=Math.cos(y.angle),t.penumbraCos=Math.cos(y.angle*(1-y.penumbra)),t.decay=y.decay,i.spot[h]=t;const r=y.shadow;if(y.map&&(i.spotLightMap[g]=y.map,g++,r.updateMatrices(y),y.castShadow&&v++),i.spotLightMatrix[h]=r.matrix,y.castShadow){const t=n.get(y);t.shadowIntensity=r.intensity,t.shadowBias=r.bias,t.shadowNormalBias=r.normalBias,t.shadowRadius=r.radius,t.shadowMapSize=r.mapSize,i.spotShadow[h]=t,i.spotShadowMap[h]=M,f++}h++}else if(y.isRectAreaLight){const t=e.get(y);t.color.copy(x).multiplyScalar(b),t.halfWidth.set(.5*y.width,0,0),t.halfHeight.set(0,.5*y.height,0),i.rectArea[d]=t,d++}else if(y.isPointLight){const t=e.get(y);if(t.color.copy(y.color).multiplyScalar(y.intensity),t.distance=y.distance,t.decay=y.decay,y.castShadow){const t=y.shadow,e=n.get(y);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,e.shadowCameraNear=t.camera.near,e.shadowCameraFar=t.camera.far,i.pointShadow[c]=e,i.pointShadowMap[c]=M,i.pointShadowMatrix[c]=y.shadow.matrix,m++}i.point[c]=t,c++}else if(y.isHemisphereLight){const t=e.get(y);t.skyColor.copy(y.color).multiplyScalar(b),t.groundColor.copy(y.groundColor).multiplyScalar(b),i.hemi[u]=t,u++}}d>0&&(!0===t.has("OES_texture_float_linear")?(i.rectAreaLTC1=vd.LTC_FLOAT_1,i.rectAreaLTC2=vd.LTC_FLOAT_2):(i.rectAreaLTC1=vd.LTC_HALF_1,i.rectAreaLTC2=vd.LTC_HALF_2)),i.ambient[0]=a,i.ambient[1]=s,i.ambient[2]=o;const y=i.hash;y.directionalLength===l&&y.pointLength===c&&y.spotLength===h&&y.rectAreaLength===d&&y.hemiLength===u&&y.numDirectionalShadows===p&&y.numPointShadows===m&&y.numSpotShadows===f&&y.numSpotMaps===g&&y.numLightProbes===_||(i.directional.length=l,i.spot.length=h,i.rectArea.length=d,i.point.length=c,i.hemi.length=u,i.directionalShadow.length=p,i.directionalShadowMap.length=p,i.pointShadow.length=m,i.pointShadowMap.length=m,i.spotShadow.length=f,i.spotShadowMap.length=f,i.directionalShadowMatrix.length=p,i.pointShadowMatrix.length=m,i.spotLightMatrix.length=f+g-v,i.spotLightMap.length=g,i.numSpotLightShadowsWithMaps=v,i.numLightProbes=_,y.directionalLength=l,y.pointLength=c,y.spotLength=h,y.rectAreaLength=d,y.hemiLength=u,y.numDirectionalShadows=p,y.numPointShadows=m,y.numSpotShadows=f,y.numSpotMaps=g,y.numLightProbes=_,i.version=Fp++)},setupView:function(t,e){let n=0,o=0,l=0,c=0,h=0;const d=e.matrixWorldInverse;for(let e=0,u=t.length;e<u;e++){const u=t[e];if(u.isDirectionalLight){const t=i.directional[n];t.direction.setFromMatrixPosition(u.matrixWorld),r.setFromMatrixPosition(u.target.matrixWorld),t.direction.sub(r),t.direction.transformDirection(d),n++}else if(u.isSpotLight){const t=i.spot[l];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),t.direction.setFromMatrixPosition(u.matrixWorld),r.setFromMatrixPosition(u.target.matrixWorld),t.direction.sub(r),t.direction.transformDirection(d),l++}else if(u.isRectAreaLight){const t=i.rectArea[c];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),s.identity(),a.copy(u.matrixWorld),a.premultiply(d),s.extractRotation(a),t.halfWidth.set(.5*u.width,0,0),t.halfHeight.set(0,.5*u.height,0),t.halfWidth.applyMatrix4(s),t.halfHeight.applyMatrix4(s),c++}else if(u.isPointLight){const t=i.point[o];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),o++}else if(u.isHemisphereLight){const t=i.hemi[h];t.direction.setFromMatrixPosition(u.matrixWorld),t.direction.transformDirection(d),h++}}},state:i}}function Bp(t){const e=new kp(t),n=[],i=[],r=[],a={lightsArray:n,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:function(t){a.camera=t,n.length=0,i.length=0,r.length=0},state:a,setupLights:function(){e.setup(n)},setupLightsView:function(t){e.setupView(n,t)},pushLight:function(t){n.push(t)},pushShadow:function(t){i.push(t)},pushLightProbeGrid:function(t){r.push(t)}}}function Gp(t){let e=new WeakMap;return{get:function(n,i=0){const r=e.get(n);let a;return void 0===r?(a=new Bp(t),e.set(n,[a])):i>=r.length?(a=new Bp(t),r.push(a)):a=r[i],a},dispose:function(){e=new WeakMap}}}const Vp=[new Ai(1,0,0),new Ai(-1,0,0),new Ai(0,1,0),new Ai(0,-1,0),new Ai(0,0,1),new Ai(0,0,-1)],Hp=[new Ai(0,-1,0),new Ai(0,-1,0),new Ai(0,0,1),new Ai(0,0,-1),new Ai(0,-1,0),new Ai(0,-1,0)],Wp=new Ji,jp=new Ai,Xp=new Ai;function qp(t,e,n){let i=new to;const r=new Ei,a=new Ei,s=new Xi,o=new Pc,l=new Lc,c={},h=n.maxTextureSize,d={[At]:1,[Ct]:0,[Rt]:2},u=new Mc({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ei},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );\n\tgl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );\n}"}),p=u.clone();p.defines.HORIZONTAL_PASS=1;const m=new Ia;m.setAttribute("position",new fa(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const f=new bs(m,u),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let v=this.type;function _(n,i){const a=e.update(f);u.defines.VSM_SAMPLES!==n.blurSamples&&(u.defines.VSM_SAMPLES=n.blurSamples,p.defines.VSM_SAMPLES=n.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new Yi(r.x,r.y,{format:je,type:Ne})),u.uniforms.shadow_pass.value=n.map.depthTexture,u.uniforms.resolution.value=n.mapSize,u.uniforms.radius.value=n.radius,t.setRenderTarget(n.mapPass),t.clear(),t.renderBufferDirect(i,null,a,u,f,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,t.setRenderTarget(n.map),t.clear(),t.renderBufferDirect(i,null,a,p,f,null)}function y(e,n,i,r){let a=null;const s=!0===i.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(void 0!==s)a=s;else if(a=!0===i.isPointLight?l:o,t.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0||!0===n.alphaToCoverage){const t=a.uuid,e=n.uuid;let i=c[t];void 0===i&&(i={},c[t]=i);let r=i[e];void 0===r&&(r=a.clone(),i[e]=r,n.addEventListener("dispose",b)),a=r}return a.visible=n.visible,a.wireframe=n.wireframe,a.side=3===r?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:d[n.side],a.alphaMap=n.alphaMap,a.alphaTest=!0===n.alphaToCoverage?.5:n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,!0===i.isPointLight&&!0===a.isMeshDistanceMaterial&&(t.properties.get(a).light=i),a}function x(n,r,a,s,o){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&3===o)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);const i=e.update(n),l=n.material;if(Array.isArray(l)){const e=i.groups;for(let c=0,h=e.length;c<h;c++){const h=e[c],d=l[h.materialIndex];if(d&&d.visible){const e=y(n,d,s,o);n.onBeforeShadow(t,n,r,a,i,e,h),t.renderBufferDirect(a,null,i,e,n,h),n.onAfterShadow(t,n,r,a,i,e,h)}}}else if(l.visible){const e=y(n,l,s,o);n.onBeforeShadow(t,n,r,a,i,e,null),t.renderBufferDirect(a,null,i,e,n,null),n.onAfterShadow(t,n,r,a,i,e,null)}}const l=n.children;for(let t=0,e=l.length;t<e;t++)x(l[t],r,a,s,o)}function b(t){t.target.removeEventListener("dispose",b);for(const e in c){const n=c[e],i=t.target.uuid;i in n&&(n[i].dispose(),delete n[i])}}this.render=function(e,n,o){if(!1===g.enabled)return;if(!1===g.autoUpdate&&!1===g.needsUpdate)return;if(0===e.length)return;2===this.type&&(ci("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=1);const l=t.getRenderTarget(),c=t.getActiveCubeFace(),d=t.getActiveMipmapLevel(),u=t.state;u.setBlending(0),!0===u.buffers.depth.getReversed()?u.buffers.color.setClear(0,0,0,0):u.buffers.color.setClear(1,1,1,1),u.buffers.depth.setTest(!0),u.setScissorTest(!1);const p=v!==this.type;p&&n.traverse((function(t){t.material&&(Array.isArray(t.material)?t.material.forEach((t=>t.needsUpdate=!0)):t.material.needsUpdate=!0)}));for(let l=0,c=e.length;l<c;l++){const c=e[l],d=c.shadow;if(void 0===d){ci("WebGLShadowMap:",c,"has no shadow.");continue}if(!1===d.autoUpdate&&!1===d.needsUpdate)continue;r.copy(d.mapSize);const m=d.getFrameExtents();r.multiply(m),a.copy(d.mapSize),(r.x>h||r.y>h)&&(r.x>h&&(a.x=Math.floor(h/m.x),r.x=a.x*m.x,d.mapSize.x=a.x),r.y>h&&(a.y=Math.floor(h/m.y),r.y=a.y*m.y,d.mapSize.y=a.y));const f=t.state.buffers.depth.getReversed();if(d.camera._reversedDepth=f,null===d.map||!0===p){if(null!==d.map&&(null!==d.map.depthTexture&&(d.map.depthTexture.dispose(),d.map.depthTexture=null),d.map.dispose()),3===this.type){if(c.isPointLight){ci("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}d.map=new Yi(r.x,r.y,{format:je,type:Ne,minFilter:we,magFilter:we,generateMipmaps:!1}),d.map.texture.name=c.name+".shadowMap",d.map.depthTexture=new Xo(r.x,r.y,De),d.map.depthTexture.name=c.name+".shadowMapDepth",d.map.depthTexture.format=Ge,d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=be,d.map.depthTexture.magFilter=be}else c.isPointLight?(d.map=new Gd(r.x),d.map.depthTexture=new qo(r.x,Le)):(d.map=new Yi(r.x,r.y),d.map.depthTexture=new Xo(r.x,r.y,Le)),d.map.depthTexture.name=c.name+".shadowMap",d.map.depthTexture.format=Ge,1===this.type?(d.map.depthTexture.compareFunction=f?518:515,d.map.depthTexture.minFilter=we,d.map.depthTexture.magFilter=we):(d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=be,d.map.depthTexture.magFilter=be);d.camera.updateProjectionMatrix()}const g=d.map.isWebGLCubeRenderTarget?6:1;for(let e=0;e<g;e++){if(d.map.isWebGLCubeRenderTarget)t.setRenderTarget(d.map,e),t.clear();else{0===e&&(t.setRenderTarget(d.map),t.clear());const n=d.getViewport(e);s.set(a.x*n.x,a.y*n.y,a.x*n.z,a.y*n.w),u.viewport(s)}if(c.isPointLight){const t=d.camera,n=d.matrix,i=c.distance||t.far;i!==t.far&&(t.far=i,t.updateProjectionMatrix()),jp.setFromMatrixPosition(c.matrixWorld),t.position.copy(jp),Xp.copy(t.position),Xp.add(Vp[e]),t.up.copy(Hp[e]),t.lookAt(Xp),t.updateMatrixWorld(),n.makeTranslation(-jp.x,-jp.y,-jp.z),Wp.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),d._frustum.setFromProjectionMatrix(Wp,t.coordinateSystem,t.reversedDepth)}else d.updateMatrices(c);i=d.getFrustum(),x(n,o,d.camera,c,this.type)}!0!==d.isPointLightShadow&&3===this.type&&_(d,o),d.needsUpdate=!1}v=this.type,g.needsUpdate=!1,t.setRenderTarget(l,c,d)}}function Yp(t,e){const n=new function(){let e=!1;const n=new Xi;let i=null;const r=new Xi(0,0,0,0);return{setMask:function(n){i===n||e||(t.colorMask(n,n,n,n),i=n)},setLocked:function(t){e=t},setClear:function(e,i,a,s,o){!0===o&&(e*=s,i*=s,a*=s),n.set(e,i,a,s),!1===r.equals(n)&&(t.clearColor(e,i,a,s),r.copy(n))},reset:function(){e=!1,i=null,r.set(-1,0,0,0)}}},i=new function(){let n=!1,i=!1,r=null,a=null,s=null;return{setReversed:function(t){if(i!==t){const n=e.get("EXT_clip_control");t?n.clipControlEXT(n.LOWER_LEFT_EXT,n.ZERO_TO_ONE_EXT):n.clipControlEXT(n.LOWER_LEFT_EXT,n.NEGATIVE_ONE_TO_ONE_EXT),i=t;const r=s;s=null,this.setClear(r)}},getReversed:function(){return i},setTest:function(e){e?G(t.DEPTH_TEST):V(t.DEPTH_TEST)},setMask:function(e){r===e||n||(t.depthMask(e),r=e)},setFunc:function(e){if(i&&(e=ui[e]),a!==e){switch(e){case 0:t.depthFunc(t.NEVER);break;case 1:t.depthFunc(t.ALWAYS);break;case 2:t.depthFunc(t.LESS);break;case 3:default:t.depthFunc(t.LEQUAL);break;case 4:t.depthFunc(t.EQUAL);break;case 5:t.depthFunc(t.GEQUAL);break;case 6:t.depthFunc(t.GREATER);break;case 7:t.depthFunc(t.NOTEQUAL)}a=e}},setLocked:function(t){n=t},setClear:function(e){s!==e&&(s=e,i&&(e=1-e),t.clearDepth(e))},reset:function(){n=!1,r=null,a=null,s=null,i=!1}}},r=new function(){let e=!1,n=null,i=null,r=null,a=null,s=null,o=null,l=null,c=null;return{setTest:function(n){e||(n?G(t.STENCIL_TEST):V(t.STENCIL_TEST))},setMask:function(i){n===i||e||(t.stencilMask(i),n=i)},setFunc:function(e,n,s){i===e&&r===n&&a===s||(t.stencilFunc(e,n,s),i=e,r=n,a=s)},setOp:function(e,n,i){s===e&&o===n&&l===i||(t.stencilOp(e,n,i),s=e,o=n,l=i)},setLocked:function(t){e=t},setClear:function(e){c!==e&&(t.clearStencil(e),c=e)},reset:function(){e=!1,n=null,i=null,r=null,a=null,s=null,o=null,l=null,c=null}}},a=new WeakMap,s=new WeakMap;let o={},l={},c={},h=new WeakMap,d=[],u=null,p=!1,m=null,f=null,g=null,v=null,_=null,y=null,x=null,b=new Lr(0,0,0),S=0,M=!1,w=null,E=null,T=null,A=null,C=null;const R=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let I=!1,P=0;const L=t.getParameter(t.VERSION);-1!==L.indexOf("WebGL")?(P=parseFloat(/^WebGL (\d)/.exec(L)[1]),I=P>=1):-1!==L.indexOf("OpenGL ES")&&(P=parseFloat(/^OpenGL ES (\d)/.exec(L)[1]),I=P>=2);let D=null,N={};const O=t.getParameter(t.SCISSOR_BOX),U=t.getParameter(t.VIEWPORT),F=(new Xi).fromArray(O),z=(new Xi).fromArray(U);function k(e,n,i,r){const a=new Uint8Array(4),s=t.createTexture();t.bindTexture(e,s),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let s=0;s<i;s++)e===t.TEXTURE_3D||e===t.TEXTURE_2D_ARRAY?t.texImage3D(n,0,t.RGBA,1,1,r,0,t.RGBA,t.UNSIGNED_BYTE,a):t.texImage2D(n+s,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,a);return s}const B={};function G(e){!0!==o[e]&&(t.enable(e),o[e]=!0)}function V(e){!1!==o[e]&&(t.disable(e),o[e]=!1)}B[t.TEXTURE_2D]=k(t.TEXTURE_2D,t.TEXTURE_2D,1),B[t.TEXTURE_CUBE_MAP]=k(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),B[t.TEXTURE_2D_ARRAY]=k(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),B[t.TEXTURE_3D]=k(t.TEXTURE_3D,t.TEXTURE_3D,1,1),n.setClear(0,0,0,1),i.setClear(1),r.setClear(0),G(t.DEPTH_TEST),i.setFunc(3),X(!1),q(1),G(t.CULL_FACE),j(0);const H={[It]:t.FUNC_ADD,[Pt]:t.FUNC_SUBTRACT,[Lt]:t.FUNC_REVERSE_SUBTRACT};H[103]=t.MIN,H[104]=t.MAX;const W={[Dt]:t.ZERO,[Nt]:t.ONE,[Ot]:t.SRC_COLOR,[Ft]:t.SRC_ALPHA,[Ht]:t.SRC_ALPHA_SATURATE,[Gt]:t.DST_COLOR,[kt]:t.DST_ALPHA,[Ut]:t.ONE_MINUS_SRC_COLOR,[zt]:t.ONE_MINUS_SRC_ALPHA,[Vt]:t.ONE_MINUS_DST_COLOR,[Bt]:t.ONE_MINUS_DST_ALPHA,[Wt]:t.CONSTANT_COLOR,[jt]:t.ONE_MINUS_CONSTANT_COLOR,[Xt]:t.CONSTANT_ALPHA,[qt]:t.ONE_MINUS_CONSTANT_ALPHA};function j(e,n,i,r,a,s,o,l,c,h){if(0!==e){if(!1===p&&(G(t.BLEND),p=!0),5===e)a=a||n,s=s||i,o=o||r,n===f&&a===_||(t.blendEquationSeparate(H[n],H[a]),f=n,_=a),i===g&&r===v&&s===y&&o===x||(t.blendFuncSeparate(W[i],W[r],W[s],W[o]),g=i,v=r,y=s,x=o),!1!==l.equals(b)&&c===S||(t.blendColor(l.r,l.g,l.b,c),b.copy(l),S=c),m=e,M=!1;else if(e!==m||h!==M){if(f===It&&_===It||(t.blendEquation(t.FUNC_ADD),f=It,_=It),h)switch(e){case 1:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFunc(t.ONE,t.ONE);break;case 3:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case 4:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:hi("WebGLState: Invalid blending: ",e)}else switch(e){case 1:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case 3:hi("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case 4:hi("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:hi("WebGLState: Invalid blending: ",e)}g=null,v=null,y=null,x=null,b.set(0,0,0),S=0,m=e,M=h}}else!0===p&&(V(t.BLEND),p=!1)}function X(e){w!==e&&(e?t.frontFace(t.CW):t.frontFace(t.CCW),w=e)}function q(e){0!==e?(G(t.CULL_FACE),e!==E&&(1===e?t.cullFace(t.BACK):2===e?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):V(t.CULL_FACE),E=e}function Y(e,n,r){e?(G(t.POLYGON_OFFSET_FILL),A===n&&C===r||(A=n,C=r,i.getReversed()&&(n=-n),t.polygonOffset(n,r))):V(t.POLYGON_OFFSET_FILL)}return{buffers:{color:n,depth:i,stencil:r},enable:G,disable:V,bindFramebuffer:function(e,n){return c[e]!==n&&(t.bindFramebuffer(e,n),c[e]=n,e===t.DRAW_FRAMEBUFFER&&(c[t.FRAMEBUFFER]=n),e===t.FRAMEBUFFER&&(c[t.DRAW_FRAMEBUFFER]=n),!0)},drawBuffers:function(e,n){let i=d,r=!1;if(e){i=h.get(n),void 0===i&&(i=[],h.set(n,i));const a=e.textures;if(i.length!==a.length||i[0]!==t.COLOR_ATTACHMENT0){for(let e=0,n=a.length;e<n;e++)i[e]=t.COLOR_ATTACHMENT0+e;i.length=a.length,r=!0}}else i[0]!==t.BACK&&(i[0]=t.BACK,r=!0);r&&t.drawBuffers(i)},useProgram:function(e){return u!==e&&(t.useProgram(e),u=e,!0)},setBlending:j,setMaterial:function(e,a){2===e.side?V(t.CULL_FACE):G(t.CULL_FACE);let s=1===e.side;a&&(s=!s),X(s),1===e.blending&&!1===e.transparent?j(0):j(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.blendColor,e.blendAlpha,e.premultipliedAlpha),i.setFunc(e.depthFunc),i.setTest(e.depthTest),i.setMask(e.depthWrite),n.setMask(e.colorWrite);const o=e.stencilWrite;r.setTest(o),o&&(r.setMask(e.stencilWriteMask),r.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),r.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),Y(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage?G(t.SAMPLE_ALPHA_TO_COVERAGE):V(t.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:X,setCullFace:q,setLineWidth:function(e){e!==T&&(I&&t.lineWidth(e),T=e)},setPolygonOffset:Y,setScissorTest:function(e){e?G(t.SCISSOR_TEST):V(t.SCISSOR_TEST)},activeTexture:function(e){void 0===e&&(e=t.TEXTURE0+R-1),D!==e&&(t.activeTexture(e),D=e)},bindTexture:function(e,n,i){void 0===i&&(i=null===D?t.TEXTURE0+R-1:D);let r=N[i];void 0===r&&(r={type:void 0,texture:void 0},N[i]=r),r.type===e&&r.texture===n||(D!==i&&(t.activeTexture(i),D=i),t.bindTexture(e,n||B[e]),r.type=e,r.texture=n)},unbindTexture:function(){const e=N[D];void 0!==e&&void 0!==e.type&&(t.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D:function(){try{t.compressedTexImage2D(...arguments)}catch(t){hi("WebGLState:",t)}},compressedTexImage3D:function(){try{t.compressedTexImage3D(...arguments)}catch(t){hi("WebGLState:",t)}},texImage2D:function(){try{t.texImage2D(...arguments)}catch(t){hi("WebGLState:",t)}},texImage3D:function(){try{t.texImage3D(...arguments)}catch(t){hi("WebGLState:",t)}},pixelStorei:function(e,n){l[e]!==n&&(t.pixelStorei(e,n),l[e]=n)},getParameter:function(e){return void 0!==l[e]?l[e]:t.getParameter(e)},updateUBOMapping:function(e,n){let i=s.get(n);void 0===i&&(i=new WeakMap,s.set(n,i));let r=i.get(e);void 0===r&&(r=t.getUniformBlockIndex(n,e.name),i.set(e,r))},uniformBlockBinding:function(e,n){const i=s.get(n).get(e);a.get(n)!==i&&(t.uniformBlockBinding(n,i,e.__bindingPointIndex),a.set(n,i))},texStorage2D:function(){try{t.texStorage2D(...arguments)}catch(t){hi("WebGLState:",t)}},texStorage3D:function(){try{t.texStorage3D(...arguments)}catch(t){hi("WebGLState:",t)}},texSubImage2D:function(){try{t.texSubImage2D(...arguments)}catch(t){hi("WebGLState:",t)}},texSubImage3D:function(){try{t.texSubImage3D(...arguments)}catch(t){hi("WebGLState:",t)}},compressedTexSubImage2D:function(){try{t.compressedTexSubImage2D(...arguments)}catch(t){hi("WebGLState:",t)}},compressedTexSubImage3D:function(){try{t.compressedTexSubImage3D(...arguments)}catch(t){hi("WebGLState:",t)}},scissor:function(e){!1===F.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),F.copy(e))},viewport:function(e){!1===z.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),z.copy(e))},reset:function(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),i.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),t.pixelStorei(t.PACK_ALIGNMENT,4),t.pixelStorei(t.UNPACK_ALIGNMENT,4),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!1),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.BROWSER_DEFAULT_WEBGL),t.pixelStorei(t.PACK_ROW_LENGTH,0),t.pixelStorei(t.PACK_SKIP_PIXELS,0),t.pixelStorei(t.PACK_SKIP_ROWS,0),t.pixelStorei(t.UNPACK_ROW_LENGTH,0),t.pixelStorei(t.UNPACK_IMAGE_HEIGHT,0),t.pixelStorei(t.UNPACK_SKIP_PIXELS,0),t.pixelStorei(t.UNPACK_SKIP_ROWS,0),t.pixelStorei(t.UNPACK_SKIP_IMAGES,0),o={},l={},D=null,N={},c={},h=new WeakMap,d=[],u=null,p=!1,m=null,f=null,g=null,v=null,_=null,y=null,x=null,b=new Lr(0,0,0),S=0,M=!1,w=null,E=null,T=null,A=null,C=null,F.set(0,0,t.canvas.width,t.canvas.height),z.set(0,0,t.canvas.width,t.canvas.height),n.reset(),i.reset(),r.reset()}}}function Zp(t,e,n,i,r,a,s){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),c=new Ei,h=new WeakMap,d=new Set;let u;const p=new WeakMap;let m=!1;try{m="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(t){}function f(t,e){return m?new OffscreenCanvas(t,e):ri("canvas")}function g(t,e,n){let i=1;const r=W(t);if((r.width>n||r.height>n)&&(i=n/Math.max(r.width,r.height)),i<1){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof VideoFrame&&t instanceof VideoFrame){const n=Math.floor(i*r.width),a=Math.floor(i*r.height);void 0===u&&(u=f(n,a));const s=e?f(n,a):u;return s.width=n,s.height=a,s.getContext("2d").drawImage(t,0,0,n,a),ci("WebGLRenderer: Texture has been resized from ("+r.width+"x"+r.height+") to ("+n+"x"+a+")."),s}return"data"in t&&ci("WebGLRenderer: Image in DataTexture is too big ("+r.width+"x"+r.height+")."),t}return t}function v(t){return t.generateMipmaps}function _(e){t.generateMipmap(e)}function y(e){return e.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:e.isWebGL3DRenderTarget?t.TEXTURE_3D:e.isWebGLArrayRenderTarget||e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function x(n,i,r,a,s,o=!1){if(null!==n){if(void 0!==t[n])return t[n];ci("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let l;a&&(l=e.get("EXT_texture_norm16"),l||ci("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let c=i;if(i===t.RED&&(r===t.FLOAT&&(c=t.R32F),r===t.HALF_FLOAT&&(c=t.R16F),r===t.UNSIGNED_BYTE&&(c=t.R8),r===t.UNSIGNED_SHORT&&l&&(c=l.R16_EXT),r===t.SHORT&&l&&(c=l.R16_SNORM_EXT)),i===t.RED_INTEGER&&(r===t.UNSIGNED_BYTE&&(c=t.R8UI),r===t.UNSIGNED_SHORT&&(c=t.R16UI),r===t.UNSIGNED_INT&&(c=t.R32UI),r===t.BYTE&&(c=t.R8I),r===t.SHORT&&(c=t.R16I),r===t.INT&&(c=t.R32I)),i===t.RG&&(r===t.FLOAT&&(c=t.RG32F),r===t.HALF_FLOAT&&(c=t.RG16F),r===t.UNSIGNED_BYTE&&(c=t.RG8),r===t.UNSIGNED_SHORT&&l&&(c=l.RG16_EXT),r===t.SHORT&&l&&(c=l.RG16_SNORM_EXT)),i===t.RG_INTEGER&&(r===t.UNSIGNED_BYTE&&(c=t.RG8UI),r===t.UNSIGNED_SHORT&&(c=t.RG16UI),r===t.UNSIGNED_INT&&(c=t.RG32UI),r===t.BYTE&&(c=t.RG8I),r===t.SHORT&&(c=t.RG16I),r===t.INT&&(c=t.RG32I)),i===t.RGB_INTEGER&&(r===t.UNSIGNED_BYTE&&(c=t.RGB8UI),r===t.UNSIGNED_SHORT&&(c=t.RGB16UI),r===t.UNSIGNED_INT&&(c=t.RGB32UI),r===t.BYTE&&(c=t.RGB8I),r===t.SHORT&&(c=t.RGB16I),r===t.INT&&(c=t.RGB32I)),i===t.RGBA_INTEGER&&(r===t.UNSIGNED_BYTE&&(c=t.RGBA8UI),r===t.UNSIGNED_SHORT&&(c=t.RGBA16UI),r===t.UNSIGNED_INT&&(c=t.RGBA32UI),r===t.BYTE&&(c=t.RGBA8I),r===t.SHORT&&(c=t.RGBA16I),r===t.INT&&(c=t.RGBA32I)),i===t.RGB&&(r===t.UNSIGNED_SHORT&&l&&(c=l.RGB16_EXT),r===t.SHORT&&l&&(c=l.RGB16_SNORM_EXT),r===t.UNSIGNED_INT_5_9_9_9_REV&&(c=t.RGB9_E5),r===t.UNSIGNED_INT_10F_11F_11F_REV&&(c=t.R11F_G11F_B10F)),i===t.RGBA){const e=o?Gn:Oi.getTransfer(s);r===t.FLOAT&&(c=t.RGBA32F),r===t.HALF_FLOAT&&(c=t.RGBA16F),r===t.UNSIGNED_BYTE&&(c=e===Vn?t.SRGB8_ALPHA8:t.RGBA8),r===t.UNSIGNED_SHORT&&l&&(c=l.RGBA16_EXT),r===t.SHORT&&l&&(c=l.RGBA16_SNORM_EXT),r===t.UNSIGNED_SHORT_4_4_4_4&&(c=t.RGBA4),r===t.UNSIGNED_SHORT_5_5_5_1&&(c=t.RGB5_A1)}return c!==t.R16F&&c!==t.R32F&&c!==t.RG16F&&c!==t.RG32F&&c!==t.RGBA16F&&c!==t.RGBA32F||e.get("EXT_color_buffer_float"),c}function b(e,n){let i;return e?null===n||n===Le||n===Fe?i=t.DEPTH24_STENCIL8:n===De?i=t.DEPTH32F_STENCIL8:n===Ie&&(i=t.DEPTH24_STENCIL8,ci("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===n||n===Le||n===Fe?i=t.DEPTH_COMPONENT24:n===De?i=t.DEPTH_COMPONENT32F:n===Ie&&(i=t.DEPTH_COMPONENT16),i}function S(t,e){return!0===v(t)||t.isFramebufferTexture&&t.minFilter!==be&&t.minFilter!==we?Math.log2(Math.max(e.width,e.height))+1:void 0!==t.mipmaps&&t.mipmaps.length>0?t.mipmaps.length:t.isCompressedTexture&&Array.isArray(t.image)?e.mipmaps.length:1}function M(t){const e=t.target;e.removeEventListener("dispose",M),function(t){const e=i.get(t);if(void 0===e.__webglInit)return;const n=t.source,r=p.get(n);if(r){const i=r[e.__cacheKey];i.usedTimes--,0===i.usedTimes&&E(t),0===Object.keys(r).length&&p.delete(n)}i.remove(t)}(e),e.isVideoTexture&&h.delete(e),e.isHTMLTexture&&d.delete(e)}function w(e){const n=e.target;n.removeEventListener("dispose",w),function(e){const n=i.get(e);if(e.depthTexture&&(e.depthTexture.dispose(),i.remove(e.depthTexture)),e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++){if(Array.isArray(n.__webglFramebuffer[e]))for(let i=0;i<n.__webglFramebuffer[e].length;i++)t.deleteFramebuffer(n.__webglFramebuffer[e][i]);else t.deleteFramebuffer(n.__webglFramebuffer[e]);n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer[e])}else{if(Array.isArray(n.__webglFramebuffer))for(let e=0;e<n.__webglFramebuffer.length;e++)t.deleteFramebuffer(n.__webglFramebuffer[e]);else t.deleteFramebuffer(n.__webglFramebuffer);if(n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer),n.__webglMultisampledFramebuffer&&t.deleteFramebuffer(n.__webglMultisampledFramebuffer),n.__webglColorRenderbuffer)for(let e=0;e<n.__webglColorRenderbuffer.length;e++)n.__webglColorRenderbuffer[e]&&t.deleteRenderbuffer(n.__webglColorRenderbuffer[e]);n.__webglDepthRenderbuffer&&t.deleteRenderbuffer(n.__webglDepthRenderbuffer)}const r=e.textures;for(let e=0,n=r.length;e<n;e++){const n=i.get(r[e]);n.__webglTexture&&(t.deleteTexture(n.__webglTexture),s.memory.textures--),i.remove(r[e])}i.remove(e)}(n)}function E(e){const n=i.get(e);t.deleteTexture(n.__webglTexture);const r=e.source;delete p.get(r)[n.__cacheKey],s.memory.textures--}let T=0;function A(e,r){const a=i.get(e);if(e.isVideoTexture&&function(t){const e=s.render.frame;h.get(t)!==e&&(h.set(t,e),t.update())}(e),!1===e.isRenderTargetTexture&&!0!==e.isExternalTexture&&e.version>0&&a.__version!==e.version){const t=e.image;if(null===t)ci("WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==t.complete)return void N(a,e,r);ci("WebGLRenderer: Texture marked for update but image is incomplete")}}else e.isExternalTexture&&(a.__webglTexture=e.sourceTexture?e.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,a.__webglTexture,t.TEXTURE0+r)}const C={[_e]:t.REPEAT,[ye]:t.CLAMP_TO_EDGE,[xe]:t.MIRRORED_REPEAT},R={[be]:t.NEAREST,[Se]:t.NEAREST_MIPMAP_NEAREST,[Me]:t.NEAREST_MIPMAP_LINEAR,[we]:t.LINEAR,[Ee]:t.LINEAR_MIPMAP_NEAREST,[Te]:t.LINEAR_MIPMAP_LINEAR},I={[Wn]:t.NEVER,[Jn]:t.ALWAYS,[jn]:t.LESS,[qn]:t.LEQUAL,[Xn]:t.EQUAL,[$n]:t.GEQUAL,[Yn]:t.GREATER,[Zn]:t.NOTEQUAL};function P(n,a){if(a.type!==De||!1!==e.has("OES_texture_float_linear")||a.magFilter!==we&&a.magFilter!==Ee&&a.magFilter!==Me&&a.magFilter!==Te&&a.minFilter!==we&&a.minFilter!==Ee&&a.minFilter!==Me&&a.minFilter!==Te||ci("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(n,t.TEXTURE_WRAP_S,C[a.wrapS]),t.texParameteri(n,t.TEXTURE_WRAP_T,C[a.wrapT]),n!==t.TEXTURE_3D&&n!==t.TEXTURE_2D_ARRAY||t.texParameteri(n,t.TEXTURE_WRAP_R,C[a.wrapR]),t.texParameteri(n,t.TEXTURE_MAG_FILTER,R[a.magFilter]),t.texParameteri(n,t.TEXTURE_MIN_FILTER,R[a.minFilter]),a.compareFunction&&(t.texParameteri(n,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(n,t.TEXTURE_COMPARE_FUNC,I[a.compareFunction])),!0===e.has("EXT_texture_filter_anisotropic")){if(a.magFilter===be)return;if(a.minFilter!==Me&&a.minFilter!==Te)return;if(a.type===De&&!1===e.has("OES_texture_float_linear"))return;if(a.anisotropy>1||i.get(a).__currentAnisotropy){const s=e.get("EXT_texture_filter_anisotropic");t.texParameterf(n,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy())),i.get(a).__currentAnisotropy=a.anisotropy}}}function L(e,n){let i=!1;void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",M));const r=n.source;let a=p.get(r);void 0===a&&(a={},p.set(r,a));const o=function(t){const e=[];return e.push(t.wrapS),e.push(t.wrapT),e.push(t.wrapR||0),e.push(t.magFilter),e.push(t.minFilter),e.push(t.anisotropy),e.push(t.internalFormat),e.push(t.format),e.push(t.type),e.push(t.generateMipmaps),e.push(t.premultiplyAlpha),e.push(t.flipY),e.push(t.unpackAlignment),e.push(t.colorSpace),e.join()}(n);if(o!==e.__cacheKey){void 0===a[o]&&(a[o]={texture:t.createTexture(),usedTimes:0},s.memory.textures++,i=!0),a[o].usedTimes++;const r=a[e.__cacheKey];void 0!==r&&(a[e.__cacheKey].usedTimes--,0===r.usedTimes&&E(n)),e.__cacheKey=o,e.__webglTexture=a[o].texture}return i}function D(t,e,n){return Math.floor(Math.floor(t/n)/e)}function N(e,s,o){let l=t.TEXTURE_2D;(s.isDataArrayTexture||s.isCompressedArrayTexture)&&(l=t.TEXTURE_2D_ARRAY),s.isData3DTexture&&(l=t.TEXTURE_3D);const c=L(e,s),h=s.source;n.bindTexture(l,e.__webglTexture,t.TEXTURE0+o);const u=i.get(h);if(h.version!==u.__version||!0===c){if(n.activeTexture(t.TEXTURE0+o),!1==("undefined"!=typeof ImageBitmap&&s.image instanceof ImageBitmap)){const e=Oi.getPrimaries(Oi.workingColorSpace),i=s.colorSpace===zn?null:Oi.getPrimaries(s.colorSpace),r=s.colorSpace===zn||e===i?t.NONE:t.BROWSER_DEFAULT_WEBGL;n.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,s.flipY),n.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),n.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,r)}n.pixelStorei(t.UNPACK_ALIGNMENT,s.unpackAlignment);let e=g(s.image,!1,r.maxTextureSize);e=H(s,e);const i=a.convert(s.format,s.colorSpace),p=a.convert(s.type);let m,f=x(s.internalFormat,i,p,s.normalized,s.colorSpace,s.isVideoTexture);P(l,s);const y=s.mipmaps,M=!0!==s.isVideoTexture,w=void 0===u.__version||!0===c,E=h.dataReady,T=S(s,e);if(s.isDepthTexture)f=b(s.format===Ve,s.type),w&&(M?n.texStorage2D(t.TEXTURE_2D,1,f,e.width,e.height):n.texImage2D(t.TEXTURE_2D,0,f,e.width,e.height,0,i,p,null));else if(s.isDataTexture)if(y.length>0){M&&w&&n.texStorage2D(t.TEXTURE_2D,T,f,y[0].width,y[0].height);for(let e=0,r=y.length;e<r;e++)m=y[e],M?E&&n.texSubImage2D(t.TEXTURE_2D,e,0,0,m.width,m.height,i,p,m.data):n.texImage2D(t.TEXTURE_2D,e,f,m.width,m.height,0,i,p,m.data);s.generateMipmaps=!1}else M?(w&&n.texStorage2D(t.TEXTURE_2D,T,f,e.width,e.height),E&&function(e,i,r,a){const s=e.updateRanges;if(0===s.length)n.texSubImage2D(t.TEXTURE_2D,0,0,0,i.width,i.height,r,a,i.data);else{s.sort(((t,e)=>t.start-e.start));let o=0;for(let t=1;t<s.length;t++){const e=s[o],n=s[t],r=e.start+e.count,a=D(n.start,i.width,4),l=D(e.start,i.width,4);n.start<=r+1&&a===l&&D(n.start+n.count-1,i.width,4)===a?e.count=Math.max(e.count,n.start+n.count-e.start):(++o,s[o]=n)}s.length=o+1;const l=n.getParameter(t.UNPACK_ROW_LENGTH),c=n.getParameter(t.UNPACK_SKIP_PIXELS),h=n.getParameter(t.UNPACK_SKIP_ROWS);n.pixelStorei(t.UNPACK_ROW_LENGTH,i.width);for(let e=0,o=s.length;e<o;e++){const o=s[e],l=Math.floor(o.start/4),c=Math.ceil(o.count/4),h=l%i.width,d=Math.floor(l/i.width),u=c,p=1;n.pixelStorei(t.UNPACK_SKIP_PIXELS,h),n.pixelStorei(t.UNPACK_SKIP_ROWS,d),n.texSubImage2D(t.TEXTURE_2D,0,h,d,u,p,r,a,i.data)}e.clearUpdateRanges(),n.pixelStorei(t.UNPACK_ROW_LENGTH,l),n.pixelStorei(t.UNPACK_SKIP_PIXELS,c),n.pixelStorei(t.UNPACK_SKIP_ROWS,h)}}(s,e,i,p)):n.texImage2D(t.TEXTURE_2D,0,f,e.width,e.height,0,i,p,e.data);else if(s.isCompressedTexture)if(s.isCompressedArrayTexture){M&&w&&n.texStorage3D(t.TEXTURE_2D_ARRAY,T,f,y[0].width,y[0].height,e.depth);for(let r=0,a=y.length;r<a;r++)if(m=y[r],s.format!==Be)if(null!==i)if(M){if(E)if(s.layerUpdates.size>0){const e=pd(m.width,m.height,s.format,s.type);for(const a of s.layerUpdates){const s=m.data.subarray(a*e/m.data.BYTES_PER_ELEMENT,(a+1)*e/m.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,r,0,0,a,m.width,m.height,1,i,s)}s.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,r,0,0,0,m.width,m.height,e.depth,i,m.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,r,f,m.width,m.height,e.depth,0,m.data,0,0);else ci("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else M?E&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,r,0,0,0,m.width,m.height,e.depth,i,p,m.data):n.texImage3D(t.TEXTURE_2D_ARRAY,r,f,m.width,m.height,e.depth,0,i,p,m.data)}else{M&&w&&n.texStorage2D(t.TEXTURE_2D,T,f,y[0].width,y[0].height);for(let e=0,r=y.length;e<r;e++)m=y[e],s.format!==Be?null!==i?M?E&&n.compressedTexSubImage2D(t.TEXTURE_2D,e,0,0,m.width,m.height,i,m.data):n.compressedTexImage2D(t.TEXTURE_2D,e,f,m.width,m.height,0,m.data):ci("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):M?E&&n.texSubImage2D(t.TEXTURE_2D,e,0,0,m.width,m.height,i,p,m.data):n.texImage2D(t.TEXTURE_2D,e,f,m.width,m.height,0,i,p,m.data)}else if(s.isDataArrayTexture)if(M){if(w&&n.texStorage3D(t.TEXTURE_2D_ARRAY,T,f,e.width,e.height,e.depth),E)if(s.layerUpdates.size>0){const r=pd(e.width,e.height,s.format,s.type);for(const a of s.layerUpdates){const s=e.data.subarray(a*r/e.data.BYTES_PER_ELEMENT,(a+1)*r/e.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,a,e.width,e.height,1,i,p,s)}s.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,e.width,e.height,e.depth,i,p,e.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,f,e.width,e.height,e.depth,0,i,p,e.data);else if(s.isData3DTexture)M?(w&&n.texStorage3D(t.TEXTURE_3D,T,f,e.width,e.height,e.depth),E&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,e.width,e.height,e.depth,i,p,e.data)):n.texImage3D(t.TEXTURE_3D,0,f,e.width,e.height,e.depth,0,i,p,e.data);else if(s.isFramebufferTexture){if(w)if(M)n.texStorage2D(t.TEXTURE_2D,T,f,e.width,e.height);else{let r=e.width,a=e.height;for(let e=0;e<T;e++)n.texImage2D(t.TEXTURE_2D,e,f,r,a,0,i,p,null),r>>=1,a>>=1}}else if(s.isHTMLTexture){if("texElementImage2D"in t){const n=t.canvas;if(n.hasAttribute("layoutsubtree")||n.setAttribute("layoutsubtree","true"),e.parentNode!==n)return n.appendChild(e),d.add(s),n.onpaint=t=>{const e=t.changedElements;for(const t of d)e.includes(t.image)&&(t.needsUpdate=!0)},void n.requestPaint();const i=0,r=t.RGBA,a=t.RGBA,o=t.UNSIGNED_BYTE;t.texElementImage2D(t.TEXTURE_2D,i,r,a,o,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)}}else if(y.length>0){if(M&&w){const e=W(y[0]);n.texStorage2D(t.TEXTURE_2D,T,f,e.width,e.height)}for(let e=0,r=y.length;e<r;e++)m=y[e],M?E&&n.texSubImage2D(t.TEXTURE_2D,e,0,0,i,p,m):n.texImage2D(t.TEXTURE_2D,e,f,i,p,m);s.generateMipmaps=!1}else if(M){if(w){const i=W(e);n.texStorage2D(t.TEXTURE_2D,T,f,i.width,i.height)}E&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,i,p,e)}else n.texImage2D(t.TEXTURE_2D,0,f,i,p,e);v(s)&&_(l),u.__version=h.version,s.onUpdate&&s.onUpdate(s)}e.__version=s.version}function O(e,r,s,l,c,h){const d=a.convert(s.format,s.colorSpace),u=a.convert(s.type),p=x(s.internalFormat,d,u,s.normalized,s.colorSpace),m=i.get(r),f=i.get(s);if(f.__renderTarget=r,!m.__hasExternalTextures){const e=Math.max(1,r.width>>h),i=Math.max(1,r.height>>h);c===t.TEXTURE_3D||c===t.TEXTURE_2D_ARRAY?n.texImage3D(c,h,p,e,i,r.depth,0,d,u,null):n.texImage2D(c,h,p,e,i,0,d,u,null)}n.bindFramebuffer(t.FRAMEBUFFER,e),V(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,l,c,f.__webglTexture,0,G(r)):(c===t.TEXTURE_2D||c>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&c<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,l,c,f.__webglTexture,h),n.bindFramebuffer(t.FRAMEBUFFER,null)}function U(e,n,i){if(t.bindRenderbuffer(t.RENDERBUFFER,e),n.depthBuffer){const r=n.depthTexture,a=r&&r.isDepthTexture?r.type:null,s=b(n.stencilBuffer,a),l=n.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;V(n)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,G(n),s,n.width,n.height):i?t.renderbufferStorageMultisample(t.RENDERBUFFER,G(n),s,n.width,n.height):t.renderbufferStorage(t.RENDERBUFFER,s,n.width,n.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,l,t.RENDERBUFFER,e)}else{const e=n.textures;for(let r=0;r<e.length;r++){const s=e[r],l=a.convert(s.format,s.colorSpace),c=a.convert(s.type),h=x(s.internalFormat,l,c,s.normalized,s.colorSpace);V(n)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,G(n),h,n.width,n.height):i?t.renderbufferStorageMultisample(t.RENDERBUFFER,G(n),h,n.width,n.height):t.renderbufferStorage(t.RENDERBUFFER,h,n.width,n.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function F(e,r,s){const l=!0===r.isWebGLCubeRenderTarget;if(n.bindFramebuffer(t.FRAMEBUFFER,e),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const c=i.get(r.depthTexture);if(c.__renderTarget=r,c.__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),l){if(void 0===c.__webglInit&&(c.__webglInit=!0,r.depthTexture.addEventListener("dispose",M)),void 0===c.__webglTexture){c.__webglTexture=t.createTexture(),n.bindTexture(t.TEXTURE_CUBE_MAP,c.__webglTexture),P(t.TEXTURE_CUBE_MAP,r.depthTexture);const e=a.convert(r.depthTexture.format),i=a.convert(r.depthTexture.type);let s;r.depthTexture.format===Ge?s=t.DEPTH_COMPONENT24:r.depthTexture.format===Ve&&(s=t.DEPTH24_STENCIL8);for(let n=0;n<6;n++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+n,0,s,r.width,r.height,0,e,i,null)}}else A(r.depthTexture,0);const h=c.__webglTexture,d=G(r),u=l?t.TEXTURE_CUBE_MAP_POSITIVE_X+s:t.TEXTURE_2D,p=r.depthTexture.format===Ve?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(r.depthTexture.format===Ge)V(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,p,u,h,0,d):t.framebufferTexture2D(t.FRAMEBUFFER,p,u,h,0);else{if(r.depthTexture.format!==Ve)throw new Error("Unknown depthTexture format");V(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,p,u,h,0,d):t.framebufferTexture2D(t.FRAMEBUFFER,p,u,h,0)}}function z(e){const r=i.get(e),a=!0===e.isWebGLCubeRenderTarget;if(r.__boundDepthTexture!==e.depthTexture){const t=e.depthTexture;if(r.__depthDisposeCallback&&r.__depthDisposeCallback(),t){const e=()=>{delete r.__boundDepthTexture,delete r.__depthDisposeCallback,t.removeEventListener("dispose",e)};t.addEventListener("dispose",e),r.__depthDisposeCallback=e}r.__boundDepthTexture=t}if(e.depthTexture&&!r.__autoAllocateDepthBuffer)if(a)for(let t=0;t<6;t++)F(r.__webglFramebuffer[t],e,t);else{const t=e.texture.mipmaps;t&&t.length>0?F(r.__webglFramebuffer[0],e,0):F(r.__webglFramebuffer,e,0)}else if(a){r.__webglDepthbuffer=[];for(let i=0;i<6;i++)if(n.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[i]),void 0===r.__webglDepthbuffer[i])r.__webglDepthbuffer[i]=t.createRenderbuffer(),U(r.__webglDepthbuffer[i],e,!1);else{const n=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,a=r.__webglDepthbuffer[i];t.bindRenderbuffer(t.RENDERBUFFER,a),t.framebufferRenderbuffer(t.FRAMEBUFFER,n,t.RENDERBUFFER,a)}}else{const i=e.texture.mipmaps;if(i&&i.length>0?n.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer),void 0===r.__webglDepthbuffer)r.__webglDepthbuffer=t.createRenderbuffer(),U(r.__webglDepthbuffer,e,!1);else{const n=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,i=r.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,i),t.framebufferRenderbuffer(t.FRAMEBUFFER,n,t.RENDERBUFFER,i)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}const k=[],B=[];function G(t){return Math.min(r.maxSamples,t.samples)}function V(t){const n=i.get(t);return t.samples>0&&!0===e.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function H(t,e){const n=t.colorSpace,i=t.format,r=t.type;return!0===t.isCompressedTexture||!0===t.isVideoTexture||n!==Bn&&n!==zn&&(Oi.getTransfer(n)===Vn?i===Be&&r===Ae||ci("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):hi("WebGLTextures: Unsupported texture color space:",n)),e}function W(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement?(c.width=t.naturalWidth||t.width,c.height=t.naturalHeight||t.height):"undefined"!=typeof VideoFrame&&t instanceof VideoFrame?(c.width=t.displayWidth,c.height=t.displayHeight):(c.width=t.width,c.height=t.height),c}this.allocateTextureUnit=function(){const t=T;return t>=r.maxTextures&&ci("WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+r.maxTextures),T+=1,t},this.resetTextureUnits=function(){T=0},this.getTextureUnits=function(){return T},this.setTextureUnits=function(t){T=t},this.setTexture2D=A,this.setTexture2DArray=function(e,r){const a=i.get(e);!1===e.isRenderTargetTexture&&e.version>0&&a.__version!==e.version?N(a,e,r):(e.isExternalTexture&&(a.__webglTexture=e.sourceTexture?e.sourceTexture:null),n.bindTexture(t.TEXTURE_2D_ARRAY,a.__webglTexture,t.TEXTURE0+r))},this.setTexture3D=function(e,r){const a=i.get(e);!1===e.isRenderTargetTexture&&e.version>0&&a.__version!==e.version?N(a,e,r):n.bindTexture(t.TEXTURE_3D,a.__webglTexture,t.TEXTURE0+r)},this.setTextureCube=function(e,s){const o=i.get(e);!0!==e.isCubeDepthTexture&&e.version>0&&o.__version!==e.version?function(e,s,o){if(6!==s.image.length)return;const l=L(e,s),c=s.source;n.bindTexture(t.TEXTURE_CUBE_MAP,e.__webglTexture,t.TEXTURE0+o);const h=i.get(c);if(c.version!==h.__version||!0===l){n.activeTexture(t.TEXTURE0+o);const e=Oi.getPrimaries(Oi.workingColorSpace),i=s.colorSpace===zn?null:Oi.getPrimaries(s.colorSpace),d=s.colorSpace===zn||e===i?t.NONE:t.BROWSER_DEFAULT_WEBGL;n.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,s.flipY),n.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),n.pixelStorei(t.UNPACK_ALIGNMENT,s.unpackAlignment),n.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);const u=s.isCompressedTexture||s.image[0].isCompressedTexture,p=s.image[0]&&s.image[0].isDataTexture,m=[];for(let t=0;t<6;t++)m[t]=u||p?p?s.image[t].image:s.image[t]:g(s.image[t],!0,r.maxCubemapSize),m[t]=H(s,m[t]);const f=m[0],y=a.convert(s.format,s.colorSpace),b=a.convert(s.type),M=x(s.internalFormat,y,b,s.normalized,s.colorSpace),w=!0!==s.isVideoTexture,E=void 0===h.__version||!0===l,T=c.dataReady;let A,C=S(s,f);if(P(t.TEXTURE_CUBE_MAP,s),u){w&&E&&n.texStorage2D(t.TEXTURE_CUBE_MAP,C,M,f.width,f.height);for(let e=0;e<6;e++){A=m[e].mipmaps;for(let i=0;i<A.length;i++){const r=A[i];s.format!==Be?null!==y?w?T&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,0,0,r.width,r.height,y,r.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,M,r.width,r.height,0,r.data):ci("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):w?T&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,0,0,r.width,r.height,y,b,r.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,M,r.width,r.height,0,y,b,r.data)}}}else{if(A=s.mipmaps,w&&E){A.length>0&&C++;const e=W(m[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,C,M,e.width,e.height)}for(let e=0;e<6;e++)if(p){w?T&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,m[e].width,m[e].height,y,b,m[e].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,M,m[e].width,m[e].height,0,y,b,m[e].data);for(let i=0;i<A.length;i++){const r=A[i].image[e].image;w?T&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,0,0,r.width,r.height,y,b,r.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,M,r.width,r.height,0,y,b,r.data)}}else{w?T&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,y,b,m[e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,M,y,b,m[e]);for(let i=0;i<A.length;i++){const r=A[i];w?T&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,0,0,y,b,r.image[e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,M,y,b,r.image[e])}}}v(s)&&_(t.TEXTURE_CUBE_MAP),h.__version=c.version,s.onUpdate&&s.onUpdate(s)}e.__version=s.version}(o,e,s):n.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture,t.TEXTURE0+s)},this.rebindTextures=function(e,n,r){const a=i.get(e);void 0!==n&&O(a.__webglFramebuffer,e,e.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),void 0!==r&&z(e)},this.setupRenderTarget=function(e){const r=e.texture,o=i.get(e),l=i.get(r);e.addEventListener("dispose",w);const c=e.textures,h=!0===e.isWebGLCubeRenderTarget,d=c.length>1;if(d||(void 0===l.__webglTexture&&(l.__webglTexture=t.createTexture()),l.__version=r.version,s.memory.textures++),h){o.__webglFramebuffer=[];for(let e=0;e<6;e++)if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer[e]=[];for(let n=0;n<r.mipmaps.length;n++)o.__webglFramebuffer[e][n]=t.createFramebuffer()}else o.__webglFramebuffer[e]=t.createFramebuffer()}else{if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer=[];for(let e=0;e<r.mipmaps.length;e++)o.__webglFramebuffer[e]=t.createFramebuffer()}else o.__webglFramebuffer=t.createFramebuffer();if(d)for(let e=0,n=c.length;e<n;e++){const n=i.get(c[e]);void 0===n.__webglTexture&&(n.__webglTexture=t.createTexture(),s.memory.textures++)}if(e.samples>0&&!1===V(e)){o.__webglMultisampledFramebuffer=t.createFramebuffer(),o.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let n=0;n<c.length;n++){const i=c[n];o.__webglColorRenderbuffer[n]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,o.__webglColorRenderbuffer[n]);const r=a.convert(i.format,i.colorSpace),s=a.convert(i.type),l=x(i.internalFormat,r,s,i.normalized,i.colorSpace,!0===e.isXRRenderTarget),h=G(e);t.renderbufferStorageMultisample(t.RENDERBUFFER,h,l,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+n,t.RENDERBUFFER,o.__webglColorRenderbuffer[n])}t.bindRenderbuffer(t.RENDERBUFFER,null),e.depthBuffer&&(o.__webglDepthRenderbuffer=t.createRenderbuffer(),U(o.__webglDepthRenderbuffer,e,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(h){n.bindTexture(t.TEXTURE_CUBE_MAP,l.__webglTexture),P(t.TEXTURE_CUBE_MAP,r);for(let n=0;n<6;n++)if(r.mipmaps&&r.mipmaps.length>0)for(let i=0;i<r.mipmaps.length;i++)O(o.__webglFramebuffer[n][i],e,r,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+n,i);else O(o.__webglFramebuffer[n],e,r,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+n,0);v(r)&&_(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(d){for(let r=0,a=c.length;r<a;r++){const a=c[r],s=i.get(a);let l=t.TEXTURE_2D;(e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&(l=e.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(l,s.__webglTexture),P(l,a),O(o.__webglFramebuffer,e,a,t.COLOR_ATTACHMENT0+r,l,0),v(a)&&_(l)}n.unbindTexture()}else{let i=t.TEXTURE_2D;if((e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&(i=e.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(i,l.__webglTexture),P(i,r),r.mipmaps&&r.mipmaps.length>0)for(let n=0;n<r.mipmaps.length;n++)O(o.__webglFramebuffer[n],e,r,t.COLOR_ATTACHMENT0,i,n);else O(o.__webglFramebuffer,e,r,t.COLOR_ATTACHMENT0,i,0);v(r)&&_(i),n.unbindTexture()}e.depthBuffer&&z(e)},this.updateRenderTargetMipmap=function(t){const e=t.textures;for(let r=0,a=e.length;r<a;r++){const a=e[r];if(v(a)){const e=y(t),r=i.get(a).__webglTexture;n.bindTexture(e,r),_(e),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(e){if(e.samples>0)if(!1===V(e)){const r=e.textures,a=e.width,s=e.height;let o=t.COLOR_BUFFER_BIT;const c=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,h=i.get(e),d=r.length>1;if(d)for(let e=0;e<r.length;e++)n.bindFramebuffer(t.FRAMEBUFFER,h.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,h.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,h.__webglMultisampledFramebuffer);const u=e.texture.mipmaps;u&&u.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,h.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,h.__webglFramebuffer);for(let n=0;n<r.length;n++){if(e.resolveDepthBuffer&&(e.depthBuffer&&(o|=t.DEPTH_BUFFER_BIT),e.stencilBuffer&&e.resolveStencilBuffer&&(o|=t.STENCIL_BUFFER_BIT)),d){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,h.__webglColorRenderbuffer[n]);const e=i.get(r[n]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0)}t.blitFramebuffer(0,0,a,s,0,0,a,s,o,t.NEAREST),!0===l&&(k.length=0,B.length=0,k.push(t.COLOR_ATTACHMENT0+n),e.depthBuffer&&!1===e.resolveDepthBuffer&&(k.push(c),B.push(c),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,B)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,k))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),d)for(let e=0;e<r.length;e++){n.bindFramebuffer(t.FRAMEBUFFER,h.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,h.__webglColorRenderbuffer[e]);const a=i.get(r[e]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,h.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,a,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,h.__webglMultisampledFramebuffer)}else if(e.depthBuffer&&!1===e.resolveDepthBuffer&&l){const n=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[n])}},this.setupDepthRenderbuffer=z,this.setupFrameBufferTexture=O,this.useMultisampledRTT=V,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function $p(t,e){return{convert:function(n,i=""){let r;const a=Oi.getTransfer(i);if(n===Ae)return t.UNSIGNED_BYTE;if(n===Oe)return t.UNSIGNED_SHORT_4_4_4_4;if(n===Ue)return t.UNSIGNED_SHORT_5_5_5_1;if(n===ze)return t.UNSIGNED_INT_5_9_9_9_REV;if(n===ke)return t.UNSIGNED_INT_10F_11F_11F_REV;if(n===Ce)return t.BYTE;if(n===Re)return t.SHORT;if(n===Ie)return t.UNSIGNED_SHORT;if(n===Pe)return t.INT;if(n===Le)return t.UNSIGNED_INT;if(n===De)return t.FLOAT;if(n===Ne)return t.HALF_FLOAT;if(1021===n)return t.ALPHA;if(1022===n)return t.RGB;if(n===Be)return t.RGBA;if(n===Ge)return t.DEPTH_COMPONENT;if(n===Ve)return t.DEPTH_STENCIL;if(n===He)return t.RED;if(n===We)return t.RED_INTEGER;if(n===je)return t.RG;if(n===Xe)return t.RG_INTEGER;if(n===qe)return t.RGBA_INTEGER;if(n===Ye||n===Ze||n===$e||n===Je)if(a===Vn){if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),null===r)return null;if(n===Ye)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Ze)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===$e)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Je)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(r=e.get("WEBGL_compressed_texture_s3tc"),null===r)return null;if(n===Ye)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Ze)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===$e)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Je)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===Ke||n===Qe||n===tn||n===en){if(r=e.get("WEBGL_compressed_texture_pvrtc"),null===r)return null;if(n===Ke)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Qe)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===tn)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===en)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===nn||n===rn||n===an||n===sn||n===on||n===ln||n===cn){if(r=e.get("WEBGL_compressed_texture_etc"),null===r)return null;if(n===nn||n===rn)return a===Vn?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===an)return a===Vn?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===sn)return r.COMPRESSED_R11_EAC;if(n===on)return r.COMPRESSED_SIGNED_R11_EAC;if(n===ln)return r.COMPRESSED_RG11_EAC;if(n===cn)return r.COMPRESSED_SIGNED_RG11_EAC}if(n===hn||n===dn||n===un||n===pn||n===mn||n===fn||n===gn||n===vn||n===_n||n===yn||n===xn||n===bn||n===Sn||n===Mn){if(r=e.get("WEBGL_compressed_texture_astc"),null===r)return null;if(n===hn)return a===Vn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===dn)return a===Vn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===un)return a===Vn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===pn)return a===Vn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===mn)return a===Vn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===fn)return a===Vn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===gn)return a===Vn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===vn)return a===Vn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===_n)return a===Vn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===yn)return a===Vn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===xn)return a===Vn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===bn)return a===Vn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Sn)return a===Vn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Mn)return a===Vn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===wn||n===En||n===Tn){if(r=e.get("EXT_texture_compression_bptc"),null===r)return null;if(n===wn)return a===Vn?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===En)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Tn)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(n===An||n===Cn||n===Rn||n===In){if(r=e.get("EXT_texture_compression_rgtc"),null===r)return null;if(n===An)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Cn)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Rn)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===In)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return n===Fe?t.UNSIGNED_INT_24_8:void 0!==t[n]?t[n]:null}}}class Jp{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(null===this.texture){const n=new Yo(t.texture);t.depthNear===e.depthNear&&t.depthFar===e.depthFar||(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=n}}getMesh(t){if(null!==this.texture&&null===this.mesh){const e=t.cameras[0].viewport,n=new Mc({vertexShader:"\nvoid main() {\n\n\tgl_Position = vec4( position, 1.0 );\n\n}",fragmentShader:"\nuniform sampler2DArray depthColor;\nuniform float depthWidth;\nuniform float depthHeight;\n\nvoid main() {\n\n\tvec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );\n\n\tif ( coord.x >= 1.0 ) {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;\n\n\t} else {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;\n\n\t}\n\n}",uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new bs(new oc(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Kp extends pi{constructor(t,e){super();const n=this;let i=null,r=1,a=null,s="local-floor",o=1,l=null,c=null,h=null,d=null,u=null,p=null;const m="undefined"!=typeof XRWebGLBinding,f=new Jp,g={},v=e.getContextAttributes();let _=null,y=null;const x=[],b=[],S=new Ei;let M=null;const w=new Mh;w.viewport=new Xi;const E=new Mh;E.viewport=new Xi;const T=[w,E],A=new Xh;let C=null,R=null;function I(t){const e=b.indexOf(t.inputSource);if(-1===e)return;const n=x[e];void 0!==n&&(n.update(t.inputSource,t.frame,l||a),n.dispatchEvent({type:t.type,data:t.inputSource}))}function P(){i.removeEventListener("select",I),i.removeEventListener("selectstart",I),i.removeEventListener("selectend",I),i.removeEventListener("squeeze",I),i.removeEventListener("squeezestart",I),i.removeEventListener("squeezeend",I),i.removeEventListener("end",P),i.removeEventListener("inputsourceschange",L);for(let t=0;t<x.length;t++){const e=b[t];null!==e&&(b[t]=null,x[t].disconnect(e))}C=null,R=null,f.reset();for(const t in g)delete g[t];t.setRenderTarget(_),u=null,d=null,h=null,i=null,y=null,F.stop(),n.isPresenting=!1,t.setPixelRatio(M),t.setSize(S.width,S.height,!1),n.dispatchEvent({type:"sessionend"})}function L(t){for(let e=0;e<t.removed.length;e++){const n=t.removed[e],i=b.indexOf(n);i>=0&&(b[i]=null,x[i].disconnect(n))}for(let e=0;e<t.added.length;e++){const n=t.added[e];let i=b.indexOf(n);if(-1===i){for(let t=0;t<x.length;t++){if(t>=b.length){b.push(n),i=t;break}if(null===b[t]){b[t]=n,i=t;break}}if(-1===i)break}const r=x[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=x[t];return void 0===e&&(e=new Ar,x[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=x[t];return void 0===e&&(e=new Ar,x[t]=e),e.getGripSpace()},this.getHand=function(t){let e=x[t];return void 0===e&&(e=new Ar,x[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){r=t,!0===n.isPresenting&&ci("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){s=t,!0===n.isPresenting&&ci("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(t){l=t},this.getBaseLayer=function(){return null!==d?d:u},this.getBinding=function(){return null===h&&m&&(h=new XRWebGLBinding(i,e)),h},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(c){if(i=c,null!==i){if(_=t.getRenderTarget(),i.addEventListener("select",I),i.addEventListener("selectstart",I),i.addEventListener("selectend",I),i.addEventListener("squeeze",I),i.addEventListener("squeezestart",I),i.addEventListener("squeezeend",I),i.addEventListener("end",P),i.addEventListener("inputsourceschange",L),!0!==v.xrCompatible&&await e.makeXRCompatible(),M=t.getPixelRatio(),t.getSize(S),m&&"createProjectionLayer"in XRWebGLBinding.prototype){let n=null,a=null,s=null;v.depth&&(s=v.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,n=v.stencil?Ve:Ge,a=v.stencil?Fe:Le);const o={colorFormat:e.RGBA8,depthFormat:s,scaleFactor:r};h=this.getBinding(),d=h.createProjectionLayer(o),i.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),y=new Yi(d.textureWidth,d.textureHeight,{format:Be,type:Ae,depthTexture:new Xo(d.textureWidth,d.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:v.stencil,colorSpace:t.outputColorSpace,samples:v.antialias?4:0,resolveDepthBuffer:!1===d.ignoreDepthValues,resolveStencilBuffer:!1===d.ignoreDepthValues})}else{const n={antialias:v.antialias,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:r};u=new XRWebGLLayer(i,e,n),i.updateRenderState({baseLayer:u}),t.setPixelRatio(1),t.setSize(u.framebufferWidth,u.framebufferHeight,!1),y=new Yi(u.framebufferWidth,u.framebufferHeight,{format:Be,type:Ae,colorSpace:t.outputColorSpace,stencilBuffer:v.stencil,resolveDepthBuffer:!1===u.ignoreDepthValues,resolveStencilBuffer:!1===u.ignoreDepthValues})}y.isXRRenderTarget=!0,this.setFoveation(o),l=null,a=await i.requestReferenceSpace(s),F.setContext(i),F.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==i)return i.environmentBlendMode},this.getDepthTexture=function(){return f.getDepthTexture()};const D=new Ai,N=new Ai;function O(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.copy(t.matrixWorld).invert()}this.updateCamera=function(t){if(null===i)return;let e=t.near,n=t.far;null!==f.texture&&(f.depthNear>0&&(e=f.depthNear),f.depthFar>0&&(n=f.depthFar)),A.near=E.near=w.near=e,A.far=E.far=w.far=n,C===A.near&&R===A.far||(i.updateRenderState({depthNear:A.near,depthFar:A.far}),C=A.near,R=A.far),A.layers.mask=6|t.layers.mask,w.layers.mask=-5&A.layers.mask,E.layers.mask=-3&A.layers.mask;const r=t.parent,a=A.cameras;O(A,r);for(let t=0;t<a.length;t++)O(a[t],r);2===a.length?function(t,e,n){D.setFromMatrixPosition(e.matrixWorld),N.setFromMatrixPosition(n.matrixWorld);const i=D.distanceTo(N),r=e.projectionMatrix.elements,a=n.projectionMatrix.elements,s=r[14]/(r[10]-1),o=r[14]/(r[10]+1),l=(r[9]+1)/r[5],c=(r[9]-1)/r[5],h=(r[8]-1)/r[0],d=(a[8]+1)/a[0],u=s*h,p=s*d,m=i/(-h+d),f=m*-h;if(e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(f),t.translateZ(m),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.copy(t.matrixWorld).invert(),-1===r[10])t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse);else{const e=s+m,n=o+m,r=u-f,a=p+(i-f),h=l*o/n*e,d=c*o/n*e;t.projectionMatrix.makePerspective(r,a,h,d,e,n),t.projectionMatrixInverse.copy(t.projectionMatrix).invert()}}(A,w,E):A.projectionMatrix.copy(w.projectionMatrix),function(t,e,n){null===n?t.matrix.copy(e.matrixWorld):(t.matrix.copy(n.matrixWorld),t.matrix.invert(),t.matrix.multiply(e.matrixWorld)),t.matrix.decompose(t.position,t.quaternion,t.scale),t.updateMatrixWorld(!0),t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse),t.isPerspectiveCamera&&(t.fov=2*vi*Math.atan(1/t.projectionMatrix.elements[5]),t.zoom=1)}(t,A,r)},this.getCamera=function(){return A},this.getFoveation=function(){if(null!==d||null!==u)return o},this.setFoveation=function(t){o=t,null!==d&&(d.fixedFoveation=t),null!==u&&void 0!==u.fixedFoveation&&(u.fixedFoveation=t)},this.hasDepthSensing=function(){return null!==f.texture},this.getDepthSensingMesh=function(){return f.getMesh(A)},this.getCameraTexture=function(t){return g[t]};let U=null;const F=new md;F.setAnimationLoop((function(e,r){if(c=r.getViewerPose(l||a),p=r,null!==c){const e=c.views;null!==u&&(t.setRenderTargetFramebuffer(y,u.framebuffer),t.setRenderTarget(y));let r=!1;e.length!==A.cameras.length&&(A.cameras.length=0,r=!0);for(let n=0;n<e.length;n++){const i=e[n];let a=null;if(null!==u)a=u.getViewport(i);else{const e=h.getViewSubImage(d,i);a=e.viewport,0===n&&(t.setRenderTargetTextures(y,e.colorTexture,e.depthStencilTexture),t.setRenderTarget(y))}let s=T[n];void 0===s&&(s=new Mh,s.layers.enable(n),s.viewport=new Xi,T[n]=s),s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.quaternion,s.scale),s.projectionMatrix.fromArray(i.projectionMatrix),s.projectionMatrixInverse.copy(s.projectionMatrix).invert(),s.viewport.set(a.x,a.y,a.width,a.height),0===n&&(A.matrix.copy(s.matrix),A.matrix.decompose(A.position,A.quaternion,A.scale)),!0===r&&A.cameras.push(s)}const a=i.enabledFeatures;if(a&&a.includes("depth-sensing")&&"gpu-optimized"==i.depthUsage&&m){h=n.getBinding();const t=h.getDepthInformation(e[0]);t&&t.isValid&&t.texture&&f.init(t,i.renderState)}if(a&&a.includes("camera-access")&&m){t.state.unbindTexture(),h=n.getBinding();for(let t=0;t<e.length;t++){const n=e[t].camera;if(n){let t=g[n];t||(t=new Yo,g[n]=t);const e=h.getCameraImage(n);t.sourceTexture=e}}}}for(let t=0;t<x.length;t++){const e=b[t],n=x[t];null!==e&&void 0!==n&&n.update(e,r,l||a)}U&&U(e,r),r.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:r}),p=null})),this.setAnimationLoop=function(t){U=t},this.dispose=function(){}}}const Qp=new Ji,tm=new Ii;function em(t,e){function n(t,e){!0===t.matrixAutoUpdate&&t.updateMatrix(),e.value.copy(t.matrix)}function i(t,i){t.opacity.value=i.opacity,i.color&&t.diffuse.value.copy(i.color),i.emissive&&t.emissive.value.copy(i.emissive).multiplyScalar(i.emissiveIntensity),i.map&&(t.map.value=i.map,n(i.map,t.mapTransform)),i.alphaMap&&(t.alphaMap.value=i.alphaMap,n(i.alphaMap,t.alphaMapTransform)),i.bumpMap&&(t.bumpMap.value=i.bumpMap,n(i.bumpMap,t.bumpMapTransform),t.bumpScale.value=i.bumpScale,1===i.side&&(t.bumpScale.value*=-1)),i.normalMap&&(t.normalMap.value=i.normalMap,n(i.normalMap,t.normalMapTransform),t.normalScale.value.copy(i.normalScale),1===i.side&&t.normalScale.value.negate()),i.displacementMap&&(t.displacementMap.value=i.displacementMap,n(i.displacementMap,t.displacementMapTransform),t.displacementScale.value=i.displacementScale,t.displacementBias.value=i.displacementBias),i.emissiveMap&&(t.emissiveMap.value=i.emissiveMap,n(i.emissiveMap,t.emissiveMapTransform)),i.specularMap&&(t.specularMap.value=i.specularMap,n(i.specularMap,t.specularMapTransform)),i.alphaTest>0&&(t.alphaTest.value=i.alphaTest);const r=e.get(i),a=r.envMap,s=r.envMapRotation;a&&(t.envMap.value=a,t.envMapRotation.value.setFromMatrix4(Qp.makeRotationFromEuler(s)).transpose(),a.isCubeTexture&&!1===a.isRenderTargetTexture&&t.envMapRotation.value.premultiply(tm),t.reflectivity.value=i.reflectivity,t.ior.value=i.ior,t.refractionRatio.value=i.refractionRatio),i.lightMap&&(t.lightMap.value=i.lightMap,t.lightMapIntensity.value=i.lightMapIntensity,n(i.lightMap,t.lightMapTransform)),i.aoMap&&(t.aoMap.value=i.aoMap,t.aoMapIntensity.value=i.aoMapIntensity,n(i.aoMap,t.aoMapTransform))}return{refreshFogUniforms:function(e,n){n.color.getRGB(e.fogColor.value,bc(t)),n.isFog?(e.fogNear.value=n.near,e.fogFar.value=n.far):n.isFogExp2&&(e.fogDensity.value=n.density)},refreshMaterialUniforms:function(t,r,a,s,o){r.isNodeMaterial?r.uniformsNeedUpdate=!1:r.isMeshBasicMaterial?i(t,r):r.isMeshLambertMaterial?(i(t,r),r.envMap&&(t.envMapIntensity.value=r.envMapIntensity)):r.isMeshToonMaterial?(i(t,r),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(t,r)):r.isMeshPhongMaterial?(i(t,r),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4)}(t,r),r.envMap&&(t.envMapIntensity.value=r.envMapIntensity)):r.isMeshStandardMaterial?(i(t,r),function(t,e){t.metalness.value=e.metalness,e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap,n(e.metalnessMap,t.metalnessMapTransform)),t.roughness.value=e.roughness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap,n(e.roughnessMap,t.roughnessMapTransform)),e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}(t,r),r.isMeshPhysicalMaterial&&function(t,e,i){t.ior.value=e.ior,e.sheen>0&&(t.sheenColor.value.copy(e.sheenColor).multiplyScalar(e.sheen),t.sheenRoughness.value=e.sheenRoughness,e.sheenColorMap&&(t.sheenColorMap.value=e.sheenColorMap,n(e.sheenColorMap,t.sheenColorMapTransform)),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap,n(e.sheenRoughnessMap,t.sheenRoughnessMapTransform))),e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap,n(e.clearcoatMap,t.clearcoatMapTransform)),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap,n(e.clearcoatRoughnessMap,t.clearcoatRoughnessMapTransform)),e.clearcoatNormalMap&&(t.clearcoatNormalMap.value=e.clearcoatNormalMap,n(e.clearcoatNormalMap,t.clearcoatNormalMapTransform),t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),1===e.side&&t.clearcoatNormalScale.value.negate())),e.dispersion>0&&(t.dispersion.value=e.dispersion),e.iridescence>0&&(t.iridescence.value=e.iridescence,t.iridescenceIOR.value=e.iridescenceIOR,t.iridescenceThicknessMinimum.value=e.iridescenceThicknessRange[0],t.iridescenceThicknessMaximum.value=e.iridescenceThicknessRange[1],e.iridescenceMap&&(t.iridescenceMap.value=e.iridescenceMap,n(e.iridescenceMap,t.iridescenceMapTransform)),e.iridescenceThicknessMap&&(t.iridescenceThicknessMap.value=e.iridescenceThicknessMap,n(e.iridescenceThicknessMap,t.iridescenceThicknessMapTransform))),e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=i.texture,t.transmissionSamplerSize.value.set(i.width,i.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap,n(e.transmissionMap,t.transmissionMapTransform)),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap,n(e.thicknessMap,t.thicknessMapTransform)),t.attenuationDistance.value=e.attenuationDistance,t.attenuationColor.value.copy(e.attenuationColor)),e.anisotropy>0&&(t.anisotropyVector.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation)),e.anisotropyMap&&(t.anisotropyMap.value=e.anisotropyMap,n(e.anisotropyMap,t.anisotropyMapTransform))),t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap,n(e.specularColorMap,t.specularColorMapTransform)),e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap,n(e.specularIntensityMap,t.specularIntensityMapTransform))}(t,r,o)):r.isMeshMatcapMaterial?(i(t,r),function(t,e){e.matcap&&(t.matcap.value=e.matcap)}(t,r)):r.isMeshDepthMaterial?i(t,r):r.isMeshDistanceMaterial?(i(t,r),function(t,n){const i=e.get(n).light;t.referencePosition.value.setFromMatrixPosition(i.matrixWorld),t.nearDistance.value=i.shadow.camera.near,t.farDistance.value=i.shadow.camera.far}(t,r)):r.isMeshNormalMaterial?i(t,r):r.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,e.map&&(t.map.value=e.map,n(e.map,t.mapTransform))}(t,r),r.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,r)):r.isPointsMaterial?function(t,e,i,r){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*i,t.scale.value=.5*r,e.map&&(t.map.value=e.map,n(e.map,t.uvTransform)),e.alphaMap&&(t.alphaMap.value=e.alphaMap,n(e.alphaMap,t.alphaMapTransform)),e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r,a,s):r.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map,n(e.map,t.mapTransform)),e.alphaMap&&(t.alphaMap.value=e.alphaMap,n(e.alphaMap,t.alphaMapTransform)),e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r):r.isShadowMaterial?(t.color.value.copy(r.color),t.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function nm(t,e,n,i){let r={},a={},s=[];const o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function l(t,e,n,i){const r=t.value,a=e+"_"+n;if(void 0===i[a])return"number"==typeof r||"boolean"==typeof r?i[a]=r:ArrayBuffer.isView(r)?i[a]=r.slice():i[a]=r.clone(),!0;{const t=i[a];if("number"==typeof r||"boolean"==typeof r){if(t!==r)return i[a]=r,!0}else{if(ArrayBuffer.isView(r))return!0;if(!1===t.equals(r))return t.copy(r),!0}}return!1}function c(t){const e={boundary:0,storage:0};return"number"==typeof t||"boolean"==typeof t?(e.boundary=4,e.storage=4):t.isVector2?(e.boundary=8,e.storage=8):t.isVector3||t.isColor?(e.boundary=16,e.storage=12):t.isVector4?(e.boundary=16,e.storage=16):t.isMatrix3?(e.boundary=48,e.storage=48):t.isMatrix4?(e.boundary=64,e.storage=64):t.isTexture?ci("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(t)?(e.boundary=16,e.storage=t.byteLength):ci("WebGLRenderer: Unsupported uniform value type.",t),e}function h(e){const n=e.target;n.removeEventListener("dispose",h);const i=s.indexOf(n.__bindingPointIndex);s.splice(i,1),t.deleteBuffer(r[n.id]),delete r[n.id],delete a[n.id]}return{bind:function(t,e){const n=e.program;i.uniformBlockBinding(t,n)},update:function(n,d){let u=r[n.id];void 0===u&&(function(t){const e=t.uniforms;let n=0;const i=16;for(let t=0,r=e.length;t<r;t++){const r=Array.isArray(e[t])?e[t]:[e[t]];for(let t=0,e=r.length;t<e;t++){const e=r[t],a=Array.isArray(e.value)?e.value:[e.value];for(let t=0,r=a.length;t<r;t++){const r=c(a[t]),s=n%i,o=s%r.boundary,l=s+o;n+=o,0!==l&&i-l<r.storage&&(n+=i-l),e.__data=new Float32Array(r.storage/Float32Array.BYTES_PER_ELEMENT),e.__offset=n,n+=r.storage}}}const r=n%i;r>0&&(n+=i-r),t.__size=n,t.__cache={}}(n),u=function(e){const n=function(){for(let t=0;t<o;t++)if(-1===s.indexOf(t))return s.push(t),t;return hi("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();e.__bindingPointIndex=n;const i=t.createBuffer(),r=e.__size,a=e.usage;return t.bindBuffer(t.UNIFORM_BUFFER,i),t.bufferData(t.UNIFORM_BUFFER,r,a),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,n,i),i}(n),r[n.id]=u,n.addEventListener("dispose",h));const p=d.program;i.updateUBOMapping(n,p);const m=e.render.frame;a[n.id]!==m&&(function(e){const n=r[e.id],i=e.uniforms,a=e.__cache;t.bindBuffer(t.UNIFORM_BUFFER,n);for(let e=0,n=i.length;e<n;e++){const n=Array.isArray(i[e])?i[e]:[i[e]];for(let i=0,r=n.length;i<r;i++){const r=n[i];if(!0===l(r,e,i,a)){const e=r.__offset,n=Array.isArray(r.value)?r.value:[r.value];let i=0;for(let a=0;a<n.length;a++){const s=n[a],o=c(s);"number"==typeof s||"boolean"==typeof s?(r.__data[0]=s,t.bufferSubData(t.UNIFORM_BUFFER,e+i,r.__data)):s.isMatrix3?(r.__data[0]=s.elements[0],r.__data[1]=s.elements[1],r.__data[2]=s.elements[2],r.__data[3]=0,r.__data[4]=s.elements[3],r.__data[5]=s.elements[4],r.__data[6]=s.elements[5],r.__data[7]=0,r.__data[8]=s.elements[6],r.__data[9]=s.elements[7],r.__data[10]=s.elements[8],r.__data[11]=0):ArrayBuffer.isView(s)?r.__data.set(new s.constructor(s.buffer,s.byteOffset,r.__data.length)):(s.toArray(r.__data,i),i+=o.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,e,r.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}(n),a[n.id]=m)},dispose:function(){for(const e in r)t.deleteBuffer(r[e]);s=[],r={},a={}}}}tm.set(-1,0,0,0,1,0,0,0,1);const im=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let rm=null;class am{constructor(t={}){const{canvas:e=ai(),context:n=null,depth:i=!0,stencil:r=!1,alpha:a=!1,antialias:s=!1,premultipliedAlpha:o=!0,preserveDrawingBuffer:l=!1,powerPreference:c="default",failIfMajorPerformanceCaveat:h=!1,reversedDepthBuffer:d=!1,outputBufferType:u=Ae}=t;let p;if(this.isWebGLRenderer=!0,null!==n){if("undefined"!=typeof WebGLRenderingContext&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=n.getContextAttributes().alpha}else p=a;const m=u,f=new Set([qe,Xe,We]),g=new Set([Ae,Le,Ie,Fe,Oe,Ue]),v=new Uint32Array(4),_=new Int32Array(4),y=new Ai;let x=null,b=null;const S=[],M=[];let w=null;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=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const E=this;let T=!1,A=null;this._outputColorSpace=kn;let C=0,R=0,I=null,P=-1,L=null;const D=new Xi,N=new Xi;let O=null;const U=new Lr(0);let F=0,z=e.width,k=e.height,B=1,G=null,V=null;const H=new Xi(0,0,z,k),W=new Xi(0,0,z,k);let j=!1;const X=new to;let q=!1,Y=!1;const Z=new Ji,$=new Ai,J=new Xi,K={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Q=!1;function tt(){return null===I?B:1}let et,nt,it,rt,at,st,ot,lt,ct,ht,dt,ut,pt,mt,ft,gt,vt,_t,xt,bt,St,Mt,wt,Et=n;function Tt(t,n){return e.getContext(t,n)}try{const t={alpha:!0,depth:i,stencil:r,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:l,powerPreference:c,failIfMajorPerformanceCaveat:h};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${yt}`),e.addEventListener("webglcontextlost",Rt,!1),e.addEventListener("webglcontextrestored",It,!1),e.addEventListener("webglcontextcreationerror",Pt,!1),null===Et){const e="webgl2";if(Et=Tt(e,t),null===Et)throw Tt(e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(t){throw hi("WebGLRenderer: "+t.message),t}function At(){et=new Hd(Et),et.init(),St=new $p(Et,et),nt=new Ed(Et,et,t,St),it=new Yp(Et,et),nt.reversedDepthBuffer&&d&&it.buffers.depth.setReversed(!0),rt=new Xd(Et),at=new Pp,st=new Zp(Et,et,it,at,nt,St,rt),ot=new Vd(E),lt=new fd(Et),Mt=new Md(Et,lt),ct=new Wd(Et,lt,rt,Mt),ht=new Yd(Et,ct,lt,Mt,rt),_t=new qd(Et,nt,st),ft=new Td(at),dt=new Ip(E,ot,et,nt,Mt,ft),ut=new em(E,at),pt=new Op,mt=new Gp(et),vt=new Sd(E,ot,it,ht,p,o),gt=new qp(E,ht,nt),wt=new nm(Et,rt,nt,it),xt=new wd(Et,et,rt),bt=new jd(Et,et,rt),rt.programs=dt.programs,E.capabilities=nt,E.extensions=et,E.properties=at,E.renderLists=pt,E.shadowMap=gt,E.state=it,E.info=rt}At(),m!==Ae&&(w=new $d(m,e.width,e.height,i,r));const Ct=new Kp(E,Et);function Rt(t){t.preventDefault(),oi("WebGLRenderer: Context Lost."),T=!0}function It(){oi("WebGLRenderer: Context Restored."),T=!1;const t=rt.autoReset,e=gt.enabled,n=gt.autoUpdate,i=gt.needsUpdate,r=gt.type;At(),rt.autoReset=t,gt.enabled=e,gt.autoUpdate=n,gt.needsUpdate=i,gt.type=r}function Pt(t){hi("WebGLRenderer: A WebGL context could not be created. Reason: ",t.statusMessage)}function Lt(t){const e=t.target;e.removeEventListener("dispose",Lt),function(t){(function(t){const e=at.get(t).programs;void 0!==e&&(e.forEach((function(t){dt.releaseProgram(t)})),t.isShaderMaterial&&dt.releaseShaderCache(t))})(t),at.remove(t)}(e)}function Dt(t,e,n){!0===t.transparent&&2===t.side&&!1===t.forceSinglePass?(t.side=1,t.needsUpdate=!0,Ht(t,e,n),t.side=0,t.needsUpdate=!0,Ht(t,e,n),t.side=2):Ht(t,e,n)}this.xr=Ct,this.getContext=function(){return Et},this.getContextAttributes=function(){return Et.getContextAttributes()},this.forceContextLoss=function(){const t=et.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){const t=et.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return B},this.setPixelRatio=function(t){void 0!==t&&(B=t,this.setSize(z,k,!1))},this.getSize=function(t){return t.set(z,k)},this.setSize=function(t,n,i=!0){Ct.isPresenting?ci("WebGLRenderer: Can't change size while VR device is presenting."):(z=t,k=n,e.width=Math.floor(t*B),e.height=Math.floor(n*B),!0===i&&(e.style.width=t+"px",e.style.height=n+"px"),null!==w&&w.setSize(e.width,e.height),this.setViewport(0,0,t,n))},this.getDrawingBufferSize=function(t){return t.set(z*B,k*B).floor()},this.setDrawingBufferSize=function(t,n,i){z=t,k=n,B=i,e.width=Math.floor(t*i),e.height=Math.floor(n*i),this.setViewport(0,0,t,n)},this.setEffects=function(t){if(m!==Ae){if(t)for(let e=0;e<t.length;e++)if(!0===t[e].isOutputPass){ci("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}w.setEffects(t||[])}else hi("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.")},this.getCurrentViewport=function(t){return t.copy(D)},this.getViewport=function(t){return t.copy(H)},this.setViewport=function(t,e,n,i){t.isVector4?H.set(t.x,t.y,t.z,t.w):H.set(t,e,n,i),it.viewport(D.copy(H).multiplyScalar(B).round())},this.getScissor=function(t){return t.copy(W)},this.setScissor=function(t,e,n,i){t.isVector4?W.set(t.x,t.y,t.z,t.w):W.set(t,e,n,i),it.scissor(N.copy(W).multiplyScalar(B).round())},this.getScissorTest=function(){return j},this.setScissorTest=function(t){it.setScissorTest(j=t)},this.setOpaqueSort=function(t){G=t},this.setTransparentSort=function(t){V=t},this.getClearColor=function(t){return t.copy(vt.getClearColor())},this.setClearColor=function(){vt.setClearColor(...arguments)},this.getClearAlpha=function(){return vt.getClearAlpha()},this.setClearAlpha=function(){vt.setClearAlpha(...arguments)},this.clear=function(t=!0,e=!0,n=!0){let i=0;if(t){let t=!1;if(null!==I){const e=I.texture.format;t=f.has(e)}if(t){const t=I.texture.type,e=g.has(t),n=vt.getClearColor(),i=vt.getClearAlpha(),r=n.r,a=n.g,s=n.b;e?(v[0]=r,v[1]=a,v[2]=s,v[3]=i,Et.clearBufferuiv(Et.COLOR,0,v)):(_[0]=r,_[1]=a,_[2]=s,_[3]=i,Et.clearBufferiv(Et.COLOR,0,_))}else i|=Et.COLOR_BUFFER_BIT}e&&(i|=Et.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),n&&(i|=Et.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),0!==i&&Et.clear(i)},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.setNodesHandler=function(t){t.setRenderer(this),A=t},this.dispose=function(){e.removeEventListener("webglcontextlost",Rt,!1),e.removeEventListener("webglcontextrestored",It,!1),e.removeEventListener("webglcontextcreationerror",Pt,!1),vt.dispose(),pt.dispose(),mt.dispose(),at.dispose(),ot.dispose(),ht.dispose(),Mt.dispose(),wt.dispose(),dt.dispose(),Ct.dispose(),Ct.removeEventListener("sessionstart",Ot),Ct.removeEventListener("sessionend",Ut),Ft.stop()},this.renderBufferDirect=function(t,e,n,i,r,a){null===e&&(e=K);const s=r.isMesh&&r.matrixWorld.determinant()<0,o=function(t,e,n,i,r){!0!==e.isScene&&(e=K),st.resetTextureUnits();const a=e.fog,s=i.isMeshStandardMaterial||i.isMeshLambertMaterial||i.isMeshPhongMaterial?e.environment:null,o=null===I?E.outputColorSpace:!0===I.isXRRenderTarget?I.texture.colorSpace:Oi.workingColorSpace,l=i.isMeshStandardMaterial||i.isMeshLambertMaterial&&!i.envMap||i.isMeshPhongMaterial&&!i.envMap,c=ot.get(i.envMap||s,l),h=!0===i.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,d=!!n.attributes.tangent&&(!!i.normalMap||i.anisotropy>0),u=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,m=!!n.morphAttributes.color;let f=0;i.toneMapped&&(null!==I&&!0!==I.isXRRenderTarget||(f=E.toneMapping));const g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,v=void 0!==g?g.length:0,_=at.get(i),x=b.state.lights;if(!0===q&&(!0===Y||t!==L)){const e=t===L&&i.id===P;ft.setState(i,t,e)}let S=!1;i.version===_.__version?_.needsLights&&_.lightsStateVersion!==x.state.version||_.outputColorSpace!==o||r.isBatchedMesh&&!1===_.batching?S=!0:r.isBatchedMesh||!0!==_.batching?r.isBatchedMesh&&!0===_.batchingColor&&null===r.colorTexture||r.isBatchedMesh&&!1===_.batchingColor&&null!==r.colorTexture||r.isInstancedMesh&&!1===_.instancing?S=!0:r.isInstancedMesh||!0!==_.instancing?r.isSkinnedMesh&&!1===_.skinning?S=!0:r.isSkinnedMesh||!0!==_.skinning?r.isInstancedMesh&&!0===_.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===_.instancingColor&&null!==r.instanceColor||r.isInstancedMesh&&!0===_.instancingMorph&&null===r.morphTexture||r.isInstancedMesh&&!1===_.instancingMorph&&null!==r.morphTexture||_.envMap!==c||!0===i.fog&&_.fog!==a?S=!0:void 0===_.numClippingPlanes||_.numClippingPlanes===ft.numPlanes&&_.numIntersection===ft.numIntersection?(_.vertexAlphas!==h||_.vertexTangents!==d||_.morphTargets!==u||_.morphNormals!==p||_.morphColors!==m||_.toneMapping!==f||_.morphTargetsCount!==v||!!_.lightProbeGrid!=b.state.lightProbeGridArray.length>0)&&(S=!0):S=!0:S=!0:S=!0:S=!0:(S=!0,_.__version=i.version);let M=_.currentProgram;!0===S&&(M=Ht(i,e,r),A&&i.isNodeMaterial&&A.onUpdateProgram(i,M,_));let w=!1,T=!1,C=!1;const R=M.getUniforms(),D=_.uniforms;if(it.useProgram(M.program)&&(w=!0,T=!0,C=!0),i.id!==P&&(P=i.id,T=!0),_.needsLights){const t=function(t,e){if(0===t.length)return null;if(1===t.length)return null!==t[0].texture?t[0]:null;y.setFromMatrixPosition(e.matrixWorld);for(let e=0,n=t.length;e<n;e++){const n=t[e];if(null!==n.texture&&n.boundingBox.containsPoint(y))return n}return null}(b.state.lightProbeGridArray,r);_.lightProbeGrid!==t&&(_.lightProbeGrid=t,T=!0)}if(w||L!==t){it.buffers.depth.getReversed()&&!0!==t.reversedDepth&&(t._reversedDepth=!0,t.updateProjectionMatrix()),R.setValue(Et,"projectionMatrix",t.projectionMatrix),R.setValue(Et,"viewMatrix",t.matrixWorldInverse);const e=R.map.cameraPosition;void 0!==e&&e.setValue(Et,$.setFromMatrixPosition(t.matrixWorld)),nt.logarithmicDepthBuffer&&R.setValue(Et,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&R.setValue(Et,"isOrthographic",!0===t.isOrthographicCamera),L!==t&&(L=t,T=!0,C=!0)}if(_.needsLights&&(x.state.directionalShadowMap.length>0&&R.setValue(Et,"directionalShadowMap",x.state.directionalShadowMap,st),x.state.spotShadowMap.length>0&&R.setValue(Et,"spotShadowMap",x.state.spotShadowMap,st),x.state.pointShadowMap.length>0&&R.setValue(Et,"pointShadowMap",x.state.pointShadowMap,st)),r.isSkinnedMesh){R.setOptional(Et,r,"bindMatrix"),R.setOptional(Et,r,"bindMatrixInverse");const t=r.skeleton;t&&(null===t.boneTexture&&t.computeBoneTexture(),R.setValue(Et,"boneTexture",t.boneTexture,st))}r.isBatchedMesh&&(R.setOptional(Et,r,"batchingTexture"),R.setValue(Et,"batchingTexture",r._matricesTexture,st),R.setOptional(Et,r,"batchingIdTexture"),R.setValue(Et,"batchingIdTexture",r._indirectTexture,st),R.setOptional(Et,r,"batchingColorTexture"),null!==r._colorsTexture&&R.setValue(Et,"batchingColorTexture",r._colorsTexture,st));const N=n.morphAttributes;if(void 0===N.position&&void 0===N.normal&&void 0===N.color||_t.update(r,n,M),(T||_.receiveShadow!==r.receiveShadow)&&(_.receiveShadow=r.receiveShadow,R.setValue(Et,"receiveShadow",r.receiveShadow)),(i.isMeshStandardMaterial||i.isMeshLambertMaterial||i.isMeshPhongMaterial)&&null===i.envMap&&null!==e.environment&&(D.envMapIntensity.value=e.environmentIntensity),void 0!==D.dfgLUT&&(D.dfgLUT.value=(null===rm&&(rm=new Ns(im,16,16,je,Ne),rm.name="DFG_LUT",rm.minFilter=we,rm.magFilter=we,rm.wrapS=ye,rm.wrapT=ye,rm.generateMipmaps=!1,rm.needsUpdate=!0),rm)),T){if(R.setValue(Et,"toneMappingExposure",E.toneMappingExposure),_.needsLights&&(U=C,(O=D).ambientLightColor.needsUpdate=U,O.lightProbe.needsUpdate=U,O.directionalLights.needsUpdate=U,O.directionalLightShadows.needsUpdate=U,O.pointLights.needsUpdate=U,O.pointLightShadows.needsUpdate=U,O.spotLights.needsUpdate=U,O.spotLightShadows.needsUpdate=U,O.rectAreaLights.needsUpdate=U,O.hemisphereLights.needsUpdate=U),a&&!0===i.fog&&ut.refreshFogUniforms(D,a),ut.refreshMaterialUniforms(D,i,B,k,b.state.transmissionRenderTarget[t.id]),_.needsLights&&_.lightProbeGrid){const t=_.lightProbeGrid;D.probesSH.value=t.texture,D.probesMin.value.copy(t.boundingBox.min),D.probesMax.value.copy(t.boundingBox.max),D.probesResolution.value.copy(t.resolution)}ep.upload(Et,Wt(_),D,st)}var O,U;if(i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(ep.upload(Et,Wt(_),D,st),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&R.setValue(Et,"center",r.center),R.setValue(Et,"modelViewMatrix",r.modelViewMatrix),R.setValue(Et,"normalMatrix",r.normalMatrix),R.setValue(Et,"modelMatrix",r.matrixWorld),void 0!==i.uniformsGroups){const t=i.uniformsGroups;for(let e=0,n=t.length;e<n;e++){const n=t[e];wt.update(n,M),wt.bind(n,M)}}return M}(t,e,n,i,r);it.setMaterial(i,s);let l=n.index,c=1;if(!0===i.wireframe){if(l=ct.getWireframeAttribute(n),void 0===l)return;c=2}const h=n.drawRange,d=n.attributes.position;let u=h.start*c,p=(h.start+h.count)*c;null!==a&&(u=Math.max(u,a.start*c),p=Math.min(p,(a.start+a.count)*c)),null!==l?(u=Math.max(u,0),p=Math.min(p,l.count)):null!=d&&(u=Math.max(u,0),p=Math.min(p,d.count));const m=p-u;if(m<0||m===1/0)return;let f;Mt.setup(r,i,o,n,l);let g=xt;if(null!==l&&(f=lt.get(l),g=bt,g.setIndex(f)),r.isMesh)!0===i.wireframe?(it.setLineWidth(i.wireframeLinewidth*tt()),g.setMode(Et.LINES)):g.setMode(Et.TRIANGLES);else if(r.isLine){let t=i.linewidth;void 0===t&&(t=1),it.setLineWidth(t*tt()),r.isLineSegments?g.setMode(Et.LINES):r.isLineLoop?g.setMode(Et.LINE_LOOP):g.setMode(Et.LINE_STRIP)}else r.isPoints?g.setMode(Et.POINTS):r.isSprite&&g.setMode(Et.TRIANGLES);if(r.isBatchedMesh)if(et.get("WEBGL_multi_draw"))g.renderMultiDraw(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount);else{const t=r._multiDrawStarts,e=r._multiDrawCounts,n=r._multiDrawCount,a=l?lt.get(l).bytesPerElement:1,s=at.get(i).currentProgram.getUniforms();for(let i=0;i<n;i++)s.setValue(Et,"_gl_DrawID",i),g.render(t[i]/a,e[i])}else if(r.isInstancedMesh)g.renderInstances(u,m,r.count);else if(n.isInstancedBufferGeometry){const t=void 0!==n._maxInstanceCount?n._maxInstanceCount:1/0,e=Math.min(n.instanceCount,t);g.renderInstances(u,m,e)}else g.render(u,m)},this.compile=function(t,e,n=null){null===n&&(n=t),b=mt.get(n),b.init(e),M.push(b),n.traverseVisible((function(t){t.isLight&&t.layers.test(e.layers)&&(b.pushLight(t),t.castShadow&&b.pushShadow(t))})),t!==n&&t.traverseVisible((function(t){t.isLight&&t.layers.test(e.layers)&&(b.pushLight(t),t.castShadow&&b.pushShadow(t))})),b.setupLights();const i=new Set;return t.traverse((function(t){if(!(t.isMesh||t.isPoints||t.isLine||t.isSprite))return;const e=t.material;if(e)if(Array.isArray(e))for(let r=0;r<e.length;r++){const a=e[r];Dt(a,n,t),i.add(a)}else Dt(e,n,t),i.add(e)})),b=M.pop(),i},this.compileAsync=function(t,e,n=null){const i=this.compile(t,e,n);return new Promise((e=>{function n(){i.forEach((function(t){at.get(t).currentProgram.isReady()&&i.delete(t)})),0!==i.size?setTimeout(n,10):e(t)}null!==et.get("KHR_parallel_shader_compile")?n():setTimeout(n,10)}))};let Nt=null;function Ot(){Ft.stop()}function Ut(){Ft.start()}const Ft=new md;function zt(t,e,n,i){if(!1===t.visible)return;if(t.layers.test(e.layers))if(t.isGroup)n=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLightProbeGrid)b.pushLightProbeGrid(t);else if(t.isLight)b.pushLight(t),t.castShadow&&b.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||X.intersectsSprite(t)){i&&J.setFromMatrixPosition(t.matrixWorld).applyMatrix4(Z);const e=ht.update(t),r=t.material;r.visible&&x.push(t,e,r,n,J.z,null)}}else if((t.isMesh||t.isLine||t.isPoints)&&(!t.frustumCulled||X.intersectsObject(t))){const e=ht.update(t),r=t.material;if(i&&(void 0!==t.boundingSphere?(null===t.boundingSphere&&t.computeBoundingSphere(),J.copy(t.boundingSphere.center)):(null===e.boundingSphere&&e.computeBoundingSphere(),J.copy(e.boundingSphere.center)),J.applyMatrix4(t.matrixWorld).applyMatrix4(Z)),Array.isArray(r)){const i=e.groups;for(let a=0,s=i.length;a<s;a++){const s=i[a],o=r[s.materialIndex];o&&o.visible&&x.push(t,e,o,n,J.z,s)}}else r.visible&&x.push(t,e,r,n,J.z,null)}const r=t.children;for(let t=0,a=r.length;t<a;t++)zt(r[t],e,n,i)}function kt(t,e,n,i){const{opaque:r,transmissive:a,transparent:s}=t;b.setupLightsView(n),!0===q&&ft.setGlobalState(E.clippingPlanes,n),i&&it.viewport(D.copy(i)),r.length>0&&Gt(r,e,n),a.length>0&&Gt(a,e,n),s.length>0&&Gt(s,e,n),it.buffers.depth.setTest(!0),it.buffers.depth.setMask(!0),it.buffers.color.setMask(!0),it.setPolygonOffset(!1)}function Bt(t,e,n,i){if(null!==(!0===n.isScene?n.overrideMaterial:null))return;if(void 0===b.state.transmissionRenderTarget[i.id]){const t=et.has("EXT_color_buffer_half_float")||et.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[i.id]=new Yi(1,1,{generateMipmaps:!0,type:t?Ne:Ae,minFilter:Te,samples:Math.max(4,nt.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Oi.workingColorSpace})}const a=b.state.transmissionRenderTarget[i.id],s=i.viewport||D;a.setSize(s.z*E.transmissionResolutionScale,s.w*E.transmissionResolutionScale);const o=E.getRenderTarget(),l=E.getActiveCubeFace(),c=E.getActiveMipmapLevel();E.setRenderTarget(a),E.getClearColor(U),F=E.getClearAlpha(),F<1&&E.setClearColor(16777215,.5),E.clear(),Q&&vt.render(n);const h=E.toneMapping;E.toneMapping=0;const d=i.viewport;if(void 0!==i.viewport&&(i.viewport=void 0),b.setupLightsView(i),!0===q&&ft.setGlobalState(E.clippingPlanes,i),Gt(t,n,i),st.updateMultisampleRenderTarget(a),st.updateRenderTargetMipmap(a),!1===et.has("WEBGL_multisampled_render_to_texture")){let t=!1;for(let r=0,a=e.length;r<a;r++){const a=e[r],{object:s,geometry:o,material:l,group:c}=a;if(2===l.side&&s.layers.test(i.layers)){const e=l.side;l.side=1,l.needsUpdate=!0,Vt(s,n,i,o,l,c),l.side=e,l.needsUpdate=!0,t=!0}}!0===t&&(st.updateMultisampleRenderTarget(a),st.updateRenderTargetMipmap(a))}E.setRenderTarget(o,l,c),E.setClearColor(U,F),void 0!==d&&(i.viewport=d),E.toneMapping=h}function Gt(t,e,n){const i=!0===e.isScene?e.overrideMaterial:null;for(let r=0,a=t.length;r<a;r++){const a=t[r],{object:s,geometry:o,group:l}=a;let c=a.material;!0===c.allowOverride&&null!==i&&(c=i),s.layers.test(n.layers)&&Vt(s,e,n,o,c,l)}}function Vt(t,e,n,i,r,a){t.onBeforeRender(E,e,n,i,r,a),t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),r.onBeforeRender(E,e,n,i,t,a),!0===r.transparent&&2===r.side&&!1===r.forceSinglePass?(r.side=1,r.needsUpdate=!0,E.renderBufferDirect(n,e,i,r,t,a),r.side=0,r.needsUpdate=!0,E.renderBufferDirect(n,e,i,r,t,a),r.side=2):E.renderBufferDirect(n,e,i,r,t,a),t.onAfterRender(E,e,n,i,r,a)}function Ht(t,e,n){!0!==e.isScene&&(e=K);const i=at.get(t),r=b.state.lights,a=b.state.shadowsArray,s=r.state.version,o=dt.getParameters(t,r.state,a,e,n,b.state.lightProbeGridArray),l=dt.getProgramCacheKey(o);let c=i.programs;i.environment=t.isMeshStandardMaterial||t.isMeshLambertMaterial||t.isMeshPhongMaterial?e.environment:null,i.fog=e.fog;const h=t.isMeshStandardMaterial||t.isMeshLambertMaterial&&!t.envMap||t.isMeshPhongMaterial&&!t.envMap;i.envMap=ot.get(t.envMap||i.environment,h),i.envMapRotation=null!==i.environment&&null===t.envMap?e.environmentRotation:t.envMapRotation,void 0===c&&(t.addEventListener("dispose",Lt),c=new Map,i.programs=c);let d=c.get(l);if(void 0!==d){if(i.currentProgram===d&&i.lightsStateVersion===s)return jt(t,o),d}else o.uniforms=dt.getUniforms(t),null!==A&&t.isNodeMaterial&&A.build(t,n,o),t.onBeforeCompile(o,E),d=dt.acquireProgram(o,l),c.set(l,d),i.uniforms=o.uniforms;const u=i.uniforms;return(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(u.clippingPlanes=ft.uniform),jt(t,o),i.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshToonMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),i.lightsStateVersion=s,i.needsLights&&(u.ambientLightColor.value=r.state.ambient,u.lightProbe.value=r.state.probe,u.directionalLights.value=r.state.directional,u.directionalLightShadows.value=r.state.directionalShadow,u.spotLights.value=r.state.spot,u.spotLightShadows.value=r.state.spotShadow,u.rectAreaLights.value=r.state.rectArea,u.ltc_1.value=r.state.rectAreaLTC1,u.ltc_2.value=r.state.rectAreaLTC2,u.pointLights.value=r.state.point,u.pointLightShadows.value=r.state.pointShadow,u.hemisphereLights.value=r.state.hemi,u.directionalShadowMatrix.value=r.state.directionalShadowMatrix,u.spotLightMatrix.value=r.state.spotLightMatrix,u.spotLightMap.value=r.state.spotLightMap,u.pointShadowMatrix.value=r.state.pointShadowMatrix),i.lightProbeGrid=b.state.lightProbeGridArray.length>0,i.currentProgram=d,i.uniformsList=null,d}function Wt(t){if(null===t.uniformsList){const e=t.currentProgram.getUniforms();t.uniformsList=ep.seqWithValue(e.seq,t.uniforms)}return t.uniformsList}function jt(t,e){const n=at.get(t);n.outputColorSpace=e.outputColorSpace,n.batching=e.batching,n.batchingColor=e.batchingColor,n.instancing=e.instancing,n.instancingColor=e.instancingColor,n.instancingMorph=e.instancingMorph,n.skinning=e.skinning,n.morphTargets=e.morphTargets,n.morphNormals=e.morphNormals,n.morphColors=e.morphColors,n.morphTargetsCount=e.morphTargetsCount,n.numClippingPlanes=e.numClippingPlanes,n.numIntersection=e.numClipIntersection,n.vertexAlphas=e.vertexAlphas,n.vertexTangents=e.vertexTangents,n.toneMapping=e.toneMapping}Ft.setAnimationLoop((function(t){Nt&&Nt(t)})),"undefined"!=typeof self&&Ft.setContext(self),this.setAnimationLoop=function(t){Nt=t,Ct.setAnimationLoop(t),null===t?Ft.stop():Ft.start()},Ct.addEventListener("sessionstart",Ot),Ct.addEventListener("sessionend",Ut),this.render=function(t,e){if(void 0!==e&&!0!==e.isCamera)return void hi("WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===T)return;null!==A&&A.renderStart(t,e);const n=!0===Ct.enabled&&!0===Ct.isPresenting,i=null!==w&&(null===I||n)&&w.begin(E,I);if(!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),null===e.parent&&!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),!0!==Ct.enabled||!0!==Ct.isPresenting||null!==w&&!1!==w.isCompositing()||(!0===Ct.cameraAutoUpdate&&Ct.updateCamera(e),e=Ct.getCamera()),!0===t.isScene&&t.onBeforeRender(E,t,e,I),b=mt.get(t,M.length),b.init(e),b.state.textureUnits=st.getTextureUnits(),M.push(b),Z.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),X.setFromProjectionMatrix(Z,ti,e.reversedDepth),Y=this.localClippingEnabled,q=ft.init(this.clippingPlanes,Y),x=pt.get(t,S.length),x.init(),S.push(x),!0===Ct.enabled&&!0===Ct.isPresenting){const t=E.xr.getDepthSensingMesh();null!==t&&zt(t,e,-1/0,E.sortObjects)}zt(t,e,0,E.sortObjects),x.finish(),!0===E.sortObjects&&x.sort(G,V),Q=!1===Ct.enabled||!1===Ct.isPresenting||!1===Ct.hasDepthSensing(),Q&&vt.addToRenderList(x,t),this.info.render.frame++,!0===q&&ft.beginShadows();const r=b.state.shadowsArray;if(gt.render(r,t,e),!0===q&&ft.endShadows(),!0===this.info.autoReset&&this.info.reset(),!1===(i&&w.hasRenderPass())){const n=x.opaque,i=x.transmissive;if(b.setupLights(),e.isArrayCamera){const r=e.cameras;if(i.length>0)for(let e=0,a=r.length;e<a;e++)Bt(n,i,t,r[e]);Q&&vt.render(t);for(let e=0,n=r.length;e<n;e++){const n=r[e];kt(x,t,n,n.viewport)}}else i.length>0&&Bt(n,i,t,e),Q&&vt.render(t),kt(x,t,e)}null!==I&&0===R&&(st.updateMultisampleRenderTarget(I),st.updateRenderTargetMipmap(I)),i&&w.end(E),!0===t.isScene&&t.onAfterRender(E,t,e),Mt.resetDefaultState(),P=-1,L=null,M.pop(),M.length>0?(b=M[M.length-1],st.setTextureUnits(b.state.textureUnits),!0===q&&ft.setGlobalState(E.clippingPlanes,b.state.camera)):b=null,S.pop(),x=S.length>0?S[S.length-1]:null,null!==A&&A.renderEnd()},this.getActiveCubeFace=function(){return C},this.getActiveMipmapLevel=function(){return R},this.getRenderTarget=function(){return I},this.setRenderTargetTextures=function(t,e,n){const i=at.get(t);i.__autoAllocateDepthBuffer=!1===t.resolveDepthBuffer,!1===i.__autoAllocateDepthBuffer&&(i.__useRenderToTexture=!1),at.get(t.texture).__webglTexture=e,at.get(t.depthTexture).__webglTexture=i.__autoAllocateDepthBuffer?void 0:n,i.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(t,e){const n=at.get(t);n.__webglFramebuffer=e,n.__useDefaultFramebuffer=void 0===e};const Xt=Et.createFramebuffer();this.setRenderTarget=function(t,e=0,n=0){I=t,C=e,R=n;let i=null,r=!1,a=!1;if(t){const s=at.get(t);if(void 0!==s.__useDefaultFramebuffer)return it.bindFramebuffer(Et.FRAMEBUFFER,s.__webglFramebuffer),D.copy(t.viewport),N.copy(t.scissor),O=t.scissorTest,it.viewport(D),it.scissor(N),it.setScissorTest(O),void(P=-1);if(void 0===s.__webglFramebuffer)st.setupRenderTarget(t);else if(s.__hasExternalTextures)st.rebindTextures(t,at.get(t.texture).__webglTexture,at.get(t.depthTexture).__webglTexture);else if(t.depthBuffer){const e=t.depthTexture;if(s.__boundDepthTexture!==e){if(null!==e&&at.has(e)&&(t.width!==e.image.width||t.height!==e.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");st.setupDepthRenderbuffer(t)}}const o=t.texture;(o.isData3DTexture||o.isDataArrayTexture||o.isCompressedArrayTexture)&&(a=!0);const l=at.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(i=Array.isArray(l[e])?l[e][n]:l[e],r=!0):i=t.samples>0&&!1===st.useMultisampledRTT(t)?at.get(t).__webglMultisampledFramebuffer:Array.isArray(l)?l[n]:l,D.copy(t.viewport),N.copy(t.scissor),O=t.scissorTest}else D.copy(H).multiplyScalar(B).floor(),N.copy(W).multiplyScalar(B).floor(),O=j;if(0!==n&&(i=Xt),it.bindFramebuffer(Et.FRAMEBUFFER,i)&&it.drawBuffers(t,i),it.viewport(D),it.scissor(N),it.setScissorTest(O),r){const i=at.get(t.texture);Et.framebufferTexture2D(Et.FRAMEBUFFER,Et.COLOR_ATTACHMENT0,Et.TEXTURE_CUBE_MAP_POSITIVE_X+e,i.__webglTexture,n)}else if(a){const i=e;for(let e=0;e<t.textures.length;e++){const r=at.get(t.textures[e]);Et.framebufferTextureLayer(Et.FRAMEBUFFER,Et.COLOR_ATTACHMENT0+e,r.__webglTexture,n,i)}}else if(null!==t&&0!==n){const e=at.get(t.texture);Et.framebufferTexture2D(Et.FRAMEBUFFER,Et.COLOR_ATTACHMENT0,Et.TEXTURE_2D,e.__webglTexture,n)}P=-1},this.readRenderTargetPixels=function(t,e,n,i,r,a,s,o=0){if(!t||!t.isWebGLRenderTarget)return void hi("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=at.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==s&&(l=l[s]),l){it.bindFramebuffer(Et.FRAMEBUFFER,l);try{const s=t.textures[o],l=s.format,c=s.type;if(t.textures.length>1&&Et.readBuffer(Et.COLOR_ATTACHMENT0+o),!nt.textureFormatReadable(l))return void hi("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!nt.textureTypeReadable(c))return void hi("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");e>=0&&e<=t.width-i&&n>=0&&n<=t.height-r&&Et.readPixels(e,n,i,r,St.convert(l),St.convert(c),a)}finally{const t=null!==I?at.get(I).__webglFramebuffer:null;it.bindFramebuffer(Et.FRAMEBUFFER,t)}}},this.readRenderTargetPixelsAsync=async function(t,e,n,i,r,a,s,o=0){if(!t||!t.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=at.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==s&&(l=l[s]),l){if(e>=0&&e<=t.width-i&&n>=0&&n<=t.height-r){it.bindFramebuffer(Et.FRAMEBUFFER,l);const s=t.textures[o],c=s.format,h=s.type;if(t.textures.length>1&&Et.readBuffer(Et.COLOR_ATTACHMENT0+o),!nt.textureFormatReadable(c))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!nt.textureTypeReadable(h))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const d=Et.createBuffer();Et.bindBuffer(Et.PIXEL_PACK_BUFFER,d),Et.bufferData(Et.PIXEL_PACK_BUFFER,a.byteLength,Et.STREAM_READ),Et.readPixels(e,n,i,r,St.convert(c),St.convert(h),0);const u=null!==I?at.get(I).__webglFramebuffer:null;it.bindFramebuffer(Et.FRAMEBUFFER,u);const p=Et.fenceSync(Et.SYNC_GPU_COMMANDS_COMPLETE,0);return Et.flush(),await function(t,e,n){return new Promise((function(i,r){setTimeout((function a(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:r();break;case t.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:i()}}),n)}))}(Et,p,4),Et.bindBuffer(Et.PIXEL_PACK_BUFFER,d),Et.getBufferSubData(Et.PIXEL_PACK_BUFFER,0,a),Et.deleteBuffer(d),Et.deleteSync(p),a}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(t,e=null,n=0){const i=Math.pow(2,-n),r=Math.floor(t.image.width*i),a=Math.floor(t.image.height*i),s=null!==e?e.x:0,o=null!==e?e.y:0;st.setTexture2D(t,0),Et.copyTexSubImage2D(Et.TEXTURE_2D,n,0,0,s,o,r,a),it.unbindTexture()};const qt=Et.createFramebuffer(),Yt=Et.createFramebuffer();this.copyTextureToTexture=function(t,e,n=null,i=null,r=0,a=0){let s,o,l,c,h,d,u,p,m;const f=t.isCompressedTexture?t.mipmaps[a]:t.image;if(null!==n)s=n.max.x-n.min.x,o=n.max.y-n.min.y,l=n.isBox3?n.max.z-n.min.z:1,c=n.min.x,h=n.min.y,d=n.isBox3?n.min.z:0;else{const e=Math.pow(2,-r);s=Math.floor(f.width*e),o=Math.floor(f.height*e),l=t.isDataArrayTexture?f.depth:t.isData3DTexture?Math.floor(f.depth*e):1,c=0,h=0,d=0}null!==i?(u=i.x,p=i.y,m=i.z):(u=0,p=0,m=0);const g=St.convert(e.format),v=St.convert(e.type);let _;e.isData3DTexture?(st.setTexture3D(e,0),_=Et.TEXTURE_3D):e.isDataArrayTexture||e.isCompressedArrayTexture?(st.setTexture2DArray(e,0),_=Et.TEXTURE_2D_ARRAY):(st.setTexture2D(e,0),_=Et.TEXTURE_2D),it.activeTexture(Et.TEXTURE0),it.pixelStorei(Et.UNPACK_FLIP_Y_WEBGL,e.flipY),it.pixelStorei(Et.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),it.pixelStorei(Et.UNPACK_ALIGNMENT,e.unpackAlignment);const y=it.getParameter(Et.UNPACK_ROW_LENGTH),x=it.getParameter(Et.UNPACK_IMAGE_HEIGHT),b=it.getParameter(Et.UNPACK_SKIP_PIXELS),S=it.getParameter(Et.UNPACK_SKIP_ROWS),M=it.getParameter(Et.UNPACK_SKIP_IMAGES);it.pixelStorei(Et.UNPACK_ROW_LENGTH,f.width),it.pixelStorei(Et.UNPACK_IMAGE_HEIGHT,f.height),it.pixelStorei(Et.UNPACK_SKIP_PIXELS,c),it.pixelStorei(Et.UNPACK_SKIP_ROWS,h),it.pixelStorei(Et.UNPACK_SKIP_IMAGES,d);const w=t.isDataArrayTexture||t.isData3DTexture,E=e.isDataArrayTexture||e.isData3DTexture;if(t.isDepthTexture){const n=at.get(t),i=at.get(e),f=at.get(n.__renderTarget),g=at.get(i.__renderTarget);it.bindFramebuffer(Et.READ_FRAMEBUFFER,f.__webglFramebuffer),it.bindFramebuffer(Et.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n<l;n++)w&&(Et.framebufferTextureLayer(Et.READ_FRAMEBUFFER,Et.COLOR_ATTACHMENT0,at.get(t).__webglTexture,r,d+n),Et.framebufferTextureLayer(Et.DRAW_FRAMEBUFFER,Et.COLOR_ATTACHMENT0,at.get(e).__webglTexture,a,m+n)),Et.blitFramebuffer(c,h,s,o,u,p,s,o,Et.DEPTH_BUFFER_BIT,Et.NEAREST);it.bindFramebuffer(Et.READ_FRAMEBUFFER,null),it.bindFramebuffer(Et.DRAW_FRAMEBUFFER,null)}else if(0!==r||t.isRenderTargetTexture||at.has(t)){const n=at.get(t),i=at.get(e);it.bindFramebuffer(Et.READ_FRAMEBUFFER,qt),it.bindFramebuffer(Et.DRAW_FRAMEBUFFER,Yt);for(let t=0;t<l;t++)w?Et.framebufferTextureLayer(Et.READ_FRAMEBUFFER,Et.COLOR_ATTACHMENT0,n.__webglTexture,r,d+t):Et.framebufferTexture2D(Et.READ_FRAMEBUFFER,Et.COLOR_ATTACHMENT0,Et.TEXTURE_2D,n.__webglTexture,r),E?Et.framebufferTextureLayer(Et.DRAW_FRAMEBUFFER,Et.COLOR_ATTACHMENT0,i.__webglTexture,a,m+t):Et.framebufferTexture2D(Et.DRAW_FRAMEBUFFER,Et.COLOR_ATTACHMENT0,Et.TEXTURE_2D,i.__webglTexture,a),0!==r?Et.blitFramebuffer(c,h,s,o,u,p,s,o,Et.COLOR_BUFFER_BIT,Et.NEAREST):E?Et.copyTexSubImage3D(_,a,u,p,m+t,c,h,s,o):Et.copyTexSubImage2D(_,a,u,p,c,h,s,o);it.bindFramebuffer(Et.READ_FRAMEBUFFER,null),it.bindFramebuffer(Et.DRAW_FRAMEBUFFER,null)}else E?t.isDataTexture||t.isData3DTexture?Et.texSubImage3D(_,a,u,p,m,s,o,l,g,v,f.data):e.isCompressedArrayTexture?Et.compressedTexSubImage3D(_,a,u,p,m,s,o,l,g,f.data):Et.texSubImage3D(_,a,u,p,m,s,o,l,g,v,f):t.isDataTexture?Et.texSubImage2D(Et.TEXTURE_2D,a,u,p,s,o,g,v,f.data):t.isCompressedTexture?Et.compressedTexSubImage2D(Et.TEXTURE_2D,a,u,p,f.width,f.height,g,f.data):Et.texSubImage2D(Et.TEXTURE_2D,a,u,p,s,o,g,v,f);it.pixelStorei(Et.UNPACK_ROW_LENGTH,y),it.pixelStorei(Et.UNPACK_IMAGE_HEIGHT,x),it.pixelStorei(Et.UNPACK_SKIP_PIXELS,b),it.pixelStorei(Et.UNPACK_SKIP_ROWS,S),it.pixelStorei(Et.UNPACK_SKIP_IMAGES,M),0===a&&e.generateMipmaps&&Et.generateMipmap(_),it.unbindTexture()},this.initRenderTarget=function(t){void 0===at.get(t).__webglFramebuffer&&st.setupRenderTarget(t)},this.initTexture=function(t){t.isCubeTexture?st.setTextureCube(t,0):t.isData3DTexture?st.setTexture3D(t,0):t.isDataArrayTexture||t.isCompressedArrayTexture?st.setTexture2DArray(t,0):st.setTexture2D(t,0),it.unbindTexture()},this.resetState=function(){C=0,R=0,I=null,it.reset(),Mt.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ti}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=Oi._getDrawingBufferColorSpace(t),e.unpackColorSpace=Oi._getUnpackColorSpace()}}
|
|
99
|
+
function fd(){let t=null,e=!1,n=null,i=null;function r(e,a){n(e,a),i=t.requestAnimationFrame(r)}return{start:function(){!0!==e&&null!==n&&null!==t&&(i=t.requestAnimationFrame(r),e=!0)},stop:function(){null!==t&&t.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(t){n=t},setContext:function(e){t=e}}}function gd(t){const e=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),e.get(t)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);const i=e.get(n);i&&(t.deleteBuffer(i.buffer),e.delete(n))},update:function(n,i){if(n.isInterleavedBufferAttribute&&(n=n.data),n.isGLBufferAttribute){const t=e.get(n);return void((!t||t.version<n.version)&&e.set(n,{buffer:n.buffer,type:n.type,bytesPerElement:n.elementSize,version:n.version}))}const r=e.get(n);if(void 0===r)e.set(n,function(e,n){const i=e.array,r=e.usage,a=i.byteLength,s=t.createBuffer();let o;if(t.bindBuffer(n,s),t.bufferData(n,i,r),e.onUploadCallback(),i instanceof Float32Array)o=t.FLOAT;else if("undefined"!=typeof Float16Array&&i instanceof Float16Array)o=t.HALF_FLOAT;else if(i instanceof Uint16Array)o=e.isFloat16BufferAttribute?t.HALF_FLOAT:t.UNSIGNED_SHORT;else if(i instanceof Int16Array)o=t.SHORT;else if(i instanceof Uint32Array)o=t.UNSIGNED_INT;else if(i instanceof Int32Array)o=t.INT;else if(i instanceof Int8Array)o=t.BYTE;else if(i instanceof Uint8Array)o=t.UNSIGNED_BYTE;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+i);o=t.UNSIGNED_BYTE}return{buffer:s,type:o,bytesPerElement:i.BYTES_PER_ELEMENT,version:e.version,size:a}}(n,i));else if(r.version<n.version){if(r.size!==n.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");!function(e,n,i){const r=n.array,a=n.updateRanges;if(t.bindBuffer(i,e),0===a.length)t.bufferSubData(i,0,r);else{a.sort(((t,e)=>t.start-e.start));let e=0;for(let t=1;t<a.length;t++){const n=a[e],i=a[t];i.start<=n.start+n.count+1?n.count=Math.max(n.count,i.start+i.count-n.start):(++e,a[e]=i)}a.length=e+1;for(let e=0,n=a.length;e<n;e++){const n=a[e];t.bufferSubData(i,n.start*r.BYTES_PER_ELEMENT,r,n.start,n.count)}n.clearUpdateRanges()}n.onUploadCallback()}(r.buffer,n,i),r.version=n.version}}}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:xt}})),"undefined"!=typeof window&&(window.__THREE__?hi("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=xt);const vd={alphahash_fragment:"#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\t#ifdef ALPHA_TO_COVERAGE\n\tdiffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\tif ( diffuseColor.a < alphaTest ) discard;\n\t#endif\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n\t#if ! defined( GL_ANGLE_multi_draw )\n\t#define gl_DrawID _gl_DrawID\n\tuniform int _gl_DrawID;\n\t#endif\n\tuniform highp sampler2D batchingTexture;\n\tuniform highp usampler2D batchingIdTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n\tfloat getIndirectIndex( const in int i ) {\n\t\tint size = textureSize( batchingIdTexture, 0 ).x;\n\t\tint x = i % size;\n\t\tint y = i / size;\n\t\treturn float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n\t}\n#endif\n#ifdef USE_BATCHING_COLOR\n\tuniform sampler2D batchingColorTexture;\n\tvec4 getBatchingColor( const in float i ) {\n\t\tint size = textureSize( batchingColorTexture, 0 ).x;\n\t\tint j = int( i );\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\treturn texelFetch( batchingColorTexture, ivec2( x, y ), 0 );\n\t}\n#endif",batching_vertex:"#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n\t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec4 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec4( 1.0 );\n#endif\n#ifdef USE_COLOR_ALPHA\n\tvColor *= color;\n#elif defined( USE_COLOR )\n\tvColor.rgb *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.rgb *= instanceColor.rgb;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n\t\temissiveColor = sRGBTransferEOTF( emissiveColor );\n\t#endif\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * reflectVec );\n\t\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t\t#endif\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif\n#include <lightprobes_pars_fragment>",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.metalness = metalnessFactor;\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;\n\tmaterial.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = vec3( 0.04 );\n\tmaterial.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tvec3 diffuseContribution;\n\tvec3 specularColor;\n\tvec3 specularColorBlended;\n\tfloat roughness;\n\tfloat metalness;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t\tvec3 iridescenceFresnelDielectric;\n\t\tvec3 iridescenceFresnelMetallic;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\treturn 0.5 / max( gv + gl, EPSILON );\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColorBlended;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat rInv = 1.0 / ( roughness + 0.1 );\n\tfloat a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n\tfloat b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n\tfloat DG = exp( a * dotNV + b );\n\treturn saturate( DG );\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;\n\tvec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;\n\tvec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;\n\tvec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;\n\tfloat Ess_V = dfgV.x + dfgV.y;\n\tfloat Ess_L = dfgL.x + dfgL.y;\n\tfloat Ems_V = 1.0 - Ess_V;\n\tfloat Ems_L = 1.0 - Ess_L;\n\tvec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;\n\tvec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );\n\tfloat compensationFactor = Ems_V * Ems_L;\n\tvec3 multiScatter = Fms * compensationFactor;\n\treturn singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t\t#ifdef USE_CLEARCOAT\n\t\t\tvec3 Ncc = geometryClearcoatNormal;\n\t\t\tvec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness );\n\t\t\tvec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat );\n\t\t\tvec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat );\n\t\t\tmat3 mInvClearcoat = mat3(\n\t\t\t\tvec3( t1Clearcoat.x, 0, t1Clearcoat.y ),\n\t\t\t\tvec3( 0, 1, 0 ),\n\t\t\t\tvec3( t1Clearcoat.z, 0, t1Clearcoat.w )\n\t\t\t);\n\t\t\tvec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y;\n\t\t\tclearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords );\n\t\t#endif\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n \n \t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n \t\tfloat sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n \t\tfloat sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n \t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n \t\tirradiance *= sheenEnergyComp;\n \n \t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );\n\t#ifdef USE_SHEEN\n\t\tfloat sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n\t\tdiffuse *= sheenEnergyComp;\n\t#endif\n\treflectedLight.indirectDiffuse += diffuse;\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n \t#endif\n\tvec3 singleScatteringDielectric = vec3( 0.0 );\n\tvec3 multiScatteringDielectric = vec3( 0.0 );\n\tvec3 singleScatteringMetallic = vec3( 0.0 );\n\tvec3 multiScatteringMetallic = vec3( 0.0 );\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n\t#endif\n\tvec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n\tvec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n\tvec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n\tvec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tvec3 indirectSpecular = radiance * singleScattering;\n\tindirectSpecular += multiScattering * cosineWeightedIrradiance;\n\tvec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n\t\tindirectSpecular *= sheenEnergyComp;\n\t\tindirectDiffuse *= sheenEnergyComp;\n\t#endif\n\treflectedLight.indirectSpecular += indirectSpecular;\n\treflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n\t\tmaterial.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#ifdef USE_LIGHT_PROBES_GRID\n\t\tvec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz;\n\t\tvec3 probeWorldNormal = inverseTransformDirection( geometryNormal, viewMatrix );\n\t\tirradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal );\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\t#if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG )\n\t\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t\t#endif\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\t#if defined( LAMBERT ) || defined( PHONG )\n\t\tirradiance += iblIrradiance;\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",lightprobes_pars_fragment:"#ifdef USE_LIGHT_PROBES_GRID\nuniform highp sampler3D probesSH;\nuniform vec3 probesMin;\nuniform vec3 probesMax;\nuniform vec3 probesResolution;\nvec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {\n\tvec3 res = probesResolution;\n\tvec3 gridRange = probesMax - probesMin;\n\tvec3 resMinusOne = res - 1.0;\n\tvec3 probeSpacing = gridRange / resMinusOne;\n\tvec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5;\n\tvec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 );\n\tuvw = uvw * resMinusOne / res + 0.5 / res;\n\tfloat nz = res.z;\n\tfloat paddedSlices = nz + 2.0;\n\tfloat atlasDepth = 7.0 * paddedSlices;\n\tfloat uvZBase = uvw.z * nz + 1.0;\n\tvec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) );\n\tvec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) );\n\tvec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) );\n\tvec3 c0 = s0.xyz;\n\tvec3 c1 = vec3( s0.w, s1.xy );\n\tvec3 c2 = vec3( s1.zw, s2.x );\n\tvec3 c3 = s2.yzw;\n\tvec3 c4 = s3.xyz;\n\tvec3 c5 = vec3( s3.w, s4.xy );\n\tvec3 c6 = vec3( s4.zw, s5.x );\n\tvec3 c7 = s5.yzw;\n\tvec3 c8 = s6.xyz;\n\tfloat x = worldNormal.x, y = worldNormal.y, z = worldNormal.z;\n\tvec3 result = c0 * 0.886227;\n\tresult += c1 * 2.0 * 0.511664 * y;\n\tresult += c2 * 2.0 * 0.511664 * z;\n\tresult += c3 * 2.0 * 0.511664 * x;\n\tresult += c4 * 2.0 * 0.429043 * x * y;\n\tresult += c5 * 2.0 * 0.429043 * y * z;\n\tresult += c6 * ( 0.743125 * z * z - 0.247708 );\n\tresult += c7 * 2.0 * 0.429043 * x * z;\n\tresult += c8 * 0.429043 * ( x * x - y * y );\n\treturn max( result, vec3( 0.0 ) );\n}\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#if defined( USE_PACKED_NORMALMAP )\n\t\tmapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) );\n\t#endif\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\n\t\treturn depth * ( far - near ) - far;\n\t#else\n\t\treturn depth * ( near - far ) - near;\n\t#endif\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\t\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\treturn ( near * far ) / ( ( near - far ) * depth - near );\n\t#else\n\t\treturn ( near * far ) / ( ( far - near ) * depth - far );\n\t#endif\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\t#else\n\t\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\t#else\n\t\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\t#elif defined( SHADOWMAP_TYPE_BASIC )\n\t\t\tuniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\tfloat interleavedGradientNoise( vec2 position ) {\n\t\t\treturn fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );\n\t\t}\n\t\tvec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {\n\t\t\tconst float goldenAngle = 2.399963229728653;\n\t\t\tfloat r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );\n\t\t\tfloat theta = float( sampleIndex ) * goldenAngle + phi;\n\t\t\treturn vec2( cos( theta ), sin( theta ) ) * r;\n\t\t}\n\t#endif\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\tfloat getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\tshadowCoord.z += shadowBias;\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\t\tfloat radius = shadowRadius * texelSize.x;\n\t\t\t\tfloat phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )\n\t\t\t\t) * 0.2;\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tshadowCoord.z -= shadowBias;\n\t\t\t#else\n\t\t\t\tshadowCoord.z += shadowBias;\n\t\t\t#endif\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tvec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;\n\t\t\t\tfloat mean = distribution.x;\n\t\t\t\tfloat variance = distribution.y * distribution.y;\n\t\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\t\tfloat hard_shadow = step( mean, shadowCoord.z );\n\t\t\t\t#else\n\t\t\t\t\tfloat hard_shadow = step( shadowCoord.z, mean );\n\t\t\t\t#endif\n\t\t\t\t\n\t\t\t\tif ( hard_shadow == 1.0 ) {\n\t\t\t\t\tshadow = 1.0;\n\t\t\t\t} else {\n\t\t\t\t\tvariance = max( variance, 0.0000001 );\n\t\t\t\t\tfloat d = shadowCoord.z - mean;\n\t\t\t\t\tfloat p_max = variance / ( variance + d * d );\n\t\t\t\t\tp_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );\n\t\t\t\t\tshadow = max( hard_shadow, p_max );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#else\n\t\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tshadowCoord.z -= shadowBias;\n\t\t\t#else\n\t\t\t\tshadowCoord.z += shadowBias;\n\t\t\t#endif\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tfloat depth = texture2D( shadowMap, shadowCoord.xy ).r;\n\t\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\t\tshadow = step( depth, shadowCoord.z );\n\t\t\t\t#else\n\t\t\t\t\tshadow = step( shadowCoord.z, depth );\n\t\t\t\t#endif\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\tfloat getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tvec3 absVec = abs( lightToPosition );\n\t\tfloat viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\t\tif ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tfloat dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\t\tdp -= shadowBias;\n\t\t\t#else\n\t\t\t\tfloat dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\t\tdp += shadowBias;\n\t\t\t#endif\n\t\t\tfloat texelSize = shadowRadius / shadowMapSize.x;\n\t\t\tvec3 absDir = abs( bd3D );\n\t\t\tvec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );\n\t\t\ttangent = normalize( cross( bd3D, tangent ) );\n\t\t\tvec3 bitangent = cross( bd3D, tangent );\n\t\t\tfloat phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n\t\t\tvec2 sample0 = vogelDiskSample( 0, 5, phi );\n\t\t\tvec2 sample1 = vogelDiskSample( 1, 5, phi );\n\t\t\tvec2 sample2 = vogelDiskSample( 2, 5, phi );\n\t\t\tvec2 sample3 = vogelDiskSample( 3, 5, phi );\n\t\t\tvec2 sample4 = vogelDiskSample( 4, 5, phi );\n\t\t\tshadow = (\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) )\n\t\t\t) * 0.2;\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\t#elif defined( SHADOWMAP_TYPE_BASIC )\n\tfloat getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 absVec = abs( lightToPosition );\n\t\tfloat viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\t\tif ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tfloat depth = textureCube( shadowMap, bd3D ).r;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tdepth = 1.0 - depth;\n\t\t\t#endif\n\t\t\tshadow = step( dp, depth );\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\t#endif\n\t#endif\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\t#ifdef HAS_NORMAL\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t#else\n\t\tvec3 shadowWorldNormal = vec3( 0.0 );\n\t#endif\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t#else\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",depth_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\tfloat fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];\n\t#else\n\t\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;\n\t#endif\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}",distance_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distance_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n \n\t\toutgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;\n \n \t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix[ 3 ];\n\tvec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}"},_d={common:{diffuse:{value:new Dr(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Pi},alphaMap:{value:null},alphaMapTransform:{value:new Pi},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Pi}},envmap:{envMap:{value:null},envMapRotation:{value:new Pi},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Pi}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Pi}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Pi},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Pi},normalScale:{value:new Ti(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Pi},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Pi}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Pi}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Pi}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Dr(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new Ci},probesMax:{value:new Ci},probesResolution:{value:new Ci}},points:{diffuse:{value:new Dr(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Pi},alphaTest:{value:0},uvTransform:{value:new Pi}},sprite:{diffuse:{value:new Dr(16777215)},opacity:{value:1},center:{value:new Ti(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Pi},alphaMap:{value:null},alphaMapTransform:{value:new Pi},alphaTest:{value:0}}},yd={basic:{uniforms:xc([_d.common,_d.specularmap,_d.envmap,_d.aomap,_d.lightmap,_d.fog]),vertexShader:vd.meshbasic_vert,fragmentShader:vd.meshbasic_frag},lambert:{uniforms:xc([_d.common,_d.specularmap,_d.envmap,_d.aomap,_d.lightmap,_d.emissivemap,_d.bumpmap,_d.normalmap,_d.displacementmap,_d.fog,_d.lights,{emissive:{value:new Dr(0)},envMapIntensity:{value:1}}]),vertexShader:vd.meshlambert_vert,fragmentShader:vd.meshlambert_frag},phong:{uniforms:xc([_d.common,_d.specularmap,_d.envmap,_d.aomap,_d.lightmap,_d.emissivemap,_d.bumpmap,_d.normalmap,_d.displacementmap,_d.fog,_d.lights,{emissive:{value:new Dr(0)},specular:{value:new Dr(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:vd.meshphong_vert,fragmentShader:vd.meshphong_frag},standard:{uniforms:xc([_d.common,_d.envmap,_d.aomap,_d.lightmap,_d.emissivemap,_d.bumpmap,_d.normalmap,_d.displacementmap,_d.roughnessmap,_d.metalnessmap,_d.fog,_d.lights,{emissive:{value:new Dr(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:vd.meshphysical_vert,fragmentShader:vd.meshphysical_frag},toon:{uniforms:xc([_d.common,_d.aomap,_d.lightmap,_d.emissivemap,_d.bumpmap,_d.normalmap,_d.displacementmap,_d.gradientmap,_d.fog,_d.lights,{emissive:{value:new Dr(0)}}]),vertexShader:vd.meshtoon_vert,fragmentShader:vd.meshtoon_frag},matcap:{uniforms:xc([_d.common,_d.bumpmap,_d.normalmap,_d.displacementmap,_d.fog,{matcap:{value:null}}]),vertexShader:vd.meshmatcap_vert,fragmentShader:vd.meshmatcap_frag},points:{uniforms:xc([_d.points,_d.fog]),vertexShader:vd.points_vert,fragmentShader:vd.points_frag},dashed:{uniforms:xc([_d.common,_d.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:vd.linedashed_vert,fragmentShader:vd.linedashed_frag},depth:{uniforms:xc([_d.common,_d.displacementmap]),vertexShader:vd.depth_vert,fragmentShader:vd.depth_frag},normal:{uniforms:xc([_d.common,_d.bumpmap,_d.normalmap,_d.displacementmap,{opacity:{value:1}}]),vertexShader:vd.meshnormal_vert,fragmentShader:vd.meshnormal_frag},sprite:{uniforms:xc([_d.sprite,_d.fog]),vertexShader:vd.sprite_vert,fragmentShader:vd.sprite_frag},background:{uniforms:{uvTransform:{value:new Pi},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:vd.background_vert,fragmentShader:vd.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Pi}},vertexShader:vd.backgroundCube_vert,fragmentShader:vd.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:vd.cube_vert,fragmentShader:vd.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:vd.equirect_vert,fragmentShader:vd.equirect_frag},distance:{uniforms:xc([_d.common,_d.displacementmap,{referencePosition:{value:new Ci},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:vd.distance_vert,fragmentShader:vd.distance_frag},shadow:{uniforms:xc([_d.lights,_d.fog,{color:{value:new Dr(0)},opacity:{value:1}}]),vertexShader:vd.shadow_vert,fragmentShader:vd.shadow_frag}};yd.physical={uniforms:xc([yd.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Pi},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Pi},clearcoatNormalScale:{value:new Ti(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Pi},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Pi},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Pi},sheen:{value:0},sheenColor:{value:new Dr(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Pi},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Pi},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Pi},transmissionSamplerSize:{value:new Ti},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Pi},attenuationDistance:{value:0},attenuationColor:{value:new Dr(0)},specularColor:{value:new Dr(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Pi},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Pi},anisotropyVector:{value:new Ti},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Pi}}]),vertexShader:vd.meshphysical_vert,fragmentShader:vd.meshphysical_frag};const xd={r:0,b:0,g:0},bd=new Ki,Sd=new Pi;function Md(t,e,n,i,r,a){const s=new Dr(0);let o,l,c=!0===r?0:1,h=null,d=0,u=null;function p(t){let n=!0===t.isScene?t.background:null;if(n&&n.isTexture){const i=t.backgroundBlurriness>0;n=e.get(n,i)}return n}function m(e,i){e.getRGB(xd,Sc(t)),n.buffers.color.setClear(xd.r,xd.g,xd.b,i,a)}return{getClearColor:function(){return s},setClearColor:function(t,e=1){s.set(t),c=e,m(s,c)},getClearAlpha:function(){return c},setClearAlpha:function(t){c=t,m(s,c)},render:function(e){let i=!1;const r=p(e);null===r?m(s,c):r&&r.isColor&&(m(r,1),i=!0);const o=t.xr.getEnvironmentBlendMode();"additive"===o?n.buffers.color.setClear(0,0,0,1,a):"alpha-blend"===o&&n.buffers.color.setClear(0,0,0,0,a),(t.autoClear||i)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))},addToRenderList:function(e,n){const r=p(n);r&&(r.isCubeTexture||r.mapping===_e)?(void 0===l&&(l=new Ss(new $o(1,1,1),new wc({name:"BackgroundCubeMaterial",uniforms:yc(yd.backgroundCube.uniforms),vertexShader:yd.backgroundCube.vertexShader,fragmentShader:yd.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(t,e,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l)),l.material.uniforms.envMap.value=r,l.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(bd.makeRotationFromEuler(n.backgroundRotation)).transpose(),r.isCubeTexture&&!1===r.isRenderTargetTexture&&l.material.uniforms.backgroundRotation.value.premultiply(Sd),l.material.toneMapped=Ui.getTransfer(r.colorSpace)!==Hn,h===r&&d===r.version&&u===t.toneMapping||(l.material.needsUpdate=!0,h=r,d=r.version,u=t.toneMapping),l.layers.enableAll(),e.unshift(l,l.geometry,l.material,0,0,null)):r&&r.isTexture&&(void 0===o&&(o=new Ss(new lc(2,2),new wc({name:"BackgroundMaterial",uniforms:yc(yd.background.uniforms),vertexShader:yd.background.vertexShader,fragmentShader:yd.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),o.geometry.deleteAttribute("normal"),Object.defineProperty(o.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(o)),o.material.uniforms.t2D.value=r,o.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,o.material.toneMapped=Ui.getTransfer(r.colorSpace)!==Hn,!0===r.matrixAutoUpdate&&r.updateMatrix(),o.material.uniforms.uvTransform.value.copy(r.matrix),h===r&&d===r.version&&u===t.toneMapping||(o.material.needsUpdate=!0,h=r,d=r.version,u=t.toneMapping),o.layers.enableAll(),e.unshift(o,o.geometry,o.material,0,0,null))},dispose:function(){void 0!==l&&(l.geometry.dispose(),l.material.dispose(),l=void 0),void 0!==o&&(o.geometry.dispose(),o.material.dispose(),o=void 0)}}}function wd(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),i={},r=c(null);let a=r,s=!1;function o(e){return t.bindVertexArray(e)}function l(e){return t.deleteVertexArray(e)}function c(t){const e=[],i=[],r=[];for(let t=0;t<n;t++)e[t]=0,i[t]=0,r[t]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:e,enabledAttributes:i,attributeDivisors:r,object:t,attributes:{},index:null}}function h(){const t=a.newAttributes;for(let e=0,n=t.length;e<n;e++)t[e]=0}function d(t){u(t,0)}function u(e,n){const i=a.newAttributes,r=a.enabledAttributes,s=a.attributeDivisors;i[e]=1,0===r[e]&&(t.enableVertexAttribArray(e),r[e]=1),s[e]!==n&&(t.vertexAttribDivisor(e,n),s[e]=n)}function p(){const e=a.newAttributes,n=a.enabledAttributes;for(let i=0,r=n.length;i<r;i++)n[i]!==e[i]&&(t.disableVertexAttribArray(i),n[i]=0)}function m(e,n,i,r,a,s,o){!0===o?t.vertexAttribIPointer(e,n,i,a,s):t.vertexAttribPointer(e,n,i,r,a,s)}function f(){g(),s=!0,a!==r&&(a=r,o(a.object))}function g(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:function(n,r,l,f,g){let v=!1;const _=function(e,n,r,a){const s=!0===a.wireframe;let o=i[n.id];void 0===o&&(o={},i[n.id]=o);const l=!0===e.isInstancedMesh?e.id:0;let h=o[l];void 0===h&&(h={},o[l]=h);let d=h[r.id];void 0===d&&(d={},h[r.id]=d);let u=d[s];return void 0===u&&(u=c(t.createVertexArray()),d[s]=u),u}(n,f,l,r);a!==_&&(a=_,o(a.object)),v=function(t,e,n,i){const r=a.attributes,s=e.attributes;let o=0;const l=n.getAttributes();for(const e in l)if(l[e].location>=0){const n=r[e];let i=s[e];if(void 0===i&&("instanceMatrix"===e&&t.instanceMatrix&&(i=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(i=t.instanceColor)),void 0===n)return!0;if(n.attribute!==i)return!0;if(i&&n.data!==i.data)return!0;o++}return a.attributesNum!==o||a.index!==i}(n,f,l,g),v&&function(t,e,n,i){const r={},s=e.attributes;let o=0;const l=n.getAttributes();for(const e in l)if(l[e].location>=0){let n=s[e];void 0===n&&("instanceMatrix"===e&&t.instanceMatrix&&(n=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(n=t.instanceColor));const i={};i.attribute=n,n&&n.data&&(i.data=n.data),r[e]=i,o++}a.attributes=r,a.attributesNum=o,a.index=i}(n,f,l,g),null!==g&&e.update(g,t.ELEMENT_ARRAY_BUFFER),(v||s)&&(s=!1,function(n,i,r,a){h();const s=a.attributes,o=r.getAttributes(),l=i.defaultAttributeValues;for(const i in o){const r=o[i];if(r.location>=0){let o=s[i];if(void 0===o&&("instanceMatrix"===i&&n.instanceMatrix&&(o=n.instanceMatrix),"instanceColor"===i&&n.instanceColor&&(o=n.instanceColor)),void 0!==o){const i=o.normalized,s=o.itemSize,l=e.get(o);if(void 0===l)continue;const c=l.buffer,h=l.type,p=l.bytesPerElement,f=h===t.INT||h===t.UNSIGNED_INT||o.gpuType===Le;if(o.isInterleavedBufferAttribute){const e=o.data,l=e.stride,g=o.offset;if(e.isInstancedInterleavedBuffer){for(let t=0;t<r.locationSize;t++)u(r.location+t,e.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===a._maxInstanceCount&&(a._maxInstanceCount=e.meshPerAttribute*e.count)}else for(let t=0;t<r.locationSize;t++)d(r.location+t);t.bindBuffer(t.ARRAY_BUFFER,c);for(let t=0;t<r.locationSize;t++)m(r.location+t,s/r.locationSize,h,i,l*p,(g+s/r.locationSize*t)*p,f)}else{if(o.isInstancedBufferAttribute){for(let t=0;t<r.locationSize;t++)u(r.location+t,o.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===a._maxInstanceCount&&(a._maxInstanceCount=o.meshPerAttribute*o.count)}else for(let t=0;t<r.locationSize;t++)d(r.location+t);t.bindBuffer(t.ARRAY_BUFFER,c);for(let t=0;t<r.locationSize;t++)m(r.location+t,s/r.locationSize,h,i,s*p,s/r.locationSize*t*p,f)}}else if(void 0!==l){const e=l[i];if(void 0!==e)switch(e.length){case 2:t.vertexAttrib2fv(r.location,e);break;case 3:t.vertexAttrib3fv(r.location,e);break;case 4:t.vertexAttrib4fv(r.location,e);break;default:t.vertexAttrib1fv(r.location,e)}}}}p()}(n,r,l,f),null!==g&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(g).buffer))},reset:f,resetDefaultState:g,dispose:function(){f();for(const t in i){const e=i[t];for(const t in e){const n=e[t];for(const t in n){const e=n[t];for(const t in e)l(e[t].object),delete e[t];delete n[t]}}delete i[t]}},releaseStatesOfGeometry:function(t){if(void 0===i[t.id])return;const e=i[t.id];for(const t in e){const n=e[t];for(const t in n){const e=n[t];for(const t in e)l(e[t].object),delete e[t];delete n[t]}}delete i[t.id]},releaseStatesOfObject:function(t){for(const e in i){const n=i[e],r=!0===t.isInstancedMesh?t.id:0,a=n[r];if(void 0!==a){for(const t in a){const e=a[t];for(const t in e)l(e[t].object),delete e[t];delete a[t]}delete n[r],0===Object.keys(n).length&&delete i[e]}}},releaseStatesOfProgram:function(t){for(const e in i){const n=i[e];for(const e in n){const i=n[e];if(void 0===i[t.id])continue;const r=i[t.id];for(const t in r)l(r[t].object),delete r[t];delete i[t.id]}}},initAttributes:h,enableAttribute:d,disableUnusedAttributes:p}}function Ed(t,e,n){let i;this.setMode=function(t){i=t},this.render=function(e,r){t.drawArrays(i,e,r),n.update(r,i,1)},this.renderInstances=function(e,r,a){0!==a&&(t.drawArraysInstanced(i,e,r,a),n.update(r,i,a))},this.renderMultiDraw=function(t,r,a){if(0===a)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,t,0,r,0,a);let s=0;for(let t=0;t<a;t++)s+=r[t];n.update(s,i,1)}}function Td(t,e,n,i){let r;function a(e){if("highp"===e){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let s=void 0!==n.precision?n.precision:"highp";const o=a(s);o!==s&&(hi("WebGLRenderer:",s,"not supported, using",o,"instead."),s=o);const l=!0===n.logarithmicDepthBuffer,c=!0===n.reversedDepthBuffer&&e.has("EXT_clip_control");return!0===n.reversedDepthBuffer&&!1===c&&hi("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer."),{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===e.has("EXT_texture_filter_anisotropic")){const n=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:a,textureFormatReadable:function(e){return e===Ge||i.convert(e)===t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(n){const r=n===Oe&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(n!==Ce&&i.convert(n)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&n!==Ne&&!r)},precision:s,logarithmicDepthBuffer:l,reversedDepthBuffer:c,maxTextures:t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),maxVertexTextures:t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:t.getParameter(t.MAX_TEXTURE_SIZE),maxCubemapSize:t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:t.getParameter(t.MAX_VERTEX_ATTRIBS),maxVertexUniforms:t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:t.getParameter(t.MAX_VARYING_VECTORS),maxFragmentUniforms:t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),maxSamples:t.getParameter(t.MAX_SAMPLES),samples:t.getParameter(t.SAMPLES)}}function Ad(t){const e=this;let n=null,i=0,r=!1,a=!1;const s=new Js,o=new Pi,l={value:null,needsUpdate:!1};function c(t,n,i,r){const a=null!==t?t.length:0;let c=null;if(0!==a){if(c=l.value,!0!==r||null===c){const e=i+4*a,r=n.matrixWorldInverse;o.getNormalMatrix(r),(null===c||c.length<e)&&(c=new Float32Array(e));for(let e=0,n=i;e!==a;++e,n+=4)s.copy(t[e]).applyMatrix4(r,o),s.normal.toArray(c,n),c[n+3]=s.constant}l.value=c,l.needsUpdate=!0}return e.numPlanes=a,e.numIntersection=0,c}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(t,e){const n=0!==t.length||e||0!==i||r;return r=e,i=t.length,n},this.beginShadows=function(){a=!0,c(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(t,e){n=c(t,e,0)},this.setState=function(s,o,h){const d=s.clippingPlanes,u=s.clipIntersection,p=s.clipShadows,m=t.get(s);if(!r||null===d||0===d.length||a&&!p)a?c(null):(l.value!==n&&(l.value=n,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0);else{const t=a?0:i,e=4*t;let r=m.clippingState||null;l.value=r,r=c(d,o,e,h);for(let t=0;t!==e;++t)r[t]=n[t];m.clippingState=r,this.numIntersection=u?this.numPlanes:0,this.numPlanes+=t}}}Sd.set(-1,0,0,0,1,0,0,0,1);const Cd=[.125,.215,.35,.446,.526,.582],Rd=20,Id=new Rh,Pd=new Dr;let Ld=null,Dd=0,Nd=0,Od=!1;const Ud=new Ci;class Fd{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(t,e=0,n=.1,i=100,r={}){const{size:a=256,position:s=Ud}=r;Ld=this._renderer.getRenderTarget(),Dd=this._renderer.getActiveCubeFace(),Nd=this._renderer.getActiveMipmapLevel(),Od=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const o=this._allocateTargets();return o.depthBuffer=!0,this._sceneToCubeUV(t,n,i,o,s),e>0&&this._blur(o,0,0,e),this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Gd(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Bd(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._ggxMaterial&&this._ggxMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodMeshes.length;t++)this._lodMeshes[t].geometry.dispose()}_cleanup(t){this._renderer.setRenderTarget(Ld,Dd,Nd),this._renderer.xr.enabled=Od,t.scissorTest=!1,kd(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===me||t.mapping===fe?this._setSize(0===t.image.length?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Ld=this._renderer.getRenderTarget(),Dd=this._renderer.getActiveCubeFace(),Nd=this._renderer.getActiveMipmapLevel(),Od=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:Ee,minFilter:Ee,generateMipmaps:!1,type:Oe,format:Ge,colorSpace:Gn,depthBuffer:!1},i=zd(t,e,n);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=zd(t,e,n);const{_lodMax:i}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=function(t){const e=[],n=[],i=[];let r=t;const a=t-4+1+Cd.length;for(let s=0;s<a;s++){const a=Math.pow(2,r);e.push(a);let o=1/a;s>t-4?o=Cd[s-t+4-1]:0===s&&(o=0),n.push(o);const l=1/(a-2),c=-l,h=1+l,d=[c,c,h,c,h,h,c,c,h,h,c,h],u=6,p=6,m=3,f=2,g=1,v=new Float32Array(m*p*u),_=new Float32Array(f*p*u),y=new Float32Array(g*p*u);for(let t=0;t<u;t++){const e=t%3*2/3-1,n=t>2?0:-1,i=[e,n,0,e+2/3,n,0,e+2/3,n+1,0,e,n,0,e+2/3,n+1,0,e,n+1,0];v.set(i,m*p*t),_.set(d,f*p*t);const r=[t,t,t,t,t,t];y.set(r,g*p*t)}const x=new Pa;x.setAttribute("position",new ga(v,m)),x.setAttribute("uv",new ga(_,f)),x.setAttribute("faceIndex",new ga(y,g)),i.push(new Ss(x,null)),r>4&&r--}return{lodMeshes:i,sizeLods:e,sigmas:n}}(i)),this._blurMaterial=function(t,e,n){const i=new Float32Array(Rd),r=new Ci(0,1,0),a=new wc({name:"SphericalGaussianBlur",defines:{n:Rd,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1});return a}(i,t,e),this._ggxMaterial=function(t,e,n){const i=new wc({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:256,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:'\n\n\t\t\tprecision highp float;\n\t\t\tprecision highp int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform float roughness;\n\t\t\tuniform float mipInt;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\t#define PI 3.14159265359\n\n\t\t\t// Van der Corput radical inverse\n\t\t\tfloat radicalInverse_VdC(uint bits) {\n\t\t\t\tbits = (bits << 16u) | (bits >> 16u);\n\t\t\t\tbits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);\n\t\t\t\tbits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);\n\t\t\t\tbits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);\n\t\t\t\tbits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);\n\t\t\t\treturn float(bits) * 2.3283064365386963e-10; // / 0x100000000\n\t\t\t}\n\n\t\t\t// Hammersley sequence\n\t\t\tvec2 hammersley(uint i, uint N) {\n\t\t\t\treturn vec2(float(i) / float(N), radicalInverse_VdC(i));\n\t\t\t}\n\n\t\t\t// GGX VNDF importance sampling (Eric Heitz 2018)\n\t\t\t// "Sampling the GGX Distribution of Visible Normals"\n\t\t\t// https://jcgt.org/published/0007/04/01/\n\t\t\tvec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {\n\t\t\t\tfloat alpha = roughness * roughness;\n\n\t\t\t\t// Section 4.1: Orthonormal basis\n\t\t\t\tvec3 T1 = vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 T2 = cross(V, T1);\n\n\t\t\t\t// Section 4.2: Parameterization of projected area\n\t\t\t\tfloat r = sqrt(Xi.x);\n\t\t\t\tfloat phi = 2.0 * PI * Xi.y;\n\t\t\t\tfloat t1 = r * cos(phi);\n\t\t\t\tfloat t2 = r * sin(phi);\n\t\t\t\tfloat s = 0.5 * (1.0 + V.z);\n\t\t\t\tt2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;\n\n\t\t\t\t// Section 4.3: Reprojection onto hemisphere\n\t\t\t\tvec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V;\n\n\t\t\t\t// Section 3.4: Transform back to ellipsoid configuration\n\t\t\t\treturn normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));\n\t\t\t}\n\n\t\t\tvoid main() {\n\t\t\t\tvec3 N = normalize(vOutputDirection);\n\t\t\t\tvec3 V = N; // Assume view direction equals normal for pre-filtering\n\n\t\t\t\tvec3 prefilteredColor = vec3(0.0);\n\t\t\t\tfloat totalWeight = 0.0;\n\n\t\t\t\t// For very low roughness, just sample the environment directly\n\t\t\t\tif (roughness < 0.001) {\n\t\t\t\t\tgl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Tangent space basis for VNDF sampling\n\t\t\t\tvec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 tangent = normalize(cross(up, N));\n\t\t\t\tvec3 bitangent = cross(N, tangent);\n\n\t\t\t\tfor(uint i = 0u; i < uint(GGX_SAMPLES); i++) {\n\t\t\t\t\tvec2 Xi = hammersley(i, uint(GGX_SAMPLES));\n\n\t\t\t\t\t// For PMREM, V = N, so in tangent space V is always (0, 0, 1)\n\t\t\t\t\tvec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);\n\n\t\t\t\t\t// Transform H back to world space\n\t\t\t\t\tvec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);\n\t\t\t\t\tvec3 L = normalize(2.0 * dot(V, H) * H - V);\n\n\t\t\t\t\tfloat NdotL = max(dot(N, L), 0.0);\n\n\t\t\t\t\tif(NdotL > 0.0) {\n\t\t\t\t\t\t// Sample environment at fixed mip level\n\t\t\t\t\t\t// VNDF importance sampling handles the distribution filtering\n\t\t\t\t\t\tvec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);\n\n\t\t\t\t\t\t// Weight by NdotL for the split-sum approximation\n\t\t\t\t\t\t// VNDF PDF naturally accounts for the visible microfacet distribution\n\t\t\t\t\t\tprefilteredColor += sampleColor * NdotL;\n\t\t\t\t\t\ttotalWeight += NdotL;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (totalWeight > 0.0) {\n\t\t\t\t\tprefilteredColor = prefilteredColor / totalWeight;\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = vec4(prefilteredColor, 1.0);\n\t\t\t}\n\t\t',blending:0,depthTest:!1,depthWrite:!1});return i}(i,t,e)}return i}_compileMaterial(t){const e=new Ss(new Pa,t);this._renderer.compile(e,Id)}_sceneToCubeUV(t,e,n,i,r){const a=new wh(90,1,e,n),s=[1,-1,1,1,1,1],o=[1,1,1,-1,-1,-1],l=this._renderer,c=l.autoClear,h=l.toneMapping;l.getClearColor(Pd),l.toneMapping=0,l.autoClear=!1,l.state.buffers.depth.getReversed()&&(l.setRenderTarget(i),l.clearDepth(),l.setRenderTarget(null)),null===this._backgroundBox&&(this._backgroundBox=new Ss(new $o,new hs({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1})));const d=this._backgroundBox,u=d.material;let p=!1;const m=t.background;m?m.isColor&&(u.color.copy(m),t.background=null,p=!0):(u.color.copy(Pd),p=!0);for(let e=0;e<6;e++){const n=e%3;0===n?(a.up.set(0,s[e],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+o[e],r.y,r.z)):1===n?(a.up.set(0,0,s[e]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+o[e],r.z)):(a.up.set(0,s[e],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+o[e]));const c=this._cubeSize;kd(i,n*c,e>2?c:0,c,c),l.setRenderTarget(i),p&&l.render(d,a),l.render(t,a)}l.toneMapping=h,l.autoClear=c,t.background=m}_textureToCubeUV(t,e){const n=this._renderer,i=t.mapping===me||t.mapping===fe;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=Gd()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===t.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=Bd());const r=i?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r,r.uniforms.envMap.value=t;const s=this._cubeSize;kd(e,0,0,3*s,2*s),n.setRenderTarget(e),n.render(a,Id)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const i=this._lodMeshes.length;for(let e=1;e<i;e++)this._applyGGXFilter(t,e-1,e);e.autoClear=n}_applyGGXFilter(t,e,n){const i=this._renderer,r=this._pingPongRenderTarget,a=this._ggxMaterial,s=this._lodMeshes[n];s.material=a;const o=a.uniforms,l=n/(this._lodMeshes.length-1),c=e/(this._lodMeshes.length-1),h=Math.sqrt(l*l-c*c)*(0+1.25*l),{_lodMax:d}=this,u=this._sizeLods[n],p=3*u*(n>d-4?n-d+4:0),m=4*(this._cubeSize-u);o.envMap.value=t.texture,o.roughness.value=h,o.mipInt.value=d-e,kd(r,p,m,3*u,2*u),i.setRenderTarget(r),i.render(s,Id),o.envMap.value=r.texture,o.roughness.value=0,o.mipInt.value=d-n,kd(t,p,m,3*u,2*u),i.setRenderTarget(t),i.render(s,Id)}_blur(t,e,n,i,r){const a=this._pingPongRenderTarget;this._halfBlur(t,a,e,n,i,"latitudinal",r),this._halfBlur(a,t,n,n,i,"longitudinal",r)}_halfBlur(t,e,n,i,r,a,s){const o=this._renderer,l=this._blurMaterial;"latitudinal"!==a&&"longitudinal"!==a&&di("blur direction must be either latitudinal or longitudinal!");const c=this._lodMeshes[i];c.material=l;const h=l.uniforms,d=this._sizeLods[n]-1,u=isFinite(r)?Math.PI/(2*d):2*Math.PI/39,p=r/u,m=isFinite(r)?1+Math.floor(3*p):Rd;m>Rd&&hi(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);const f=[];let g=0;for(let t=0;t<Rd;++t){const e=t/p,n=Math.exp(-e*e/2);f.push(n),0===t?g+=n:t<m&&(g+=2*n)}for(let t=0;t<f.length;t++)f[t]=f[t]/g;h.envMap.value=t.texture,h.samples.value=m,h.weights.value=f,h.latitudinal.value="latitudinal"===a,s&&(h.poleAxis.value=s);const{_lodMax:v}=this;h.dTheta.value=u,h.mipInt.value=v-n;const _=this._sizeLods[i];kd(e,3*_*(i>v-4?i-v+4:0),4*(this._cubeSize-_),3*_,2*_),o.setRenderTarget(e),o.render(c,Id)}}function zd(t,e,n){const i=new Zi(t,e,n);return i.texture.mapping=_e,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function kd(t,e,n,i,r){t.viewport.set(e,n,i,r),t.scissor.set(e,n,i,r)}function Bd(){return new wc({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Gd(){return new wc({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}class Vd extends Zi{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},i=[n,n,n,n,n,n];this.texture=new Xo(i),this._setTextureOptions(e),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},i=new $o(5,5,5),r=new wc({name:"CubemapFromEquirect",uniforms:yc(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});r.uniforms.tEquirect.value=e;const a=new Ss(i,r),s=e.minFilter;return e.minFilter===Ae&&(e.minFilter=Ee),new Xh(1,10,this).update(t,a),e.minFilter=s,a.geometry.dispose(),a.material.dispose(),this}clear(t,e=!0,n=!0,i=!0){const r=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,n,i);t.setRenderTarget(r)}}function Hd(t){let e=new WeakMap,n=new WeakMap,i=null;function r(t,e){return e===ge?t.mapping=me:e===ve&&(t.mapping=fe),t}function a(t){const n=t.target;n.removeEventListener("dispose",a);const i=e.get(n);void 0!==i&&(e.delete(n),i.dispose())}function s(t){const e=t.target;e.removeEventListener("dispose",s);const i=n.get(e);void 0!==i&&(n.delete(e),i.dispose())}return{get:function(o,l=!1){return null==o?null:l?function(e){if(e&&e.isTexture){const r=e.mapping,a=r===ge||r===ve,o=r===me||r===fe;if(a||o){let r=n.get(e);const l=void 0!==r?r.texture.pmremVersion:0;if(e.isRenderTargetTexture&&e.pmremVersion!==l)return null===i&&(i=new Fd(t)),r=a?i.fromEquirectangular(e,r):i.fromCubemap(e,r),r.texture.pmremVersion=e.pmremVersion,n.set(e,r),r.texture;if(void 0!==r)return r.texture;{const l=e.image;return a&&l&&l.height>0||o&&l&&function(t){let e=0;const n=6;for(let i=0;i<n;i++)void 0!==t[i]&&e++;return e===n}(l)?(null===i&&(i=new Fd(t)),r=a?i.fromEquirectangular(e):i.fromCubemap(e),r.texture.pmremVersion=e.pmremVersion,n.set(e,r),e.addEventListener("dispose",s),r.texture):null}}}return e}(o):function(n){if(n&&n.isTexture){const i=n.mapping;if(i===ge||i===ve){if(e.has(n))return r(e.get(n).texture,n.mapping);{const i=n.image;if(i&&i.height>0){const s=new Vd(i.height);return s.fromEquirectangularTexture(t,n),e.set(n,s),n.addEventListener("dispose",a),r(s.texture,n.mapping)}return null}}}return n}(o)},dispose:function(){e=new WeakMap,n=new WeakMap,null!==i&&(i.dispose(),i=null)}}}function Wd(t){const e={};function n(n){if(void 0!==e[n])return e[n];const i=t.getExtension(n);return e[n]=i,i}return{has:function(t){return null!==n(t)},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(t){const e=n(t);return null===e&&ui("WebGLRenderer: "+t+" extension not supported."),e}}}function jd(t,e,n,i){const r={},a=new WeakMap;function s(t){const o=t.target;null!==o.index&&e.remove(o.index);for(const t in o.attributes)e.remove(o.attributes[t]);o.removeEventListener("dispose",s),delete r[o.id];const l=a.get(o);l&&(e.remove(l),a.delete(o)),i.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,n.memory.geometries--}function o(t){const n=[],i=t.index,r=t.attributes.position;let s=0;if(void 0===r)return;if(null!==i){const t=i.array;s=i.version;for(let e=0,i=t.length;e<i;e+=3){const i=t[e+0],r=t[e+1],a=t[e+2];n.push(i,r,r,a,a,i)}}else{const t=r.array;s=r.version;for(let e=0,i=t.length/3-1;e<i;e+=3){const t=e+0,i=e+1,r=e+2;n.push(t,i,i,r,r,t)}}const o=new(r.count>=65535?_a:va)(n,1);o.version=s;const l=a.get(t);l&&e.remove(l),a.set(t,o)}return{get:function(t,e){return!0===r[e.id]||(e.addEventListener("dispose",s),r[e.id]=!0,n.memory.geometries++),e},update:function(n){const i=n.attributes;for(const n in i)e.update(i[n],t.ARRAY_BUFFER)},getWireframeAttribute:function(t){const e=a.get(t);if(e){const n=t.index;null!==n&&e.version<n.version&&o(t)}else o(t);return a.get(t)}}}function Xd(t,e,n){let i,r,a;this.setMode=function(t){i=t},this.setIndex=function(t){r=t.type,a=t.bytesPerElement},this.render=function(e,s){t.drawElements(i,s,r,e*a),n.update(s,i,1)},this.renderInstances=function(e,s,o){0!==o&&(t.drawElementsInstanced(i,s,r,e*a,o),n.update(s,i,o))},this.renderMultiDraw=function(t,a,s){if(0===s)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,a,0,r,t,0,s);let o=0;for(let t=0;t<s;t++)o+=a[t];n.update(o,i,1)}}function qd(t){const e={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:e,programs:null,autoReset:!0,reset:function(){e.calls=0,e.triangles=0,e.points=0,e.lines=0},update:function(n,i,r){switch(e.calls++,i){case t.TRIANGLES:e.triangles+=r*(n/3);break;case t.LINES:e.lines+=r*(n/2);break;case t.LINE_STRIP:e.lines+=r*(n-1);break;case t.LINE_LOOP:e.lines+=r*n;break;case t.POINTS:e.points+=r*n;break;default:di("WebGLInfo: Unknown draw mode:",i)}}}}function Yd(t,e,n){const i=new WeakMap,r=new qi;return{update:function(a,s,o){const l=a.morphTargetInfluences,c=s.morphAttributes.position||s.morphAttributes.normal||s.morphAttributes.color,h=void 0!==c?c.length:0;let d=i.get(s);if(void 0===d||d.count!==h){void 0!==d&&d.texture.dispose();const u=void 0!==s.morphAttributes.position,p=void 0!==s.morphAttributes.normal,m=void 0!==s.morphAttributes.color,f=s.morphAttributes.position||[],g=s.morphAttributes.normal||[],v=s.morphAttributes.color||[];let _=0;!0===u&&(_=1),!0===p&&(_=2),!0===m&&(_=3);let y=s.attributes.position.count*_,x=1;y>e.maxTextureSize&&(x=Math.ceil(y/e.maxTextureSize),y=e.maxTextureSize);const b=new Float32Array(y*x*4*h),S=new $i(b,y,x,h);S.type=Ne,S.needsUpdate=!0;const M=4*_;for(let E=0;E<h;E++){const T=f[E],A=g[E],C=v[E],R=y*x*4*E;for(let I=0;I<T.count;I++){const P=I*M;!0===u&&(r.fromBufferAttribute(T,I),b[R+P+0]=r.x,b[R+P+1]=r.y,b[R+P+2]=r.z,b[R+P+3]=0),!0===p&&(r.fromBufferAttribute(A,I),b[R+P+4]=r.x,b[R+P+5]=r.y,b[R+P+6]=r.z,b[R+P+7]=0),!0===m&&(r.fromBufferAttribute(C,I),b[R+P+8]=r.x,b[R+P+9]=r.y,b[R+P+10]=r.z,b[R+P+11]=4===C.itemSize?r.w:1)}}function w(){S.dispose(),i.delete(s),s.removeEventListener("dispose",w)}d={count:h,texture:S,size:new Ti(y,x)},i.set(s,d),s.addEventListener("dispose",w)}if(!0===a.isInstancedMesh&&null!==a.morphTexture)o.getUniforms().setValue(t,"morphTexture",a.morphTexture,n);else{let L=0;for(let N=0;N<l.length;N++)L+=l[N];const D=s.morphTargetsRelative?1:1-L;o.getUniforms().setValue(t,"morphTargetBaseInfluence",D),o.getUniforms().setValue(t,"morphTargetInfluences",l)}o.getUniforms().setValue(t,"morphTargetsTexture",d.texture,n),o.getUniforms().setValue(t,"morphTargetsTextureSize",d.size)}}}function Zd(t,e,n,i,r){let a=new WeakMap;function s(t){const e=t.target;e.removeEventListener("dispose",s),i.releaseStatesOfObject(e),n.remove(e.instanceMatrix),null!==e.instanceColor&&n.remove(e.instanceColor)}return{update:function(i){const o=r.render.frame,l=i.geometry,c=e.get(i,l);if(a.get(c)!==o&&(e.update(c),a.set(c,o)),i.isInstancedMesh&&(!1===i.hasEventListener("dispose",s)&&i.addEventListener("dispose",s),a.get(i)!==o&&(n.update(i.instanceMatrix,t.ARRAY_BUFFER),null!==i.instanceColor&&n.update(i.instanceColor,t.ARRAY_BUFFER),a.set(i,o))),i.isSkinnedMesh){const t=i.skeleton;a.get(t)!==o&&(t.update(),a.set(t,o))}return c},dispose:function(){a=new WeakMap}}}const $d={[se]:"LINEAR_TONE_MAPPING",[oe]:"REINHARD_TONE_MAPPING",[le]:"CINEON_TONE_MAPPING",[ce]:"ACES_FILMIC_TONE_MAPPING",[de]:"AGX_TONE_MAPPING",[ue]:"NEUTRAL_TONE_MAPPING",[he]:"CUSTOM_TONE_MAPPING"};function Jd(t,e,n,i,r){const a=new Zi(e,n,{type:t,depthBuffer:i,stencilBuffer:r,depthTexture:i?new qo(e,n):void 0}),s=new Zi(e,n,{type:Oe,depthBuffer:!1,stencilBuffer:!1}),o=new Pa;o.setAttribute("position",new ya([-1,3,0,-1,-1,0,3,-1,0],3)),o.setAttribute("uv",new ya([0,2,0,0,2,0],2));const l=new Ec({uniforms:{tDiffuse:{value:null}},vertexShader:"\n\t\t\tprecision highp float;\n\n\t\t\tuniform mat4 modelViewMatrix;\n\t\t\tuniform mat4 projectionMatrix;\n\n\t\t\tattribute vec3 position;\n\t\t\tattribute vec2 uv;\n\n\t\t\tvarying vec2 vUv;\n\n\t\t\tvoid main() {\n\t\t\t\tvUv = uv;\n\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t}",fragmentShader:"\n\t\t\tprecision highp float;\n\n\t\t\tuniform sampler2D tDiffuse;\n\n\t\t\tvarying vec2 vUv;\n\n\t\t\t#include <tonemapping_pars_fragment>\n\t\t\t#include <colorspace_pars_fragment>\n\n\t\t\tvoid main() {\n\t\t\t\tgl_FragColor = texture2D( tDiffuse, vUv );\n\n\t\t\t\t#ifdef LINEAR_TONE_MAPPING\n\t\t\t\t\tgl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( REINHARD_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( CINEON_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( ACES_FILMIC_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( AGX_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( NEUTRAL_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( CUSTOM_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );\n\t\t\t\t#endif\n\n\t\t\t\t#ifdef SRGB_TRANSFER\n\t\t\t\t\tgl_FragColor = sRGBTransferOETF( gl_FragColor );\n\t\t\t\t#endif\n\t\t\t}",depthTest:!1,depthWrite:!1}),c=new Ss(o,l),h=new Rh(-1,1,1,-1,0,1);let d,u=null,p=null,m=!1,f=null,g=[],v=!1;this.setSize=function(t,e){a.setSize(t,e),s.setSize(t,e);for(let n=0;n<g.length;n++){const i=g[n];i.setSize&&i.setSize(t,e)}},this.setEffects=function(t){g=t,v=g.length>0&&!0===g[0].isRenderPass;const e=a.width,n=a.height;for(let t=0;t<g.length;t++){const i=g[t];i.setSize&&i.setSize(e,n)}},this.begin=function(t,e){if(m)return!1;if(0===t.toneMapping&&0===g.length)return!1;if(f=e,null!==e){const t=e.width,n=e.height;a.width===t&&a.height===n||this.setSize(t,n)}return!1===v&&t.setRenderTarget(a),d=t.toneMapping,t.toneMapping=0,!0},this.hasRenderPass=function(){return v},this.end=function(t,e){t.toneMapping=d,m=!0;let n=a,i=s;for(let r=0;r<g.length;r++){const a=g[r];if(!1!==a.enabled&&(a.render(t,i,n,e),!1!==a.needsSwap)){const t=n;n=i,i=t}}if(u!==t.outputColorSpace||p!==t.toneMapping){u=t.outputColorSpace,p=t.toneMapping,l.defines={},Ui.getTransfer(u)===Hn&&(l.defines.SRGB_TRANSFER="");const e=$d[p];e&&(l.defines[e]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=n.texture,t.setRenderTarget(f),t.render(c,h),f=null,m=!1},this.isCompositing=function(){return m},this.dispose=function(){a.depthTexture&&a.depthTexture.dispose(),a.dispose(),s.dispose(),o.dispose(),l.dispose()}}const Kd=new Xi,Qd=new qo(1,1),tu=new $i,eu=new Ji,nu=new Xo,iu=[],ru=[],au=new Float32Array(16),su=new Float32Array(9),ou=new Float32Array(4);function lu(t,e,n){const i=t[0];if(i<=0||i>0)return t;const r=e*n;let a=iu[r];if(void 0===a&&(a=new Float32Array(r),iu[r]=a),0!==e){i.toArray(a,0);for(let i=1,r=0;i!==e;++i)r+=n,t[i].toArray(a,r)}return a}function cu(t,e){if(t.length!==e.length)return!1;for(let n=0,i=t.length;n<i;n++)if(t[n]!==e[n])return!1;return!0}function hu(t,e){for(let n=0,i=e.length;n<i;n++)t[n]=e[n]}function du(t,e){let n=ru[e];void 0===n&&(n=new Int32Array(e),ru[e]=n);for(let i=0;i!==e;++i)n[i]=t.allocateTextureUnit();return n}function uu(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function pu(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(cu(n,e))return;t.uniform2fv(this.addr,e),hu(n,e)}}function mu(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(void 0!==e.r)n[0]===e.r&&n[1]===e.g&&n[2]===e.b||(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(cu(n,e))return;t.uniform3fv(this.addr,e),hu(n,e)}}function fu(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(cu(n,e))return;t.uniform4fv(this.addr,e),hu(n,e)}}function gu(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(cu(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),hu(n,e)}else{if(cu(n,i))return;ou.set(i),t.uniformMatrix2fv(this.addr,!1,ou),hu(n,i)}}function vu(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(cu(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),hu(n,e)}else{if(cu(n,i))return;su.set(i),t.uniformMatrix3fv(this.addr,!1,su),hu(n,i)}}function _u(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(cu(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),hu(n,e)}else{if(cu(n,i))return;au.set(i),t.uniformMatrix4fv(this.addr,!1,au),hu(n,i)}}function yu(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function xu(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(cu(n,e))return;t.uniform2iv(this.addr,e),hu(n,e)}}function bu(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(cu(n,e))return;t.uniform3iv(this.addr,e),hu(n,e)}}function Su(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(cu(n,e))return;t.uniform4iv(this.addr,e),hu(n,e)}}function Mu(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function wu(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(cu(n,e))return;t.uniform2uiv(this.addr,e),hu(n,e)}}function Eu(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(cu(n,e))return;t.uniform3uiv(this.addr,e),hu(n,e)}}function Tu(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(cu(n,e))return;t.uniform4uiv(this.addr,e),hu(n,e)}}function Au(t,e,n){const i=this.cache,r=n.allocateTextureUnit();let a;i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),this.type===t.SAMPLER_2D_SHADOW?(Qd.compareFunction=n.isReversedDepthBuffer()?518:515,a=Qd):a=Kd,n.setTexture2D(e||a,r)}function Cu(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTexture3D(e||eu,r)}function Ru(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTextureCube(e||nu,r)}function Iu(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTexture2DArray(e||tu,r)}function Pu(t,e){t.uniform1fv(this.addr,e)}function Lu(t,e){const n=lu(e,this.size,2);t.uniform2fv(this.addr,n)}function Du(t,e){const n=lu(e,this.size,3);t.uniform3fv(this.addr,n)}function Nu(t,e){const n=lu(e,this.size,4);t.uniform4fv(this.addr,n)}function Ou(t,e){const n=lu(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function Uu(t,e){const n=lu(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function Fu(t,e){const n=lu(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function zu(t,e){t.uniform1iv(this.addr,e)}function ku(t,e){t.uniform2iv(this.addr,e)}function Bu(t,e){t.uniform3iv(this.addr,e)}function Gu(t,e){t.uniform4iv(this.addr,e)}function Vu(t,e){t.uniform1uiv(this.addr,e)}function Hu(t,e){t.uniform2uiv(this.addr,e)}function Wu(t,e){t.uniform3uiv(this.addr,e)}function ju(t,e){t.uniform4uiv(this.addr,e)}function Xu(t,e,n){const i=this.cache,r=e.length,a=du(n,r);let s;cu(i,a)||(t.uniform1iv(this.addr,a),hu(i,a)),s=this.type===t.SAMPLER_2D_SHADOW?Qd:Kd;for(let t=0;t!==r;++t)n.setTexture2D(e[t]||s,a[t])}function qu(t,e,n){const i=this.cache,r=e.length,a=du(n,r);cu(i,a)||(t.uniform1iv(this.addr,a),hu(i,a));for(let t=0;t!==r;++t)n.setTexture3D(e[t]||eu,a[t])}function Yu(t,e,n){const i=this.cache,r=e.length,a=du(n,r);cu(i,a)||(t.uniform1iv(this.addr,a),hu(i,a));for(let t=0;t!==r;++t)n.setTextureCube(e[t]||nu,a[t])}function Zu(t,e,n){const i=this.cache,r=e.length,a=du(n,r);cu(i,a)||(t.uniform1iv(this.addr,a),hu(i,a));for(let t=0;t!==r;++t)n.setTexture2DArray(e[t]||tu,a[t])}class $u{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=function(t){switch(t){case 5126:return uu;case 35664:return pu;case 35665:return mu;case 35666:return fu;case 35674:return gu;case 35675:return vu;case 35676:return _u;case 5124:case 35670:return yu;case 35667:case 35671:return xu;case 35668:case 35672:return bu;case 35669:case 35673:return Su;case 5125:return Mu;case 36294:return wu;case 36295:return Eu;case 36296:return Tu;case 35678:case 36198:case 36298:case 36306:case 35682:return Au;case 35679:case 36299:case 36307:return Cu;case 35680:case 36300:case 36308:case 36293:return Ru;case 36289:case 36303:case 36311:case 36292:return Iu}}(e.type)}}class Ju{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=function(t){switch(t){case 5126:return Pu;case 35664:return Lu;case 35665:return Du;case 35666:return Nu;case 35674:return Ou;case 35675:return Uu;case 35676:return Fu;case 5124:case 35670:return zu;case 35667:case 35671:return ku;case 35668:case 35672:return Bu;case 35669:case 35673:return Gu;case 5125:return Vu;case 36294:return Hu;case 36295:return Wu;case 36296:return ju;case 35678:case 36198:case 36298:case 36306:case 35682:return Xu;case 35679:case 36299:case 36307:return qu;case 35680:case 36300:case 36308:case 36293:return Yu;case 36289:case 36303:case 36311:case 36292:return Zu}}(e.type)}}class Ku{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){const i=this.seq;for(let r=0,a=i.length;r!==a;++r){const a=i[r];a.setValue(t,e[a.id],n)}}}const Qu=/(\w+)(\])?(\[|\.)?/g;function tp(t,e){t.seq.push(e),t.map[e.id]=e}function ep(t,e,n){const i=t.name,r=i.length;for(Qu.lastIndex=0;;){const a=Qu.exec(i),s=Qu.lastIndex;let o=a[1];const l="]"===a[2],c=a[3];if(l&&(o|=0),void 0===c||"["===c&&s+2===r){tp(n,void 0===c?new $u(o,t,e):new Ju(o,t,e));break}{let t=n.map[o];void 0===t&&(t=new Ku(o),tp(n,t)),n=t}}}class np{constructor(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){const n=t.getActiveUniform(e,i);ep(n,t.getUniformLocation(e,n.name),this)}const i=[],r=[];for(const e of this.seq)e.type===t.SAMPLER_2D_SHADOW||e.type===t.SAMPLER_CUBE_SHADOW||e.type===t.SAMPLER_2D_ARRAY_SHADOW?i.push(e):r.push(e);i.length>0&&(this.seq=i.concat(r))}setValue(t,e,n,i){const r=this.map[e];void 0!==r&&r.setValue(t,n,i)}setOptional(t,e,n){const i=e[n];void 0!==i&&this.setValue(t,n,i)}static upload(t,e,n,i){for(let r=0,a=e.length;r!==a;++r){const a=e[r],s=n[a.id];!1!==s.needsUpdate&&a.setValue(t,s.value,i)}}static seqWithValue(t,e){const n=[];for(let i=0,r=t.length;i!==r;++i){const r=t[i];r.id in e&&n.push(r)}return n}}function ip(t,e,n){const i=t.createShader(e);return t.shaderSource(i,n),t.compileShader(i),i}let rp=0;const ap=new Pi;function sp(t,e,n){const i=t.getShaderParameter(e,t.COMPILE_STATUS),r=(t.getShaderInfoLog(e)||"").trim();if(i&&""===r)return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const i=parseInt(a[1]);return n.toUpperCase()+"\n\n"+r+"\n\n"+function(t,e){const n=t.split("\n"),i=[],r=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let t=r;t<a;t++){const r=t+1;i.push(`${r===e?">":" "} ${r}: ${n[t]}`)}return i.join("\n")}(t.getShaderSource(e),i)}return r}function op(t,e){const n=function(t){Ui._getMatrix(ap,Ui.workingColorSpace,t);const e=`mat3( ${ap.elements.map((t=>t.toFixed(4)))} )`;switch(Ui.getTransfer(t)){case Vn:return[e,"LinearTransferOETF"];case Hn:return[e,"sRGBTransferOETF"];default:return hi("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}(e);return[`vec4 ${t}( vec4 value ) {`,`\treturn ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join("\n")}const lp={[se]:"Linear",[oe]:"Reinhard",[le]:"Cineon",[ce]:"ACESFilmic",[de]:"AgX",[ue]:"Neutral",[he]:"Custom"};function cp(t,e){const n=lp[e];return void 0===n?(hi("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+t+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const hp=new Ci;function dp(){return Ui.getLuminanceCoefficients(hp),["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${hp.x.toFixed(4)}, ${hp.y.toFixed(4)}, ${hp.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")}function up(t){return""!==t}function pp(t,e){const n=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function mp(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const fp=/^[ \t]*#include +<([\w\d./]+)>/gm;function gp(t){return t.replace(fp,_p)}const vp=new Map;function _p(t,e){let n=vd[e];if(void 0===n){const t=vp.get(e);if(void 0===t)throw new Error("Can not resolve #include <"+e+">");n=vd[t],hi('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,t)}return gp(n)}const yp=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function xp(t){return t.replace(yp,bp)}function bp(t,e,n,i){let r="";for(let t=parseInt(e);t<parseInt(n);t++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+t+" ]").replace(/UNROLLED_LOOP_INDEX/g,t);return r}function Sp(t){let e=`precision ${t.precision} float;\n\tprecision ${t.precision} int;\n\tprecision ${t.precision} sampler2D;\n\tprecision ${t.precision} samplerCube;\n\tprecision ${t.precision} sampler3D;\n\tprecision ${t.precision} sampler2DArray;\n\tprecision ${t.precision} sampler2DShadow;\n\tprecision ${t.precision} samplerCubeShadow;\n\tprecision ${t.precision} sampler2DArrayShadow;\n\tprecision ${t.precision} isampler2D;\n\tprecision ${t.precision} isampler3D;\n\tprecision ${t.precision} isamplerCube;\n\tprecision ${t.precision} isampler2DArray;\n\tprecision ${t.precision} usampler2D;\n\tprecision ${t.precision} usampler3D;\n\tprecision ${t.precision} usamplerCube;\n\tprecision ${t.precision} usampler2DArray;\n\t`;return"highp"===t.precision?e+="\n#define HIGH_PRECISION":"mediump"===t.precision?e+="\n#define MEDIUM_PRECISION":"lowp"===t.precision&&(e+="\n#define LOW_PRECISION"),e}const Mp={[Tt]:"SHADOWMAP_TYPE_PCF",[At]:"SHADOWMAP_TYPE_VSM"},wp={[me]:"ENVMAP_TYPE_CUBE",[fe]:"ENVMAP_TYPE_CUBE",[_e]:"ENVMAP_TYPE_CUBE_UV"},Ep={[fe]:"ENVMAP_MODE_REFRACTION"},Tp={[ie]:"ENVMAP_BLENDING_MULTIPLY",[re]:"ENVMAP_BLENDING_MIX",[ae]:"ENVMAP_BLENDING_ADD"};function Ap(t,e,n,i){const r=t.getContext(),a=n.defines;let s=n.vertexShader,o=n.fragmentShader;const l=function(t){return Mp[t.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}(n),c=function(t){return!1===t.envMap?"ENVMAP_TYPE_CUBE":wp[t.envMapMode]||"ENVMAP_TYPE_CUBE"}(n),h=function(t){return!1===t.envMap?"ENVMAP_MODE_REFLECTION":Ep[t.envMapMode]||"ENVMAP_MODE_REFLECTION"}(n),d=function(t){return!1===t.envMap?"ENVMAP_BLENDING_NONE":Tp[t.combine]||"ENVMAP_BLENDING_NONE"}(n),u=function(t){const e=t.envMapCubeUVHeight;if(null===e)return null;const n=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}(n),p=function(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(up).join("\n")}(n),m=function(t){const e=[];for(const n in t){const i=t[n];!1!==i&&e.push("#define "+n+" "+i)}return e.join("\n")}(a),f=r.createProgram();let g,v,_=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(up).join("\n"),g.length>0&&(g+="\n"),v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(up).join("\n"),v.length>0&&(v+="\n")):(g=[Sp(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+h:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexNormals?"#define HAS_NORMAL":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(up).join("\n"),v=[Sp(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+h:"",n.envMap?"#define "+d:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==n.toneMapping?"#define TONE_MAPPING":"",0!==n.toneMapping?vd.tonemapping_pars_fragment:"",0!==n.toneMapping?cp("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",vd.colorspace_pars_fragment,op("linearToOutputTexel",n.outputColorSpace),dp(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(up).join("\n")),s=gp(s),s=pp(s,n),s=mp(s,n),o=gp(o),o=pp(o,n),o=mp(o,n),s=xp(s),o=xp(o),!0!==n.isRawShaderMaterial&&(_="#version 300 es\n",g=[p,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,v=["#define varying in",n.glslVersion===ti?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===ti?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+v);const y=_+g+s,x=_+v+o,b=ip(r,r.VERTEX_SHADER,y),S=ip(r,r.FRAGMENT_SHADER,x);function M(e){if(t.debug.checkShaderErrors){const n=r.getProgramInfoLog(f)||"",i=r.getShaderInfoLog(b)||"",a=r.getShaderInfoLog(S)||"",s=n.trim(),o=i.trim(),l=a.trim();let c=!0,h=!0;if(!1===r.getProgramParameter(f,r.LINK_STATUS))if(c=!1,"function"==typeof t.debug.onShaderError)t.debug.onShaderError(r,f,b,S);else{const t=sp(r,b,"vertex"),n=sp(r,S,"fragment");di("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(f,r.VALIDATE_STATUS)+"\n\nMaterial Name: "+e.name+"\nMaterial Type: "+e.type+"\n\nProgram Info Log: "+s+"\n"+t+"\n"+n)}else""!==s?hi("WebGLProgram: Program Info Log:",s):""!==o&&""!==l||(h=!1);h&&(e.diagnostics={runnable:c,programLog:s,vertexShader:{log:o,prefix:g},fragmentShader:{log:l,prefix:v}})}r.deleteShader(b),r.deleteShader(S),w=new np(r,f),E=function(t,e){const n={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const i=t.getActiveAttrib(e,r),a=i.name;let s=1;i.type===t.FLOAT_MAT2&&(s=2),i.type===t.FLOAT_MAT3&&(s=3),i.type===t.FLOAT_MAT4&&(s=4),n[a]={type:i.type,location:t.getAttribLocation(e,a),locationSize:s}}return n}(r,f)}let w,E;r.attachShader(f,b),r.attachShader(f,S),void 0!==n.index0AttributeName?r.bindAttribLocation(f,0,n.index0AttributeName):!0===n.morphTargets&&r.bindAttribLocation(f,0,"position"),r.linkProgram(f),this.getUniforms=function(){return void 0===w&&M(this),w},this.getAttributes=function(){return void 0===E&&M(this),E};let T=!1===n.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===T&&(T=r.getProgramParameter(f,37297)),T},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(f),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=rp++,this.cacheKey=e,this.usedTimes=1,this.program=f,this.vertexShader=b,this.fragmentShader=S,this}let Cp=0;class Rp{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,n=t.fragmentShader,i=this._getShaderStage(e),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(t);return!1===a.has(i)&&(a.add(i),i.usedTimes++),!1===a.has(r)&&(a.add(r),r.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const t of e)t.usedTimes--,0===t.usedTimes&&this.shaderCache.delete(t.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let n=e.get(t);return void 0===n&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return void 0===n&&(n=new Ip(t),e.set(t,n)),n}}class Ip{constructor(t){this.id=Cp++,this.code=t,this.usedTimes=0}}function Pp(t,e,n,i,r,a){const s=new cr,o=new Rp,l=new Set,c=[],h=new Map,d=i.logarithmicDepthBuffer;let u=i.precision;const p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(t){return l.add(t),0===t?"uv":`uv${t}`}return{getParameters:function(r,s,c,h,f,g){const v=h.fog,_=f.geometry,y=r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial?h.environment:null,x=r.isMeshStandardMaterial||r.isMeshLambertMaterial&&!r.envMap||r.isMeshPhongMaterial&&!r.envMap,b=e.get(r.envMap||y,x),S=b&&b.mapping===_e?b.image.height:null,M=p[r.type];null!==r.precision&&(u=i.getMaxPrecision(r.precision),u!==r.precision&&hi("WebGLProgram.getParameters:",r.precision,"not supported, using",u,"instead."));const w=_.morphAttributes.position||_.morphAttributes.normal||_.morphAttributes.color,E=void 0!==w?w.length:0;let T,A,C,R,I=0;if(void 0!==_.morphAttributes.position&&(I=1),void 0!==_.morphAttributes.normal&&(I=2),void 0!==_.morphAttributes.color&&(I=3),M){const t=yd[M];T=t.vertexShader,A=t.fragmentShader}else T=r.vertexShader,A=r.fragmentShader,o.update(r),C=o.getVertexShaderID(r),R=o.getFragmentShaderID(r);const P=t.getRenderTarget(),L=t.state.buffers.depth.getReversed(),D=!0===f.isInstancedMesh,N=!0===f.isBatchedMesh,O=!!r.map,U=!!r.matcap,F=!!b,z=!!r.aoMap,k=!!r.lightMap,B=!!r.bumpMap,G=!!r.normalMap,V=!!r.displacementMap,H=!!r.emissiveMap,W=!!r.metalnessMap,j=!!r.roughnessMap,X=r.anisotropy>0,q=r.clearcoat>0,Y=r.dispersion>0,Z=r.iridescence>0,$=r.sheen>0,J=r.transmission>0,K=X&&!!r.anisotropyMap,Q=q&&!!r.clearcoatMap,tt=q&&!!r.clearcoatNormalMap,et=q&&!!r.clearcoatRoughnessMap,nt=Z&&!!r.iridescenceMap,it=Z&&!!r.iridescenceThicknessMap,rt=$&&!!r.sheenColorMap,at=$&&!!r.sheenRoughnessMap,st=!!r.specularMap,ot=!!r.specularColorMap,lt=!!r.specularIntensityMap,ct=J&&!!r.transmissionMap,ht=J&&!!r.thicknessMap,dt=!!r.gradientMap,ut=!!r.alphaMap,pt=r.alphaTest>0,mt=!!r.alphaHash,ft=!!r.extensions;let gt=0;r.toneMapped&&(null!==P&&!0!==P.isXRRenderTarget||(gt=t.toneMapping));const vt={shaderID:M,shaderType:r.type,shaderName:r.name,vertexShader:T,fragmentShader:A,defines:r.defines,customVertexShaderID:C,customFragmentShaderID:R,isRawShaderMaterial:!0===r.isRawShaderMaterial,glslVersion:r.glslVersion,precision:u,batching:N,batchingColor:N&&null!==f._colorsTexture,instancing:D,instancingColor:D&&null!==f.instanceColor,instancingMorph:D&&null!==f.morphTexture,outputColorSpace:null===P?t.outputColorSpace:!0===P.isXRRenderTarget?P.texture.colorSpace:Ui.workingColorSpace,alphaToCoverage:!!r.alphaToCoverage,map:O,matcap:U,envMap:F,envMapMode:F&&b.mapping,envMapCubeUVHeight:S,aoMap:z,lightMap:k,bumpMap:B,normalMap:G,displacementMap:V,emissiveMap:H,normalMapObjectSpace:G&&1===r.normalMapType,normalMapTangentSpace:G&&0===r.normalMapType,packedNormalMap:G&&0===r.normalMapType&&(_t=r.normalMap.format,_t===Xe||_t===cn||_t===In),metalnessMap:W,roughnessMap:j,anisotropy:X,anisotropyMap:K,clearcoat:q,clearcoatMap:Q,clearcoatNormalMap:tt,clearcoatRoughnessMap:et,dispersion:Y,iridescence:Z,iridescenceMap:nt,iridescenceThicknessMap:it,sheen:$,sheenColorMap:rt,sheenRoughnessMap:at,specularMap:st,specularColorMap:ot,specularIntensityMap:lt,transmission:J,transmissionMap:ct,thicknessMap:ht,gradientMap:dt,opaque:!1===r.transparent&&1===r.blending&&!1===r.alphaToCoverage,alphaMap:ut,alphaTest:pt,alphaHash:mt,combine:r.combine,mapUv:O&&m(r.map.channel),aoMapUv:z&&m(r.aoMap.channel),lightMapUv:k&&m(r.lightMap.channel),bumpMapUv:B&&m(r.bumpMap.channel),normalMapUv:G&&m(r.normalMap.channel),displacementMapUv:V&&m(r.displacementMap.channel),emissiveMapUv:H&&m(r.emissiveMap.channel),metalnessMapUv:W&&m(r.metalnessMap.channel),roughnessMapUv:j&&m(r.roughnessMap.channel),anisotropyMapUv:K&&m(r.anisotropyMap.channel),clearcoatMapUv:Q&&m(r.clearcoatMap.channel),clearcoatNormalMapUv:tt&&m(r.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:et&&m(r.clearcoatRoughnessMap.channel),iridescenceMapUv:nt&&m(r.iridescenceMap.channel),iridescenceThicknessMapUv:it&&m(r.iridescenceThicknessMap.channel),sheenColorMapUv:rt&&m(r.sheenColorMap.channel),sheenRoughnessMapUv:at&&m(r.sheenRoughnessMap.channel),specularMapUv:st&&m(r.specularMap.channel),specularColorMapUv:ot&&m(r.specularColorMap.channel),specularIntensityMapUv:lt&&m(r.specularIntensityMap.channel),transmissionMapUv:ct&&m(r.transmissionMap.channel),thicknessMapUv:ht&&m(r.thicknessMap.channel),alphaMapUv:ut&&m(r.alphaMap.channel),vertexTangents:!!_.attributes.tangent&&(G||X),vertexNormals:!!_.attributes.normal,vertexColors:r.vertexColors,vertexAlphas:!0===r.vertexColors&&!!_.attributes.color&&4===_.attributes.color.itemSize,pointsUvs:!0===f.isPoints&&!!_.attributes.uv&&(O||ut),fog:!!v,useFog:!0===r.fog,fogExp2:!!v&&v.isFogExp2,flatShading:!1===r.wireframe&&(!0===r.flatShading||void 0===_.attributes.normal&&!1===G&&(r.isMeshLambertMaterial||r.isMeshPhongMaterial||r.isMeshStandardMaterial||r.isMeshPhysicalMaterial)),sizeAttenuation:!0===r.sizeAttenuation,logarithmicDepthBuffer:d,reversedDepthBuffer:L,skinning:!0===f.isSkinnedMesh,morphTargets:void 0!==_.morphAttributes.position,morphNormals:void 0!==_.morphAttributes.normal,morphColors:void 0!==_.morphAttributes.color,morphTargetsCount:E,morphTextureStride:I,numDirLights:s.directional.length,numPointLights:s.point.length,numSpotLights:s.spot.length,numSpotLightMaps:s.spotLightMap.length,numRectAreaLights:s.rectArea.length,numHemiLights:s.hemi.length,numDirLightShadows:s.directionalShadowMap.length,numPointLightShadows:s.pointShadowMap.length,numSpotLightShadows:s.spotShadowMap.length,numSpotLightShadowsWithMaps:s.numSpotLightShadowsWithMaps,numLightProbes:s.numLightProbes,numLightProbeGrids:g.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:r.dithering,shadowMapEnabled:t.shadowMap.enabled&&c.length>0,shadowMapType:t.shadowMap.type,toneMapping:gt,decodeVideoTexture:O&&!0===r.map.isVideoTexture&&Ui.getTransfer(r.map.colorSpace)===Hn,decodeVideoTextureEmissive:H&&!0===r.emissiveMap.isVideoTexture&&Ui.getTransfer(r.emissiveMap.colorSpace)===Hn,premultipliedAlpha:r.premultipliedAlpha,doubleSided:2===r.side,flipSided:1===r.side,useDepthPacking:r.depthPacking>=0,depthPacking:r.depthPacking||0,index0AttributeName:r.index0AttributeName,extensionClipCullDistance:ft&&!0===r.extensions.clipCullDistance&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ft&&!0===r.extensions.multiDraw||N)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:r.customProgramCacheKey()};var _t;return vt.vertexUv1s=l.has(1),vt.vertexUv2s=l.has(2),vt.vertexUv3s=l.has(3),l.clear(),vt},getProgramCacheKey:function(e){const n=[];if(e.shaderID?n.push(e.shaderID):(n.push(e.customVertexShaderID),n.push(e.customFragmentShaderID)),void 0!==e.defines)for(const t in e.defines)n.push(t),n.push(e.defines[t]);return!1===e.isRawShaderMaterial&&(function(t,e){t.push(e.precision),t.push(e.outputColorSpace),t.push(e.envMapMode),t.push(e.envMapCubeUVHeight),t.push(e.mapUv),t.push(e.alphaMapUv),t.push(e.lightMapUv),t.push(e.aoMapUv),t.push(e.bumpMapUv),t.push(e.normalMapUv),t.push(e.displacementMapUv),t.push(e.emissiveMapUv),t.push(e.metalnessMapUv),t.push(e.roughnessMapUv),t.push(e.anisotropyMapUv),t.push(e.clearcoatMapUv),t.push(e.clearcoatNormalMapUv),t.push(e.clearcoatRoughnessMapUv),t.push(e.iridescenceMapUv),t.push(e.iridescenceThicknessMapUv),t.push(e.sheenColorMapUv),t.push(e.sheenRoughnessMapUv),t.push(e.specularMapUv),t.push(e.specularColorMapUv),t.push(e.specularIntensityMapUv),t.push(e.transmissionMapUv),t.push(e.thicknessMapUv),t.push(e.combine),t.push(e.fogExp2),t.push(e.sizeAttenuation),t.push(e.morphTargetsCount),t.push(e.morphAttributeCount),t.push(e.numDirLights),t.push(e.numPointLights),t.push(e.numSpotLights),t.push(e.numSpotLightMaps),t.push(e.numHemiLights),t.push(e.numRectAreaLights),t.push(e.numDirLightShadows),t.push(e.numPointLightShadows),t.push(e.numSpotLightShadows),t.push(e.numSpotLightShadowsWithMaps),t.push(e.numLightProbes),t.push(e.shadowMapType),t.push(e.toneMapping),t.push(e.numClippingPlanes),t.push(e.numClipIntersection),t.push(e.depthPacking)}(n,e),function(t,e){s.disableAll(),e.instancing&&s.enable(0),e.instancingColor&&s.enable(1),e.instancingMorph&&s.enable(2),e.matcap&&s.enable(3),e.envMap&&s.enable(4),e.normalMapObjectSpace&&s.enable(5),e.normalMapTangentSpace&&s.enable(6),e.clearcoat&&s.enable(7),e.iridescence&&s.enable(8),e.alphaTest&&s.enable(9),e.vertexColors&&s.enable(10),e.vertexAlphas&&s.enable(11),e.vertexUv1s&&s.enable(12),e.vertexUv2s&&s.enable(13),e.vertexUv3s&&s.enable(14),e.vertexTangents&&s.enable(15),e.anisotropy&&s.enable(16),e.alphaHash&&s.enable(17),e.batching&&s.enable(18),e.dispersion&&s.enable(19),e.batchingColor&&s.enable(20),e.gradientMap&&s.enable(21),e.packedNormalMap&&s.enable(22),e.vertexNormals&&s.enable(23),t.push(s.mask),s.disableAll(),e.fog&&s.enable(0),e.useFog&&s.enable(1),e.flatShading&&s.enable(2),e.logarithmicDepthBuffer&&s.enable(3),e.reversedDepthBuffer&&s.enable(4),e.skinning&&s.enable(5),e.morphTargets&&s.enable(6),e.morphNormals&&s.enable(7),e.morphColors&&s.enable(8),e.premultipliedAlpha&&s.enable(9),e.shadowMapEnabled&&s.enable(10),e.doubleSided&&s.enable(11),e.flipSided&&s.enable(12),e.useDepthPacking&&s.enable(13),e.dithering&&s.enable(14),e.transmission&&s.enable(15),e.sheen&&s.enable(16),e.opaque&&s.enable(17),e.pointsUvs&&s.enable(18),e.decodeVideoTexture&&s.enable(19),e.decodeVideoTextureEmissive&&s.enable(20),e.alphaToCoverage&&s.enable(21),e.numLightProbeGrids>0&&s.enable(22),t.push(s.mask)}(n,e),n.push(t.outputColorSpace)),n.push(e.customProgramCacheKey),n.join()},getUniforms:function(t){const e=p[t.type];let n;if(e){const t=yd[e];n=Mc.clone(t.uniforms)}else n=t.uniforms;return n},acquireProgram:function(e,n){let i=h.get(n);return void 0!==i?++i.usedTimes:(i=new Ap(t,n,e,r),c.push(i),h.set(n,i)),i},releaseProgram:function(t){if(0===--t.usedTimes){const e=c.indexOf(t);c[e]=c[c.length-1],c.pop(),h.delete(t.cacheKey),t.destroy()}},releaseShaderCache:function(t){o.remove(t)},programs:c,dispose:function(){o.dispose()}}}function Lp(){let t=new WeakMap;return{has:function(e){return t.has(e)},get:function(e){let n=t.get(e);return void 0===n&&(n={},t.set(e,n)),n},remove:function(e){t.delete(e)},update:function(e,n,i){t.get(e)[n]=i},dispose:function(){t=new WeakMap}}}function Dp(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.materialVariant!==e.materialVariant?t.materialVariant-e.materialVariant:t.z!==e.z?t.z-e.z:t.id-e.id}function Np(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function Op(){const t=[];let e=0;const n=[],i=[],r=[];function a(t){let e=0;return t.isInstancedMesh&&(e+=2),t.isSkinnedMesh&&(e+=1),e}function s(n,i,r,s,o,l){let c=t[e];return void 0===c?(c={id:n.id,object:n,geometry:i,material:r,materialVariant:a(n),groupOrder:s,renderOrder:n.renderOrder,z:o,group:l},t[e]=c):(c.id=n.id,c.object=n,c.geometry=i,c.material=r,c.materialVariant=a(n),c.groupOrder=s,c.renderOrder=n.renderOrder,c.z=o,c.group=l),e++,c}return{opaque:n,transmissive:i,transparent:r,init:function(){e=0,n.length=0,i.length=0,r.length=0},push:function(t,e,a,o,l,c){const h=s(t,e,a,o,l,c);a.transmission>0?i.push(h):!0===a.transparent?r.push(h):n.push(h)},unshift:function(t,e,a,o,l,c){const h=s(t,e,a,o,l,c);a.transmission>0?i.unshift(h):!0===a.transparent?r.unshift(h):n.unshift(h)},finish:function(){for(let n=e,i=t.length;n<i;n++){const e=t[n];if(null===e.id)break;e.id=null,e.object=null,e.geometry=null,e.material=null,e.group=null}},sort:function(t,e){n.length>1&&n.sort(t||Dp),i.length>1&&i.sort(e||Np),r.length>1&&r.sort(e||Np)}}}function Up(){let t=new WeakMap;return{get:function(e,n){const i=t.get(e);let r;return void 0===i?(r=new Op,t.set(e,[r])):n>=i.length?(r=new Op,i.push(r)):r=i[n],r},dispose:function(){t=new WeakMap}}}function Fp(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new Ci,color:new Dr};break;case"SpotLight":n={position:new Ci,direction:new Ci,color:new Dr,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Ci,color:new Dr,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Ci,skyColor:new Dr,groundColor:new Dr};break;case"RectAreaLight":n={color:new Dr,position:new Ci,halfWidth:new Ci,halfHeight:new Ci}}return t[e.id]=n,n}}}let zp=0;function kp(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function Bp(t){const e=new Fp,n=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ti};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ti,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=n,n}}}(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let t=0;t<9;t++)i.probe.push(new Ci);const r=new Ci,a=new Ki,s=new Ki;return{setup:function(r){let a=0,s=0,o=0;for(let t=0;t<9;t++)i.probe[t].set(0,0,0);let l=0,c=0,h=0,d=0,u=0,p=0,m=0,f=0,g=0,v=0,_=0;r.sort(kp);for(let t=0,y=r.length;t<y;t++){const y=r[t],x=y.color,b=y.intensity,S=y.distance;let M=null;if(y.shadow&&y.shadow.map&&(M=y.shadow.map.texture.format===Xe?y.shadow.map.texture:y.shadow.map.depthTexture||y.shadow.map.texture),y.isAmbientLight)a+=x.r*b,s+=x.g*b,o+=x.b*b;else if(y.isLightProbe){for(let t=0;t<9;t++)i.probe[t].addScaledVector(y.sh.coefficients[t],b);_++}else if(y.isDirectionalLight){const t=e.get(y);if(t.color.copy(y.color).multiplyScalar(y.intensity),y.castShadow){const t=y.shadow,e=n.get(y);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,i.directionalShadow[l]=e,i.directionalShadowMap[l]=M,i.directionalShadowMatrix[l]=y.shadow.matrix,p++}i.directional[l]=t,l++}else if(y.isSpotLight){const t=e.get(y);t.position.setFromMatrixPosition(y.matrixWorld),t.color.copy(x).multiplyScalar(b),t.distance=S,t.coneCos=Math.cos(y.angle),t.penumbraCos=Math.cos(y.angle*(1-y.penumbra)),t.decay=y.decay,i.spot[h]=t;const r=y.shadow;if(y.map&&(i.spotLightMap[g]=y.map,g++,r.updateMatrices(y),y.castShadow&&v++),i.spotLightMatrix[h]=r.matrix,y.castShadow){const t=n.get(y);t.shadowIntensity=r.intensity,t.shadowBias=r.bias,t.shadowNormalBias=r.normalBias,t.shadowRadius=r.radius,t.shadowMapSize=r.mapSize,i.spotShadow[h]=t,i.spotShadowMap[h]=M,f++}h++}else if(y.isRectAreaLight){const t=e.get(y);t.color.copy(x).multiplyScalar(b),t.halfWidth.set(.5*y.width,0,0),t.halfHeight.set(0,.5*y.height,0),i.rectArea[d]=t,d++}else if(y.isPointLight){const t=e.get(y);if(t.color.copy(y.color).multiplyScalar(y.intensity),t.distance=y.distance,t.decay=y.decay,y.castShadow){const t=y.shadow,e=n.get(y);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,e.shadowCameraNear=t.camera.near,e.shadowCameraFar=t.camera.far,i.pointShadow[c]=e,i.pointShadowMap[c]=M,i.pointShadowMatrix[c]=y.shadow.matrix,m++}i.point[c]=t,c++}else if(y.isHemisphereLight){const t=e.get(y);t.skyColor.copy(y.color).multiplyScalar(b),t.groundColor.copy(y.groundColor).multiplyScalar(b),i.hemi[u]=t,u++}}d>0&&(!0===t.has("OES_texture_float_linear")?(i.rectAreaLTC1=_d.LTC_FLOAT_1,i.rectAreaLTC2=_d.LTC_FLOAT_2):(i.rectAreaLTC1=_d.LTC_HALF_1,i.rectAreaLTC2=_d.LTC_HALF_2)),i.ambient[0]=a,i.ambient[1]=s,i.ambient[2]=o;const y=i.hash;y.directionalLength===l&&y.pointLength===c&&y.spotLength===h&&y.rectAreaLength===d&&y.hemiLength===u&&y.numDirectionalShadows===p&&y.numPointShadows===m&&y.numSpotShadows===f&&y.numSpotMaps===g&&y.numLightProbes===_||(i.directional.length=l,i.spot.length=h,i.rectArea.length=d,i.point.length=c,i.hemi.length=u,i.directionalShadow.length=p,i.directionalShadowMap.length=p,i.pointShadow.length=m,i.pointShadowMap.length=m,i.spotShadow.length=f,i.spotShadowMap.length=f,i.directionalShadowMatrix.length=p,i.pointShadowMatrix.length=m,i.spotLightMatrix.length=f+g-v,i.spotLightMap.length=g,i.numSpotLightShadowsWithMaps=v,i.numLightProbes=_,y.directionalLength=l,y.pointLength=c,y.spotLength=h,y.rectAreaLength=d,y.hemiLength=u,y.numDirectionalShadows=p,y.numPointShadows=m,y.numSpotShadows=f,y.numSpotMaps=g,y.numLightProbes=_,i.version=zp++)},setupView:function(t,e){let n=0,o=0,l=0,c=0,h=0;const d=e.matrixWorldInverse;for(let e=0,u=t.length;e<u;e++){const u=t[e];if(u.isDirectionalLight){const t=i.directional[n];t.direction.setFromMatrixPosition(u.matrixWorld),r.setFromMatrixPosition(u.target.matrixWorld),t.direction.sub(r),t.direction.transformDirection(d),n++}else if(u.isSpotLight){const t=i.spot[l];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),t.direction.setFromMatrixPosition(u.matrixWorld),r.setFromMatrixPosition(u.target.matrixWorld),t.direction.sub(r),t.direction.transformDirection(d),l++}else if(u.isRectAreaLight){const t=i.rectArea[c];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),s.identity(),a.copy(u.matrixWorld),a.premultiply(d),s.extractRotation(a),t.halfWidth.set(.5*u.width,0,0),t.halfHeight.set(0,.5*u.height,0),t.halfWidth.applyMatrix4(s),t.halfHeight.applyMatrix4(s),c++}else if(u.isPointLight){const t=i.point[o];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),o++}else if(u.isHemisphereLight){const t=i.hemi[h];t.direction.setFromMatrixPosition(u.matrixWorld),t.direction.transformDirection(d),h++}}},state:i}}function Gp(t){const e=new Bp(t),n=[],i=[],r=[],a={lightsArray:n,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:function(t){a.camera=t,n.length=0,i.length=0,r.length=0},state:a,setupLights:function(){e.setup(n)},setupLightsView:function(t){e.setupView(n,t)},pushLight:function(t){n.push(t)},pushShadow:function(t){i.push(t)},pushLightProbeGrid:function(t){r.push(t)}}}function Vp(t){let e=new WeakMap;return{get:function(n,i=0){const r=e.get(n);let a;return void 0===r?(a=new Gp(t),e.set(n,[a])):i>=r.length?(a=new Gp(t),r.push(a)):a=r[i],a},dispose:function(){e=new WeakMap}}}const Hp=[new Ci(1,0,0),new Ci(-1,0,0),new Ci(0,1,0),new Ci(0,-1,0),new Ci(0,0,1),new Ci(0,0,-1)],Wp=[new Ci(0,-1,0),new Ci(0,-1,0),new Ci(0,0,1),new Ci(0,0,-1),new Ci(0,-1,0),new Ci(0,-1,0)],jp=new Ki,Xp=new Ci,qp=new Ci;function Yp(t,e,n){let i=new eo;const r=new Ti,a=new Ti,s=new qi,o=new Lc,l=new Dc,c={},h=n.maxTextureSize,d={[Ct]:1,[Rt]:0,[It]:2},u=new wc({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ti},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );\n\tgl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );\n}"}),p=u.clone();p.defines.HORIZONTAL_PASS=1;const m=new Pa;m.setAttribute("position",new ga(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const f=new Ss(m,u),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let v=this.type;function _(n,i){const a=e.update(f);u.defines.VSM_SAMPLES!==n.blurSamples&&(u.defines.VSM_SAMPLES=n.blurSamples,p.defines.VSM_SAMPLES=n.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new Zi(r.x,r.y,{format:Xe,type:Oe})),u.uniforms.shadow_pass.value=n.map.depthTexture,u.uniforms.resolution.value=n.mapSize,u.uniforms.radius.value=n.radius,t.setRenderTarget(n.mapPass),t.clear(),t.renderBufferDirect(i,null,a,u,f,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,t.setRenderTarget(n.map),t.clear(),t.renderBufferDirect(i,null,a,p,f,null)}function y(e,n,i,r){let a=null;const s=!0===i.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(void 0!==s)a=s;else if(a=!0===i.isPointLight?l:o,t.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0||!0===n.alphaToCoverage){const t=a.uuid,e=n.uuid;let i=c[t];void 0===i&&(i={},c[t]=i);let r=i[e];void 0===r&&(r=a.clone(),i[e]=r,n.addEventListener("dispose",b)),a=r}return a.visible=n.visible,a.wireframe=n.wireframe,a.side=3===r?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:d[n.side],a.alphaMap=n.alphaMap,a.alphaTest=!0===n.alphaToCoverage?.5:n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,!0===i.isPointLight&&!0===a.isMeshDistanceMaterial&&(t.properties.get(a).light=i),a}function x(n,r,a,s,o){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&3===o)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);const i=e.update(n),l=n.material;if(Array.isArray(l)){const e=i.groups;for(let c=0,h=e.length;c<h;c++){const h=e[c],d=l[h.materialIndex];if(d&&d.visible){const e=y(n,d,s,o);n.onBeforeShadow(t,n,r,a,i,e,h),t.renderBufferDirect(a,null,i,e,n,h),n.onAfterShadow(t,n,r,a,i,e,h)}}}else if(l.visible){const e=y(n,l,s,o);n.onBeforeShadow(t,n,r,a,i,e,null),t.renderBufferDirect(a,null,i,e,n,null),n.onAfterShadow(t,n,r,a,i,e,null)}}const l=n.children;for(let t=0,e=l.length;t<e;t++)x(l[t],r,a,s,o)}function b(t){t.target.removeEventListener("dispose",b);for(const e in c){const n=c[e],i=t.target.uuid;i in n&&(n[i].dispose(),delete n[i])}}this.render=function(e,n,o){if(!1===g.enabled)return;if(!1===g.autoUpdate&&!1===g.needsUpdate)return;if(0===e.length)return;2===this.type&&(hi("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=1);const l=t.getRenderTarget(),c=t.getActiveCubeFace(),d=t.getActiveMipmapLevel(),u=t.state;u.setBlending(0),!0===u.buffers.depth.getReversed()?u.buffers.color.setClear(0,0,0,0):u.buffers.color.setClear(1,1,1,1),u.buffers.depth.setTest(!0),u.setScissorTest(!1);const p=v!==this.type;p&&n.traverse((function(t){t.material&&(Array.isArray(t.material)?t.material.forEach((t=>t.needsUpdate=!0)):t.material.needsUpdate=!0)}));for(let l=0,c=e.length;l<c;l++){const c=e[l],d=c.shadow;if(void 0===d){hi("WebGLShadowMap:",c,"has no shadow.");continue}if(!1===d.autoUpdate&&!1===d.needsUpdate)continue;r.copy(d.mapSize);const m=d.getFrameExtents();r.multiply(m),a.copy(d.mapSize),(r.x>h||r.y>h)&&(r.x>h&&(a.x=Math.floor(h/m.x),r.x=a.x*m.x,d.mapSize.x=a.x),r.y>h&&(a.y=Math.floor(h/m.y),r.y=a.y*m.y,d.mapSize.y=a.y));const f=t.state.buffers.depth.getReversed();if(d.camera._reversedDepth=f,null===d.map||!0===p){if(null!==d.map&&(null!==d.map.depthTexture&&(d.map.depthTexture.dispose(),d.map.depthTexture=null),d.map.dispose()),3===this.type){if(c.isPointLight){hi("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}d.map=new Zi(r.x,r.y,{format:Xe,type:Oe,minFilter:Ee,magFilter:Ee,generateMipmaps:!1}),d.map.texture.name=c.name+".shadowMap",d.map.depthTexture=new qo(r.x,r.y,Ne),d.map.depthTexture.name=c.name+".shadowMapDepth",d.map.depthTexture.format=Ve,d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=Se,d.map.depthTexture.magFilter=Se}else c.isPointLight?(d.map=new Vd(r.x),d.map.depthTexture=new Yo(r.x,De)):(d.map=new Zi(r.x,r.y),d.map.depthTexture=new qo(r.x,r.y,De)),d.map.depthTexture.name=c.name+".shadowMap",d.map.depthTexture.format=Ve,1===this.type?(d.map.depthTexture.compareFunction=f?518:515,d.map.depthTexture.minFilter=Ee,d.map.depthTexture.magFilter=Ee):(d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=Se,d.map.depthTexture.magFilter=Se);d.camera.updateProjectionMatrix()}const g=d.map.isWebGLCubeRenderTarget?6:1;for(let e=0;e<g;e++){if(d.map.isWebGLCubeRenderTarget)t.setRenderTarget(d.map,e),t.clear();else{0===e&&(t.setRenderTarget(d.map),t.clear());const n=d.getViewport(e);s.set(a.x*n.x,a.y*n.y,a.x*n.z,a.y*n.w),u.viewport(s)}if(c.isPointLight){const t=d.camera,n=d.matrix,i=c.distance||t.far;i!==t.far&&(t.far=i,t.updateProjectionMatrix()),Xp.setFromMatrixPosition(c.matrixWorld),t.position.copy(Xp),qp.copy(t.position),qp.add(Hp[e]),t.up.copy(Wp[e]),t.lookAt(qp),t.updateMatrixWorld(),n.makeTranslation(-Xp.x,-Xp.y,-Xp.z),jp.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),d._frustum.setFromProjectionMatrix(jp,t.coordinateSystem,t.reversedDepth)}else d.updateMatrices(c);i=d.getFrustum(),x(n,o,d.camera,c,this.type)}!0!==d.isPointLightShadow&&3===this.type&&_(d,o),d.needsUpdate=!1}v=this.type,g.needsUpdate=!1,t.setRenderTarget(l,c,d)}}function Zp(t,e){const n=new function(){let e=!1;const n=new qi;let i=null;const r=new qi(0,0,0,0);return{setMask:function(n){i===n||e||(t.colorMask(n,n,n,n),i=n)},setLocked:function(t){e=t},setClear:function(e,i,a,s,o){!0===o&&(e*=s,i*=s,a*=s),n.set(e,i,a,s),!1===r.equals(n)&&(t.clearColor(e,i,a,s),r.copy(n))},reset:function(){e=!1,i=null,r.set(-1,0,0,0)}}},i=new function(){let n=!1,i=!1,r=null,a=null,s=null;return{setReversed:function(t){if(i!==t){const n=e.get("EXT_clip_control");t?n.clipControlEXT(n.LOWER_LEFT_EXT,n.ZERO_TO_ONE_EXT):n.clipControlEXT(n.LOWER_LEFT_EXT,n.NEGATIVE_ONE_TO_ONE_EXT),i=t;const r=s;s=null,this.setClear(r)}},getReversed:function(){return i},setTest:function(e){e?G(t.DEPTH_TEST):V(t.DEPTH_TEST)},setMask:function(e){r===e||n||(t.depthMask(e),r=e)},setFunc:function(e){if(i&&(e=pi[e]),a!==e){switch(e){case 0:t.depthFunc(t.NEVER);break;case 1:t.depthFunc(t.ALWAYS);break;case 2:t.depthFunc(t.LESS);break;case 3:default:t.depthFunc(t.LEQUAL);break;case 4:t.depthFunc(t.EQUAL);break;case 5:t.depthFunc(t.GEQUAL);break;case 6:t.depthFunc(t.GREATER);break;case 7:t.depthFunc(t.NOTEQUAL)}a=e}},setLocked:function(t){n=t},setClear:function(e){s!==e&&(s=e,i&&(e=1-e),t.clearDepth(e))},reset:function(){n=!1,r=null,a=null,s=null,i=!1}}},r=new function(){let e=!1,n=null,i=null,r=null,a=null,s=null,o=null,l=null,c=null;return{setTest:function(n){e||(n?G(t.STENCIL_TEST):V(t.STENCIL_TEST))},setMask:function(i){n===i||e||(t.stencilMask(i),n=i)},setFunc:function(e,n,s){i===e&&r===n&&a===s||(t.stencilFunc(e,n,s),i=e,r=n,a=s)},setOp:function(e,n,i){s===e&&o===n&&l===i||(t.stencilOp(e,n,i),s=e,o=n,l=i)},setLocked:function(t){e=t},setClear:function(e){c!==e&&(t.clearStencil(e),c=e)},reset:function(){e=!1,n=null,i=null,r=null,a=null,s=null,o=null,l=null,c=null}}},a=new WeakMap,s=new WeakMap;let o={},l={},c={},h=new WeakMap,d=[],u=null,p=!1,m=null,f=null,g=null,v=null,_=null,y=null,x=null,b=new Dr(0,0,0),S=0,M=!1,w=null,E=null,T=null,A=null,C=null;const R=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let I=!1,P=0;const L=t.getParameter(t.VERSION);-1!==L.indexOf("WebGL")?(P=parseFloat(/^WebGL (\d)/.exec(L)[1]),I=P>=1):-1!==L.indexOf("OpenGL ES")&&(P=parseFloat(/^OpenGL ES (\d)/.exec(L)[1]),I=P>=2);let D=null,N={};const O=t.getParameter(t.SCISSOR_BOX),U=t.getParameter(t.VIEWPORT),F=(new qi).fromArray(O),z=(new qi).fromArray(U);function k(e,n,i,r){const a=new Uint8Array(4),s=t.createTexture();t.bindTexture(e,s),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let s=0;s<i;s++)e===t.TEXTURE_3D||e===t.TEXTURE_2D_ARRAY?t.texImage3D(n,0,t.RGBA,1,1,r,0,t.RGBA,t.UNSIGNED_BYTE,a):t.texImage2D(n+s,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,a);return s}const B={};function G(e){!0!==o[e]&&(t.enable(e),o[e]=!0)}function V(e){!1!==o[e]&&(t.disable(e),o[e]=!1)}B[t.TEXTURE_2D]=k(t.TEXTURE_2D,t.TEXTURE_2D,1),B[t.TEXTURE_CUBE_MAP]=k(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),B[t.TEXTURE_2D_ARRAY]=k(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),B[t.TEXTURE_3D]=k(t.TEXTURE_3D,t.TEXTURE_3D,1,1),n.setClear(0,0,0,1),i.setClear(1),r.setClear(0),G(t.DEPTH_TEST),i.setFunc(3),X(!1),q(1),G(t.CULL_FACE),j(0);const H={[Pt]:t.FUNC_ADD,[Lt]:t.FUNC_SUBTRACT,[Dt]:t.FUNC_REVERSE_SUBTRACT};H[103]=t.MIN,H[104]=t.MAX;const W={[Nt]:t.ZERO,[Ot]:t.ONE,[Ut]:t.SRC_COLOR,[zt]:t.SRC_ALPHA,[Wt]:t.SRC_ALPHA_SATURATE,[Vt]:t.DST_COLOR,[Bt]:t.DST_ALPHA,[Ft]:t.ONE_MINUS_SRC_COLOR,[kt]:t.ONE_MINUS_SRC_ALPHA,[Ht]:t.ONE_MINUS_DST_COLOR,[Gt]:t.ONE_MINUS_DST_ALPHA,[jt]:t.CONSTANT_COLOR,[Xt]:t.ONE_MINUS_CONSTANT_COLOR,[qt]:t.CONSTANT_ALPHA,[Yt]:t.ONE_MINUS_CONSTANT_ALPHA};function j(e,n,i,r,a,s,o,l,c,h){if(0!==e){if(!1===p&&(G(t.BLEND),p=!0),5===e)a=a||n,s=s||i,o=o||r,n===f&&a===_||(t.blendEquationSeparate(H[n],H[a]),f=n,_=a),i===g&&r===v&&s===y&&o===x||(t.blendFuncSeparate(W[i],W[r],W[s],W[o]),g=i,v=r,y=s,x=o),!1!==l.equals(b)&&c===S||(t.blendColor(l.r,l.g,l.b,c),b.copy(l),S=c),m=e,M=!1;else if(e!==m||h!==M){if(f===Pt&&_===Pt||(t.blendEquation(t.FUNC_ADD),f=Pt,_=Pt),h)switch(e){case 1:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFunc(t.ONE,t.ONE);break;case 3:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case 4:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:di("WebGLState: Invalid blending: ",e)}else switch(e){case 1:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case 3:di("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case 4:di("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:di("WebGLState: Invalid blending: ",e)}g=null,v=null,y=null,x=null,b.set(0,0,0),S=0,m=e,M=h}}else!0===p&&(V(t.BLEND),p=!1)}function X(e){w!==e&&(e?t.frontFace(t.CW):t.frontFace(t.CCW),w=e)}function q(e){0!==e?(G(t.CULL_FACE),e!==E&&(1===e?t.cullFace(t.BACK):2===e?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):V(t.CULL_FACE),E=e}function Y(e,n,r){e?(G(t.POLYGON_OFFSET_FILL),A===n&&C===r||(A=n,C=r,i.getReversed()&&(n=-n),t.polygonOffset(n,r))):V(t.POLYGON_OFFSET_FILL)}return{buffers:{color:n,depth:i,stencil:r},enable:G,disable:V,bindFramebuffer:function(e,n){return c[e]!==n&&(t.bindFramebuffer(e,n),c[e]=n,e===t.DRAW_FRAMEBUFFER&&(c[t.FRAMEBUFFER]=n),e===t.FRAMEBUFFER&&(c[t.DRAW_FRAMEBUFFER]=n),!0)},drawBuffers:function(e,n){let i=d,r=!1;if(e){i=h.get(n),void 0===i&&(i=[],h.set(n,i));const a=e.textures;if(i.length!==a.length||i[0]!==t.COLOR_ATTACHMENT0){for(let e=0,n=a.length;e<n;e++)i[e]=t.COLOR_ATTACHMENT0+e;i.length=a.length,r=!0}}else i[0]!==t.BACK&&(i[0]=t.BACK,r=!0);r&&t.drawBuffers(i)},useProgram:function(e){return u!==e&&(t.useProgram(e),u=e,!0)},setBlending:j,setMaterial:function(e,a){2===e.side?V(t.CULL_FACE):G(t.CULL_FACE);let s=1===e.side;a&&(s=!s),X(s),1===e.blending&&!1===e.transparent?j(0):j(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.blendColor,e.blendAlpha,e.premultipliedAlpha),i.setFunc(e.depthFunc),i.setTest(e.depthTest),i.setMask(e.depthWrite),n.setMask(e.colorWrite);const o=e.stencilWrite;r.setTest(o),o&&(r.setMask(e.stencilWriteMask),r.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),r.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),Y(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage?G(t.SAMPLE_ALPHA_TO_COVERAGE):V(t.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:X,setCullFace:q,setLineWidth:function(e){e!==T&&(I&&t.lineWidth(e),T=e)},setPolygonOffset:Y,setScissorTest:function(e){e?G(t.SCISSOR_TEST):V(t.SCISSOR_TEST)},activeTexture:function(e){void 0===e&&(e=t.TEXTURE0+R-1),D!==e&&(t.activeTexture(e),D=e)},bindTexture:function(e,n,i){void 0===i&&(i=null===D?t.TEXTURE0+R-1:D);let r=N[i];void 0===r&&(r={type:void 0,texture:void 0},N[i]=r),r.type===e&&r.texture===n||(D!==i&&(t.activeTexture(i),D=i),t.bindTexture(e,n||B[e]),r.type=e,r.texture=n)},unbindTexture:function(){const e=N[D];void 0!==e&&void 0!==e.type&&(t.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D:function(){try{t.compressedTexImage2D(...arguments)}catch(t){di("WebGLState:",t)}},compressedTexImage3D:function(){try{t.compressedTexImage3D(...arguments)}catch(t){di("WebGLState:",t)}},texImage2D:function(){try{t.texImage2D(...arguments)}catch(t){di("WebGLState:",t)}},texImage3D:function(){try{t.texImage3D(...arguments)}catch(t){di("WebGLState:",t)}},pixelStorei:function(e,n){l[e]!==n&&(t.pixelStorei(e,n),l[e]=n)},getParameter:function(e){return void 0!==l[e]?l[e]:t.getParameter(e)},updateUBOMapping:function(e,n){let i=s.get(n);void 0===i&&(i=new WeakMap,s.set(n,i));let r=i.get(e);void 0===r&&(r=t.getUniformBlockIndex(n,e.name),i.set(e,r))},uniformBlockBinding:function(e,n){const i=s.get(n).get(e);a.get(n)!==i&&(t.uniformBlockBinding(n,i,e.__bindingPointIndex),a.set(n,i))},texStorage2D:function(){try{t.texStorage2D(...arguments)}catch(t){di("WebGLState:",t)}},texStorage3D:function(){try{t.texStorage3D(...arguments)}catch(t){di("WebGLState:",t)}},texSubImage2D:function(){try{t.texSubImage2D(...arguments)}catch(t){di("WebGLState:",t)}},texSubImage3D:function(){try{t.texSubImage3D(...arguments)}catch(t){di("WebGLState:",t)}},compressedTexSubImage2D:function(){try{t.compressedTexSubImage2D(...arguments)}catch(t){di("WebGLState:",t)}},compressedTexSubImage3D:function(){try{t.compressedTexSubImage3D(...arguments)}catch(t){di("WebGLState:",t)}},scissor:function(e){!1===F.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),F.copy(e))},viewport:function(e){!1===z.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),z.copy(e))},reset:function(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),i.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),t.pixelStorei(t.PACK_ALIGNMENT,4),t.pixelStorei(t.UNPACK_ALIGNMENT,4),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!1),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.BROWSER_DEFAULT_WEBGL),t.pixelStorei(t.PACK_ROW_LENGTH,0),t.pixelStorei(t.PACK_SKIP_PIXELS,0),t.pixelStorei(t.PACK_SKIP_ROWS,0),t.pixelStorei(t.UNPACK_ROW_LENGTH,0),t.pixelStorei(t.UNPACK_IMAGE_HEIGHT,0),t.pixelStorei(t.UNPACK_SKIP_PIXELS,0),t.pixelStorei(t.UNPACK_SKIP_ROWS,0),t.pixelStorei(t.UNPACK_SKIP_IMAGES,0),o={},l={},D=null,N={},c={},h=new WeakMap,d=[],u=null,p=!1,m=null,f=null,g=null,v=null,_=null,y=null,x=null,b=new Dr(0,0,0),S=0,M=!1,w=null,E=null,T=null,A=null,C=null,F.set(0,0,t.canvas.width,t.canvas.height),z.set(0,0,t.canvas.width,t.canvas.height),n.reset(),i.reset(),r.reset()}}}function $p(t,e,n,i,r,a,s){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),c=new Ti,h=new WeakMap,d=new Set;let u;const p=new WeakMap;let m=!1;try{m="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(t){}function f(t,e){return m?new OffscreenCanvas(t,e):ai("canvas")}function g(t,e,n){let i=1;const r=W(t);if((r.width>n||r.height>n)&&(i=n/Math.max(r.width,r.height)),i<1){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof VideoFrame&&t instanceof VideoFrame){const n=Math.floor(i*r.width),a=Math.floor(i*r.height);void 0===u&&(u=f(n,a));const s=e?f(n,a):u;return s.width=n,s.height=a,s.getContext("2d").drawImage(t,0,0,n,a),hi("WebGLRenderer: Texture has been resized from ("+r.width+"x"+r.height+") to ("+n+"x"+a+")."),s}return"data"in t&&hi("WebGLRenderer: Image in DataTexture is too big ("+r.width+"x"+r.height+")."),t}return t}function v(t){return t.generateMipmaps}function _(e){t.generateMipmap(e)}function y(e){return e.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:e.isWebGL3DRenderTarget?t.TEXTURE_3D:e.isWebGLArrayRenderTarget||e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function x(n,i,r,a,s,o=!1){if(null!==n){if(void 0!==t[n])return t[n];hi("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let l;a&&(l=e.get("EXT_texture_norm16"),l||hi("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let c=i;if(i===t.RED&&(r===t.FLOAT&&(c=t.R32F),r===t.HALF_FLOAT&&(c=t.R16F),r===t.UNSIGNED_BYTE&&(c=t.R8),r===t.UNSIGNED_SHORT&&l&&(c=l.R16_EXT),r===t.SHORT&&l&&(c=l.R16_SNORM_EXT)),i===t.RED_INTEGER&&(r===t.UNSIGNED_BYTE&&(c=t.R8UI),r===t.UNSIGNED_SHORT&&(c=t.R16UI),r===t.UNSIGNED_INT&&(c=t.R32UI),r===t.BYTE&&(c=t.R8I),r===t.SHORT&&(c=t.R16I),r===t.INT&&(c=t.R32I)),i===t.RG&&(r===t.FLOAT&&(c=t.RG32F),r===t.HALF_FLOAT&&(c=t.RG16F),r===t.UNSIGNED_BYTE&&(c=t.RG8),r===t.UNSIGNED_SHORT&&l&&(c=l.RG16_EXT),r===t.SHORT&&l&&(c=l.RG16_SNORM_EXT)),i===t.RG_INTEGER&&(r===t.UNSIGNED_BYTE&&(c=t.RG8UI),r===t.UNSIGNED_SHORT&&(c=t.RG16UI),r===t.UNSIGNED_INT&&(c=t.RG32UI),r===t.BYTE&&(c=t.RG8I),r===t.SHORT&&(c=t.RG16I),r===t.INT&&(c=t.RG32I)),i===t.RGB_INTEGER&&(r===t.UNSIGNED_BYTE&&(c=t.RGB8UI),r===t.UNSIGNED_SHORT&&(c=t.RGB16UI),r===t.UNSIGNED_INT&&(c=t.RGB32UI),r===t.BYTE&&(c=t.RGB8I),r===t.SHORT&&(c=t.RGB16I),r===t.INT&&(c=t.RGB32I)),i===t.RGBA_INTEGER&&(r===t.UNSIGNED_BYTE&&(c=t.RGBA8UI),r===t.UNSIGNED_SHORT&&(c=t.RGBA16UI),r===t.UNSIGNED_INT&&(c=t.RGBA32UI),r===t.BYTE&&(c=t.RGBA8I),r===t.SHORT&&(c=t.RGBA16I),r===t.INT&&(c=t.RGBA32I)),i===t.RGB&&(r===t.UNSIGNED_SHORT&&l&&(c=l.RGB16_EXT),r===t.SHORT&&l&&(c=l.RGB16_SNORM_EXT),r===t.UNSIGNED_INT_5_9_9_9_REV&&(c=t.RGB9_E5),r===t.UNSIGNED_INT_10F_11F_11F_REV&&(c=t.R11F_G11F_B10F)),i===t.RGBA){const e=o?Vn:Ui.getTransfer(s);r===t.FLOAT&&(c=t.RGBA32F),r===t.HALF_FLOAT&&(c=t.RGBA16F),r===t.UNSIGNED_BYTE&&(c=e===Hn?t.SRGB8_ALPHA8:t.RGBA8),r===t.UNSIGNED_SHORT&&l&&(c=l.RGBA16_EXT),r===t.SHORT&&l&&(c=l.RGBA16_SNORM_EXT),r===t.UNSIGNED_SHORT_4_4_4_4&&(c=t.RGBA4),r===t.UNSIGNED_SHORT_5_5_5_1&&(c=t.RGB5_A1)}return c!==t.R16F&&c!==t.R32F&&c!==t.RG16F&&c!==t.RG32F&&c!==t.RGBA16F&&c!==t.RGBA32F||e.get("EXT_color_buffer_float"),c}function b(e,n){let i;return e?null===n||n===De||n===ze?i=t.DEPTH24_STENCIL8:n===Ne?i=t.DEPTH32F_STENCIL8:n===Pe&&(i=t.DEPTH24_STENCIL8,hi("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===n||n===De||n===ze?i=t.DEPTH_COMPONENT24:n===Ne?i=t.DEPTH_COMPONENT32F:n===Pe&&(i=t.DEPTH_COMPONENT16),i}function S(t,e){return!0===v(t)||t.isFramebufferTexture&&t.minFilter!==Se&&t.minFilter!==Ee?Math.log2(Math.max(e.width,e.height))+1:void 0!==t.mipmaps&&t.mipmaps.length>0?t.mipmaps.length:t.isCompressedTexture&&Array.isArray(t.image)?e.mipmaps.length:1}function M(t){const e=t.target;e.removeEventListener("dispose",M),function(t){const e=i.get(t);if(void 0===e.__webglInit)return;const n=t.source,r=p.get(n);if(r){const i=r[e.__cacheKey];i.usedTimes--,0===i.usedTimes&&E(t),0===Object.keys(r).length&&p.delete(n)}i.remove(t)}(e),e.isVideoTexture&&h.delete(e),e.isHTMLTexture&&d.delete(e)}function w(e){const n=e.target;n.removeEventListener("dispose",w),function(e){const n=i.get(e);if(e.depthTexture&&(e.depthTexture.dispose(),i.remove(e.depthTexture)),e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++){if(Array.isArray(n.__webglFramebuffer[e]))for(let i=0;i<n.__webglFramebuffer[e].length;i++)t.deleteFramebuffer(n.__webglFramebuffer[e][i]);else t.deleteFramebuffer(n.__webglFramebuffer[e]);n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer[e])}else{if(Array.isArray(n.__webglFramebuffer))for(let e=0;e<n.__webglFramebuffer.length;e++)t.deleteFramebuffer(n.__webglFramebuffer[e]);else t.deleteFramebuffer(n.__webglFramebuffer);if(n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer),n.__webglMultisampledFramebuffer&&t.deleteFramebuffer(n.__webglMultisampledFramebuffer),n.__webglColorRenderbuffer)for(let e=0;e<n.__webglColorRenderbuffer.length;e++)n.__webglColorRenderbuffer[e]&&t.deleteRenderbuffer(n.__webglColorRenderbuffer[e]);n.__webglDepthRenderbuffer&&t.deleteRenderbuffer(n.__webglDepthRenderbuffer)}const r=e.textures;for(let e=0,n=r.length;e<n;e++){const n=i.get(r[e]);n.__webglTexture&&(t.deleteTexture(n.__webglTexture),s.memory.textures--),i.remove(r[e])}i.remove(e)}(n)}function E(e){const n=i.get(e);t.deleteTexture(n.__webglTexture);const r=e.source;delete p.get(r)[n.__cacheKey],s.memory.textures--}let T=0;function A(e,r){const a=i.get(e);if(e.isVideoTexture&&function(t){const e=s.render.frame;h.get(t)!==e&&(h.set(t,e),t.update())}(e),!1===e.isRenderTargetTexture&&!0!==e.isExternalTexture&&e.version>0&&a.__version!==e.version){const t=e.image;if(null===t)hi("WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==t.complete)return void N(a,e,r);hi("WebGLRenderer: Texture marked for update but image is incomplete")}}else e.isExternalTexture&&(a.__webglTexture=e.sourceTexture?e.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,a.__webglTexture,t.TEXTURE0+r)}const C={[ye]:t.REPEAT,[xe]:t.CLAMP_TO_EDGE,[be]:t.MIRRORED_REPEAT},R={[Se]:t.NEAREST,[Me]:t.NEAREST_MIPMAP_NEAREST,[we]:t.NEAREST_MIPMAP_LINEAR,[Ee]:t.LINEAR,[Te]:t.LINEAR_MIPMAP_NEAREST,[Ae]:t.LINEAR_MIPMAP_LINEAR},I={[jn]:t.NEVER,[Kn]:t.ALWAYS,[Xn]:t.LESS,[Yn]:t.LEQUAL,[qn]:t.EQUAL,[Jn]:t.GEQUAL,[Zn]:t.GREATER,[$n]:t.NOTEQUAL};function P(n,a){if(a.type!==Ne||!1!==e.has("OES_texture_float_linear")||a.magFilter!==Ee&&a.magFilter!==Te&&a.magFilter!==we&&a.magFilter!==Ae&&a.minFilter!==Ee&&a.minFilter!==Te&&a.minFilter!==we&&a.minFilter!==Ae||hi("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(n,t.TEXTURE_WRAP_S,C[a.wrapS]),t.texParameteri(n,t.TEXTURE_WRAP_T,C[a.wrapT]),n!==t.TEXTURE_3D&&n!==t.TEXTURE_2D_ARRAY||t.texParameteri(n,t.TEXTURE_WRAP_R,C[a.wrapR]),t.texParameteri(n,t.TEXTURE_MAG_FILTER,R[a.magFilter]),t.texParameteri(n,t.TEXTURE_MIN_FILTER,R[a.minFilter]),a.compareFunction&&(t.texParameteri(n,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(n,t.TEXTURE_COMPARE_FUNC,I[a.compareFunction])),!0===e.has("EXT_texture_filter_anisotropic")){if(a.magFilter===Se)return;if(a.minFilter!==we&&a.minFilter!==Ae)return;if(a.type===Ne&&!1===e.has("OES_texture_float_linear"))return;if(a.anisotropy>1||i.get(a).__currentAnisotropy){const s=e.get("EXT_texture_filter_anisotropic");t.texParameterf(n,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy())),i.get(a).__currentAnisotropy=a.anisotropy}}}function L(e,n){let i=!1;void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",M));const r=n.source;let a=p.get(r);void 0===a&&(a={},p.set(r,a));const o=function(t){const e=[];return e.push(t.wrapS),e.push(t.wrapT),e.push(t.wrapR||0),e.push(t.magFilter),e.push(t.minFilter),e.push(t.anisotropy),e.push(t.internalFormat),e.push(t.format),e.push(t.type),e.push(t.generateMipmaps),e.push(t.premultiplyAlpha),e.push(t.flipY),e.push(t.unpackAlignment),e.push(t.colorSpace),e.join()}(n);if(o!==e.__cacheKey){void 0===a[o]&&(a[o]={texture:t.createTexture(),usedTimes:0},s.memory.textures++,i=!0),a[o].usedTimes++;const r=a[e.__cacheKey];void 0!==r&&(a[e.__cacheKey].usedTimes--,0===r.usedTimes&&E(n)),e.__cacheKey=o,e.__webglTexture=a[o].texture}return i}function D(t,e,n){return Math.floor(Math.floor(t/n)/e)}function N(e,s,o){let l=t.TEXTURE_2D;(s.isDataArrayTexture||s.isCompressedArrayTexture)&&(l=t.TEXTURE_2D_ARRAY),s.isData3DTexture&&(l=t.TEXTURE_3D);const c=L(e,s),h=s.source;n.bindTexture(l,e.__webglTexture,t.TEXTURE0+o);const u=i.get(h);if(h.version!==u.__version||!0===c){if(n.activeTexture(t.TEXTURE0+o),!1==("undefined"!=typeof ImageBitmap&&s.image instanceof ImageBitmap)){const e=Ui.getPrimaries(Ui.workingColorSpace),i=s.colorSpace===kn?null:Ui.getPrimaries(s.colorSpace),r=s.colorSpace===kn||e===i?t.NONE:t.BROWSER_DEFAULT_WEBGL;n.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,s.flipY),n.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),n.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,r)}n.pixelStorei(t.UNPACK_ALIGNMENT,s.unpackAlignment);let e=g(s.image,!1,r.maxTextureSize);e=H(s,e);const i=a.convert(s.format,s.colorSpace),p=a.convert(s.type);let m,f=x(s.internalFormat,i,p,s.normalized,s.colorSpace,s.isVideoTexture);P(l,s);const y=s.mipmaps,M=!0!==s.isVideoTexture,w=void 0===u.__version||!0===c,E=h.dataReady,T=S(s,e);if(s.isDepthTexture)f=b(s.format===He,s.type),w&&(M?n.texStorage2D(t.TEXTURE_2D,1,f,e.width,e.height):n.texImage2D(t.TEXTURE_2D,0,f,e.width,e.height,0,i,p,null));else if(s.isDataTexture)if(y.length>0){M&&w&&n.texStorage2D(t.TEXTURE_2D,T,f,y[0].width,y[0].height);for(let e=0,r=y.length;e<r;e++)m=y[e],M?E&&n.texSubImage2D(t.TEXTURE_2D,e,0,0,m.width,m.height,i,p,m.data):n.texImage2D(t.TEXTURE_2D,e,f,m.width,m.height,0,i,p,m.data);s.generateMipmaps=!1}else M?(w&&n.texStorage2D(t.TEXTURE_2D,T,f,e.width,e.height),E&&function(e,i,r,a){const s=e.updateRanges;if(0===s.length)n.texSubImage2D(t.TEXTURE_2D,0,0,0,i.width,i.height,r,a,i.data);else{s.sort(((t,e)=>t.start-e.start));let o=0;for(let t=1;t<s.length;t++){const e=s[o],n=s[t],r=e.start+e.count,a=D(n.start,i.width,4),l=D(e.start,i.width,4);n.start<=r+1&&a===l&&D(n.start+n.count-1,i.width,4)===a?e.count=Math.max(e.count,n.start+n.count-e.start):(++o,s[o]=n)}s.length=o+1;const l=n.getParameter(t.UNPACK_ROW_LENGTH),c=n.getParameter(t.UNPACK_SKIP_PIXELS),h=n.getParameter(t.UNPACK_SKIP_ROWS);n.pixelStorei(t.UNPACK_ROW_LENGTH,i.width);for(let e=0,o=s.length;e<o;e++){const o=s[e],l=Math.floor(o.start/4),c=Math.ceil(o.count/4),h=l%i.width,d=Math.floor(l/i.width),u=c,p=1;n.pixelStorei(t.UNPACK_SKIP_PIXELS,h),n.pixelStorei(t.UNPACK_SKIP_ROWS,d),n.texSubImage2D(t.TEXTURE_2D,0,h,d,u,p,r,a,i.data)}e.clearUpdateRanges(),n.pixelStorei(t.UNPACK_ROW_LENGTH,l),n.pixelStorei(t.UNPACK_SKIP_PIXELS,c),n.pixelStorei(t.UNPACK_SKIP_ROWS,h)}}(s,e,i,p)):n.texImage2D(t.TEXTURE_2D,0,f,e.width,e.height,0,i,p,e.data);else if(s.isCompressedTexture)if(s.isCompressedArrayTexture){M&&w&&n.texStorage3D(t.TEXTURE_2D_ARRAY,T,f,y[0].width,y[0].height,e.depth);for(let r=0,a=y.length;r<a;r++)if(m=y[r],s.format!==Ge)if(null!==i)if(M){if(E)if(s.layerUpdates.size>0){const e=md(m.width,m.height,s.format,s.type);for(const a of s.layerUpdates){const s=m.data.subarray(a*e/m.data.BYTES_PER_ELEMENT,(a+1)*e/m.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,r,0,0,a,m.width,m.height,1,i,s)}s.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,r,0,0,0,m.width,m.height,e.depth,i,m.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,r,f,m.width,m.height,e.depth,0,m.data,0,0);else hi("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else M?E&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,r,0,0,0,m.width,m.height,e.depth,i,p,m.data):n.texImage3D(t.TEXTURE_2D_ARRAY,r,f,m.width,m.height,e.depth,0,i,p,m.data)}else{M&&w&&n.texStorage2D(t.TEXTURE_2D,T,f,y[0].width,y[0].height);for(let e=0,r=y.length;e<r;e++)m=y[e],s.format!==Ge?null!==i?M?E&&n.compressedTexSubImage2D(t.TEXTURE_2D,e,0,0,m.width,m.height,i,m.data):n.compressedTexImage2D(t.TEXTURE_2D,e,f,m.width,m.height,0,m.data):hi("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):M?E&&n.texSubImage2D(t.TEXTURE_2D,e,0,0,m.width,m.height,i,p,m.data):n.texImage2D(t.TEXTURE_2D,e,f,m.width,m.height,0,i,p,m.data)}else if(s.isDataArrayTexture)if(M){if(w&&n.texStorage3D(t.TEXTURE_2D_ARRAY,T,f,e.width,e.height,e.depth),E)if(s.layerUpdates.size>0){const r=md(e.width,e.height,s.format,s.type);for(const a of s.layerUpdates){const s=e.data.subarray(a*r/e.data.BYTES_PER_ELEMENT,(a+1)*r/e.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,a,e.width,e.height,1,i,p,s)}s.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,e.width,e.height,e.depth,i,p,e.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,f,e.width,e.height,e.depth,0,i,p,e.data);else if(s.isData3DTexture)M?(w&&n.texStorage3D(t.TEXTURE_3D,T,f,e.width,e.height,e.depth),E&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,e.width,e.height,e.depth,i,p,e.data)):n.texImage3D(t.TEXTURE_3D,0,f,e.width,e.height,e.depth,0,i,p,e.data);else if(s.isFramebufferTexture){if(w)if(M)n.texStorage2D(t.TEXTURE_2D,T,f,e.width,e.height);else{let r=e.width,a=e.height;for(let e=0;e<T;e++)n.texImage2D(t.TEXTURE_2D,e,f,r,a,0,i,p,null),r>>=1,a>>=1}}else if(s.isHTMLTexture){if("texElementImage2D"in t){const n=t.canvas;if(n.hasAttribute("layoutsubtree")||n.setAttribute("layoutsubtree","true"),e.parentNode!==n)return n.appendChild(e),d.add(s),n.onpaint=t=>{const e=t.changedElements;for(const t of d)e.includes(t.image)&&(t.needsUpdate=!0)},void n.requestPaint();const i=0,r=t.RGBA,a=t.RGBA,o=t.UNSIGNED_BYTE;t.texElementImage2D(t.TEXTURE_2D,i,r,a,o,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)}}else if(y.length>0){if(M&&w){const e=W(y[0]);n.texStorage2D(t.TEXTURE_2D,T,f,e.width,e.height)}for(let e=0,r=y.length;e<r;e++)m=y[e],M?E&&n.texSubImage2D(t.TEXTURE_2D,e,0,0,i,p,m):n.texImage2D(t.TEXTURE_2D,e,f,i,p,m);s.generateMipmaps=!1}else if(M){if(w){const i=W(e);n.texStorage2D(t.TEXTURE_2D,T,f,i.width,i.height)}E&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,i,p,e)}else n.texImage2D(t.TEXTURE_2D,0,f,i,p,e);v(s)&&_(l),u.__version=h.version,s.onUpdate&&s.onUpdate(s)}e.__version=s.version}function O(e,r,s,l,c,h){const d=a.convert(s.format,s.colorSpace),u=a.convert(s.type),p=x(s.internalFormat,d,u,s.normalized,s.colorSpace),m=i.get(r),f=i.get(s);if(f.__renderTarget=r,!m.__hasExternalTextures){const e=Math.max(1,r.width>>h),i=Math.max(1,r.height>>h);c===t.TEXTURE_3D||c===t.TEXTURE_2D_ARRAY?n.texImage3D(c,h,p,e,i,r.depth,0,d,u,null):n.texImage2D(c,h,p,e,i,0,d,u,null)}n.bindFramebuffer(t.FRAMEBUFFER,e),V(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,l,c,f.__webglTexture,0,G(r)):(c===t.TEXTURE_2D||c>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&c<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,l,c,f.__webglTexture,h),n.bindFramebuffer(t.FRAMEBUFFER,null)}function U(e,n,i){if(t.bindRenderbuffer(t.RENDERBUFFER,e),n.depthBuffer){const r=n.depthTexture,a=r&&r.isDepthTexture?r.type:null,s=b(n.stencilBuffer,a),l=n.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;V(n)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,G(n),s,n.width,n.height):i?t.renderbufferStorageMultisample(t.RENDERBUFFER,G(n),s,n.width,n.height):t.renderbufferStorage(t.RENDERBUFFER,s,n.width,n.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,l,t.RENDERBUFFER,e)}else{const e=n.textures;for(let r=0;r<e.length;r++){const s=e[r],l=a.convert(s.format,s.colorSpace),c=a.convert(s.type),h=x(s.internalFormat,l,c,s.normalized,s.colorSpace);V(n)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,G(n),h,n.width,n.height):i?t.renderbufferStorageMultisample(t.RENDERBUFFER,G(n),h,n.width,n.height):t.renderbufferStorage(t.RENDERBUFFER,h,n.width,n.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function F(e,r,s){const l=!0===r.isWebGLCubeRenderTarget;if(n.bindFramebuffer(t.FRAMEBUFFER,e),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const c=i.get(r.depthTexture);if(c.__renderTarget=r,c.__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),l){if(void 0===c.__webglInit&&(c.__webglInit=!0,r.depthTexture.addEventListener("dispose",M)),void 0===c.__webglTexture){c.__webglTexture=t.createTexture(),n.bindTexture(t.TEXTURE_CUBE_MAP,c.__webglTexture),P(t.TEXTURE_CUBE_MAP,r.depthTexture);const e=a.convert(r.depthTexture.format),i=a.convert(r.depthTexture.type);let s;r.depthTexture.format===Ve?s=t.DEPTH_COMPONENT24:r.depthTexture.format===He&&(s=t.DEPTH24_STENCIL8);for(let n=0;n<6;n++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+n,0,s,r.width,r.height,0,e,i,null)}}else A(r.depthTexture,0);const h=c.__webglTexture,d=G(r),u=l?t.TEXTURE_CUBE_MAP_POSITIVE_X+s:t.TEXTURE_2D,p=r.depthTexture.format===He?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(r.depthTexture.format===Ve)V(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,p,u,h,0,d):t.framebufferTexture2D(t.FRAMEBUFFER,p,u,h,0);else{if(r.depthTexture.format!==He)throw new Error("Unknown depthTexture format");V(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,p,u,h,0,d):t.framebufferTexture2D(t.FRAMEBUFFER,p,u,h,0)}}function z(e){const r=i.get(e),a=!0===e.isWebGLCubeRenderTarget;if(r.__boundDepthTexture!==e.depthTexture){const t=e.depthTexture;if(r.__depthDisposeCallback&&r.__depthDisposeCallback(),t){const e=()=>{delete r.__boundDepthTexture,delete r.__depthDisposeCallback,t.removeEventListener("dispose",e)};t.addEventListener("dispose",e),r.__depthDisposeCallback=e}r.__boundDepthTexture=t}if(e.depthTexture&&!r.__autoAllocateDepthBuffer)if(a)for(let t=0;t<6;t++)F(r.__webglFramebuffer[t],e,t);else{const t=e.texture.mipmaps;t&&t.length>0?F(r.__webglFramebuffer[0],e,0):F(r.__webglFramebuffer,e,0)}else if(a){r.__webglDepthbuffer=[];for(let i=0;i<6;i++)if(n.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[i]),void 0===r.__webglDepthbuffer[i])r.__webglDepthbuffer[i]=t.createRenderbuffer(),U(r.__webglDepthbuffer[i],e,!1);else{const n=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,a=r.__webglDepthbuffer[i];t.bindRenderbuffer(t.RENDERBUFFER,a),t.framebufferRenderbuffer(t.FRAMEBUFFER,n,t.RENDERBUFFER,a)}}else{const i=e.texture.mipmaps;if(i&&i.length>0?n.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer),void 0===r.__webglDepthbuffer)r.__webglDepthbuffer=t.createRenderbuffer(),U(r.__webglDepthbuffer,e,!1);else{const n=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,i=r.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,i),t.framebufferRenderbuffer(t.FRAMEBUFFER,n,t.RENDERBUFFER,i)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}const k=[],B=[];function G(t){return Math.min(r.maxSamples,t.samples)}function V(t){const n=i.get(t);return t.samples>0&&!0===e.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function H(t,e){const n=t.colorSpace,i=t.format,r=t.type;return!0===t.isCompressedTexture||!0===t.isVideoTexture||n!==Gn&&n!==kn&&(Ui.getTransfer(n)===Hn?i===Ge&&r===Ce||hi("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):di("WebGLTextures: Unsupported texture color space:",n)),e}function W(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement?(c.width=t.naturalWidth||t.width,c.height=t.naturalHeight||t.height):"undefined"!=typeof VideoFrame&&t instanceof VideoFrame?(c.width=t.displayWidth,c.height=t.displayHeight):(c.width=t.width,c.height=t.height),c}this.allocateTextureUnit=function(){const t=T;return t>=r.maxTextures&&hi("WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+r.maxTextures),T+=1,t},this.resetTextureUnits=function(){T=0},this.getTextureUnits=function(){return T},this.setTextureUnits=function(t){T=t},this.setTexture2D=A,this.setTexture2DArray=function(e,r){const a=i.get(e);!1===e.isRenderTargetTexture&&e.version>0&&a.__version!==e.version?N(a,e,r):(e.isExternalTexture&&(a.__webglTexture=e.sourceTexture?e.sourceTexture:null),n.bindTexture(t.TEXTURE_2D_ARRAY,a.__webglTexture,t.TEXTURE0+r))},this.setTexture3D=function(e,r){const a=i.get(e);!1===e.isRenderTargetTexture&&e.version>0&&a.__version!==e.version?N(a,e,r):n.bindTexture(t.TEXTURE_3D,a.__webglTexture,t.TEXTURE0+r)},this.setTextureCube=function(e,s){const o=i.get(e);!0!==e.isCubeDepthTexture&&e.version>0&&o.__version!==e.version?function(e,s,o){if(6!==s.image.length)return;const l=L(e,s),c=s.source;n.bindTexture(t.TEXTURE_CUBE_MAP,e.__webglTexture,t.TEXTURE0+o);const h=i.get(c);if(c.version!==h.__version||!0===l){n.activeTexture(t.TEXTURE0+o);const e=Ui.getPrimaries(Ui.workingColorSpace),i=s.colorSpace===kn?null:Ui.getPrimaries(s.colorSpace),d=s.colorSpace===kn||e===i?t.NONE:t.BROWSER_DEFAULT_WEBGL;n.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,s.flipY),n.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),n.pixelStorei(t.UNPACK_ALIGNMENT,s.unpackAlignment),n.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);const u=s.isCompressedTexture||s.image[0].isCompressedTexture,p=s.image[0]&&s.image[0].isDataTexture,m=[];for(let t=0;t<6;t++)m[t]=u||p?p?s.image[t].image:s.image[t]:g(s.image[t],!0,r.maxCubemapSize),m[t]=H(s,m[t]);const f=m[0],y=a.convert(s.format,s.colorSpace),b=a.convert(s.type),M=x(s.internalFormat,y,b,s.normalized,s.colorSpace),w=!0!==s.isVideoTexture,E=void 0===h.__version||!0===l,T=c.dataReady;let A,C=S(s,f);if(P(t.TEXTURE_CUBE_MAP,s),u){w&&E&&n.texStorage2D(t.TEXTURE_CUBE_MAP,C,M,f.width,f.height);for(let e=0;e<6;e++){A=m[e].mipmaps;for(let i=0;i<A.length;i++){const r=A[i];s.format!==Ge?null!==y?w?T&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,0,0,r.width,r.height,y,r.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,M,r.width,r.height,0,r.data):hi("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):w?T&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,0,0,r.width,r.height,y,b,r.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,M,r.width,r.height,0,y,b,r.data)}}}else{if(A=s.mipmaps,w&&E){A.length>0&&C++;const e=W(m[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,C,M,e.width,e.height)}for(let e=0;e<6;e++)if(p){w?T&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,m[e].width,m[e].height,y,b,m[e].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,M,m[e].width,m[e].height,0,y,b,m[e].data);for(let i=0;i<A.length;i++){const r=A[i].image[e].image;w?T&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,0,0,r.width,r.height,y,b,r.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,M,r.width,r.height,0,y,b,r.data)}}else{w?T&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,y,b,m[e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,M,y,b,m[e]);for(let i=0;i<A.length;i++){const r=A[i];w?T&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,0,0,y,b,r.image[e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,M,y,b,r.image[e])}}}v(s)&&_(t.TEXTURE_CUBE_MAP),h.__version=c.version,s.onUpdate&&s.onUpdate(s)}e.__version=s.version}(o,e,s):n.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture,t.TEXTURE0+s)},this.rebindTextures=function(e,n,r){const a=i.get(e);void 0!==n&&O(a.__webglFramebuffer,e,e.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),void 0!==r&&z(e)},this.setupRenderTarget=function(e){const r=e.texture,o=i.get(e),l=i.get(r);e.addEventListener("dispose",w);const c=e.textures,h=!0===e.isWebGLCubeRenderTarget,d=c.length>1;if(d||(void 0===l.__webglTexture&&(l.__webglTexture=t.createTexture()),l.__version=r.version,s.memory.textures++),h){o.__webglFramebuffer=[];for(let e=0;e<6;e++)if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer[e]=[];for(let n=0;n<r.mipmaps.length;n++)o.__webglFramebuffer[e][n]=t.createFramebuffer()}else o.__webglFramebuffer[e]=t.createFramebuffer()}else{if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer=[];for(let e=0;e<r.mipmaps.length;e++)o.__webglFramebuffer[e]=t.createFramebuffer()}else o.__webglFramebuffer=t.createFramebuffer();if(d)for(let e=0,n=c.length;e<n;e++){const n=i.get(c[e]);void 0===n.__webglTexture&&(n.__webglTexture=t.createTexture(),s.memory.textures++)}if(e.samples>0&&!1===V(e)){o.__webglMultisampledFramebuffer=t.createFramebuffer(),o.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let n=0;n<c.length;n++){const i=c[n];o.__webglColorRenderbuffer[n]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,o.__webglColorRenderbuffer[n]);const r=a.convert(i.format,i.colorSpace),s=a.convert(i.type),l=x(i.internalFormat,r,s,i.normalized,i.colorSpace,!0===e.isXRRenderTarget),h=G(e);t.renderbufferStorageMultisample(t.RENDERBUFFER,h,l,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+n,t.RENDERBUFFER,o.__webglColorRenderbuffer[n])}t.bindRenderbuffer(t.RENDERBUFFER,null),e.depthBuffer&&(o.__webglDepthRenderbuffer=t.createRenderbuffer(),U(o.__webglDepthRenderbuffer,e,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(h){n.bindTexture(t.TEXTURE_CUBE_MAP,l.__webglTexture),P(t.TEXTURE_CUBE_MAP,r);for(let n=0;n<6;n++)if(r.mipmaps&&r.mipmaps.length>0)for(let i=0;i<r.mipmaps.length;i++)O(o.__webglFramebuffer[n][i],e,r,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+n,i);else O(o.__webglFramebuffer[n],e,r,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+n,0);v(r)&&_(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(d){for(let r=0,a=c.length;r<a;r++){const a=c[r],s=i.get(a);let l=t.TEXTURE_2D;(e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&(l=e.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(l,s.__webglTexture),P(l,a),O(o.__webglFramebuffer,e,a,t.COLOR_ATTACHMENT0+r,l,0),v(a)&&_(l)}n.unbindTexture()}else{let i=t.TEXTURE_2D;if((e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&(i=e.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(i,l.__webglTexture),P(i,r),r.mipmaps&&r.mipmaps.length>0)for(let n=0;n<r.mipmaps.length;n++)O(o.__webglFramebuffer[n],e,r,t.COLOR_ATTACHMENT0,i,n);else O(o.__webglFramebuffer,e,r,t.COLOR_ATTACHMENT0,i,0);v(r)&&_(i),n.unbindTexture()}e.depthBuffer&&z(e)},this.updateRenderTargetMipmap=function(t){const e=t.textures;for(let r=0,a=e.length;r<a;r++){const a=e[r];if(v(a)){const e=y(t),r=i.get(a).__webglTexture;n.bindTexture(e,r),_(e),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(e){if(e.samples>0)if(!1===V(e)){const r=e.textures,a=e.width,s=e.height;let o=t.COLOR_BUFFER_BIT;const c=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,h=i.get(e),d=r.length>1;if(d)for(let e=0;e<r.length;e++)n.bindFramebuffer(t.FRAMEBUFFER,h.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,h.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,h.__webglMultisampledFramebuffer);const u=e.texture.mipmaps;u&&u.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,h.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,h.__webglFramebuffer);for(let n=0;n<r.length;n++){if(e.resolveDepthBuffer&&(e.depthBuffer&&(o|=t.DEPTH_BUFFER_BIT),e.stencilBuffer&&e.resolveStencilBuffer&&(o|=t.STENCIL_BUFFER_BIT)),d){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,h.__webglColorRenderbuffer[n]);const e=i.get(r[n]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0)}t.blitFramebuffer(0,0,a,s,0,0,a,s,o,t.NEAREST),!0===l&&(k.length=0,B.length=0,k.push(t.COLOR_ATTACHMENT0+n),e.depthBuffer&&!1===e.resolveDepthBuffer&&(k.push(c),B.push(c),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,B)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,k))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),d)for(let e=0;e<r.length;e++){n.bindFramebuffer(t.FRAMEBUFFER,h.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,h.__webglColorRenderbuffer[e]);const a=i.get(r[e]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,h.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,a,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,h.__webglMultisampledFramebuffer)}else if(e.depthBuffer&&!1===e.resolveDepthBuffer&&l){const n=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[n])}},this.setupDepthRenderbuffer=z,this.setupFrameBufferTexture=O,this.useMultisampledRTT=V,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function Jp(t,e){return{convert:function(n,i=""){let r;const a=Ui.getTransfer(i);if(n===Ce)return t.UNSIGNED_BYTE;if(n===Ue)return t.UNSIGNED_SHORT_4_4_4_4;if(n===Fe)return t.UNSIGNED_SHORT_5_5_5_1;if(n===ke)return t.UNSIGNED_INT_5_9_9_9_REV;if(n===Be)return t.UNSIGNED_INT_10F_11F_11F_REV;if(n===Re)return t.BYTE;if(n===Ie)return t.SHORT;if(n===Pe)return t.UNSIGNED_SHORT;if(n===Le)return t.INT;if(n===De)return t.UNSIGNED_INT;if(n===Ne)return t.FLOAT;if(n===Oe)return t.HALF_FLOAT;if(1021===n)return t.ALPHA;if(1022===n)return t.RGB;if(n===Ge)return t.RGBA;if(n===Ve)return t.DEPTH_COMPONENT;if(n===He)return t.DEPTH_STENCIL;if(n===We)return t.RED;if(n===je)return t.RED_INTEGER;if(n===Xe)return t.RG;if(n===qe)return t.RG_INTEGER;if(n===Ye)return t.RGBA_INTEGER;if(n===Ze||n===$e||n===Je||n===Ke)if(a===Hn){if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),null===r)return null;if(n===Ze)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===$e)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Je)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Ke)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(r=e.get("WEBGL_compressed_texture_s3tc"),null===r)return null;if(n===Ze)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===$e)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Je)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Ke)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===Qe||n===tn||n===en||n===nn){if(r=e.get("WEBGL_compressed_texture_pvrtc"),null===r)return null;if(n===Qe)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===tn)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===en)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===nn)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===rn||n===an||n===sn||n===on||n===ln||n===cn||n===hn){if(r=e.get("WEBGL_compressed_texture_etc"),null===r)return null;if(n===rn||n===an)return a===Hn?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===sn)return a===Hn?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===on)return r.COMPRESSED_R11_EAC;if(n===ln)return r.COMPRESSED_SIGNED_R11_EAC;if(n===cn)return r.COMPRESSED_RG11_EAC;if(n===hn)return r.COMPRESSED_SIGNED_RG11_EAC}if(n===dn||n===un||n===pn||n===mn||n===fn||n===gn||n===vn||n===_n||n===yn||n===xn||n===bn||n===Sn||n===Mn||n===wn){if(r=e.get("WEBGL_compressed_texture_astc"),null===r)return null;if(n===dn)return a===Hn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===un)return a===Hn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===pn)return a===Hn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===mn)return a===Hn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===fn)return a===Hn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===gn)return a===Hn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===vn)return a===Hn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===_n)return a===Hn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===yn)return a===Hn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===xn)return a===Hn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===bn)return a===Hn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Sn)return a===Hn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Mn)return a===Hn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===wn)return a===Hn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===En||n===Tn||n===An){if(r=e.get("EXT_texture_compression_bptc"),null===r)return null;if(n===En)return a===Hn?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Tn)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===An)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(n===Cn||n===Rn||n===In||n===Pn){if(r=e.get("EXT_texture_compression_rgtc"),null===r)return null;if(n===Cn)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Rn)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===In)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Pn)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return n===ze?t.UNSIGNED_INT_24_8:void 0!==t[n]?t[n]:null}}}class Kp{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(null===this.texture){const n=new Zo(t.texture);t.depthNear===e.depthNear&&t.depthFar===e.depthFar||(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=n}}getMesh(t){if(null!==this.texture&&null===this.mesh){const e=t.cameras[0].viewport,n=new wc({vertexShader:"\nvoid main() {\n\n\tgl_Position = vec4( position, 1.0 );\n\n}",fragmentShader:"\nuniform sampler2DArray depthColor;\nuniform float depthWidth;\nuniform float depthHeight;\n\nvoid main() {\n\n\tvec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );\n\n\tif ( coord.x >= 1.0 ) {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;\n\n\t} else {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;\n\n\t}\n\n}",uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new Ss(new lc(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Qp extends mi{constructor(t,e){super();const n=this;let i=null,r=1,a=null,s="local-floor",o=1,l=null,c=null,h=null,d=null,u=null,p=null;const m="undefined"!=typeof XRWebGLBinding,f=new Kp,g={},v=e.getContextAttributes();let _=null,y=null;const x=[],b=[],S=new Ti;let M=null;const w=new wh;w.viewport=new qi;const E=new wh;E.viewport=new qi;const T=[w,E],A=new qh;let C=null,R=null;function I(t){const e=b.indexOf(t.inputSource);if(-1===e)return;const n=x[e];void 0!==n&&(n.update(t.inputSource,t.frame,l||a),n.dispatchEvent({type:t.type,data:t.inputSource}))}function P(){i.removeEventListener("select",I),i.removeEventListener("selectstart",I),i.removeEventListener("selectend",I),i.removeEventListener("squeeze",I),i.removeEventListener("squeezestart",I),i.removeEventListener("squeezeend",I),i.removeEventListener("end",P),i.removeEventListener("inputsourceschange",L);for(let t=0;t<x.length;t++){const e=b[t];null!==e&&(b[t]=null,x[t].disconnect(e))}C=null,R=null,f.reset();for(const t in g)delete g[t];t.setRenderTarget(_),u=null,d=null,h=null,i=null,y=null,F.stop(),n.isPresenting=!1,t.setPixelRatio(M),t.setSize(S.width,S.height,!1),n.dispatchEvent({type:"sessionend"})}function L(t){for(let e=0;e<t.removed.length;e++){const n=t.removed[e],i=b.indexOf(n);i>=0&&(b[i]=null,x[i].disconnect(n))}for(let e=0;e<t.added.length;e++){const n=t.added[e];let i=b.indexOf(n);if(-1===i){for(let t=0;t<x.length;t++){if(t>=b.length){b.push(n),i=t;break}if(null===b[t]){b[t]=n,i=t;break}}if(-1===i)break}const r=x[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=x[t];return void 0===e&&(e=new Cr,x[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=x[t];return void 0===e&&(e=new Cr,x[t]=e),e.getGripSpace()},this.getHand=function(t){let e=x[t];return void 0===e&&(e=new Cr,x[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){r=t,!0===n.isPresenting&&hi("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){s=t,!0===n.isPresenting&&hi("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(t){l=t},this.getBaseLayer=function(){return null!==d?d:u},this.getBinding=function(){return null===h&&m&&(h=new XRWebGLBinding(i,e)),h},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(c){if(i=c,null!==i){if(_=t.getRenderTarget(),i.addEventListener("select",I),i.addEventListener("selectstart",I),i.addEventListener("selectend",I),i.addEventListener("squeeze",I),i.addEventListener("squeezestart",I),i.addEventListener("squeezeend",I),i.addEventListener("end",P),i.addEventListener("inputsourceschange",L),!0!==v.xrCompatible&&await e.makeXRCompatible(),M=t.getPixelRatio(),t.getSize(S),m&&"createProjectionLayer"in XRWebGLBinding.prototype){let n=null,a=null,s=null;v.depth&&(s=v.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,n=v.stencil?He:Ve,a=v.stencil?ze:De);const o={colorFormat:e.RGBA8,depthFormat:s,scaleFactor:r};h=this.getBinding(),d=h.createProjectionLayer(o),i.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),y=new Zi(d.textureWidth,d.textureHeight,{format:Ge,type:Ce,depthTexture:new qo(d.textureWidth,d.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:v.stencil,colorSpace:t.outputColorSpace,samples:v.antialias?4:0,resolveDepthBuffer:!1===d.ignoreDepthValues,resolveStencilBuffer:!1===d.ignoreDepthValues})}else{const n={antialias:v.antialias,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:r};u=new XRWebGLLayer(i,e,n),i.updateRenderState({baseLayer:u}),t.setPixelRatio(1),t.setSize(u.framebufferWidth,u.framebufferHeight,!1),y=new Zi(u.framebufferWidth,u.framebufferHeight,{format:Ge,type:Ce,colorSpace:t.outputColorSpace,stencilBuffer:v.stencil,resolveDepthBuffer:!1===u.ignoreDepthValues,resolveStencilBuffer:!1===u.ignoreDepthValues})}y.isXRRenderTarget=!0,this.setFoveation(o),l=null,a=await i.requestReferenceSpace(s),F.setContext(i),F.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==i)return i.environmentBlendMode},this.getDepthTexture=function(){return f.getDepthTexture()};const D=new Ci,N=new Ci;function O(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.copy(t.matrixWorld).invert()}this.updateCamera=function(t){if(null===i)return;let e=t.near,n=t.far;null!==f.texture&&(f.depthNear>0&&(e=f.depthNear),f.depthFar>0&&(n=f.depthFar)),A.near=E.near=w.near=e,A.far=E.far=w.far=n,C===A.near&&R===A.far||(i.updateRenderState({depthNear:A.near,depthFar:A.far}),C=A.near,R=A.far),A.layers.mask=6|t.layers.mask,w.layers.mask=-5&A.layers.mask,E.layers.mask=-3&A.layers.mask;const r=t.parent,a=A.cameras;O(A,r);for(let t=0;t<a.length;t++)O(a[t],r);2===a.length?function(t,e,n){D.setFromMatrixPosition(e.matrixWorld),N.setFromMatrixPosition(n.matrixWorld);const i=D.distanceTo(N),r=e.projectionMatrix.elements,a=n.projectionMatrix.elements,s=r[14]/(r[10]-1),o=r[14]/(r[10]+1),l=(r[9]+1)/r[5],c=(r[9]-1)/r[5],h=(r[8]-1)/r[0],d=(a[8]+1)/a[0],u=s*h,p=s*d,m=i/(-h+d),f=m*-h;if(e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(f),t.translateZ(m),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.copy(t.matrixWorld).invert(),-1===r[10])t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse);else{const e=s+m,n=o+m,r=u-f,a=p+(i-f),h=l*o/n*e,d=c*o/n*e;t.projectionMatrix.makePerspective(r,a,h,d,e,n),t.projectionMatrixInverse.copy(t.projectionMatrix).invert()}}(A,w,E):A.projectionMatrix.copy(w.projectionMatrix),function(t,e,n){null===n?t.matrix.copy(e.matrixWorld):(t.matrix.copy(n.matrixWorld),t.matrix.invert(),t.matrix.multiply(e.matrixWorld)),t.matrix.decompose(t.position,t.quaternion,t.scale),t.updateMatrixWorld(!0),t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse),t.isPerspectiveCamera&&(t.fov=2*_i*Math.atan(1/t.projectionMatrix.elements[5]),t.zoom=1)}(t,A,r)},this.getCamera=function(){return A},this.getFoveation=function(){if(null!==d||null!==u)return o},this.setFoveation=function(t){o=t,null!==d&&(d.fixedFoveation=t),null!==u&&void 0!==u.fixedFoveation&&(u.fixedFoveation=t)},this.hasDepthSensing=function(){return null!==f.texture},this.getDepthSensingMesh=function(){return f.getMesh(A)},this.getCameraTexture=function(t){return g[t]};let U=null;const F=new fd;F.setAnimationLoop((function(e,r){if(c=r.getViewerPose(l||a),p=r,null!==c){const e=c.views;null!==u&&(t.setRenderTargetFramebuffer(y,u.framebuffer),t.setRenderTarget(y));let r=!1;e.length!==A.cameras.length&&(A.cameras.length=0,r=!0);for(let n=0;n<e.length;n++){const i=e[n];let a=null;if(null!==u)a=u.getViewport(i);else{const e=h.getViewSubImage(d,i);a=e.viewport,0===n&&(t.setRenderTargetTextures(y,e.colorTexture,e.depthStencilTexture),t.setRenderTarget(y))}let s=T[n];void 0===s&&(s=new wh,s.layers.enable(n),s.viewport=new qi,T[n]=s),s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.quaternion,s.scale),s.projectionMatrix.fromArray(i.projectionMatrix),s.projectionMatrixInverse.copy(s.projectionMatrix).invert(),s.viewport.set(a.x,a.y,a.width,a.height),0===n&&(A.matrix.copy(s.matrix),A.matrix.decompose(A.position,A.quaternion,A.scale)),!0===r&&A.cameras.push(s)}const a=i.enabledFeatures;if(a&&a.includes("depth-sensing")&&"gpu-optimized"==i.depthUsage&&m){h=n.getBinding();const t=h.getDepthInformation(e[0]);t&&t.isValid&&t.texture&&f.init(t,i.renderState)}if(a&&a.includes("camera-access")&&m){t.state.unbindTexture(),h=n.getBinding();for(let t=0;t<e.length;t++){const n=e[t].camera;if(n){let t=g[n];t||(t=new Zo,g[n]=t);const e=h.getCameraImage(n);t.sourceTexture=e}}}}for(let t=0;t<x.length;t++){const e=b[t],n=x[t];null!==e&&void 0!==n&&n.update(e,r,l||a)}U&&U(e,r),r.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:r}),p=null})),this.setAnimationLoop=function(t){U=t},this.dispose=function(){}}}const tm=new Ki,em=new Pi;function nm(t,e){function n(t,e){!0===t.matrixAutoUpdate&&t.updateMatrix(),e.value.copy(t.matrix)}function i(t,i){t.opacity.value=i.opacity,i.color&&t.diffuse.value.copy(i.color),i.emissive&&t.emissive.value.copy(i.emissive).multiplyScalar(i.emissiveIntensity),i.map&&(t.map.value=i.map,n(i.map,t.mapTransform)),i.alphaMap&&(t.alphaMap.value=i.alphaMap,n(i.alphaMap,t.alphaMapTransform)),i.bumpMap&&(t.bumpMap.value=i.bumpMap,n(i.bumpMap,t.bumpMapTransform),t.bumpScale.value=i.bumpScale,1===i.side&&(t.bumpScale.value*=-1)),i.normalMap&&(t.normalMap.value=i.normalMap,n(i.normalMap,t.normalMapTransform),t.normalScale.value.copy(i.normalScale),1===i.side&&t.normalScale.value.negate()),i.displacementMap&&(t.displacementMap.value=i.displacementMap,n(i.displacementMap,t.displacementMapTransform),t.displacementScale.value=i.displacementScale,t.displacementBias.value=i.displacementBias),i.emissiveMap&&(t.emissiveMap.value=i.emissiveMap,n(i.emissiveMap,t.emissiveMapTransform)),i.specularMap&&(t.specularMap.value=i.specularMap,n(i.specularMap,t.specularMapTransform)),i.alphaTest>0&&(t.alphaTest.value=i.alphaTest);const r=e.get(i),a=r.envMap,s=r.envMapRotation;a&&(t.envMap.value=a,t.envMapRotation.value.setFromMatrix4(tm.makeRotationFromEuler(s)).transpose(),a.isCubeTexture&&!1===a.isRenderTargetTexture&&t.envMapRotation.value.premultiply(em),t.reflectivity.value=i.reflectivity,t.ior.value=i.ior,t.refractionRatio.value=i.refractionRatio),i.lightMap&&(t.lightMap.value=i.lightMap,t.lightMapIntensity.value=i.lightMapIntensity,n(i.lightMap,t.lightMapTransform)),i.aoMap&&(t.aoMap.value=i.aoMap,t.aoMapIntensity.value=i.aoMapIntensity,n(i.aoMap,t.aoMapTransform))}return{refreshFogUniforms:function(e,n){n.color.getRGB(e.fogColor.value,Sc(t)),n.isFog?(e.fogNear.value=n.near,e.fogFar.value=n.far):n.isFogExp2&&(e.fogDensity.value=n.density)},refreshMaterialUniforms:function(t,r,a,s,o){r.isNodeMaterial?r.uniformsNeedUpdate=!1:r.isMeshBasicMaterial?i(t,r):r.isMeshLambertMaterial?(i(t,r),r.envMap&&(t.envMapIntensity.value=r.envMapIntensity)):r.isMeshToonMaterial?(i(t,r),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(t,r)):r.isMeshPhongMaterial?(i(t,r),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4)}(t,r),r.envMap&&(t.envMapIntensity.value=r.envMapIntensity)):r.isMeshStandardMaterial?(i(t,r),function(t,e){t.metalness.value=e.metalness,e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap,n(e.metalnessMap,t.metalnessMapTransform)),t.roughness.value=e.roughness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap,n(e.roughnessMap,t.roughnessMapTransform)),e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}(t,r),r.isMeshPhysicalMaterial&&function(t,e,i){t.ior.value=e.ior,e.sheen>0&&(t.sheenColor.value.copy(e.sheenColor).multiplyScalar(e.sheen),t.sheenRoughness.value=e.sheenRoughness,e.sheenColorMap&&(t.sheenColorMap.value=e.sheenColorMap,n(e.sheenColorMap,t.sheenColorMapTransform)),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap,n(e.sheenRoughnessMap,t.sheenRoughnessMapTransform))),e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap,n(e.clearcoatMap,t.clearcoatMapTransform)),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap,n(e.clearcoatRoughnessMap,t.clearcoatRoughnessMapTransform)),e.clearcoatNormalMap&&(t.clearcoatNormalMap.value=e.clearcoatNormalMap,n(e.clearcoatNormalMap,t.clearcoatNormalMapTransform),t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),1===e.side&&t.clearcoatNormalScale.value.negate())),e.dispersion>0&&(t.dispersion.value=e.dispersion),e.iridescence>0&&(t.iridescence.value=e.iridescence,t.iridescenceIOR.value=e.iridescenceIOR,t.iridescenceThicknessMinimum.value=e.iridescenceThicknessRange[0],t.iridescenceThicknessMaximum.value=e.iridescenceThicknessRange[1],e.iridescenceMap&&(t.iridescenceMap.value=e.iridescenceMap,n(e.iridescenceMap,t.iridescenceMapTransform)),e.iridescenceThicknessMap&&(t.iridescenceThicknessMap.value=e.iridescenceThicknessMap,n(e.iridescenceThicknessMap,t.iridescenceThicknessMapTransform))),e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=i.texture,t.transmissionSamplerSize.value.set(i.width,i.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap,n(e.transmissionMap,t.transmissionMapTransform)),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap,n(e.thicknessMap,t.thicknessMapTransform)),t.attenuationDistance.value=e.attenuationDistance,t.attenuationColor.value.copy(e.attenuationColor)),e.anisotropy>0&&(t.anisotropyVector.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation)),e.anisotropyMap&&(t.anisotropyMap.value=e.anisotropyMap,n(e.anisotropyMap,t.anisotropyMapTransform))),t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap,n(e.specularColorMap,t.specularColorMapTransform)),e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap,n(e.specularIntensityMap,t.specularIntensityMapTransform))}(t,r,o)):r.isMeshMatcapMaterial?(i(t,r),function(t,e){e.matcap&&(t.matcap.value=e.matcap)}(t,r)):r.isMeshDepthMaterial?i(t,r):r.isMeshDistanceMaterial?(i(t,r),function(t,n){const i=e.get(n).light;t.referencePosition.value.setFromMatrixPosition(i.matrixWorld),t.nearDistance.value=i.shadow.camera.near,t.farDistance.value=i.shadow.camera.far}(t,r)):r.isMeshNormalMaterial?i(t,r):r.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,e.map&&(t.map.value=e.map,n(e.map,t.mapTransform))}(t,r),r.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,r)):r.isPointsMaterial?function(t,e,i,r){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*i,t.scale.value=.5*r,e.map&&(t.map.value=e.map,n(e.map,t.uvTransform)),e.alphaMap&&(t.alphaMap.value=e.alphaMap,n(e.alphaMap,t.alphaMapTransform)),e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r,a,s):r.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map,n(e.map,t.mapTransform)),e.alphaMap&&(t.alphaMap.value=e.alphaMap,n(e.alphaMap,t.alphaMapTransform)),e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r):r.isShadowMaterial?(t.color.value.copy(r.color),t.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function im(t,e,n,i){let r={},a={},s=[];const o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function l(t,e,n,i){const r=t.value,a=e+"_"+n;if(void 0===i[a])return"number"==typeof r||"boolean"==typeof r?i[a]=r:ArrayBuffer.isView(r)?i[a]=r.slice():i[a]=r.clone(),!0;{const t=i[a];if("number"==typeof r||"boolean"==typeof r){if(t!==r)return i[a]=r,!0}else{if(ArrayBuffer.isView(r))return!0;if(!1===t.equals(r))return t.copy(r),!0}}return!1}function c(t){const e={boundary:0,storage:0};return"number"==typeof t||"boolean"==typeof t?(e.boundary=4,e.storage=4):t.isVector2?(e.boundary=8,e.storage=8):t.isVector3||t.isColor?(e.boundary=16,e.storage=12):t.isVector4?(e.boundary=16,e.storage=16):t.isMatrix3?(e.boundary=48,e.storage=48):t.isMatrix4?(e.boundary=64,e.storage=64):t.isTexture?hi("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(t)?(e.boundary=16,e.storage=t.byteLength):hi("WebGLRenderer: Unsupported uniform value type.",t),e}function h(e){const n=e.target;n.removeEventListener("dispose",h);const i=s.indexOf(n.__bindingPointIndex);s.splice(i,1),t.deleteBuffer(r[n.id]),delete r[n.id],delete a[n.id]}return{bind:function(t,e){const n=e.program;i.uniformBlockBinding(t,n)},update:function(n,d){let u=r[n.id];void 0===u&&(function(t){const e=t.uniforms;let n=0;const i=16;for(let t=0,r=e.length;t<r;t++){const r=Array.isArray(e[t])?e[t]:[e[t]];for(let t=0,e=r.length;t<e;t++){const e=r[t],a=Array.isArray(e.value)?e.value:[e.value];for(let t=0,r=a.length;t<r;t++){const r=c(a[t]),s=n%i,o=s%r.boundary,l=s+o;n+=o,0!==l&&i-l<r.storage&&(n+=i-l),e.__data=new Float32Array(r.storage/Float32Array.BYTES_PER_ELEMENT),e.__offset=n,n+=r.storage}}}const r=n%i;r>0&&(n+=i-r),t.__size=n,t.__cache={}}(n),u=function(e){const n=function(){for(let t=0;t<o;t++)if(-1===s.indexOf(t))return s.push(t),t;return di("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();e.__bindingPointIndex=n;const i=t.createBuffer(),r=e.__size,a=e.usage;return t.bindBuffer(t.UNIFORM_BUFFER,i),t.bufferData(t.UNIFORM_BUFFER,r,a),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,n,i),i}(n),r[n.id]=u,n.addEventListener("dispose",h));const p=d.program;i.updateUBOMapping(n,p);const m=e.render.frame;a[n.id]!==m&&(function(e){const n=r[e.id],i=e.uniforms,a=e.__cache;t.bindBuffer(t.UNIFORM_BUFFER,n);for(let e=0,n=i.length;e<n;e++){const n=Array.isArray(i[e])?i[e]:[i[e]];for(let i=0,r=n.length;i<r;i++){const r=n[i];if(!0===l(r,e,i,a)){const e=r.__offset,n=Array.isArray(r.value)?r.value:[r.value];let i=0;for(let a=0;a<n.length;a++){const s=n[a],o=c(s);"number"==typeof s||"boolean"==typeof s?(r.__data[0]=s,t.bufferSubData(t.UNIFORM_BUFFER,e+i,r.__data)):s.isMatrix3?(r.__data[0]=s.elements[0],r.__data[1]=s.elements[1],r.__data[2]=s.elements[2],r.__data[3]=0,r.__data[4]=s.elements[3],r.__data[5]=s.elements[4],r.__data[6]=s.elements[5],r.__data[7]=0,r.__data[8]=s.elements[6],r.__data[9]=s.elements[7],r.__data[10]=s.elements[8],r.__data[11]=0):ArrayBuffer.isView(s)?r.__data.set(new s.constructor(s.buffer,s.byteOffset,r.__data.length)):(s.toArray(r.__data,i),i+=o.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,e,r.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}(n),a[n.id]=m)},dispose:function(){for(const e in r)t.deleteBuffer(r[e]);s=[],r={},a={}}}}em.set(-1,0,0,0,1,0,0,0,1);const rm=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let am=null;class sm{constructor(t={}){const{canvas:e=si(),context:n=null,depth:i=!0,stencil:r=!1,alpha:a=!1,antialias:s=!1,premultipliedAlpha:o=!0,preserveDrawingBuffer:l=!1,powerPreference:c="default",failIfMajorPerformanceCaveat:h=!1,reversedDepthBuffer:d=!1,outputBufferType:u=Ce}=t;let p;if(this.isWebGLRenderer=!0,null!==n){if("undefined"!=typeof WebGLRenderingContext&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=n.getContextAttributes().alpha}else p=a;const m=u,f=new Set([Ye,qe,je]),g=new Set([Ce,De,Pe,ze,Ue,Fe]),v=new Uint32Array(4),_=new Int32Array(4),y=new Ci;let x=null,b=null;const S=[],M=[];let w=null;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=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const E=this;let T=!1,A=null;this._outputColorSpace=Bn;let C=0,R=0,I=null,P=-1,L=null;const D=new qi,N=new qi;let O=null;const U=new Dr(0);let F=0,z=e.width,k=e.height,B=1,G=null,V=null;const H=new qi(0,0,z,k),W=new qi(0,0,z,k);let j=!1;const X=new eo;let q=!1,Y=!1;const Z=new Ki,$=new Ci,J=new qi,K={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Q=!1;function tt(){return null===I?B:1}let et,nt,it,rt,at,st,ot,lt,ct,ht,dt,ut,pt,mt,ft,gt,vt,_t,yt,bt,St,Mt,wt,Et=n;function Tt(t,n){return e.getContext(t,n)}try{const t={alpha:!0,depth:i,stencil:r,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:l,powerPreference:c,failIfMajorPerformanceCaveat:h};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${xt}`),e.addEventListener("webglcontextlost",Rt,!1),e.addEventListener("webglcontextrestored",It,!1),e.addEventListener("webglcontextcreationerror",Pt,!1),null===Et){const e="webgl2";if(Et=Tt(e,t),null===Et)throw Tt(e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(t){throw di("WebGLRenderer: "+t.message),t}function At(){et=new Wd(Et),et.init(),St=new Jp(Et,et),nt=new Td(Et,et,t,St),it=new Zp(Et,et),nt.reversedDepthBuffer&&d&&it.buffers.depth.setReversed(!0),rt=new qd(Et),at=new Lp,st=new $p(Et,et,it,at,nt,St,rt),ot=new Hd(E),lt=new gd(Et),Mt=new wd(Et,lt),ct=new jd(Et,lt,rt,Mt),ht=new Zd(Et,ct,lt,Mt,rt),_t=new Yd(Et,nt,st),ft=new Ad(at),dt=new Pp(E,ot,et,nt,Mt,ft),ut=new nm(E,at),pt=new Up,mt=new Vp(et),vt=new Md(E,ot,it,ht,p,o),gt=new Yp(E,ht,nt),wt=new im(Et,rt,nt,it),yt=new Ed(Et,et,rt),bt=new Xd(Et,et,rt),rt.programs=dt.programs,E.capabilities=nt,E.extensions=et,E.properties=at,E.renderLists=pt,E.shadowMap=gt,E.state=it,E.info=rt}At(),m!==Ce&&(w=new Jd(m,e.width,e.height,i,r));const Ct=new Qp(E,Et);function Rt(t){t.preventDefault(),li("WebGLRenderer: Context Lost."),T=!0}function It(){li("WebGLRenderer: Context Restored."),T=!1;const t=rt.autoReset,e=gt.enabled,n=gt.autoUpdate,i=gt.needsUpdate,r=gt.type;At(),rt.autoReset=t,gt.enabled=e,gt.autoUpdate=n,gt.needsUpdate=i,gt.type=r}function Pt(t){di("WebGLRenderer: A WebGL context could not be created. Reason: ",t.statusMessage)}function Lt(t){const e=t.target;e.removeEventListener("dispose",Lt),function(t){(function(t){const e=at.get(t).programs;void 0!==e&&(e.forEach((function(t){dt.releaseProgram(t)})),t.isShaderMaterial&&dt.releaseShaderCache(t))})(t),at.remove(t)}(e)}function Dt(t,e,n){!0===t.transparent&&2===t.side&&!1===t.forceSinglePass?(t.side=1,t.needsUpdate=!0,Ht(t,e,n),t.side=0,t.needsUpdate=!0,Ht(t,e,n),t.side=2):Ht(t,e,n)}this.xr=Ct,this.getContext=function(){return Et},this.getContextAttributes=function(){return Et.getContextAttributes()},this.forceContextLoss=function(){const t=et.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){const t=et.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return B},this.setPixelRatio=function(t){void 0!==t&&(B=t,this.setSize(z,k,!1))},this.getSize=function(t){return t.set(z,k)},this.setSize=function(t,n,i=!0){Ct.isPresenting?hi("WebGLRenderer: Can't change size while VR device is presenting."):(z=t,k=n,e.width=Math.floor(t*B),e.height=Math.floor(n*B),!0===i&&(e.style.width=t+"px",e.style.height=n+"px"),null!==w&&w.setSize(e.width,e.height),this.setViewport(0,0,t,n))},this.getDrawingBufferSize=function(t){return t.set(z*B,k*B).floor()},this.setDrawingBufferSize=function(t,n,i){z=t,k=n,B=i,e.width=Math.floor(t*i),e.height=Math.floor(n*i),this.setViewport(0,0,t,n)},this.setEffects=function(t){if(m!==Ce){if(t)for(let e=0;e<t.length;e++)if(!0===t[e].isOutputPass){hi("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}w.setEffects(t||[])}else di("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.")},this.getCurrentViewport=function(t){return t.copy(D)},this.getViewport=function(t){return t.copy(H)},this.setViewport=function(t,e,n,i){t.isVector4?H.set(t.x,t.y,t.z,t.w):H.set(t,e,n,i),it.viewport(D.copy(H).multiplyScalar(B).round())},this.getScissor=function(t){return t.copy(W)},this.setScissor=function(t,e,n,i){t.isVector4?W.set(t.x,t.y,t.z,t.w):W.set(t,e,n,i),it.scissor(N.copy(W).multiplyScalar(B).round())},this.getScissorTest=function(){return j},this.setScissorTest=function(t){it.setScissorTest(j=t)},this.setOpaqueSort=function(t){G=t},this.setTransparentSort=function(t){V=t},this.getClearColor=function(t){return t.copy(vt.getClearColor())},this.setClearColor=function(){vt.setClearColor(...arguments)},this.getClearAlpha=function(){return vt.getClearAlpha()},this.setClearAlpha=function(){vt.setClearAlpha(...arguments)},this.clear=function(t=!0,e=!0,n=!0){let i=0;if(t){let t=!1;if(null!==I){const e=I.texture.format;t=f.has(e)}if(t){const t=I.texture.type,e=g.has(t),n=vt.getClearColor(),i=vt.getClearAlpha(),r=n.r,a=n.g,s=n.b;e?(v[0]=r,v[1]=a,v[2]=s,v[3]=i,Et.clearBufferuiv(Et.COLOR,0,v)):(_[0]=r,_[1]=a,_[2]=s,_[3]=i,Et.clearBufferiv(Et.COLOR,0,_))}else i|=Et.COLOR_BUFFER_BIT}e&&(i|=Et.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),n&&(i|=Et.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),0!==i&&Et.clear(i)},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.setNodesHandler=function(t){t.setRenderer(this),A=t},this.dispose=function(){e.removeEventListener("webglcontextlost",Rt,!1),e.removeEventListener("webglcontextrestored",It,!1),e.removeEventListener("webglcontextcreationerror",Pt,!1),vt.dispose(),pt.dispose(),mt.dispose(),at.dispose(),ot.dispose(),ht.dispose(),Mt.dispose(),wt.dispose(),dt.dispose(),Ct.dispose(),Ct.removeEventListener("sessionstart",Ot),Ct.removeEventListener("sessionend",Ut),Ft.stop()},this.renderBufferDirect=function(t,e,n,i,r,a){null===e&&(e=K);const s=r.isMesh&&r.matrixWorld.determinant()<0,o=function(t,e,n,i,r){!0!==e.isScene&&(e=K),st.resetTextureUnits();const a=e.fog,s=i.isMeshStandardMaterial||i.isMeshLambertMaterial||i.isMeshPhongMaterial?e.environment:null,o=null===I?E.outputColorSpace:!0===I.isXRRenderTarget?I.texture.colorSpace:Ui.workingColorSpace,l=i.isMeshStandardMaterial||i.isMeshLambertMaterial&&!i.envMap||i.isMeshPhongMaterial&&!i.envMap,c=ot.get(i.envMap||s,l),h=!0===i.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,d=!!n.attributes.tangent&&(!!i.normalMap||i.anisotropy>0),u=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,m=!!n.morphAttributes.color;let f=0;i.toneMapped&&(null!==I&&!0!==I.isXRRenderTarget||(f=E.toneMapping));const g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,v=void 0!==g?g.length:0,_=at.get(i),x=b.state.lights;if(!0===q&&(!0===Y||t!==L)){const e=t===L&&i.id===P;ft.setState(i,t,e)}let S=!1;i.version===_.__version?_.needsLights&&_.lightsStateVersion!==x.state.version||_.outputColorSpace!==o||r.isBatchedMesh&&!1===_.batching?S=!0:r.isBatchedMesh||!0!==_.batching?r.isBatchedMesh&&!0===_.batchingColor&&null===r.colorTexture||r.isBatchedMesh&&!1===_.batchingColor&&null!==r.colorTexture||r.isInstancedMesh&&!1===_.instancing?S=!0:r.isInstancedMesh||!0!==_.instancing?r.isSkinnedMesh&&!1===_.skinning?S=!0:r.isSkinnedMesh||!0!==_.skinning?r.isInstancedMesh&&!0===_.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===_.instancingColor&&null!==r.instanceColor||r.isInstancedMesh&&!0===_.instancingMorph&&null===r.morphTexture||r.isInstancedMesh&&!1===_.instancingMorph&&null!==r.morphTexture||_.envMap!==c||!0===i.fog&&_.fog!==a?S=!0:void 0===_.numClippingPlanes||_.numClippingPlanes===ft.numPlanes&&_.numIntersection===ft.numIntersection?(_.vertexAlphas!==h||_.vertexTangents!==d||_.morphTargets!==u||_.morphNormals!==p||_.morphColors!==m||_.toneMapping!==f||_.morphTargetsCount!==v||!!_.lightProbeGrid!=b.state.lightProbeGridArray.length>0)&&(S=!0):S=!0:S=!0:S=!0:S=!0:(S=!0,_.__version=i.version);let M=_.currentProgram;!0===S&&(M=Ht(i,e,r),A&&i.isNodeMaterial&&A.onUpdateProgram(i,M,_));let w=!1,T=!1,C=!1;const R=M.getUniforms(),D=_.uniforms;if(it.useProgram(M.program)&&(w=!0,T=!0,C=!0),i.id!==P&&(P=i.id,T=!0),_.needsLights){const t=function(t,e){if(0===t.length)return null;if(1===t.length)return null!==t[0].texture?t[0]:null;y.setFromMatrixPosition(e.matrixWorld);for(let e=0,n=t.length;e<n;e++){const n=t[e];if(null!==n.texture&&n.boundingBox.containsPoint(y))return n}return null}(b.state.lightProbeGridArray,r);_.lightProbeGrid!==t&&(_.lightProbeGrid=t,T=!0)}if(w||L!==t){it.buffers.depth.getReversed()&&!0!==t.reversedDepth&&(t._reversedDepth=!0,t.updateProjectionMatrix()),R.setValue(Et,"projectionMatrix",t.projectionMatrix),R.setValue(Et,"viewMatrix",t.matrixWorldInverse);const e=R.map.cameraPosition;void 0!==e&&e.setValue(Et,$.setFromMatrixPosition(t.matrixWorld)),nt.logarithmicDepthBuffer&&R.setValue(Et,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&R.setValue(Et,"isOrthographic",!0===t.isOrthographicCamera),L!==t&&(L=t,T=!0,C=!0)}if(_.needsLights&&(x.state.directionalShadowMap.length>0&&R.setValue(Et,"directionalShadowMap",x.state.directionalShadowMap,st),x.state.spotShadowMap.length>0&&R.setValue(Et,"spotShadowMap",x.state.spotShadowMap,st),x.state.pointShadowMap.length>0&&R.setValue(Et,"pointShadowMap",x.state.pointShadowMap,st)),r.isSkinnedMesh){R.setOptional(Et,r,"bindMatrix"),R.setOptional(Et,r,"bindMatrixInverse");const t=r.skeleton;t&&(null===t.boneTexture&&t.computeBoneTexture(),R.setValue(Et,"boneTexture",t.boneTexture,st))}r.isBatchedMesh&&(R.setOptional(Et,r,"batchingTexture"),R.setValue(Et,"batchingTexture",r._matricesTexture,st),R.setOptional(Et,r,"batchingIdTexture"),R.setValue(Et,"batchingIdTexture",r._indirectTexture,st),R.setOptional(Et,r,"batchingColorTexture"),null!==r._colorsTexture&&R.setValue(Et,"batchingColorTexture",r._colorsTexture,st));const N=n.morphAttributes;if(void 0===N.position&&void 0===N.normal&&void 0===N.color||_t.update(r,n,M),(T||_.receiveShadow!==r.receiveShadow)&&(_.receiveShadow=r.receiveShadow,R.setValue(Et,"receiveShadow",r.receiveShadow)),(i.isMeshStandardMaterial||i.isMeshLambertMaterial||i.isMeshPhongMaterial)&&null===i.envMap&&null!==e.environment&&(D.envMapIntensity.value=e.environmentIntensity),void 0!==D.dfgLUT&&(D.dfgLUT.value=(null===am&&(am=new Os(rm,16,16,Xe,Oe),am.name="DFG_LUT",am.minFilter=Ee,am.magFilter=Ee,am.wrapS=xe,am.wrapT=xe,am.generateMipmaps=!1,am.needsUpdate=!0),am)),T){if(R.setValue(Et,"toneMappingExposure",E.toneMappingExposure),_.needsLights&&(U=C,(O=D).ambientLightColor.needsUpdate=U,O.lightProbe.needsUpdate=U,O.directionalLights.needsUpdate=U,O.directionalLightShadows.needsUpdate=U,O.pointLights.needsUpdate=U,O.pointLightShadows.needsUpdate=U,O.spotLights.needsUpdate=U,O.spotLightShadows.needsUpdate=U,O.rectAreaLights.needsUpdate=U,O.hemisphereLights.needsUpdate=U),a&&!0===i.fog&&ut.refreshFogUniforms(D,a),ut.refreshMaterialUniforms(D,i,B,k,b.state.transmissionRenderTarget[t.id]),_.needsLights&&_.lightProbeGrid){const t=_.lightProbeGrid;D.probesSH.value=t.texture,D.probesMin.value.copy(t.boundingBox.min),D.probesMax.value.copy(t.boundingBox.max),D.probesResolution.value.copy(t.resolution)}np.upload(Et,Wt(_),D,st)}var O,U;if(i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(np.upload(Et,Wt(_),D,st),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&R.setValue(Et,"center",r.center),R.setValue(Et,"modelViewMatrix",r.modelViewMatrix),R.setValue(Et,"normalMatrix",r.normalMatrix),R.setValue(Et,"modelMatrix",r.matrixWorld),void 0!==i.uniformsGroups){const t=i.uniformsGroups;for(let e=0,n=t.length;e<n;e++){const n=t[e];wt.update(n,M),wt.bind(n,M)}}return M}(t,e,n,i,r);it.setMaterial(i,s);let l=n.index,c=1;if(!0===i.wireframe){if(l=ct.getWireframeAttribute(n),void 0===l)return;c=2}const h=n.drawRange,d=n.attributes.position;let u=h.start*c,p=(h.start+h.count)*c;null!==a&&(u=Math.max(u,a.start*c),p=Math.min(p,(a.start+a.count)*c)),null!==l?(u=Math.max(u,0),p=Math.min(p,l.count)):null!=d&&(u=Math.max(u,0),p=Math.min(p,d.count));const m=p-u;if(m<0||m===1/0)return;let f;Mt.setup(r,i,o,n,l);let g=yt;if(null!==l&&(f=lt.get(l),g=bt,g.setIndex(f)),r.isMesh)!0===i.wireframe?(it.setLineWidth(i.wireframeLinewidth*tt()),g.setMode(Et.LINES)):g.setMode(Et.TRIANGLES);else if(r.isLine){let t=i.linewidth;void 0===t&&(t=1),it.setLineWidth(t*tt()),r.isLineSegments?g.setMode(Et.LINES):r.isLineLoop?g.setMode(Et.LINE_LOOP):g.setMode(Et.LINE_STRIP)}else r.isPoints?g.setMode(Et.POINTS):r.isSprite&&g.setMode(Et.TRIANGLES);if(r.isBatchedMesh)if(et.get("WEBGL_multi_draw"))g.renderMultiDraw(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount);else{const t=r._multiDrawStarts,e=r._multiDrawCounts,n=r._multiDrawCount,a=l?lt.get(l).bytesPerElement:1,s=at.get(i).currentProgram.getUniforms();for(let i=0;i<n;i++)s.setValue(Et,"_gl_DrawID",i),g.render(t[i]/a,e[i])}else if(r.isInstancedMesh)g.renderInstances(u,m,r.count);else if(n.isInstancedBufferGeometry){const t=void 0!==n._maxInstanceCount?n._maxInstanceCount:1/0,e=Math.min(n.instanceCount,t);g.renderInstances(u,m,e)}else g.render(u,m)},this.compile=function(t,e,n=null){null===n&&(n=t),b=mt.get(n),b.init(e),M.push(b),n.traverseVisible((function(t){t.isLight&&t.layers.test(e.layers)&&(b.pushLight(t),t.castShadow&&b.pushShadow(t))})),t!==n&&t.traverseVisible((function(t){t.isLight&&t.layers.test(e.layers)&&(b.pushLight(t),t.castShadow&&b.pushShadow(t))})),b.setupLights();const i=new Set;return t.traverse((function(t){if(!(t.isMesh||t.isPoints||t.isLine||t.isSprite))return;const e=t.material;if(e)if(Array.isArray(e))for(let r=0;r<e.length;r++){const a=e[r];Dt(a,n,t),i.add(a)}else Dt(e,n,t),i.add(e)})),b=M.pop(),i},this.compileAsync=function(t,e,n=null){const i=this.compile(t,e,n);return new Promise((e=>{function n(){i.forEach((function(t){at.get(t).currentProgram.isReady()&&i.delete(t)})),0!==i.size?setTimeout(n,10):e(t)}null!==et.get("KHR_parallel_shader_compile")?n():setTimeout(n,10)}))};let Nt=null;function Ot(){Ft.stop()}function Ut(){Ft.start()}const Ft=new fd;function zt(t,e,n,i){if(!1===t.visible)return;if(t.layers.test(e.layers))if(t.isGroup)n=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLightProbeGrid)b.pushLightProbeGrid(t);else if(t.isLight)b.pushLight(t),t.castShadow&&b.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||X.intersectsSprite(t)){i&&J.setFromMatrixPosition(t.matrixWorld).applyMatrix4(Z);const e=ht.update(t),r=t.material;r.visible&&x.push(t,e,r,n,J.z,null)}}else if((t.isMesh||t.isLine||t.isPoints)&&(!t.frustumCulled||X.intersectsObject(t))){const e=ht.update(t),r=t.material;if(i&&(void 0!==t.boundingSphere?(null===t.boundingSphere&&t.computeBoundingSphere(),J.copy(t.boundingSphere.center)):(null===e.boundingSphere&&e.computeBoundingSphere(),J.copy(e.boundingSphere.center)),J.applyMatrix4(t.matrixWorld).applyMatrix4(Z)),Array.isArray(r)){const i=e.groups;for(let a=0,s=i.length;a<s;a++){const s=i[a],o=r[s.materialIndex];o&&o.visible&&x.push(t,e,o,n,J.z,s)}}else r.visible&&x.push(t,e,r,n,J.z,null)}const r=t.children;for(let t=0,a=r.length;t<a;t++)zt(r[t],e,n,i)}function kt(t,e,n,i){const{opaque:r,transmissive:a,transparent:s}=t;b.setupLightsView(n),!0===q&&ft.setGlobalState(E.clippingPlanes,n),i&&it.viewport(D.copy(i)),r.length>0&&Gt(r,e,n),a.length>0&&Gt(a,e,n),s.length>0&&Gt(s,e,n),it.buffers.depth.setTest(!0),it.buffers.depth.setMask(!0),it.buffers.color.setMask(!0),it.setPolygonOffset(!1)}function Bt(t,e,n,i){if(null!==(!0===n.isScene?n.overrideMaterial:null))return;if(void 0===b.state.transmissionRenderTarget[i.id]){const t=et.has("EXT_color_buffer_half_float")||et.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[i.id]=new Zi(1,1,{generateMipmaps:!0,type:t?Oe:Ce,minFilter:Ae,samples:Math.max(4,nt.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ui.workingColorSpace})}const a=b.state.transmissionRenderTarget[i.id],s=i.viewport||D;a.setSize(s.z*E.transmissionResolutionScale,s.w*E.transmissionResolutionScale);const o=E.getRenderTarget(),l=E.getActiveCubeFace(),c=E.getActiveMipmapLevel();E.setRenderTarget(a),E.getClearColor(U),F=E.getClearAlpha(),F<1&&E.setClearColor(16777215,.5),E.clear(),Q&&vt.render(n);const h=E.toneMapping;E.toneMapping=0;const d=i.viewport;if(void 0!==i.viewport&&(i.viewport=void 0),b.setupLightsView(i),!0===q&&ft.setGlobalState(E.clippingPlanes,i),Gt(t,n,i),st.updateMultisampleRenderTarget(a),st.updateRenderTargetMipmap(a),!1===et.has("WEBGL_multisampled_render_to_texture")){let t=!1;for(let r=0,a=e.length;r<a;r++){const a=e[r],{object:s,geometry:o,material:l,group:c}=a;if(2===l.side&&s.layers.test(i.layers)){const e=l.side;l.side=1,l.needsUpdate=!0,Vt(s,n,i,o,l,c),l.side=e,l.needsUpdate=!0,t=!0}}!0===t&&(st.updateMultisampleRenderTarget(a),st.updateRenderTargetMipmap(a))}E.setRenderTarget(o,l,c),E.setClearColor(U,F),void 0!==d&&(i.viewport=d),E.toneMapping=h}function Gt(t,e,n){const i=!0===e.isScene?e.overrideMaterial:null;for(let r=0,a=t.length;r<a;r++){const a=t[r],{object:s,geometry:o,group:l}=a;let c=a.material;!0===c.allowOverride&&null!==i&&(c=i),s.layers.test(n.layers)&&Vt(s,e,n,o,c,l)}}function Vt(t,e,n,i,r,a){t.onBeforeRender(E,e,n,i,r,a),t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),r.onBeforeRender(E,e,n,i,t,a),!0===r.transparent&&2===r.side&&!1===r.forceSinglePass?(r.side=1,r.needsUpdate=!0,E.renderBufferDirect(n,e,i,r,t,a),r.side=0,r.needsUpdate=!0,E.renderBufferDirect(n,e,i,r,t,a),r.side=2):E.renderBufferDirect(n,e,i,r,t,a),t.onAfterRender(E,e,n,i,r,a)}function Ht(t,e,n){!0!==e.isScene&&(e=K);const i=at.get(t),r=b.state.lights,a=b.state.shadowsArray,s=r.state.version,o=dt.getParameters(t,r.state,a,e,n,b.state.lightProbeGridArray),l=dt.getProgramCacheKey(o);let c=i.programs;i.environment=t.isMeshStandardMaterial||t.isMeshLambertMaterial||t.isMeshPhongMaterial?e.environment:null,i.fog=e.fog;const h=t.isMeshStandardMaterial||t.isMeshLambertMaterial&&!t.envMap||t.isMeshPhongMaterial&&!t.envMap;i.envMap=ot.get(t.envMap||i.environment,h),i.envMapRotation=null!==i.environment&&null===t.envMap?e.environmentRotation:t.envMapRotation,void 0===c&&(t.addEventListener("dispose",Lt),c=new Map,i.programs=c);let d=c.get(l);if(void 0!==d){if(i.currentProgram===d&&i.lightsStateVersion===s)return jt(t,o),d}else o.uniforms=dt.getUniforms(t),null!==A&&t.isNodeMaterial&&A.build(t,n,o),t.onBeforeCompile(o,E),d=dt.acquireProgram(o,l),c.set(l,d),i.uniforms=o.uniforms;const u=i.uniforms;return(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(u.clippingPlanes=ft.uniform),jt(t,o),i.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshToonMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),i.lightsStateVersion=s,i.needsLights&&(u.ambientLightColor.value=r.state.ambient,u.lightProbe.value=r.state.probe,u.directionalLights.value=r.state.directional,u.directionalLightShadows.value=r.state.directionalShadow,u.spotLights.value=r.state.spot,u.spotLightShadows.value=r.state.spotShadow,u.rectAreaLights.value=r.state.rectArea,u.ltc_1.value=r.state.rectAreaLTC1,u.ltc_2.value=r.state.rectAreaLTC2,u.pointLights.value=r.state.point,u.pointLightShadows.value=r.state.pointShadow,u.hemisphereLights.value=r.state.hemi,u.directionalShadowMatrix.value=r.state.directionalShadowMatrix,u.spotLightMatrix.value=r.state.spotLightMatrix,u.spotLightMap.value=r.state.spotLightMap,u.pointShadowMatrix.value=r.state.pointShadowMatrix),i.lightProbeGrid=b.state.lightProbeGridArray.length>0,i.currentProgram=d,i.uniformsList=null,d}function Wt(t){if(null===t.uniformsList){const e=t.currentProgram.getUniforms();t.uniformsList=np.seqWithValue(e.seq,t.uniforms)}return t.uniformsList}function jt(t,e){const n=at.get(t);n.outputColorSpace=e.outputColorSpace,n.batching=e.batching,n.batchingColor=e.batchingColor,n.instancing=e.instancing,n.instancingColor=e.instancingColor,n.instancingMorph=e.instancingMorph,n.skinning=e.skinning,n.morphTargets=e.morphTargets,n.morphNormals=e.morphNormals,n.morphColors=e.morphColors,n.morphTargetsCount=e.morphTargetsCount,n.numClippingPlanes=e.numClippingPlanes,n.numIntersection=e.numClipIntersection,n.vertexAlphas=e.vertexAlphas,n.vertexTangents=e.vertexTangents,n.toneMapping=e.toneMapping}Ft.setAnimationLoop((function(t){Nt&&Nt(t)})),"undefined"!=typeof self&&Ft.setContext(self),this.setAnimationLoop=function(t){Nt=t,Ct.setAnimationLoop(t),null===t?Ft.stop():Ft.start()},Ct.addEventListener("sessionstart",Ot),Ct.addEventListener("sessionend",Ut),this.render=function(t,e){if(void 0!==e&&!0!==e.isCamera)return void di("WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===T)return;null!==A&&A.renderStart(t,e);const n=!0===Ct.enabled&&!0===Ct.isPresenting,i=null!==w&&(null===I||n)&&w.begin(E,I);if(!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),null===e.parent&&!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),!0!==Ct.enabled||!0!==Ct.isPresenting||null!==w&&!1!==w.isCompositing()||(!0===Ct.cameraAutoUpdate&&Ct.updateCamera(e),e=Ct.getCamera()),!0===t.isScene&&t.onBeforeRender(E,t,e,I),b=mt.get(t,M.length),b.init(e),b.state.textureUnits=st.getTextureUnits(),M.push(b),Z.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),X.setFromProjectionMatrix(Z,ei,e.reversedDepth),Y=this.localClippingEnabled,q=ft.init(this.clippingPlanes,Y),x=pt.get(t,S.length),x.init(),S.push(x),!0===Ct.enabled&&!0===Ct.isPresenting){const t=E.xr.getDepthSensingMesh();null!==t&&zt(t,e,-1/0,E.sortObjects)}zt(t,e,0,E.sortObjects),x.finish(),!0===E.sortObjects&&x.sort(G,V),Q=!1===Ct.enabled||!1===Ct.isPresenting||!1===Ct.hasDepthSensing(),Q&&vt.addToRenderList(x,t),this.info.render.frame++,!0===q&&ft.beginShadows();const r=b.state.shadowsArray;if(gt.render(r,t,e),!0===q&&ft.endShadows(),!0===this.info.autoReset&&this.info.reset(),!1===(i&&w.hasRenderPass())){const n=x.opaque,i=x.transmissive;if(b.setupLights(),e.isArrayCamera){const r=e.cameras;if(i.length>0)for(let e=0,a=r.length;e<a;e++)Bt(n,i,t,r[e]);Q&&vt.render(t);for(let e=0,n=r.length;e<n;e++){const n=r[e];kt(x,t,n,n.viewport)}}else i.length>0&&Bt(n,i,t,e),Q&&vt.render(t),kt(x,t,e)}null!==I&&0===R&&(st.updateMultisampleRenderTarget(I),st.updateRenderTargetMipmap(I)),i&&w.end(E),!0===t.isScene&&t.onAfterRender(E,t,e),Mt.resetDefaultState(),P=-1,L=null,M.pop(),M.length>0?(b=M[M.length-1],st.setTextureUnits(b.state.textureUnits),!0===q&&ft.setGlobalState(E.clippingPlanes,b.state.camera)):b=null,S.pop(),x=S.length>0?S[S.length-1]:null,null!==A&&A.renderEnd()},this.getActiveCubeFace=function(){return C},this.getActiveMipmapLevel=function(){return R},this.getRenderTarget=function(){return I},this.setRenderTargetTextures=function(t,e,n){const i=at.get(t);i.__autoAllocateDepthBuffer=!1===t.resolveDepthBuffer,!1===i.__autoAllocateDepthBuffer&&(i.__useRenderToTexture=!1),at.get(t.texture).__webglTexture=e,at.get(t.depthTexture).__webglTexture=i.__autoAllocateDepthBuffer?void 0:n,i.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(t,e){const n=at.get(t);n.__webglFramebuffer=e,n.__useDefaultFramebuffer=void 0===e};const Xt=Et.createFramebuffer();this.setRenderTarget=function(t,e=0,n=0){I=t,C=e,R=n;let i=null,r=!1,a=!1;if(t){const s=at.get(t);if(void 0!==s.__useDefaultFramebuffer)return it.bindFramebuffer(Et.FRAMEBUFFER,s.__webglFramebuffer),D.copy(t.viewport),N.copy(t.scissor),O=t.scissorTest,it.viewport(D),it.scissor(N),it.setScissorTest(O),void(P=-1);if(void 0===s.__webglFramebuffer)st.setupRenderTarget(t);else if(s.__hasExternalTextures)st.rebindTextures(t,at.get(t.texture).__webglTexture,at.get(t.depthTexture).__webglTexture);else if(t.depthBuffer){const e=t.depthTexture;if(s.__boundDepthTexture!==e){if(null!==e&&at.has(e)&&(t.width!==e.image.width||t.height!==e.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");st.setupDepthRenderbuffer(t)}}const o=t.texture;(o.isData3DTexture||o.isDataArrayTexture||o.isCompressedArrayTexture)&&(a=!0);const l=at.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(i=Array.isArray(l[e])?l[e][n]:l[e],r=!0):i=t.samples>0&&!1===st.useMultisampledRTT(t)?at.get(t).__webglMultisampledFramebuffer:Array.isArray(l)?l[n]:l,D.copy(t.viewport),N.copy(t.scissor),O=t.scissorTest}else D.copy(H).multiplyScalar(B).floor(),N.copy(W).multiplyScalar(B).floor(),O=j;if(0!==n&&(i=Xt),it.bindFramebuffer(Et.FRAMEBUFFER,i)&&it.drawBuffers(t,i),it.viewport(D),it.scissor(N),it.setScissorTest(O),r){const i=at.get(t.texture);Et.framebufferTexture2D(Et.FRAMEBUFFER,Et.COLOR_ATTACHMENT0,Et.TEXTURE_CUBE_MAP_POSITIVE_X+e,i.__webglTexture,n)}else if(a){const i=e;for(let e=0;e<t.textures.length;e++){const r=at.get(t.textures[e]);Et.framebufferTextureLayer(Et.FRAMEBUFFER,Et.COLOR_ATTACHMENT0+e,r.__webglTexture,n,i)}}else if(null!==t&&0!==n){const e=at.get(t.texture);Et.framebufferTexture2D(Et.FRAMEBUFFER,Et.COLOR_ATTACHMENT0,Et.TEXTURE_2D,e.__webglTexture,n)}P=-1},this.readRenderTargetPixels=function(t,e,n,i,r,a,s,o=0){if(!t||!t.isWebGLRenderTarget)return void di("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=at.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==s&&(l=l[s]),l){it.bindFramebuffer(Et.FRAMEBUFFER,l);try{const s=t.textures[o],l=s.format,c=s.type;if(t.textures.length>1&&Et.readBuffer(Et.COLOR_ATTACHMENT0+o),!nt.textureFormatReadable(l))return void di("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!nt.textureTypeReadable(c))return void di("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");e>=0&&e<=t.width-i&&n>=0&&n<=t.height-r&&Et.readPixels(e,n,i,r,St.convert(l),St.convert(c),a)}finally{const t=null!==I?at.get(I).__webglFramebuffer:null;it.bindFramebuffer(Et.FRAMEBUFFER,t)}}},this.readRenderTargetPixelsAsync=async function(t,e,n,i,r,a,s,o=0){if(!t||!t.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=at.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==s&&(l=l[s]),l){if(e>=0&&e<=t.width-i&&n>=0&&n<=t.height-r){it.bindFramebuffer(Et.FRAMEBUFFER,l);const s=t.textures[o],c=s.format,h=s.type;if(t.textures.length>1&&Et.readBuffer(Et.COLOR_ATTACHMENT0+o),!nt.textureFormatReadable(c))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!nt.textureTypeReadable(h))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const d=Et.createBuffer();Et.bindBuffer(Et.PIXEL_PACK_BUFFER,d),Et.bufferData(Et.PIXEL_PACK_BUFFER,a.byteLength,Et.STREAM_READ),Et.readPixels(e,n,i,r,St.convert(c),St.convert(h),0);const u=null!==I?at.get(I).__webglFramebuffer:null;it.bindFramebuffer(Et.FRAMEBUFFER,u);const p=Et.fenceSync(Et.SYNC_GPU_COMMANDS_COMPLETE,0);return Et.flush(),await function(t,e,n){return new Promise((function(i,r){setTimeout((function a(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:r();break;case t.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:i()}}),n)}))}(Et,p,4),Et.bindBuffer(Et.PIXEL_PACK_BUFFER,d),Et.getBufferSubData(Et.PIXEL_PACK_BUFFER,0,a),Et.deleteBuffer(d),Et.deleteSync(p),a}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(t,e=null,n=0){const i=Math.pow(2,-n),r=Math.floor(t.image.width*i),a=Math.floor(t.image.height*i),s=null!==e?e.x:0,o=null!==e?e.y:0;st.setTexture2D(t,0),Et.copyTexSubImage2D(Et.TEXTURE_2D,n,0,0,s,o,r,a),it.unbindTexture()};const qt=Et.createFramebuffer(),Yt=Et.createFramebuffer();this.copyTextureToTexture=function(t,e,n=null,i=null,r=0,a=0){let s,o,l,c,h,d,u,p,m;const f=t.isCompressedTexture?t.mipmaps[a]:t.image;if(null!==n)s=n.max.x-n.min.x,o=n.max.y-n.min.y,l=n.isBox3?n.max.z-n.min.z:1,c=n.min.x,h=n.min.y,d=n.isBox3?n.min.z:0;else{const e=Math.pow(2,-r);s=Math.floor(f.width*e),o=Math.floor(f.height*e),l=t.isDataArrayTexture?f.depth:t.isData3DTexture?Math.floor(f.depth*e):1,c=0,h=0,d=0}null!==i?(u=i.x,p=i.y,m=i.z):(u=0,p=0,m=0);const g=St.convert(e.format),v=St.convert(e.type);let _;e.isData3DTexture?(st.setTexture3D(e,0),_=Et.TEXTURE_3D):e.isDataArrayTexture||e.isCompressedArrayTexture?(st.setTexture2DArray(e,0),_=Et.TEXTURE_2D_ARRAY):(st.setTexture2D(e,0),_=Et.TEXTURE_2D),it.activeTexture(Et.TEXTURE0),it.pixelStorei(Et.UNPACK_FLIP_Y_WEBGL,e.flipY),it.pixelStorei(Et.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),it.pixelStorei(Et.UNPACK_ALIGNMENT,e.unpackAlignment);const y=it.getParameter(Et.UNPACK_ROW_LENGTH),x=it.getParameter(Et.UNPACK_IMAGE_HEIGHT),b=it.getParameter(Et.UNPACK_SKIP_PIXELS),S=it.getParameter(Et.UNPACK_SKIP_ROWS),M=it.getParameter(Et.UNPACK_SKIP_IMAGES);it.pixelStorei(Et.UNPACK_ROW_LENGTH,f.width),it.pixelStorei(Et.UNPACK_IMAGE_HEIGHT,f.height),it.pixelStorei(Et.UNPACK_SKIP_PIXELS,c),it.pixelStorei(Et.UNPACK_SKIP_ROWS,h),it.pixelStorei(Et.UNPACK_SKIP_IMAGES,d);const w=t.isDataArrayTexture||t.isData3DTexture,E=e.isDataArrayTexture||e.isData3DTexture;if(t.isDepthTexture){const n=at.get(t),i=at.get(e),f=at.get(n.__renderTarget),g=at.get(i.__renderTarget);it.bindFramebuffer(Et.READ_FRAMEBUFFER,f.__webglFramebuffer),it.bindFramebuffer(Et.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n<l;n++)w&&(Et.framebufferTextureLayer(Et.READ_FRAMEBUFFER,Et.COLOR_ATTACHMENT0,at.get(t).__webglTexture,r,d+n),Et.framebufferTextureLayer(Et.DRAW_FRAMEBUFFER,Et.COLOR_ATTACHMENT0,at.get(e).__webglTexture,a,m+n)),Et.blitFramebuffer(c,h,s,o,u,p,s,o,Et.DEPTH_BUFFER_BIT,Et.NEAREST);it.bindFramebuffer(Et.READ_FRAMEBUFFER,null),it.bindFramebuffer(Et.DRAW_FRAMEBUFFER,null)}else if(0!==r||t.isRenderTargetTexture||at.has(t)){const n=at.get(t),i=at.get(e);it.bindFramebuffer(Et.READ_FRAMEBUFFER,qt),it.bindFramebuffer(Et.DRAW_FRAMEBUFFER,Yt);for(let t=0;t<l;t++)w?Et.framebufferTextureLayer(Et.READ_FRAMEBUFFER,Et.COLOR_ATTACHMENT0,n.__webglTexture,r,d+t):Et.framebufferTexture2D(Et.READ_FRAMEBUFFER,Et.COLOR_ATTACHMENT0,Et.TEXTURE_2D,n.__webglTexture,r),E?Et.framebufferTextureLayer(Et.DRAW_FRAMEBUFFER,Et.COLOR_ATTACHMENT0,i.__webglTexture,a,m+t):Et.framebufferTexture2D(Et.DRAW_FRAMEBUFFER,Et.COLOR_ATTACHMENT0,Et.TEXTURE_2D,i.__webglTexture,a),0!==r?Et.blitFramebuffer(c,h,s,o,u,p,s,o,Et.COLOR_BUFFER_BIT,Et.NEAREST):E?Et.copyTexSubImage3D(_,a,u,p,m+t,c,h,s,o):Et.copyTexSubImage2D(_,a,u,p,c,h,s,o);it.bindFramebuffer(Et.READ_FRAMEBUFFER,null),it.bindFramebuffer(Et.DRAW_FRAMEBUFFER,null)}else E?t.isDataTexture||t.isData3DTexture?Et.texSubImage3D(_,a,u,p,m,s,o,l,g,v,f.data):e.isCompressedArrayTexture?Et.compressedTexSubImage3D(_,a,u,p,m,s,o,l,g,f.data):Et.texSubImage3D(_,a,u,p,m,s,o,l,g,v,f):t.isDataTexture?Et.texSubImage2D(Et.TEXTURE_2D,a,u,p,s,o,g,v,f.data):t.isCompressedTexture?Et.compressedTexSubImage2D(Et.TEXTURE_2D,a,u,p,f.width,f.height,g,f.data):Et.texSubImage2D(Et.TEXTURE_2D,a,u,p,s,o,g,v,f);it.pixelStorei(Et.UNPACK_ROW_LENGTH,y),it.pixelStorei(Et.UNPACK_IMAGE_HEIGHT,x),it.pixelStorei(Et.UNPACK_SKIP_PIXELS,b),it.pixelStorei(Et.UNPACK_SKIP_ROWS,S),it.pixelStorei(Et.UNPACK_SKIP_IMAGES,M),0===a&&e.generateMipmaps&&Et.generateMipmap(_),it.unbindTexture()},this.initRenderTarget=function(t){void 0===at.get(t).__webglFramebuffer&&st.setupRenderTarget(t)},this.initTexture=function(t){t.isCubeTexture?st.setTextureCube(t,0):t.isData3DTexture?st.setTexture3D(t,0):t.isDataArrayTexture||t.isCompressedArrayTexture?st.setTexture2DArray(t,0):st.setTexture2D(t,0),it.unbindTexture()},this.resetState=function(){C=0,R=0,I=null,it.reset(),Mt.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ei}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=Ui._getDrawingBufferColorSpace(t),e.unpackColorSpace=Ui._getUnpackColorSpace()}}
|
|
100
100
|
/**
|
|
101
101
|
* @license
|
|
102
|
-
* Copyright 2018 Advanced Visual Systems Inc.
|
|
102
|
+
* Copyright 2018-2026 Advanced Visual Systems Inc.
|
|
103
103
|
*
|
|
104
104
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
105
105
|
* you may not use this file except in compliance with the License.
|
|
@@ -115,12 +115,12 @@ function md(){let t=null,e=!1,n=null,i=null;function r(e,a){n(e,a),i=t.requestAn
|
|
|
115
115
|
*
|
|
116
116
|
* This product includes software developed at
|
|
117
117
|
* Advanced Visual Systems Inc. (http://www.avs.com)
|
|
118
|
-
*/class
|
|
118
|
+
*/class om extends HTMLElement{constructor(){super(...arguments),this.webGLRenderer=void 0}connectedCallback(){this.webGLRenderer=new sm({alpha:!0})}}customElements.define("avs-renderer",om);
|
|
119
119
|
// @license Licensed by Advanced Visual Systems Inc. to You under the Apache License, Version 2.0.
|
|
120
|
-
var om=0,lm=1,cm=0,hm=1,dm=1,um=2,pm=3,mm=4;const fm=new Ai;class gm extends Er{constructor(){super(),this.scaleFactorX=1,this.scaleFactorY=1,this.scaleFactorZ=1}updateMatrix(){fm.set(this.scale.x*this.scaleFactorX,this.scale.y*this.scaleFactorY,this.scale.z*this.scaleFactorZ),this.matrix.compose(this.position,this.quaternion,fm),this.matrixWorldNeedsUpdate=!0}toJSON(t){const e=super.toJSON(t);return"{}"!==JSON.stringify(this.internalData)&&(e.object.internalData=this.internalData),e.metadata=void 0,1===this.layers.mask&&(e.object.layers=void 0),this.matrix.equals(new Ji)&&(e.object.matrix=void 0),e}}const vm=new Ai,_m=new Ai;class ym extends Ho{constructor(t,e){super(t,e),this.scaleFactorX=1,this.scaleFactorY=1,this.scaleFactorZ=1}updateMatrix(){_m.set(this.scale.x*this.scaleFactorX,this.scale.y*this.scaleFactorY,this.scale.z*this.scaleFactorZ),this.matrix.compose(this.position,this.quaternion,_m),this.matrixWorldNeedsUpdate=!0}toJSON(t){const e=super.toJSON(t);return e.metadata=void 0,1===this.layers.mask&&(e.object.layers=void 0),this.matrix.equals(new Ji)&&(e.object.matrix=void 0),e}raycast(t,e){const n=this.geometry.attributes,i=n.position.array;let r,a,s,o,l,c,h=.5;void 0===this.material.vertexSizes&&(h=this.material.size/2);for(let d=0,u=i.length/3;d<u;d++)vm.fromArray(i,3*d),vm.applyMatrix4(this.matrixWorld),vm.project(t.camera),r=(vm.x+1)/2*t.landscapeWidth,a=(1-(vm.y+1)/2)*t.landscapeHeight,this.material.vertexSizes&&(h=n.vsize.array[d]/2),s=r-h,o=r+h,l=a-h,c=a+h,t.x>=s&&t.x<=o&&t.y>=l&&t.y<=c&&e.push({distance:null,distanceToRay:null,point:null,index:d,face:null,object:this})}}const xm=new Ai;class bm extends Uo{constructor(t,e){super(t,e),this.scaleFactorX=1,this.scaleFactorY=1,this.scaleFactorZ=1}updateMatrix(){xm.set(this.scale.x*this.scaleFactorX,this.scale.y*this.scaleFactorY,this.scale.z*this.scaleFactorZ),this.matrix.compose(this.position,this.quaternion,xm),this.matrixWorldNeedsUpdate=!0}toJSON(t){const e=super.toJSON(t);return e.metadata=void 0,1===this.layers.mask&&(e.object.layers=void 0),this.matrix.equals(new Ji)&&(e.object.matrix=void 0),e}}const Sm=new Ji,Mm=new Ji,wm=new Ji,Em=[],Tm=new bs,Am=new Ai;class Cm extends bs{constructor(t,e){super(t,e),this.scaleFactorX=1,this.scaleFactorY=1,this.scaleFactorZ=1}updateMatrix(){Am.set(this.scale.x*this.scaleFactorX,this.scale.y*this.scaleFactorY,this.scale.z*this.scaleFactorZ),this.matrix.compose(this.position,this.quaternion,Am),this.matrixWorldNeedsUpdate=!0}raycast(t,e){if(Tm.geometry=this.geometry,Tm.material=this.material,void 0===Tm.material||void 0===Tm.geometry)return;if(!Tm.material.glyphs)return super.raycast(t,e);const n=this.matrixWorld,i=Tm.geometry.attributes.glyphOffset.array,r=i.length/3;let a,s,o;for(let l=0;l<r;l++){if(a=3*l,Tm.material.vertexGlyphScales?(s=Tm.geometry.attributes.glyphScale.array,Sm.makeScale(s[a],s[a+1],s[a+2])):Sm.makeScale(Tm.material.glyphScale.x,Tm.material.glyphScale.y,Tm.material.glyphScale.z),Tm.material.vertexGlyphOrientations&&(o=Tm.geometry.attributes.glyphOrientation.array,wm.set(o[a],o[a+3],o[a+6],0,o[a+1],o[a+4],o[a+7],0,o[a+2],o[a+5],o[a+8],0,0,0,0,1),Sm.multiply(wm)),Sm.setPosition(i[a],i[a+1],i[a+2]),Mm.multiplyMatrices(n,Sm),Tm.matrixWorld=Mm,Tm.raycast(t,Em),Em.length>0){const t=Em[0];t.faceIndex=l,t.object=this,e.push(t)}Em.length=0}}toJSON(t){const e=super.toJSON(t);return e.metadata=void 0,1===this.layers.mask&&(e.object.layers=void 0),this.matrix.equals(new Ji)&&(e.object.matrix=void 0),e}}class Rm extends Ah{constructor(t,e=Math.PI){super(t,e)}toJSON(t){const e=super.toJSON(t);return e.metadata=void 0,1===this.layers.mask&&(e.object.layers=void 0),this.matrix.equals(new Ji)&&(e.object.matrix=void 0),16777215===this.color.getHex()&&(e.object.color=void 0),this.intensity===Math.PI&&(e.object.intensity=void 0),e.object.shadow=void 0,e}}class Im extends Ih{constructor(t,e=Math.PI){super(t,e)}toJSON(t){const e=super.toJSON(t);return e.metadata=void 0,1===this.layers.mask&&(e.object.layers=void 0),this.matrix.equals(new Ji)&&(e.object.matrix=void 0),16777215===this.color.getHex()&&(e.object.color=void 0),this.intensity===Math.PI&&(e.object.intensity=void 0),e.object.shadow=void 0,e}}class Pm extends Ph{constructor(t,e=Math.PI){super(t,e)}toJSON(t){const e=super.toJSON(t);return e.metadata=void 0,1===this.layers.mask&&(e.object.layers=void 0),this.matrix.equals(new Ji)&&(e.object.matrix=void 0),16777215===this.color.getHex()&&(e.object.color=void 0),this.intensity===Math.PI&&(e.object.intensity=void 0),e}}class Lm extends Ch{constructor(t,e,n,i,r,a){super(t,e,n,i,r,a),this.keepAspectRatio=!1,this.origLeft=t,this.origRight=e,this.origTop=n,this.origBottom=i}toJSON(t){const e=super.toJSON(t);return e.metadata=void 0,1===this.layers.mask&&(e.object.layers=void 0),this.matrix.equals(new Ji)&&(e.object.matrix=void 0),1===this.zoom&&(e.object.zoom=void 0),-1===this.left&&(e.object.left=void 0),1===this.right&&(e.object.right=void 0),1===this.top&&(e.object.top=void 0),-1===this.bottom&&(e.object.bottom=void 0),.1===this.near&&(e.object.near=void 0),2e3===this.far&&(e.object.far=void 0),this.keepAspectRatio&&(e.object.keepAspectRatio=!0),e}}class Dm extends Mh{toJSON(t){const e=super.toJSON(t);return e.metadata=void 0,1===this.layers.mask&&(e.object.layers=void 0),this.matrix.equals(new Ji)&&(e.object.matrix=void 0),50===this.fov&&(e.object.fov=void 0),1===this.zoom&&(e.object.zoom=void 0),.1===this.near&&(e.object.near=void 0),2e3===this.far&&(e.object.far=void 0),10===this.focus&&(e.object.focus=void 0),1===this.aspect&&(e.object.aspect=void 0),35===this.filmGauge&&(e.object.filmGauge=void 0),0===this.filmOffset&&(e.object.filmOffset=void 0),e}}class Nm extends Ur{toJSON(t){const e=super.toJSON(t);return e.metadata=void 0,1===this.layers.mask&&(e.object.layers=void 0),this.matrix.equals(new Ji)&&(e.object.matrix=void 0),e}}class Om extends Mc{constructor(t){super(),Object.defineProperties(this,{pickState:{get:function(){return this.uniforms.pickState.value},set:function(t){this.uniforms.pickState.value=t}},startCell:{get:function(){return this.uniforms.startCell.value},set:function(t){this.uniforms.startCell.value=t}},glyphs:{get:function(){return this.defines.GLYPH},set:function(t){this.defines.GLYPH=t}},glyphScale:{get:function(){return this.uniforms.uGlyphScale.value},set:function(t){this.uniforms.uGlyphScale.value=t}},glyphScaleFactorX:{get:function(){return this.uniforms.glyphScaleFactorX.value},set:function(t){this.uniforms.glyphScaleFactorX.value=t}},glyphScaleFactorY:{get:function(){return this.uniforms.glyphScaleFactorY.value},set:function(t){this.uniforms.glyphScaleFactorY.value=t}},glyphScaleFactorZ:{get:function(){return this.uniforms.glyphScaleFactorZ.value},set:function(t){this.uniforms.glyphScaleFactorZ.value=t}},vertexGlyphScales:{get:function(){return this.defines.USE_GLYPH_SCALE},set:function(t){this.defines.USE_GLYPH_SCALE=t}},glyphOrientation:{get:function(){return this.uniforms.uGlyphOrientation.value},set:function(t){this.uniforms.uGlyphOrientation.value=t}},vertexGlyphOrientations:{get:function(){return this.defines.USE_GLYPH_ORIENTATION},set:function(t){this.defines.USE_GLYPH_ORIENTATION=t}},opacityFactor:{get:function(){return this.uniforms.opacityFactor.value},set:function(t){this.uniforms.opacityFactor.value=t}}}),this.color=new Lr(16777215),this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this}toJSON(t){const e=super.toJSON(t);return 3===this.depthFunc&&(e.depthFunc=void 0),!0===this.depthTest&&(e.depthTest=void 0),!0===this.depthWrite&&(e.depthWrite=void 0),!1===this.stencilWrite&&(e.stencilWrite=void 0),255===this.stencilWriteMask&&(e.stencilWriteMask=void 0),519===this.stencilFunc&&(e.stencilFunc=void 0),0===this.stencilRef&&(e.stencilRef=void 0),255===this.stencilFuncMask&&(e.stencilFuncMask=void 0),this.stencilFail===Hn&&(e.stencilFail=void 0),this.stencilZFail===Hn&&(e.stencilZFail=void 0),this.stencilZPass===Hn&&(e.stencilZPass=void 0),this.vertexGlyphScales&&(e.vertexGlyphScales=!0),this.vertexGlyphOrientations&&(e.vertexGlyphOrientations=!0),e.uniforms=void 0,e.fragmentShader=void 0,e.vertexShader=void 0,e}equals(t){return t.color.getHex()===this.color.getHex()&&t.opacity===this.opacity&&t.transparent===this.transparent&&t.side===this.side&&t.vertexColors===this.vertexColors}}const Um={base:{pickState:{value:new Float32Array(1)},startCell:{value:0},uGlyphScale:{value:new Ai(1,1,1)},glyphScaleFactorX:{value:1},glyphScaleFactorY:{value:1},glyphScaleFactorZ:{value:1},uGlyphOrientation:{value:new Ii},opacityFactor:{value:1}},line:{linePattern:{value:65535},resolution:{value:new Ei(1,1)}},mesh:{stipple:{value:0},stippleColor:{value:new Lr(0)},stipplePattern:{value:new Float32Array(64)},textureBlending:{value:1}}},Fm="uniform vec3 diffuse;\nuniform float opacity;\nuniform float opacityFactor;\nuniform float linePattern;\nuniform float pickState[ 1 ];\nvarying vec3 vPickColor;\n#ifdef USE_PATTERN\nvarying float vPattern;\n#endif\nvarying float vDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity * opacityFactor );\n\t#include <clipping_planes_fragment>\n\tif ( pickState[ 0 ] > 0.5 ) {\n\t\tgl_FragColor = vec4( vPickColor, 1.0 );\n\t} else {\n\tfloat pattern;\n#ifdef USE_PATTERN\n\tpattern = floor( vPattern );\n#else\n\tpattern = linePattern;\n#endif\n\tfloat shift = pow( 2.0, floor( mod( vDistance, 16.0 ) ) );\n\tif( mod( floor( pattern / shift ), 2.0 ) < 0.5 ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t}\n}",zm=Fm,km=Fm,Bm={points:{uniforms:Sc.merge([vd.points,vd.fog,Um.base]),vertexShader:"attribute float vsize;\nattribute float cellCount;\nattribute vec3 glyphOffset;\nattribute vec3 glyphScale;\nuniform vec3 uGlyphScale;\nuniform float glyphScaleFactorX;\nuniform float glyphScaleFactorY;\nuniform float glyphScaleFactorZ;\nattribute mat3 glyphOrientation;\nuniform mat3 uGlyphOrientation;\nuniform float size;\nuniform float pickState[ 1 ];\nuniform float startCell;\nvarying vec3 vPickColor;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tif ( pickState[ 0 ] > 0.5 ) {\n\t\tfloat cellNum = startCell + cellCount;\n\t\t\n\t\tfloat red = fract( cellNum / (255.0*255.0*255.0) );\n\t\tif ( pickState[ 0 ] > 1.5 ) {\n\t\n\t\t\tfloat red2 = fract( cellNum / (255.0*255.0*255.0*255.0*255.0*255.0) );\n\t\t\tfloat green2 = fract( cellNum / (255.0*255.0*255.0*255.0*255.0) );\n\t\t\tfloat blue2 = fract( cellNum / (255.0*255.0*255.0*255.0) );\n\t\n\t\t\tred2 -= green2 / 255.0;\n\t\t\tgreen2 -= blue2 / 255.0;\n\t\t\tblue2 -= red / 255.0;\n\t\t\tvPickColor = vec3( red2, green2, blue2 );\n\t\t} else {\n\t\t\tfloat green = fract( cellNum / (255.0*255.0) );\n\t\t\tfloat blue = fract( cellNum / 255.0 );\n\t\t\tred -= green / 255.0;\n\t\t\tgreen -= blue / 255.0;\n\t\t\tvPickColor = vec3( red, green, blue );\n\t\t}\n\t}\n\t#include <color_vertex>\n\t#include <begin_vertex>\n#ifdef GLYPH\n#ifdef USE_GLYPH_SCALE\n\ttransformed *= glyphScale;\n#else\n\ttransformed *= uGlyphScale;\n#endif\n\tvec3 glyphScaleFactor = vec3( glyphScaleFactorX, glyphScaleFactorY, glyphScaleFactorZ );\n\ttransformed *= glyphScaleFactor;\n#ifdef USE_GLYPH_ORIENTATION\n\ttransformed = glyphOrientation * transformed;\n#else\n\ttransformed = uGlyphOrientation * transformed;\n#endif\n\ttransformed += glyphOffset;\n#endif\n\t#include <project_vertex>\n#ifdef USE_SIZE\n\tgl_PointSize = vsize;\n#else\n\tgl_PointSize = size;\n#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",fragmentShader:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float opacityFactor;\nuniform float pickState[ 1 ];\nvarying vec3 vPickColor;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity * opacityFactor );\n\t#include <clipping_planes_fragment>\n\tif ( pickState[ 0 ] > 0.5 ) {\n\t\tgl_FragColor = vec4( vPickColor, 1.0 );\n\t} else {\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t}\n}"},line:{uniforms:Sc.merge([vd.common,vd.fog,Um.base,Um.line]),vertexShader:"attribute vec3 otherPosition;\nattribute float pattern;\nattribute float cellCount;\nattribute vec3 glyphOffset;\nattribute vec3 glyphScale;\nuniform vec3 uGlyphScale;\nuniform float glyphScaleFactorX;\nuniform float glyphScaleFactorY;\nuniform float glyphScaleFactorZ;\nattribute mat3 glyphOrientation;\nuniform mat3 uGlyphOrientation;\nuniform float pickState[ 1 ];\nuniform float startCell;\nuniform vec2 resolution;\n#ifdef USE_PATTERN\nvarying float vPattern;\n#endif\nvarying float vDistance;\nvarying vec3 vPickColor;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tif ( pickState[ 0 ] > 0.5 ) {\n\t\tfloat cellNum = startCell + cellCount;\n\t\t\n\t\tfloat red = fract( cellNum / (255.0*255.0*255.0) );\n\t\tif ( pickState[ 0 ] > 1.5 ) {\n\t\n\t\t\tfloat red2 = fract( cellNum / (255.0*255.0*255.0*255.0*255.0*255.0) );\n\t\t\tfloat green2 = fract( cellNum / (255.0*255.0*255.0*255.0*255.0) );\n\t\t\tfloat blue2 = fract( cellNum / (255.0*255.0*255.0*255.0) );\n\t\n\t\t\tred2 -= green2 / 255.0;\n\t\t\tgreen2 -= blue2 / 255.0;\n\t\t\tblue2 -= red / 255.0;\n\t\t\tvPickColor = vec3( red2, green2, blue2 );\n\t\t} else {\n\t\t\tfloat green = fract( cellNum / (255.0*255.0) );\n\t\t\tfloat blue = fract( cellNum / 255.0 );\n\t\t\tred -= green / 255.0;\n\t\t\tgreen -= blue / 255.0;\n\t\t\tvPickColor = vec3( red, green, blue );\n\t\t}\n\t}\n\t#include <color_vertex>\n\tvec3 transformed = vec3( position );\n\tvec3 otherTransformed = vec3( otherPosition );\n#ifdef GLYPH\n#ifdef USE_GLYPH_SCALE\n\ttransformed *= glyphScale;\n\totherTransformed *= glyphScale;\n#else\n\ttransformed *= uGlyphScale;\n\totherTransformed *= uGlyphScale;\n#endif\n\tvec3 glyphScaleFactor = vec3( glyphScaleFactorX, glyphScaleFactorY, glyphScaleFactorZ );\n\ttransformed *= glyphScaleFactor;\n\totherTransformed *= glyphScaleFactor;\n#ifdef USE_GLYPH_ORIENTATION\n\ttransformed = glyphOrientation * transformed;\n\totherTransformed = glyphOrientation * otherTransformed;\n#else\n\ttransformed = uGlyphOrientation * transformed;\n\totherTransformed = uGlyphOrientation * otherTransformed;\n#endif\n\ttransformed += glyphOffset;\n\totherTransformed += glyphOffset;\n#endif\n\tvec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\tvec2 ndcPos1 = gl_Position.xy / gl_Position.w;\n\tvec4 other_Position = projectionMatrix * modelViewMatrix * vec4( otherTransformed, 1.0 );\n\tvec2 ndcPos2 = other_Position.xy / other_Position.w;\n\tfloat aspect = resolution.x / resolution.y;\n\tvec2 dir = ndcPos2 - ndcPos1;\n\tdir.x *= aspect;\n\tbool end = false;\n\tif ( dir.y < -EPSILON ) {\n\t\tend = true;\n\t}\n\telse if ( dir.y > EPSILON ) {\n\t\tend = false;\n\t}\n\telse if ( dir.x < -EPSILON ) {\n\t\tend = true;\n\t}\n\tvDistance = end ? 0.0 : length( dir * resolution ) / 2.0;\n#ifdef USE_PATTERN\n\tvPattern = pattern + 0.5;\n#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",fragmentShader:zm},thick:{uniforms:Sc.merge([vd.common,vd.fog,Um.base,Um.line,{linewidth:{value:1}}]),vertexShader:"attribute vec3 instanceStart;\nattribute vec3 instanceEnd;\nattribute vec3 instanceColorStart;\nattribute vec3 instanceColorEnd;\nattribute float instancePattern;\nattribute float instanceLinewidthStart;\nattribute float instanceLinewidthEnd;\nattribute float cellCount;\nuniform float pickState[ 1 ];\nuniform float startCell;\nuniform float linewidth;\nuniform vec2 resolution;\n#ifdef USE_PATTERN\nvarying float vPattern;\n#endif\nvarying float vDistance;\nvarying vec3 vPickColor;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tif ( pickState[ 0 ] > 0.5 ) {\n\t\tfloat cellNum = startCell + cellCount;\n\t\t\n\t\tfloat red = fract( cellNum / (255.0*255.0*255.0) );\n\t\tif ( pickState[ 0 ] > 1.5 ) {\n\t\n\t\t\tfloat red2 = fract( cellNum / (255.0*255.0*255.0*255.0*255.0*255.0) );\n\t\t\tfloat green2 = fract( cellNum / (255.0*255.0*255.0*255.0*255.0) );\n\t\t\tfloat blue2 = fract( cellNum / (255.0*255.0*255.0*255.0) );\n\t\n\t\t\tred2 -= green2 / 255.0;\n\t\t\tgreen2 -= blue2 / 255.0;\n\t\t\tblue2 -= red / 255.0;\n\t\t\tvPickColor = vec3( red2, green2, blue2 );\n\t\t} else {\n\t\t\tfloat green = fract( cellNum / (255.0*255.0) );\n\t\t\tfloat blue = fract( cellNum / 255.0 );\n\t\t\tred -= green / 255.0;\n\t\t\tgreen -= blue / 255.0;\n\t\t\tvPickColor = vec3( red, green, blue );\n\t\t}\n\t}\n#ifdef USE_COLOR\n\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart.xyz : instanceColorEnd.xyz;\n#endif\n#ifdef USE_PATTERN\n\tvPattern = instancePattern + 0.5;\n#endif\n\tfloat widthFactor, avgWidthFactor;\n#ifdef USE_LINEWIDTH\n\twidthFactor = ( position.y < 0.5 ) ? instanceLinewidthStart : instanceLinewidthEnd;\n\tavgWidthFactor = ( instanceLinewidthStart + instanceLinewidthEnd ) / 2.0;\n#else\n\twidthFactor = avgWidthFactor = linewidth;\n#endif\n\tfloat aspect = resolution.x / resolution.y;\n\tvec4 localStart = vec4( instanceStart, 1.0 );\n\tvec4 localEnd = vec4( instanceEnd, 1.0 );\n\tvec4 start = modelViewMatrix * localStart;\n\tvec4 end = modelViewMatrix * localEnd;\n\tvec4 clipStart = projectionMatrix * start;\n\tvec4 clipEnd = projectionMatrix * end;\n\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n#ifdef LINEWIDTH_SCALE\n\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 );\n\tif ( perspective ) {\n\t\tvec2 xyStart = localStart.xy;\n\t\tvec2 xyEnd = localEnd.xy;\n\t\tvec2 scaleDir = xyEnd - xyStart;\n\t\tscaleDir = normalize( scaleDir );\n\t\tvec2 scaleOffset = vec2( scaleDir.y, -scaleDir.x );\n\t\tscaleOffset.y /= aspect;\n\t\tif ( position.x < 0.5 ) scaleOffset *= -1.0;\n\t\tscaleOffset *= ( widthFactor * 0.5 );\n\t\tvec4 startEnd = ( position.y < 0.5 ) ? localStart : localEnd;\n\t\tvec4 scaleClip = vec4( startEnd );\n\t\tscaleClip.xy += scaleOffset;\n\t\tvec4 scalePosition = projectionMatrix * modelViewMatrix * scaleClip;\n\t\tvec4 scalePosition2 = projectionMatrix * modelViewMatrix * startEnd;\n\t\twidthFactor = avgWidthFactor = length( scalePosition2.xy - scalePosition.xy ) * resolution.y * 2.0;\n\t} else {\n\t\tvec4 localScale = ( position.y < 0.5 ) ? localStart : localEnd;\n\t\tlocalScale.y += widthFactor;\n\t\tvec4 clipScale = projectionMatrix * modelViewMatrix * localScale;\n\t\twidthFactor = avgWidthFactor = length( clipScale.xy - clip.xy ) * resolution.y / 2.0;\n\t}\n#endif\n\tif ( widthFactor < 1.0 ) {\n\t\twidthFactor = 1.0;\n\t}\n\tif ( avgWidthFactor < 1.0 ) {\n\t\tavgWidthFactor = 1.0;\n\t}\n\tvec3 ndcStart = clipStart.xyz / clipStart.w;\n\tvec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\tvec2 dir = ndcEnd.xy - ndcStart.xy;\n\tvec2 dirOrig = dir;\n\tdir.x *= aspect;\n\tdir = normalize( dir );\n\tvec2 offset = vec2( dir.y, -dir.x );\n\tdir.x /= aspect;\n\toffset.x /= aspect;\n\tif ( position.x < 0.5 ) offset *= -1.0;\n\toffset += ( position.y < 0.5 ) ? -dir * 0.3 : dir * 0.3;\n\toffset *= widthFactor;\n\tdir *= widthFactor;\n\toffset /= resolution.y;\n\tdir /= resolution.y;\n\toffset *= clip.w;\n\tclip.xy += offset;\n\tif ( clip.z > -1.0 ) {\n\t\tclip.z -= 5.0e-4;\n\t\tif ( clip.z < -1.0 ) clip.z = -1.0;\n\t}\n\tgl_Position = clip;\n\tvDistance = ( position.y < 0.5 ) ? 0.0 : ( length( dirOrig * resolution ) + 2.0 * length( dir * resolution ) ) / avgWidthFactor / 2.0;\n\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",fragmentShader:km},basic:{uniforms:Sc.merge([vd.common,vd.fog,Um.base,Um.mesh]),vertexShader:"attribute float cellCount;\nattribute vec3 glyphOffset;\nattribute vec3 glyphScale;\nuniform vec3 uGlyphScale;\nuniform float glyphScaleFactorX;\nuniform float glyphScaleFactorY;\nuniform float glyphScaleFactorZ;\nattribute mat3 glyphOrientation;\nuniform mat3 uGlyphOrientation;\nuniform float pickState[ 1 ];\nuniform float startCell;\nvarying vec3 vPickColor;\n#include <common>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tif ( pickState[ 0 ] > 0.5 ) {\n\t\tfloat cellNum = startCell + cellCount;\n\t\t\n\t\tfloat red = fract( cellNum / (255.0*255.0*255.0) );\n\t\tif ( pickState[ 0 ] > 1.5 ) {\n\t\n\t\t\tfloat red2 = fract( cellNum / (255.0*255.0*255.0*255.0*255.0*255.0) );\n\t\t\tfloat green2 = fract( cellNum / (255.0*255.0*255.0*255.0*255.0) );\n\t\t\tfloat blue2 = fract( cellNum / (255.0*255.0*255.0*255.0) );\n\t\n\t\t\tred2 -= green2 / 255.0;\n\t\t\tgreen2 -= blue2 / 255.0;\n\t\t\tblue2 -= red / 255.0;\n\t\t\tvPickColor = vec3( red2, green2, blue2 );\n\t\t} else {\n\t\t\tfloat green = fract( cellNum / (255.0*255.0) );\n\t\t\tfloat blue = fract( cellNum / 255.0 );\n\t\t\tred -= green / 255.0;\n\t\t\tgreen -= blue / 255.0;\n\t\t\tvPickColor = vec3( red, green, blue );\n\t\t}\n\t}\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n#ifdef GLYPH\n#ifdef USE_GLYPH_SCALE\n\ttransformed *= glyphScale;\n#else\n\ttransformed *= uGlyphScale;\n#endif\n\tvec3 glyphScaleFactor = vec3( glyphScaleFactorX, glyphScaleFactorY, glyphScaleFactorZ );\n\ttransformed *= glyphScaleFactor;\n#ifdef USE_GLYPH_ORIENTATION\n\ttransformed = glyphOrientation * transformed;\n#else\n\ttransformed = uGlyphOrientation * transformed;\n#endif\n\ttransformed += glyphOffset;\n#endif\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",fragmentShader:"uniform float stipple;\nuniform vec3 stippleColor;\nuniform vec4 stipplePattern[ 16 ];\nuniform vec3 diffuse;\nuniform float opacity;\nuniform float opacityFactor;\nuniform float textureBlending;\nuniform float pickState[ 1 ];\nvarying vec3 vPickColor;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity * opacityFactor );\n\t#include <clipping_planes_fragment>\n\tif ( pickState[ 0 ] > 0.5 ) {\n\t\tgl_FragColor = vec4( vPickColor, 1.0 );\n\t} else {\n\tif ( stipple > 0.5 ) {\n\t\tvec2 coord = floor( mod( gl_FragCoord.xy, 32.0 ) );\n\t\tint index = int( floor( coord.x / 64.0 ) + ( coord.y / 2.0 ) );\n\t\tint comp = int( floor( coord.x / 16.0 ) + mod( coord.y , 2.0 ) * 2.0 );\n\t\tfor ( int i = 0; i < 16; i ++ ) {\n\t\t\tif ( i == index ) {\n\t\t\t\tfloat shift = pow( 2.0, floor( mod( gl_FragCoord.x, 16.0 ) ) );\n\t\t\t\tfloat shortPattern;\n\t\t\t\tif ( comp == 0 ) {\n\t\t\t\t\tshortPattern = stipplePattern[ i ].x;\n\t\t\t\t} else if ( comp == 1 ) {\n\t\t\t\t\tshortPattern = stipplePattern[ i ].y;\n\t\t\t\t} else if ( comp == 2 ) {\n\t\t\t\t\tshortPattern = stipplePattern[ i ].z;\n\t\t\t\t} else {\n\t\t\t\t\tshortPattern = stipplePattern[ i ].w;\n\t\t\t\t}\n\t\t\t\tif ( mod( floor( shortPattern / shift ), 2.0 ) > 0.5 ) {\n\t\t\t\t\tdiffuseColor = vec4( stippleColor, opacity );\n\t\t\t\t} else if ( stipple < 1.5 ) {\n\t\t\t\t\tdiscard;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tif ( textureBlending > 1.5 ) {\n\t\tvec3 temp = mix( diffuseColor.rgb, sampledDiffuseColor.rgb, sampledDiffuseColor.a );\n\t\tdiffuseColor = vec4( temp, diffuseColor.a );\n\t} else if ( textureBlending < 0.5 ) {\n\t\tdiffuseColor = sampledDiffuseColor;\n\t} else {\n\t\tdiffuseColor *= sampledDiffuseColor;\n\t}\n#endif\n\t#include <alphatest_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n\t}\n}"},phong:{uniforms:Sc.merge([vd.common,vd.fog,vd.lights,Um.base,Um.mesh,{ambientIntensity:{value:.31},diffuseIntensity:{value:.7},emissive:{value:new Lr(0)},specular:{value:new Lr(2039583)},shininess:{value:63.8386159788056}}]),vertexShader:"attribute float cellCount;\nattribute vec3 glyphOffset;\nattribute vec3 glyphScale;\nuniform vec3 uGlyphScale;\nuniform float glyphScaleFactorX;\nuniform float glyphScaleFactorY;\nuniform float glyphScaleFactorZ;\nattribute mat3 glyphOrientation;\nuniform mat3 uGlyphOrientation;\nuniform float pickState[ 1 ];\nuniform float startCell;\nvarying vec3 vPickColor;\n#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tif ( pickState[ 0 ] > 0.5 ) {\n\t\tfloat cellNum = startCell + cellCount;\n\t\t\n\t\tfloat red = fract( cellNum / (255.0*255.0*255.0) );\n\t\tif ( pickState[ 0 ] > 1.5 ) {\n\t\n\t\t\tfloat red2 = fract( cellNum / (255.0*255.0*255.0*255.0*255.0*255.0) );\n\t\t\tfloat green2 = fract( cellNum / (255.0*255.0*255.0*255.0*255.0) );\n\t\t\tfloat blue2 = fract( cellNum / (255.0*255.0*255.0*255.0) );\n\t\n\t\t\tred2 -= green2 / 255.0;\n\t\t\tgreen2 -= blue2 / 255.0;\n\t\t\tblue2 -= red / 255.0;\n\t\t\tvPickColor = vec3( red2, green2, blue2 );\n\t\t} else {\n\t\t\tfloat green = fract( cellNum / (255.0*255.0) );\n\t\t\tfloat blue = fract( cellNum / 255.0 );\n\t\t\tred -= green / 255.0;\n\t\t\tgreen -= blue / 255.0;\n\t\t\tvPickColor = vec3( red, green, blue );\n\t\t}\n\t}\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n#ifdef GLYPH\n#ifdef USE_GLYPH_SCALE\n\ttransformed *= glyphScale;\n#else\n\ttransformed *= uGlyphScale;\n#endif\n\tvec3 glyphScaleFactor = vec3( glyphScaleFactorX, glyphScaleFactorY, glyphScaleFactorZ );\n\ttransformed *= glyphScaleFactor;\n#ifdef USE_GLYPH_ORIENTATION\n\ttransformed = glyphOrientation * transformed;\n#else\n\ttransformed = uGlyphOrientation * transformed;\n#endif\n\ttransformed += glyphOffset;\n#endif\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",fragmentShader:"uniform float ambientIntensity;\nuniform float diffuseIntensity;\nuniform float stipple;\nuniform vec3 stippleColor;\nuniform vec4 stipplePattern[ 16 ];\nuniform float textureBlending;\nuniform float pickState[ 1 ];\nvarying vec3 vPickColor;\n#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\nuniform float opacityFactor;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity * opacityFactor );\n\t#include <clipping_planes_fragment>\n\tif ( pickState[ 0 ] > 0.5 ) {\n\t\tgl_FragColor = vec4( vPickColor, 1.0 );\n\t} else {\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\tif ( stipple > 0.5 ) {\n\t\tvec2 coord = floor( mod( gl_FragCoord.xy, 32.0 ) );\n\t\tint index = int( floor( coord.x / 64.0 ) + ( coord.y / 2.0 ) );\n\t\tint comp = int( floor( coord.x / 16.0 ) + mod( coord.y , 2.0 ) * 2.0 );\n\t\tfor ( int i = 0; i < 16; i ++ ) {\n\t\t\tif ( i == index ) {\n\t\t\t\tfloat shift = pow( 2.0, floor( mod( gl_FragCoord.x, 16.0 ) ) );\n\t\t\t\tfloat shortPattern;\n\t\t\t\tif ( comp == 0 ) {\n\t\t\t\t\tshortPattern = stipplePattern[ i ].x;\n\t\t\t\t} else if ( comp == 1 ) {\n\t\t\t\t\tshortPattern = stipplePattern[ i ].y;\n\t\t\t\t} else if ( comp == 2 ) {\n\t\t\t\t\tshortPattern = stipplePattern[ i ].z;\n\t\t\t\t} else {\n\t\t\t\t\tshortPattern = stipplePattern[ i ].w;\n\t\t\t\t}\n\t\t\t\tif ( mod( floor( shortPattern / shift ), 2.0 ) > 0.5 ) {\n\t\t\t\t\tdiffuseColor = vec4( stippleColor, opacity );\n\t\t\t\t} else if ( stipple < 1.5 ) {\n\t\t\t\t\tdiscard;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tif ( textureBlending > 1.5 ) {\n\t\tvec3 temp = mix( diffuseColor.rgb, sampledDiffuseColor.rgb, sampledDiffuseColor.a );\n\t\tdiffuseColor = vec4( temp, diffuseColor.a );\n\t} else if ( textureBlending < 0.5 ) {\n\t\tdiffuseColor = sampledDiffuseColor;\n\t} else {\n\t\tdiffuseColor *= sampledDiffuseColor;\n\t}\n#endif\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\tvec3 outgoingLight = ( reflectedLight.directDiffuse * diffuseIntensity ) + ( reflectedLight.indirectDiffuse * ambientIntensity ) + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n\t}\n}"}};class Gm extends Om{constructor(t){super({uniforms:Sc.clone(Bm.points.uniforms),vertexShader:Bm.points.vertexShader,fragmentShader:Bm.points.fragmentShader}),this.isPointsMaterial=!0,Object.defineProperties(this,{vertexSizes:{get:function(){return this.defines.USE_SIZE},set:function(t){this.defines.USE_SIZE=t}}}),this.map=null,this.size=1,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.size=t.size,this}toJSON(t){const e=super.toJSON(t);return e.type="PointsMaterial",this.vertexSizes&&(e.vertexSizes=!0),e}equals(t){return!1!==super.equals(t)&&!!t.isPointsMaterial}}class Vm extends Om{constructor(t){super({uniforms:Sc.clone(Bm.basic.uniforms),vertexShader:Bm.basic.vertexShader,fragmentShader:Bm.basic.fragmentShader}),this.isMeshBasicMaterial=!0,Object.defineProperties(this,{stipple:{get:function(){return this.uniforms.stipple.value},set:function(t){this.uniforms.stipple.value=t}},stippleColor:{get:function(){return this.uniforms.stippleColor.value},set:function(t){this.uniforms.stippleColor.value=t}},stipplePattern:{get:function(){return this.uniforms.stipplePattern.value},set:function(t){this.uniforms.stipplePattern.value=t}},textureBlending:{get:function(){return this.uniforms.textureBlending.value},set:function(t){this.uniforms.textureBlending.value=t}}}),this.map=null,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this}toJSON(t){const e=super.toJSON(t);return e.type="MeshBasicMaterial",0!==this.stipple&&(e.stipple=this.stipple),0!==this.stippleColor.getHex()&&(e.stippleColor=this.stippleColor.getHex()),JSON.stringify(this.stipplePattern)!==JSON.stringify(new Float32Array(64))&&(e.stipplePattern=Array.prototype.slice.call(this.stipplePattern)),1!==this.textureBlending&&(e.textureBlending=this.textureBlending),e}equals(t){return!1!==super.equals(t)&&!(!t.isMeshBasicMaterial&&!t.isMeshPhongMaterial)}}class Hm extends Vm{constructor(t){super({uniforms:Sc.clone(Bm.phong.uniforms),vertexShader:Bm.phong.vertexShader,fragmentShader:Bm.phong.fragmentShader}),this.isMeshPhongMaterial=!0,this.isMeshBasicMaterial=!1,Object.defineProperties(this,{ambientIntensity:{get:function(){return this.uniforms.ambientIntensity.value},set:function(t){this.uniforms.ambientIntensity.value=t}},diffuseIntensity:{get:function(){return this.uniforms.diffuseIntensity.value},set:function(t){this.uniforms.diffuseIntensity.value=t}}}),this.specular=new Lr(4737096),this.shininess=63.8386159788056,this.emissive=new Lr(0),this.emissiveIntensity=1,this.lights=!0,this.setValues(t)}copy(t){return super.copy(t),this.specular.copy(t.specular),this.shininess=t.shininess,this.flatShading=t.flatShading,this}toJSON(t){const e=super.toJSON(t);return e.type="MeshPhongMaterial",.31!==this.ambientIntensity&&(e.ambientIntensity=this.ambientIntensity),.7!==this.diffuseIntensity&&(e.diffuseIntensity=this.diffuseIntensity),4737096===this.specular.getHex()&&(e.specular=void 0),63.8386159788056===this.shininess&&(e.shininess=void 0),e}equals(t){return!1!==super.equals(t)&&!!t.isMeshPhongMaterial&&t.ambientIntensity===this.ambientIntensity&&t.diffuseIntensity===this.diffuseIntensity&&t.specular.getHex()===this.specular.getHex()&&t.shininess===this.shininess}}class Wm extends Om{constructor(t){super({uniforms:Sc.clone(Bm.line.uniforms),vertexShader:Bm.line.vertexShader,fragmentShader:Bm.line.fragmentShader}),this.isLineBasicMaterial=!0,Object.defineProperties(this,{pattern:{get:function(){return this.uniforms.linePattern.value},set:function(t){this.uniforms.linePattern.value=t}},vertexPatterns:{get:function(){return this.defines.USE_PATTERN},set:function(t){this.defines.USE_PATTERN=t}},resolution:{get:function(){return this.uniforms.resolution.value},set:function(t){this.uniforms.resolution.value=t}}}),this.setValues(t)}toJSON(t){const e=super.toJSON(t);return e.type="LineMaterial",65535!==this.pattern&&(e.pattern=this.pattern),this.vertexPatterns&&(e.vertexPatterns=!0),e}equals(t){return!1!==super.equals(t)&&!!t.isLineBasicMaterial}}class jm extends Wm{constructor(t){super({uniforms:Sc.clone(Bm.thick.uniforms),vertexShader:Bm.thick.vertexShader,fragmentShader:Bm.thick.fragmentShader}),this.isThickLineMaterial=!0,Object.defineProperties(this,{linewidth:{get:function(){return this.uniforms.linewidth.value},set:function(t){this.uniforms.linewidth.value=t}},vertexLinewidths:{get:function(){return this.defines.USE_LINEWIDTH},set:function(t){this.defines.USE_LINEWIDTH=t}},linewidthScale:{get:function(){return this.defines.LINEWIDTH_SCALE},set:function(t){this.defines.LINEWIDTH_SCALE=t}}}),this.setValues(t)}toJSON(t){const e=super.toJSON(t);return e.type="ThickLineMaterial",this.vertexLinewidths&&(e.vertexLinewidths=!0),this.linewidthScale&&(e.linewidthScale=!0),e}equals(t){return!1!==super.equals(t)&&!!t.isThickLineMaterial&&t.vertexLinewidths===this.vertexLinewidths}}Oh.createMaterialFromType=function(t){return new{PointsMaterial:Gm,MeshPhongMaterial:Hm,MeshBasicMaterial:Vm,LineMaterial:Wm,ThickLineMaterial:jm}[t]};class Xm extends Oh{parse(t){const e=super.parse(t);if(void 0!==t.glyphs&&(e.glyphs=t.glyphs),void 0!==t.vertexGlyphScales&&(e.vertexGlyphScales=t.vertexGlyphScales),void 0!==t.glyphScale&&e.glyphScale.fromArray(t.glyphScale),void 0!==t.vertexGlyphOrientations&&(e.vertexGlyphOrientations=t.vertexGlyphOrientations),void 0!==t.glyphOrientation&&e.glyphOrientation.fromArray(t.glyphOrientation),void 0!==t.vertexSizes&&(e.vertexSizes=t.vertexSizes),void 0!==t.pattern&&(e.pattern=t.pattern),void 0!==t.vertexPatterns&&(e.vertexPatterns=t.vertexPatterns),void 0!==t.vertexLinewidths&&(e.vertexLinewidths=t.vertexLinewidths),void 0!==t.linewidthScale&&(e.linewidthScale=t.linewidthScale),void 0!==t.stipple&&(e.stipple=t.stipple),void 0!==t.stippleColor&&void 0!==e.stippleColor&&e.stippleColor.setHex(t.stippleColor),void 0!==t.stipplePattern&&(e.stipplePattern=t.stipplePattern),void 0!==t.textureBlending&&(e.textureBlending=t.textureBlending),void 0!==t.ambientIntensity&&(e.ambientIntensity=t.ambientIntensity),void 0!==t.diffuseIntensity&&(e.diffuseIntensity=t.diffuseIntensity),void 0!==t.clippingPlanes){e.clippingPlanes=[];for(let n=0,i=t.clippingPlanes.length;n<i;n++){const i=t.clippingPlanes[n],r=new $s(new Ai(i.normal[0],i.normal[1],i.normal[2]),i.constant);e.clippingPlanes.push(r)}}return e.origTransparent=e.transparent,e}}class qm{constructor(t){this.bufferGeometryLoader=t}parse(t){const e=this.bufferGeometryLoader.parse(t),n=e.attributes.position;if(void 0!==n){const t=new _a(n.array.length,3);for(let e=0,i=n.array.length/6;e<i;e++)t.array[6*e+0]=n.array[6*e+3],t.array[6*e+1]=n.array[6*e+4],t.array[6*e+2]=n.array[6*e+5],t.array[6*e+3]=n.array[6*e+0],t.array[6*e+4]=n.array[6*e+1],t.array[6*e+5]=n.array[6*e+2];e.setAttribute("otherPosition",t)}return e}}const Ym=new Jr,Zm=new Ai;class $m extends Fh{constructor(){super(),this.isThickLineSegmentsBufferGeometry=!0,this.type="ThickLineSegmentsBufferGeometry",this.setAttribute("position",new _a([0,0,0,1,1,0,0,1,0,0,0,0,1,0,0,1,1,0],3))}applyMatrix4(t){const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;return void 0!==e&&(e.applyMatrix4(t),n.applyMatrix4(t),e.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}setPositions(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const n=new od(e,6,1);return this.setAttribute("instanceStart",new Da(n,3,0)),this.setAttribute("instanceEnd",new Da(n,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const n=new od(e,6,1);return this.setAttribute("instanceColorStart",new Da(n,3,0)),this.setAttribute("instanceColorEnd",new Da(n,3,3)),this}setPatterns(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const n=new od(e,2,1);return this.setAttribute("instancePattern",new Da(n,1,0)),this}setLinewidths(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const n=new od(e,2,1);return this.setAttribute("instanceLinewidthStart",new Da(n,1,0)),this.setAttribute("instanceLinewidthEnd",new Da(n,1,1)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Jr);const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;void 0!==t&&void 0!==e&&(this.boundingBox.setFromBufferAttribute(t),Ym.setFromBufferAttribute(e),this.boundingBox.union(Ym))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new Sa),null===this.boundingBox&&this.computeBoundingBox();const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;if(void 0!==t&&void 0!==e){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let i=0;for(let r=0,a=t.count;r<a;r++)Zm.fromBufferAttribute(t,r),i=Math.max(i,n.distanceToSquared(Zm)),Zm.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(Zm));this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error("AVS.Three.ThickLineSegmentsBufferGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}applyMatrix(t){return console.warn("AVS.Three.ThickLineSegmentsBufferGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(t)}}class Jm{parse(t){const e=new $m,n=t.data.attributes;return void 0!==n.position&&e.setPositions(n.position.array),void 0!==n.color&&e.setColors(n.color.array),void 0!==n.pattern&&e.setPatterns(n.pattern.array),void 0!==n.linewidth&&e.setLinewidths(n.linewidth.array),e}}const Km=new Ji,Qm=new ls,tf=new Sa;class ef extends Cm{constructor(t,e){super(t,e),this.isThickLineSegments=!0,this.type="ThickLineSegments"}raycast(t,e){const n=this.geometry,i=this.matrixWorld,r=t.params.Line.threshold,a=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),tf.copy(n.boundingSphere),tf.applyMatrix4(i),tf.radius+=r,!1===t.ray.intersectsSphere(tf))return;Km.copy(i).invert(),Qm.copy(t.ray).applyMatrix4(Km);const s=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=s*s,l=new Ai,c=new Ai,h=new Ai,d=new Ai,u=n.attributes.instanceStart;for(let n=Math.max(0,a.start),i=Math.min(u.count,a.start+a.count)-1;n<i;n+=2){if(l.fromBufferAttribute(u,n),c.fromBufferAttribute(u,n+1),Qm.distanceSqToSegment(l,c,d,h)>o)continue;d.applyMatrix4(this.matrixWorld);const i=t.ray.origin.distanceTo(d);i<t.near||i>t.far||e.push({distance:i,point:h.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}}class nf{constructor(){this.uuid=wi.generateUUID(),this.transparent=!1,this.opacity=1,this.opacityFactor=1}dispose(){}}class rf extends wr{constructor(){super(),this.isBillboardText=!0,this.type="BillboardText",this.text="Label",this.fontSize=16,this.fontStyle="normal",this.fontWeight="normal",this.textDecoration="",this.fontFamily="sans-serif",this.color=new Lr(0),this.textAlign="",this.transform="",this.transformOrigin="",this.material=new nf,this.div=document.createElement("div"),this.div.style.position="absolute",this.div.style.whiteSpace="nowrap",this.div.style.userSelect="none",this.scene=null,this.scaleFactor=1,this.left=0,this.top=0,this.updateStyle()}addToScene(t){null===this.scene&&(this.scene=t,t.labels.push(this),t.landscapeDiv.appendChild(this.div),this.updateStyle())}updateStyle(){this.div.innerHTML=this.text,this.div.style.fontStyle=this.fontStyle,this.div.style.fontWeight=this.fontWeight,this.div.style.textDecoration=this.textDecoration,this.div.style.color="#"+this.color.getHexString(),this.div.style.transform=this.transform,this.div.style.transformOrigin=this.transformOrigin,this.material.transparent?this.div.style.opacity=this.material.opacity*this.material.opacityFactor:this.div.style.opacity=1,this.div.style.visibility=this.visible?"visible":"hidden",void 0!==this.div.firstChild.style&&(this.div.firstChild.style.float="left"),/\s/.test(this.fontFamily)?this.div.style.fontFamily="'"+this.fontFamily+"'":this.div.style.fontFamily=this.fontFamily,this.textScale||(this.div.style.fontSize=this.fontSize+"px")}updatePosition(){this.updateMatrixWorld();const t=(new Ai).setFromMatrixPosition(this.matrixWorld);if(t.project(this.scene.camera),this.left=(t.x+1)/2*this.scene.landscapeWidth,this.top=(1-(t.y+1)/2)*this.scene.landscapeHeight,this.moveText(),this.textScale){const t=new Ai(0,1,0).multiplyScalar(this.fontSize).add(this.position);t.applyMatrix4(this.parent.matrixWorld),t.project(this.scene.camera);const e=(1-(t.y+1)/2)*this.scene.landscapeHeight,n=Math.abs(e-this.top);this.div.style.fontSize=n+"px"}this.material.transparent?this.div.style.opacity=this.material.opacity*this.material.opacityFactor:this.div.style.opacity=1,this.div.style.visibility=this.visible?"visible":"hidden"}moveText(){this.div.style.left=Math.floor((this.panOffsetX??0)+this.left)+"px",this.div.style.top=Math.floor((this.panOffsetY??0)+this.top)+"px"}}class af extends Bh{parse(t,e,n,i,r,a,s){const o=this.parseGeometries(t.geometries);a=Object.assign(a??{},o);const l=this.parseImages(t.images,(function(){void 0!==e&&e(d)}));n=Object.assign(n??{},l);const c=this.parseTextures(t.textures,n);i=Object.assign(i??{},c);const h=this.parseMaterials(t.materials,i);r=Object.assign(r??{},h);const d=this.parseObject(t.object,a,r,i);if(void 0!==s&&(s.add(d),d.saveVisible=d.visible,d.visible=!1),void 0!==e){let t=!1;for(const e in l)if(l[e].data instanceof HTMLImageElement){t=!0;break}!1===t&&e(d)}return d}parseGeometries(t,e){const n={};if(void 0!==t){const e=new zh,i=new qm(e),r=new Jm;for(let a=0,s=t.length;a<s;a++){let s;const o=t[a];switch(o.type){case"BufferGeometry":case"InstancedBufferGeometry":s=e.parse(o);break;case"LinePatternBufferGeometry":s=i.parse(o);break;case"ThickLineBufferGeometry":s=r.parse(o);break;case"SphereGeometry":s=hc.fromJSON(o);break;default:console.warn(`AVS.Three.ObjectLoader: Unsupported geometry type "${o.type}"`)}s.uuid=o.uuid,void 0!==o.name&&(s.name=o.name),!0===s.isBufferGeometry&&void 0!==o.userData&&(s.userData=o.userData),n[o.uuid]=s}}return n}parseMaterials(t,e){const n={};if(void 0!==t){const i=new Xm;i.setTextures(e);for(let e=0,r=t.length;e<r;e++){const r=t[e];n[r.uuid]=i.parse(r)}}return n}parseObject(t,e,n,i){let r,a,s;function o(t){return void 0===e[t]&&console.warn("AVS.Three.ObjectLoader: Undefined geometry",t),e[t]}function l(t){if(void 0!==t){if(Array.isArray(t)){const e=[];for(let i=0,r=t.length;i<r;i++){const r=t[i];void 0===n[r]&&console.warn("AVS.Three.ObjectLoader: Undefined material",r),e.push(n[r])}return e}return void 0===n[t]&&console.warn("AVS.Three.ObjectLoader: Undefined material",t),n[t]}}function c(t){return void 0===i[t]&&console.warn("AVS.Three.ObjectLoader: Undefined texture",t),i[t]}switch(t.type){case"Scene":r=new Nm,void 0!==t.background&&(Number.isInteger(t.background)?r.background=new Lr(t.background):r.background=c(t.background)),void 0!==t.environment&&(r.environment=c(t.environment)),void 0!==t.fog&&("Fog"===t.fog.type?r.fog=new Or(t.fog.color,t.fog.near,t.fog.far):"FogExp2"===t.fog.type&&(r.fog=new Nr(t.fog.color,t.fog.density))),void 0!==t.backgroundBlurriness&&(r.backgroundBlurriness=t.backgroundBlurriness);break;case"PerspectiveCamera":r=new Dm(t.fov,t.aspect,t.near,t.far),void 0!==t.focus&&(r.focus=t.focus),void 0!==t.zoom&&(r.zoom=t.zoom),void 0!==t.filmGauge&&(r.filmGauge=t.filmGauge),void 0!==t.filmOffset&&(r.filmOffset=t.filmOffset),void 0!==t.view&&(r.view=Object.assign({},t.view));break;case"OrthographicCamera":r=new Lm(t.left,t.right,t.top,t.bottom,t.near,t.far),void 0!==t.zoom&&(r.zoom=t.zoom),void 0!==t.view&&(r.view=Object.assign({},t.view)),void 0!==t.keepAspectRatio&&(r.keepAspectRatio=t.keepAspectRatio);break;case"AmbientLight":r=new Pm(t.color,t.intensity);break;case"DirectionalLight":r=new Im(t.color,t.intensity);break;case"PointLight":r=new Rm(t.color,t.intensity,t.distance,t.decay);break;case"Mesh":case"Quads":a=o(t.geometry),s=l(t.material),r=new Cm(a,s),r.cellType="Quads"===t.type?mm:pm,r.frustumCulled=void 0===s.glyphs;break;case"LineSegments":r=new bm(o(t.geometry),l(t.material)),r.cellType=um,r.frustumCulled=void 0===r.material.glyphs;break;case"ThickLineSegments":r=new ef(o(t.geometry),l(t.material)),r.cellType=mm,r.frustumCulled=void 0===r.material.glyphs;break;case"PointCloud":case"Points":r=new ym(o(t.geometry),l(t.material)),r.cellType=dm,r.frustumCulled=void 0===r.material.glyphs;break;case"Group":r=new gm;break;case"BillboardText":r=new rf,void 0!==t.text&&(r.text=t.text),void 0!==t.fontSize&&(r.fontSize=t.fontSize),void 0!==t.fontStyle&&(r.fontStyle=t.fontStyle),void 0!==t.fontWeight&&(r.fontWeight=t.fontWeight),void 0!==t.fontFamily&&(r.fontFamily=t.fontFamily),void 0!==t.textDecoration&&(r.textDecoration=t.textDecoration),void 0!==t.color&&r.color.setHex(t.color),void 0!==t.transform&&(r.transform=t.transform),void 0!==t.transformOrigin&&(r.transformOrigin=t.transformOrigin),void 0!==t.textScale&&(r.textScale=t.textScale),void 0!==t.width&&(r.width=t.width),void 0!==t.height&&(r.height=t.height);break;default:r=new wr}if(r.uuid=t.uuid,void 0!==t.name&&(r.name=t.name),void 0!==t.matrix?(r.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(r.matrixAutoUpdate=t.matrixAutoUpdate),r.matrixAutoUpdate&&r.matrix.decompose(r.position,r.quaternion,r.scale)):(void 0!==t.position&&r.position.fromArray(t.position),void 0!==t.rotation&&r.rotation.fromArray(t.rotation),void 0!==t.quaternion&&r.quaternion.fromArray(t.quaternion),void 0!==t.scale&&r.scale.fromArray(t.scale)),void 0!==t.castShadow&&(r.castShadow=t.castShadow),void 0!==t.receiveShadow&&(r.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.bias&&(r.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(r.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(r.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&r.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(r.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(r.visible=t.visible),void 0!==t.frustumCulled&&(r.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(r.renderOrder=t.renderOrder),void 0!==t.userData&&(r.userData=t.userData),void 0!==t.layers&&(r.layers.mask=t.layers),r.internalData={},void 0!==t.internalData&&(r.internalData=t.internalData),void 0!==t.children){const a=t.children;for(let t=0;t<a.length;t++)r.add(this.parseObject(a[t],e,n,i))}return r}}class sf{constructor(t){var e=t;this.getID=function(){return e},this.container=document.createElement("div"),this.container.style.position="relative",this.container.style.outline="none",this.container.style.overflow="hidden",this.container.style.width="100%",this.container.style.height="100%",this.container.id="avsthreeDiv",this.domElement=this.container,this.scenes=[],this.currentScene=null,this.renderNextFrame=!1,this.objectLoader=new af,this.startCell=1,this.raycaster=new cd,this.raycaster.params.Line.threshold=.001,this.validPick=!1,this.pickType=cm,this.pickDepth=lm,this.pickRayX=0,this.pickRayY=0,this.pickRectangleLeft=0,this.pickRectangleTop=0,this.pickRectangleRight=1,this.pickRectangleBottom=1,this.selectionListeners=[],this.intersects=[],this.highlightList=[],this.updateHighlight=!1,this.highlightColor=new Lr(16711680),this.updatePicking=!1,this.pickState=new Float32Array(1),this.resolution=new Ei,this.loading=!1,this.firstChunk=!1,this.animator=null,this.animatedGlyphs=[],this.enableAnimatedGlyphs=!1,this.visibleAnimatedGlyphs=!1,this.displayCanvas=!1,this.animate()}setWebGLRenderer(t){this.renderer=t,this.renderer.autoClear=!1,this.renderer.localClippingEnabled=!0,this.renderer.sortObjects=!1}updateSize(){var t=this.container.clientWidth,e=this.container.clientHeight;if(t!==this.width||e!==this.height){this.width=t,this.height=e,this.updateHighlight=!0,this.updatePicking=!0,this.validPick=!1;for(var n=0;n<this.scenes.length;n++)this.updateSceneSize(this.scenes[n])}}updateSceneSize(t){if(t.windowX=Math.floor(t.windowFractionX*this.width),t.windowWidth=Math.floor(t.windowFractionWidth*this.width),t.windowY=Math.floor(t.windowFractionY*this.height),t.windowHeight=Math.floor(t.windowFractionHeight*this.height),t.windowTop=this.height-t.windowHeight-t.windowY,t.windowDiv.style.left=t.windowX+"px",t.windowDiv.style.width=t.windowWidth+"px",t.windowDiv.style.top=t.windowTop+"px",t.windowDiv.style.height=t.windowHeight+"px",t.panScene||(t.landscapeWidth=t.windowWidth,t.landscapeHeight=t.windowHeight),t.landscapeDiv.style.width=t.landscapeWidth+"px",t.landscapeDiv.style.height=t.landscapeHeight+"px",t.landscapeDiv.style.left=(t.baseLeft??0)+(t.panOffsetX??0)+"px",t.landscapeDiv.style.top=(t.baseTop??0)+(t.panOffsetY??0)+"px",t.landscapeGrid&&this.sizeLandscapeGrid(t),t.rectCanvas&&(t.rectCanvas.width=t.windowWidth,t.rectCanvas.height=t.windowHeight),t.camera.isOrthographicCamera&&t.camera.keepAspectRatio){var e=t.landscapeWidth/t.internalData.width,n=t.landscapeHeight/t.internalData.height,i=t.internalData.width/t.internalData.height;t.landscapeWidth,t.landscapeHeight,i<1||(t.camera.left=t.camera.origLeft*e/n,t.camera.right=t.camera.origRight*e/n),t.camera.updateProjectionMatrix()}}sizeLandscapeGrid(t){for(var e=[],n=[],i=Math.floor(t.landscapeHeight/t.landscapeRows),r=0,a=0;a<t.landscapeRows;a++){var s=a==t.landscapeRows-1?t.landscapeHeight-r:i;e.push(r),n.push(s),r+=s}for(var o=[],l=[],c=Math.floor(t.landscapeWidth/t.landscapeColumns),h=0,d=0;d<t.landscapeColumns;d++){var u=d==t.landscapeColumns-1?t.landscapeWidth-h:c;o.push(h),l.push(u),h+=u}for(a=0;a<t.landscapeRows;a++)for(d=0;d<t.landscapeColumns;d++){var p=t.landscapeGrid[a][d];p.left=o[d],p.top=e[a];var m=!1;p.width===l[d]&&p.height===n[a]||(p.width=l[d],p.height=n[a],m=!0),this.isGridItemVisible(p)?p.initialized&&!m||(p.initialized||this.initializeGridItem(p),this.sizeGridItem(p)):p.initialized&&this.disposeGridItem(p)}}sizeGridItem(t){t.initialized&&(t.canvas.style.left=t.left+"px",t.canvas.style.top=t.top+"px",t.canvas.style.width=t.width+"px",t.canvas.style.height=t.height+"px",t.highlightCanvas.style.left=t.left+"px",t.highlightCanvas.style.top=t.top+"px",t.highlightCanvas.style.width=t.width+"px",t.highlightCanvas.style.height=t.height+"px",t.pixelX=Math.floor(t.left*window.devicePixelRatio),t.pixelY=Math.floor(t.top*window.devicePixelRatio),t.pixelWidth=Math.floor(t.width*window.devicePixelRatio),t.pixelHeight=Math.floor(t.height*window.devicePixelRatio),t.canvas.width=t.pixelWidth,t.canvas.height=t.pixelHeight,t.highlightCanvas.width=t.pixelWidth,t.highlightCanvas.height=t.pixelHeight,t.renderTarget.setSize(t.pixelWidth,t.pixelHeight),t.pixelBuffer=new Uint8Array(4*t.pixelWidth*t.pixelHeight),t.pickingRenderTarget.setSize(t.pixelWidth,t.pixelHeight),t.pickingPixelBuffer=new Uint8Array(4*t.pixelWidth*t.pixelHeight))}clearGeometry(){for(;this.container.lastChild;)this.container.removeChild(this.container.lastChild);this.panInteractor&&this.panInteractor.clear();for(let t=0;t<this.scenes.length;t++)this.scenes[t].traverse((function(t){t.material&&(t.material.map&&t.material.map.dispose(),t.material.dispose()),t.geometry&&t.geometry.dispose()}));this.scenes=[],this.currentScene=null,this.startCell=1,null!==this.animator&&this.animator.clear(),this.animatedGlyphs=[]}setPickDepth(t){void 0===t&&(t=lm),this.pickDepth!==t&&(this.pickDepth=t)}setPickRay(t,e){if(t<0||e<0||t>this.width||e>this.height)return this.validPick=!1,void console.error("AVS.Three.Viewer: pick ray coordinates out of range.");this.pickType=cm,this.pickRayX=t,this.pickRayY=e,this.validPick=!0}setPickRectangle(t,e,n,i){if(t<0||e<0||n>this.width||i>this.height)return this.validPick=!1,void console.error("AVS.Three.Viewer: pick rectangle coordinates out of range.");this.pickType=hm,this.pickRectangleLeft=t,this.pickRectangleTop=e,this.pickRectangleRight=n,this.pickRectangleBottom=i,this.validPick=!0}interactorUpdate(t){t===this.transformInteractor&&void 0!==this.zoomRectangleInteractor&&t.object===this.zoomRectangleInteractor.object&&(this.zoomRectangleInteractor.scale.copy(t.object.scale),this.zoomRectangleInteractor.position.copy(t.object.position)),t===this.zoomRectangleInteractor&&void 0!==this.transformInteractor&&t.object===this.transformInteractor.object&&(this.transformInteractor.scale.copy(t.object.scale),this.transformInteractor.position.copy(t.object.position)),this.updatePicking=!0,this.renderNextFrame=!0,void 0!==this.stats&&this.stats.update()}panInteractorUpdate(){for(var t=0;t<this.scenes.length;t++){var e=this.scenes[t];if(e.landscapeGrid)for(var n=0;n<e.landscapeRows;n++)for(var i=0;i<e.landscapeColumns;i++){var r=e.landscapeGrid[n][i];this.isGridItemVisible(r)?r.initialized||(this.initializeGridItem(r),this.sizeGridItem(r),this.renderGridItem(r,!0),this.updatePicking=!0):r.initialized&&this.disposeGridItem(r)}}}addInteractor(t){if(t.isTransformInteractor)this.transformInteractor=t,t.addEventListener("change",this.interactorUpdate.bind(this,t));else if(t.isZoomRectangleInteractor)this.zoomRectangleInteractor=t,t.addEventListener("change",this.interactorUpdate.bind(this,t));else{if(!t.isPanInteractor)return;this.panInteractor=t,t.addEventListener("change",this.panInteractorUpdate.bind(this))}t.domElement=this.domElement}removeInteractor(t){t.isTransformInteractor?(t.removeEventListener("change",this.interactorUpdate.bind(this,this.transformInteractor)),this.transformInteractor=void 0):t.isZoomRectangleInteractor?(t.removeEventListener("change",this.interactorUpdate.bind(this,this.zoomRectangleInteractor)),this.zoomRectangleInteractor=void 0):t.isPanInteractor&&(this.panInteractor=void 0)}setAnimator(t){this.animator=t,t.addEventListener("change",this.interactorUpdate.bind(this))}addStats(){void 0===this.stats&&(this.stats=new Stats,this.container.appendChild(this.stats.dom))}addGeometry(t){t.updateMatrixWorld(),void 0!==t.internalData.background?this.container.style.backgroundColor="#"+t.internalData.background.toString(16).padStart(6,"0"):this.container.style.backgroundColor="transparent",this.processGeometry(t);for(var e=0;e<this.scenes.length;e++){var n=this.scenes[e];n.parent&&n.parent.remove(n)}}processGeometry(t){if(t.isScene){for(var e=0;e<t.children.length;e++){var n=t.children[e];if(n.isPerspectiveCamera||n.isOrthographicCamera){t.camera=n,t.remove(n);break}}null==t.camera&&null!==t.background&&(t.camera=new Ch),void 0!==t.camera&&this.addScene(t)}this.attachInteractors(t),this.addLabels(t),this.createPickingInfo(t),this.addMaterialReferences(t),t.internalData.animatedGlyphs&&this.animatedGlyphs.push(t);var i=t.children,r=i.length;for(e=0;e<r;)this.processGeometry(i[e]),i.length<r?r=i.length:e++}addScene(t,e=!1){this.scenes.push(t),this.currentScene=t,e||(this.currentRealScene=t),t.labels=[],this.calculateSceneFractions(t);var n=document.createElement("div");n.style.position="absolute",n.style.overflow="hidden",n.id=t.name+"-Window";var i=document.createElement("div");i.style.position="absolute",i.style.overflow="hidden",i.id=t.name+"-Landscape",n.appendChild(i),t.landscapeDiv=i,t.windowDiv=n,this.container.appendChild(n),this.updateSceneSize(t),t.startCell=this.startCell,t.highlightScene=new Ur,t.highlightScene.add(new Er);for(var r=0;r<t.children.length;r++)t.children[r].isLight&&t.highlightScene.add(t.children[r].clone())}calculateSceneFractions(t){t.windowFractionX=t.internalData.x?Math.max(0,t.internalData.x/this.width):0,t.windowFractionWidth=t.internalData.width?Math.min(1,t.internalData.width/this.width):1,t.windowFractionY=t.internalData.y?Math.max(0,t.internalData.y/this.height):0,t.windowFractionHeight=t.internalData.height?Math.min(1,t.internalData.height/this.height):1}createLandscapeGrid(t){void 0===t.landscapeRows&&(t.landscapeRows=1),void 0===t.landscapeColumns&&(t.landscapeColumns=1),t.landscapeGrid=[];for(var e=0;e<t.landscapeRows;e++){t.landscapeGrid.push([]);for(var n=0;n<t.landscapeColumns;n++){var i={};i.container=t.landscapeDiv,i.scene=t,i.name=t.name+"-Landscape-Grid-Row"+e+"-Col"+n,i.initialized=!1,t.landscapeGrid[e].push(i)}}this.sizeLandscapeGrid(t)}isGridItemVisible(t){var e=t.scene,n=(e.baseLeft??0)+(e.panOffsetX??0)+t.left,i=n+t.width,r=(e.baseTop??0)+(e.panOffsetY??0)+t.top,a=r+t.height;return!(i<0||n>e.windowWidth||a<0||r>e.windowHeight)}initializeGridItem(t){var e=document.createElement("canvas");e.style.position="absolute",e.id=t.name,t.container.insertBefore(e,t.container.firstChild),t.canvas=e,t.ctx=e.getContext("2d"),this.displayCanvas&&(e.style.backgroundColor="rgba("+255*Math.random()+","+255*Math.random()+","+255*Math.random()+",0.1)");var n=document.createElement("canvas");n.style.position="absolute",n.id=t.name+"-Highlight",t.container.appendChild(n),t.highlightCanvas=n,t.highlightCtx=n.getContext("2d"),t.renderTarget=new Yi,t.renderTarget.texture.colorSpace=kn,t.pickingRenderTarget=new Yi,t.initialized=!0}disposeGridItem(t){t.container.removeChild(t.canvas),t.canvas=null,t.ctx=null,t.container.removeChild(t.highlightCanvas),t.highlightCanvas=null,t.highlightCtx=null,t.renderTarget=null,t.pickingRenderTarget=null,t.initialized=!1}attachInteractors(t){if(t.internalData.attachTransformInteractor&&this.transformInteractor&&this.transformInteractor.setObjectScene(t,this.currentScene),t.internalData.attachZoomRectangleInteractor&&this.zoomRectangleInteractor&&this.zoomRectangleInteractor.setObjectScene(t,this.currentScene),t.internalData.attachPanInteractor&&this.panInteractor){var e=this.currentRealScene,n=t.parent;n.matrix.copy(t.parent.matrixWorld),n.matrixAutoUpdate=!1,n.isScene=!0,n.autoUpdate=!0,n.overrideMaterial=null,n.internalData.is3D=!1,n.internalData.pickable=this.isObjectPickable(t.parent),n.name=t.name,n.panScene=!0,e.origCamera||(e.origCamera=e.camera.clone(),e.internalData.origWidth=e.internalData.width,e.internalData.origHeight=e.internalData.height),n.camera=e.origCamera.clone();for(var i=n.camera.right-n.camera.left,r=n.camera.top-n.camera.bottom,a=0;a<e.children.length;a++)e.children[a].isLight&&n.add(e.children[a].clone());var s=new Ai;s.set(-t.internalData.xSize/2,-t.internalData.ySize/2,0),s.applyMatrix4(n.matrix);var o=new Ai;o.set(t.internalData.xSize/2,t.internalData.ySize/2,0),o.applyMatrix4(n.matrix);var l=e.internalData.origWidth,c=e.internalData.origHeight,h=Math.floor((s.x-n.camera.left)/i*l),d=Math.floor((1-(o.x-n.camera.left)/i)*l),u=Math.floor((s.y-n.camera.bottom)/r*c),p=Math.floor((1-(o.y-n.camera.bottom)/r)*c);this.panInteractor.leftLimit=(l-this.width)/2,this.panInteractor.rightLimit=-this.panInteractor.leftLimit,this.panInteractor.topLimit=(c-this.height)/2,this.panInteractor.bottomLimit=-this.panInteractor.topLimit,n.baseLeft=this.panInteractor.rightLimit-h,n.baseTop=this.panInteractor.bottomLimit-p,n.landscapeWidth=l,n.landscapeHeight=c,n.landscapeRows=Math.ceil(c/this.height),n.landscapeColumns=Math.ceil(l/this.width),n.centerWidth=l-h-d,n.centerHeight=c-u-p,n.zoomOffsetLeft=2*h+n.baseLeft,n.zoomOffsetTop=2*p+n.baseTop,"center"===t.internalData.attachPanInteractor?(n.internalData.x=h,n.internalData.width=this.width-h-d,n.internalData.y=u,n.internalData.height=this.height-u-p,e.internalData.x=n.internalData.x,e.internalData.width=n.internalData.width,e.internalData.y=n.internalData.y,e.internalData.height=n.internalData.height,e.camera.left=s.x,e.camera.right=o.x,e.camera.bottom=s.y,e.camera.top=o.y,this.calculateSceneFractions(e),this.updateSceneSize(e)):"bottom"===t.internalData.attachPanInteractor?(n.landscapeHeight=this.height,n.landscapeRows=1,n.camera.top=n.camera.bottom+r*this.height/c,n.internalData.x=h,n.internalData.width=this.width-h-d,n.internalData.y=0,n.internalData.height=this.height-p,n.baseTop=-p):"top"===t.internalData.attachPanInteractor?(n.landscapeHeight=this.height,n.landscapeRows=1,n.camera.bottom=n.camera.top-r*this.height/c,n.internalData.x=h,n.internalData.width=this.width-h-d,n.internalData.y=u,n.internalData.height=this.height-u,n.baseTop=0):"left"===t.internalData.attachPanInteractor?(n.landscapeWidth=this.width,n.landscapeColumns=1,n.camera.right=n.camera.left+i*this.width/l,n.internalData.x=0,n.internalData.width=this.width-d,n.internalData.y=u,n.internalData.height=this.height-u-p,n.baseLeft=0):"right"===t.internalData.attachPanInteractor&&(n.landscapeWidth=this.width,n.landscapeColumns=1,n.camera.left=n.camera.right-i*this.width/l,n.internalData.x=h,n.internalData.width=this.width-h,n.internalData.y=u,n.internalData.height=this.height-u-p,n.baseLeft=-h),this.addScene(n,!0),n.parent&&n.parent.remove(n),"center"===t.internalData.attachPanInteractor?this.panInteractor.object=n:"bottom"===t.internalData.attachPanInteractor?this.panInteractor.linkObjectsBottom.push(n):"top"===t.internalData.attachPanInteractor?this.panInteractor.linkObjectsTop.push(n):"left"===t.internalData.attachPanInteractor?this.panInteractor.linkObjectsLeft.push(n):"right"===t.internalData.attachPanInteractor&&this.panInteractor.linkObjectsRight.push(n),this.panInteractor.restorePanOffset(n),this.panInteractor.update()}else if(t.internalData.attachPanInteractorStatic&&this.panInteractor){var m=this;t.traverseAncestors((function(e){"bottom"===e.internalData.attachPanInteractor?(m.panInteractor.linkObjectsBottomStatic.push(t),t.linkBottom=e):"top"===e.internalData.attachPanInteractor?(m.panInteractor.linkObjectsTopStatic.push(t),t.linkTop=e):"left"===e.internalData.attachPanInteractor?(m.panInteractor.linkObjectsLeftStatic.push(t),t.linkLeft=e):"right"===e.internalData.attachPanInteractor&&(m.panInteractor.linkObjectsRightStatic.push(t),t.linkRight=e)}))}}createPickingInfo(t){if(void 0!==t.geometry&&void 0!==t.material){if(void 0===t.geometry.attributes.cellCount){var e,n;if(t.material.glyphs){var i=t.geometry.attributes.glyphOffset.array.length/3;n=i;for(var r=new Float32Array(i),a=0;a<i;a++)r[a]=a;e=new zs(r,1)}else if(t.isThickLineSegments){for(n=(s=t.geometry.attributes.instanceStart.array.length/3)/2,r=new Float32Array(n),a=0;a<n;a++)r[a]=a;e=new zs(r,1)}else{var s,o=1;for(t.isPoints?o=1:t.isLineSegments?o=2:t.isMesh&&(o=3),n=(s=t.geometry.attributes.position.array.length/3)/o,e=new _a(s,1),a=0;a<n;a++)for(var l=0;l<o;l++)e.array[a*o+l]=a}t.geometry.setAttribute("cellCount",e),t.geometry.nCells=n}t.nCells=t.geometry.nCells,t.startCell=this.startCell,t.onBeforeRender=function(t,e,n,i,r,a){r.uniforms.startCell.value=this.startCell,r.uniformsNeedUpdate=!0},this.startCell+=t.nCells,this.currentScene.landscapeGrid||this.createLandscapeGrid(this.currentScene),!this.pickingRenderTarget2&&this.startCell>16777215&&(this.pickingRenderTarget2=new Yi(this.pixelWidth,this.pixelHeight),this.pickingPixelBuffer2=new Uint8Array(4*this.pixelWidth*this.pixelHeight)),this.updatePicking=!0}}addLabels(t){t.isBillboardText&&t.addToScene(this.currentScene)}addMaterialReferences(t){void 0!==t.material&&(t.material.pickState=this.pickState,void 0!==t.material.isLineBasicMaterial&&(t.material.resolution=this.resolution))}loadGeometryAsJson(t,e,n,i){var r=this;this.objectLoader.parse(t,(function(t){r.clearGeometry(),r.updateSize(),r.addGeometry(t),r.renderNextFrame=!0,e&&e()}),n,i)}runAnimation(){if(null!==this.animator){this.animator.clear();for(var t=0;t<this.scenes.length;t++)this.animator.attach(this.scenes[t]);this.animator.hasAnimations()&&this.animator.play()}}animate(t){requestAnimationFrame(this.animate.bind(this)),this.visibleAnimatedGlyphs&&this.updateAnimatedGlyphs(this.enableAnimatedGlyphs?t:0),this.renderNextFrame&&(this.renderNextFrame=!1,this.render()),this.pickDepth===lm&&this.updatePicking&&(this.updatePicking=!1,this.pickRender())}setVisibleAnimatedGlyphs(t){this.visibleAnimatedGlyphs=t;for(let e=0;e<this.animatedGlyphs.length;e++)this.animatedGlyphs[e].traverse((function(e){e.visible=t}));this.renderNextFrame=!0}setEnableAnimatedGlyphs(t){this.enableAnimatedGlyphs=t}updateAnimatedGlyphs(t){const e=new Ai,n=new Ai,i=new Ai,r=new Ai,a=new Ai,s=new Ii,o=new Lr;for(let l=0;l<this.animatedGlyphs.length;l++){const c=this.animatedGlyphs[l];void 0===c.animatedGlyphsInitialized&&(c.animatedGlyphsInfo=JSON.parse(c.internalData.animatedGlyphs));const h=c.animatedGlyphsInfo.colorPalette,d=c.animatedGlyphsInfo.coordinates,u=c.animatedGlyphsInfo.segmentStartCoordIndex,p=c.animatedGlyphsInfo.segmentEndCoordIndex,m=c.animatedGlyphsInfo.segmentSpacing,f=c.animatedGlyphsInfo.segmentSpeed,g=c.animatedGlyphsInfo.segmentSurfaceColorIndex;if(void 0===c.animatedGlyphsInitialized){let t=0;for(let i=0;i<u.length;i++){if(m[i]<=0||0===f[i])continue;const r=u[i],a=p[i],s=m[i];let o=0;for(let t=r;t<a;t++)e.set(d[3*t],d[3*t+1],d[3*t+2]),n.set(d[3*t+3],d[3*t+4],d[3*t+5]),o+=e.distanceTo(n);t+=Math.ceil(o/s)}c.traverse((function(e){let n=e.geometry;if(void 0!==n){const i=n.getAttribute("position");n.dispose();const r=new Fh;r.setAttribute("position",i),r.setAttribute("glyphOffset",new zs(new Float32Array(3*t),3)),r.setAttribute("glyphOrientation",new zs(new Float32Array(9*t),9)),e.isMesh&&e.material.vertexColors&&r.setAttribute("color",new zs(new Float32Array(3*t),3)),e.geometry=r}})),c.animatedGlyphsInitialized=!0}const v=[],_=[],y=[];let x=0;for(let l=0;l<u.length;l++){if(m[l]<=0||0===f[l])continue;let c=g[l];(c<0||c>h.length)&&(c=0),o.set(h[c]);const b=f[l]>0?1:-1,S=m[l],M=b<0?p[l]-1:u[l],w=b<0?u[l]-1:p[l],E=S/Math.abs(f[l]);let T=S*(t%(1e3*E)/(1e3*E));for(let t=M;t!=w;t+=b){e.set(d[3*t],d[3*t+1],d[3*t+2]),n.set(d[3*t+3],d[3*t+4],d[3*t+5]);const l=e.distanceTo(n);i.subVectors(n,e).multiplyScalar(b).normalize(),r.copy(i).multiplyScalar(S),a.copy(i).multiplyScalar(T).add(b<0?n:e);const c=Math.atan2(-i.x,i.y);for(s.makeRotation(c);T<l;)v.push(a.x),v.push(a.y),v.push(a.z),_.push(s.elements[0]),_.push(s.elements[1]),_.push(s.elements[2]),_.push(s.elements[3]),_.push(s.elements[4]),_.push(s.elements[5]),_.push(s.elements[6]),_.push(s.elements[7]),_.push(s.elements[8]),y.push(o.r),y.push(o.g),y.push(o.b),a.add(r),T+=S,x++;T-=l}}c.traverse((function(t){const e=t.geometry;if(void 0!==e){const n=e.getAttribute("glyphOffset");n.set(v,0),n.needsUpdate=!0;const i=e.getAttribute("glyphOrientation");if(i.set(_,0),i.needsUpdate=!0,t.material.vertexColors){const t=e.getAttribute("color");t.set(y,0),t.needsUpdate=!0}e.instanceCount=x}})),this.renderNextFrame=!0}}loadGeometryAsEvents(t,e,n,i){var r=this,a=0,s=-1,o=0;function l(t){if(o--,t.layers.set(1),t.visible=t.saveVisible,s>0&&0==o)return r.render(),r.loading=!1,r.firstChunk=!1,void(e&&e())}function c(t){if("Group"===t.type){var e=r.objectLoader.parse(t);null!==r.curGroup&&r.curGroup.add(e),"SceneRoot"===e.name&&(void 0!==e.internalData.background?r.container.style.backgroundColor="#"+e.internalData.background.toString(16).padStart(6,"0"):r.container.style.backgroundColor="transparent"),e.updateMatrixWorld(!0),r.attachInteractors(e),r.curGroup=e}else if("FinishGroup"===t.type)null!==r.curGroup.parent&&(r.curGroup=r.curGroup.parent);else if("Geometry"===t.type){o++;var n=r.objectLoader.parse(t,l,r.images,r.textures,r.materials,r.geometries,r.curGroup);a++,r.addLabels(n),r.createPickingInfo(n),r.addMaterialReferences(n)}else if("Layout"===t.type){for(var i=r.objectLoader.parse(t),s=0;s<i.children.length;s++){var c=i.children[s];if(c.isPerspectiveCamera||c.isOrthographicCamera){i.camera=c,i.remove(c);break}}null==i.camera&&null!==i.background&&(i.camera=new Ch),void 0!==i.camera&&r.addScene(i),r.curGroup=i}else console.log("ERROR: unknown type: "+t.type)}if(void 0!==this.chunkId&&this.chunkId===t.chunkId||(this.clearGeometry(),this.curGroup=null,this.images=[],this.textures=[],this.materials=[],this.geometries=[],this.firstChunk=!0,this.chunkId=t.chunkId),this.loading=!0,this.updateSize(),void 0!==t&&void 0!==t.events&&0!==t.events.length){for(var h=0;h<t.events.length;h++)c(t.events[h]);!0===t.moreChunks?this.render():(s=a-1,0==o&&(this.render(),this.loading=!1,e&&e())),this.firstChunk=!1}else console.error("AVS.Three.Viewer.loadGeometryAsEvents: Can't get events")}highlightRender(){if(void 0!==this.renderer)for(var t=0;t<this.scenes.length;t++){var e=this.scenes[t];if(e.landscapeGrid){for(var n=0;n<e.landscapeRows;n++)for(var i=0;i<e.landscapeColumns;i++){var r=e.landscapeGrid[n][i];r.initialized&&(this.resolution.x=r.pixelWidth,this.resolution.y=r.pixelHeight,this.renderer.setSize(r.pixelWidth,r.pixelHeight),this.renderer.setClearColor(0,0),this.renderer.clear(),e.camera.setViewOffset(e.landscapeWidth,e.landscapeHeight,r.left,r.top,r.width,r.height),this.renderer.render(e.highlightScene,e.camera),r.highlightCtx.clearRect(0,0,r.pixelWidth,r.pixelHeight),r.highlightCtx.drawImage(this.renderer.domElement,0,0))}e.camera.clearViewOffset()}}else console.error("AVS.Three.Viewer: WebGLRenderer not set.")}pickRender(){if(void 0!==this.renderer){for(var t=0;t<this.scenes.length;t++){var e=this.scenes[t];if(e.landscapeGrid){e.traverse((function(t){void 0!==t.material&&(t.material.transparent=!1)}));for(var n=0;n<e.landscapeRows;n++)for(var i=0;i<e.landscapeColumns;i++){var r=e.landscapeGrid[n][i];r.initialized&&(this.resolution.x=r.pixelWidth,this.resolution.y=r.pixelHeight,this.renderer.setRenderTarget(r.pickingRenderTarget),this.pickState[0]=1,this.renderer.setClearColor(0,0),this.renderer.clear(),e.camera.setViewOffset(e.landscapeWidth,e.landscapeHeight,r.left,r.top,r.width,r.height),this.renderer.render(e,e.camera),this.renderer.readRenderTargetPixels(r.pickingRenderTarget,0,0,r.pixelWidth,r.pixelHeight,r.pickingPixelBuffer),r.pickingRenderTarget2&&(this.renderer.setRenderTarget(r.pickingRenderTarget2),this.pickState[0]=2,this.renderer.clear(),this.renderer.render(e,e.camera),this.renderer.readRenderTargetPixels(r.pickingRenderTarget2,0,0,r.pixelWidth,r.pixelHeight,r.pickingPixelBuffer2)))}e.camera.clearViewOffset(),e.traverse((function(t){void 0!==t.material&&(t.material.transparent=t.material.origTransparent)}))}}this.pickState[0]=0,this.renderer.setRenderTarget(null)}else console.error("AVS.Three.Viewer: WebGLRenderer not set.")}render(t){if(void 0!==this.renderer){if(null!==this.domElement.offsetParent){this.updateSize();for(var e=this.loading,n=t||!e,i=0;i<this.scenes.length;i++){var r=this.scenes[i];if(r.landscapeGrid){if(!n){r.camera.layers.set(1);for(var a=0;a<r.children.length;a++)r.children[a].isLight&&r.children[a].layers.set(1)}for(var s=0;s<r.landscapeRows;s++)for(var o=0;o<r.landscapeColumns;o++){var l=r.landscapeGrid[s][o];this.renderGridItem(l,n)}n||(r.camera.layers.set(0),r.traverse((function(t){t.layers.set(0)})))}for(a=0;a<r.labels.length;a++)r.labels[a].updatePosition()}this.updateHighlight&&(this.highlightRender(),this.updateHighlight=!1)}}else console.error("AVS.Three.Viewer: WebGLRenderer not set.")}renderGridItem(t,e){if(t.initialized){var n=t.scene;if(this.resolution.x=t.pixelWidth,this.resolution.y=t.pixelHeight,e?this.renderer.setSize(t.pixelWidth,t.pixelHeight):this.renderer.setRenderTarget(t.renderTarget),(e||this.firstChunk)&&(n.internalData.background?this.renderer.setClearColor(n.internalData.background,1):this.renderer.setClearColor(0,0),this.renderer.clear()),n.camera.setViewOffset(n.landscapeWidth,n.landscapeHeight,t.left,t.top,t.width,t.height),this.renderer.render(n,n.camera),e)t.ctx.clearRect(0,0,t.pixelWidth,t.pixelHeight),t.ctx.drawImage(this.renderer.domElement,0,0);else{this.renderer.readRenderTargetPixels(t.renderTarget,0,0,t.pixelWidth,t.pixelHeight,t.pixelBuffer);for(var i,r,a=t.ctx.createImageData(t.pixelWidth,t.pixelHeight),s=4*t.pixelWidth,o=0;o<t.pixelBuffer.length;o++)i=Math.floor(o/s),r=o%s,a.data[(t.pixelHeight-i-1)*s+r]=t.pixelBuffer[o];t.ctx.putImageData(a,0,0),this.renderer.setRenderTarget(null)}n.camera.clearViewOffset()}}addSelectionListener(t){void 0!==t&&this.selectionListeners.push(t)}concatObjectsFromCellNums(t,e,n,i){if(void 0!==n&&0!==n.length&&0!==n[0]){for(void 0===i&&(i=e.startCell,n.sort((function(t,e){return t-e})));void 0!==e.nCells&&n[0]>=i&&n[0]<i+e.nCells;)if(e.material.glyphs||e.isThickLineSegments?t.push({object:e,index:n[0]-i}):e.isMesh?t.push({object:e,faceIndex:n[0]-i}):t.push({object:e,index:(e.isLineSegments?2:1)*(n[0]-i)}),n.splice(0,1),0===n.length)return;void 0!==e.nCells&&(i+=e.nCells);for(var r=0;r<e.children.length&&void 0!==(i=this.concatObjectsFromCellNums(t,e.children[r],n,i));r++);return i}}pick(){if(!1!==this.validPick){this.intersects=[];for(var t=0;t<this.scenes.length;t++){var e=this.scenes[t];if(e.landscapeGrid)if(this.pickType===hm){var n=Math.max(this.pickRectangleLeft,e.windowX),i=Math.max(this.pickRectangleTop,e.windowTop),r=Math.min(this.pickRectangleRight,e.windowX+e.windowWidth),a=Math.min(this.pickRectangleBottom,e.windowTop+e.windowHeight);n-=e.windowX,i-=e.windowTop,r-=e.windowX,a-=e.windowTop,n-=(e.panOffsetX??0)+(e.baseLeft??0),r-=(e.panOffsetX??0)+(e.baseLeft??0),i-=(e.panOffsetY??0)+(e.baseTop??0),a-=(e.panOffsetY??0)+(e.baseTop??0);for(var s=[],o=n;o<r;o++)for(var l=i;l<a;l++)if(this.pickDepth===om){var c=o/e.landscapeWidth*2-1,h=(e.landscapeHeight-l-1)/e.landscapeHeight*2-1;this.raycaster.setFromCamera(new Ei(c,h),e.camera),this.raycaster.landscapeWidth=e.landscapeWidth,this.raycaster.landscapeHeight=e.landscapeHeight,this.raycaster.x=o,this.raycaster.y=l;var d=this.raycaster.intersectObjects(e.children,!0);this.intersects=this.intersects.concat(d)}else for(var u=0;u<e.landscapeRows;u++)for(var p=0;p<e.landscapeColumns;p++)if((_=e.landscapeGrid[u][p]).initialized&&!(o<_.left||o>_.left+_.width||l<_.top||l>_.top+_.height)){var m=Math.floor(o*window.devicePixelRatio),f=Math.floor(l*window.devicePixelRatio),g=4*(m-_.pixelX+(_.pixelHeight-(f-_.pixelY)-1)*_.pixelWidth),v=255*_.pickingPixelBuffer[g]*255+255*_.pickingPixelBuffer[g+1]+_.pickingPixelBuffer[g+2];_.pickingPixelBuffer2&&(v+=255*_.pickingPixelBuffer2[g]*255*255*255*255+255*_.pickingPixelBuffer2[g+1]*255*255*255+255*_.pickingPixelBuffer2[g+2]*255*255),v>0&&-1===s.indexOf(v)&&s.push(v)}this.pickDepth===lm&&this.concatObjectsFromCellNums(this.intersects,e,s)}else{if(this.pickRayX<e.windowX||this.pickRayX>e.windowX+e.windowWidth||this.pickRayY<e.windowTop||this.pickRayY>e.windowTop+e.windowHeight)continue;if(o=this.pickRayX-e.windowX,l=this.pickRayY-e.windowTop,o-=(e.panOffsetX??0)+(e.baseLeft??0),l-=(e.panOffsetY??0)+(e.baseTop??0),this.pickDepth===om)c=o/e.landscapeWidth*2-1,h=(e.landscapeHeight-l-1)/e.landscapeHeight*2-1,this.raycaster.setFromCamera(new Ei(c,h),e.camera),this.raycaster.landscapeWidth=e.landscapeWidth,this.raycaster.landscapeHeight=e.landscapeHeight,this.raycaster.x=o,this.raycaster.y=l,d=this.raycaster.intersectObjects(e.children,!0),this.intersects=this.intersects.concat(d);else for(u=0;u<e.landscapeRows;u++)for(p=0;p<e.landscapeColumns;p++){var _;(_=e.landscapeGrid[u][p]).initialized&&!(o<_.left||o>_.left+_.width||l<_.top||l>_.top+_.height)&&(m=Math.floor(o*window.devicePixelRatio),f=Math.floor(l*window.devicePixelRatio),g=4*(m-_.pixelX+(_.pixelHeight-(f-_.pixelY)-1)*_.pixelWidth),v=255*_.pickingPixelBuffer[g]*255+255*_.pickingPixelBuffer[g+1]+_.pickingPixelBuffer[g+2],_.pickingPixelBuffer2&&(v+=255*_.pickingPixelBuffer2[g]*255*255*255*255+255*_.pickingPixelBuffer2[g+1]*255*255*255+255*_.pickingPixelBuffer2[g+2]*255*255),this.concatObjectsFromCellNums(this.intersects,e,[v]))}}}for(t=0;t<this.selectionListeners.length;t++)this.selectionListeners[t]()}else console.error("AVS.Three.Viewer: invalid pick ray or rectangle.")}isObjectPickable(t){return void 0!==t.internalData.pickable?t.internalData.pickable:null===t.parent||this.isObjectPickable(t.parent)}getPickedCells(){for(var t=[],e=0;e<this.intersects.length;e++){var n=this.intersects[e].object;if(this.isObjectPickable(n)){for(var i=this.intersects[e].faceIndex??this.intersects[e].index,r=!1,a=0;a<t.length;a++)if(n===t[a].object){r=!0;for(var s=!1,o=0;o<t[a].indices.length;o++)if(i===t[a].indices[o]){s=!0;break}s||t[a].indices.push(i);break}r||t.push({object:n,indices:[i]})}}return t}getPickedCellSets(){for(var t=[],e=0;e<this.intersects.length;e++){var n=this.intersects[e].object;if(this.isObjectPickable(n)){for(var i=!1,r=0;r<t.length;r++)if(t[r].object===n){i=!0;break}i||t.push({object:n})}}return t}getPickedSceneNodes(){for(var t=[],e=0;e<this.intersects.length;e++){var n=this.intersects[e].object;if(this.isObjectPickable(n)){for(var i=n.parent,r=!1,a=0;a<t.length;a++)if(t[a].object===i){r=!0;break}r||t.push({object:i})}}return t}getSelectionInfo(t){for(var e=[],n=0;n<t.length;n++){var i=t[n].object,r=t[n].indices;if(void 0!==r)for(var a=0;a<r.length;a++)e.push(s(i,{},r[a]));else e.push(s(i,{}))}function s(t,e,n){for(var i in t.userData)void 0===e[i]&&(void 0!==n&&Array.isArray(t.userData[i])?e[i]=decodeURIComponent(t.userData[i][t.isLineSegments&&!t.material.glyphs?n/2:n]):e[i]=decodeURIComponent(t.userData[i]));return t.parent?s(t.parent,e):e}return e}highlightObjects(t,e){for(var n=!1,i=0;i<this.highlightList.length;i++)void 0!==(s=this.highlightList[i]).saveMaterial&&(s.material=s.saveMaterial,s.saveMaterial=void 0,n=!0),void 0!==s.saveGeometry&&(s.geometry=s.saveGeometry,s.saveGeometry=void 0,n=!0);for(i=0;i<this.scenes.length;i++){var r=this.scenes[i].highlightScene.children[0].children;r.length>0&&(r.length=0,this.updateHighlight=!0)}this.highlightList.length=0;var a=this;for(i=0;i<t.length;i++){var s;o(s=t[i].object,t[i].indices)}function o(t,i){if(t.isMesh||t.isLineSegments||t.isPoints){a.highlightList.push(t);var r,s=t.material.clone();if(s.opacity=1,void 0!==i){var l=t.geometry;if(s.vertexColors=!0,s.color=new Lr(16777215),t.isThickLineSegments){var c;if(r=new Fh,l.attributes.instancedColorStart,void 0===oldColorStart){c=new od(new Float32Array(l.attributes.instanceStart.array.length),6,1);for(var h=0,d=0;d<c.array.length/3;d++)c.array[h++]=t.material.color.r,c.array[h++]=t.material.color.g,c.array[h++]=t.material.color.b}else c=oldColorStart.data.clone();h=null;var u=null;for(d=0;d<i.length;d++){h=6*Math.floor(i[d]/6),u=2;for(var p=0;p<u;p++)c.array[h++]=a.highlightColor.r,c.array[h++]=a.highlightColor.g,c.array[h++]=a.highlightColor.b}for(var m in r.setAttribute("instancedColorStart",new Da(c,3,0)),r.setAttribute("instancedColorEnd",new Da(c,3,3)),l.attributes)"instancedColorStart"!==m&&"instancedColorEnd"!==m&&r.setAttribute(m,l.attributes[m])}else{r=t.material.glyphs?new Fh:new Ia;var f=l.attributes.color,g=null;if(void 0===f)for(g=t.material.glyphs?new zs(new Float32Array(l.attributes.offset.array.length),3):new _a(l.attributes.position.array.length,3),h=0,d=0;d<g.array.length/3;d++)g.array[h++]=t.material.color.r,g.array[h++]=t.material.color.g,g.array[h++]=t.material.color.b;else g=f.clone();for(h=null,u=null,d=0;d<i.length;d++)for(t.material.glyphs||t.cellType===dm?(h=3*i[d],u=1):t.cellType===um?(h=3*i[d],u=2):t.cellType===pm?(h=9*i[d],u=3):(h=18*Math.floor(i[d]/2),u=6),p=0;p<u;p++)g.array[h++]=a.highlightColor.r,g.array[h++]=a.highlightColor.g,g.array[h++]=a.highlightColor.b;for(var m in r.setAttribute("color",g),l.attributes)"color"!==m&&r.setAttribute(m,l.attributes[m])}}else s.vertexColors=!1,s.color=a.highlightColor,r=t.geometry;var v=a.getObjectScene(t);if(void 0!==v.internalData.is3D&&!1===v.internalData.is3D&&void 0!==e&&!0===e){var _=t.clone();_.material=s,_.geometry=r,_.matrixAutoUpdate=!1,_.matrix.copy(t.matrixWorld),v.highlightScene.children[0].add(_),a.updateHighlight=!0}else t.saveMaterial=t.material,t.material=s,t.saveGeometry=t.geometry,t.geometry=r,n=!0}for(var y=0;y<t.children.length;y++)o(t.children[y])}n?this.render(!0):this.updateHighlight&&(this.highlightRender(),this.updateHighlight=!1)}getObjectScene(t){return t.isScene?t:this.getObjectScene(t.parent)}}const of={type:"change"},lf={type:"start"},cf={type:"end"};class hf extends pi{constructor(t){super(),this.isTransformInteractor=!0,this.domElement=t,this.domElement.style.touchAction="none",this.object=new wr,this.scene=null,this.enabled=!0,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.enablePan=!0,this.keyPanSpeed=7,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.touches={ONE:bt,TWO:Mt},this.quaternion=this.object.quaternion.clone(),this.position=this.object.position.clone(),this.scale=this.object.scale.clone(),this.clientOnly=!1,this.fullReset=!1,this.quaternion0=this.object.quaternion.clone(),this.position0=this.object.position.clone(),this.scale0=this.object.scale.clone(),this._domElementKeyEvents=null,this.listenToKeyEvents=function(t){t.addEventListener("keydown",F),this._domElementKeyEvents=t},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",F),this._domElementKeyEvents=null},this.setObjectScene=function(t,n){e.object=t,e.scene=n,this.fullReset||t.internalData.transformFullReset?(e.quaternion.copy(e.object.quaternion),e.scale.copy(e.object.scale),e.position.copy(e.object.position),e.quaternion0.copy(e.object.quaternion),e.scale0.copy(e.object.scale),e.position0.copy(e.object.position),this.fullReset=!1):e.clientOnly&&(e.object.quaternion.copy(e.quaternion),e.object.scale.copy(e.scale),e.object.position.copy(e.position)),t.internalData.transformWheelActions&&(r=JSON.parse(t.internalData.transformWheelActions)),t.internalData.transformTriggers&&(a=JSON.parse(t.internalData.transformTriggers))},this.reset=function(){e.quaternion.copy(e.quaternion0),e.scale.copy(e.scale0),e.position.copy(e.position0),e.object.quaternion.copy(e.quaternion0),e.object.scale.copy(e.scale0),e.object.position.copy(e.position0),e.dispatchEvent(of),i=n.NONE},this.zoomIn=function(){b(1/f(),0,0)&&e.dispatchEvent(of)},this.zoomOut=function(){b(f(),0,0)&&e.dispatchEvent(of)},this.panTo=function(t,n,i){var r=e.object.parent.matrixWorld,a=1/r.elements[0],s=1/r.elements[5],o=1/r.elements[10],l=r.elements[12]*a,c=r.elements[13]*s,h=r.elements[14]*o;t*=e.object.scale.x,n*=e.object.scale.y,i*=e.object.scale.z,t+=l,n+=c,i+=h,e.object.position.set(e.position0.x-t,e.position0.y-n,e.position0.z-i),e.position.copy(e.object.position),e.dispatchEvent(of)},this.dispose=function(){e.domElement.removeEventListener("contextmenu",z),e.domElement.removeEventListener("pointerdown",D),e.domElement.removeEventListener("pointercancel",O),e.domElement.removeEventListener("wheel",U),e.domElement.removeEventListener("pointermove",N),e.domElement.removeEventListener("pointerup",O),null!==e._domElementKeyEvents&&(e._domElementKeyEvents.removeEventListener("keydown",F),e._domElementKeyEvents=null)};const e=this,n={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let i=n.NONE,r=[{modifiers:0,param:"ZOOM_AT_POINTER"}],a=[{buttons:1,modifiers:0,param:"ROTATE"},{buttons:2,modifiers:0,param:"SCALE"},{buttons:4,modifiers:0,param:"TRANSLATE"}];const s=new Ei,o=new Ei,l=new Ei,c=new Ei,h=new Ei,d=new Ei,u=new Ei,p=[],m={};function f(){return Math.pow(.95,e.zoomSpeed)}function g(t){return 2*(t-e.scene.windowDiv.getBoundingClientRect().left)/e.scene.windowWidth-1}function v(t){return 1-2*(t-e.scene.windowDiv.getBoundingClientRect().top)/e.scene.windowHeight}const _=function(){const t=new Ji,n=new Ai,i=new Ai,r=new Ai,a=new Ji,l=new Ai;let c,h;const d=new Ti;return function(){return null!==e.object&&null!==e.object.parent&&(t.multiplyMatrices(e.scene.camera.matrixWorldInverse,e.object.parent.matrixWorld),n.set(0,0,0),i.set(s.x,s.y,1),r.set(o.x,o.y,1),a.copy(t).invert(),n.applyMatrix4(a),i.applyMatrix4(a),r.applyMatrix4(a),i.sub(n).normalize(),r.sub(n).normalize(),void 0!==e.scene.internalData.is3D&&!1===e.scene.internalData.is3D?(l.set(0,0,1),c=i.x*r.y-i.y*r.x,c<0&&(l.negate(),c=-c)):(l.crossVectors(i,r),c=l.length()),!(c<1e-5||(h=Math.abs(c)<1?2*Math.sin(c):Math.PI,i.dot(r)<0&&(h+=.5*Math.PI),d.setFromAxisAngle(l.normalize(),h),e.object.quaternion.premultiply(d),e.quaternion.copy(e.object.quaternion),0)))}}(),y=function(){const t=new Ji,n=new Xi,i=new Ai,r=new Ji,a=new Xi,s=new Xi,o=new Ai,h=new Ai,d=new Ai;return function(){return null!==e.object&&null!==e.object.parent&&(t.multiplyMatrices(e.scene.camera.matrixWorldInverse,e.object.parent.matrixWorld),t.premultiply(e.scene.camera.projectionMatrix),n.set(0,0,0,1).applyMatrix4(t),i.set(n.x/n.w,n.y/n.w,n.z/n.w),r.copy(t).invert(),a.set(l.x,l.y,i.z,1),s.set(c.x,c.y,i.z,1),a.applyMatrix4(r),s.applyMatrix4(r),o.set(a.x/a.w,a.y/a.w,a.z/a.w),h.set(s.x/s.w,s.y/s.w,s.z/s.w),d.subVectors(h,o),e.object.position.add(d),e.position.copy(e.object.position),!0)}}();function x(t){return null!==e.object&&(e.object.scale.multiplyScalar(t),e.scale.copy(e.object.scale),!0)}const b=function(){const t=new Ji,n=new Ji,i=new Xi,r=new Xi,a=new Ai,s=new Ai;return function(o,l,c){return null!==e.object&&null!==e.object.parent&&(t.multiplyMatrices(e.scene.camera.matrixWorldInverse,e.object.parent.matrixWorld),t.premultiply(e.scene.camera.projectionMatrix),i.set(0,0,0,1).applyMatrix4(t),n.copy(t).invert(),r.set(l,c,i.z/i.w,1).applyMatrix4(n),a.set(r.x/r.w,r.y/r.w,r.z/r.w),a.sub(e.object.position),s.copy(a).multiplyScalar(o).add(a.negate()),e.object.scale.multiplyScalar(o),e.object.position.sub(s),e.scale.copy(e.object.scale),e.position.copy(e.object.position),!0)}}();function S(t){s.set(g(t.clientX),v(t.clientY))}function M(t){h.set(t.clientX,t.clientY)}function w(t){l.set(g(t.clientX),v(t.clientY))}function E(t){x(t.deltaY>0?f():1/f())&&e.dispatchEvent(of)}function T(t){const n=t.deltaY>0?f():1/f();b(n,g(t.clientX),v(t.clientY))&&e.dispatchEvent(of)}function A(){if(1===p.length)s.set(g(p[0].clientX),v(p[0].clientY));else{const t=.5*(p[0].clientX+p[1].clientX),e=.5*(p[0].clientY+p[1].clientY);s.set(g(t),v(e))}}function C(){if(1===p.length)l.set(g(p[0].clientX),v(p[0].clientY));else{const t=.5*(p[0].clientX+p[1].clientX),e=.5*(p[0].clientY+p[1].clientY);l.set(g(t),v(e))}}function R(){const t=Math.abs(p[0].clientX-p[1].clientX),e=Math.abs(p[0].clientY-p[1].clientY),n=Math.sqrt(t*t+e*e);h.set(0,n)}function I(t){if(1==p.length)o.set(g(t.clientX),v(t.clientY));else{const e=B(t),n=.5*(t.clientX+e.x),i=.5*(t.clientY+e.y);o.set(g(n),v(i))}_()&&e.dispatchEvent(of),s.copy(o)}function P(t){if(1===p.length)c.set(g(t.clientX),v(t.clientY));else{const e=B(t),n=.5*(t.clientX+e.x),i=.5*(t.clientY+e.y);c.set(g(n),v(i))}y()&&e.dispatchEvent(of),l.copy(c)}function L(t){const n=B(t),i=t.clientX-n.x,r=t.clientY-n.y,a=Math.sqrt(i*i+r*r);d.set(0,a),u.set(0,Math.pow(d.y/h.y,e.zoomSpeed)),x(u.y)&&e.dispatchEvent(of),h.copy(d)}function D(t){!1!==e.enabled&&(0===p.length&&(e.domElement.setPointerCapture(t.pointerId),e.domElement.addEventListener("pointermove",N),e.domElement.addEventListener("pointerup",O)),function(t){p.push(t)}(t),"touch"===t.pointerType?function(t){switch(k(t),p.length){case 1:switch(e.touches.ONE){case bt:if(!1===e.enableRotate)return;A(),i=n.TOUCH_ROTATE;break;case St:if(!1===e.enablePan)return;C(),i=n.TOUCH_PAN;break;default:i=n.NONE}break;case 2:switch(e.touches.TWO){case Mt:if(!1===e.enableZoom&&!1===e.enablePan)return;e.enableZoom&&R(),e.enablePan&&C(),i=n.TOUCH_DOLLY_PAN;break;case wt:if(!1===e.enableZoom&&!1===e.enableRotate)return;e.enableZoom&&R(),e.enableRotate&&A(),i=n.TOUCH_DOLLY_ROTATE;break;default:i=n.NONE}break;default:i=n.NONE}i!==n.NONE&&e.dispatchEvent(lf)}(t):function(t){t.preventDefault();var r=0;r+=t.shiftKey?1:0,r+=t.ctrlKey?2:0,r+=t.metaKey?4:0;let s=0;switch(t.button){case 0:s=1;break;case 1:s=2;break;case 2:s=4}for(var o=0,l=a.length;o<l;o++)if(r===a[o].modifiers&&s&a[o].buttons){switch(a[o].param){case 0:case"ROTATE":if(!1===e.enableRotate)continue;S(t),i=n.ROTATE,e.domElement.ownerDocument.body.style.cursor="move";break;case 1:case"SCALE":if(!1===e.enableZoom)continue;M(t),i=n.DOLLY,e.domElement.ownerDocument.body.style.cursor="ne-resize";break;case 2:case"TRANSLATE":if(!1===e.enablePan)continue;w(t),i=n.PAN,e.domElement.ownerDocument.body.style.cursor="move";break;default:i=n.NONE}i!==n.NONE&&e.dispatchEvent(lf);break}}(t))}function N(t){!1!==e.enabled&&("touch"===t.pointerType?function(t){switch(k(t),i){case n.TOUCH_ROTATE:if(!1===e.enableRotate)return;I(t);break;case n.TOUCH_PAN:if(!1===e.enablePan)return;P(t);break;case n.TOUCH_DOLLY_PAN:if(!1===e.enableZoom&&!1===e.enablePan)return;!function(t){e.enableZoom&&L(t),e.enablePan&&P(t)}(t);break;case n.TOUCH_DOLLY_ROTATE:if(!1===e.enableZoom&&!1===e.enableRotate)return;!function(t){e.enableZoom&&L(t),e.enableRotate&&I(t)}(t);break;default:i=n.NONE}}(t):function(t){if(!1!==e.enabled)switch(t.preventDefault(),i){case n.ROTATE:if(!1===e.enableRotate)return;!function(t){o.set(g(t.clientX),v(t.clientY)),_()&&e.dispatchEvent(of),s.copy(o)}(t);break;case n.DOLLY:if(!1===e.enableZoom)return;!function(t){d.set(t.clientX,t.clientY),u.subVectors(d,h),x((Math.abs(u.x)>Math.abs(u.y)?-u.x:u.y)>0?f():1/f())&&e.dispatchEvent(of),h.copy(d)}(t);break;case n.PAN:if(!1===e.enablePan)return;!function(t){c.set(g(t.clientX),v(t.clientY)),y()&&e.dispatchEvent(of),l.copy(c)}(t)}}(t))}function O(t){!function(t){delete m[t.pointerId];for(let e=0;e<p.length;e++)if(p[e].pointerId==t.pointerId)return void p.splice(e,1)}(t),0===p.length&&(e.domElement.releasePointerCapture(t.pointerId),e.domElement.removeEventListener("pointermove",N),e.domElement.removeEventListener("pointerup",O)),e.domElement.ownerDocument.body.style.cursor="default",e.dispatchEvent(cf),i=n.NONE}function U(t){if(!1!==e.enabled&&!1!==e.enableZoom&&i===n.NONE){var a=0;a+=t.shiftKey?1:0,a+=t.ctrlKey?2:0,a+=t.metaKey?4:0;for(var s=0,o=r.length;s<o;s++)if(a===r[s].modifiers){switch(t.preventDefault(),r[s].param){case 0:case"ZOOM":e.dispatchEvent(lf),E(t),e.dispatchEvent(cf);break;case 1:case"ZOOM_AT_POINTER":e.dispatchEvent(lf),T(t),e.dispatchEvent(cf)}return}}}function F(t){!1!==e.enabled&&!1!==e.enablePan&&function(t){let n=!1;switch(l.set(0,0),c.set(0,0),t.code){case e.keys.UP:c.y=e.keyPanSpeed/(e.scene.windowHeight/2),n=!0;break;case e.keys.BOTTOM:c.y=-e.keyPanSpeed/(e.scene.windowHeight/2),n=!0;break;case e.keys.LEFT:c.x=-e.keyPanSpeed/(e.scene.windowWidth/2),n=!0;break;case e.keys.RIGHT:c.x=e.keyPanSpeed/(e.scene.windowWidth/2),n=!0}let i=!1;n&&(i=y(),t.preventDefault()),i&&e.dispatchEvent(of)}(t)}function z(t){!1!==e.enabled&&t.preventDefault()}function k(t){let e=m[t.pointerId];void 0===e&&(e=new Ei,m[t.pointerId]=e),e.set(t.clientX,t.clientY)}function B(t){const e=t.pointerId===p[0].pointerId?p[1]:p[0];return m[e.pointerId]}e.domElement.addEventListener("contextmenu",z),e.domElement.addEventListener("pointerdown",D),e.domElement.addEventListener("pointercancel",O),e.domElement.addEventListener("wheel",U,{passive:!1}),e.listenToKeyEvents(window)}}const df={type:"change"},uf={type:"zoom"},pf={type:"zoomEnd"},mf={type:"start"},ff={type:"end"};class gf extends pi{constructor(t){super(),void 0===t&&console.warn('AVS.Three.PanInteractor: The first parameter "domElement" is now mandatory.'),t===document&&console.error('AVS.Three.PanInteractor: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.isPanInteractor=!0,this.domElement=t,this.domElement.style.touchAction="none",this.object=new wr,this.linkObjectsBottom=[],this.linkObjectsTop=[],this.linkObjectsLeft=[],this.linkObjectsRight=[],this.linkObjectsBottomStatic=[],this.linkObjectsTopStatic=[],this.linkObjectsLeftStatic=[],this.linkObjectsRightStatic=[],this.leftLimit=0,this.rightLimit=0,this.topLimit=0,this.bottomLimit=0,this.domElement=t,this.enabled=!0,this.enableZoom=!0,this.zoomSpeed=1,this.enablePan=!0,this.panSpeed=1,this.keyPanSpeed=7,this.enableKeys=!0,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:xt.PAN,MIDDLE:xt.NONE,RIGHT:xt.NONE},this.touches={ONE:St,TWO:Mt},this._domElementKeyEvents=null,this.listenToKeyEvents=function(t){t.addEventListener("keydown",L),this._domElementKeyEvents=t},this.saveState=function(){a.copy(r),l.copy(o)},this.reset=function(){o.equals(l)?(r.copy(a),e.update()):(o.copy(l),p.set(-1,-1),r.copy(a),T()),i=n.NONE},this.update=function(t=!0){if(void 0!==e.object&&void 0!==e.object.landscapeDiv){r.x>e.leftLimit?r.x=e.leftLimit:r.x<e.rightLimit&&(r.x=e.rightLimit),r.y<e.bottomLimit?r.y=e.bottomLimit:r.y>e.topLimit&&(r.y=e.topLimit),e.object.panOffsetX=r.x,e.object.panOffsetY=r.y,e.object.landscapeDiv.style.left=e.object.baseLeft+r.x+"px",e.object.landscapeDiv.style.top=e.object.baseTop+r.y+"px";for(let t=0,n=e.linkObjectsBottom.length;t<n;t++){const n=e.linkObjectsBottom[t];n.panOffsetX=r.x,n.landscapeDiv.style.left=n.baseLeft+r.x+"px"}for(let t=0,n=e.linkObjectsBottomStatic.length;t<n;t++)e.linkObjectsBottomStatic[t].traverse((function(t){t.isBillboardText&&(t.panOffsetX=-r.x,t.moveText())}));for(let t=0,n=e.linkObjectsTop.length;t<n;t++){const n=e.linkObjectsTop[t];n.panOffsetX=r.x,n.landscapeDiv.style.left=n.baseLeft+r.x+"px"}for(let t=0,n=e.linkObjectsTopStatic.length;t<n;t++)e.linkObjectsTopStatic[t].traverse((function(t){t.isBillboardText&&(t.panOffsetX=-r.x,t.moveText())}));for(let t=0,n=e.linkObjectsLeft.length;t<n;t++){const n=e.linkObjectsLeft[t];n.panOffsetY=r.y,n.landscapeDiv.style.top=n.baseTop+r.y+"px"}for(let t=0,n=e.linkObjectsLeftStatic.length;t<n;t++)e.linkObjectsLeftStatic[t].traverse((function(t){t.isBillboardText&&(t.panOffsetY=-r.y,t.moveText())}));for(let t=0,n=e.linkObjectsRight.length;t<n;t++){const n=e.linkObjectsRight[t];n.panOffsetY=r.y,n.landscapeDiv.style.top=n.baseTop+r.y+"px"}for(let t=0,n=e.linkObjectsRightStatic.length;t<n;t++)e.linkObjectsRightStatic[t].traverse((function(t){t.isBillboardText&&(t.panOffsetY=-r.y,t.moveText())}));t&&(df.detail={widthZoomLevel:o.x,heightZoomLevel:o.y,panX:-r.x,panY:-r.y},e.dispatchEvent(df)),p.set(-1,-1)}},this.restorePanOffset=function(t){p.x<0||(r.x=p.x-t.zoomOffsetLeft-Math.floor(t.centerWidth*m.x),r.y=p.y-t.zoomOffsetTop-Math.floor(t.centerHeight*m.y),e.update(!1))},this.clear=function(){this.linkObjectsBottom=[],this.linkObjectsTop=[],this.linkObjectsLeft=[],this.linkObjectsRight=[],this.linkObjectsBottomStatic=[],this.linkObjectsTopStatic=[],this.linkObjectsLeftStatic=[],this.linkObjectsRightStatic=[]},this.setWidthZoomLevel=function(t){t<100||(o.x,o.x=t,o.x>c&&(o.x=c),o.x)},this.setHeightZoomLevel=function(t){t<100||(o.y,o.y=t,o.y>c&&(o.y=c),o.y)},this.setMaximumZoomLevel=function(t){t<100||(c=t,(o.x>c||o.y>c)&&(o.x>c&&(o.x=c),o.y>c&&(o.y=c)))},this.dispose=function(){e.domElement.removeEventListener("contextmenu",D),e.domElement.removeEventListener("pointerdown",A),e.domElement.removeEventListener("pointercancel",I),e.domElement.removeEventListener("wheel",P),e.domElement.removeEventListener("pointermove",C),e.domElement.removeEventListener("pointerup",R),null!==e._domElementKeyEvents&&e._domElementKeyEvents.removeEventListener("keydown",L)};const e=this,n={NONE:-1,PAN:2,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5};let i=n.NONE;const r=new Ai,a=r.clone(),s=new Ei,o=new Ei(100,100),l=o.clone();let c=1e6;const h=new Ei,d=new Ei,u=new Ei,p=new Ei(-1,-1),m=new Ei,f=new Ei,g=new Ei,v=new Ei,_=[],y={};let x;function b(){return Math.pow(.95,e.zoomSpeed)}function S(){let t=!1;return o.x<100||o.y<100?(o.y<o.x?(o.x=100*o.x/o.y,o.y=100):(o.y=100*o.y/o.x,o.x=100),t=!0):(o.x>c||o.y>c)&&(o.y>o.x?(o.x=c*o.x/o.y,o.y=c):(o.y=c*o.y/o.x,o.x=c),t=!0),t}function M(t,e){var n;n=t,r.x+=n,function(t){r.y+=t}(e)}function w(t){o.multiplyScalar(t)}function E(t,n){if(!o.equals(s)){const i=e.domElement.getBoundingClientRect();p.x=Math.round(t-i.left),p.y=Math.round(n-i.top),p.x<e.object.windowX?p.x=e.object.windowX:p.x>e.object.windowX+e.object.windowWidth&&(p.x=e.object.windowX+e.object.windowWidth),p.y<e.object.windowTop?p.y=e.object.windowTop:p.y>e.object.windowTop+e.object.windowHeight&&(p.y=e.object.windowTop+e.object.windowHeight),m.x=(p.x-e.object.panOffsetX-e.object.zoomOffsetLeft)/e.object.centerWidth,m.y=(p.y-e.object.panOffsetY-e.object.zoomOffsetTop)/e.object.centerHeight,T()}}function T(){pf.detail={widthZoomLevel:o.x,heightZoomLevel:o.y},e.dispatchEvent(pf),s.copy(o)}function A(t){!1!==e.enabled&&(0===_.length&&(e.domElement.setPointerCapture(t.pointerId),e.domElement.addEventListener("pointermove",C),e.domElement.addEventListener("pointerup",R)),function(t){_.push(t)}(t),"touch"===t.pointerType?function(t){switch(O(t),_.length){case 1:if(e.touches.ONE===St){if(!1===e.enablePan)return;h.set(_[0].clientX,_[0].clientY),i=n.TOUCH_PAN}else i=n.NONE;break;case 2:if(e.touches.TWO===Mt){if(!1===e.enableZoom)return;!function(){const t=_[0].clientX-_[1].clientX,e=_[0].clientY-_[1].clientY,n=Math.sqrt(t*t+e*e);f.set(0,n)}(),i=n.TOUCH_DOLLY_PAN}else i=n.NONE;break;default:i=n.NONE}i!==n.NONE&&e.dispatchEvent(mf)}(t):function(t){let r;switch(t.preventDefault(),t.button){case 0:r=e.mouseButtons.LEFT;break;case 1:r=e.mouseButtons.MIDDLE;break;case 2:r=e.mouseButtons.RIGHT;break;default:r=-1}if(r===xt.PAN){if(!1===e.enablePan)return;!function(t){h.set(t.clientX,t.clientY)}(t),i=n.PAN,e.domElement.ownerDocument.body.style.cursor="move"}else i=n.NONE;i!==n.NONE&&e.dispatchEvent(mf)}(t))}function C(t){!1!==e.enabled&&("touch"===t.pointerType?function(t){switch(O(t),i){case n.TOUCH_PAN:if(!1===e.enablePan)return;!function(t){d.set(t.clientX,t.clientY),u.subVectors(d,h).multiplyScalar(e.panSpeed),M(u.x,u.y),h.copy(d)}(t),e.update();break;case n.TOUCH_DOLLY_PAN:if(!1===e.enableZoom)return;!function(t){clearTimeout(x);const n=function(t){const e=t.pointerId===_[0].pointerId?_[1]:_[0];return y[e.pointerId]}(t),i=t.clientX-n.x,r=t.clientY-n.y,a=Math.sqrt(i*i+r*r);g.set(0,a),v.set(0,Math.pow(g.y/f.y,e.zoomSpeed)),w(v.y),f.copy(g);const s=.5*(t.clientX+n.x),o=.5*(t.clientY+n.y);S()?E(s,o):x=setTimeout(E,300,s,o)}(t);break;default:i=n.NONE}}(t):function(t){if(!1!==e.enabled&&(t.preventDefault(),i===n.PAN)){if(!1===e.enablePan)return;!function(t){d.set(t.clientX,t.clientY),u.subVectors(d,h).multiplyScalar(e.panSpeed),M(u.x,u.y),h.copy(d),e.update()}(t)}}(t))}function R(t){N(t),0===_.length&&(e.domElement.releasePointerCapture(t.pointerId),e.domElement.removeEventListener("pointermove",C),e.domElement.removeEventListener("pointerup",R)),e.domElement.ownerDocument.body.style.cursor="default",e.dispatchEvent(ff),i=n.NONE}function I(t){N(t)}function P(t){!1!==e.enabled&&!1!==e.enableZoom&&i===n.NONE&&(t.preventDefault(),e.dispatchEvent(mf),function(t){var n;clearTimeout(x),t.deltaY<0?(n=b(),o.divideScalar(n)):t.deltaY>0&&w(b());const i=S();uf.detail={widthZoomLevel:o.x,heightZoomLevel:o.y,clientX:t.clientX,clientY:t.clientY},e.dispatchEvent(uf),i?E(t.clientX,t.clientY):x=setTimeout(E,300,t.clientX,t.clientY)}(t),e.dispatchEvent(ff))}function L(t){!1!==e.enabled&&!1!==e.enablePan&&function(t){let n=!1;switch(t.code){case e.keys.UP:M(0,e.keyPanSpeed),n=!0;break;case e.keys.BOTTOM:M(0,-e.keyPanSpeed),n=!0;break;case e.keys.LEFT:M(e.keyPanSpeed,0),n=!0;break;case e.keys.RIGHT:M(-e.keyPanSpeed,0),n=!0}n&&(t.preventDefault(),e.update())}(t)}function D(t){!1!==e.enabled&&t.preventDefault()}function N(t){delete y[t.pointerId];for(let e=0;e<_.length;e++)if(_[e].pointerId==t.pointerId)return void _.splice(e,1)}function O(t){let e=y[t.pointerId];void 0===e&&(e=new Ei,y[t.pointerId]=e),e.set(t.clientX,t.clientY)}e.domElement.addEventListener("contextmenu",D),e.domElement.addEventListener("pointerdown",A),e.domElement.addEventListener("pointercancel",I),e.domElement.addEventListener("wheel",P,{passive:!1}),e.listenToKeyEvents(window)}}const vf={type:"change"},_f={type:"start"},yf={type:"end"};class xf extends pi{constructor(t){super(),void 0===t&&console.warn('AVS.Three.ZoomRectangleInteractor: The first parameter "domElement" is now mandatory.'),t===document&&console.error('AVS.Three.ZoomRectangleInteractor: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.isZoomRectangleInteractor=!0,this.domElement=t,this.domElement.style.touchAction="none",this.object=new wr,this.scene=null,this.enabled=!0,this.position=this.object.position.clone(),this.scale=this.object.scale.clone(),this.clientOnly=!1,this.fullReset=!1,this.scale0=this.object.scale.clone(),this.position0=this.object.position.clone(),this.setObjectScene=function(t,n){switch(e.object=t,e.scene=n,this.fullReset||t.internalData.zoomRectangleFullReset?(e.scale.copy(e.object.scale),e.position.copy(e.object.position),e.scale0.copy(e.object.scale),e.position0.copy(e.object.position),this.fullReset=!1):e.clientOnly&&(e.object.scale.copy(e.scale),e.object.position.copy(e.position)),t.internalData.zoomRectangleTriggers&&(s=JSON.parse(t.internalData.zoomRectangleTriggers)),i=t.internalData.zoomInMaxLimit,r=t.internalData.zoomOutMaxLimit,c=void 0!==t.internalData.zoomRectangleColor?"#"+t.internalData.zoomRectangleColor.toString(16).padStart(6,"0"):null,h=t.internalData.zoomRectangleWidth?t.internalData.zoomRectangleWidth:null,t.internalData.zoomRectanglePattern){case 0:d=[];break;case 1:d=[4,4];break;case 2:d=[1,3];break;case 3:d=[5,1,1,1];break;default:d=null}const a=document.createElement("canvas");a.style.position="absolute",a.style.width="100%",a.style.height="100%",a.id=e.scene.name+"RectCanvas",a.width=e.scene.windowWidth,a.height=e.scene.windowHeight,e.scene.windowDiv.appendChild(a),e.scene.rectCanvas=a,e.scene.rectCtx=a.getContext("2d")},this.reset=function(){e.scale.copy(e.scale0),e.position.copy(e.position0),e.object.scale.copy(e.scale0),e.object.position.copy(e.position0),e.dispatchEvent(vf),a=n.NONE},this.dispose=function(){e.domElement.removeEventListener("contextmenu",w),e.domElement.removeEventListener("pointerdown",x),e.domElement.removeEventListener("pointercancel",M),e.domElement.removeEventListener("pointermove",b),e.domElement.removeEventListener("pointerup",S)};const e=this,n={NONE:-1,ZOOM_IN:0,ZOOM_OUT:1};let i,r,a=n.NONE,s=[{buttons:1,modifiers:0,param:"ZOOM_IN"},{buttons:1,modifiers:1,param:"ZOOM_OUT"}],o=0;const l=[];let c=null,h=null,d=null;const u=new Ei,p=new Ei,m=[],f={};function g(t){return Math.max(0,Math.min(t.clientX-e.scene.windowDiv.getBoundingClientRect().left,e.scene.windowWidth))}function v(t){return Math.max(0,Math.min(t.clientY-e.scene.windowDiv.getBoundingClientRect().top,e.scene.windowHeight))}const _=function(){const t=new Ji,s=new Ji,o=new Xi,l=new Xi,c=new Ai,h=new Xi,d=new Ai;return function(u,p,m,f){const g=e.scene.windowWidth/(p-u),v=e.scene.windowHeight/(f-m);t.multiplyMatrices(e.scene.camera.matrixWorldInverse,e.object.parent.matrixWorld),t.premultiply(e.scene.camera.projectionMatrix),o.set(0,0,0,1).applyMatrix4(t),s.copy(t).invert();let _=1;if(a===n.ZOOM_IN){if(_=v<g?v:g,void 0!==i){const t=Math.max(Math.max(e.object.scale.x,e.object.scale.y),e.object.scale.z);_*t>i&&(_=i/t)}const t=(u+p)/e.scene.windowWidth-1,n=1-(m+f)/e.scene.windowHeight;l.set(t,n,o.z/o.w,1).applyMatrix4(s),c.set(l.x/l.w,l.y/l.w,l.z/l.w),h.set(0,0,o.z/o.w,1).applyMatrix4(s),d.set(h.x/h.w,h.y/h.w,h.z/h.w),c.sub(e.object.position),d.sub(e.object.position),c.multiplyScalar(_).sub(d),e.object.position.sub(c)}else if(a===n.ZOOM_OUT){if(_=v>g?1/v:1/g,void 0!==r){const t=Math.max(Math.max(e.object.scale.x,e.object.scale.y),e.object.scale.z);_*t<1/r&&(_=1/r/t)}l.set(0,0,o.z/o.w,1).applyMatrix4(s),c.set(l.x/l.w,l.y/l.w,l.z/l.w),c.sub(e.object.position),d.copy(c),c.multiplyScalar(_).sub(d),e.object.position.sub(c)}return e.object.scale.multiplyScalar(_),!0}}();function y(t){u.set(g(t),v(t));const n=window.getComputedStyle(e.scene.rectCanvas);let i="#ff0000";const r=n.getPropertyValue("--avs-drag-rectangle-stroke-style").trim();null!==c?i=c:null!==r&&r.length>0&&(i=r),e.scene.rectCtx.strokeStyle=i;let a=1;const s=n.getPropertyValue("--avs-drag-rectangle-line-width").trim();null!==h?a=h:null!==s&&s.length>0&&(a=s),e.scene.rectCtx.lineWidth=a;let p=l;const m=n.getPropertyValue("--avs-drag-rectangle-line-dash").trim();null!==d?p=d:null!==m&&m.length>0&&(p=JSON.parse(m)),e.scene.rectCtx.setLineDash(p),o=1}function x(t){!1!==e.enabled&&(0===m.length&&(e.domElement.setPointerCapture(t.pointerId),e.domElement.addEventListener("pointermove",b),e.domElement.addEventListener("pointerup",S)),function(t){m.push(t)}(t),function(t){let i=0;i+=t.shiftKey?1:0,i+=t.ctrlKey?2:0,i+=t.metaKey?4:0;let r=0;switch(t.button){case 0:r=1;break;case 1:r=2;break;case 2:r=4}for(let o=0,l=s.length;o<l;o++)if(i===s[o].modifiers&&r&s[o].buttons){switch(s[o].param){case 1:case"ZOOM_IN":y(t),a=n.ZOOM_IN,e.domElement.ownerDocument.body.style.cursor="zoom-in";break;case 2:case"ZOOM_OUT":y(t),a=n.ZOOM_OUT,e.domElement.ownerDocument.body.style.cursor="zoom-out";break;default:a=n.NONE}a!==n.NONE&&e.dispatchEvent(_f);break}}(t))}function b(t){!1!==e.enabled&&function(t){!1!==e.enabled&&function(t){if(o<1)return;if(p.set(g(t),v(t)),e.scene.rectCtx.clearRect(0,0,e.scene.windowWidth,e.scene.windowHeight),1==o){const t=Math.abs(u.x-p.x),e=Math.abs(u.y-p.y);if(t*t+e*e<25)return;o=2}const n=Math.min(u.x,p.x),i=Math.max(u.x,p.x),r=Math.min(u.y,p.y),a=Math.max(u.y,p.y);e.scene.rectCtx.strokeRect(n+.5,r+.5,i-n,a-r)}(t)}(t)}function S(t){!1!==e.enabled&&(function(t){(function(t){if(o<2)return;p.set(g(t),v(t)),e.scene.rectCtx.clearRect(0,0,e.scene.windowWidth,e.scene.windowHeight);const n=Math.min(u.x,p.x),i=Math.max(u.x,p.x),r=Math.min(u.y,p.y),a=Math.max(u.y,p.y);_(n,i,r,a)&&(e.scale.copy(e.object.scale),e.position.copy(e.object.position),e.dispatchEvent(vf)),o=0})(t),e.domElement.ownerDocument.body.style.cursor="default",e.dispatchEvent(yf),a=n.NONE}(t),E(t),0===m.length&&(e.domElement.releasePointerCapture(t.pointerId),e.domElement.removeEventListener("pointermove",b),e.domElement.removeEventListener("pointerup",S)))}function M(t){E(t)}function w(t){!1!==e.enabled&&t.preventDefault()}function E(t){delete f[t.pointerId];for(let e=0;e<m.length;e++)if(m[e].pointerId==t.pointerId)return void m.splice(e,1)}e.domElement.addEventListener("contextmenu",w),e.domElement.addEventListener("pointerdown",x),e.domElement.addEventListener("pointercancel",M)}}const bf={type:"change"},Sf={type:"start"},Mf={type:"end"};class wf extends pi{constructor(t){super(),this.hasStyleAnimations=!1,this.hasObjectAnimations=!1,this.createAnimationLibrary(),this.animating=0,this.mixers=[]}createAnimationLibrary(){const t=[0,2],e=new qc(".material.opacityFactor",t,[0,1]),n=new jc(".material.transparent",t,[!0,!1]);this.fadeInClip=new Kc("fade-in",-1,[e,n]),this.fadeInClip.setOnChildren=!0;const i=new qc(".material.opacityFactor",t,[1,0]),r=new jc(".material.transparent",t,[!0,!0]);this.fadeOutClip=new Kc("fade-out",-1,[i,r]),this.fadeOutClip.setOnChildren=!0;const a=new qc(".scaleFactorX",t,[0,1]);this.growXClip=new Kc("grow-x",-1,[a]);const s=new qc(".scaleFactorY",t,[0,1]);this.growYClip=new Kc("grow-y",-1,[s]);const o=new qc(".scaleFactorZ",t,[0,1]);this.growZClip=new Kc("grow-z",-1,[o]);const l=new qc(".material.glyphScaleFactorX",t,[0,1]);this.growXGlyphClip=new Kc("grow-x-glyph",-1,[l]),this.growXGlyphClip.setOnChildren=!0;const c=new qc(".material.glyphScaleFactorY",t,[0,1]);this.growYGlyphClip=new Kc("grow-y-glyph",-1,[c]),this.growYGlyphClip.setOnChildren=!0;const h=new qc(".material.glyphScaleFactorZ",t,[0,1]);this.growZGlyphClip=new Kc("grow-z-glyph",-1,[h]),this.growZGlyphClip.setOnChildren=!0;const d=new jc(".visible",t,[!1,!0]);this.enterAfterClip=new Kc("enter-after",-1,[d]),this.enterAfterClip.setOnChildren=!0}setStyleMap(t){if(this.hasStyleAnimations=!1,void 0===t)return;const e=["scene","sceneTitle","chart","chartTitle","axis","legend","legendTitle","glyph","transform"];this.styleAnimationClips={},this.transformAnimations=void 0;for(let n=0,i=e.length;n<i;n++){const i=e[n];void 0!==t[i]&&(i.startsWith("transform")?this.transformAnimations=JSON.parse(t[i]):this.styleAnimationClips[i]=this.fillStyleClipsArray(t[i].split(","),"glyph"===i))}}fillStyleClipsArray(t,e){const n=[];for(let i=0,r=t.length;i<r;i++){const r=t[i].trim();"fade-in"===r?(n.push(this.fadeInClip),this.hasStyleAnimations=!0):"fade-out"===r?(n.push(this.fadeOutClip),this.hasStyleAnimations=!0):"grow-x"===r?(n.push(e?this.growXGlyphClip:this.growXClip),this.hasStyleAnimations=!0):"grow-y"===r?(n.push(e?this.growYGlyphClip:this.growYClip),this.hasStyleAnimations=!0):"grow-z"===r?(n.push(e?this.growZGlyphClip:this.growZClip),this.hasStyleAnimations=!0):"enter-after"===r&&(n.push(this.enterAfterClip),this.hasStyleAnimations=!0)}return n}fillObjectClipsArray(t,e){const n=[];return!!(1&t)&&(n.push(this.fadeInClip),this.hasObjectAnimations=!0),!!(2&t)&&(n.push(this.fadeOutClip),this.hasObjectAnimations=!0),!!(4&t)&&(n.push(e?this.growXGlyphClip:this.growXClip),this.hasObjectAnimations=!0),!!(8&t)&&(n.push(e?this.growYGlyphClip:this.growYClip),this.hasObjectAnimations=!0),!!(16&t)&&(n.push(e?this.growZGlyphClip:this.growZClip),this.hasObjectAnimations=!0),!!(32&t)&&(n.push(this.enterAfterClip),this.hasObjectAnimations=!0),n}hasAnimations(){return this.hasStyleAnimations||this.hasObjectAnimations||this.transformAnimations}clear(){this.mixers=[],this.hasObjectAnimations=!1}attach(t){const e=this,n=this.createMixers.bind(this);this.createMixers(t,this.styleAnimationClips.scene),t.traverse((function(t){if(t.internalData.animations){const i=e.fillObjectClipsArray(t.internalData.animations,"GLYPH"===t.internalData.visualizationGroup);n(t,i)}if(t.internalData.attachTransformInteractor&&e.transformAnimations){const i=new Ai,r=new Ti,a=new or,s=new Ai;t.matrix.decompose(i,r,s);const o=[],l=[],c=[],h=[];let d=!1;for(let t=0,n=e.transformAnimations.length;t<n;t++){const n=e.transformAnimations[t];void 0===n.time&&(console.error("AVS.Three.Animator: Missing time value from transform animation index "+t),d=!0),o.push(n.time/1e3),void 0!==n.position&&i.set(n.position[0],n.position[1],n.position[2]),l.push(i.x),l.push(i.y),l.push(i.z),void 0!==n.scale&&s.set(n.scale/100,n.scale/100,n.scale/100),h.push(s.x),h.push(s.y),h.push(s.z),void 0!==n.rotation&&(a.set(n.rotation[0]*Math.PI/180,n.rotation[1]*Math.PI/180,n.rotation[2]*Math.PI/180,n.rotation[3]),r.setFromEuler(a)),c.push(r.x),c.push(r.y),c.push(r.z),c.push(r.w)}if(!d){const e=new Jc(".position",o,l),i=new Zc(".quaternion",o,c),r=new Jc(".scale",o,h),a=new Kc("transform",-1,[e,i,r]);n(t,[a])}}"SCENE_TITLE"===t.internalData.visualizationGroup&&n(t,e.styleAnimationClips.sceneTitle),"CHART"===t.internalData.visualizationGroup&&n(t,e.styleAnimationClips.chart),"CHART_TITLE"===t.internalData.visualizationGroup&&n(t,e.styleAnimationClips.chartTitle),"AXIS"===t.internalData.visualizationGroup&&n(t,e.styleAnimationClips.axis),"LEGEND"===t.internalData.visualizationGroup&&n(t,e.styleAnimationClips.legend),"LEGEND_TITLE"===t.internalData.visualizationGroup&&n(t,e.styleAnimationClips.legendTitle),"GLYPH"===t.internalData.visualizationGroup&&n(t,e.styleAnimationClips.glyph)}))}createMixers(t,e){if(void 0!==e)for(let n=0,i=e.length;n<i;n++){let i;if(e[n].setOnChildren?t.traverse((function(t){t.material&&(void 0===i&&(i=new id),i.add(t))})):i=t,void 0!==i){const t=new sd(i);t.clip=e[n],this.mixers.push(t)}}}play(){this.mixers.length<=0&&(this.dispatchEvent(Sf),this.dispatchEvent(bf),this.dispatchEvent(Mf)),this.animating=0,this.finishedFunc=this.animationFinished.bind(this);for(let t=0,e=this.mixers.length;t<e;t++){const e=this.mixers[t];e.addEventListener("finished",this.finishedFunc);const n=e.clipAction(e.clip);e.action=n,n.repetitions=1,n.clampWhenFinished=!0,n.play(),this.animating++}this.dispatchEvent(Sf),this.timer=new qh,this.animate()}animationFinished(t){t.target.removeEventListener("finished",this.finishedFunc),this.animating--}animate(){if(this.animating<=0)return void this.dispatchEvent(Mf);requestAnimationFrame(this.animate.bind(this)),this.timer.update();const t=this.timer.getDelta();for(let e=0,n=this.mixers.length;e<n;e++)this.mixers[e].action.isRunning()&&this.mixers[e].update(t);this.dispatchEvent(bf)}}
|
|
120
|
+
var lm=0,cm=1,hm=0,dm=1,um=1,pm=2,mm=3,fm=4;const gm=new Ci;class vm extends Tr{constructor(){super(),this.scaleFactorX=1,this.scaleFactorY=1,this.scaleFactorZ=1}updateMatrix(){gm.set(this.scale.x*this.scaleFactorX,this.scale.y*this.scaleFactorY,this.scale.z*this.scaleFactorZ),this.matrix.compose(this.position,this.quaternion,gm),this.matrixWorldNeedsUpdate=!0}toJSON(t){const e=super.toJSON(t);return"{}"!==JSON.stringify(this.internalData)&&(e.object.internalData=this.internalData),e.metadata=void 0,1===this.layers.mask&&(e.object.layers=void 0),this.matrix.equals(new Ki)&&(e.object.matrix=void 0),e}}const _m=new Ci,ym=new Ci;class xm extends Wo{constructor(t,e){super(t,e),this.scaleFactorX=1,this.scaleFactorY=1,this.scaleFactorZ=1}updateMatrix(){ym.set(this.scale.x*this.scaleFactorX,this.scale.y*this.scaleFactorY,this.scale.z*this.scaleFactorZ),this.matrix.compose(this.position,this.quaternion,ym),this.matrixWorldNeedsUpdate=!0}toJSON(t){const e=super.toJSON(t);return e.metadata=void 0,1===this.layers.mask&&(e.object.layers=void 0),this.matrix.equals(new Ki)&&(e.object.matrix=void 0),e}raycast(t,e){const n=this.geometry.attributes,i=n.position.array;let r,a,s,o,l,c,h=.5;void 0===this.material.vertexSizes&&(h=this.material.size/2);for(let d=0,u=i.length/3;d<u;d++)_m.fromArray(i,3*d),_m.applyMatrix4(this.matrixWorld),_m.project(t.camera),r=(_m.x+1)/2*t.landscapeWidth,a=(1-(_m.y+1)/2)*t.landscapeHeight,this.material.vertexSizes&&(h=n.vsize.array[d]/2),s=r-h,o=r+h,l=a-h,c=a+h,t.x>=s&&t.x<=o&&t.y>=l&&t.y<=c&&e.push({distance:null,distanceToRay:null,point:null,index:d,face:null,object:this})}}const bm=new Ci;class Sm extends Fo{constructor(t,e){super(t,e),this.scaleFactorX=1,this.scaleFactorY=1,this.scaleFactorZ=1}updateMatrix(){bm.set(this.scale.x*this.scaleFactorX,this.scale.y*this.scaleFactorY,this.scale.z*this.scaleFactorZ),this.matrix.compose(this.position,this.quaternion,bm),this.matrixWorldNeedsUpdate=!0}toJSON(t){const e=super.toJSON(t);return e.metadata=void 0,1===this.layers.mask&&(e.object.layers=void 0),this.matrix.equals(new Ki)&&(e.object.matrix=void 0),e}}const Mm=new Ki,wm=new Ki,Em=new Ki,Tm=[],Am=new Ss,Cm=new Ci;class Rm extends Ss{constructor(t,e){super(t,e),this.scaleFactorX=1,this.scaleFactorY=1,this.scaleFactorZ=1}updateMatrix(){Cm.set(this.scale.x*this.scaleFactorX,this.scale.y*this.scaleFactorY,this.scale.z*this.scaleFactorZ),this.matrix.compose(this.position,this.quaternion,Cm),this.matrixWorldNeedsUpdate=!0}raycast(t,e){if(Am.geometry=this.geometry,Am.material=this.material,void 0===Am.material||void 0===Am.geometry)return;if(!Am.material.glyphs)return super.raycast(t,e);const n=this.matrixWorld,i=Am.geometry.attributes.glyphOffset.array,r=i.length/3;let a,s,o;for(let l=0;l<r;l++){if(a=3*l,Am.material.vertexGlyphScales?(s=Am.geometry.attributes.glyphScale.array,Mm.makeScale(s[a],s[a+1],s[a+2])):Mm.makeScale(Am.material.glyphScale.x,Am.material.glyphScale.y,Am.material.glyphScale.z),Am.material.vertexGlyphOrientations&&(o=Am.geometry.attributes.glyphOrientation.array,Em.set(o[a],o[a+3],o[a+6],0,o[a+1],o[a+4],o[a+7],0,o[a+2],o[a+5],o[a+8],0,0,0,0,1),Mm.multiply(Em)),Mm.setPosition(i[a],i[a+1],i[a+2]),wm.multiplyMatrices(n,Mm),Am.matrixWorld=wm,Am.raycast(t,Tm),Tm.length>0){const t=Tm[0];t.faceIndex=l,t.object=this,e.push(t)}Tm.length=0}}toJSON(t){const e=super.toJSON(t);return e.metadata=void 0,1===this.layers.mask&&(e.object.layers=void 0),this.matrix.equals(new Ki)&&(e.object.matrix=void 0),e}}class Im extends Ch{constructor(t,e=Math.PI){super(t,e)}toJSON(t){const e=super.toJSON(t);return e.metadata=void 0,1===this.layers.mask&&(e.object.layers=void 0),this.matrix.equals(new Ki)&&(e.object.matrix=void 0),16777215===this.color.getHex()&&(e.object.color=void 0),this.intensity===Math.PI&&(e.object.intensity=void 0),e.object.shadow=void 0,e}}class Pm extends Ph{constructor(t,e=Math.PI){super(t,e)}toJSON(t){const e=super.toJSON(t);return e.metadata=void 0,1===this.layers.mask&&(e.object.layers=void 0),this.matrix.equals(new Ki)&&(e.object.matrix=void 0),16777215===this.color.getHex()&&(e.object.color=void 0),this.intensity===Math.PI&&(e.object.intensity=void 0),e.object.shadow=void 0,e}}class Lm extends Lh{constructor(t,e=Math.PI){super(t,e)}toJSON(t){const e=super.toJSON(t);return e.metadata=void 0,1===this.layers.mask&&(e.object.layers=void 0),this.matrix.equals(new Ki)&&(e.object.matrix=void 0),16777215===this.color.getHex()&&(e.object.color=void 0),this.intensity===Math.PI&&(e.object.intensity=void 0),e}}class Dm extends Rh{constructor(t,e,n,i,r,a){super(t,e,n,i,r,a),this.keepAspectRatio=!1,this.origLeft=t,this.origRight=e,this.origTop=n,this.origBottom=i}toJSON(t){const e=super.toJSON(t);return e.metadata=void 0,1===this.layers.mask&&(e.object.layers=void 0),this.matrix.equals(new Ki)&&(e.object.matrix=void 0),1===this.zoom&&(e.object.zoom=void 0),-1===this.left&&(e.object.left=void 0),1===this.right&&(e.object.right=void 0),1===this.top&&(e.object.top=void 0),-1===this.bottom&&(e.object.bottom=void 0),.1===this.near&&(e.object.near=void 0),2e3===this.far&&(e.object.far=void 0),this.keepAspectRatio&&(e.object.keepAspectRatio=!0),e}}class Nm extends wh{toJSON(t){const e=super.toJSON(t);return e.metadata=void 0,1===this.layers.mask&&(e.object.layers=void 0),this.matrix.equals(new Ki)&&(e.object.matrix=void 0),50===this.fov&&(e.object.fov=void 0),1===this.zoom&&(e.object.zoom=void 0),.1===this.near&&(e.object.near=void 0),2e3===this.far&&(e.object.far=void 0),10===this.focus&&(e.object.focus=void 0),1===this.aspect&&(e.object.aspect=void 0),35===this.filmGauge&&(e.object.filmGauge=void 0),0===this.filmOffset&&(e.object.filmOffset=void 0),e}}class Om extends Fr{toJSON(t){const e=super.toJSON(t);return e.metadata=void 0,1===this.layers.mask&&(e.object.layers=void 0),this.matrix.equals(new Ki)&&(e.object.matrix=void 0),e}}class Um extends wc{constructor(t){super(),Object.defineProperties(this,{pickState:{get:function(){return this.uniforms.pickState.value},set:function(t){this.uniforms.pickState.value=t}},startCell:{get:function(){return this.uniforms.startCell.value},set:function(t){this.uniforms.startCell.value=t}},glyphs:{get:function(){return this.defines.GLYPH},set:function(t){this.defines.GLYPH=t}},glyphScale:{get:function(){return this.uniforms.uGlyphScale.value},set:function(t){this.uniforms.uGlyphScale.value=t}},glyphScaleFactorX:{get:function(){return this.uniforms.glyphScaleFactorX.value},set:function(t){this.uniforms.glyphScaleFactorX.value=t}},glyphScaleFactorY:{get:function(){return this.uniforms.glyphScaleFactorY.value},set:function(t){this.uniforms.glyphScaleFactorY.value=t}},glyphScaleFactorZ:{get:function(){return this.uniforms.glyphScaleFactorZ.value},set:function(t){this.uniforms.glyphScaleFactorZ.value=t}},vertexGlyphScales:{get:function(){return this.defines.USE_GLYPH_SCALE},set:function(t){this.defines.USE_GLYPH_SCALE=t}},glyphOrientation:{get:function(){return this.uniforms.uGlyphOrientation.value},set:function(t){this.uniforms.uGlyphOrientation.value=t}},vertexGlyphOrientations:{get:function(){return this.defines.USE_GLYPH_ORIENTATION},set:function(t){this.defines.USE_GLYPH_ORIENTATION=t}},opacityFactor:{get:function(){return this.uniforms.opacityFactor.value},set:function(t){this.uniforms.opacityFactor.value=t}}}),this.color=new Dr(16777215),this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this}toJSON(t){const e=super.toJSON(t);return 3===this.depthFunc&&(e.depthFunc=void 0),!0===this.depthTest&&(e.depthTest=void 0),!0===this.depthWrite&&(e.depthWrite=void 0),!1===this.stencilWrite&&(e.stencilWrite=void 0),255===this.stencilWriteMask&&(e.stencilWriteMask=void 0),519===this.stencilFunc&&(e.stencilFunc=void 0),0===this.stencilRef&&(e.stencilRef=void 0),255===this.stencilFuncMask&&(e.stencilFuncMask=void 0),this.stencilFail===Wn&&(e.stencilFail=void 0),this.stencilZFail===Wn&&(e.stencilZFail=void 0),this.stencilZPass===Wn&&(e.stencilZPass=void 0),this.vertexGlyphScales&&(e.vertexGlyphScales=!0),this.vertexGlyphOrientations&&(e.vertexGlyphOrientations=!0),e.uniforms=void 0,e.fragmentShader=void 0,e.vertexShader=void 0,e}equals(t){return t.color.getHex()===this.color.getHex()&&t.opacity===this.opacity&&t.transparent===this.transparent&&t.side===this.side&&t.vertexColors===this.vertexColors}}const Fm={base:{pickState:{value:new Float32Array(1)},startCell:{value:0},uGlyphScale:{value:new Ci(1,1,1)},glyphScaleFactorX:{value:1},glyphScaleFactorY:{value:1},glyphScaleFactorZ:{value:1},uGlyphOrientation:{value:new Pi},opacityFactor:{value:1}},line:{linePattern:{value:65535},resolution:{value:new Ti(1,1)}},mesh:{stipple:{value:0},stippleColor:{value:new Dr(0)},stipplePattern:{value:new Float32Array(64)},textureBlending:{value:1}}},zm="uniform vec3 diffuse;\nuniform float opacity;\nuniform float opacityFactor;\nuniform float linePattern;\nuniform float pickState[ 1 ];\nvarying vec3 vPickColor;\n#ifdef USE_PATTERN\nvarying float vPattern;\n#endif\nvarying float vDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity * opacityFactor );\n\t#include <clipping_planes_fragment>\n\tif ( pickState[ 0 ] > 0.5 ) {\n\t\tgl_FragColor = vec4( vPickColor, 1.0 );\n\t} else {\n\tfloat pattern;\n#ifdef USE_PATTERN\n\tpattern = floor( vPattern );\n#else\n\tpattern = linePattern;\n#endif\n\tfloat shift = pow( 2.0, floor( mod( vDistance, 16.0 ) ) );\n\tif( mod( floor( pattern / shift ), 2.0 ) < 0.5 ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t}\n}",km=zm,Bm=zm,Gm={points:{uniforms:Mc.merge([_d.points,_d.fog,Fm.base]),vertexShader:"attribute float vsize;\nattribute float cellCount;\nattribute vec3 glyphOffset;\nattribute vec3 glyphScale;\nuniform vec3 uGlyphScale;\nuniform float glyphScaleFactorX;\nuniform float glyphScaleFactorY;\nuniform float glyphScaleFactorZ;\nattribute mat3 glyphOrientation;\nuniform mat3 uGlyphOrientation;\nuniform float size;\nuniform float pickState[ 1 ];\nuniform float startCell;\nvarying vec3 vPickColor;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tif ( pickState[ 0 ] > 0.5 ) {\n\t\tfloat cellNum = startCell + cellCount;\n\t\t\n\t\tfloat red = fract( cellNum / (255.0*255.0*255.0) );\n\t\tif ( pickState[ 0 ] > 1.5 ) {\n\t\n\t\t\tfloat red2 = fract( cellNum / (255.0*255.0*255.0*255.0*255.0*255.0) );\n\t\t\tfloat green2 = fract( cellNum / (255.0*255.0*255.0*255.0*255.0) );\n\t\t\tfloat blue2 = fract( cellNum / (255.0*255.0*255.0*255.0) );\n\t\n\t\t\tred2 -= green2 / 255.0;\n\t\t\tgreen2 -= blue2 / 255.0;\n\t\t\tblue2 -= red / 255.0;\n\t\t\tvPickColor = vec3( red2, green2, blue2 );\n\t\t} else {\n\t\t\tfloat green = fract( cellNum / (255.0*255.0) );\n\t\t\tfloat blue = fract( cellNum / 255.0 );\n\t\t\tred -= green / 255.0;\n\t\t\tgreen -= blue / 255.0;\n\t\t\tvPickColor = vec3( red, green, blue );\n\t\t}\n\t}\n\t#include <color_vertex>\n\t#include <begin_vertex>\n#ifdef GLYPH\n#ifdef USE_GLYPH_SCALE\n\ttransformed *= glyphScale;\n#else\n\ttransformed *= uGlyphScale;\n#endif\n\tvec3 glyphScaleFactor = vec3( glyphScaleFactorX, glyphScaleFactorY, glyphScaleFactorZ );\n\ttransformed *= glyphScaleFactor;\n#ifdef USE_GLYPH_ORIENTATION\n\ttransformed = glyphOrientation * transformed;\n#else\n\ttransformed = uGlyphOrientation * transformed;\n#endif\n\ttransformed += glyphOffset;\n#endif\n\t#include <project_vertex>\n#ifdef USE_SIZE\n\tgl_PointSize = vsize;\n#else\n\tgl_PointSize = size;\n#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",fragmentShader:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float opacityFactor;\nuniform float pickState[ 1 ];\nvarying vec3 vPickColor;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity * opacityFactor );\n\t#include <clipping_planes_fragment>\n\tif ( pickState[ 0 ] > 0.5 ) {\n\t\tgl_FragColor = vec4( vPickColor, 1.0 );\n\t} else {\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t}\n}"},line:{uniforms:Mc.merge([_d.common,_d.fog,Fm.base,Fm.line]),vertexShader:"attribute vec3 otherPosition;\nattribute float pattern;\nattribute float cellCount;\nattribute vec3 glyphOffset;\nattribute vec3 glyphScale;\nuniform vec3 uGlyphScale;\nuniform float glyphScaleFactorX;\nuniform float glyphScaleFactorY;\nuniform float glyphScaleFactorZ;\nattribute mat3 glyphOrientation;\nuniform mat3 uGlyphOrientation;\nuniform float pickState[ 1 ];\nuniform float startCell;\nuniform vec2 resolution;\n#ifdef USE_PATTERN\nvarying float vPattern;\n#endif\nvarying float vDistance;\nvarying vec3 vPickColor;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tif ( pickState[ 0 ] > 0.5 ) {\n\t\tfloat cellNum = startCell + cellCount;\n\t\t\n\t\tfloat red = fract( cellNum / (255.0*255.0*255.0) );\n\t\tif ( pickState[ 0 ] > 1.5 ) {\n\t\n\t\t\tfloat red2 = fract( cellNum / (255.0*255.0*255.0*255.0*255.0*255.0) );\n\t\t\tfloat green2 = fract( cellNum / (255.0*255.0*255.0*255.0*255.0) );\n\t\t\tfloat blue2 = fract( cellNum / (255.0*255.0*255.0*255.0) );\n\t\n\t\t\tred2 -= green2 / 255.0;\n\t\t\tgreen2 -= blue2 / 255.0;\n\t\t\tblue2 -= red / 255.0;\n\t\t\tvPickColor = vec3( red2, green2, blue2 );\n\t\t} else {\n\t\t\tfloat green = fract( cellNum / (255.0*255.0) );\n\t\t\tfloat blue = fract( cellNum / 255.0 );\n\t\t\tred -= green / 255.0;\n\t\t\tgreen -= blue / 255.0;\n\t\t\tvPickColor = vec3( red, green, blue );\n\t\t}\n\t}\n\t#include <color_vertex>\n\tvec3 transformed = vec3( position );\n\tvec3 otherTransformed = vec3( otherPosition );\n#ifdef GLYPH\n#ifdef USE_GLYPH_SCALE\n\ttransformed *= glyphScale;\n\totherTransformed *= glyphScale;\n#else\n\ttransformed *= uGlyphScale;\n\totherTransformed *= uGlyphScale;\n#endif\n\tvec3 glyphScaleFactor = vec3( glyphScaleFactorX, glyphScaleFactorY, glyphScaleFactorZ );\n\ttransformed *= glyphScaleFactor;\n\totherTransformed *= glyphScaleFactor;\n#ifdef USE_GLYPH_ORIENTATION\n\ttransformed = glyphOrientation * transformed;\n\totherTransformed = glyphOrientation * otherTransformed;\n#else\n\ttransformed = uGlyphOrientation * transformed;\n\totherTransformed = uGlyphOrientation * otherTransformed;\n#endif\n\ttransformed += glyphOffset;\n\totherTransformed += glyphOffset;\n#endif\n\tvec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\tvec2 ndcPos1 = gl_Position.xy / gl_Position.w;\n\tvec4 other_Position = projectionMatrix * modelViewMatrix * vec4( otherTransformed, 1.0 );\n\tvec2 ndcPos2 = other_Position.xy / other_Position.w;\n\tfloat aspect = resolution.x / resolution.y;\n\tvec2 dir = ndcPos2 - ndcPos1;\n\tdir.x *= aspect;\n\tbool end = false;\n\tif ( dir.y < -EPSILON ) {\n\t\tend = true;\n\t}\n\telse if ( dir.y > EPSILON ) {\n\t\tend = false;\n\t}\n\telse if ( dir.x < -EPSILON ) {\n\t\tend = true;\n\t}\n\tvDistance = end ? 0.0 : length( dir * resolution ) / 2.0;\n#ifdef USE_PATTERN\n\tvPattern = pattern + 0.5;\n#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",fragmentShader:km},thick:{uniforms:Mc.merge([_d.common,_d.fog,Fm.base,Fm.line,{linewidth:{value:1}}]),vertexShader:"attribute vec3 instanceStart;\nattribute vec3 instanceEnd;\nattribute vec3 instanceColorStart;\nattribute vec3 instanceColorEnd;\nattribute float instancePattern;\nattribute float instanceLinewidthStart;\nattribute float instanceLinewidthEnd;\nattribute float cellCount;\nuniform float pickState[ 1 ];\nuniform float startCell;\nuniform float linewidth;\nuniform vec2 resolution;\n#ifdef USE_PATTERN\nvarying float vPattern;\n#endif\nvarying float vDistance;\nvarying vec3 vPickColor;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tif ( pickState[ 0 ] > 0.5 ) {\n\t\tfloat cellNum = startCell + cellCount;\n\t\t\n\t\tfloat red = fract( cellNum / (255.0*255.0*255.0) );\n\t\tif ( pickState[ 0 ] > 1.5 ) {\n\t\n\t\t\tfloat red2 = fract( cellNum / (255.0*255.0*255.0*255.0*255.0*255.0) );\n\t\t\tfloat green2 = fract( cellNum / (255.0*255.0*255.0*255.0*255.0) );\n\t\t\tfloat blue2 = fract( cellNum / (255.0*255.0*255.0*255.0) );\n\t\n\t\t\tred2 -= green2 / 255.0;\n\t\t\tgreen2 -= blue2 / 255.0;\n\t\t\tblue2 -= red / 255.0;\n\t\t\tvPickColor = vec3( red2, green2, blue2 );\n\t\t} else {\n\t\t\tfloat green = fract( cellNum / (255.0*255.0) );\n\t\t\tfloat blue = fract( cellNum / 255.0 );\n\t\t\tred -= green / 255.0;\n\t\t\tgreen -= blue / 255.0;\n\t\t\tvPickColor = vec3( red, green, blue );\n\t\t}\n\t}\n#ifdef USE_COLOR\n\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart.xyz : instanceColorEnd.xyz;\n#endif\n#ifdef USE_PATTERN\n\tvPattern = instancePattern + 0.5;\n#endif\n\tfloat widthFactor, avgWidthFactor;\n#ifdef USE_LINEWIDTH\n\twidthFactor = ( position.y < 0.5 ) ? instanceLinewidthStart : instanceLinewidthEnd;\n\tavgWidthFactor = ( instanceLinewidthStart + instanceLinewidthEnd ) / 2.0;\n#else\n\twidthFactor = avgWidthFactor = linewidth;\n#endif\n\tfloat aspect = resolution.x / resolution.y;\n\tvec4 localStart = vec4( instanceStart, 1.0 );\n\tvec4 localEnd = vec4( instanceEnd, 1.0 );\n\tvec4 start = modelViewMatrix * localStart;\n\tvec4 end = modelViewMatrix * localEnd;\n\tvec4 clipStart = projectionMatrix * start;\n\tvec4 clipEnd = projectionMatrix * end;\n\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n#ifdef LINEWIDTH_SCALE\n\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 );\n\tif ( perspective ) {\n\t\tvec2 xyStart = localStart.xy;\n\t\tvec2 xyEnd = localEnd.xy;\n\t\tvec2 scaleDir = xyEnd - xyStart;\n\t\tscaleDir = normalize( scaleDir );\n\t\tvec2 scaleOffset = vec2( scaleDir.y, -scaleDir.x );\n\t\tscaleOffset.y /= aspect;\n\t\tif ( position.x < 0.5 ) scaleOffset *= -1.0;\n\t\tscaleOffset *= ( widthFactor * 0.5 );\n\t\tvec4 startEnd = ( position.y < 0.5 ) ? localStart : localEnd;\n\t\tvec4 scaleClip = vec4( startEnd );\n\t\tscaleClip.xy += scaleOffset;\n\t\tvec4 scalePosition = projectionMatrix * modelViewMatrix * scaleClip;\n\t\tvec4 scalePosition2 = projectionMatrix * modelViewMatrix * startEnd;\n\t\twidthFactor = avgWidthFactor = length( scalePosition2.xy - scalePosition.xy ) * resolution.y * 2.0;\n\t} else {\n\t\tvec4 localScale = ( position.y < 0.5 ) ? localStart : localEnd;\n\t\tlocalScale.y += widthFactor;\n\t\tvec4 clipScale = projectionMatrix * modelViewMatrix * localScale;\n\t\twidthFactor = avgWidthFactor = length( clipScale.xy - clip.xy ) * resolution.y / 2.0;\n\t}\n#endif\n\tif ( widthFactor < 1.0 ) {\n\t\twidthFactor = 1.0;\n\t}\n\tif ( avgWidthFactor < 1.0 ) {\n\t\tavgWidthFactor = 1.0;\n\t}\n\tvec3 ndcStart = clipStart.xyz / clipStart.w;\n\tvec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\tvec2 dir = ndcEnd.xy - ndcStart.xy;\n\tvec2 dirOrig = dir;\n\tdir.x *= aspect;\n\tdir = normalize( dir );\n\tvec2 offset = vec2( dir.y, -dir.x );\n\tdir.x /= aspect;\n\toffset.x /= aspect;\n\tif ( position.x < 0.5 ) offset *= -1.0;\n\toffset += ( position.y < 0.5 ) ? -dir * 0.3 : dir * 0.3;\n\toffset *= widthFactor;\n\tdir *= widthFactor;\n\toffset /= resolution.y;\n\tdir /= resolution.y;\n\toffset *= clip.w;\n\tclip.xy += offset;\n\tif ( clip.z > -1.0 ) {\n\t\tclip.z -= 5.0e-4;\n\t\tif ( clip.z < -1.0 ) clip.z = -1.0;\n\t}\n\tgl_Position = clip;\n\tvDistance = ( position.y < 0.5 ) ? 0.0 : ( length( dirOrig * resolution ) + 2.0 * length( dir * resolution ) ) / avgWidthFactor / 2.0;\n\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",fragmentShader:Bm},basic:{uniforms:Mc.merge([_d.common,_d.fog,Fm.base,Fm.mesh]),vertexShader:"attribute float cellCount;\nattribute vec3 glyphOffset;\nattribute vec3 glyphScale;\nuniform vec3 uGlyphScale;\nuniform float glyphScaleFactorX;\nuniform float glyphScaleFactorY;\nuniform float glyphScaleFactorZ;\nattribute mat3 glyphOrientation;\nuniform mat3 uGlyphOrientation;\nuniform float pickState[ 1 ];\nuniform float startCell;\nvarying vec3 vPickColor;\n#include <common>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tif ( pickState[ 0 ] > 0.5 ) {\n\t\tfloat cellNum = startCell + cellCount;\n\t\t\n\t\tfloat red = fract( cellNum / (255.0*255.0*255.0) );\n\t\tif ( pickState[ 0 ] > 1.5 ) {\n\t\n\t\t\tfloat red2 = fract( cellNum / (255.0*255.0*255.0*255.0*255.0*255.0) );\n\t\t\tfloat green2 = fract( cellNum / (255.0*255.0*255.0*255.0*255.0) );\n\t\t\tfloat blue2 = fract( cellNum / (255.0*255.0*255.0*255.0) );\n\t\n\t\t\tred2 -= green2 / 255.0;\n\t\t\tgreen2 -= blue2 / 255.0;\n\t\t\tblue2 -= red / 255.0;\n\t\t\tvPickColor = vec3( red2, green2, blue2 );\n\t\t} else {\n\t\t\tfloat green = fract( cellNum / (255.0*255.0) );\n\t\t\tfloat blue = fract( cellNum / 255.0 );\n\t\t\tred -= green / 255.0;\n\t\t\tgreen -= blue / 255.0;\n\t\t\tvPickColor = vec3( red, green, blue );\n\t\t}\n\t}\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n#ifdef GLYPH\n#ifdef USE_GLYPH_SCALE\n\ttransformed *= glyphScale;\n#else\n\ttransformed *= uGlyphScale;\n#endif\n\tvec3 glyphScaleFactor = vec3( glyphScaleFactorX, glyphScaleFactorY, glyphScaleFactorZ );\n\ttransformed *= glyphScaleFactor;\n#ifdef USE_GLYPH_ORIENTATION\n\ttransformed = glyphOrientation * transformed;\n#else\n\ttransformed = uGlyphOrientation * transformed;\n#endif\n\ttransformed += glyphOffset;\n#endif\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",fragmentShader:"uniform float stipple;\nuniform vec3 stippleColor;\nuniform vec4 stipplePattern[ 16 ];\nuniform vec3 diffuse;\nuniform float opacity;\nuniform float opacityFactor;\nuniform float textureBlending;\nuniform float pickState[ 1 ];\nvarying vec3 vPickColor;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity * opacityFactor );\n\t#include <clipping_planes_fragment>\n\tif ( pickState[ 0 ] > 0.5 ) {\n\t\tgl_FragColor = vec4( vPickColor, 1.0 );\n\t} else {\n\tif ( stipple > 0.5 ) {\n\t\tvec2 coord = floor( mod( gl_FragCoord.xy, 32.0 ) );\n\t\tint index = int( floor( coord.x / 64.0 ) + ( coord.y / 2.0 ) );\n\t\tint comp = int( floor( coord.x / 16.0 ) + mod( coord.y , 2.0 ) * 2.0 );\n\t\tfor ( int i = 0; i < 16; i ++ ) {\n\t\t\tif ( i == index ) {\n\t\t\t\tfloat shift = pow( 2.0, floor( mod( gl_FragCoord.x, 16.0 ) ) );\n\t\t\t\tfloat shortPattern;\n\t\t\t\tif ( comp == 0 ) {\n\t\t\t\t\tshortPattern = stipplePattern[ i ].x;\n\t\t\t\t} else if ( comp == 1 ) {\n\t\t\t\t\tshortPattern = stipplePattern[ i ].y;\n\t\t\t\t} else if ( comp == 2 ) {\n\t\t\t\t\tshortPattern = stipplePattern[ i ].z;\n\t\t\t\t} else {\n\t\t\t\t\tshortPattern = stipplePattern[ i ].w;\n\t\t\t\t}\n\t\t\t\tif ( mod( floor( shortPattern / shift ), 2.0 ) > 0.5 ) {\n\t\t\t\t\tdiffuseColor = vec4( stippleColor, opacity );\n\t\t\t\t} else if ( stipple < 1.5 ) {\n\t\t\t\t\tdiscard;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tif ( textureBlending > 1.5 ) {\n\t\tvec3 temp = mix( diffuseColor.rgb, sampledDiffuseColor.rgb, sampledDiffuseColor.a );\n\t\tdiffuseColor = vec4( temp, diffuseColor.a );\n\t} else if ( textureBlending < 0.5 ) {\n\t\tdiffuseColor = sampledDiffuseColor;\n\t} else {\n\t\tdiffuseColor *= sampledDiffuseColor;\n\t}\n#endif\n\t#include <alphatest_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n\t}\n}"},phong:{uniforms:Mc.merge([_d.common,_d.fog,_d.lights,Fm.base,Fm.mesh,{ambientIntensity:{value:.31},diffuseIntensity:{value:.7},emissive:{value:new Dr(0)},specular:{value:new Dr(2039583)},shininess:{value:63.8386159788056}}]),vertexShader:"attribute float cellCount;\nattribute vec3 glyphOffset;\nattribute vec3 glyphScale;\nuniform vec3 uGlyphScale;\nuniform float glyphScaleFactorX;\nuniform float glyphScaleFactorY;\nuniform float glyphScaleFactorZ;\nattribute mat3 glyphOrientation;\nuniform mat3 uGlyphOrientation;\nuniform float pickState[ 1 ];\nuniform float startCell;\nvarying vec3 vPickColor;\n#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tif ( pickState[ 0 ] > 0.5 ) {\n\t\tfloat cellNum = startCell + cellCount;\n\t\t\n\t\tfloat red = fract( cellNum / (255.0*255.0*255.0) );\n\t\tif ( pickState[ 0 ] > 1.5 ) {\n\t\n\t\t\tfloat red2 = fract( cellNum / (255.0*255.0*255.0*255.0*255.0*255.0) );\n\t\t\tfloat green2 = fract( cellNum / (255.0*255.0*255.0*255.0*255.0) );\n\t\t\tfloat blue2 = fract( cellNum / (255.0*255.0*255.0*255.0) );\n\t\n\t\t\tred2 -= green2 / 255.0;\n\t\t\tgreen2 -= blue2 / 255.0;\n\t\t\tblue2 -= red / 255.0;\n\t\t\tvPickColor = vec3( red2, green2, blue2 );\n\t\t} else {\n\t\t\tfloat green = fract( cellNum / (255.0*255.0) );\n\t\t\tfloat blue = fract( cellNum / 255.0 );\n\t\t\tred -= green / 255.0;\n\t\t\tgreen -= blue / 255.0;\n\t\t\tvPickColor = vec3( red, green, blue );\n\t\t}\n\t}\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n#ifdef GLYPH\n#ifdef USE_GLYPH_SCALE\n\ttransformed *= glyphScale;\n#else\n\ttransformed *= uGlyphScale;\n#endif\n\tvec3 glyphScaleFactor = vec3( glyphScaleFactorX, glyphScaleFactorY, glyphScaleFactorZ );\n\ttransformed *= glyphScaleFactor;\n#ifdef USE_GLYPH_ORIENTATION\n\ttransformed = glyphOrientation * transformed;\n#else\n\ttransformed = uGlyphOrientation * transformed;\n#endif\n\ttransformed += glyphOffset;\n#endif\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",fragmentShader:"uniform float ambientIntensity;\nuniform float diffuseIntensity;\nuniform float stipple;\nuniform vec3 stippleColor;\nuniform vec4 stipplePattern[ 16 ];\nuniform float textureBlending;\nuniform float pickState[ 1 ];\nvarying vec3 vPickColor;\n#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\nuniform float opacityFactor;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity * opacityFactor );\n\t#include <clipping_planes_fragment>\n\tif ( pickState[ 0 ] > 0.5 ) {\n\t\tgl_FragColor = vec4( vPickColor, 1.0 );\n\t} else {\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\tif ( stipple > 0.5 ) {\n\t\tvec2 coord = floor( mod( gl_FragCoord.xy, 32.0 ) );\n\t\tint index = int( floor( coord.x / 64.0 ) + ( coord.y / 2.0 ) );\n\t\tint comp = int( floor( coord.x / 16.0 ) + mod( coord.y , 2.0 ) * 2.0 );\n\t\tfor ( int i = 0; i < 16; i ++ ) {\n\t\t\tif ( i == index ) {\n\t\t\t\tfloat shift = pow( 2.0, floor( mod( gl_FragCoord.x, 16.0 ) ) );\n\t\t\t\tfloat shortPattern;\n\t\t\t\tif ( comp == 0 ) {\n\t\t\t\t\tshortPattern = stipplePattern[ i ].x;\n\t\t\t\t} else if ( comp == 1 ) {\n\t\t\t\t\tshortPattern = stipplePattern[ i ].y;\n\t\t\t\t} else if ( comp == 2 ) {\n\t\t\t\t\tshortPattern = stipplePattern[ i ].z;\n\t\t\t\t} else {\n\t\t\t\t\tshortPattern = stipplePattern[ i ].w;\n\t\t\t\t}\n\t\t\t\tif ( mod( floor( shortPattern / shift ), 2.0 ) > 0.5 ) {\n\t\t\t\t\tdiffuseColor = vec4( stippleColor, opacity );\n\t\t\t\t} else if ( stipple < 1.5 ) {\n\t\t\t\t\tdiscard;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tif ( textureBlending > 1.5 ) {\n\t\tvec3 temp = mix( diffuseColor.rgb, sampledDiffuseColor.rgb, sampledDiffuseColor.a );\n\t\tdiffuseColor = vec4( temp, diffuseColor.a );\n\t} else if ( textureBlending < 0.5 ) {\n\t\tdiffuseColor = sampledDiffuseColor;\n\t} else {\n\t\tdiffuseColor *= sampledDiffuseColor;\n\t}\n#endif\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\tvec3 outgoingLight = ( reflectedLight.directDiffuse * diffuseIntensity ) + ( reflectedLight.indirectDiffuse * ambientIntensity ) + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n\t}\n}"}};class Vm extends Um{constructor(t){super({uniforms:Mc.clone(Gm.points.uniforms),vertexShader:Gm.points.vertexShader,fragmentShader:Gm.points.fragmentShader}),this.isPointsMaterial=!0,Object.defineProperties(this,{vertexSizes:{get:function(){return this.defines.USE_SIZE},set:function(t){this.defines.USE_SIZE=t}}}),this.map=null,this.size=1,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.size=t.size,this}toJSON(t){const e=super.toJSON(t);return e.type="PointsMaterial",this.vertexSizes&&(e.vertexSizes=!0),e}equals(t){return!1!==super.equals(t)&&!!t.isPointsMaterial}}class Hm extends Um{constructor(t){super({uniforms:Mc.clone(Gm.basic.uniforms),vertexShader:Gm.basic.vertexShader,fragmentShader:Gm.basic.fragmentShader}),this.isMeshBasicMaterial=!0,Object.defineProperties(this,{stipple:{get:function(){return this.uniforms.stipple.value},set:function(t){this.uniforms.stipple.value=t}},stippleColor:{get:function(){return this.uniforms.stippleColor.value},set:function(t){this.uniforms.stippleColor.value=t}},stipplePattern:{get:function(){return this.uniforms.stipplePattern.value},set:function(t){this.uniforms.stipplePattern.value=t}},textureBlending:{get:function(){return this.uniforms.textureBlending.value},set:function(t){this.uniforms.textureBlending.value=t}}}),this.map=null,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this}toJSON(t){const e=super.toJSON(t);return e.type="MeshBasicMaterial",0!==this.stipple&&(e.stipple=this.stipple),0!==this.stippleColor.getHex()&&(e.stippleColor=this.stippleColor.getHex()),JSON.stringify(this.stipplePattern)!==JSON.stringify(new Float32Array(64))&&(e.stipplePattern=Array.prototype.slice.call(this.stipplePattern)),1!==this.textureBlending&&(e.textureBlending=this.textureBlending),e}equals(t){return!1!==super.equals(t)&&!(!t.isMeshBasicMaterial&&!t.isMeshPhongMaterial)}}class Wm extends Hm{constructor(t){super({uniforms:Mc.clone(Gm.phong.uniforms),vertexShader:Gm.phong.vertexShader,fragmentShader:Gm.phong.fragmentShader}),this.isMeshPhongMaterial=!0,this.isMeshBasicMaterial=!1,Object.defineProperties(this,{ambientIntensity:{get:function(){return this.uniforms.ambientIntensity.value},set:function(t){this.uniforms.ambientIntensity.value=t}},diffuseIntensity:{get:function(){return this.uniforms.diffuseIntensity.value},set:function(t){this.uniforms.diffuseIntensity.value=t}}}),this.specular=new Dr(4737096),this.shininess=63.8386159788056,this.emissive=new Dr(0),this.emissiveIntensity=1,this.lights=!0,this.setValues(t)}copy(t){return super.copy(t),this.specular.copy(t.specular),this.shininess=t.shininess,this.flatShading=t.flatShading,this}toJSON(t){const e=super.toJSON(t);return e.type="MeshPhongMaterial",.31!==this.ambientIntensity&&(e.ambientIntensity=this.ambientIntensity),.7!==this.diffuseIntensity&&(e.diffuseIntensity=this.diffuseIntensity),4737096===this.specular.getHex()&&(e.specular=void 0),63.8386159788056===this.shininess&&(e.shininess=void 0),e}equals(t){return!1!==super.equals(t)&&!!t.isMeshPhongMaterial&&t.ambientIntensity===this.ambientIntensity&&t.diffuseIntensity===this.diffuseIntensity&&t.specular.getHex()===this.specular.getHex()&&t.shininess===this.shininess}}class jm extends Um{constructor(t){super({uniforms:Mc.clone(Gm.line.uniforms),vertexShader:Gm.line.vertexShader,fragmentShader:Gm.line.fragmentShader}),this.isLineBasicMaterial=!0,Object.defineProperties(this,{pattern:{get:function(){return this.uniforms.linePattern.value},set:function(t){this.uniforms.linePattern.value=t}},vertexPatterns:{get:function(){return this.defines.USE_PATTERN},set:function(t){this.defines.USE_PATTERN=t}},resolution:{get:function(){return this.uniforms.resolution.value},set:function(t){this.uniforms.resolution.value=t}}}),this.setValues(t)}toJSON(t){const e=super.toJSON(t);return e.type="LineMaterial",65535!==this.pattern&&(e.pattern=this.pattern),this.vertexPatterns&&(e.vertexPatterns=!0),e}equals(t){return!1!==super.equals(t)&&!!t.isLineBasicMaterial}}class Xm extends jm{constructor(t){super({uniforms:Mc.clone(Gm.thick.uniforms),vertexShader:Gm.thick.vertexShader,fragmentShader:Gm.thick.fragmentShader}),this.isThickLineMaterial=!0,Object.defineProperties(this,{linewidth:{get:function(){return this.uniforms.linewidth.value},set:function(t){this.uniforms.linewidth.value=t}},vertexLinewidths:{get:function(){return this.defines.USE_LINEWIDTH},set:function(t){this.defines.USE_LINEWIDTH=t}},linewidthScale:{get:function(){return this.defines.LINEWIDTH_SCALE},set:function(t){this.defines.LINEWIDTH_SCALE=t}}}),this.setValues(t)}toJSON(t){const e=super.toJSON(t);return e.type="ThickLineMaterial",this.vertexLinewidths&&(e.vertexLinewidths=!0),this.linewidthScale&&(e.linewidthScale=!0),e}equals(t){return!1!==super.equals(t)&&!!t.isThickLineMaterial&&t.vertexLinewidths===this.vertexLinewidths}}Uh.createMaterialFromType=function(t){return new{PointsMaterial:Vm,MeshPhongMaterial:Wm,MeshBasicMaterial:Hm,LineMaterial:jm,ThickLineMaterial:Xm}[t]};class qm extends Uh{parse(t){const e=super.parse(t);if(void 0!==t.glyphs&&(e.glyphs=t.glyphs),void 0!==t.vertexGlyphScales&&(e.vertexGlyphScales=t.vertexGlyphScales),void 0!==t.glyphScale&&e.glyphScale.fromArray(t.glyphScale),void 0!==t.vertexGlyphOrientations&&(e.vertexGlyphOrientations=t.vertexGlyphOrientations),void 0!==t.glyphOrientation&&e.glyphOrientation.fromArray(t.glyphOrientation),void 0!==t.vertexSizes&&(e.vertexSizes=t.vertexSizes),void 0!==t.pattern&&(e.pattern=t.pattern),void 0!==t.vertexPatterns&&(e.vertexPatterns=t.vertexPatterns),void 0!==t.vertexLinewidths&&(e.vertexLinewidths=t.vertexLinewidths),void 0!==t.linewidthScale&&(e.linewidthScale=t.linewidthScale),void 0!==t.stipple&&(e.stipple=t.stipple),void 0!==t.stippleColor&&void 0!==e.stippleColor&&e.stippleColor.setHex(t.stippleColor),void 0!==t.stipplePattern&&(e.stipplePattern=t.stipplePattern),void 0!==t.textureBlending&&(e.textureBlending=t.textureBlending),void 0!==t.ambientIntensity&&(e.ambientIntensity=t.ambientIntensity),void 0!==t.diffuseIntensity&&(e.diffuseIntensity=t.diffuseIntensity),void 0!==t.clippingPlanes){e.clippingPlanes=[];for(let n=0,i=t.clippingPlanes.length;n<i;n++){const i=t.clippingPlanes[n],r=new Js(new Ci(i.normal[0],i.normal[1],i.normal[2]),i.constant);e.clippingPlanes.push(r)}}return e.origTransparent=e.transparent,e}}class Ym{constructor(t){this.bufferGeometryLoader=t}parse(t){const e=this.bufferGeometryLoader.parse(t),n=e.attributes.position;if(void 0!==n){const t=new ya(n.array.length,3);for(let e=0,i=n.array.length/6;e<i;e++)t.array[6*e+0]=n.array[6*e+3],t.array[6*e+1]=n.array[6*e+4],t.array[6*e+2]=n.array[6*e+5],t.array[6*e+3]=n.array[6*e+0],t.array[6*e+4]=n.array[6*e+1],t.array[6*e+5]=n.array[6*e+2];e.setAttribute("otherPosition",t)}return e}}const Zm=new Kr,$m=new Ci;class Jm extends zh{constructor(){super(),this.isThickLineSegmentsBufferGeometry=!0,this.type="ThickLineSegmentsBufferGeometry",this.setAttribute("position",new ya([0,0,0,1,1,0,0,1,0,0,0,0,1,0,0,1,1,0],3))}applyMatrix4(t){const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;return void 0!==e&&(e.applyMatrix4(t),n.applyMatrix4(t),e.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}setPositions(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const n=new ld(e,6,1);return this.setAttribute("instanceStart",new Na(n,3,0)),this.setAttribute("instanceEnd",new Na(n,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const n=new ld(e,6,1);return this.setAttribute("instanceColorStart",new Na(n,3,0)),this.setAttribute("instanceColorEnd",new Na(n,3,3)),this}setPatterns(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const n=new ld(e,2,1);return this.setAttribute("instancePattern",new Na(n,1,0)),this}setLinewidths(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const n=new ld(e,2,1);return this.setAttribute("instanceLinewidthStart",new Na(n,1,0)),this.setAttribute("instanceLinewidthEnd",new Na(n,1,1)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Kr);const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;void 0!==t&&void 0!==e&&(this.boundingBox.setFromBufferAttribute(t),Zm.setFromBufferAttribute(e),this.boundingBox.union(Zm))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new Ma),null===this.boundingBox&&this.computeBoundingBox();const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;if(void 0!==t&&void 0!==e){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let i=0;for(let r=0,a=t.count;r<a;r++)$m.fromBufferAttribute(t,r),i=Math.max(i,n.distanceToSquared($m)),$m.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared($m));this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error("AVS.Three.ThickLineSegmentsBufferGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}applyMatrix(t){return console.warn("AVS.Three.ThickLineSegmentsBufferGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(t)}}class Km{parse(t){const e=new Jm,n=t.data.attributes;return void 0!==n.position&&e.setPositions(n.position.array),void 0!==n.color&&e.setColors(n.color.array),void 0!==n.pattern&&e.setPatterns(n.pattern.array),void 0!==n.linewidth&&e.setLinewidths(n.linewidth.array),e}}const Qm=new Ki,tf=new cs,ef=new Ma;class nf extends Rm{constructor(t,e){super(t,e),this.isThickLineSegments=!0,this.type="ThickLineSegments"}raycast(t,e){const n=this.geometry,i=this.matrixWorld,r=t.params.Line.threshold,a=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),ef.copy(n.boundingSphere),ef.applyMatrix4(i),ef.radius+=r,!1===t.ray.intersectsSphere(ef))return;Qm.copy(i).invert(),tf.copy(t.ray).applyMatrix4(Qm);const s=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=s*s,l=new Ci,c=new Ci,h=new Ci,d=new Ci,u=n.attributes.instanceStart;for(let n=Math.max(0,a.start),i=Math.min(u.count,a.start+a.count)-1;n<i;n+=2){if(l.fromBufferAttribute(u,n),c.fromBufferAttribute(u,n+1),tf.distanceSqToSegment(l,c,d,h)>o)continue;d.applyMatrix4(this.matrixWorld);const i=t.ray.origin.distanceTo(d);i<t.near||i>t.far||e.push({distance:i,point:h.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}}class rf{constructor(){this.uuid=Ei.generateUUID(),this.transparent=!1,this.opacity=1,this.opacityFactor=1}dispose(){}}class af extends Er{constructor(){super(),this.isBillboardText=!0,this.type="BillboardText",this.text="Label",this.fontSize=16,this.fontStyle="normal",this.fontWeight="normal",this.textDecoration="",this.fontFamily="sans-serif",this.color=new Dr(0),this.textAlign="",this.transform="",this.transformOrigin="",this.material=new rf,this.div=document.createElement("div"),this.div.style.position="absolute",this.div.style.whiteSpace="nowrap",this.div.style.userSelect="none",this.scene=null,this.scaleFactor=1,this.left=0,this.top=0,this.updateStyle()}addToScene(t){null===this.scene&&(this.scene=t,t.labels.push(this),t.landscapeDiv.appendChild(this.div),this.updateStyle())}updateStyle(){this.div.innerHTML=this.text,this.div.style.fontStyle=this.fontStyle,this.div.style.fontWeight=this.fontWeight,this.div.style.textDecoration=this.textDecoration,this.div.style.color="#"+this.color.getHexString(),this.div.style.transform=this.transform,this.div.style.transformOrigin=this.transformOrigin,this.material.transparent?this.div.style.opacity=this.material.opacity*this.material.opacityFactor:this.div.style.opacity=1,this.div.style.visibility=this.visible?"visible":"hidden",void 0!==this.div.firstChild.style&&(this.div.firstChild.style.float="left"),/\s/.test(this.fontFamily)?this.div.style.fontFamily="'"+this.fontFamily+"'":this.div.style.fontFamily=this.fontFamily,this.textScale||(this.div.style.fontSize=this.fontSize+"px")}updatePosition(){this.updateMatrixWorld();const t=(new Ci).setFromMatrixPosition(this.matrixWorld);if(t.project(this.scene.camera),this.left=(t.x+1)/2*this.scene.landscapeWidth,this.top=(1-(t.y+1)/2)*this.scene.landscapeHeight,this.moveText(),this.textScale){const t=new Ci(0,1,0).multiplyScalar(this.fontSize).add(this.position);t.applyMatrix4(this.parent.matrixWorld),t.project(this.scene.camera);const e=(1-(t.y+1)/2)*this.scene.landscapeHeight,n=Math.abs(e-this.top);this.div.style.fontSize=n+"px"}this.material.transparent?this.div.style.opacity=this.material.opacity*this.material.opacityFactor:this.div.style.opacity=1,this.div.style.visibility=this.visible?"visible":"hidden"}moveText(){this.div.style.left=Math.floor((this.panOffsetX??0)+this.left)+"px",this.div.style.top=Math.floor((this.panOffsetY??0)+this.top)+"px"}}class sf extends Gh{parse(t,e,n,i,r,a,s){const o=this.parseGeometries(t.geometries);a=Object.assign(a??{},o);const l=this.parseImages(t.images,(function(){void 0!==e&&e(d)}));n=Object.assign(n??{},l);const c=this.parseTextures(t.textures,n);i=Object.assign(i??{},c);const h=this.parseMaterials(t.materials,i);r=Object.assign(r??{},h);const d=this.parseObject(t.object,a,r,i);if(void 0!==s&&(s.add(d),d.saveVisible=d.visible,d.visible=!1),void 0!==e){let t=!1;for(const e in l)if(l[e].data instanceof HTMLImageElement){t=!0;break}!1===t&&e(d)}return d}parseGeometries(t,e){const n={};if(void 0!==t){const e=new kh,i=new Ym(e),r=new Km;for(let a=0,s=t.length;a<s;a++){let s;const o=t[a];switch(o.type){case"BufferGeometry":case"InstancedBufferGeometry":s=e.parse(o);break;case"LinePatternBufferGeometry":s=i.parse(o);break;case"ThickLineBufferGeometry":s=r.parse(o);break;case"SphereGeometry":s=dc.fromJSON(o);break;default:console.warn(`AVS.Three.ObjectLoader: Unsupported geometry type "${o.type}"`)}s.uuid=o.uuid,void 0!==o.name&&(s.name=o.name),!0===s.isBufferGeometry&&void 0!==o.userData&&(s.userData=o.userData),n[o.uuid]=s}}return n}parseMaterials(t,e){const n={};if(void 0!==t){const i=new qm;i.setTextures(e);for(let e=0,r=t.length;e<r;e++){const r=t[e];n[r.uuid]=i.parse(r)}}return n}parseObject(t,e,n,i){let r,a,s;function o(t){return void 0===e[t]&&console.warn("AVS.Three.ObjectLoader: Undefined geometry",t),e[t]}function l(t){if(void 0!==t){if(Array.isArray(t)){const e=[];for(let i=0,r=t.length;i<r;i++){const r=t[i];void 0===n[r]&&console.warn("AVS.Three.ObjectLoader: Undefined material",r),e.push(n[r])}return e}return void 0===n[t]&&console.warn("AVS.Three.ObjectLoader: Undefined material",t),n[t]}}function c(t){return void 0===i[t]&&console.warn("AVS.Three.ObjectLoader: Undefined texture",t),i[t]}switch(t.type){case"Scene":r=new Om,void 0!==t.background&&(Number.isInteger(t.background)?r.background=new Dr(t.background):r.background=c(t.background)),void 0!==t.environment&&(r.environment=c(t.environment)),void 0!==t.fog&&("Fog"===t.fog.type?r.fog=new Ur(t.fog.color,t.fog.near,t.fog.far):"FogExp2"===t.fog.type&&(r.fog=new Or(t.fog.color,t.fog.density))),void 0!==t.backgroundBlurriness&&(r.backgroundBlurriness=t.backgroundBlurriness);break;case"PerspectiveCamera":r=new Nm(t.fov,t.aspect,t.near,t.far),void 0!==t.focus&&(r.focus=t.focus),void 0!==t.zoom&&(r.zoom=t.zoom),void 0!==t.filmGauge&&(r.filmGauge=t.filmGauge),void 0!==t.filmOffset&&(r.filmOffset=t.filmOffset),void 0!==t.view&&(r.view=Object.assign({},t.view));break;case"OrthographicCamera":r=new Dm(t.left,t.right,t.top,t.bottom,t.near,t.far),void 0!==t.zoom&&(r.zoom=t.zoom),void 0!==t.view&&(r.view=Object.assign({},t.view)),void 0!==t.keepAspectRatio&&(r.keepAspectRatio=t.keepAspectRatio);break;case"AmbientLight":r=new Lm(t.color,t.intensity);break;case"DirectionalLight":r=new Pm(t.color,t.intensity);break;case"PointLight":r=new Im(t.color,t.intensity,t.distance,t.decay);break;case"Mesh":case"Quads":a=o(t.geometry),s=l(t.material),r=new Rm(a,s),r.cellType="Quads"===t.type?fm:mm,r.frustumCulled=void 0===s.glyphs;break;case"LineSegments":r=new Sm(o(t.geometry),l(t.material)),r.cellType=pm,r.frustumCulled=void 0===r.material.glyphs;break;case"ThickLineSegments":r=new nf(o(t.geometry),l(t.material)),r.cellType=fm,r.frustumCulled=void 0===r.material.glyphs;break;case"PointCloud":case"Points":r=new xm(o(t.geometry),l(t.material)),r.cellType=um,r.frustumCulled=void 0===r.material.glyphs;break;case"Group":r=new vm;break;case"BillboardText":r=new af,void 0!==t.text&&(r.text=t.text),void 0!==t.fontSize&&(r.fontSize=t.fontSize),void 0!==t.fontStyle&&(r.fontStyle=t.fontStyle),void 0!==t.fontWeight&&(r.fontWeight=t.fontWeight),void 0!==t.fontFamily&&(r.fontFamily=t.fontFamily),void 0!==t.textDecoration&&(r.textDecoration=t.textDecoration),void 0!==t.color&&r.color.setHex(t.color),void 0!==t.transform&&(r.transform=t.transform),void 0!==t.transformOrigin&&(r.transformOrigin=t.transformOrigin),void 0!==t.textScale&&(r.textScale=t.textScale),void 0!==t.width&&(r.width=t.width),void 0!==t.height&&(r.height=t.height);break;default:r=new Er}if(r.uuid=t.uuid,void 0!==t.name&&(r.name=t.name),void 0!==t.matrix?(r.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(r.matrixAutoUpdate=t.matrixAutoUpdate),r.matrixAutoUpdate&&r.matrix.decompose(r.position,r.quaternion,r.scale)):(void 0!==t.position&&r.position.fromArray(t.position),void 0!==t.rotation&&r.rotation.fromArray(t.rotation),void 0!==t.quaternion&&r.quaternion.fromArray(t.quaternion),void 0!==t.scale&&r.scale.fromArray(t.scale)),void 0!==t.castShadow&&(r.castShadow=t.castShadow),void 0!==t.receiveShadow&&(r.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.bias&&(r.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(r.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(r.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&r.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(r.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(r.visible=t.visible),void 0!==t.frustumCulled&&(r.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(r.renderOrder=t.renderOrder),void 0!==t.userData&&(r.userData=t.userData),void 0!==t.layers&&(r.layers.mask=t.layers),r.internalData={},void 0!==t.internalData&&(r.internalData=t.internalData),void 0!==t.children){const a=t.children;for(let t=0;t<a.length;t++)r.add(this.parseObject(a[t],e,n,i))}return r}}class of{constructor(t){var e=t;this.getID=function(){return e},this.container=document.createElement("div"),this.container.style.position="relative",this.container.style.outline="none",this.container.style.overflow="hidden",this.container.style.width="100%",this.container.style.height="100%",this.container.id="avsthreeDiv",this.domElement=this.container,this.scenes=[],this.currentScene=null,this.renderNextFrame=!1,this.objectLoader=new sf,this.startCell=1,this.raycaster=new hd,this.raycaster.params.Line.threshold=.001,this.validPick=!1,this.pickType=hm,this.pickDepth=cm,this.pickRayX=0,this.pickRayY=0,this.pickRectangleLeft=0,this.pickRectangleTop=0,this.pickRectangleRight=1,this.pickRectangleBottom=1,this.selectionListeners=[],this.intersects=[],this.highlightList=[],this.updateHighlight=!1,this.highlightColor=new Dr(16711680),this.updatePicking=!1,this.pickState=new Float32Array(1),this.resolution=new Ti,this.loading=!1,this.firstChunk=!1,this.animator=null,this.animatedGlyphs=[],this.enableAnimatedGlyphs=!1,this.visibleAnimatedGlyphs=!1,this.displayCanvas=!1,this.animate()}setWebGLRenderer(t){this.renderer=t,this.renderer.autoClear=!1,this.renderer.localClippingEnabled=!0,this.renderer.sortObjects=!1}updateSize(){var t=this.container.clientWidth,e=this.container.clientHeight;if(t!==this.width||e!==this.height){this.width=t,this.height=e,this.updateHighlight=!0,this.updatePicking=!0,this.validPick=!1;for(var n=0;n<this.scenes.length;n++)this.updateSceneSize(this.scenes[n])}}updateSceneSize(t){if(t.windowX=Math.floor(t.windowFractionX*this.width),t.windowWidth=Math.floor(t.windowFractionWidth*this.width),t.windowY=Math.floor(t.windowFractionY*this.height),t.windowHeight=Math.floor(t.windowFractionHeight*this.height),t.windowTop=this.height-t.windowHeight-t.windowY,t.windowDiv.style.left=t.windowX+"px",t.windowDiv.style.width=t.windowWidth+"px",t.windowDiv.style.top=t.windowTop+"px",t.windowDiv.style.height=t.windowHeight+"px",t.panScene||(t.landscapeWidth=t.windowWidth,t.landscapeHeight=t.windowHeight),t.landscapeDiv.style.width=t.landscapeWidth+"px",t.landscapeDiv.style.height=t.landscapeHeight+"px",t.landscapeDiv.style.left=(t.baseLeft??0)+(t.panOffsetX??0)+"px",t.landscapeDiv.style.top=(t.baseTop??0)+(t.panOffsetY??0)+"px",t.landscapeGrid&&this.sizeLandscapeGrid(t),t.rectCanvas&&(t.rectCanvas.width=t.windowWidth,t.rectCanvas.height=t.windowHeight),t.camera.isOrthographicCamera&&t.camera.keepAspectRatio){var e=t.landscapeWidth/t.internalData.width,n=t.landscapeHeight/t.internalData.height,i=t.internalData.width/t.internalData.height;t.landscapeWidth,t.landscapeHeight,i<1||(t.camera.left=t.camera.origLeft*e/n,t.camera.right=t.camera.origRight*e/n),t.camera.updateProjectionMatrix()}}sizeLandscapeGrid(t){for(var e=[],n=[],i=Math.floor(t.landscapeHeight/t.landscapeRows),r=0,a=0;a<t.landscapeRows;a++){var s=a==t.landscapeRows-1?t.landscapeHeight-r:i;e.push(r),n.push(s),r+=s}for(var o=[],l=[],c=Math.floor(t.landscapeWidth/t.landscapeColumns),h=0,d=0;d<t.landscapeColumns;d++){var u=d==t.landscapeColumns-1?t.landscapeWidth-h:c;o.push(h),l.push(u),h+=u}for(a=0;a<t.landscapeRows;a++)for(d=0;d<t.landscapeColumns;d++){var p=t.landscapeGrid[a][d];p.left=o[d],p.top=e[a];var m=!1;p.width===l[d]&&p.height===n[a]||(p.width=l[d],p.height=n[a],m=!0),this.isGridItemVisible(p)?p.initialized&&!m||(p.initialized||this.initializeGridItem(p),this.sizeGridItem(p)):p.initialized&&this.disposeGridItem(p)}}sizeGridItem(t){t.initialized&&(t.canvas.style.left=t.left+"px",t.canvas.style.top=t.top+"px",t.canvas.style.width=t.width+"px",t.canvas.style.height=t.height+"px",t.highlightCanvas.style.left=t.left+"px",t.highlightCanvas.style.top=t.top+"px",t.highlightCanvas.style.width=t.width+"px",t.highlightCanvas.style.height=t.height+"px",t.pixelX=Math.floor(t.left*window.devicePixelRatio),t.pixelY=Math.floor(t.top*window.devicePixelRatio),t.pixelWidth=Math.floor(t.width*window.devicePixelRatio),t.pixelHeight=Math.floor(t.height*window.devicePixelRatio),t.canvas.width=t.pixelWidth,t.canvas.height=t.pixelHeight,t.highlightCanvas.width=t.pixelWidth,t.highlightCanvas.height=t.pixelHeight,t.renderTarget.setSize(t.pixelWidth,t.pixelHeight),t.pixelBuffer=new Uint8Array(4*t.pixelWidth*t.pixelHeight),t.pickingRenderTarget.setSize(t.pixelWidth,t.pixelHeight),t.pickingPixelBuffer=new Uint8Array(4*t.pixelWidth*t.pixelHeight))}clearGeometry(){for(;this.container.lastChild;)this.container.removeChild(this.container.lastChild);this.panInteractor&&this.panInteractor.clear();for(let t=0;t<this.scenes.length;t++)this.scenes[t].traverse((function(t){t.material&&(t.material.map&&t.material.map.dispose(),t.material.dispose()),t.geometry&&t.geometry.dispose()}));this.scenes=[],this.currentScene=null,this.startCell=1,null!==this.animator&&this.animator.clear(),this.animatedGlyphs=[]}setPickDepth(t){void 0===t&&(t=cm),this.pickDepth!==t&&(this.pickDepth=t)}setPickRay(t,e){if(t<0||e<0||t>this.width||e>this.height)return this.validPick=!1,void console.error("AVS.Three.Viewer: pick ray coordinates out of range.");this.pickType=hm,this.pickRayX=t,this.pickRayY=e,this.validPick=!0}setPickRectangle(t,e,n,i){if(t<0||e<0||n>this.width||i>this.height)return this.validPick=!1,void console.error("AVS.Three.Viewer: pick rectangle coordinates out of range.");this.pickType=dm,this.pickRectangleLeft=t,this.pickRectangleTop=e,this.pickRectangleRight=n,this.pickRectangleBottom=i,this.validPick=!0}interactorUpdate(t){t===this.transformInteractor&&void 0!==this.zoomRectangleInteractor&&t.object===this.zoomRectangleInteractor.object&&(this.zoomRectangleInteractor.scale.copy(t.object.scale),this.zoomRectangleInteractor.position.copy(t.object.position)),t===this.zoomRectangleInteractor&&void 0!==this.transformInteractor&&t.object===this.transformInteractor.object&&(this.transformInteractor.scale.copy(t.object.scale),this.transformInteractor.position.copy(t.object.position)),this.updatePicking=!0,this.renderNextFrame=!0,void 0!==this.stats&&this.stats.update()}panInteractorUpdate(){for(var t=0;t<this.scenes.length;t++){var e=this.scenes[t];if(e.landscapeGrid)for(var n=0;n<e.landscapeRows;n++)for(var i=0;i<e.landscapeColumns;i++){var r=e.landscapeGrid[n][i];this.isGridItemVisible(r)?r.initialized||(this.initializeGridItem(r),this.sizeGridItem(r),this.renderGridItem(r,!0),this.updatePicking=!0):r.initialized&&this.disposeGridItem(r)}}}addInteractor(t){if(t.isTransformInteractor)this.transformInteractor=t,t.addEventListener("change",this.interactorUpdate.bind(this,t));else if(t.isZoomRectangleInteractor)this.zoomRectangleInteractor=t,t.addEventListener("change",this.interactorUpdate.bind(this,t));else{if(!t.isPanInteractor)return;this.panInteractor=t,t.addEventListener("change",this.panInteractorUpdate.bind(this))}t.domElement=this.domElement}removeInteractor(t){t.isTransformInteractor?(t.removeEventListener("change",this.interactorUpdate.bind(this,this.transformInteractor)),this.transformInteractor=void 0):t.isZoomRectangleInteractor?(t.removeEventListener("change",this.interactorUpdate.bind(this,this.zoomRectangleInteractor)),this.zoomRectangleInteractor=void 0):t.isPanInteractor&&(this.panInteractor=void 0)}setAnimator(t){this.animator=t,t.addEventListener("change",this.interactorUpdate.bind(this))}addStats(){void 0===this.stats&&(this.stats=new Stats,this.container.appendChild(this.stats.dom))}addGeometry(t){t.updateMatrixWorld(),void 0!==t.internalData.background?this.container.style.backgroundColor="#"+t.internalData.background.toString(16).padStart(6,"0"):this.container.style.backgroundColor="transparent",this.processGeometry(t);for(var e=0;e<this.scenes.length;e++){var n=this.scenes[e];n.parent&&n.parent.remove(n)}}processGeometry(t){if(t.isScene){for(var e=0;e<t.children.length;e++){var n=t.children[e];if(n.isPerspectiveCamera||n.isOrthographicCamera){t.camera=n,t.remove(n);break}}null==t.camera&&null!==t.background&&(t.camera=new Rh),void 0!==t.camera&&this.addScene(t)}this.attachInteractors(t),this.addLabels(t),this.createPickingInfo(t),this.addMaterialReferences(t),t.internalData.animatedGlyphs&&this.animatedGlyphs.push(t);var i=t.children,r=i.length;for(e=0;e<r;)this.processGeometry(i[e]),i.length<r?r=i.length:e++}addScene(t,e=!1){this.scenes.push(t),this.currentScene=t,e||(this.currentRealScene=t),t.labels=[],this.calculateSceneFractions(t);var n=document.createElement("div");n.style.position="absolute",n.style.overflow="hidden",n.id=t.name+"-Window";var i=document.createElement("div");i.style.position="absolute",i.style.overflow="hidden",i.id=t.name+"-Landscape",n.appendChild(i),t.landscapeDiv=i,t.windowDiv=n,this.container.appendChild(n),this.updateSceneSize(t),t.startCell=this.startCell,t.highlightScene=new Fr,t.highlightScene.add(new Tr);for(var r=0;r<t.children.length;r++)t.children[r].isLight&&t.highlightScene.add(t.children[r].clone())}calculateSceneFractions(t){t.windowFractionX=t.internalData.x?Math.max(0,t.internalData.x/this.width):0,t.windowFractionWidth=t.internalData.width?Math.min(1,t.internalData.width/this.width):1,t.windowFractionY=t.internalData.y?Math.max(0,t.internalData.y/this.height):0,t.windowFractionHeight=t.internalData.height?Math.min(1,t.internalData.height/this.height):1}createLandscapeGrid(t){void 0===t.landscapeRows&&(t.landscapeRows=1),void 0===t.landscapeColumns&&(t.landscapeColumns=1),t.landscapeGrid=[];for(var e=0;e<t.landscapeRows;e++){t.landscapeGrid.push([]);for(var n=0;n<t.landscapeColumns;n++){var i={};i.container=t.landscapeDiv,i.scene=t,i.name=t.name+"-Landscape-Grid-Row"+e+"-Col"+n,i.initialized=!1,t.landscapeGrid[e].push(i)}}this.sizeLandscapeGrid(t)}isGridItemVisible(t){var e=t.scene,n=(e.baseLeft??0)+(e.panOffsetX??0)+t.left,i=n+t.width,r=(e.baseTop??0)+(e.panOffsetY??0)+t.top,a=r+t.height;return!(i<0||n>e.windowWidth||a<0||r>e.windowHeight)}initializeGridItem(t){var e=document.createElement("canvas");e.style.position="absolute",e.id=t.name,t.container.insertBefore(e,t.container.firstChild),t.canvas=e,t.ctx=e.getContext("2d"),this.displayCanvas&&(e.style.backgroundColor="rgba("+255*Math.random()+","+255*Math.random()+","+255*Math.random()+",0.1)");var n=document.createElement("canvas");n.style.position="absolute",n.id=t.name+"-Highlight",t.container.appendChild(n),t.highlightCanvas=n,t.highlightCtx=n.getContext("2d"),t.renderTarget=new Zi,t.renderTarget.texture.colorSpace=Bn,t.pickingRenderTarget=new Zi,t.initialized=!0}disposeGridItem(t){t.container.removeChild(t.canvas),t.canvas=null,t.ctx=null,t.container.removeChild(t.highlightCanvas),t.highlightCanvas=null,t.highlightCtx=null,t.renderTarget=null,t.pickingRenderTarget=null,t.initialized=!1}attachInteractors(t){if(t.internalData.attachTransformInteractor&&this.transformInteractor&&this.transformInteractor.setObjectScene(t,this.currentScene),t.internalData.attachZoomRectangleInteractor&&this.zoomRectangleInteractor&&this.zoomRectangleInteractor.setObjectScene(t,this.currentScene),t.internalData.attachPanInteractor&&this.panInteractor){var e=this.currentRealScene,n=t.parent;n.matrix.copy(t.parent.matrixWorld),n.matrixAutoUpdate=!1,n.isScene=!0,n.autoUpdate=!0,n.overrideMaterial=null,n.internalData.is3D=!1,n.internalData.pickable=this.isObjectPickable(t.parent),n.name=t.name,n.panScene=!0,e.origCamera||(e.origCamera=e.camera.clone(),e.internalData.origWidth=e.internalData.width,e.internalData.origHeight=e.internalData.height),n.camera=e.origCamera.clone();for(var i=n.camera.right-n.camera.left,r=n.camera.top-n.camera.bottom,a=0;a<e.children.length;a++)e.children[a].isLight&&n.add(e.children[a].clone());var s=new Ci;s.set(-t.internalData.xSize/2,-t.internalData.ySize/2,0),s.applyMatrix4(n.matrix);var o=new Ci;o.set(t.internalData.xSize/2,t.internalData.ySize/2,0),o.applyMatrix4(n.matrix);var l=e.internalData.origWidth,c=e.internalData.origHeight,h=Math.floor((s.x-n.camera.left)/i*l),d=Math.floor((1-(o.x-n.camera.left)/i)*l),u=Math.floor((s.y-n.camera.bottom)/r*c),p=Math.floor((1-(o.y-n.camera.bottom)/r)*c);this.panInteractor.leftLimit=(l-this.width)/2,this.panInteractor.rightLimit=-this.panInteractor.leftLimit,this.panInteractor.topLimit=(c-this.height)/2,this.panInteractor.bottomLimit=-this.panInteractor.topLimit,n.baseLeft=this.panInteractor.rightLimit-h,n.baseTop=this.panInteractor.bottomLimit-p,n.landscapeWidth=l,n.landscapeHeight=c,n.landscapeRows=Math.ceil(c/this.height),n.landscapeColumns=Math.ceil(l/this.width),n.centerWidth=l-h-d,n.centerHeight=c-u-p,n.zoomOffsetLeft=2*h+n.baseLeft,n.zoomOffsetTop=2*p+n.baseTop,"center"===t.internalData.attachPanInteractor?(n.internalData.x=h,n.internalData.width=this.width-h-d,n.internalData.y=u,n.internalData.height=this.height-u-p,e.internalData.x=n.internalData.x,e.internalData.width=n.internalData.width,e.internalData.y=n.internalData.y,e.internalData.height=n.internalData.height,e.camera.left=s.x,e.camera.right=o.x,e.camera.bottom=s.y,e.camera.top=o.y,this.calculateSceneFractions(e),this.updateSceneSize(e)):"bottom"===t.internalData.attachPanInteractor?(n.landscapeHeight=this.height,n.landscapeRows=1,n.camera.top=n.camera.bottom+r*this.height/c,n.internalData.x=h,n.internalData.width=this.width-h-d,n.internalData.y=0,n.internalData.height=this.height-p,n.baseTop=-p):"top"===t.internalData.attachPanInteractor?(n.landscapeHeight=this.height,n.landscapeRows=1,n.camera.bottom=n.camera.top-r*this.height/c,n.internalData.x=h,n.internalData.width=this.width-h-d,n.internalData.y=u,n.internalData.height=this.height-u,n.baseTop=0):"left"===t.internalData.attachPanInteractor?(n.landscapeWidth=this.width,n.landscapeColumns=1,n.camera.right=n.camera.left+i*this.width/l,n.internalData.x=0,n.internalData.width=this.width-d,n.internalData.y=u,n.internalData.height=this.height-u-p,n.baseLeft=0):"right"===t.internalData.attachPanInteractor&&(n.landscapeWidth=this.width,n.landscapeColumns=1,n.camera.left=n.camera.right-i*this.width/l,n.internalData.x=h,n.internalData.width=this.width-h,n.internalData.y=u,n.internalData.height=this.height-u-p,n.baseLeft=-h),this.addScene(n,!0),n.parent&&n.parent.remove(n),"center"===t.internalData.attachPanInteractor?this.panInteractor.object=n:"bottom"===t.internalData.attachPanInteractor?this.panInteractor.linkObjectsBottom.push(n):"top"===t.internalData.attachPanInteractor?this.panInteractor.linkObjectsTop.push(n):"left"===t.internalData.attachPanInteractor?this.panInteractor.linkObjectsLeft.push(n):"right"===t.internalData.attachPanInteractor&&this.panInteractor.linkObjectsRight.push(n),this.panInteractor.restorePanOffset(n),this.panInteractor.update()}else if(t.internalData.attachPanInteractorStatic&&this.panInteractor){var m=this;t.traverseAncestors((function(e){"bottom"===e.internalData.attachPanInteractor?(m.panInteractor.linkObjectsBottomStatic.push(t),t.linkBottom=e):"top"===e.internalData.attachPanInteractor?(m.panInteractor.linkObjectsTopStatic.push(t),t.linkTop=e):"left"===e.internalData.attachPanInteractor?(m.panInteractor.linkObjectsLeftStatic.push(t),t.linkLeft=e):"right"===e.internalData.attachPanInteractor&&(m.panInteractor.linkObjectsRightStatic.push(t),t.linkRight=e)}))}}createPickingInfo(t){if(void 0!==t.geometry&&void 0!==t.material){if(void 0===t.geometry.attributes.cellCount){var e,n;if(t.material.glyphs){var i=t.geometry.attributes.glyphOffset.array.length/3;n=i;for(var r=new Float32Array(i),a=0;a<i;a++)r[a]=a;e=new ks(r,1)}else if(t.isThickLineSegments){for(n=(s=t.geometry.attributes.instanceStart.array.length/3)/2,r=new Float32Array(n),a=0;a<n;a++)r[a]=a;e=new ks(r,1)}else{var s,o=1;for(t.isPoints?o=1:t.isLineSegments?o=2:t.isMesh&&(o=3),n=(s=t.geometry.attributes.position.array.length/3)/o,e=new ya(s,1),a=0;a<n;a++)for(var l=0;l<o;l++)e.array[a*o+l]=a}t.geometry.setAttribute("cellCount",e),t.geometry.nCells=n}t.nCells=t.geometry.nCells,t.startCell=this.startCell,t.onBeforeRender=function(t,e,n,i,r,a){r.uniforms.startCell.value=this.startCell,r.uniformsNeedUpdate=!0},this.startCell+=t.nCells,this.currentScene.landscapeGrid||this.createLandscapeGrid(this.currentScene),!this.pickingRenderTarget2&&this.startCell>16777215&&(this.pickingRenderTarget2=new Zi(this.pixelWidth,this.pixelHeight),this.pickingPixelBuffer2=new Uint8Array(4*this.pixelWidth*this.pixelHeight)),this.updatePicking=!0}}addLabels(t){t.isBillboardText&&t.addToScene(this.currentScene)}addMaterialReferences(t){void 0!==t.material&&(t.material.pickState=this.pickState,void 0!==t.material.isLineBasicMaterial&&(t.material.resolution=this.resolution))}loadGeometryAsJson(t,e,n,i){var r=this;this.objectLoader.parse(t,(function(t){r.clearGeometry(),r.updateSize(),r.addGeometry(t),r.renderNextFrame=!0,e&&e()}),n,i)}runAnimation(){if(null!==this.animator){this.animator.clear();for(var t=0;t<this.scenes.length;t++)this.animator.attach(this.scenes[t]);this.animator.hasAnimations()&&this.animator.play()}}animate(t){requestAnimationFrame(this.animate.bind(this)),this.visibleAnimatedGlyphs&&this.updateAnimatedGlyphs(this.enableAnimatedGlyphs?t:0),this.renderNextFrame&&(this.renderNextFrame=!1,this.render()),this.pickDepth===cm&&this.updatePicking&&(this.updatePicking=!1,this.pickRender())}setVisibleAnimatedGlyphs(t){this.visibleAnimatedGlyphs=t;for(let e=0;e<this.animatedGlyphs.length;e++)this.animatedGlyphs[e].traverse((function(e){e.visible=t}));this.renderNextFrame=!0}setEnableAnimatedGlyphs(t){this.enableAnimatedGlyphs=t}updateAnimatedGlyphs(t){const e=new Ci,n=new Ci,i=new Ci,r=new Ci,a=new Ci,s=new Pi,o=new Dr;for(let l=0;l<this.animatedGlyphs.length;l++){const c=this.animatedGlyphs[l];void 0===c.animatedGlyphsInitialized&&(c.animatedGlyphsInfo=JSON.parse(c.internalData.animatedGlyphs));const h=c.animatedGlyphsInfo.colorPalette,d=c.animatedGlyphsInfo.coordinates,u=c.animatedGlyphsInfo.segmentStartCoordIndex,p=c.animatedGlyphsInfo.segmentEndCoordIndex,m=c.animatedGlyphsInfo.segmentSpacing,f=c.animatedGlyphsInfo.segmentSpeed,g=c.animatedGlyphsInfo.segmentSurfaceColorIndex;if(void 0===c.animatedGlyphsInitialized){let t=0;for(let i=0;i<u.length;i++){if(m[i]<=0||0===f[i])continue;const r=u[i],a=p[i],s=m[i];let o=0;for(let t=r;t<a;t++)e.set(d[3*t],d[3*t+1],d[3*t+2]),n.set(d[3*t+3],d[3*t+4],d[3*t+5]),o+=e.distanceTo(n);t+=Math.ceil(o/s)}c.traverse((function(e){let n=e.geometry;if(void 0!==n){const i=n.getAttribute("position");n.dispose();const r=new zh;r.setAttribute("position",i),r.setAttribute("glyphOffset",new ks(new Float32Array(3*t),3)),r.setAttribute("glyphOrientation",new ks(new Float32Array(9*t),9)),e.isMesh&&e.material.vertexColors&&r.setAttribute("color",new ks(new Float32Array(3*t),3)),e.geometry=r}})),c.animatedGlyphsInitialized=!0}const v=[],_=[],y=[];let x=0;for(let l=0;l<u.length;l++){if(m[l]<=0||0===f[l])continue;let c=g[l];(c<0||c>h.length)&&(c=0),o.set(h[c]);const b=f[l]>0?1:-1,S=m[l],M=b<0?p[l]-1:u[l],w=b<0?u[l]-1:p[l],E=S/Math.abs(f[l]);let T=S*(t%(1e3*E)/(1e3*E));for(let t=M;t!=w;t+=b){e.set(d[3*t],d[3*t+1],d[3*t+2]),n.set(d[3*t+3],d[3*t+4],d[3*t+5]);const l=e.distanceTo(n);i.subVectors(n,e).multiplyScalar(b).normalize(),r.copy(i).multiplyScalar(S),a.copy(i).multiplyScalar(T).add(b<0?n:e);const c=Math.atan2(-i.x,i.y);for(s.makeRotation(c);T<l;)v.push(a.x),v.push(a.y),v.push(a.z),_.push(s.elements[0]),_.push(s.elements[1]),_.push(s.elements[2]),_.push(s.elements[3]),_.push(s.elements[4]),_.push(s.elements[5]),_.push(s.elements[6]),_.push(s.elements[7]),_.push(s.elements[8]),y.push(o.r),y.push(o.g),y.push(o.b),a.add(r),T+=S,x++;T-=l}}c.traverse((function(t){const e=t.geometry;if(void 0!==e){const n=e.getAttribute("glyphOffset");n.set(v,0),n.needsUpdate=!0;const i=e.getAttribute("glyphOrientation");if(i.set(_,0),i.needsUpdate=!0,t.material.vertexColors){const t=e.getAttribute("color");t.set(y,0),t.needsUpdate=!0}e.instanceCount=x}})),this.renderNextFrame=!0}}loadGeometryAsEvents(t,e,n,i){var r=this,a=0,s=-1,o=0;function l(t){if(o--,t.layers.set(1),t.visible=t.saveVisible,s>0&&0==o)return r.render(),r.loading=!1,r.firstChunk=!1,void(e&&e())}function c(t){if("Group"===t.type){var e=r.objectLoader.parse(t);null!==r.curGroup&&r.curGroup.add(e),"SceneRoot"===e.name&&(void 0!==e.internalData.background?r.container.style.backgroundColor="#"+e.internalData.background.toString(16).padStart(6,"0"):r.container.style.backgroundColor="transparent"),e.updateMatrixWorld(!0),r.attachInteractors(e),r.curGroup=e}else if("FinishGroup"===t.type)null!==r.curGroup.parent&&(r.curGroup=r.curGroup.parent);else if("Geometry"===t.type){o++;var n=r.objectLoader.parse(t,l,r.images,r.textures,r.materials,r.geometries,r.curGroup);a++,r.addLabels(n),r.createPickingInfo(n),r.addMaterialReferences(n)}else if("Layout"===t.type){for(var i=r.objectLoader.parse(t),s=0;s<i.children.length;s++){var c=i.children[s];if(c.isPerspectiveCamera||c.isOrthographicCamera){i.camera=c,i.remove(c);break}}null==i.camera&&null!==i.background&&(i.camera=new Rh),void 0!==i.camera&&r.addScene(i),r.curGroup=i}else console.log("ERROR: unknown type: "+t.type)}if(void 0!==this.chunkId&&this.chunkId===t.chunkId||(this.clearGeometry(),this.curGroup=null,this.images=[],this.textures=[],this.materials=[],this.geometries=[],this.firstChunk=!0,this.chunkId=t.chunkId),this.loading=!0,this.updateSize(),void 0!==t&&void 0!==t.events&&0!==t.events.length){for(var h=0;h<t.events.length;h++)c(t.events[h]);!0===t.moreChunks?this.render():(s=a-1,0==o&&(this.render(),this.loading=!1,e&&e())),this.firstChunk=!1}else console.error("AVS.Three.Viewer.loadGeometryAsEvents: Can't get events")}highlightRender(){if(void 0!==this.renderer)for(var t=0;t<this.scenes.length;t++){var e=this.scenes[t];if(e.landscapeGrid){for(var n=0;n<e.landscapeRows;n++)for(var i=0;i<e.landscapeColumns;i++){var r=e.landscapeGrid[n][i];r.initialized&&(this.resolution.x=r.pixelWidth,this.resolution.y=r.pixelHeight,this.renderer.setSize(r.pixelWidth,r.pixelHeight),this.renderer.setClearColor(0,0),this.renderer.clear(),e.camera.setViewOffset(e.landscapeWidth,e.landscapeHeight,r.left,r.top,r.width,r.height),this.renderer.render(e.highlightScene,e.camera),r.highlightCtx.clearRect(0,0,r.pixelWidth,r.pixelHeight),r.highlightCtx.drawImage(this.renderer.domElement,0,0))}e.camera.clearViewOffset()}}else console.error("AVS.Three.Viewer: WebGLRenderer not set.")}pickRender(){if(void 0!==this.renderer){for(var t=0;t<this.scenes.length;t++){var e=this.scenes[t];if(e.landscapeGrid){e.traverse((function(t){void 0!==t.material&&(t.material.transparent=!1)}));for(var n=0;n<e.landscapeRows;n++)for(var i=0;i<e.landscapeColumns;i++){var r=e.landscapeGrid[n][i];r.initialized&&(this.resolution.x=r.pixelWidth,this.resolution.y=r.pixelHeight,this.renderer.setRenderTarget(r.pickingRenderTarget),this.pickState[0]=1,this.renderer.setClearColor(0,0),this.renderer.clear(),e.camera.setViewOffset(e.landscapeWidth,e.landscapeHeight,r.left,r.top,r.width,r.height),this.renderer.render(e,e.camera),this.renderer.readRenderTargetPixels(r.pickingRenderTarget,0,0,r.pixelWidth,r.pixelHeight,r.pickingPixelBuffer),r.pickingRenderTarget2&&(this.renderer.setRenderTarget(r.pickingRenderTarget2),this.pickState[0]=2,this.renderer.clear(),this.renderer.render(e,e.camera),this.renderer.readRenderTargetPixels(r.pickingRenderTarget2,0,0,r.pixelWidth,r.pixelHeight,r.pickingPixelBuffer2)))}e.camera.clearViewOffset(),e.traverse((function(t){void 0!==t.material&&(t.material.transparent=t.material.origTransparent)}))}}this.pickState[0]=0,this.renderer.setRenderTarget(null)}else console.error("AVS.Three.Viewer: WebGLRenderer not set.")}render(t){if(void 0!==this.renderer){if(null!==this.domElement.offsetParent){this.updateSize();for(var e=this.loading,n=t||!e,i=0;i<this.scenes.length;i++){var r=this.scenes[i];if(r.landscapeGrid){if(!n){r.camera.layers.set(1);for(var a=0;a<r.children.length;a++)r.children[a].isLight&&r.children[a].layers.set(1)}for(var s=0;s<r.landscapeRows;s++)for(var o=0;o<r.landscapeColumns;o++){var l=r.landscapeGrid[s][o];this.renderGridItem(l,n)}n||(r.camera.layers.set(0),r.traverse((function(t){t.layers.set(0)})))}for(a=0;a<r.labels.length;a++)r.labels[a].updatePosition()}this.updateHighlight&&(this.highlightRender(),this.updateHighlight=!1)}}else console.error("AVS.Three.Viewer: WebGLRenderer not set.")}renderGridItem(t,e){if(t.initialized){var n=t.scene;if(this.resolution.x=t.pixelWidth,this.resolution.y=t.pixelHeight,e?this.renderer.setSize(t.pixelWidth,t.pixelHeight):this.renderer.setRenderTarget(t.renderTarget),(e||this.firstChunk)&&(n.internalData.background?this.renderer.setClearColor(n.internalData.background,1):this.renderer.setClearColor(0,0),this.renderer.clear()),n.camera.setViewOffset(n.landscapeWidth,n.landscapeHeight,t.left,t.top,t.width,t.height),this.renderer.render(n,n.camera),e)t.ctx.clearRect(0,0,t.pixelWidth,t.pixelHeight),t.ctx.drawImage(this.renderer.domElement,0,0);else{this.renderer.readRenderTargetPixels(t.renderTarget,0,0,t.pixelWidth,t.pixelHeight,t.pixelBuffer);for(var i,r,a=t.ctx.createImageData(t.pixelWidth,t.pixelHeight),s=4*t.pixelWidth,o=0;o<t.pixelBuffer.length;o++)i=Math.floor(o/s),r=o%s,a.data[(t.pixelHeight-i-1)*s+r]=t.pixelBuffer[o];t.ctx.putImageData(a,0,0),this.renderer.setRenderTarget(null)}n.camera.clearViewOffset()}}addSelectionListener(t){void 0!==t&&this.selectionListeners.push(t)}concatObjectsFromCellNums(t,e,n,i){if(void 0!==n&&0!==n.length&&0!==n[0]){for(void 0===i&&(i=e.startCell,n.sort((function(t,e){return t-e})));void 0!==e.nCells&&n[0]>=i&&n[0]<i+e.nCells;)if(e.material.glyphs||e.isThickLineSegments?t.push({object:e,index:n[0]-i}):e.isMesh?t.push({object:e,faceIndex:n[0]-i}):t.push({object:e,index:(e.isLineSegments?2:1)*(n[0]-i)}),n.splice(0,1),0===n.length)return;void 0!==e.nCells&&(i+=e.nCells);for(var r=0;r<e.children.length&&void 0!==(i=this.concatObjectsFromCellNums(t,e.children[r],n,i));r++);return i}}pick(){if(!1!==this.validPick){this.intersects=[];for(var t=0;t<this.scenes.length;t++){var e=this.scenes[t];if(e.landscapeGrid)if(this.pickType===dm){var n=Math.max(this.pickRectangleLeft,e.windowX),i=Math.max(this.pickRectangleTop,e.windowTop),r=Math.min(this.pickRectangleRight,e.windowX+e.windowWidth),a=Math.min(this.pickRectangleBottom,e.windowTop+e.windowHeight);n-=e.windowX,i-=e.windowTop,r-=e.windowX,a-=e.windowTop,n-=(e.panOffsetX??0)+(e.baseLeft??0),r-=(e.panOffsetX??0)+(e.baseLeft??0),i-=(e.panOffsetY??0)+(e.baseTop??0),a-=(e.panOffsetY??0)+(e.baseTop??0);for(var s=[],o=n;o<r;o++)for(var l=i;l<a;l++)if(this.pickDepth===lm){var c=o/e.landscapeWidth*2-1,h=(e.landscapeHeight-l-1)/e.landscapeHeight*2-1;this.raycaster.setFromCamera(new Ti(c,h),e.camera),this.raycaster.landscapeWidth=e.landscapeWidth,this.raycaster.landscapeHeight=e.landscapeHeight,this.raycaster.x=o,this.raycaster.y=l;var d=this.raycaster.intersectObjects(e.children,!0);this.intersects=this.intersects.concat(d)}else for(var u=0;u<e.landscapeRows;u++)for(var p=0;p<e.landscapeColumns;p++)if((_=e.landscapeGrid[u][p]).initialized&&!(o<_.left||o>_.left+_.width||l<_.top||l>_.top+_.height)){var m=Math.floor(o*window.devicePixelRatio),f=Math.floor(l*window.devicePixelRatio),g=4*(m-_.pixelX+(_.pixelHeight-(f-_.pixelY)-1)*_.pixelWidth),v=255*_.pickingPixelBuffer[g]*255+255*_.pickingPixelBuffer[g+1]+_.pickingPixelBuffer[g+2];_.pickingPixelBuffer2&&(v+=255*_.pickingPixelBuffer2[g]*255*255*255*255+255*_.pickingPixelBuffer2[g+1]*255*255*255+255*_.pickingPixelBuffer2[g+2]*255*255),v>0&&-1===s.indexOf(v)&&s.push(v)}this.pickDepth===cm&&this.concatObjectsFromCellNums(this.intersects,e,s)}else{if(this.pickRayX<e.windowX||this.pickRayX>e.windowX+e.windowWidth||this.pickRayY<e.windowTop||this.pickRayY>e.windowTop+e.windowHeight)continue;if(o=this.pickRayX-e.windowX,l=this.pickRayY-e.windowTop,o-=(e.panOffsetX??0)+(e.baseLeft??0),l-=(e.panOffsetY??0)+(e.baseTop??0),this.pickDepth===lm)c=o/e.landscapeWidth*2-1,h=(e.landscapeHeight-l-1)/e.landscapeHeight*2-1,this.raycaster.setFromCamera(new Ti(c,h),e.camera),this.raycaster.landscapeWidth=e.landscapeWidth,this.raycaster.landscapeHeight=e.landscapeHeight,this.raycaster.x=o,this.raycaster.y=l,d=this.raycaster.intersectObjects(e.children,!0),this.intersects=this.intersects.concat(d);else for(u=0;u<e.landscapeRows;u++)for(p=0;p<e.landscapeColumns;p++){var _;(_=e.landscapeGrid[u][p]).initialized&&!(o<_.left||o>_.left+_.width||l<_.top||l>_.top+_.height)&&(m=Math.floor(o*window.devicePixelRatio),f=Math.floor(l*window.devicePixelRatio),g=4*(m-_.pixelX+(_.pixelHeight-(f-_.pixelY)-1)*_.pixelWidth),v=255*_.pickingPixelBuffer[g]*255+255*_.pickingPixelBuffer[g+1]+_.pickingPixelBuffer[g+2],_.pickingPixelBuffer2&&(v+=255*_.pickingPixelBuffer2[g]*255*255*255*255+255*_.pickingPixelBuffer2[g+1]*255*255*255+255*_.pickingPixelBuffer2[g+2]*255*255),this.concatObjectsFromCellNums(this.intersects,e,[v]))}}}for(t=0;t<this.selectionListeners.length;t++)this.selectionListeners[t]()}else console.error("AVS.Three.Viewer: invalid pick ray or rectangle.")}isObjectPickable(t){return void 0!==t.internalData.pickable?t.internalData.pickable:null===t.parent||this.isObjectPickable(t.parent)}getPickedCells(){for(var t=[],e=0;e<this.intersects.length;e++){var n=this.intersects[e].object;if(this.isObjectPickable(n)){for(var i=this.intersects[e].faceIndex??this.intersects[e].index,r=!1,a=0;a<t.length;a++)if(n===t[a].object){r=!0;for(var s=!1,o=0;o<t[a].indices.length;o++)if(i===t[a].indices[o]){s=!0;break}s||t[a].indices.push(i);break}r||t.push({object:n,indices:[i]})}}return t}getPickedCellSets(){for(var t=[],e=0;e<this.intersects.length;e++){var n=this.intersects[e].object;if(this.isObjectPickable(n)){for(var i=!1,r=0;r<t.length;r++)if(t[r].object===n){i=!0;break}i||t.push({object:n})}}return t}getPickedSceneNodes(){for(var t=[],e=0;e<this.intersects.length;e++){var n=this.intersects[e].object;if(this.isObjectPickable(n)){for(var i=n.parent,r=!1,a=0;a<t.length;a++)if(t[a].object===i){r=!0;break}r||t.push({object:i})}}return t}getSelectionInfo(t){for(var e=[],n=0;n<t.length;n++){var i=t[n].object,r=t[n].indices;if(void 0!==r)for(var a=0;a<r.length;a++)e.push(s(i,{},r[a]));else e.push(s(i,{}))}function s(t,e,n){for(var i in t.userData)void 0===e[i]&&(void 0!==n&&Array.isArray(t.userData[i])?e[i]=decodeURIComponent(t.userData[i][t.isLineSegments&&!t.material.glyphs?n/2:n]):e[i]=decodeURIComponent(t.userData[i]));return t.parent?s(t.parent,e):e}return e}highlightObjects(t,e){for(var n=!1,i=0;i<this.highlightList.length;i++)void 0!==(s=this.highlightList[i]).saveMaterial&&(s.material=s.saveMaterial,s.saveMaterial=void 0,n=!0),void 0!==s.saveGeometry&&(s.geometry=s.saveGeometry,s.saveGeometry=void 0,n=!0);for(i=0;i<this.scenes.length;i++){var r=this.scenes[i].highlightScene.children[0].children;r.length>0&&(r.length=0,this.updateHighlight=!0)}this.highlightList.length=0;var a=this;for(i=0;i<t.length;i++){var s;o(s=t[i].object,t[i].indices)}function o(t,i){if(t.isMesh||t.isLineSegments||t.isPoints){a.highlightList.push(t);var r,s=t.material.clone();if(s.opacity=1,void 0!==i){var l=t.geometry;if(s.vertexColors=!0,s.color=new Dr(16777215),t.isThickLineSegments){var c;if(r=new zh,l.attributes.instancedColorStart,void 0===oldColorStart){c=new ld(new Float32Array(l.attributes.instanceStart.array.length),6,1);for(var h=0,d=0;d<c.array.length/3;d++)c.array[h++]=t.material.color.r,c.array[h++]=t.material.color.g,c.array[h++]=t.material.color.b}else c=oldColorStart.data.clone();h=null;var u=null;for(d=0;d<i.length;d++){h=6*Math.floor(i[d]/6),u=2;for(var p=0;p<u;p++)c.array[h++]=a.highlightColor.r,c.array[h++]=a.highlightColor.g,c.array[h++]=a.highlightColor.b}for(var m in r.setAttribute("instancedColorStart",new Na(c,3,0)),r.setAttribute("instancedColorEnd",new Na(c,3,3)),l.attributes)"instancedColorStart"!==m&&"instancedColorEnd"!==m&&r.setAttribute(m,l.attributes[m])}else{r=t.material.glyphs?new zh:new Pa;var f=l.attributes.color,g=null;if(void 0===f)for(g=t.material.glyphs?new ks(new Float32Array(l.attributes.offset.array.length),3):new ya(l.attributes.position.array.length,3),h=0,d=0;d<g.array.length/3;d++)g.array[h++]=t.material.color.r,g.array[h++]=t.material.color.g,g.array[h++]=t.material.color.b;else g=f.clone();for(h=null,u=null,d=0;d<i.length;d++)for(t.material.glyphs||t.cellType===um?(h=3*i[d],u=1):t.cellType===pm?(h=3*i[d],u=2):t.cellType===mm?(h=9*i[d],u=3):(h=18*Math.floor(i[d]/2),u=6),p=0;p<u;p++)g.array[h++]=a.highlightColor.r,g.array[h++]=a.highlightColor.g,g.array[h++]=a.highlightColor.b;for(var m in r.setAttribute("color",g),l.attributes)"color"!==m&&r.setAttribute(m,l.attributes[m])}}else s.vertexColors=!1,s.color=a.highlightColor,r=t.geometry;var v=a.getObjectScene(t);if(void 0!==v.internalData.is3D&&!1===v.internalData.is3D&&void 0!==e&&!0===e){var _=t.clone();_.material=s,_.geometry=r,_.matrixAutoUpdate=!1,_.matrix.copy(t.matrixWorld),v.highlightScene.children[0].add(_),a.updateHighlight=!0}else t.saveMaterial=t.material,t.material=s,t.saveGeometry=t.geometry,t.geometry=r,n=!0}for(var y=0;y<t.children.length;y++)o(t.children[y])}n?this.render(!0):this.updateHighlight&&(this.highlightRender(),this.updateHighlight=!1)}getObjectScene(t){return t.isScene?t:this.getObjectScene(t.parent)}}const lf={type:"change"},cf={type:"start"},hf={type:"end"};class df extends mi{constructor(t){super(),this.isTransformInteractor=!0,this.domElement=t,this.domElement.style.touchAction="none",this.object=new Er,this.scene=null,this.enabled=!0,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.enablePan=!0,this.keyPanSpeed=7,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.touches={ONE:St,TWO:wt},this.quaternion=this.object.quaternion.clone(),this.position=this.object.position.clone(),this.scale=this.object.scale.clone(),this.clientOnly=!1,this.fullReset=!1,this.quaternion0=this.object.quaternion.clone(),this.position0=this.object.position.clone(),this.scale0=this.object.scale.clone(),this._domElementKeyEvents=null,this.listenToKeyEvents=function(t){t.addEventListener("keydown",F),this._domElementKeyEvents=t},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",F),this._domElementKeyEvents=null},this.setObjectScene=function(t,n){e.object=t,e.scene=n,this.fullReset||t.internalData.transformFullReset?(e.quaternion.copy(e.object.quaternion),e.scale.copy(e.object.scale),e.position.copy(e.object.position),e.quaternion0.copy(e.object.quaternion),e.scale0.copy(e.object.scale),e.position0.copy(e.object.position),this.fullReset=!1):e.clientOnly&&(e.object.quaternion.copy(e.quaternion),e.object.scale.copy(e.scale),e.object.position.copy(e.position)),t.internalData.transformWheelActions&&(r=JSON.parse(t.internalData.transformWheelActions)),t.internalData.transformTriggers&&(a=JSON.parse(t.internalData.transformTriggers))},this.reset=function(){e.quaternion.copy(e.quaternion0),e.scale.copy(e.scale0),e.position.copy(e.position0),e.object.quaternion.copy(e.quaternion0),e.object.scale.copy(e.scale0),e.object.position.copy(e.position0),e.dispatchEvent(lf),i=n.NONE},this.zoomIn=function(){b(1/f(),0,0)&&e.dispatchEvent(lf)},this.zoomOut=function(){b(f(),0,0)&&e.dispatchEvent(lf)},this.panTo=function(t,n,i){var r=e.object.parent.matrixWorld,a=1/r.elements[0],s=1/r.elements[5],o=1/r.elements[10],l=r.elements[12]*a,c=r.elements[13]*s,h=r.elements[14]*o;t*=e.object.scale.x,n*=e.object.scale.y,i*=e.object.scale.z,t+=l,n+=c,i+=h,e.object.position.set(e.position0.x-t,e.position0.y-n,e.position0.z-i),e.position.copy(e.object.position),e.dispatchEvent(lf)},this.dispose=function(){e.domElement.removeEventListener("contextmenu",z),e.domElement.removeEventListener("pointerdown",D),e.domElement.removeEventListener("pointercancel",O),e.domElement.removeEventListener("wheel",U),e.domElement.removeEventListener("pointermove",N),e.domElement.removeEventListener("pointerup",O),null!==e._domElementKeyEvents&&(e._domElementKeyEvents.removeEventListener("keydown",F),e._domElementKeyEvents=null)};const e=this,n={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let i=n.NONE,r=[{modifiers:0,param:"ZOOM_AT_POINTER"}],a=[{buttons:1,modifiers:0,param:"ROTATE"},{buttons:2,modifiers:0,param:"SCALE"},{buttons:4,modifiers:0,param:"TRANSLATE"}];const s=new Ti,o=new Ti,l=new Ti,c=new Ti,h=new Ti,d=new Ti,u=new Ti,p=[],m={};function f(){return Math.pow(.95,e.zoomSpeed)}function g(t){return 2*(t-e.scene.windowDiv.getBoundingClientRect().left)/e.scene.windowWidth-1}function v(t){return 1-2*(t-e.scene.windowDiv.getBoundingClientRect().top)/e.scene.windowHeight}const _=function(){const t=new Ki,n=new Ci,i=new Ci,r=new Ci,a=new Ki,l=new Ci;let c,h;const d=new Ai;return function(){return null!==e.object&&null!==e.object.parent&&(t.multiplyMatrices(e.scene.camera.matrixWorldInverse,e.object.parent.matrixWorld),n.set(0,0,0),i.set(s.x,s.y,1),r.set(o.x,o.y,1),a.copy(t).invert(),n.applyMatrix4(a),i.applyMatrix4(a),r.applyMatrix4(a),i.sub(n).normalize(),r.sub(n).normalize(),void 0!==e.scene.internalData.is3D&&!1===e.scene.internalData.is3D?(l.set(0,0,1),c=i.x*r.y-i.y*r.x,c<0&&(l.negate(),c=-c)):(l.crossVectors(i,r),c=l.length()),!(c<1e-5||(h=Math.abs(c)<1?2*Math.sin(c):Math.PI,i.dot(r)<0&&(h+=.5*Math.PI),d.setFromAxisAngle(l.normalize(),h),e.object.quaternion.premultiply(d),e.quaternion.copy(e.object.quaternion),0)))}}(),y=function(){const t=new Ki,n=new qi,i=new Ci,r=new Ki,a=new qi,s=new qi,o=new Ci,h=new Ci,d=new Ci;return function(){return null!==e.object&&null!==e.object.parent&&(t.multiplyMatrices(e.scene.camera.matrixWorldInverse,e.object.parent.matrixWorld),t.premultiply(e.scene.camera.projectionMatrix),n.set(0,0,0,1).applyMatrix4(t),i.set(n.x/n.w,n.y/n.w,n.z/n.w),r.copy(t).invert(),a.set(l.x,l.y,i.z,1),s.set(c.x,c.y,i.z,1),a.applyMatrix4(r),s.applyMatrix4(r),o.set(a.x/a.w,a.y/a.w,a.z/a.w),h.set(s.x/s.w,s.y/s.w,s.z/s.w),d.subVectors(h,o),e.object.position.add(d),e.position.copy(e.object.position),!0)}}();function x(t){return null!==e.object&&(e.object.scale.multiplyScalar(t),e.scale.copy(e.object.scale),!0)}const b=function(){const t=new Ki,n=new Ki,i=new qi,r=new qi,a=new Ci,s=new Ci;return function(o,l,c){return null!==e.object&&null!==e.object.parent&&(t.multiplyMatrices(e.scene.camera.matrixWorldInverse,e.object.parent.matrixWorld),t.premultiply(e.scene.camera.projectionMatrix),i.set(0,0,0,1).applyMatrix4(t),n.copy(t).invert(),r.set(l,c,i.z/i.w,1).applyMatrix4(n),a.set(r.x/r.w,r.y/r.w,r.z/r.w),a.sub(e.object.position),s.copy(a).multiplyScalar(o).add(a.negate()),e.object.scale.multiplyScalar(o),e.object.position.sub(s),e.scale.copy(e.object.scale),e.position.copy(e.object.position),!0)}}();function S(t){s.set(g(t.clientX),v(t.clientY))}function M(t){h.set(t.clientX,t.clientY)}function w(t){l.set(g(t.clientX),v(t.clientY))}function E(t){x(t.deltaY>0?f():1/f())&&e.dispatchEvent(lf)}function T(t){const n=t.deltaY>0?f():1/f();b(n,g(t.clientX),v(t.clientY))&&e.dispatchEvent(lf)}function A(){if(1===p.length)s.set(g(p[0].clientX),v(p[0].clientY));else{const t=.5*(p[0].clientX+p[1].clientX),e=.5*(p[0].clientY+p[1].clientY);s.set(g(t),v(e))}}function C(){if(1===p.length)l.set(g(p[0].clientX),v(p[0].clientY));else{const t=.5*(p[0].clientX+p[1].clientX),e=.5*(p[0].clientY+p[1].clientY);l.set(g(t),v(e))}}function R(){const t=Math.abs(p[0].clientX-p[1].clientX),e=Math.abs(p[0].clientY-p[1].clientY),n=Math.sqrt(t*t+e*e);h.set(0,n)}function I(t){if(1==p.length)o.set(g(t.clientX),v(t.clientY));else{const e=B(t),n=.5*(t.clientX+e.x),i=.5*(t.clientY+e.y);o.set(g(n),v(i))}_()&&e.dispatchEvent(lf),s.copy(o)}function P(t){if(1===p.length)c.set(g(t.clientX),v(t.clientY));else{const e=B(t),n=.5*(t.clientX+e.x),i=.5*(t.clientY+e.y);c.set(g(n),v(i))}y()&&e.dispatchEvent(lf),l.copy(c)}function L(t){const n=B(t),i=t.clientX-n.x,r=t.clientY-n.y,a=Math.sqrt(i*i+r*r);d.set(0,a),u.set(0,Math.pow(d.y/h.y,e.zoomSpeed)),x(u.y)&&e.dispatchEvent(lf),h.copy(d)}function D(t){!1!==e.enabled&&(0===p.length&&(e.domElement.setPointerCapture(t.pointerId),e.domElement.addEventListener("pointermove",N),e.domElement.addEventListener("pointerup",O)),function(t){p.push(t)}(t),"touch"===t.pointerType?function(t){switch(k(t),p.length){case 1:switch(e.touches.ONE){case St:if(!1===e.enableRotate)return;A(),i=n.TOUCH_ROTATE;break;case Mt:if(!1===e.enablePan)return;C(),i=n.TOUCH_PAN;break;default:i=n.NONE}break;case 2:switch(e.touches.TWO){case wt:if(!1===e.enableZoom&&!1===e.enablePan)return;e.enableZoom&&R(),e.enablePan&&C(),i=n.TOUCH_DOLLY_PAN;break;case Et:if(!1===e.enableZoom&&!1===e.enableRotate)return;e.enableZoom&&R(),e.enableRotate&&A(),i=n.TOUCH_DOLLY_ROTATE;break;default:i=n.NONE}break;default:i=n.NONE}i!==n.NONE&&e.dispatchEvent(cf)}(t):function(t){t.preventDefault();var r=0;r+=t.shiftKey?1:0,r+=t.ctrlKey?2:0,r+=t.metaKey?4:0;let s=0;switch(t.button){case 0:s=1;break;case 1:s=2;break;case 2:s=4}for(var o=0,l=a.length;o<l;o++)if(r===a[o].modifiers&&s&a[o].buttons){switch(a[o].param){case 0:case"ROTATE":if(!1===e.enableRotate)continue;S(t),i=n.ROTATE,e.domElement.ownerDocument.body.style.cursor="move";break;case 1:case"SCALE":if(!1===e.enableZoom)continue;M(t),i=n.DOLLY,e.domElement.ownerDocument.body.style.cursor="ne-resize";break;case 2:case"TRANSLATE":if(!1===e.enablePan)continue;w(t),i=n.PAN,e.domElement.ownerDocument.body.style.cursor="move";break;default:i=n.NONE}i!==n.NONE&&e.dispatchEvent(cf);break}}(t))}function N(t){!1!==e.enabled&&("touch"===t.pointerType?function(t){switch(k(t),i){case n.TOUCH_ROTATE:if(!1===e.enableRotate)return;I(t);break;case n.TOUCH_PAN:if(!1===e.enablePan)return;P(t);break;case n.TOUCH_DOLLY_PAN:if(!1===e.enableZoom&&!1===e.enablePan)return;!function(t){e.enableZoom&&L(t),e.enablePan&&P(t)}(t);break;case n.TOUCH_DOLLY_ROTATE:if(!1===e.enableZoom&&!1===e.enableRotate)return;!function(t){e.enableZoom&&L(t),e.enableRotate&&I(t)}(t);break;default:i=n.NONE}}(t):function(t){if(!1!==e.enabled)switch(t.preventDefault(),i){case n.ROTATE:if(!1===e.enableRotate)return;!function(t){o.set(g(t.clientX),v(t.clientY)),_()&&e.dispatchEvent(lf),s.copy(o)}(t);break;case n.DOLLY:if(!1===e.enableZoom)return;!function(t){d.set(t.clientX,t.clientY),u.subVectors(d,h),x((Math.abs(u.x)>Math.abs(u.y)?-u.x:u.y)>0?f():1/f())&&e.dispatchEvent(lf),h.copy(d)}(t);break;case n.PAN:if(!1===e.enablePan)return;!function(t){c.set(g(t.clientX),v(t.clientY)),y()&&e.dispatchEvent(lf),l.copy(c)}(t)}}(t))}function O(t){!function(t){delete m[t.pointerId];for(let e=0;e<p.length;e++)if(p[e].pointerId==t.pointerId)return void p.splice(e,1)}(t),0===p.length&&(e.domElement.releasePointerCapture(t.pointerId),e.domElement.removeEventListener("pointermove",N),e.domElement.removeEventListener("pointerup",O)),e.domElement.ownerDocument.body.style.cursor="default",e.dispatchEvent(hf),i=n.NONE}function U(t){if(!1!==e.enabled&&!1!==e.enableZoom&&i===n.NONE){var a=0;a+=t.shiftKey?1:0,a+=t.ctrlKey?2:0,a+=t.metaKey?4:0;for(var s=0,o=r.length;s<o;s++)if(a===r[s].modifiers){switch(t.preventDefault(),r[s].param){case 0:case"ZOOM":e.dispatchEvent(cf),E(t),e.dispatchEvent(hf);break;case 1:case"ZOOM_AT_POINTER":e.dispatchEvent(cf),T(t),e.dispatchEvent(hf)}return}}}function F(t){!1!==e.enabled&&!1!==e.enablePan&&function(t){let n=!1;switch(l.set(0,0),c.set(0,0),t.code){case e.keys.UP:c.y=e.keyPanSpeed/(e.scene.windowHeight/2),n=!0;break;case e.keys.BOTTOM:c.y=-e.keyPanSpeed/(e.scene.windowHeight/2),n=!0;break;case e.keys.LEFT:c.x=-e.keyPanSpeed/(e.scene.windowWidth/2),n=!0;break;case e.keys.RIGHT:c.x=e.keyPanSpeed/(e.scene.windowWidth/2),n=!0}let i=!1;n&&(i=y(),t.preventDefault()),i&&e.dispatchEvent(lf)}(t)}function z(t){!1!==e.enabled&&t.preventDefault()}function k(t){let e=m[t.pointerId];void 0===e&&(e=new Ti,m[t.pointerId]=e),e.set(t.clientX,t.clientY)}function B(t){const e=t.pointerId===p[0].pointerId?p[1]:p[0];return m[e.pointerId]}e.domElement.addEventListener("contextmenu",z),e.domElement.addEventListener("pointerdown",D),e.domElement.addEventListener("pointercancel",O),e.domElement.addEventListener("wheel",U,{passive:!1}),e.listenToKeyEvents(window)}}const uf={type:"change"},pf={type:"zoom"},mf={type:"zoomEnd"},ff={type:"start"},gf={type:"end"};class vf extends mi{constructor(t){super(),void 0===t&&console.warn('AVS.Three.PanInteractor: The first parameter "domElement" is now mandatory.'),t===document&&console.error('AVS.Three.PanInteractor: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.isPanInteractor=!0,this.domElement=t,this.domElement.style.touchAction="none",this.object=new Er,this.linkObjectsBottom=[],this.linkObjectsTop=[],this.linkObjectsLeft=[],this.linkObjectsRight=[],this.linkObjectsBottomStatic=[],this.linkObjectsTopStatic=[],this.linkObjectsLeftStatic=[],this.linkObjectsRightStatic=[],this.leftLimit=0,this.rightLimit=0,this.topLimit=0,this.bottomLimit=0,this.domElement=t,this.enabled=!0,this.enableZoom=!0,this.zoomSpeed=1,this.enablePan=!0,this.panSpeed=1,this.keyPanSpeed=7,this.enableKeys=!0,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:bt.PAN,MIDDLE:bt.NONE,RIGHT:bt.NONE},this.touches={ONE:Mt,TWO:wt},this._domElementKeyEvents=null,this.listenToKeyEvents=function(t){t.addEventListener("keydown",L),this._domElementKeyEvents=t},this.saveState=function(){a.copy(r),l.copy(o)},this.reset=function(){o.equals(l)?(r.copy(a),e.update()):(o.copy(l),p.set(-1,-1),r.copy(a),T()),i=n.NONE},this.update=function(t=!0){if(void 0!==e.object&&void 0!==e.object.landscapeDiv){r.x>e.leftLimit?r.x=e.leftLimit:r.x<e.rightLimit&&(r.x=e.rightLimit),r.y<e.bottomLimit?r.y=e.bottomLimit:r.y>e.topLimit&&(r.y=e.topLimit),e.object.panOffsetX=r.x,e.object.panOffsetY=r.y,e.object.landscapeDiv.style.left=e.object.baseLeft+r.x+"px",e.object.landscapeDiv.style.top=e.object.baseTop+r.y+"px";for(let t=0,n=e.linkObjectsBottom.length;t<n;t++){const n=e.linkObjectsBottom[t];n.panOffsetX=r.x,n.landscapeDiv.style.left=n.baseLeft+r.x+"px"}for(let t=0,n=e.linkObjectsBottomStatic.length;t<n;t++)e.linkObjectsBottomStatic[t].traverse((function(t){t.isBillboardText&&(t.panOffsetX=-r.x,t.moveText())}));for(let t=0,n=e.linkObjectsTop.length;t<n;t++){const n=e.linkObjectsTop[t];n.panOffsetX=r.x,n.landscapeDiv.style.left=n.baseLeft+r.x+"px"}for(let t=0,n=e.linkObjectsTopStatic.length;t<n;t++)e.linkObjectsTopStatic[t].traverse((function(t){t.isBillboardText&&(t.panOffsetX=-r.x,t.moveText())}));for(let t=0,n=e.linkObjectsLeft.length;t<n;t++){const n=e.linkObjectsLeft[t];n.panOffsetY=r.y,n.landscapeDiv.style.top=n.baseTop+r.y+"px"}for(let t=0,n=e.linkObjectsLeftStatic.length;t<n;t++)e.linkObjectsLeftStatic[t].traverse((function(t){t.isBillboardText&&(t.panOffsetY=-r.y,t.moveText())}));for(let t=0,n=e.linkObjectsRight.length;t<n;t++){const n=e.linkObjectsRight[t];n.panOffsetY=r.y,n.landscapeDiv.style.top=n.baseTop+r.y+"px"}for(let t=0,n=e.linkObjectsRightStatic.length;t<n;t++)e.linkObjectsRightStatic[t].traverse((function(t){t.isBillboardText&&(t.panOffsetY=-r.y,t.moveText())}));t&&(uf.detail={widthZoomLevel:o.x,heightZoomLevel:o.y,panX:-r.x,panY:-r.y},e.dispatchEvent(uf)),p.set(-1,-1)}},this.restorePanOffset=function(t){p.x<0||(r.x=p.x-t.zoomOffsetLeft-Math.floor(t.centerWidth*m.x),r.y=p.y-t.zoomOffsetTop-Math.floor(t.centerHeight*m.y),e.update(!1))},this.clear=function(){this.linkObjectsBottom=[],this.linkObjectsTop=[],this.linkObjectsLeft=[],this.linkObjectsRight=[],this.linkObjectsBottomStatic=[],this.linkObjectsTopStatic=[],this.linkObjectsLeftStatic=[],this.linkObjectsRightStatic=[]},this.setWidthZoomLevel=function(t){t<100||(o.x,o.x=t,o.x>c&&(o.x=c),o.x)},this.setHeightZoomLevel=function(t){t<100||(o.y,o.y=t,o.y>c&&(o.y=c),o.y)},this.setMaximumZoomLevel=function(t){t<100||(c=t,(o.x>c||o.y>c)&&(o.x>c&&(o.x=c),o.y>c&&(o.y=c)))},this.dispose=function(){e.domElement.removeEventListener("contextmenu",D),e.domElement.removeEventListener("pointerdown",A),e.domElement.removeEventListener("pointercancel",I),e.domElement.removeEventListener("wheel",P),e.domElement.removeEventListener("pointermove",C),e.domElement.removeEventListener("pointerup",R),null!==e._domElementKeyEvents&&e._domElementKeyEvents.removeEventListener("keydown",L)};const e=this,n={NONE:-1,PAN:2,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5};let i=n.NONE;const r=new Ci,a=r.clone(),s=new Ti,o=new Ti(100,100),l=o.clone();let c=1e6;const h=new Ti,d=new Ti,u=new Ti,p=new Ti(-1,-1),m=new Ti,f=new Ti,g=new Ti,v=new Ti,_=[],y={};let x;function b(){return Math.pow(.95,e.zoomSpeed)}function S(){let t=!1;return o.x<100||o.y<100?(o.y<o.x?(o.x=100*o.x/o.y,o.y=100):(o.y=100*o.y/o.x,o.x=100),t=!0):(o.x>c||o.y>c)&&(o.y>o.x?(o.x=c*o.x/o.y,o.y=c):(o.y=c*o.y/o.x,o.x=c),t=!0),t}function M(t,e){var n;n=t,r.x+=n,function(t){r.y+=t}(e)}function w(t){o.multiplyScalar(t)}function E(t,n){if(!o.equals(s)){const i=e.domElement.getBoundingClientRect();p.x=Math.round(t-i.left),p.y=Math.round(n-i.top),p.x<e.object.windowX?p.x=e.object.windowX:p.x>e.object.windowX+e.object.windowWidth&&(p.x=e.object.windowX+e.object.windowWidth),p.y<e.object.windowTop?p.y=e.object.windowTop:p.y>e.object.windowTop+e.object.windowHeight&&(p.y=e.object.windowTop+e.object.windowHeight),m.x=(p.x-e.object.panOffsetX-e.object.zoomOffsetLeft)/e.object.centerWidth,m.y=(p.y-e.object.panOffsetY-e.object.zoomOffsetTop)/e.object.centerHeight,T()}}function T(){mf.detail={widthZoomLevel:o.x,heightZoomLevel:o.y},e.dispatchEvent(mf),s.copy(o)}function A(t){!1!==e.enabled&&(0===_.length&&(e.domElement.setPointerCapture(t.pointerId),e.domElement.addEventListener("pointermove",C),e.domElement.addEventListener("pointerup",R)),function(t){_.push(t)}(t),"touch"===t.pointerType?function(t){switch(O(t),_.length){case 1:if(e.touches.ONE===Mt){if(!1===e.enablePan)return;h.set(_[0].clientX,_[0].clientY),i=n.TOUCH_PAN}else i=n.NONE;break;case 2:if(e.touches.TWO===wt){if(!1===e.enableZoom)return;!function(){const t=_[0].clientX-_[1].clientX,e=_[0].clientY-_[1].clientY,n=Math.sqrt(t*t+e*e);f.set(0,n)}(),i=n.TOUCH_DOLLY_PAN}else i=n.NONE;break;default:i=n.NONE}i!==n.NONE&&e.dispatchEvent(ff)}(t):function(t){let r;switch(t.preventDefault(),t.button){case 0:r=e.mouseButtons.LEFT;break;case 1:r=e.mouseButtons.MIDDLE;break;case 2:r=e.mouseButtons.RIGHT;break;default:r=-1}if(r===bt.PAN){if(!1===e.enablePan)return;!function(t){h.set(t.clientX,t.clientY)}(t),i=n.PAN,e.domElement.ownerDocument.body.style.cursor="move"}else i=n.NONE;i!==n.NONE&&e.dispatchEvent(ff)}(t))}function C(t){!1!==e.enabled&&("touch"===t.pointerType?function(t){switch(O(t),i){case n.TOUCH_PAN:if(!1===e.enablePan)return;!function(t){d.set(t.clientX,t.clientY),u.subVectors(d,h).multiplyScalar(e.panSpeed),M(u.x,u.y),h.copy(d)}(t),e.update();break;case n.TOUCH_DOLLY_PAN:if(!1===e.enableZoom)return;!function(t){clearTimeout(x);const n=function(t){const e=t.pointerId===_[0].pointerId?_[1]:_[0];return y[e.pointerId]}(t),i=t.clientX-n.x,r=t.clientY-n.y,a=Math.sqrt(i*i+r*r);g.set(0,a),v.set(0,Math.pow(g.y/f.y,e.zoomSpeed)),w(v.y),f.copy(g);const s=.5*(t.clientX+n.x),o=.5*(t.clientY+n.y);S()?E(s,o):x=setTimeout(E,300,s,o)}(t);break;default:i=n.NONE}}(t):function(t){if(!1!==e.enabled&&(t.preventDefault(),i===n.PAN)){if(!1===e.enablePan)return;!function(t){d.set(t.clientX,t.clientY),u.subVectors(d,h).multiplyScalar(e.panSpeed),M(u.x,u.y),h.copy(d),e.update()}(t)}}(t))}function R(t){N(t),0===_.length&&(e.domElement.releasePointerCapture(t.pointerId),e.domElement.removeEventListener("pointermove",C),e.domElement.removeEventListener("pointerup",R)),e.domElement.ownerDocument.body.style.cursor="default",e.dispatchEvent(gf),i=n.NONE}function I(t){N(t)}function P(t){!1!==e.enabled&&!1!==e.enableZoom&&i===n.NONE&&(t.preventDefault(),e.dispatchEvent(ff),function(t){var n;clearTimeout(x),t.deltaY<0?(n=b(),o.divideScalar(n)):t.deltaY>0&&w(b());const i=S();pf.detail={widthZoomLevel:o.x,heightZoomLevel:o.y,clientX:t.clientX,clientY:t.clientY},e.dispatchEvent(pf),i?E(t.clientX,t.clientY):x=setTimeout(E,300,t.clientX,t.clientY)}(t),e.dispatchEvent(gf))}function L(t){!1!==e.enabled&&!1!==e.enablePan&&function(t){let n=!1;switch(t.code){case e.keys.UP:M(0,e.keyPanSpeed),n=!0;break;case e.keys.BOTTOM:M(0,-e.keyPanSpeed),n=!0;break;case e.keys.LEFT:M(e.keyPanSpeed,0),n=!0;break;case e.keys.RIGHT:M(-e.keyPanSpeed,0),n=!0}n&&(t.preventDefault(),e.update())}(t)}function D(t){!1!==e.enabled&&t.preventDefault()}function N(t){delete y[t.pointerId];for(let e=0;e<_.length;e++)if(_[e].pointerId==t.pointerId)return void _.splice(e,1)}function O(t){let e=y[t.pointerId];void 0===e&&(e=new Ti,y[t.pointerId]=e),e.set(t.clientX,t.clientY)}e.domElement.addEventListener("contextmenu",D),e.domElement.addEventListener("pointerdown",A),e.domElement.addEventListener("pointercancel",I),e.domElement.addEventListener("wheel",P,{passive:!1}),e.listenToKeyEvents(window)}}const _f={type:"change"},yf={type:"start"},xf={type:"end"};class bf extends mi{constructor(t){super(),void 0===t&&console.warn('AVS.Three.ZoomRectangleInteractor: The first parameter "domElement" is now mandatory.'),t===document&&console.error('AVS.Three.ZoomRectangleInteractor: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.isZoomRectangleInteractor=!0,this.domElement=t,this.domElement.style.touchAction="none",this.object=new Er,this.scene=null,this.enabled=!0,this.position=this.object.position.clone(),this.scale=this.object.scale.clone(),this.clientOnly=!1,this.fullReset=!1,this.scale0=this.object.scale.clone(),this.position0=this.object.position.clone(),this.setObjectScene=function(t,n){switch(e.object=t,e.scene=n,this.fullReset||t.internalData.zoomRectangleFullReset?(e.scale.copy(e.object.scale),e.position.copy(e.object.position),e.scale0.copy(e.object.scale),e.position0.copy(e.object.position),this.fullReset=!1):e.clientOnly&&(e.object.scale.copy(e.scale),e.object.position.copy(e.position)),t.internalData.zoomRectangleTriggers&&(s=JSON.parse(t.internalData.zoomRectangleTriggers)),i=t.internalData.zoomInMaxLimit,r=t.internalData.zoomOutMaxLimit,c=void 0!==t.internalData.zoomRectangleColor?"#"+t.internalData.zoomRectangleColor.toString(16).padStart(6,"0"):null,h=t.internalData.zoomRectangleWidth?t.internalData.zoomRectangleWidth:null,t.internalData.zoomRectanglePattern){case 0:d=[];break;case 1:d=[4,4];break;case 2:d=[1,3];break;case 3:d=[5,1,1,1];break;default:d=null}const a=document.createElement("canvas");a.style.position="absolute",a.style.width="100%",a.style.height="100%",a.id=e.scene.name+"RectCanvas",a.width=e.scene.windowWidth,a.height=e.scene.windowHeight,e.scene.windowDiv.appendChild(a),e.scene.rectCanvas=a,e.scene.rectCtx=a.getContext("2d")},this.reset=function(){e.scale.copy(e.scale0),e.position.copy(e.position0),e.object.scale.copy(e.scale0),e.object.position.copy(e.position0),e.dispatchEvent(_f),a=n.NONE},this.dispose=function(){e.domElement.removeEventListener("contextmenu",w),e.domElement.removeEventListener("pointerdown",x),e.domElement.removeEventListener("pointercancel",M),e.domElement.removeEventListener("pointermove",b),e.domElement.removeEventListener("pointerup",S)};const e=this,n={NONE:-1,ZOOM_IN:0,ZOOM_OUT:1};let i,r,a=n.NONE,s=[{buttons:1,modifiers:0,param:"ZOOM_IN"},{buttons:1,modifiers:1,param:"ZOOM_OUT"}],o=0;const l=[];let c=null,h=null,d=null;const u=new Ti,p=new Ti,m=[],f={};function g(t){return Math.max(0,Math.min(t.clientX-e.scene.windowDiv.getBoundingClientRect().left,e.scene.windowWidth))}function v(t){return Math.max(0,Math.min(t.clientY-e.scene.windowDiv.getBoundingClientRect().top,e.scene.windowHeight))}const _=function(){const t=new Ki,s=new Ki,o=new qi,l=new qi,c=new Ci,h=new qi,d=new Ci;return function(u,p,m,f){const g=e.scene.windowWidth/(p-u),v=e.scene.windowHeight/(f-m);t.multiplyMatrices(e.scene.camera.matrixWorldInverse,e.object.parent.matrixWorld),t.premultiply(e.scene.camera.projectionMatrix),o.set(0,0,0,1).applyMatrix4(t),s.copy(t).invert();let _=1;if(a===n.ZOOM_IN){if(_=v<g?v:g,void 0!==i){const t=Math.max(Math.max(e.object.scale.x,e.object.scale.y),e.object.scale.z);_*t>i&&(_=i/t)}const t=(u+p)/e.scene.windowWidth-1,n=1-(m+f)/e.scene.windowHeight;l.set(t,n,o.z/o.w,1).applyMatrix4(s),c.set(l.x/l.w,l.y/l.w,l.z/l.w),h.set(0,0,o.z/o.w,1).applyMatrix4(s),d.set(h.x/h.w,h.y/h.w,h.z/h.w),c.sub(e.object.position),d.sub(e.object.position),c.multiplyScalar(_).sub(d),e.object.position.sub(c)}else if(a===n.ZOOM_OUT){if(_=v>g?1/v:1/g,void 0!==r){const t=Math.max(Math.max(e.object.scale.x,e.object.scale.y),e.object.scale.z);_*t<1/r&&(_=1/r/t)}l.set(0,0,o.z/o.w,1).applyMatrix4(s),c.set(l.x/l.w,l.y/l.w,l.z/l.w),c.sub(e.object.position),d.copy(c),c.multiplyScalar(_).sub(d),e.object.position.sub(c)}return e.object.scale.multiplyScalar(_),!0}}();function y(t){u.set(g(t),v(t));const n=window.getComputedStyle(e.scene.rectCanvas);let i="#ff0000";const r=n.getPropertyValue("--avs-drag-rectangle-stroke-style").trim();null!==c?i=c:null!==r&&r.length>0&&(i=r),e.scene.rectCtx.strokeStyle=i;let a=1;const s=n.getPropertyValue("--avs-drag-rectangle-line-width").trim();null!==h?a=h:null!==s&&s.length>0&&(a=s),e.scene.rectCtx.lineWidth=a;let p=l;const m=n.getPropertyValue("--avs-drag-rectangle-line-dash").trim();null!==d?p=d:null!==m&&m.length>0&&(p=JSON.parse(m)),e.scene.rectCtx.setLineDash(p),o=1}function x(t){!1!==e.enabled&&(0===m.length&&(e.domElement.setPointerCapture(t.pointerId),e.domElement.addEventListener("pointermove",b),e.domElement.addEventListener("pointerup",S)),function(t){m.push(t)}(t),function(t){let i=0;i+=t.shiftKey?1:0,i+=t.ctrlKey?2:0,i+=t.metaKey?4:0;let r=0;switch(t.button){case 0:r=1;break;case 1:r=2;break;case 2:r=4}for(let o=0,l=s.length;o<l;o++)if(i===s[o].modifiers&&r&s[o].buttons){switch(s[o].param){case 1:case"ZOOM_IN":y(t),a=n.ZOOM_IN,e.domElement.ownerDocument.body.style.cursor="zoom-in";break;case 2:case"ZOOM_OUT":y(t),a=n.ZOOM_OUT,e.domElement.ownerDocument.body.style.cursor="zoom-out";break;default:a=n.NONE}a!==n.NONE&&e.dispatchEvent(yf);break}}(t))}function b(t){!1!==e.enabled&&function(t){!1!==e.enabled&&function(t){if(o<1)return;if(p.set(g(t),v(t)),e.scene.rectCtx.clearRect(0,0,e.scene.windowWidth,e.scene.windowHeight),1==o){const t=Math.abs(u.x-p.x),e=Math.abs(u.y-p.y);if(t*t+e*e<25)return;o=2}const n=Math.min(u.x,p.x),i=Math.max(u.x,p.x),r=Math.min(u.y,p.y),a=Math.max(u.y,p.y);e.scene.rectCtx.strokeRect(n+.5,r+.5,i-n,a-r)}(t)}(t)}function S(t){!1!==e.enabled&&(function(t){(function(t){if(o<2)return;p.set(g(t),v(t)),e.scene.rectCtx.clearRect(0,0,e.scene.windowWidth,e.scene.windowHeight);const n=Math.min(u.x,p.x),i=Math.max(u.x,p.x),r=Math.min(u.y,p.y),a=Math.max(u.y,p.y);_(n,i,r,a)&&(e.scale.copy(e.object.scale),e.position.copy(e.object.position),e.dispatchEvent(_f)),o=0})(t),e.domElement.ownerDocument.body.style.cursor="default",e.dispatchEvent(xf),a=n.NONE}(t),E(t),0===m.length&&(e.domElement.releasePointerCapture(t.pointerId),e.domElement.removeEventListener("pointermove",b),e.domElement.removeEventListener("pointerup",S)))}function M(t){E(t)}function w(t){!1!==e.enabled&&t.preventDefault()}function E(t){delete f[t.pointerId];for(let e=0;e<m.length;e++)if(m[e].pointerId==t.pointerId)return void m.splice(e,1)}e.domElement.addEventListener("contextmenu",w),e.domElement.addEventListener("pointerdown",x),e.domElement.addEventListener("pointercancel",M)}}const Sf={type:"change"},Mf={type:"start"},wf={type:"end"};class Ef extends mi{constructor(t){super(),this.hasStyleAnimations=!1,this.hasObjectAnimations=!1,this.createAnimationLibrary(),this.animating=0,this.mixers=[]}createAnimationLibrary(){const t=[0,2],e=new Yc(".material.opacityFactor",t,[0,1]),n=new Xc(".material.transparent",t,[!0,!1]);this.fadeInClip=new Qc("fade-in",-1,[e,n]),this.fadeInClip.setOnChildren=!0;const i=new Yc(".material.opacityFactor",t,[1,0]),r=new Xc(".material.transparent",t,[!0,!0]);this.fadeOutClip=new Qc("fade-out",-1,[i,r]),this.fadeOutClip.setOnChildren=!0;const a=new Yc(".scaleFactorX",t,[0,1]);this.growXClip=new Qc("grow-x",-1,[a]);const s=new Yc(".scaleFactorY",t,[0,1]);this.growYClip=new Qc("grow-y",-1,[s]);const o=new Yc(".scaleFactorZ",t,[0,1]);this.growZClip=new Qc("grow-z",-1,[o]);const l=new Yc(".material.glyphScaleFactorX",t,[0,1]);this.growXGlyphClip=new Qc("grow-x-glyph",-1,[l]),this.growXGlyphClip.setOnChildren=!0;const c=new Yc(".material.glyphScaleFactorY",t,[0,1]);this.growYGlyphClip=new Qc("grow-y-glyph",-1,[c]),this.growYGlyphClip.setOnChildren=!0;const h=new Yc(".material.glyphScaleFactorZ",t,[0,1]);this.growZGlyphClip=new Qc("grow-z-glyph",-1,[h]),this.growZGlyphClip.setOnChildren=!0;const d=new Xc(".visible",t,[!1,!0]);this.enterAfterClip=new Qc("enter-after",-1,[d]),this.enterAfterClip.setOnChildren=!0}setStyleMap(t){if(this.hasStyleAnimations=!1,void 0===t)return;const e=["scene","sceneTitle","chart","chartTitle","axis","legend","legendTitle","glyph","transform"];this.styleAnimationClips={},this.transformAnimations=void 0;for(let n=0,i=e.length;n<i;n++){const i=e[n];void 0!==t[i]&&(i.startsWith("transform")?this.transformAnimations=JSON.parse(t[i]):this.styleAnimationClips[i]=this.fillStyleClipsArray(t[i].split(","),"glyph"===i))}}fillStyleClipsArray(t,e){const n=[];for(let i=0,r=t.length;i<r;i++){const r=t[i].trim();"fade-in"===r?(n.push(this.fadeInClip),this.hasStyleAnimations=!0):"fade-out"===r?(n.push(this.fadeOutClip),this.hasStyleAnimations=!0):"grow-x"===r?(n.push(e?this.growXGlyphClip:this.growXClip),this.hasStyleAnimations=!0):"grow-y"===r?(n.push(e?this.growYGlyphClip:this.growYClip),this.hasStyleAnimations=!0):"grow-z"===r?(n.push(e?this.growZGlyphClip:this.growZClip),this.hasStyleAnimations=!0):"enter-after"===r&&(n.push(this.enterAfterClip),this.hasStyleAnimations=!0)}return n}fillObjectClipsArray(t,e){const n=[];return!!(1&t)&&(n.push(this.fadeInClip),this.hasObjectAnimations=!0),!!(2&t)&&(n.push(this.fadeOutClip),this.hasObjectAnimations=!0),!!(4&t)&&(n.push(e?this.growXGlyphClip:this.growXClip),this.hasObjectAnimations=!0),!!(8&t)&&(n.push(e?this.growYGlyphClip:this.growYClip),this.hasObjectAnimations=!0),!!(16&t)&&(n.push(e?this.growZGlyphClip:this.growZClip),this.hasObjectAnimations=!0),!!(32&t)&&(n.push(this.enterAfterClip),this.hasObjectAnimations=!0),n}hasAnimations(){return this.hasStyleAnimations||this.hasObjectAnimations||this.transformAnimations}clear(){this.mixers=[],this.hasObjectAnimations=!1}attach(t){const e=this,n=this.createMixers.bind(this);this.createMixers(t,this.styleAnimationClips.scene),t.traverse((function(t){if(t.internalData.animations){const i=e.fillObjectClipsArray(t.internalData.animations,"GLYPH"===t.internalData.visualizationGroup);n(t,i)}if(t.internalData.attachTransformInteractor&&e.transformAnimations){const i=new Ci,r=new Ai,a=new lr,s=new Ci;t.matrix.decompose(i,r,s);const o=[],l=[],c=[],h=[];let d=!1;for(let t=0,n=e.transformAnimations.length;t<n;t++){const n=e.transformAnimations[t];void 0===n.time&&(console.error("AVS.Three.Animator: Missing time value from transform animation index "+t),d=!0),o.push(n.time/1e3),void 0!==n.position&&i.set(n.position[0],n.position[1],n.position[2]),l.push(i.x),l.push(i.y),l.push(i.z),void 0!==n.scale&&s.set(n.scale/100,n.scale/100,n.scale/100),h.push(s.x),h.push(s.y),h.push(s.z),void 0!==n.rotation&&(a.set(n.rotation[0]*Math.PI/180,n.rotation[1]*Math.PI/180,n.rotation[2]*Math.PI/180,n.rotation[3]),r.setFromEuler(a)),c.push(r.x),c.push(r.y),c.push(r.z),c.push(r.w)}if(!d){const e=new Kc(".position",o,l),i=new $c(".quaternion",o,c),r=new Kc(".scale",o,h),a=new Qc("transform",-1,[e,i,r]);n(t,[a])}}"SCENE_TITLE"===t.internalData.visualizationGroup&&n(t,e.styleAnimationClips.sceneTitle),"CHART"===t.internalData.visualizationGroup&&n(t,e.styleAnimationClips.chart),"CHART_TITLE"===t.internalData.visualizationGroup&&n(t,e.styleAnimationClips.chartTitle),"AXIS"===t.internalData.visualizationGroup&&n(t,e.styleAnimationClips.axis),"LEGEND"===t.internalData.visualizationGroup&&n(t,e.styleAnimationClips.legend),"LEGEND_TITLE"===t.internalData.visualizationGroup&&n(t,e.styleAnimationClips.legendTitle),"GLYPH"===t.internalData.visualizationGroup&&n(t,e.styleAnimationClips.glyph)}))}createMixers(t,e){if(void 0!==e)for(let n=0,i=e.length;n<i;n++){let i;if(e[n].setOnChildren?t.traverse((function(t){t.material&&(void 0===i&&(i=new rd),i.add(t))})):i=t,void 0!==i){const t=new od(i);t.clip=e[n],this.mixers.push(t)}}}play(){this.mixers.length<=0&&(this.dispatchEvent(Mf),this.dispatchEvent(Sf),this.dispatchEvent(wf)),this.animating=0,this.finishedFunc=this.animationFinished.bind(this);for(let t=0,e=this.mixers.length;t<e;t++){const e=this.mixers[t];e.addEventListener("finished",this.finishedFunc);const n=e.clipAction(e.clip);e.action=n,n.repetitions=1,n.clampWhenFinished=!0,n.play(),this.animating++}this.dispatchEvent(Mf),this.timer=new Yh,this.animate()}animationFinished(t){t.target.removeEventListener("finished",this.finishedFunc),this.animating--}animate(){if(this.animating<=0)return void this.dispatchEvent(wf);requestAnimationFrame(this.animate.bind(this)),this.timer.update();const t=this.timer.getDelta();for(let e=0,n=this.mixers.length;e<n;e++)this.mixers[e].action.isRunning()&&this.mixers[e].update(t);this.dispatchEvent(Sf)}}
|
|
121
121
|
/**
|
|
122
122
|
* @license
|
|
123
|
-
* Copyright 2018 Advanced Visual Systems Inc.
|
|
123
|
+
* Copyright 2018-2026 Advanced Visual Systems Inc.
|
|
124
124
|
*
|
|
125
125
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
126
126
|
* you may not use this file except in compliance with the License.
|
|
@@ -136,10 +136,10 @@ var om=0,lm=1,cm=0,hm=1,dm=1,um=2,pm=3,mm=4;const fm=new Ai;class gm extends Er{
|
|
|
136
136
|
*
|
|
137
137
|
* This product includes software developed at
|
|
138
138
|
* Advanced Visual Systems Inc. (http://www.avs.com)
|
|
139
|
-
*/const
|
|
139
|
+
*/const Tf='<svg xmlns="http://www.w3.org/2000/svg" height="46px" viewBox="0 0 12.170833 12.170834" width="46px"><path d="M 7.2486073,9.9076469 H 5.2849946 L 8.4704866,6.123394 6.2360101,3.4130208 7.1885217,2.271515 10.424524,6.122616 Z M 6.0677825,8.6164059 3.9785527,6.1181874 6.0843599,3.5947138 8.1676051,6.1217782 Z M 1.7215741,6.1177086 6.5503222,0.33124232 H 8.5047186 L 3.6754319,6.1184268 5.9155339,8.7972611 4.958833,9.9337997 Z M 7.3399924,2.0900614 9.0019205,0.09856041 H 6.441462 L 1.4175556,6.1188457 4.7994028,10.140329 H 7.3569887 L 10.728423,6.122616 Z" style="display:inline;fill:#2e8cbd;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.0598462" id="path22" /><path d="M 7.2486073,9.9076469 H 5.2849946 L 8.4704866,6.123394 6.2360101,3.4130208 7.1885217,2.271515 10.424524,6.122616 Z M 6.0677825,8.6164059 3.9785527,6.1181874 6.0843599,3.5947138 8.1676051,6.1217782 Z M 1.7215741,6.1177086 6.5503222,0.33124232 H 8.5047186 L 3.6754319,6.1184268 5.9155339,8.7972611 4.958833,9.9337997 Z M 7.3399924,2.0900614 9.0019205,0.09856041 H 6.441462 L 1.4175556,6.1188457 4.7994028,10.140329 H 7.3569887 L 10.728423,6.122616 Z" style="fill:none;stroke:#2e8cbd;stroke-width:0.179539;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1" id="path26" /><g id="g78" class="spinnerBackground"><path d="M 5.0916012,7.2951741 C 4.5581951,6.6568 4.1217726,6.1273448 4.1217726,6.1186069 c 0,-0.022412 1.9511841,-2.3603376 1.9654853,-2.3550616 0.00645,0.00237 0.4481639,0.5337638 0.981573,1.1808488 L 8.0386633,6.1209126 7.7794202,6.4289493 C 7.6368389,6.5983701 7.1955674,7.1235887 6.7988191,7.5961017 6.4020707,8.0686158 6.0738528,8.4553619 6.0694438,8.4555369 6.0650388,8.4557059 5.6250056,7.9335497 5.0916012,7.2951741 Z" id="path39" /><path d="M 5.5264617,9.7764122 C 5.5385577,9.7616559 6.2319291,8.9374956 7.0672769,7.9449584 7.9026265,6.9524246 8.5861155,6.1329723 8.5861409,6.1239554 8.5861681,6.1149485 8.0879549,5.5032753 7.4789997,4.7647 6.8700453,4.0261248 6.3741103,3.4156149 6.3769213,3.4080117 6.3797713,3.4004117 6.562373,3.1774787 6.7827896,2.9126121 7.164399,2.4540426 7.1848936,2.4323657 7.2117806,2.4588741 7.2273026,2.4741751 7.9274525,3.3048587 8.767655,4.3048177 L 10.295296,6.1229243 9.4136171,7.1736012 C 8.9286921,7.751474 8.2336861,8.5795488 7.8691565,9.0137659 L 7.2063776,9.8032561 H 6.3554188 c -0.7939025,0 -0.8494825,-0.00179 -0.8289571,-0.026839 z" id="path41" /><path d="M 3.4382986,7.9881037 C 2.6063322,7.0074024 1.9089456,6.1852746 1.8885531,6.1611518 L 1.8514763,6.1172937 4.2262773,3.2714352 6.6010789,0.42557499 H 7.4490822 8.2970851 L 7.0763447,1.8883334 c -3.0218884,3.6209928 -3.5158893,4.2139972 -3.519859,4.2252855 -0.00231,0.00662 0.4954141,0.6094855 1.1060858,1.3397178 0.6106728,0.7302338 1.1103133,1.3348316 1.1103133,1.3435515 0,0.017734 -0.7956667,0.9718373 -0.8117152,0.9733472 -0.00562,5.108e-4 -0.6909038,-0.80143 -1.522871,-1.7821306 z" id="path43" /></g></svg>';
|
|
140
140
|
/**
|
|
141
141
|
* @license
|
|
142
|
-
* Copyright 2026 Advanced Visual Systems Inc.
|
|
142
|
+
* Copyright 2018-2026 Advanced Visual Systems Inc.
|
|
143
143
|
*
|
|
144
144
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
145
145
|
* you may not use this file except in compliance with the License.
|
|
@@ -156,28 +156,7 @@ var om=0,lm=1,cm=0,hm=1,dm=1,um=2,pm=3,mm=4;const fm=new Ai;class gm extends Er{
|
|
|
156
156
|
* This product includes software developed at
|
|
157
157
|
* Advanced Visual Systems Inc. (http://www.avs.com)
|
|
158
158
|
*/
|
|
159
|
-
var
|
|
160
|
-
/**
|
|
161
|
-
* @license
|
|
162
|
-
* Copyright 2018 Advanced Visual Systems Inc.
|
|
163
|
-
*
|
|
164
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
165
|
-
* you may not use this file except in compliance with the License.
|
|
166
|
-
* You may obtain a copy of the License at
|
|
167
|
-
*
|
|
168
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
169
|
-
*
|
|
170
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
171
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
172
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
173
|
-
* See the License for the specific language governing permissions and
|
|
174
|
-
* limitations under the License.
|
|
175
|
-
*
|
|
176
|
-
* This product includes software developed at
|
|
177
|
-
* Advanced Visual Systems Inc. (http://www.avs.com)
|
|
178
|
-
*/
|
|
179
|
-
var Rf=function(t,e,n,i){var r,a=arguments.length,s=a<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,i);else for(var o=t.length-1;o>=0;o--)(r=t[o])&&(s=(a<3?r(s):a>3?r(e,n,s):r(e,n))||s);return a>3&&s&&Object.defineProperty(e,n,s),s};const If=new ResizeObserver(((t,e)=>{t.forEach((t=>{t.target._onResize(t.contentRect)}))}));t.AvsGoDataViz=class extends(e(st)){render(){return V`
|
|
180
|
-
<style>
|
|
159
|
+
var Af=function(t,e,n,i){var r,a=arguments.length,s=a<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,i);else for(var o=t.length-1;o>=0;o--)(r=t[o])&&(s=(a<3?r(s):a>3?r(e,n,s):r(e,n))||s);return a>3&&s&&Object.defineProperty(e,n,s),s};const Cf=new ResizeObserver(((t,e)=>{t.forEach((t=>{t.target._onResize(t.contentRect)}))}));t.AvsGoDataViz=class extends(e(ot)){static{this.styles=o`
|
|
181
160
|
:host {
|
|
182
161
|
display:block;
|
|
183
162
|
width:100%;
|
|
@@ -325,28 +304,28 @@ var Rf=function(t,e,n,i){var r,a=arguments.length,s=a<3?e:null===i?i=Object.getO
|
|
|
325
304
|
@-moz-keyframes spin { 100% { -moz-transform: rotate(360deg); } }
|
|
326
305
|
@-webkit-keyframes spin { 100% { -webkit-transform: rotate(360deg); } }
|
|
327
306
|
@keyframes spin { 100% { -webkit-transform: rotate(360deg); transform:rotate(360deg); } }
|
|
328
|
-
|
|
307
|
+
`}render(){return H`
|
|
329
308
|
<div id="dataVizDiv"></div>
|
|
330
309
|
<div id="motionCapture">
|
|
331
310
|
<div style="display: flex; justify-content: center" id="motionCaptureTitle">Motion Capture</div>
|
|
332
311
|
<div>
|
|
333
|
-
<a class="btn disabled" id="motionCapturePlay" data-tooltip="Play motion capture" @click="${this.runAnimation}" @pointermove="${this._handlePointerEnterMotionCaptureControl}" @pointerout="${this._handlePointerLeaveMotionCaptureControl}">${
|
|
312
|
+
<a class="btn disabled" id="motionCapturePlay" data-tooltip="Play motion capture" @click="${this.runAnimation}" @pointermove="${this._handlePointerEnterMotionCaptureControl}" @pointerout="${this._handlePointerLeaveMotionCaptureControl}">${yt('<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M10 8.64L15.27 12 10 15.36V8.64M8 5v14l11-7L8 5z"/></svg>')}</a>
|
|
334
313
|
<a class="btn" id="motionCaptureSnapshot" data-tooltip="Take snapshot" @click="${this._handleMotionCaptureSnapshot}" @pointermove="${this._handlePointerEnterMotionCaptureControl}" @pointerout="${this._handlePointerLeaveMotionCaptureControl}">
|
|
335
|
-
<div id="motionCaptureSnapshotIcon">${
|
|
314
|
+
<div id="motionCaptureSnapshotIcon">${yt('<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M20 4h-3.17L15 2H9L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 14H4V6h4.05l1.83-2h4.24l1.83 2H20v12zM12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5zm0 8c-1.65 0-3-1.35-3-3s1.35-3 3-3 3 1.35 3 3-1.35 3-3 3z"/></svg>')}</div>
|
|
336
315
|
<div id="motionCaptureSnapshotLabel">0</div>
|
|
337
316
|
</a>
|
|
338
317
|
<div class="btn disabled" id="motionCaptureDelay" data-tooltip="Frame delay (seconds)" @pointermove="${this._handlePointerEnterMotionCaptureControl}" @pointerout="${this._handlePointerLeaveMotionCaptureControl}">
|
|
339
|
-
<div id="motionCaptureDelayIcon">${
|
|
318
|
+
<div id="motionCaptureDelayIcon">${yt('<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M16.24 7.75c-1.17-1.17-2.7-1.76-4.24-1.76v6l-4.24 4.24c2.34 2.34 6.14 2.34 8.49 0 2.34-2.34 2.34-6.14-.01-8.48zM12 1.99c-5.52 0-10 4.48-10 10s4.48 10 10 10 10-4.48 10-10-4.48-10-10-10zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg>')}</div>
|
|
340
319
|
<div id="motionCaptureDelayLabel">0</div>
|
|
341
320
|
<div id="motionCaptureDelayWheel">
|
|
342
321
|
<a id="motionCaptureDelayIncrease" @click="${this._handleMotionCaptureDelayIncrease}">+</a>
|
|
343
322
|
<a id="motionCaptureDelayDecrease" @click="${this._handleMotionCaptureDelayDecrease}">-</a>
|
|
344
323
|
</div>
|
|
345
324
|
</div>
|
|
346
|
-
<a class="btn" id="motionCaptureReset" data-tooltip="Reset transform" @click="${this.resetTransform}" @pointermove="${this._handlePointerEnterMotionCaptureControl}" @pointerout="${this._handlePointerLeaveMotionCaptureControl}">${
|
|
347
|
-
<a class="btn disabled" id="motionCaptureClear" data-tooltip="Clear motion capture frames" @click="${this._handleMotionCaptureClear}" @pointermove="${this._handlePointerEnterMotionCaptureControl}" @pointerout="${this._handlePointerLeaveMotionCaptureControl}">${
|
|
348
|
-
<a class="btn disabled" id="motionCaptureCopyData" data-tooltip="Copy motion capture data to clipboard" @click="${this._handleMotionCaptureCopyData}" @pointermove="${this._handlePointerEnterMotionCaptureControl}" @pointerout="${this._handlePointerLeaveMotionCaptureControl}">${
|
|
349
|
-
<a class="btn disabled" id="motionCaptureCopyUrl" data-tooltip="Copy motion capture URL to clipboard" @click="${this._handleMotionCaptureCopyUrl}" @pointermove="${this._handlePointerEnterMotionCaptureControl}" @pointerout="${this._handlePointerLeaveMotionCaptureControl}">${
|
|
325
|
+
<a class="btn" id="motionCaptureReset" data-tooltip="Reset transform" @click="${this.resetTransform}" @pointermove="${this._handlePointerEnterMotionCaptureControl}" @pointerout="${this._handlePointerLeaveMotionCaptureControl}">${yt('<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M12 5.69l5 4.5V18h-2v-6H9v6H7v-7.81l5-4.5M12 3L2 12h3v8h6v-6h2v6h6v-8h3L12 3z"/></svg>')}</a>
|
|
326
|
+
<a class="btn disabled" id="motionCaptureClear" data-tooltip="Clear motion capture frames" @click="${this._handleMotionCaptureClear}" @pointermove="${this._handlePointerEnterMotionCaptureControl}" @pointerout="${this._handlePointerLeaveMotionCaptureControl}">${yt('<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M16 9v10H8V9h8m-1.5-6h-5l-1 1H5v2h14V4h-3.5l-1-1zM18 7H6v12c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7z"/></svg>')}</a>
|
|
327
|
+
<a class="btn disabled" id="motionCaptureCopyData" data-tooltip="Copy motion capture data to clipboard" @click="${this._handleMotionCaptureCopyData}" @pointermove="${this._handlePointerEnterMotionCaptureControl}" @pointerout="${this._handlePointerLeaveMotionCaptureControl}">${yt('<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg>')}</a>
|
|
328
|
+
<a class="btn disabled" id="motionCaptureCopyUrl" data-tooltip="Copy motion capture URL to clipboard" @click="${this._handleMotionCaptureCopyUrl}" @pointermove="${this._handlePointerEnterMotionCaptureControl}" @pointerout="${this._handlePointerLeaveMotionCaptureControl}">${yt('<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M17 7h-4v2h4c1.65 0 3 1.35 3 3s-1.35 3-3 3h-4v2h4c2.76 0 5-2.24 5-5s-2.24-5-5-5zm-6 8H7c-1.65 0-3-1.35-3-3s1.35-3 3-3h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-2zm-3-4h8v2H8z"/></svg>')}</a>
|
|
350
329
|
</div>
|
|
351
330
|
</div>
|
|
352
331
|
<div id="motionCaptureTooltip"></div>
|
|
@@ -356,10 +335,10 @@ var Rf=function(t,e,n,i){var r,a=arguments.length,s=a<3?e:null===i?i=Object.getO
|
|
|
356
335
|
<div id="spinner"></div>
|
|
357
336
|
</div>
|
|
358
337
|
<div id="tooltip"></div>
|
|
359
|
-
`}_rectangleStyle(){this.rectCtx.setLineDash([3]),this.rectCtx.strokeStyle="#ff0000"}_assembleModel(t){if(!this.sceneName)return void this._dispatchErrorEvent("'scene-name' property must be set to the name of the scene registered in the library map on the AVS/Go server.");if(!this.width||!this.height)return;const e={sceneProperties:{name:this.sceneName}};if(this.sceneUserProperties){let t;try{t=JSON.parse(this.sceneUserProperties)}catch(t){return void this._dispatchErrorEvent("Can't parse 'scene-user-properties'. "+t.message)}e.sceneProperties.userProperties=t}const n={width:this.width,height:this.height,name:this.rendererName,type:this.renderer};if(this.rendererUserProperties){let t;try{t=JSON.parse(this.rendererUserProperties)}catch(t){return void this._dispatchErrorEvent("Can't parse 'renderer-user-properties'. "+t.message)}n.userProperties=t}e.rendererProperties=n,this.transformInteractor&&(this.transformMatrix=this.transformInteractor.object.matrix.elements.slice()),this.transformMatrix&&!this.transformClientOnly&&(n.transformMatrix=this.transformMatrix),t&&(this.transformClientOnly&&this.transformInteractor?this.transformInteractor.fullReset=t:n.fullReset=!0),this.panEnable&&(n.panProperties={widthZoomLevel:Math.min(this.panWidthZoomLevel,this.panMaximumZoomLevel),heightZoomLevel:Math.min(this.panHeightZoomLevel,this.panMaximumZoomLevel)}),n.themeName=this.themeName;var i=window.getComputedStyle(this,null),r=i.getPropertyValue("background-color").trim(),a=i.getPropertyValue("color").trim(),s=i.getPropertyValue("font-family").trim().replace(/['"]+/g,"");if(n.cssProperties={sceneBackgroundType:"Solid",sceneBackgroundColor:r,sceneLineColor:a,sceneTextColor:a,sceneFontFamily:s,sceneSurfaceColor:a},this._applyCustomCssProperties(n.cssProperties,i,{sceneBackgroundType:"--avs-scene-background-type",sceneBackgroundColor:"--avs-scene-background-color",sceneBackgroundStartColor:"--avs-scene-background-start-color",sceneBackgroundEndColor:"--avs-scene-background-end-color",sceneBackgroundGradientStyle:"--avs-scene-background-gradient-style",sceneBackgroundGradientInterpolation:"--avs-scene-background-gradient-interpolation",sceneBackgroundGradientColorRepeat:"--avs-scene-background-gradient-color-repeat",sceneHighlightColor:"--avs-scene-highlight-color",sceneSurfaceColor:"--avs-scene-surface-color",scenePointColor:"--avs-scene-point-color",sceneLineColor:"--avs-scene-line-color",sceneLineWidth:"--avs-scene-line-width",sceneTextColor:"--avs-scene-text-color",sceneTextRotation:"--avs-scene-text-rotation",sceneFontFamily:"--avs-scene-font-family",sceneFontStyle:"--avs-scene-font-style",sceneFontWeight:"--avs-scene-font-weight",sceneFontSize:"--avs-scene-font-size",sceneTitleTextColor:"--avs-scene-title-text-color",sceneTitleTextRotation:"--avs-scene-title-text-rotation",sceneTitleFontFamily:"--avs-scene-title-font-family",sceneTitleFontStyle:"--avs-scene-title-font-style",sceneTitleFontWeight:"--avs-scene-title-font-weight",sceneTitleFontSize:"--avs-scene-title-font-size",chartBackgroundType:"--avs-chart-background-type",chartBackgroundColor:"--avs-chart-background-color",chartBackgroundStartColor:"--avs-chart-background-start-color",chartBackgroundEndColor:"--avs-chart-background-end-color",chartBackgroundGradientStyle:"--avs-chart-background-gradient-style",chartBackgroundGradientInterpolation:"--avs-chart-background-gradient-interpolation",chartBackgroundGradientColorRepeat:"--avs-chart-background-gradient-color-repeat",chartHighlightColor:"--avs-chart-highlight-color",chartSurfaceColor:"--avs-chart-surface-color",chartPointColor:"--avs-chart-point-color",chartLineColor:"--avs-chart-line-color",chartLineWidth:"--avs-chart-line-width",chartLinePattern:"--avs-chart-line-pattern",chartTextColor:"--avs-chart-text-color",chartTextRotation:"--avs-chart-text-rotation",chartFontFamily:"--avs-chart-font-family",chartFontStyle:"--avs-chart-font-style",chartFontWeight:"--avs-chart-font-weight",chartFontSize:"--avs-chart-font-size",chartTitleTextColor:"--avs-chart-title-text-color",chartTitleTextRotation:"--avs-chart-title-text-rotation",chartTitleFontFamily:"--avs-chart-title-font-family",chartTitleFontStyle:"--avs-chart-title-font-style",chartTitleFontWeight:"--avs-chart-title-font-weight",chartTitleFontSize:"--avs-chart-title-font-size",axisLineColor:"--avs-axis-line-color",axisLineWidth:"--avs-axis-line-width",axisTextColor:"--avs-axis-text-color",axisTextRotation:"--avs-axis-text-rotation",axisFontFamily:"--avs-axis-font-family",axisFontStyle:"--avs-axis-font-style",axisFontWeight:"--avs-axis-font-weight",axisFontSize:"--avs-axis-font-size",axisAxleColor:"--avs-axis-axle-color",axisAxleWidth:"--avs-axis-axle-width",axisMajorTickMarkColor:"--avs-axis-major-tick-mark-color",axisMajorTickMarkWidth:"--avs-axis-major-tick-mark-width",axisMajorTickLineColor:"--avs-axis-major-tick-line-color",axisMajorTickLineWidth:"--avs-axis-major-tick-line-width",axisMajorTickLineStyle:"--avs-axis-major-tick-line-style",axisMajorUnlabeledTickMarkColor:"--avs-axis-major-unlabeled-tick-mark-color",axisMajorUnlabeledTickMarkWidth:"--avs-axis-major-unlabeled-tick-mark-width",axisMajorUnlabeledTickLineColor:"--avs-axis-major-unlabeled-tick-line-color",axisMajorUnlabeledTickLineWidth:"--avs-axis-major-unlabeled-tick-line-width",axisMajorUnlabeledTickLineStyle:"--avs-axis-major-unlabeled-tick-line-style",axisMinorTickMarkColor:"--avs-axis-minor-tick-mark-color",axisMinorTickMarkWidth:"--avs-axis-minor-tick-mark-width",axisMinorTickLineColor:"--avs-axis-minor-tick-line-color",axisMinorTickLineWidth:"--avs-axis-minor-tick-line-width",axisMinorTickLineStyle:"--avs-axis-minor-tick-line-style",axisTitleTextColor:"--avs-axis-title-text-color",axisTitleTextRotation:"--avs-axis-title-text-rotation",axisTitleFontFamily:"--avs-axis-title-font-family",axisTitleFontStyle:"--avs-axis-title-font-style",axisTitleFontWeight:"--avs-axis-title-font-weight",axisTitleFontSize:"--avs-axis-title-font-size",axisUnitTextColor:"--avs-axis-unit-text-color",axisUnitTextRotation:"--avs-axis-unit-text-rotation",axisUnitFontFamily:"--avs-axis-unit-font-family",axisUnitFontStyle:"--avs-axis-unit-font-style",axisUnitFontWeight:"--avs-axis-unit-font-weight",axisUnitFontSize:"--avs-axis-unit-font-size",axisLabelTextColor:"--avs-axis-label-text-color",axisLabelTextRotation:"--avs-axis-label-text-rotation",axisLabelFontFamily:"--avs-axis-label-font-family",axisLabelFontStyle:"--avs-axis-label-font-style",axisLabelFontWeight:"--avs-axis-label-font-weight",axisLabelFontSize:"--avs-axis-label-font-size",legendBackgroundColor:"--avs-legend-background-color",legendTextColor:"--avs-legend-text-color",legendTextRotation:"--avs-legend-text-rotation",legendFontFamily:"--avs-legend-font-family",legendFontStyle:"--avs-legend-font-style",legendFontWeight:"--avs-legend-font-weight",legendFontSize:"--avs-legend-font-size",legendPointColor:"--avs-legend-point-color",legendTitleTextColor:"--avs-legend-title-text-color",legendTitleTextRotation:"--avs-legend-title-text-rotation",legendTitleFontFamily:"--avs-legend-title-font-family",legendTitleFontStyle:"--avs-legend-title-font-style",legendTitleFontWeight:"--avs-legend-title-font-weight",legendTitleFontSize:"--avs-legend-title-font-size"}),this.dataSourceName&&(e.dataSourceProperties={name:this.dataSourceName},this.dataSourceUserProperties)){let t;try{t=JSON.parse(this.dataSourceUserProperties)}catch(t){return void this._dispatchErrorEvent("Can't parse 'data-source-user-properties'. "+t.message)}e.dataSourceProperties.userProperties=t}return this.threeViewer&&this.streamEnable&&(n.streamProperties={chunkSizeFirst:this.streamChunkSizeFirst,chunkSize:this.streamChunkSize}),e}_applyCustomCssProperties(t,e,n){for(var i in n)if(n.hasOwnProperty(i)){var r=e.getPropertyValue(n[i]).trim();r.length>0&&(t[i]=r)}}_onResize(t){this.width=Math.round(t.width),this.height=Math.round(t.height),this.rectCanvas&&(this.rectCanvas.width=this.width,this.rectCanvas.height=this.height),!this.urlLoadJsonFile&&!this.manualUpdate&&this.resizeThreshold>0&&(!this.lowResizeWidth||this.width<this.lowResizeWidth||this.width>this.highResizeWidth||this.height<this.lowResizeHeight||this.height>this.highResizeHeight)?(this._updateResizeLimits(),this.updateViewer()):this.threeViewer&&this.threeViewer.render(!0)}_updateResizeLimits(){this.lowResizeWidth=(100-this.resizeThreshold)/100*this.width,this.highResizeWidth=(100+this.resizeThreshold)/100*this.width,this.lowResizeHeight=(100-this.resizeThreshold)/100*this.height,this.highResizeHeight=(100+this.resizeThreshold)/100*this.height}showSpinner(){var t=window.getComputedStyle(this,null).getPropertyValue("--avs-spinner").trim().replace(/['"]+/g,"");t.length>0?fetch(t).then((t=>{if(t.ok)return t.text()})).then((t=>{this.renderRoot.querySelector("#spinner").innerHTML=t})).catch((t=>{this.renderRoot.querySelector("#spinner").innerHTML=Ef})):this.renderRoot.querySelector("#spinner").innerHTML=Ef,this.renderRoot.querySelector("#spinner").style.display="block"}hideSpinner(){this.renderRoot.querySelector("#spinner").style.display="none"}startSpinner(){this.renderRoot.querySelector("#spinner").className="spin"}stopSpinner(){this.renderRoot.querySelector("#spinner").className=""}updated(t){if(!Object.values(Tf)?.includes(this.renderer))return void this._dispatchErrorEvent("'renderer' property must be 'IMAGE', 'SVG' or 'THREEJS'.");if(t.has("renderer")&&this._rendererChanged(this.renderer,t.renderer),t.has("transformEnable")&&this._transformEnableChanged(this.transformEnable,t.transformEnable),t.has("transformClientOnly")&&this._transformClientOnlyChanged(this.transformClientOnly,t.transformClientOnly),t.has("transformRotateDisable")&&this._transformRotateDisableChanged(this.transformRotateDisable,t.transformRotateDisable),t.has("transformZoomDisable")&&this._transformZoomDisableChanged(this.transformZoomDisable,t.transformZoomDisable),t.has("transformPanDisable")&&this._transformPanDisableChanged(this.transformPanDisable,t.transformPanDisable),t.has("animatedGlyphsVisible")&&this._animatedGlyphsVisibleChanged(this.animatedGlyphsVisible,t.animatedGlyphsVisible),t.has("animatedGlyphsEnable")&&this._animatedGlyphsEnableChanged(this.animatedGlyphsEnable,t.animatedGlyphsEnable),(t.has("transformTwistAngle")||t.has("transformTiltAngle")||t.has("transformScale"))&&this._transformValueChanged(),t.has("animatedGlyphsEnable")&&this._animatedGlyphsEnableChanged(this.animatedGlyphsEnable,t.animatedGlyphsEnable),t.has("zoomRectangleEnable")&&this._zoomRectangleEnableChanged(this.zoomRectangleEnable,t.zoomRectangleEnable),t.has("panEnable")&&this._panEnableChanged(this.panEnable,t.panEnable),t.has("panZoomEnable")&&this._panZoomEnableChanged(this.panZoomEnable,t.panZoomEnable),t.has("panWidthZoomLevel")&&this._panWidthZoomLevelChanged(this.panWidthZoomLevel,t.panWidthZoomLevel),t.has("panHeightZoomLevel")&&this._panHeightZoomLevelChanged(this.panHeightZoomLevel,t.panHeightZoomLevel),t.has("panMaximumZoomLevel")&&this._panMaximumZoomLevelChanged(this.panMaximumZoomLevel,t.panMaximumZoomLevel),t.has("trackEnable")&&this._trackEnableChanged(this.trackEnable,t.trackEnable),t.has("displayCanvas")&&this._displayCanvasChanged(this.displayCanvas,t.displayCanvas),t.has("motionCaptureControlsEnable")&&this._motionCaptureControlsEnableChanged(this.motionCaptureControlsEnable,t.motionCaptureControlsEnable),t.has("motionCapture")&&this._motionCaptureValueChanged(this.motionCapture,t.motionCapture),!this.url)return;let e=!1;this.manualUpdate?this.forceUpdate&&(e=!0):(this.forceUpdate||t.has("url")||t.has("renderer")||t.has("urlLoadJsonFile")||t.has("sceneName")||t.has("sceneUserProperties")||t.has("dataSourceName")||t.has("dataSourceUserProperties")||t.has("rendererName")||t.has("rendererUserProperties")||t.has("streamEnable")||this.panEnable&&t.has("panWidthZoomLevel")||this.panEnable&&t.has("panHeightZoomLevel"))&&(e=!0),e&&(this.forceUpdate=!1,this.urlLoadJsonFile?(this.chunkFile=0,this.showSpinner(),this.startSpinner(),this._httpRequest(this.url,this._handleHttpResponse.bind(this),this._handleHttpError.bind(this))):(this.model=this._assembleModel(),this.model&&(this.showSpinner(),this.startSpinner(),this._httpRequest(this.url,this._handleHttpResponse.bind(this),this._handleHttpError.bind(this),this.model))))}_handleHttpError(){this.hideSpinner()}updateViewer(){this.forceUpdate=!0,this.requestUpdate()}clear(){if(this.threeViewer)this.threeViewer.clearGeometry(),this.threeViewer.render();else if("SVG"===this.renderer)for(var t=this.svgDiv;t.firstChild;)t.removeChild(t.firstChild);else this.sceneImage.src="data:,";this.showSpinner()}_handleHttpResponse(t){if(t){if(t.selectionInfo&&this._dispatchPickEvents(t.selectionInfo),t.sceneInfo){this.dispatchEvent(new CustomEvent("avs-scene-info",{detail:t.sceneInfo}));const s=this.renderRoot.querySelector("#motionCapture"),o=this.renderRoot.querySelector("#zoomOverlay"),l=this.renderRoot.querySelector("#tooltip"),c=this.renderRoot.querySelector("#motionCaptureTooltip");if(t.sceneInfo.backgroundColor){var e=t.sceneInfo.backgroundColor.match(/[0-9.]+/gi),n=this.getInheritedBackgroundCol(this).trim().match(/[0-9.]+/gi),i=Number(e[0])*Number(e[3]),r=Number(e[1])*Number(e[3]),a=Number(e[2])*Number(e[3]);0==Number(e[3])&&(i+=n[0]*(1-Number(e[3])),r+=n[1]*(1-Number(e[3])),a+=n[2]*(1-Number(e[3]))),s.style.color="var(--avs-motion-capture-color, rgb("+i+", "+r+", "+a+"))",o.style.color="var(--avs-zoom-overlay-color, rgb("+i+","+r+","+a+"))",l.style.color="var(--avs-tooltip-color, rgb("+i+","+r+","+a+"))",c.style.color="var(--avs-tooltip-color, rgb("+i+","+r+","+a+"))"}t.sceneInfo.color&&(e=t.sceneInfo.color.match(/[0-9.]+/gi),s.style.background="var(--avs-motion-capture-background, rgba("+e[0]+","+e[1]+","+e[2]+",0.75))",o.style.background="var(--avs-zoom-overlay-background, rgba("+e[0]+","+e[1]+","+e[2]+",0.75))",l.style.background="var(--avs-tooltip-background, rgb("+e[0]+","+e[1]+","+e[2]+"))",c.style.background="var(--avs-tooltip-background, rgb("+e[0]+","+e[1]+","+e[2]+"))"),t.sceneInfo.fontFamily&&(s.style.fontFamily="var(--avs-motion-capture-font-family, "+t.sceneInfo.fontFamily+")",o.style.fontFamily="var(--avs-zoom-overlay-font-family, "+t.sceneInfo.fontFamily+")",l.style.fontFamily="var(--avs-tooltip-font-family, "+t.sceneInfo.fontFamily+")",c.style.fontFamily="var(--avs-tooltip-font-family, "+t.sceneInfo.fontFamily+")")}if(t.image)this.sceneImage.src=t.image,t.imagemap?(this.sceneImageMap.innerHTML=decodeURIComponent(t.imagemap.replace(/\+/g,"%20")),this.imageMapData=Array.from(this.sceneImageMap.querySelectorAll("area")).map((t=>({shape:t.getAttribute("shape"),coords:t.getAttribute("coords").split(",").map(Number),seriesIndex:t.getAttribute("series-index"),itemIndex:t.getAttribute("item-index"),componentInfo:t.getAttribute("component-info")})))):(this.sceneImageMap.innerHTML="",this.imageMapData=void 0),this.urlLoadJsonFile||this._dispatchSceneData(t),this._handleLoadComplete();else if(t.svg)this.svgDiv.innerHTML=decodeURIComponent(t.svg.replace(/\+/g,"%20")),this.urlLoadJsonFile||this._dispatchSceneData(t),this._handleLoadComplete();else if(t.threejs)if(this.urlLoadJsonFile||this._dispatchSceneData(t),t.threejs.chunkId){if(this.threeViewer.loadGeometryAsEvents(t.threejs,this._handleLoadComplete.bind(this)),t.threejs.moreChunks)if(this.urlLoadJsonFile){this.chunkFile++;const t=this.url.substring(0,this.url.lastIndexOf("."))||this.url,e=this.url.split(".").pop();this._httpRequest(t+"-"+this.chunkFile+"."+e,this._handleHttpResponse.bind(this),this._handleHttpError.bind(this))}else this.model.rendererProperties.streamProperties.chunkId=t.threejs.chunkId,this._httpRequest(this.url,this._handleHttpResponse.bind(this),this._handleHttpError.bind(this),this.model)}else this.threeViewer.loadGeometryAsJson(t.threejs,this._handleLoadComplete.bind(this));else this._dispatchErrorEvent("No image, SVG, or ThreeJS found in response."),this._handleLoadComplete()}}getInheritedBackgroundCol(t){var e=this.getDefaultBackground(),n=window.getComputedStyle(t).backgroundColor;return n!=e?n:t.parentElement?this.getInheritedBackgroundCol(t.parentElement):e}getDefaultBackground(){var t=document.createElement("div");document.head.appendChild(t);var e=window.getComputedStyle(t).backgroundColor;return document.head.removeChild(t),e}_handleLoadComplete(){this.hideSpinner(),this.stopSpinner(),this.dispatchEvent(new CustomEvent("avs-load-complete"))}_dispatchSceneData(t){this.dispatchEvent(new CustomEvent("avs-scene-data",{detail:t}))}_handleTap(t,e,n){const i=this._getAdjustedCoords(t,e),r={type:"TAP",x:i.x,y:i.y,level:this.tapLevel,depth:this.tapDepth,highlight:this.tapHighlightEnable,highlightColor:this.tapHighlightColor,highlightLayer:this.tapHighlightLayerEnable};this._processPick(r,this.tapProcessEventOnClient,n)}_handleTrack(t,e,n,i,r){var a=this._getAdjustedRectangleCoords(e,n,i,r);switch(t){case"start":break;case"track":this.rectCtx.clearRect(0,0,this.width,this.height),this._rectangleStyle(),this.rectCtx.strokeRect(a.left,a.top,a.right-a.left,a.bottom-a.top);break;case"end":this.rectCtx.clearRect(0,0,this.width,this.height);const t={type:"TRACK",left:a.left,right:a.right,top:a.top,bottom:a.bottom,level:this.trackLevel,depth:this.trackDepth,highlight:this.trackHighlightEnable,highlightColor:this.trackHighlightColor,highlightLayer:this.trackHighlightLayerEnable};this._processPick(t,this.trackProcessEventOnClient)}}_handlePointerDown(t){this.pointerDownX=t.clientX,this.pointerDownY=t.clientY,this.pointerDown=!0,this.tapEnable&&1&t.buttons&&(this.tapping=!0),this.trackEnable&&2&t.buttons&&(this.tracking=1)}_handlePointerMove(t){if(this.tracking>=1){if(1===this.tracking){var e=Math.abs(t.clientX-this.pointerDownX),n=Math.abs(t.clientY-this.pointerDownY);e*e+n*n>=5&&(this.tracking=2,this._handleTrack("start",t.clientX,t.clientY,t.clientX-this.pointerDownX,t.clientY-this.pointerDownY))}2===this.tracking&&this._handleTrack("track",t.clientX,t.clientY,t.clientX-this.pointerDownX,t.clientY-this.pointerDownY)}if(this.hoverEnable){var i=this._getAdjustedCoords(t.clientX,t.clientY);const e={type:"HOVER",x:i.x,y:i.y};this.pointerDown?(e.selected=[],this._dispatchPickEvents(e)):(void 0!==this.hoverLevel&&(e.level=this.hoverLevel),void 0!==this.hoverDepth&&(e.depth=this.hoverDepth),this.hoverHighlightEnable&&(e.highlight=!0),void 0!==this.hoverHighlightColor&&(e.highlightColor=this.hoverHighlightColor),this.hoverHighlightLayerEnable&&(e.highlightLayer=!0),this._processPick(e,!0,t.target))}this._resetTimer()}_handlePointerUp(t){if(this.pointerDown=!1,this.tapping){this.tapping=!1;var e=Math.abs(t.clientX-this.pointerDownX),n=Math.abs(t.clientY-this.pointerDownY);e*e+n*n<25&&this._handleTap(t.clientX,t.clientY,t.currentTarget)}this.tracking>1&&(this.tracking=0,this._handleTrack("end",t.clientX,t.clientY,t.clientX-this.pointerDownX,t.clientY-this.pointerDownY))}_getAdjustedCoords(t,e){var n=this.renderRoot.querySelector("#dataVizDiv").getBoundingClientRect(),i=Math.round(t-n.left),r=Math.round(e-n.top);return{x:Math.max(0,Math.min(i,this.width)),y:Math.max(0,Math.min(r,this.height))}}_getAdjustedRectangleCoords(t,e,n,i){var r=this.renderRoot.querySelector("#dataVizDiv").getBoundingClientRect(),a=Math.round(t-r.left),s=Math.round(e-r.top),o=Math.max(0,Math.min(a,this.width)),l=Math.max(0,Math.min(s,this.height)),c=Math.max(0,Math.min(a-n,this.width)),h=Math.max(0,Math.min(s-i,this.height));return{left:Math.min(c,o),right:Math.max(c,o),top:Math.min(h,l),bottom:Math.max(h,l)}}_processPick(t,e,n){if(e)if(this.threeViewer){this.threeViewer.setPickDepth("ALL"===t.depth?om:lm),"TRACK"===t.type?this.threeViewer.setPickRectangle(t.left,t.top,t.right,t.bottom):this.threeViewer.setPickRay(t.x,t.y),this.threeViewer.pick();var i={};i="CELL"===t.level?this.threeViewer.getPickedCells():"CELL_SET"===t.level?this.threeViewer.getPickedCellSets():this.threeViewer.getPickedSceneNodes(),t.selected=this.threeViewer.getSelectionInfo(i),this._dispatchPickEvents(t),t.highlight&&(this.threeViewer.highlightColor.set(t.highlightColor),this.threeViewer.highlightObjects(i,t.highlightLayer))}else if("SVG"===this.renderer){if(t.selected=[],"TRACK"!==t.type&&("polygon"===n.nodeName||"circle"===n.nodeName)){const e={};for(var r=null,a=n.parentElement;null!==a&&null===(r=a.getAttribute("series-index"));)a=a.parentElement;null!==r&&(e.seriesIndex=parseInt(r));var s=null;for(a=n.parentElement;null!==a&&null===(s=a.getAttribute("item-index"));)a=a.parentElement;null!==s&&(e.itemIndex=parseInt(s));var o=null;for(a=n.parentElement;null!==a&&null===(o=a.getAttribute("component-info"));)a=a.parentElement;null!==o&&(e.componentInfo=decodeURIComponent(o)),t.selected.push(e)}if(this._dispatchPickEvents(t),t.highlight){void 0===this.highlightSvg&&(this.highlightSvg=[]);for(var l=0;l<this.highlightSvg.length;l++)this.highlightSvg[l].setAttribute("fill",this.highlightSvg[l].getAttribute("saveFill"));this.highlightSvg.length=0,"TRACK"===t.type||"polygon"!==n.nodeName&&"circle"!==n.nodeName||(this.highlightSvg.push(n),n.setAttribute("saveFill",n.getAttribute("fill")),n.setAttribute("fill",t.highlightColor))}}else{if(t.selected=[],"TRACK"!==t.type&&void 0!==this.imageMapData)for(l=0;l<this.imageMapData.length;l++){var c=this.imageMapData[l];if(console.log(t.x+" "+t.y),"poly"===c.shape&&this._pointInPoly(t.x,t.y,c.coords)){const e={};null!==c.seriesIndex&&(e.seriesIndex=parseInt(c.seriesIndex)),null!==c.itemIndex&&(e.itemIndex=parseInt(c.itemIndex)),null!==c.componentInfo&&(e.componentInfo=decodeURIComponent(c.componentInfo)),t.selected.push(e)}}this._dispatchPickEvents(t)}else this.urlLoadJsonFile||(this.showSpinner(),this.url&&(this.startSpinner(),this.model=this._assembleModel(),this.model&&(this.model.rendererProperties.pickProperties=t,this._httpRequest(this.url,this._handleHttpResponse.bind(this),this._handleHttpError.bind(this),this.model))))}_pointInPoly(t,e,n){for(var i,r,a,s=n[0]-t,o=n[1]-e,l=0,c=2;c<n.length;c+=2)if(r=n[c+1]-e,o<0&&r<0||o>0&&r>0)o=r,s=n[c]-t;else{if(i=n[c]-t,r>0&&o<=0){if((a=s*r-i*o)>0)l++;else if(0===a)return!1}else if(o>0&&r<=0){if((a=s*r-i*o)<0)l++;else if(0===a)return!1}else if(0===r&&o<0){if(0===(a=s*r-i*o))return!1}else if(0===o&&r<0){if(0===(a=s*r-i*o))return!1}else if(0===o&&0===r){if(i<=0&&s>=0)return!1;if(s<=0&&i>=0)return!1}o=r,s=i}return l%2!=0}_dispatchPickEvents(t){const e={selected:t.selected};"TRACK"===t.type?(e.left=t.left,e.top=t.top,e.right=t.right,e.bottom=t.bottom,this.dispatchEvent(new CustomEvent("avs-track",{detail:e}))):(e.x=t.x,e.y=t.y,"HOVER"===t.type?this.dispatchEvent(new CustomEvent("avs-hover",{detail:e})):this.dispatchEvent(new CustomEvent("avs-tap",{detail:e})))}_resetTimer(){window.clearTimeout(this.timer),this.timer=window.setTimeout((()=>{this.dispatchEvent(new Event("avs-pointer-timeout"))}),1e3*this.pointerTimeout)}constructor(){super(),this.renderer=Tf.THREEJS,this.resizeThreshold=10,this.pointerTimeout=600,this.panWidthZoomLevel=100,this.panHeightZoomLevel=100,this.panMaximumZoomLevel=1e3,this.lowResizeWidth=this.highResizeWidth=0,this.highResizeWidth=this.highResizeHeight=0,this.motionCaptureTime=0,this.motionCaptureFrames??=[],this._resetTimer(),this._updatePixelRatio()}connectedCallback(){super.connectedCallback(),If.observe(this),this.addEventListener("pointerdown",this._handlePointerDown),this.addEventListener("pointerup",this._handlePointerUp),this.addEventListener("pointermove",this._handlePointerMove),this.addEventListener("pointerout",this._handlePointerMove);var t=this;this.addEventListener("contextmenu",(function(e){t.trackEnable&&e.preventDefault()}))}disconnectedCallback(){super.disconnectedCallback(),If.unobserve(this)}_handlePointerEnterMotionCaptureControl(t){if(!this.showMotionCaptureTooltip){var e=this._getAdjustedCoords(t.clientX,t.clientY),n=this.renderRoot.querySelector("#motionCaptureTooltip"),i=this._calcTooltipPosition(n,e.x,e.y);n.style.left=i.x+"px",n.style.top=i.y+"px",n.style.opacity="1";const r=t.currentTarget;n.innerHTML=r.dataset.tooltip??r.id,this.showMotionCaptureTooltip=!0}}_handlePointerLeaveMotionCaptureControl(){this.renderRoot.querySelector("#motionCaptureTooltip").style.opacity="0",this.showMotionCaptureTooltip=!1}_round2dp(t){return Math.round(100*(t+Number.EPSILON))/100}_handleMotionCaptureSnapshot(){const t=this._getTransformComponents();this.motionCaptureFrames.length>0&&(this.motionCaptureTime+=this.motionCaptureDelay);const e={time:1e3*this.motionCaptureTime,scale:this._round2dp(t.scale),position:[this._round2dp(t.position[0]),this._round2dp(t.position[1]),this._round2dp(t.position[2])],rotation:[this._round2dp(t.rotation[0]),this._round2dp(t.rotation[1]),this._round2dp(t.rotation[2]),t.rotation[3]]};this.motionCaptureFrames.push(e),1==this.motionCaptureFrames.length&&(this.renderRoot.querySelector("#motionCapturePlay").classList.remove("disabled"),this.renderRoot.querySelector("#motionCaptureDelay").classList.remove("disabled"),this.renderRoot.querySelector("#motionCaptureDelayLabel").innerHTML="2",this.renderRoot.querySelector("#motionCaptureClear").classList.remove("disabled"),this.renderRoot.querySelector("#motionCaptureCopyData").classList.remove("disabled"),this.renderRoot.querySelector("#motionCaptureCopyUrl").classList.remove("disabled"),this.motionCaptureDelay=2),this.renderRoot.querySelector("#motionCaptureSnapshotLabel").innerHTML=String(this.motionCaptureFrames.length)}_handleMotionCaptureDelayIncrease(){this.motionCaptureDelay++,this.motionCaptureDelay>9&&(this.motionCaptureDelay=9),this.renderRoot.querySelector("#motionCaptureDelayLabel").innerHTML=String(this.motionCaptureDelay)}_handleMotionCaptureDelayDecrease(){this.motionCaptureDelay--,this.motionCaptureDelay<1&&(this.motionCaptureDelay=1),this.renderRoot.querySelector("#motionCaptureDelayLabel").innerHTML=String(this.motionCaptureDelay)}_handleMotionCaptureCopyData(){const t=JSON.stringify(this.motionCaptureFrames);navigator.clipboard.writeText(t);const e=this.renderRoot.querySelector("#motionCaptureAlert");e.innerHTML="Motion capture URL copied to clipboard",e.style.opacity="1",setTimeout((()=>{e.style.opacity="0"}),2e3)}async _handleMotionCaptureCopyUrl(){const t=JSON.stringify(this.motionCaptureFrames),e=await this._compress(t),n=btoa(String.fromCharCode(...new Uint8Array(e))).replaceAll("/","_").replaceAll("+","-"),i=window.location.origin+window.location.pathname+"?motionCapture="+n;navigator.clipboard.writeText(i);const r=this.renderRoot.querySelector("#motionCaptureAlert");r.innerHTML="Motion capture URL copied to clipboard",r.style.opacity="1",setTimeout((()=>{r.style.opacity="0"}),2e3)}async _compress(t){const e=new Blob([t]).stream().pipeThrough(new CompressionStream("gzip")),n=[];for await(const t of e)n.push(t);return this._concatUint8Arrays(n)}async _decompress(t){const e=new Blob([t]).stream().pipeThrough(new DecompressionStream("gzip")),n=[];for await(const t of e)n.push(t);const i=await this._concatUint8Arrays(n);return(new TextDecoder).decode(i)}async _concatUint8Arrays(t){const e=new Blob(t),n=await e.arrayBuffer();return new Uint8Array(n)}_handleMotionCaptureClear(){this.motionCaptureFrames.length=0,this.renderRoot.querySelector("#motionCapturePlay").classList.add("disabled"),this.renderRoot.querySelector("#motionCaptureSnapshotLabel").innerHTML="0",this.renderRoot.querySelector("#motionCaptureDelay").classList.add("disabled"),this.renderRoot.querySelector("#motionCaptureDelayLabel").innerHTML="0",this.renderRoot.querySelector("#motionCaptureClear").classList.add("disabled"),this.renderRoot.querySelector("#motionCaptureCopyData").classList.add("disabled"),this.renderRoot.querySelector("#motionCaptureCopyUrl").classList.add("disabled"),this.motionCaptureDelay=0,this.motionCaptureTime=0}_updatePixelRatio(t){const e=window.devicePixelRatio;matchMedia(`(resolution: ${e}dppx)`).addEventListener("change",this._updatePixelRatio.bind(this,!0),{once:!0}),t&&this.updateViewer()}_motionCaptureControlsEnableChanged(t,e){this.renderRoot.querySelector("#motionCapture").style.display=t?"block":"none"}_transformEnableChanged(t,e){this.threeViewer&&(t?(void 0===this.transformInteractor&&(this.transformInteractor=new hf(this.renderRoot.querySelector("#dataVizDiv"))),this.threeViewer.addInteractor(this.transformInteractor),this.transformRotateDisable&&(this.transformInteractor.enableRotate=!1),this.transformZoomDisable&&(this.transformInteractor.enableZoom=!1),this.transformPanDisable&&(this.transformInteractor.enablePan=!1),this.transformClientOnly&&(this.transformInteractor.clientOnly=!0)):this.threeViewer.removeInteractor(this.transformInteractor))}_transformClientOnlyChanged(t,e){this.transformInteractor&&(this.transformInteractor.clientOnly=t),this.zoomRectangleInteractor&&(this.zoomRectangleInteractor.clientOnly=t)}_transformRotateDisableChanged(t,e){this.transformInteractor&&(this.transformInteractor.enableRotate=!t)}_transformZoomDisableChanged(t,e){this.transformInteractor&&(this.transformInteractor.enableZoom=!t)}_transformPanDisableChanged(t,e){this.transformInteractor&&(this.transformInteractor.enablePan=!t)}resetTransform(){this.transformInteractor&&this.transformInteractor.reset()}zoomIn(){this.transformInteractor&&this.transformInteractor.zoomIn()}zoomOut(){this.transformInteractor&&this.transformInteractor.zoomOut()}panTo(t,e,n){this.transformInteractor&&this.transformInteractor.panTo(t,e,n)}_getTransformComponents(){var t,e=new Ai,n=new Ti,i=new Ai,r=new or;return this.transformInteractor&&(t=this.transformInteractor.object.matrix),t.decompose(e,n,i),r.setFromQuaternion(n),{position:e.toArray(),rotation:[180*r.x/Math.PI,180*r.y/Math.PI,180*r.z/Math.PI],rotationOrder:r.order,scale:100*i.x}}getTransformMatrix(){if(this.transformInteractor)return this.transformInteractor.object.matrix.elements.slice()}runAnimation(){if(this.threeViewer){var t=window.getComputedStyle(this,null),e={transform:this.motionCaptureFrames.length>0?JSON.stringify(this.motionCaptureFrames):null};this._applyCustomCssProperties(e,t,{scene:"--avs-scene-animations",sceneTitle:"--avs-scene-title-animations",chart:"--avs-chart-animations",chartTitle:"--avs-chart-title-animations",axis:"--avs-axis-animations",legend:"--avs-legend-animations",legendTitle:"--avs-legend-title-animations",glyph:"--avs-glyph-animations"}),this.animator.setStyleMap(e),this.threeViewer.runAnimation()}}_animatedGlyphsVisibleChanged(t,e){this.threeViewer&&this.threeViewer.setVisibleAnimatedGlyphs(t)}_animatedGlyphsEnableChanged(t,e){this.threeViewer&&this.threeViewer.setEnableAnimatedGlyphs(t)}_transformValueChanged(){var t=void 0!==this.transformTwistAngle?this.transformTwistAngle*Math.PI/180:0,e=void 0!==this.transformTiltAngle?this.transformTiltAngle*Math.PI/180:0,n=void 0!==this.transformScale?this.transformScale/100:1,i=Math.sin(t),r=Math.cos(t),a=Math.sin(e),s=Math.cos(e),o=[r*n,0,s*i*n,0,0,s*n,-a*n,0,-i*n,r*a*n,r*s*n,0,0,0,0,1];this.transformMatrix=o,this.transformInteractor&&this.transformInteractor.object.matrix.fromArray(o)}async _motionCaptureValueChanged(t,e){if(t){try{this.motionCaptureFrames=JSON.parse(t)}catch{const e=atob(t).replaceAll("_","/").replaceAll("-","+"),n=await this._decompress(e);this.motionCaptureFrames=JSON.parse(n)}this.motionCaptureFrames||(this.motionCaptureFrames=[]),this.motionCaptureFrames.length>0?(this.renderRoot.querySelector("#motionCapturePlay").classList.remove("disabled"),this.renderRoot.querySelector("#motionCaptureSnapshotLabel").innerHTML=String(this.motionCaptureFrames.length),this.renderRoot.querySelector("#motionCaptureDelay").classList.remove("disabled"),this.renderRoot.querySelector("#motionCaptureDelayLabel").innerHTML="2",this.renderRoot.querySelector("#motionCaptureClear").classList.remove("disabled"),this.renderRoot.querySelector("#motionCaptureCopyData").classList.remove("disabled"),this.renderRoot.querySelector("#motionCaptureCopyUrl").classList.remove("disabled"),this.motionCaptureDelay=2,this.motionCaptureTime=this.motionCaptureFrames[this.motionCaptureFrames.length-1].time/1e3):(this.renderRoot.querySelector("#motionCapturePlay").classList.add("disabled"),this.renderRoot.querySelector("#motionCaptureSnapshotLabel").innerHTML="0",this.renderRoot.querySelector("#motionCaptureDelay").classList.add("disabled"),this.renderRoot.querySelector("#motionCaptureDelayLabel").innerHTML="0",this.renderRoot.querySelector("#motionCaptureClear").classList.add("disabled"),this.renderRoot.querySelector("#motionCaptureCopyData").classList.add("disabled"),this.renderRoot.querySelector("#motionCaptureCopyUrl").classList.add("disabled"),this.motionCaptureDelay=0,this.motionCaptureTime=0)}}_zoomRectangleEnableChanged(t,e){this.threeViewer&&(t?(void 0===this.zoomRectangleInteractor&&(this.zoomRectangleInteractor=new xf(this)),this.threeViewer.addInteractor(this.zoomRectangleInteractor),this.transformClientOnly&&(this.zoomRectangleInteractor.clientOnly=!0)):this.threeViewer.removeInteractor(this.zoomRectangleInteractor))}_panEnableChanged(t,e){this.threeViewer&&(t?(void 0===this.panInteractor&&(this.panInteractor=new gf(this)),this.threeViewer.addInteractor(this.panInteractor),this.panZoomEnable&&(this.panInteractor.addEventListener("change",this._handlePanChanged.bind(this)),this.panInteractor.addEventListener("zoom",this._handlePanZoom.bind(this)),this.panInteractor.addEventListener("zoomEnd",this._handlePanZoomEnd.bind(this))),this.panInteractor.setWidthZoomLevel(this.panWidthZoomLevel),this.panInteractor.setHeightZoomLevel(this.panHeightZoomLevel),this.panInteractor.setMaximumZoomLevel(this.panMaximumZoomLevel),this.panInteractor.saveState()):(this.threeViewer.removeInteractor(this.panInteractor),this.panZoomEnable&&(this.panInteractor.removeEventListener("change",this._handlePanChanged.bind(this)),this.panInteractor.removeEventListener("zoom",this._handlePanZoom.bind(this)),this.panInteractor.removeEventListener("zoomEnd",this._handlePanZoomEnd.bind(this)))))}_panZoomEnableChanged(t,e){this.threeViewer&&this.panInteractor&&(t?(this.panInteractor.addEventListener("change",this._handlePanChanged.bind(this)),this.panInteractor.addEventListener("zoom",this._handlePanZoom.bind(this)),this.panInteractor.addEventListener("zoomEnd",this._handlePanZoomEnd.bind(this))):(this.panInteractor.removeEventListener("change",this._handlePanChanged.bind(this)),this.panInteractor.removeEventListener("zoom",this._handlePanZoom.bind(this)),this.panInteractor.removeEventListener("zoomEnd",this._handlePanZoomEnd.bind(this))))}_handlePanChanged(t){this.dispatchEvent(new CustomEvent("avs-pan-info",t))}_handlePanZoom(t){window.clearTimeout(this.zoomOverlayTimeoutId);var e=Math.round(t.detail.widthZoomLevel),n=Math.round(t.detail.heightZoomLevel);this.renderRoot.querySelector("#zoomOverlay").innerHTML=e===n?e+"%":e+"%,"+n+"%";var i=this._getAdjustedCoords(t.detail.clientX,t.detail.clientY);const r=this.renderRoot.querySelector("#zoomOverlay");r.style.left=i.x+"px",r.style.top=i.y+"px",r.style.opacity="1",this.pointerDown=!0,this._dispatchPickEvents({type:"HOVER",x:0,y:0,selected:[]}),this.zoomOverlayTimeoutId=window.setTimeout((()=>{this.renderRoot.querySelector("#zoomOverlay").style.opacity="0",this.pointerDown=!1}),1e3)}_handlePanZoomEnd(t){this.panWidthZoomLevel=t.detail.widthZoomLevel,this.panHeightZoomLevel=t.detail.heightZoomLevel}_panWidthZoomLevelChanged(t,e){this.panInteractor&&this.panInteractor.setWidthZoomLevel(t)}_panHeightZoomLevelChanged(t,e){this.panInteractor&&this.panInteractor.setHeightZoomLevel(t)}_panMaximumZoomLevelChanged(t,e){this.panInteractor&&this.panInteractor.setMaximumZoomLevel(t)}resetPan(){this.panInteractor&&this.panInteractor.reset()}_rendererChanged(t,e){if("IMAGE"===e)this.sceneImage.src="data:,",this.renderRoot.querySelector("#dataVizDiv").removeChild(this.sceneImage),this.renderRoot.querySelector("#dataVizDiv").removeChild(this.sceneImageMap);else if("SVG"===e){for(var n=this.svgDiv;n.firstChild;)n.removeChild(n.firstChild);this.renderRoot.querySelector("#dataVizDiv").removeChild(this.svgDiv)}else this.threeViewer&&(this.threeViewer.clearGeometry(),this.threeViewer.render(),this.renderRoot.querySelector("#dataVizDiv").removeChild(this.threeViewer.domElement));if("IMAGE"===t)void 0===this.sceneImage&&(this.sceneImage=document.createElement("img"),this.sceneImage.setAttribute("id","sceneImage"),this.sceneImage.setAttribute("usemap","#sceneImageMap"),this.sceneImageMap=document.createElement("map"),this.sceneImageMap.setAttribute("id","sceneImageMap"),this.sceneImageMap.setAttribute("name","sceneImageMap")),this.renderRoot.querySelector("#dataVizDiv").appendChild(this.sceneImage),this.renderRoot.querySelector("#dataVizDiv").appendChild(this.sceneImageMap),this.threeViewer=null;else if("SVG"===t)void 0===this.svgDiv&&(this.svgDiv=document.createElement("div"),this.svgDiv.setAttribute("id","svgDiv")),this.renderRoot.querySelector("#dataVizDiv").appendChild(this.svgDiv),this.threeViewer=null;else{if(!this.threeViewer){this.threeViewer=new sf;var i="avsDefaultWebGLRenderer",r=document.getElementById(i);null==r&&((r=new sm).setAttribute("id",i),document.body.appendChild(r)),this.threeViewer.setWebGLRenderer(r.webGLRenderer),this.animator=new wf,this.threeViewer.setAnimator(this.animator)}this.renderRoot.querySelector("#dataVizDiv").appendChild(this.threeViewer.domElement)}}_trackEnableChanged(t,e){t?(void 0===this.rectCanvas&&(this.rectCanvas=document.createElement("canvas"),this.rectCanvas.setAttribute("id","rectCanvas"),this.rectCtx=this.rectCanvas.getContext("2d")),this.renderRoot.appendChild(this.rectCanvas)):this.renderRoot.removeChild(this.rectCanvas)}_displayCanvasChanged(t,e){this.threeViewer&&(this.threeViewer.displayCanvas=t)}setTooltipHTML(t){this.renderRoot.querySelector("#tooltip").innerHTML=t}showTooltip(t,e){var n=this.renderRoot.querySelector("#tooltip"),i=this._calcTooltipPosition(n,t,e);n.style.left=i.x+"px",n.style.top=i.y+"px",n.style.opacity="1"}hideTooltip(){this.renderRoot.querySelector("#tooltip").style.opacity="0"}_calcTooltipPosition(t,e,n){var i=this.renderRoot.querySelector("#dataVizDiv"),r=this._getOffset(i),a=-Math.min(0,r.top-window.pageYOffset),s=-Math.min(0,r.left-window.pageXOffset),o=-Math.min(0,window.innerHeight-(i.offsetHeight+r.top-window.pageYOffset)),l=-Math.min(0,window.innerWidth-(i.offsetWidth+r.left-window.pageXOffset)),c=(i.offsetHeight-a-o)/2+a,h={x:0,y:0};if(e<(i.offsetWidth-s-l)/2+s){var d=n<c?15:5;h.x=e+d+i.offsetLeft}else h.x=e-10+i.offsetLeft-t.offsetWidth;return h.y=n<c?n+5+i.offsetTop:n-10+i.offsetTop-t.offsetHeight,h}_getOffset(t){var e=t.getBoundingClientRect(),n=window.pageXOffset||document.documentElement.scrollLeft,i=window.pageYOffset||document.documentElement.scrollTop;return{top:e.top+i,left:e.left+n}}},Rf([dt({attribute:"manual-update",type:Boolean})],t.AvsGoDataViz.prototype,"manualUpdate",void 0),Rf([dt({attribute:"display-canvas",type:Boolean})],t.AvsGoDataViz.prototype,"displayCanvas",void 0),Rf([dt()],t.AvsGoDataViz.prototype,"url",void 0),Rf([dt({attribute:"url-load-json-file",type:Boolean})],t.AvsGoDataViz.prototype,"urlLoadJsonFile",void 0),Rf([dt({attribute:"data-source-name"})],t.AvsGoDataViz.prototype,"dataSourceName",void 0),Rf([dt({attribute:"data-source-user-properties"})],t.AvsGoDataViz.prototype,"dataSourceUserProperties",void 0),Rf([dt({attribute:"scene-name"})],t.AvsGoDataViz.prototype,"sceneName",void 0),Rf([dt({attribute:"scene-user-properties"})],t.AvsGoDataViz.prototype,"sceneUserProperties",void 0),Rf([dt({attribute:"renderer-name"})],t.AvsGoDataViz.prototype,"rendererName",void 0),Rf([dt({attribute:"renderer-user-properties"})],t.AvsGoDataViz.prototype,"rendererUserProperties",void 0),Rf([dt()],t.AvsGoDataViz.prototype,"renderer",void 0),Rf([dt({attribute:"stream-enable",type:Boolean})],t.AvsGoDataViz.prototype,"streamEnable",void 0),Rf([dt({attribute:"stream-chunk-size-first"})],t.AvsGoDataViz.prototype,"streamChunkSizeFirst",void 0),Rf([dt({attribute:"stream-chunk-size"})],t.AvsGoDataViz.prototype,"streamChunkSize",void 0),Rf([dt({attribute:"theme-name"})],t.AvsGoDataViz.prototype,"themeName",void 0),Rf([dt({attribute:"resize-threshold"})],t.AvsGoDataViz.prototype,"resizeThreshold",void 0),Rf([dt({attribute:"pointer-timeout"})],t.AvsGoDataViz.prototype,"pointerTimeout",void 0),Rf([dt({attribute:"tap-enable",type:Boolean})],t.AvsGoDataViz.prototype,"tapEnable",void 0),Rf([dt({attribute:"tap-level"})],t.AvsGoDataViz.prototype,"tapLevel",void 0),Rf([dt({attribute:"tap-depth"})],t.AvsGoDataViz.prototype,"tapDepth",void 0),Rf([dt({attribute:"tap-highlight-enable",type:Boolean})],t.AvsGoDataViz.prototype,"tapHighlightEnable",void 0),Rf([dt({attribute:"tap-highlight-color"})],t.AvsGoDataViz.prototype,"tapHighlightColor",void 0),Rf([dt({attribute:"tap-highlight-layer-enable",type:Boolean})],t.AvsGoDataViz.prototype,"tapHighlightLayerEnable",void 0),Rf([dt({attribute:"tap-process-event-on-client",type:Boolean})],t.AvsGoDataViz.prototype,"tapProcessEventOnClient",void 0),Rf([dt({attribute:"track-enable",type:Boolean})],t.AvsGoDataViz.prototype,"trackEnable",void 0),Rf([dt({attribute:"track-level"})],t.AvsGoDataViz.prototype,"trackLevel",void 0),Rf([dt({attribute:"track-depth"})],t.AvsGoDataViz.prototype,"trackDepth",void 0),Rf([dt({attribute:"track-highlight-enable",type:Boolean})],t.AvsGoDataViz.prototype,"trackHighlightEnable",void 0),Rf([dt({attribute:"track-highlight-color"})],t.AvsGoDataViz.prototype,"trackHighlightColor",void 0),Rf([dt({attribute:"track-highlight-layer-enable",type:Boolean})],t.AvsGoDataViz.prototype,"trackHighlightLayerEnable",void 0),Rf([dt({attribute:"track-process-event-on-client",type:Boolean})],t.AvsGoDataViz.prototype,"trackProcessEventOnClient",void 0),Rf([dt({attribute:"hover-enable",type:Boolean})],t.AvsGoDataViz.prototype,"hoverEnable",void 0),Rf([dt({attribute:"hover-level"})],t.AvsGoDataViz.prototype,"hoverLevel",void 0),Rf([dt({attribute:"hover-depth"})],t.AvsGoDataViz.prototype,"hoverDepth",void 0),Rf([dt({attribute:"hover-highlight-enable",type:Boolean})],t.AvsGoDataViz.prototype,"hoverHighlightEnable",void 0),Rf([dt({attribute:"hover-highlight-color"})],t.AvsGoDataViz.prototype,"hoverHighlightColor",void 0),Rf([dt({attribute:"hover-highlight-layer-enable",type:Boolean})],t.AvsGoDataViz.prototype,"hoverHighlightLayerEnable",void 0),Rf([dt({attribute:"transform-enable",type:Boolean})],t.AvsGoDataViz.prototype,"transformEnable",void 0),Rf([dt({attribute:"transform-client-only",type:Boolean})],t.AvsGoDataViz.prototype,"transformClientOnly",void 0),Rf([dt({attribute:"transform-rotate-disable",type:Boolean})],t.AvsGoDataViz.prototype,"transformRotateDisable",void 0),Rf([dt({attribute:"transform-zoom-disable",type:Boolean})],t.AvsGoDataViz.prototype,"transformZoomDisable",void 0),Rf([dt({attribute:"transform-pan-disable",type:Boolean})],t.AvsGoDataViz.prototype,"transformPanDisable",void 0),Rf([dt({attribute:"transform-twist-angle"})],t.AvsGoDataViz.prototype,"transformTwistAngle",void 0),Rf([dt({attribute:"transform-tilt-angle"})],t.AvsGoDataViz.prototype,"transformTiltAngle",void 0),Rf([dt({attribute:"transform-scale"})],t.AvsGoDataViz.prototype,"transformScale",void 0),Rf([dt({attribute:"motion-capture"})],t.AvsGoDataViz.prototype,"motionCapture",void 0),Rf([dt({attribute:"zoom-rectangle-enable",type:Boolean})],t.AvsGoDataViz.prototype,"zoomRectangleEnable",void 0),Rf([dt({attribute:"pan-enable",type:Boolean})],t.AvsGoDataViz.prototype,"panEnable",void 0),Rf([dt({attribute:"pan-zoom-enable",type:Boolean})],t.AvsGoDataViz.prototype,"panZoomEnable",void 0),Rf([dt({attribute:"pan-width-zoom-level"})],t.AvsGoDataViz.prototype,"panWidthZoomLevel",void 0),Rf([dt({attribute:"pan-height-zoom-level"})],t.AvsGoDataViz.prototype,"panHeightZoomLevel",void 0),Rf([dt({attribute:"pan-maximum-zoom-level"})],t.AvsGoDataViz.prototype,"panMaximumZoomLevel",void 0),Rf([dt({attribute:"animated-glyphs-visible",type:Boolean})],t.AvsGoDataViz.prototype,"animatedGlyphsVisible",void 0),Rf([dt({attribute:"animated-glyphs-enable",type:Boolean})],t.AvsGoDataViz.prototype,"animatedGlyphsEnable",void 0),Rf([dt({attribute:"motion-capture-controls-enable",type:Boolean})],t.AvsGoDataViz.prototype,"motionCaptureControlsEnable",void 0),t.AvsGoDataViz=Rf([lt("avs-go-dataviz")],t.AvsGoDataViz);
|
|
338
|
+
`}_assembleModel(t){if(!this.sceneName)return void this._dispatchErrorEvent("'scene-name' property must be set to the name of the scene registered in the library map on the AVS/Go server.");if(!this.width||!this.height)return;const e={sceneProperties:{name:this.sceneName}};if(this.sceneUserProperties){let t;try{t=JSON.parse(this.sceneUserProperties)}catch(t){return void this._dispatchErrorEvent("Can't parse 'scene-user-properties'. "+t.message)}e.sceneProperties.userProperties=t}const n={width:this.width,height:this.height,name:this.rendererName,type:this.renderer};if(this.rendererUserProperties){let t;try{t=JSON.parse(this.rendererUserProperties)}catch(t){return void this._dispatchErrorEvent("Can't parse 'renderer-user-properties'. "+t.message)}n.userProperties=t}e.rendererProperties=n,this.transformInteractor&&(this.transformMatrix=this.transformInteractor.object.matrix.elements.slice()),this.transformMatrix&&!this.transformClientOnly&&(n.transformMatrix=this.transformMatrix),t&&(this.transformClientOnly&&this.transformInteractor?this.transformInteractor.fullReset=t:n.fullReset=!0),this.panEnable&&(n.panProperties={widthZoomLevel:Math.min(this.panWidthZoomLevel,this.panMaximumZoomLevel),heightZoomLevel:Math.min(this.panHeightZoomLevel,this.panMaximumZoomLevel)}),n.themeName=this.themeName;var i=window.getComputedStyle(this,null),r=i.getPropertyValue("background-color").trim(),a=i.getPropertyValue("color").trim(),s=i.getPropertyValue("font-family").trim().replace(/['"]+/g,"");if(n.cssProperties={sceneBackgroundType:"Solid",sceneBackgroundColor:r,sceneLineColor:a,sceneTextColor:a,sceneFontFamily:s,sceneSurfaceColor:a},this._applyCustomCssProperties(n.cssProperties,i,{sceneBackgroundType:"--avs-scene-background-type",sceneBackgroundColor:"--avs-scene-background-color",sceneBackgroundStartColor:"--avs-scene-background-start-color",sceneBackgroundEndColor:"--avs-scene-background-end-color",sceneBackgroundGradientStyle:"--avs-scene-background-gradient-style",sceneBackgroundGradientInterpolation:"--avs-scene-background-gradient-interpolation",sceneBackgroundGradientColorRepeat:"--avs-scene-background-gradient-color-repeat",sceneHighlightColor:"--avs-scene-highlight-color",sceneSurfaceColor:"--avs-scene-surface-color",scenePointColor:"--avs-scene-point-color",sceneLineColor:"--avs-scene-line-color",sceneLineWidth:"--avs-scene-line-width",sceneTextColor:"--avs-scene-text-color",sceneTextRotation:"--avs-scene-text-rotation",sceneFontFamily:"--avs-scene-font-family",sceneFontStyle:"--avs-scene-font-style",sceneFontWeight:"--avs-scene-font-weight",sceneFontSize:"--avs-scene-font-size",sceneTitleTextColor:"--avs-scene-title-text-color",sceneTitleTextRotation:"--avs-scene-title-text-rotation",sceneTitleFontFamily:"--avs-scene-title-font-family",sceneTitleFontStyle:"--avs-scene-title-font-style",sceneTitleFontWeight:"--avs-scene-title-font-weight",sceneTitleFontSize:"--avs-scene-title-font-size",chartBackgroundType:"--avs-chart-background-type",chartBackgroundColor:"--avs-chart-background-color",chartBackgroundStartColor:"--avs-chart-background-start-color",chartBackgroundEndColor:"--avs-chart-background-end-color",chartBackgroundGradientStyle:"--avs-chart-background-gradient-style",chartBackgroundGradientInterpolation:"--avs-chart-background-gradient-interpolation",chartBackgroundGradientColorRepeat:"--avs-chart-background-gradient-color-repeat",chartHighlightColor:"--avs-chart-highlight-color",chartSurfaceColor:"--avs-chart-surface-color",chartPointColor:"--avs-chart-point-color",chartLineColor:"--avs-chart-line-color",chartLineWidth:"--avs-chart-line-width",chartLinePattern:"--avs-chart-line-pattern",chartTextColor:"--avs-chart-text-color",chartTextRotation:"--avs-chart-text-rotation",chartFontFamily:"--avs-chart-font-family",chartFontStyle:"--avs-chart-font-style",chartFontWeight:"--avs-chart-font-weight",chartFontSize:"--avs-chart-font-size",chartTitleTextColor:"--avs-chart-title-text-color",chartTitleTextRotation:"--avs-chart-title-text-rotation",chartTitleFontFamily:"--avs-chart-title-font-family",chartTitleFontStyle:"--avs-chart-title-font-style",chartTitleFontWeight:"--avs-chart-title-font-weight",chartTitleFontSize:"--avs-chart-title-font-size",axisLineColor:"--avs-axis-line-color",axisLineWidth:"--avs-axis-line-width",axisTextColor:"--avs-axis-text-color",axisTextRotation:"--avs-axis-text-rotation",axisFontFamily:"--avs-axis-font-family",axisFontStyle:"--avs-axis-font-style",axisFontWeight:"--avs-axis-font-weight",axisFontSize:"--avs-axis-font-size",axisAxleColor:"--avs-axis-axle-color",axisAxleWidth:"--avs-axis-axle-width",axisMajorTickMarkColor:"--avs-axis-major-tick-mark-color",axisMajorTickMarkWidth:"--avs-axis-major-tick-mark-width",axisMajorTickLineColor:"--avs-axis-major-tick-line-color",axisMajorTickLineWidth:"--avs-axis-major-tick-line-width",axisMajorTickLineStyle:"--avs-axis-major-tick-line-style",axisMajorUnlabeledTickMarkColor:"--avs-axis-major-unlabeled-tick-mark-color",axisMajorUnlabeledTickMarkWidth:"--avs-axis-major-unlabeled-tick-mark-width",axisMajorUnlabeledTickLineColor:"--avs-axis-major-unlabeled-tick-line-color",axisMajorUnlabeledTickLineWidth:"--avs-axis-major-unlabeled-tick-line-width",axisMajorUnlabeledTickLineStyle:"--avs-axis-major-unlabeled-tick-line-style",axisMinorTickMarkColor:"--avs-axis-minor-tick-mark-color",axisMinorTickMarkWidth:"--avs-axis-minor-tick-mark-width",axisMinorTickLineColor:"--avs-axis-minor-tick-line-color",axisMinorTickLineWidth:"--avs-axis-minor-tick-line-width",axisMinorTickLineStyle:"--avs-axis-minor-tick-line-style",axisTitleTextColor:"--avs-axis-title-text-color",axisTitleTextRotation:"--avs-axis-title-text-rotation",axisTitleFontFamily:"--avs-axis-title-font-family",axisTitleFontStyle:"--avs-axis-title-font-style",axisTitleFontWeight:"--avs-axis-title-font-weight",axisTitleFontSize:"--avs-axis-title-font-size",axisUnitTextColor:"--avs-axis-unit-text-color",axisUnitTextRotation:"--avs-axis-unit-text-rotation",axisUnitFontFamily:"--avs-axis-unit-font-family",axisUnitFontStyle:"--avs-axis-unit-font-style",axisUnitFontWeight:"--avs-axis-unit-font-weight",axisUnitFontSize:"--avs-axis-unit-font-size",axisLabelTextColor:"--avs-axis-label-text-color",axisLabelTextRotation:"--avs-axis-label-text-rotation",axisLabelFontFamily:"--avs-axis-label-font-family",axisLabelFontStyle:"--avs-axis-label-font-style",axisLabelFontWeight:"--avs-axis-label-font-weight",axisLabelFontSize:"--avs-axis-label-font-size",legendBackgroundColor:"--avs-legend-background-color",legendTextColor:"--avs-legend-text-color",legendTextRotation:"--avs-legend-text-rotation",legendFontFamily:"--avs-legend-font-family",legendFontStyle:"--avs-legend-font-style",legendFontWeight:"--avs-legend-font-weight",legendFontSize:"--avs-legend-font-size",legendPointColor:"--avs-legend-point-color",legendTitleTextColor:"--avs-legend-title-text-color",legendTitleTextRotation:"--avs-legend-title-text-rotation",legendTitleFontFamily:"--avs-legend-title-font-family",legendTitleFontStyle:"--avs-legend-title-font-style",legendTitleFontWeight:"--avs-legend-title-font-weight",legendTitleFontSize:"--avs-legend-title-font-size"}),this.dataSourceName&&(e.dataSourceProperties={name:this.dataSourceName},this.dataSourceUserProperties)){let t;try{t=JSON.parse(this.dataSourceUserProperties)}catch(t){return void this._dispatchErrorEvent("Can't parse 'data-source-user-properties'. "+t.message)}e.dataSourceProperties.userProperties=t}return this.threeViewer&&this.streamEnable&&(n.streamProperties={chunkSizeFirst:this.streamChunkSizeFirst,chunkSize:this.streamChunkSize}),e}_applyCustomCssProperties(t,e,n){for(var i in n)if(n.hasOwnProperty(i)){var r=e.getPropertyValue(n[i]).trim();r.length>0&&(t[i]=r)}}_onResize(t){this.width=Math.round(t.width),this.height=Math.round(t.height),this.rectCanvas&&(this.rectCanvas.width=this.width,this.rectCanvas.height=this.height),!this.urlLoadJsonFile&&!this.manualUpdate&&this.resizeThreshold>0&&(!this.lowResizeWidth||this.width<this.lowResizeWidth||this.width>this.highResizeWidth||this.height<this.lowResizeHeight||this.height>this.highResizeHeight)?(this._updateResizeLimits(),this.updateViewer()):this.threeViewer&&this.threeViewer.render(!0)}_updateResizeLimits(){this.lowResizeWidth=(100-this.resizeThreshold)/100*this.width,this.highResizeWidth=(100+this.resizeThreshold)/100*this.width,this.lowResizeHeight=(100-this.resizeThreshold)/100*this.height,this.highResizeHeight=(100+this.resizeThreshold)/100*this.height}showSpinner(){var t=window.getComputedStyle(this,null).getPropertyValue("--avs-spinner").trim().replace(/['"]+/g,"");t.length>0?fetch(t).then((t=>{if(t.ok)return t.text()})).then((t=>{this.renderRoot.querySelector("#spinner").innerHTML=t})).catch((t=>{this.renderRoot.querySelector("#spinner").innerHTML=Tf})):this.renderRoot.querySelector("#spinner").innerHTML=Tf,this.renderRoot.querySelector("#spinner").style.display="block"}hideSpinner(){this.renderRoot.querySelector("#spinner").style.display="none"}startSpinner(){this.renderRoot.querySelector("#spinner").className="spin"}stopSpinner(){this.renderRoot.querySelector("#spinner").className=""}updated(t){if(!["IMAGE","SVG","THREEJS"].includes(this.renderer))return void this._dispatchErrorEvent("'renderer' property must be 'IMAGE', 'SVG' or 'THREEJS'.");if(t.has("renderer")&&this._rendererChanged(this.renderer,t.renderer),t.has("transformEnable")&&this._transformEnableChanged(this.transformEnable,t.transformEnable),t.has("transformClientOnly")&&this._transformClientOnlyChanged(this.transformClientOnly,t.transformClientOnly),t.has("transformRotateDisable")&&this._transformRotateDisableChanged(this.transformRotateDisable,t.transformRotateDisable),t.has("transformZoomDisable")&&this._transformZoomDisableChanged(this.transformZoomDisable,t.transformZoomDisable),t.has("transformPanDisable")&&this._transformPanDisableChanged(this.transformPanDisable,t.transformPanDisable),t.has("animatedGlyphsVisible")&&this._animatedGlyphsVisibleChanged(this.animatedGlyphsVisible,t.animatedGlyphsVisible),t.has("animatedGlyphsEnable")&&this._animatedGlyphsEnableChanged(this.animatedGlyphsEnable,t.animatedGlyphsEnable),(t.has("transformTwistAngle")||t.has("transformTiltAngle")||t.has("transformScale"))&&this._transformValueChanged(),t.has("animatedGlyphsEnable")&&this._animatedGlyphsEnableChanged(this.animatedGlyphsEnable,t.animatedGlyphsEnable),t.has("zoomRectangleEnable")&&this._zoomRectangleEnableChanged(this.zoomRectangleEnable,t.zoomRectangleEnable),t.has("panEnable")&&this._panEnableChanged(this.panEnable,t.panEnable),t.has("panZoomEnable")&&this._panZoomEnableChanged(this.panZoomEnable,t.panZoomEnable),t.has("panWidthZoomLevel")&&this._panWidthZoomLevelChanged(this.panWidthZoomLevel,t.panWidthZoomLevel),t.has("panHeightZoomLevel")&&this._panHeightZoomLevelChanged(this.panHeightZoomLevel,t.panHeightZoomLevel),t.has("panMaximumZoomLevel")&&this._panMaximumZoomLevelChanged(this.panMaximumZoomLevel,t.panMaximumZoomLevel),t.has("trackEnable")&&this._trackEnableChanged(this.trackEnable,t.trackEnable),t.has("displayCanvas")&&this._displayCanvasChanged(this.displayCanvas,t.displayCanvas),t.has("motionCaptureControlsEnable")&&this._motionCaptureControlsEnableChanged(this.motionCaptureControlsEnable,t.motionCaptureControlsEnable),t.has("motionCapture")&&this._motionCaptureValueChanged(this.motionCapture,t.motionCapture),!this.url)return;let e=!1;this.manualUpdate?this.forceUpdate&&(e=!0):(this.forceUpdate||t.has("url")||t.has("renderer")||t.has("urlLoadJsonFile")||t.has("sceneName")||t.has("sceneUserProperties")||t.has("dataSourceName")||t.has("dataSourceUserProperties")||t.has("rendererName")||t.has("rendererUserProperties")||t.has("streamEnable")||this.panEnable&&t.has("panWidthZoomLevel")||this.panEnable&&t.has("panHeightZoomLevel"))&&(e=!0),e&&(this.forceUpdate=!1,this.urlLoadJsonFile?(this.chunkFile=0,this.showSpinner(),this.startSpinner(),this._httpRequest(this.url,this._handleHttpResponse.bind(this),this._handleHttpError.bind(this))):(this.model=this._assembleModel(),this.model&&(this.showSpinner(),this.startSpinner(),this._httpRequest(this.url,this._handleHttpResponse.bind(this),this._handleHttpError.bind(this),this.model))))}_handleHttpError(){this.hideSpinner()}updateViewer(){this.forceUpdate=!0,this.requestUpdate()}clear(){if(this.threeViewer)this.threeViewer.clearGeometry(),this.threeViewer.render();else if("SVG"===this.renderer)for(var t=this.svgDiv;t.firstChild;)t.removeChild(t.firstChild);else this.sceneImage.src="data:,";this.showSpinner()}_handleHttpResponse(t){if(t){if(t.selectionInfo&&this._dispatchPickEvents(t.selectionInfo),t.sceneInfo){this.dispatchEvent(new CustomEvent("avs-scene-info",{detail:t.sceneInfo}));const s=this.renderRoot.querySelector("#motionCapture"),o=this.renderRoot.querySelector("#zoomOverlay"),l=this.renderRoot.querySelector("#tooltip"),c=this.renderRoot.querySelector("#motionCaptureTooltip");if(t.sceneInfo.backgroundColor){var e=t.sceneInfo.backgroundColor.match(/[0-9.]+/gi),n=this._getInheritedBackgroundCol(this).trim().match(/[0-9.]+/gi),i=Number(e[0])*Number(e[3]),r=Number(e[1])*Number(e[3]),a=Number(e[2])*Number(e[3]);0==Number(e[3])&&(i+=Number(n[0])*(1-Number(e[3])),r+=Number(n[1])*(1-Number(e[3])),a+=Number(n[2])*(1-Number(e[3]))),s.style.color="var(--avs-motion-capture-color, rgb("+i+", "+r+", "+a+"))",o.style.color="var(--avs-zoom-overlay-color, rgb("+i+","+r+","+a+"))",l.style.color="var(--avs-tooltip-color, rgb("+i+","+r+","+a+"))",c.style.color="var(--avs-tooltip-color, rgb("+i+","+r+","+a+"))"}t.sceneInfo.color&&(e=t.sceneInfo.color.match(/[0-9.]+/gi),s.style.background="var(--avs-motion-capture-background, rgba("+e[0]+","+e[1]+","+e[2]+",0.75))",o.style.background="var(--avs-zoom-overlay-background, rgba("+e[0]+","+e[1]+","+e[2]+",0.75))",l.style.background="var(--avs-tooltip-background, rgb("+e[0]+","+e[1]+","+e[2]+"))",c.style.background="var(--avs-tooltip-background, rgb("+e[0]+","+e[1]+","+e[2]+"))"),t.sceneInfo.fontFamily&&(s.style.fontFamily="var(--avs-motion-capture-font-family, "+t.sceneInfo.fontFamily+")",o.style.fontFamily="var(--avs-zoom-overlay-font-family, "+t.sceneInfo.fontFamily+")",l.style.fontFamily="var(--avs-tooltip-font-family, "+t.sceneInfo.fontFamily+")",c.style.fontFamily="var(--avs-tooltip-font-family, "+t.sceneInfo.fontFamily+")")}if(t.image)this.sceneImage.src=t.image,t.imagemap?(this.sceneImageMap.innerHTML=decodeURIComponent(t.imagemap.replace(/\+/g,"%20")),this.imageMapData=Array.from(this.sceneImageMap.querySelectorAll("area")).map((t=>({shape:t.getAttribute("shape"),coords:t.getAttribute("coords").split(",").map(Number),seriesIndex:t.getAttribute("series-index"),itemIndex:t.getAttribute("item-index"),componentInfo:t.getAttribute("component-info")})))):(this.sceneImageMap.innerHTML="",this.imageMapData=void 0),this.urlLoadJsonFile||this._dispatchSceneData(t),this._handleLoadComplete();else if(t.svg)this.svgDiv.innerHTML=decodeURIComponent(t.svg.replace(/\+/g,"%20")),this.urlLoadJsonFile||this._dispatchSceneData(t),this._handleLoadComplete();else if(t.threejs)if(this.urlLoadJsonFile||this._dispatchSceneData(t),t.threejs.chunkId){if(this.threeViewer.loadGeometryAsEvents(t.threejs,this._handleLoadComplete.bind(this)),t.threejs.moreChunks)if(this.urlLoadJsonFile){this.chunkFile++;const t=this.url.substring(0,this.url.lastIndexOf("."))||this.url,e=this.url.split(".").pop();this._httpRequest(t+"-"+this.chunkFile+"."+e,this._handleHttpResponse.bind(this),this._handleHttpError.bind(this))}else this.model.rendererProperties.streamProperties.chunkId=t.threejs.chunkId,this._httpRequest(this.url,this._handleHttpResponse.bind(this),this._handleHttpError.bind(this),this.model)}else this.threeViewer.loadGeometryAsJson(t.threejs,this._handleLoadComplete.bind(this));else this._dispatchErrorEvent("No image, SVG, or ThreeJS found in response."),this._handleLoadComplete()}}_getInheritedBackgroundCol(t){var e=this._getDefaultBackground(),n=window.getComputedStyle(t).backgroundColor;return n!=e?n:t.parentElement?this._getInheritedBackgroundCol(t.parentElement):e}_getDefaultBackground(){var t=document.createElement("div");document.head.appendChild(t);var e=window.getComputedStyle(t).backgroundColor;return document.head.removeChild(t),e}_handleLoadComplete(){this.hideSpinner(),this.stopSpinner(),this.dispatchEvent(new CustomEvent("avs-load-complete"))}_dispatchSceneData(t){this.dispatchEvent(new CustomEvent("avs-scene-data",{detail:t}))}_handleTap(t,e,n){const i=this._getAdjustedCoords(t,e),r={type:"TAP",x:i.x,y:i.y,level:this.tapLevel,depth:this.tapDepth,highlight:this.tapHighlightEnable,highlightColor:this.tapHighlightColor,highlightLayer:this.tapHighlightLayerEnable};this._processPick(r,this.tapProcessEventOnClient,n)}_handleTrack(t,e,n,i,r){var a=this._getAdjustedRectangleCoords(e,n,i,r);switch(t){case"start":break;case"track":this.rectCtx.clearRect(0,0,this.width,this.height),this.rectCtx.setLineDash([3]),this.rectCtx.strokeStyle="#ff0000",this.rectCtx.strokeRect(a.left,a.top,a.right-a.left,a.bottom-a.top);break;case"end":this.rectCtx.clearRect(0,0,this.width,this.height);const t={type:"TRACK",left:a.left,right:a.right,top:a.top,bottom:a.bottom,level:this.trackLevel,depth:this.trackDepth,highlight:this.trackHighlightEnable,highlightColor:this.trackHighlightColor,highlightLayer:this.trackHighlightLayerEnable};this._processPick(t,this.trackProcessEventOnClient)}}_handlePointerDown(t){this.pointerDownX=t.clientX,this.pointerDownY=t.clientY,this.pointerDown=!0,this.tapEnable&&1&t.buttons&&(this.tapping=!0),this.trackEnable&&1&t.buttons&&(this.tracking=1)}_handlePointerMove(t){if(this.tracking>=1){if(1===this.tracking){var e=Math.abs(t.clientX-this.pointerDownX),n=Math.abs(t.clientY-this.pointerDownY);e*e+n*n>=5&&(this.tracking=2,this._handleTrack("start",t.clientX,t.clientY,t.clientX-this.pointerDownX,t.clientY-this.pointerDownY))}2===this.tracking&&this._handleTrack("track",t.clientX,t.clientY,t.clientX-this.pointerDownX,t.clientY-this.pointerDownY)}if(this.hoverEnable){var i=this._getAdjustedCoords(t.clientX,t.clientY);const e={type:"HOVER",x:i.x,y:i.y};this.pointerDown?(e.selected=[],this._dispatchPickEvents(e)):(void 0!==this.hoverLevel&&(e.level=this.hoverLevel),void 0!==this.hoverDepth&&(e.depth=this.hoverDepth),this.hoverHighlightEnable&&(e.highlight=!0),void 0!==this.hoverHighlightColor&&(e.highlightColor=this.hoverHighlightColor),this.hoverHighlightLayerEnable&&(e.highlightLayer=!0),this._processPick(e,!0,t.target))}this._resetTimer()}_handlePointerUp(t){if(this.pointerDown=!1,this.tapping){this.tapping=!1;var e=Math.abs(t.clientX-this.pointerDownX),n=Math.abs(t.clientY-this.pointerDownY);e*e+n*n<25&&this._handleTap(t.clientX,t.clientY,t.currentTarget)}this.tracking>1&&(this.tracking=0,this._handleTrack("end",t.clientX,t.clientY,t.clientX-this.pointerDownX,t.clientY-this.pointerDownY))}_getAdjustedCoords(t,e){var n=this.renderRoot.querySelector("#dataVizDiv").getBoundingClientRect(),i=Math.round(t-n.left),r=Math.round(e-n.top);return{x:Math.max(0,Math.min(i,this.width)),y:Math.max(0,Math.min(r,this.height))}}_getAdjustedRectangleCoords(t,e,n,i){var r=this.renderRoot.querySelector("#dataVizDiv").getBoundingClientRect(),a=Math.round(t-r.left),s=Math.round(e-r.top),o=Math.max(0,Math.min(a,this.width)),l=Math.max(0,Math.min(s,this.height)),c=Math.max(0,Math.min(a-n,this.width)),h=Math.max(0,Math.min(s-i,this.height));return{left:Math.min(c,o),right:Math.max(c,o),top:Math.min(h,l),bottom:Math.max(h,l)}}_processPick(t,e,n){if(e)if(this.threeViewer){this.threeViewer.setPickDepth("ALL"===t.depth?lm:cm),"TRACK"===t.type?this.threeViewer.setPickRectangle(t.left,t.top,t.right,t.bottom):this.threeViewer.setPickRay(t.x,t.y),this.threeViewer.pick();var i={};i="CELL"===t.level?this.threeViewer.getPickedCells():"CELL_SET"===t.level?this.threeViewer.getPickedCellSets():this.threeViewer.getPickedSceneNodes(),t.selected=this.threeViewer.getSelectionInfo(i),this._dispatchPickEvents(t),t.highlight&&(this.threeViewer.highlightColor.set(t.highlightColor),this.threeViewer.highlightObjects(i,t.highlightLayer))}else if("SVG"===this.renderer){if(t.selected=[],"TRACK"!==t.type&&("polygon"===n.nodeName||"circle"===n.nodeName)){const e={};for(var r=null,a=n.parentElement;null!==a&&null===(r=a.getAttribute("series-index"));)a=a.parentElement;null!==r&&(e.seriesIndex=parseInt(r));var s=null;for(a=n.parentElement;null!==a&&null===(s=a.getAttribute("item-index"));)a=a.parentElement;null!==s&&(e.itemIndex=parseInt(s));var o=null;for(a=n.parentElement;null!==a&&null===(o=a.getAttribute("component-info"));)a=a.parentElement;null!==o&&(e.componentInfo=decodeURIComponent(o)),t.selected.push(e)}if(this._dispatchPickEvents(t),t.highlight){void 0===this.highlightSvg&&(this.highlightSvg=[]);for(var l=0;l<this.highlightSvg.length;l++)this.highlightSvg[l].setAttribute("fill",this.highlightSvg[l].getAttribute("saveFill"));this.highlightSvg.length=0,"TRACK"===t.type||"polygon"!==n.nodeName&&"circle"!==n.nodeName||(this.highlightSvg.push(n),n.setAttribute("saveFill",n.getAttribute("fill")),n.setAttribute("fill",t.highlightColor))}}else{if(t.selected=[],"TRACK"!==t.type&&void 0!==this.imageMapData)for(l=0;l<this.imageMapData.length;l++){var c=this.imageMapData[l];if(console.log(t.x+" "+t.y),"poly"===c.shape&&this._pointInPoly(t.x,t.y,c.coords)){const e={};null!==c.seriesIndex&&(e.seriesIndex=parseInt(c.seriesIndex)),null!==c.itemIndex&&(e.itemIndex=parseInt(c.itemIndex)),null!==c.componentInfo&&(e.componentInfo=decodeURIComponent(c.componentInfo)),t.selected.push(e)}}this._dispatchPickEvents(t)}else this.urlLoadJsonFile||(this.showSpinner(),this.url&&(this.startSpinner(),this.model=this._assembleModel(),this.model&&(this.model.rendererProperties.pickProperties=t,this._httpRequest(this.url,this._handleHttpResponse.bind(this),this._handleHttpError.bind(this),this.model))))}_pointInPoly(t,e,n){for(var i,r,a,s=n[0]-t,o=n[1]-e,l=0,c=2;c<n.length;c+=2)if(r=n[c+1]-e,o<0&&r<0||o>0&&r>0)o=r,s=n[c]-t;else{if(i=n[c]-t,r>0&&o<=0){if((a=s*r-i*o)>0)l++;else if(0===a)return!1}else if(o>0&&r<=0){if((a=s*r-i*o)<0)l++;else if(0===a)return!1}else if(0===r&&o<0){if(0===(a=s*r-i*o))return!1}else if(0===o&&r<0){if(0===(a=s*r-i*o))return!1}else if(0===o&&0===r){if(i<=0&&s>=0)return!1;if(s<=0&&i>=0)return!1}o=r,s=i}return l%2!=0}_dispatchPickEvents(t){const e={selected:t.selected};"TRACK"===t.type?(e.left=t.left,e.top=t.top,e.right=t.right,e.bottom=t.bottom,this.dispatchEvent(new CustomEvent("avs-track",{detail:e}))):(e.x=t.x,e.y=t.y,"HOVER"===t.type?this.dispatchEvent(new CustomEvent("avs-hover",{detail:e})):this.dispatchEvent(new CustomEvent("avs-tap",{detail:e})))}_resetTimer(){window.clearTimeout(this.timer),this.timer=window.setTimeout((()=>{this.dispatchEvent(new Event("avs-pointer-timeout"))}),1e3*this.pointerTimeout)}constructor(){super(),this.renderer="THREEJS",this.resizeThreshold=10,this.pointerTimeout=600,this.panWidthZoomLevel=100,this.panHeightZoomLevel=100,this.panMaximumZoomLevel=1e3,this.lowResizeWidth=this.highResizeWidth=0,this.highResizeWidth=this.highResizeHeight=0,this.motionCaptureTime=0,this.motionCaptureFrames??=[],this._resetTimer(),this._updatePixelRatio()}connectedCallback(){super.connectedCallback(),Cf.observe(this),this.addEventListener("pointerdown",this._handlePointerDown),this.addEventListener("pointerup",this._handlePointerUp),this.addEventListener("pointermove",this._handlePointerMove),this.addEventListener("pointerout",this._handlePointerMove);var t=this;this.addEventListener("contextmenu",(function(e){t.trackEnable&&e.preventDefault()}))}disconnectedCallback(){super.disconnectedCallback(),Cf.unobserve(this)}_handlePointerEnterMotionCaptureControl(t){if(!this.showMotionCaptureTooltip){var e=this._getAdjustedCoords(t.clientX,t.clientY),n=this.renderRoot.querySelector("#motionCaptureTooltip"),i=this._calcTooltipPosition(n,e.x,e.y);n.style.left=i.x+"px",n.style.top=i.y+"px",n.style.opacity="1";const r=t.currentTarget;n.innerHTML=r.dataset.tooltip??r.id,this.showMotionCaptureTooltip=!0}}_handlePointerLeaveMotionCaptureControl(){this.renderRoot.querySelector("#motionCaptureTooltip").style.opacity="0",this.showMotionCaptureTooltip=!1}_round2dp(t){return Math.round(100*(t+Number.EPSILON))/100}_handleMotionCaptureSnapshot(){const t=this._getTransformComponents();this.motionCaptureFrames.length>0&&(this.motionCaptureTime+=this.motionCaptureDelay);const e={time:1e3*this.motionCaptureTime,scale:this._round2dp(t.scale),position:[this._round2dp(t.position[0]),this._round2dp(t.position[1]),this._round2dp(t.position[2])],rotation:[this._round2dp(t.rotation[0]),this._round2dp(t.rotation[1]),this._round2dp(t.rotation[2]),t.rotation[3]]};this.motionCaptureFrames.push(e),1==this.motionCaptureFrames.length&&(this.renderRoot.querySelector("#motionCapturePlay").classList.remove("disabled"),this.renderRoot.querySelector("#motionCaptureDelay").classList.remove("disabled"),this.renderRoot.querySelector("#motionCaptureDelayLabel").innerHTML="2",this.renderRoot.querySelector("#motionCaptureClear").classList.remove("disabled"),this.renderRoot.querySelector("#motionCaptureCopyData").classList.remove("disabled"),this.renderRoot.querySelector("#motionCaptureCopyUrl").classList.remove("disabled"),this.motionCaptureDelay=2),this.renderRoot.querySelector("#motionCaptureSnapshotLabel").innerHTML=String(this.motionCaptureFrames.length)}_handleMotionCaptureDelayIncrease(){this.motionCaptureDelay++,this.motionCaptureDelay>9&&(this.motionCaptureDelay=9),this.renderRoot.querySelector("#motionCaptureDelayLabel").innerHTML=String(this.motionCaptureDelay)}_handleMotionCaptureDelayDecrease(){this.motionCaptureDelay--,this.motionCaptureDelay<1&&(this.motionCaptureDelay=1),this.renderRoot.querySelector("#motionCaptureDelayLabel").innerHTML=String(this.motionCaptureDelay)}_handleMotionCaptureCopyData(){const t=JSON.stringify(this.motionCaptureFrames);navigator.clipboard.writeText(t);const e=this.renderRoot.querySelector("#motionCaptureAlert");e.innerHTML="Motion capture URL copied to clipboard",e.style.opacity="1",setTimeout((()=>{e.style.opacity="0"}),2e3)}async _handleMotionCaptureCopyUrl(){const t=JSON.stringify(this.motionCaptureFrames),e=await this._compress(t),n=btoa(e).replaceAll("/","_").replaceAll("+","-"),i=window.location.origin+window.location.pathname+"?motionCapture="+n;navigator.clipboard.writeText(i);const r=this.renderRoot.querySelector("#motionCaptureAlert");r.innerHTML="Motion capture URL copied to clipboard",r.style.opacity="1",setTimeout((()=>{r.style.opacity="0"}),2e3)}async _compress(t){const e=(new TextEncoder).encode(t),n=new CompressionStream("gzip"),i=n.writable.getWriter();i.write(e),i.close();const r=await new Response(n.readable).arrayBuffer();return String.fromCharCode(...new Uint8Array(r))}async _decompress(t){const e=new Uint8Array(t.length);for(let n=0;n<t.length;n++)e[n]=t.charCodeAt(n);const n=new DecompressionStream("gzip"),i=n.writable.getWriter();i.write(e),i.close();const r=await new Response(n.readable).arrayBuffer();return String.fromCharCode(...new Uint8Array(r))}_handleMotionCaptureClear(){this.motionCaptureFrames.length=0,this.renderRoot.querySelector("#motionCapturePlay").classList.add("disabled"),this.renderRoot.querySelector("#motionCaptureSnapshotLabel").innerHTML="0",this.renderRoot.querySelector("#motionCaptureDelay").classList.add("disabled"),this.renderRoot.querySelector("#motionCaptureDelayLabel").innerHTML="0",this.renderRoot.querySelector("#motionCaptureClear").classList.add("disabled"),this.renderRoot.querySelector("#motionCaptureCopyData").classList.add("disabled"),this.renderRoot.querySelector("#motionCaptureCopyUrl").classList.add("disabled"),this.motionCaptureDelay=0,this.motionCaptureTime=0}_updatePixelRatio(t){const e=window.devicePixelRatio;matchMedia(`(resolution: ${e}dppx)`).addEventListener("change",this._updatePixelRatio.bind(this,!0),{once:!0}),t&&this.updateViewer()}_motionCaptureControlsEnableChanged(t,e){this.renderRoot.querySelector("#motionCapture").style.display=t?"block":"none"}_transformEnableChanged(t,e){this.threeViewer&&(t?(void 0===this.transformInteractor&&(this.transformInteractor=new df(this.renderRoot.querySelector("#dataVizDiv"))),this.threeViewer.addInteractor(this.transformInteractor),this.transformRotateDisable&&(this.transformInteractor.enableRotate=!1),this.transformZoomDisable&&(this.transformInteractor.enableZoom=!1),this.transformPanDisable&&(this.transformInteractor.enablePan=!1),this.transformClientOnly&&(this.transformInteractor.clientOnly=!0)):this.threeViewer.removeInteractor(this.transformInteractor))}_transformClientOnlyChanged(t,e){this.transformInteractor&&(this.transformInteractor.clientOnly=t),this.zoomRectangleInteractor&&(this.zoomRectangleInteractor.clientOnly=t)}_transformRotateDisableChanged(t,e){this.transformInteractor&&(this.transformInteractor.enableRotate=!t)}_transformZoomDisableChanged(t,e){this.transformInteractor&&(this.transformInteractor.enableZoom=!t)}_transformPanDisableChanged(t,e){this.transformInteractor&&(this.transformInteractor.enablePan=!t)}resetTransform(){this.transformInteractor&&this.transformInteractor.reset()}zoomIn(){this.transformInteractor&&this.transformInteractor.zoomIn()}zoomOut(){this.transformInteractor&&this.transformInteractor.zoomOut()}panTo(t,e,n){this.transformInteractor&&this.transformInteractor.panTo(t,e,n)}_getTransformComponents(){var t,e=new Ci,n=new Ai,i=new Ci,r=new lr;return this.transformInteractor&&(t=this.transformInteractor.object.matrix),t.decompose(e,n,i),r.setFromQuaternion(n),{position:e.toArray(),rotation:[180*r.x/Math.PI,180*r.y/Math.PI,180*r.z/Math.PI],rotationOrder:r.order,scale:100*i.x}}getTransformMatrix(){if(this.transformInteractor)return this.transformInteractor.object.matrix.elements.slice()}runAnimation(){if(this.threeViewer){var t=window.getComputedStyle(this,null),e={transform:this.motionCaptureFrames.length>0?JSON.stringify(this.motionCaptureFrames):null};this._applyCustomCssProperties(e,t,{scene:"--avs-scene-animations",sceneTitle:"--avs-scene-title-animations",chart:"--avs-chart-animations",chartTitle:"--avs-chart-title-animations",axis:"--avs-axis-animations",legend:"--avs-legend-animations",legendTitle:"--avs-legend-title-animations",glyph:"--avs-glyph-animations"}),this.animator.setStyleMap(e),this.threeViewer.runAnimation()}}_animatedGlyphsVisibleChanged(t,e){this.threeViewer&&this.threeViewer.setVisibleAnimatedGlyphs(t)}_animatedGlyphsEnableChanged(t,e){this.threeViewer&&this.threeViewer.setEnableAnimatedGlyphs(t)}_transformValueChanged(){var t=void 0!==this.transformTwistAngle?this.transformTwistAngle*Math.PI/180:0,e=void 0!==this.transformTiltAngle?this.transformTiltAngle*Math.PI/180:0,n=void 0!==this.transformScale?this.transformScale/100:1,i=Math.sin(t),r=Math.cos(t),a=Math.sin(e),s=Math.cos(e),o=[r*n,0,s*i*n,0,0,s*n,-a*n,0,-i*n,r*a*n,r*s*n,0,0,0,0,1];this.transformMatrix=o,this.transformInteractor&&this.transformInteractor.object.matrix.fromArray(o)}async _motionCaptureValueChanged(t,e){if(t){try{this.motionCaptureFrames=JSON.parse(t)}catch{const e=atob(t.replaceAll("_","/").replaceAll("-","+")),n=await this._decompress(e);this.motionCaptureFrames=JSON.parse(n)}this.motionCaptureFrames||(this.motionCaptureFrames=[]),this.motionCaptureFrames.length>0?(this.renderRoot.querySelector("#motionCapturePlay").classList.remove("disabled"),this.renderRoot.querySelector("#motionCaptureSnapshotLabel").innerHTML=String(this.motionCaptureFrames.length),this.renderRoot.querySelector("#motionCaptureDelay").classList.remove("disabled"),this.renderRoot.querySelector("#motionCaptureDelayLabel").innerHTML="2",this.renderRoot.querySelector("#motionCaptureClear").classList.remove("disabled"),this.renderRoot.querySelector("#motionCaptureCopyData").classList.remove("disabled"),this.renderRoot.querySelector("#motionCaptureCopyUrl").classList.remove("disabled"),this.motionCaptureDelay=2,this.motionCaptureTime=this.motionCaptureFrames[this.motionCaptureFrames.length-1].time/1e3):(this.renderRoot.querySelector("#motionCapturePlay").classList.add("disabled"),this.renderRoot.querySelector("#motionCaptureSnapshotLabel").innerHTML="0",this.renderRoot.querySelector("#motionCaptureDelay").classList.add("disabled"),this.renderRoot.querySelector("#motionCaptureDelayLabel").innerHTML="0",this.renderRoot.querySelector("#motionCaptureClear").classList.add("disabled"),this.renderRoot.querySelector("#motionCaptureCopyData").classList.add("disabled"),this.renderRoot.querySelector("#motionCaptureCopyUrl").classList.add("disabled"),this.motionCaptureDelay=0,this.motionCaptureTime=0)}}_zoomRectangleEnableChanged(t,e){this.threeViewer&&(t?(void 0===this.zoomRectangleInteractor&&(this.zoomRectangleInteractor=new bf(this)),this.threeViewer.addInteractor(this.zoomRectangleInteractor),this.transformClientOnly&&(this.zoomRectangleInteractor.clientOnly=!0)):this.threeViewer.removeInteractor(this.zoomRectangleInteractor))}_panEnableChanged(t,e){this.threeViewer&&(t?(void 0===this.panInteractor&&(this.panInteractor=new vf(this)),this.threeViewer.addInteractor(this.panInteractor),this.panZoomEnable&&(this.panInteractor.addEventListener("change",this._handlePanChanged.bind(this)),this.panInteractor.addEventListener("zoom",this._handlePanZoom.bind(this)),this.panInteractor.addEventListener("zoomEnd",this._handlePanZoomEnd.bind(this))),this.panInteractor.setWidthZoomLevel(this.panWidthZoomLevel),this.panInteractor.setHeightZoomLevel(this.panHeightZoomLevel),this.panInteractor.setMaximumZoomLevel(this.panMaximumZoomLevel),this.panInteractor.saveState()):(this.threeViewer.removeInteractor(this.panInteractor),this.panZoomEnable&&(this.panInteractor.removeEventListener("change",this._handlePanChanged.bind(this)),this.panInteractor.removeEventListener("zoom",this._handlePanZoom.bind(this)),this.panInteractor.removeEventListener("zoomEnd",this._handlePanZoomEnd.bind(this)))))}_panZoomEnableChanged(t,e){this.threeViewer&&this.panInteractor&&(t?(this.panInteractor.addEventListener("change",this._handlePanChanged.bind(this)),this.panInteractor.addEventListener("zoom",this._handlePanZoom.bind(this)),this.panInteractor.addEventListener("zoomEnd",this._handlePanZoomEnd.bind(this))):(this.panInteractor.removeEventListener("change",this._handlePanChanged.bind(this)),this.panInteractor.removeEventListener("zoom",this._handlePanZoom.bind(this)),this.panInteractor.removeEventListener("zoomEnd",this._handlePanZoomEnd.bind(this))))}_handlePanChanged(t){this.dispatchEvent(new CustomEvent("avs-pan-info",t))}_handlePanZoom(t){window.clearTimeout(this.zoomOverlayTimeoutId);var e=Math.round(t.detail.widthZoomLevel),n=Math.round(t.detail.heightZoomLevel);this.renderRoot.querySelector("#zoomOverlay").innerHTML=e===n?e+"%":e+"%,"+n+"%";var i=this._getAdjustedCoords(t.detail.clientX,t.detail.clientY);const r=this.renderRoot.querySelector("#zoomOverlay");r.style.left=i.x+"px",r.style.top=i.y+"px",r.style.opacity="1",this.pointerDown=!0,this._dispatchPickEvents({type:"HOVER",x:0,y:0,selected:[]}),this.zoomOverlayTimeoutId=window.setTimeout((()=>{this.renderRoot.querySelector("#zoomOverlay").style.opacity="0",this.pointerDown=!1}),1e3)}_handlePanZoomEnd(t){this.panWidthZoomLevel=t.detail.widthZoomLevel,this.panHeightZoomLevel=t.detail.heightZoomLevel}_panWidthZoomLevelChanged(t,e){this.panInteractor&&this.panInteractor.setWidthZoomLevel(t)}_panHeightZoomLevelChanged(t,e){this.panInteractor&&this.panInteractor.setHeightZoomLevel(t)}_panMaximumZoomLevelChanged(t,e){this.panInteractor&&this.panInteractor.setMaximumZoomLevel(t)}resetPan(){this.panInteractor&&this.panInteractor.reset()}_rendererChanged(t,e){if("IMAGE"===e)this.sceneImage.src="data:,",this.renderRoot.querySelector("#dataVizDiv").removeChild(this.sceneImage),this.renderRoot.querySelector("#dataVizDiv").removeChild(this.sceneImageMap);else if("SVG"===e){for(var n=this.svgDiv;n.firstChild;)n.removeChild(n.firstChild);this.renderRoot.querySelector("#dataVizDiv").removeChild(this.svgDiv)}else this.threeViewer&&(this.threeViewer.clearGeometry(),this.threeViewer.render(),this.renderRoot.querySelector("#dataVizDiv").removeChild(this.threeViewer.domElement));if("IMAGE"===t)void 0===this.sceneImage&&(this.sceneImage=document.createElement("img"),this.sceneImage.setAttribute("id","sceneImage"),this.sceneImage.setAttribute("usemap","#sceneImageMap"),this.sceneImageMap=document.createElement("map"),this.sceneImageMap.setAttribute("id","sceneImageMap"),this.sceneImageMap.setAttribute("name","sceneImageMap")),this.renderRoot.querySelector("#dataVizDiv").appendChild(this.sceneImage),this.renderRoot.querySelector("#dataVizDiv").appendChild(this.sceneImageMap),this.threeViewer=null;else if("SVG"===t)void 0===this.svgDiv&&(this.svgDiv=document.createElement("div"),this.svgDiv.setAttribute("id","svgDiv")),this.renderRoot.querySelector("#dataVizDiv").appendChild(this.svgDiv),this.threeViewer=null;else{if(!this.threeViewer){this.threeViewer=new of;var i="avsDefaultWebGLRenderer",r=document.getElementById(i);null==r&&((r=new om).setAttribute("id",i),document.body.appendChild(r)),this.threeViewer.setWebGLRenderer(r.webGLRenderer),this.animator=new Ef,this.threeViewer.setAnimator(this.animator)}this.renderRoot.querySelector("#dataVizDiv").appendChild(this.threeViewer.domElement)}}_trackEnableChanged(t,e){t?(void 0===this.rectCanvas&&(this.rectCanvas=document.createElement("canvas"),this.rectCanvas.setAttribute("id","rectCanvas"),this.rectCtx=this.rectCanvas.getContext("2d")),this.renderRoot.appendChild(this.rectCanvas)):this.renderRoot.removeChild(this.rectCanvas)}_displayCanvasChanged(t,e){this.threeViewer&&(this.threeViewer.displayCanvas=t)}setTooltipHTML(t){this.renderRoot.querySelector("#tooltip").innerHTML=t}showTooltip(t,e){var n=this.renderRoot.querySelector("#tooltip"),i=this._calcTooltipPosition(n,t,e);n.style.left=i.x+"px",n.style.top=i.y+"px",n.style.opacity="1"}hideTooltip(){this.renderRoot.querySelector("#tooltip").style.opacity="0"}_calcTooltipPosition(t,e,n){var i=this.renderRoot.querySelector("#dataVizDiv"),r=this._getOffset(i),a=-Math.min(0,r.top-window.pageYOffset),s=-Math.min(0,r.left-window.pageXOffset),o=-Math.min(0,window.innerHeight-(i.offsetHeight+r.top-window.pageYOffset)),l=-Math.min(0,window.innerWidth-(i.offsetWidth+r.left-window.pageXOffset)),c=(i.offsetHeight-a-o)/2+a,h={x:0,y:0};if(e<(i.offsetWidth-s-l)/2+s){var d=n<c?15:5;h.x=e+d+i.offsetLeft}else h.x=e-10+i.offsetLeft-t.offsetWidth;return h.y=n<c?n+5+i.offsetTop:n-10+i.offsetTop-t.offsetHeight,h}_getOffset(t){var e=t.getBoundingClientRect(),n=window.pageXOffset||document.documentElement.scrollLeft,i=window.pageYOffset||document.documentElement.scrollTop;return{top:e.top+i,left:e.left+n}}},Af([ut({attribute:"manual-update",type:Boolean})],t.AvsGoDataViz.prototype,"manualUpdate",void 0),Af([ut({attribute:"display-canvas",type:Boolean})],t.AvsGoDataViz.prototype,"displayCanvas",void 0),Af([ut()],t.AvsGoDataViz.prototype,"url",void 0),Af([ut({attribute:"url-load-json-file",type:Boolean})],t.AvsGoDataViz.prototype,"urlLoadJsonFile",void 0),Af([ut({attribute:"data-source-name"})],t.AvsGoDataViz.prototype,"dataSourceName",void 0),Af([ut({attribute:"data-source-user-properties"})],t.AvsGoDataViz.prototype,"dataSourceUserProperties",void 0),Af([ut({attribute:"scene-name"})],t.AvsGoDataViz.prototype,"sceneName",void 0),Af([ut({attribute:"scene-user-properties"})],t.AvsGoDataViz.prototype,"sceneUserProperties",void 0),Af([ut({attribute:"renderer-name"})],t.AvsGoDataViz.prototype,"rendererName",void 0),Af([ut({attribute:"renderer-user-properties"})],t.AvsGoDataViz.prototype,"rendererUserProperties",void 0),Af([ut()],t.AvsGoDataViz.prototype,"renderer",void 0),Af([ut({attribute:"stream-enable",type:Boolean})],t.AvsGoDataViz.prototype,"streamEnable",void 0),Af([ut({attribute:"stream-chunk-size-first"})],t.AvsGoDataViz.prototype,"streamChunkSizeFirst",void 0),Af([ut({attribute:"stream-chunk-size"})],t.AvsGoDataViz.prototype,"streamChunkSize",void 0),Af([ut({attribute:"theme-name"})],t.AvsGoDataViz.prototype,"themeName",void 0),Af([ut({attribute:"resize-threshold"})],t.AvsGoDataViz.prototype,"resizeThreshold",void 0),Af([ut({attribute:"pointer-timeout"})],t.AvsGoDataViz.prototype,"pointerTimeout",void 0),Af([ut({attribute:"tap-enable",type:Boolean})],t.AvsGoDataViz.prototype,"tapEnable",void 0),Af([ut({attribute:"tap-level"})],t.AvsGoDataViz.prototype,"tapLevel",void 0),Af([ut({attribute:"tap-depth"})],t.AvsGoDataViz.prototype,"tapDepth",void 0),Af([ut({attribute:"tap-highlight-enable",type:Boolean})],t.AvsGoDataViz.prototype,"tapHighlightEnable",void 0),Af([ut({attribute:"tap-highlight-color"})],t.AvsGoDataViz.prototype,"tapHighlightColor",void 0),Af([ut({attribute:"tap-highlight-layer-enable",type:Boolean})],t.AvsGoDataViz.prototype,"tapHighlightLayerEnable",void 0),Af([ut({attribute:"tap-process-event-on-client",type:Boolean})],t.AvsGoDataViz.prototype,"tapProcessEventOnClient",void 0),Af([ut({attribute:"track-enable",type:Boolean})],t.AvsGoDataViz.prototype,"trackEnable",void 0),Af([ut({attribute:"track-level"})],t.AvsGoDataViz.prototype,"trackLevel",void 0),Af([ut({attribute:"track-depth"})],t.AvsGoDataViz.prototype,"trackDepth",void 0),Af([ut({attribute:"track-highlight-enable",type:Boolean})],t.AvsGoDataViz.prototype,"trackHighlightEnable",void 0),Af([ut({attribute:"track-highlight-color"})],t.AvsGoDataViz.prototype,"trackHighlightColor",void 0),Af([ut({attribute:"track-highlight-layer-enable",type:Boolean})],t.AvsGoDataViz.prototype,"trackHighlightLayerEnable",void 0),Af([ut({attribute:"track-process-event-on-client",type:Boolean})],t.AvsGoDataViz.prototype,"trackProcessEventOnClient",void 0),Af([ut({attribute:"hover-enable",type:Boolean})],t.AvsGoDataViz.prototype,"hoverEnable",void 0),Af([ut({attribute:"hover-level"})],t.AvsGoDataViz.prototype,"hoverLevel",void 0),Af([ut({attribute:"hover-depth"})],t.AvsGoDataViz.prototype,"hoverDepth",void 0),Af([ut({attribute:"hover-highlight-enable",type:Boolean})],t.AvsGoDataViz.prototype,"hoverHighlightEnable",void 0),Af([ut({attribute:"hover-highlight-color"})],t.AvsGoDataViz.prototype,"hoverHighlightColor",void 0),Af([ut({attribute:"hover-highlight-layer-enable",type:Boolean})],t.AvsGoDataViz.prototype,"hoverHighlightLayerEnable",void 0),Af([ut({attribute:"transform-enable",type:Boolean})],t.AvsGoDataViz.prototype,"transformEnable",void 0),Af([ut({attribute:"transform-client-only",type:Boolean})],t.AvsGoDataViz.prototype,"transformClientOnly",void 0),Af([ut({attribute:"transform-rotate-disable",type:Boolean})],t.AvsGoDataViz.prototype,"transformRotateDisable",void 0),Af([ut({attribute:"transform-zoom-disable",type:Boolean})],t.AvsGoDataViz.prototype,"transformZoomDisable",void 0),Af([ut({attribute:"transform-pan-disable",type:Boolean})],t.AvsGoDataViz.prototype,"transformPanDisable",void 0),Af([ut({attribute:"transform-twist-angle"})],t.AvsGoDataViz.prototype,"transformTwistAngle",void 0),Af([ut({attribute:"transform-tilt-angle"})],t.AvsGoDataViz.prototype,"transformTiltAngle",void 0),Af([ut({attribute:"transform-scale"})],t.AvsGoDataViz.prototype,"transformScale",void 0),Af([ut({attribute:"motion-capture"})],t.AvsGoDataViz.prototype,"motionCapture",void 0),Af([ut({attribute:"zoom-rectangle-enable",type:Boolean})],t.AvsGoDataViz.prototype,"zoomRectangleEnable",void 0),Af([ut({attribute:"pan-enable",type:Boolean})],t.AvsGoDataViz.prototype,"panEnable",void 0),Af([ut({attribute:"pan-zoom-enable",type:Boolean})],t.AvsGoDataViz.prototype,"panZoomEnable",void 0),Af([ut({attribute:"pan-width-zoom-level"})],t.AvsGoDataViz.prototype,"panWidthZoomLevel",void 0),Af([ut({attribute:"pan-height-zoom-level"})],t.AvsGoDataViz.prototype,"panHeightZoomLevel",void 0),Af([ut({attribute:"pan-maximum-zoom-level"})],t.AvsGoDataViz.prototype,"panMaximumZoomLevel",void 0),Af([ut({attribute:"animated-glyphs-visible",type:Boolean})],t.AvsGoDataViz.prototype,"animatedGlyphsVisible",void 0),Af([ut({attribute:"animated-glyphs-enable",type:Boolean})],t.AvsGoDataViz.prototype,"animatedGlyphsEnable",void 0),Af([ut({attribute:"motion-capture-controls-enable",type:Boolean})],t.AvsGoDataViz.prototype,"motionCaptureControlsEnable",void 0),t.AvsGoDataViz=Af([ct("avs-go-dataviz")],t.AvsGoDataViz);
|
|
360
339
|
/**
|
|
361
340
|
* @license
|
|
362
|
-
* Copyright 2018 Advanced Visual Systems Inc.
|
|
341
|
+
* Copyright 2018-2026 Advanced Visual Systems Inc.
|
|
363
342
|
*
|
|
364
343
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
365
344
|
* you may not use this file except in compliance with the License.
|
|
@@ -376,12 +355,12 @@ var Rf=function(t,e,n,i){var r,a=arguments.length,s=a<3?e:null===i?i=Object.getO
|
|
|
376
355
|
* This product includes software developed at
|
|
377
356
|
* Advanced Visual Systems Inc. (http://www.avs.com)
|
|
378
357
|
*/
|
|
379
|
-
var
|
|
380
|
-
/*! @license DOMPurify 3.4.
|
|
381
|
-
const{entries:Lf,setPrototypeOf:Df,isFrozen:Nf,getPrototypeOf:Of,getOwnPropertyDescriptor:Uf}=Object;let{freeze:Ff,seal:zf,create:kf}=Object,{apply:Bf,construct:Gf}="undefined"!=typeof Reflect&&Reflect;Ff||(Ff=function(t){return t}),zf||(zf=function(t){return t}),Bf||(Bf=function(t,e){for(var n=arguments.length,i=new Array(n>2?n-2:0),r=2;r<n;r++)i[r-2]=arguments[r];return t.apply(e,i)}),Gf||(Gf=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return new t(...n)});const Vf=cg(Array.prototype.forEach),Hf=cg(Array.prototype.lastIndexOf),Wf=cg(Array.prototype.pop),jf=cg(Array.prototype.push),Xf=cg(Array.prototype.splice),qf=Array.isArray,Yf=cg(String.prototype.toLowerCase),Zf=cg(String.prototype.toString),$f=cg(String.prototype.match),Jf=cg(String.prototype.replace),Kf=cg(String.prototype.indexOf),Qf=cg(String.prototype.trim),tg=cg(Number.prototype.toString),eg=cg(Boolean.prototype.toString),ng="undefined"==typeof BigInt?null:cg(BigInt.prototype.toString),ig="undefined"==typeof Symbol?null:cg(Symbol.prototype.toString),rg=cg(Object.prototype.hasOwnProperty),ag=cg(Object.prototype.toString),sg=cg(RegExp.prototype.test),og=(lg=TypeError,function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return Gf(lg,e)});var lg;function cg(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return Bf(t,e,i)}}function hg(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Yf;if(Df&&Df(t,null),!qf(e))return t;let i=e.length;for(;i--;){let r=e[i];if("string"==typeof r){const t=n(r);t!==r&&(Nf(e)||(e[i]=t),r=t)}t[r]=!0}return t}function dg(t){for(let e=0;e<t.length;e++)rg(t,e)||(t[e]=null);return t}function ug(t){const e=kf(null);for(const[n,i]of Lf(t))rg(t,n)&&(qf(i)?e[n]=dg(i):i&&"object"==typeof i&&i.constructor===Object?e[n]=ug(i):e[n]=i);return e}function pg(t,e){for(;null!==t;){const n=Uf(t,e);if(n){if(n.get)return cg(n.get);if("function"==typeof n.value)return cg(n.value)}t=Of(t)}return function(){return null}}const mg=Ff(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),fg=Ff(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),gg=Ff(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),vg=Ff(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),_g=Ff(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),yg=Ff(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),xg=Ff(["#text"]),bg=Ff(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Sg=Ff(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Mg=Ff(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),wg=Ff(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Eg=zf(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Tg=zf(/<%[\w\W]*|[\w\W]*%>/gm),Ag=zf(/\$\{[\w\W]*/gm),Cg=zf(/^data-[\-\w.\u00B7-\uFFFF]+$/),Rg=zf(/^aria-[\-\w]+$/),Ig=zf(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Pg=zf(/^(?:\w+script|data):/i),Lg=zf(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Dg=zf(/^html$/i),Ng=zf(/^[a-z][.\w]*(-[.\w]+)+$/i);var Og=Object.freeze({__proto__:null,ARIA_ATTR:Rg,ATTR_WHITESPACE:Lg,CUSTOM_ELEMENT:Ng,DATA_ATTR:Cg,DOCTYPE_NAME:Dg,ERB_EXPR:Tg,IS_ALLOWED_URI:Ig,IS_SCRIPT_OR_DATA:Pg,MUSTACHE_EXPR:Eg,TMPLIT_EXPR:Ag});const Ug=1,Fg=3,zg=7,kg=8,Bg=9,Gg=function(){return"undefined"==typeof window?null:window};var Vg=function t(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Gg();const n=e=>t(e);if(n.version="3.4.2",n.removed=[],!e||!e.document||e.document.nodeType!==Bg||!e.Element)return n.isSupported=!1,n;let{document:i}=e;const r=i,a=r.currentScript,{DocumentFragment:s,HTMLTemplateElement:o,Node:l,Element:c,NodeFilter:h,NamedNodeMap:d=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:u,DOMParser:p,trustedTypes:m}=e,f=c.prototype,g=pg(f,"cloneNode"),v=pg(f,"remove"),_=pg(f,"nextSibling"),y=pg(f,"childNodes"),x=pg(f,"parentNode");if("function"==typeof o){const t=i.createElement("template");t.content&&t.content.ownerDocument&&(i=t.content.ownerDocument)}let b,S="";const{implementation:M,createNodeIterator:w,createDocumentFragment:E,getElementsByTagName:T}=i,{importNode:A}=r;let C={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof Lf&&"function"==typeof x&&M&&void 0!==M.createHTMLDocument;const{MUSTACHE_EXPR:R,ERB_EXPR:I,TMPLIT_EXPR:P,DATA_ATTR:L,ARIA_ATTR:D,IS_SCRIPT_OR_DATA:N,ATTR_WHITESPACE:O,CUSTOM_ELEMENT:U}=Og;let{IS_ALLOWED_URI:F}=Og,z=null;const k=hg({},[...mg,...fg,...gg,..._g,...xg]);let B=null;const G=hg({},[...bg,...Sg,...Mg,...wg]);let V=Object.seal(kf(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),H=null,W=null;const j=Object.seal(kf(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let X=!0,q=!0,Y=!1,Z=!0,$=!1,J=!0,K=!1,Q=!1,tt=!1,et=!1,nt=!1,it=!1,rt=!0,at=!1;const st="user-content-";let ot=!0,lt=!1,ct={},ht=null;const dt=hg({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let ut=null;const pt=hg({},["audio","video","img","source","image","track"]);let mt=null;const ft=hg({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),gt="http://www.w3.org/1998/Math/MathML",vt="http://www.w3.org/2000/svg",_t="http://www.w3.org/1999/xhtml";let yt=_t,xt=!1,bt=null;const St=hg({},[gt,vt,_t],Zf);let Mt=hg({},["mi","mo","mn","ms","mtext"]),wt=hg({},["annotation-xml"]);const Et=hg({},["title","style","font","a","script"]);let Tt=null;const At=["application/xhtml+xml","text/html"];let Ct=null,Rt=null;const It=i.createElement("form"),Pt=function(t){return t instanceof RegExp||t instanceof Function},Lt=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(Rt&&Rt===t)return;t&&"object"==typeof t||(t={}),t=ug(t),Tt=-1===At.indexOf(t.PARSER_MEDIA_TYPE)?"text/html":t.PARSER_MEDIA_TYPE,Ct="application/xhtml+xml"===Tt?Zf:Yf,z=rg(t,"ALLOWED_TAGS")&&qf(t.ALLOWED_TAGS)?hg({},t.ALLOWED_TAGS,Ct):k,B=rg(t,"ALLOWED_ATTR")&&qf(t.ALLOWED_ATTR)?hg({},t.ALLOWED_ATTR,Ct):G,bt=rg(t,"ALLOWED_NAMESPACES")&&qf(t.ALLOWED_NAMESPACES)?hg({},t.ALLOWED_NAMESPACES,Zf):St,mt=rg(t,"ADD_URI_SAFE_ATTR")&&qf(t.ADD_URI_SAFE_ATTR)?hg(ug(ft),t.ADD_URI_SAFE_ATTR,Ct):ft,ut=rg(t,"ADD_DATA_URI_TAGS")&&qf(t.ADD_DATA_URI_TAGS)?hg(ug(pt),t.ADD_DATA_URI_TAGS,Ct):pt,ht=rg(t,"FORBID_CONTENTS")&&qf(t.FORBID_CONTENTS)?hg({},t.FORBID_CONTENTS,Ct):dt,H=rg(t,"FORBID_TAGS")&&qf(t.FORBID_TAGS)?hg({},t.FORBID_TAGS,Ct):ug({}),W=rg(t,"FORBID_ATTR")&&qf(t.FORBID_ATTR)?hg({},t.FORBID_ATTR,Ct):ug({}),ct=!!rg(t,"USE_PROFILES")&&(t.USE_PROFILES&&"object"==typeof t.USE_PROFILES?ug(t.USE_PROFILES):t.USE_PROFILES),X=!1!==t.ALLOW_ARIA_ATTR,q=!1!==t.ALLOW_DATA_ATTR,Y=t.ALLOW_UNKNOWN_PROTOCOLS||!1,Z=!1!==t.ALLOW_SELF_CLOSE_IN_ATTR,$=t.SAFE_FOR_TEMPLATES||!1,J=!1!==t.SAFE_FOR_XML,K=t.WHOLE_DOCUMENT||!1,et=t.RETURN_DOM||!1,nt=t.RETURN_DOM_FRAGMENT||!1,it=t.RETURN_TRUSTED_TYPE||!1,tt=t.FORCE_BODY||!1,rt=!1!==t.SANITIZE_DOM,at=t.SANITIZE_NAMED_PROPS||!1,ot=!1!==t.KEEP_CONTENT,lt=t.IN_PLACE||!1,F=function(t){try{return sg(t,""),!0}catch(t){return!1}}(t.ALLOWED_URI_REGEXP)?t.ALLOWED_URI_REGEXP:Ig,yt="string"==typeof t.NAMESPACE?t.NAMESPACE:_t,Mt=rg(t,"MATHML_TEXT_INTEGRATION_POINTS")&&t.MATHML_TEXT_INTEGRATION_POINTS&&"object"==typeof t.MATHML_TEXT_INTEGRATION_POINTS?ug(t.MATHML_TEXT_INTEGRATION_POINTS):hg({},["mi","mo","mn","ms","mtext"]),wt=rg(t,"HTML_INTEGRATION_POINTS")&&t.HTML_INTEGRATION_POINTS&&"object"==typeof t.HTML_INTEGRATION_POINTS?ug(t.HTML_INTEGRATION_POINTS):hg({},["annotation-xml"]);const e=rg(t,"CUSTOM_ELEMENT_HANDLING")&&t.CUSTOM_ELEMENT_HANDLING&&"object"==typeof t.CUSTOM_ELEMENT_HANDLING?ug(t.CUSTOM_ELEMENT_HANDLING):kf(null);if(V=kf(null),rg(e,"tagNameCheck")&&Pt(e.tagNameCheck)&&(V.tagNameCheck=e.tagNameCheck),rg(e,"attributeNameCheck")&&Pt(e.attributeNameCheck)&&(V.attributeNameCheck=e.attributeNameCheck),rg(e,"allowCustomizedBuiltInElements")&&"boolean"==typeof e.allowCustomizedBuiltInElements&&(V.allowCustomizedBuiltInElements=e.allowCustomizedBuiltInElements),$&&(q=!1),nt&&(et=!0),ct&&(z=hg({},xg),B=kf(null),!0===ct.html&&(hg(z,mg),hg(B,bg)),!0===ct.svg&&(hg(z,fg),hg(B,Sg),hg(B,wg)),!0===ct.svgFilters&&(hg(z,gg),hg(B,Sg),hg(B,wg)),!0===ct.mathMl&&(hg(z,_g),hg(B,Mg),hg(B,wg))),j.tagCheck=null,j.attributeCheck=null,rg(t,"ADD_TAGS")&&("function"==typeof t.ADD_TAGS?j.tagCheck=t.ADD_TAGS:qf(t.ADD_TAGS)&&(z===k&&(z=ug(z)),hg(z,t.ADD_TAGS,Ct))),rg(t,"ADD_ATTR")&&("function"==typeof t.ADD_ATTR?j.attributeCheck=t.ADD_ATTR:qf(t.ADD_ATTR)&&(B===G&&(B=ug(B)),hg(B,t.ADD_ATTR,Ct))),rg(t,"ADD_URI_SAFE_ATTR")&&qf(t.ADD_URI_SAFE_ATTR)&&hg(mt,t.ADD_URI_SAFE_ATTR,Ct),rg(t,"FORBID_CONTENTS")&&qf(t.FORBID_CONTENTS)&&(ht===dt&&(ht=ug(ht)),hg(ht,t.FORBID_CONTENTS,Ct)),rg(t,"ADD_FORBID_CONTENTS")&&qf(t.ADD_FORBID_CONTENTS)&&(ht===dt&&(ht=ug(ht)),hg(ht,t.ADD_FORBID_CONTENTS,Ct)),ot&&(z["#text"]=!0),K&&hg(z,["html","head","body"]),z.table&&(hg(z,["tbody"]),delete H.tbody),t.TRUSTED_TYPES_POLICY){if("function"!=typeof t.TRUSTED_TYPES_POLICY.createHTML)throw og('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof t.TRUSTED_TYPES_POLICY.createScriptURL)throw og('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');b=t.TRUSTED_TYPES_POLICY,S=b.createHTML("")}else void 0===b&&(b=function(t,e){if("object"!=typeof t||"function"!=typeof t.createPolicy)return null;let n=null;const i="data-tt-policy-suffix";e&&e.hasAttribute(i)&&(n=e.getAttribute(i));const r="dompurify"+(n?"#"+n:"");try{return t.createPolicy(r,{createHTML:t=>t,createScriptURL:t=>t})}catch(t){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(m,a)),null!==b&&"string"==typeof S&&(S=b.createHTML(""));Ff&&Ff(t),Rt=t},Dt=hg({},[...fg,...gg,...vg]),Nt=hg({},[..._g,...yg]),Ot=function(t){jf(n.removed,{element:t});try{x(t).removeChild(t)}catch(e){v(t)}},Ut=function(t,e){try{jf(n.removed,{attribute:e.getAttributeNode(t),from:e})}catch(t){jf(n.removed,{attribute:null,from:e})}if(e.removeAttribute(t),"is"===t)if(et||nt)try{Ot(e)}catch(t){}else try{e.setAttribute(t,"")}catch(t){}},Ft=function(t){let e=null,n=null;if(tt)t="<remove></remove>"+t;else{const e=$f(t,/^[\r\n\t ]+/);n=e&&e[0]}"application/xhtml+xml"===Tt&&yt===_t&&(t='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+t+"</body></html>");const r=b?b.createHTML(t):t;if(yt===_t)try{e=(new p).parseFromString(r,Tt)}catch(t){}if(!e||!e.documentElement){e=M.createDocument(yt,"template",null);try{e.documentElement.innerHTML=xt?S:r}catch(t){}}const a=e.body||e.documentElement;return t&&n&&a.insertBefore(i.createTextNode(n),a.childNodes[0]||null),yt===_t?T.call(e,K?"html":"body")[0]:K?e.documentElement:a},zt=function(t){return w.call(t.ownerDocument||t,t,h.SHOW_ELEMENT|h.SHOW_COMMENT|h.SHOW_TEXT|h.SHOW_PROCESSING_INSTRUCTION|h.SHOW_CDATA_SECTION,null)},kt=function(t){return t instanceof u&&("string"!=typeof t.nodeName||"string"!=typeof t.textContent||"function"!=typeof t.removeChild||!(t.attributes instanceof d)||"function"!=typeof t.removeAttribute||"function"!=typeof t.setAttribute||"string"!=typeof t.namespaceURI||"function"!=typeof t.insertBefore||"function"!=typeof t.hasChildNodes)},Bt=function(t){return"function"==typeof l&&t instanceof l};function Gt(t,e,i){Vf(t,(t=>{t.call(n,e,i,Rt)}))}const Vt=function(t){let e=null;if(Gt(C.beforeSanitizeElements,t,null),kt(t))return Ot(t),!0;const i=Ct(t.nodeName);if(Gt(C.uponSanitizeElement,t,{tagName:i,allowedTags:z}),J&&t.hasChildNodes()&&!Bt(t.firstElementChild)&&sg(/<[/\w!]/g,t.innerHTML)&&sg(/<[/\w!]/g,t.textContent))return Ot(t),!0;if(J&&t.namespaceURI===_t&&"style"===i&&Bt(t.firstElementChild))return Ot(t),!0;if(t.nodeType===zg)return Ot(t),!0;if(J&&t.nodeType===kg&&sg(/<[/\w]/g,t.data))return Ot(t),!0;if(H[i]||!(j.tagCheck instanceof Function&&j.tagCheck(i))&&!z[i]){if(!H[i]&&jt(i)){if(V.tagNameCheck instanceof RegExp&&sg(V.tagNameCheck,i))return!1;if(V.tagNameCheck instanceof Function&&V.tagNameCheck(i))return!1}if(ot&&!ht[i]){const e=x(t)||t.parentNode,n=y(t)||t.childNodes;if(n&&e)for(let i=n.length-1;i>=0;--i){const r=g(n[i],!0);e.insertBefore(r,_(t))}}return Ot(t),!0}return t instanceof c&&!function(t){let e=x(t);e&&e.tagName||(e={namespaceURI:yt,tagName:"template"});const n=Yf(t.tagName),i=Yf(e.tagName);return!!bt[t.namespaceURI]&&(t.namespaceURI===vt?e.namespaceURI===_t?"svg"===n:e.namespaceURI===gt?"svg"===n&&("annotation-xml"===i||Mt[i]):Boolean(Dt[n]):t.namespaceURI===gt?e.namespaceURI===_t?"math"===n:e.namespaceURI===vt?"math"===n&&wt[i]:Boolean(Nt[n]):t.namespaceURI===_t?!(e.namespaceURI===vt&&!wt[i])&&!(e.namespaceURI===gt&&!Mt[i])&&!Nt[n]&&(Et[n]||!Dt[n]):!("application/xhtml+xml"!==Tt||!bt[t.namespaceURI]))}(t)?(Ot(t),!0):"noscript"!==i&&"noembed"!==i&&"noframes"!==i||!sg(/<\/no(script|embed|frames)/i,t.innerHTML)?($&&t.nodeType===Fg&&(e=t.textContent,Vf([R,I,P],(t=>{e=Jf(e,t," ")})),t.textContent!==e&&(jf(n.removed,{element:t.cloneNode()}),t.textContent=e)),Gt(C.afterSanitizeElements,t,null),!1):(Ot(t),!0)},Ht=function(t,e,n){if(W[e])return!1;if(rt&&("id"===e||"name"===e)&&(n in i||n in It))return!1;const r=B[e]||j.attributeCheck instanceof Function&&j.attributeCheck(e,t);if(q&&!W[e]&&sg(L,e));else if(X&&sg(D,e));else if(!r||W[e]){if(!(jt(t)&&(V.tagNameCheck instanceof RegExp&&sg(V.tagNameCheck,t)||V.tagNameCheck instanceof Function&&V.tagNameCheck(t))&&(V.attributeNameCheck instanceof RegExp&&sg(V.attributeNameCheck,e)||V.attributeNameCheck instanceof Function&&V.attributeNameCheck(e,t))||"is"===e&&V.allowCustomizedBuiltInElements&&(V.tagNameCheck instanceof RegExp&&sg(V.tagNameCheck,n)||V.tagNameCheck instanceof Function&&V.tagNameCheck(n))))return!1}else if(mt[e]);else if(sg(F,Jf(n,O,"")));else if("src"!==e&&"xlink:href"!==e&&"href"!==e||"script"===t||0!==Kf(n,"data:")||!ut[t])if(Y&&!sg(N,Jf(n,O,"")));else if(n)return!1;return!0},Wt=hg({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),jt=function(t){return!Wt[Yf(t)]&&sg(U,t)},Xt=function(t){Gt(C.beforeSanitizeAttributes,t,null);const{attributes:e}=t;if(!e||kt(t))return;const i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:B,forceKeepAttr:void 0};let r=e.length;for(;r--;){const a=e[r],{name:s,namespaceURI:o,value:l}=a,c=Ct(s),h=l;let d="value"===s?h:Qf(h);if(i.attrName=c,i.attrValue=d,i.keepAttr=!0,i.forceKeepAttr=void 0,Gt(C.uponSanitizeAttribute,t,i),d=i.attrValue,!at||"id"!==c&&"name"!==c||0===Kf(d,st)||(Ut(s,t),d=st+d),J&&sg(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){Ut(s,t);continue}if("attributename"===c&&$f(d,"href")){Ut(s,t);continue}if(i.forceKeepAttr)continue;if(!i.keepAttr){Ut(s,t);continue}if(!Z&&sg(/\/>/i,d)){Ut(s,t);continue}$&&Vf([R,I,P],(t=>{d=Jf(d,t," ")}));const u=Ct(t.nodeName);if(Ht(u,c,d)){if(b&&"object"==typeof m&&"function"==typeof m.getAttributeType)if(o);else switch(m.getAttributeType(u,c)){case"TrustedHTML":d=b.createHTML(d);break;case"TrustedScriptURL":d=b.createScriptURL(d)}if(d!==h)try{o?t.setAttributeNS(o,s,d):t.setAttribute(s,d),kt(t)?Ot(t):Wf(n.removed)}catch(e){Ut(s,t)}}else Ut(s,t)}Gt(C.afterSanitizeAttributes,t,null)},qt=function(t){let e=null;const n=zt(t);for(Gt(C.beforeSanitizeShadowDOM,t,null);e=n.nextNode();)Gt(C.uponSanitizeShadowNode,e,null),Vt(e),Xt(e),e.content instanceof s&&qt(e.content);Gt(C.afterSanitizeShadowDOM,t,null)};return n.sanitize=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=null,a=null,o=null,c=null;if(xt=!t,xt&&(t="\x3c!--\x3e"),"string"!=typeof t&&!Bt(t)&&"string"!=typeof(t=function(t){switch(typeof t){case"string":return t;case"number":return tg(t);case"boolean":return eg(t);case"bigint":return ng?ng(t):"0";case"symbol":return ig?ig(t):"Symbol()";case"undefined":default:return ag(t);case"function":case"object":{if(null===t)return ag(t);const e=t,n=pg(e,"toString");if("function"==typeof n){const t=n(e);return"string"==typeof t?t:ag(t)}return ag(t)}}}(t)))throw og("dirty is not a string, aborting");if(!n.isSupported)return t;if(Q||Lt(e),n.removed=[],"string"==typeof t&&(lt=!1),lt){const e=t.nodeName;if("string"==typeof e){const t=Ct(e);if(!z[t]||H[t])throw og("root node is forbidden and cannot be sanitized in-place")}}else if(t instanceof l)i=Ft("\x3c!----\x3e"),a=i.ownerDocument.importNode(t,!0),a.nodeType===Ug&&"BODY"===a.nodeName||"HTML"===a.nodeName?i=a:i.appendChild(a);else{if(!et&&!$&&!K&&-1===t.indexOf("<"))return b&&it?b.createHTML(t):t;if(i=Ft(t),!i)return et?null:it?S:""}i&&tt&&Ot(i.firstChild);const h=zt(lt?t:i);for(;o=h.nextNode();)Vt(o),Xt(o),o.content instanceof s&&qt(o.content);if(lt)return t;if(et){if($){i.normalize();let t=i.innerHTML;Vf([R,I,P],(e=>{t=Jf(t,e," ")})),i.innerHTML=t}if(nt)for(c=E.call(i.ownerDocument);i.firstChild;)c.appendChild(i.firstChild);else c=i;return(B.shadowroot||B.shadowrootmode)&&(c=A.call(r,c,!0)),c}let d=K?i.outerHTML:i.innerHTML;return K&&z["!doctype"]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&sg(Dg,i.ownerDocument.doctype.name)&&(d="<!DOCTYPE "+i.ownerDocument.doctype.name+">\n"+d),$&&Vf([R,I,P],(t=>{d=Jf(d,t," ")})),b&&it?b.createHTML(d):d},n.setConfig=function(){Lt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Q=!0},n.clearConfig=function(){Rt=null,Q=!1},n.isValidAttribute=function(t,e,n){Rt||Lt({});const i=Ct(t),r=Ct(e);return Ht(i,r,n)},n.addHook=function(t,e){"function"==typeof e&&jf(C[t],e)},n.removeHook=function(t,e){if(void 0!==e){const n=Hf(C[t],e);return-1===n?void 0:Xf(C[t],n,1)[0]}return Wf(C[t])},n.removeHooks=function(t){C[t]=[]},n.removeAllHooks=function(){C={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}(),Hg=function(t,e,n,i){var r,a=arguments.length,s=a<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,i);else for(var o=t.length-1;o>=0;o--)(r=t[o])&&(s=(a<3?r(s):a>3?r(e,n,s):r(e,n))||s);return a>3&&s&&Object.defineProperty(e,n,s),s};
|
|
358
|
+
var Rf=function(t,e,n,i){var r,a=arguments.length,s=a<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,i);else for(var o=t.length-1;o>=0;o--)(r=t[o])&&(s=(a<3?r(s):a>3?r(e,n,s):r(e,n))||s);return a>3&&s&&Object.defineProperty(e,n,s),s};
|
|
359
|
+
/*! @license DOMPurify 3.4.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.5/LICENSE */
|
|
360
|
+
function If(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function Pf(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,a,s,o=[],l=!0,c=!1;try{if(a=(n=n.call(t)).next,0===e);else for(;!(l=(i=a.call(n)).done)&&(o.push(i.value),o.length!==e);l=!0);}catch(t){c=!0,r=t}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw r}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return If(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?If(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}t.AvsGoInfo=class extends(e(ot)){constructor(){super(...arguments),this.url=""}updateInfo(){if(!this.url||this.url.length<1)return void this._dispatchErrorEvent("'url' property must be set to an instance of AVS/Go server.");if(!this.infoName)return void this._dispatchErrorEvent("'info-name' property must be set to the name of the info registered in the library map on the AVS/Go server.");const t={infoProperties:{name:this.infoName}};if(this.infoUserProperties){let e;try{e=JSON.parse(this.infoUserProperties)}catch(t){return void this._dispatchErrorEvent("Can't parse 'info-user-properties'. "+t)}t.infoProperties.userProperties=e}if(this.dataSourceName&&(t.dataSourceProperties={name:this.dataSourceName},this.dataSourceUserProperties)){let e;try{e=JSON.parse(this.dataSourceUserProperties)}catch(t){return void this._dispatchErrorEvent("Can't parse 'data-source-user-properties'. "+t)}t.dataSourceProperties.userProperties=e}this._httpRequest(this.url,(t=>{if(t.info){const e=JSON.parse(decodeURIComponent(t.info.replace(/\+/g,"%20")));this.dispatchEvent(new CustomEvent("avs-go-info-response",{bubbles:!0,composed:!0,detail:e}))}else this._dispatchErrorEvent("Empty response from AVS/Go server.")}),void 0,t)}},Rf([ut()],t.AvsGoInfo.prototype,"url",void 0),Rf([ut({attribute:"data-source-name"})],t.AvsGoInfo.prototype,"dataSourceName",void 0),Rf([ut({attribute:"data-source-user-properties"})],t.AvsGoInfo.prototype,"dataSourceUserProperties",void 0),Rf([ut({attribute:"info-name"})],t.AvsGoInfo.prototype,"infoName",void 0),Rf([ut({attribute:"info-user-properties"})],t.AvsGoInfo.prototype,"infoUserProperties",void 0),t.AvsGoInfo=Rf([ct("avs-go-info")],t.AvsGoInfo);const Lf=Object.entries,Df=Object.setPrototypeOf,Nf=Object.isFrozen,Of=Object.getPrototypeOf,Uf=Object.getOwnPropertyDescriptor;let Ff=Object.freeze,zf=Object.seal,kf=Object.create,Bf="undefined"!=typeof Reflect&&Reflect,Gf=Bf.apply,Vf=Bf.construct;Ff||(Ff=function(t){return t}),zf||(zf=function(t){return t}),Gf||(Gf=function(t,e){for(var n=arguments.length,i=new Array(n>2?n-2:0),r=2;r<n;r++)i[r-2]=arguments[r];return t.apply(e,i)}),Vf||(Vf=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return new t(...n)});const Hf=hg(Array.prototype.forEach),Wf=hg(Array.prototype.lastIndexOf),jf=hg(Array.prototype.pop),Xf=hg(Array.prototype.push),qf=hg(Array.prototype.splice),Yf=Array.isArray,Zf=hg(String.prototype.toLowerCase),$f=hg(String.prototype.toString),Jf=hg(String.prototype.match),Kf=hg(String.prototype.replace),Qf=hg(String.prototype.indexOf),tg=hg(String.prototype.trim),eg=hg(Number.prototype.toString),ng=hg(Boolean.prototype.toString),ig="undefined"==typeof BigInt?null:hg(BigInt.prototype.toString),rg="undefined"==typeof Symbol?null:hg(Symbol.prototype.toString),ag=hg(Object.prototype.hasOwnProperty),sg=hg(Object.prototype.toString),og=hg(RegExp.prototype.test),lg=(cg=TypeError,function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return Vf(cg,e)});var cg;function hg(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return Gf(t,e,i)}}function dg(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Zf;if(Df&&Df(t,null),!Yf(e))return t;let i=e.length;for(;i--;){let r=e[i];if("string"==typeof r){const t=n(r);t!==r&&(Nf(e)||(e[i]=t),r=t)}t[r]=!0}return t}function ug(t){for(let e=0;e<t.length;e++)ag(t,e)||(t[e]=null);return t}function pg(t){const e=kf(null);for(const i of Lf(t)){var n=Pf(i,2);const r=n[0],a=n[1];ag(t,r)&&(Yf(a)?e[r]=ug(a):a&&"object"==typeof a&&a.constructor===Object?e[r]=pg(a):e[r]=a)}return e}function mg(t,e){for(;null!==t;){const n=Uf(t,e);if(n){if(n.get)return hg(n.get);if("function"==typeof n.value)return hg(n.value)}t=Of(t)}return function(){return null}}const fg=Ff(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),gg=Ff(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),vg=Ff(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),_g=Ff(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),yg=Ff(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),xg=Ff(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),bg=Ff(["#text"]),Sg=Ff(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Mg=Ff(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),wg=Ff(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Eg=Ff(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Tg=zf(/{{[\w\W]*|^[\w\W]*}}/g),Ag=zf(/<%[\w\W]*|^[\w\W]*%>/g),Cg=zf(/\${[\w\W]*/g),Rg=zf(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ig=zf(/^aria-[\-\w]+$/),Pg=zf(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Lg=zf(/^(?:\w+script|data):/i),Dg=zf(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ng=zf(/^html$/i),Og=zf(/^[a-z][.\w]*(-[.\w]+)+$/i),Ug=1,Fg=3,zg=7,kg=8,Bg=9,Gg=function(){return"undefined"==typeof window?null:window};var Vg=function t(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Gg();const n=e=>t(e);if(n.version="3.4.5",n.removed=[],!e||!e.document||e.document.nodeType!==Bg||!e.Element)return n.isSupported=!1,n;let i=e.document;const r=i,a=r.currentScript,s=e.DocumentFragment,o=e.HTMLTemplateElement,l=e.Node,c=e.Element,h=e.NodeFilter,d=e.NamedNodeMap,u=void 0===d?e.NamedNodeMap||e.MozNamedAttrMap:d,p=e.HTMLFormElement,m=e.DOMParser,f=e.trustedTypes,g=c.prototype,v=mg(g,"cloneNode"),_=mg(g,"remove"),y=mg(g,"nextSibling"),x=mg(g,"childNodes"),b=mg(g,"parentNode"),S=l&&l.prototype?mg(l.prototype,"nodeType"):null;if("function"==typeof o){const t=i.createElement("template");t.content&&t.content.ownerDocument&&(i=t.content.ownerDocument)}let M,w="";const E=i,T=E.implementation,A=E.createNodeIterator,C=E.createDocumentFragment,R=E.getElementsByTagName,I=r.importNode;let P={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof Lf&&"function"==typeof b&&T&&void 0!==T.createHTMLDocument;const L=Tg,D=Ag,N=Cg,O=Rg,U=Ig,F=Lg,z=Dg,k=Og;let B=Pg,G=null;const V=dg({},[...fg,...gg,...vg,...yg,...bg]);let H=null;const W=dg({},[...Sg,...Mg,...wg,...Eg]);let j=Object.seal(kf(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),X=null,q=null;const Y=Object.seal(kf(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Z=!0,$=!0,J=!1,K=!0,Q=!1,tt=!0,et=!1,nt=!1,it=!1,rt=!1,at=!1,st=!1,ot=!0,lt=!1;const ct="user-content-";let ht=!0,dt=!1,ut={},pt=null;const mt=dg({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let ft=null;const gt=dg({},["audio","video","img","source","image","track"]);let vt=null;const _t=dg({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),yt="http://www.w3.org/1998/Math/MathML",xt="http://www.w3.org/2000/svg",bt="http://www.w3.org/1999/xhtml";let St=bt,Mt=!1,wt=null;const Et=dg({},[yt,xt,bt],$f);let Tt=dg({},["mi","mo","mn","ms","mtext"]),At=dg({},["annotation-xml"]);const Ct=dg({},["title","style","font","a","script"]);let Rt=null;const It=["application/xhtml+xml","text/html"];let Pt=null,Lt=null;const Dt=i.createElement("form"),Nt=function(t){return t instanceof RegExp||t instanceof Function},Ot=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(Lt&&Lt===t)return;t&&"object"==typeof t||(t={}),t=pg(t),Rt=-1===It.indexOf(t.PARSER_MEDIA_TYPE)?"text/html":t.PARSER_MEDIA_TYPE,Pt="application/xhtml+xml"===Rt?$f:Zf,G=ag(t,"ALLOWED_TAGS")&&Yf(t.ALLOWED_TAGS)?dg({},t.ALLOWED_TAGS,Pt):V,H=ag(t,"ALLOWED_ATTR")&&Yf(t.ALLOWED_ATTR)?dg({},t.ALLOWED_ATTR,Pt):W,wt=ag(t,"ALLOWED_NAMESPACES")&&Yf(t.ALLOWED_NAMESPACES)?dg({},t.ALLOWED_NAMESPACES,$f):Et,vt=ag(t,"ADD_URI_SAFE_ATTR")&&Yf(t.ADD_URI_SAFE_ATTR)?dg(pg(_t),t.ADD_URI_SAFE_ATTR,Pt):_t,ft=ag(t,"ADD_DATA_URI_TAGS")&&Yf(t.ADD_DATA_URI_TAGS)?dg(pg(gt),t.ADD_DATA_URI_TAGS,Pt):gt,pt=ag(t,"FORBID_CONTENTS")&&Yf(t.FORBID_CONTENTS)?dg({},t.FORBID_CONTENTS,Pt):mt,X=ag(t,"FORBID_TAGS")&&Yf(t.FORBID_TAGS)?dg({},t.FORBID_TAGS,Pt):pg({}),q=ag(t,"FORBID_ATTR")&&Yf(t.FORBID_ATTR)?dg({},t.FORBID_ATTR,Pt):pg({}),ut=!!ag(t,"USE_PROFILES")&&(t.USE_PROFILES&&"object"==typeof t.USE_PROFILES?pg(t.USE_PROFILES):t.USE_PROFILES),Z=!1!==t.ALLOW_ARIA_ATTR,$=!1!==t.ALLOW_DATA_ATTR,J=t.ALLOW_UNKNOWN_PROTOCOLS||!1,K=!1!==t.ALLOW_SELF_CLOSE_IN_ATTR,Q=t.SAFE_FOR_TEMPLATES||!1,tt=!1!==t.SAFE_FOR_XML,et=t.WHOLE_DOCUMENT||!1,rt=t.RETURN_DOM||!1,at=t.RETURN_DOM_FRAGMENT||!1,st=t.RETURN_TRUSTED_TYPE||!1,it=t.FORCE_BODY||!1,ot=!1!==t.SANITIZE_DOM,lt=t.SANITIZE_NAMED_PROPS||!1,ht=!1!==t.KEEP_CONTENT,dt=t.IN_PLACE||!1,B=function(t){try{return og(t,""),!0}catch(t){return!1}}(t.ALLOWED_URI_REGEXP)?t.ALLOWED_URI_REGEXP:Pg,St="string"==typeof t.NAMESPACE?t.NAMESPACE:bt,Tt=ag(t,"MATHML_TEXT_INTEGRATION_POINTS")&&t.MATHML_TEXT_INTEGRATION_POINTS&&"object"==typeof t.MATHML_TEXT_INTEGRATION_POINTS?pg(t.MATHML_TEXT_INTEGRATION_POINTS):dg({},["mi","mo","mn","ms","mtext"]),At=ag(t,"HTML_INTEGRATION_POINTS")&&t.HTML_INTEGRATION_POINTS&&"object"==typeof t.HTML_INTEGRATION_POINTS?pg(t.HTML_INTEGRATION_POINTS):dg({},["annotation-xml"]);const e=ag(t,"CUSTOM_ELEMENT_HANDLING")&&t.CUSTOM_ELEMENT_HANDLING&&"object"==typeof t.CUSTOM_ELEMENT_HANDLING?pg(t.CUSTOM_ELEMENT_HANDLING):kf(null);if(j=kf(null),ag(e,"tagNameCheck")&&Nt(e.tagNameCheck)&&(j.tagNameCheck=e.tagNameCheck),ag(e,"attributeNameCheck")&&Nt(e.attributeNameCheck)&&(j.attributeNameCheck=e.attributeNameCheck),ag(e,"allowCustomizedBuiltInElements")&&"boolean"==typeof e.allowCustomizedBuiltInElements&&(j.allowCustomizedBuiltInElements=e.allowCustomizedBuiltInElements),Q&&($=!1),at&&(rt=!0),ut&&(G=dg({},bg),H=kf(null),!0===ut.html&&(dg(G,fg),dg(H,Sg)),!0===ut.svg&&(dg(G,gg),dg(H,Mg),dg(H,Eg)),!0===ut.svgFilters&&(dg(G,vg),dg(H,Mg),dg(H,Eg)),!0===ut.mathMl&&(dg(G,yg),dg(H,wg),dg(H,Eg))),Y.tagCheck=null,Y.attributeCheck=null,ag(t,"ADD_TAGS")&&("function"==typeof t.ADD_TAGS?Y.tagCheck=t.ADD_TAGS:Yf(t.ADD_TAGS)&&(G===V&&(G=pg(G)),dg(G,t.ADD_TAGS,Pt))),ag(t,"ADD_ATTR")&&("function"==typeof t.ADD_ATTR?Y.attributeCheck=t.ADD_ATTR:Yf(t.ADD_ATTR)&&(H===W&&(H=pg(H)),dg(H,t.ADD_ATTR,Pt))),ag(t,"ADD_URI_SAFE_ATTR")&&Yf(t.ADD_URI_SAFE_ATTR)&&dg(vt,t.ADD_URI_SAFE_ATTR,Pt),ag(t,"FORBID_CONTENTS")&&Yf(t.FORBID_CONTENTS)&&(pt===mt&&(pt=pg(pt)),dg(pt,t.FORBID_CONTENTS,Pt)),ag(t,"ADD_FORBID_CONTENTS")&&Yf(t.ADD_FORBID_CONTENTS)&&(pt===mt&&(pt=pg(pt)),dg(pt,t.ADD_FORBID_CONTENTS,Pt)),ht&&(G["#text"]=!0),et&&dg(G,["html","head","body"]),G.table&&(dg(G,["tbody"]),delete X.tbody),t.TRUSTED_TYPES_POLICY){if("function"!=typeof t.TRUSTED_TYPES_POLICY.createHTML)throw lg('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof t.TRUSTED_TYPES_POLICY.createScriptURL)throw lg('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');M=t.TRUSTED_TYPES_POLICY,w=M.createHTML("")}else void 0===M&&(M=function(t,e){if("object"!=typeof t||"function"!=typeof t.createPolicy)return null;let n=null;const i="data-tt-policy-suffix";e&&e.hasAttribute(i)&&(n=e.getAttribute(i));const r="dompurify"+(n?"#"+n:"");try{return t.createPolicy(r,{createHTML:t=>t,createScriptURL:t=>t})}catch(t){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(f,a)),null!==M&&"string"==typeof w&&(w=M.createHTML(""));Ff&&Ff(t),Lt=t},Ut=dg({},[...gg,...vg,..._g]),Ft=dg({},[...yg,...xg]),zt=function(t){Xf(n.removed,{element:t});try{b(t).removeChild(t)}catch(e){_(t)}},kt=function(t,e){try{Xf(n.removed,{attribute:e.getAttributeNode(t),from:e})}catch(t){Xf(n.removed,{attribute:null,from:e})}if(e.removeAttribute(t),"is"===t)if(rt||at)try{zt(e)}catch(t){}else try{e.setAttribute(t,"")}catch(t){}},Bt=function(t){let e=null,n=null;if(it)t="<remove></remove>"+t;else{const e=Jf(t,/^[\r\n\t ]+/);n=e&&e[0]}"application/xhtml+xml"===Rt&&St===bt&&(t='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+t+"</body></html>");const r=M?M.createHTML(t):t;if(St===bt)try{e=(new m).parseFromString(r,Rt)}catch(t){}if(!e||!e.documentElement){e=T.createDocument(St,"template",null);try{e.documentElement.innerHTML=Mt?w:r}catch(t){}}const a=e.body||e.documentElement;return t&&n&&a.insertBefore(i.createTextNode(n),a.childNodes[0]||null),St===bt?R.call(e,et?"html":"body")[0]:et?e.documentElement:a},Gt=function(t){return A.call(t.ownerDocument||t,t,h.SHOW_ELEMENT|h.SHOW_COMMENT|h.SHOW_TEXT|h.SHOW_PROCESSING_INSTRUCTION|h.SHOW_CDATA_SECTION,null)},Vt=function(t){t.normalize();const e=A.call(t.ownerDocument||t,t,h.SHOW_TEXT|h.SHOW_COMMENT|h.SHOW_CDATA_SECTION|h.SHOW_PROCESSING_INSTRUCTION,null);let n=e.nextNode();for(;n;){let t=n.data;Hf([L,D,N],(e=>{t=Kf(t,e," ")})),n.data=t,n=e.nextNode()}},Ht=function(t){return t instanceof p&&("string"!=typeof t.nodeName||"string"!=typeof t.textContent||"function"!=typeof t.removeChild||!(t.attributes instanceof u)||"function"!=typeof t.removeAttribute||"function"!=typeof t.setAttribute||"string"!=typeof t.namespaceURI||"function"!=typeof t.insertBefore||"function"!=typeof t.hasChildNodes)},Wt=function(t){if(!S||"object"!=typeof t||null===t)return!1;try{return"number"==typeof S(t)}catch(t){return!1}};function jt(t,e,i){Hf(t,(t=>{t.call(n,e,i,Lt)}))}const Xt=function(t){let e=null;if(jt(P.beforeSanitizeElements,t,null),Ht(t))return zt(t),!0;const i=Pt(t.nodeName);if(jt(P.uponSanitizeElement,t,{tagName:i,allowedTags:G}),tt&&t.hasChildNodes()&&!Wt(t.firstElementChild)&&og(/<[/\w!]/g,t.innerHTML)&&og(/<[/\w!]/g,t.textContent))return zt(t),!0;if(tt&&t.namespaceURI===bt&&"style"===i&&Wt(t.firstElementChild))return zt(t),!0;if(t.nodeType===zg)return zt(t),!0;if(tt&&t.nodeType===kg&&og(/<[/\w]/g,t.data))return zt(t),!0;if(X[i]||!(Y.tagCheck instanceof Function&&Y.tagCheck(i))&&!G[i]){if(!X[i]&&Zt(i)){if(j.tagNameCheck instanceof RegExp&&og(j.tagNameCheck,i))return!1;if(j.tagNameCheck instanceof Function&&j.tagNameCheck(i))return!1}if(ht&&!pt[i]){const e=b(t)||t.parentNode,n=x(t)||t.childNodes;if(n&&e)for(let i=n.length-1;i>=0;--i){const r=v(n[i],!0);e.insertBefore(r,y(t))}}return zt(t),!0}return t instanceof c&&!function(t){let e=b(t);e&&e.tagName||(e={namespaceURI:St,tagName:"template"});const n=Zf(t.tagName),i=Zf(e.tagName);return!!wt[t.namespaceURI]&&(t.namespaceURI===xt?e.namespaceURI===bt?"svg"===n:e.namespaceURI===yt?"svg"===n&&("annotation-xml"===i||Tt[i]):Boolean(Ut[n]):t.namespaceURI===yt?e.namespaceURI===bt?"math"===n:e.namespaceURI===xt?"math"===n&&At[i]:Boolean(Ft[n]):t.namespaceURI===bt?!(e.namespaceURI===xt&&!At[i])&&!(e.namespaceURI===yt&&!Tt[i])&&!Ft[n]&&(Ct[n]||!Ut[n]):!("application/xhtml+xml"!==Rt||!wt[t.namespaceURI]))}(t)?(zt(t),!0):"noscript"!==i&&"noembed"!==i&&"noframes"!==i||!og(/<\/no(script|embed|frames)/i,t.innerHTML)?(Q&&t.nodeType===Fg&&(e=t.textContent,Hf([L,D,N],(t=>{e=Kf(e,t," ")})),t.textContent!==e&&(Xf(n.removed,{element:t.cloneNode()}),t.textContent=e)),jt(P.afterSanitizeElements,t,null),!1):(zt(t),!0)},qt=function(t,e,n){if(q[e])return!1;if(ot&&("id"===e||"name"===e)&&(n in i||n in Dt))return!1;const r=H[e]||Y.attributeCheck instanceof Function&&Y.attributeCheck(e,t);if($&&!q[e]&&og(O,e));else if(Z&&og(U,e));else if(!r||q[e]){if(!(Zt(t)&&(j.tagNameCheck instanceof RegExp&&og(j.tagNameCheck,t)||j.tagNameCheck instanceof Function&&j.tagNameCheck(t))&&(j.attributeNameCheck instanceof RegExp&&og(j.attributeNameCheck,e)||j.attributeNameCheck instanceof Function&&j.attributeNameCheck(e,t))||"is"===e&&j.allowCustomizedBuiltInElements&&(j.tagNameCheck instanceof RegExp&&og(j.tagNameCheck,n)||j.tagNameCheck instanceof Function&&j.tagNameCheck(n))))return!1}else if(vt[e]);else if(og(B,Kf(n,z,"")));else if("src"!==e&&"xlink:href"!==e&&"href"!==e||"script"===t||0!==Qf(n,"data:")||!ft[t])if(J&&!og(F,Kf(n,z,"")));else if(n)return!1;return!0},Yt=dg({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Zt=function(t){return!Yt[Zf(t)]&&og(k,t)},$t=function(t){jt(P.beforeSanitizeAttributes,t,null);const e=t.attributes;if(!e||Ht(t))return;const i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:H,forceKeepAttr:void 0};let r=e.length;for(;r--;){const a=e[r],s=a.name,o=a.namespaceURI,l=a.value,c=Pt(s),h=l;let d="value"===s?h:tg(h);if(i.attrName=c,i.attrValue=d,i.keepAttr=!0,i.forceKeepAttr=void 0,jt(P.uponSanitizeAttribute,t,i),d=i.attrValue,!lt||"id"!==c&&"name"!==c||0===Qf(d,ct)||(kt(s,t),d=ct+d),tt&&og(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){kt(s,t);continue}if("attributename"===c&&Jf(d,"href")){kt(s,t);continue}if(i.forceKeepAttr)continue;if(!i.keepAttr){kt(s,t);continue}if(!K&&og(/\/>/i,d)){kt(s,t);continue}Q&&Hf([L,D,N],(t=>{d=Kf(d,t," ")}));const u=Pt(t.nodeName);if(qt(u,c,d)){if(M&&"object"==typeof f&&"function"==typeof f.getAttributeType)if(o);else switch(f.getAttributeType(u,c)){case"TrustedHTML":d=M.createHTML(d);break;case"TrustedScriptURL":d=M.createScriptURL(d)}if(d!==h)try{o?t.setAttributeNS(o,s,d):t.setAttribute(s,d),Ht(t)?zt(t):jf(n.removed)}catch(e){kt(s,t)}}else kt(s,t)}jt(P.afterSanitizeAttributes,t,null)},Jt=function(t){let e=null;const n=Gt(t);for(jt(P.beforeSanitizeShadowDOM,t,null);e=n.nextNode();)jt(P.uponSanitizeShadowNode,e,null),Xt(e),$t(e),e.content instanceof s&&Jt(e.content);jt(P.afterSanitizeShadowDOM,t,null)},Kt=function(t){if(t.nodeType===Ug&&t.shadowRoot instanceof s){const e=t.shadowRoot;Kt(e),Jt(e)}const e=t.childNodes;if(!e)return;const n=[];Hf(e,(t=>{Xf(n,t)}));for(const t of n)Kt(t)};return n.sanitize=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=null,a=null,o=null,l=null;if(Mt=!t,Mt&&(t="\x3c!--\x3e"),"string"!=typeof t&&!Wt(t)&&"string"!=typeof(t=function(t){switch(typeof t){case"string":return t;case"number":return eg(t);case"boolean":return ng(t);case"bigint":return ig?ig(t):"0";case"symbol":return rg?rg(t):"Symbol()";case"undefined":default:return sg(t);case"function":case"object":{if(null===t)return sg(t);const e=t,n=mg(e,"toString");if("function"==typeof n){const t=n(e);return"string"==typeof t?t:sg(t)}return sg(t)}}}(t)))throw lg("dirty is not a string, aborting");if(!n.isSupported)return t;if(nt||Ot(e),n.removed=[],"string"==typeof t&&(dt=!1),dt){const e=t.nodeName;if("string"==typeof e){const t=Pt(e);if(!G[t]||X[t])throw lg("root node is forbidden and cannot be sanitized in-place")}Kt(t)}else if(Wt(t))i=Bt("\x3c!----\x3e"),a=i.ownerDocument.importNode(t,!0),a.nodeType===Ug&&"BODY"===a.nodeName||"HTML"===a.nodeName?i=a:i.appendChild(a),Kt(a);else{if(!rt&&!Q&&!et&&-1===t.indexOf("<"))return M&&st?M.createHTML(t):t;if(i=Bt(t),!i)return rt?null:st?w:""}i&&it&&zt(i.firstChild);const c=Gt(dt?t:i);for(;o=c.nextNode();)Xt(o),$t(o),o.content instanceof s&&Jt(o.content);if(dt)return Q&&Vt(t),t;if(rt){if(Q&&Vt(i),at)for(l=C.call(i.ownerDocument);i.firstChild;)l.appendChild(i.firstChild);else l=i;return(H.shadowroot||H.shadowrootmode)&&(l=I.call(r,l,!0)),l}let h=et?i.outerHTML:i.innerHTML;return et&&G["!doctype"]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&og(Ng,i.ownerDocument.doctype.name)&&(h="<!DOCTYPE "+i.ownerDocument.doctype.name+">\n"+h),Q&&Hf([L,D,N],(t=>{h=Kf(h,t," ")})),M&&st?M.createHTML(h):h},n.setConfig=function(){Ot(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),nt=!0},n.clearConfig=function(){Lt=null,nt=!1},n.isValidAttribute=function(t,e,n){Lt||Ot({});const i=Pt(t),r=Pt(e);return qt(i,r,n)},n.addHook=function(t,e){"function"==typeof e&&Xf(P[t],e)},n.removeHook=function(t,e){if(void 0!==e){const n=Wf(P[t],e);return-1===n?void 0:qf(P[t],n,1)[0]}return jf(P[t])},n.removeHooks=function(t){P[t]=[]},n.removeAllHooks=function(){P={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}(),Hg=function(t,e,n,i){var r,a=arguments.length,s=a<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,i);else for(var o=t.length-1;o>=0;o--)(r=t[o])&&(s=(a<3?r(s):a>3?r(e,n,s):r(e,n))||s);return a>3&&s&&Object.defineProperty(e,n,s),s};
|
|
382
361
|
/**
|
|
383
362
|
* @license
|
|
384
|
-
* Copyright 2018 Advanced Visual Systems Inc.
|
|
363
|
+
* Copyright 2018-2026 Advanced Visual Systems Inc.
|
|
385
364
|
*
|
|
386
365
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
387
366
|
* you may not use this file except in compliance with the License.
|
|
@@ -397,4 +376,4 @@ const{entries:Lf,setPrototypeOf:Df,isFrozen:Nf,getPrototypeOf:Of,getOwnPropertyD
|
|
|
397
376
|
*
|
|
398
377
|
* This product includes software developed at
|
|
399
378
|
* Advanced Visual Systems Inc. (http://www.avs.com)
|
|
400
|
-
*/t.AvsGoDynamicHtml=class extends(e(
|
|
379
|
+
*/t.AvsGoDynamicHtml=class extends(e(ot)){constructor(){super(...arguments),this.url=""}render(){return H`${vt(this._html)}`}willUpdate(t){if(!this.url||this.url.length<1)return void(t.has("url")&&this._dispatchErrorEvent("'url' property must be set to an instance of AVS/Go server."));if(!this.dynamicHtmlName)return void(t.has("dynamicHtmlName")&&this._dispatchErrorEvent("'dynamic-html-name' property must be set to the name of the dynamicHtml registered in the library map on the AVS/Go server."));const e={dynamicHtmlProperties:{name:this.dynamicHtmlName}};if(this.dynamicHtmlUserProperties){let t;try{t=JSON.parse(this.dynamicHtmlUserProperties)}catch(t){return void this._dispatchErrorEvent("Can't parse 'dynamic-html-user-properties'. "+t)}e.dynamicHtmlProperties.userProperties=t}if(this.dataSourceName&&(e.dataSourceProperties={name:this.dataSourceName},this.dataSourceUserProperties)){let t;try{t=JSON.parse(this.dataSourceUserProperties)}catch(t){return void this._dispatchErrorEvent("Can't parse 'data-source-user-properties'. "+t)}e.dataSourceProperties.userProperties=t}this._httpRequest(this.url,(t=>{if(t.html){const e=decodeURIComponent(t.html.replace(/\+/g,"%20"));this._html=Vg.sanitize(e)}else this._dispatchErrorEvent("Empty response from AVS/Go server.")}),void 0,e)}},Hg([ut()],t.AvsGoDynamicHtml.prototype,"url",void 0),Hg([ut({attribute:"data-source-name"})],t.AvsGoDynamicHtml.prototype,"dataSourceName",void 0),Hg([ut({attribute:"data-source-user-properties"})],t.AvsGoDynamicHtml.prototype,"dataSourceUserProperties",void 0),Hg([ut({attribute:"dynamic-html-name"})],t.AvsGoDynamicHtml.prototype,"dynamicHtmlName",void 0),Hg([ut({attribute:"dynamic-html-user-properties"})],t.AvsGoDynamicHtml.prototype,"dynamicHtmlUserProperties",void 0),Hg([function(t){return ut({...t,state:!0,attribute:!1})}()],t.AvsGoDynamicHtml.prototype,"_html",void 0),t.AvsGoDynamicHtml=Hg([ct("avs-go-dynamic-html")],t.AvsGoDynamicHtml)},"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).AvsGo={});
|