@planara/core 2.3.0 → 2.3.1

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/dist/index.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var kc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Gc={};/*! *****************************************************************************
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var Ou=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Lu={};/*! *****************************************************************************
2
2
  Copyright (C) Microsoft. All rights reserved.
3
3
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4
4
  this file except in compliance with the License. You may obtain a copy of the
@@ -11,15 +11,15 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
11
11
 
12
12
  See the Apache Version 2.0 License for specific language governing permissions
13
13
  and limitations under the License.
14
- ***************************************************************************** */var Wc;function pd(){if(Wc)return Gc;Wc=1;var n;return(function(e){(function(t){var i=typeof globalThis=="object"?globalThis:typeof kc=="object"?kc:typeof self=="object"?self:typeof this=="object"?this:l(),r=s(e);typeof i.Reflect<"u"&&(r=s(i.Reflect,r)),t(r,i),typeof i.Reflect>"u"&&(i.Reflect=e);function s(c,u){return function(h,d){Object.defineProperty(c,h,{configurable:!0,writable:!0,value:d}),u&&u(h,d)}}function o(){try{return Function("return this;")()}catch{}}function a(){try{return(0,eval)("(function() { return this; })()")}catch{}}function l(){return o()||a()}})(function(t,i){var r=Object.prototype.hasOwnProperty,s=typeof Symbol=="function",o=s&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",a=s&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",l=typeof Object.create=="function",c={__proto__:[]}instanceof Array,u=!l&&!c,h={create:l?function(){return Te(Object.create(null))}:c?function(){return Te({__proto__:null})}:function(){return Te({})},has:u?function(I,P){return r.call(I,P)}:function(I,P){return P in I},get:u?function(I,P){return r.call(I,P)?I[P]:void 0}:function(I,P){return I[P]}},d=Object.getPrototypeOf(Function),p=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:te(),g=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Re(),y=typeof WeakMap=="function"?WeakMap:fe(),m=s?Symbol.for("@reflect-metadata:registry"):void 0,f=v(),w=H(f);function T(I,P,U,Q){if(de(U)){if(!St(I))throw new TypeError;if(!rt(P))throw new TypeError;return Y(I,P)}else{if(!St(I))throw new TypeError;if(!Z(P))throw new TypeError;if(!Z(Q)&&!de(Q)&&!qe(Q))throw new TypeError;return qe(Q)&&(Q=void 0),U=ze(U),q(I,P,U,Q)}}t("decorate",T);function _(I,P){function U(Q,ie){if(!Z(Q))throw new TypeError;if(!de(ie)&&!Ve(ie))throw new TypeError;le(I,P,Q,ie)}return U}t("metadata",_);function S(I,P,U,Q){if(!Z(U))throw new TypeError;return de(Q)||(Q=ze(Q)),le(I,P,U,Q)}t("defineMetadata",S);function b(I,P,U){if(!Z(P))throw new TypeError;return de(U)||(U=ze(U)),J(I,P,U)}t("hasMetadata",b);function A(I,P,U){if(!Z(P))throw new TypeError;return de(U)||(U=ze(U)),K(I,P,U)}t("hasOwnMetadata",A);function C(I,P,U){if(!Z(P))throw new TypeError;return de(U)||(U=ze(U)),se(I,P,U)}t("getMetadata",C);function M(I,P,U){if(!Z(P))throw new TypeError;return de(U)||(U=ze(U)),$(I,P,U)}t("getOwnMetadata",M);function x(I,P){if(!Z(I))throw new TypeError;return de(P)||(P=ze(P)),me(I,P)}t("getMetadataKeys",x);function N(I,P){if(!Z(I))throw new TypeError;return de(P)||(P=ze(P)),Ee(I,P)}t("getOwnMetadataKeys",N);function z(I,P,U){if(!Z(P))throw new TypeError;if(de(U)||(U=ze(U)),!Z(P))throw new TypeError;de(U)||(U=ze(U));var Q=re(P,U,!1);return de(Q)?!1:Q.OrdinaryDeleteMetadata(I,P,U)}t("deleteMetadata",z);function Y(I,P){for(var U=I.length-1;U>=0;--U){var Q=I[U],ie=Q(P);if(!de(ie)&&!qe(ie)){if(!rt(ie))throw new TypeError;P=ie}}return P}function q(I,P,U,Q){for(var ie=I.length-1;ie>=0;--ie){var ae=I[ie],we=ae(P,U,Q);if(!de(we)&&!qe(we)){if(!Z(we))throw new TypeError;Q=we}}return Q}function J(I,P,U){var Q=K(I,P,U);if(Q)return!0;var ie=ut(P);return qe(ie)?!1:J(I,ie,U)}function K(I,P,U){var Q=re(P,U,!1);return de(Q)?!1:Ie(Q.OrdinaryHasOwnMetadata(I,P,U))}function se(I,P,U){var Q=K(I,P,U);if(Q)return $(I,P,U);var ie=ut(P);if(!qe(ie))return se(I,ie,U)}function $(I,P,U){var Q=re(P,U,!1);if(!de(Q))return Q.OrdinaryGetOwnMetadata(I,P,U)}function le(I,P,U,Q){var ie=re(U,Q,!0);ie.OrdinaryDefineOwnMetadata(I,P,U,Q)}function me(I,P){var U=Ee(I,P),Q=ut(I);if(Q===null)return U;var ie=me(Q,P);if(ie.length<=0)return U;if(U.length<=0)return ie;for(var ae=new g,we=[],D=0,V=U;D<V.length;D++){var G=V[D],ee=ae.has(G);ee||(ae.add(G),we.push(G))}for(var k=0,W=ie;k<W.length;k++){var G=W[k],ee=ae.has(G);ee||(ae.add(G),we.push(G))}return we}function Ee(I,P){var U=re(I,P,!1);return U?U.OrdinaryOwnMetadataKeys(I,P):[]}function Be(I){if(I===null)return 1;switch(typeof I){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return I===null?1:6;default:return 6}}function de(I){return I===void 0}function qe(I){return I===null}function Ke(I){return typeof I=="symbol"}function Z(I){return typeof I=="object"?I!==null:typeof I=="function"}function oe(I,P){switch(Be(I)){case 0:return I;case 1:return I;case 2:return I;case 3:return I;case 4:return I;case 5:return I}var U="string",Q=be(I,o);if(Q!==void 0){var ie=Q.call(I,U);if(Z(ie))throw new TypeError;return ie}return Me(I)}function Me(I,P){var U,Q,ie;{var ae=I.toString;if(L(ae)){var Q=ae.call(I);if(!Z(Q))return Q}var U=I.valueOf;if(L(U)){var Q=U.call(I);if(!Z(Q))return Q}}throw new TypeError}function Ie(I){return!!I}function Ce(I){return""+I}function ze(I){var P=oe(I);return Ke(P)?P:Ce(P)}function St(I){return Array.isArray?Array.isArray(I):I instanceof Object?I instanceof Array:Object.prototype.toString.call(I)==="[object Array]"}function L(I){return typeof I=="function"}function rt(I){return typeof I=="function"}function Ve(I){switch(Be(I)){case 3:return!0;case 4:return!0;default:return!1}}function De(I,P){return I===P||I!==I&&P!==P}function be(I,P){var U=I[P];if(U!=null){if(!L(U))throw new TypeError;return U}}function st(I){var P=be(I,a);if(!L(P))throw new TypeError;var U=P.call(I);if(!Z(U))throw new TypeError;return U}function Se(I){return I.value}function He(I){var P=I.next();return P.done?!1:P}function vt(I){var P=I.return;P&&P.call(I)}function ut(I){var P=Object.getPrototypeOf(I);if(typeof I!="function"||I===d||P!==d)return P;var U=I.prototype,Q=U&&Object.getPrototypeOf(U);if(Q==null||Q===Object.prototype)return P;var ie=Q.constructor;return typeof ie!="function"||ie===I?P:ie}function R(){var I;!de(m)&&typeof i.Reflect<"u"&&!(m in i.Reflect)&&typeof i.Reflect.defineMetadata=="function"&&(I=ne(i.Reflect));var P,U,Q,ie=new y,ae={registerProvider:we,getProvider:V,setProvider:ee};return ae;function we(k){if(!Object.isExtensible(ae))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case I===k:break;case de(P):P=k;break;case P===k:break;case de(U):U=k;break;case U===k:break;default:Q===void 0&&(Q=new g),Q.add(k);break}}function D(k,W){if(!de(P)){if(P.isProviderFor(k,W))return P;if(!de(U)){if(U.isProviderFor(k,W))return P;if(!de(Q))for(var ue=st(Q);;){var xe=He(ue);if(!xe)return;var We=Se(xe);if(We.isProviderFor(k,W))return vt(ue),We}}}if(!de(I)&&I.isProviderFor(k,W))return I}function V(k,W){var ue=ie.get(k),xe;return de(ue)||(xe=ue.get(W)),de(xe)&&(xe=D(k,W),de(xe)||(de(ue)&&(ue=new p,ie.set(k,ue)),ue.set(W,xe))),xe}function G(k){if(de(k))throw new TypeError;return P===k||U===k||!de(Q)&&Q.has(k)}function ee(k,W,ue){if(!G(ue))throw new Error("Metadata provider not registered.");var xe=V(k,W);if(xe!==ue){if(!de(xe))return!1;var We=ie.get(k);de(We)&&(We=new p,ie.set(k,We)),We.set(W,ue)}return!0}}function v(){var I;return!de(m)&&Z(i.Reflect)&&Object.isExtensible(i.Reflect)&&(I=i.Reflect[m]),de(I)&&(I=R()),!de(m)&&Z(i.Reflect)&&Object.isExtensible(i.Reflect)&&Object.defineProperty(i.Reflect,m,{enumerable:!1,configurable:!1,writable:!1,value:I}),I}function H(I){var P=new y,U={isProviderFor:function(G,ee){var k=P.get(G);return de(k)?!1:k.has(ee)},OrdinaryDefineOwnMetadata:we,OrdinaryHasOwnMetadata:ie,OrdinaryGetOwnMetadata:ae,OrdinaryOwnMetadataKeys:D,OrdinaryDeleteMetadata:V};return f.registerProvider(U),U;function Q(G,ee,k){var W=P.get(G),ue=!1;if(de(W)){if(!k)return;W=new p,P.set(G,W),ue=!0}var xe=W.get(ee);if(de(xe)){if(!k)return;if(xe=new p,W.set(ee,xe),!I.setProvider(G,ee,U))throw W.delete(ee),ue&&P.delete(G),new Error("Wrong provider for target.")}return xe}function ie(G,ee,k){var W=Q(ee,k,!1);return de(W)?!1:Ie(W.has(G))}function ae(G,ee,k){var W=Q(ee,k,!1);if(!de(W))return W.get(G)}function we(G,ee,k,W){var ue=Q(k,W,!0);ue.set(G,ee)}function D(G,ee){var k=[],W=Q(G,ee,!1);if(de(W))return k;for(var ue=W.keys(),xe=st(ue),We=0;;){var $e=He(xe);if(!$e)return k.length=We,k;var vn=Se($e);try{k[We]=vn}catch(nn){try{vt(xe)}finally{throw nn}}We++}}function V(G,ee,k){var W=Q(ee,k,!1);if(de(W)||!W.delete(G))return!1;if(W.size===0){var ue=P.get(ee);de(ue)||(ue.delete(k),ue.size===0&&P.delete(ue))}return!0}}function ne(I){var P=I.defineMetadata,U=I.hasOwnMetadata,Q=I.getOwnMetadata,ie=I.getOwnMetadataKeys,ae=I.deleteMetadata,we=new y,D={isProviderFor:function(V,G){var ee=we.get(V);return!de(ee)&&ee.has(G)?!0:ie(V,G).length?(de(ee)&&(ee=new g,we.set(V,ee)),ee.add(G),!0):!1},OrdinaryDefineOwnMetadata:P,OrdinaryHasOwnMetadata:U,OrdinaryGetOwnMetadata:Q,OrdinaryOwnMetadataKeys:ie,OrdinaryDeleteMetadata:ae};return D}function re(I,P,U){var Q=f.getProvider(I,P);if(!de(Q))return Q;if(U){if(f.setProvider(I,P,w))return w;throw new Error("Illegal state.")}}function te(){var I={},P=[],U=(function(){function D(V,G,ee){this._index=0,this._keys=V,this._values=G,this._selector=ee}return D.prototype["@@iterator"]=function(){return this},D.prototype[a]=function(){return this},D.prototype.next=function(){var V=this._index;if(V>=0&&V<this._keys.length){var G=this._selector(this._keys[V],this._values[V]);return V+1>=this._keys.length?(this._index=-1,this._keys=P,this._values=P):this._index++,{value:G,done:!1}}return{value:void 0,done:!0}},D.prototype.throw=function(V){throw this._index>=0&&(this._index=-1,this._keys=P,this._values=P),V},D.prototype.return=function(V){return this._index>=0&&(this._index=-1,this._keys=P,this._values=P),{value:V,done:!0}},D})(),Q=(function(){function D(){this._keys=[],this._values=[],this._cacheKey=I,this._cacheIndex=-2}return Object.defineProperty(D.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),D.prototype.has=function(V){return this._find(V,!1)>=0},D.prototype.get=function(V){var G=this._find(V,!1);return G>=0?this._values[G]:void 0},D.prototype.set=function(V,G){var ee=this._find(V,!0);return this._values[ee]=G,this},D.prototype.delete=function(V){var G=this._find(V,!1);if(G>=0){for(var ee=this._keys.length,k=G+1;k<ee;k++)this._keys[k-1]=this._keys[k],this._values[k-1]=this._values[k];return this._keys.length--,this._values.length--,De(V,this._cacheKey)&&(this._cacheKey=I,this._cacheIndex=-2),!0}return!1},D.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=I,this._cacheIndex=-2},D.prototype.keys=function(){return new U(this._keys,this._values,ie)},D.prototype.values=function(){return new U(this._keys,this._values,ae)},D.prototype.entries=function(){return new U(this._keys,this._values,we)},D.prototype["@@iterator"]=function(){return this.entries()},D.prototype[a]=function(){return this.entries()},D.prototype._find=function(V,G){if(!De(this._cacheKey,V)){this._cacheIndex=-1;for(var ee=0;ee<this._keys.length;ee++)if(De(this._keys[ee],V)){this._cacheIndex=ee;break}}return this._cacheIndex<0&&G&&(this._cacheIndex=this._keys.length,this._keys.push(V),this._values.push(void 0)),this._cacheIndex},D})();return Q;function ie(D,V){return D}function ae(D,V){return V}function we(D,V){return[D,V]}}function Re(){var I=(function(){function P(){this._map=new p}return Object.defineProperty(P.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),P.prototype.has=function(U){return this._map.has(U)},P.prototype.add=function(U){return this._map.set(U,U),this},P.prototype.delete=function(U){return this._map.delete(U)},P.prototype.clear=function(){this._map.clear()},P.prototype.keys=function(){return this._map.keys()},P.prototype.values=function(){return this._map.keys()},P.prototype.entries=function(){return this._map.entries()},P.prototype["@@iterator"]=function(){return this.keys()},P.prototype[a]=function(){return this.keys()},P})();return I}function fe(){var I=16,P=h.create(),U=Q();return(function(){function V(){this._key=Q()}return V.prototype.has=function(G){var ee=ie(G,!1);return ee!==void 0?h.has(ee,this._key):!1},V.prototype.get=function(G){var ee=ie(G,!1);return ee!==void 0?h.get(ee,this._key):void 0},V.prototype.set=function(G,ee){var k=ie(G,!0);return k[this._key]=ee,this},V.prototype.delete=function(G){var ee=ie(G,!1);return ee!==void 0?delete ee[this._key]:!1},V.prototype.clear=function(){this._key=Q()},V})();function Q(){var V;do V="@@WeakMap@@"+D();while(h.has(P,V));return P[V]=!0,V}function ie(V,G){if(!r.call(V,U)){if(!G)return;Object.defineProperty(V,U,{value:h.create()})}return V[U]}function ae(V,G){for(var ee=0;ee<G;++ee)V[ee]=Math.random()*255|0;return V}function we(V){if(typeof Uint8Array=="function"){var G=new Uint8Array(V);return typeof crypto<"u"?crypto.getRandomValues(G):typeof msCrypto<"u"?msCrypto.getRandomValues(G):ae(G,V),G}return ae(new Array(V),V)}function D(){var V=we(I);V[6]=V[6]&79|64,V[8]=V[8]&191|128;for(var G="",ee=0;ee<I;++ee){var k=V[ee];(ee===4||ee===6||ee===8)&&(G+="-"),k<16&&(G+="0"),G+=k.toString(16).toLowerCase()}return G}}function Te(I){return I.__=void 0,delete I.__,I}})})(n||(n={})),Gc}pd();/**
14
+ ***************************************************************************** */var Nu;function Hm(){if(Nu)return Lu;Nu=1;var i;return(function(t){(function(e){var n=typeof globalThis=="object"?globalThis:typeof Ou=="object"?Ou:typeof self=="object"?self:typeof this=="object"?this:l(),s=r(t);typeof n.Reflect<"u"&&(s=r(n.Reflect,s)),e(s,n),typeof n.Reflect>"u"&&(n.Reflect=t);function r(c,h){return function(u,d){Object.defineProperty(c,u,{configurable:!0,writable:!0,value:d}),h&&h(u,d)}}function a(){try{return Function("return this;")()}catch{}}function o(){try{return(0,eval)("(function() { return this; })()")}catch{}}function l(){return a()||o()}})(function(e,n){var s=Object.prototype.hasOwnProperty,r=typeof Symbol=="function",a=r&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",o=r&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",l=typeof Object.create=="function",c={__proto__:[]}instanceof Array,h=!l&&!c,u={create:l?function(){return Pt(Object.create(null))}:c?function(){return Pt({__proto__:null})}:function(){return Pt({})},has:h?function(L,D){return s.call(L,D)}:function(L,D){return D in L},get:h?function(L,D){return s.call(L,D)?L[D]:void 0}:function(L,D){return L[D]}},d=Object.getPrototypeOf(Function),f=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:Q(),m=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:At(),x=typeof WeakMap=="function"?WeakMap:mt(),_=r?Symbol.for("@reflect-metadata:registry"):void 0,p=b(),w=V(p);function S(L,D,U,et){if(pt(U)){if(!Ae(L))throw new TypeError;if(!he(D))throw new TypeError;return k(L,D)}else{if(!Ae(L))throw new TypeError;if(!J(D))throw new TypeError;if(!J(et)&&!pt(et)&&!$t(et))throw new TypeError;return $t(et)&&(et=void 0),U=It(U),G(L,D,U,et)}}e("decorate",S);function y(L,D){function U(et,ot){if(!J(et))throw new TypeError;if(!pt(ot)&&!N(ot))throw new TypeError;st(L,D,et,ot)}return U}e("metadata",y);function E(L,D,U,et){if(!J(U))throw new TypeError;return pt(et)||(et=It(et)),st(L,D,U,et)}e("defineMetadata",E);function v(L,D,U){if(!J(D))throw new TypeError;return pt(U)||(U=It(U)),K(L,D,U)}e("hasMetadata",v);function A(L,D,U){if(!J(D))throw new TypeError;return pt(U)||(U=It(U)),tt(L,D,U)}e("hasOwnMetadata",A);function R(L,D,U){if(!J(D))throw new TypeError;return pt(U)||(U=It(U)),lt(L,D,U)}e("getMetadata",R);function M(L,D,U){if(!J(D))throw new TypeError;return pt(U)||(U=It(U)),$(L,D,U)}e("getOwnMetadata",M);function g(L,D){if(!J(L))throw new TypeError;return pt(D)||(D=It(D)),ct(L,D)}e("getMetadataKeys",g);function O(L,D){if(!J(L))throw new TypeError;return pt(D)||(D=It(D)),Et(L,D)}e("getOwnMetadataKeys",O);function F(L,D,U){if(!J(D))throw new TypeError;if(pt(U)||(U=It(U)),!J(D))throw new TypeError;pt(U)||(U=It(U));var et=it(D,U,!1);return pt(et)?!1:et.OrdinaryDeleteMetadata(L,D,U)}e("deleteMetadata",F);function k(L,D){for(var U=L.length-1;U>=0;--U){var et=L[U],ot=et(D);if(!pt(ot)&&!$t(ot)){if(!he(ot))throw new TypeError;D=ot}}return D}function G(L,D,U,et){for(var ot=L.length-1;ot>=0;--ot){var ht=L[ot],yt=ht(D,U,et);if(!pt(yt)&&!$t(yt)){if(!J(yt))throw new TypeError;et=yt}}return et}function K(L,D,U){var et=tt(L,D,U);if(et)return!0;var ot=Ut(D);return $t(ot)?!1:K(L,ot,U)}function tt(L,D,U){var et=it(D,U,!1);return pt(et)?!1:Bt(et.OrdinaryHasOwnMetadata(L,D,U))}function lt(L,D,U){var et=tt(L,D,U);if(et)return $(L,D,U);var ot=Ut(D);if(!$t(ot))return lt(L,ot,U)}function $(L,D,U){var et=it(D,U,!1);if(!pt(et))return et.OrdinaryGetOwnMetadata(L,D,U)}function st(L,D,U,et){var ot=it(U,et,!0);ot.OrdinaryDefineOwnMetadata(L,D,U,et)}function ct(L,D){var U=Et(L,D),et=Ut(L);if(et===null)return U;var ot=ct(et,D);if(ot.length<=0)return U;if(U.length<=0)return ot;for(var ht=new m,yt=[],P=0,W=U;P<W.length;P++){var X=W[P],Y=ht.has(X);Y||(ht.add(X),yt.push(X))}for(var H=0,j=ot;H<j.length;H++){var X=j[H],Y=ht.has(X);Y||(ht.add(X),yt.push(X))}return yt}function Et(L,D){var U=it(L,D,!1);return U?U.OrdinaryOwnMetadataKeys(L,D):[]}function Vt(L){if(L===null)return 1;switch(typeof L){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return L===null?1:6;default:return 6}}function pt(L){return L===void 0}function $t(L){return L===null}function se(L){return typeof L=="symbol"}function J(L){return typeof L=="object"?L!==null:typeof L=="function"}function rt(L,D){switch(Vt(L)){case 0:return L;case 1:return L;case 2:return L;case 3:return L;case 4:return L;case 5:return L}var U="string",et=jt(L,a);if(et!==void 0){var ot=et.call(L,U);if(J(ot))throw new TypeError;return ot}return Mt(L)}function Mt(L,D){var U,et,ot;{var ht=L.toString;if(Ht(ht)){var et=ht.call(L);if(!J(et))return et}var U=L.valueOf;if(Ht(U)){var et=U.call(L);if(!J(et))return et}}throw new TypeError}function Bt(L){return!!L}function Ct(L){return""+L}function It(L){var D=rt(L);return se(D)?D:Ct(D)}function Ae(L){return Array.isArray?Array.isArray(L):L instanceof Object?L instanceof Array:Object.prototype.toString.call(L)==="[object Array]"}function Ht(L){return typeof L=="function"}function he(L){return typeof L=="function"}function N(L){switch(Vt(L)){case 3:return!0;case 4:return!0;default:return!1}}function Wt(L,D){return L===D||L!==L&&D!==D}function jt(L,D){var U=L[D];if(U!=null){if(!Ht(U))throw new TypeError;return U}}function ie(L){var D=jt(L,o);if(!Ht(D))throw new TypeError;var U=D.call(L);if(!J(U))throw new TypeError;return U}function wt(L){return L.value}function pe(L){var D=L.next();return D.done?!1:D}function Rt(L){var D=L.return;D&&D.call(L)}function Ut(L){var D=Object.getPrototypeOf(L);if(typeof L!="function"||L===d||D!==d)return D;var U=L.prototype,et=U&&Object.getPrototypeOf(U);if(et==null||et===Object.prototype)return D;var ot=et.constructor;return typeof ot!="function"||ot===L?D:ot}function C(){var L;!pt(_)&&typeof n.Reflect<"u"&&!(_ in n.Reflect)&&typeof n.Reflect.defineMetadata=="function"&&(L=nt(n.Reflect));var D,U,et,ot=new x,ht={registerProvider:yt,getProvider:W,setProvider:Y};return ht;function yt(H){if(!Object.isExtensible(ht))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case L===H:break;case pt(D):D=H;break;case D===H:break;case pt(U):U=H;break;case U===H:break;default:et===void 0&&(et=new m),et.add(H);break}}function P(H,j){if(!pt(D)){if(D.isProviderFor(H,j))return D;if(!pt(U)){if(U.isProviderFor(H,j))return D;if(!pt(et))for(var ut=ie(et);;){var bt=pe(ut);if(!bt)return;var Yt=wt(bt);if(Yt.isProviderFor(H,j))return Rt(ut),Yt}}}if(!pt(L)&&L.isProviderFor(H,j))return L}function W(H,j){var ut=ot.get(H),bt;return pt(ut)||(bt=ut.get(j)),pt(bt)&&(bt=P(H,j),pt(bt)||(pt(ut)&&(ut=new f,ot.set(H,ut)),ut.set(j,bt))),bt}function X(H){if(pt(H))throw new TypeError;return D===H||U===H||!pt(et)&&et.has(H)}function Y(H,j,ut){if(!X(ut))throw new Error("Metadata provider not registered.");var bt=W(H,j);if(bt!==ut){if(!pt(bt))return!1;var Yt=ot.get(H);pt(Yt)&&(Yt=new f,ot.set(H,Yt)),Yt.set(j,ut)}return!0}}function b(){var L;return!pt(_)&&J(n.Reflect)&&Object.isExtensible(n.Reflect)&&(L=n.Reflect[_]),pt(L)&&(L=C()),!pt(_)&&J(n.Reflect)&&Object.isExtensible(n.Reflect)&&Object.defineProperty(n.Reflect,_,{enumerable:!1,configurable:!1,writable:!1,value:L}),L}function V(L){var D=new x,U={isProviderFor:function(X,Y){var H=D.get(X);return pt(H)?!1:H.has(Y)},OrdinaryDefineOwnMetadata:yt,OrdinaryHasOwnMetadata:ot,OrdinaryGetOwnMetadata:ht,OrdinaryOwnMetadataKeys:P,OrdinaryDeleteMetadata:W};return p.registerProvider(U),U;function et(X,Y,H){var j=D.get(X),ut=!1;if(pt(j)){if(!H)return;j=new f,D.set(X,j),ut=!0}var bt=j.get(Y);if(pt(bt)){if(!H)return;if(bt=new f,j.set(Y,bt),!L.setProvider(X,Y,U))throw j.delete(Y),ut&&D.delete(X),new Error("Wrong provider for target.")}return bt}function ot(X,Y,H){var j=et(Y,H,!1);return pt(j)?!1:Bt(j.has(X))}function ht(X,Y,H){var j=et(Y,H,!1);if(!pt(j))return j.get(X)}function yt(X,Y,H,j){var ut=et(H,j,!0);ut.set(X,Y)}function P(X,Y){var H=[],j=et(X,Y,!1);if(pt(j))return H;for(var ut=j.keys(),bt=ie(ut),Yt=0;;){var ne=pe(bt);if(!ne)return H.length=Yt,H;var Mn=wt(ne);try{H[Yt]=Mn}catch(ln){try{Rt(bt)}finally{throw ln}}Yt++}}function W(X,Y,H){var j=et(Y,H,!1);if(pt(j)||!j.delete(X))return!1;if(j.size===0){var ut=D.get(Y);pt(ut)||(ut.delete(H),ut.size===0&&D.delete(ut))}return!0}}function nt(L){var D=L.defineMetadata,U=L.hasOwnMetadata,et=L.getOwnMetadata,ot=L.getOwnMetadataKeys,ht=L.deleteMetadata,yt=new x,P={isProviderFor:function(W,X){var Y=yt.get(W);return!pt(Y)&&Y.has(X)?!0:ot(W,X).length?(pt(Y)&&(Y=new m,yt.set(W,Y)),Y.add(X),!0):!1},OrdinaryDefineOwnMetadata:D,OrdinaryHasOwnMetadata:U,OrdinaryGetOwnMetadata:et,OrdinaryOwnMetadataKeys:ot,OrdinaryDeleteMetadata:ht};return P}function it(L,D,U){var et=p.getProvider(L,D);if(!pt(et))return et;if(U){if(p.setProvider(L,D,w))return w;throw new Error("Illegal state.")}}function Q(){var L={},D=[],U=(function(){function P(W,X,Y){this._index=0,this._keys=W,this._values=X,this._selector=Y}return P.prototype["@@iterator"]=function(){return this},P.prototype[o]=function(){return this},P.prototype.next=function(){var W=this._index;if(W>=0&&W<this._keys.length){var X=this._selector(this._keys[W],this._values[W]);return W+1>=this._keys.length?(this._index=-1,this._keys=D,this._values=D):this._index++,{value:X,done:!1}}return{value:void 0,done:!0}},P.prototype.throw=function(W){throw this._index>=0&&(this._index=-1,this._keys=D,this._values=D),W},P.prototype.return=function(W){return this._index>=0&&(this._index=-1,this._keys=D,this._values=D),{value:W,done:!0}},P})(),et=(function(){function P(){this._keys=[],this._values=[],this._cacheKey=L,this._cacheIndex=-2}return Object.defineProperty(P.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),P.prototype.has=function(W){return this._find(W,!1)>=0},P.prototype.get=function(W){var X=this._find(W,!1);return X>=0?this._values[X]:void 0},P.prototype.set=function(W,X){var Y=this._find(W,!0);return this._values[Y]=X,this},P.prototype.delete=function(W){var X=this._find(W,!1);if(X>=0){for(var Y=this._keys.length,H=X+1;H<Y;H++)this._keys[H-1]=this._keys[H],this._values[H-1]=this._values[H];return this._keys.length--,this._values.length--,Wt(W,this._cacheKey)&&(this._cacheKey=L,this._cacheIndex=-2),!0}return!1},P.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=L,this._cacheIndex=-2},P.prototype.keys=function(){return new U(this._keys,this._values,ot)},P.prototype.values=function(){return new U(this._keys,this._values,ht)},P.prototype.entries=function(){return new U(this._keys,this._values,yt)},P.prototype["@@iterator"]=function(){return this.entries()},P.prototype[o]=function(){return this.entries()},P.prototype._find=function(W,X){if(!Wt(this._cacheKey,W)){this._cacheIndex=-1;for(var Y=0;Y<this._keys.length;Y++)if(Wt(this._keys[Y],W)){this._cacheIndex=Y;break}}return this._cacheIndex<0&&X&&(this._cacheIndex=this._keys.length,this._keys.push(W),this._values.push(void 0)),this._cacheIndex},P})();return et;function ot(P,W){return P}function ht(P,W){return W}function yt(P,W){return[P,W]}}function At(){var L=(function(){function D(){this._map=new f}return Object.defineProperty(D.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),D.prototype.has=function(U){return this._map.has(U)},D.prototype.add=function(U){return this._map.set(U,U),this},D.prototype.delete=function(U){return this._map.delete(U)},D.prototype.clear=function(){this._map.clear()},D.prototype.keys=function(){return this._map.keys()},D.prototype.values=function(){return this._map.keys()},D.prototype.entries=function(){return this._map.entries()},D.prototype["@@iterator"]=function(){return this.keys()},D.prototype[o]=function(){return this.keys()},D})();return L}function mt(){var L=16,D=u.create(),U=et();return(function(){function W(){this._key=et()}return W.prototype.has=function(X){var Y=ot(X,!1);return Y!==void 0?u.has(Y,this._key):!1},W.prototype.get=function(X){var Y=ot(X,!1);return Y!==void 0?u.get(Y,this._key):void 0},W.prototype.set=function(X,Y){var H=ot(X,!0);return H[this._key]=Y,this},W.prototype.delete=function(X){var Y=ot(X,!1);return Y!==void 0?delete Y[this._key]:!1},W.prototype.clear=function(){this._key=et()},W})();function et(){var W;do W="@@WeakMap@@"+P();while(u.has(D,W));return D[W]=!0,W}function ot(W,X){if(!s.call(W,U)){if(!X)return;Object.defineProperty(W,U,{value:u.create()})}return W[U]}function ht(W,X){for(var Y=0;Y<X;++Y)W[Y]=Math.random()*255|0;return W}function yt(W){if(typeof Uint8Array=="function"){var X=new Uint8Array(W);return typeof crypto<"u"?crypto.getRandomValues(X):typeof msCrypto<"u"?msCrypto.getRandomValues(X):ht(X,W),X}return ht(new Array(W),W)}function P(){var W=yt(L);W[6]=W[6]&79|64,W[8]=W[8]&191|128;for(var X="",Y=0;Y<L;++Y){var H=W[Y];(Y===4||Y===6||Y===8)&&(X+="-"),H<16&&(X+="0"),X+=H.toString(16).toLowerCase()}return X}}function Pt(L){return L.__=void 0,delete L.__,L}})})(i||(i={})),Lu}Hm();/**
15
15
  * @license
16
16
  * Copyright 2010-2025 Three.js Authors
17
17
  * SPDX-License-Identifier: MIT
18
- */const nc="180",Mr={ROTATE:0,DOLLY:1,PAN:2},mr={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},md=0,Xc=1,_d=2,Oh=1,gd=2,qn=3,mi=0,Wt=1,Nn=2,di=0,Er=1,jc=2,Yc=3,qc=4,vd=5,Ii=100,xd=101,yd=102,Md=103,Ed=104,bd=200,Sd=201,Td=202,wd=203,Fa=204,Ba=205,Ad=206,Rd=207,Cd=208,Pd=209,Dd=210,Ld=211,Od=212,Id=213,Nd=214,za=0,Va=1,Ha=2,wr=3,ka=4,Ga=5,Wa=6,Xa=7,Ih=0,Ud=1,Fd=2,pi=0,Bd=1,zd=2,Vd=3,Hd=4,kd=5,Gd=6,Wd=7,Nh=300,Ar=301,Rr=302,ja=303,Ya=304,Do=306,qa=1e3,Fi=1001,$a=1002,Tn=1003,Xd=1004,bs=1005,Fn=1006,$o=1007,Bi=1008,kn=1009,Uh=1010,Fh=1011,is=1012,ic=1013,Hi=1014,Jn=1015,ds=1016,rc=1017,sc=1018,rs=1020,Bh=35902,zh=35899,Vh=1021,Hh=1022,bn=1023,ss=1026,os=1027,kh=1028,oc=1029,Gh=1030,ac=1031,lc=1033,so=33776,oo=33777,ao=33778,lo=33779,Za=35840,Ka=35841,Ja=35842,Qa=35843,el=36196,tl=37492,nl=37496,il=37808,rl=37809,sl=37810,ol=37811,al=37812,ll=37813,cl=37814,ul=37815,hl=37816,fl=37817,dl=37818,pl=37819,ml=37820,_l=37821,gl=36492,vl=36494,xl=36495,yl=36283,Ml=36284,El=36285,bl=36286,jd=3200,Yd=3201,Wh=0,qd=1,ui="",ln="srgb",Cr="srgb-linear",mo="linear",nt="srgb",er=7680,$c=519,$d=512,Zd=513,Kd=514,Xh=515,Jd=516,Qd=517,ep=518,tp=519,Zc=35044,np=35048,Kc="300 es",Bn=2e3,_o=2001;class qi{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const r=i[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const r=i.slice(0);for(let s=0,o=r.length;s<o;s++)r[s].call(this,e);e.target=null}}}const Nt=["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"],ts=Math.PI/180,Sl=180/Math.PI;function ps(){const n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Nt[n&255]+Nt[n>>8&255]+Nt[n>>16&255]+Nt[n>>24&255]+"-"+Nt[e&255]+Nt[e>>8&255]+"-"+Nt[e>>16&15|64]+Nt[e>>24&255]+"-"+Nt[t&63|128]+Nt[t>>8&255]+"-"+Nt[t>>16&255]+Nt[t>>24&255]+Nt[i&255]+Nt[i>>8&255]+Nt[i>>16&255]+Nt[i>>24&255]).toLowerCase()}function Xe(n,e,t){return Math.max(e,Math.min(t,n))}function ip(n,e){return(n%e+e)%e}function Zo(n,e,t){return(1-t)*n+t*e}function Hr(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function Ht(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}const rp={DEG2RAD:ts};class Ne{constructor(e=0,t=0){Ne.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Xe(this.x,e.x,t.x),this.y=Xe(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Xe(this.x,e,t),this.y=Xe(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Xe(i,e,t))}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(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.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(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Xe(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),r=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*i-o*r+e.x,this.y=s*r+o*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Dt{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,s,o,a){let l=i[r+0],c=i[r+1],u=i[r+2],h=i[r+3];const d=s[o+0],p=s[o+1],g=s[o+2],y=s[o+3];if(a===0){e[t+0]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h;return}if(a===1){e[t+0]=d,e[t+1]=p,e[t+2]=g,e[t+3]=y;return}if(h!==y||l!==d||c!==p||u!==g){let m=1-a;const f=l*d+c*p+u*g+h*y,w=f>=0?1:-1,T=1-f*f;if(T>Number.EPSILON){const S=Math.sqrt(T),b=Math.atan2(S,f*w);m=Math.sin(m*b)/S,a=Math.sin(a*b)/S}const _=a*w;if(l=l*m+d*_,c=c*m+p*_,u=u*m+g*_,h=h*m+y*_,m===1-a){const S=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=S,c*=S,u*=S,h*=S}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,i,r,s,o){const a=i[r],l=i[r+1],c=i[r+2],u=i[r+3],h=s[o],d=s[o+1],p=s[o+2],g=s[o+3];return e[t]=a*g+u*h+l*p-c*d,e[t+1]=l*g+u*d+c*h-a*p,e[t+2]=c*g+u*p+a*d-l*h,e[t+3]=u*g-a*h-l*d-c*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,r=e._y,s=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(i/2),u=a(r/2),h=a(s/2),d=l(i/2),p=l(r/2),g=l(s/2);switch(o){case"XYZ":this._x=d*u*h+c*p*g,this._y=c*p*h-d*u*g,this._z=c*u*g+d*p*h,this._w=c*u*h-d*p*g;break;case"YXZ":this._x=d*u*h+c*p*g,this._y=c*p*h-d*u*g,this._z=c*u*g-d*p*h,this._w=c*u*h+d*p*g;break;case"ZXY":this._x=d*u*h-c*p*g,this._y=c*p*h+d*u*g,this._z=c*u*g+d*p*h,this._w=c*u*h-d*p*g;break;case"ZYX":this._x=d*u*h-c*p*g,this._y=c*p*h+d*u*g,this._z=c*u*g-d*p*h,this._w=c*u*h+d*p*g;break;case"YZX":this._x=d*u*h+c*p*g,this._y=c*p*h+d*u*g,this._z=c*u*g-d*p*h,this._w=c*u*h-d*p*g;break;case"XZY":this._x=d*u*h-c*p*g,this._y=c*p*h-d*u*g,this._z=c*u*g+d*p*h,this._w=c*u*h+d*p*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],r=t[4],s=t[8],o=t[1],a=t[5],l=t[9],c=t[2],u=t[6],h=t[10],d=i+a+h;if(d>0){const p=.5/Math.sqrt(d+1);this._w=.25/p,this._x=(u-l)*p,this._y=(s-c)*p,this._z=(o-r)*p}else if(i>a&&i>h){const p=2*Math.sqrt(1+i-a-h);this._w=(u-l)/p,this._x=.25*p,this._y=(r+o)/p,this._z=(s+c)/p}else if(a>h){const p=2*Math.sqrt(1+a-i-h);this._w=(s-c)/p,this._x=(r+o)/p,this._y=.25*p,this._z=(l+u)/p}else{const p=2*Math.sqrt(1+h-i-a);this._w=(o-r)/p,this._x=(s+c)/p,this._y=(l+u)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Xe(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const r=Math.min(1,t/i);return this.slerp(e,r),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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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 e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,r=e._y,s=e._z,o=e._w,a=t._x,l=t._y,c=t._z,u=t._w;return this._x=i*u+o*a+r*c-s*l,this._y=r*u+o*l+s*a-i*c,this._z=s*u+o*c+i*l-r*a,this._w=o*u-i*a-r*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const i=this._x,r=this._y,s=this._z,o=this._w;let a=o*e._w+i*e._x+r*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=i,this._y=r,this._z=s,this;const l=1-a*a;if(l<=Number.EPSILON){const p=1-t;return this._w=p*o+t*this._w,this._x=p*i+t*this._x,this._y=p*r+t*this._y,this._z=p*s+t*this._z,this.normalize(),this}const c=Math.sqrt(l),u=Math.atan2(c,a),h=Math.sin((1-t)*u)/c,d=Math.sin(t*u)/c;return this._w=o*h+this._w*d,this._x=i*h+this._x*d,this._y=r*h+this._y*d,this._z=s*h+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class O{constructor(e=0,t=0,i=0){O.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Jc.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Jc.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*r,this.y=s[1]*t+s[4]*i+s[7]*r,this.z=s[2]*t+s[5]*i+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,s=e.elements,o=1/(s[3]*t+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*r+s[12])*o,this.y=(s[1]*t+s[5]*i+s[9]*r+s[13])*o,this.z=(s[2]*t+s[6]*i+s[10]*r+s[14])*o,this}applyQuaternion(e){const t=this.x,i=this.y,r=this.z,s=e.x,o=e.y,a=e.z,l=e.w,c=2*(o*r-a*i),u=2*(a*t-s*r),h=2*(s*i-o*t);return this.x=t+l*c+o*h-a*u,this.y=i+l*u+a*c-s*h,this.z=r+l*h+s*u-o*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r,this.y=s[1]*t+s[5]*i+s[9]*r,this.z=s[2]*t+s[6]*i+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Xe(this.x,e.x,t.x),this.y=Xe(this.y,e.y,t.y),this.z=Xe(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Xe(this.x,e,t),this.y=Xe(this.y,e,t),this.z=Xe(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Xe(i,e,t))}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(e){return this.x*e.x+this.y*e.y+this.z*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,r=e.y,s=e.z,o=t.x,a=t.y,l=t.z;return this.x=r*l-s*a,this.y=s*o-i*l,this.z=i*a-r*o,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Ko.copy(this).projectOnVector(e),this.sub(Ko)}reflect(e){return this.sub(Ko.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Xe(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Ko=new O,Jc=new Dt;class ke{constructor(e,t,i,r,s,o,a,l,c){ke.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,o,a,l,c)}set(e,t,i,r,s,o,a,l,c){const u=this.elements;return u[0]=e,u[1]=r,u[2]=a,u[3]=t,u[4]=s,u[5]=l,u[6]=i,u[7]=o,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,s=this.elements,o=i[0],a=i[3],l=i[6],c=i[1],u=i[4],h=i[7],d=i[2],p=i[5],g=i[8],y=r[0],m=r[3],f=r[6],w=r[1],T=r[4],_=r[7],S=r[2],b=r[5],A=r[8];return s[0]=o*y+a*w+l*S,s[3]=o*m+a*T+l*b,s[6]=o*f+a*_+l*A,s[1]=c*y+u*w+h*S,s[4]=c*m+u*T+h*b,s[7]=c*f+u*_+h*A,s[2]=d*y+p*w+g*S,s[5]=d*m+p*T+g*b,s[8]=d*f+p*_+g*A,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8];return t*o*u-t*a*c-i*s*u+i*a*l+r*s*c-r*o*l}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=u*o-a*c,d=a*l-u*s,p=c*s-o*l,g=t*h+i*d+r*p;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/g;return e[0]=h*y,e[1]=(r*c-u*i)*y,e[2]=(a*i-r*o)*y,e[3]=d*y,e[4]=(u*t-r*l)*y,e[5]=(r*s-a*t)*y,e[6]=p*y,e[7]=(i*l-c*t)*y,e[8]=(o*t-i*s)*y,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,s,o,a){const l=Math.cos(s),c=Math.sin(s);return this.set(i*l,i*c,-i*(l*o+c*a)+o+e,-r*c,r*l,-r*(-c*o+l*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(Jo.makeScale(e,t)),this}rotate(e){return this.premultiply(Jo.makeRotation(-e)),this}translate(e,t){return this.premultiply(Jo.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Jo=new ke;function jh(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function go(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function sp(){const n=go("canvas");return n.style.display="block",n}const Qc={};function as(n){n in Qc||(Qc[n]=!0,console.warn(n))}function op(n,e,t){return new Promise(function(i,r){function s(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:r();break;case n.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:i()}}setTimeout(s,t)})}const eu=new ke().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),tu=new ke().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function ap(){const n={enabled:!0,workingColorSpace:Cr,spaces:{},convert:function(r,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===nt&&(r.r=Qn(r.r),r.g=Qn(r.g),r.b=Qn(r.b)),this.spaces[s].primaries!==this.spaces[o].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===nt&&(r.r=br(r.r),r.g=br(r.g),r.b=br(r.b))),r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===ui?mo:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,o){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return as("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return as("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(r,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return n.define({[Cr]:{primaries:e,whitePoint:i,transfer:mo,toXYZ:eu,fromXYZ:tu,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:ln},outputColorSpaceConfig:{drawingBufferColorSpace:ln}},[ln]:{primaries:e,whitePoint:i,transfer:nt,toXYZ:eu,fromXYZ:tu,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:ln}}}),n}const Qe=ap();function Qn(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function br(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let tr;class lp{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{tr===void 0&&(tr=go("canvas")),tr.width=e.width,tr.height=e.height;const r=tr.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),i=tr}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=go("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const r=i.getImageData(0,0,e.width,e.height),s=r.data;for(let o=0;o<s.length;o++)s[o]=Qn(s[o]/255)*255;return i.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(Qn(t[i]/255)*255):t[i]=Qn(t[i]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let cp=0;class cc{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:cp++}),this.uuid=ps(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let o=0,a=r.length;o<a;o++)r[o].isDataTexture?s.push(Qo(r[o].image)):s.push(Qo(r[o]))}else s=Qo(r);i.url=s}return t||(e.images[this.uuid]=i),i}}function Qo(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?lp.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let up=0;const ea=new O;class Xt extends qi{constructor(e=Xt.DEFAULT_IMAGE,t=Xt.DEFAULT_MAPPING,i=Fi,r=Fi,s=Fn,o=Bi,a=bn,l=kn,c=Xt.DEFAULT_ANISOTROPY,u=ui){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:up++}),this.uuid=ps(),this.name="",this.source=new cc(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=s,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new Ne(0,0),this.repeat=new Ne(1,1),this.center=new Ne(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ke,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(ea).x}get height(){return this.source.getSize(ea).y}get depth(){return this.source.getSize(ea).z}get image(){return this.source.data}set image(e=null){this.source.data=e}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(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(i===void 0){console.warn(`THREE.Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Texture.setValues(): property '${t}' does not exist.`);continue}r&&i&&r.isVector2&&i.isVector2||r&&i&&r.isVector3&&i.isVector3||r&&i&&r.isMatrix3&&i.isMatrix3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Nh)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case qa:e.x=e.x-Math.floor(e.x);break;case Fi:e.x=e.x<0?0:1;break;case $a:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case qa:e.y=e.y-Math.floor(e.y);break;case Fi:e.y=e.y<0?0:1;break;case $a:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Xt.DEFAULT_IMAGE=null;Xt.DEFAULT_MAPPING=Nh;Xt.DEFAULT_ANISOTROPY=1;class gt{constructor(e=0,t=0,i=0,r=1){gt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){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: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*r+o[12]*s,this.y=o[1]*t+o[5]*i+o[9]*r+o[13]*s,this.z=o[2]*t+o[6]*i+o[10]*r+o[14]*s,this.w=o[3]*t+o[7]*i+o[11]*r+o[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,s;const l=e.elements,c=l[0],u=l[4],h=l[8],d=l[1],p=l[5],g=l[9],y=l[2],m=l[6],f=l[10];if(Math.abs(u-d)<.01&&Math.abs(h-y)<.01&&Math.abs(g-m)<.01){if(Math.abs(u+d)<.1&&Math.abs(h+y)<.1&&Math.abs(g+m)<.1&&Math.abs(c+p+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const T=(c+1)/2,_=(p+1)/2,S=(f+1)/2,b=(u+d)/4,A=(h+y)/4,C=(g+m)/4;return T>_&&T>S?T<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(T),r=b/i,s=A/i):_>S?_<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(_),i=b/r,s=C/r):S<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(S),i=A/s,r=C/s),this.set(i,r,s,t),this}let w=Math.sqrt((m-g)*(m-g)+(h-y)*(h-y)+(d-u)*(d-u));return Math.abs(w)<.001&&(w=1),this.x=(m-g)/w,this.y=(h-y)/w,this.z=(d-u)/w,this.w=Math.acos((c+p+f-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Xe(this.x,e.x,t.x),this.y=Xe(this.y,e.y,t.y),this.z=Xe(this.z,e.z,t.z),this.w=Xe(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Xe(this.x,e,t),this.y=Xe(this.y,e,t),this.z=Xe(this.z,e,t),this.w=Xe(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Xe(i,e,t))}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(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),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 hp extends qi{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Fn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new gt(0,0,e,t),this.scissorTest=!1,this.viewport=new gt(0,0,e,t);const r={width:e,height:t,depth:i.depth},s=new Xt(r);this.textures=[];const o=i.count;for(let a=0;a<o;a++)this.textures[a]=s.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview}_setTextureOptions(e={}){const t={minFilter:Fn,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let i=0;i<this.textures.length;i++)this.textures[i].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=i,this.textures[r].isArrayTexture=this.textures[r].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t<i;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const r=Object.assign({},e.textures[t].image);this.textures[t].source=new cc(r)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class ki extends hp{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class Yh extends Xt{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Tn,this.minFilter=Tn,this.wrapR=Fi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class fp extends Xt{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Tn,this.minFilter=Tn,this.wrapR=Fi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class ms{constructor(e=new O(1/0,1/0,1/0),t=new O(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(xn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(xn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=xn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.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(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const i=e.geometry;if(i!==void 0){const s=i.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=s.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,xn):xn.fromBufferAttribute(s,o),xn.applyMatrix4(e.matrixWorld),this.expandByPoint(xn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Ss.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Ss.copy(i.boundingBox)),Ss.applyMatrix4(e.matrixWorld),this.union(Ss)}const r=e.children;for(let s=0,o=r.length;s<o;s++)this.expandByObject(r[s],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,xn),xn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(kr),Ts.subVectors(this.max,kr),nr.subVectors(e.a,kr),ir.subVectors(e.b,kr),rr.subVectors(e.c,kr),ni.subVectors(ir,nr),ii.subVectors(rr,ir),Si.subVectors(nr,rr);let t=[0,-ni.z,ni.y,0,-ii.z,ii.y,0,-Si.z,Si.y,ni.z,0,-ni.x,ii.z,0,-ii.x,Si.z,0,-Si.x,-ni.y,ni.x,0,-ii.y,ii.x,0,-Si.y,Si.x,0];return!ta(t,nr,ir,rr,Ts)||(t=[1,0,0,0,1,0,0,0,1],!ta(t,nr,ir,rr,Ts))?!1:(ws.crossVectors(ni,ii),t=[ws.x,ws.y,ws.z],ta(t,nr,ir,rr,Ts))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,xn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(xn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Gn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Gn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Gn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Gn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Gn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Gn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Gn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Gn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Gn),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const Gn=[new O,new O,new O,new O,new O,new O,new O,new O],xn=new O,Ss=new ms,nr=new O,ir=new O,rr=new O,ni=new O,ii=new O,Si=new O,kr=new O,Ts=new O,ws=new O,Ti=new O;function ta(n,e,t,i,r){for(let s=0,o=n.length-3;s<=o;s+=3){Ti.fromArray(n,s);const a=r.x*Math.abs(Ti.x)+r.y*Math.abs(Ti.y)+r.z*Math.abs(Ti.z),l=e.dot(Ti),c=t.dot(Ti),u=i.dot(Ti);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>a)return!1}return!0}const dp=new ms,Gr=new O,na=new O;class Lo{constructor(e=new O,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;t!==void 0?i.copy(t):dp.setFromPoints(e).getCenter(i);let r=0;for(let s=0,o=e.length;s<o;s++)r=Math.max(r,i.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Gr.subVectors(e,this.center);const t=Gr.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(Gr,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(na.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Gr.copy(e.center).add(na)),this.expandByPoint(Gr.copy(e.center).sub(na))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}const Wn=new O,ia=new O,As=new O,ri=new O,ra=new O,Rs=new O,sa=new O;class Oo{constructor(e=new O,t=new O(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Wn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Wn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Wn.copy(this.origin).addScaledVector(this.direction,t),Wn.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){ia.copy(e).add(t).multiplyScalar(.5),As.copy(t).sub(e).normalize(),ri.copy(this.origin).sub(ia);const s=e.distanceTo(t)*.5,o=-this.direction.dot(As),a=ri.dot(this.direction),l=-ri.dot(As),c=ri.lengthSq(),u=Math.abs(1-o*o);let h,d,p,g;if(u>0)if(h=o*l-a,d=o*a-l,g=s*u,h>=0)if(d>=-g)if(d<=g){const y=1/u;h*=y,d*=y,p=h*(h+o*d+2*a)+d*(o*h+d+2*l)+c}else d=s,h=Math.max(0,-(o*d+a)),p=-h*h+d*(d+2*l)+c;else d=-s,h=Math.max(0,-(o*d+a)),p=-h*h+d*(d+2*l)+c;else d<=-g?(h=Math.max(0,-(-o*s+a)),d=h>0?-s:Math.min(Math.max(-s,-l),s),p=-h*h+d*(d+2*l)+c):d<=g?(h=0,d=Math.min(Math.max(-s,-l),s),p=d*(d+2*l)+c):(h=Math.max(0,-(o*s+a)),d=h>0?s:Math.min(Math.max(-s,-l),s),p=-h*h+d*(d+2*l)+c);else d=o>0?-s:s,h=Math.max(0,-(o*d+a)),p=-h*h+d*(d+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,h),r&&r.copy(ia).addScaledVector(As,d),p}intersectSphere(e,t){Wn.subVectors(e.center,this.origin);const i=Wn.dot(this.direction),r=Wn.dot(Wn)-i*i,s=e.radius*e.radius;if(r>s)return null;const o=Math.sqrt(s-r),a=i-o,l=i+o;return l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,s,o,a,l;const c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,d=this.origin;return c>=0?(i=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(i=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),u>=0?(s=(e.min.y-d.y)*u,o=(e.max.y-d.y)*u):(s=(e.max.y-d.y)*u,o=(e.min.y-d.y)*u),i>o||s>r||((s>i||isNaN(i))&&(i=s),(o<r||isNaN(r))&&(r=o),h>=0?(a=(e.min.z-d.z)*h,l=(e.max.z-d.z)*h):(a=(e.max.z-d.z)*h,l=(e.min.z-d.z)*h),i>l||a>r)||((a>i||i!==i)&&(i=a),(l<r||r!==r)&&(r=l),r<0)?null:this.at(i>=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,Wn)!==null}intersectTriangle(e,t,i,r,s){ra.subVectors(t,e),Rs.subVectors(i,e),sa.crossVectors(ra,Rs);let o=this.direction.dot(sa),a;if(o>0){if(r)return null;a=1}else if(o<0)a=-1,o=-o;else return null;ri.subVectors(this.origin,e);const l=a*this.direction.dot(Rs.crossVectors(ri,Rs));if(l<0)return null;const c=a*this.direction.dot(ra.cross(ri));if(c<0||l+c>o)return null;const u=-a*ri.dot(sa);return u<0?null:this.at(u/o,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class ft{constructor(e,t,i,r,s,o,a,l,c,u,h,d,p,g,y,m){ft.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,o,a,l,c,u,h,d,p,g,y,m)}set(e,t,i,r,s,o,a,l,c,u,h,d,p,g,y,m){const f=this.elements;return f[0]=e,f[4]=t,f[8]=i,f[12]=r,f[1]=s,f[5]=o,f[9]=a,f[13]=l,f[2]=c,f[6]=u,f[10]=h,f[14]=d,f[3]=p,f[7]=g,f[11]=y,f[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new ft().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,i=e.elements,r=1/sr.setFromMatrixColumn(e,0).length(),s=1/sr.setFromMatrixColumn(e,1).length(),o=1/sr.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*o,t[9]=i[9]*o,t[10]=i[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,r=e.y,s=e.z,o=Math.cos(i),a=Math.sin(i),l=Math.cos(r),c=Math.sin(r),u=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const d=o*u,p=o*h,g=a*u,y=a*h;t[0]=l*u,t[4]=-l*h,t[8]=c,t[1]=p+g*c,t[5]=d-y*c,t[9]=-a*l,t[2]=y-d*c,t[6]=g+p*c,t[10]=o*l}else if(e.order==="YXZ"){const d=l*u,p=l*h,g=c*u,y=c*h;t[0]=d+y*a,t[4]=g*a-p,t[8]=o*c,t[1]=o*h,t[5]=o*u,t[9]=-a,t[2]=p*a-g,t[6]=y+d*a,t[10]=o*l}else if(e.order==="ZXY"){const d=l*u,p=l*h,g=c*u,y=c*h;t[0]=d-y*a,t[4]=-o*h,t[8]=g+p*a,t[1]=p+g*a,t[5]=o*u,t[9]=y-d*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){const d=o*u,p=o*h,g=a*u,y=a*h;t[0]=l*u,t[4]=g*c-p,t[8]=d*c+y,t[1]=l*h,t[5]=y*c+d,t[9]=p*c-g,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){const d=o*l,p=o*c,g=a*l,y=a*c;t[0]=l*u,t[4]=y-d*h,t[8]=g*h+p,t[1]=h,t[5]=o*u,t[9]=-a*u,t[2]=-c*u,t[6]=p*h+g,t[10]=d-y*h}else if(e.order==="XZY"){const d=o*l,p=o*c,g=a*l,y=a*c;t[0]=l*u,t[4]=-h,t[8]=c*u,t[1]=d*h+y,t[5]=o*u,t[9]=p*h-g,t[2]=g*h-p,t[6]=a*u,t[10]=y*h+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(pp,e,mp)}lookAt(e,t,i){const r=this.elements;return qt.subVectors(e,t),qt.lengthSq()===0&&(qt.z=1),qt.normalize(),si.crossVectors(i,qt),si.lengthSq()===0&&(Math.abs(i.z)===1?qt.x+=1e-4:qt.z+=1e-4,qt.normalize(),si.crossVectors(i,qt)),si.normalize(),Cs.crossVectors(qt,si),r[0]=si.x,r[4]=Cs.x,r[8]=qt.x,r[1]=si.y,r[5]=Cs.y,r[9]=qt.y,r[2]=si.z,r[6]=Cs.z,r[10]=qt.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,s=this.elements,o=i[0],a=i[4],l=i[8],c=i[12],u=i[1],h=i[5],d=i[9],p=i[13],g=i[2],y=i[6],m=i[10],f=i[14],w=i[3],T=i[7],_=i[11],S=i[15],b=r[0],A=r[4],C=r[8],M=r[12],x=r[1],N=r[5],z=r[9],Y=r[13],q=r[2],J=r[6],K=r[10],se=r[14],$=r[3],le=r[7],me=r[11],Ee=r[15];return s[0]=o*b+a*x+l*q+c*$,s[4]=o*A+a*N+l*J+c*le,s[8]=o*C+a*z+l*K+c*me,s[12]=o*M+a*Y+l*se+c*Ee,s[1]=u*b+h*x+d*q+p*$,s[5]=u*A+h*N+d*J+p*le,s[9]=u*C+h*z+d*K+p*me,s[13]=u*M+h*Y+d*se+p*Ee,s[2]=g*b+y*x+m*q+f*$,s[6]=g*A+y*N+m*J+f*le,s[10]=g*C+y*z+m*K+f*me,s[14]=g*M+y*Y+m*se+f*Ee,s[3]=w*b+T*x+_*q+S*$,s[7]=w*A+T*N+_*J+S*le,s[11]=w*C+T*z+_*K+S*me,s[15]=w*M+T*Y+_*se+S*Ee,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],r=e[8],s=e[12],o=e[1],a=e[5],l=e[9],c=e[13],u=e[2],h=e[6],d=e[10],p=e[14],g=e[3],y=e[7],m=e[11],f=e[15];return g*(+s*l*h-r*c*h-s*a*d+i*c*d+r*a*p-i*l*p)+y*(+t*l*p-t*c*d+s*o*d-r*o*p+r*c*u-s*l*u)+m*(+t*c*h-t*a*p-s*o*h+i*o*p+s*a*u-i*c*u)+f*(-r*a*u-t*l*h+t*a*d+r*o*h-i*o*d+i*l*u)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=e[9],d=e[10],p=e[11],g=e[12],y=e[13],m=e[14],f=e[15],w=h*m*c-y*d*c+y*l*p-a*m*p-h*l*f+a*d*f,T=g*d*c-u*m*c-g*l*p+o*m*p+u*l*f-o*d*f,_=u*y*c-g*h*c+g*a*p-o*y*p-u*a*f+o*h*f,S=g*h*l-u*y*l-g*a*d+o*y*d+u*a*m-o*h*m,b=t*w+i*T+r*_+s*S;if(b===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const A=1/b;return e[0]=w*A,e[1]=(y*d*s-h*m*s-y*r*p+i*m*p+h*r*f-i*d*f)*A,e[2]=(a*m*s-y*l*s+y*r*c-i*m*c-a*r*f+i*l*f)*A,e[3]=(h*l*s-a*d*s-h*r*c+i*d*c+a*r*p-i*l*p)*A,e[4]=T*A,e[5]=(u*m*s-g*d*s+g*r*p-t*m*p-u*r*f+t*d*f)*A,e[6]=(g*l*s-o*m*s-g*r*c+t*m*c+o*r*f-t*l*f)*A,e[7]=(o*d*s-u*l*s+u*r*c-t*d*c-o*r*p+t*l*p)*A,e[8]=_*A,e[9]=(g*h*s-u*y*s-g*i*p+t*y*p+u*i*f-t*h*f)*A,e[10]=(o*y*s-g*a*s+g*i*c-t*y*c-o*i*f+t*a*f)*A,e[11]=(u*a*s-o*h*s-u*i*c+t*h*c+o*i*p-t*a*p)*A,e[12]=S*A,e[13]=(u*y*r-g*h*r+g*i*d-t*y*d-u*i*m+t*h*m)*A,e[14]=(g*a*r-o*y*r-g*i*l+t*y*l+o*i*m-t*a*m)*A,e[15]=(o*h*r-u*a*r+u*i*l-t*h*l-o*i*d+t*a*d)*A,this}scale(e){const t=this.elements,i=e.x,r=e.y,s=e.z;return t[0]*=i,t[4]*=r,t[8]*=s,t[1]*=i,t[5]*=r,t[9]*=s,t[2]*=i,t[6]*=r,t[10]*=s,t[3]*=i,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),r=Math.sin(t),s=1-i,o=e.x,a=e.y,l=e.z,c=s*o,u=s*a;return this.set(c*o+i,c*a-r*l,c*l+r*a,0,c*a+r*l,u*a+i,u*l-r*o,0,c*l-r*a,u*l+r*o,s*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,s,o){return this.set(1,i,s,0,e,1,o,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){const r=this.elements,s=t._x,o=t._y,a=t._z,l=t._w,c=s+s,u=o+o,h=a+a,d=s*c,p=s*u,g=s*h,y=o*u,m=o*h,f=a*h,w=l*c,T=l*u,_=l*h,S=i.x,b=i.y,A=i.z;return r[0]=(1-(y+f))*S,r[1]=(p+_)*S,r[2]=(g-T)*S,r[3]=0,r[4]=(p-_)*b,r[5]=(1-(d+f))*b,r[6]=(m+w)*b,r[7]=0,r[8]=(g+T)*A,r[9]=(m-w)*A,r[10]=(1-(d+y))*A,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){const r=this.elements;let s=sr.set(r[0],r[1],r[2]).length();const o=sr.set(r[4],r[5],r[6]).length(),a=sr.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],yn.copy(this);const c=1/s,u=1/o,h=1/a;return yn.elements[0]*=c,yn.elements[1]*=c,yn.elements[2]*=c,yn.elements[4]*=u,yn.elements[5]*=u,yn.elements[6]*=u,yn.elements[8]*=h,yn.elements[9]*=h,yn.elements[10]*=h,t.setFromRotationMatrix(yn),i.x=s,i.y=o,i.z=a,this}makePerspective(e,t,i,r,s,o,a=Bn,l=!1){const c=this.elements,u=2*s/(t-e),h=2*s/(i-r),d=(t+e)/(t-e),p=(i+r)/(i-r);let g,y;if(l)g=s/(o-s),y=o*s/(o-s);else if(a===Bn)g=-(o+s)/(o-s),y=-2*o*s/(o-s);else if(a===_o)g=-o/(o-s),y=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=u,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=h,c[9]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=g,c[14]=y,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,i,r,s,o,a=Bn,l=!1){const c=this.elements,u=2/(t-e),h=2/(i-r),d=-(t+e)/(t-e),p=-(i+r)/(i-r);let g,y;if(l)g=1/(o-s),y=o/(o-s);else if(a===Bn)g=-2/(o-s),y=-(o+s)/(o-s);else if(a===_o)g=-1/(o-s),y=-s/(o-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=u,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=h,c[9]=0,c[13]=p,c[2]=0,c[6]=0,c[10]=g,c[14]=y,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const sr=new O,yn=new ft,pp=new O(0,0,0),mp=new O(1,1,1),si=new O,Cs=new O,qt=new O,nu=new ft,iu=new Dt;class Pn{constructor(e=0,t=0,i=0,r=Pn.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const r=e.elements,s=r[0],o=r[4],a=r[8],l=r[1],c=r[5],u=r[9],h=r[2],d=r[6],p=r[10];switch(t){case"XYZ":this._y=Math.asin(Xe(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Xe(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Xe(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,p),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Xe(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(Xe(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-Xe(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return nu.makeRotationFromQuaternion(e),this.setFromRotationMatrix(nu,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return iu.setFromEuler(this),this.setFromQuaternion(iu,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Pn.DEFAULT_ORDER="XYZ";class uc{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let _p=0;const ru=new O,or=new Dt,Xn=new ft,Ps=new O,Wr=new O,gp=new O,vp=new Dt,su=new O(1,0,0),ou=new O(0,1,0),au=new O(0,0,1),lu={type:"added"},xp={type:"removed"},ar={type:"childadded",child:null},oa={type:"childremoved",child:null};class Mt extends qi{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:_p++}),this.uuid=ps(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Mt.DEFAULT_UP.clone();const e=new O,t=new Pn,i=new Dt,r=new O(1,1,1);function s(){i.setFromEuler(t,!1)}function o(){t.setFromQuaternion(i,void 0,!1)}t._onChange(s),i._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new ft},normalMatrix:{value:new ke}}),this.matrix=new ft,this.matrixWorld=new ft,this.matrixAutoUpdate=Mt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Mt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new uc,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return or.setFromAxisAngle(e,t),this.quaternion.multiply(or),this}rotateOnWorldAxis(e,t){return or.setFromAxisAngle(e,t),this.quaternion.premultiply(or),this}rotateX(e){return this.rotateOnAxis(su,e)}rotateY(e){return this.rotateOnAxis(ou,e)}rotateZ(e){return this.rotateOnAxis(au,e)}translateOnAxis(e,t){return ru.copy(e).applyQuaternion(this.quaternion),this.position.add(ru.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(su,e)}translateY(e){return this.translateOnAxis(ou,e)}translateZ(e){return this.translateOnAxis(au,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Xn.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?Ps.copy(e):Ps.set(e,t,i);const r=this.parent;this.updateWorldMatrix(!0,!1),Wr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Xn.lookAt(Wr,Ps,this.up):Xn.lookAt(Ps,Wr,this.up),this.quaternion.setFromRotationMatrix(Xn),r&&(Xn.extractRotation(r.matrixWorld),or.setFromRotationMatrix(Xn),this.quaternion.premultiply(or.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(lu),ar.child=e,this.dispatchEvent(ar),ar.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(xp),oa.child=e,this.dispatchEvent(oa),oa.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Xn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Xn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Xn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(lu),ar.child=e,this.dispatchEvent(ar),ar.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,r=this.children.length;i<r;i++){const o=this.children[i].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Wr,e,gp),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Wr,vp,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t){const i=this.parent;if(e===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(a=>({...a})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c<u;c++){const h=l[c];s(e.shapes,h)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(s(e.materials,this.material[l]));r.material=a}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let a=0;a<this.children.length;a++)r.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let a=0;a<this.animations.length;a++){const l=this.animations[a];r.animations.push(s(e.animations,l))}}if(t){const a=o(e.geometries),l=o(e.materials),c=o(e.textures),u=o(e.images),h=o(e.shapes),d=o(e.skeletons),p=o(e.animations),g=o(e.nodes);a.length>0&&(i.geometries=a),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),u.length>0&&(i.images=u),h.length>0&&(i.shapes=h),d.length>0&&(i.skeletons=d),p.length>0&&(i.animations=p),g.length>0&&(i.nodes=g)}return i.object=r,i;function o(a){const l=[];for(const c in a){const u=a[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){const r=e.children[i];this.add(r.clone())}return this}}Mt.DEFAULT_UP=new O(0,1,0);Mt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Mt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Mn=new O,jn=new O,aa=new O,Yn=new O,lr=new O,cr=new O,cu=new O,la=new O,ca=new O,ua=new O,ha=new gt,fa=new gt,da=new gt;class un{constructor(e=new O,t=new O,i=new O){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),Mn.subVectors(e,t),r.cross(Mn);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,i,r,s){Mn.subVectors(r,t),jn.subVectors(i,t),aa.subVectors(e,t);const o=Mn.dot(Mn),a=Mn.dot(jn),l=Mn.dot(aa),c=jn.dot(jn),u=jn.dot(aa),h=o*c-a*a;if(h===0)return s.set(0,0,0),null;const d=1/h,p=(c*l-a*u)*d,g=(o*u-a*l)*d;return s.set(1-p-g,g,p)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,Yn)===null?!1:Yn.x>=0&&Yn.y>=0&&Yn.x+Yn.y<=1}static getInterpolation(e,t,i,r,s,o,a,l){return this.getBarycoord(e,t,i,r,Yn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,Yn.x),l.addScaledVector(o,Yn.y),l.addScaledVector(a,Yn.z),l)}static getInterpolatedAttribute(e,t,i,r,s,o){return ha.setScalar(0),fa.setScalar(0),da.setScalar(0),ha.fromBufferAttribute(e,t),fa.fromBufferAttribute(e,i),da.fromBufferAttribute(e,r),o.setScalar(0),o.addScaledVector(ha,s.x),o.addScaledVector(fa,s.y),o.addScaledVector(da,s.z),o}static isFrontFacing(e,t,i,r){return Mn.subVectors(i,t),jn.subVectors(e,t),Mn.cross(jn).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Mn.subVectors(this.c,this.b),jn.subVectors(this.a,this.b),Mn.cross(jn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return un.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return un.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,s){return un.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}containsPoint(e){return un.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return un.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,r=this.b,s=this.c;let o,a;lr.subVectors(r,i),cr.subVectors(s,i),la.subVectors(e,i);const l=lr.dot(la),c=cr.dot(la);if(l<=0&&c<=0)return t.copy(i);ca.subVectors(e,r);const u=lr.dot(ca),h=cr.dot(ca);if(u>=0&&h<=u)return t.copy(r);const d=l*h-u*c;if(d<=0&&l>=0&&u<=0)return o=l/(l-u),t.copy(i).addScaledVector(lr,o);ua.subVectors(e,s);const p=lr.dot(ua),g=cr.dot(ua);if(g>=0&&p<=g)return t.copy(s);const y=p*c-l*g;if(y<=0&&c>=0&&g<=0)return a=c/(c-g),t.copy(i).addScaledVector(cr,a);const m=u*g-p*h;if(m<=0&&h-u>=0&&p-g>=0)return cu.subVectors(s,r),a=(h-u)/(h-u+(p-g)),t.copy(r).addScaledVector(cu,a);const f=1/(m+y+d);return o=y*f,a=d*f,t.copy(i).addScaledVector(lr,o).addScaledVector(cr,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const qh={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},oi={h:0,s:0,l:0},Ds={h:0,s:0,l:0};function pa(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class je{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=ln){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Qe.colorSpaceToWorking(this,t),this}setRGB(e,t,i,r=Qe.workingColorSpace){return this.r=e,this.g=t,this.b=i,Qe.colorSpaceToWorking(this,r),this}setHSL(e,t,i,r=Qe.workingColorSpace){if(e=ip(e,1),t=Xe(t,0,1),i=Xe(i,0,1),t===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+t):i+t-i*t,o=2*i-s;this.r=pa(o,s,e+1/3),this.g=pa(o,s,e),this.b=pa(o,s,e-1/3)}return Qe.colorSpaceToWorking(this,r),this}setStyle(e,t=ln){function i(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const o=r[1],a=r[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=ln){const i=qh[e.toLowerCase()];return i!==void 0?this.setHex(i,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Qn(e.r),this.g=Qn(e.g),this.b=Qn(e.b),this}copyLinearToSRGB(e){return this.r=br(e.r),this.g=br(e.g),this.b=br(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=ln){return Qe.workingToColorSpace(Ut.copy(this),e),Math.round(Xe(Ut.r*255,0,255))*65536+Math.round(Xe(Ut.g*255,0,255))*256+Math.round(Xe(Ut.b*255,0,255))}getHexString(e=ln){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Qe.workingColorSpace){Qe.workingToColorSpace(Ut.copy(this),t);const i=Ut.r,r=Ut.g,s=Ut.b,o=Math.max(i,r,s),a=Math.min(i,r,s);let l,c;const u=(a+o)/2;if(a===o)l=0,c=0;else{const h=o-a;switch(c=u<=.5?h/(o+a):h/(2-o-a),o){case i:l=(r-s)/h+(r<s?6:0);break;case r:l=(s-i)/h+2;break;case s:l=(i-r)/h+4;break}l/=6}return e.h=l,e.s=c,e.l=u,e}getRGB(e,t=Qe.workingColorSpace){return Qe.workingToColorSpace(Ut.copy(this),t),e.r=Ut.r,e.g=Ut.g,e.b=Ut.b,e}getStyle(e=ln){Qe.workingToColorSpace(Ut.copy(this),e);const t=Ut.r,i=Ut.g,r=Ut.b;return e!==ln?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,t,i){return this.getHSL(oi),this.setHSL(oi.h+e,oi.s+t,oi.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(oi),e.getHSL(Ds);const i=Zo(oi.h,Ds.h,t),r=Zo(oi.s,Ds.s,t),s=Zo(oi.l,Ds.l,t);return this.setHSL(i,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,i=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*i+s[6]*r,this.g=s[1]*t+s[4]*i+s[7]*r,this.b=s[2]*t+s[5]*i+s[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Ut=new je;je.NAMES=qh;let yp=0;class Or extends qi{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:yp++}),this.uuid=ps(),this.name="",this.type="Material",this.blending=Er,this.side=mi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Fa,this.blendDst=Ba,this.blendEquation=Ii,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new je(0,0,0),this.blendAlpha=0,this.depthFunc=wr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=$c,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=er,this.stencilZFail=er,this.stencilZPass=er,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(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Er&&(i.blending=this.blending),this.side!==mi&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Fa&&(i.blendSrc=this.blendSrc),this.blendDst!==Ba&&(i.blendDst=this.blendDst),this.blendEquation!==Ii&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==wr&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==$c&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==er&&(i.stencilFail=this.stencilFail),this.stencilZFail!==er&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==er&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(s){const o=[];for(const a in s){const l=s[a];delete l.metadata,o.push(l)}return o}if(t){const s=r(e.textures),o=r(e.images);s.length>0&&(i.textures=s),o.length>0&&(i.images=o)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const r=t.length;i=new Array(r);for(let s=0;s!==r;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Io extends Or{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new je(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 Pn,this.combine=Ih,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Et=new O,Ls=new Ne;let Mp=0;class wn{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Mp++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=Zc,this.updateRanges=[],this.gpuType=Jn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)Ls.fromBufferAttribute(this,t),Ls.applyMatrix3(e),this.setXY(t,Ls.x,Ls.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)Et.fromBufferAttribute(this,t),Et.applyMatrix3(e),this.setXYZ(t,Et.x,Et.y,Et.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Et.fromBufferAttribute(this,t),Et.applyMatrix4(e),this.setXYZ(t,Et.x,Et.y,Et.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Et.fromBufferAttribute(this,t),Et.applyNormalMatrix(e),this.setXYZ(t,Et.x,Et.y,Et.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Et.fromBufferAttribute(this,t),Et.transformDirection(e),this.setXYZ(t,Et.x,Et.y,Et.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=Hr(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=Ht(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Hr(t,this.array)),t}setX(e,t){return this.normalized&&(t=Ht(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Hr(t,this.array)),t}setY(e,t){return this.normalized&&(t=Ht(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Hr(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Ht(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Hr(t,this.array)),t}setW(e,t){return this.normalized&&(t=Ht(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=Ht(t,this.array),i=Ht(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=Ht(t,this.array),i=Ht(i,this.array),r=Ht(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=Ht(t,this.array),i=Ht(i,this.array),r=Ht(r,this.array),s=Ht(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Zc&&(e.usage=this.usage),e}}class $h extends wn{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class Zh extends wn{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class Ze extends wn{constructor(e,t,i){super(new Float32Array(e),t,i)}}let Ep=0;const on=new ft,ma=new Mt,ur=new O,$t=new ms,Xr=new ms,Ct=new O;class bt extends qi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ep++}),this.uuid=ps(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(jh(e)?Zh:$h)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const s=new ke().getNormalMatrix(e);i.applyNormalMatrix(s),i.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return on.makeRotationFromQuaternion(e),this.applyMatrix4(on),this}rotateX(e){return on.makeRotationX(e),this.applyMatrix4(on),this}rotateY(e){return on.makeRotationY(e),this.applyMatrix4(on),this}rotateZ(e){return on.makeRotationZ(e),this.applyMatrix4(on),this}translate(e,t,i){return on.makeTranslation(e,t,i),this.applyMatrix4(on),this}scale(e,t,i){return on.makeScale(e,t,i),this.applyMatrix4(on),this}lookAt(e){return ma.lookAt(e),ma.updateMatrix(),this.applyMatrix4(ma.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ur).negate(),this.translate(ur.x,ur.y,ur.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let r=0,s=e.length;r<s;r++){const o=e[r];i.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Ze(i,3))}else{const i=Math.min(e.length,t.count);for(let r=0;r<i;r++){const s=e[r];t.setXYZ(r,s.x,s.y,s.z||0)}e.length>t.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ms);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new O(-1/0,-1/0,-1/0),new O(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,r=t.length;i<r;i++){const s=t[i];$t.setFromBufferAttribute(s),this.morphTargetsRelative?(Ct.addVectors(this.boundingBox.min,$t.min),this.boundingBox.expandByPoint(Ct),Ct.addVectors(this.boundingBox.max,$t.max),this.boundingBox.expandByPoint(Ct)):(this.boundingBox.expandByPoint($t.min),this.boundingBox.expandByPoint($t.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Lo);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new O,1/0);return}if(e){const i=this.boundingSphere.center;if($t.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){const a=t[s];Xr.setFromBufferAttribute(a),this.morphTargetsRelative?(Ct.addVectors($t.min,Xr.min),$t.expandByPoint(Ct),Ct.addVectors($t.max,Xr.max),$t.expandByPoint(Ct)):($t.expandByPoint(Xr.min),$t.expandByPoint(Xr.max))}$t.getCenter(i);let r=0;for(let s=0,o=e.count;s<o;s++)Ct.fromBufferAttribute(e,s),r=Math.max(r,i.distanceToSquared(Ct));if(t)for(let s=0,o=t.length;s<o;s++){const a=t[s],l=this.morphTargetsRelative;for(let c=0,u=a.count;c<u;c++)Ct.fromBufferAttribute(a,c),l&&(ur.fromBufferAttribute(e,c),Ct.add(ur)),r=Math.max(r,i.distanceToSquared(Ct))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new wn(new Float32Array(4*i.count),4));const o=this.getAttribute("tangent"),a=[],l=[];for(let C=0;C<i.count;C++)a[C]=new O,l[C]=new O;const c=new O,u=new O,h=new O,d=new Ne,p=new Ne,g=new Ne,y=new O,m=new O;function f(C,M,x){c.fromBufferAttribute(i,C),u.fromBufferAttribute(i,M),h.fromBufferAttribute(i,x),d.fromBufferAttribute(s,C),p.fromBufferAttribute(s,M),g.fromBufferAttribute(s,x),u.sub(c),h.sub(c),p.sub(d),g.sub(d);const N=1/(p.x*g.y-g.x*p.y);isFinite(N)&&(y.copy(u).multiplyScalar(g.y).addScaledVector(h,-p.y).multiplyScalar(N),m.copy(h).multiplyScalar(p.x).addScaledVector(u,-g.x).multiplyScalar(N),a[C].add(y),a[M].add(y),a[x].add(y),l[C].add(m),l[M].add(m),l[x].add(m))}let w=this.groups;w.length===0&&(w=[{start:0,count:e.count}]);for(let C=0,M=w.length;C<M;++C){const x=w[C],N=x.start,z=x.count;for(let Y=N,q=N+z;Y<q;Y+=3)f(e.getX(Y+0),e.getX(Y+1),e.getX(Y+2))}const T=new O,_=new O,S=new O,b=new O;function A(C){S.fromBufferAttribute(r,C),b.copy(S);const M=a[C];T.copy(M),T.sub(S.multiplyScalar(S.dot(M))).normalize(),_.crossVectors(b,M);const N=_.dot(l[C])<0?-1:1;o.setXYZW(C,T.x,T.y,T.z,N)}for(let C=0,M=w.length;C<M;++C){const x=w[C],N=x.start,z=x.count;for(let Y=N,q=N+z;Y<q;Y+=3)A(e.getX(Y+0)),A(e.getX(Y+1)),A(e.getX(Y+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new wn(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let d=0,p=i.count;d<p;d++)i.setXYZ(d,0,0,0);const r=new O,s=new O,o=new O,a=new O,l=new O,c=new O,u=new O,h=new O;if(e)for(let d=0,p=e.count;d<p;d+=3){const g=e.getX(d+0),y=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,g),s.fromBufferAttribute(t,y),o.fromBufferAttribute(t,m),u.subVectors(o,s),h.subVectors(r,s),u.cross(h),a.fromBufferAttribute(i,g),l.fromBufferAttribute(i,y),c.fromBufferAttribute(i,m),a.add(u),l.add(u),c.add(u),i.setXYZ(g,a.x,a.y,a.z),i.setXYZ(y,l.x,l.y,l.z),i.setXYZ(m,c.x,c.y,c.z)}else for(let d=0,p=t.count;d<p;d+=3)r.fromBufferAttribute(t,d+0),s.fromBufferAttribute(t,d+1),o.fromBufferAttribute(t,d+2),u.subVectors(o,s),h.subVectors(r,s),u.cross(h),i.setXYZ(d+0,u.x,u.y,u.z),i.setXYZ(d+1,u.x,u.y,u.z),i.setXYZ(d+2,u.x,u.y,u.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)Ct.fromBufferAttribute(e,t),Ct.normalize(),e.setXYZ(t,Ct.x,Ct.y,Ct.z)}toNonIndexed(){function e(a,l){const c=a.array,u=a.itemSize,h=a.normalized,d=new c.constructor(l.length*u);let p=0,g=0;for(let y=0,m=l.length;y<m;y++){a.isInterleavedBufferAttribute?p=l[y]*a.data.stride+a.offset:p=l[y]*u;for(let f=0;f<u;f++)d[g++]=c[p++]}return new wn(d,u,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new bt,i=this.index.array,r=this.attributes;for(const a in r){const l=r[a],c=e(l,i);t.setAttribute(a,c)}const s=this.morphAttributes;for(const a in s){const l=[],c=s[a];for(let u=0,h=c.length;u<h;u++){const d=c[u],p=e(d,i);l.push(p)}t.morphAttributes[a]=l}t.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,l=o.length;a<l;a++){const c=o[a];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const r={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let h=0,d=c.length;h<d;h++){const p=c[h];u.push(p.toJSON(e.data))}u.length>0&&(r[l]=u,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere=a.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const r=e.attributes;for(const c in r){const u=r[c];this.setAttribute(c,u.clone(t))}const s=e.morphAttributes;for(const c in s){const u=[],h=s[c];for(let d=0,p=h.length;d<p;d++)u.push(h[d].clone(t));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let c=0,u=o.length;c<u;c++){const h=o[c];this.addGroup(h.start,h.count,h.materialIndex)}const a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const uu=new ft,wi=new Oo,Os=new Lo,hu=new O,Is=new O,Ns=new O,Us=new O,_a=new O,Fs=new O,fu=new O,Bs=new O;class ge extends Mt{constructor(e=new bt,t=new Io){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){const a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(e,t){const i=this.geometry,r=i.attributes.position,s=i.morphAttributes.position,o=i.morphTargetsRelative;t.fromBufferAttribute(r,e);const a=this.morphTargetInfluences;if(s&&a){Fs.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const u=a[l],h=s[l];u!==0&&(_a.fromBufferAttribute(h,e),o?Fs.addScaledVector(_a,u):Fs.addScaledVector(_a.sub(t),u))}t.add(Fs)}return t}raycast(e,t){const i=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Os.copy(i.boundingSphere),Os.applyMatrix4(s),wi.copy(e.ray).recast(e.near),!(Os.containsPoint(wi.origin)===!1&&(wi.intersectSphere(Os,hu)===null||wi.origin.distanceToSquared(hu)>(e.far-e.near)**2))&&(uu.copy(s).invert(),wi.copy(e.ray).applyMatrix4(uu),!(i.boundingBox!==null&&wi.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,wi)))}_computeIntersections(e,t,i){let r;const s=this.geometry,o=this.material,a=s.index,l=s.attributes.position,c=s.attributes.uv,u=s.attributes.uv1,h=s.attributes.normal,d=s.groups,p=s.drawRange;if(a!==null)if(Array.isArray(o))for(let g=0,y=d.length;g<y;g++){const m=d[g],f=o[m.materialIndex],w=Math.max(m.start,p.start),T=Math.min(a.count,Math.min(m.start+m.count,p.start+p.count));for(let _=w,S=T;_<S;_+=3){const b=a.getX(_),A=a.getX(_+1),C=a.getX(_+2);r=zs(this,f,e,i,c,u,h,b,A,C),r&&(r.faceIndex=Math.floor(_/3),r.face.materialIndex=m.materialIndex,t.push(r))}}else{const g=Math.max(0,p.start),y=Math.min(a.count,p.start+p.count);for(let m=g,f=y;m<f;m+=3){const w=a.getX(m),T=a.getX(m+1),_=a.getX(m+2);r=zs(this,o,e,i,c,u,h,w,T,_),r&&(r.faceIndex=Math.floor(m/3),t.push(r))}}else if(l!==void 0)if(Array.isArray(o))for(let g=0,y=d.length;g<y;g++){const m=d[g],f=o[m.materialIndex],w=Math.max(m.start,p.start),T=Math.min(l.count,Math.min(m.start+m.count,p.start+p.count));for(let _=w,S=T;_<S;_+=3){const b=_,A=_+1,C=_+2;r=zs(this,f,e,i,c,u,h,b,A,C),r&&(r.faceIndex=Math.floor(_/3),r.face.materialIndex=m.materialIndex,t.push(r))}}else{const g=Math.max(0,p.start),y=Math.min(l.count,p.start+p.count);for(let m=g,f=y;m<f;m+=3){const w=m,T=m+1,_=m+2;r=zs(this,o,e,i,c,u,h,w,T,_),r&&(r.faceIndex=Math.floor(m/3),t.push(r))}}}}function bp(n,e,t,i,r,s,o,a){let l;if(e.side===Wt?l=i.intersectTriangle(o,s,r,!0,a):l=i.intersectTriangle(r,s,o,e.side===mi,a),l===null)return null;Bs.copy(a),Bs.applyMatrix4(n.matrixWorld);const c=t.ray.origin.distanceTo(Bs);return c<t.near||c>t.far?null:{distance:c,point:Bs.clone(),object:n}}function zs(n,e,t,i,r,s,o,a,l,c){n.getVertexPosition(a,Is),n.getVertexPosition(l,Ns),n.getVertexPosition(c,Us);const u=bp(n,e,t,i,Is,Ns,Us,fu);if(u){const h=new O;un.getBarycoord(fu,Is,Ns,Us,h),r&&(u.uv=un.getInterpolatedAttribute(r,a,l,c,h,new Ne)),s&&(u.uv1=un.getInterpolatedAttribute(s,a,l,c,h,new Ne)),o&&(u.normal=un.getInterpolatedAttribute(o,a,l,c,h,new O),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const d={a,b:l,c,normal:new O,materialIndex:0};un.getNormal(Is,Ns,Us,d.normal),u.face=d,u.barycoord=h}return u}class yt extends bt{constructor(e=1,t=1,i=1,r=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:s,depthSegments:o};const a=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o);const l=[],c=[],u=[],h=[];let d=0,p=0;g("z","y","x",-1,-1,i,t,e,o,s,0),g("z","y","x",1,-1,i,t,-e,o,s,1),g("x","z","y",1,1,e,i,t,r,o,2),g("x","z","y",1,-1,e,i,-t,r,o,3),g("x","y","z",1,-1,e,t,i,r,s,4),g("x","y","z",-1,-1,e,t,-i,r,s,5),this.setIndex(l),this.setAttribute("position",new Ze(c,3)),this.setAttribute("normal",new Ze(u,3)),this.setAttribute("uv",new Ze(h,2));function g(y,m,f,w,T,_,S,b,A,C,M){const x=_/A,N=S/C,z=_/2,Y=S/2,q=b/2,J=A+1,K=C+1;let se=0,$=0;const le=new O;for(let me=0;me<K;me++){const Ee=me*N-Y;for(let Be=0;Be<J;Be++){const de=Be*x-z;le[y]=de*w,le[m]=Ee*T,le[f]=q,c.push(le.x,le.y,le.z),le[y]=0,le[m]=0,le[f]=b>0?1:-1,u.push(le.x,le.y,le.z),h.push(Be/A),h.push(1-me/C),se+=1}}for(let me=0;me<C;me++)for(let Ee=0;Ee<A;Ee++){const Be=d+Ee+J*me,de=d+Ee+J*(me+1),qe=d+(Ee+1)+J*(me+1),Ke=d+(Ee+1)+J*me;l.push(Be,de,Ke),l.push(de,qe,Ke),$+=6}a.addGroup(p,$,M),p+=$,d+=se}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new yt(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Pr(n){const e={};for(const t in n){e[t]={};for(const i in n[t]){const r=n[t][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=r.clone():Array.isArray(r)?e[t][i]=r.slice():e[t][i]=r}}return e}function zt(n){const e={};for(let t=0;t<n.length;t++){const i=Pr(n[t]);for(const r in i)e[r]=i[r]}return e}function Sp(n){const e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function Kh(n){const e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Qe.workingColorSpace}const Tp={clone:Pr,merge:zt};var wp=`void main() {
18
+ */const Wh="181",pr={ROTATE:0,DOLLY:1,PAN:2},lr={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Gm=0,Iu=1,Wm=2,ep=1,Xm=2,bi=3,Ji=0,on=1,si=2,Ai=0,mr=1,Uu=2,Fu=3,zu=4,jm=5,xs=100,Ym=101,qm=102,Zm=103,$m=104,Km=200,Jm=201,Qm=202,t0=203,wc=204,Tc=205,e0=206,n0=207,i0=208,s0=209,r0=210,a0=211,o0=212,l0=213,c0=214,Ac=0,Cc=1,Rc=2,Mr=3,Pc=4,Dc=5,Oc=6,Lc=7,np=0,h0=1,u0=2,Ki=0,d0=1,f0=2,p0=3,m0=4,_0=5,x0=6,g0=7,ip=300,Sr=301,Er=302,Nc=303,Ic=304,Qo=306,Uc=1e3,wi=1001,Fc=1002,xn=1003,v0=1004,Ra=1005,On=1006,bl=1007,bs=1008,ui=1009,sp=1010,rp=1011,oa=1012,Xh=1013,ws=1014,Ti=1015,Rr=1016,jh=1017,Yh=1018,la=1020,ap=35902,op=35899,lp=1021,cp=1022,Xn=1023,ca=1026,ha=1027,hp=1028,qh=1029,Zh=1030,$h=1031,Kh=1033,To=33776,Ao=33777,Co=33778,Ro=33779,zc=35840,Bc=35841,kc=35842,Vc=35843,Hc=36196,Gc=37492,Wc=37496,Xc=37808,jc=37809,Yc=37810,qc=37811,Zc=37812,$c=37813,Kc=37814,Jc=37815,Qc=37816,th=37817,eh=37818,nh=37819,ih=37820,sh=37821,rh=36492,ah=36494,oh=36495,lh=36283,ch=36284,hh=36285,uh=36286,y0=3200,b0=3201,up=0,M0=1,Yi="",An="srgb",wr="srgb-linear",Io="linear",ae="srgb",zs=7680,Bu=519,S0=512,E0=513,w0=514,dp=515,T0=516,A0=517,C0=518,R0=519,ku=35044,P0=35048,Vu="300 es",ai=2e3,Uo=2001;function fp(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function Fo(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function D0(){const i=Fo("canvas");return i.style.display="block",i}const Hu={};function Gu(...i){const t="THREE."+i.shift();console.log(t,...i)}function kt(...i){const t="THREE."+i.shift();console.warn(t,...i)}function Me(...i){const t="THREE."+i.shift();console.error(t,...i)}function ua(...i){const t=i.join(" ");t in Hu||(Hu[t]=!0,kt(...i))}function O0(i,t,e){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(t,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,e);break;default:n()}}setTimeout(r,e)})}class Ls{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){const n=this._listeners;return n===void 0?!1:n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){const n=this._listeners;if(n===void 0)return;const s=n[t];if(s!==void 0){const r=s.indexOf(e);r!==-1&&s.splice(r,1)}}dispatchEvent(t){const e=this._listeners;if(e===void 0)return;const n=e[t.type];if(n!==void 0){t.target=this;const s=n.slice(0);for(let r=0,a=s.length;r<a;r++)s[r].call(this,t);t.target=null}}}const Xe=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],ra=Math.PI/180,dh=180/Math.PI;function xa(){const i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Xe[i&255]+Xe[i>>8&255]+Xe[i>>16&255]+Xe[i>>24&255]+"-"+Xe[t&255]+Xe[t>>8&255]+"-"+Xe[t>>16&15|64]+Xe[t>>24&255]+"-"+Xe[e&63|128]+Xe[e>>8&255]+"-"+Xe[e>>16&255]+Xe[e>>24&255]+Xe[n&255]+Xe[n>>8&255]+Xe[n>>16&255]+Xe[n>>24&255]).toLowerCase()}function qt(i,t,e){return Math.max(t,Math.min(e,i))}function L0(i,t){return(i%t+t)%t}function Ml(i,t,e){return(1-e)*i+e*t}function Br(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function en(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const N0={DEG2RAD:ra};class Nt{constructor(t=0,e=0){Nt.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6],this.y=s[1]*e+s[4]*n+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=qt(this.x,t.x,e.x),this.y=qt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=qt(this.x,t,e),this.y=qt(this.y,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(qt(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(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(qt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),s=Math.sin(e),r=this.x-t.x,a=this.y-t.y;return this.x=r*n-a*s+t.x,this.y=r*s+a*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ke{constructor(t=0,e=0,n=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=s}static slerpFlat(t,e,n,s,r,a,o){let l=n[s+0],c=n[s+1],h=n[s+2],u=n[s+3],d=r[a+0],f=r[a+1],m=r[a+2],x=r[a+3];if(o<=0){t[e+0]=l,t[e+1]=c,t[e+2]=h,t[e+3]=u;return}if(o>=1){t[e+0]=d,t[e+1]=f,t[e+2]=m,t[e+3]=x;return}if(u!==x||l!==d||c!==f||h!==m){let _=l*d+c*f+h*m+u*x;_<0&&(d=-d,f=-f,m=-m,x=-x,_=-_);let p=1-o;if(_<.9995){const w=Math.acos(_),S=Math.sin(w);p=Math.sin(p*w)/S,o=Math.sin(o*w)/S,l=l*p+d*o,c=c*p+f*o,h=h*p+m*o,u=u*p+x*o}else{l=l*p+d*o,c=c*p+f*o,h=h*p+m*o,u=u*p+x*o;const w=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=w,c*=w,h*=w,u*=w}}t[e]=l,t[e+1]=c,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,s,r,a){const o=n[s],l=n[s+1],c=n[s+2],h=n[s+3],u=r[a],d=r[a+1],f=r[a+2],m=r[a+3];return t[e]=o*m+h*u+l*f-c*d,t[e+1]=l*m+h*d+c*u-o*f,t[e+2]=c*m+h*f+o*d-l*u,t[e+3]=h*m-o*u-l*d-c*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,s){return this._x=t,this._y=e,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,s=t._y,r=t._z,a=t._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(s/2),u=o(r/2),d=l(n/2),f=l(s/2),m=l(r/2);switch(a){case"XYZ":this._x=d*h*u+c*f*m,this._y=c*f*u-d*h*m,this._z=c*h*m+d*f*u,this._w=c*h*u-d*f*m;break;case"YXZ":this._x=d*h*u+c*f*m,this._y=c*f*u-d*h*m,this._z=c*h*m-d*f*u,this._w=c*h*u+d*f*m;break;case"ZXY":this._x=d*h*u-c*f*m,this._y=c*f*u+d*h*m,this._z=c*h*m+d*f*u,this._w=c*h*u-d*f*m;break;case"ZYX":this._x=d*h*u-c*f*m,this._y=c*f*u+d*h*m,this._z=c*h*m-d*f*u,this._w=c*h*u+d*f*m;break;case"YZX":this._x=d*h*u+c*f*m,this._y=c*f*u+d*h*m,this._z=c*h*m-d*f*u,this._w=c*h*u-d*f*m;break;case"XZY":this._x=d*h*u-c*f*m,this._y=c*f*u-d*h*m,this._z=c*h*m+d*f*u,this._w=c*h*u+d*f*m;break;default:kt("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,s=Math.sin(n);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],s=e[4],r=e[8],a=e[1],o=e[5],l=e[9],c=e[2],h=e[6],u=e[10],d=n+o+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-l)*f,this._y=(r-c)*f,this._z=(a-s)*f}else if(n>o&&n>u){const f=2*Math.sqrt(1+n-o-u);this._w=(h-l)/f,this._x=.25*f,this._y=(s+a)/f,this._z=(r+c)/f}else if(o>u){const f=2*Math.sqrt(1+o-n-u);this._w=(r-c)/f,this._x=(s+a)/f,this._y=.25*f,this._z=(l+h)/f}else{const f=2*Math.sqrt(1+u-n-o);this._w=(a-s)/f,this._x=(r+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<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(qt(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const s=Math.min(1,e/n);return this.slerp(t,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,s=t._y,r=t._z,a=t._w,o=e._x,l=e._y,c=e._z,h=e._w;return this._x=n*h+a*o+s*c-r*l,this._y=s*h+a*l+r*o-n*c,this._z=r*h+a*c+n*l-s*o,this._w=a*h-n*o-s*l-r*c,this._onChangeCallback(),this}slerp(t,e){if(e<=0)return this;if(e>=1)return this.copy(t);let n=t._x,s=t._y,r=t._z,a=t._w,o=this.dot(t);o<0&&(n=-n,s=-s,r=-r,a=-a,o=-o);let l=1-e;if(o<.9995){const c=Math.acos(o),h=Math.sin(c);l=Math.sin(l*c)/h,e=Math.sin(e*c)/h,this._x=this._x*l+n*e,this._y=this._y*l+s*e,this._z=this._z*l+r*e,this._w=this._w*l+a*e,this._onChangeCallback()}else this._x=this._x*l+n*e,this._y=this._y*l+s*e,this._z=this._z*l+r*e,this._w=this._w*l+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(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(t),s*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class I{constructor(t=0,e=0,n=0){I.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Wu.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Wu.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*s,this.y=r[1]*e+r[4]*n+r[7]*s,this.z=r[2]*e+r[5]*n+r[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,s=this.z,r=t.elements,a=1/(r[3]*e+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*s+r[12])*a,this.y=(r[1]*e+r[5]*n+r[9]*s+r[13])*a,this.z=(r[2]*e+r[6]*n+r[10]*s+r[14])*a,this}applyQuaternion(t){const e=this.x,n=this.y,s=this.z,r=t.x,a=t.y,o=t.z,l=t.w,c=2*(a*s-o*n),h=2*(o*e-r*s),u=2*(r*n-a*e);return this.x=e+l*c+a*u-o*h,this.y=n+l*h+o*c-r*u,this.z=s+l*u+r*h-a*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*s,this.y=r[1]*e+r[5]*n+r[9]*s,this.z=r[2]*e+r[6]*n+r[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=qt(this.x,t.x,e.x),this.y=qt(this.y,t.y,e.y),this.z=qt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=qt(this.x,t,e),this.y=qt(this.y,t,e),this.z=qt(this.z,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(qt(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,s=t.y,r=t.z,a=e.x,o=e.y,l=e.z;return this.x=s*l-r*o,this.y=r*a-n*l,this.z=n*o-s*a,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Sl.copy(this).projectOnVector(t),this.sub(Sl)}reflect(t){return this.sub(Sl.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(qt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,s=this.z-t.z;return e*e+n*n+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const s=Math.sin(e)*t;return this.x=s*Math.sin(n),this.y=Math.cos(e)*t,this.z=s*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=s,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Sl=new I,Wu=new ke;class Gt{constructor(t,e,n,s,r,a,o,l,c){Gt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,a,o,l,c)}set(t,e,n,s,r,a,o,l,c){const h=this.elements;return h[0]=t,h[1]=s,h[2]=o,h[3]=e,h[4]=r,h[5]=l,h[6]=n,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,s=e.elements,r=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],h=n[4],u=n[7],d=n[2],f=n[5],m=n[8],x=s[0],_=s[3],p=s[6],w=s[1],S=s[4],y=s[7],E=s[2],v=s[5],A=s[8];return r[0]=a*x+o*w+l*E,r[3]=a*_+o*S+l*v,r[6]=a*p+o*y+l*A,r[1]=c*x+h*w+u*E,r[4]=c*_+h*S+u*v,r[7]=c*p+h*y+u*A,r[2]=d*x+f*w+m*E,r[5]=d*_+f*S+m*v,r[8]=d*p+f*y+m*A,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8];return e*a*h-e*o*c-n*r*h+n*o*l+s*r*c-s*a*l}invert(){const t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8],u=h*a-o*c,d=o*l-h*r,f=c*r-a*l,m=e*u+n*d+s*f;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/m;return t[0]=u*x,t[1]=(s*c-h*n)*x,t[2]=(o*n-s*a)*x,t[3]=d*x,t[4]=(h*e-s*l)*x,t[5]=(s*r-o*e)*x,t[6]=f*x,t[7]=(n*l-c*e)*x,t[8]=(a*e-n*r)*x,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,s,r,a,o){const l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*a+c*o)+a+t,-s*c,s*l,-s*(-c*a+l*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(El.makeScale(t,e)),this}rotate(t){return this.premultiply(El.makeRotation(-t)),this}translate(t,e){return this.premultiply(El.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let s=0;s<9;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const El=new Gt,Xu=new Gt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ju=new Gt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function I0(){const i={enabled:!0,workingColorSpace:wr,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===ae&&(s.r=Ci(s.r),s.g=Ci(s.g),s.b=Ci(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===ae&&(s.r=_r(s.r),s.g=_r(s.g),s.b=_r(s.b))),s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===Yi?Io:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return ua("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return ua("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(s,r)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[wr]:{primaries:t,whitePoint:n,transfer:Io,toXYZ:Xu,fromXYZ:ju,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:An},outputColorSpaceConfig:{drawingBufferColorSpace:An}},[An]:{primaries:t,whitePoint:n,transfer:ae,toXYZ:Xu,fromXYZ:ju,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:An}}}),i}const te=I0();function Ci(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function _r(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let Bs;class U0{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{Bs===void 0&&(Bs=Fo("canvas")),Bs.width=t.width,Bs.height=t.height;const s=Bs.getContext("2d");t instanceof ImageData?s.putImageData(t,0,0):s.drawImage(t,0,0,t.width,t.height),n=Bs}return n.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=Fo("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const s=n.getImageData(0,0,t.width,t.height),r=s.data;for(let a=0;a<r.length;a++)r[a]=Ci(r[a]/255)*255;return n.putImageData(s,0,0),e}else if(t.data){const e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(Ci(e[n]/255)*255):e[n]=Ci(e[n]);return{data:e,width:t.width,height:t.height}}else return kt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let F0=0;class Jh{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:F0++}),this.uuid=xa(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):e instanceof VideoFrame?t.set(e.displayHeight,e.displayWidth,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const n={uuid:this.uuid,url:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let a=0,o=s.length;a<o;a++)s[a].isDataTexture?r.push(wl(s[a].image)):r.push(wl(s[a]))}else r=wl(s);n.url=r}return e||(t.images[this.uuid]=n),n}}function wl(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?U0.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(kt("Texture: Unable to serialize Texture."),{})}let z0=0;const Tl=new I;class Je extends Ls{constructor(t=Je.DEFAULT_IMAGE,e=Je.DEFAULT_MAPPING,n=wi,s=wi,r=On,a=bs,o=Xn,l=ui,c=Je.DEFAULT_ANISOTROPY,h=Yi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:z0++}),this.uuid=xa(),this.name="",this.source=new Jh(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Nt(0,0),this.repeat=new Nt(1,1),this.center=new Nt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Gt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Tl).x}get height(){return this.source.getSize(Tl).y}get depth(){return this.source.getSize(Tl).z}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const n=t[e];if(n===void 0){kt(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const s=this[e];if(s===void 0){kt(`Texture.setValues(): property '${e}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==ip)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Uc:t.x=t.x-Math.floor(t.x);break;case wi:t.x=t.x<0?0:1;break;case Fc:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Uc:t.y=t.y-Math.floor(t.y);break;case wi:t.y=t.y<0?0:1;break;case Fc:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}Je.DEFAULT_IMAGE=null;Je.DEFAULT_MAPPING=ip;Je.DEFAULT_ANISOTROPY=1;class Se{constructor(t=0,e=0,n=0,s=1){Se.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=s}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,s){return this.x=t,this.y=e,this.z=n,this.w=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,s=this.z,r=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*s+a[12]*r,this.y=a[1]*e+a[5]*n+a[9]*s+a[13]*r,this.z=a[2]*e+a[6]*n+a[10]*s+a[14]*r,this.w=a[3]*e+a[7]*n+a[11]*s+a[15]*r,this}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,s,r;const l=t.elements,c=l[0],h=l[4],u=l[8],d=l[1],f=l[5],m=l[9],x=l[2],_=l[6],p=l[10];if(Math.abs(h-d)<.01&&Math.abs(u-x)<.01&&Math.abs(m-_)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+x)<.1&&Math.abs(m+_)<.1&&Math.abs(c+f+p-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const S=(c+1)/2,y=(f+1)/2,E=(p+1)/2,v=(h+d)/4,A=(u+x)/4,R=(m+_)/4;return S>y&&S>E?S<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(S),s=v/n,r=A/n):y>E?y<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(y),n=v/s,r=R/s):E<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(E),n=A/r,s=R/r),this.set(n,s,r,e),this}let w=Math.sqrt((_-m)*(_-m)+(u-x)*(u-x)+(d-h)*(d-h));return Math.abs(w)<.001&&(w=1),this.x=(_-m)/w,this.y=(u-x)/w,this.z=(d-h)/w,this.w=Math.acos((c+f+p-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=qt(this.x,t.x,e.x),this.y=qt(this.y,t.y,e.y),this.z=qt(this.z,t.z,e.z),this.w=qt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=qt(this.x,t,e),this.y=qt(this.y,t,e),this.z=qt(this.z,t,e),this.w=qt(this.w,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(qt(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 B0 extends Ls{constructor(t=1,e=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:On,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 Se(0,0,t,e),this.scissorTest=!1,this.viewport=new Se(0,0,t,e);const s={width:t,height:e,depth:n.depth},r=new Je(s);this.textures=[];const a=n.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].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:On,generateMipmaps:!1,flipY:!1,internalFormat:null};t.mapping!==void 0&&(e.mapping=t.mapping),t.wrapS!==void 0&&(e.wrapS=t.wrapS),t.wrapT!==void 0&&(e.wrapT=t.wrapT),t.wrapR!==void 0&&(e.wrapR=t.wrapR),t.magFilter!==void 0&&(e.magFilter=t.magFilter),t.minFilter!==void 0&&(e.minFilter=t.minFilter),t.format!==void 0&&(e.format=t.format),t.type!==void 0&&(e.type=t.type),t.anisotropy!==void 0&&(e.anisotropy=t.anisotropy),t.colorSpace!==void 0&&(e.colorSpace=t.colorSpace),t.flipY!==void 0&&(e.flipY=t.flipY),t.generateMipmaps!==void 0&&(e.generateMipmaps=t.generateMipmaps),t.internalFormat!==void 0&&(e.internalFormat=t.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(e)}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),t!==null&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=t,this.textures[s].image.height=e,this.textures[s].image.depth=n,this.textures[s].isData3DTexture!==!0&&(this.textures[s].isArrayTexture=this.textures[s].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 s=Object.assign({},t.textures[e].image);this.textures[e].source=new Jh(s)}return this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Ts extends B0{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class pp extends Je{constructor(t=null,e=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=xn,this.minFilter=xn,this.wrapR=wi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class k0 extends Je{constructor(t=null,e=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=xn,this.minFilter=xn,this.wrapR=wi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class ga{constructor(t=new I(1/0,1/0,1/0),e=new I(-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(zn.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(zn.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=zn.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(n!==void 0){const r=n.getAttribute("position");if(e===!0&&r!==void 0&&t.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)t.isMesh===!0?t.getVertexPosition(a,zn):zn.fromBufferAttribute(r,a),zn.applyMatrix4(t.matrixWorld),this.expandByPoint(zn);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Pa.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Pa.copy(n.boundingBox)),Pa.applyMatrix4(t.matrixWorld),this.union(Pa)}const s=t.children;for(let r=0,a=s.length;r<a;r++)this.expandByObject(s[r],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,zn),zn.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(kr),Da.subVectors(this.max,kr),ks.subVectors(t.a,kr),Vs.subVectors(t.b,kr),Hs.subVectors(t.c,kr),Ni.subVectors(Vs,ks),Ii.subVectors(Hs,Vs),as.subVectors(ks,Hs);let e=[0,-Ni.z,Ni.y,0,-Ii.z,Ii.y,0,-as.z,as.y,Ni.z,0,-Ni.x,Ii.z,0,-Ii.x,as.z,0,-as.x,-Ni.y,Ni.x,0,-Ii.y,Ii.x,0,-as.y,as.x,0];return!Al(e,ks,Vs,Hs,Da)||(e=[1,0,0,0,1,0,0,0,1],!Al(e,ks,Vs,Hs,Da))?!1:(Oa.crossVectors(Ni,Ii),e=[Oa.x,Oa.y,Oa.z],Al(e,ks,Vs,Hs,Da))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,zn).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(zn).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(di[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),di[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),di[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),di[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),di[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),di[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),di[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),di[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(di),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 di=[new I,new I,new I,new I,new I,new I,new I,new I],zn=new I,Pa=new ga,ks=new I,Vs=new I,Hs=new I,Ni=new I,Ii=new I,as=new I,kr=new I,Da=new I,Oa=new I,os=new I;function Al(i,t,e,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){os.fromArray(i,r);const o=s.x*Math.abs(os.x)+s.y*Math.abs(os.y)+s.z*Math.abs(os.z),l=t.dot(os),c=e.dot(os),h=n.dot(os);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const V0=new ga,Vr=new I,Cl=new I;class tl{constructor(t=new I,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;e!==void 0?n.copy(e):V0.setFromPoints(t).getCenter(n);let s=0;for(let r=0,a=t.length;r<a;r++)s=Math.max(s,n.distanceToSquared(t[r]));return this.radius=Math.sqrt(s),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Vr.subVectors(t,this.center);const e=Vr.lengthSq();if(e>this.radius*this.radius){const n=Math.sqrt(e),s=(n-this.radius)*.5;this.center.addScaledVector(Vr,s/n),this.radius+=s}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(Cl.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Vr.copy(t.center).add(Cl)),this.expandByPoint(Vr.copy(t.center).sub(Cl))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}}const fi=new I,Rl=new I,La=new I,Ui=new I,Pl=new I,Na=new I,Dl=new I;class el{constructor(t=new I,e=new I(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,fi)),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=fi.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(fi.copy(this.origin).addScaledVector(this.direction,e),fi.distanceToSquared(t))}distanceSqToSegment(t,e,n,s){Rl.copy(t).add(e).multiplyScalar(.5),La.copy(e).sub(t).normalize(),Ui.copy(this.origin).sub(Rl);const r=t.distanceTo(e)*.5,a=-this.direction.dot(La),o=Ui.dot(this.direction),l=-Ui.dot(La),c=Ui.lengthSq(),h=Math.abs(1-a*a);let u,d,f,m;if(h>0)if(u=a*l-o,d=a*o-l,m=r*h,u>=0)if(d>=-m)if(d<=m){const x=1/h;u*=x,d*=x,f=u*(u+a*d+2*o)+d*(a*u+d+2*l)+c}else d=r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;else d=-r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;else d<=-m?(u=Math.max(0,-(-a*r+o)),d=u>0?-r:Math.min(Math.max(-r,-l),r),f=-u*u+d*(d+2*l)+c):d<=m?(u=0,d=Math.min(Math.max(-r,-l),r),f=d*(d+2*l)+c):(u=Math.max(0,-(a*r+o)),d=u>0?r:Math.min(Math.max(-r,-l),r),f=-u*u+d*(d+2*l)+c);else d=a>0?-r:r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),s&&s.copy(Rl).addScaledVector(La,d),f}intersectSphere(t,e){fi.subVectors(t.center,this.origin);const n=fi.dot(this.direction),s=fi.dot(fi)-n*n,r=t.radius*t.radius;if(s>r)return null;const a=Math.sqrt(r-s),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,e):this.at(o,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,s,r,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(t.min.x-d.x)*c,s=(t.max.x-d.x)*c):(n=(t.max.x-d.x)*c,s=(t.min.x-d.x)*c),h>=0?(r=(t.min.y-d.y)*h,a=(t.max.y-d.y)*h):(r=(t.max.y-d.y)*h,a=(t.min.y-d.y)*h),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a<s||isNaN(s))&&(s=a),u>=0?(o=(t.min.z-d.z)*u,l=(t.max.z-d.z)*u):(o=(t.max.z-d.z)*u,l=(t.min.z-d.z)*u),n>l||o>s)||((o>n||n!==n)&&(n=o),(l<s||s!==s)&&(s=l),s<0)?null:this.at(n>=0?n:s,e)}intersectsBox(t){return this.intersectBox(t,fi)!==null}intersectTriangle(t,e,n,s,r){Pl.subVectors(e,t),Na.subVectors(n,t),Dl.crossVectors(Pl,Na);let a=this.direction.dot(Dl),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Ui.subVectors(this.origin,t);const l=o*this.direction.dot(Na.crossVectors(Ui,Na));if(l<0)return null;const c=o*this.direction.dot(Pl.cross(Ui));if(c<0||l+c>a)return null;const h=-o*Ui.dot(Dl);return h<0?null:this.at(h/a,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class _e{constructor(t,e,n,s,r,a,o,l,c,h,u,d,f,m,x,_){_e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,a,o,l,c,h,u,d,f,m,x,_)}set(t,e,n,s,r,a,o,l,c,h,u,d,f,m,x,_){const p=this.elements;return p[0]=t,p[4]=e,p[8]=n,p[12]=s,p[1]=r,p[5]=a,p[9]=o,p[13]=l,p[2]=c,p[6]=h,p[10]=u,p[14]=d,p[3]=f,p[7]=m,p[11]=x,p[15]=_,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 _e().fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,s=1/Gs.setFromMatrixColumn(t,0).length(),r=1/Gs.setFromMatrixColumn(t,1).length(),a=1/Gs.setFromMatrixColumn(t,2).length();return e[0]=n[0]*s,e[1]=n[1]*s,e[2]=n[2]*s,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,s=t.y,r=t.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(s),c=Math.sin(s),h=Math.cos(r),u=Math.sin(r);if(t.order==="XYZ"){const d=a*h,f=a*u,m=o*h,x=o*u;e[0]=l*h,e[4]=-l*u,e[8]=c,e[1]=f+m*c,e[5]=d-x*c,e[9]=-o*l,e[2]=x-d*c,e[6]=m+f*c,e[10]=a*l}else if(t.order==="YXZ"){const d=l*h,f=l*u,m=c*h,x=c*u;e[0]=d+x*o,e[4]=m*o-f,e[8]=a*c,e[1]=a*u,e[5]=a*h,e[9]=-o,e[2]=f*o-m,e[6]=x+d*o,e[10]=a*l}else if(t.order==="ZXY"){const d=l*h,f=l*u,m=c*h,x=c*u;e[0]=d-x*o,e[4]=-a*u,e[8]=m+f*o,e[1]=f+m*o,e[5]=a*h,e[9]=x-d*o,e[2]=-a*c,e[6]=o,e[10]=a*l}else if(t.order==="ZYX"){const d=a*h,f=a*u,m=o*h,x=o*u;e[0]=l*h,e[4]=m*c-f,e[8]=d*c+x,e[1]=l*u,e[5]=x*c+d,e[9]=f*c-m,e[2]=-c,e[6]=o*l,e[10]=a*l}else if(t.order==="YZX"){const d=a*l,f=a*c,m=o*l,x=o*c;e[0]=l*h,e[4]=x-d*u,e[8]=m*u+f,e[1]=u,e[5]=a*h,e[9]=-o*h,e[2]=-c*h,e[6]=f*u+m,e[10]=d-x*u}else if(t.order==="XZY"){const d=a*l,f=a*c,m=o*l,x=o*c;e[0]=l*h,e[4]=-u,e[8]=c*h,e[1]=d*u+x,e[5]=a*h,e[9]=f*u-m,e[2]=m*u-f,e[6]=o*h,e[10]=x*u+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(H0,t,G0)}lookAt(t,e,n){const s=this.elements;return un.subVectors(t,e),un.lengthSq()===0&&(un.z=1),un.normalize(),Fi.crossVectors(n,un),Fi.lengthSq()===0&&(Math.abs(n.z)===1?un.x+=1e-4:un.z+=1e-4,un.normalize(),Fi.crossVectors(n,un)),Fi.normalize(),Ia.crossVectors(un,Fi),s[0]=Fi.x,s[4]=Ia.x,s[8]=un.x,s[1]=Fi.y,s[5]=Ia.y,s[9]=un.y,s[2]=Fi.z,s[6]=Ia.z,s[10]=un.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,s=e.elements,r=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],h=n[1],u=n[5],d=n[9],f=n[13],m=n[2],x=n[6],_=n[10],p=n[14],w=n[3],S=n[7],y=n[11],E=n[15],v=s[0],A=s[4],R=s[8],M=s[12],g=s[1],O=s[5],F=s[9],k=s[13],G=s[2],K=s[6],tt=s[10],lt=s[14],$=s[3],st=s[7],ct=s[11],Et=s[15];return r[0]=a*v+o*g+l*G+c*$,r[4]=a*A+o*O+l*K+c*st,r[8]=a*R+o*F+l*tt+c*ct,r[12]=a*M+o*k+l*lt+c*Et,r[1]=h*v+u*g+d*G+f*$,r[5]=h*A+u*O+d*K+f*st,r[9]=h*R+u*F+d*tt+f*ct,r[13]=h*M+u*k+d*lt+f*Et,r[2]=m*v+x*g+_*G+p*$,r[6]=m*A+x*O+_*K+p*st,r[10]=m*R+x*F+_*tt+p*ct,r[14]=m*M+x*k+_*lt+p*Et,r[3]=w*v+S*g+y*G+E*$,r[7]=w*A+S*O+y*K+E*st,r[11]=w*R+S*F+y*tt+E*ct,r[15]=w*M+S*k+y*lt+E*Et,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],s=t[8],r=t[12],a=t[1],o=t[5],l=t[9],c=t[13],h=t[2],u=t[6],d=t[10],f=t[14],m=t[3],x=t[7],_=t[11],p=t[15];return m*(+r*l*u-s*c*u-r*o*d+n*c*d+s*o*f-n*l*f)+x*(+e*l*f-e*c*d+r*a*d-s*a*f+s*c*h-r*l*h)+_*(+e*c*u-e*o*f-r*a*u+n*a*f+r*o*h-n*c*h)+p*(-s*o*h-e*l*u+e*o*d+s*a*u-n*a*d+n*l*h)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],f=t[11],m=t[12],x=t[13],_=t[14],p=t[15],w=u*_*c-x*d*c+x*l*f-o*_*f-u*l*p+o*d*p,S=m*d*c-h*_*c-m*l*f+a*_*f+h*l*p-a*d*p,y=h*x*c-m*u*c+m*o*f-a*x*f-h*o*p+a*u*p,E=m*u*l-h*x*l-m*o*d+a*x*d+h*o*_-a*u*_,v=e*w+n*S+s*y+r*E;if(v===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const A=1/v;return t[0]=w*A,t[1]=(x*d*r-u*_*r-x*s*f+n*_*f+u*s*p-n*d*p)*A,t[2]=(o*_*r-x*l*r+x*s*c-n*_*c-o*s*p+n*l*p)*A,t[3]=(u*l*r-o*d*r-u*s*c+n*d*c+o*s*f-n*l*f)*A,t[4]=S*A,t[5]=(h*_*r-m*d*r+m*s*f-e*_*f-h*s*p+e*d*p)*A,t[6]=(m*l*r-a*_*r-m*s*c+e*_*c+a*s*p-e*l*p)*A,t[7]=(a*d*r-h*l*r+h*s*c-e*d*c-a*s*f+e*l*f)*A,t[8]=y*A,t[9]=(m*u*r-h*x*r-m*n*f+e*x*f+h*n*p-e*u*p)*A,t[10]=(a*x*r-m*o*r+m*n*c-e*x*c-a*n*p+e*o*p)*A,t[11]=(h*o*r-a*u*r-h*n*c+e*u*c+a*n*f-e*o*f)*A,t[12]=E*A,t[13]=(h*x*s-m*u*s+m*n*d-e*x*d-h*n*_+e*u*_)*A,t[14]=(m*o*s-a*x*s-m*n*l+e*x*l+a*n*_-e*o*_)*A,t[15]=(a*u*s-h*o*s+h*n*l-e*u*l-a*n*d+e*o*d)*A,this}scale(t){const e=this.elements,n=t.x,s=t.y,r=t.z;return e[0]*=n,e[4]*=s,e[8]*=r,e[1]*=n,e[5]*=s,e[9]*=r,e[2]*=n,e[6]*=s,e[10]*=r,e[3]*=n,e[7]*=s,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,s))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),s=Math.sin(e),r=1-n,a=t.x,o=t.y,l=t.z,c=r*a,h=r*o;return this.set(c*a+n,c*o-s*l,c*l+s*o,0,c*o+s*l,h*o+n,h*l-s*a,0,c*l-s*o,h*l+s*a,r*l*l+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,s,r,a){return this.set(1,n,r,0,t,1,a,0,e,s,1,0,0,0,0,1),this}compose(t,e,n){const s=this.elements,r=e._x,a=e._y,o=e._z,l=e._w,c=r+r,h=a+a,u=o+o,d=r*c,f=r*h,m=r*u,x=a*h,_=a*u,p=o*u,w=l*c,S=l*h,y=l*u,E=n.x,v=n.y,A=n.z;return s[0]=(1-(x+p))*E,s[1]=(f+y)*E,s[2]=(m-S)*E,s[3]=0,s[4]=(f-y)*v,s[5]=(1-(d+p))*v,s[6]=(_+w)*v,s[7]=0,s[8]=(m+S)*A,s[9]=(_-w)*A,s[10]=(1-(d+x))*A,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,n){const s=this.elements;let r=Gs.set(s[0],s[1],s[2]).length();const a=Gs.set(s[4],s[5],s[6]).length(),o=Gs.set(s[8],s[9],s[10]).length();this.determinant()<0&&(r=-r),t.x=s[12],t.y=s[13],t.z=s[14],Bn.copy(this);const c=1/r,h=1/a,u=1/o;return Bn.elements[0]*=c,Bn.elements[1]*=c,Bn.elements[2]*=c,Bn.elements[4]*=h,Bn.elements[5]*=h,Bn.elements[6]*=h,Bn.elements[8]*=u,Bn.elements[9]*=u,Bn.elements[10]*=u,e.setFromRotationMatrix(Bn),n.x=r,n.y=a,n.z=o,this}makePerspective(t,e,n,s,r,a,o=ai,l=!1){const c=this.elements,h=2*r/(e-t),u=2*r/(n-s),d=(e+t)/(e-t),f=(n+s)/(n-s);let m,x;if(l)m=r/(a-r),x=a*r/(a-r);else if(o===ai)m=-(a+r)/(a-r),x=-2*a*r/(a-r);else if(o===Uo)m=-a/(a-r),x=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,n,s,r,a,o=ai,l=!1){const c=this.elements,h=2/(e-t),u=2/(n-s),d=-(e+t)/(e-t),f=-(n+s)/(n-s);let m,x;if(l)m=1/(a-r),x=a/(a-r);else if(o===ai)m=-2/(a-r),x=-(a+r)/(a-r);else if(o===Uo)m=-1/(a-r),x=-r/(a-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=m,c[14]=x,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let s=0;s<16;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const Gs=new I,Bn=new _e,H0=new I(0,0,0),G0=new I(1,1,1),Fi=new I,Ia=new I,un=new I,Yu=new _e,qu=new ke;class Jn{constructor(t=0,e=0,n=0,s=Jn.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,s=this._order){return this._x=t,this._y=e,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const s=t.elements,r=s[0],a=s[4],o=s[8],l=s[1],c=s[5],h=s[9],u=s[2],d=s[6],f=s[10];switch(e){case"XYZ":this._y=Math.asin(qt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-qt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(qt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-qt(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(qt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-qt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,f),this._y=0);break;default:kt("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Yu.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Yu,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return qu.setFromEuler(this),this.setFromQuaternion(qu,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Jn.DEFAULT_ORDER="XYZ";class Qh{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let W0=0;const Zu=new I,Ws=new ke,pi=new _e,Ua=new I,Hr=new I,X0=new I,j0=new ke,$u=new I(1,0,0),Ku=new I(0,1,0),Ju=new I(0,0,1),Qu={type:"added"},Y0={type:"removed"},Xs={type:"childadded",child:null},Ol={type:"childremoved",child:null};class Te extends Ls{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:W0++}),this.uuid=xa(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Te.DEFAULT_UP.clone();const t=new I,e=new Jn,n=new ke,s=new I(1,1,1);function r(){n.setFromEuler(e,!1)}function a(){e.setFromQuaternion(n,void 0,!1)}e._onChange(r),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new _e},normalMatrix:{value:new Gt}}),this.matrix=new _e,this.matrixWorld=new _e,this.matrixAutoUpdate=Te.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Te.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Qh,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Ws.setFromAxisAngle(t,e),this.quaternion.multiply(Ws),this}rotateOnWorldAxis(t,e){return Ws.setFromAxisAngle(t,e),this.quaternion.premultiply(Ws),this}rotateX(t){return this.rotateOnAxis($u,t)}rotateY(t){return this.rotateOnAxis(Ku,t)}rotateZ(t){return this.rotateOnAxis(Ju,t)}translateOnAxis(t,e){return Zu.copy(t).applyQuaternion(this.quaternion),this.position.add(Zu.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis($u,t)}translateY(t){return this.translateOnAxis(Ku,t)}translateZ(t){return this.translateOnAxis(Ju,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(pi.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?Ua.copy(t):Ua.set(t,e,n);const s=this.parent;this.updateWorldMatrix(!0,!1),Hr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?pi.lookAt(Hr,Ua,this.up):pi.lookAt(Ua,Hr,this.up),this.quaternion.setFromRotationMatrix(pi),s&&(pi.extractRotation(s.matrixWorld),Ws.setFromRotationMatrix(pi),this.quaternion.premultiply(Ws.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(Me("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(Qu),Xs.child=t,this.dispatchEvent(Xs),Xs.child=null):Me("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Y0),Ol.child=t,this.dispatchEvent(Ol),Ol.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),pi.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),pi.multiply(t.parent.matrixWorld)),t.applyMatrix4(pi),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Qu),Xs.child=t,this.dispatchEvent(Xs),Xs.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,s=this.children.length;n<s;n++){const a=this.children[n].getObjectByProperty(t,e);if(a!==void 0)return a}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Hr,t,X0),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Hr,j0,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e){const n=this.parent;if(t===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){const s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(t),s.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(t.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const u=l[c];r(t.shapes,u)}else r(t.shapes,l)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(t.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(r(t.materials,this.material[l]));s.material=o}else s.material=r(t.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];s.animations.push(r(t.animations,l))}}if(e){const o=a(t.geometries),l=a(t.materials),c=a(t.textures),h=a(t.images),u=a(t.shapes),d=a(t.skeletons),f=a(t.animations),m=a(t.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),m.length>0&&(n.nodes=m)}return n.object=s,n;function a(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){const s=t.children[n];this.add(s.clone())}return this}}Te.DEFAULT_UP=new I(0,1,0);Te.DEFAULT_MATRIX_AUTO_UPDATE=!0;Te.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const kn=new I,mi=new I,Ll=new I,_i=new I,js=new I,Ys=new I,td=new I,Nl=new I,Il=new I,Ul=new I,Fl=new Se,zl=new Se,Bl=new Se;class Rn{constructor(t=new I,e=new I,n=new I){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,s){s.subVectors(n,e),kn.subVectors(t,e),s.cross(kn);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(t,e,n,s,r){kn.subVectors(s,e),mi.subVectors(n,e),Ll.subVectors(t,e);const a=kn.dot(kn),o=kn.dot(mi),l=kn.dot(Ll),c=mi.dot(mi),h=mi.dot(Ll),u=a*c-o*o;if(u===0)return r.set(0,0,0),null;const d=1/u,f=(c*l-o*h)*d,m=(a*h-o*l)*d;return r.set(1-f-m,m,f)}static containsPoint(t,e,n,s){return this.getBarycoord(t,e,n,s,_i)===null?!1:_i.x>=0&&_i.y>=0&&_i.x+_i.y<=1}static getInterpolation(t,e,n,s,r,a,o,l){return this.getBarycoord(t,e,n,s,_i)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,_i.x),l.addScaledVector(a,_i.y),l.addScaledVector(o,_i.z),l)}static getInterpolatedAttribute(t,e,n,s,r,a){return Fl.setScalar(0),zl.setScalar(0),Bl.setScalar(0),Fl.fromBufferAttribute(t,e),zl.fromBufferAttribute(t,n),Bl.fromBufferAttribute(t,s),a.setScalar(0),a.addScaledVector(Fl,r.x),a.addScaledVector(zl,r.y),a.addScaledVector(Bl,r.z),a}static isFrontFacing(t,e,n,s){return kn.subVectors(n,e),mi.subVectors(t,e),kn.cross(mi).dot(s)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,s){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,e,n,s){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,s),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return kn.subVectors(this.c,this.b),mi.subVectors(this.a,this.b),kn.cross(mi).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Rn.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Rn.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,s,r){return Rn.getInterpolation(t,this.a,this.b,this.c,e,n,s,r)}containsPoint(t){return Rn.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Rn.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,s=this.b,r=this.c;let a,o;js.subVectors(s,n),Ys.subVectors(r,n),Nl.subVectors(t,n);const l=js.dot(Nl),c=Ys.dot(Nl);if(l<=0&&c<=0)return e.copy(n);Il.subVectors(t,s);const h=js.dot(Il),u=Ys.dot(Il);if(h>=0&&u<=h)return e.copy(s);const d=l*u-h*c;if(d<=0&&l>=0&&h<=0)return a=l/(l-h),e.copy(n).addScaledVector(js,a);Ul.subVectors(t,r);const f=js.dot(Ul),m=Ys.dot(Ul);if(m>=0&&f<=m)return e.copy(r);const x=f*c-l*m;if(x<=0&&c>=0&&m<=0)return o=c/(c-m),e.copy(n).addScaledVector(Ys,o);const _=h*m-f*u;if(_<=0&&u-h>=0&&f-m>=0)return td.subVectors(r,s),o=(u-h)/(u-h+(f-m)),e.copy(s).addScaledVector(td,o);const p=1/(_+x+d);return a=x*p,o=d*p,e.copy(n).addScaledVector(js,a).addScaledVector(Ys,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const mp={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},zi={h:0,s:0,l:0},Fa={h:0,s:0,l:0};function kl(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+(t-i)*6*e:e<1/2?t:e<2/3?i+(t-i)*6*(2/3-e):i}class Zt{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){const s=t;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=An){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,te.colorSpaceToWorking(this,e),this}setRGB(t,e,n,s=te.workingColorSpace){return this.r=t,this.g=e,this.b=n,te.colorSpaceToWorking(this,s),this}setHSL(t,e,n,s=te.workingColorSpace){if(t=L0(t,1),e=qt(e,0,1),n=qt(n,0,1),e===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+e):n+e-n*e,a=2*n-r;this.r=kl(a,r,t+1/3),this.g=kl(a,r,t),this.b=kl(a,r,t-1/3)}return te.colorSpaceToWorking(this,s),this}setStyle(t,e=An){function n(r){r!==void 0&&parseFloat(r)<1&&kt("Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:kt("Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){const r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(r,16),e);kt("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=An){const n=mp[t.toLowerCase()];return n!==void 0?this.setHex(n,e):kt("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=Ci(t.r),this.g=Ci(t.g),this.b=Ci(t.b),this}copyLinearToSRGB(t){return this.r=_r(t.r),this.g=_r(t.g),this.b=_r(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=An){return te.workingToColorSpace(je.copy(this),t),Math.round(qt(je.r*255,0,255))*65536+Math.round(qt(je.g*255,0,255))*256+Math.round(qt(je.b*255,0,255))}getHexString(t=An){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=te.workingColorSpace){te.workingToColorSpace(je.copy(this),e);const n=je.r,s=je.g,r=je.b,a=Math.max(n,s,r),o=Math.min(n,s,r);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const u=a-o;switch(c=h<=.5?u/(a+o):u/(2-a-o),a){case n:l=(s-r)/u+(s<r?6:0);break;case s:l=(r-n)/u+2;break;case r:l=(n-s)/u+4;break}l/=6}return t.h=l,t.s=c,t.l=h,t}getRGB(t,e=te.workingColorSpace){return te.workingToColorSpace(je.copy(this),e),t.r=je.r,t.g=je.g,t.b=je.b,t}getStyle(t=An){te.workingToColorSpace(je.copy(this),t);const e=je.r,n=je.g,s=je.b;return t!==An?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(t,e,n){return this.getHSL(zi),this.setHSL(zi.h+t,zi.s+e,zi.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(zi),t.getHSL(Fa);const n=Ml(zi.h,Fa.h,e),s=Ml(zi.s,Fa.s,e),r=Ml(zi.l,Fa.l,e);return this.setHSL(n,s,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,s=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*s,this.g=r[1]*e+r[4]*n+r[7]*s,this.b=r[2]*e+r[5]*n+r[8]*s,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const je=new Zt;Zt.NAMES=mp;let q0=0;class Pr extends Ls{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:q0++}),this.uuid=xa(),this.name="",this.type="Material",this.blending=mr,this.side=Ji,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=wc,this.blendDst=Tc,this.blendEquation=xs,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Zt(0,0,0),this.blendAlpha=0,this.depthFunc=Mr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Bu,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=zs,this.stencilZFail=zs,this.stencilZPass=zs,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const n=t[e];if(n===void 0){kt(`Material: parameter '${e}' has value of undefined.`);continue}const s=this[e];if(s===void 0){kt(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==mr&&(n.blending=this.blending),this.side!==Ji&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==wc&&(n.blendSrc=this.blendSrc),this.blendDst!==Tc&&(n.blendDst=this.blendDst),this.blendEquation!==xs&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Mr&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Bu&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==zs&&(n.stencilFail=this.stencilFail),this.stencilZFail!==zs&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==zs&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(e){const r=s(t.textures),a=s(t.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(e!==null){const s=e.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}}class nl extends Pr{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Zt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Jn,this.combine=np,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 Ce=new I,za=new Nt;let Z0=0;class Yn{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Z0++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=ku,this.updateRanges=[],this.gpuType=Ti,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let s=0,r=this.itemSize;s<r;s++)this.array[t+s]=e.array[n+s];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)za.fromBufferAttribute(this,e),za.applyMatrix3(t),this.setXY(e,za.x,za.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)Ce.fromBufferAttribute(this,e),Ce.applyMatrix3(t),this.setXYZ(e,Ce.x,Ce.y,Ce.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)Ce.fromBufferAttribute(this,e),Ce.applyMatrix4(t),this.setXYZ(e,Ce.x,Ce.y,Ce.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Ce.fromBufferAttribute(this,e),Ce.applyNormalMatrix(t),this.setXYZ(e,Ce.x,Ce.y,Ce.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Ce.fromBufferAttribute(this,e),Ce.transformDirection(t),this.setXYZ(e,Ce.x,Ce.y,Ce.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=Br(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=en(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Br(e,this.array)),e}setX(t,e){return this.normalized&&(e=en(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Br(e,this.array)),e}setY(t,e){return this.normalized&&(e=en(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=Br(e,this.array)),e}setZ(t,e){return this.normalized&&(e=en(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=Br(e,this.array)),e}setW(t,e){return this.normalized&&(e=en(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=en(e,this.array),n=en(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,s){return t*=this.itemSize,this.normalized&&(e=en(e,this.array),n=en(n,this.array),s=en(s,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=s,this}setXYZW(t,e,n,s,r){return t*=this.itemSize,this.normalized&&(e=en(e,this.array),n=en(n,this.array),s=en(s,this.array),r=en(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=s,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==ku&&(t.usage=this.usage),t}}class _p extends Yn{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class xp extends Yn{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class Jt extends Yn{constructor(t,e,n){super(new Float32Array(t),e,n)}}let $0=0;const En=new _e,Vl=new Te,qs=new I,dn=new ga,Gr=new ga,Fe=new I;class De extends Ls{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:$0++}),this.uuid=xa(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(fp(t)?xp:_p)(t,1):this.index=t,this}setIndirect(t){return this.indirect=t,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new Gt().getNormalMatrix(t);n.applyNormalMatrix(r),n.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(t),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return En.makeRotationFromQuaternion(t),this.applyMatrix4(En),this}rotateX(t){return En.makeRotationX(t),this.applyMatrix4(En),this}rotateY(t){return En.makeRotationY(t),this.applyMatrix4(En),this}rotateZ(t){return En.makeRotationZ(t),this.applyMatrix4(En),this}translate(t,e,n){return En.makeTranslation(t,e,n),this.applyMatrix4(En),this}scale(t,e,n){return En.makeScale(t,e,n),this.applyMatrix4(En),this}lookAt(t){return Vl.lookAt(t),Vl.updateMatrix(),this.applyMatrix4(Vl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(qs).negate(),this.translate(qs.x,qs.y,qs.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const n=[];for(let s=0,r=t.length;s<r;s++){const a=t[s];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Jt(n,3))}else{const n=Math.min(t.length,e.count);for(let s=0;s<n;s++){const r=t[s];e.setXYZ(s,r.x,r.y,r.z||0)}t.length>e.count&&kt("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ga);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Me("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new I(-1/0,-1/0,-1/0),new I(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,s=e.length;n<s;n++){const r=e[n];dn.setFromBufferAttribute(r),this.morphTargetsRelative?(Fe.addVectors(this.boundingBox.min,dn.min),this.boundingBox.expandByPoint(Fe),Fe.addVectors(this.boundingBox.max,dn.max),this.boundingBox.expandByPoint(Fe)):(this.boundingBox.expandByPoint(dn.min),this.boundingBox.expandByPoint(dn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Me('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new tl);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Me("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new I,1/0);return}if(t){const n=this.boundingSphere.center;if(dn.setFromBufferAttribute(t),e)for(let r=0,a=e.length;r<a;r++){const o=e[r];Gr.setFromBufferAttribute(o),this.morphTargetsRelative?(Fe.addVectors(dn.min,Gr.min),dn.expandByPoint(Fe),Fe.addVectors(dn.max,Gr.max),dn.expandByPoint(Fe)):(dn.expandByPoint(Gr.min),dn.expandByPoint(Gr.max))}dn.getCenter(n);let s=0;for(let r=0,a=t.count;r<a;r++)Fe.fromBufferAttribute(t,r),s=Math.max(s,n.distanceToSquared(Fe));if(e)for(let r=0,a=e.length;r<a;r++){const o=e[r],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)Fe.fromBufferAttribute(o,c),l&&(qs.fromBufferAttribute(t,c),Fe.add(qs)),s=Math.max(s,n.distanceToSquared(Fe))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&Me('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){Me("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.position,s=e.normal,r=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Yn(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let R=0;R<n.count;R++)o[R]=new I,l[R]=new I;const c=new I,h=new I,u=new I,d=new Nt,f=new Nt,m=new Nt,x=new I,_=new I;function p(R,M,g){c.fromBufferAttribute(n,R),h.fromBufferAttribute(n,M),u.fromBufferAttribute(n,g),d.fromBufferAttribute(r,R),f.fromBufferAttribute(r,M),m.fromBufferAttribute(r,g),h.sub(c),u.sub(c),f.sub(d),m.sub(d);const O=1/(f.x*m.y-m.x*f.y);isFinite(O)&&(x.copy(h).multiplyScalar(m.y).addScaledVector(u,-f.y).multiplyScalar(O),_.copy(u).multiplyScalar(f.x).addScaledVector(h,-m.x).multiplyScalar(O),o[R].add(x),o[M].add(x),o[g].add(x),l[R].add(_),l[M].add(_),l[g].add(_))}let w=this.groups;w.length===0&&(w=[{start:0,count:t.count}]);for(let R=0,M=w.length;R<M;++R){const g=w[R],O=g.start,F=g.count;for(let k=O,G=O+F;k<G;k+=3)p(t.getX(k+0),t.getX(k+1),t.getX(k+2))}const S=new I,y=new I,E=new I,v=new I;function A(R){E.fromBufferAttribute(s,R),v.copy(E);const M=o[R];S.copy(M),S.sub(E.multiplyScalar(E.dot(M))).normalize(),y.crossVectors(v,M);const O=y.dot(l[R])<0?-1:1;a.setXYZW(R,S.x,S.y,S.z,O)}for(let R=0,M=w.length;R<M;++R){const g=w[R],O=g.start,F=g.count;for(let k=O,G=O+F;k<G;k+=3)A(t.getX(k+0)),A(t.getX(k+1)),A(t.getX(k+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new Yn(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);const s=new I,r=new I,a=new I,o=new I,l=new I,c=new I,h=new I,u=new I;if(t)for(let d=0,f=t.count;d<f;d+=3){const m=t.getX(d+0),x=t.getX(d+1),_=t.getX(d+2);s.fromBufferAttribute(e,m),r.fromBufferAttribute(e,x),a.fromBufferAttribute(e,_),h.subVectors(a,r),u.subVectors(s,r),h.cross(u),o.fromBufferAttribute(n,m),l.fromBufferAttribute(n,x),c.fromBufferAttribute(n,_),o.add(h),l.add(h),c.add(h),n.setXYZ(m,o.x,o.y,o.z),n.setXYZ(x,l.x,l.y,l.z),n.setXYZ(_,c.x,c.y,c.z)}else for(let d=0,f=e.count;d<f;d+=3)s.fromBufferAttribute(e,d+0),r.fromBufferAttribute(e,d+1),a.fromBufferAttribute(e,d+2),h.subVectors(a,r),u.subVectors(s,r),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)Fe.fromBufferAttribute(t,e),Fe.normalize(),t.setXYZ(e,Fe.x,Fe.y,Fe.z)}toNonIndexed(){function t(o,l){const c=o.array,h=o.itemSize,u=o.normalized,d=new c.constructor(l.length*h);let f=0,m=0;for(let x=0,_=l.length;x<_;x++){o.isInterleavedBufferAttribute?f=l[x]*o.data.stride+o.offset:f=l[x]*h;for(let p=0;p<h;p++)d[m++]=c[f++]}return new Yn(d,h,u)}if(this.index===null)return kt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new De,n=this.index.array,s=this.attributes;for(const o in s){const l=s[o],c=t(l,n);e.setAttribute(o,c)}const r=this.morphAttributes;for(const o in r){const l=[],c=r[o];for(let h=0,u=c.length;h<u;h++){const d=c[h],f=t(d,n);l.push(f)}e.morphAttributes[o]=l}e.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];e.addGroup(c.start,c.count,c.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(t[c]=l[c]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const l in n){const c=n[l];t.data.attributes[l]=c.toJSON(t.data)}const s={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let u=0,d=c.length;u<d;u++){const f=c[u];h.push(f.toJSON(t.data))}h.length>0&&(s[l]=h,r=!0)}r&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(t.data.boundingSphere=o.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;n!==null&&this.setIndex(n.clone());const s=t.attributes;for(const c in s){const h=s[c];this.setAttribute(c,h.clone(e))}const r=t.morphAttributes;for(const c in r){const h=[],u=r[c];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(e));this.morphAttributes[c]=h}this.morphTargetsRelative=t.morphTargetsRelative;const a=t.groups;for(let c=0,h=a.length;c<h;c++){const u=a[c];this.addGroup(u.start,u.count,u.materialIndex)}const o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=t.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const ed=new _e,ls=new el,Ba=new tl,nd=new I,ka=new I,Va=new I,Ha=new I,Hl=new I,Ga=new I,id=new I,Wa=new I;class gt extends Te{constructor(t=new De,e=new nl){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){const o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(t,e){const n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;e.fromBufferAttribute(s,t);const o=this.morphTargetInfluences;if(r&&o){Ga.set(0,0,0);for(let l=0,c=r.length;l<c;l++){const h=o[l],u=r[l];h!==0&&(Hl.fromBufferAttribute(u,t),a?Ga.addScaledVector(Hl,h):Ga.addScaledVector(Hl.sub(e),h))}e.add(Ga)}return e}raycast(t,e){const n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Ba.copy(n.boundingSphere),Ba.applyMatrix4(r),ls.copy(t.ray).recast(t.near),!(Ba.containsPoint(ls.origin)===!1&&(ls.intersectSphere(Ba,nd)===null||ls.origin.distanceToSquared(nd)>(t.far-t.near)**2))&&(ed.copy(r).invert(),ls.copy(t.ray).applyMatrix4(ed),!(n.boundingBox!==null&&ls.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,ls)))}_computeIntersections(t,e,n){let s;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,u=r.attributes.normal,d=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let m=0,x=d.length;m<x;m++){const _=d[m],p=a[_.materialIndex],w=Math.max(_.start,f.start),S=Math.min(o.count,Math.min(_.start+_.count,f.start+f.count));for(let y=w,E=S;y<E;y+=3){const v=o.getX(y),A=o.getX(y+1),R=o.getX(y+2);s=Xa(this,p,t,n,c,h,u,v,A,R),s&&(s.faceIndex=Math.floor(y/3),s.face.materialIndex=_.materialIndex,e.push(s))}}else{const m=Math.max(0,f.start),x=Math.min(o.count,f.start+f.count);for(let _=m,p=x;_<p;_+=3){const w=o.getX(_),S=o.getX(_+1),y=o.getX(_+2);s=Xa(this,a,t,n,c,h,u,w,S,y),s&&(s.faceIndex=Math.floor(_/3),e.push(s))}}else if(l!==void 0)if(Array.isArray(a))for(let m=0,x=d.length;m<x;m++){const _=d[m],p=a[_.materialIndex],w=Math.max(_.start,f.start),S=Math.min(l.count,Math.min(_.start+_.count,f.start+f.count));for(let y=w,E=S;y<E;y+=3){const v=y,A=y+1,R=y+2;s=Xa(this,p,t,n,c,h,u,v,A,R),s&&(s.faceIndex=Math.floor(y/3),s.face.materialIndex=_.materialIndex,e.push(s))}}else{const m=Math.max(0,f.start),x=Math.min(l.count,f.start+f.count);for(let _=m,p=x;_<p;_+=3){const w=_,S=_+1,y=_+2;s=Xa(this,a,t,n,c,h,u,w,S,y),s&&(s.faceIndex=Math.floor(_/3),e.push(s))}}}}function K0(i,t,e,n,s,r,a,o){let l;if(t.side===on?l=n.intersectTriangle(a,r,s,!0,o):l=n.intersectTriangle(s,r,a,t.side===Ji,o),l===null)return null;Wa.copy(o),Wa.applyMatrix4(i.matrixWorld);const c=e.ray.origin.distanceTo(Wa);return c<e.near||c>e.far?null:{distance:c,point:Wa.clone(),object:i}}function Xa(i,t,e,n,s,r,a,o,l,c){i.getVertexPosition(o,ka),i.getVertexPosition(l,Va),i.getVertexPosition(c,Ha);const h=K0(i,t,e,n,ka,Va,Ha,id);if(h){const u=new I;Rn.getBarycoord(id,ka,Va,Ha,u),s&&(h.uv=Rn.getInterpolatedAttribute(s,o,l,c,u,new Nt)),r&&(h.uv1=Rn.getInterpolatedAttribute(r,o,l,c,u,new Nt)),a&&(h.normal=Rn.getInterpolatedAttribute(a,o,l,c,u,new I),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:l,c,normal:new I,materialIndex:0};Rn.getNormal(ka,Va,Ha,d.normal),h.face=d,h.barycoord=u}return h}class we extends De{constructor(t=1,e=1,n=1,s=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:s,heightSegments:r,depthSegments:a};const o=this;s=Math.floor(s),r=Math.floor(r),a=Math.floor(a);const l=[],c=[],h=[],u=[];let d=0,f=0;m("z","y","x",-1,-1,n,e,t,a,r,0),m("z","y","x",1,-1,n,e,-t,a,r,1),m("x","z","y",1,1,t,n,e,s,a,2),m("x","z","y",1,-1,t,n,-e,s,a,3),m("x","y","z",1,-1,t,e,n,s,r,4),m("x","y","z",-1,-1,t,e,-n,s,r,5),this.setIndex(l),this.setAttribute("position",new Jt(c,3)),this.setAttribute("normal",new Jt(h,3)),this.setAttribute("uv",new Jt(u,2));function m(x,_,p,w,S,y,E,v,A,R,M){const g=y/A,O=E/R,F=y/2,k=E/2,G=v/2,K=A+1,tt=R+1;let lt=0,$=0;const st=new I;for(let ct=0;ct<tt;ct++){const Et=ct*O-k;for(let Vt=0;Vt<K;Vt++){const pt=Vt*g-F;st[x]=pt*w,st[_]=Et*S,st[p]=G,c.push(st.x,st.y,st.z),st[x]=0,st[_]=0,st[p]=v>0?1:-1,h.push(st.x,st.y,st.z),u.push(Vt/A),u.push(1-ct/R),lt+=1}}for(let ct=0;ct<R;ct++)for(let Et=0;Et<A;Et++){const Vt=d+Et+K*ct,pt=d+Et+K*(ct+1),$t=d+(Et+1)+K*(ct+1),se=d+(Et+1)+K*ct;l.push(Vt,pt,se),l.push(pt,$t,se),$+=6}o.addGroup(f,$,M),f+=$,d+=lt}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new we(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function Tr(i){const t={};for(const e in i){t[e]={};for(const n in i[e]){const s=i[e][n];s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)?s.isRenderTargetTexture?(kt("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=s.clone():Array.isArray(s)?t[e][n]=s.slice():t[e][n]=s}}return t}function Ke(i){const t={};for(let e=0;e<i.length;e++){const n=Tr(i[e]);for(const s in n)t[s]=n[s]}return t}function J0(i){const t=[];for(let e=0;e<i.length;e++)t.push(i[e].clone());return t}function gp(i){const t=i.getRenderTarget();return t===null?i.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:te.workingColorSpace}const Q0={clone:Tr,merge:Ke};var t_=`void main() {
19
19
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
20
- }`,Ap=`void main() {
20
+ }`,e_=`void main() {
21
21
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
22
- }`;class _i extends Or{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=wp,this.fragmentShader=Ap,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,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Pr(e.uniforms),this.uniformsGroups=Sp(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const r in this.uniforms){const o=this.uniforms[r].value;o&&o.isTexture?t.uniforms[r]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[r]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[r]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[r]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[r]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[r]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[r]={type:"m4",value:o.toArray()}:t.uniforms[r]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class Jh extends Mt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ft,this.projectionMatrix=new ft,this.projectionMatrixInverse=new ft,this.coordinateSystem=Bn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const ai=new O,du=new Ne,pu=new Ne;class cn extends Jh{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Sl*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(ts*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Sl*2*Math.atan(Math.tan(ts*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){ai.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(ai.x,ai.y).multiplyScalar(-e/ai.z),ai.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(ai.x,ai.y).multiplyScalar(-e/ai.z)}getViewSize(e,t){return this.getViewBounds(e,du,pu),t.subVectors(pu,du)}setViewOffset(e,t,i,r,s,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(ts*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,s=-.5*r;const o=this.view;if(this.view!==null&&this.view.enabled){const l=o.fullWidth,c=o.fullHeight;s+=o.offsetX*r/l,t-=o.offsetY*i/c,r*=o.width/l,i*=o.height/c}const a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const hr=-90,fr=1;class Rp extends Mt{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new cn(hr,fr,e,t);r.layers=this.layers,this.add(r);const s=new cn(hr,fr,e,t);s.layers=this.layers,this.add(s);const o=new cn(hr,fr,e,t);o.layers=this.layers,this.add(o);const a=new cn(hr,fr,e,t);a.layers=this.layers,this.add(a);const l=new cn(hr,fr,e,t);l.layers=this.layers,this.add(l);const c=new cn(hr,fr,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,r,s,o,a,l]=t;for(const c of t)this.remove(c);if(e===Bn)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===_o)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,o,a,l,c,u]=this.children,h=e.getRenderTarget(),d=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const y=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,r),e.render(t,s),e.setRenderTarget(i,1,r),e.render(t,o),e.setRenderTarget(i,2,r),e.render(t,a),e.setRenderTarget(i,3,r),e.render(t,l),e.setRenderTarget(i,4,r),e.render(t,c),i.texture.generateMipmaps=y,e.setRenderTarget(i,5,r),e.render(t,u),e.setRenderTarget(h,d,p),e.xr.enabled=g,i.texture.needsPMREMUpdate=!0}}class Qh extends Xt{constructor(e=[],t=Ar,i,r,s,o,a,l,c,u){super(e,t,i,r,s,o,a,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Cp extends ki{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];this.texture=new Qh(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:`
22
+ }`;class Di extends Pr{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=t_,this.fragmentShader=e_,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Tr(t.uniforms),this.uniformsGroups=J0(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const s in this.uniforms){const a=this.uniforms[s].value;a&&a.isTexture?e.uniforms[s]={type:"t",value:a.toJSON(t).uuid}:a&&a.isColor?e.uniforms[s]={type:"c",value:a.getHex()}:a&&a.isVector2?e.uniforms[s]={type:"v2",value:a.toArray()}:a&&a.isVector3?e.uniforms[s]={type:"v3",value:a.toArray()}:a&&a.isVector4?e.uniforms[s]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?e.uniforms[s]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?e.uniforms[s]={type:"m4",value:a.toArray()}:e.uniforms[s]={value:a}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}class vp extends Te{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new _e,this.projectionMatrix=new _e,this.projectionMatrixInverse=new _e,this.coordinateSystem=ai,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.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const Bi=new I,sd=new Nt,rd=new Nt;class Cn extends vp{constructor(t=50,e=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=dh*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(ra*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return dh*2*Math.atan(Math.tan(ra*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){Bi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(Bi.x,Bi.y).multiplyScalar(-t/Bi.z),Bi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Bi.x,Bi.y).multiplyScalar(-t/Bi.z)}getViewSize(t,e){return this.getViewBounds(t,sd,rd),e.subVectors(rd,sd)}setViewOffset(t,e,n,s,r,a){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(ra*.5*this.fov)/this.zoom,n=2*e,s=this.aspect*n,r=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*s/l,e-=a.offsetY*n/c,s*=a.width/l,n*=a.height/c}const o=this.filmOffset;o!==0&&(r+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,e,e-n,t,this.far,this.coordinateSystem,this.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,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const Zs=-90,$s=1;class n_ extends Te{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new Cn(Zs,$s,t,e);s.layers=this.layers,this.add(s);const r=new Cn(Zs,$s,t,e);r.layers=this.layers,this.add(r);const a=new Cn(Zs,$s,t,e);a.layers=this.layers,this.add(a);const o=new Cn(Zs,$s,t,e);o.layers=this.layers,this.add(o);const l=new Cn(Zs,$s,t,e);l.layers=this.layers,this.add(l);const c=new Cn(Zs,$s,t,e);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,s,r,a,o,l]=e;for(const c of e)this.remove(c);if(t===ai)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(t===Uo)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(const c of e)this.add(c),c.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,l,c,h]=this.children,u=t.getRenderTarget(),d=t.getActiveCubeFace(),f=t.getActiveMipmapLevel(),m=t.xr.enabled;t.xr.enabled=!1;const x=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0,s),t.render(e,r),t.setRenderTarget(n,1,s),t.render(e,a),t.setRenderTarget(n,2,s),t.render(e,o),t.setRenderTarget(n,3,s),t.render(e,l),t.setRenderTarget(n,4,s),t.render(e,c),n.texture.generateMipmaps=x,t.setRenderTarget(n,5,s),t.render(e,h),t.setRenderTarget(u,d,f),t.xr.enabled=m,n.texture.needsPMREMUpdate=!0}}class yp extends Je{constructor(t=[],e=Sr,n,s,r,a,o,l,c,h){super(t,e,n,s,r,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class i_ extends Ts{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},s=[n,n,n,n,n,n];this.texture=new yp(s),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:`
23
23
 
24
24
  varying vec3 vWorldDirection;
25
25
 
@@ -54,13 +54,13 @@ and limitations under the License.
54
54
  gl_FragColor = texture2D( tEquirect, sampleUV );
55
55
 
56
56
  }
57
- `},r=new yt(5,5,5),s=new _i({name:"CubemapFromEquirect",uniforms:Pr(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:Wt,blending:di});s.uniforms.tEquirect.value=t;const o=new ge(r,s),a=t.minFilter;return t.minFilter===Bi&&(t.minFilter=Fn),new Rp(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t=!0,i=!0,r=!0){const s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,i,r);e.setRenderTarget(s)}}class Kr extends Mt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Pp={type:"move"};class ga{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Kr,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Kr,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new O,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new O),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Kr,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new O,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new O),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,o=null;const a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(const y of e.hand.values()){const m=t.getJointPose(y,i),f=this._getHandJoint(c,y);m!==null&&(f.matrix.fromArray(m.transform.matrix),f.matrix.decompose(f.position,f.rotation,f.scale),f.matrixWorldNeedsUpdate=!0,f.jointRadius=m.radius),f.visible=m!==null}const u=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],d=u.position.distanceTo(h.position),p=.02,g=.005;c.inputState.pinching&&d>p+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=p-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Pp)))}return a!==null&&(a.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new Kr;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}class Dp extends Mt{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 Pn,this.environmentIntensity=1,this.environmentRotation=new Pn,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const va=new O,Lp=new O,Op=new ke;class ci{constructor(e=new O(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const r=va.subVectors(i,t).cross(Lp.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const i=e.delta(va),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||Op.getNormalMatrix(e),r=this.coplanarPoint(va).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Ai=new Lo,Ip=new Ne(.5,.5),Vs=new O;class hc{constructor(e=new ci,t=new ci,i=new ci,r=new ci,s=new ci,o=new ci){this.planes=[e,t,i,r,s,o]}set(e,t,i,r,s,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(i),a[3].copy(r),a[4].copy(s),a[5].copy(o),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Bn,i=!1){const r=this.planes,s=e.elements,o=s[0],a=s[1],l=s[2],c=s[3],u=s[4],h=s[5],d=s[6],p=s[7],g=s[8],y=s[9],m=s[10],f=s[11],w=s[12],T=s[13],_=s[14],S=s[15];if(r[0].setComponents(c-o,p-u,f-g,S-w).normalize(),r[1].setComponents(c+o,p+u,f+g,S+w).normalize(),r[2].setComponents(c+a,p+h,f+y,S+T).normalize(),r[3].setComponents(c-a,p-h,f-y,S-T).normalize(),i)r[4].setComponents(l,d,m,_).normalize(),r[5].setComponents(c-l,p-d,f-m,S-_).normalize();else if(r[4].setComponents(c-l,p-d,f-m,S-_).normalize(),t===Bn)r[5].setComponents(c+l,p+d,f+m,S+_).normalize();else if(t===_o)r[5].setComponents(l,d,m,_).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Ai.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ai.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ai)}intersectsSprite(e){Ai.center.set(0,0,0);const t=Ip.distanceTo(e.center);return Ai.radius=.7071067811865476+t,Ai.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ai)}intersectsSphere(e){const t=this.planes,i=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const r=t[i];if(Vs.x=r.normal.x>0?e.max.x:e.min.x,Vs.y=r.normal.y>0?e.max.y:e.min.y,Vs.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Vs)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class $i extends Or{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new je(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const vo=new O,xo=new O,mu=new ft,jr=new Oo,Hs=new Lo,xa=new O,_u=new O;class En extends Mt{constructor(e=new bt,t=new $i){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let r=1,s=t.count;r<s;r++)vo.fromBufferAttribute(t,r-1),xo.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=vo.distanceTo(xo);e.setAttribute("lineDistance",new Ze(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Hs.copy(i.boundingSphere),Hs.applyMatrix4(r),Hs.radius+=s,e.ray.intersectsSphere(Hs)===!1)return;mu.copy(r).invert(),jr.copy(e.ray).applyMatrix4(mu);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=this.isLineSegments?2:1,u=i.index,d=i.attributes.position;if(u!==null){const p=Math.max(0,o.start),g=Math.min(u.count,o.start+o.count);for(let y=p,m=g-1;y<m;y+=c){const f=u.getX(y),w=u.getX(y+1),T=ks(this,e,jr,l,f,w,y);T&&t.push(T)}if(this.isLineLoop){const y=u.getX(g-1),m=u.getX(p),f=ks(this,e,jr,l,y,m,g-1);f&&t.push(f)}}else{const p=Math.max(0,o.start),g=Math.min(d.count,o.start+o.count);for(let y=p,m=g-1;y<m;y+=c){const f=ks(this,e,jr,l,y,y+1,y);f&&t.push(f)}if(this.isLineLoop){const y=ks(this,e,jr,l,g-1,p,g-1);y&&t.push(y)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){const a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}}function ks(n,e,t,i,r,s,o){const a=n.geometry.attributes.position;if(vo.fromBufferAttribute(a,r),xo.fromBufferAttribute(a,s),t.distanceSqToSegment(vo,xo,xa,_u)>i)return;xa.applyMatrix4(n.matrixWorld);const c=e.ray.origin.distanceTo(xa);if(!(c<e.near||c>e.far))return{distance:c,point:_u.clone().applyMatrix4(n.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:n}}const gu=new O,vu=new O;class fc extends En{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let r=0,s=t.count;r<s;r+=2)gu.fromBufferAttribute(t,r),vu.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+gu.distanceTo(vu);e.setAttribute("lineDistance",new Ze(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class ef extends Xt{constructor(e,t,i=Hi,r,s,o,a=Tn,l=Tn,c,u=ss,h=1){if(u!==ss&&u!==os)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:e,height:t,depth:h};super(d,r,s,o,a,l,u,i,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new cc(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class tf extends Xt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class dc extends bt{constructor(e=1,t=32,i=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},t=Math.max(3,t);const s=[],o=[],a=[],l=[],c=new O,u=new Ne;o.push(0,0,0),a.push(0,0,1),l.push(.5,.5);for(let h=0,d=3;h<=t;h++,d+=3){const p=i+h/t*r;c.x=e*Math.cos(p),c.y=e*Math.sin(p),o.push(c.x,c.y,c.z),a.push(0,0,1),u.x=(o[d]/e+1)/2,u.y=(o[d+1]/e+1)/2,l.push(u.x,u.y)}for(let h=1;h<=t;h++)s.push(h,h+1,0);this.setIndex(s),this.setAttribute("position",new Ze(o,3)),this.setAttribute("normal",new Ze(a,3)),this.setAttribute("uv",new Ze(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new dc(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Pt extends bt{constructor(e=1,t=1,i=1,r=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};const c=this;r=Math.floor(r),s=Math.floor(s);const u=[],h=[],d=[],p=[];let g=0;const y=[],m=i/2;let f=0;w(),o===!1&&(e>0&&T(!0),t>0&&T(!1)),this.setIndex(u),this.setAttribute("position",new Ze(h,3)),this.setAttribute("normal",new Ze(d,3)),this.setAttribute("uv",new Ze(p,2));function w(){const _=new O,S=new O;let b=0;const A=(t-e)/i;for(let C=0;C<=s;C++){const M=[],x=C/s,N=x*(t-e)+e;for(let z=0;z<=r;z++){const Y=z/r,q=Y*l+a,J=Math.sin(q),K=Math.cos(q);S.x=N*J,S.y=-x*i+m,S.z=N*K,h.push(S.x,S.y,S.z),_.set(J,A,K).normalize(),d.push(_.x,_.y,_.z),p.push(Y,1-x),M.push(g++)}y.push(M)}for(let C=0;C<r;C++)for(let M=0;M<s;M++){const x=y[M][C],N=y[M+1][C],z=y[M+1][C+1],Y=y[M][C+1];(e>0||M!==0)&&(u.push(x,N,Y),b+=3),(t>0||M!==s-1)&&(u.push(N,z,Y),b+=3)}c.addGroup(f,b,0),f+=b}function T(_){const S=g,b=new Ne,A=new O;let C=0;const M=_===!0?e:t,x=_===!0?1:-1;for(let z=1;z<=r;z++)h.push(0,m*x,0),d.push(0,x,0),p.push(.5,.5),g++;const N=g;for(let z=0;z<=r;z++){const q=z/r*l+a,J=Math.cos(q),K=Math.sin(q);A.x=M*K,A.y=m*x,A.z=M*J,h.push(A.x,A.y,A.z),d.push(0,x,0),b.x=J*.5+.5,b.y=K*.5*x+.5,p.push(b.x,b.y),g++}for(let z=0;z<r;z++){const Y=S+z,q=N+z;_===!0?u.push(q,q+1,Y):u.push(q+1,q,Y),C+=3}c.addGroup(f,C,_===!0?1:2),f+=C}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Pt(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class pc extends Pt{constructor(e=1,t=1,i=32,r=1,s=!1,o=0,a=Math.PI*2){super(0,e,t,i,r,s,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(e){return new pc(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class No extends bt{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};const s=[],o=[];a(r),c(i),u(),this.setAttribute("position",new Ze(s,3)),this.setAttribute("normal",new Ze(s.slice(),3)),this.setAttribute("uv",new Ze(o,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(w){const T=new O,_=new O,S=new O;for(let b=0;b<t.length;b+=3)p(t[b+0],T),p(t[b+1],_),p(t[b+2],S),l(T,_,S,w)}function l(w,T,_,S){const b=S+1,A=[];for(let C=0;C<=b;C++){A[C]=[];const M=w.clone().lerp(_,C/b),x=T.clone().lerp(_,C/b),N=b-C;for(let z=0;z<=N;z++)z===0&&C===b?A[C][z]=M:A[C][z]=M.clone().lerp(x,z/N)}for(let C=0;C<b;C++)for(let M=0;M<2*(b-C)-1;M++){const x=Math.floor(M/2);M%2===0?(d(A[C][x+1]),d(A[C+1][x]),d(A[C][x])):(d(A[C][x+1]),d(A[C+1][x+1]),d(A[C+1][x]))}}function c(w){const T=new O;for(let _=0;_<s.length;_+=3)T.x=s[_+0],T.y=s[_+1],T.z=s[_+2],T.normalize().multiplyScalar(w),s[_+0]=T.x,s[_+1]=T.y,s[_+2]=T.z}function u(){const w=new O;for(let T=0;T<s.length;T+=3){w.x=s[T+0],w.y=s[T+1],w.z=s[T+2];const _=m(w)/2/Math.PI+.5,S=f(w)/Math.PI+.5;o.push(_,1-S)}g(),h()}function h(){for(let w=0;w<o.length;w+=6){const T=o[w+0],_=o[w+2],S=o[w+4],b=Math.max(T,_,S),A=Math.min(T,_,S);b>.9&&A<.1&&(T<.2&&(o[w+0]+=1),_<.2&&(o[w+2]+=1),S<.2&&(o[w+4]+=1))}}function d(w){s.push(w.x,w.y,w.z)}function p(w,T){const _=w*3;T.x=e[_+0],T.y=e[_+1],T.z=e[_+2]}function g(){const w=new O,T=new O,_=new O,S=new O,b=new Ne,A=new Ne,C=new Ne;for(let M=0,x=0;M<s.length;M+=9,x+=6){w.set(s[M+0],s[M+1],s[M+2]),T.set(s[M+3],s[M+4],s[M+5]),_.set(s[M+6],s[M+7],s[M+8]),b.set(o[x+0],o[x+1]),A.set(o[x+2],o[x+3]),C.set(o[x+4],o[x+5]),S.copy(w).add(T).add(_).divideScalar(3);const N=m(S);y(b,x+0,w,N),y(A,x+2,T,N),y(C,x+4,_,N)}}function y(w,T,_,S){S<0&&w.x===1&&(o[T]=w.x-1),_.x===0&&_.z===0&&(o[T]=S/2/Math.PI+.5)}function m(w){return Math.atan2(w.z,-w.x)}function f(w){return Math.atan2(-w.y,Math.sqrt(w.x*w.x+w.z*w.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new No(e.vertices,e.indices,e.radius,e.details)}}const Gs=new O,Ws=new O,ya=new O,Xs=new un;class nf extends bt{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const r=Math.pow(10,4),s=Math.cos(ts*t),o=e.getIndex(),a=e.getAttribute("position"),l=o?o.count:a.count,c=[0,0,0],u=["a","b","c"],h=new Array(3),d={},p=[];for(let g=0;g<l;g+=3){o?(c[0]=o.getX(g),c[1]=o.getX(g+1),c[2]=o.getX(g+2)):(c[0]=g,c[1]=g+1,c[2]=g+2);const{a:y,b:m,c:f}=Xs;if(y.fromBufferAttribute(a,c[0]),m.fromBufferAttribute(a,c[1]),f.fromBufferAttribute(a,c[2]),Xs.getNormal(ya),h[0]=`${Math.round(y.x*r)},${Math.round(y.y*r)},${Math.round(y.z*r)}`,h[1]=`${Math.round(m.x*r)},${Math.round(m.y*r)},${Math.round(m.z*r)}`,h[2]=`${Math.round(f.x*r)},${Math.round(f.y*r)},${Math.round(f.z*r)}`,!(h[0]===h[1]||h[1]===h[2]||h[2]===h[0]))for(let w=0;w<3;w++){const T=(w+1)%3,_=h[w],S=h[T],b=Xs[u[w]],A=Xs[u[T]],C=`${_}_${S}`,M=`${S}_${_}`;M in d&&d[M]?(ya.dot(d[M].normal)<=s&&(p.push(b.x,b.y,b.z),p.push(A.x,A.y,A.z)),d[M]=null):C in d||(d[C]={index0:c[w],index1:c[T],normal:ya.clone()})}}for(const g in d)if(d[g]){const{index0:y,index1:m}=d[g];Gs.fromBufferAttribute(a,y),Ws.fromBufferAttribute(a,m),p.push(Gs.x,Gs.y,Gs.z),p.push(Ws.x,Ws.y,Ws.z)}this.setAttribute("position",new Ze(p,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class mc extends No{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new mc(e.radius,e.detail)}}class _r extends No{constructor(e=1,t=0){const i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(i,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new _r(e.radius,e.detail)}}class Ir extends bt{constructor(e=1,t=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};const s=e/2,o=t/2,a=Math.floor(i),l=Math.floor(r),c=a+1,u=l+1,h=e/a,d=t/l,p=[],g=[],y=[],m=[];for(let f=0;f<u;f++){const w=f*d-o;for(let T=0;T<c;T++){const _=T*h-s;g.push(_,-w,0),y.push(0,0,1),m.push(T/a),m.push(1-f/l)}}for(let f=0;f<l;f++)for(let w=0;w<a;w++){const T=w+c*f,_=w+c*(f+1),S=w+1+c*(f+1),b=w+1+c*f;p.push(T,_,b),p.push(_,S,b)}this.setIndex(p),this.setAttribute("position",new Ze(g,3)),this.setAttribute("normal",new Ze(y,3)),this.setAttribute("uv",new Ze(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ir(e.width,e.height,e.widthSegments,e.heightSegments)}}class ls extends bt{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const l=Math.min(o+a,Math.PI);let c=0;const u=[],h=new O,d=new O,p=[],g=[],y=[],m=[];for(let f=0;f<=i;f++){const w=[],T=f/i;let _=0;f===0&&o===0?_=.5/t:f===i&&l===Math.PI&&(_=-.5/t);for(let S=0;S<=t;S++){const b=S/t;h.x=-e*Math.cos(r+b*s)*Math.sin(o+T*a),h.y=e*Math.cos(o+T*a),h.z=e*Math.sin(r+b*s)*Math.sin(o+T*a),g.push(h.x,h.y,h.z),d.copy(h).normalize(),y.push(d.x,d.y,d.z),m.push(b+_,1-T),w.push(c++)}u.push(w)}for(let f=0;f<i;f++)for(let w=0;w<t;w++){const T=u[f][w+1],_=u[f][w],S=u[f+1][w],b=u[f+1][w+1];(f!==0||o>0)&&p.push(T,_,b),(f!==i-1||l<Math.PI)&&p.push(_,S,b)}this.setIndex(p),this.setAttribute("position",new Ze(g,3)),this.setAttribute("normal",new Ze(y,3)),this.setAttribute("uv",new Ze(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ls(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class hi extends bt{constructor(e=1,t=.4,i=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:s},i=Math.floor(i),r=Math.floor(r);const o=[],a=[],l=[],c=[],u=new O,h=new O,d=new O;for(let p=0;p<=i;p++)for(let g=0;g<=r;g++){const y=g/r*s,m=p/i*Math.PI*2;h.x=(e+t*Math.cos(m))*Math.cos(y),h.y=(e+t*Math.cos(m))*Math.sin(y),h.z=t*Math.sin(m),a.push(h.x,h.y,h.z),u.x=e*Math.cos(y),u.y=e*Math.sin(y),d.subVectors(h,u).normalize(),l.push(d.x,d.y,d.z),c.push(g/r),c.push(p/i)}for(let p=1;p<=i;p++)for(let g=1;g<=r;g++){const y=(r+1)*p+g-1,m=(r+1)*(p-1)+g-1,f=(r+1)*(p-1)+g,w=(r+1)*p+g;o.push(y,m,w),o.push(m,f,w)}this.setIndex(o),this.setAttribute("position",new Ze(a,3)),this.setAttribute("normal",new Ze(l,3)),this.setAttribute("uv",new Ze(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new hi(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class Np extends Or{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new je(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 je(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Wh,this.normalScale=new Ne(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 Pn,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Up extends Or{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=jd,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Fp extends Or{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class _c extends Mt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new je(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}class Bp extends _c{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Mt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new je(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const Ma=new ft,xu=new O,yu=new O;class zp{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ne(512,512),this.mapType=kn,this.map=null,this.mapPass=null,this.matrix=new ft,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new hc,this._frameExtents=new Ne(1,1),this._viewportCount=1,this._viewports=[new gt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;xu.setFromMatrixPosition(e.matrixWorld),t.position.copy(xu),yu.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(yu),t.updateMatrixWorld(),Ma.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ma,t.coordinateSystem,t.reversedDepth),t.reversedDepth?i.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Ma)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class rf extends Jh{constructor(e=-1,t=1,i=1,r=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=i-e,o=i+e,a=r+t,l=r-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=u*this.view.offsetY,l=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class Vp extends zp{constructor(){super(new rf(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Hp extends _c{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Mt.DEFAULT_UP),this.updateMatrix(),this.target=new Mt,this.shadow=new Vp}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class kp extends _c{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Gp extends cn{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const Mu=new ft;class sf{constructor(e,t,i=0,r=1/0){this.ray=new Oo(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new uc,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Mu.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Mu),this}intersectObject(e,t=!0,i=[]){return Tl(e,this,i,t),i.sort(Eu),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)Tl(e[r],this,i,t);return i.sort(Eu),i}}function Eu(n,e){return n.distance-e.distance}function Tl(n,e,t,i){let r=!0;if(n.layers.test(e.layers)&&n.raycast(e,t)===!1&&(r=!1),r===!0&&i===!0){const s=n.children;for(let o=0,a=s.length;o<a;o++)Tl(s[o],e,t,!0)}}class bu{constructor(e=1,t=0,i=0){this.radius=e,this.phi=t,this.theta=i}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Xe(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Xe(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class Wp extends fc{constructor(e=10,t=10,i=4473924,r=8947848){i=new je(i),r=new je(r);const s=t/2,o=e/t,a=e/2,l=[],c=[];for(let d=0,p=0,g=-a;d<=t;d++,g+=o){l.push(-a,0,g,a,0,g),l.push(g,0,-a,g,0,a);const y=d===s?i:r;y.toArray(c,p),p+=3,y.toArray(c,p),p+=3,y.toArray(c,p),p+=3,y.toArray(c,p),p+=3}const u=new bt;u.setAttribute("position",new Ze(l,3)),u.setAttribute("color",new Ze(c,3));const h=new $i({vertexColors:!0,toneMapped:!1});super(u,h),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class of extends qi{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){console.warn("THREE.Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function Su(n,e,t,i){const r=Xp(i);switch(t){case Vh:return n*e;case kh:return n*e/r.components*r.byteLength;case oc:return n*e/r.components*r.byteLength;case Gh:return n*e*2/r.components*r.byteLength;case ac:return n*e*2/r.components*r.byteLength;case Hh:return n*e*3/r.components*r.byteLength;case bn:return n*e*4/r.components*r.byteLength;case lc:return n*e*4/r.components*r.byteLength;case so:case oo:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case ao:case lo:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Ka:case Qa:return Math.max(n,16)*Math.max(e,8)/4;case Za:case Ja:return Math.max(n,8)*Math.max(e,8)/2;case el:case tl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case nl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case il:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case rl:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case sl:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case ol:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case al:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case ll:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case cl:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case ul:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case hl:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case fl:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case dl:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case pl:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case ml:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case _l:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case gl:case vl:case xl:return Math.ceil(n/4)*Math.ceil(e/4)*16;case yl:case Ml:return Math.ceil(n/4)*Math.ceil(e/4)*8;case El:case bl:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Xp(n){switch(n){case kn:case Uh:return{byteLength:1,components:1};case is:case Fh:case ds:return{byteLength:2,components:1};case rc:case sc:return{byteLength:2,components:4};case Hi:case ic:case Jn:return{byteLength:4,components:1};case Bh:case zh:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${n}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:nc}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=nc);/**
57
+ `},s=new we(5,5,5),r=new Di({name:"CubemapFromEquirect",uniforms:Tr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:on,blending:Ai});r.uniforms.tEquirect.value=e;const a=new gt(s,r),o=e.minFilter;return e.minFilter===bs&&(e.minFilter=On),new n_(1,10,this).update(t,a),e.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(t,e=!0,n=!0,s=!0){const r=t.getRenderTarget();for(let a=0;a<6;a++)t.setRenderTarget(this,a),t.clear(e,n,s);t.setRenderTarget(r)}}class ja extends Te{constructor(){super(),this.isGroup=!0,this.type="Group"}}const s_={type:"move"};class Gl{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ja,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new ja,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new I,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new I),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ja,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new I,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new I),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let s=null,r=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(c&&t.hand){a=!0;for(const x of t.hand.values()){const _=e.getJointPose(x,n),p=this._getHandJoint(c,x);_!==null&&(p.matrix.fromArray(_.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=_.radius),p.visible=_!==null}const h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,m=.005;c.inputState.pinching&&d>f+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&d<=f-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(s=e.getPose(t.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(s_)))}return o!==null&&(o.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){const n=new ja;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}class r_ extends Te{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 Jn,this.environmentIntensity=1,this.environmentRotation=new Jn,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}class a_ extends Je{constructor(t=null,e=1,n=1,s,r,a,o,l,c=xn,h=xn,u,d){super(null,a,o,l,c,h,s,r,u,d),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Wl=new I,o_=new I,l_=new Gt;class ji{constructor(t=new I(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,s){return this.normal.set(t,e,n),this.constant=s,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const s=Wl.subVectors(n,e).cross(o_.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(s,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const n=t.delta(Wl),s=this.normal.dot(n);if(s===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const r=-(t.start.dot(this.normal)+this.constant)/s;return r<0||r>1?null:e.copy(t.start).addScaledVector(n,r)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||l_.getNormalMatrix(t),s=this.coplanarPoint(Wl).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const cs=new tl,c_=new Nt(.5,.5),Ya=new I;class tu{constructor(t=new ji,e=new ji,n=new ji,s=new ji,r=new ji,a=new ji){this.planes=[t,e,n,s,r,a]}set(t,e,n,s,r,a){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=ai,n=!1){const s=this.planes,r=t.elements,a=r[0],o=r[1],l=r[2],c=r[3],h=r[4],u=r[5],d=r[6],f=r[7],m=r[8],x=r[9],_=r[10],p=r[11],w=r[12],S=r[13],y=r[14],E=r[15];if(s[0].setComponents(c-a,f-h,p-m,E-w).normalize(),s[1].setComponents(c+a,f+h,p+m,E+w).normalize(),s[2].setComponents(c+o,f+u,p+x,E+S).normalize(),s[3].setComponents(c-o,f-u,p-x,E-S).normalize(),n)s[4].setComponents(l,d,_,y).normalize(),s[5].setComponents(c-l,f-d,p-_,E-y).normalize();else if(s[4].setComponents(c-l,f-d,p-_,E-y).normalize(),e===ai)s[5].setComponents(c+l,f+d,p+_,E+y).normalize();else if(e===Uo)s[5].setComponents(l,d,_,y).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),cs.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),cs.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(cs)}intersectsSprite(t){cs.center.set(0,0,0);const e=c_.distanceTo(t.center);return cs.radius=.7071067811865476+e,cs.applyMatrix4(t.matrixWorld),this.intersectsSphere(cs)}intersectsSphere(t){const e=this.planes,n=t.center,s=-t.radius;for(let r=0;r<6;r++)if(e[r].distanceToPoint(n)<s)return!1;return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const s=e[n];if(Ya.x=s.normal.x>0?t.max.x:t.min.x,Ya.y=s.normal.y>0?t.max.y:t.min.y,Ya.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(Ya)<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)}}class Dr extends Pr{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Zt(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 zo=new I,Bo=new I,ad=new _e,Wr=new el,qa=new tl,Xl=new I,od=new I;class ni extends Te{constructor(t=new De,e=new Dr){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(t.index===null){const e=t.attributes.position,n=[0];for(let s=1,r=e.count;s<r;s++)zo.fromBufferAttribute(e,s-1),Bo.fromBufferAttribute(e,s),n[s]=n[s-1],n[s]+=zo.distanceTo(Bo);t.setAttribute("lineDistance",new Jt(n,1))}else kt("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const n=this.geometry,s=this.matrixWorld,r=t.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),qa.copy(n.boundingSphere),qa.applyMatrix4(s),qa.radius+=r,t.ray.intersectsSphere(qa)===!1)return;ad.copy(s).invert(),Wr.copy(t.ray).applyMatrix4(ad);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,h=n.index,d=n.attributes.position;if(h!==null){const f=Math.max(0,a.start),m=Math.min(h.count,a.start+a.count);for(let x=f,_=m-1;x<_;x+=c){const p=h.getX(x),w=h.getX(x+1),S=Za(this,t,Wr,l,p,w,x);S&&e.push(S)}if(this.isLineLoop){const x=h.getX(m-1),_=h.getX(f),p=Za(this,t,Wr,l,x,_,m-1);p&&e.push(p)}}else{const f=Math.max(0,a.start),m=Math.min(d.count,a.start+a.count);for(let x=f,_=m-1;x<_;x+=c){const p=Za(this,t,Wr,l,x,x+1,x);p&&e.push(p)}if(this.isLineLoop){const x=Za(this,t,Wr,l,m-1,f,m-1);x&&e.push(x)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){const o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Za(i,t,e,n,s,r,a){const o=i.geometry.attributes.position;if(zo.fromBufferAttribute(o,s),Bo.fromBufferAttribute(o,r),e.distanceSqToSegment(zo,Bo,Xl,od)>n)return;Xl.applyMatrix4(i.matrixWorld);const c=t.ray.origin.distanceTo(Xl);if(!(c<t.near||c>t.far))return{distance:c,point:od.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}const ld=new I,cd=new I;class eu extends ni{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,n=[];for(let s=0,r=e.count;s<r;s+=2)ld.fromBufferAttribute(e,s),cd.fromBufferAttribute(e,s+1),n[s]=s===0?0:n[s-1],n[s+1]=n[s]+ld.distanceTo(cd);t.setAttribute("lineDistance",new Jt(n,1))}else kt("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class bp extends Je{constructor(t,e,n=ws,s,r,a,o=xn,l=xn,c,h=ca,u=1){if(h!==ca&&h!==ha)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:t,height:e,depth:u};super(d,s,r,a,o,l,h,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new Jh(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}}class Mp extends Je{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}}class nu extends De{constructor(t=1,e=32,n=0,s=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:s},e=Math.max(3,e);const r=[],a=[],o=[],l=[],c=new I,h=new Nt;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let u=0,d=3;u<=e;u++,d+=3){const f=n+u/e*s;c.x=t*Math.cos(f),c.y=t*Math.sin(f),a.push(c.x,c.y,c.z),o.push(0,0,1),h.x=(a[d]/t+1)/2,h.y=(a[d+1]/t+1)/2,l.push(h.x,h.y)}for(let u=1;u<=e;u++)r.push(u,u+1,0);this.setIndex(r),this.setAttribute("position",new Jt(a,3)),this.setAttribute("normal",new Jt(o,3)),this.setAttribute("uv",new Jt(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new nu(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class Be extends De{constructor(t=1,e=1,n=1,s=32,r=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:s,heightSegments:r,openEnded:a,thetaStart:o,thetaLength:l};const c=this;s=Math.floor(s),r=Math.floor(r);const h=[],u=[],d=[],f=[];let m=0;const x=[],_=n/2;let p=0;w(),a===!1&&(t>0&&S(!0),e>0&&S(!1)),this.setIndex(h),this.setAttribute("position",new Jt(u,3)),this.setAttribute("normal",new Jt(d,3)),this.setAttribute("uv",new Jt(f,2));function w(){const y=new I,E=new I;let v=0;const A=(e-t)/n;for(let R=0;R<=r;R++){const M=[],g=R/r,O=g*(e-t)+t;for(let F=0;F<=s;F++){const k=F/s,G=k*l+o,K=Math.sin(G),tt=Math.cos(G);E.x=O*K,E.y=-g*n+_,E.z=O*tt,u.push(E.x,E.y,E.z),y.set(K,A,tt).normalize(),d.push(y.x,y.y,y.z),f.push(k,1-g),M.push(m++)}x.push(M)}for(let R=0;R<s;R++)for(let M=0;M<r;M++){const g=x[M][R],O=x[M+1][R],F=x[M+1][R+1],k=x[M][R+1];(t>0||M!==0)&&(h.push(g,O,k),v+=3),(e>0||M!==r-1)&&(h.push(O,F,k),v+=3)}c.addGroup(p,v,0),p+=v}function S(y){const E=m,v=new Nt,A=new I;let R=0;const M=y===!0?t:e,g=y===!0?1:-1;for(let F=1;F<=s;F++)u.push(0,_*g,0),d.push(0,g,0),f.push(.5,.5),m++;const O=m;for(let F=0;F<=s;F++){const G=F/s*l+o,K=Math.cos(G),tt=Math.sin(G);A.x=M*tt,A.y=_*g,A.z=M*K,u.push(A.x,A.y,A.z),d.push(0,g,0),v.x=K*.5+.5,v.y=tt*.5*g+.5,f.push(v.x,v.y),m++}for(let F=0;F<s;F++){const k=E+F,G=O+F;y===!0?h.push(G,G+1,k):h.push(G+1,G,k),R+=3}c.addGroup(p,R,y===!0?1:2),p+=R}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Be(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class iu extends Be{constructor(t=1,e=1,n=32,s=1,r=!1,a=0,o=Math.PI*2){super(0,t,e,n,s,r,a,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:s,openEnded:r,thetaStart:a,thetaLength:o}}static fromJSON(t){return new iu(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class il extends De{constructor(t=[],e=[],n=1,s=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:s};const r=[],a=[];o(s),c(n),h(),this.setAttribute("position",new Jt(r,3)),this.setAttribute("normal",new Jt(r.slice(),3)),this.setAttribute("uv",new Jt(a,2)),s===0?this.computeVertexNormals():this.normalizeNormals();function o(w){const S=new I,y=new I,E=new I;for(let v=0;v<e.length;v+=3)f(e[v+0],S),f(e[v+1],y),f(e[v+2],E),l(S,y,E,w)}function l(w,S,y,E){const v=E+1,A=[];for(let R=0;R<=v;R++){A[R]=[];const M=w.clone().lerp(y,R/v),g=S.clone().lerp(y,R/v),O=v-R;for(let F=0;F<=O;F++)F===0&&R===v?A[R][F]=M:A[R][F]=M.clone().lerp(g,F/O)}for(let R=0;R<v;R++)for(let M=0;M<2*(v-R)-1;M++){const g=Math.floor(M/2);M%2===0?(d(A[R][g+1]),d(A[R+1][g]),d(A[R][g])):(d(A[R][g+1]),d(A[R+1][g+1]),d(A[R+1][g]))}}function c(w){const S=new I;for(let y=0;y<r.length;y+=3)S.x=r[y+0],S.y=r[y+1],S.z=r[y+2],S.normalize().multiplyScalar(w),r[y+0]=S.x,r[y+1]=S.y,r[y+2]=S.z}function h(){const w=new I;for(let S=0;S<r.length;S+=3){w.x=r[S+0],w.y=r[S+1],w.z=r[S+2];const y=_(w)/2/Math.PI+.5,E=p(w)/Math.PI+.5;a.push(y,1-E)}m(),u()}function u(){for(let w=0;w<a.length;w+=6){const S=a[w+0],y=a[w+2],E=a[w+4],v=Math.max(S,y,E),A=Math.min(S,y,E);v>.9&&A<.1&&(S<.2&&(a[w+0]+=1),y<.2&&(a[w+2]+=1),E<.2&&(a[w+4]+=1))}}function d(w){r.push(w.x,w.y,w.z)}function f(w,S){const y=w*3;S.x=t[y+0],S.y=t[y+1],S.z=t[y+2]}function m(){const w=new I,S=new I,y=new I,E=new I,v=new Nt,A=new Nt,R=new Nt;for(let M=0,g=0;M<r.length;M+=9,g+=6){w.set(r[M+0],r[M+1],r[M+2]),S.set(r[M+3],r[M+4],r[M+5]),y.set(r[M+6],r[M+7],r[M+8]),v.set(a[g+0],a[g+1]),A.set(a[g+2],a[g+3]),R.set(a[g+4],a[g+5]),E.copy(w).add(S).add(y).divideScalar(3);const O=_(E);x(v,g+0,w,O),x(A,g+2,S,O),x(R,g+4,y,O)}}function x(w,S,y,E){E<0&&w.x===1&&(a[S]=w.x-1),y.x===0&&y.z===0&&(a[S]=E/2/Math.PI+.5)}function _(w){return Math.atan2(w.z,-w.x)}function p(w){return Math.atan2(-w.y,Math.sqrt(w.x*w.x+w.z*w.z))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new il(t.vertices,t.indices,t.radius,t.details)}}const $a=new I,Ka=new I,jl=new I,Ja=new Rn;class Sp extends De{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},t!==null){const s=Math.pow(10,4),r=Math.cos(ra*e),a=t.getIndex(),o=t.getAttribute("position"),l=a?a.count:o.count,c=[0,0,0],h=["a","b","c"],u=new Array(3),d={},f=[];for(let m=0;m<l;m+=3){a?(c[0]=a.getX(m),c[1]=a.getX(m+1),c[2]=a.getX(m+2)):(c[0]=m,c[1]=m+1,c[2]=m+2);const{a:x,b:_,c:p}=Ja;if(x.fromBufferAttribute(o,c[0]),_.fromBufferAttribute(o,c[1]),p.fromBufferAttribute(o,c[2]),Ja.getNormal(jl),u[0]=`${Math.round(x.x*s)},${Math.round(x.y*s)},${Math.round(x.z*s)}`,u[1]=`${Math.round(_.x*s)},${Math.round(_.y*s)},${Math.round(_.z*s)}`,u[2]=`${Math.round(p.x*s)},${Math.round(p.y*s)},${Math.round(p.z*s)}`,!(u[0]===u[1]||u[1]===u[2]||u[2]===u[0]))for(let w=0;w<3;w++){const S=(w+1)%3,y=u[w],E=u[S],v=Ja[h[w]],A=Ja[h[S]],R=`${y}_${E}`,M=`${E}_${y}`;M in d&&d[M]?(jl.dot(d[M].normal)<=r&&(f.push(v.x,v.y,v.z),f.push(A.x,A.y,A.z)),d[M]=null):R in d||(d[R]={index0:c[w],index1:c[S],normal:jl.clone()})}}for(const m in d)if(d[m]){const{index0:x,index1:_}=d[m];$a.fromBufferAttribute(o,x),Ka.fromBufferAttribute(o,_),f.push($a.x,$a.y,$a.z),f.push(Ka.x,Ka.y,Ka.z)}this.setAttribute("position",new Jt(f,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}class su extends il{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2,s=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],r=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(s,r,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new su(t.radius,t.detail)}}class cr extends il{constructor(t=1,e=0){const n=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],s=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(n,s,t,e),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new cr(t.radius,t.detail)}}class Or extends De{constructor(t=1,e=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:s};const r=t/2,a=e/2,o=Math.floor(n),l=Math.floor(s),c=o+1,h=l+1,u=t/o,d=e/l,f=[],m=[],x=[],_=[];for(let p=0;p<h;p++){const w=p*d-a;for(let S=0;S<c;S++){const y=S*u-r;m.push(y,-w,0),x.push(0,0,1),_.push(S/o),_.push(1-p/l)}}for(let p=0;p<l;p++)for(let w=0;w<o;w++){const S=w+c*p,y=w+c*(p+1),E=w+1+c*(p+1),v=w+1+c*p;f.push(S,y,v),f.push(y,E,v)}this.setIndex(f),this.setAttribute("position",new Jt(m,3)),this.setAttribute("normal",new Jt(x,3)),this.setAttribute("uv",new Jt(_,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Or(t.width,t.height,t.widthSegments,t.heightSegments)}}class da extends De{constructor(t=1,e=32,n=16,s=0,r=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:s,phiLength:r,thetaStart:a,thetaLength:o},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const l=Math.min(a+o,Math.PI);let c=0;const h=[],u=new I,d=new I,f=[],m=[],x=[],_=[];for(let p=0;p<=n;p++){const w=[],S=p/n;let y=0;p===0&&a===0?y=.5/e:p===n&&l===Math.PI&&(y=-.5/e);for(let E=0;E<=e;E++){const v=E/e;u.x=-t*Math.cos(s+v*r)*Math.sin(a+S*o),u.y=t*Math.cos(a+S*o),u.z=t*Math.sin(s+v*r)*Math.sin(a+S*o),m.push(u.x,u.y,u.z),d.copy(u).normalize(),x.push(d.x,d.y,d.z),_.push(v+y,1-S),w.push(c++)}h.push(w)}for(let p=0;p<n;p++)for(let w=0;w<e;w++){const S=h[p][w+1],y=h[p][w],E=h[p+1][w],v=h[p+1][w+1];(p!==0||a>0)&&f.push(S,y,v),(p!==n-1||l<Math.PI)&&f.push(y,E,v)}this.setIndex(f),this.setAttribute("position",new Jt(m,3)),this.setAttribute("normal",new Jt(x,3)),this.setAttribute("uv",new Jt(_,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new da(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class qi extends De{constructor(t=1,e=.4,n=12,s=48,r=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:n,tubularSegments:s,arc:r},n=Math.floor(n),s=Math.floor(s);const a=[],o=[],l=[],c=[],h=new I,u=new I,d=new I;for(let f=0;f<=n;f++)for(let m=0;m<=s;m++){const x=m/s*r,_=f/n*Math.PI*2;u.x=(t+e*Math.cos(_))*Math.cos(x),u.y=(t+e*Math.cos(_))*Math.sin(x),u.z=e*Math.sin(_),o.push(u.x,u.y,u.z),h.x=t*Math.cos(x),h.y=t*Math.sin(x),d.subVectors(u,h).normalize(),l.push(d.x,d.y,d.z),c.push(m/s),c.push(f/n)}for(let f=1;f<=n;f++)for(let m=1;m<=s;m++){const x=(s+1)*f+m-1,_=(s+1)*(f-1)+m-1,p=(s+1)*(f-1)+m,w=(s+1)*f+m;a.push(x,_,w),a.push(_,p,w)}this.setIndex(a),this.setAttribute("position",new Jt(o,3)),this.setAttribute("normal",new Jt(l,3)),this.setAttribute("uv",new Jt(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new qi(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class h_ extends Pr{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Zt(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Zt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=up,this.normalScale=new Nt(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 Jn,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 u_ extends Pr{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=y0,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 d_ extends Pr{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 ru extends Te{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Zt(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(e.object.target=this.target.uuid),e}}class f_ extends ru{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Te.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Zt(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}}const Yl=new _e,hd=new I,ud=new I;class p_{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Nt(512,512),this.mapType=ui,this.map=null,this.mapPass=null,this.matrix=new _e,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new tu,this._frameExtents=new Nt(1,1),this._viewportCount=1,this._viewports=[new Se(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;hd.setFromMatrixPosition(t.matrixWorld),e.position.copy(hd),ud.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(ud),e.updateMatrixWorld(),Yl.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Yl,e.coordinateSystem,e.reversedDepth),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(Yl)}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}clone(){return new this.constructor().copy(this)}toJSON(){const t={};return this.intensity!==1&&(t.intensity=this.intensity),this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class Ep extends vp{constructor(t=-1,e=1,n=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,s,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let r=n-t,a=n+t,o=s+e,l=s-e;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,this.near,this.far,this.coordinateSystem,this.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,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}class m_ extends p_{constructor(){super(new Ep(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class __ extends ru{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Te.DEFAULT_UP),this.updateMatrix(),this.target=new Te,this.shadow=new m_}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class x_ extends ru{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class g_ extends Cn{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}}const dd=new _e;class wp{constructor(t,e,n=0,s=1/0){this.ray=new el(t,e),this.near=n,this.far=s,this.camera=null,this.layers=new Qh,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):Me("Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return dd.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(dd),this}intersectObject(t,e=!0,n=[]){return fh(t,this,n,e),n.sort(fd),n}intersectObjects(t,e=!0,n=[]){for(let s=0,r=t.length;s<r;s++)fh(t[s],this,n,e);return n.sort(fd),n}}function fd(i,t){return i.distance-t.distance}function fh(i,t,e,n){let s=!0;if(i.layers.test(t.layers)&&i.raycast(t,e)===!1&&(s=!1),s===!0&&n===!0){const r=i.children;for(let a=0,o=r.length;a<o;a++)fh(r[a],t,e,!0)}}class pd{constructor(t=1,e=0,n=0){this.radius=t,this.phi=e,this.theta=n}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=qt(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(qt(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class v_ extends eu{constructor(t=10,e=10,n=4473924,s=8947848){n=new Zt(n),s=new Zt(s);const r=e/2,a=t/e,o=t/2,l=[],c=[];for(let d=0,f=0,m=-o;d<=e;d++,m+=a){l.push(-o,0,m,o,0,m),l.push(m,0,-o,m,0,o);const x=d===r?n:s;x.toArray(c,f),f+=3,x.toArray(c,f),f+=3,x.toArray(c,f),f+=3,x.toArray(c,f),f+=3}const h=new De;h.setAttribute("position",new Jt(l,3)),h.setAttribute("color",new Jt(c,3));const u=new Dr({vertexColors:!0,toneMapped:!1});super(h,u),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class Tp extends Ls{constructor(t,e=null){super(),this.object=t,this.domElement=e,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(t){if(t===void 0){kt("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=t}disconnect(){}dispose(){}update(){}}function md(i,t,e,n){const s=y_(n);switch(e){case lp:return i*t;case hp:return i*t/s.components*s.byteLength;case qh:return i*t/s.components*s.byteLength;case Zh:return i*t*2/s.components*s.byteLength;case $h:return i*t*2/s.components*s.byteLength;case cp:return i*t*3/s.components*s.byteLength;case Xn:return i*t*4/s.components*s.byteLength;case Kh:return i*t*4/s.components*s.byteLength;case To:case Ao:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case Co:case Ro:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case Bc:case Vc:return Math.max(i,16)*Math.max(t,8)/4;case zc:case kc:return Math.max(i,8)*Math.max(t,8)/2;case Hc:case Gc:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case Wc:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case Xc:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case jc:return Math.floor((i+4)/5)*Math.floor((t+3)/4)*16;case Yc:return Math.floor((i+4)/5)*Math.floor((t+4)/5)*16;case qc:return Math.floor((i+5)/6)*Math.floor((t+4)/5)*16;case Zc:return Math.floor((i+5)/6)*Math.floor((t+5)/6)*16;case $c:return Math.floor((i+7)/8)*Math.floor((t+4)/5)*16;case Kc:return Math.floor((i+7)/8)*Math.floor((t+5)/6)*16;case Jc:return Math.floor((i+7)/8)*Math.floor((t+7)/8)*16;case Qc:return Math.floor((i+9)/10)*Math.floor((t+4)/5)*16;case th:return Math.floor((i+9)/10)*Math.floor((t+5)/6)*16;case eh:return Math.floor((i+9)/10)*Math.floor((t+7)/8)*16;case nh:return Math.floor((i+9)/10)*Math.floor((t+9)/10)*16;case ih:return Math.floor((i+11)/12)*Math.floor((t+9)/10)*16;case sh:return Math.floor((i+11)/12)*Math.floor((t+11)/12)*16;case rh:case ah:case oh:return Math.ceil(i/4)*Math.ceil(t/4)*16;case lh:case ch:return Math.ceil(i/4)*Math.ceil(t/4)*8;case hh:case uh:return Math.ceil(i/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function y_(i){switch(i){case ui:case sp:return{byteLength:1,components:1};case oa:case rp:case Rr:return{byteLength:2,components:1};case jh:case Yh:return{byteLength:2,components:4};case ws:case Xh:case Ti:return{byteLength:4,components:1};case ap:case op:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Wh}}));typeof window<"u"&&(window.__THREE__?kt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Wh);/**
58
58
  * @license
59
59
  * Copyright 2010-2025 Three.js Authors
60
60
  * SPDX-License-Identifier: MIT
61
- */function af(){let n=null,e=!1,t=null,i=null;function r(s,o){t(s,o),i=n.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(r),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){n=s}}}function jp(n){const e=new WeakMap;function t(a,l){const c=a.array,u=a.usage,h=c.byteLength,d=n.createBuffer();n.bindBuffer(l,d),n.bufferData(l,c,u),a.onUploadCallback();let p;if(c instanceof Float32Array)p=n.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)p=n.HALF_FLOAT;else if(c instanceof Uint16Array)a.isFloat16BufferAttribute?p=n.HALF_FLOAT:p=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)p=n.SHORT;else if(c instanceof Uint32Array)p=n.UNSIGNED_INT;else if(c instanceof Int32Array)p=n.INT;else if(c instanceof Int8Array)p=n.BYTE;else if(c instanceof Uint8Array)p=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)p=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:p,bytesPerElement:c.BYTES_PER_ELEMENT,version:a.version,size:h}}function i(a,l,c){const u=l.array,h=l.updateRanges;if(n.bindBuffer(c,a),h.length===0)n.bufferSubData(c,0,u);else{h.sort((p,g)=>p.start-g.start);let d=0;for(let p=1;p<h.length;p++){const g=h[d],y=h[p];y.start<=g.start+g.count+1?g.count=Math.max(g.count,y.start+y.count-g.start):(++d,h[d]=y)}h.length=d+1;for(let p=0,g=h.length;p<g;p++){const y=h[p];n.bufferSubData(c,y.start*u.BYTES_PER_ELEMENT,u,y.start,y.count)}l.clearUpdateRanges()}l.onUploadCallback()}function r(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function s(a){a.isInterleavedBufferAttribute&&(a=a.data);const l=e.get(a);l&&(n.deleteBuffer(l.buffer),e.delete(a))}function o(a,l){if(a.isInterleavedBufferAttribute&&(a=a.data),a.isGLBufferAttribute){const u=e.get(a);(!u||u.version<a.version)&&e.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}const c=e.get(a);if(c===void 0)e.set(a,t(a,l));else if(c.version<a.version){if(c.size!==a.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.");i(c.buffer,a,l),c.version=a.version}}return{get:r,remove:s,update:o}}var Yp=`#ifdef USE_ALPHAHASH
61
+ */function Ap(){let i=null,t=!1,e=null,n=null;function s(r,a){e(r,a),n=i.requestAnimationFrame(s)}return{start:function(){t!==!0&&e!==null&&(n=i.requestAnimationFrame(s),t=!0)},stop:function(){i.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(r){e=r},setContext:function(r){i=r}}}function b_(i){const t=new WeakMap;function e(o,l){const c=o.array,h=o.usage,u=c.byteLength,d=i.createBuffer();i.bindBuffer(l,d),i.bufferData(l,c,h),o.onUploadCallback();let f;if(c instanceof Float32Array)f=i.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)f=i.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?f=i.HALF_FLOAT:f=i.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=i.SHORT;else if(c instanceof Uint32Array)f=i.UNSIGNED_INT;else if(c instanceof Int32Array)f=i.INT;else if(c instanceof Int8Array)f=i.BYTE;else if(c instanceof Uint8Array)f=i.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:u}}function n(o,l,c){const h=l.array,u=l.updateRanges;if(i.bindBuffer(c,o),u.length===0)i.bufferSubData(c,0,h);else{u.sort((f,m)=>f.start-m.start);let d=0;for(let f=1;f<u.length;f++){const m=u[d],x=u[f];x.start<=m.start+m.count+1?m.count=Math.max(m.count,x.start+x.count-m.start):(++d,u[d]=x)}u.length=d+1;for(let f=0,m=u.length;f<m;f++){const x=u[f];i.bufferSubData(c,x.start*h.BYTES_PER_ELEMENT,h,x.start,x.count)}l.clearUpdateRanges()}l.onUploadCallback()}function s(o){return o.isInterleavedBufferAttribute&&(o=o.data),t.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=t.get(o);l&&(i.deleteBuffer(l.buffer),t.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const h=t.get(o);(!h||h.version<o.version)&&t.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=t.get(o);if(c===void 0)t.set(o,e(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(c.buffer,o,l),c.version=o.version}}return{get:s,remove:r,update:a}}var M_=`#ifdef USE_ALPHAHASH
62
62
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
63
- #endif`,qp=`#ifdef USE_ALPHAHASH
63
+ #endif`,S_=`#ifdef USE_ALPHAHASH
64
64
  const float ALPHA_HASH_SCALE = 0.05;
65
65
  float hash2D( vec2 value ) {
66
66
  return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
@@ -95,20 +95,20 @@ and limitations under the License.
95
95
  : cases.z;
96
96
  return clamp( threshold , 1.0e-6, 1.0 );
97
97
  }
98
- #endif`,$p=`#ifdef USE_ALPHAMAP
98
+ #endif`,E_=`#ifdef USE_ALPHAMAP
99
99
  diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
100
- #endif`,Zp=`#ifdef USE_ALPHAMAP
100
+ #endif`,w_=`#ifdef USE_ALPHAMAP
101
101
  uniform sampler2D alphaMap;
102
- #endif`,Kp=`#ifdef USE_ALPHATEST
102
+ #endif`,T_=`#ifdef USE_ALPHATEST
103
103
  #ifdef ALPHA_TO_COVERAGE
104
104
  diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
105
105
  if ( diffuseColor.a == 0.0 ) discard;
106
106
  #else
107
107
  if ( diffuseColor.a < alphaTest ) discard;
108
108
  #endif
109
- #endif`,Jp=`#ifdef USE_ALPHATEST
109
+ #endif`,A_=`#ifdef USE_ALPHATEST
110
110
  uniform float alphaTest;
111
- #endif`,Qp=`#ifdef USE_AOMAP
111
+ #endif`,C_=`#ifdef USE_AOMAP
112
112
  float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
113
113
  reflectedLight.indirectDiffuse *= ambientOcclusion;
114
114
  #if defined( USE_CLEARCOAT )
@@ -121,10 +121,10 @@ and limitations under the License.
121
121
  float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
122
122
  reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
123
123
  #endif
124
- #endif`,em=`#ifdef USE_AOMAP
124
+ #endif`,R_=`#ifdef USE_AOMAP
125
125
  uniform sampler2D aoMap;
126
126
  uniform float aoMapIntensity;
127
- #endif`,tm=`#ifdef USE_BATCHING
127
+ #endif`,P_=`#ifdef USE_BATCHING
128
128
  #if ! defined( GL_ANGLE_multi_draw )
129
129
  #define gl_DrawID _gl_DrawID
130
130
  uniform int _gl_DrawID;
@@ -158,15 +158,15 @@ and limitations under the License.
158
158
  int y = j / size;
159
159
  return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
160
160
  }
161
- #endif`,nm=`#ifdef USE_BATCHING
161
+ #endif`,D_=`#ifdef USE_BATCHING
162
162
  mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
163
- #endif`,im=`vec3 transformed = vec3( position );
163
+ #endif`,O_=`vec3 transformed = vec3( position );
164
164
  #ifdef USE_ALPHAHASH
165
165
  vPosition = vec3( position );
166
- #endif`,rm=`vec3 objectNormal = vec3( normal );
166
+ #endif`,L_=`vec3 objectNormal = vec3( normal );
167
167
  #ifdef USE_TANGENT
168
168
  vec3 objectTangent = vec3( tangent.xyz );
169
- #endif`,sm=`float G_BlinnPhong_Implicit( ) {
169
+ #endif`,N_=`float G_BlinnPhong_Implicit( ) {
170
170
  return 0.25;
171
171
  }
172
172
  float D_BlinnPhong( const in float shininess, const in float dotNH ) {
@@ -180,7 +180,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
180
180
  float G = G_BlinnPhong_Implicit( );
181
181
  float D = D_BlinnPhong( shininess, dotNH );
182
182
  return F * ( G * D );
183
- } // validated`,om=`#ifdef USE_IRIDESCENCE
183
+ } // validated`,I_=`#ifdef USE_IRIDESCENCE
184
184
  const mat3 XYZ_TO_REC709 = mat3(
185
185
  3.2404542, -0.9692660, 0.0556434,
186
186
  -1.5371385, 1.8760108, -0.2040259,
@@ -243,7 +243,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
243
243
  }
244
244
  return max( I, vec3( 0.0 ) );
245
245
  }
246
- #endif`,am=`#ifdef USE_BUMPMAP
246
+ #endif`,U_=`#ifdef USE_BUMPMAP
247
247
  uniform sampler2D bumpMap;
248
248
  uniform float bumpScale;
249
249
  vec2 dHdxy_fwd() {
@@ -264,7 +264,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
264
264
  vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
265
265
  return normalize( abs( fDet ) * surf_norm - vGrad );
266
266
  }
267
- #endif`,lm=`#if NUM_CLIPPING_PLANES > 0
267
+ #endif`,F_=`#if NUM_CLIPPING_PLANES > 0
268
268
  vec4 plane;
269
269
  #ifdef ALPHA_TO_COVERAGE
270
270
  float distanceToPlane, distanceGradient;
@@ -310,26 +310,26 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
310
310
  if ( clipped ) discard;
311
311
  #endif
312
312
  #endif
313
- #endif`,cm=`#if NUM_CLIPPING_PLANES > 0
313
+ #endif`,z_=`#if NUM_CLIPPING_PLANES > 0
314
314
  varying vec3 vClipPosition;
315
315
  uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
316
- #endif`,um=`#if NUM_CLIPPING_PLANES > 0
316
+ #endif`,B_=`#if NUM_CLIPPING_PLANES > 0
317
317
  varying vec3 vClipPosition;
318
- #endif`,hm=`#if NUM_CLIPPING_PLANES > 0
318
+ #endif`,k_=`#if NUM_CLIPPING_PLANES > 0
319
319
  vClipPosition = - mvPosition.xyz;
320
- #endif`,fm=`#if defined( USE_COLOR_ALPHA )
320
+ #endif`,V_=`#if defined( USE_COLOR_ALPHA )
321
321
  diffuseColor *= vColor;
322
322
  #elif defined( USE_COLOR )
323
323
  diffuseColor.rgb *= vColor;
324
- #endif`,dm=`#if defined( USE_COLOR_ALPHA )
324
+ #endif`,H_=`#if defined( USE_COLOR_ALPHA )
325
325
  varying vec4 vColor;
326
326
  #elif defined( USE_COLOR )
327
327
  varying vec3 vColor;
328
- #endif`,pm=`#if defined( USE_COLOR_ALPHA )
328
+ #endif`,G_=`#if defined( USE_COLOR_ALPHA )
329
329
  varying vec4 vColor;
330
330
  #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
331
331
  varying vec3 vColor;
332
- #endif`,mm=`#if defined( USE_COLOR_ALPHA )
332
+ #endif`,W_=`#if defined( USE_COLOR_ALPHA )
333
333
  vColor = vec4( 1.0 );
334
334
  #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
335
335
  vColor = vec3( 1.0 );
@@ -343,7 +343,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
343
343
  #ifdef USE_BATCHING_COLOR
344
344
  vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
345
345
  vColor.xyz *= batchingColor.xyz;
346
- #endif`,_m=`#define PI 3.141592653589793
346
+ #endif`,X_=`#define PI 3.141592653589793
347
347
  #define PI2 6.283185307179586
348
348
  #define PI_HALF 1.5707963267948966
349
349
  #define RECIPROCAL_PI 0.3183098861837907
@@ -392,13 +392,6 @@ vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
392
392
  vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
393
393
  return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
394
394
  }
395
- mat3 transposeMat3( const in mat3 m ) {
396
- mat3 tmp;
397
- tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
398
- tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
399
- tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
400
- return tmp;
401
- }
402
395
  bool isPerspectiveMatrix( mat4 m ) {
403
396
  return m[ 2 ][ 3 ] == - 1.0;
404
397
  }
@@ -417,7 +410,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
417
410
  float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
418
411
  float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
419
412
  return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
420
- } // validated`,gm=`#ifdef ENVMAP_TYPE_CUBE_UV
413
+ } // validated`,j_=`#ifdef ENVMAP_TYPE_CUBE_UV
421
414
  #define cubeUV_minMipLevel 4.0
422
415
  #define cubeUV_minTileSize 16.0
423
416
  float getFace( vec3 direction ) {
@@ -510,7 +503,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
510
503
  return vec4( mix( color0, color1, mipF ), 1.0 );
511
504
  }
512
505
  }
513
- #endif`,vm=`vec3 transformedNormal = objectNormal;
506
+ #endif`,Y_=`vec3 transformedNormal = objectNormal;
514
507
  #ifdef USE_TANGENT
515
508
  vec3 transformedTangent = objectTangent;
516
509
  #endif
@@ -539,21 +532,21 @@ transformedNormal = normalMatrix * transformedNormal;
539
532
  #ifdef FLIP_SIDED
540
533
  transformedTangent = - transformedTangent;
541
534
  #endif
542
- #endif`,xm=`#ifdef USE_DISPLACEMENTMAP
535
+ #endif`,q_=`#ifdef USE_DISPLACEMENTMAP
543
536
  uniform sampler2D displacementMap;
544
537
  uniform float displacementScale;
545
538
  uniform float displacementBias;
546
- #endif`,ym=`#ifdef USE_DISPLACEMENTMAP
539
+ #endif`,Z_=`#ifdef USE_DISPLACEMENTMAP
547
540
  transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
548
- #endif`,Mm=`#ifdef USE_EMISSIVEMAP
541
+ #endif`,$_=`#ifdef USE_EMISSIVEMAP
549
542
  vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
550
543
  #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
551
544
  emissiveColor = sRGBTransferEOTF( emissiveColor );
552
545
  #endif
553
546
  totalEmissiveRadiance *= emissiveColor.rgb;
554
- #endif`,Em=`#ifdef USE_EMISSIVEMAP
547
+ #endif`,K_=`#ifdef USE_EMISSIVEMAP
555
548
  uniform sampler2D emissiveMap;
556
- #endif`,bm="gl_FragColor = linearToOutputTexel( gl_FragColor );",Sm=`vec4 LinearTransferOETF( in vec4 value ) {
549
+ #endif`,J_="gl_FragColor = linearToOutputTexel( gl_FragColor );",Q_=`vec4 LinearTransferOETF( in vec4 value ) {
557
550
  return value;
558
551
  }
559
552
  vec4 sRGBTransferEOTF( in vec4 value ) {
@@ -561,7 +554,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {
561
554
  }
562
555
  vec4 sRGBTransferOETF( in vec4 value ) {
563
556
  return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
564
- }`,Tm=`#ifdef USE_ENVMAP
557
+ }`,tx=`#ifdef USE_ENVMAP
565
558
  #ifdef ENV_WORLDPOS
566
559
  vec3 cameraToFrag;
567
560
  if ( isOrthographic ) {
@@ -590,7 +583,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
590
583
  #elif defined( ENVMAP_BLENDING_ADD )
591
584
  outgoingLight += envColor.xyz * specularStrength * reflectivity;
592
585
  #endif
593
- #endif`,wm=`#ifdef USE_ENVMAP
586
+ #endif`,ex=`#ifdef USE_ENVMAP
594
587
  uniform float envMapIntensity;
595
588
  uniform float flipEnvMap;
596
589
  uniform mat3 envMapRotation;
@@ -599,8 +592,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
599
592
  #else
600
593
  uniform sampler2D envMap;
601
594
  #endif
602
-
603
- #endif`,Am=`#ifdef USE_ENVMAP
595
+ #endif`,nx=`#ifdef USE_ENVMAP
604
596
  uniform float reflectivity;
605
597
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
606
598
  #define ENV_WORLDPOS
@@ -611,7 +603,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
611
603
  #else
612
604
  varying vec3 vReflect;
613
605
  #endif
614
- #endif`,Rm=`#ifdef USE_ENVMAP
606
+ #endif`,ix=`#ifdef USE_ENVMAP
615
607
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
616
608
  #define ENV_WORLDPOS
617
609
  #endif
@@ -622,7 +614,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
622
614
  varying vec3 vReflect;
623
615
  uniform float refractionRatio;
624
616
  #endif
625
- #endif`,Cm=`#ifdef USE_ENVMAP
617
+ #endif`,sx=`#ifdef USE_ENVMAP
626
618
  #ifdef ENV_WORLDPOS
627
619
  vWorldPosition = worldPosition.xyz;
628
620
  #else
@@ -639,18 +631,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
639
631
  vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
640
632
  #endif
641
633
  #endif
642
- #endif`,Pm=`#ifdef USE_FOG
634
+ #endif`,rx=`#ifdef USE_FOG
643
635
  vFogDepth = - mvPosition.z;
644
- #endif`,Dm=`#ifdef USE_FOG
636
+ #endif`,ax=`#ifdef USE_FOG
645
637
  varying float vFogDepth;
646
- #endif`,Lm=`#ifdef USE_FOG
638
+ #endif`,ox=`#ifdef USE_FOG
647
639
  #ifdef FOG_EXP2
648
640
  float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
649
641
  #else
650
642
  float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
651
643
  #endif
652
644
  gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
653
- #endif`,Om=`#ifdef USE_FOG
645
+ #endif`,lx=`#ifdef USE_FOG
654
646
  uniform vec3 fogColor;
655
647
  varying float vFogDepth;
656
648
  #ifdef FOG_EXP2
@@ -659,7 +651,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
659
651
  uniform float fogNear;
660
652
  uniform float fogFar;
661
653
  #endif
662
- #endif`,Im=`#ifdef USE_GRADIENTMAP
654
+ #endif`,cx=`#ifdef USE_GRADIENTMAP
663
655
  uniform sampler2D gradientMap;
664
656
  #endif
665
657
  vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
@@ -671,12 +663,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
671
663
  vec2 fw = fwidth( coord ) * 0.5;
672
664
  return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
673
665
  #endif
674
- }`,Nm=`#ifdef USE_LIGHTMAP
666
+ }`,hx=`#ifdef USE_LIGHTMAP
675
667
  uniform sampler2D lightMap;
676
668
  uniform float lightMapIntensity;
677
- #endif`,Um=`LambertMaterial material;
669
+ #endif`,ux=`LambertMaterial material;
678
670
  material.diffuseColor = diffuseColor.rgb;
679
- material.specularStrength = specularStrength;`,Fm=`varying vec3 vViewPosition;
671
+ material.specularStrength = specularStrength;`,dx=`varying vec3 vViewPosition;
680
672
  struct LambertMaterial {
681
673
  vec3 diffuseColor;
682
674
  float specularStrength;
@@ -690,7 +682,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
690
682
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
691
683
  }
692
684
  #define RE_Direct RE_Direct_Lambert
693
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Bm=`uniform bool receiveShadow;
685
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,fx=`uniform bool receiveShadow;
694
686
  uniform vec3 ambientLightColor;
695
687
  #if defined( USE_LIGHT_PROBES )
696
688
  uniform vec3 lightProbe[ 9 ];
@@ -806,7 +798,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
806
798
  vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
807
799
  return irradiance;
808
800
  }
809
- #endif`,zm=`#ifdef USE_ENVMAP
801
+ #endif`,px=`#ifdef USE_ENVMAP
810
802
  vec3 getIBLIrradiance( const in vec3 normal ) {
811
803
  #ifdef ENVMAP_TYPE_CUBE_UV
812
804
  vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
@@ -819,7 +811,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
819
811
  vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
820
812
  #ifdef ENVMAP_TYPE_CUBE_UV
821
813
  vec3 reflectVec = reflect( - viewDir, normal );
822
- reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
814
+ reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
823
815
  reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
824
816
  vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
825
817
  return envMapColor.rgb * envMapIntensity;
@@ -839,8 +831,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
839
831
  #endif
840
832
  }
841
833
  #endif
842
- #endif`,Vm=`ToonMaterial material;
843
- material.diffuseColor = diffuseColor.rgb;`,Hm=`varying vec3 vViewPosition;
834
+ #endif`,mx=`ToonMaterial material;
835
+ material.diffuseColor = diffuseColor.rgb;`,_x=`varying vec3 vViewPosition;
844
836
  struct ToonMaterial {
845
837
  vec3 diffuseColor;
846
838
  };
@@ -852,11 +844,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
852
844
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
853
845
  }
854
846
  #define RE_Direct RE_Direct_Toon
855
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,km=`BlinnPhongMaterial material;
847
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,xx=`BlinnPhongMaterial material;
856
848
  material.diffuseColor = diffuseColor.rgb;
857
849
  material.specularColor = specular;
858
850
  material.specularShininess = shininess;
859
- material.specularStrength = specularStrength;`,Gm=`varying vec3 vViewPosition;
851
+ material.specularStrength = specularStrength;`,gx=`varying vec3 vViewPosition;
860
852
  struct BlinnPhongMaterial {
861
853
  vec3 diffuseColor;
862
854
  vec3 specularColor;
@@ -873,7 +865,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
873
865
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
874
866
  }
875
867
  #define RE_Direct RE_Direct_BlinnPhong
876
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Wm=`PhysicalMaterial material;
868
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,vx=`PhysicalMaterial material;
877
869
  material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
878
870
  vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
879
871
  float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
@@ -959,7 +951,8 @@ material.roughness = min( material.roughness, 1.0 );
959
951
  material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
960
952
  material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
961
953
  material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
962
- #endif`,Xm=`struct PhysicalMaterial {
954
+ #endif`,yx=`uniform sampler2D dfgLUT;
955
+ struct PhysicalMaterial {
963
956
  vec3 diffuseColor;
964
957
  float roughness;
965
958
  vec3 specularColor;
@@ -1111,7 +1104,7 @@ vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in m
1111
1104
  vec3 T1, T2;
1112
1105
  T1 = normalize( V - N * dot( V, N ) );
1113
1106
  T2 = - cross( N, T1 );
1114
- mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
1107
+ mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
1115
1108
  vec3 coords[ 4 ];
1116
1109
  coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
1117
1110
  coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
@@ -1160,12 +1153,8 @@ float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float
1160
1153
  }
1161
1154
  vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
1162
1155
  float dotNV = saturate( dot( normal, viewDir ) );
1163
- const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
1164
- const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
1165
- vec4 r = roughness * c0 + c1;
1166
- float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
1167
- vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
1168
- return fab;
1156
+ vec2 uv = vec2( roughness, dotNV );
1157
+ return texture2D( dfgLUT, uv ).rg;
1169
1158
  }
1170
1159
  vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
1171
1160
  vec2 fab = DFGApprox( normal, viewDir, roughness );
@@ -1189,6 +1178,24 @@ void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const
1189
1178
  singleScatter += FssEss;
1190
1179
  multiScatter += Fms * Ems;
1191
1180
  }
1181
+ vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
1182
+ vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
1183
+ float dotNL = saturate( dot( normal, lightDir ) );
1184
+ float dotNV = saturate( dot( normal, viewDir ) );
1185
+ vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
1186
+ vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
1187
+ vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
1188
+ vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;
1189
+ float Ess_V = dfgV.x + dfgV.y;
1190
+ float Ess_L = dfgL.x + dfgL.y;
1191
+ float Ems_V = 1.0 - Ess_V;
1192
+ float Ems_L = 1.0 - Ess_L;
1193
+ vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
1194
+ vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );
1195
+ float compensationFactor = Ems_V * Ems_L;
1196
+ vec3 multiScatter = Fms * compensationFactor;
1197
+ return singleScatter + multiScatter;
1198
+ }
1192
1199
  #if NUM_RECT_AREA_LIGHTS > 0
1193
1200
  void 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 ) {
1194
1201
  vec3 normal = geometryNormal;
@@ -1227,7 +1234,7 @@ void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geome
1227
1234
  #ifdef USE_SHEEN
1228
1235
  sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
1229
1236
  #endif
1230
- reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
1237
+ reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
1231
1238
  reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1232
1239
  }
1233
1240
  void 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 ) {
@@ -1260,7 +1267,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
1260
1267
  #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1261
1268
  float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1262
1269
  return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1263
- }`,jm=`
1270
+ }`,bx=`
1264
1271
  vec3 geometryPosition = - vViewPosition;
1265
1272
  vec3 geometryNormal = normal;
1266
1273
  vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
@@ -1375,7 +1382,7 @@ IncidentLight directLight;
1375
1382
  #if defined( RE_IndirectSpecular )
1376
1383
  vec3 radiance = vec3( 0.0 );
1377
1384
  vec3 clearcoatRadiance = vec3( 0.0 );
1378
- #endif`,Ym=`#if defined( RE_IndirectDiffuse )
1385
+ #endif`,Mx=`#if defined( RE_IndirectDiffuse )
1379
1386
  #ifdef USE_LIGHTMAP
1380
1387
  vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1381
1388
  vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
@@ -1394,32 +1401,32 @@ IncidentLight directLight;
1394
1401
  #ifdef USE_CLEARCOAT
1395
1402
  clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
1396
1403
  #endif
1397
- #endif`,qm=`#if defined( RE_IndirectDiffuse )
1404
+ #endif`,Sx=`#if defined( RE_IndirectDiffuse )
1398
1405
  RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1399
1406
  #endif
1400
1407
  #if defined( RE_IndirectSpecular )
1401
1408
  RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1402
- #endif`,$m=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1409
+ #endif`,Ex=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1403
1410
  gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1404
- #endif`,Zm=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1411
+ #endif`,wx=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1405
1412
  uniform float logDepthBufFC;
1406
1413
  varying float vFragDepth;
1407
1414
  varying float vIsPerspective;
1408
- #endif`,Km=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1415
+ #endif`,Tx=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1409
1416
  varying float vFragDepth;
1410
1417
  varying float vIsPerspective;
1411
- #endif`,Jm=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1418
+ #endif`,Ax=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1412
1419
  vFragDepth = 1.0 + gl_Position.w;
1413
1420
  vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1414
- #endif`,Qm=`#ifdef USE_MAP
1421
+ #endif`,Cx=`#ifdef USE_MAP
1415
1422
  vec4 sampledDiffuseColor = texture2D( map, vMapUv );
1416
1423
  #ifdef DECODE_VIDEO_TEXTURE
1417
1424
  sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
1418
1425
  #endif
1419
1426
  diffuseColor *= sampledDiffuseColor;
1420
- #endif`,e_=`#ifdef USE_MAP
1427
+ #endif`,Rx=`#ifdef USE_MAP
1421
1428
  uniform sampler2D map;
1422
- #endif`,t_=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1429
+ #endif`,Px=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1423
1430
  #if defined( USE_POINTS_UV )
1424
1431
  vec2 uv = vUv;
1425
1432
  #else
@@ -1431,7 +1438,7 @@ IncidentLight directLight;
1431
1438
  #endif
1432
1439
  #ifdef USE_ALPHAMAP
1433
1440
  diffuseColor.a *= texture2D( alphaMap, uv ).g;
1434
- #endif`,n_=`#if defined( USE_POINTS_UV )
1441
+ #endif`,Dx=`#if defined( USE_POINTS_UV )
1435
1442
  varying vec2 vUv;
1436
1443
  #else
1437
1444
  #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
@@ -1443,19 +1450,19 @@ IncidentLight directLight;
1443
1450
  #endif
1444
1451
  #ifdef USE_ALPHAMAP
1445
1452
  uniform sampler2D alphaMap;
1446
- #endif`,i_=`float metalnessFactor = metalness;
1453
+ #endif`,Ox=`float metalnessFactor = metalness;
1447
1454
  #ifdef USE_METALNESSMAP
1448
1455
  vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1449
1456
  metalnessFactor *= texelMetalness.b;
1450
- #endif`,r_=`#ifdef USE_METALNESSMAP
1457
+ #endif`,Lx=`#ifdef USE_METALNESSMAP
1451
1458
  uniform sampler2D metalnessMap;
1452
- #endif`,s_=`#ifdef USE_INSTANCING_MORPH
1459
+ #endif`,Nx=`#ifdef USE_INSTANCING_MORPH
1453
1460
  float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1454
1461
  float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
1455
1462
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1456
1463
  morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
1457
1464
  }
1458
- #endif`,o_=`#if defined( USE_MORPHCOLORS )
1465
+ #endif`,Ix=`#if defined( USE_MORPHCOLORS )
1459
1466
  vColor *= morphTargetBaseInfluence;
1460
1467
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1461
1468
  #if defined( USE_COLOR_ALPHA )
@@ -1464,12 +1471,12 @@ IncidentLight directLight;
1464
1471
  if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1465
1472
  #endif
1466
1473
  }
1467
- #endif`,a_=`#ifdef USE_MORPHNORMALS
1474
+ #endif`,Ux=`#ifdef USE_MORPHNORMALS
1468
1475
  objectNormal *= morphTargetBaseInfluence;
1469
1476
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1470
1477
  if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
1471
1478
  }
1472
- #endif`,l_=`#ifdef USE_MORPHTARGETS
1479
+ #endif`,Fx=`#ifdef USE_MORPHTARGETS
1473
1480
  #ifndef USE_INSTANCING_MORPH
1474
1481
  uniform float morphTargetBaseInfluence;
1475
1482
  uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
@@ -1483,12 +1490,12 @@ IncidentLight directLight;
1483
1490
  ivec3 morphUV = ivec3( x, y, morphTargetIndex );
1484
1491
  return texelFetch( morphTargetsTexture, morphUV, 0 );
1485
1492
  }
1486
- #endif`,c_=`#ifdef USE_MORPHTARGETS
1493
+ #endif`,zx=`#ifdef USE_MORPHTARGETS
1487
1494
  transformed *= morphTargetBaseInfluence;
1488
1495
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1489
1496
  if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
1490
1497
  }
1491
- #endif`,u_=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1498
+ #endif`,Bx=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1492
1499
  #ifdef FLAT_SHADED
1493
1500
  vec3 fdx = dFdx( vViewPosition );
1494
1501
  vec3 fdy = dFdy( vViewPosition );
@@ -1529,7 +1536,7 @@ IncidentLight directLight;
1529
1536
  tbn2[1] *= faceDirection;
1530
1537
  #endif
1531
1538
  #endif
1532
- vec3 nonPerturbedNormal = normal;`,h_=`#ifdef USE_NORMALMAP_OBJECTSPACE
1539
+ vec3 nonPerturbedNormal = normal;`,kx=`#ifdef USE_NORMALMAP_OBJECTSPACE
1533
1540
  normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1534
1541
  #ifdef FLIP_SIDED
1535
1542
  normal = - normal;
@@ -1544,25 +1551,25 @@ vec3 nonPerturbedNormal = normal;`,h_=`#ifdef USE_NORMALMAP_OBJECTSPACE
1544
1551
  normal = normalize( tbn * mapN );
1545
1552
  #elif defined( USE_BUMPMAP )
1546
1553
  normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1547
- #endif`,f_=`#ifndef FLAT_SHADED
1554
+ #endif`,Vx=`#ifndef FLAT_SHADED
1548
1555
  varying vec3 vNormal;
1549
1556
  #ifdef USE_TANGENT
1550
1557
  varying vec3 vTangent;
1551
1558
  varying vec3 vBitangent;
1552
1559
  #endif
1553
- #endif`,d_=`#ifndef FLAT_SHADED
1560
+ #endif`,Hx=`#ifndef FLAT_SHADED
1554
1561
  varying vec3 vNormal;
1555
1562
  #ifdef USE_TANGENT
1556
1563
  varying vec3 vTangent;
1557
1564
  varying vec3 vBitangent;
1558
1565
  #endif
1559
- #endif`,p_=`#ifndef FLAT_SHADED
1566
+ #endif`,Gx=`#ifndef FLAT_SHADED
1560
1567
  vNormal = normalize( transformedNormal );
1561
1568
  #ifdef USE_TANGENT
1562
1569
  vTangent = normalize( transformedTangent );
1563
1570
  vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
1564
1571
  #endif
1565
- #endif`,m_=`#ifdef USE_NORMALMAP
1572
+ #endif`,Wx=`#ifdef USE_NORMALMAP
1566
1573
  uniform sampler2D normalMap;
1567
1574
  uniform vec2 normalScale;
1568
1575
  #endif
@@ -1584,13 +1591,13 @@ vec3 nonPerturbedNormal = normal;`,h_=`#ifdef USE_NORMALMAP_OBJECTSPACE
1584
1591
  float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1585
1592
  return mat3( T * scale, B * scale, N );
1586
1593
  }
1587
- #endif`,__=`#ifdef USE_CLEARCOAT
1594
+ #endif`,Xx=`#ifdef USE_CLEARCOAT
1588
1595
  vec3 clearcoatNormal = nonPerturbedNormal;
1589
- #endif`,g_=`#ifdef USE_CLEARCOAT_NORMALMAP
1596
+ #endif`,jx=`#ifdef USE_CLEARCOAT_NORMALMAP
1590
1597
  vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1591
1598
  clearcoatMapN.xy *= clearcoatNormalScale;
1592
1599
  clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1593
- #endif`,v_=`#ifdef USE_CLEARCOATMAP
1600
+ #endif`,Yx=`#ifdef USE_CLEARCOATMAP
1594
1601
  uniform sampler2D clearcoatMap;
1595
1602
  #endif
1596
1603
  #ifdef USE_CLEARCOAT_NORMALMAP
@@ -1599,18 +1606,18 @@ vec3 nonPerturbedNormal = normal;`,h_=`#ifdef USE_NORMALMAP_OBJECTSPACE
1599
1606
  #endif
1600
1607
  #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1601
1608
  uniform sampler2D clearcoatRoughnessMap;
1602
- #endif`,x_=`#ifdef USE_IRIDESCENCEMAP
1609
+ #endif`,qx=`#ifdef USE_IRIDESCENCEMAP
1603
1610
  uniform sampler2D iridescenceMap;
1604
1611
  #endif
1605
1612
  #ifdef USE_IRIDESCENCE_THICKNESSMAP
1606
1613
  uniform sampler2D iridescenceThicknessMap;
1607
- #endif`,y_=`#ifdef OPAQUE
1614
+ #endif`,Zx=`#ifdef OPAQUE
1608
1615
  diffuseColor.a = 1.0;
1609
1616
  #endif
1610
1617
  #ifdef USE_TRANSMISSION
1611
1618
  diffuseColor.a *= material.transmissionAlpha;
1612
1619
  #endif
1613
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,M_=`vec3 packNormalToRGB( const in vec3 normal ) {
1620
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,$x=`vec3 packNormalToRGB( const in vec3 normal ) {
1614
1621
  return normalize( normal ) * 0.5 + 0.5;
1615
1622
  }
1616
1623
  vec3 unpackRGBToNormal( const in vec3 rgb ) {
@@ -1679,9 +1686,9 @@ float viewZToPerspectiveDepth( const in float viewZ, const in float near, const
1679
1686
  }
1680
1687
  float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
1681
1688
  return ( near * far ) / ( ( far - near ) * depth - far );
1682
- }`,E_=`#ifdef PREMULTIPLIED_ALPHA
1689
+ }`,Kx=`#ifdef PREMULTIPLIED_ALPHA
1683
1690
  gl_FragColor.rgb *= gl_FragColor.a;
1684
- #endif`,b_=`vec4 mvPosition = vec4( transformed, 1.0 );
1691
+ #endif`,Jx=`vec4 mvPosition = vec4( transformed, 1.0 );
1685
1692
  #ifdef USE_BATCHING
1686
1693
  mvPosition = batchingMatrix * mvPosition;
1687
1694
  #endif
@@ -1689,22 +1696,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
1689
1696
  mvPosition = instanceMatrix * mvPosition;
1690
1697
  #endif
1691
1698
  mvPosition = modelViewMatrix * mvPosition;
1692
- gl_Position = projectionMatrix * mvPosition;`,S_=`#ifdef DITHERING
1699
+ gl_Position = projectionMatrix * mvPosition;`,Qx=`#ifdef DITHERING
1693
1700
  gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1694
- #endif`,T_=`#ifdef DITHERING
1701
+ #endif`,tg=`#ifdef DITHERING
1695
1702
  vec3 dithering( vec3 color ) {
1696
1703
  float grid_position = rand( gl_FragCoord.xy );
1697
1704
  vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
1698
1705
  dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
1699
1706
  return color + dither_shift_RGB;
1700
1707
  }
1701
- #endif`,w_=`float roughnessFactor = roughness;
1708
+ #endif`,eg=`float roughnessFactor = roughness;
1702
1709
  #ifdef USE_ROUGHNESSMAP
1703
1710
  vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1704
1711
  roughnessFactor *= texelRoughness.g;
1705
- #endif`,A_=`#ifdef USE_ROUGHNESSMAP
1712
+ #endif`,ng=`#ifdef USE_ROUGHNESSMAP
1706
1713
  uniform sampler2D roughnessMap;
1707
- #endif`,R_=`#if NUM_SPOT_LIGHT_COORDS > 0
1714
+ #endif`,ig=`#if NUM_SPOT_LIGHT_COORDS > 0
1708
1715
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1709
1716
  #endif
1710
1717
  #if NUM_SPOT_LIGHT_MAPS > 0
@@ -1899,7 +1906,7 @@ gl_Position = projectionMatrix * mvPosition;`,S_=`#ifdef DITHERING
1899
1906
  }
1900
1907
  return mix( 1.0, shadow, shadowIntensity );
1901
1908
  }
1902
- #endif`,C_=`#if NUM_SPOT_LIGHT_COORDS > 0
1909
+ #endif`,sg=`#if NUM_SPOT_LIGHT_COORDS > 0
1903
1910
  uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
1904
1911
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1905
1912
  #endif
@@ -1940,7 +1947,7 @@ gl_Position = projectionMatrix * mvPosition;`,S_=`#ifdef DITHERING
1940
1947
  };
1941
1948
  uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1942
1949
  #endif
1943
- #endif`,P_=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
1950
+ #endif`,rg=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
1944
1951
  vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
1945
1952
  vec4 shadowWorldPosition;
1946
1953
  #endif
@@ -1972,7 +1979,7 @@ gl_Position = projectionMatrix * mvPosition;`,S_=`#ifdef DITHERING
1972
1979
  vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
1973
1980
  }
1974
1981
  #pragma unroll_loop_end
1975
- #endif`,D_=`float getShadowMask() {
1982
+ #endif`,ag=`float getShadowMask() {
1976
1983
  float shadow = 1.0;
1977
1984
  #ifdef USE_SHADOWMAP
1978
1985
  #if NUM_DIR_LIGHT_SHADOWS > 0
@@ -2004,12 +2011,12 @@ gl_Position = projectionMatrix * mvPosition;`,S_=`#ifdef DITHERING
2004
2011
  #endif
2005
2012
  #endif
2006
2013
  return shadow;
2007
- }`,L_=`#ifdef USE_SKINNING
2014
+ }`,og=`#ifdef USE_SKINNING
2008
2015
  mat4 boneMatX = getBoneMatrix( skinIndex.x );
2009
2016
  mat4 boneMatY = getBoneMatrix( skinIndex.y );
2010
2017
  mat4 boneMatZ = getBoneMatrix( skinIndex.z );
2011
2018
  mat4 boneMatW = getBoneMatrix( skinIndex.w );
2012
- #endif`,O_=`#ifdef USE_SKINNING
2019
+ #endif`,lg=`#ifdef USE_SKINNING
2013
2020
  uniform mat4 bindMatrix;
2014
2021
  uniform mat4 bindMatrixInverse;
2015
2022
  uniform highp sampler2D boneTexture;
@@ -2024,7 +2031,7 @@ gl_Position = projectionMatrix * mvPosition;`,S_=`#ifdef DITHERING
2024
2031
  vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
2025
2032
  return mat4( v1, v2, v3, v4 );
2026
2033
  }
2027
- #endif`,I_=`#ifdef USE_SKINNING
2034
+ #endif`,cg=`#ifdef USE_SKINNING
2028
2035
  vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
2029
2036
  vec4 skinned = vec4( 0.0 );
2030
2037
  skinned += boneMatX * skinVertex * skinWeight.x;
@@ -2032,7 +2039,7 @@ gl_Position = projectionMatrix * mvPosition;`,S_=`#ifdef DITHERING
2032
2039
  skinned += boneMatZ * skinVertex * skinWeight.z;
2033
2040
  skinned += boneMatW * skinVertex * skinWeight.w;
2034
2041
  transformed = ( bindMatrixInverse * skinned ).xyz;
2035
- #endif`,N_=`#ifdef USE_SKINNING
2042
+ #endif`,hg=`#ifdef USE_SKINNING
2036
2043
  mat4 skinMatrix = mat4( 0.0 );
2037
2044
  skinMatrix += skinWeight.x * boneMatX;
2038
2045
  skinMatrix += skinWeight.y * boneMatY;
@@ -2043,17 +2050,17 @@ gl_Position = projectionMatrix * mvPosition;`,S_=`#ifdef DITHERING
2043
2050
  #ifdef USE_TANGENT
2044
2051
  objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2045
2052
  #endif
2046
- #endif`,U_=`float specularStrength;
2053
+ #endif`,ug=`float specularStrength;
2047
2054
  #ifdef USE_SPECULARMAP
2048
2055
  vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2049
2056
  specularStrength = texelSpecular.r;
2050
2057
  #else
2051
2058
  specularStrength = 1.0;
2052
- #endif`,F_=`#ifdef USE_SPECULARMAP
2059
+ #endif`,dg=`#ifdef USE_SPECULARMAP
2053
2060
  uniform sampler2D specularMap;
2054
- #endif`,B_=`#if defined( TONE_MAPPING )
2061
+ #endif`,fg=`#if defined( TONE_MAPPING )
2055
2062
  gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2056
- #endif`,z_=`#ifndef saturate
2063
+ #endif`,pg=`#ifndef saturate
2057
2064
  #define saturate( a ) clamp( a, 0.0, 1.0 )
2058
2065
  #endif
2059
2066
  uniform float toneMappingExposure;
@@ -2150,7 +2157,7 @@ vec3 NeutralToneMapping( vec3 color ) {
2150
2157
  float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
2151
2158
  return mix( color, vec3( newPeak ), g );
2152
2159
  }
2153
- vec3 CustomToneMapping( vec3 color ) { return color; }`,V_=`#ifdef USE_TRANSMISSION
2160
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,mg=`#ifdef USE_TRANSMISSION
2154
2161
  material.transmission = transmission;
2155
2162
  material.transmissionAlpha = 1.0;
2156
2163
  material.thickness = thickness;
@@ -2171,7 +2178,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,V_=`#ifdef USE_TRANSMISS
2171
2178
  material.attenuationColor, material.attenuationDistance );
2172
2179
  material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2173
2180
  totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2174
- #endif`,H_=`#ifdef USE_TRANSMISSION
2181
+ #endif`,_g=`#ifdef USE_TRANSMISSION
2175
2182
  uniform float transmission;
2176
2183
  uniform float thickness;
2177
2184
  uniform float attenuationDistance;
@@ -2297,7 +2304,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,V_=`#ifdef USE_TRANSMISS
2297
2304
  float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2298
2305
  return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2299
2306
  }
2300
- #endif`,k_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2307
+ #endif`,xg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2301
2308
  varying vec2 vUv;
2302
2309
  #endif
2303
2310
  #ifdef USE_MAP
@@ -2367,7 +2374,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,V_=`#ifdef USE_TRANSMISS
2367
2374
  #ifdef USE_THICKNESSMAP
2368
2375
  uniform mat3 thicknessMapTransform;
2369
2376
  varying vec2 vThicknessMapUv;
2370
- #endif`,G_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2377
+ #endif`,gg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2371
2378
  varying vec2 vUv;
2372
2379
  #endif
2373
2380
  #ifdef USE_MAP
@@ -2461,7 +2468,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,V_=`#ifdef USE_TRANSMISS
2461
2468
  #ifdef USE_THICKNESSMAP
2462
2469
  uniform mat3 thicknessMapTransform;
2463
2470
  varying vec2 vThicknessMapUv;
2464
- #endif`,W_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2471
+ #endif`,vg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2465
2472
  vUv = vec3( uv, 1 ).xy;
2466
2473
  #endif
2467
2474
  #ifdef USE_MAP
@@ -2532,7 +2539,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,V_=`#ifdef USE_TRANSMISS
2532
2539
  #endif
2533
2540
  #ifdef USE_THICKNESSMAP
2534
2541
  vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2535
- #endif`,X_=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2542
+ #endif`,yg=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2536
2543
  vec4 worldPosition = vec4( transformed, 1.0 );
2537
2544
  #ifdef USE_BATCHING
2538
2545
  worldPosition = batchingMatrix * worldPosition;
@@ -2541,12 +2548,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,V_=`#ifdef USE_TRANSMISS
2541
2548
  worldPosition = instanceMatrix * worldPosition;
2542
2549
  #endif
2543
2550
  worldPosition = modelMatrix * worldPosition;
2544
- #endif`;const j_=`varying vec2 vUv;
2551
+ #endif`;const bg=`varying vec2 vUv;
2545
2552
  uniform mat3 uvTransform;
2546
2553
  void main() {
2547
2554
  vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2548
2555
  gl_Position = vec4( position.xy, 1.0, 1.0 );
2549
- }`,Y_=`uniform sampler2D t2D;
2556
+ }`,Mg=`uniform sampler2D t2D;
2550
2557
  uniform float backgroundIntensity;
2551
2558
  varying vec2 vUv;
2552
2559
  void main() {
@@ -2558,14 +2565,14 @@ void main() {
2558
2565
  gl_FragColor = texColor;
2559
2566
  #include <tonemapping_fragment>
2560
2567
  #include <colorspace_fragment>
2561
- }`,q_=`varying vec3 vWorldDirection;
2568
+ }`,Sg=`varying vec3 vWorldDirection;
2562
2569
  #include <common>
2563
2570
  void main() {
2564
2571
  vWorldDirection = transformDirection( position, modelMatrix );
2565
2572
  #include <begin_vertex>
2566
2573
  #include <project_vertex>
2567
2574
  gl_Position.z = gl_Position.w;
2568
- }`,$_=`#ifdef ENVMAP_TYPE_CUBE
2575
+ }`,Eg=`#ifdef ENVMAP_TYPE_CUBE
2569
2576
  uniform samplerCube envMap;
2570
2577
  #elif defined( ENVMAP_TYPE_CUBE_UV )
2571
2578
  uniform sampler2D envMap;
@@ -2588,14 +2595,14 @@ void main() {
2588
2595
  gl_FragColor = texColor;
2589
2596
  #include <tonemapping_fragment>
2590
2597
  #include <colorspace_fragment>
2591
- }`,Z_=`varying vec3 vWorldDirection;
2598
+ }`,wg=`varying vec3 vWorldDirection;
2592
2599
  #include <common>
2593
2600
  void main() {
2594
2601
  vWorldDirection = transformDirection( position, modelMatrix );
2595
2602
  #include <begin_vertex>
2596
2603
  #include <project_vertex>
2597
2604
  gl_Position.z = gl_Position.w;
2598
- }`,K_=`uniform samplerCube tCube;
2605
+ }`,Tg=`uniform samplerCube tCube;
2599
2606
  uniform float tFlip;
2600
2607
  uniform float opacity;
2601
2608
  varying vec3 vWorldDirection;
@@ -2605,7 +2612,7 @@ void main() {
2605
2612
  gl_FragColor.a *= opacity;
2606
2613
  #include <tonemapping_fragment>
2607
2614
  #include <colorspace_fragment>
2608
- }`,J_=`#include <common>
2615
+ }`,Ag=`#include <common>
2609
2616
  #include <batching_pars_vertex>
2610
2617
  #include <uv_pars_vertex>
2611
2618
  #include <displacementmap_pars_vertex>
@@ -2632,7 +2639,7 @@ void main() {
2632
2639
  #include <logdepthbuf_vertex>
2633
2640
  #include <clipping_planes_vertex>
2634
2641
  vHighPrecisionZW = gl_Position.zw;
2635
- }`,Q_=`#if DEPTH_PACKING == 3200
2642
+ }`,Cg=`#if DEPTH_PACKING == 3200
2636
2643
  uniform float opacity;
2637
2644
  #endif
2638
2645
  #include <common>
@@ -2670,7 +2677,7 @@ void main() {
2670
2677
  #elif DEPTH_PACKING == 3203
2671
2678
  gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
2672
2679
  #endif
2673
- }`,eg=`#define DISTANCE
2680
+ }`,Rg=`#define DISTANCE
2674
2681
  varying vec3 vWorldPosition;
2675
2682
  #include <common>
2676
2683
  #include <batching_pars_vertex>
@@ -2697,7 +2704,7 @@ void main() {
2697
2704
  #include <worldpos_vertex>
2698
2705
  #include <clipping_planes_vertex>
2699
2706
  vWorldPosition = worldPosition.xyz;
2700
- }`,tg=`#define DISTANCE
2707
+ }`,Pg=`#define DISTANCE
2701
2708
  uniform vec3 referencePosition;
2702
2709
  uniform float nearDistance;
2703
2710
  uniform float farDistance;
@@ -2721,13 +2728,13 @@ void main () {
2721
2728
  dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
2722
2729
  dist = saturate( dist );
2723
2730
  gl_FragColor = packDepthToRGBA( dist );
2724
- }`,ng=`varying vec3 vWorldDirection;
2731
+ }`,Dg=`varying vec3 vWorldDirection;
2725
2732
  #include <common>
2726
2733
  void main() {
2727
2734
  vWorldDirection = transformDirection( position, modelMatrix );
2728
2735
  #include <begin_vertex>
2729
2736
  #include <project_vertex>
2730
- }`,ig=`uniform sampler2D tEquirect;
2737
+ }`,Og=`uniform sampler2D tEquirect;
2731
2738
  varying vec3 vWorldDirection;
2732
2739
  #include <common>
2733
2740
  void main() {
@@ -2736,7 +2743,7 @@ void main() {
2736
2743
  gl_FragColor = texture2D( tEquirect, sampleUV );
2737
2744
  #include <tonemapping_fragment>
2738
2745
  #include <colorspace_fragment>
2739
- }`,rg=`uniform float scale;
2746
+ }`,Lg=`uniform float scale;
2740
2747
  attribute float lineDistance;
2741
2748
  varying float vLineDistance;
2742
2749
  #include <common>
@@ -2758,7 +2765,7 @@ void main() {
2758
2765
  #include <logdepthbuf_vertex>
2759
2766
  #include <clipping_planes_vertex>
2760
2767
  #include <fog_vertex>
2761
- }`,sg=`uniform vec3 diffuse;
2768
+ }`,Ng=`uniform vec3 diffuse;
2762
2769
  uniform float opacity;
2763
2770
  uniform float dashSize;
2764
2771
  uniform float totalSize;
@@ -2786,7 +2793,7 @@ void main() {
2786
2793
  #include <colorspace_fragment>
2787
2794
  #include <fog_fragment>
2788
2795
  #include <premultiplied_alpha_fragment>
2789
- }`,og=`#include <common>
2796
+ }`,Ig=`#include <common>
2790
2797
  #include <batching_pars_vertex>
2791
2798
  #include <uv_pars_vertex>
2792
2799
  #include <envmap_pars_vertex>
@@ -2818,7 +2825,7 @@ void main() {
2818
2825
  #include <worldpos_vertex>
2819
2826
  #include <envmap_vertex>
2820
2827
  #include <fog_vertex>
2821
- }`,ag=`uniform vec3 diffuse;
2828
+ }`,Ug=`uniform vec3 diffuse;
2822
2829
  uniform float opacity;
2823
2830
  #ifndef FLAT_SHADED
2824
2831
  varying vec3 vNormal;
@@ -2866,7 +2873,7 @@ void main() {
2866
2873
  #include <fog_fragment>
2867
2874
  #include <premultiplied_alpha_fragment>
2868
2875
  #include <dithering_fragment>
2869
- }`,lg=`#define LAMBERT
2876
+ }`,Fg=`#define LAMBERT
2870
2877
  varying vec3 vViewPosition;
2871
2878
  #include <common>
2872
2879
  #include <batching_pars_vertex>
@@ -2905,7 +2912,7 @@ void main() {
2905
2912
  #include <envmap_vertex>
2906
2913
  #include <shadowmap_vertex>
2907
2914
  #include <fog_vertex>
2908
- }`,cg=`#define LAMBERT
2915
+ }`,zg=`#define LAMBERT
2909
2916
  uniform vec3 diffuse;
2910
2917
  uniform vec3 emissive;
2911
2918
  uniform float opacity;
@@ -2962,7 +2969,7 @@ void main() {
2962
2969
  #include <fog_fragment>
2963
2970
  #include <premultiplied_alpha_fragment>
2964
2971
  #include <dithering_fragment>
2965
- }`,ug=`#define MATCAP
2972
+ }`,Bg=`#define MATCAP
2966
2973
  varying vec3 vViewPosition;
2967
2974
  #include <common>
2968
2975
  #include <batching_pars_vertex>
@@ -2996,7 +3003,7 @@ void main() {
2996
3003
  #include <clipping_planes_vertex>
2997
3004
  #include <fog_vertex>
2998
3005
  vViewPosition = - mvPosition.xyz;
2999
- }`,hg=`#define MATCAP
3006
+ }`,kg=`#define MATCAP
3000
3007
  uniform vec3 diffuse;
3001
3008
  uniform float opacity;
3002
3009
  uniform sampler2D matcap;
@@ -3042,7 +3049,7 @@ void main() {
3042
3049
  #include <fog_fragment>
3043
3050
  #include <premultiplied_alpha_fragment>
3044
3051
  #include <dithering_fragment>
3045
- }`,fg=`#define NORMAL
3052
+ }`,Vg=`#define NORMAL
3046
3053
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3047
3054
  varying vec3 vViewPosition;
3048
3055
  #endif
@@ -3075,7 +3082,7 @@ void main() {
3075
3082
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3076
3083
  vViewPosition = - mvPosition.xyz;
3077
3084
  #endif
3078
- }`,dg=`#define NORMAL
3085
+ }`,Hg=`#define NORMAL
3079
3086
  uniform float opacity;
3080
3087
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3081
3088
  varying vec3 vViewPosition;
@@ -3097,7 +3104,7 @@ void main() {
3097
3104
  #ifdef OPAQUE
3098
3105
  gl_FragColor.a = 1.0;
3099
3106
  #endif
3100
- }`,pg=`#define PHONG
3107
+ }`,Gg=`#define PHONG
3101
3108
  varying vec3 vViewPosition;
3102
3109
  #include <common>
3103
3110
  #include <batching_pars_vertex>
@@ -3136,7 +3143,7 @@ void main() {
3136
3143
  #include <envmap_vertex>
3137
3144
  #include <shadowmap_vertex>
3138
3145
  #include <fog_vertex>
3139
- }`,mg=`#define PHONG
3146
+ }`,Wg=`#define PHONG
3140
3147
  uniform vec3 diffuse;
3141
3148
  uniform vec3 emissive;
3142
3149
  uniform vec3 specular;
@@ -3195,7 +3202,7 @@ void main() {
3195
3202
  #include <fog_fragment>
3196
3203
  #include <premultiplied_alpha_fragment>
3197
3204
  #include <dithering_fragment>
3198
- }`,_g=`#define STANDARD
3205
+ }`,Xg=`#define STANDARD
3199
3206
  varying vec3 vViewPosition;
3200
3207
  #ifdef USE_TRANSMISSION
3201
3208
  varying vec3 vWorldPosition;
@@ -3238,7 +3245,7 @@ void main() {
3238
3245
  #ifdef USE_TRANSMISSION
3239
3246
  vWorldPosition = worldPosition.xyz;
3240
3247
  #endif
3241
- }`,gg=`#define STANDARD
3248
+ }`,jg=`#define STANDARD
3242
3249
  #ifdef PHYSICAL
3243
3250
  #define IOR
3244
3251
  #define USE_SPECULAR
@@ -3363,7 +3370,7 @@ void main() {
3363
3370
  #include <fog_fragment>
3364
3371
  #include <premultiplied_alpha_fragment>
3365
3372
  #include <dithering_fragment>
3366
- }`,vg=`#define TOON
3373
+ }`,Yg=`#define TOON
3367
3374
  varying vec3 vViewPosition;
3368
3375
  #include <common>
3369
3376
  #include <batching_pars_vertex>
@@ -3400,7 +3407,7 @@ void main() {
3400
3407
  #include <worldpos_vertex>
3401
3408
  #include <shadowmap_vertex>
3402
3409
  #include <fog_vertex>
3403
- }`,xg=`#define TOON
3410
+ }`,qg=`#define TOON
3404
3411
  uniform vec3 diffuse;
3405
3412
  uniform vec3 emissive;
3406
3413
  uniform float opacity;
@@ -3453,7 +3460,7 @@ void main() {
3453
3460
  #include <fog_fragment>
3454
3461
  #include <premultiplied_alpha_fragment>
3455
3462
  #include <dithering_fragment>
3456
- }`,yg=`uniform float size;
3463
+ }`,Zg=`uniform float size;
3457
3464
  uniform float scale;
3458
3465
  #include <common>
3459
3466
  #include <color_pars_vertex>
@@ -3484,7 +3491,7 @@ void main() {
3484
3491
  #include <clipping_planes_vertex>
3485
3492
  #include <worldpos_vertex>
3486
3493
  #include <fog_vertex>
3487
- }`,Mg=`uniform vec3 diffuse;
3494
+ }`,$g=`uniform vec3 diffuse;
3488
3495
  uniform float opacity;
3489
3496
  #include <common>
3490
3497
  #include <color_pars_fragment>
@@ -3509,7 +3516,7 @@ void main() {
3509
3516
  #include <colorspace_fragment>
3510
3517
  #include <fog_fragment>
3511
3518
  #include <premultiplied_alpha_fragment>
3512
- }`,Eg=`#include <common>
3519
+ }`,Kg=`#include <common>
3513
3520
  #include <batching_pars_vertex>
3514
3521
  #include <fog_pars_vertex>
3515
3522
  #include <morphtarget_pars_vertex>
@@ -3532,7 +3539,7 @@ void main() {
3532
3539
  #include <worldpos_vertex>
3533
3540
  #include <shadowmap_vertex>
3534
3541
  #include <fog_vertex>
3535
- }`,bg=`uniform vec3 color;
3542
+ }`,Jg=`uniform vec3 color;
3536
3543
  uniform float opacity;
3537
3544
  #include <common>
3538
3545
  #include <packing>
@@ -3548,7 +3555,7 @@ void main() {
3548
3555
  #include <tonemapping_fragment>
3549
3556
  #include <colorspace_fragment>
3550
3557
  #include <fog_fragment>
3551
- }`,Sg=`uniform float rotation;
3558
+ }`,Qg=`uniform float rotation;
3552
3559
  uniform vec2 center;
3553
3560
  #include <common>
3554
3561
  #include <uv_pars_vertex>
@@ -3572,7 +3579,7 @@ void main() {
3572
3579
  #include <logdepthbuf_vertex>
3573
3580
  #include <clipping_planes_vertex>
3574
3581
  #include <fog_vertex>
3575
- }`,Tg=`uniform vec3 diffuse;
3582
+ }`,tv=`uniform vec3 diffuse;
3576
3583
  uniform float opacity;
3577
3584
  #include <common>
3578
3585
  #include <uv_pars_fragment>
@@ -3597,7 +3604,115 @@ void main() {
3597
3604
  #include <tonemapping_fragment>
3598
3605
  #include <colorspace_fragment>
3599
3606
  #include <fog_fragment>
3600
- }`,Ge={alphahash_fragment:Yp,alphahash_pars_fragment:qp,alphamap_fragment:$p,alphamap_pars_fragment:Zp,alphatest_fragment:Kp,alphatest_pars_fragment:Jp,aomap_fragment:Qp,aomap_pars_fragment:em,batching_pars_vertex:tm,batching_vertex:nm,begin_vertex:im,beginnormal_vertex:rm,bsdfs:sm,iridescence_fragment:om,bumpmap_pars_fragment:am,clipping_planes_fragment:lm,clipping_planes_pars_fragment:cm,clipping_planes_pars_vertex:um,clipping_planes_vertex:hm,color_fragment:fm,color_pars_fragment:dm,color_pars_vertex:pm,color_vertex:mm,common:_m,cube_uv_reflection_fragment:gm,defaultnormal_vertex:vm,displacementmap_pars_vertex:xm,displacementmap_vertex:ym,emissivemap_fragment:Mm,emissivemap_pars_fragment:Em,colorspace_fragment:bm,colorspace_pars_fragment:Sm,envmap_fragment:Tm,envmap_common_pars_fragment:wm,envmap_pars_fragment:Am,envmap_pars_vertex:Rm,envmap_physical_pars_fragment:zm,envmap_vertex:Cm,fog_vertex:Pm,fog_pars_vertex:Dm,fog_fragment:Lm,fog_pars_fragment:Om,gradientmap_pars_fragment:Im,lightmap_pars_fragment:Nm,lights_lambert_fragment:Um,lights_lambert_pars_fragment:Fm,lights_pars_begin:Bm,lights_toon_fragment:Vm,lights_toon_pars_fragment:Hm,lights_phong_fragment:km,lights_phong_pars_fragment:Gm,lights_physical_fragment:Wm,lights_physical_pars_fragment:Xm,lights_fragment_begin:jm,lights_fragment_maps:Ym,lights_fragment_end:qm,logdepthbuf_fragment:$m,logdepthbuf_pars_fragment:Zm,logdepthbuf_pars_vertex:Km,logdepthbuf_vertex:Jm,map_fragment:Qm,map_pars_fragment:e_,map_particle_fragment:t_,map_particle_pars_fragment:n_,metalnessmap_fragment:i_,metalnessmap_pars_fragment:r_,morphinstance_vertex:s_,morphcolor_vertex:o_,morphnormal_vertex:a_,morphtarget_pars_vertex:l_,morphtarget_vertex:c_,normal_fragment_begin:u_,normal_fragment_maps:h_,normal_pars_fragment:f_,normal_pars_vertex:d_,normal_vertex:p_,normalmap_pars_fragment:m_,clearcoat_normal_fragment_begin:__,clearcoat_normal_fragment_maps:g_,clearcoat_pars_fragment:v_,iridescence_pars_fragment:x_,opaque_fragment:y_,packing:M_,premultiplied_alpha_fragment:E_,project_vertex:b_,dithering_fragment:S_,dithering_pars_fragment:T_,roughnessmap_fragment:w_,roughnessmap_pars_fragment:A_,shadowmap_pars_fragment:R_,shadowmap_pars_vertex:C_,shadowmap_vertex:P_,shadowmask_pars_fragment:D_,skinbase_vertex:L_,skinning_pars_vertex:O_,skinning_vertex:I_,skinnormal_vertex:N_,specularmap_fragment:U_,specularmap_pars_fragment:F_,tonemapping_fragment:B_,tonemapping_pars_fragment:z_,transmission_fragment:V_,transmission_pars_fragment:H_,uv_pars_fragment:k_,uv_pars_vertex:G_,uv_vertex:W_,worldpos_vertex:X_,background_vert:j_,background_frag:Y_,backgroundCube_vert:q_,backgroundCube_frag:$_,cube_vert:Z_,cube_frag:K_,depth_vert:J_,depth_frag:Q_,distanceRGBA_vert:eg,distanceRGBA_frag:tg,equirect_vert:ng,equirect_frag:ig,linedashed_vert:rg,linedashed_frag:sg,meshbasic_vert:og,meshbasic_frag:ag,meshlambert_vert:lg,meshlambert_frag:cg,meshmatcap_vert:ug,meshmatcap_frag:hg,meshnormal_vert:fg,meshnormal_frag:dg,meshphong_vert:pg,meshphong_frag:mg,meshphysical_vert:_g,meshphysical_frag:gg,meshtoon_vert:vg,meshtoon_frag:xg,points_vert:yg,points_frag:Mg,shadow_vert:Eg,shadow_frag:bg,sprite_vert:Sg,sprite_frag:Tg},pe={common:{diffuse:{value:new je(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ke},alphaMap:{value:null},alphaMapTransform:{value:new ke},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ke}},envmap:{envMap:{value:null},envMapRotation:{value:new ke},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ke}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ke}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ke},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ke},normalScale:{value:new Ne(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ke},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ke}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ke}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ke}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new je(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new je(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ke},alphaTest:{value:0},uvTransform:{value:new ke}},sprite:{diffuse:{value:new je(16777215)},opacity:{value:1},center:{value:new Ne(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ke},alphaMap:{value:null},alphaMapTransform:{value:new ke},alphaTest:{value:0}}},In={basic:{uniforms:zt([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.fog]),vertexShader:Ge.meshbasic_vert,fragmentShader:Ge.meshbasic_frag},lambert:{uniforms:zt([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,pe.lights,{emissive:{value:new je(0)}}]),vertexShader:Ge.meshlambert_vert,fragmentShader:Ge.meshlambert_frag},phong:{uniforms:zt([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,pe.lights,{emissive:{value:new je(0)},specular:{value:new je(1118481)},shininess:{value:30}}]),vertexShader:Ge.meshphong_vert,fragmentShader:Ge.meshphong_frag},standard:{uniforms:zt([pe.common,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.roughnessmap,pe.metalnessmap,pe.fog,pe.lights,{emissive:{value:new je(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ge.meshphysical_vert,fragmentShader:Ge.meshphysical_frag},toon:{uniforms:zt([pe.common,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.gradientmap,pe.fog,pe.lights,{emissive:{value:new je(0)}}]),vertexShader:Ge.meshtoon_vert,fragmentShader:Ge.meshtoon_frag},matcap:{uniforms:zt([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,{matcap:{value:null}}]),vertexShader:Ge.meshmatcap_vert,fragmentShader:Ge.meshmatcap_frag},points:{uniforms:zt([pe.points,pe.fog]),vertexShader:Ge.points_vert,fragmentShader:Ge.points_frag},dashed:{uniforms:zt([pe.common,pe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ge.linedashed_vert,fragmentShader:Ge.linedashed_frag},depth:{uniforms:zt([pe.common,pe.displacementmap]),vertexShader:Ge.depth_vert,fragmentShader:Ge.depth_frag},normal:{uniforms:zt([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,{opacity:{value:1}}]),vertexShader:Ge.meshnormal_vert,fragmentShader:Ge.meshnormal_frag},sprite:{uniforms:zt([pe.sprite,pe.fog]),vertexShader:Ge.sprite_vert,fragmentShader:Ge.sprite_frag},background:{uniforms:{uvTransform:{value:new ke},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ge.background_vert,fragmentShader:Ge.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ke}},vertexShader:Ge.backgroundCube_vert,fragmentShader:Ge.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ge.cube_vert,fragmentShader:Ge.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ge.equirect_vert,fragmentShader:Ge.equirect_frag},distanceRGBA:{uniforms:zt([pe.common,pe.displacementmap,{referencePosition:{value:new O},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ge.distanceRGBA_vert,fragmentShader:Ge.distanceRGBA_frag},shadow:{uniforms:zt([pe.lights,pe.fog,{color:{value:new je(0)},opacity:{value:1}}]),vertexShader:Ge.shadow_vert,fragmentShader:Ge.shadow_frag}};In.physical={uniforms:zt([In.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ke},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ke},clearcoatNormalScale:{value:new Ne(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ke},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ke},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ke},sheen:{value:0},sheenColor:{value:new je(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ke},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ke},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ke},transmissionSamplerSize:{value:new Ne},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ke},attenuationDistance:{value:0},attenuationColor:{value:new je(0)},specularColor:{value:new je(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ke},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ke},anisotropyVector:{value:new Ne},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ke}}]),vertexShader:Ge.meshphysical_vert,fragmentShader:Ge.meshphysical_frag};const js={r:0,b:0,g:0},Ri=new Pn,wg=new ft;function Ag(n,e,t,i,r,s,o){const a=new je(0);let l=s===!0?0:1,c,u,h=null,d=0,p=null;function g(T){let _=T.isScene===!0?T.background:null;return _&&_.isTexture&&(_=(T.backgroundBlurriness>0?t:e).get(_)),_}function y(T){let _=!1;const S=g(T);S===null?f(a,l):S&&S.isColor&&(f(S,1),_=!0);const b=n.xr.getEnvironmentBlendMode();b==="additive"?i.buffers.color.setClear(0,0,0,1,o):b==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,o),(n.autoClear||_)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function m(T,_){const S=g(_);S&&(S.isCubeTexture||S.mapping===Do)?(u===void 0&&(u=new ge(new yt(1,1,1),new _i({name:"BackgroundCubeMaterial",uniforms:Pr(In.backgroundCube.uniforms),vertexShader:In.backgroundCube.vertexShader,fragmentShader:In.backgroundCube.fragmentShader,side:Wt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(b,A,C){this.matrixWorld.copyPosition(C.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),Ri.copy(_.backgroundRotation),Ri.x*=-1,Ri.y*=-1,Ri.z*=-1,S.isCubeTexture&&S.isRenderTargetTexture===!1&&(Ri.y*=-1,Ri.z*=-1),u.material.uniforms.envMap.value=S,u.material.uniforms.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=_.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(wg.makeRotationFromEuler(Ri)),u.material.toneMapped=Qe.getTransfer(S.colorSpace)!==nt,(h!==S||d!==S.version||p!==n.toneMapping)&&(u.material.needsUpdate=!0,h=S,d=S.version,p=n.toneMapping),u.layers.enableAll(),T.unshift(u,u.geometry,u.material,0,0,null)):S&&S.isTexture&&(c===void 0&&(c=new ge(new Ir(2,2),new _i({name:"BackgroundMaterial",uniforms:Pr(In.background.uniforms),vertexShader:In.background.vertexShader,fragmentShader:In.background.fragmentShader,side:mi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=S,c.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,c.material.toneMapped=Qe.getTransfer(S.colorSpace)!==nt,S.matrixAutoUpdate===!0&&S.updateMatrix(),c.material.uniforms.uvTransform.value.copy(S.matrix),(h!==S||d!==S.version||p!==n.toneMapping)&&(c.material.needsUpdate=!0,h=S,d=S.version,p=n.toneMapping),c.layers.enableAll(),T.unshift(c,c.geometry,c.material,0,0,null))}function f(T,_){T.getRGB(js,Kh(n)),i.buffers.color.setClear(js.r,js.g,js.b,_,o)}function w(){u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return a},setClearColor:function(T,_=1){a.set(T),l=_,f(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(T){l=T,f(a,l)},render:y,addToRenderList:m,dispose:w}}function Rg(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},r=d(null);let s=r,o=!1;function a(x,N,z,Y,q){let J=!1;const K=h(Y,z,N);s!==K&&(s=K,c(s.object)),J=p(x,Y,z,q),J&&g(x,Y,z,q),q!==null&&e.update(q,n.ELEMENT_ARRAY_BUFFER),(J||o)&&(o=!1,_(x,N,z,Y),q!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(q).buffer))}function l(){return n.createVertexArray()}function c(x){return n.bindVertexArray(x)}function u(x){return n.deleteVertexArray(x)}function h(x,N,z){const Y=z.wireframe===!0;let q=i[x.id];q===void 0&&(q={},i[x.id]=q);let J=q[N.id];J===void 0&&(J={},q[N.id]=J);let K=J[Y];return K===void 0&&(K=d(l()),J[Y]=K),K}function d(x){const N=[],z=[],Y=[];for(let q=0;q<t;q++)N[q]=0,z[q]=0,Y[q]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:N,enabledAttributes:z,attributeDivisors:Y,object:x,attributes:{},index:null}}function p(x,N,z,Y){const q=s.attributes,J=N.attributes;let K=0;const se=z.getAttributes();for(const $ in se)if(se[$].location>=0){const me=q[$];let Ee=J[$];if(Ee===void 0&&($==="instanceMatrix"&&x.instanceMatrix&&(Ee=x.instanceMatrix),$==="instanceColor"&&x.instanceColor&&(Ee=x.instanceColor)),me===void 0||me.attribute!==Ee||Ee&&me.data!==Ee.data)return!0;K++}return s.attributesNum!==K||s.index!==Y}function g(x,N,z,Y){const q={},J=N.attributes;let K=0;const se=z.getAttributes();for(const $ in se)if(se[$].location>=0){let me=J[$];me===void 0&&($==="instanceMatrix"&&x.instanceMatrix&&(me=x.instanceMatrix),$==="instanceColor"&&x.instanceColor&&(me=x.instanceColor));const Ee={};Ee.attribute=me,me&&me.data&&(Ee.data=me.data),q[$]=Ee,K++}s.attributes=q,s.attributesNum=K,s.index=Y}function y(){const x=s.newAttributes;for(let N=0,z=x.length;N<z;N++)x[N]=0}function m(x){f(x,0)}function f(x,N){const z=s.newAttributes,Y=s.enabledAttributes,q=s.attributeDivisors;z[x]=1,Y[x]===0&&(n.enableVertexAttribArray(x),Y[x]=1),q[x]!==N&&(n.vertexAttribDivisor(x,N),q[x]=N)}function w(){const x=s.newAttributes,N=s.enabledAttributes;for(let z=0,Y=N.length;z<Y;z++)N[z]!==x[z]&&(n.disableVertexAttribArray(z),N[z]=0)}function T(x,N,z,Y,q,J,K){K===!0?n.vertexAttribIPointer(x,N,z,q,J):n.vertexAttribPointer(x,N,z,Y,q,J)}function _(x,N,z,Y){y();const q=Y.attributes,J=z.getAttributes(),K=N.defaultAttributeValues;for(const se in J){const $=J[se];if($.location>=0){let le=q[se];if(le===void 0&&(se==="instanceMatrix"&&x.instanceMatrix&&(le=x.instanceMatrix),se==="instanceColor"&&x.instanceColor&&(le=x.instanceColor)),le!==void 0){const me=le.normalized,Ee=le.itemSize,Be=e.get(le);if(Be===void 0)continue;const de=Be.buffer,qe=Be.type,Ke=Be.bytesPerElement,Z=qe===n.INT||qe===n.UNSIGNED_INT||le.gpuType===ic;if(le.isInterleavedBufferAttribute){const oe=le.data,Me=oe.stride,Ie=le.offset;if(oe.isInstancedInterleavedBuffer){for(let Ce=0;Ce<$.locationSize;Ce++)f($.location+Ce,oe.meshPerAttribute);x.isInstancedMesh!==!0&&Y._maxInstanceCount===void 0&&(Y._maxInstanceCount=oe.meshPerAttribute*oe.count)}else for(let Ce=0;Ce<$.locationSize;Ce++)m($.location+Ce);n.bindBuffer(n.ARRAY_BUFFER,de);for(let Ce=0;Ce<$.locationSize;Ce++)T($.location+Ce,Ee/$.locationSize,qe,me,Me*Ke,(Ie+Ee/$.locationSize*Ce)*Ke,Z)}else{if(le.isInstancedBufferAttribute){for(let oe=0;oe<$.locationSize;oe++)f($.location+oe,le.meshPerAttribute);x.isInstancedMesh!==!0&&Y._maxInstanceCount===void 0&&(Y._maxInstanceCount=le.meshPerAttribute*le.count)}else for(let oe=0;oe<$.locationSize;oe++)m($.location+oe);n.bindBuffer(n.ARRAY_BUFFER,de);for(let oe=0;oe<$.locationSize;oe++)T($.location+oe,Ee/$.locationSize,qe,me,Ee*Ke,Ee/$.locationSize*oe*Ke,Z)}}else if(K!==void 0){const me=K[se];if(me!==void 0)switch(me.length){case 2:n.vertexAttrib2fv($.location,me);break;case 3:n.vertexAttrib3fv($.location,me);break;case 4:n.vertexAttrib4fv($.location,me);break;default:n.vertexAttrib1fv($.location,me)}}}}w()}function S(){C();for(const x in i){const N=i[x];for(const z in N){const Y=N[z];for(const q in Y)u(Y[q].object),delete Y[q];delete N[z]}delete i[x]}}function b(x){if(i[x.id]===void 0)return;const N=i[x.id];for(const z in N){const Y=N[z];for(const q in Y)u(Y[q].object),delete Y[q];delete N[z]}delete i[x.id]}function A(x){for(const N in i){const z=i[N];if(z[x.id]===void 0)continue;const Y=z[x.id];for(const q in Y)u(Y[q].object),delete Y[q];delete z[x.id]}}function C(){M(),o=!0,s!==r&&(s=r,c(s.object))}function M(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:C,resetDefaultState:M,dispose:S,releaseStatesOfGeometry:b,releaseStatesOfProgram:A,initAttributes:y,enableAttribute:m,disableUnusedAttributes:w}}function Cg(n,e,t){let i;function r(c){i=c}function s(c,u){n.drawArrays(i,c,u),t.update(u,i,1)}function o(c,u,h){h!==0&&(n.drawArraysInstanced(i,c,u,h),t.update(u,i,h))}function a(c,u,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,u,0,h);let p=0;for(let g=0;g<h;g++)p+=u[g];t.update(p,i,1)}function l(c,u,h,d){if(h===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let g=0;g<c.length;g++)o(c[g],u[g],d[g]);else{p.multiDrawArraysInstancedWEBGL(i,c,0,u,0,d,0,h);let g=0;for(let y=0;y<h;y++)g+=u[y]*d[y];t.update(g,i,1)}}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=l}function Pg(n,e,t,i){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const A=e.get("EXT_texture_filter_anisotropic");r=n.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(A){return!(A!==bn&&i.convert(A)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(A){const C=A===ds&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(A!==kn&&i.convert(A)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&A!==Jn&&!C)}function l(A){if(A==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const u=l(c);u!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const h=t.logarithmicDepthBuffer===!0,d=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),p=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),g=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=n.getParameter(n.MAX_TEXTURE_SIZE),m=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),f=n.getParameter(n.MAX_VERTEX_ATTRIBS),w=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),T=n.getParameter(n.MAX_VARYING_VECTORS),_=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),S=g>0,b=n.getParameter(n.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:h,reversedDepthBuffer:d,maxTextures:p,maxVertexTextures:g,maxTextureSize:y,maxCubemapSize:m,maxAttributes:f,maxVertexUniforms:w,maxVaryings:T,maxFragmentUniforms:_,vertexTextures:S,maxSamples:b}}function Dg(n){const e=this;let t=null,i=0,r=!1,s=!1;const o=new ci,a=new ke,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d){const p=h.length!==0||d||i!==0||r;return r=d,i=h.length,p},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,d){t=u(h,d,0)},this.setState=function(h,d,p){const g=h.clippingPlanes,y=h.clipIntersection,m=h.clipShadows,f=n.get(h);if(!r||g===null||g.length===0||s&&!m)s?u(null):c();else{const w=s?0:i,T=w*4;let _=f.clippingState||null;l.value=_,_=u(g,d,T,p);for(let S=0;S!==T;++S)_[S]=t[S];f.clippingState=_,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=w}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(h,d,p,g){const y=h!==null?h.length:0;let m=null;if(y!==0){if(m=l.value,g!==!0||m===null){const f=p+y*4,w=d.matrixWorldInverse;a.getNormalMatrix(w),(m===null||m.length<f)&&(m=new Float32Array(f));for(let T=0,_=p;T!==y;++T,_+=4)o.copy(h[T]).applyMatrix4(w,a),o.normal.toArray(m,_),m[_+3]=o.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,m}}function Lg(n){let e=new WeakMap;function t(o,a){return a===ja?o.mapping=Ar:a===Ya&&(o.mapping=Rr),o}function i(o){if(o&&o.isTexture){const a=o.mapping;if(a===ja||a===Ya)if(e.has(o)){const l=e.get(o).texture;return t(l,o.mapping)}else{const l=o.image;if(l&&l.height>0){const c=new Cp(l.height);return c.fromEquirectangularTexture(n,o),e.set(o,c),o.addEventListener("dispose",r),t(c.texture,o.mapping)}else return null}}return o}function r(o){const a=o.target;a.removeEventListener("dispose",r);const l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function s(){e=new WeakMap}return{get:i,dispose:s}}const gr=4,Tu=[.125,.215,.35,.446,.526,.582],Ni=20,Ea=new rf,wu=new je;let ba=null,Sa=0,Ta=0,wa=!1;const Li=(1+Math.sqrt(5))/2,dr=1/Li,Au=[new O(-Li,dr,0),new O(Li,dr,0),new O(-dr,0,Li),new O(dr,0,Li),new O(0,Li,-dr),new O(0,Li,dr),new O(-1,1,-1),new O(1,1,-1),new O(-1,1,1),new O(1,1,1)],Og=new O;class Ru{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,r=100,s={}){const{size:o=256,position:a=Og}=s;ba=this._renderer.getRenderTarget(),Sa=this._renderer.getActiveCubeFace(),Ta=this._renderer.getActiveMipmapLevel(),wa=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(o);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,i,r,l,a),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Du(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Pu(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(ba,Sa,Ta),this._renderer.xr.enabled=wa,e.scissorTest=!1,Ys(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Ar||e.mapping===Rr?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),ba=this._renderer.getRenderTarget(),Sa=this._renderer.getActiveCubeFace(),Ta=this._renderer.getActiveMipmapLevel(),wa=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:Fn,minFilter:Fn,generateMipmaps:!1,type:ds,format:bn,colorSpace:Cr,depthBuffer:!1},r=Cu(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Cu(e,t,i);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Ig(s)),this._blurMaterial=Ng(s,e,t)}return r}_compileMaterial(e){const t=new ge(this._lodPlanes[0],e);this._renderer.compile(t,Ea)}_sceneToCubeUV(e,t,i,r,s){const l=new cn(90,1,t,i),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],h=this._renderer,d=h.autoClear,p=h.toneMapping;h.getClearColor(wu),h.toneMapping=pi,h.autoClear=!1,h.state.buffers.depth.getReversed()&&(h.setRenderTarget(r),h.clearDepth(),h.setRenderTarget(null));const y=new Io({name:"PMREM.Background",side:Wt,depthWrite:!1,depthTest:!1}),m=new ge(new yt,y);let f=!1;const w=e.background;w?w.isColor&&(y.color.copy(w),e.background=null,f=!0):(y.color.copy(wu),f=!0);for(let T=0;T<6;T++){const _=T%3;_===0?(l.up.set(0,c[T],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x+u[T],s.y,s.z)):_===1?(l.up.set(0,0,c[T]),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y+u[T],s.z)):(l.up.set(0,c[T],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y,s.z+u[T]));const S=this._cubeSize;Ys(r,_*S,T>2?S:0,S,S),h.setRenderTarget(r),f&&h.render(m,l),h.render(e,l)}m.geometry.dispose(),m.material.dispose(),h.toneMapping=p,h.autoClear=d,e.background=w}_textureToCubeUV(e,t){const i=this._renderer,r=e.mapping===Ar||e.mapping===Rr;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Du()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Pu());const s=r?this._cubemapMaterial:this._equirectMaterial,o=new ge(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;const l=this._cubeSize;Ys(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(o,Ea)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;s<r;s++){const o=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),a=Au[(r-s-1)%Au.length];this._blur(e,s-1,s,o,a)}t.autoClear=i}_blur(e,t,i,r,s){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,i,r,"latitudinal",s),this._halfBlur(o,e,i,i,r,"longitudinal",s)}_halfBlur(e,t,i,r,s,o,a){const l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,h=new ge(this._lodPlanes[r],c),d=c.uniforms,p=this._sizeLods[i]-1,g=isFinite(s)?Math.PI/(2*p):2*Math.PI/(2*Ni-1),y=s/g,m=isFinite(s)?1+Math.floor(u*y):Ni;m>Ni&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Ni}`);const f=[];let w=0;for(let A=0;A<Ni;++A){const C=A/y,M=Math.exp(-C*C/2);f.push(M),A===0?w+=M:A<m&&(w+=2*M)}for(let A=0;A<f.length;A++)f[A]=f[A]/w;d.envMap.value=e.texture,d.samples.value=m,d.weights.value=f,d.latitudinal.value=o==="latitudinal",a&&(d.poleAxis.value=a);const{_lodMax:T}=this;d.dTheta.value=g,d.mipInt.value=T-i;const _=this._sizeLods[r],S=3*_*(r>T-gr?r-T+gr:0),b=4*(this._cubeSize-_);Ys(t,S,b,3*_,2*_),l.setRenderTarget(t),l.render(h,Ea)}}function Ig(n){const e=[],t=[],i=[];let r=n;const s=n-gr+1+Tu.length;for(let o=0;o<s;o++){const a=Math.pow(2,r);t.push(a);let l=1/a;o>n-gr?l=Tu[o-n+gr-1]:o===0&&(l=0),i.push(l);const c=1/(a-2),u=-c,h=1+c,d=[u,u,h,u,h,h,u,u,h,h,u,h],p=6,g=6,y=3,m=2,f=1,w=new Float32Array(y*g*p),T=new Float32Array(m*g*p),_=new Float32Array(f*g*p);for(let b=0;b<p;b++){const A=b%3*2/3-1,C=b>2?0:-1,M=[A,C,0,A+2/3,C,0,A+2/3,C+1,0,A,C,0,A+2/3,C+1,0,A,C+1,0];w.set(M,y*g*b),T.set(d,m*g*b);const x=[b,b,b,b,b,b];_.set(x,f*g*b)}const S=new bt;S.setAttribute("position",new wn(w,y)),S.setAttribute("uv",new wn(T,m)),S.setAttribute("faceIndex",new wn(_,f)),e.push(S),r>gr&&r--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function Cu(n,e,t){const i=new ki(n,e,t);return i.texture.mapping=Do,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Ys(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function Ng(n,e,t){const i=new Float32Array(Ni),r=new O(0,1,0);return new _i({name:"SphericalGaussianBlur",defines:{n:Ni,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:gc(),fragmentShader:`
3607
+ }`,Xt={alphahash_fragment:M_,alphahash_pars_fragment:S_,alphamap_fragment:E_,alphamap_pars_fragment:w_,alphatest_fragment:T_,alphatest_pars_fragment:A_,aomap_fragment:C_,aomap_pars_fragment:R_,batching_pars_vertex:P_,batching_vertex:D_,begin_vertex:O_,beginnormal_vertex:L_,bsdfs:N_,iridescence_fragment:I_,bumpmap_pars_fragment:U_,clipping_planes_fragment:F_,clipping_planes_pars_fragment:z_,clipping_planes_pars_vertex:B_,clipping_planes_vertex:k_,color_fragment:V_,color_pars_fragment:H_,color_pars_vertex:G_,color_vertex:W_,common:X_,cube_uv_reflection_fragment:j_,defaultnormal_vertex:Y_,displacementmap_pars_vertex:q_,displacementmap_vertex:Z_,emissivemap_fragment:$_,emissivemap_pars_fragment:K_,colorspace_fragment:J_,colorspace_pars_fragment:Q_,envmap_fragment:tx,envmap_common_pars_fragment:ex,envmap_pars_fragment:nx,envmap_pars_vertex:ix,envmap_physical_pars_fragment:px,envmap_vertex:sx,fog_vertex:rx,fog_pars_vertex:ax,fog_fragment:ox,fog_pars_fragment:lx,gradientmap_pars_fragment:cx,lightmap_pars_fragment:hx,lights_lambert_fragment:ux,lights_lambert_pars_fragment:dx,lights_pars_begin:fx,lights_toon_fragment:mx,lights_toon_pars_fragment:_x,lights_phong_fragment:xx,lights_phong_pars_fragment:gx,lights_physical_fragment:vx,lights_physical_pars_fragment:yx,lights_fragment_begin:bx,lights_fragment_maps:Mx,lights_fragment_end:Sx,logdepthbuf_fragment:Ex,logdepthbuf_pars_fragment:wx,logdepthbuf_pars_vertex:Tx,logdepthbuf_vertex:Ax,map_fragment:Cx,map_pars_fragment:Rx,map_particle_fragment:Px,map_particle_pars_fragment:Dx,metalnessmap_fragment:Ox,metalnessmap_pars_fragment:Lx,morphinstance_vertex:Nx,morphcolor_vertex:Ix,morphnormal_vertex:Ux,morphtarget_pars_vertex:Fx,morphtarget_vertex:zx,normal_fragment_begin:Bx,normal_fragment_maps:kx,normal_pars_fragment:Vx,normal_pars_vertex:Hx,normal_vertex:Gx,normalmap_pars_fragment:Wx,clearcoat_normal_fragment_begin:Xx,clearcoat_normal_fragment_maps:jx,clearcoat_pars_fragment:Yx,iridescence_pars_fragment:qx,opaque_fragment:Zx,packing:$x,premultiplied_alpha_fragment:Kx,project_vertex:Jx,dithering_fragment:Qx,dithering_pars_fragment:tg,roughnessmap_fragment:eg,roughnessmap_pars_fragment:ng,shadowmap_pars_fragment:ig,shadowmap_pars_vertex:sg,shadowmap_vertex:rg,shadowmask_pars_fragment:ag,skinbase_vertex:og,skinning_pars_vertex:lg,skinning_vertex:cg,skinnormal_vertex:hg,specularmap_fragment:ug,specularmap_pars_fragment:dg,tonemapping_fragment:fg,tonemapping_pars_fragment:pg,transmission_fragment:mg,transmission_pars_fragment:_g,uv_pars_fragment:xg,uv_pars_vertex:gg,uv_vertex:vg,worldpos_vertex:yg,background_vert:bg,background_frag:Mg,backgroundCube_vert:Sg,backgroundCube_frag:Eg,cube_vert:wg,cube_frag:Tg,depth_vert:Ag,depth_frag:Cg,distanceRGBA_vert:Rg,distanceRGBA_frag:Pg,equirect_vert:Dg,equirect_frag:Og,linedashed_vert:Lg,linedashed_frag:Ng,meshbasic_vert:Ig,meshbasic_frag:Ug,meshlambert_vert:Fg,meshlambert_frag:zg,meshmatcap_vert:Bg,meshmatcap_frag:kg,meshnormal_vert:Vg,meshnormal_frag:Hg,meshphong_vert:Gg,meshphong_frag:Wg,meshphysical_vert:Xg,meshphysical_frag:jg,meshtoon_vert:Yg,meshtoon_frag:qg,points_vert:Zg,points_frag:$g,shadow_vert:Kg,shadow_frag:Jg,sprite_vert:Qg,sprite_frag:tv},_t={common:{diffuse:{value:new Zt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Gt},alphaMap:{value:null},alphaMapTransform:{value:new Gt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Gt}},envmap:{envMap:{value:null},envMapRotation:{value:new Gt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Gt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Gt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Gt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Gt},normalScale:{value:new Nt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Gt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Gt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Gt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Gt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Zt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Zt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Gt},alphaTest:{value:0},uvTransform:{value:new Gt}},sprite:{diffuse:{value:new Zt(16777215)},opacity:{value:1},center:{value:new Nt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Gt},alphaMap:{value:null},alphaMapTransform:{value:new Gt},alphaTest:{value:0}}},ii={basic:{uniforms:Ke([_t.common,_t.specularmap,_t.envmap,_t.aomap,_t.lightmap,_t.fog]),vertexShader:Xt.meshbasic_vert,fragmentShader:Xt.meshbasic_frag},lambert:{uniforms:Ke([_t.common,_t.specularmap,_t.envmap,_t.aomap,_t.lightmap,_t.emissivemap,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.fog,_t.lights,{emissive:{value:new Zt(0)}}]),vertexShader:Xt.meshlambert_vert,fragmentShader:Xt.meshlambert_frag},phong:{uniforms:Ke([_t.common,_t.specularmap,_t.envmap,_t.aomap,_t.lightmap,_t.emissivemap,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.fog,_t.lights,{emissive:{value:new Zt(0)},specular:{value:new Zt(1118481)},shininess:{value:30}}]),vertexShader:Xt.meshphong_vert,fragmentShader:Xt.meshphong_frag},standard:{uniforms:Ke([_t.common,_t.envmap,_t.aomap,_t.lightmap,_t.emissivemap,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.roughnessmap,_t.metalnessmap,_t.fog,_t.lights,{emissive:{value:new Zt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Xt.meshphysical_vert,fragmentShader:Xt.meshphysical_frag},toon:{uniforms:Ke([_t.common,_t.aomap,_t.lightmap,_t.emissivemap,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.gradientmap,_t.fog,_t.lights,{emissive:{value:new Zt(0)}}]),vertexShader:Xt.meshtoon_vert,fragmentShader:Xt.meshtoon_frag},matcap:{uniforms:Ke([_t.common,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.fog,{matcap:{value:null}}]),vertexShader:Xt.meshmatcap_vert,fragmentShader:Xt.meshmatcap_frag},points:{uniforms:Ke([_t.points,_t.fog]),vertexShader:Xt.points_vert,fragmentShader:Xt.points_frag},dashed:{uniforms:Ke([_t.common,_t.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Xt.linedashed_vert,fragmentShader:Xt.linedashed_frag},depth:{uniforms:Ke([_t.common,_t.displacementmap]),vertexShader:Xt.depth_vert,fragmentShader:Xt.depth_frag},normal:{uniforms:Ke([_t.common,_t.bumpmap,_t.normalmap,_t.displacementmap,{opacity:{value:1}}]),vertexShader:Xt.meshnormal_vert,fragmentShader:Xt.meshnormal_frag},sprite:{uniforms:Ke([_t.sprite,_t.fog]),vertexShader:Xt.sprite_vert,fragmentShader:Xt.sprite_frag},background:{uniforms:{uvTransform:{value:new Gt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Xt.background_vert,fragmentShader:Xt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Gt}},vertexShader:Xt.backgroundCube_vert,fragmentShader:Xt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Xt.cube_vert,fragmentShader:Xt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Xt.equirect_vert,fragmentShader:Xt.equirect_frag},distanceRGBA:{uniforms:Ke([_t.common,_t.displacementmap,{referencePosition:{value:new I},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Xt.distanceRGBA_vert,fragmentShader:Xt.distanceRGBA_frag},shadow:{uniforms:Ke([_t.lights,_t.fog,{color:{value:new Zt(0)},opacity:{value:1}}]),vertexShader:Xt.shadow_vert,fragmentShader:Xt.shadow_frag}};ii.physical={uniforms:Ke([ii.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Gt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Gt},clearcoatNormalScale:{value:new Nt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Gt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Gt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Gt},sheen:{value:0},sheenColor:{value:new Zt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Gt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Gt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Gt},transmissionSamplerSize:{value:new Nt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Gt},attenuationDistance:{value:0},attenuationColor:{value:new Zt(0)},specularColor:{value:new Zt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Gt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Gt},anisotropyVector:{value:new Nt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Gt}}]),vertexShader:Xt.meshphysical_vert,fragmentShader:Xt.meshphysical_frag};const Qa={r:0,b:0,g:0},hs=new Jn,ev=new _e;function nv(i,t,e,n,s,r,a){const o=new Zt(0);let l=r===!0?0:1,c,h,u=null,d=0,f=null;function m(S){let y=S.isScene===!0?S.background:null;return y&&y.isTexture&&(y=(S.backgroundBlurriness>0?e:t).get(y)),y}function x(S){let y=!1;const E=m(S);E===null?p(o,l):E&&E.isColor&&(p(E,1),y=!0);const v=i.xr.getEnvironmentBlendMode();v==="additive"?n.buffers.color.setClear(0,0,0,1,a):v==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||y)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function _(S,y){const E=m(y);E&&(E.isCubeTexture||E.mapping===Qo)?(h===void 0&&(h=new gt(new we(1,1,1),new Di({name:"BackgroundCubeMaterial",uniforms:Tr(ii.backgroundCube.uniforms),vertexShader:ii.backgroundCube.vertexShader,fragmentShader:ii.backgroundCube.fragmentShader,side:on,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(v,A,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(h)),hs.copy(y.backgroundRotation),hs.x*=-1,hs.y*=-1,hs.z*=-1,E.isCubeTexture&&E.isRenderTargetTexture===!1&&(hs.y*=-1,hs.z*=-1),h.material.uniforms.envMap.value=E,h.material.uniforms.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=y.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(ev.makeRotationFromEuler(hs)),h.material.toneMapped=te.getTransfer(E.colorSpace)!==ae,(u!==E||d!==E.version||f!==i.toneMapping)&&(h.material.needsUpdate=!0,u=E,d=E.version,f=i.toneMapping),h.layers.enableAll(),S.unshift(h,h.geometry,h.material,0,0,null)):E&&E.isTexture&&(c===void 0&&(c=new gt(new Or(2,2),new Di({name:"BackgroundMaterial",uniforms:Tr(ii.background.uniforms),vertexShader:ii.background.vertexShader,fragmentShader:ii.background.fragmentShader,side:Ji,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(c)),c.material.uniforms.t2D.value=E,c.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,c.material.toneMapped=te.getTransfer(E.colorSpace)!==ae,E.matrixAutoUpdate===!0&&E.updateMatrix(),c.material.uniforms.uvTransform.value.copy(E.matrix),(u!==E||d!==E.version||f!==i.toneMapping)&&(c.material.needsUpdate=!0,u=E,d=E.version,f=i.toneMapping),c.layers.enableAll(),S.unshift(c,c.geometry,c.material,0,0,null))}function p(S,y){S.getRGB(Qa,gp(i)),n.buffers.color.setClear(Qa.r,Qa.g,Qa.b,y,a)}function w(){h!==void 0&&(h.geometry.dispose(),h.material.dispose(),h=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(S,y=1){o.set(S),l=y,p(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(S){l=S,p(o,l)},render:x,addToRenderList:_,dispose:w}}function iv(i,t){const e=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=d(null);let r=s,a=!1;function o(g,O,F,k,G){let K=!1;const tt=u(k,F,O);r!==tt&&(r=tt,c(r.object)),K=f(g,k,F,G),K&&m(g,k,F,G),G!==null&&t.update(G,i.ELEMENT_ARRAY_BUFFER),(K||a)&&(a=!1,y(g,O,F,k),G!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t.get(G).buffer))}function l(){return i.createVertexArray()}function c(g){return i.bindVertexArray(g)}function h(g){return i.deleteVertexArray(g)}function u(g,O,F){const k=F.wireframe===!0;let G=n[g.id];G===void 0&&(G={},n[g.id]=G);let K=G[O.id];K===void 0&&(K={},G[O.id]=K);let tt=K[k];return tt===void 0&&(tt=d(l()),K[k]=tt),tt}function d(g){const O=[],F=[],k=[];for(let G=0;G<e;G++)O[G]=0,F[G]=0,k[G]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:O,enabledAttributes:F,attributeDivisors:k,object:g,attributes:{},index:null}}function f(g,O,F,k){const G=r.attributes,K=O.attributes;let tt=0;const lt=F.getAttributes();for(const $ in lt)if(lt[$].location>=0){const ct=G[$];let Et=K[$];if(Et===void 0&&($==="instanceMatrix"&&g.instanceMatrix&&(Et=g.instanceMatrix),$==="instanceColor"&&g.instanceColor&&(Et=g.instanceColor)),ct===void 0||ct.attribute!==Et||Et&&ct.data!==Et.data)return!0;tt++}return r.attributesNum!==tt||r.index!==k}function m(g,O,F,k){const G={},K=O.attributes;let tt=0;const lt=F.getAttributes();for(const $ in lt)if(lt[$].location>=0){let ct=K[$];ct===void 0&&($==="instanceMatrix"&&g.instanceMatrix&&(ct=g.instanceMatrix),$==="instanceColor"&&g.instanceColor&&(ct=g.instanceColor));const Et={};Et.attribute=ct,ct&&ct.data&&(Et.data=ct.data),G[$]=Et,tt++}r.attributes=G,r.attributesNum=tt,r.index=k}function x(){const g=r.newAttributes;for(let O=0,F=g.length;O<F;O++)g[O]=0}function _(g){p(g,0)}function p(g,O){const F=r.newAttributes,k=r.enabledAttributes,G=r.attributeDivisors;F[g]=1,k[g]===0&&(i.enableVertexAttribArray(g),k[g]=1),G[g]!==O&&(i.vertexAttribDivisor(g,O),G[g]=O)}function w(){const g=r.newAttributes,O=r.enabledAttributes;for(let F=0,k=O.length;F<k;F++)O[F]!==g[F]&&(i.disableVertexAttribArray(F),O[F]=0)}function S(g,O,F,k,G,K,tt){tt===!0?i.vertexAttribIPointer(g,O,F,G,K):i.vertexAttribPointer(g,O,F,k,G,K)}function y(g,O,F,k){x();const G=k.attributes,K=F.getAttributes(),tt=O.defaultAttributeValues;for(const lt in K){const $=K[lt];if($.location>=0){let st=G[lt];if(st===void 0&&(lt==="instanceMatrix"&&g.instanceMatrix&&(st=g.instanceMatrix),lt==="instanceColor"&&g.instanceColor&&(st=g.instanceColor)),st!==void 0){const ct=st.normalized,Et=st.itemSize,Vt=t.get(st);if(Vt===void 0)continue;const pt=Vt.buffer,$t=Vt.type,se=Vt.bytesPerElement,J=$t===i.INT||$t===i.UNSIGNED_INT||st.gpuType===Xh;if(st.isInterleavedBufferAttribute){const rt=st.data,Mt=rt.stride,Bt=st.offset;if(rt.isInstancedInterleavedBuffer){for(let Ct=0;Ct<$.locationSize;Ct++)p($.location+Ct,rt.meshPerAttribute);g.isInstancedMesh!==!0&&k._maxInstanceCount===void 0&&(k._maxInstanceCount=rt.meshPerAttribute*rt.count)}else for(let Ct=0;Ct<$.locationSize;Ct++)_($.location+Ct);i.bindBuffer(i.ARRAY_BUFFER,pt);for(let Ct=0;Ct<$.locationSize;Ct++)S($.location+Ct,Et/$.locationSize,$t,ct,Mt*se,(Bt+Et/$.locationSize*Ct)*se,J)}else{if(st.isInstancedBufferAttribute){for(let rt=0;rt<$.locationSize;rt++)p($.location+rt,st.meshPerAttribute);g.isInstancedMesh!==!0&&k._maxInstanceCount===void 0&&(k._maxInstanceCount=st.meshPerAttribute*st.count)}else for(let rt=0;rt<$.locationSize;rt++)_($.location+rt);i.bindBuffer(i.ARRAY_BUFFER,pt);for(let rt=0;rt<$.locationSize;rt++)S($.location+rt,Et/$.locationSize,$t,ct,Et*se,Et/$.locationSize*rt*se,J)}}else if(tt!==void 0){const ct=tt[lt];if(ct!==void 0)switch(ct.length){case 2:i.vertexAttrib2fv($.location,ct);break;case 3:i.vertexAttrib3fv($.location,ct);break;case 4:i.vertexAttrib4fv($.location,ct);break;default:i.vertexAttrib1fv($.location,ct)}}}}w()}function E(){R();for(const g in n){const O=n[g];for(const F in O){const k=O[F];for(const G in k)h(k[G].object),delete k[G];delete O[F]}delete n[g]}}function v(g){if(n[g.id]===void 0)return;const O=n[g.id];for(const F in O){const k=O[F];for(const G in k)h(k[G].object),delete k[G];delete O[F]}delete n[g.id]}function A(g){for(const O in n){const F=n[O];if(F[g.id]===void 0)continue;const k=F[g.id];for(const G in k)h(k[G].object),delete k[G];delete F[g.id]}}function R(){M(),a=!0,r!==s&&(r=s,c(r.object))}function M(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:R,resetDefaultState:M,dispose:E,releaseStatesOfGeometry:v,releaseStatesOfProgram:A,initAttributes:x,enableAttribute:_,disableUnusedAttributes:w}}function sv(i,t,e){let n;function s(c){n=c}function r(c,h){i.drawArrays(n,c,h),e.update(h,n,1)}function a(c,h,u){u!==0&&(i.drawArraysInstanced(n,c,h,u),e.update(h,n,u))}function o(c,h,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,h,0,u);let f=0;for(let m=0;m<u;m++)f+=h[m];e.update(f,n,1)}function l(c,h,u,d){if(u===0)return;const f=t.get("WEBGL_multi_draw");if(f===null)for(let m=0;m<c.length;m++)a(c[m],h[m],d[m]);else{f.multiDrawArraysInstancedWEBGL(n,c,0,h,0,d,0,u);let m=0;for(let x=0;x<u;x++)m+=h[x]*d[x];e.update(m,n,1)}}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function rv(i,t,e,n){let s;function r(){if(s!==void 0)return s;if(t.has("EXT_texture_filter_anisotropic")===!0){const A=t.get("EXT_texture_filter_anisotropic");s=i.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function a(A){return!(A!==Xn&&n.convert(A)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(A){const R=A===Rr&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(A!==ui&&n.convert(A)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&A!==Ti&&!R)}function l(A){if(A==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=e.precision!==void 0?e.precision:"highp";const h=l(c);h!==c&&(kt("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const u=e.logarithmicDepthBuffer===!0,d=e.reversedDepthBuffer===!0&&t.has("EXT_clip_control"),f=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),m=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=i.getParameter(i.MAX_TEXTURE_SIZE),_=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),p=i.getParameter(i.MAX_VERTEX_ATTRIBS),w=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),S=i.getParameter(i.MAX_VARYING_VECTORS),y=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),E=m>0,v=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:m,maxTextureSize:x,maxCubemapSize:_,maxAttributes:p,maxVertexUniforms:w,maxVaryings:S,maxFragmentUniforms:y,vertexTextures:E,maxSamples:v}}function av(i){const t=this;let e=null,n=0,s=!1,r=!1;const a=new ji,o=new Gt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const f=u.length!==0||d||n!==0||s;return s=d,n=u.length,f},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,d){e=h(u,d,0)},this.setState=function(u,d,f){const m=u.clippingPlanes,x=u.clipIntersection,_=u.clipShadows,p=i.get(u);if(!s||m===null||m.length===0||r&&!_)r?h(null):c();else{const w=r?0:n,S=w*4;let y=p.clippingState||null;l.value=y,y=h(m,d,S,f);for(let E=0;E!==S;++E)y[E]=e[E];p.clippingState=y,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=w}};function c(){l.value!==e&&(l.value=e,l.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(u,d,f,m){const x=u!==null?u.length:0;let _=null;if(x!==0){if(_=l.value,m!==!0||_===null){const p=f+x*4,w=d.matrixWorldInverse;o.getNormalMatrix(w),(_===null||_.length<p)&&(_=new Float32Array(p));for(let S=0,y=f;S!==x;++S,y+=4)a.copy(u[S]).applyMatrix4(w,o),a.normal.toArray(_,y),_[y+3]=a.constant}l.value=_,l.needsUpdate=!0}return t.numPlanes=x,t.numIntersection=0,_}}function ov(i){let t=new WeakMap;function e(a,o){return o===Nc?a.mapping=Sr:o===Ic&&(a.mapping=Er),a}function n(a){if(a&&a.isTexture){const o=a.mapping;if(o===Nc||o===Ic)if(t.has(a)){const l=t.get(a).texture;return e(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const c=new i_(l.height);return c.fromEquirectangularTexture(i,a),t.set(a,c),a.addEventListener("dispose",s),e(c.texture,a.mapping)}else return null}}return a}function s(a){const o=a.target;o.removeEventListener("dispose",s);const l=t.get(o);l!==void 0&&(t.delete(o),l.dispose())}function r(){t=new WeakMap}return{get:n,dispose:r}}const Zi=4,_d=[.125,.215,.35,.446,.526,.582],gs=20,lv=256,Xr=new Ep,xd=new Zt;let ql=null,Zl=0,$l=0,Kl=!1;const cv=new I;class gd{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,s=100,r={}){const{size:a=256,position:o=cv}=r;ql=this._renderer.getRenderTarget(),Zl=this._renderer.getActiveCubeFace(),$l=this._renderer.getActiveMipmapLevel(),Kl=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(t,n,s,l,o),e>0&&this._blur(l,0,0,e),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=bd(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=yd(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(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(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodMeshes.length;t++)this._lodMeshes[t].geometry.dispose()}_cleanup(t){this._renderer.setRenderTarget(ql,Zl,$l),this._renderer.xr.enabled=Kl,t.scissorTest=!1,Ks(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===Sr||t.mapping===Er?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),ql=this._renderer.getRenderTarget(),Zl=this._renderer.getActiveCubeFace(),$l=this._renderer.getActiveMipmapLevel(),Kl=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:On,minFilter:On,generateMipmaps:!1,type:Rr,format:Xn,colorSpace:wr,depthBuffer:!1},s=vd(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=vd(t,e,n);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=hv(r)),this._blurMaterial=dv(r,t,e)}return s}_compileMaterial(t){const e=new gt(new De,t);this._renderer.compile(e,Xr)}_sceneToCubeUV(t,e,n,s,r){const l=new Cn(90,1,e,n),c=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,f=u.toneMapping;u.getClearColor(xd),u.toneMapping=Ki,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(s),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new gt(new we,new nl({name:"PMREM.Background",side:on,depthWrite:!1,depthTest:!1})));const x=this._backgroundBox,_=x.material;let p=!1;const w=t.background;w?w.isColor&&(_.color.copy(w),t.background=null,p=!0):(_.color.copy(xd),p=!0);for(let S=0;S<6;S++){const y=S%3;y===0?(l.up.set(0,c[S],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x+h[S],r.y,r.z)):y===1?(l.up.set(0,0,c[S]),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y+h[S],r.z)):(l.up.set(0,c[S],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y,r.z+h[S]));const E=this._cubeSize;Ks(s,y*E,S>2?E:0,E,E),u.setRenderTarget(s),p&&u.render(x,l),u.render(t,l)}u.toneMapping=f,u.autoClear=d,t.background=w}_textureToCubeUV(t,e){const n=this._renderer,s=t.mapping===Sr||t.mapping===Er;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=bd()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=yd());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=t;const l=this._cubeSize;Ks(e,0,0,3*l,2*l),n.setRenderTarget(e),n.render(a,Xr)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const s=this._lodMeshes.length;for(let r=1;r<s;r++)this._applyGGXFilter(t,r-1,r);e.autoClear=n}_applyGGXFilter(t,e,n){const s=this._renderer,r=this._pingPongRenderTarget;if(this._ggxMaterial===null){const w=3*Math.max(this._cubeSize,16),S=4*this._cubeSize;this._ggxMaterial=uv(this._lodMax,w,S)}const a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;const l=a.uniforms,c=n/(this._lodMeshes.length-1),h=e/(this._lodMeshes.length-1),u=Math.sqrt(c*c-h*h),d=.05+c*.95,f=u*d,{_lodMax:m}=this,x=this._sizeLods[n],_=3*x*(n>m-Zi?n-m+Zi:0),p=4*(this._cubeSize-x);l.envMap.value=t.texture,l.roughness.value=f,l.mipInt.value=m-e,Ks(r,_,p,3*x,2*x),s.setRenderTarget(r),s.render(o,Xr),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=m-n,Ks(t,_,p,3*x,2*x),s.setRenderTarget(t),s.render(o,Xr)}_blur(t,e,n,s,r){const a=this._pingPongRenderTarget;this._halfBlur(t,a,e,n,s,"latitudinal",r),this._halfBlur(a,t,n,n,s,"longitudinal",r)}_halfBlur(t,e,n,s,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Me("blur direction must be either latitudinal or longitudinal!");const h=3,u=this._lodMeshes[s];u.material=c;const d=c.uniforms,f=this._sizeLods[n]-1,m=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*gs-1),x=r/m,_=isFinite(r)?1+Math.floor(h*x):gs;_>gs&&kt(`sigmaRadians, ${r}, is too large and will clip, as it requested ${_} samples when the maximum is set to ${gs}`);const p=[];let w=0;for(let A=0;A<gs;++A){const R=A/x,M=Math.exp(-R*R/2);p.push(M),A===0?w+=M:A<_&&(w+=2*M)}for(let A=0;A<p.length;A++)p[A]=p[A]/w;d.envMap.value=t.texture,d.samples.value=_,d.weights.value=p,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:S}=this;d.dTheta.value=m,d.mipInt.value=S-n;const y=this._sizeLods[s],E=3*y*(s>S-Zi?s-S+Zi:0),v=4*(this._cubeSize-y);Ks(e,E,v,3*y,2*y),l.setRenderTarget(e),l.render(u,Xr)}}function hv(i){const t=[],e=[],n=[];let s=i;const r=i-Zi+1+_d.length;for(let a=0;a<r;a++){const o=Math.pow(2,s);t.push(o);let l=1/o;a>i-Zi?l=_d[a-i+Zi-1]:a===0&&(l=0),e.push(l);const c=1/(o-2),h=-c,u=1+c,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,m=6,x=3,_=2,p=1,w=new Float32Array(x*m*f),S=new Float32Array(_*m*f),y=new Float32Array(p*m*f);for(let v=0;v<f;v++){const A=v%3*2/3-1,R=v>2?0:-1,M=[A,R,0,A+2/3,R,0,A+2/3,R+1,0,A,R,0,A+2/3,R+1,0,A,R+1,0];w.set(M,x*m*v),S.set(d,_*m*v);const g=[v,v,v,v,v,v];y.set(g,p*m*v)}const E=new De;E.setAttribute("position",new Yn(w,x)),E.setAttribute("uv",new Yn(S,_)),E.setAttribute("faceIndex",new Yn(y,p)),n.push(new gt(E,null)),s>Zi&&s--}return{lodMeshes:n,sizeLods:t,sigmas:e}}function vd(i,t,e){const n=new Ts(i,t,e);return n.texture.mapping=Qo,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Ks(i,t,e,n,s){i.viewport.set(t,e,n,s),i.scissor.set(t,e,n,s)}function uv(i,t,e){return new Di({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:lv,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:sl(),fragmentShader:`
3608
+
3609
+ precision highp float;
3610
+ precision highp int;
3611
+
3612
+ varying vec3 vOutputDirection;
3613
+
3614
+ uniform sampler2D envMap;
3615
+ uniform float roughness;
3616
+ uniform float mipInt;
3617
+
3618
+ #define ENVMAP_TYPE_CUBE_UV
3619
+ #include <cube_uv_reflection_fragment>
3620
+
3621
+ #define PI 3.14159265359
3622
+
3623
+ // Van der Corput radical inverse
3624
+ float radicalInverse_VdC(uint bits) {
3625
+ bits = (bits << 16u) | (bits >> 16u);
3626
+ bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
3627
+ bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
3628
+ bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
3629
+ bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
3630
+ return float(bits) * 2.3283064365386963e-10; // / 0x100000000
3631
+ }
3632
+
3633
+ // Hammersley sequence
3634
+ vec2 hammersley(uint i, uint N) {
3635
+ return vec2(float(i) / float(N), radicalInverse_VdC(i));
3636
+ }
3637
+
3638
+ // GGX VNDF importance sampling (Eric Heitz 2018)
3639
+ // "Sampling the GGX Distribution of Visible Normals"
3640
+ // https://jcgt.org/published/0007/04/01/
3641
+ vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
3642
+ float alpha = roughness * roughness;
3643
+
3644
+ // Section 3.2: Transform view direction to hemisphere configuration
3645
+ vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
3646
+
3647
+ // Section 4.1: Orthonormal basis
3648
+ float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
3649
+ vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
3650
+ vec3 T2 = cross(Vh, T1);
3651
+
3652
+ // Section 4.2: Parameterization of projected area
3653
+ float r = sqrt(Xi.x);
3654
+ float phi = 2.0 * PI * Xi.y;
3655
+ float t1 = r * cos(phi);
3656
+ float t2 = r * sin(phi);
3657
+ float s = 0.5 * (1.0 + Vh.z);
3658
+ t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
3659
+
3660
+ // Section 4.3: Reprojection onto hemisphere
3661
+ vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
3662
+
3663
+ // Section 3.4: Transform back to ellipsoid configuration
3664
+ return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
3665
+ }
3666
+
3667
+ void main() {
3668
+ vec3 N = normalize(vOutputDirection);
3669
+ vec3 V = N; // Assume view direction equals normal for pre-filtering
3670
+
3671
+ vec3 prefilteredColor = vec3(0.0);
3672
+ float totalWeight = 0.0;
3673
+
3674
+ // For very low roughness, just sample the environment directly
3675
+ if (roughness < 0.001) {
3676
+ gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
3677
+ return;
3678
+ }
3679
+
3680
+ // Tangent space basis for VNDF sampling
3681
+ vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
3682
+ vec3 tangent = normalize(cross(up, N));
3683
+ vec3 bitangent = cross(N, tangent);
3684
+
3685
+ for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
3686
+ vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
3687
+
3688
+ // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
3689
+ vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
3690
+
3691
+ // Transform H back to world space
3692
+ vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
3693
+ vec3 L = normalize(2.0 * dot(V, H) * H - V);
3694
+
3695
+ float NdotL = max(dot(N, L), 0.0);
3696
+
3697
+ if(NdotL > 0.0) {
3698
+ // Sample environment at fixed mip level
3699
+ // VNDF importance sampling handles the distribution filtering
3700
+ vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
3701
+
3702
+ // Weight by NdotL for the split-sum approximation
3703
+ // VNDF PDF naturally accounts for the visible microfacet distribution
3704
+ prefilteredColor += sampleColor * NdotL;
3705
+ totalWeight += NdotL;
3706
+ }
3707
+ }
3708
+
3709
+ if (totalWeight > 0.0) {
3710
+ prefilteredColor = prefilteredColor / totalWeight;
3711
+ }
3712
+
3713
+ gl_FragColor = vec4(prefilteredColor, 1.0);
3714
+ }
3715
+ `,blending:Ai,depthTest:!1,depthWrite:!1})}function dv(i,t,e){const n=new Float32Array(gs),s=new I(0,1,0);return new Di({name:"SphericalGaussianBlur",defines:{n:gs,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:sl(),fragmentShader:`
3601
3716
 
3602
3717
  precision mediump float;
3603
3718
  precision mediump int;
@@ -3657,7 +3772,7 @@ void main() {
3657
3772
  }
3658
3773
 
3659
3774
  }
3660
- `,blending:di,depthTest:!1,depthWrite:!1})}function Pu(){return new _i({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:gc(),fragmentShader:`
3775
+ `,blending:Ai,depthTest:!1,depthWrite:!1})}function yd(){return new Di({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:sl(),fragmentShader:`
3661
3776
 
3662
3777
  precision mediump float;
3663
3778
  precision mediump int;
@@ -3676,7 +3791,7 @@ void main() {
3676
3791
  gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
3677
3792
 
3678
3793
  }
3679
- `,blending:di,depthTest:!1,depthWrite:!1})}function Du(){return new _i({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:gc(),fragmentShader:`
3794
+ `,blending:Ai,depthTest:!1,depthWrite:!1})}function bd(){return new Di({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:sl(),fragmentShader:`
3680
3795
 
3681
3796
  precision mediump float;
3682
3797
  precision mediump int;
@@ -3692,7 +3807,7 @@ void main() {
3692
3807
  gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
3693
3808
 
3694
3809
  }
3695
- `,blending:di,depthTest:!1,depthWrite:!1})}function gc(){return`
3810
+ `,blending:Ai,depthTest:!1,depthWrite:!1})}function sl(){return`
3696
3811
 
3697
3812
  precision mediump float;
3698
3813
  precision mediump int;
@@ -3747,60 +3862,60 @@ void main() {
3747
3862
  gl_Position = vec4( position, 1.0 );
3748
3863
 
3749
3864
  }
3750
- `}function Ug(n){let e=new WeakMap,t=null;function i(a){if(a&&a.isTexture){const l=a.mapping,c=l===ja||l===Ya,u=l===Ar||l===Rr;if(c||u){let h=e.get(a);const d=h!==void 0?h.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==d)return t===null&&(t=new Ru(n)),h=c?t.fromEquirectangular(a,h):t.fromCubemap(a,h),h.texture.pmremVersion=a.pmremVersion,e.set(a,h),h.texture;if(h!==void 0)return h.texture;{const p=a.image;return c&&p&&p.height>0||u&&p&&r(p)?(t===null&&(t=new Ru(n)),h=c?t.fromEquirectangular(a):t.fromCubemap(a),h.texture.pmremVersion=a.pmremVersion,e.set(a,h),a.addEventListener("dispose",s),h.texture):null}}}return a}function r(a){let l=0;const c=6;for(let u=0;u<c;u++)a[u]!==void 0&&l++;return l===c}function s(a){const l=a.target;l.removeEventListener("dispose",s);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:o}}function Fg(n){const e={};function t(i){if(e[i]!==void 0)return e[i];let r;switch(i){case"WEBGL_depth_texture":r=n.getExtension("WEBGL_depth_texture")||n.getExtension("MOZ_WEBGL_depth_texture")||n.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=n.getExtension("EXT_texture_filter_anisotropic")||n.getExtension("MOZ_EXT_texture_filter_anisotropic")||n.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=n.getExtension("WEBGL_compressed_texture_s3tc")||n.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=n.getExtension("WEBGL_compressed_texture_pvrtc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=n.getExtension(i)}return e[i]=r,r}return{has:function(i){return t(i)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(i){const r=t(i);return r===null&&as("THREE.WebGLRenderer: "+i+" extension not supported."),r}}}function Bg(n,e,t,i){const r={},s=new WeakMap;function o(h){const d=h.target;d.index!==null&&e.remove(d.index);for(const g in d.attributes)e.remove(d.attributes[g]);d.removeEventListener("dispose",o),delete r[d.id];const p=s.get(d);p&&(e.remove(p),s.delete(d)),i.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function a(h,d){return r[d.id]===!0||(d.addEventListener("dispose",o),r[d.id]=!0,t.memory.geometries++),d}function l(h){const d=h.attributes;for(const p in d)e.update(d[p],n.ARRAY_BUFFER)}function c(h){const d=[],p=h.index,g=h.attributes.position;let y=0;if(p!==null){const w=p.array;y=p.version;for(let T=0,_=w.length;T<_;T+=3){const S=w[T+0],b=w[T+1],A=w[T+2];d.push(S,b,b,A,A,S)}}else if(g!==void 0){const w=g.array;y=g.version;for(let T=0,_=w.length/3-1;T<_;T+=3){const S=T+0,b=T+1,A=T+2;d.push(S,b,b,A,A,S)}}else return;const m=new(jh(d)?Zh:$h)(d,1);m.version=y;const f=s.get(h);f&&e.remove(f),s.set(h,m)}function u(h){const d=s.get(h);if(d){const p=h.index;p!==null&&d.version<p.version&&c(h)}else c(h);return s.get(h)}return{get:a,update:l,getWireframeAttribute:u}}function zg(n,e,t){let i;function r(d){i=d}let s,o;function a(d){s=d.type,o=d.bytesPerElement}function l(d,p){n.drawElements(i,p,s,d*o),t.update(p,i,1)}function c(d,p,g){g!==0&&(n.drawElementsInstanced(i,p,s,d*o,g),t.update(p,i,g))}function u(d,p,g){if(g===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,p,0,s,d,0,g);let m=0;for(let f=0;f<g;f++)m+=p[f];t.update(m,i,1)}function h(d,p,g,y){if(g===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let f=0;f<d.length;f++)c(d[f]/o,p[f],y[f]);else{m.multiDrawElementsInstancedWEBGL(i,p,0,s,d,0,y,0,g);let f=0;for(let w=0;w<g;w++)f+=p[w]*y[w];t.update(f,i,1)}}this.setMode=r,this.setIndex=a,this.render=l,this.renderInstances=c,this.renderMultiDraw=u,this.renderMultiDrawInstances=h}function Vg(n){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,o,a){switch(t.calls++,o){case n.TRIANGLES:t.triangles+=a*(s/3);break;case n.LINES:t.lines+=a*(s/2);break;case n.LINE_STRIP:t.lines+=a*(s-1);break;case n.LINE_LOOP:t.lines+=a*s;break;case n.POINTS:t.points+=a*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:i}}function Hg(n,e,t){const i=new WeakMap,r=new gt;function s(o,a,l){const c=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,h=u!==void 0?u.length:0;let d=i.get(a);if(d===void 0||d.count!==h){let M=function(){A.dispose(),i.delete(a),a.removeEventListener("dispose",M)};d!==void 0&&d.texture.dispose();const p=a.morphAttributes.position!==void 0,g=a.morphAttributes.normal!==void 0,y=a.morphAttributes.color!==void 0,m=a.morphAttributes.position||[],f=a.morphAttributes.normal||[],w=a.morphAttributes.color||[];let T=0;p===!0&&(T=1),g===!0&&(T=2),y===!0&&(T=3);let _=a.attributes.position.count*T,S=1;_>e.maxTextureSize&&(S=Math.ceil(_/e.maxTextureSize),_=e.maxTextureSize);const b=new Float32Array(_*S*4*h),A=new Yh(b,_,S,h);A.type=Jn,A.needsUpdate=!0;const C=T*4;for(let x=0;x<h;x++){const N=m[x],z=f[x],Y=w[x],q=_*S*4*x;for(let J=0;J<N.count;J++){const K=J*C;p===!0&&(r.fromBufferAttribute(N,J),b[q+K+0]=r.x,b[q+K+1]=r.y,b[q+K+2]=r.z,b[q+K+3]=0),g===!0&&(r.fromBufferAttribute(z,J),b[q+K+4]=r.x,b[q+K+5]=r.y,b[q+K+6]=r.z,b[q+K+7]=0),y===!0&&(r.fromBufferAttribute(Y,J),b[q+K+8]=r.x,b[q+K+9]=r.y,b[q+K+10]=r.z,b[q+K+11]=Y.itemSize===4?r.w:1)}}d={count:h,texture:A,size:new Ne(_,S)},i.set(a,d),a.addEventListener("dispose",M)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)l.getUniforms().setValue(n,"morphTexture",o.morphTexture,t);else{let p=0;for(let y=0;y<c.length;y++)p+=c[y];const g=a.morphTargetsRelative?1:1-p;l.getUniforms().setValue(n,"morphTargetBaseInfluence",g),l.getUniforms().setValue(n,"morphTargetInfluences",c)}l.getUniforms().setValue(n,"morphTargetsTexture",d.texture,t),l.getUniforms().setValue(n,"morphTargetsTextureSize",d.size)}return{update:s}}function kg(n,e,t,i){let r=new WeakMap;function s(l){const c=i.render.frame,u=l.geometry,h=e.get(l,u);if(r.get(h)!==c&&(e.update(h),r.set(h,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",a)===!1&&l.addEventListener("dispose",a),r.get(l)!==c&&(t.update(l.instanceMatrix,n.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,n.ARRAY_BUFFER),r.set(l,c))),l.isSkinnedMesh){const d=l.skeleton;r.get(d)!==c&&(d.update(),r.set(d,c))}return h}function o(){r=new WeakMap}function a(l){const c=l.target;c.removeEventListener("dispose",a),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:s,dispose:o}}const lf=new Xt,Lu=new ef(1,1),cf=new Yh,uf=new fp,hf=new Qh,Ou=[],Iu=[],Nu=new Float32Array(16),Uu=new Float32Array(9),Fu=new Float32Array(4);function Nr(n,e,t){const i=n[0];if(i<=0||i>0)return n;const r=e*t;let s=Ou[r];if(s===void 0&&(s=new Float32Array(r),Ou[r]=s),e!==0){i.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,n[o].toArray(s,a)}return s}function wt(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function At(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function Uo(n,e){let t=Iu[e];t===void 0&&(t=new Int32Array(e),Iu[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function Gg(n,e){const t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function Wg(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(wt(t,e))return;n.uniform2fv(this.addr,e),At(t,e)}}function Xg(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(wt(t,e))return;n.uniform3fv(this.addr,e),At(t,e)}}function jg(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(wt(t,e))return;n.uniform4fv(this.addr,e),At(t,e)}}function Yg(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(wt(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),At(t,e)}else{if(wt(t,i))return;Fu.set(i),n.uniformMatrix2fv(this.addr,!1,Fu),At(t,i)}}function qg(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(wt(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),At(t,e)}else{if(wt(t,i))return;Uu.set(i),n.uniformMatrix3fv(this.addr,!1,Uu),At(t,i)}}function $g(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(wt(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),At(t,e)}else{if(wt(t,i))return;Nu.set(i),n.uniformMatrix4fv(this.addr,!1,Nu),At(t,i)}}function Zg(n,e){const t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function Kg(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(wt(t,e))return;n.uniform2iv(this.addr,e),At(t,e)}}function Jg(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(wt(t,e))return;n.uniform3iv(this.addr,e),At(t,e)}}function Qg(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(wt(t,e))return;n.uniform4iv(this.addr,e),At(t,e)}}function ev(n,e){const t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function tv(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(wt(t,e))return;n.uniform2uiv(this.addr,e),At(t,e)}}function nv(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(wt(t,e))return;n.uniform3uiv(this.addr,e),At(t,e)}}function iv(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(wt(t,e))return;n.uniform4uiv(this.addr,e),At(t,e)}}function rv(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r);let s;this.type===n.SAMPLER_2D_SHADOW?(Lu.compareFunction=Xh,s=Lu):s=lf,t.setTexture2D(e||s,r)}function sv(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture3D(e||uf,r)}function ov(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||hf,r)}function av(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||cf,r)}function lv(n){switch(n){case 5126:return Gg;case 35664:return Wg;case 35665:return Xg;case 35666:return jg;case 35674:return Yg;case 35675:return qg;case 35676:return $g;case 5124:case 35670:return Zg;case 35667:case 35671:return Kg;case 35668:case 35672:return Jg;case 35669:case 35673:return Qg;case 5125:return ev;case 36294:return tv;case 36295:return nv;case 36296:return iv;case 35678:case 36198:case 36298:case 36306:case 35682:return rv;case 35679:case 36299:case 36307:return sv;case 35680:case 36300:case 36308:case 36293:return ov;case 36289:case 36303:case 36311:case 36292:return av}}function cv(n,e){n.uniform1fv(this.addr,e)}function uv(n,e){const t=Nr(e,this.size,2);n.uniform2fv(this.addr,t)}function hv(n,e){const t=Nr(e,this.size,3);n.uniform3fv(this.addr,t)}function fv(n,e){const t=Nr(e,this.size,4);n.uniform4fv(this.addr,t)}function dv(n,e){const t=Nr(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function pv(n,e){const t=Nr(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function mv(n,e){const t=Nr(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function _v(n,e){n.uniform1iv(this.addr,e)}function gv(n,e){n.uniform2iv(this.addr,e)}function vv(n,e){n.uniform3iv(this.addr,e)}function xv(n,e){n.uniform4iv(this.addr,e)}function yv(n,e){n.uniform1uiv(this.addr,e)}function Mv(n,e){n.uniform2uiv(this.addr,e)}function Ev(n,e){n.uniform3uiv(this.addr,e)}function bv(n,e){n.uniform4uiv(this.addr,e)}function Sv(n,e,t){const i=this.cache,r=e.length,s=Uo(t,r);wt(i,s)||(n.uniform1iv(this.addr,s),At(i,s));for(let o=0;o!==r;++o)t.setTexture2D(e[o]||lf,s[o])}function Tv(n,e,t){const i=this.cache,r=e.length,s=Uo(t,r);wt(i,s)||(n.uniform1iv(this.addr,s),At(i,s));for(let o=0;o!==r;++o)t.setTexture3D(e[o]||uf,s[o])}function wv(n,e,t){const i=this.cache,r=e.length,s=Uo(t,r);wt(i,s)||(n.uniform1iv(this.addr,s),At(i,s));for(let o=0;o!==r;++o)t.setTextureCube(e[o]||hf,s[o])}function Av(n,e,t){const i=this.cache,r=e.length,s=Uo(t,r);wt(i,s)||(n.uniform1iv(this.addr,s),At(i,s));for(let o=0;o!==r;++o)t.setTexture2DArray(e[o]||cf,s[o])}function Rv(n){switch(n){case 5126:return cv;case 35664:return uv;case 35665:return hv;case 35666:return fv;case 35674:return dv;case 35675:return pv;case 35676:return mv;case 5124:case 35670:return _v;case 35667:case 35671:return gv;case 35668:case 35672:return vv;case 35669:case 35673:return xv;case 5125:return yv;case 36294:return Mv;case 36295:return Ev;case 36296:return bv;case 35678:case 36198:case 36298:case 36306:case 35682:return Sv;case 35679:case 36299:case 36307:return Tv;case 35680:case 36300:case 36308:case 36293:return wv;case 36289:case 36303:case 36311:case 36292:return Av}}class Cv{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=lv(t.type)}}class Pv{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=Rv(t.type)}}class Dv{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const r=this.seq;for(let s=0,o=r.length;s!==o;++s){const a=r[s];a.setValue(e,t[a.id],i)}}}const Aa=/(\w+)(\])?(\[|\.)?/g;function Bu(n,e){n.seq.push(e),n.map[e.id]=e}function Lv(n,e,t){const i=n.name,r=i.length;for(Aa.lastIndex=0;;){const s=Aa.exec(i),o=Aa.lastIndex;let a=s[1];const l=s[2]==="]",c=s[3];if(l&&(a=a|0),c===void 0||c==="["&&o+2===r){Bu(t,c===void 0?new Cv(a,n,e):new Pv(a,n,e));break}else{let h=t.map[a];h===void 0&&(h=new Dv(a),Bu(t,h)),t=h}}}class co{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<i;++r){const s=e.getActiveUniform(t,r),o=e.getUniformLocation(t,s.name);Lv(s,o,this)}}setValue(e,t,i,r){const s=this.map[t];s!==void 0&&s.setValue(e,i,r)}setOptional(e,t,i){const r=t[i];r!==void 0&&this.setValue(e,i,r)}static upload(e,t,i,r){for(let s=0,o=t.length;s!==o;++s){const a=t[s],l=i[a.id];l.needsUpdate!==!1&&a.setValue(e,l.value,r)}}static seqWithValue(e,t){const i=[];for(let r=0,s=e.length;r!==s;++r){const o=e[r];o.id in t&&i.push(o)}return i}}function zu(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const Ov=37297;let Iv=0;function Nv(n,e){const t=n.split(`
3751
- `),i=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let o=r;o<s;o++){const a=o+1;i.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return i.join(`
3752
- `)}const Vu=new ke;function Uv(n){Qe._getMatrix(Vu,Qe.workingColorSpace,n);const e=`mat3( ${Vu.elements.map(t=>t.toFixed(4))} )`;switch(Qe.getTransfer(n)){case mo:return[e,"LinearTransferOETF"];case nt:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function Hu(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),s=(n.getShaderInfoLog(e)||"").trim();if(i&&s==="")return"";const o=/ERROR: 0:(\d+)/.exec(s);if(o){const a=parseInt(o[1]);return t.toUpperCase()+`
3753
-
3754
- `+s+`
3755
-
3756
- `+Nv(n.getShaderSource(e),a)}else return s}function Fv(n,e){const t=Uv(e);return[`vec4 ${n}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
3757
- `)}function Bv(n,e){let t;switch(e){case Bd:t="Linear";break;case zd:t="Reinhard";break;case Vd:t="Cineon";break;case Hd:t="ACESFilmic";break;case Gd:t="AgX";break;case Wd:t="Neutral";break;case kd:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const qs=new O;function zv(){Qe.getLuminanceCoefficients(qs);const n=qs.x.toFixed(4),e=qs.y.toFixed(4),t=qs.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
3758
- `)}function Vv(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Jr).join(`
3759
- `)}function Hv(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
3760
- `)}function kv(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const s=n.getActiveAttrib(e,r),o=s.name;let a=1;s.type===n.FLOAT_MAT2&&(a=2),s.type===n.FLOAT_MAT3&&(a=3),s.type===n.FLOAT_MAT4&&(a=4),t[o]={type:s.type,location:n.getAttribLocation(e,o),locationSize:a}}return t}function Jr(n){return n!==""}function ku(n,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return n.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,t).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 Gu(n,e){return n.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Gv=/^[ \t]*#include +<([\w\d./]+)>/gm;function wl(n){return n.replace(Gv,Xv)}const Wv=new Map;function Xv(n,e){let t=Ge[e];if(t===void 0){const i=Wv.get(e);if(i!==void 0)t=Ge[i],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return wl(t)}const jv=/#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 Wu(n){return n.replace(jv,Yv)}function Yv(n,e,t,i){let r="";for(let s=parseInt(e);s<parseInt(t);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function Xu(n){let e=`precision ${n.precision} float;
3761
- precision ${n.precision} int;
3762
- precision ${n.precision} sampler2D;
3763
- precision ${n.precision} samplerCube;
3764
- precision ${n.precision} sampler3D;
3765
- precision ${n.precision} sampler2DArray;
3766
- precision ${n.precision} sampler2DShadow;
3767
- precision ${n.precision} samplerCubeShadow;
3768
- precision ${n.precision} sampler2DArrayShadow;
3769
- precision ${n.precision} isampler2D;
3770
- precision ${n.precision} isampler3D;
3771
- precision ${n.precision} isamplerCube;
3772
- precision ${n.precision} isampler2DArray;
3773
- precision ${n.precision} usampler2D;
3774
- precision ${n.precision} usampler3D;
3775
- precision ${n.precision} usamplerCube;
3776
- precision ${n.precision} usampler2DArray;
3777
- `;return n.precision==="highp"?e+=`
3778
- #define HIGH_PRECISION`:n.precision==="mediump"?e+=`
3779
- #define MEDIUM_PRECISION`:n.precision==="lowp"&&(e+=`
3780
- #define LOW_PRECISION`),e}function qv(n){let e="SHADOWMAP_TYPE_BASIC";return n.shadowMapType===Oh?e="SHADOWMAP_TYPE_PCF":n.shadowMapType===gd?e="SHADOWMAP_TYPE_PCF_SOFT":n.shadowMapType===qn&&(e="SHADOWMAP_TYPE_VSM"),e}function $v(n){let e="ENVMAP_TYPE_CUBE";if(n.envMap)switch(n.envMapMode){case Ar:case Rr:e="ENVMAP_TYPE_CUBE";break;case Do:e="ENVMAP_TYPE_CUBE_UV";break}return e}function Zv(n){let e="ENVMAP_MODE_REFLECTION";if(n.envMap)switch(n.envMapMode){case Rr:e="ENVMAP_MODE_REFRACTION";break}return e}function Kv(n){let e="ENVMAP_BLENDING_NONE";if(n.envMap)switch(n.combine){case Ih:e="ENVMAP_BLENDING_MULTIPLY";break;case Ud:e="ENVMAP_BLENDING_MIX";break;case Fd:e="ENVMAP_BLENDING_ADD";break}return e}function Jv(n){const e=n.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:i,maxMip:t}}function Qv(n,e,t,i){const r=n.getContext(),s=t.defines;let o=t.vertexShader,a=t.fragmentShader;const l=qv(t),c=$v(t),u=Zv(t),h=Kv(t),d=Jv(t),p=Vv(t),g=Hv(s),y=r.createProgram();let m,f,w=t.glslVersion?"#version "+t.glslVersion+`
3781
- `:"";t.isRawShaderMaterial?(m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(Jr).join(`
3782
- `),m.length>0&&(m+=`
3783
- `),f=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(Jr).join(`
3784
- `),f.length>0&&(f+=`
3785
- `)):(m=[Xu(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.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"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
3786
- `].filter(Jr).join(`
3787
- `),f=[Xu(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+h:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==pi?"#define TONE_MAPPING":"",t.toneMapping!==pi?Ge.tonemapping_pars_fragment:"",t.toneMapping!==pi?Bv("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ge.colorspace_pars_fragment,Fv("linearToOutputTexel",t.outputColorSpace),zv(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
3788
- `].filter(Jr).join(`
3789
- `)),o=wl(o),o=ku(o,t),o=Gu(o,t),a=wl(a),a=ku(a,t),a=Gu(a,t),o=Wu(o),a=Wu(a),t.isRawShaderMaterial!==!0&&(w=`#version 300 es
3790
- `,m=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
3865
+ `}function fv(i){let t=new WeakMap,e=null;function n(o){if(o&&o.isTexture){const l=o.mapping,c=l===Nc||l===Ic,h=l===Sr||l===Er;if(c||h){let u=t.get(o);const d=u!==void 0?u.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==d)return e===null&&(e=new gd(i)),u=c?e.fromEquirectangular(o,u):e.fromCubemap(o,u),u.texture.pmremVersion=o.pmremVersion,t.set(o,u),u.texture;if(u!==void 0)return u.texture;{const f=o.image;return c&&f&&f.height>0||h&&f&&s(f)?(e===null&&(e=new gd(i)),u=c?e.fromEquirectangular(o):e.fromCubemap(o),u.texture.pmremVersion=o.pmremVersion,t.set(o,u),o.addEventListener("dispose",r),u.texture):null}}}return o}function s(o){let l=0;const c=6;for(let h=0;h<c;h++)o[h]!==void 0&&l++;return l===c}function r(o){const l=o.target;l.removeEventListener("dispose",r);const c=t.get(l);c!==void 0&&(t.delete(l),c.dispose())}function a(){t=new WeakMap,e!==null&&(e.dispose(),e=null)}return{get:n,dispose:a}}function pv(i){const t={};function e(n){if(t[n]!==void 0)return t[n];const s=i.getExtension(n);return t[n]=s,s}return{has:function(n){return e(n)!==null},init:function(){e("EXT_color_buffer_float"),e("WEBGL_clip_cull_distance"),e("OES_texture_float_linear"),e("EXT_color_buffer_half_float"),e("WEBGL_multisampled_render_to_texture"),e("WEBGL_render_shared_exponent")},get:function(n){const s=e(n);return s===null&&ua("WebGLRenderer: "+n+" extension not supported."),s}}}function mv(i,t,e,n){const s={},r=new WeakMap;function a(u){const d=u.target;d.index!==null&&t.remove(d.index);for(const m in d.attributes)t.remove(d.attributes[m]);d.removeEventListener("dispose",a),delete s[d.id];const f=r.get(d);f&&(t.remove(f),r.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,e.memory.geometries--}function o(u,d){return s[d.id]===!0||(d.addEventListener("dispose",a),s[d.id]=!0,e.memory.geometries++),d}function l(u){const d=u.attributes;for(const f in d)t.update(d[f],i.ARRAY_BUFFER)}function c(u){const d=[],f=u.index,m=u.attributes.position;let x=0;if(f!==null){const w=f.array;x=f.version;for(let S=0,y=w.length;S<y;S+=3){const E=w[S+0],v=w[S+1],A=w[S+2];d.push(E,v,v,A,A,E)}}else if(m!==void 0){const w=m.array;x=m.version;for(let S=0,y=w.length/3-1;S<y;S+=3){const E=S+0,v=S+1,A=S+2;d.push(E,v,v,A,A,E)}}else return;const _=new(fp(d)?xp:_p)(d,1);_.version=x;const p=r.get(u);p&&t.remove(p),r.set(u,_)}function h(u){const d=r.get(u);if(d){const f=u.index;f!==null&&d.version<f.version&&c(u)}else c(u);return r.get(u)}return{get:o,update:l,getWireframeAttribute:h}}function _v(i,t,e){let n;function s(d){n=d}let r,a;function o(d){r=d.type,a=d.bytesPerElement}function l(d,f){i.drawElements(n,f,r,d*a),e.update(f,n,1)}function c(d,f,m){m!==0&&(i.drawElementsInstanced(n,f,r,d*a,m),e.update(f,n,m))}function h(d,f,m){if(m===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,f,0,r,d,0,m);let _=0;for(let p=0;p<m;p++)_+=f[p];e.update(_,n,1)}function u(d,f,m,x){if(m===0)return;const _=t.get("WEBGL_multi_draw");if(_===null)for(let p=0;p<d.length;p++)c(d[p]/a,f[p],x[p]);else{_.multiDrawElementsInstancedWEBGL(n,f,0,r,d,0,x,0,m);let p=0;for(let w=0;w<m;w++)p+=f[w]*x[w];e.update(p,n,1)}}this.setMode=s,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=h,this.renderMultiDrawInstances=u}function xv(i){const t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,a,o){switch(e.calls++,a){case i.TRIANGLES:e.triangles+=o*(r/3);break;case i.LINES:e.lines+=o*(r/2);break;case i.LINE_STRIP:e.lines+=o*(r-1);break;case i.LINE_LOOP:e.lines+=o*r;break;case i.POINTS:e.points+=o*r;break;default:Me("WebGLInfo: Unknown draw mode:",a);break}}function s(){e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:s,update:n}}function gv(i,t,e){const n=new WeakMap,s=new Se;function r(a,o,l){const c=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=h!==void 0?h.length:0;let d=n.get(o);if(d===void 0||d.count!==u){let M=function(){A.dispose(),n.delete(o),o.removeEventListener("dispose",M)};d!==void 0&&d.texture.dispose();const f=o.morphAttributes.position!==void 0,m=o.morphAttributes.normal!==void 0,x=o.morphAttributes.color!==void 0,_=o.morphAttributes.position||[],p=o.morphAttributes.normal||[],w=o.morphAttributes.color||[];let S=0;f===!0&&(S=1),m===!0&&(S=2),x===!0&&(S=3);let y=o.attributes.position.count*S,E=1;y>t.maxTextureSize&&(E=Math.ceil(y/t.maxTextureSize),y=t.maxTextureSize);const v=new Float32Array(y*E*4*u),A=new pp(v,y,E,u);A.type=Ti,A.needsUpdate=!0;const R=S*4;for(let g=0;g<u;g++){const O=_[g],F=p[g],k=w[g],G=y*E*4*g;for(let K=0;K<O.count;K++){const tt=K*R;f===!0&&(s.fromBufferAttribute(O,K),v[G+tt+0]=s.x,v[G+tt+1]=s.y,v[G+tt+2]=s.z,v[G+tt+3]=0),m===!0&&(s.fromBufferAttribute(F,K),v[G+tt+4]=s.x,v[G+tt+5]=s.y,v[G+tt+6]=s.z,v[G+tt+7]=0),x===!0&&(s.fromBufferAttribute(k,K),v[G+tt+8]=s.x,v[G+tt+9]=s.y,v[G+tt+10]=s.z,v[G+tt+11]=k.itemSize===4?s.w:1)}}d={count:u,texture:A,size:new Nt(y,E)},n.set(o,d),o.addEventListener("dispose",M)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(i,"morphTexture",a.morphTexture,e);else{let f=0;for(let x=0;x<c.length;x++)f+=c[x];const m=o.morphTargetsRelative?1:1-f;l.getUniforms().setValue(i,"morphTargetBaseInfluence",m),l.getUniforms().setValue(i,"morphTargetInfluences",c)}l.getUniforms().setValue(i,"morphTargetsTexture",d.texture,e),l.getUniforms().setValue(i,"morphTargetsTextureSize",d.size)}return{update:r}}function vv(i,t,e,n){let s=new WeakMap;function r(l){const c=n.render.frame,h=l.geometry,u=t.get(l,h);if(s.get(u)!==c&&(t.update(u),s.set(u,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),s.get(l)!==c&&(e.update(l.instanceMatrix,i.ARRAY_BUFFER),l.instanceColor!==null&&e.update(l.instanceColor,i.ARRAY_BUFFER),s.set(l,c))),l.isSkinnedMesh){const d=l.skeleton;s.get(d)!==c&&(d.update(),s.set(d,c))}return u}function a(){s=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),e.remove(c.instanceMatrix),c.instanceColor!==null&&e.remove(c.instanceColor)}return{update:r,dispose:a}}const Cp=new Je,Md=new bp(1,1),Rp=new pp,Pp=new k0,Dp=new yp,Sd=[],Ed=[],wd=new Float32Array(16),Td=new Float32Array(9),Ad=new Float32Array(4);function Lr(i,t,e){const n=i[0];if(n<=0||n>0)return i;const s=t*e;let r=Sd[s];if(r===void 0&&(r=new Float32Array(s),Sd[s]=r),t!==0){n.toArray(r,0);for(let a=1,o=0;a!==t;++a)o+=e,i[a].toArray(r,o)}return r}function Ne(i,t){if(i.length!==t.length)return!1;for(let e=0,n=i.length;e<n;e++)if(i[e]!==t[e])return!1;return!0}function Ie(i,t){for(let e=0,n=t.length;e<n;e++)i[e]=t[e]}function rl(i,t){let e=Ed[t];e===void 0&&(e=new Int32Array(t),Ed[t]=e);for(let n=0;n!==t;++n)e[n]=i.allocateTextureUnit();return e}function yv(i,t){const e=this.cache;e[0]!==t&&(i.uniform1f(this.addr,t),e[0]=t)}function bv(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Ne(e,t))return;i.uniform2fv(this.addr,t),Ie(e,t)}}function Mv(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3f(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else if(t.r!==void 0)(e[0]!==t.r||e[1]!==t.g||e[2]!==t.b)&&(i.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(Ne(e,t))return;i.uniform3fv(this.addr,t),Ie(e,t)}}function Sv(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4f(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Ne(e,t))return;i.uniform4fv(this.addr,t),Ie(e,t)}}function Ev(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(Ne(e,t))return;i.uniformMatrix2fv(this.addr,!1,t),Ie(e,t)}else{if(Ne(e,n))return;Ad.set(n),i.uniformMatrix2fv(this.addr,!1,Ad),Ie(e,n)}}function wv(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(Ne(e,t))return;i.uniformMatrix3fv(this.addr,!1,t),Ie(e,t)}else{if(Ne(e,n))return;Td.set(n),i.uniformMatrix3fv(this.addr,!1,Td),Ie(e,n)}}function Tv(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(Ne(e,t))return;i.uniformMatrix4fv(this.addr,!1,t),Ie(e,t)}else{if(Ne(e,n))return;wd.set(n),i.uniformMatrix4fv(this.addr,!1,wd),Ie(e,n)}}function Av(i,t){const e=this.cache;e[0]!==t&&(i.uniform1i(this.addr,t),e[0]=t)}function Cv(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2i(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Ne(e,t))return;i.uniform2iv(this.addr,t),Ie(e,t)}}function Rv(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3i(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(Ne(e,t))return;i.uniform3iv(this.addr,t),Ie(e,t)}}function Pv(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4i(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Ne(e,t))return;i.uniform4iv(this.addr,t),Ie(e,t)}}function Dv(i,t){const e=this.cache;e[0]!==t&&(i.uniform1ui(this.addr,t),e[0]=t)}function Ov(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2ui(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Ne(e,t))return;i.uniform2uiv(this.addr,t),Ie(e,t)}}function Lv(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3ui(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(Ne(e,t))return;i.uniform3uiv(this.addr,t),Ie(e,t)}}function Nv(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4ui(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Ne(e,t))return;i.uniform4uiv(this.addr,t),Ie(e,t)}}function Iv(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let r;this.type===i.SAMPLER_2D_SHADOW?(Md.compareFunction=dp,r=Md):r=Cp,e.setTexture2D(t||r,s)}function Uv(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture3D(t||Pp,s)}function Fv(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTextureCube(t||Dp,s)}function zv(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture2DArray(t||Rp,s)}function Bv(i){switch(i){case 5126:return yv;case 35664:return bv;case 35665:return Mv;case 35666:return Sv;case 35674:return Ev;case 35675:return wv;case 35676:return Tv;case 5124:case 35670:return Av;case 35667:case 35671:return Cv;case 35668:case 35672:return Rv;case 35669:case 35673:return Pv;case 5125:return Dv;case 36294:return Ov;case 36295:return Lv;case 36296:return Nv;case 35678:case 36198:case 36298:case 36306:case 35682:return Iv;case 35679:case 36299:case 36307:return Uv;case 35680:case 36300:case 36308:case 36293:return Fv;case 36289:case 36303:case 36311:case 36292:return zv}}function kv(i,t){i.uniform1fv(this.addr,t)}function Vv(i,t){const e=Lr(t,this.size,2);i.uniform2fv(this.addr,e)}function Hv(i,t){const e=Lr(t,this.size,3);i.uniform3fv(this.addr,e)}function Gv(i,t){const e=Lr(t,this.size,4);i.uniform4fv(this.addr,e)}function Wv(i,t){const e=Lr(t,this.size,4);i.uniformMatrix2fv(this.addr,!1,e)}function Xv(i,t){const e=Lr(t,this.size,9);i.uniformMatrix3fv(this.addr,!1,e)}function jv(i,t){const e=Lr(t,this.size,16);i.uniformMatrix4fv(this.addr,!1,e)}function Yv(i,t){i.uniform1iv(this.addr,t)}function qv(i,t){i.uniform2iv(this.addr,t)}function Zv(i,t){i.uniform3iv(this.addr,t)}function $v(i,t){i.uniform4iv(this.addr,t)}function Kv(i,t){i.uniform1uiv(this.addr,t)}function Jv(i,t){i.uniform2uiv(this.addr,t)}function Qv(i,t){i.uniform3uiv(this.addr,t)}function ty(i,t){i.uniform4uiv(this.addr,t)}function ey(i,t,e){const n=this.cache,s=t.length,r=rl(e,s);Ne(n,r)||(i.uniform1iv(this.addr,r),Ie(n,r));for(let a=0;a!==s;++a)e.setTexture2D(t[a]||Cp,r[a])}function ny(i,t,e){const n=this.cache,s=t.length,r=rl(e,s);Ne(n,r)||(i.uniform1iv(this.addr,r),Ie(n,r));for(let a=0;a!==s;++a)e.setTexture3D(t[a]||Pp,r[a])}function iy(i,t,e){const n=this.cache,s=t.length,r=rl(e,s);Ne(n,r)||(i.uniform1iv(this.addr,r),Ie(n,r));for(let a=0;a!==s;++a)e.setTextureCube(t[a]||Dp,r[a])}function sy(i,t,e){const n=this.cache,s=t.length,r=rl(e,s);Ne(n,r)||(i.uniform1iv(this.addr,r),Ie(n,r));for(let a=0;a!==s;++a)e.setTexture2DArray(t[a]||Rp,r[a])}function ry(i){switch(i){case 5126:return kv;case 35664:return Vv;case 35665:return Hv;case 35666:return Gv;case 35674:return Wv;case 35675:return Xv;case 35676:return jv;case 5124:case 35670:return Yv;case 35667:case 35671:return qv;case 35668:case 35672:return Zv;case 35669:case 35673:return $v;case 5125:return Kv;case 36294:return Jv;case 36295:return Qv;case 36296:return ty;case 35678:case 36198:case 36298:case 36306:case 35682:return ey;case 35679:case 36299:case 36307:return ny;case 35680:case 36300:case 36308:case 36293:return iy;case 36289:case 36303:case 36311:case 36292:return sy}}class ay{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=Bv(e.type)}}class oy{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=ry(e.type)}}class ly{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){const s=this.seq;for(let r=0,a=s.length;r!==a;++r){const o=s[r];o.setValue(t,e[o.id],n)}}}const Jl=/(\w+)(\])?(\[|\.)?/g;function Cd(i,t){i.seq.push(t),i.map[t.id]=t}function cy(i,t,e){const n=i.name,s=n.length;for(Jl.lastIndex=0;;){const r=Jl.exec(n),a=Jl.lastIndex;let o=r[1];const l=r[2]==="]",c=r[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===s){Cd(e,c===void 0?new ay(o,i,t):new oy(o,i,t));break}else{let u=e.map[o];u===void 0&&(u=new ly(o),Cd(e,u)),e=u}}}class Po{constructor(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){const r=t.getActiveUniform(e,s),a=t.getUniformLocation(e,r.name);cy(r,a,this)}}setValue(t,e,n,s){const r=this.map[e];r!==void 0&&r.setValue(t,n,s)}setOptional(t,e,n){const s=e[n];s!==void 0&&this.setValue(t,n,s)}static upload(t,e,n,s){for(let r=0,a=e.length;r!==a;++r){const o=e[r],l=n[o.id];l.needsUpdate!==!1&&o.setValue(t,l.value,s)}}static seqWithValue(t,e){const n=[];for(let s=0,r=t.length;s!==r;++s){const a=t[s];a.id in e&&n.push(a)}return n}}function Rd(i,t,e){const n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}const hy=37297;let uy=0;function dy(i,t){const e=i.split(`
3866
+ `),n=[],s=Math.max(t-6,0),r=Math.min(t+6,e.length);for(let a=s;a<r;a++){const o=a+1;n.push(`${o===t?">":" "} ${o}: ${e[a]}`)}return n.join(`
3867
+ `)}const Pd=new Gt;function fy(i){te._getMatrix(Pd,te.workingColorSpace,i);const t=`mat3( ${Pd.elements.map(e=>e.toFixed(4))} )`;switch(te.getTransfer(i)){case Io:return[t,"LinearTransferOETF"];case ae:return[t,"sRGBTransferOETF"];default:return kt("WebGLProgram: Unsupported color space: ",i),[t,"LinearTransferOETF"]}}function Dd(i,t,e){const n=i.getShaderParameter(t,i.COMPILE_STATUS),r=(i.getShaderInfoLog(t)||"").trim();if(n&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return e.toUpperCase()+`
3868
+
3869
+ `+r+`
3870
+
3871
+ `+dy(i.getShaderSource(t),o)}else return r}function py(i,t){const e=fy(t);return[`vec4 ${i}( vec4 value ) {`,` return ${e[1]}( vec4( value.rgb * ${e[0]}, value.a ) );`,"}"].join(`
3872
+ `)}function my(i,t){let e;switch(t){case d0:e="Linear";break;case f0:e="Reinhard";break;case p0:e="Cineon";break;case m0:e="ACESFilmic";break;case x0:e="AgX";break;case g0:e="Neutral";break;case _0:e="Custom";break;default:kt("WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+i+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}const to=new I;function _y(){te.getLuminanceCoefficients(to);const i=to.x.toFixed(4),t=to.y.toFixed(4),e=to.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${t}, ${e} );`," return dot( weights, rgb );","}"].join(`
3873
+ `)}function xy(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(na).join(`
3874
+ `)}function gy(i){const t=[];for(const e in i){const n=i[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(`
3875
+ `)}function vy(i,t){const e={},n=i.getProgramParameter(t,i.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){const r=i.getActiveAttrib(t,s),a=r.name;let o=1;r.type===i.FLOAT_MAT2&&(o=2),r.type===i.FLOAT_MAT3&&(o=3),r.type===i.FLOAT_MAT4&&(o=4),e[a]={type:r.type,location:i.getAttribLocation(t,a),locationSize:o}}return e}function na(i){return i!==""}function Od(i,t){const e=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,e).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Ld(i,t){return i.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const yy=/^[ \t]*#include +<([\w\d./]+)>/gm;function ph(i){return i.replace(yy,My)}const by=new Map;function My(i,t){let e=Xt[t];if(e===void 0){const n=by.get(t);if(n!==void 0)e=Xt[n],kt('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("Can not resolve #include <"+t+">")}return ph(e)}const Sy=/#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 Nd(i){return i.replace(Sy,Ey)}function Ey(i,t,e,n){let s="";for(let r=parseInt(t);r<parseInt(e);r++)s+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function Id(i){let t=`precision ${i.precision} float;
3876
+ precision ${i.precision} int;
3877
+ precision ${i.precision} sampler2D;
3878
+ precision ${i.precision} samplerCube;
3879
+ precision ${i.precision} sampler3D;
3880
+ precision ${i.precision} sampler2DArray;
3881
+ precision ${i.precision} sampler2DShadow;
3882
+ precision ${i.precision} samplerCubeShadow;
3883
+ precision ${i.precision} sampler2DArrayShadow;
3884
+ precision ${i.precision} isampler2D;
3885
+ precision ${i.precision} isampler3D;
3886
+ precision ${i.precision} isamplerCube;
3887
+ precision ${i.precision} isampler2DArray;
3888
+ precision ${i.precision} usampler2D;
3889
+ precision ${i.precision} usampler3D;
3890
+ precision ${i.precision} usamplerCube;
3891
+ precision ${i.precision} usampler2DArray;
3892
+ `;return i.precision==="highp"?t+=`
3893
+ #define HIGH_PRECISION`:i.precision==="mediump"?t+=`
3894
+ #define MEDIUM_PRECISION`:i.precision==="lowp"&&(t+=`
3895
+ #define LOW_PRECISION`),t}function wy(i){let t="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===ep?t="SHADOWMAP_TYPE_PCF":i.shadowMapType===Xm?t="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===bi&&(t="SHADOWMAP_TYPE_VSM"),t}function Ty(i){let t="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case Sr:case Er:t="ENVMAP_TYPE_CUBE";break;case Qo:t="ENVMAP_TYPE_CUBE_UV";break}return t}function Ay(i){let t="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case Er:t="ENVMAP_MODE_REFRACTION";break}return t}function Cy(i){let t="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case np:t="ENVMAP_BLENDING_MULTIPLY";break;case h0:t="ENVMAP_BLENDING_MIX";break;case u0:t="ENVMAP_BLENDING_ADD";break}return t}function Ry(i){const t=i.envMapCubeUVHeight;if(t===null)return null;const e=Math.log2(t)-2,n=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:n,maxMip:e}}function Py(i,t,e,n){const s=i.getContext(),r=e.defines;let a=e.vertexShader,o=e.fragmentShader;const l=wy(e),c=Ty(e),h=Ay(e),u=Cy(e),d=Ry(e),f=xy(e),m=gy(r),x=s.createProgram();let _,p,w=e.glslVersion?"#version "+e.glslVersion+`
3896
+ `:"";e.isRawShaderMaterial?(_=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m].filter(na).join(`
3897
+ `),_.length>0&&(_+=`
3898
+ `),p=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m].filter(na).join(`
3899
+ `),p.length>0&&(p+=`
3900
+ `)):(_=[Id(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m,e.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",e.batching?"#define USE_BATCHING":"",e.batchingColor?"#define USE_BATCHING_COLOR":"",e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.instancingMorph?"#define USE_INSTANCING_MORPH":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+h:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.displacementMap?"#define USE_DISPLACEMENTMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.mapUv?"#define MAP_UV "+e.mapUv:"",e.alphaMapUv?"#define ALPHAMAP_UV "+e.alphaMapUv:"",e.lightMapUv?"#define LIGHTMAP_UV "+e.lightMapUv:"",e.aoMapUv?"#define AOMAP_UV "+e.aoMapUv:"",e.emissiveMapUv?"#define EMISSIVEMAP_UV "+e.emissiveMapUv:"",e.bumpMapUv?"#define BUMPMAP_UV "+e.bumpMapUv:"",e.normalMapUv?"#define NORMALMAP_UV "+e.normalMapUv:"",e.displacementMapUv?"#define DISPLACEMENTMAP_UV "+e.displacementMapUv:"",e.metalnessMapUv?"#define METALNESSMAP_UV "+e.metalnessMapUv:"",e.roughnessMapUv?"#define ROUGHNESSMAP_UV "+e.roughnessMapUv:"",e.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+e.anisotropyMapUv:"",e.clearcoatMapUv?"#define CLEARCOATMAP_UV "+e.clearcoatMapUv:"",e.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+e.clearcoatNormalMapUv:"",e.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+e.clearcoatRoughnessMapUv:"",e.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+e.iridescenceMapUv:"",e.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+e.iridescenceThicknessMapUv:"",e.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+e.sheenColorMapUv:"",e.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+e.sheenRoughnessMapUv:"",e.specularMapUv?"#define SPECULARMAP_UV "+e.specularMapUv:"",e.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+e.specularColorMapUv:"",e.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+e.specularIntensityMapUv:"",e.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+e.transmissionMapUv:"",e.thicknessMapUv?"#define THICKNESSMAP_UV "+e.thicknessMapUv:"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.morphColors?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",e.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"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
3901
+ `].filter(na).join(`
3902
+ `),p=[Id(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+c:"",e.envMap?"#define "+h:"",e.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.dispersion?"#define USE_DISPERSION":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor||e.batchingColor?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",e.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",e.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==Ki?"#define TONE_MAPPING":"",e.toneMapping!==Ki?Xt.tonemapping_pars_fragment:"",e.toneMapping!==Ki?my("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",Xt.colorspace_pars_fragment,py("linearToOutputTexel",e.outputColorSpace),_y(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`
3903
+ `].filter(na).join(`
3904
+ `)),a=ph(a),a=Od(a,e),a=Ld(a,e),o=ph(o),o=Od(o,e),o=Ld(o,e),a=Nd(a),o=Nd(o),e.isRawShaderMaterial!==!0&&(w=`#version 300 es
3905
+ `,_=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`
3791
3906
  `)+`
3792
- `+m,f=["#define varying in",t.glslVersion===Kc?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Kc?"":"#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(`
3907
+ `+_,p=["#define varying in",e.glslVersion===Vu?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===Vu?"":"#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(`
3793
3908
  `)+`
3794
- `+f);const T=w+m+o,_=w+f+a,S=zu(r,r.VERTEX_SHADER,T),b=zu(r,r.FRAGMENT_SHADER,_);r.attachShader(y,S),r.attachShader(y,b),t.index0AttributeName!==void 0?r.bindAttribLocation(y,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(y,0,"position"),r.linkProgram(y);function A(N){if(n.debug.checkShaderErrors){const z=r.getProgramInfoLog(y)||"",Y=r.getShaderInfoLog(S)||"",q=r.getShaderInfoLog(b)||"",J=z.trim(),K=Y.trim(),se=q.trim();let $=!0,le=!0;if(r.getProgramParameter(y,r.LINK_STATUS)===!1)if($=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(r,y,S,b);else{const me=Hu(r,S,"vertex"),Ee=Hu(r,b,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(y,r.VALIDATE_STATUS)+`
3909
+ `+p);const S=w+_+a,y=w+p+o,E=Rd(s,s.VERTEX_SHADER,S),v=Rd(s,s.FRAGMENT_SHADER,y);s.attachShader(x,E),s.attachShader(x,v),e.index0AttributeName!==void 0?s.bindAttribLocation(x,0,e.index0AttributeName):e.morphTargets===!0&&s.bindAttribLocation(x,0,"position"),s.linkProgram(x);function A(O){if(i.debug.checkShaderErrors){const F=s.getProgramInfoLog(x)||"",k=s.getShaderInfoLog(E)||"",G=s.getShaderInfoLog(v)||"",K=F.trim(),tt=k.trim(),lt=G.trim();let $=!0,st=!0;if(s.getProgramParameter(x,s.LINK_STATUS)===!1)if($=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,x,E,v);else{const ct=Dd(s,E,"vertex"),Et=Dd(s,v,"fragment");Me("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(x,s.VALIDATE_STATUS)+`
3795
3910
 
3796
- Material Name: `+N.name+`
3797
- Material Type: `+N.type+`
3911
+ Material Name: `+O.name+`
3912
+ Material Type: `+O.type+`
3798
3913
 
3799
- Program Info Log: `+J+`
3800
- `+me+`
3801
- `+Ee)}else J!==""?console.warn("THREE.WebGLProgram: Program Info Log:",J):(K===""||se==="")&&(le=!1);le&&(N.diagnostics={runnable:$,programLog:J,vertexShader:{log:K,prefix:m},fragmentShader:{log:se,prefix:f}})}r.deleteShader(S),r.deleteShader(b),C=new co(r,y),M=kv(r,y)}let C;this.getUniforms=function(){return C===void 0&&A(this),C};let M;this.getAttributes=function(){return M===void 0&&A(this),M};let x=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return x===!1&&(x=r.getProgramParameter(y,Ov)),x},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(y),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Iv++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=S,this.fragmentShader=b,this}let e0=0;class t0{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(i),o=this._getShaderCacheForMaterial(e);return o.has(r)===!1&&(o.add(r),r.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new n0(e),t.set(e,i)),i}}class n0{constructor(e){this.id=e0++,this.code=e,this.usedTimes=0}}function i0(n,e,t,i,r,s,o){const a=new uc,l=new t0,c=new Set,u=[],h=r.logarithmicDepthBuffer,d=r.vertexTextures;let p=r.precision;const g={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(M){return c.add(M),M===0?"uv":`uv${M}`}function m(M,x,N,z,Y){const q=z.fog,J=Y.geometry,K=M.isMeshStandardMaterial?z.environment:null,se=(M.isMeshStandardMaterial?t:e).get(M.envMap||K),$=se&&se.mapping===Do?se.image.height:null,le=g[M.type];M.precision!==null&&(p=r.getMaxPrecision(M.precision),p!==M.precision&&console.warn("THREE.WebGLProgram.getParameters:",M.precision,"not supported, using",p,"instead."));const me=J.morphAttributes.position||J.morphAttributes.normal||J.morphAttributes.color,Ee=me!==void 0?me.length:0;let Be=0;J.morphAttributes.position!==void 0&&(Be=1),J.morphAttributes.normal!==void 0&&(Be=2),J.morphAttributes.color!==void 0&&(Be=3);let de,qe,Ke,Z;if(le){const $e=In[le];de=$e.vertexShader,qe=$e.fragmentShader}else de=M.vertexShader,qe=M.fragmentShader,l.update(M),Ke=l.getVertexShaderID(M),Z=l.getFragmentShaderID(M);const oe=n.getRenderTarget(),Me=n.state.buffers.depth.getReversed(),Ie=Y.isInstancedMesh===!0,Ce=Y.isBatchedMesh===!0,ze=!!M.map,St=!!M.matcap,L=!!se,rt=!!M.aoMap,Ve=!!M.lightMap,De=!!M.bumpMap,be=!!M.normalMap,st=!!M.displacementMap,Se=!!M.emissiveMap,He=!!M.metalnessMap,vt=!!M.roughnessMap,ut=M.anisotropy>0,R=M.clearcoat>0,v=M.dispersion>0,H=M.iridescence>0,ne=M.sheen>0,re=M.transmission>0,te=ut&&!!M.anisotropyMap,Re=R&&!!M.clearcoatMap,fe=R&&!!M.clearcoatNormalMap,Te=R&&!!M.clearcoatRoughnessMap,I=H&&!!M.iridescenceMap,P=H&&!!M.iridescenceThicknessMap,U=ne&&!!M.sheenColorMap,Q=ne&&!!M.sheenRoughnessMap,ie=!!M.specularMap,ae=!!M.specularColorMap,we=!!M.specularIntensityMap,D=re&&!!M.transmissionMap,V=re&&!!M.thicknessMap,G=!!M.gradientMap,ee=!!M.alphaMap,k=M.alphaTest>0,W=!!M.alphaHash,ue=!!M.extensions;let xe=pi;M.toneMapped&&(oe===null||oe.isXRRenderTarget===!0)&&(xe=n.toneMapping);const We={shaderID:le,shaderType:M.type,shaderName:M.name,vertexShader:de,fragmentShader:qe,defines:M.defines,customVertexShaderID:Ke,customFragmentShaderID:Z,isRawShaderMaterial:M.isRawShaderMaterial===!0,glslVersion:M.glslVersion,precision:p,batching:Ce,batchingColor:Ce&&Y._colorsTexture!==null,instancing:Ie,instancingColor:Ie&&Y.instanceColor!==null,instancingMorph:Ie&&Y.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:oe===null?n.outputColorSpace:oe.isXRRenderTarget===!0?oe.texture.colorSpace:Cr,alphaToCoverage:!!M.alphaToCoverage,map:ze,matcap:St,envMap:L,envMapMode:L&&se.mapping,envMapCubeUVHeight:$,aoMap:rt,lightMap:Ve,bumpMap:De,normalMap:be,displacementMap:d&&st,emissiveMap:Se,normalMapObjectSpace:be&&M.normalMapType===qd,normalMapTangentSpace:be&&M.normalMapType===Wh,metalnessMap:He,roughnessMap:vt,anisotropy:ut,anisotropyMap:te,clearcoat:R,clearcoatMap:Re,clearcoatNormalMap:fe,clearcoatRoughnessMap:Te,dispersion:v,iridescence:H,iridescenceMap:I,iridescenceThicknessMap:P,sheen:ne,sheenColorMap:U,sheenRoughnessMap:Q,specularMap:ie,specularColorMap:ae,specularIntensityMap:we,transmission:re,transmissionMap:D,thicknessMap:V,gradientMap:G,opaque:M.transparent===!1&&M.blending===Er&&M.alphaToCoverage===!1,alphaMap:ee,alphaTest:k,alphaHash:W,combine:M.combine,mapUv:ze&&y(M.map.channel),aoMapUv:rt&&y(M.aoMap.channel),lightMapUv:Ve&&y(M.lightMap.channel),bumpMapUv:De&&y(M.bumpMap.channel),normalMapUv:be&&y(M.normalMap.channel),displacementMapUv:st&&y(M.displacementMap.channel),emissiveMapUv:Se&&y(M.emissiveMap.channel),metalnessMapUv:He&&y(M.metalnessMap.channel),roughnessMapUv:vt&&y(M.roughnessMap.channel),anisotropyMapUv:te&&y(M.anisotropyMap.channel),clearcoatMapUv:Re&&y(M.clearcoatMap.channel),clearcoatNormalMapUv:fe&&y(M.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Te&&y(M.clearcoatRoughnessMap.channel),iridescenceMapUv:I&&y(M.iridescenceMap.channel),iridescenceThicknessMapUv:P&&y(M.iridescenceThicknessMap.channel),sheenColorMapUv:U&&y(M.sheenColorMap.channel),sheenRoughnessMapUv:Q&&y(M.sheenRoughnessMap.channel),specularMapUv:ie&&y(M.specularMap.channel),specularColorMapUv:ae&&y(M.specularColorMap.channel),specularIntensityMapUv:we&&y(M.specularIntensityMap.channel),transmissionMapUv:D&&y(M.transmissionMap.channel),thicknessMapUv:V&&y(M.thicknessMap.channel),alphaMapUv:ee&&y(M.alphaMap.channel),vertexTangents:!!J.attributes.tangent&&(be||ut),vertexColors:M.vertexColors,vertexAlphas:M.vertexColors===!0&&!!J.attributes.color&&J.attributes.color.itemSize===4,pointsUvs:Y.isPoints===!0&&!!J.attributes.uv&&(ze||ee),fog:!!q,useFog:M.fog===!0,fogExp2:!!q&&q.isFogExp2,flatShading:M.flatShading===!0&&M.wireframe===!1,sizeAttenuation:M.sizeAttenuation===!0,logarithmicDepthBuffer:h,reversedDepthBuffer:Me,skinning:Y.isSkinnedMesh===!0,morphTargets:J.morphAttributes.position!==void 0,morphNormals:J.morphAttributes.normal!==void 0,morphColors:J.morphAttributes.color!==void 0,morphTargetsCount:Ee,morphTextureStride:Be,numDirLights:x.directional.length,numPointLights:x.point.length,numSpotLights:x.spot.length,numSpotLightMaps:x.spotLightMap.length,numRectAreaLights:x.rectArea.length,numHemiLights:x.hemi.length,numDirLightShadows:x.directionalShadowMap.length,numPointLightShadows:x.pointShadowMap.length,numSpotLightShadows:x.spotShadowMap.length,numSpotLightShadowsWithMaps:x.numSpotLightShadowsWithMaps,numLightProbes:x.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:M.dithering,shadowMapEnabled:n.shadowMap.enabled&&N.length>0,shadowMapType:n.shadowMap.type,toneMapping:xe,decodeVideoTexture:ze&&M.map.isVideoTexture===!0&&Qe.getTransfer(M.map.colorSpace)===nt,decodeVideoTextureEmissive:Se&&M.emissiveMap.isVideoTexture===!0&&Qe.getTransfer(M.emissiveMap.colorSpace)===nt,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===Nn,flipSided:M.side===Wt,useDepthPacking:M.depthPacking>=0,depthPacking:M.depthPacking||0,index0AttributeName:M.index0AttributeName,extensionClipCullDistance:ue&&M.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ue&&M.extensions.multiDraw===!0||Ce)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:M.customProgramCacheKey()};return We.vertexUv1s=c.has(1),We.vertexUv2s=c.has(2),We.vertexUv3s=c.has(3),c.clear(),We}function f(M){const x=[];if(M.shaderID?x.push(M.shaderID):(x.push(M.customVertexShaderID),x.push(M.customFragmentShaderID)),M.defines!==void 0)for(const N in M.defines)x.push(N),x.push(M.defines[N]);return M.isRawShaderMaterial===!1&&(w(x,M),T(x,M),x.push(n.outputColorSpace)),x.push(M.customProgramCacheKey),x.join()}function w(M,x){M.push(x.precision),M.push(x.outputColorSpace),M.push(x.envMapMode),M.push(x.envMapCubeUVHeight),M.push(x.mapUv),M.push(x.alphaMapUv),M.push(x.lightMapUv),M.push(x.aoMapUv),M.push(x.bumpMapUv),M.push(x.normalMapUv),M.push(x.displacementMapUv),M.push(x.emissiveMapUv),M.push(x.metalnessMapUv),M.push(x.roughnessMapUv),M.push(x.anisotropyMapUv),M.push(x.clearcoatMapUv),M.push(x.clearcoatNormalMapUv),M.push(x.clearcoatRoughnessMapUv),M.push(x.iridescenceMapUv),M.push(x.iridescenceThicknessMapUv),M.push(x.sheenColorMapUv),M.push(x.sheenRoughnessMapUv),M.push(x.specularMapUv),M.push(x.specularColorMapUv),M.push(x.specularIntensityMapUv),M.push(x.transmissionMapUv),M.push(x.thicknessMapUv),M.push(x.combine),M.push(x.fogExp2),M.push(x.sizeAttenuation),M.push(x.morphTargetsCount),M.push(x.morphAttributeCount),M.push(x.numDirLights),M.push(x.numPointLights),M.push(x.numSpotLights),M.push(x.numSpotLightMaps),M.push(x.numHemiLights),M.push(x.numRectAreaLights),M.push(x.numDirLightShadows),M.push(x.numPointLightShadows),M.push(x.numSpotLightShadows),M.push(x.numSpotLightShadowsWithMaps),M.push(x.numLightProbes),M.push(x.shadowMapType),M.push(x.toneMapping),M.push(x.numClippingPlanes),M.push(x.numClipIntersection),M.push(x.depthPacking)}function T(M,x){a.disableAll(),x.supportsVertexTextures&&a.enable(0),x.instancing&&a.enable(1),x.instancingColor&&a.enable(2),x.instancingMorph&&a.enable(3),x.matcap&&a.enable(4),x.envMap&&a.enable(5),x.normalMapObjectSpace&&a.enable(6),x.normalMapTangentSpace&&a.enable(7),x.clearcoat&&a.enable(8),x.iridescence&&a.enable(9),x.alphaTest&&a.enable(10),x.vertexColors&&a.enable(11),x.vertexAlphas&&a.enable(12),x.vertexUv1s&&a.enable(13),x.vertexUv2s&&a.enable(14),x.vertexUv3s&&a.enable(15),x.vertexTangents&&a.enable(16),x.anisotropy&&a.enable(17),x.alphaHash&&a.enable(18),x.batching&&a.enable(19),x.dispersion&&a.enable(20),x.batchingColor&&a.enable(21),x.gradientMap&&a.enable(22),M.push(a.mask),a.disableAll(),x.fog&&a.enable(0),x.useFog&&a.enable(1),x.flatShading&&a.enable(2),x.logarithmicDepthBuffer&&a.enable(3),x.reversedDepthBuffer&&a.enable(4),x.skinning&&a.enable(5),x.morphTargets&&a.enable(6),x.morphNormals&&a.enable(7),x.morphColors&&a.enable(8),x.premultipliedAlpha&&a.enable(9),x.shadowMapEnabled&&a.enable(10),x.doubleSided&&a.enable(11),x.flipSided&&a.enable(12),x.useDepthPacking&&a.enable(13),x.dithering&&a.enable(14),x.transmission&&a.enable(15),x.sheen&&a.enable(16),x.opaque&&a.enable(17),x.pointsUvs&&a.enable(18),x.decodeVideoTexture&&a.enable(19),x.decodeVideoTextureEmissive&&a.enable(20),x.alphaToCoverage&&a.enable(21),M.push(a.mask)}function _(M){const x=g[M.type];let N;if(x){const z=In[x];N=Tp.clone(z.uniforms)}else N=M.uniforms;return N}function S(M,x){let N;for(let z=0,Y=u.length;z<Y;z++){const q=u[z];if(q.cacheKey===x){N=q,++N.usedTimes;break}}return N===void 0&&(N=new Qv(n,x,M,s),u.push(N)),N}function b(M){if(--M.usedTimes===0){const x=u.indexOf(M);u[x]=u[u.length-1],u.pop(),M.destroy()}}function A(M){l.remove(M)}function C(){l.dispose()}return{getParameters:m,getProgramCacheKey:f,getUniforms:_,acquireProgram:S,releaseProgram:b,releaseShaderCache:A,programs:u,dispose:C}}function r0(){let n=new WeakMap;function e(o){return n.has(o)}function t(o){let a=n.get(o);return a===void 0&&(a={},n.set(o,a)),a}function i(o){n.delete(o)}function r(o,a,l){n.get(o)[a]=l}function s(){n=new WeakMap}return{has:e,get:t,remove:i,update:r,dispose:s}}function s0(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.z!==e.z?n.z-e.z:n.id-e.id}function ju(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function Yu(){const n=[];let e=0;const t=[],i=[],r=[];function s(){e=0,t.length=0,i.length=0,r.length=0}function o(h,d,p,g,y,m){let f=n[e];return f===void 0?(f={id:h.id,object:h,geometry:d,material:p,groupOrder:g,renderOrder:h.renderOrder,z:y,group:m},n[e]=f):(f.id=h.id,f.object=h,f.geometry=d,f.material=p,f.groupOrder=g,f.renderOrder=h.renderOrder,f.z=y,f.group=m),e++,f}function a(h,d,p,g,y,m){const f=o(h,d,p,g,y,m);p.transmission>0?i.push(f):p.transparent===!0?r.push(f):t.push(f)}function l(h,d,p,g,y,m){const f=o(h,d,p,g,y,m);p.transmission>0?i.unshift(f):p.transparent===!0?r.unshift(f):t.unshift(f)}function c(h,d){t.length>1&&t.sort(h||s0),i.length>1&&i.sort(d||ju),r.length>1&&r.sort(d||ju)}function u(){for(let h=e,d=n.length;h<d;h++){const p=n[h];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:t,transmissive:i,transparent:r,init:s,push:a,unshift:l,finish:u,sort:c}}function o0(){let n=new WeakMap;function e(i,r){const s=n.get(i);let o;return s===void 0?(o=new Yu,n.set(i,[o])):r>=s.length?(o=new Yu,s.push(o)):o=s[r],o}function t(){n=new WeakMap}return{get:e,dispose:t}}function a0(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new O,color:new je};break;case"SpotLight":t={position:new O,direction:new O,color:new je,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new O,color:new je,distance:0,decay:0};break;case"HemisphereLight":t={direction:new O,skyColor:new je,groundColor:new je};break;case"RectAreaLight":t={color:new je,position:new O,halfWidth:new O,halfHeight:new O};break}return n[e.id]=t,t}}}function l0(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let c0=0;function u0(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function h0(n){const e=new a0,t=l0(),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 c=0;c<9;c++)i.probe.push(new O);const r=new O,s=new ft,o=new ft;function a(c){let u=0,h=0,d=0;for(let M=0;M<9;M++)i.probe[M].set(0,0,0);let p=0,g=0,y=0,m=0,f=0,w=0,T=0,_=0,S=0,b=0,A=0;c.sort(u0);for(let M=0,x=c.length;M<x;M++){const N=c[M],z=N.color,Y=N.intensity,q=N.distance,J=N.shadow&&N.shadow.map?N.shadow.map.texture:null;if(N.isAmbientLight)u+=z.r*Y,h+=z.g*Y,d+=z.b*Y;else if(N.isLightProbe){for(let K=0;K<9;K++)i.probe[K].addScaledVector(N.sh.coefficients[K],Y);A++}else if(N.isDirectionalLight){const K=e.get(N);if(K.color.copy(N.color).multiplyScalar(N.intensity),N.castShadow){const se=N.shadow,$=t.get(N);$.shadowIntensity=se.intensity,$.shadowBias=se.bias,$.shadowNormalBias=se.normalBias,$.shadowRadius=se.radius,$.shadowMapSize=se.mapSize,i.directionalShadow[p]=$,i.directionalShadowMap[p]=J,i.directionalShadowMatrix[p]=N.shadow.matrix,w++}i.directional[p]=K,p++}else if(N.isSpotLight){const K=e.get(N);K.position.setFromMatrixPosition(N.matrixWorld),K.color.copy(z).multiplyScalar(Y),K.distance=q,K.coneCos=Math.cos(N.angle),K.penumbraCos=Math.cos(N.angle*(1-N.penumbra)),K.decay=N.decay,i.spot[y]=K;const se=N.shadow;if(N.map&&(i.spotLightMap[S]=N.map,S++,se.updateMatrices(N),N.castShadow&&b++),i.spotLightMatrix[y]=se.matrix,N.castShadow){const $=t.get(N);$.shadowIntensity=se.intensity,$.shadowBias=se.bias,$.shadowNormalBias=se.normalBias,$.shadowRadius=se.radius,$.shadowMapSize=se.mapSize,i.spotShadow[y]=$,i.spotShadowMap[y]=J,_++}y++}else if(N.isRectAreaLight){const K=e.get(N);K.color.copy(z).multiplyScalar(Y),K.halfWidth.set(N.width*.5,0,0),K.halfHeight.set(0,N.height*.5,0),i.rectArea[m]=K,m++}else if(N.isPointLight){const K=e.get(N);if(K.color.copy(N.color).multiplyScalar(N.intensity),K.distance=N.distance,K.decay=N.decay,N.castShadow){const se=N.shadow,$=t.get(N);$.shadowIntensity=se.intensity,$.shadowBias=se.bias,$.shadowNormalBias=se.normalBias,$.shadowRadius=se.radius,$.shadowMapSize=se.mapSize,$.shadowCameraNear=se.camera.near,$.shadowCameraFar=se.camera.far,i.pointShadow[g]=$,i.pointShadowMap[g]=J,i.pointShadowMatrix[g]=N.shadow.matrix,T++}i.point[g]=K,g++}else if(N.isHemisphereLight){const K=e.get(N);K.skyColor.copy(N.color).multiplyScalar(Y),K.groundColor.copy(N.groundColor).multiplyScalar(Y),i.hemi[f]=K,f++}}m>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=pe.LTC_FLOAT_1,i.rectAreaLTC2=pe.LTC_FLOAT_2):(i.rectAreaLTC1=pe.LTC_HALF_1,i.rectAreaLTC2=pe.LTC_HALF_2)),i.ambient[0]=u,i.ambient[1]=h,i.ambient[2]=d;const C=i.hash;(C.directionalLength!==p||C.pointLength!==g||C.spotLength!==y||C.rectAreaLength!==m||C.hemiLength!==f||C.numDirectionalShadows!==w||C.numPointShadows!==T||C.numSpotShadows!==_||C.numSpotMaps!==S||C.numLightProbes!==A)&&(i.directional.length=p,i.spot.length=y,i.rectArea.length=m,i.point.length=g,i.hemi.length=f,i.directionalShadow.length=w,i.directionalShadowMap.length=w,i.pointShadow.length=T,i.pointShadowMap.length=T,i.spotShadow.length=_,i.spotShadowMap.length=_,i.directionalShadowMatrix.length=w,i.pointShadowMatrix.length=T,i.spotLightMatrix.length=_+S-b,i.spotLightMap.length=S,i.numSpotLightShadowsWithMaps=b,i.numLightProbes=A,C.directionalLength=p,C.pointLength=g,C.spotLength=y,C.rectAreaLength=m,C.hemiLength=f,C.numDirectionalShadows=w,C.numPointShadows=T,C.numSpotShadows=_,C.numSpotMaps=S,C.numLightProbes=A,i.version=c0++)}function l(c,u){let h=0,d=0,p=0,g=0,y=0;const m=u.matrixWorldInverse;for(let f=0,w=c.length;f<w;f++){const T=c[f];if(T.isDirectionalLight){const _=i.directional[h];_.direction.setFromMatrixPosition(T.matrixWorld),r.setFromMatrixPosition(T.target.matrixWorld),_.direction.sub(r),_.direction.transformDirection(m),h++}else if(T.isSpotLight){const _=i.spot[p];_.position.setFromMatrixPosition(T.matrixWorld),_.position.applyMatrix4(m),_.direction.setFromMatrixPosition(T.matrixWorld),r.setFromMatrixPosition(T.target.matrixWorld),_.direction.sub(r),_.direction.transformDirection(m),p++}else if(T.isRectAreaLight){const _=i.rectArea[g];_.position.setFromMatrixPosition(T.matrixWorld),_.position.applyMatrix4(m),o.identity(),s.copy(T.matrixWorld),s.premultiply(m),o.extractRotation(s),_.halfWidth.set(T.width*.5,0,0),_.halfHeight.set(0,T.height*.5,0),_.halfWidth.applyMatrix4(o),_.halfHeight.applyMatrix4(o),g++}else if(T.isPointLight){const _=i.point[d];_.position.setFromMatrixPosition(T.matrixWorld),_.position.applyMatrix4(m),d++}else if(T.isHemisphereLight){const _=i.hemi[y];_.direction.setFromMatrixPosition(T.matrixWorld),_.direction.transformDirection(m),y++}}}return{setup:a,setupView:l,state:i}}function qu(n){const e=new h0(n),t=[],i=[];function r(u){c.camera=u,t.length=0,i.length=0}function s(u){t.push(u)}function o(u){i.push(u)}function a(){e.setup(t)}function l(u){e.setupView(t,u)}const c={lightsArray:t,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:c,setupLights:a,setupLightsView:l,pushLight:s,pushShadow:o}}function f0(n){let e=new WeakMap;function t(r,s=0){const o=e.get(r);let a;return o===void 0?(a=new qu(n),e.set(r,[a])):s>=o.length?(a=new qu(n),o.push(a)):a=o[s],a}function i(){e=new WeakMap}return{get:t,dispose:i}}const d0=`void main() {
3914
+ Program Info Log: `+K+`
3915
+ `+ct+`
3916
+ `+Et)}else K!==""?kt("WebGLProgram: Program Info Log:",K):(tt===""||lt==="")&&(st=!1);st&&(O.diagnostics={runnable:$,programLog:K,vertexShader:{log:tt,prefix:_},fragmentShader:{log:lt,prefix:p}})}s.deleteShader(E),s.deleteShader(v),R=new Po(s,x),M=vy(s,x)}let R;this.getUniforms=function(){return R===void 0&&A(this),R};let M;this.getAttributes=function(){return M===void 0&&A(this),M};let g=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return g===!1&&(g=s.getProgramParameter(x,hy)),g},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(x),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=uy++,this.cacheKey=t,this.usedTimes=1,this.program=x,this.vertexShader=E,this.fragmentShader=v,this}let Dy=0;class Oy{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,n=t.fragmentShader,s=this._getShaderStage(e),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(t);return a.has(s)===!1&&(a.add(s),s.usedTimes++),a.has(r)===!1&&(a.add(r),r.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return n===void 0&&(n=new Ly(t),e.set(t,n)),n}}class Ly{constructor(t){this.id=Dy++,this.code=t,this.usedTimes=0}}function Ny(i,t,e,n,s,r,a){const o=new Qh,l=new Oy,c=new Set,h=[],u=s.logarithmicDepthBuffer,d=s.vertexTextures;let f=s.precision;const m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function x(M){return c.add(M),M===0?"uv":`uv${M}`}function _(M,g,O,F,k){const G=F.fog,K=k.geometry,tt=M.isMeshStandardMaterial?F.environment:null,lt=(M.isMeshStandardMaterial?e:t).get(M.envMap||tt),$=lt&&lt.mapping===Qo?lt.image.height:null,st=m[M.type];M.precision!==null&&(f=s.getMaxPrecision(M.precision),f!==M.precision&&kt("WebGLProgram.getParameters:",M.precision,"not supported, using",f,"instead."));const ct=K.morphAttributes.position||K.morphAttributes.normal||K.morphAttributes.color,Et=ct!==void 0?ct.length:0;let Vt=0;K.morphAttributes.position!==void 0&&(Vt=1),K.morphAttributes.normal!==void 0&&(Vt=2),K.morphAttributes.color!==void 0&&(Vt=3);let pt,$t,se,J;if(st){const ne=ii[st];pt=ne.vertexShader,$t=ne.fragmentShader}else pt=M.vertexShader,$t=M.fragmentShader,l.update(M),se=l.getVertexShaderID(M),J=l.getFragmentShaderID(M);const rt=i.getRenderTarget(),Mt=i.state.buffers.depth.getReversed(),Bt=k.isInstancedMesh===!0,Ct=k.isBatchedMesh===!0,It=!!M.map,Ae=!!M.matcap,Ht=!!lt,he=!!M.aoMap,N=!!M.lightMap,Wt=!!M.bumpMap,jt=!!M.normalMap,ie=!!M.displacementMap,wt=!!M.emissiveMap,pe=!!M.metalnessMap,Rt=!!M.roughnessMap,Ut=M.anisotropy>0,C=M.clearcoat>0,b=M.dispersion>0,V=M.iridescence>0,nt=M.sheen>0,it=M.transmission>0,Q=Ut&&!!M.anisotropyMap,At=C&&!!M.clearcoatMap,mt=C&&!!M.clearcoatNormalMap,Pt=C&&!!M.clearcoatRoughnessMap,L=V&&!!M.iridescenceMap,D=V&&!!M.iridescenceThicknessMap,U=nt&&!!M.sheenColorMap,et=nt&&!!M.sheenRoughnessMap,ot=!!M.specularMap,ht=!!M.specularColorMap,yt=!!M.specularIntensityMap,P=it&&!!M.transmissionMap,W=it&&!!M.thicknessMap,X=!!M.gradientMap,Y=!!M.alphaMap,H=M.alphaTest>0,j=!!M.alphaHash,ut=!!M.extensions;let bt=Ki;M.toneMapped&&(rt===null||rt.isXRRenderTarget===!0)&&(bt=i.toneMapping);const Yt={shaderID:st,shaderType:M.type,shaderName:M.name,vertexShader:pt,fragmentShader:$t,defines:M.defines,customVertexShaderID:se,customFragmentShaderID:J,isRawShaderMaterial:M.isRawShaderMaterial===!0,glslVersion:M.glslVersion,precision:f,batching:Ct,batchingColor:Ct&&k._colorsTexture!==null,instancing:Bt,instancingColor:Bt&&k.instanceColor!==null,instancingMorph:Bt&&k.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:rt===null?i.outputColorSpace:rt.isXRRenderTarget===!0?rt.texture.colorSpace:wr,alphaToCoverage:!!M.alphaToCoverage,map:It,matcap:Ae,envMap:Ht,envMapMode:Ht&&lt.mapping,envMapCubeUVHeight:$,aoMap:he,lightMap:N,bumpMap:Wt,normalMap:jt,displacementMap:d&&ie,emissiveMap:wt,normalMapObjectSpace:jt&&M.normalMapType===M0,normalMapTangentSpace:jt&&M.normalMapType===up,metalnessMap:pe,roughnessMap:Rt,anisotropy:Ut,anisotropyMap:Q,clearcoat:C,clearcoatMap:At,clearcoatNormalMap:mt,clearcoatRoughnessMap:Pt,dispersion:b,iridescence:V,iridescenceMap:L,iridescenceThicknessMap:D,sheen:nt,sheenColorMap:U,sheenRoughnessMap:et,specularMap:ot,specularColorMap:ht,specularIntensityMap:yt,transmission:it,transmissionMap:P,thicknessMap:W,gradientMap:X,opaque:M.transparent===!1&&M.blending===mr&&M.alphaToCoverage===!1,alphaMap:Y,alphaTest:H,alphaHash:j,combine:M.combine,mapUv:It&&x(M.map.channel),aoMapUv:he&&x(M.aoMap.channel),lightMapUv:N&&x(M.lightMap.channel),bumpMapUv:Wt&&x(M.bumpMap.channel),normalMapUv:jt&&x(M.normalMap.channel),displacementMapUv:ie&&x(M.displacementMap.channel),emissiveMapUv:wt&&x(M.emissiveMap.channel),metalnessMapUv:pe&&x(M.metalnessMap.channel),roughnessMapUv:Rt&&x(M.roughnessMap.channel),anisotropyMapUv:Q&&x(M.anisotropyMap.channel),clearcoatMapUv:At&&x(M.clearcoatMap.channel),clearcoatNormalMapUv:mt&&x(M.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Pt&&x(M.clearcoatRoughnessMap.channel),iridescenceMapUv:L&&x(M.iridescenceMap.channel),iridescenceThicknessMapUv:D&&x(M.iridescenceThicknessMap.channel),sheenColorMapUv:U&&x(M.sheenColorMap.channel),sheenRoughnessMapUv:et&&x(M.sheenRoughnessMap.channel),specularMapUv:ot&&x(M.specularMap.channel),specularColorMapUv:ht&&x(M.specularColorMap.channel),specularIntensityMapUv:yt&&x(M.specularIntensityMap.channel),transmissionMapUv:P&&x(M.transmissionMap.channel),thicknessMapUv:W&&x(M.thicknessMap.channel),alphaMapUv:Y&&x(M.alphaMap.channel),vertexTangents:!!K.attributes.tangent&&(jt||Ut),vertexColors:M.vertexColors,vertexAlphas:M.vertexColors===!0&&!!K.attributes.color&&K.attributes.color.itemSize===4,pointsUvs:k.isPoints===!0&&!!K.attributes.uv&&(It||Y),fog:!!G,useFog:M.fog===!0,fogExp2:!!G&&G.isFogExp2,flatShading:M.flatShading===!0&&M.wireframe===!1,sizeAttenuation:M.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:Mt,skinning:k.isSkinnedMesh===!0,morphTargets:K.morphAttributes.position!==void 0,morphNormals:K.morphAttributes.normal!==void 0,morphColors:K.morphAttributes.color!==void 0,morphTargetsCount:Et,morphTextureStride:Vt,numDirLights:g.directional.length,numPointLights:g.point.length,numSpotLights:g.spot.length,numSpotLightMaps:g.spotLightMap.length,numRectAreaLights:g.rectArea.length,numHemiLights:g.hemi.length,numDirLightShadows:g.directionalShadowMap.length,numPointLightShadows:g.pointShadowMap.length,numSpotLightShadows:g.spotShadowMap.length,numSpotLightShadowsWithMaps:g.numSpotLightShadowsWithMaps,numLightProbes:g.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:M.dithering,shadowMapEnabled:i.shadowMap.enabled&&O.length>0,shadowMapType:i.shadowMap.type,toneMapping:bt,decodeVideoTexture:It&&M.map.isVideoTexture===!0&&te.getTransfer(M.map.colorSpace)===ae,decodeVideoTextureEmissive:wt&&M.emissiveMap.isVideoTexture===!0&&te.getTransfer(M.emissiveMap.colorSpace)===ae,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===si,flipSided:M.side===on,useDepthPacking:M.depthPacking>=0,depthPacking:M.depthPacking||0,index0AttributeName:M.index0AttributeName,extensionClipCullDistance:ut&&M.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ut&&M.extensions.multiDraw===!0||Ct)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:M.customProgramCacheKey()};return Yt.vertexUv1s=c.has(1),Yt.vertexUv2s=c.has(2),Yt.vertexUv3s=c.has(3),c.clear(),Yt}function p(M){const g=[];if(M.shaderID?g.push(M.shaderID):(g.push(M.customVertexShaderID),g.push(M.customFragmentShaderID)),M.defines!==void 0)for(const O in M.defines)g.push(O),g.push(M.defines[O]);return M.isRawShaderMaterial===!1&&(w(g,M),S(g,M),g.push(i.outputColorSpace)),g.push(M.customProgramCacheKey),g.join()}function w(M,g){M.push(g.precision),M.push(g.outputColorSpace),M.push(g.envMapMode),M.push(g.envMapCubeUVHeight),M.push(g.mapUv),M.push(g.alphaMapUv),M.push(g.lightMapUv),M.push(g.aoMapUv),M.push(g.bumpMapUv),M.push(g.normalMapUv),M.push(g.displacementMapUv),M.push(g.emissiveMapUv),M.push(g.metalnessMapUv),M.push(g.roughnessMapUv),M.push(g.anisotropyMapUv),M.push(g.clearcoatMapUv),M.push(g.clearcoatNormalMapUv),M.push(g.clearcoatRoughnessMapUv),M.push(g.iridescenceMapUv),M.push(g.iridescenceThicknessMapUv),M.push(g.sheenColorMapUv),M.push(g.sheenRoughnessMapUv),M.push(g.specularMapUv),M.push(g.specularColorMapUv),M.push(g.specularIntensityMapUv),M.push(g.transmissionMapUv),M.push(g.thicknessMapUv),M.push(g.combine),M.push(g.fogExp2),M.push(g.sizeAttenuation),M.push(g.morphTargetsCount),M.push(g.morphAttributeCount),M.push(g.numDirLights),M.push(g.numPointLights),M.push(g.numSpotLights),M.push(g.numSpotLightMaps),M.push(g.numHemiLights),M.push(g.numRectAreaLights),M.push(g.numDirLightShadows),M.push(g.numPointLightShadows),M.push(g.numSpotLightShadows),M.push(g.numSpotLightShadowsWithMaps),M.push(g.numLightProbes),M.push(g.shadowMapType),M.push(g.toneMapping),M.push(g.numClippingPlanes),M.push(g.numClipIntersection),M.push(g.depthPacking)}function S(M,g){o.disableAll(),g.supportsVertexTextures&&o.enable(0),g.instancing&&o.enable(1),g.instancingColor&&o.enable(2),g.instancingMorph&&o.enable(3),g.matcap&&o.enable(4),g.envMap&&o.enable(5),g.normalMapObjectSpace&&o.enable(6),g.normalMapTangentSpace&&o.enable(7),g.clearcoat&&o.enable(8),g.iridescence&&o.enable(9),g.alphaTest&&o.enable(10),g.vertexColors&&o.enable(11),g.vertexAlphas&&o.enable(12),g.vertexUv1s&&o.enable(13),g.vertexUv2s&&o.enable(14),g.vertexUv3s&&o.enable(15),g.vertexTangents&&o.enable(16),g.anisotropy&&o.enable(17),g.alphaHash&&o.enable(18),g.batching&&o.enable(19),g.dispersion&&o.enable(20),g.batchingColor&&o.enable(21),g.gradientMap&&o.enable(22),M.push(o.mask),o.disableAll(),g.fog&&o.enable(0),g.useFog&&o.enable(1),g.flatShading&&o.enable(2),g.logarithmicDepthBuffer&&o.enable(3),g.reversedDepthBuffer&&o.enable(4),g.skinning&&o.enable(5),g.morphTargets&&o.enable(6),g.morphNormals&&o.enable(7),g.morphColors&&o.enable(8),g.premultipliedAlpha&&o.enable(9),g.shadowMapEnabled&&o.enable(10),g.doubleSided&&o.enable(11),g.flipSided&&o.enable(12),g.useDepthPacking&&o.enable(13),g.dithering&&o.enable(14),g.transmission&&o.enable(15),g.sheen&&o.enable(16),g.opaque&&o.enable(17),g.pointsUvs&&o.enable(18),g.decodeVideoTexture&&o.enable(19),g.decodeVideoTextureEmissive&&o.enable(20),g.alphaToCoverage&&o.enable(21),M.push(o.mask)}function y(M){const g=m[M.type];let O;if(g){const F=ii[g];O=Q0.clone(F.uniforms)}else O=M.uniforms;return O}function E(M,g){let O;for(let F=0,k=h.length;F<k;F++){const G=h[F];if(G.cacheKey===g){O=G,++O.usedTimes;break}}return O===void 0&&(O=new Py(i,g,M,r),h.push(O)),O}function v(M){if(--M.usedTimes===0){const g=h.indexOf(M);h[g]=h[h.length-1],h.pop(),M.destroy()}}function A(M){l.remove(M)}function R(){l.dispose()}return{getParameters:_,getProgramCacheKey:p,getUniforms:y,acquireProgram:E,releaseProgram:v,releaseShaderCache:A,programs:h,dispose:R}}function Iy(){let i=new WeakMap;function t(a){return i.has(a)}function e(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function s(a,o,l){i.get(a)[o]=l}function r(){i=new WeakMap}return{has:t,get:e,remove:n,update:s,dispose:r}}function Uy(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.material.id!==t.material.id?i.material.id-t.material.id:i.z!==t.z?i.z-t.z:i.id-t.id}function Ud(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.z!==t.z?t.z-i.z:i.id-t.id}function Fd(){const i=[];let t=0;const e=[],n=[],s=[];function r(){t=0,e.length=0,n.length=0,s.length=0}function a(u,d,f,m,x,_){let p=i[t];return p===void 0?(p={id:u.id,object:u,geometry:d,material:f,groupOrder:m,renderOrder:u.renderOrder,z:x,group:_},i[t]=p):(p.id=u.id,p.object=u,p.geometry=d,p.material=f,p.groupOrder=m,p.renderOrder=u.renderOrder,p.z=x,p.group=_),t++,p}function o(u,d,f,m,x,_){const p=a(u,d,f,m,x,_);f.transmission>0?n.push(p):f.transparent===!0?s.push(p):e.push(p)}function l(u,d,f,m,x,_){const p=a(u,d,f,m,x,_);f.transmission>0?n.unshift(p):f.transparent===!0?s.unshift(p):e.unshift(p)}function c(u,d){e.length>1&&e.sort(u||Uy),n.length>1&&n.sort(d||Ud),s.length>1&&s.sort(d||Ud)}function h(){for(let u=t,d=i.length;u<d;u++){const f=i[u];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:e,transmissive:n,transparent:s,init:r,push:o,unshift:l,finish:h,sort:c}}function Fy(){let i=new WeakMap;function t(n,s){const r=i.get(n);let a;return r===void 0?(a=new Fd,i.set(n,[a])):s>=r.length?(a=new Fd,r.push(a)):a=r[s],a}function e(){i=new WeakMap}return{get:t,dispose:e}}function zy(){const i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new I,color:new Zt};break;case"SpotLight":e={position:new I,direction:new I,color:new Zt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new I,color:new Zt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new I,skyColor:new Zt,groundColor:new Zt};break;case"RectAreaLight":e={color:new Zt,position:new I,halfWidth:new I,halfHeight:new I};break}return i[t.id]=e,e}}}function By(){const i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Nt};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Nt};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Nt,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}let ky=0;function Vy(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function Hy(i){const t=new zy,e=By(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new I);const s=new I,r=new _e,a=new _e;function o(c){let h=0,u=0,d=0;for(let M=0;M<9;M++)n.probe[M].set(0,0,0);let f=0,m=0,x=0,_=0,p=0,w=0,S=0,y=0,E=0,v=0,A=0;c.sort(Vy);for(let M=0,g=c.length;M<g;M++){const O=c[M],F=O.color,k=O.intensity,G=O.distance,K=O.shadow&&O.shadow.map?O.shadow.map.texture:null;if(O.isAmbientLight)h+=F.r*k,u+=F.g*k,d+=F.b*k;else if(O.isLightProbe){for(let tt=0;tt<9;tt++)n.probe[tt].addScaledVector(O.sh.coefficients[tt],k);A++}else if(O.isDirectionalLight){const tt=t.get(O);if(tt.color.copy(O.color).multiplyScalar(O.intensity),O.castShadow){const lt=O.shadow,$=e.get(O);$.shadowIntensity=lt.intensity,$.shadowBias=lt.bias,$.shadowNormalBias=lt.normalBias,$.shadowRadius=lt.radius,$.shadowMapSize=lt.mapSize,n.directionalShadow[f]=$,n.directionalShadowMap[f]=K,n.directionalShadowMatrix[f]=O.shadow.matrix,w++}n.directional[f]=tt,f++}else if(O.isSpotLight){const tt=t.get(O);tt.position.setFromMatrixPosition(O.matrixWorld),tt.color.copy(F).multiplyScalar(k),tt.distance=G,tt.coneCos=Math.cos(O.angle),tt.penumbraCos=Math.cos(O.angle*(1-O.penumbra)),tt.decay=O.decay,n.spot[x]=tt;const lt=O.shadow;if(O.map&&(n.spotLightMap[E]=O.map,E++,lt.updateMatrices(O),O.castShadow&&v++),n.spotLightMatrix[x]=lt.matrix,O.castShadow){const $=e.get(O);$.shadowIntensity=lt.intensity,$.shadowBias=lt.bias,$.shadowNormalBias=lt.normalBias,$.shadowRadius=lt.radius,$.shadowMapSize=lt.mapSize,n.spotShadow[x]=$,n.spotShadowMap[x]=K,y++}x++}else if(O.isRectAreaLight){const tt=t.get(O);tt.color.copy(F).multiplyScalar(k),tt.halfWidth.set(O.width*.5,0,0),tt.halfHeight.set(0,O.height*.5,0),n.rectArea[_]=tt,_++}else if(O.isPointLight){const tt=t.get(O);if(tt.color.copy(O.color).multiplyScalar(O.intensity),tt.distance=O.distance,tt.decay=O.decay,O.castShadow){const lt=O.shadow,$=e.get(O);$.shadowIntensity=lt.intensity,$.shadowBias=lt.bias,$.shadowNormalBias=lt.normalBias,$.shadowRadius=lt.radius,$.shadowMapSize=lt.mapSize,$.shadowCameraNear=lt.camera.near,$.shadowCameraFar=lt.camera.far,n.pointShadow[m]=$,n.pointShadowMap[m]=K,n.pointShadowMatrix[m]=O.shadow.matrix,S++}n.point[m]=tt,m++}else if(O.isHemisphereLight){const tt=t.get(O);tt.skyColor.copy(O.color).multiplyScalar(k),tt.groundColor.copy(O.groundColor).multiplyScalar(k),n.hemi[p]=tt,p++}}_>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=_t.LTC_FLOAT_1,n.rectAreaLTC2=_t.LTC_FLOAT_2):(n.rectAreaLTC1=_t.LTC_HALF_1,n.rectAreaLTC2=_t.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;const R=n.hash;(R.directionalLength!==f||R.pointLength!==m||R.spotLength!==x||R.rectAreaLength!==_||R.hemiLength!==p||R.numDirectionalShadows!==w||R.numPointShadows!==S||R.numSpotShadows!==y||R.numSpotMaps!==E||R.numLightProbes!==A)&&(n.directional.length=f,n.spot.length=x,n.rectArea.length=_,n.point.length=m,n.hemi.length=p,n.directionalShadow.length=w,n.directionalShadowMap.length=w,n.pointShadow.length=S,n.pointShadowMap.length=S,n.spotShadow.length=y,n.spotShadowMap.length=y,n.directionalShadowMatrix.length=w,n.pointShadowMatrix.length=S,n.spotLightMatrix.length=y+E-v,n.spotLightMap.length=E,n.numSpotLightShadowsWithMaps=v,n.numLightProbes=A,R.directionalLength=f,R.pointLength=m,R.spotLength=x,R.rectAreaLength=_,R.hemiLength=p,R.numDirectionalShadows=w,R.numPointShadows=S,R.numSpotShadows=y,R.numSpotMaps=E,R.numLightProbes=A,n.version=ky++)}function l(c,h){let u=0,d=0,f=0,m=0,x=0;const _=h.matrixWorldInverse;for(let p=0,w=c.length;p<w;p++){const S=c[p];if(S.isDirectionalLight){const y=n.directional[u];y.direction.setFromMatrixPosition(S.matrixWorld),s.setFromMatrixPosition(S.target.matrixWorld),y.direction.sub(s),y.direction.transformDirection(_),u++}else if(S.isSpotLight){const y=n.spot[f];y.position.setFromMatrixPosition(S.matrixWorld),y.position.applyMatrix4(_),y.direction.setFromMatrixPosition(S.matrixWorld),s.setFromMatrixPosition(S.target.matrixWorld),y.direction.sub(s),y.direction.transformDirection(_),f++}else if(S.isRectAreaLight){const y=n.rectArea[m];y.position.setFromMatrixPosition(S.matrixWorld),y.position.applyMatrix4(_),a.identity(),r.copy(S.matrixWorld),r.premultiply(_),a.extractRotation(r),y.halfWidth.set(S.width*.5,0,0),y.halfHeight.set(0,S.height*.5,0),y.halfWidth.applyMatrix4(a),y.halfHeight.applyMatrix4(a),m++}else if(S.isPointLight){const y=n.point[d];y.position.setFromMatrixPosition(S.matrixWorld),y.position.applyMatrix4(_),d++}else if(S.isHemisphereLight){const y=n.hemi[x];y.direction.setFromMatrixPosition(S.matrixWorld),y.direction.transformDirection(_),x++}}}return{setup:o,setupView:l,state:n}}function zd(i){const t=new Hy(i),e=[],n=[];function s(h){c.camera=h,e.length=0,n.length=0}function r(h){e.push(h)}function a(h){n.push(h)}function o(){t.setup(e)}function l(h){t.setupView(e,h)}const c={lightsArray:e,shadowsArray:n,camera:null,lights:t,transmissionRenderTarget:{}};return{init:s,state:c,setupLights:o,setupLightsView:l,pushLight:r,pushShadow:a}}function Gy(i){let t=new WeakMap;function e(s,r=0){const a=t.get(s);let o;return a===void 0?(o=new zd(i),t.set(s,[o])):r>=a.length?(o=new zd(i),a.push(o)):o=a[r],o}function n(){t=new WeakMap}return{get:e,dispose:n}}const Wy=`void main() {
3802
3917
  gl_Position = vec4( position, 1.0 );
3803
- }`,p0=`uniform sampler2D shadow_pass;
3918
+ }`,Xy=`uniform sampler2D shadow_pass;
3804
3919
  uniform vec2 resolution;
3805
3920
  uniform float radius;
3806
3921
  #include <packing>
@@ -3826,12 +3941,12 @@ void main() {
3826
3941
  squared_mean = squared_mean / samples;
3827
3942
  float std_dev = sqrt( squared_mean - mean * mean );
3828
3943
  gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3829
- }`;function m0(n,e,t){let i=new hc;const r=new Ne,s=new Ne,o=new gt,a=new Up({depthPacking:Yd}),l=new Fp,c={},u=t.maxTextureSize,h={[mi]:Wt,[Wt]:mi,[Nn]:Nn},d=new _i({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ne},radius:{value:4}},vertexShader:d0,fragmentShader:p0}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const g=new bt;g.setAttribute("position",new wn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new ge(g,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Oh;let f=this.type;this.render=function(b,A,C){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||b.length===0)return;const M=n.getRenderTarget(),x=n.getActiveCubeFace(),N=n.getActiveMipmapLevel(),z=n.state;z.setBlending(di),z.buffers.depth.getReversed()===!0?z.buffers.color.setClear(0,0,0,0):z.buffers.color.setClear(1,1,1,1),z.buffers.depth.setTest(!0),z.setScissorTest(!1);const Y=f!==qn&&this.type===qn,q=f===qn&&this.type!==qn;for(let J=0,K=b.length;J<K;J++){const se=b[J],$=se.shadow;if($===void 0){console.warn("THREE.WebGLShadowMap:",se,"has no shadow.");continue}if($.autoUpdate===!1&&$.needsUpdate===!1)continue;r.copy($.mapSize);const le=$.getFrameExtents();if(r.multiply(le),s.copy($.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/le.x),r.x=s.x*le.x,$.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/le.y),r.y=s.y*le.y,$.mapSize.y=s.y)),$.map===null||Y===!0||q===!0){const Ee=this.type!==qn?{minFilter:Tn,magFilter:Tn}:{};$.map!==null&&$.map.dispose(),$.map=new ki(r.x,r.y,Ee),$.map.texture.name=se.name+".shadowMap",$.camera.updateProjectionMatrix()}n.setRenderTarget($.map),n.clear();const me=$.getViewportCount();for(let Ee=0;Ee<me;Ee++){const Be=$.getViewport(Ee);o.set(s.x*Be.x,s.y*Be.y,s.x*Be.z,s.y*Be.w),z.viewport(o),$.updateMatrices(se,Ee),i=$.getFrustum(),_(A,C,$.camera,se,this.type)}$.isPointLightShadow!==!0&&this.type===qn&&w($,C),$.needsUpdate=!1}f=this.type,m.needsUpdate=!1,n.setRenderTarget(M,x,N)};function w(b,A){const C=e.update(y);d.defines.VSM_SAMPLES!==b.blurSamples&&(d.defines.VSM_SAMPLES=b.blurSamples,p.defines.VSM_SAMPLES=b.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new ki(r.x,r.y)),d.uniforms.shadow_pass.value=b.map.texture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,n.setRenderTarget(b.mapPass),n.clear(),n.renderBufferDirect(A,null,C,d,y,null),p.uniforms.shadow_pass.value=b.mapPass.texture,p.uniforms.resolution.value=b.mapSize,p.uniforms.radius.value=b.radius,n.setRenderTarget(b.map),n.clear(),n.renderBufferDirect(A,null,C,p,y,null)}function T(b,A,C,M){let x=null;const N=C.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(N!==void 0)x=N;else if(x=C.isPointLight===!0?l:a,n.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){const z=x.uuid,Y=A.uuid;let q=c[z];q===void 0&&(q={},c[z]=q);let J=q[Y];J===void 0&&(J=x.clone(),q[Y]=J,A.addEventListener("dispose",S)),x=J}if(x.visible=A.visible,x.wireframe=A.wireframe,M===qn?x.side=A.shadowSide!==null?A.shadowSide:A.side:x.side=A.shadowSide!==null?A.shadowSide:h[A.side],x.alphaMap=A.alphaMap,x.alphaTest=A.alphaToCoverage===!0?.5:A.alphaTest,x.map=A.map,x.clipShadows=A.clipShadows,x.clippingPlanes=A.clippingPlanes,x.clipIntersection=A.clipIntersection,x.displacementMap=A.displacementMap,x.displacementScale=A.displacementScale,x.displacementBias=A.displacementBias,x.wireframeLinewidth=A.wireframeLinewidth,x.linewidth=A.linewidth,C.isPointLight===!0&&x.isMeshDistanceMaterial===!0){const z=n.properties.get(x);z.light=C}return x}function _(b,A,C,M,x){if(b.visible===!1)return;if(b.layers.test(A.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&x===qn)&&(!b.frustumCulled||i.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,b.matrixWorld);const Y=e.update(b),q=b.material;if(Array.isArray(q)){const J=Y.groups;for(let K=0,se=J.length;K<se;K++){const $=J[K],le=q[$.materialIndex];if(le&&le.visible){const me=T(b,le,M,x);b.onBeforeShadow(n,b,A,C,Y,me,$),n.renderBufferDirect(C,null,Y,me,b,$),b.onAfterShadow(n,b,A,C,Y,me,$)}}}else if(q.visible){const J=T(b,q,M,x);b.onBeforeShadow(n,b,A,C,Y,J,null),n.renderBufferDirect(C,null,Y,J,b,null),b.onAfterShadow(n,b,A,C,Y,J,null)}}const z=b.children;for(let Y=0,q=z.length;Y<q;Y++)_(z[Y],A,C,M,x)}function S(b){b.target.removeEventListener("dispose",S);for(const C in c){const M=c[C],x=b.target.uuid;x in M&&(M[x].dispose(),delete M[x])}}}const _0={[za]:Va,[Ha]:Wa,[ka]:Xa,[wr]:Ga,[Va]:za,[Wa]:Ha,[Xa]:ka,[Ga]:wr};function g0(n,e){function t(){let D=!1;const V=new gt;let G=null;const ee=new gt(0,0,0,0);return{setMask:function(k){G!==k&&!D&&(n.colorMask(k,k,k,k),G=k)},setLocked:function(k){D=k},setClear:function(k,W,ue,xe,We){We===!0&&(k*=xe,W*=xe,ue*=xe),V.set(k,W,ue,xe),ee.equals(V)===!1&&(n.clearColor(k,W,ue,xe),ee.copy(V))},reset:function(){D=!1,G=null,ee.set(-1,0,0,0)}}}function i(){let D=!1,V=!1,G=null,ee=null,k=null;return{setReversed:function(W){if(V!==W){const ue=e.get("EXT_clip_control");W?ue.clipControlEXT(ue.LOWER_LEFT_EXT,ue.ZERO_TO_ONE_EXT):ue.clipControlEXT(ue.LOWER_LEFT_EXT,ue.NEGATIVE_ONE_TO_ONE_EXT),V=W;const xe=k;k=null,this.setClear(xe)}},getReversed:function(){return V},setTest:function(W){W?oe(n.DEPTH_TEST):Me(n.DEPTH_TEST)},setMask:function(W){G!==W&&!D&&(n.depthMask(W),G=W)},setFunc:function(W){if(V&&(W=_0[W]),ee!==W){switch(W){case za:n.depthFunc(n.NEVER);break;case Va:n.depthFunc(n.ALWAYS);break;case Ha:n.depthFunc(n.LESS);break;case wr:n.depthFunc(n.LEQUAL);break;case ka:n.depthFunc(n.EQUAL);break;case Ga:n.depthFunc(n.GEQUAL);break;case Wa:n.depthFunc(n.GREATER);break;case Xa:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}ee=W}},setLocked:function(W){D=W},setClear:function(W){k!==W&&(V&&(W=1-W),n.clearDepth(W),k=W)},reset:function(){D=!1,G=null,ee=null,k=null,V=!1}}}function r(){let D=!1,V=null,G=null,ee=null,k=null,W=null,ue=null,xe=null,We=null;return{setTest:function($e){D||($e?oe(n.STENCIL_TEST):Me(n.STENCIL_TEST))},setMask:function($e){V!==$e&&!D&&(n.stencilMask($e),V=$e)},setFunc:function($e,vn,nn){(G!==$e||ee!==vn||k!==nn)&&(n.stencilFunc($e,vn,nn),G=$e,ee=vn,k=nn)},setOp:function($e,vn,nn){(W!==$e||ue!==vn||xe!==nn)&&(n.stencilOp($e,vn,nn),W=$e,ue=vn,xe=nn)},setLocked:function($e){D=$e},setClear:function($e){We!==$e&&(n.clearStencil($e),We=$e)},reset:function(){D=!1,V=null,G=null,ee=null,k=null,W=null,ue=null,xe=null,We=null}}}const s=new t,o=new i,a=new r,l=new WeakMap,c=new WeakMap;let u={},h={},d=new WeakMap,p=[],g=null,y=!1,m=null,f=null,w=null,T=null,_=null,S=null,b=null,A=new je(0,0,0),C=0,M=!1,x=null,N=null,z=null,Y=null,q=null;const J=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,se=0;const $=n.getParameter(n.VERSION);$.indexOf("WebGL")!==-1?(se=parseFloat(/^WebGL (\d)/.exec($)[1]),K=se>=1):$.indexOf("OpenGL ES")!==-1&&(se=parseFloat(/^OpenGL ES (\d)/.exec($)[1]),K=se>=2);let le=null,me={};const Ee=n.getParameter(n.SCISSOR_BOX),Be=n.getParameter(n.VIEWPORT),de=new gt().fromArray(Ee),qe=new gt().fromArray(Be);function Ke(D,V,G,ee){const k=new Uint8Array(4),W=n.createTexture();n.bindTexture(D,W),n.texParameteri(D,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(D,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let ue=0;ue<G;ue++)D===n.TEXTURE_3D||D===n.TEXTURE_2D_ARRAY?n.texImage3D(V,0,n.RGBA,1,1,ee,0,n.RGBA,n.UNSIGNED_BYTE,k):n.texImage2D(V+ue,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,k);return W}const Z={};Z[n.TEXTURE_2D]=Ke(n.TEXTURE_2D,n.TEXTURE_2D,1),Z[n.TEXTURE_CUBE_MAP]=Ke(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),Z[n.TEXTURE_2D_ARRAY]=Ke(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),Z[n.TEXTURE_3D]=Ke(n.TEXTURE_3D,n.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),a.setClear(0),oe(n.DEPTH_TEST),o.setFunc(wr),De(!1),be(Xc),oe(n.CULL_FACE),rt(di);function oe(D){u[D]!==!0&&(n.enable(D),u[D]=!0)}function Me(D){u[D]!==!1&&(n.disable(D),u[D]=!1)}function Ie(D,V){return h[D]!==V?(n.bindFramebuffer(D,V),h[D]=V,D===n.DRAW_FRAMEBUFFER&&(h[n.FRAMEBUFFER]=V),D===n.FRAMEBUFFER&&(h[n.DRAW_FRAMEBUFFER]=V),!0):!1}function Ce(D,V){let G=p,ee=!1;if(D){G=d.get(V),G===void 0&&(G=[],d.set(V,G));const k=D.textures;if(G.length!==k.length||G[0]!==n.COLOR_ATTACHMENT0){for(let W=0,ue=k.length;W<ue;W++)G[W]=n.COLOR_ATTACHMENT0+W;G.length=k.length,ee=!0}}else G[0]!==n.BACK&&(G[0]=n.BACK,ee=!0);ee&&n.drawBuffers(G)}function ze(D){return g!==D?(n.useProgram(D),g=D,!0):!1}const St={[Ii]:n.FUNC_ADD,[xd]:n.FUNC_SUBTRACT,[yd]:n.FUNC_REVERSE_SUBTRACT};St[Md]=n.MIN,St[Ed]=n.MAX;const L={[bd]:n.ZERO,[Sd]:n.ONE,[Td]:n.SRC_COLOR,[Fa]:n.SRC_ALPHA,[Dd]:n.SRC_ALPHA_SATURATE,[Cd]:n.DST_COLOR,[Ad]:n.DST_ALPHA,[wd]:n.ONE_MINUS_SRC_COLOR,[Ba]:n.ONE_MINUS_SRC_ALPHA,[Pd]:n.ONE_MINUS_DST_COLOR,[Rd]:n.ONE_MINUS_DST_ALPHA,[Ld]:n.CONSTANT_COLOR,[Od]:n.ONE_MINUS_CONSTANT_COLOR,[Id]:n.CONSTANT_ALPHA,[Nd]:n.ONE_MINUS_CONSTANT_ALPHA};function rt(D,V,G,ee,k,W,ue,xe,We,$e){if(D===di){y===!0&&(Me(n.BLEND),y=!1);return}if(y===!1&&(oe(n.BLEND),y=!0),D!==vd){if(D!==m||$e!==M){if((f!==Ii||_!==Ii)&&(n.blendEquation(n.FUNC_ADD),f=Ii,_=Ii),$e)switch(D){case Er:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case jc:n.blendFunc(n.ONE,n.ONE);break;case Yc:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case qc:n.blendFuncSeparate(n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:console.error("THREE.WebGLState: Invalid blending: ",D);break}else switch(D){case Er:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case jc:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE,n.ONE,n.ONE);break;case Yc:console.error("THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case qc:console.error("THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:console.error("THREE.WebGLState: Invalid blending: ",D);break}w=null,T=null,S=null,b=null,A.set(0,0,0),C=0,m=D,M=$e}return}k=k||V,W=W||G,ue=ue||ee,(V!==f||k!==_)&&(n.blendEquationSeparate(St[V],St[k]),f=V,_=k),(G!==w||ee!==T||W!==S||ue!==b)&&(n.blendFuncSeparate(L[G],L[ee],L[W],L[ue]),w=G,T=ee,S=W,b=ue),(xe.equals(A)===!1||We!==C)&&(n.blendColor(xe.r,xe.g,xe.b,We),A.copy(xe),C=We),m=D,M=!1}function Ve(D,V){D.side===Nn?Me(n.CULL_FACE):oe(n.CULL_FACE);let G=D.side===Wt;V&&(G=!G),De(G),D.blending===Er&&D.transparent===!1?rt(di):rt(D.blending,D.blendEquation,D.blendSrc,D.blendDst,D.blendEquationAlpha,D.blendSrcAlpha,D.blendDstAlpha,D.blendColor,D.blendAlpha,D.premultipliedAlpha),o.setFunc(D.depthFunc),o.setTest(D.depthTest),o.setMask(D.depthWrite),s.setMask(D.colorWrite);const ee=D.stencilWrite;a.setTest(ee),ee&&(a.setMask(D.stencilWriteMask),a.setFunc(D.stencilFunc,D.stencilRef,D.stencilFuncMask),a.setOp(D.stencilFail,D.stencilZFail,D.stencilZPass)),Se(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),D.alphaToCoverage===!0?oe(n.SAMPLE_ALPHA_TO_COVERAGE):Me(n.SAMPLE_ALPHA_TO_COVERAGE)}function De(D){x!==D&&(D?n.frontFace(n.CW):n.frontFace(n.CCW),x=D)}function be(D){D!==md?(oe(n.CULL_FACE),D!==N&&(D===Xc?n.cullFace(n.BACK):D===_d?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):Me(n.CULL_FACE),N=D}function st(D){D!==z&&(K&&n.lineWidth(D),z=D)}function Se(D,V,G){D?(oe(n.POLYGON_OFFSET_FILL),(Y!==V||q!==G)&&(n.polygonOffset(V,G),Y=V,q=G)):Me(n.POLYGON_OFFSET_FILL)}function He(D){D?oe(n.SCISSOR_TEST):Me(n.SCISSOR_TEST)}function vt(D){D===void 0&&(D=n.TEXTURE0+J-1),le!==D&&(n.activeTexture(D),le=D)}function ut(D,V,G){G===void 0&&(le===null?G=n.TEXTURE0+J-1:G=le);let ee=me[G];ee===void 0&&(ee={type:void 0,texture:void 0},me[G]=ee),(ee.type!==D||ee.texture!==V)&&(le!==G&&(n.activeTexture(G),le=G),n.bindTexture(D,V||Z[D]),ee.type=D,ee.texture=V)}function R(){const D=me[le];D!==void 0&&D.type!==void 0&&(n.bindTexture(D.type,null),D.type=void 0,D.texture=void 0)}function v(){try{n.compressedTexImage2D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function H(){try{n.compressedTexImage3D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function ne(){try{n.texSubImage2D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function re(){try{n.texSubImage3D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function te(){try{n.compressedTexSubImage2D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function Re(){try{n.compressedTexSubImage3D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function fe(){try{n.texStorage2D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function Te(){try{n.texStorage3D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function I(){try{n.texImage2D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function P(){try{n.texImage3D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function U(D){de.equals(D)===!1&&(n.scissor(D.x,D.y,D.z,D.w),de.copy(D))}function Q(D){qe.equals(D)===!1&&(n.viewport(D.x,D.y,D.z,D.w),qe.copy(D))}function ie(D,V){let G=c.get(V);G===void 0&&(G=new WeakMap,c.set(V,G));let ee=G.get(D);ee===void 0&&(ee=n.getUniformBlockIndex(V,D.name),G.set(D,ee))}function ae(D,V){const ee=c.get(V).get(D);l.get(V)!==ee&&(n.uniformBlockBinding(V,ee,D.__bindingPointIndex),l.set(V,ee))}function we(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),o.setReversed(!1),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),u={},le=null,me={},h={},d=new WeakMap,p=[],g=null,y=!1,m=null,f=null,w=null,T=null,_=null,S=null,b=null,A=new je(0,0,0),C=0,M=!1,x=null,N=null,z=null,Y=null,q=null,de.set(0,0,n.canvas.width,n.canvas.height),qe.set(0,0,n.canvas.width,n.canvas.height),s.reset(),o.reset(),a.reset()}return{buffers:{color:s,depth:o,stencil:a},enable:oe,disable:Me,bindFramebuffer:Ie,drawBuffers:Ce,useProgram:ze,setBlending:rt,setMaterial:Ve,setFlipSided:De,setCullFace:be,setLineWidth:st,setPolygonOffset:Se,setScissorTest:He,activeTexture:vt,bindTexture:ut,unbindTexture:R,compressedTexImage2D:v,compressedTexImage3D:H,texImage2D:I,texImage3D:P,updateUBOMapping:ie,uniformBlockBinding:ae,texStorage2D:fe,texStorage3D:Te,texSubImage2D:ne,texSubImage3D:re,compressedTexSubImage2D:te,compressedTexSubImage3D:Re,scissor:U,viewport:Q,reset:we}}function v0(n,e,t,i,r,s,o){const a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Ne,u=new WeakMap;let h;const d=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(R,v){return p?new OffscreenCanvas(R,v):go("canvas")}function y(R,v,H){let ne=1;const re=ut(R);if((re.width>H||re.height>H)&&(ne=H/Math.max(re.width,re.height)),ne<1)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap||typeof VideoFrame<"u"&&R instanceof VideoFrame){const te=Math.floor(ne*re.width),Re=Math.floor(ne*re.height);h===void 0&&(h=g(te,Re));const fe=v?g(te,Re):h;return fe.width=te,fe.height=Re,fe.getContext("2d").drawImage(R,0,0,te,Re),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+re.width+"x"+re.height+") to ("+te+"x"+Re+")."),fe}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+re.width+"x"+re.height+")."),R;return R}function m(R){return R.generateMipmaps}function f(R){n.generateMipmap(R)}function w(R){return R.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:R.isWebGL3DRenderTarget?n.TEXTURE_3D:R.isWebGLArrayRenderTarget||R.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function T(R,v,H,ne,re=!1){if(R!==null){if(n[R]!==void 0)return n[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let te=v;if(v===n.RED&&(H===n.FLOAT&&(te=n.R32F),H===n.HALF_FLOAT&&(te=n.R16F),H===n.UNSIGNED_BYTE&&(te=n.R8)),v===n.RED_INTEGER&&(H===n.UNSIGNED_BYTE&&(te=n.R8UI),H===n.UNSIGNED_SHORT&&(te=n.R16UI),H===n.UNSIGNED_INT&&(te=n.R32UI),H===n.BYTE&&(te=n.R8I),H===n.SHORT&&(te=n.R16I),H===n.INT&&(te=n.R32I)),v===n.RG&&(H===n.FLOAT&&(te=n.RG32F),H===n.HALF_FLOAT&&(te=n.RG16F),H===n.UNSIGNED_BYTE&&(te=n.RG8)),v===n.RG_INTEGER&&(H===n.UNSIGNED_BYTE&&(te=n.RG8UI),H===n.UNSIGNED_SHORT&&(te=n.RG16UI),H===n.UNSIGNED_INT&&(te=n.RG32UI),H===n.BYTE&&(te=n.RG8I),H===n.SHORT&&(te=n.RG16I),H===n.INT&&(te=n.RG32I)),v===n.RGB_INTEGER&&(H===n.UNSIGNED_BYTE&&(te=n.RGB8UI),H===n.UNSIGNED_SHORT&&(te=n.RGB16UI),H===n.UNSIGNED_INT&&(te=n.RGB32UI),H===n.BYTE&&(te=n.RGB8I),H===n.SHORT&&(te=n.RGB16I),H===n.INT&&(te=n.RGB32I)),v===n.RGBA_INTEGER&&(H===n.UNSIGNED_BYTE&&(te=n.RGBA8UI),H===n.UNSIGNED_SHORT&&(te=n.RGBA16UI),H===n.UNSIGNED_INT&&(te=n.RGBA32UI),H===n.BYTE&&(te=n.RGBA8I),H===n.SHORT&&(te=n.RGBA16I),H===n.INT&&(te=n.RGBA32I)),v===n.RGB&&(H===n.UNSIGNED_INT_5_9_9_9_REV&&(te=n.RGB9_E5),H===n.UNSIGNED_INT_10F_11F_11F_REV&&(te=n.R11F_G11F_B10F)),v===n.RGBA){const Re=re?mo:Qe.getTransfer(ne);H===n.FLOAT&&(te=n.RGBA32F),H===n.HALF_FLOAT&&(te=n.RGBA16F),H===n.UNSIGNED_BYTE&&(te=Re===nt?n.SRGB8_ALPHA8:n.RGBA8),H===n.UNSIGNED_SHORT_4_4_4_4&&(te=n.RGBA4),H===n.UNSIGNED_SHORT_5_5_5_1&&(te=n.RGB5_A1)}return(te===n.R16F||te===n.R32F||te===n.RG16F||te===n.RG32F||te===n.RGBA16F||te===n.RGBA32F)&&e.get("EXT_color_buffer_float"),te}function _(R,v){let H;return R?v===null||v===Hi||v===rs?H=n.DEPTH24_STENCIL8:v===Jn?H=n.DEPTH32F_STENCIL8:v===is&&(H=n.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):v===null||v===Hi||v===rs?H=n.DEPTH_COMPONENT24:v===Jn?H=n.DEPTH_COMPONENT32F:v===is&&(H=n.DEPTH_COMPONENT16),H}function S(R,v){return m(R)===!0||R.isFramebufferTexture&&R.minFilter!==Tn&&R.minFilter!==Fn?Math.log2(Math.max(v.width,v.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?v.mipmaps.length:1}function b(R){const v=R.target;v.removeEventListener("dispose",b),C(v),v.isVideoTexture&&u.delete(v)}function A(R){const v=R.target;v.removeEventListener("dispose",A),x(v)}function C(R){const v=i.get(R);if(v.__webglInit===void 0)return;const H=R.source,ne=d.get(H);if(ne){const re=ne[v.__cacheKey];re.usedTimes--,re.usedTimes===0&&M(R),Object.keys(ne).length===0&&d.delete(H)}i.remove(R)}function M(R){const v=i.get(R);n.deleteTexture(v.__webglTexture);const H=R.source,ne=d.get(H);delete ne[v.__cacheKey],o.memory.textures--}function x(R){const v=i.get(R);if(R.depthTexture&&(R.depthTexture.dispose(),i.remove(R.depthTexture)),R.isWebGLCubeRenderTarget)for(let ne=0;ne<6;ne++){if(Array.isArray(v.__webglFramebuffer[ne]))for(let re=0;re<v.__webglFramebuffer[ne].length;re++)n.deleteFramebuffer(v.__webglFramebuffer[ne][re]);else n.deleteFramebuffer(v.__webglFramebuffer[ne]);v.__webglDepthbuffer&&n.deleteRenderbuffer(v.__webglDepthbuffer[ne])}else{if(Array.isArray(v.__webglFramebuffer))for(let ne=0;ne<v.__webglFramebuffer.length;ne++)n.deleteFramebuffer(v.__webglFramebuffer[ne]);else n.deleteFramebuffer(v.__webglFramebuffer);if(v.__webglDepthbuffer&&n.deleteRenderbuffer(v.__webglDepthbuffer),v.__webglMultisampledFramebuffer&&n.deleteFramebuffer(v.__webglMultisampledFramebuffer),v.__webglColorRenderbuffer)for(let ne=0;ne<v.__webglColorRenderbuffer.length;ne++)v.__webglColorRenderbuffer[ne]&&n.deleteRenderbuffer(v.__webglColorRenderbuffer[ne]);v.__webglDepthRenderbuffer&&n.deleteRenderbuffer(v.__webglDepthRenderbuffer)}const H=R.textures;for(let ne=0,re=H.length;ne<re;ne++){const te=i.get(H[ne]);te.__webglTexture&&(n.deleteTexture(te.__webglTexture),o.memory.textures--),i.remove(H[ne])}i.remove(R)}let N=0;function z(){N=0}function Y(){const R=N;return R>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+r.maxTextures),N+=1,R}function q(R){const v=[];return v.push(R.wrapS),v.push(R.wrapT),v.push(R.wrapR||0),v.push(R.magFilter),v.push(R.minFilter),v.push(R.anisotropy),v.push(R.internalFormat),v.push(R.format),v.push(R.type),v.push(R.generateMipmaps),v.push(R.premultiplyAlpha),v.push(R.flipY),v.push(R.unpackAlignment),v.push(R.colorSpace),v.join()}function J(R,v){const H=i.get(R);if(R.isVideoTexture&&He(R),R.isRenderTargetTexture===!1&&R.isExternalTexture!==!0&&R.version>0&&H.__version!==R.version){const ne=R.image;if(ne===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ne.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Z(H,R,v);return}}else R.isExternalTexture&&(H.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,H.__webglTexture,n.TEXTURE0+v)}function K(R,v){const H=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&H.__version!==R.version){Z(H,R,v);return}t.bindTexture(n.TEXTURE_2D_ARRAY,H.__webglTexture,n.TEXTURE0+v)}function se(R,v){const H=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&H.__version!==R.version){Z(H,R,v);return}t.bindTexture(n.TEXTURE_3D,H.__webglTexture,n.TEXTURE0+v)}function $(R,v){const H=i.get(R);if(R.version>0&&H.__version!==R.version){oe(H,R,v);return}t.bindTexture(n.TEXTURE_CUBE_MAP,H.__webglTexture,n.TEXTURE0+v)}const le={[qa]:n.REPEAT,[Fi]:n.CLAMP_TO_EDGE,[$a]:n.MIRRORED_REPEAT},me={[Tn]:n.NEAREST,[Xd]:n.NEAREST_MIPMAP_NEAREST,[bs]:n.NEAREST_MIPMAP_LINEAR,[Fn]:n.LINEAR,[$o]:n.LINEAR_MIPMAP_NEAREST,[Bi]:n.LINEAR_MIPMAP_LINEAR},Ee={[$d]:n.NEVER,[tp]:n.ALWAYS,[Zd]:n.LESS,[Xh]:n.LEQUAL,[Kd]:n.EQUAL,[ep]:n.GEQUAL,[Jd]:n.GREATER,[Qd]:n.NOTEQUAL};function Be(R,v){if(v.type===Jn&&e.has("OES_texture_float_linear")===!1&&(v.magFilter===Fn||v.magFilter===$o||v.magFilter===bs||v.magFilter===Bi||v.minFilter===Fn||v.minFilter===$o||v.minFilter===bs||v.minFilter===Bi)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(R,n.TEXTURE_WRAP_S,le[v.wrapS]),n.texParameteri(R,n.TEXTURE_WRAP_T,le[v.wrapT]),(R===n.TEXTURE_3D||R===n.TEXTURE_2D_ARRAY)&&n.texParameteri(R,n.TEXTURE_WRAP_R,le[v.wrapR]),n.texParameteri(R,n.TEXTURE_MAG_FILTER,me[v.magFilter]),n.texParameteri(R,n.TEXTURE_MIN_FILTER,me[v.minFilter]),v.compareFunction&&(n.texParameteri(R,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(R,n.TEXTURE_COMPARE_FUNC,Ee[v.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(v.magFilter===Tn||v.minFilter!==bs&&v.minFilter!==Bi||v.type===Jn&&e.has("OES_texture_float_linear")===!1)return;if(v.anisotropy>1||i.get(v).__currentAnisotropy){const H=e.get("EXT_texture_filter_anisotropic");n.texParameterf(R,H.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(v.anisotropy,r.getMaxAnisotropy())),i.get(v).__currentAnisotropy=v.anisotropy}}}function de(R,v){let H=!1;R.__webglInit===void 0&&(R.__webglInit=!0,v.addEventListener("dispose",b));const ne=v.source;let re=d.get(ne);re===void 0&&(re={},d.set(ne,re));const te=q(v);if(te!==R.__cacheKey){re[te]===void 0&&(re[te]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,H=!0),re[te].usedTimes++;const Re=re[R.__cacheKey];Re!==void 0&&(re[R.__cacheKey].usedTimes--,Re.usedTimes===0&&M(v)),R.__cacheKey=te,R.__webglTexture=re[te].texture}return H}function qe(R,v,H){return Math.floor(Math.floor(R/H)/v)}function Ke(R,v,H,ne){const te=R.updateRanges;if(te.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,v.width,v.height,H,ne,v.data);else{te.sort((P,U)=>P.start-U.start);let Re=0;for(let P=1;P<te.length;P++){const U=te[Re],Q=te[P],ie=U.start+U.count,ae=qe(Q.start,v.width,4),we=qe(U.start,v.width,4);Q.start<=ie+1&&ae===we&&qe(Q.start+Q.count-1,v.width,4)===ae?U.count=Math.max(U.count,Q.start+Q.count-U.start):(++Re,te[Re]=Q)}te.length=Re+1;const fe=n.getParameter(n.UNPACK_ROW_LENGTH),Te=n.getParameter(n.UNPACK_SKIP_PIXELS),I=n.getParameter(n.UNPACK_SKIP_ROWS);n.pixelStorei(n.UNPACK_ROW_LENGTH,v.width);for(let P=0,U=te.length;P<U;P++){const Q=te[P],ie=Math.floor(Q.start/4),ae=Math.ceil(Q.count/4),we=ie%v.width,D=Math.floor(ie/v.width),V=ae,G=1;n.pixelStorei(n.UNPACK_SKIP_PIXELS,we),n.pixelStorei(n.UNPACK_SKIP_ROWS,D),t.texSubImage2D(n.TEXTURE_2D,0,we,D,V,G,H,ne,v.data)}R.clearUpdateRanges(),n.pixelStorei(n.UNPACK_ROW_LENGTH,fe),n.pixelStorei(n.UNPACK_SKIP_PIXELS,Te),n.pixelStorei(n.UNPACK_SKIP_ROWS,I)}}function Z(R,v,H){let ne=n.TEXTURE_2D;(v.isDataArrayTexture||v.isCompressedArrayTexture)&&(ne=n.TEXTURE_2D_ARRAY),v.isData3DTexture&&(ne=n.TEXTURE_3D);const re=de(R,v),te=v.source;t.bindTexture(ne,R.__webglTexture,n.TEXTURE0+H);const Re=i.get(te);if(te.version!==Re.__version||re===!0){t.activeTexture(n.TEXTURE0+H);const fe=Qe.getPrimaries(Qe.workingColorSpace),Te=v.colorSpace===ui?null:Qe.getPrimaries(v.colorSpace),I=v.colorSpace===ui||fe===Te?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,v.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,v.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,I);let P=y(v.image,!1,r.maxTextureSize);P=vt(v,P);const U=s.convert(v.format,v.colorSpace),Q=s.convert(v.type);let ie=T(v.internalFormat,U,Q,v.colorSpace,v.isVideoTexture);Be(ne,v);let ae;const we=v.mipmaps,D=v.isVideoTexture!==!0,V=Re.__version===void 0||re===!0,G=te.dataReady,ee=S(v,P);if(v.isDepthTexture)ie=_(v.format===os,v.type),V&&(D?t.texStorage2D(n.TEXTURE_2D,1,ie,P.width,P.height):t.texImage2D(n.TEXTURE_2D,0,ie,P.width,P.height,0,U,Q,null));else if(v.isDataTexture)if(we.length>0){D&&V&&t.texStorage2D(n.TEXTURE_2D,ee,ie,we[0].width,we[0].height);for(let k=0,W=we.length;k<W;k++)ae=we[k],D?G&&t.texSubImage2D(n.TEXTURE_2D,k,0,0,ae.width,ae.height,U,Q,ae.data):t.texImage2D(n.TEXTURE_2D,k,ie,ae.width,ae.height,0,U,Q,ae.data);v.generateMipmaps=!1}else D?(V&&t.texStorage2D(n.TEXTURE_2D,ee,ie,P.width,P.height),G&&Ke(v,P,U,Q)):t.texImage2D(n.TEXTURE_2D,0,ie,P.width,P.height,0,U,Q,P.data);else if(v.isCompressedTexture)if(v.isCompressedArrayTexture){D&&V&&t.texStorage3D(n.TEXTURE_2D_ARRAY,ee,ie,we[0].width,we[0].height,P.depth);for(let k=0,W=we.length;k<W;k++)if(ae=we[k],v.format!==bn)if(U!==null)if(D){if(G)if(v.layerUpdates.size>0){const ue=Su(ae.width,ae.height,v.format,v.type);for(const xe of v.layerUpdates){const We=ae.data.subarray(xe*ue/ae.data.BYTES_PER_ELEMENT,(xe+1)*ue/ae.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,k,0,0,xe,ae.width,ae.height,1,U,We)}v.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,k,0,0,0,ae.width,ae.height,P.depth,U,ae.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,k,ie,ae.width,ae.height,P.depth,0,ae.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else D?G&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,k,0,0,0,ae.width,ae.height,P.depth,U,Q,ae.data):t.texImage3D(n.TEXTURE_2D_ARRAY,k,ie,ae.width,ae.height,P.depth,0,U,Q,ae.data)}else{D&&V&&t.texStorage2D(n.TEXTURE_2D,ee,ie,we[0].width,we[0].height);for(let k=0,W=we.length;k<W;k++)ae=we[k],v.format!==bn?U!==null?D?G&&t.compressedTexSubImage2D(n.TEXTURE_2D,k,0,0,ae.width,ae.height,U,ae.data):t.compressedTexImage2D(n.TEXTURE_2D,k,ie,ae.width,ae.height,0,ae.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):D?G&&t.texSubImage2D(n.TEXTURE_2D,k,0,0,ae.width,ae.height,U,Q,ae.data):t.texImage2D(n.TEXTURE_2D,k,ie,ae.width,ae.height,0,U,Q,ae.data)}else if(v.isDataArrayTexture)if(D){if(V&&t.texStorage3D(n.TEXTURE_2D_ARRAY,ee,ie,P.width,P.height,P.depth),G)if(v.layerUpdates.size>0){const k=Su(P.width,P.height,v.format,v.type);for(const W of v.layerUpdates){const ue=P.data.subarray(W*k/P.data.BYTES_PER_ELEMENT,(W+1)*k/P.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,W,P.width,P.height,1,U,Q,ue)}v.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,P.width,P.height,P.depth,U,Q,P.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,ie,P.width,P.height,P.depth,0,U,Q,P.data);else if(v.isData3DTexture)D?(V&&t.texStorage3D(n.TEXTURE_3D,ee,ie,P.width,P.height,P.depth),G&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,P.width,P.height,P.depth,U,Q,P.data)):t.texImage3D(n.TEXTURE_3D,0,ie,P.width,P.height,P.depth,0,U,Q,P.data);else if(v.isFramebufferTexture){if(V)if(D)t.texStorage2D(n.TEXTURE_2D,ee,ie,P.width,P.height);else{let k=P.width,W=P.height;for(let ue=0;ue<ee;ue++)t.texImage2D(n.TEXTURE_2D,ue,ie,k,W,0,U,Q,null),k>>=1,W>>=1}}else if(we.length>0){if(D&&V){const k=ut(we[0]);t.texStorage2D(n.TEXTURE_2D,ee,ie,k.width,k.height)}for(let k=0,W=we.length;k<W;k++)ae=we[k],D?G&&t.texSubImage2D(n.TEXTURE_2D,k,0,0,U,Q,ae):t.texImage2D(n.TEXTURE_2D,k,ie,U,Q,ae);v.generateMipmaps=!1}else if(D){if(V){const k=ut(P);t.texStorage2D(n.TEXTURE_2D,ee,ie,k.width,k.height)}G&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,U,Q,P)}else t.texImage2D(n.TEXTURE_2D,0,ie,U,Q,P);m(v)&&f(ne),Re.__version=te.version,v.onUpdate&&v.onUpdate(v)}R.__version=v.version}function oe(R,v,H){if(v.image.length!==6)return;const ne=de(R,v),re=v.source;t.bindTexture(n.TEXTURE_CUBE_MAP,R.__webglTexture,n.TEXTURE0+H);const te=i.get(re);if(re.version!==te.__version||ne===!0){t.activeTexture(n.TEXTURE0+H);const Re=Qe.getPrimaries(Qe.workingColorSpace),fe=v.colorSpace===ui?null:Qe.getPrimaries(v.colorSpace),Te=v.colorSpace===ui||Re===fe?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,v.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,v.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Te);const I=v.isCompressedTexture||v.image[0].isCompressedTexture,P=v.image[0]&&v.image[0].isDataTexture,U=[];for(let W=0;W<6;W++)!I&&!P?U[W]=y(v.image[W],!0,r.maxCubemapSize):U[W]=P?v.image[W].image:v.image[W],U[W]=vt(v,U[W]);const Q=U[0],ie=s.convert(v.format,v.colorSpace),ae=s.convert(v.type),we=T(v.internalFormat,ie,ae,v.colorSpace),D=v.isVideoTexture!==!0,V=te.__version===void 0||ne===!0,G=re.dataReady;let ee=S(v,Q);Be(n.TEXTURE_CUBE_MAP,v);let k;if(I){D&&V&&t.texStorage2D(n.TEXTURE_CUBE_MAP,ee,we,Q.width,Q.height);for(let W=0;W<6;W++){k=U[W].mipmaps;for(let ue=0;ue<k.length;ue++){const xe=k[ue];v.format!==bn?ie!==null?D?G&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+W,ue,0,0,xe.width,xe.height,ie,xe.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+W,ue,we,xe.width,xe.height,0,xe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):D?G&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+W,ue,0,0,xe.width,xe.height,ie,ae,xe.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+W,ue,we,xe.width,xe.height,0,ie,ae,xe.data)}}}else{if(k=v.mipmaps,D&&V){k.length>0&&ee++;const W=ut(U[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,ee,we,W.width,W.height)}for(let W=0;W<6;W++)if(P){D?G&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,0,0,U[W].width,U[W].height,ie,ae,U[W].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,we,U[W].width,U[W].height,0,ie,ae,U[W].data);for(let ue=0;ue<k.length;ue++){const We=k[ue].image[W].image;D?G&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+W,ue+1,0,0,We.width,We.height,ie,ae,We.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+W,ue+1,we,We.width,We.height,0,ie,ae,We.data)}}else{D?G&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,0,0,ie,ae,U[W]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,we,ie,ae,U[W]);for(let ue=0;ue<k.length;ue++){const xe=k[ue];D?G&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+W,ue+1,0,0,ie,ae,xe.image[W]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+W,ue+1,we,ie,ae,xe.image[W])}}}m(v)&&f(n.TEXTURE_CUBE_MAP),te.__version=re.version,v.onUpdate&&v.onUpdate(v)}R.__version=v.version}function Me(R,v,H,ne,re,te){const Re=s.convert(H.format,H.colorSpace),fe=s.convert(H.type),Te=T(H.internalFormat,Re,fe,H.colorSpace),I=i.get(v),P=i.get(H);if(P.__renderTarget=v,!I.__hasExternalTextures){const U=Math.max(1,v.width>>te),Q=Math.max(1,v.height>>te);re===n.TEXTURE_3D||re===n.TEXTURE_2D_ARRAY?t.texImage3D(re,te,Te,U,Q,v.depth,0,Re,fe,null):t.texImage2D(re,te,Te,U,Q,0,Re,fe,null)}t.bindFramebuffer(n.FRAMEBUFFER,R),Se(v)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,ne,re,P.__webglTexture,0,st(v)):(re===n.TEXTURE_2D||re>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&re<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,ne,re,P.__webglTexture,te),t.bindFramebuffer(n.FRAMEBUFFER,null)}function Ie(R,v,H){if(n.bindRenderbuffer(n.RENDERBUFFER,R),v.depthBuffer){const ne=v.depthTexture,re=ne&&ne.isDepthTexture?ne.type:null,te=_(v.stencilBuffer,re),Re=v.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,fe=st(v);Se(v)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,fe,te,v.width,v.height):H?n.renderbufferStorageMultisample(n.RENDERBUFFER,fe,te,v.width,v.height):n.renderbufferStorage(n.RENDERBUFFER,te,v.width,v.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,Re,n.RENDERBUFFER,R)}else{const ne=v.textures;for(let re=0;re<ne.length;re++){const te=ne[re],Re=s.convert(te.format,te.colorSpace),fe=s.convert(te.type),Te=T(te.internalFormat,Re,fe,te.colorSpace),I=st(v);H&&Se(v)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,I,Te,v.width,v.height):Se(v)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,I,Te,v.width,v.height):n.renderbufferStorage(n.RENDERBUFFER,Te,v.width,v.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function Ce(R,v){if(v&&v.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(n.FRAMEBUFFER,R),!(v.depthTexture&&v.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const ne=i.get(v.depthTexture);ne.__renderTarget=v,(!ne.__webglTexture||v.depthTexture.image.width!==v.width||v.depthTexture.image.height!==v.height)&&(v.depthTexture.image.width=v.width,v.depthTexture.image.height=v.height,v.depthTexture.needsUpdate=!0),J(v.depthTexture,0);const re=ne.__webglTexture,te=st(v);if(v.depthTexture.format===ss)Se(v)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,re,0,te):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,re,0);else if(v.depthTexture.format===os)Se(v)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,re,0,te):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,re,0);else throw new Error("Unknown depthTexture format")}function ze(R){const v=i.get(R),H=R.isWebGLCubeRenderTarget===!0;if(v.__boundDepthTexture!==R.depthTexture){const ne=R.depthTexture;if(v.__depthDisposeCallback&&v.__depthDisposeCallback(),ne){const re=()=>{delete v.__boundDepthTexture,delete v.__depthDisposeCallback,ne.removeEventListener("dispose",re)};ne.addEventListener("dispose",re),v.__depthDisposeCallback=re}v.__boundDepthTexture=ne}if(R.depthTexture&&!v.__autoAllocateDepthBuffer){if(H)throw new Error("target.depthTexture not supported in Cube render targets");const ne=R.texture.mipmaps;ne&&ne.length>0?Ce(v.__webglFramebuffer[0],R):Ce(v.__webglFramebuffer,R)}else if(H){v.__webglDepthbuffer=[];for(let ne=0;ne<6;ne++)if(t.bindFramebuffer(n.FRAMEBUFFER,v.__webglFramebuffer[ne]),v.__webglDepthbuffer[ne]===void 0)v.__webglDepthbuffer[ne]=n.createRenderbuffer(),Ie(v.__webglDepthbuffer[ne],R,!1);else{const re=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,te=v.__webglDepthbuffer[ne];n.bindRenderbuffer(n.RENDERBUFFER,te),n.framebufferRenderbuffer(n.FRAMEBUFFER,re,n.RENDERBUFFER,te)}}else{const ne=R.texture.mipmaps;if(ne&&ne.length>0?t.bindFramebuffer(n.FRAMEBUFFER,v.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,v.__webglFramebuffer),v.__webglDepthbuffer===void 0)v.__webglDepthbuffer=n.createRenderbuffer(),Ie(v.__webglDepthbuffer,R,!1);else{const re=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,te=v.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,te),n.framebufferRenderbuffer(n.FRAMEBUFFER,re,n.RENDERBUFFER,te)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function St(R,v,H){const ne=i.get(R);v!==void 0&&Me(ne.__webglFramebuffer,R,R.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),H!==void 0&&ze(R)}function L(R){const v=R.texture,H=i.get(R),ne=i.get(v);R.addEventListener("dispose",A);const re=R.textures,te=R.isWebGLCubeRenderTarget===!0,Re=re.length>1;if(Re||(ne.__webglTexture===void 0&&(ne.__webglTexture=n.createTexture()),ne.__version=v.version,o.memory.textures++),te){H.__webglFramebuffer=[];for(let fe=0;fe<6;fe++)if(v.mipmaps&&v.mipmaps.length>0){H.__webglFramebuffer[fe]=[];for(let Te=0;Te<v.mipmaps.length;Te++)H.__webglFramebuffer[fe][Te]=n.createFramebuffer()}else H.__webglFramebuffer[fe]=n.createFramebuffer()}else{if(v.mipmaps&&v.mipmaps.length>0){H.__webglFramebuffer=[];for(let fe=0;fe<v.mipmaps.length;fe++)H.__webglFramebuffer[fe]=n.createFramebuffer()}else H.__webglFramebuffer=n.createFramebuffer();if(Re)for(let fe=0,Te=re.length;fe<Te;fe++){const I=i.get(re[fe]);I.__webglTexture===void 0&&(I.__webglTexture=n.createTexture(),o.memory.textures++)}if(R.samples>0&&Se(R)===!1){H.__webglMultisampledFramebuffer=n.createFramebuffer(),H.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,H.__webglMultisampledFramebuffer);for(let fe=0;fe<re.length;fe++){const Te=re[fe];H.__webglColorRenderbuffer[fe]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,H.__webglColorRenderbuffer[fe]);const I=s.convert(Te.format,Te.colorSpace),P=s.convert(Te.type),U=T(Te.internalFormat,I,P,Te.colorSpace,R.isXRRenderTarget===!0),Q=st(R);n.renderbufferStorageMultisample(n.RENDERBUFFER,Q,U,R.width,R.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+fe,n.RENDERBUFFER,H.__webglColorRenderbuffer[fe])}n.bindRenderbuffer(n.RENDERBUFFER,null),R.depthBuffer&&(H.__webglDepthRenderbuffer=n.createRenderbuffer(),Ie(H.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(te){t.bindTexture(n.TEXTURE_CUBE_MAP,ne.__webglTexture),Be(n.TEXTURE_CUBE_MAP,v);for(let fe=0;fe<6;fe++)if(v.mipmaps&&v.mipmaps.length>0)for(let Te=0;Te<v.mipmaps.length;Te++)Me(H.__webglFramebuffer[fe][Te],R,v,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Te);else Me(H.__webglFramebuffer[fe],R,v,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+fe,0);m(v)&&f(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Re){for(let fe=0,Te=re.length;fe<Te;fe++){const I=re[fe],P=i.get(I);let U=n.TEXTURE_2D;(R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(U=R.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(U,P.__webglTexture),Be(U,I),Me(H.__webglFramebuffer,R,I,n.COLOR_ATTACHMENT0+fe,U,0),m(I)&&f(U)}t.unbindTexture()}else{let fe=n.TEXTURE_2D;if((R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(fe=R.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(fe,ne.__webglTexture),Be(fe,v),v.mipmaps&&v.mipmaps.length>0)for(let Te=0;Te<v.mipmaps.length;Te++)Me(H.__webglFramebuffer[Te],R,v,n.COLOR_ATTACHMENT0,fe,Te);else Me(H.__webglFramebuffer,R,v,n.COLOR_ATTACHMENT0,fe,0);m(v)&&f(fe),t.unbindTexture()}R.depthBuffer&&ze(R)}function rt(R){const v=R.textures;for(let H=0,ne=v.length;H<ne;H++){const re=v[H];if(m(re)){const te=w(R),Re=i.get(re).__webglTexture;t.bindTexture(te,Re),f(te),t.unbindTexture()}}}const Ve=[],De=[];function be(R){if(R.samples>0){if(Se(R)===!1){const v=R.textures,H=R.width,ne=R.height;let re=n.COLOR_BUFFER_BIT;const te=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Re=i.get(R),fe=v.length>1;if(fe)for(let I=0;I<v.length;I++)t.bindFramebuffer(n.FRAMEBUFFER,Re.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+I,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,Re.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+I,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,Re.__webglMultisampledFramebuffer);const Te=R.texture.mipmaps;Te&&Te.length>0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Re.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Re.__webglFramebuffer);for(let I=0;I<v.length;I++){if(R.resolveDepthBuffer&&(R.depthBuffer&&(re|=n.DEPTH_BUFFER_BIT),R.stencilBuffer&&R.resolveStencilBuffer&&(re|=n.STENCIL_BUFFER_BIT)),fe){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,Re.__webglColorRenderbuffer[I]);const P=i.get(v[I]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,P,0)}n.blitFramebuffer(0,0,H,ne,0,0,H,ne,re,n.NEAREST),l===!0&&(Ve.length=0,De.length=0,Ve.push(n.COLOR_ATTACHMENT0+I),R.depthBuffer&&R.resolveDepthBuffer===!1&&(Ve.push(te),De.push(te),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,De)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,Ve))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),fe)for(let I=0;I<v.length;I++){t.bindFramebuffer(n.FRAMEBUFFER,Re.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+I,n.RENDERBUFFER,Re.__webglColorRenderbuffer[I]);const P=i.get(v[I]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,Re.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+I,n.TEXTURE_2D,P,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Re.__webglMultisampledFramebuffer)}else if(R.depthBuffer&&R.resolveDepthBuffer===!1&&l){const v=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[v])}}}function st(R){return Math.min(r.maxSamples,R.samples)}function Se(R){const v=i.get(R);return R.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&v.__useRenderToTexture!==!1}function He(R){const v=o.render.frame;u.get(R)!==v&&(u.set(R,v),R.update())}function vt(R,v){const H=R.colorSpace,ne=R.format,re=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||H!==Cr&&H!==ui&&(Qe.getTransfer(H)===nt?(ne!==bn||re!==kn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",H)),v}function ut(R){return typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement?(c.width=R.naturalWidth||R.width,c.height=R.naturalHeight||R.height):typeof VideoFrame<"u"&&R instanceof VideoFrame?(c.width=R.displayWidth,c.height=R.displayHeight):(c.width=R.width,c.height=R.height),c}this.allocateTextureUnit=Y,this.resetTextureUnits=z,this.setTexture2D=J,this.setTexture2DArray=K,this.setTexture3D=se,this.setTextureCube=$,this.rebindTextures=St,this.setupRenderTarget=L,this.updateRenderTargetMipmap=rt,this.updateMultisampleRenderTarget=be,this.setupDepthRenderbuffer=ze,this.setupFrameBufferTexture=Me,this.useMultisampledRTT=Se}function x0(n,e){function t(i,r=ui){let s;const o=Qe.getTransfer(r);if(i===kn)return n.UNSIGNED_BYTE;if(i===rc)return n.UNSIGNED_SHORT_4_4_4_4;if(i===sc)return n.UNSIGNED_SHORT_5_5_5_1;if(i===Bh)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===zh)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===Uh)return n.BYTE;if(i===Fh)return n.SHORT;if(i===is)return n.UNSIGNED_SHORT;if(i===ic)return n.INT;if(i===Hi)return n.UNSIGNED_INT;if(i===Jn)return n.FLOAT;if(i===ds)return n.HALF_FLOAT;if(i===Vh)return n.ALPHA;if(i===Hh)return n.RGB;if(i===bn)return n.RGBA;if(i===ss)return n.DEPTH_COMPONENT;if(i===os)return n.DEPTH_STENCIL;if(i===kh)return n.RED;if(i===oc)return n.RED_INTEGER;if(i===Gh)return n.RG;if(i===ac)return n.RG_INTEGER;if(i===lc)return n.RGBA_INTEGER;if(i===so||i===oo||i===ao||i===lo)if(o===nt)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===so)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===oo)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===ao)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===lo)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===so)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===oo)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===ao)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===lo)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Za||i===Ka||i===Ja||i===Qa)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Za)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Ka)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Ja)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Qa)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===el||i===tl||i===nl)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(i===el||i===tl)return o===nt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===nl)return o===nt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===il||i===rl||i===sl||i===ol||i===al||i===ll||i===cl||i===ul||i===hl||i===fl||i===dl||i===pl||i===ml||i===_l)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(i===il)return o===nt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===rl)return o===nt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===sl)return o===nt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===ol)return o===nt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===al)return o===nt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===ll)return o===nt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===cl)return o===nt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===ul)return o===nt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===hl)return o===nt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===fl)return o===nt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===dl)return o===nt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===pl)return o===nt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===ml)return o===nt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===_l)return o===nt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===gl||i===vl||i===xl)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===gl)return o===nt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===vl)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===xl)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===yl||i===Ml||i===El||i===bl)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(i===yl)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Ml)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===El)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===bl)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===rs?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}const y0=`
3944
+ }`;function jy(i,t,e){let n=new tu;const s=new Nt,r=new Nt,a=new Se,o=new u_({depthPacking:b0}),l=new d_,c={},h=e.maxTextureSize,u={[Ji]:on,[on]:Ji,[si]:si},d=new Di({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Nt},radius:{value:4}},vertexShader:Wy,fragmentShader:Xy}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const m=new De;m.setAttribute("position",new Yn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const x=new gt(m,d),_=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ep;let p=this.type;this.render=function(v,A,R){if(_.enabled===!1||_.autoUpdate===!1&&_.needsUpdate===!1||v.length===0)return;const M=i.getRenderTarget(),g=i.getActiveCubeFace(),O=i.getActiveMipmapLevel(),F=i.state;F.setBlending(Ai),F.buffers.depth.getReversed()===!0?F.buffers.color.setClear(0,0,0,0):F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);const k=p!==bi&&this.type===bi,G=p===bi&&this.type!==bi;for(let K=0,tt=v.length;K<tt;K++){const lt=v[K],$=lt.shadow;if($===void 0){kt("WebGLShadowMap:",lt,"has no shadow.");continue}if($.autoUpdate===!1&&$.needsUpdate===!1)continue;s.copy($.mapSize);const st=$.getFrameExtents();if(s.multiply(st),r.copy($.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/st.x),s.x=r.x*st.x,$.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/st.y),s.y=r.y*st.y,$.mapSize.y=r.y)),$.map===null||k===!0||G===!0){const Et=this.type!==bi?{minFilter:xn,magFilter:xn}:{};$.map!==null&&$.map.dispose(),$.map=new Ts(s.x,s.y,Et),$.map.texture.name=lt.name+".shadowMap",$.camera.updateProjectionMatrix()}i.setRenderTarget($.map),i.clear();const ct=$.getViewportCount();for(let Et=0;Et<ct;Et++){const Vt=$.getViewport(Et);a.set(r.x*Vt.x,r.y*Vt.y,r.x*Vt.z,r.y*Vt.w),F.viewport(a),$.updateMatrices(lt,Et),n=$.getFrustum(),y(A,R,$.camera,lt,this.type)}$.isPointLightShadow!==!0&&this.type===bi&&w($,R),$.needsUpdate=!1}p=this.type,_.needsUpdate=!1,i.setRenderTarget(M,g,O)};function w(v,A){const R=t.update(x);d.defines.VSM_SAMPLES!==v.blurSamples&&(d.defines.VSM_SAMPLES=v.blurSamples,f.defines.VSM_SAMPLES=v.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),v.mapPass===null&&(v.mapPass=new Ts(s.x,s.y)),d.uniforms.shadow_pass.value=v.map.texture,d.uniforms.resolution.value=v.mapSize,d.uniforms.radius.value=v.radius,i.setRenderTarget(v.mapPass),i.clear(),i.renderBufferDirect(A,null,R,d,x,null),f.uniforms.shadow_pass.value=v.mapPass.texture,f.uniforms.resolution.value=v.mapSize,f.uniforms.radius.value=v.radius,i.setRenderTarget(v.map),i.clear(),i.renderBufferDirect(A,null,R,f,x,null)}function S(v,A,R,M){let g=null;const O=R.isPointLight===!0?v.customDistanceMaterial:v.customDepthMaterial;if(O!==void 0)g=O;else if(g=R.isPointLight===!0?l:o,i.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){const F=g.uuid,k=A.uuid;let G=c[F];G===void 0&&(G={},c[F]=G);let K=G[k];K===void 0&&(K=g.clone(),G[k]=K,A.addEventListener("dispose",E)),g=K}if(g.visible=A.visible,g.wireframe=A.wireframe,M===bi?g.side=A.shadowSide!==null?A.shadowSide:A.side:g.side=A.shadowSide!==null?A.shadowSide:u[A.side],g.alphaMap=A.alphaMap,g.alphaTest=A.alphaToCoverage===!0?.5:A.alphaTest,g.map=A.map,g.clipShadows=A.clipShadows,g.clippingPlanes=A.clippingPlanes,g.clipIntersection=A.clipIntersection,g.displacementMap=A.displacementMap,g.displacementScale=A.displacementScale,g.displacementBias=A.displacementBias,g.wireframeLinewidth=A.wireframeLinewidth,g.linewidth=A.linewidth,R.isPointLight===!0&&g.isMeshDistanceMaterial===!0){const F=i.properties.get(g);F.light=R}return g}function y(v,A,R,M,g){if(v.visible===!1)return;if(v.layers.test(A.layers)&&(v.isMesh||v.isLine||v.isPoints)&&(v.castShadow||v.receiveShadow&&g===bi)&&(!v.frustumCulled||n.intersectsObject(v))){v.modelViewMatrix.multiplyMatrices(R.matrixWorldInverse,v.matrixWorld);const k=t.update(v),G=v.material;if(Array.isArray(G)){const K=k.groups;for(let tt=0,lt=K.length;tt<lt;tt++){const $=K[tt],st=G[$.materialIndex];if(st&&st.visible){const ct=S(v,st,M,g);v.onBeforeShadow(i,v,A,R,k,ct,$),i.renderBufferDirect(R,null,k,ct,v,$),v.onAfterShadow(i,v,A,R,k,ct,$)}}}else if(G.visible){const K=S(v,G,M,g);v.onBeforeShadow(i,v,A,R,k,K,null),i.renderBufferDirect(R,null,k,K,v,null),v.onAfterShadow(i,v,A,R,k,K,null)}}const F=v.children;for(let k=0,G=F.length;k<G;k++)y(F[k],A,R,M,g)}function E(v){v.target.removeEventListener("dispose",E);for(const R in c){const M=c[R],g=v.target.uuid;g in M&&(M[g].dispose(),delete M[g])}}}const Yy={[Ac]:Cc,[Rc]:Oc,[Pc]:Lc,[Mr]:Dc,[Cc]:Ac,[Oc]:Rc,[Lc]:Pc,[Dc]:Mr};function qy(i,t){function e(){let P=!1;const W=new Se;let X=null;const Y=new Se(0,0,0,0);return{setMask:function(H){X!==H&&!P&&(i.colorMask(H,H,H,H),X=H)},setLocked:function(H){P=H},setClear:function(H,j,ut,bt,Yt){Yt===!0&&(H*=bt,j*=bt,ut*=bt),W.set(H,j,ut,bt),Y.equals(W)===!1&&(i.clearColor(H,j,ut,bt),Y.copy(W))},reset:function(){P=!1,X=null,Y.set(-1,0,0,0)}}}function n(){let P=!1,W=!1,X=null,Y=null,H=null;return{setReversed:function(j){if(W!==j){const ut=t.get("EXT_clip_control");j?ut.clipControlEXT(ut.LOWER_LEFT_EXT,ut.ZERO_TO_ONE_EXT):ut.clipControlEXT(ut.LOWER_LEFT_EXT,ut.NEGATIVE_ONE_TO_ONE_EXT),W=j;const bt=H;H=null,this.setClear(bt)}},getReversed:function(){return W},setTest:function(j){j?rt(i.DEPTH_TEST):Mt(i.DEPTH_TEST)},setMask:function(j){X!==j&&!P&&(i.depthMask(j),X=j)},setFunc:function(j){if(W&&(j=Yy[j]),Y!==j){switch(j){case Ac:i.depthFunc(i.NEVER);break;case Cc:i.depthFunc(i.ALWAYS);break;case Rc:i.depthFunc(i.LESS);break;case Mr:i.depthFunc(i.LEQUAL);break;case Pc:i.depthFunc(i.EQUAL);break;case Dc:i.depthFunc(i.GEQUAL);break;case Oc:i.depthFunc(i.GREATER);break;case Lc:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}Y=j}},setLocked:function(j){P=j},setClear:function(j){H!==j&&(W&&(j=1-j),i.clearDepth(j),H=j)},reset:function(){P=!1,X=null,Y=null,H=null,W=!1}}}function s(){let P=!1,W=null,X=null,Y=null,H=null,j=null,ut=null,bt=null,Yt=null;return{setTest:function(ne){P||(ne?rt(i.STENCIL_TEST):Mt(i.STENCIL_TEST))},setMask:function(ne){W!==ne&&!P&&(i.stencilMask(ne),W=ne)},setFunc:function(ne,Mn,ln){(X!==ne||Y!==Mn||H!==ln)&&(i.stencilFunc(ne,Mn,ln),X=ne,Y=Mn,H=ln)},setOp:function(ne,Mn,ln){(j!==ne||ut!==Mn||bt!==ln)&&(i.stencilOp(ne,Mn,ln),j=ne,ut=Mn,bt=ln)},setLocked:function(ne){P=ne},setClear:function(ne){Yt!==ne&&(i.clearStencil(ne),Yt=ne)},reset:function(){P=!1,W=null,X=null,Y=null,H=null,j=null,ut=null,bt=null,Yt=null}}}const r=new e,a=new n,o=new s,l=new WeakMap,c=new WeakMap;let h={},u={},d=new WeakMap,f=[],m=null,x=!1,_=null,p=null,w=null,S=null,y=null,E=null,v=null,A=new Zt(0,0,0),R=0,M=!1,g=null,O=null,F=null,k=null,G=null;const K=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let tt=!1,lt=0;const $=i.getParameter(i.VERSION);$.indexOf("WebGL")!==-1?(lt=parseFloat(/^WebGL (\d)/.exec($)[1]),tt=lt>=1):$.indexOf("OpenGL ES")!==-1&&(lt=parseFloat(/^OpenGL ES (\d)/.exec($)[1]),tt=lt>=2);let st=null,ct={};const Et=i.getParameter(i.SCISSOR_BOX),Vt=i.getParameter(i.VIEWPORT),pt=new Se().fromArray(Et),$t=new Se().fromArray(Vt);function se(P,W,X,Y){const H=new Uint8Array(4),j=i.createTexture();i.bindTexture(P,j),i.texParameteri(P,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(P,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let ut=0;ut<X;ut++)P===i.TEXTURE_3D||P===i.TEXTURE_2D_ARRAY?i.texImage3D(W,0,i.RGBA,1,1,Y,0,i.RGBA,i.UNSIGNED_BYTE,H):i.texImage2D(W+ut,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,H);return j}const J={};J[i.TEXTURE_2D]=se(i.TEXTURE_2D,i.TEXTURE_2D,1),J[i.TEXTURE_CUBE_MAP]=se(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),J[i.TEXTURE_2D_ARRAY]=se(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),J[i.TEXTURE_3D]=se(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),rt(i.DEPTH_TEST),a.setFunc(Mr),Wt(!1),jt(Iu),rt(i.CULL_FACE),he(Ai);function rt(P){h[P]!==!0&&(i.enable(P),h[P]=!0)}function Mt(P){h[P]!==!1&&(i.disable(P),h[P]=!1)}function Bt(P,W){return u[P]!==W?(i.bindFramebuffer(P,W),u[P]=W,P===i.DRAW_FRAMEBUFFER&&(u[i.FRAMEBUFFER]=W),P===i.FRAMEBUFFER&&(u[i.DRAW_FRAMEBUFFER]=W),!0):!1}function Ct(P,W){let X=f,Y=!1;if(P){X=d.get(W),X===void 0&&(X=[],d.set(W,X));const H=P.textures;if(X.length!==H.length||X[0]!==i.COLOR_ATTACHMENT0){for(let j=0,ut=H.length;j<ut;j++)X[j]=i.COLOR_ATTACHMENT0+j;X.length=H.length,Y=!0}}else X[0]!==i.BACK&&(X[0]=i.BACK,Y=!0);Y&&i.drawBuffers(X)}function It(P){return m!==P?(i.useProgram(P),m=P,!0):!1}const Ae={[xs]:i.FUNC_ADD,[Ym]:i.FUNC_SUBTRACT,[qm]:i.FUNC_REVERSE_SUBTRACT};Ae[Zm]=i.MIN,Ae[$m]=i.MAX;const Ht={[Km]:i.ZERO,[Jm]:i.ONE,[Qm]:i.SRC_COLOR,[wc]:i.SRC_ALPHA,[r0]:i.SRC_ALPHA_SATURATE,[i0]:i.DST_COLOR,[e0]:i.DST_ALPHA,[t0]:i.ONE_MINUS_SRC_COLOR,[Tc]:i.ONE_MINUS_SRC_ALPHA,[s0]:i.ONE_MINUS_DST_COLOR,[n0]:i.ONE_MINUS_DST_ALPHA,[a0]:i.CONSTANT_COLOR,[o0]:i.ONE_MINUS_CONSTANT_COLOR,[l0]:i.CONSTANT_ALPHA,[c0]:i.ONE_MINUS_CONSTANT_ALPHA};function he(P,W,X,Y,H,j,ut,bt,Yt,ne){if(P===Ai){x===!0&&(Mt(i.BLEND),x=!1);return}if(x===!1&&(rt(i.BLEND),x=!0),P!==jm){if(P!==_||ne!==M){if((p!==xs||y!==xs)&&(i.blendEquation(i.FUNC_ADD),p=xs,y=xs),ne)switch(P){case mr:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Uu:i.blendFunc(i.ONE,i.ONE);break;case Fu:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case zu:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:Me("WebGLState: Invalid blending: ",P);break}else switch(P){case mr:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Uu:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case Fu:Me("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case zu:Me("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Me("WebGLState: Invalid blending: ",P);break}w=null,S=null,E=null,v=null,A.set(0,0,0),R=0,_=P,M=ne}return}H=H||W,j=j||X,ut=ut||Y,(W!==p||H!==y)&&(i.blendEquationSeparate(Ae[W],Ae[H]),p=W,y=H),(X!==w||Y!==S||j!==E||ut!==v)&&(i.blendFuncSeparate(Ht[X],Ht[Y],Ht[j],Ht[ut]),w=X,S=Y,E=j,v=ut),(bt.equals(A)===!1||Yt!==R)&&(i.blendColor(bt.r,bt.g,bt.b,Yt),A.copy(bt),R=Yt),_=P,M=!1}function N(P,W){P.side===si?Mt(i.CULL_FACE):rt(i.CULL_FACE);let X=P.side===on;W&&(X=!X),Wt(X),P.blending===mr&&P.transparent===!1?he(Ai):he(P.blending,P.blendEquation,P.blendSrc,P.blendDst,P.blendEquationAlpha,P.blendSrcAlpha,P.blendDstAlpha,P.blendColor,P.blendAlpha,P.premultipliedAlpha),a.setFunc(P.depthFunc),a.setTest(P.depthTest),a.setMask(P.depthWrite),r.setMask(P.colorWrite);const Y=P.stencilWrite;o.setTest(Y),Y&&(o.setMask(P.stencilWriteMask),o.setFunc(P.stencilFunc,P.stencilRef,P.stencilFuncMask),o.setOp(P.stencilFail,P.stencilZFail,P.stencilZPass)),wt(P.polygonOffset,P.polygonOffsetFactor,P.polygonOffsetUnits),P.alphaToCoverage===!0?rt(i.SAMPLE_ALPHA_TO_COVERAGE):Mt(i.SAMPLE_ALPHA_TO_COVERAGE)}function Wt(P){g!==P&&(P?i.frontFace(i.CW):i.frontFace(i.CCW),g=P)}function jt(P){P!==Gm?(rt(i.CULL_FACE),P!==O&&(P===Iu?i.cullFace(i.BACK):P===Wm?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):Mt(i.CULL_FACE),O=P}function ie(P){P!==F&&(tt&&i.lineWidth(P),F=P)}function wt(P,W,X){P?(rt(i.POLYGON_OFFSET_FILL),(k!==W||G!==X)&&(i.polygonOffset(W,X),k=W,G=X)):Mt(i.POLYGON_OFFSET_FILL)}function pe(P){P?rt(i.SCISSOR_TEST):Mt(i.SCISSOR_TEST)}function Rt(P){P===void 0&&(P=i.TEXTURE0+K-1),st!==P&&(i.activeTexture(P),st=P)}function Ut(P,W,X){X===void 0&&(st===null?X=i.TEXTURE0+K-1:X=st);let Y=ct[X];Y===void 0&&(Y={type:void 0,texture:void 0},ct[X]=Y),(Y.type!==P||Y.texture!==W)&&(st!==X&&(i.activeTexture(X),st=X),i.bindTexture(P,W||J[P]),Y.type=P,Y.texture=W)}function C(){const P=ct[st];P!==void 0&&P.type!==void 0&&(i.bindTexture(P.type,null),P.type=void 0,P.texture=void 0)}function b(){try{i.compressedTexImage2D(...arguments)}catch(P){P("WebGLState:",P)}}function V(){try{i.compressedTexImage3D(...arguments)}catch(P){P("WebGLState:",P)}}function nt(){try{i.texSubImage2D(...arguments)}catch(P){P("WebGLState:",P)}}function it(){try{i.texSubImage3D(...arguments)}catch(P){P("WebGLState:",P)}}function Q(){try{i.compressedTexSubImage2D(...arguments)}catch(P){P("WebGLState:",P)}}function At(){try{i.compressedTexSubImage3D(...arguments)}catch(P){P("WebGLState:",P)}}function mt(){try{i.texStorage2D(...arguments)}catch(P){P("WebGLState:",P)}}function Pt(){try{i.texStorage3D(...arguments)}catch(P){P("WebGLState:",P)}}function L(){try{i.texImage2D(...arguments)}catch(P){P("WebGLState:",P)}}function D(){try{i.texImage3D(...arguments)}catch(P){P("WebGLState:",P)}}function U(P){pt.equals(P)===!1&&(i.scissor(P.x,P.y,P.z,P.w),pt.copy(P))}function et(P){$t.equals(P)===!1&&(i.viewport(P.x,P.y,P.z,P.w),$t.copy(P))}function ot(P,W){let X=c.get(W);X===void 0&&(X=new WeakMap,c.set(W,X));let Y=X.get(P);Y===void 0&&(Y=i.getUniformBlockIndex(W,P.name),X.set(P,Y))}function ht(P,W){const Y=c.get(W).get(P);l.get(W)!==Y&&(i.uniformBlockBinding(W,Y,P.__bindingPointIndex),l.set(W,Y))}function yt(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),a.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),h={},st=null,ct={},u={},d=new WeakMap,f=[],m=null,x=!1,_=null,p=null,w=null,S=null,y=null,E=null,v=null,A=new Zt(0,0,0),R=0,M=!1,g=null,O=null,F=null,k=null,G=null,pt.set(0,0,i.canvas.width,i.canvas.height),$t.set(0,0,i.canvas.width,i.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:rt,disable:Mt,bindFramebuffer:Bt,drawBuffers:Ct,useProgram:It,setBlending:he,setMaterial:N,setFlipSided:Wt,setCullFace:jt,setLineWidth:ie,setPolygonOffset:wt,setScissorTest:pe,activeTexture:Rt,bindTexture:Ut,unbindTexture:C,compressedTexImage2D:b,compressedTexImage3D:V,texImage2D:L,texImage3D:D,updateUBOMapping:ot,uniformBlockBinding:ht,texStorage2D:mt,texStorage3D:Pt,texSubImage2D:nt,texSubImage3D:it,compressedTexSubImage2D:Q,compressedTexSubImage3D:At,scissor:U,viewport:et,reset:yt}}function Zy(i,t,e,n,s,r,a){const o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Nt,h=new WeakMap;let u;const d=new WeakMap;let f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function m(C,b){return f?new OffscreenCanvas(C,b):Fo("canvas")}function x(C,b,V){let nt=1;const it=Ut(C);if((it.width>V||it.height>V)&&(nt=V/Math.max(it.width,it.height)),nt<1)if(typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&C instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&C instanceof ImageBitmap||typeof VideoFrame<"u"&&C instanceof VideoFrame){const Q=Math.floor(nt*it.width),At=Math.floor(nt*it.height);u===void 0&&(u=m(Q,At));const mt=b?m(Q,At):u;return mt.width=Q,mt.height=At,mt.getContext("2d").drawImage(C,0,0,Q,At),kt("WebGLRenderer: Texture has been resized from ("+it.width+"x"+it.height+") to ("+Q+"x"+At+")."),mt}else return"data"in C&&kt("WebGLRenderer: Image in DataTexture is too big ("+it.width+"x"+it.height+")."),C;return C}function _(C){return C.generateMipmaps}function p(C){i.generateMipmap(C)}function w(C){return C.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:C.isWebGL3DRenderTarget?i.TEXTURE_3D:C.isWebGLArrayRenderTarget||C.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function S(C,b,V,nt,it=!1){if(C!==null){if(i[C]!==void 0)return i[C];kt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+C+"'")}let Q=b;if(b===i.RED&&(V===i.FLOAT&&(Q=i.R32F),V===i.HALF_FLOAT&&(Q=i.R16F),V===i.UNSIGNED_BYTE&&(Q=i.R8)),b===i.RED_INTEGER&&(V===i.UNSIGNED_BYTE&&(Q=i.R8UI),V===i.UNSIGNED_SHORT&&(Q=i.R16UI),V===i.UNSIGNED_INT&&(Q=i.R32UI),V===i.BYTE&&(Q=i.R8I),V===i.SHORT&&(Q=i.R16I),V===i.INT&&(Q=i.R32I)),b===i.RG&&(V===i.FLOAT&&(Q=i.RG32F),V===i.HALF_FLOAT&&(Q=i.RG16F),V===i.UNSIGNED_BYTE&&(Q=i.RG8)),b===i.RG_INTEGER&&(V===i.UNSIGNED_BYTE&&(Q=i.RG8UI),V===i.UNSIGNED_SHORT&&(Q=i.RG16UI),V===i.UNSIGNED_INT&&(Q=i.RG32UI),V===i.BYTE&&(Q=i.RG8I),V===i.SHORT&&(Q=i.RG16I),V===i.INT&&(Q=i.RG32I)),b===i.RGB_INTEGER&&(V===i.UNSIGNED_BYTE&&(Q=i.RGB8UI),V===i.UNSIGNED_SHORT&&(Q=i.RGB16UI),V===i.UNSIGNED_INT&&(Q=i.RGB32UI),V===i.BYTE&&(Q=i.RGB8I),V===i.SHORT&&(Q=i.RGB16I),V===i.INT&&(Q=i.RGB32I)),b===i.RGBA_INTEGER&&(V===i.UNSIGNED_BYTE&&(Q=i.RGBA8UI),V===i.UNSIGNED_SHORT&&(Q=i.RGBA16UI),V===i.UNSIGNED_INT&&(Q=i.RGBA32UI),V===i.BYTE&&(Q=i.RGBA8I),V===i.SHORT&&(Q=i.RGBA16I),V===i.INT&&(Q=i.RGBA32I)),b===i.RGB&&(V===i.UNSIGNED_INT_5_9_9_9_REV&&(Q=i.RGB9_E5),V===i.UNSIGNED_INT_10F_11F_11F_REV&&(Q=i.R11F_G11F_B10F)),b===i.RGBA){const At=it?Io:te.getTransfer(nt);V===i.FLOAT&&(Q=i.RGBA32F),V===i.HALF_FLOAT&&(Q=i.RGBA16F),V===i.UNSIGNED_BYTE&&(Q=At===ae?i.SRGB8_ALPHA8:i.RGBA8),V===i.UNSIGNED_SHORT_4_4_4_4&&(Q=i.RGBA4),V===i.UNSIGNED_SHORT_5_5_5_1&&(Q=i.RGB5_A1)}return(Q===i.R16F||Q===i.R32F||Q===i.RG16F||Q===i.RG32F||Q===i.RGBA16F||Q===i.RGBA32F)&&t.get("EXT_color_buffer_float"),Q}function y(C,b){let V;return C?b===null||b===ws||b===la?V=i.DEPTH24_STENCIL8:b===Ti?V=i.DEPTH32F_STENCIL8:b===oa&&(V=i.DEPTH24_STENCIL8,kt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):b===null||b===ws||b===la?V=i.DEPTH_COMPONENT24:b===Ti?V=i.DEPTH_COMPONENT32F:b===oa&&(V=i.DEPTH_COMPONENT16),V}function E(C,b){return _(C)===!0||C.isFramebufferTexture&&C.minFilter!==xn&&C.minFilter!==On?Math.log2(Math.max(b.width,b.height))+1:C.mipmaps!==void 0&&C.mipmaps.length>0?C.mipmaps.length:C.isCompressedTexture&&Array.isArray(C.image)?b.mipmaps.length:1}function v(C){const b=C.target;b.removeEventListener("dispose",v),R(b),b.isVideoTexture&&h.delete(b)}function A(C){const b=C.target;b.removeEventListener("dispose",A),g(b)}function R(C){const b=n.get(C);if(b.__webglInit===void 0)return;const V=C.source,nt=d.get(V);if(nt){const it=nt[b.__cacheKey];it.usedTimes--,it.usedTimes===0&&M(C),Object.keys(nt).length===0&&d.delete(V)}n.remove(C)}function M(C){const b=n.get(C);i.deleteTexture(b.__webglTexture);const V=C.source,nt=d.get(V);delete nt[b.__cacheKey],a.memory.textures--}function g(C){const b=n.get(C);if(C.depthTexture&&(C.depthTexture.dispose(),n.remove(C.depthTexture)),C.isWebGLCubeRenderTarget)for(let nt=0;nt<6;nt++){if(Array.isArray(b.__webglFramebuffer[nt]))for(let it=0;it<b.__webglFramebuffer[nt].length;it++)i.deleteFramebuffer(b.__webglFramebuffer[nt][it]);else i.deleteFramebuffer(b.__webglFramebuffer[nt]);b.__webglDepthbuffer&&i.deleteRenderbuffer(b.__webglDepthbuffer[nt])}else{if(Array.isArray(b.__webglFramebuffer))for(let nt=0;nt<b.__webglFramebuffer.length;nt++)i.deleteFramebuffer(b.__webglFramebuffer[nt]);else i.deleteFramebuffer(b.__webglFramebuffer);if(b.__webglDepthbuffer&&i.deleteRenderbuffer(b.__webglDepthbuffer),b.__webglMultisampledFramebuffer&&i.deleteFramebuffer(b.__webglMultisampledFramebuffer),b.__webglColorRenderbuffer)for(let nt=0;nt<b.__webglColorRenderbuffer.length;nt++)b.__webglColorRenderbuffer[nt]&&i.deleteRenderbuffer(b.__webglColorRenderbuffer[nt]);b.__webglDepthRenderbuffer&&i.deleteRenderbuffer(b.__webglDepthRenderbuffer)}const V=C.textures;for(let nt=0,it=V.length;nt<it;nt++){const Q=n.get(V[nt]);Q.__webglTexture&&(i.deleteTexture(Q.__webglTexture),a.memory.textures--),n.remove(V[nt])}n.remove(C)}let O=0;function F(){O=0}function k(){const C=O;return C>=s.maxTextures&&kt("WebGLTextures: Trying to use "+C+" texture units while this GPU supports only "+s.maxTextures),O+=1,C}function G(C){const b=[];return b.push(C.wrapS),b.push(C.wrapT),b.push(C.wrapR||0),b.push(C.magFilter),b.push(C.minFilter),b.push(C.anisotropy),b.push(C.internalFormat),b.push(C.format),b.push(C.type),b.push(C.generateMipmaps),b.push(C.premultiplyAlpha),b.push(C.flipY),b.push(C.unpackAlignment),b.push(C.colorSpace),b.join()}function K(C,b){const V=n.get(C);if(C.isVideoTexture&&pe(C),C.isRenderTargetTexture===!1&&C.isExternalTexture!==!0&&C.version>0&&V.__version!==C.version){const nt=C.image;if(nt===null)kt("WebGLRenderer: Texture marked for update but no image data found.");else if(nt.complete===!1)kt("WebGLRenderer: Texture marked for update but image is incomplete");else{J(V,C,b);return}}else C.isExternalTexture&&(V.__webglTexture=C.sourceTexture?C.sourceTexture:null);e.bindTexture(i.TEXTURE_2D,V.__webglTexture,i.TEXTURE0+b)}function tt(C,b){const V=n.get(C);if(C.isRenderTargetTexture===!1&&C.version>0&&V.__version!==C.version){J(V,C,b);return}else C.isExternalTexture&&(V.__webglTexture=C.sourceTexture?C.sourceTexture:null);e.bindTexture(i.TEXTURE_2D_ARRAY,V.__webglTexture,i.TEXTURE0+b)}function lt(C,b){const V=n.get(C);if(C.isRenderTargetTexture===!1&&C.version>0&&V.__version!==C.version){J(V,C,b);return}e.bindTexture(i.TEXTURE_3D,V.__webglTexture,i.TEXTURE0+b)}function $(C,b){const V=n.get(C);if(C.version>0&&V.__version!==C.version){rt(V,C,b);return}e.bindTexture(i.TEXTURE_CUBE_MAP,V.__webglTexture,i.TEXTURE0+b)}const st={[Uc]:i.REPEAT,[wi]:i.CLAMP_TO_EDGE,[Fc]:i.MIRRORED_REPEAT},ct={[xn]:i.NEAREST,[v0]:i.NEAREST_MIPMAP_NEAREST,[Ra]:i.NEAREST_MIPMAP_LINEAR,[On]:i.LINEAR,[bl]:i.LINEAR_MIPMAP_NEAREST,[bs]:i.LINEAR_MIPMAP_LINEAR},Et={[S0]:i.NEVER,[R0]:i.ALWAYS,[E0]:i.LESS,[dp]:i.LEQUAL,[w0]:i.EQUAL,[C0]:i.GEQUAL,[T0]:i.GREATER,[A0]:i.NOTEQUAL};function Vt(C,b){if(b.type===Ti&&t.has("OES_texture_float_linear")===!1&&(b.magFilter===On||b.magFilter===bl||b.magFilter===Ra||b.magFilter===bs||b.minFilter===On||b.minFilter===bl||b.minFilter===Ra||b.minFilter===bs)&&kt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(C,i.TEXTURE_WRAP_S,st[b.wrapS]),i.texParameteri(C,i.TEXTURE_WRAP_T,st[b.wrapT]),(C===i.TEXTURE_3D||C===i.TEXTURE_2D_ARRAY)&&i.texParameteri(C,i.TEXTURE_WRAP_R,st[b.wrapR]),i.texParameteri(C,i.TEXTURE_MAG_FILTER,ct[b.magFilter]),i.texParameteri(C,i.TEXTURE_MIN_FILTER,ct[b.minFilter]),b.compareFunction&&(i.texParameteri(C,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(C,i.TEXTURE_COMPARE_FUNC,Et[b.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(b.magFilter===xn||b.minFilter!==Ra&&b.minFilter!==bs||b.type===Ti&&t.has("OES_texture_float_linear")===!1)return;if(b.anisotropy>1||n.get(b).__currentAnisotropy){const V=t.get("EXT_texture_filter_anisotropic");i.texParameterf(C,V.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(b.anisotropy,s.getMaxAnisotropy())),n.get(b).__currentAnisotropy=b.anisotropy}}}function pt(C,b){let V=!1;C.__webglInit===void 0&&(C.__webglInit=!0,b.addEventListener("dispose",v));const nt=b.source;let it=d.get(nt);it===void 0&&(it={},d.set(nt,it));const Q=G(b);if(Q!==C.__cacheKey){it[Q]===void 0&&(it[Q]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,V=!0),it[Q].usedTimes++;const At=it[C.__cacheKey];At!==void 0&&(it[C.__cacheKey].usedTimes--,At.usedTimes===0&&M(b)),C.__cacheKey=Q,C.__webglTexture=it[Q].texture}return V}function $t(C,b,V){return Math.floor(Math.floor(C/V)/b)}function se(C,b,V,nt){const Q=C.updateRanges;if(Q.length===0)e.texSubImage2D(i.TEXTURE_2D,0,0,0,b.width,b.height,V,nt,b.data);else{Q.sort((D,U)=>D.start-U.start);let At=0;for(let D=1;D<Q.length;D++){const U=Q[At],et=Q[D],ot=U.start+U.count,ht=$t(et.start,b.width,4),yt=$t(U.start,b.width,4);et.start<=ot+1&&ht===yt&&$t(et.start+et.count-1,b.width,4)===ht?U.count=Math.max(U.count,et.start+et.count-U.start):(++At,Q[At]=et)}Q.length=At+1;const mt=i.getParameter(i.UNPACK_ROW_LENGTH),Pt=i.getParameter(i.UNPACK_SKIP_PIXELS),L=i.getParameter(i.UNPACK_SKIP_ROWS);i.pixelStorei(i.UNPACK_ROW_LENGTH,b.width);for(let D=0,U=Q.length;D<U;D++){const et=Q[D],ot=Math.floor(et.start/4),ht=Math.ceil(et.count/4),yt=ot%b.width,P=Math.floor(ot/b.width),W=ht,X=1;i.pixelStorei(i.UNPACK_SKIP_PIXELS,yt),i.pixelStorei(i.UNPACK_SKIP_ROWS,P),e.texSubImage2D(i.TEXTURE_2D,0,yt,P,W,X,V,nt,b.data)}C.clearUpdateRanges(),i.pixelStorei(i.UNPACK_ROW_LENGTH,mt),i.pixelStorei(i.UNPACK_SKIP_PIXELS,Pt),i.pixelStorei(i.UNPACK_SKIP_ROWS,L)}}function J(C,b,V){let nt=i.TEXTURE_2D;(b.isDataArrayTexture||b.isCompressedArrayTexture)&&(nt=i.TEXTURE_2D_ARRAY),b.isData3DTexture&&(nt=i.TEXTURE_3D);const it=pt(C,b),Q=b.source;e.bindTexture(nt,C.__webglTexture,i.TEXTURE0+V);const At=n.get(Q);if(Q.version!==At.__version||it===!0){e.activeTexture(i.TEXTURE0+V);const mt=te.getPrimaries(te.workingColorSpace),Pt=b.colorSpace===Yi?null:te.getPrimaries(b.colorSpace),L=b.colorSpace===Yi||mt===Pt?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,b.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,b.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,b.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,L);let D=x(b.image,!1,s.maxTextureSize);D=Rt(b,D);const U=r.convert(b.format,b.colorSpace),et=r.convert(b.type);let ot=S(b.internalFormat,U,et,b.colorSpace,b.isVideoTexture);Vt(nt,b);let ht;const yt=b.mipmaps,P=b.isVideoTexture!==!0,W=At.__version===void 0||it===!0,X=Q.dataReady,Y=E(b,D);if(b.isDepthTexture)ot=y(b.format===ha,b.type),W&&(P?e.texStorage2D(i.TEXTURE_2D,1,ot,D.width,D.height):e.texImage2D(i.TEXTURE_2D,0,ot,D.width,D.height,0,U,et,null));else if(b.isDataTexture)if(yt.length>0){P&&W&&e.texStorage2D(i.TEXTURE_2D,Y,ot,yt[0].width,yt[0].height);for(let H=0,j=yt.length;H<j;H++)ht=yt[H],P?X&&e.texSubImage2D(i.TEXTURE_2D,H,0,0,ht.width,ht.height,U,et,ht.data):e.texImage2D(i.TEXTURE_2D,H,ot,ht.width,ht.height,0,U,et,ht.data);b.generateMipmaps=!1}else P?(W&&e.texStorage2D(i.TEXTURE_2D,Y,ot,D.width,D.height),X&&se(b,D,U,et)):e.texImage2D(i.TEXTURE_2D,0,ot,D.width,D.height,0,U,et,D.data);else if(b.isCompressedTexture)if(b.isCompressedArrayTexture){P&&W&&e.texStorage3D(i.TEXTURE_2D_ARRAY,Y,ot,yt[0].width,yt[0].height,D.depth);for(let H=0,j=yt.length;H<j;H++)if(ht=yt[H],b.format!==Xn)if(U!==null)if(P){if(X)if(b.layerUpdates.size>0){const ut=md(ht.width,ht.height,b.format,b.type);for(const bt of b.layerUpdates){const Yt=ht.data.subarray(bt*ut/ht.data.BYTES_PER_ELEMENT,(bt+1)*ut/ht.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,H,0,0,bt,ht.width,ht.height,1,U,Yt)}b.clearLayerUpdates()}else e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,H,0,0,0,ht.width,ht.height,D.depth,U,ht.data)}else e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,H,ot,ht.width,ht.height,D.depth,0,ht.data,0,0);else kt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else P?X&&e.texSubImage3D(i.TEXTURE_2D_ARRAY,H,0,0,0,ht.width,ht.height,D.depth,U,et,ht.data):e.texImage3D(i.TEXTURE_2D_ARRAY,H,ot,ht.width,ht.height,D.depth,0,U,et,ht.data)}else{P&&W&&e.texStorage2D(i.TEXTURE_2D,Y,ot,yt[0].width,yt[0].height);for(let H=0,j=yt.length;H<j;H++)ht=yt[H],b.format!==Xn?U!==null?P?X&&e.compressedTexSubImage2D(i.TEXTURE_2D,H,0,0,ht.width,ht.height,U,ht.data):e.compressedTexImage2D(i.TEXTURE_2D,H,ot,ht.width,ht.height,0,ht.data):kt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):P?X&&e.texSubImage2D(i.TEXTURE_2D,H,0,0,ht.width,ht.height,U,et,ht.data):e.texImage2D(i.TEXTURE_2D,H,ot,ht.width,ht.height,0,U,et,ht.data)}else if(b.isDataArrayTexture)if(P){if(W&&e.texStorage3D(i.TEXTURE_2D_ARRAY,Y,ot,D.width,D.height,D.depth),X)if(b.layerUpdates.size>0){const H=md(D.width,D.height,b.format,b.type);for(const j of b.layerUpdates){const ut=D.data.subarray(j*H/D.data.BYTES_PER_ELEMENT,(j+1)*H/D.data.BYTES_PER_ELEMENT);e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,j,D.width,D.height,1,U,et,ut)}b.clearLayerUpdates()}else e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,D.width,D.height,D.depth,U,et,D.data)}else e.texImage3D(i.TEXTURE_2D_ARRAY,0,ot,D.width,D.height,D.depth,0,U,et,D.data);else if(b.isData3DTexture)P?(W&&e.texStorage3D(i.TEXTURE_3D,Y,ot,D.width,D.height,D.depth),X&&e.texSubImage3D(i.TEXTURE_3D,0,0,0,0,D.width,D.height,D.depth,U,et,D.data)):e.texImage3D(i.TEXTURE_3D,0,ot,D.width,D.height,D.depth,0,U,et,D.data);else if(b.isFramebufferTexture){if(W)if(P)e.texStorage2D(i.TEXTURE_2D,Y,ot,D.width,D.height);else{let H=D.width,j=D.height;for(let ut=0;ut<Y;ut++)e.texImage2D(i.TEXTURE_2D,ut,ot,H,j,0,U,et,null),H>>=1,j>>=1}}else if(yt.length>0){if(P&&W){const H=Ut(yt[0]);e.texStorage2D(i.TEXTURE_2D,Y,ot,H.width,H.height)}for(let H=0,j=yt.length;H<j;H++)ht=yt[H],P?X&&e.texSubImage2D(i.TEXTURE_2D,H,0,0,U,et,ht):e.texImage2D(i.TEXTURE_2D,H,ot,U,et,ht);b.generateMipmaps=!1}else if(P){if(W){const H=Ut(D);e.texStorage2D(i.TEXTURE_2D,Y,ot,H.width,H.height)}X&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,U,et,D)}else e.texImage2D(i.TEXTURE_2D,0,ot,U,et,D);_(b)&&p(nt),At.__version=Q.version,b.onUpdate&&b.onUpdate(b)}C.__version=b.version}function rt(C,b,V){if(b.image.length!==6)return;const nt=pt(C,b),it=b.source;e.bindTexture(i.TEXTURE_CUBE_MAP,C.__webglTexture,i.TEXTURE0+V);const Q=n.get(it);if(it.version!==Q.__version||nt===!0){e.activeTexture(i.TEXTURE0+V);const At=te.getPrimaries(te.workingColorSpace),mt=b.colorSpace===Yi?null:te.getPrimaries(b.colorSpace),Pt=b.colorSpace===Yi||At===mt?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,b.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,b.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,b.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Pt);const L=b.isCompressedTexture||b.image[0].isCompressedTexture,D=b.image[0]&&b.image[0].isDataTexture,U=[];for(let j=0;j<6;j++)!L&&!D?U[j]=x(b.image[j],!0,s.maxCubemapSize):U[j]=D?b.image[j].image:b.image[j],U[j]=Rt(b,U[j]);const et=U[0],ot=r.convert(b.format,b.colorSpace),ht=r.convert(b.type),yt=S(b.internalFormat,ot,ht,b.colorSpace),P=b.isVideoTexture!==!0,W=Q.__version===void 0||nt===!0,X=it.dataReady;let Y=E(b,et);Vt(i.TEXTURE_CUBE_MAP,b);let H;if(L){P&&W&&e.texStorage2D(i.TEXTURE_CUBE_MAP,Y,yt,et.width,et.height);for(let j=0;j<6;j++){H=U[j].mipmaps;for(let ut=0;ut<H.length;ut++){const bt=H[ut];b.format!==Xn?ot!==null?P?X&&e.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,ut,0,0,bt.width,bt.height,ot,bt.data):e.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,ut,yt,bt.width,bt.height,0,bt.data):kt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):P?X&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,ut,0,0,bt.width,bt.height,ot,ht,bt.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,ut,yt,bt.width,bt.height,0,ot,ht,bt.data)}}}else{if(H=b.mipmaps,P&&W){H.length>0&&Y++;const j=Ut(U[0]);e.texStorage2D(i.TEXTURE_CUBE_MAP,Y,yt,j.width,j.height)}for(let j=0;j<6;j++)if(D){P?X&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,0,0,U[j].width,U[j].height,ot,ht,U[j].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,yt,U[j].width,U[j].height,0,ot,ht,U[j].data);for(let ut=0;ut<H.length;ut++){const Yt=H[ut].image[j].image;P?X&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,ut+1,0,0,Yt.width,Yt.height,ot,ht,Yt.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,ut+1,yt,Yt.width,Yt.height,0,ot,ht,Yt.data)}}else{P?X&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,0,0,ot,ht,U[j]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,yt,ot,ht,U[j]);for(let ut=0;ut<H.length;ut++){const bt=H[ut];P?X&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,ut+1,0,0,ot,ht,bt.image[j]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,ut+1,yt,ot,ht,bt.image[j])}}}_(b)&&p(i.TEXTURE_CUBE_MAP),Q.__version=it.version,b.onUpdate&&b.onUpdate(b)}C.__version=b.version}function Mt(C,b,V,nt,it,Q){const At=r.convert(V.format,V.colorSpace),mt=r.convert(V.type),Pt=S(V.internalFormat,At,mt,V.colorSpace),L=n.get(b),D=n.get(V);if(D.__renderTarget=b,!L.__hasExternalTextures){const U=Math.max(1,b.width>>Q),et=Math.max(1,b.height>>Q);it===i.TEXTURE_3D||it===i.TEXTURE_2D_ARRAY?e.texImage3D(it,Q,Pt,U,et,b.depth,0,At,mt,null):e.texImage2D(it,Q,Pt,U,et,0,At,mt,null)}e.bindFramebuffer(i.FRAMEBUFFER,C),wt(b)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,nt,it,D.__webglTexture,0,ie(b)):(it===i.TEXTURE_2D||it>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&it<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,nt,it,D.__webglTexture,Q),e.bindFramebuffer(i.FRAMEBUFFER,null)}function Bt(C,b,V){if(i.bindRenderbuffer(i.RENDERBUFFER,C),b.depthBuffer){const nt=b.depthTexture,it=nt&&nt.isDepthTexture?nt.type:null,Q=y(b.stencilBuffer,it),At=b.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,mt=ie(b);wt(b)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,mt,Q,b.width,b.height):V?i.renderbufferStorageMultisample(i.RENDERBUFFER,mt,Q,b.width,b.height):i.renderbufferStorage(i.RENDERBUFFER,Q,b.width,b.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,At,i.RENDERBUFFER,C)}else{const nt=b.textures;for(let it=0;it<nt.length;it++){const Q=nt[it],At=r.convert(Q.format,Q.colorSpace),mt=r.convert(Q.type),Pt=S(Q.internalFormat,At,mt,Q.colorSpace),L=ie(b);V&&wt(b)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,L,Pt,b.width,b.height):wt(b)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,L,Pt,b.width,b.height):i.renderbufferStorage(i.RENDERBUFFER,Pt,b.width,b.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Ct(C,b){if(b&&b.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(i.FRAMEBUFFER,C),!(b.depthTexture&&b.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const nt=n.get(b.depthTexture);nt.__renderTarget=b,(!nt.__webglTexture||b.depthTexture.image.width!==b.width||b.depthTexture.image.height!==b.height)&&(b.depthTexture.image.width=b.width,b.depthTexture.image.height=b.height,b.depthTexture.needsUpdate=!0),K(b.depthTexture,0);const it=nt.__webglTexture,Q=ie(b);if(b.depthTexture.format===ca)wt(b)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,it,0,Q):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,it,0);else if(b.depthTexture.format===ha)wt(b)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,it,0,Q):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,it,0);else throw new Error("Unknown depthTexture format")}function It(C){const b=n.get(C),V=C.isWebGLCubeRenderTarget===!0;if(b.__boundDepthTexture!==C.depthTexture){const nt=C.depthTexture;if(b.__depthDisposeCallback&&b.__depthDisposeCallback(),nt){const it=()=>{delete b.__boundDepthTexture,delete b.__depthDisposeCallback,nt.removeEventListener("dispose",it)};nt.addEventListener("dispose",it),b.__depthDisposeCallback=it}b.__boundDepthTexture=nt}if(C.depthTexture&&!b.__autoAllocateDepthBuffer){if(V)throw new Error("target.depthTexture not supported in Cube render targets");const nt=C.texture.mipmaps;nt&&nt.length>0?Ct(b.__webglFramebuffer[0],C):Ct(b.__webglFramebuffer,C)}else if(V){b.__webglDepthbuffer=[];for(let nt=0;nt<6;nt++)if(e.bindFramebuffer(i.FRAMEBUFFER,b.__webglFramebuffer[nt]),b.__webglDepthbuffer[nt]===void 0)b.__webglDepthbuffer[nt]=i.createRenderbuffer(),Bt(b.__webglDepthbuffer[nt],C,!1);else{const it=C.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Q=b.__webglDepthbuffer[nt];i.bindRenderbuffer(i.RENDERBUFFER,Q),i.framebufferRenderbuffer(i.FRAMEBUFFER,it,i.RENDERBUFFER,Q)}}else{const nt=C.texture.mipmaps;if(nt&&nt.length>0?e.bindFramebuffer(i.FRAMEBUFFER,b.__webglFramebuffer[0]):e.bindFramebuffer(i.FRAMEBUFFER,b.__webglFramebuffer),b.__webglDepthbuffer===void 0)b.__webglDepthbuffer=i.createRenderbuffer(),Bt(b.__webglDepthbuffer,C,!1);else{const it=C.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Q=b.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,Q),i.framebufferRenderbuffer(i.FRAMEBUFFER,it,i.RENDERBUFFER,Q)}}e.bindFramebuffer(i.FRAMEBUFFER,null)}function Ae(C,b,V){const nt=n.get(C);b!==void 0&&Mt(nt.__webglFramebuffer,C,C.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),V!==void 0&&It(C)}function Ht(C){const b=C.texture,V=n.get(C),nt=n.get(b);C.addEventListener("dispose",A);const it=C.textures,Q=C.isWebGLCubeRenderTarget===!0,At=it.length>1;if(At||(nt.__webglTexture===void 0&&(nt.__webglTexture=i.createTexture()),nt.__version=b.version,a.memory.textures++),Q){V.__webglFramebuffer=[];for(let mt=0;mt<6;mt++)if(b.mipmaps&&b.mipmaps.length>0){V.__webglFramebuffer[mt]=[];for(let Pt=0;Pt<b.mipmaps.length;Pt++)V.__webglFramebuffer[mt][Pt]=i.createFramebuffer()}else V.__webglFramebuffer[mt]=i.createFramebuffer()}else{if(b.mipmaps&&b.mipmaps.length>0){V.__webglFramebuffer=[];for(let mt=0;mt<b.mipmaps.length;mt++)V.__webglFramebuffer[mt]=i.createFramebuffer()}else V.__webglFramebuffer=i.createFramebuffer();if(At)for(let mt=0,Pt=it.length;mt<Pt;mt++){const L=n.get(it[mt]);L.__webglTexture===void 0&&(L.__webglTexture=i.createTexture(),a.memory.textures++)}if(C.samples>0&&wt(C)===!1){V.__webglMultisampledFramebuffer=i.createFramebuffer(),V.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,V.__webglMultisampledFramebuffer);for(let mt=0;mt<it.length;mt++){const Pt=it[mt];V.__webglColorRenderbuffer[mt]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,V.__webglColorRenderbuffer[mt]);const L=r.convert(Pt.format,Pt.colorSpace),D=r.convert(Pt.type),U=S(Pt.internalFormat,L,D,Pt.colorSpace,C.isXRRenderTarget===!0),et=ie(C);i.renderbufferStorageMultisample(i.RENDERBUFFER,et,U,C.width,C.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+mt,i.RENDERBUFFER,V.__webglColorRenderbuffer[mt])}i.bindRenderbuffer(i.RENDERBUFFER,null),C.depthBuffer&&(V.__webglDepthRenderbuffer=i.createRenderbuffer(),Bt(V.__webglDepthRenderbuffer,C,!0)),e.bindFramebuffer(i.FRAMEBUFFER,null)}}if(Q){e.bindTexture(i.TEXTURE_CUBE_MAP,nt.__webglTexture),Vt(i.TEXTURE_CUBE_MAP,b);for(let mt=0;mt<6;mt++)if(b.mipmaps&&b.mipmaps.length>0)for(let Pt=0;Pt<b.mipmaps.length;Pt++)Mt(V.__webglFramebuffer[mt][Pt],C,b,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+mt,Pt);else Mt(V.__webglFramebuffer[mt],C,b,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+mt,0);_(b)&&p(i.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(At){for(let mt=0,Pt=it.length;mt<Pt;mt++){const L=it[mt],D=n.get(L);let U=i.TEXTURE_2D;(C.isWebGL3DRenderTarget||C.isWebGLArrayRenderTarget)&&(U=C.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(U,D.__webglTexture),Vt(U,L),Mt(V.__webglFramebuffer,C,L,i.COLOR_ATTACHMENT0+mt,U,0),_(L)&&p(U)}e.unbindTexture()}else{let mt=i.TEXTURE_2D;if((C.isWebGL3DRenderTarget||C.isWebGLArrayRenderTarget)&&(mt=C.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(mt,nt.__webglTexture),Vt(mt,b),b.mipmaps&&b.mipmaps.length>0)for(let Pt=0;Pt<b.mipmaps.length;Pt++)Mt(V.__webglFramebuffer[Pt],C,b,i.COLOR_ATTACHMENT0,mt,Pt);else Mt(V.__webglFramebuffer,C,b,i.COLOR_ATTACHMENT0,mt,0);_(b)&&p(mt),e.unbindTexture()}C.depthBuffer&&It(C)}function he(C){const b=C.textures;for(let V=0,nt=b.length;V<nt;V++){const it=b[V];if(_(it)){const Q=w(C),At=n.get(it).__webglTexture;e.bindTexture(Q,At),p(Q),e.unbindTexture()}}}const N=[],Wt=[];function jt(C){if(C.samples>0){if(wt(C)===!1){const b=C.textures,V=C.width,nt=C.height;let it=i.COLOR_BUFFER_BIT;const Q=C.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,At=n.get(C),mt=b.length>1;if(mt)for(let L=0;L<b.length;L++)e.bindFramebuffer(i.FRAMEBUFFER,At.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+L,i.RENDERBUFFER,null),e.bindFramebuffer(i.FRAMEBUFFER,At.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+L,i.TEXTURE_2D,null,0);e.bindFramebuffer(i.READ_FRAMEBUFFER,At.__webglMultisampledFramebuffer);const Pt=C.texture.mipmaps;Pt&&Pt.length>0?e.bindFramebuffer(i.DRAW_FRAMEBUFFER,At.__webglFramebuffer[0]):e.bindFramebuffer(i.DRAW_FRAMEBUFFER,At.__webglFramebuffer);for(let L=0;L<b.length;L++){if(C.resolveDepthBuffer&&(C.depthBuffer&&(it|=i.DEPTH_BUFFER_BIT),C.stencilBuffer&&C.resolveStencilBuffer&&(it|=i.STENCIL_BUFFER_BIT)),mt){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,At.__webglColorRenderbuffer[L]);const D=n.get(b[L]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,D,0)}i.blitFramebuffer(0,0,V,nt,0,0,V,nt,it,i.NEAREST),l===!0&&(N.length=0,Wt.length=0,N.push(i.COLOR_ATTACHMENT0+L),C.depthBuffer&&C.resolveDepthBuffer===!1&&(N.push(Q),Wt.push(Q),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,Wt)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,N))}if(e.bindFramebuffer(i.READ_FRAMEBUFFER,null),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),mt)for(let L=0;L<b.length;L++){e.bindFramebuffer(i.FRAMEBUFFER,At.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+L,i.RENDERBUFFER,At.__webglColorRenderbuffer[L]);const D=n.get(b[L]).__webglTexture;e.bindFramebuffer(i.FRAMEBUFFER,At.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+L,i.TEXTURE_2D,D,0)}e.bindFramebuffer(i.DRAW_FRAMEBUFFER,At.__webglMultisampledFramebuffer)}else if(C.depthBuffer&&C.resolveDepthBuffer===!1&&l){const b=C.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[b])}}}function ie(C){return Math.min(s.maxSamples,C.samples)}function wt(C){const b=n.get(C);return C.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&b.__useRenderToTexture!==!1}function pe(C){const b=a.render.frame;h.get(C)!==b&&(h.set(C,b),C.update())}function Rt(C,b){const V=C.colorSpace,nt=C.format,it=C.type;return C.isCompressedTexture===!0||C.isVideoTexture===!0||V!==wr&&V!==Yi&&(te.getTransfer(V)===ae?(nt!==Xn||it!==ui)&&kt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Me("WebGLTextures: Unsupported texture color space:",V)),b}function Ut(C){return typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement?(c.width=C.naturalWidth||C.width,c.height=C.naturalHeight||C.height):typeof VideoFrame<"u"&&C instanceof VideoFrame?(c.width=C.displayWidth,c.height=C.displayHeight):(c.width=C.width,c.height=C.height),c}this.allocateTextureUnit=k,this.resetTextureUnits=F,this.setTexture2D=K,this.setTexture2DArray=tt,this.setTexture3D=lt,this.setTextureCube=$,this.rebindTextures=Ae,this.setupRenderTarget=Ht,this.updateRenderTargetMipmap=he,this.updateMultisampleRenderTarget=jt,this.setupDepthRenderbuffer=It,this.setupFrameBufferTexture=Mt,this.useMultisampledRTT=wt}function $y(i,t){function e(n,s=Yi){let r;const a=te.getTransfer(s);if(n===ui)return i.UNSIGNED_BYTE;if(n===jh)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Yh)return i.UNSIGNED_SHORT_5_5_5_1;if(n===ap)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===op)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===sp)return i.BYTE;if(n===rp)return i.SHORT;if(n===oa)return i.UNSIGNED_SHORT;if(n===Xh)return i.INT;if(n===ws)return i.UNSIGNED_INT;if(n===Ti)return i.FLOAT;if(n===Rr)return i.HALF_FLOAT;if(n===lp)return i.ALPHA;if(n===cp)return i.RGB;if(n===Xn)return i.RGBA;if(n===ca)return i.DEPTH_COMPONENT;if(n===ha)return i.DEPTH_STENCIL;if(n===hp)return i.RED;if(n===qh)return i.RED_INTEGER;if(n===Zh)return i.RG;if(n===$h)return i.RG_INTEGER;if(n===Kh)return i.RGBA_INTEGER;if(n===To||n===Ao||n===Co||n===Ro)if(a===ae)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===To)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Ao)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Co)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Ro)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===To)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Ao)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Co)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Ro)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===zc||n===Bc||n===kc||n===Vc)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===zc)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Bc)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===kc)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Vc)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Hc||n===Gc||n===Wc)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Hc||n===Gc)return a===ae?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Wc)return a===ae?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===Xc||n===jc||n===Yc||n===qc||n===Zc||n===$c||n===Kc||n===Jc||n===Qc||n===th||n===eh||n===nh||n===ih||n===sh)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Xc)return a===ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===jc)return a===ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Yc)return a===ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===qc)return a===ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Zc)return a===ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===$c)return a===ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Kc)return a===ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Jc)return a===ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Qc)return a===ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===th)return a===ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===eh)return a===ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===nh)return a===ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===ih)return a===ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===sh)return a===ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===rh||n===ah||n===oh)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(n===rh)return a===ae?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===ah)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===oh)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===lh||n===ch||n===hh||n===uh)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(n===lh)return r.COMPRESSED_RED_RGTC1_EXT;if(n===ch)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===hh)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===uh)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===la?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:e}}const Ky=`
3830
3945
  void main() {
3831
3946
 
3832
3947
  gl_Position = vec4( position, 1.0 );
3833
3948
 
3834
- }`,M0=`
3949
+ }`,Jy=`
3835
3950
  uniform sampler2DArray depthColor;
3836
3951
  uniform float depthWidth;
3837
3952
  uniform float depthHeight;
@@ -3850,7 +3965,11 @@ void main() {
3850
3965
 
3851
3966
  }
3852
3967
 
3853
- }`;class E0{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new tf(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new _i({vertexShader:y0,fragmentShader:M0,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new ge(new Ir(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class b0 extends qi{constructor(e,t){super();const i=this;let r=null,s=1,o=null,a="local-floor",l=1,c=null,u=null,h=null,d=null,p=null,g=null;const y=typeof XRWebGLBinding<"u",m=new E0,f={},w=t.getContextAttributes();let T=null,_=null;const S=[],b=[],A=new Ne;let C=null;const M=new cn;M.viewport=new gt;const x=new cn;x.viewport=new gt;const N=[M,x],z=new Gp;let Y=null,q=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let oe=S[Z];return oe===void 0&&(oe=new ga,S[Z]=oe),oe.getTargetRaySpace()},this.getControllerGrip=function(Z){let oe=S[Z];return oe===void 0&&(oe=new ga,S[Z]=oe),oe.getGripSpace()},this.getHand=function(Z){let oe=S[Z];return oe===void 0&&(oe=new ga,S[Z]=oe),oe.getHandSpace()};function J(Z){const oe=b.indexOf(Z.inputSource);if(oe===-1)return;const Me=S[oe];Me!==void 0&&(Me.update(Z.inputSource,Z.frame,c||o),Me.dispatchEvent({type:Z.type,data:Z.inputSource}))}function K(){r.removeEventListener("select",J),r.removeEventListener("selectstart",J),r.removeEventListener("selectend",J),r.removeEventListener("squeeze",J),r.removeEventListener("squeezestart",J),r.removeEventListener("squeezeend",J),r.removeEventListener("end",K),r.removeEventListener("inputsourceschange",se);for(let Z=0;Z<S.length;Z++){const oe=b[Z];oe!==null&&(b[Z]=null,S[Z].disconnect(oe))}Y=null,q=null,m.reset();for(const Z in f)delete f[Z];e.setRenderTarget(T),p=null,d=null,h=null,r=null,_=null,Ke.stop(),i.isPresenting=!1,e.setPixelRatio(C),e.setSize(A.width,A.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Z){s=Z,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Z){a=Z,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(Z){c=Z},this.getBaseLayer=function(){return d!==null?d:p},this.getBinding=function(){return h===null&&y&&(h=new XRWebGLBinding(r,t)),h},this.getFrame=function(){return g},this.getSession=function(){return r},this.setSession=async function(Z){if(r=Z,r!==null){if(T=e.getRenderTarget(),r.addEventListener("select",J),r.addEventListener("selectstart",J),r.addEventListener("selectend",J),r.addEventListener("squeeze",J),r.addEventListener("squeezestart",J),r.addEventListener("squeezeend",J),r.addEventListener("end",K),r.addEventListener("inputsourceschange",se),w.xrCompatible!==!0&&await t.makeXRCompatible(),C=e.getPixelRatio(),e.getSize(A),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let Me=null,Ie=null,Ce=null;w.depth&&(Ce=w.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Me=w.stencil?os:ss,Ie=w.stencil?rs:Hi);const ze={colorFormat:t.RGBA8,depthFormat:Ce,scaleFactor:s};h=this.getBinding(),d=h.createProjectionLayer(ze),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),_=new ki(d.textureWidth,d.textureHeight,{format:bn,type:kn,depthTexture:new ef(d.textureWidth,d.textureHeight,Ie,void 0,void 0,void 0,void 0,void 0,void 0,Me),stencilBuffer:w.stencil,colorSpace:e.outputColorSpace,samples:w.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const Me={antialias:w.antialias,alpha:!0,depth:w.depth,stencil:w.stencil,framebufferScaleFactor:s};p=new XRWebGLLayer(r,t,Me),r.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),_=new ki(p.framebufferWidth,p.framebufferHeight,{format:bn,type:kn,colorSpace:e.outputColorSpace,stencilBuffer:w.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}_.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await r.requestReferenceSpace(a),Ke.setContext(r),Ke.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function se(Z){for(let oe=0;oe<Z.removed.length;oe++){const Me=Z.removed[oe],Ie=b.indexOf(Me);Ie>=0&&(b[Ie]=null,S[Ie].disconnect(Me))}for(let oe=0;oe<Z.added.length;oe++){const Me=Z.added[oe];let Ie=b.indexOf(Me);if(Ie===-1){for(let ze=0;ze<S.length;ze++)if(ze>=b.length){b.push(Me),Ie=ze;break}else if(b[ze]===null){b[ze]=Me,Ie=ze;break}if(Ie===-1)break}const Ce=S[Ie];Ce&&Ce.connect(Me)}}const $=new O,le=new O;function me(Z,oe,Me){$.setFromMatrixPosition(oe.matrixWorld),le.setFromMatrixPosition(Me.matrixWorld);const Ie=$.distanceTo(le),Ce=oe.projectionMatrix.elements,ze=Me.projectionMatrix.elements,St=Ce[14]/(Ce[10]-1),L=Ce[14]/(Ce[10]+1),rt=(Ce[9]+1)/Ce[5],Ve=(Ce[9]-1)/Ce[5],De=(Ce[8]-1)/Ce[0],be=(ze[8]+1)/ze[0],st=St*De,Se=St*be,He=Ie/(-De+be),vt=He*-De;if(oe.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(vt),Z.translateZ(He),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert(),Ce[10]===-1)Z.projectionMatrix.copy(oe.projectionMatrix),Z.projectionMatrixInverse.copy(oe.projectionMatrixInverse);else{const ut=St+He,R=L+He,v=st-vt,H=Se+(Ie-vt),ne=rt*L/R*ut,re=Ve*L/R*ut;Z.projectionMatrix.makePerspective(v,H,ne,re,ut,R),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert()}}function Ee(Z,oe){oe===null?Z.matrixWorld.copy(Z.matrix):Z.matrixWorld.multiplyMatrices(oe.matrixWorld,Z.matrix),Z.matrixWorldInverse.copy(Z.matrixWorld).invert()}this.updateCamera=function(Z){if(r===null)return;let oe=Z.near,Me=Z.far;m.texture!==null&&(m.depthNear>0&&(oe=m.depthNear),m.depthFar>0&&(Me=m.depthFar)),z.near=x.near=M.near=oe,z.far=x.far=M.far=Me,(Y!==z.near||q!==z.far)&&(r.updateRenderState({depthNear:z.near,depthFar:z.far}),Y=z.near,q=z.far),z.layers.mask=Z.layers.mask|6,M.layers.mask=z.layers.mask&3,x.layers.mask=z.layers.mask&5;const Ie=Z.parent,Ce=z.cameras;Ee(z,Ie);for(let ze=0;ze<Ce.length;ze++)Ee(Ce[ze],Ie);Ce.length===2?me(z,M,x):z.projectionMatrix.copy(M.projectionMatrix),Be(Z,z,Ie)};function Be(Z,oe,Me){Me===null?Z.matrix.copy(oe.matrixWorld):(Z.matrix.copy(Me.matrixWorld),Z.matrix.invert(),Z.matrix.multiply(oe.matrixWorld)),Z.matrix.decompose(Z.position,Z.quaternion,Z.scale),Z.updateMatrixWorld(!0),Z.projectionMatrix.copy(oe.projectionMatrix),Z.projectionMatrixInverse.copy(oe.projectionMatrixInverse),Z.isPerspectiveCamera&&(Z.fov=Sl*2*Math.atan(1/Z.projectionMatrix.elements[5]),Z.zoom=1)}this.getCamera=function(){return z},this.getFoveation=function(){if(!(d===null&&p===null))return l},this.setFoveation=function(Z){l=Z,d!==null&&(d.fixedFoveation=Z),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=Z)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(z)},this.getCameraTexture=function(Z){return f[Z]};let de=null;function qe(Z,oe){if(u=oe.getViewerPose(c||o),g=oe,u!==null){const Me=u.views;p!==null&&(e.setRenderTargetFramebuffer(_,p.framebuffer),e.setRenderTarget(_));let Ie=!1;Me.length!==z.cameras.length&&(z.cameras.length=0,Ie=!0);for(let L=0;L<Me.length;L++){const rt=Me[L];let Ve=null;if(p!==null)Ve=p.getViewport(rt);else{const be=h.getViewSubImage(d,rt);Ve=be.viewport,L===0&&(e.setRenderTargetTextures(_,be.colorTexture,be.depthStencilTexture),e.setRenderTarget(_))}let De=N[L];De===void 0&&(De=new cn,De.layers.enable(L),De.viewport=new gt,N[L]=De),De.matrix.fromArray(rt.transform.matrix),De.matrix.decompose(De.position,De.quaternion,De.scale),De.projectionMatrix.fromArray(rt.projectionMatrix),De.projectionMatrixInverse.copy(De.projectionMatrix).invert(),De.viewport.set(Ve.x,Ve.y,Ve.width,Ve.height),L===0&&(z.matrix.copy(De.matrix),z.matrix.decompose(z.position,z.quaternion,z.scale)),Ie===!0&&z.cameras.push(De)}const Ce=r.enabledFeatures;if(Ce&&Ce.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&y){h=i.getBinding();const L=h.getDepthInformation(Me[0]);L&&L.isValid&&L.texture&&m.init(L,r.renderState)}if(Ce&&Ce.includes("camera-access")&&y){e.state.unbindTexture(),h=i.getBinding();for(let L=0;L<Me.length;L++){const rt=Me[L].camera;if(rt){let Ve=f[rt];Ve||(Ve=new tf,f[rt]=Ve);const De=h.getCameraImage(rt);Ve.sourceTexture=De}}}}for(let Me=0;Me<S.length;Me++){const Ie=b[Me],Ce=S[Me];Ie!==null&&Ce!==void 0&&Ce.update(Ie,oe,c||o)}de&&de(Z,oe),oe.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:oe}),g=null}const Ke=new af;Ke.setAnimationLoop(qe),this.setAnimationLoop=function(Z){de=Z},this.dispose=function(){}}}const Ci=new Pn,S0=new ft;function T0(n,e){function t(m,f){m.matrixAutoUpdate===!0&&m.updateMatrix(),f.value.copy(m.matrix)}function i(m,f){f.color.getRGB(m.fogColor.value,Kh(n)),f.isFog?(m.fogNear.value=f.near,m.fogFar.value=f.far):f.isFogExp2&&(m.fogDensity.value=f.density)}function r(m,f,w,T,_){f.isMeshBasicMaterial||f.isMeshLambertMaterial?s(m,f):f.isMeshToonMaterial?(s(m,f),h(m,f)):f.isMeshPhongMaterial?(s(m,f),u(m,f)):f.isMeshStandardMaterial?(s(m,f),d(m,f),f.isMeshPhysicalMaterial&&p(m,f,_)):f.isMeshMatcapMaterial?(s(m,f),g(m,f)):f.isMeshDepthMaterial?s(m,f):f.isMeshDistanceMaterial?(s(m,f),y(m,f)):f.isMeshNormalMaterial?s(m,f):f.isLineBasicMaterial?(o(m,f),f.isLineDashedMaterial&&a(m,f)):f.isPointsMaterial?l(m,f,w,T):f.isSpriteMaterial?c(m,f):f.isShadowMaterial?(m.color.value.copy(f.color),m.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function s(m,f){m.opacity.value=f.opacity,f.color&&m.diffuse.value.copy(f.color),f.emissive&&m.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(m.map.value=f.map,t(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.bumpMap&&(m.bumpMap.value=f.bumpMap,t(f.bumpMap,m.bumpMapTransform),m.bumpScale.value=f.bumpScale,f.side===Wt&&(m.bumpScale.value*=-1)),f.normalMap&&(m.normalMap.value=f.normalMap,t(f.normalMap,m.normalMapTransform),m.normalScale.value.copy(f.normalScale),f.side===Wt&&m.normalScale.value.negate()),f.displacementMap&&(m.displacementMap.value=f.displacementMap,t(f.displacementMap,m.displacementMapTransform),m.displacementScale.value=f.displacementScale,m.displacementBias.value=f.displacementBias),f.emissiveMap&&(m.emissiveMap.value=f.emissiveMap,t(f.emissiveMap,m.emissiveMapTransform)),f.specularMap&&(m.specularMap.value=f.specularMap,t(f.specularMap,m.specularMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest);const w=e.get(f),T=w.envMap,_=w.envMapRotation;T&&(m.envMap.value=T,Ci.copy(_),Ci.x*=-1,Ci.y*=-1,Ci.z*=-1,T.isCubeTexture&&T.isRenderTargetTexture===!1&&(Ci.y*=-1,Ci.z*=-1),m.envMapRotation.value.setFromMatrix4(S0.makeRotationFromEuler(Ci)),m.flipEnvMap.value=T.isCubeTexture&&T.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=f.reflectivity,m.ior.value=f.ior,m.refractionRatio.value=f.refractionRatio),f.lightMap&&(m.lightMap.value=f.lightMap,m.lightMapIntensity.value=f.lightMapIntensity,t(f.lightMap,m.lightMapTransform)),f.aoMap&&(m.aoMap.value=f.aoMap,m.aoMapIntensity.value=f.aoMapIntensity,t(f.aoMap,m.aoMapTransform))}function o(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,f.map&&(m.map.value=f.map,t(f.map,m.mapTransform))}function a(m,f){m.dashSize.value=f.dashSize,m.totalSize.value=f.dashSize+f.gapSize,m.scale.value=f.scale}function l(m,f,w,T){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.size.value=f.size*w,m.scale.value=T*.5,f.map&&(m.map.value=f.map,t(f.map,m.uvTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function c(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.rotation.value=f.rotation,f.map&&(m.map.value=f.map,t(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function u(m,f){m.specular.value.copy(f.specular),m.shininess.value=Math.max(f.shininess,1e-4)}function h(m,f){f.gradientMap&&(m.gradientMap.value=f.gradientMap)}function d(m,f){m.metalness.value=f.metalness,f.metalnessMap&&(m.metalnessMap.value=f.metalnessMap,t(f.metalnessMap,m.metalnessMapTransform)),m.roughness.value=f.roughness,f.roughnessMap&&(m.roughnessMap.value=f.roughnessMap,t(f.roughnessMap,m.roughnessMapTransform)),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)}function p(m,f,w){m.ior.value=f.ior,f.sheen>0&&(m.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),m.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(m.sheenColorMap.value=f.sheenColorMap,t(f.sheenColorMap,m.sheenColorMapTransform)),f.sheenRoughnessMap&&(m.sheenRoughnessMap.value=f.sheenRoughnessMap,t(f.sheenRoughnessMap,m.sheenRoughnessMapTransform))),f.clearcoat>0&&(m.clearcoat.value=f.clearcoat,m.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(m.clearcoatMap.value=f.clearcoatMap,t(f.clearcoatMap,m.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,t(f.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(m.clearcoatNormalMap.value=f.clearcoatNormalMap,t(f.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===Wt&&m.clearcoatNormalScale.value.negate())),f.dispersion>0&&(m.dispersion.value=f.dispersion),f.iridescence>0&&(m.iridescence.value=f.iridescence,m.iridescenceIOR.value=f.iridescenceIOR,m.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(m.iridescenceMap.value=f.iridescenceMap,t(f.iridescenceMap,m.iridescenceMapTransform)),f.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=f.iridescenceThicknessMap,t(f.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),f.transmission>0&&(m.transmission.value=f.transmission,m.transmissionSamplerMap.value=w.texture,m.transmissionSamplerSize.value.set(w.width,w.height),f.transmissionMap&&(m.transmissionMap.value=f.transmissionMap,t(f.transmissionMap,m.transmissionMapTransform)),m.thickness.value=f.thickness,f.thicknessMap&&(m.thicknessMap.value=f.thicknessMap,t(f.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=f.attenuationDistance,m.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(m.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(m.anisotropyMap.value=f.anisotropyMap,t(f.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=f.specularIntensity,m.specularColor.value.copy(f.specularColor),f.specularColorMap&&(m.specularColorMap.value=f.specularColorMap,t(f.specularColorMap,m.specularColorMapTransform)),f.specularIntensityMap&&(m.specularIntensityMap.value=f.specularIntensityMap,t(f.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,f){f.matcap&&(m.matcap.value=f.matcap)}function y(m,f){const w=e.get(f).light;m.referencePosition.value.setFromMatrixPosition(w.matrixWorld),m.nearDistance.value=w.shadow.camera.near,m.farDistance.value=w.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function w0(n,e,t,i){let r={},s={},o=[];const a=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(w,T){const _=T.program;i.uniformBlockBinding(w,_)}function c(w,T){let _=r[w.id];_===void 0&&(g(w),_=u(w),r[w.id]=_,w.addEventListener("dispose",m));const S=T.program;i.updateUBOMapping(w,S);const b=e.render.frame;s[w.id]!==b&&(d(w),s[w.id]=b)}function u(w){const T=h();w.__bindingPointIndex=T;const _=n.createBuffer(),S=w.__size,b=w.usage;return n.bindBuffer(n.UNIFORM_BUFFER,_),n.bufferData(n.UNIFORM_BUFFER,S,b),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,T,_),_}function h(){for(let w=0;w<a;w++)if(o.indexOf(w)===-1)return o.push(w),w;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(w){const T=r[w.id],_=w.uniforms,S=w.__cache;n.bindBuffer(n.UNIFORM_BUFFER,T);for(let b=0,A=_.length;b<A;b++){const C=Array.isArray(_[b])?_[b]:[_[b]];for(let M=0,x=C.length;M<x;M++){const N=C[M];if(p(N,b,M,S)===!0){const z=N.__offset,Y=Array.isArray(N.value)?N.value:[N.value];let q=0;for(let J=0;J<Y.length;J++){const K=Y[J],se=y(K);typeof K=="number"||typeof K=="boolean"?(N.__data[0]=K,n.bufferSubData(n.UNIFORM_BUFFER,z+q,N.__data)):K.isMatrix3?(N.__data[0]=K.elements[0],N.__data[1]=K.elements[1],N.__data[2]=K.elements[2],N.__data[3]=0,N.__data[4]=K.elements[3],N.__data[5]=K.elements[4],N.__data[6]=K.elements[5],N.__data[7]=0,N.__data[8]=K.elements[6],N.__data[9]=K.elements[7],N.__data[10]=K.elements[8],N.__data[11]=0):(K.toArray(N.__data,q),q+=se.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,z,N.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function p(w,T,_,S){const b=w.value,A=T+"_"+_;if(S[A]===void 0)return typeof b=="number"||typeof b=="boolean"?S[A]=b:S[A]=b.clone(),!0;{const C=S[A];if(typeof b=="number"||typeof b=="boolean"){if(C!==b)return S[A]=b,!0}else if(C.equals(b)===!1)return C.copy(b),!0}return!1}function g(w){const T=w.uniforms;let _=0;const S=16;for(let A=0,C=T.length;A<C;A++){const M=Array.isArray(T[A])?T[A]:[T[A]];for(let x=0,N=M.length;x<N;x++){const z=M[x],Y=Array.isArray(z.value)?z.value:[z.value];for(let q=0,J=Y.length;q<J;q++){const K=Y[q],se=y(K),$=_%S,le=$%se.boundary,me=$+le;_+=le,me!==0&&S-me<se.storage&&(_+=S-me),z.__data=new Float32Array(se.storage/Float32Array.BYTES_PER_ELEMENT),z.__offset=_,_+=se.storage}}}const b=_%S;return b>0&&(_+=S-b),w.__size=_,w.__cache={},this}function y(w){const T={boundary:0,storage:0};return typeof w=="number"||typeof w=="boolean"?(T.boundary=4,T.storage=4):w.isVector2?(T.boundary=8,T.storage=8):w.isVector3||w.isColor?(T.boundary=16,T.storage=12):w.isVector4?(T.boundary=16,T.storage=16):w.isMatrix3?(T.boundary=48,T.storage=48):w.isMatrix4?(T.boundary=64,T.storage=64):w.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",w),T}function m(w){const T=w.target;T.removeEventListener("dispose",m);const _=o.indexOf(T.__bindingPointIndex);o.splice(_,1),n.deleteBuffer(r[T.id]),delete r[T.id],delete s[T.id]}function f(){for(const w in r)n.deleteBuffer(r[w]);o=[],r={},s={}}return{bind:l,update:c,dispose:f}}class A0{constructor(e={}){const{canvas:t=sp(),context:i=null,depth:r=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1,reversedDepthBuffer:d=!1}=e;this.isWebGLRenderer=!0;let p;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=i.getContextAttributes().alpha}else p=o;const g=new Uint32Array(4),y=new Int32Array(4);let m=null,f=null;const w=[],T=[];this.domElement=t,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=pi,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const _=this;let S=!1;this._outputColorSpace=ln;let b=0,A=0,C=null,M=-1,x=null;const N=new gt,z=new gt;let Y=null;const q=new je(0);let J=0,K=t.width,se=t.height,$=1,le=null,me=null;const Ee=new gt(0,0,K,se),Be=new gt(0,0,K,se);let de=!1;const qe=new hc;let Ke=!1,Z=!1;const oe=new ft,Me=new O,Ie=new gt,Ce={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ze=!1;function St(){return C===null?$:1}let L=i;function rt(E,F){return t.getContext(E,F)}try{const E={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${nc}`),t.addEventListener("webglcontextlost",G,!1),t.addEventListener("webglcontextrestored",ee,!1),t.addEventListener("webglcontextcreationerror",k,!1),L===null){const F="webgl2";if(L=rt(F,E),L===null)throw rt(F)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(E){throw console.error("THREE.WebGLRenderer: "+E.message),E}let Ve,De,be,st,Se,He,vt,ut,R,v,H,ne,re,te,Re,fe,Te,I,P,U,Q,ie,ae,we;function D(){Ve=new Fg(L),Ve.init(),ie=new x0(L,Ve),De=new Pg(L,Ve,e,ie),be=new g0(L,Ve),De.reversedDepthBuffer&&d&&be.buffers.depth.setReversed(!0),st=new Vg(L),Se=new r0,He=new v0(L,Ve,be,Se,De,ie,st),vt=new Lg(_),ut=new Ug(_),R=new jp(L),ae=new Rg(L,R),v=new Bg(L,R,st,ae),H=new kg(L,v,R,st),P=new Hg(L,De,He),fe=new Dg(Se),ne=new i0(_,vt,ut,Ve,De,ae,fe),re=new T0(_,Se),te=new o0,Re=new f0(Ve),I=new Ag(_,vt,ut,be,H,p,l),Te=new m0(_,H,De),we=new w0(L,st,De,be),U=new Cg(L,Ve,st),Q=new zg(L,Ve,st),st.programs=ne.programs,_.capabilities=De,_.extensions=Ve,_.properties=Se,_.renderLists=te,_.shadowMap=Te,_.state=be,_.info=st}D();const V=new b0(_,L);this.xr=V,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){const E=Ve.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){const E=Ve.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return $},this.setPixelRatio=function(E){E!==void 0&&($=E,this.setSize(K,se,!1))},this.getSize=function(E){return E.set(K,se)},this.setSize=function(E,F,X=!0){if(V.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}K=E,se=F,t.width=Math.floor(E*$),t.height=Math.floor(F*$),X===!0&&(t.style.width=E+"px",t.style.height=F+"px"),this.setViewport(0,0,E,F)},this.getDrawingBufferSize=function(E){return E.set(K*$,se*$).floor()},this.setDrawingBufferSize=function(E,F,X){K=E,se=F,$=X,t.width=Math.floor(E*X),t.height=Math.floor(F*X),this.setViewport(0,0,E,F)},this.getCurrentViewport=function(E){return E.copy(N)},this.getViewport=function(E){return E.copy(Ee)},this.setViewport=function(E,F,X,j){E.isVector4?Ee.set(E.x,E.y,E.z,E.w):Ee.set(E,F,X,j),be.viewport(N.copy(Ee).multiplyScalar($).round())},this.getScissor=function(E){return E.copy(Be)},this.setScissor=function(E,F,X,j){E.isVector4?Be.set(E.x,E.y,E.z,E.w):Be.set(E,F,X,j),be.scissor(z.copy(Be).multiplyScalar($).round())},this.getScissorTest=function(){return de},this.setScissorTest=function(E){be.setScissorTest(de=E)},this.setOpaqueSort=function(E){le=E},this.setTransparentSort=function(E){me=E},this.getClearColor=function(E){return E.copy(I.getClearColor())},this.setClearColor=function(){I.setClearColor(...arguments)},this.getClearAlpha=function(){return I.getClearAlpha()},this.setClearAlpha=function(){I.setClearAlpha(...arguments)},this.clear=function(E=!0,F=!0,X=!0){let j=0;if(E){let B=!1;if(C!==null){const ce=C.texture.format;B=ce===lc||ce===ac||ce===oc}if(B){const ce=C.texture.type,_e=ce===kn||ce===Hi||ce===is||ce===rs||ce===rc||ce===sc,Ae=I.getClearColor(),ye=I.getClearAlpha(),Oe=Ae.r,Ue=Ae.g,Pe=Ae.b;_e?(g[0]=Oe,g[1]=Ue,g[2]=Pe,g[3]=ye,L.clearBufferuiv(L.COLOR,0,g)):(y[0]=Oe,y[1]=Ue,y[2]=Pe,y[3]=ye,L.clearBufferiv(L.COLOR,0,y))}else j|=L.COLOR_BUFFER_BIT}F&&(j|=L.DEPTH_BUFFER_BIT),X&&(j|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),L.clear(j)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",G,!1),t.removeEventListener("webglcontextrestored",ee,!1),t.removeEventListener("webglcontextcreationerror",k,!1),I.dispose(),te.dispose(),Re.dispose(),Se.dispose(),vt.dispose(),ut.dispose(),H.dispose(),ae.dispose(),we.dispose(),ne.dispose(),V.dispose(),V.removeEventListener("sessionstart",nn),V.removeEventListener("sessionend",Uc),Ei.stop()};function G(E){E.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),S=!0}function ee(){console.log("THREE.WebGLRenderer: Context Restored."),S=!1;const E=st.autoReset,F=Te.enabled,X=Te.autoUpdate,j=Te.needsUpdate,B=Te.type;D(),st.autoReset=E,Te.enabled=F,Te.autoUpdate=X,Te.needsUpdate=j,Te.type=B}function k(E){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",E.statusMessage)}function W(E){const F=E.target;F.removeEventListener("dispose",W),ue(F)}function ue(E){xe(E),Se.remove(E)}function xe(E){const F=Se.get(E).programs;F!==void 0&&(F.forEach(function(X){ne.releaseProgram(X)}),E.isShaderMaterial&&ne.releaseShaderCache(E))}this.renderBufferDirect=function(E,F,X,j,B,ce){F===null&&(F=Ce);const _e=B.isMesh&&B.matrixWorld.determinant()<0,Ae=ld(E,F,X,j,B);be.setMaterial(j,_e);let ye=X.index,Oe=1;if(j.wireframe===!0){if(ye=v.getWireframeAttribute(X),ye===void 0)return;Oe=2}const Ue=X.drawRange,Pe=X.attributes.position;let Ye=Ue.start*Oe,tt=(Ue.start+Ue.count)*Oe;ce!==null&&(Ye=Math.max(Ye,ce.start*Oe),tt=Math.min(tt,(ce.start+ce.count)*Oe)),ye!==null?(Ye=Math.max(Ye,0),tt=Math.min(tt,ye.count)):Pe!=null&&(Ye=Math.max(Ye,0),tt=Math.min(tt,Pe.count));const _t=tt-Ye;if(_t<0||_t===1/0)return;ae.setup(B,j,Ae,X,ye);let ht,ot=U;if(ye!==null&&(ht=R.get(ye),ot=Q,ot.setIndex(ht)),B.isMesh)j.wireframe===!0?(be.setLineWidth(j.wireframeLinewidth*St()),ot.setMode(L.LINES)):ot.setMode(L.TRIANGLES);else if(B.isLine){let Le=j.linewidth;Le===void 0&&(Le=1),be.setLineWidth(Le*St()),B.isLineSegments?ot.setMode(L.LINES):B.isLineLoop?ot.setMode(L.LINE_LOOP):ot.setMode(L.LINE_STRIP)}else B.isPoints?ot.setMode(L.POINTS):B.isSprite&&ot.setMode(L.TRIANGLES);if(B.isBatchedMesh)if(B._multiDrawInstances!==null)as("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),ot.renderMultiDrawInstances(B._multiDrawStarts,B._multiDrawCounts,B._multiDrawCount,B._multiDrawInstances);else if(Ve.get("WEBGL_multi_draw"))ot.renderMultiDraw(B._multiDrawStarts,B._multiDrawCounts,B._multiDrawCount);else{const Le=B._multiDrawStarts,pt=B._multiDrawCounts,Je=B._multiDrawCount,jt=ye?R.get(ye).bytesPerElement:1,Qi=Se.get(j).currentProgram.getUniforms();for(let Yt=0;Yt<Je;Yt++)Qi.setValue(L,"_gl_DrawID",Yt),ot.render(Le[Yt]/jt,pt[Yt])}else if(B.isInstancedMesh)ot.renderInstances(Ye,_t,B.count);else if(X.isInstancedBufferGeometry){const Le=X._maxInstanceCount!==void 0?X._maxInstanceCount:1/0,pt=Math.min(X.instanceCount,Le);ot.renderInstances(Ye,_t,pt)}else ot.render(Ye,_t)};function We(E,F,X){E.transparent===!0&&E.side===Nn&&E.forceSinglePass===!1?(E.side=Wt,E.needsUpdate=!0,Es(E,F,X),E.side=mi,E.needsUpdate=!0,Es(E,F,X),E.side=Nn):Es(E,F,X)}this.compile=function(E,F,X=null){X===null&&(X=E),f=Re.get(X),f.init(F),T.push(f),X.traverseVisible(function(B){B.isLight&&B.layers.test(F.layers)&&(f.pushLight(B),B.castShadow&&f.pushShadow(B))}),E!==X&&E.traverseVisible(function(B){B.isLight&&B.layers.test(F.layers)&&(f.pushLight(B),B.castShadow&&f.pushShadow(B))}),f.setupLights();const j=new Set;return E.traverse(function(B){if(!(B.isMesh||B.isPoints||B.isLine||B.isSprite))return;const ce=B.material;if(ce)if(Array.isArray(ce))for(let _e=0;_e<ce.length;_e++){const Ae=ce[_e];We(Ae,X,B),j.add(Ae)}else We(ce,X,B),j.add(ce)}),f=T.pop(),j},this.compileAsync=function(E,F,X=null){const j=this.compile(E,F,X);return new Promise(B=>{function ce(){if(j.forEach(function(_e){Se.get(_e).currentProgram.isReady()&&j.delete(_e)}),j.size===0){B(E);return}setTimeout(ce,10)}Ve.get("KHR_parallel_shader_compile")!==null?ce():setTimeout(ce,10)})};let $e=null;function vn(E){$e&&$e(E)}function nn(){Ei.stop()}function Uc(){Ei.start()}const Ei=new af;Ei.setAnimationLoop(vn),typeof self<"u"&&Ei.setContext(self),this.setAnimationLoop=function(E){$e=E,V.setAnimationLoop(E),E===null?Ei.stop():Ei.start()},V.addEventListener("sessionstart",nn),V.addEventListener("sessionend",Uc),this.render=function(E,F){if(F!==void 0&&F.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(S===!0)return;if(E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),F.parent===null&&F.matrixWorldAutoUpdate===!0&&F.updateMatrixWorld(),V.enabled===!0&&V.isPresenting===!0&&(V.cameraAutoUpdate===!0&&V.updateCamera(F),F=V.getCamera()),E.isScene===!0&&E.onBeforeRender(_,E,F,C),f=Re.get(E,T.length),f.init(F),T.push(f),oe.multiplyMatrices(F.projectionMatrix,F.matrixWorldInverse),qe.setFromProjectionMatrix(oe,Bn,F.reversedDepth),Z=this.localClippingEnabled,Ke=fe.init(this.clippingPlanes,Z),m=te.get(E,w.length),m.init(),w.push(m),V.enabled===!0&&V.isPresenting===!0){const ce=_.xr.getDepthSensingMesh();ce!==null&&Yo(ce,F,-1/0,_.sortObjects)}Yo(E,F,0,_.sortObjects),m.finish(),_.sortObjects===!0&&m.sort(le,me),ze=V.enabled===!1||V.isPresenting===!1||V.hasDepthSensing()===!1,ze&&I.addToRenderList(m,E),this.info.render.frame++,Ke===!0&&fe.beginShadows();const X=f.state.shadowsArray;Te.render(X,E,F),Ke===!0&&fe.endShadows(),this.info.autoReset===!0&&this.info.reset();const j=m.opaque,B=m.transmissive;if(f.setupLights(),F.isArrayCamera){const ce=F.cameras;if(B.length>0)for(let _e=0,Ae=ce.length;_e<Ae;_e++){const ye=ce[_e];Bc(j,B,E,ye)}ze&&I.render(E);for(let _e=0,Ae=ce.length;_e<Ae;_e++){const ye=ce[_e];Fc(m,E,ye,ye.viewport)}}else B.length>0&&Bc(j,B,E,F),ze&&I.render(E),Fc(m,E,F);C!==null&&A===0&&(He.updateMultisampleRenderTarget(C),He.updateRenderTargetMipmap(C)),E.isScene===!0&&E.onAfterRender(_,E,F),ae.resetDefaultState(),M=-1,x=null,T.pop(),T.length>0?(f=T[T.length-1],Ke===!0&&fe.setGlobalState(_.clippingPlanes,f.state.camera)):f=null,w.pop(),w.length>0?m=w[w.length-1]:m=null};function Yo(E,F,X,j){if(E.visible===!1)return;if(E.layers.test(F.layers)){if(E.isGroup)X=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(F);else if(E.isLight)f.pushLight(E),E.castShadow&&f.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||qe.intersectsSprite(E)){j&&Ie.setFromMatrixPosition(E.matrixWorld).applyMatrix4(oe);const _e=H.update(E),Ae=E.material;Ae.visible&&m.push(E,_e,Ae,X,Ie.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||qe.intersectsObject(E))){const _e=H.update(E),Ae=E.material;if(j&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),Ie.copy(E.boundingSphere.center)):(_e.boundingSphere===null&&_e.computeBoundingSphere(),Ie.copy(_e.boundingSphere.center)),Ie.applyMatrix4(E.matrixWorld).applyMatrix4(oe)),Array.isArray(Ae)){const ye=_e.groups;for(let Oe=0,Ue=ye.length;Oe<Ue;Oe++){const Pe=ye[Oe],Ye=Ae[Pe.materialIndex];Ye&&Ye.visible&&m.push(E,_e,Ye,X,Ie.z,Pe)}}else Ae.visible&&m.push(E,_e,Ae,X,Ie.z,null)}}const ce=E.children;for(let _e=0,Ae=ce.length;_e<Ae;_e++)Yo(ce[_e],F,X,j)}function Fc(E,F,X,j){const B=E.opaque,ce=E.transmissive,_e=E.transparent;f.setupLightsView(X),Ke===!0&&fe.setGlobalState(_.clippingPlanes,X),j&&be.viewport(N.copy(j)),B.length>0&&Ms(B,F,X),ce.length>0&&Ms(ce,F,X),_e.length>0&&Ms(_e,F,X),be.buffers.depth.setTest(!0),be.buffers.depth.setMask(!0),be.buffers.color.setMask(!0),be.setPolygonOffset(!1)}function Bc(E,F,X,j){if((X.isScene===!0?X.overrideMaterial:null)!==null)return;f.state.transmissionRenderTarget[j.id]===void 0&&(f.state.transmissionRenderTarget[j.id]=new ki(1,1,{generateMipmaps:!0,type:Ve.has("EXT_color_buffer_half_float")||Ve.has("EXT_color_buffer_float")?ds:kn,minFilter:Bi,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Qe.workingColorSpace}));const ce=f.state.transmissionRenderTarget[j.id],_e=j.viewport||N;ce.setSize(_e.z*_.transmissionResolutionScale,_e.w*_.transmissionResolutionScale);const Ae=_.getRenderTarget(),ye=_.getActiveCubeFace(),Oe=_.getActiveMipmapLevel();_.setRenderTarget(ce),_.getClearColor(q),J=_.getClearAlpha(),J<1&&_.setClearColor(16777215,.5),_.clear(),ze&&I.render(X);const Ue=_.toneMapping;_.toneMapping=pi;const Pe=j.viewport;if(j.viewport!==void 0&&(j.viewport=void 0),f.setupLightsView(j),Ke===!0&&fe.setGlobalState(_.clippingPlanes,j),Ms(E,X,j),He.updateMultisampleRenderTarget(ce),He.updateRenderTargetMipmap(ce),Ve.has("WEBGL_multisampled_render_to_texture")===!1){let Ye=!1;for(let tt=0,_t=F.length;tt<_t;tt++){const ht=F[tt],ot=ht.object,Le=ht.geometry,pt=ht.material,Je=ht.group;if(pt.side===Nn&&ot.layers.test(j.layers)){const jt=pt.side;pt.side=Wt,pt.needsUpdate=!0,zc(ot,X,j,Le,pt,Je),pt.side=jt,pt.needsUpdate=!0,Ye=!0}}Ye===!0&&(He.updateMultisampleRenderTarget(ce),He.updateRenderTargetMipmap(ce))}_.setRenderTarget(Ae,ye,Oe),_.setClearColor(q,J),Pe!==void 0&&(j.viewport=Pe),_.toneMapping=Ue}function Ms(E,F,X){const j=F.isScene===!0?F.overrideMaterial:null;for(let B=0,ce=E.length;B<ce;B++){const _e=E[B],Ae=_e.object,ye=_e.geometry,Oe=_e.group;let Ue=_e.material;Ue.allowOverride===!0&&j!==null&&(Ue=j),Ae.layers.test(X.layers)&&zc(Ae,F,X,ye,Ue,Oe)}}function zc(E,F,X,j,B,ce){E.onBeforeRender(_,F,X,j,B,ce),E.modelViewMatrix.multiplyMatrices(X.matrixWorldInverse,E.matrixWorld),E.normalMatrix.getNormalMatrix(E.modelViewMatrix),B.onBeforeRender(_,F,X,j,E,ce),B.transparent===!0&&B.side===Nn&&B.forceSinglePass===!1?(B.side=Wt,B.needsUpdate=!0,_.renderBufferDirect(X,F,j,B,E,ce),B.side=mi,B.needsUpdate=!0,_.renderBufferDirect(X,F,j,B,E,ce),B.side=Nn):_.renderBufferDirect(X,F,j,B,E,ce),E.onAfterRender(_,F,X,j,B,ce)}function Es(E,F,X){F.isScene!==!0&&(F=Ce);const j=Se.get(E),B=f.state.lights,ce=f.state.shadowsArray,_e=B.state.version,Ae=ne.getParameters(E,B.state,ce,F,X),ye=ne.getProgramCacheKey(Ae);let Oe=j.programs;j.environment=E.isMeshStandardMaterial?F.environment:null,j.fog=F.fog,j.envMap=(E.isMeshStandardMaterial?ut:vt).get(E.envMap||j.environment),j.envMapRotation=j.environment!==null&&E.envMap===null?F.environmentRotation:E.envMapRotation,Oe===void 0&&(E.addEventListener("dispose",W),Oe=new Map,j.programs=Oe);let Ue=Oe.get(ye);if(Ue!==void 0){if(j.currentProgram===Ue&&j.lightsStateVersion===_e)return Hc(E,Ae),Ue}else Ae.uniforms=ne.getUniforms(E),E.onBeforeCompile(Ae,_),Ue=ne.acquireProgram(Ae,ye),Oe.set(ye,Ue),j.uniforms=Ae.uniforms;const Pe=j.uniforms;return(!E.isShaderMaterial&&!E.isRawShaderMaterial||E.clipping===!0)&&(Pe.clippingPlanes=fe.uniform),Hc(E,Ae),j.needsLights=ud(E),j.lightsStateVersion=_e,j.needsLights&&(Pe.ambientLightColor.value=B.state.ambient,Pe.lightProbe.value=B.state.probe,Pe.directionalLights.value=B.state.directional,Pe.directionalLightShadows.value=B.state.directionalShadow,Pe.spotLights.value=B.state.spot,Pe.spotLightShadows.value=B.state.spotShadow,Pe.rectAreaLights.value=B.state.rectArea,Pe.ltc_1.value=B.state.rectAreaLTC1,Pe.ltc_2.value=B.state.rectAreaLTC2,Pe.pointLights.value=B.state.point,Pe.pointLightShadows.value=B.state.pointShadow,Pe.hemisphereLights.value=B.state.hemi,Pe.directionalShadowMap.value=B.state.directionalShadowMap,Pe.directionalShadowMatrix.value=B.state.directionalShadowMatrix,Pe.spotShadowMap.value=B.state.spotShadowMap,Pe.spotLightMatrix.value=B.state.spotLightMatrix,Pe.spotLightMap.value=B.state.spotLightMap,Pe.pointShadowMap.value=B.state.pointShadowMap,Pe.pointShadowMatrix.value=B.state.pointShadowMatrix),j.currentProgram=Ue,j.uniformsList=null,Ue}function Vc(E){if(E.uniformsList===null){const F=E.currentProgram.getUniforms();E.uniformsList=co.seqWithValue(F.seq,E.uniforms)}return E.uniformsList}function Hc(E,F){const X=Se.get(E);X.outputColorSpace=F.outputColorSpace,X.batching=F.batching,X.batchingColor=F.batchingColor,X.instancing=F.instancing,X.instancingColor=F.instancingColor,X.instancingMorph=F.instancingMorph,X.skinning=F.skinning,X.morphTargets=F.morphTargets,X.morphNormals=F.morphNormals,X.morphColors=F.morphColors,X.morphTargetsCount=F.morphTargetsCount,X.numClippingPlanes=F.numClippingPlanes,X.numIntersection=F.numClipIntersection,X.vertexAlphas=F.vertexAlphas,X.vertexTangents=F.vertexTangents,X.toneMapping=F.toneMapping}function ld(E,F,X,j,B){F.isScene!==!0&&(F=Ce),He.resetTextureUnits();const ce=F.fog,_e=j.isMeshStandardMaterial?F.environment:null,Ae=C===null?_.outputColorSpace:C.isXRRenderTarget===!0?C.texture.colorSpace:Cr,ye=(j.isMeshStandardMaterial?ut:vt).get(j.envMap||_e),Oe=j.vertexColors===!0&&!!X.attributes.color&&X.attributes.color.itemSize===4,Ue=!!X.attributes.tangent&&(!!j.normalMap||j.anisotropy>0),Pe=!!X.morphAttributes.position,Ye=!!X.morphAttributes.normal,tt=!!X.morphAttributes.color;let _t=pi;j.toneMapped&&(C===null||C.isXRRenderTarget===!0)&&(_t=_.toneMapping);const ht=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,ot=ht!==void 0?ht.length:0,Le=Se.get(j),pt=f.state.lights;if(Ke===!0&&(Z===!0||E!==x)){const Bt=E===x&&j.id===M;fe.setState(j,E,Bt)}let Je=!1;j.version===Le.__version?(Le.needsLights&&Le.lightsStateVersion!==pt.state.version||Le.outputColorSpace!==Ae||B.isBatchedMesh&&Le.batching===!1||!B.isBatchedMesh&&Le.batching===!0||B.isBatchedMesh&&Le.batchingColor===!0&&B.colorTexture===null||B.isBatchedMesh&&Le.batchingColor===!1&&B.colorTexture!==null||B.isInstancedMesh&&Le.instancing===!1||!B.isInstancedMesh&&Le.instancing===!0||B.isSkinnedMesh&&Le.skinning===!1||!B.isSkinnedMesh&&Le.skinning===!0||B.isInstancedMesh&&Le.instancingColor===!0&&B.instanceColor===null||B.isInstancedMesh&&Le.instancingColor===!1&&B.instanceColor!==null||B.isInstancedMesh&&Le.instancingMorph===!0&&B.morphTexture===null||B.isInstancedMesh&&Le.instancingMorph===!1&&B.morphTexture!==null||Le.envMap!==ye||j.fog===!0&&Le.fog!==ce||Le.numClippingPlanes!==void 0&&(Le.numClippingPlanes!==fe.numPlanes||Le.numIntersection!==fe.numIntersection)||Le.vertexAlphas!==Oe||Le.vertexTangents!==Ue||Le.morphTargets!==Pe||Le.morphNormals!==Ye||Le.morphColors!==tt||Le.toneMapping!==_t||Le.morphTargetsCount!==ot)&&(Je=!0):(Je=!0,Le.__version=j.version);let jt=Le.currentProgram;Je===!0&&(jt=Es(j,F,B));let Qi=!1,Yt=!1,Vr=!1;const mt=jt.getUniforms(),rn=Le.uniforms;if(be.useProgram(jt.program)&&(Qi=!0,Yt=!0,Vr=!0),j.id!==M&&(M=j.id,Yt=!0),Qi||x!==E){be.buffers.depth.getReversed()&&E.reversedDepth!==!0&&(E._reversedDepth=!0,E.updateProjectionMatrix()),mt.setValue(L,"projectionMatrix",E.projectionMatrix),mt.setValue(L,"viewMatrix",E.matrixWorldInverse);const Vt=mt.map.cameraPosition;Vt!==void 0&&Vt.setValue(L,Me.setFromMatrixPosition(E.matrixWorld)),De.logarithmicDepthBuffer&&mt.setValue(L,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),(j.isMeshPhongMaterial||j.isMeshToonMaterial||j.isMeshLambertMaterial||j.isMeshBasicMaterial||j.isMeshStandardMaterial||j.isShaderMaterial)&&mt.setValue(L,"isOrthographic",E.isOrthographicCamera===!0),x!==E&&(x=E,Yt=!0,Vr=!0)}if(B.isSkinnedMesh){mt.setOptional(L,B,"bindMatrix"),mt.setOptional(L,B,"bindMatrixInverse");const Bt=B.skeleton;Bt&&(Bt.boneTexture===null&&Bt.computeBoneTexture(),mt.setValue(L,"boneTexture",Bt.boneTexture,He))}B.isBatchedMesh&&(mt.setOptional(L,B,"batchingTexture"),mt.setValue(L,"batchingTexture",B._matricesTexture,He),mt.setOptional(L,B,"batchingIdTexture"),mt.setValue(L,"batchingIdTexture",B._indirectTexture,He),mt.setOptional(L,B,"batchingColorTexture"),B._colorsTexture!==null&&mt.setValue(L,"batchingColorTexture",B._colorsTexture,He));const sn=X.morphAttributes;if((sn.position!==void 0||sn.normal!==void 0||sn.color!==void 0)&&P.update(B,X,jt),(Yt||Le.receiveShadow!==B.receiveShadow)&&(Le.receiveShadow=B.receiveShadow,mt.setValue(L,"receiveShadow",B.receiveShadow)),j.isMeshGouraudMaterial&&j.envMap!==null&&(rn.envMap.value=ye,rn.flipEnvMap.value=ye.isCubeTexture&&ye.isRenderTargetTexture===!1?-1:1),j.isMeshStandardMaterial&&j.envMap===null&&F.environment!==null&&(rn.envMapIntensity.value=F.environmentIntensity),Yt&&(mt.setValue(L,"toneMappingExposure",_.toneMappingExposure),Le.needsLights&&cd(rn,Vr),ce&&j.fog===!0&&re.refreshFogUniforms(rn,ce),re.refreshMaterialUniforms(rn,j,$,se,f.state.transmissionRenderTarget[E.id]),co.upload(L,Vc(Le),rn,He)),j.isShaderMaterial&&j.uniformsNeedUpdate===!0&&(co.upload(L,Vc(Le),rn,He),j.uniformsNeedUpdate=!1),j.isSpriteMaterial&&mt.setValue(L,"center",B.center),mt.setValue(L,"modelViewMatrix",B.modelViewMatrix),mt.setValue(L,"normalMatrix",B.normalMatrix),mt.setValue(L,"modelMatrix",B.matrixWorld),j.isShaderMaterial||j.isRawShaderMaterial){const Bt=j.uniformsGroups;for(let Vt=0,qo=Bt.length;Vt<qo;Vt++){const bi=Bt[Vt];we.update(bi,jt),we.bind(bi,jt)}}return jt}function cd(E,F){E.ambientLightColor.needsUpdate=F,E.lightProbe.needsUpdate=F,E.directionalLights.needsUpdate=F,E.directionalLightShadows.needsUpdate=F,E.pointLights.needsUpdate=F,E.pointLightShadows.needsUpdate=F,E.spotLights.needsUpdate=F,E.spotLightShadows.needsUpdate=F,E.rectAreaLights.needsUpdate=F,E.hemisphereLights.needsUpdate=F}function ud(E){return E.isMeshLambertMaterial||E.isMeshToonMaterial||E.isMeshPhongMaterial||E.isMeshStandardMaterial||E.isShadowMaterial||E.isShaderMaterial&&E.lights===!0}this.getActiveCubeFace=function(){return b},this.getActiveMipmapLevel=function(){return A},this.getRenderTarget=function(){return C},this.setRenderTargetTextures=function(E,F,X){const j=Se.get(E);j.__autoAllocateDepthBuffer=E.resolveDepthBuffer===!1,j.__autoAllocateDepthBuffer===!1&&(j.__useRenderToTexture=!1),Se.get(E.texture).__webglTexture=F,Se.get(E.depthTexture).__webglTexture=j.__autoAllocateDepthBuffer?void 0:X,j.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(E,F){const X=Se.get(E);X.__webglFramebuffer=F,X.__useDefaultFramebuffer=F===void 0};const hd=L.createFramebuffer();this.setRenderTarget=function(E,F=0,X=0){C=E,b=F,A=X;let j=!0,B=null,ce=!1,_e=!1;if(E){const ye=Se.get(E);if(ye.__useDefaultFramebuffer!==void 0)be.bindFramebuffer(L.FRAMEBUFFER,null),j=!1;else if(ye.__webglFramebuffer===void 0)He.setupRenderTarget(E);else if(ye.__hasExternalTextures)He.rebindTextures(E,Se.get(E.texture).__webglTexture,Se.get(E.depthTexture).__webglTexture);else if(E.depthBuffer){const Pe=E.depthTexture;if(ye.__boundDepthTexture!==Pe){if(Pe!==null&&Se.has(Pe)&&(E.width!==Pe.image.width||E.height!==Pe.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");He.setupDepthRenderbuffer(E)}}const Oe=E.texture;(Oe.isData3DTexture||Oe.isDataArrayTexture||Oe.isCompressedArrayTexture)&&(_e=!0);const Ue=Se.get(E).__webglFramebuffer;E.isWebGLCubeRenderTarget?(Array.isArray(Ue[F])?B=Ue[F][X]:B=Ue[F],ce=!0):E.samples>0&&He.useMultisampledRTT(E)===!1?B=Se.get(E).__webglMultisampledFramebuffer:Array.isArray(Ue)?B=Ue[X]:B=Ue,N.copy(E.viewport),z.copy(E.scissor),Y=E.scissorTest}else N.copy(Ee).multiplyScalar($).floor(),z.copy(Be).multiplyScalar($).floor(),Y=de;if(X!==0&&(B=hd),be.bindFramebuffer(L.FRAMEBUFFER,B)&&j&&be.drawBuffers(E,B),be.viewport(N),be.scissor(z),be.setScissorTest(Y),ce){const ye=Se.get(E.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+F,ye.__webglTexture,X)}else if(_e){const ye=F;for(let Oe=0;Oe<E.textures.length;Oe++){const Ue=Se.get(E.textures[Oe]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+Oe,Ue.__webglTexture,X,ye)}}else if(E!==null&&X!==0){const ye=Se.get(E.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,ye.__webglTexture,X)}M=-1},this.readRenderTargetPixels=function(E,F,X,j,B,ce,_e,Ae=0){if(!(E&&E.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ye=Se.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&_e!==void 0&&(ye=ye[_e]),ye){be.bindFramebuffer(L.FRAMEBUFFER,ye);try{const Oe=E.textures[Ae],Ue=Oe.format,Pe=Oe.type;if(!De.textureFormatReadable(Ue)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!De.textureTypeReadable(Pe)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}F>=0&&F<=E.width-j&&X>=0&&X<=E.height-B&&(E.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+Ae),L.readPixels(F,X,j,B,ie.convert(Ue),ie.convert(Pe),ce))}finally{const Oe=C!==null?Se.get(C).__webglFramebuffer:null;be.bindFramebuffer(L.FRAMEBUFFER,Oe)}}},this.readRenderTargetPixelsAsync=async function(E,F,X,j,B,ce,_e,Ae=0){if(!(E&&E.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ye=Se.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&_e!==void 0&&(ye=ye[_e]),ye)if(F>=0&&F<=E.width-j&&X>=0&&X<=E.height-B){be.bindFramebuffer(L.FRAMEBUFFER,ye);const Oe=E.textures[Ae],Ue=Oe.format,Pe=Oe.type;if(!De.textureFormatReadable(Ue))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!De.textureTypeReadable(Pe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ye=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,Ye),L.bufferData(L.PIXEL_PACK_BUFFER,ce.byteLength,L.STREAM_READ),E.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+Ae),L.readPixels(F,X,j,B,ie.convert(Ue),ie.convert(Pe),0);const tt=C!==null?Se.get(C).__webglFramebuffer:null;be.bindFramebuffer(L.FRAMEBUFFER,tt);const _t=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await op(L,_t,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,Ye),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,ce),L.deleteBuffer(Ye),L.deleteSync(_t),ce}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(E,F=null,X=0){const j=Math.pow(2,-X),B=Math.floor(E.image.width*j),ce=Math.floor(E.image.height*j),_e=F!==null?F.x:0,Ae=F!==null?F.y:0;He.setTexture2D(E,0),L.copyTexSubImage2D(L.TEXTURE_2D,X,0,0,_e,Ae,B,ce),be.unbindTexture()};const fd=L.createFramebuffer(),dd=L.createFramebuffer();this.copyTextureToTexture=function(E,F,X=null,j=null,B=0,ce=null){ce===null&&(B!==0?(as("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),ce=B,B=0):ce=0);let _e,Ae,ye,Oe,Ue,Pe,Ye,tt,_t;const ht=E.isCompressedTexture?E.mipmaps[ce]:E.image;if(X!==null)_e=X.max.x-X.min.x,Ae=X.max.y-X.min.y,ye=X.isBox3?X.max.z-X.min.z:1,Oe=X.min.x,Ue=X.min.y,Pe=X.isBox3?X.min.z:0;else{const sn=Math.pow(2,-B);_e=Math.floor(ht.width*sn),Ae=Math.floor(ht.height*sn),E.isDataArrayTexture?ye=ht.depth:E.isData3DTexture?ye=Math.floor(ht.depth*sn):ye=1,Oe=0,Ue=0,Pe=0}j!==null?(Ye=j.x,tt=j.y,_t=j.z):(Ye=0,tt=0,_t=0);const ot=ie.convert(F.format),Le=ie.convert(F.type);let pt;F.isData3DTexture?(He.setTexture3D(F,0),pt=L.TEXTURE_3D):F.isDataArrayTexture||F.isCompressedArrayTexture?(He.setTexture2DArray(F,0),pt=L.TEXTURE_2D_ARRAY):(He.setTexture2D(F,0),pt=L.TEXTURE_2D),L.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,F.flipY),L.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,F.premultiplyAlpha),L.pixelStorei(L.UNPACK_ALIGNMENT,F.unpackAlignment);const Je=L.getParameter(L.UNPACK_ROW_LENGTH),jt=L.getParameter(L.UNPACK_IMAGE_HEIGHT),Qi=L.getParameter(L.UNPACK_SKIP_PIXELS),Yt=L.getParameter(L.UNPACK_SKIP_ROWS),Vr=L.getParameter(L.UNPACK_SKIP_IMAGES);L.pixelStorei(L.UNPACK_ROW_LENGTH,ht.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,ht.height),L.pixelStorei(L.UNPACK_SKIP_PIXELS,Oe),L.pixelStorei(L.UNPACK_SKIP_ROWS,Ue),L.pixelStorei(L.UNPACK_SKIP_IMAGES,Pe);const mt=E.isDataArrayTexture||E.isData3DTexture,rn=F.isDataArrayTexture||F.isData3DTexture;if(E.isDepthTexture){const sn=Se.get(E),Bt=Se.get(F),Vt=Se.get(sn.__renderTarget),qo=Se.get(Bt.__renderTarget);be.bindFramebuffer(L.READ_FRAMEBUFFER,Vt.__webglFramebuffer),be.bindFramebuffer(L.DRAW_FRAMEBUFFER,qo.__webglFramebuffer);for(let bi=0;bi<ye;bi++)mt&&(L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Se.get(E).__webglTexture,B,Pe+bi),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Se.get(F).__webglTexture,ce,_t+bi)),L.blitFramebuffer(Oe,Ue,_e,Ae,Ye,tt,_e,Ae,L.DEPTH_BUFFER_BIT,L.NEAREST);be.bindFramebuffer(L.READ_FRAMEBUFFER,null),be.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(B!==0||E.isRenderTargetTexture||Se.has(E)){const sn=Se.get(E),Bt=Se.get(F);be.bindFramebuffer(L.READ_FRAMEBUFFER,fd),be.bindFramebuffer(L.DRAW_FRAMEBUFFER,dd);for(let Vt=0;Vt<ye;Vt++)mt?L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,sn.__webglTexture,B,Pe+Vt):L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,sn.__webglTexture,B),rn?L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Bt.__webglTexture,ce,_t+Vt):L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,Bt.__webglTexture,ce),B!==0?L.blitFramebuffer(Oe,Ue,_e,Ae,Ye,tt,_e,Ae,L.COLOR_BUFFER_BIT,L.NEAREST):rn?L.copyTexSubImage3D(pt,ce,Ye,tt,_t+Vt,Oe,Ue,_e,Ae):L.copyTexSubImage2D(pt,ce,Ye,tt,Oe,Ue,_e,Ae);be.bindFramebuffer(L.READ_FRAMEBUFFER,null),be.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else rn?E.isDataTexture||E.isData3DTexture?L.texSubImage3D(pt,ce,Ye,tt,_t,_e,Ae,ye,ot,Le,ht.data):F.isCompressedArrayTexture?L.compressedTexSubImage3D(pt,ce,Ye,tt,_t,_e,Ae,ye,ot,ht.data):L.texSubImage3D(pt,ce,Ye,tt,_t,_e,Ae,ye,ot,Le,ht):E.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,ce,Ye,tt,_e,Ae,ot,Le,ht.data):E.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,ce,Ye,tt,ht.width,ht.height,ot,ht.data):L.texSubImage2D(L.TEXTURE_2D,ce,Ye,tt,_e,Ae,ot,Le,ht);L.pixelStorei(L.UNPACK_ROW_LENGTH,Je),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,jt),L.pixelStorei(L.UNPACK_SKIP_PIXELS,Qi),L.pixelStorei(L.UNPACK_SKIP_ROWS,Yt),L.pixelStorei(L.UNPACK_SKIP_IMAGES,Vr),ce===0&&F.generateMipmaps&&L.generateMipmap(pt),be.unbindTexture()},this.initRenderTarget=function(E){Se.get(E).__webglFramebuffer===void 0&&He.setupRenderTarget(E)},this.initTexture=function(E){E.isCubeTexture?He.setTextureCube(E,0):E.isData3DTexture?He.setTexture3D(E,0):E.isDataArrayTexture||E.isCompressedArrayTexture?He.setTexture2DArray(E,0):He.setTexture2D(E,0),be.unbindTexture()},this.resetState=function(){b=0,A=0,C=null,be.reset(),ae.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Bn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=Qe._getDrawingBufferColorSpace(e),t.unpackColorSpace=Qe._getUnpackColorSpace()}}class R0{type;position;normal;uv;material;constructor(e){this.type=e.type,this.position=e.position,this.normal=e.normal??[],this.uv=e.uv??[],this.material=e.material}}var an=(n=>(n[n.Cube=0]="Cube",n[n.Sphere=1]="Sphere",n[n.Plane=2]="Plane",n[n.Cylinder=3]="Cylinder",n[n.Cone=4]="Cone",n[n.Torus=5]="Torus",n[n.Circle=6]="Circle",n[n.Icosphere=7]="Icosphere",n[n.UVSphere=8]="UVSphere",n[n.Custom=9]="Custom",n))(an||{}),Sr=(n=>(n.Plane="plane",n.Wireframe="wireframe",n.Texture="texture",n))(Sr||{}),dn=(n=>(n.Mesh="mesh",n.Face="face",n.Edge="edge",n.Vertex="vertex",n))(dn||{}),gi=(n=>(n.Translate="translate",n.Scale="scale",n.Rotate="rotate",n))(gi||{}),Tr=(n=>(n[n.AddFigure=0]="AddFigure",n[n.DeleteFigure=1]="DeleteFigure",n[n.LoadFigure=2]="LoadFigure",n[n.Load=3]="Load",n[n.Export=4]="Export",n))(Tr||{});const C0={[an.Plane]:()=>new Ir(1,1,1,1),[an.Cube]:()=>new yt(1,1,1,1,1,1),[an.UVSphere]:()=>new ls(.5,32,16),[an.Icosphere]:()=>new mc(.5,0),[an.Cylinder]:()=>new Pt(.5,.5,1,32,1,!1),[an.Cone]:()=>new pc(.5,1,32,1,!1),[an.Torus]:()=>new hi(.5,.2,16,64),[an.Circle]:()=>new dc(.5,32),[an.Sphere]:()=>new ls(.5,32,16),[an.Custom]:function(){throw new Error("Custom geometry is not generated here.")}},ff=new Np({color:12566463,metalness:0,roughness:.6});class vc{scene;camera;renderer;canvas;meshes=[];constructor(e){this.canvas=e,this.scene=new Dp,this.scene.background=new je(1710618),this.camera=new cn(45,e.clientWidth/e.clientHeight,.1,1e3),this.camera.position.set(1,1,7),this.renderer=new A0({canvas:e,antialias:!0}),this.renderer.setSize(e.clientWidth,e.clientHeight);const t=new kp(16777215,.5);this.scene.add(t);const i=new Hp(16777215,1);i.position.set(5,10,7),this.scene.add(i)}resize(){this.camera.aspect=this.canvas.clientWidth/this.canvas.clientHeight,this.camera.updateProjectionMatrix(),this.renderer.setSize(this.canvas.clientWidth,this.canvas.clientHeight)}render(){this.renderer.render(this.scene,this.camera)}update(){}loop(){this.update(),this.render(),requestAnimationFrame(()=>this.loop())}addFigure(e){const t=new bt;t.setAttribute("position",new Ze(e.position,3)),e.normal&&t.setAttribute("normal",new Ze(e.normal,3)),e.uv&&t.setAttribute("uv",new Ze(e.uv,2));const i=new ge(t,ff);return this.scene.add(i),this.meshes.push(i),i}addMesh(e){this.scene&&(this.scene.add(e),this.meshes.push(e))}removeMesh(e){this.scene&&(this.scene.remove(e),this.meshes=this.meshes.filter(t=>t!==e))}getMeshes(){return this.meshes}addObject(e,t){this.scene&&(typeof t=="number"&&e.layers.set(t),this.scene.add(e))}removeObject(e){this.scene&&(e.parent?e.parent.remove(e):this.scene.remove(e))}enableCameraLayer(e){this.camera&&this.camera.layers.enable(e)}dispose(){this.meshes&&(this.meshes.length=0,this.meshes=[]),this.scene=null,this.camera=null,this.renderer?.dispose(),this.canvas=null}}const $u={type:"change"},xc={type:"start"},df={type:"end"},$s=new Oo,Zu=new ci,P0=Math.cos(70*rp.DEG2RAD),Tt=new O,kt=2*Math.PI,it={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Ra=1e-6;class pf extends of{constructor(e,t=null){super(e,t),this.state=it.NONE,this.target=new O,this.cursor=new O,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Mr.ROTATE,MIDDLE:Mr.DOLLY,RIGHT:Mr.PAN},this.touches={ONE:mr.ROTATE,TWO:mr.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new O,this._lastQuaternion=new Dt,this._lastTargetPosition=new O,this._quat=new Dt().setFromUnitVectors(e.up,new O(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new bu,this._sphericalDelta=new bu,this._scale=1,this._panOffset=new O,this._rotateStart=new Ne,this._rotateEnd=new Ne,this._rotateDelta=new Ne,this._panStart=new Ne,this._panEnd=new Ne,this._panDelta=new Ne,this._dollyStart=new Ne,this._dollyEnd=new Ne,this._dollyDelta=new Ne,this._dollyDirection=new O,this._mouse=new Ne,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=L0.bind(this),this._onPointerDown=D0.bind(this),this._onPointerUp=O0.bind(this),this._onContextMenu=V0.bind(this),this._onMouseWheel=U0.bind(this),this._onKeyDown=F0.bind(this),this._onTouchStart=B0.bind(this),this._onTouchMove=z0.bind(this),this._onMouseDown=I0.bind(this),this._onMouseMove=N0.bind(this),this._interceptControlDown=H0.bind(this),this._interceptControlUp=k0.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent($u),this.update(),this.state=it.NONE}update(e=null){const t=this.object.position;Tt.copy(t).sub(this.target),Tt.applyQuaternion(this._quat),this._spherical.setFromVector3(Tt),this.autoRotate&&this.state===it.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let i=this.minAzimuthAngle,r=this.maxAzimuthAngle;isFinite(i)&&isFinite(r)&&(i<-Math.PI?i+=kt:i>Math.PI&&(i-=kt),r<-Math.PI?r+=kt:r>Math.PI&&(r-=kt),i<=r?this._spherical.theta=Math.max(i,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+r)/2?Math.max(i,this._spherical.theta):Math.min(r,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=o!=this._spherical.radius}if(Tt.setFromSpherical(this._spherical),Tt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Tt),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const a=Tt.length();o=this._clampDistance(a*this._scale);const l=a-o;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),s=!!l}else if(this.object.isOrthographicCamera){const a=new O(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=l!==this.object.zoom;const c=new O(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),o=Tt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):($s.origin.copy(this.object.position),$s.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot($s.direction))<P0?this.object.lookAt(this.target):(Zu.setFromNormalAndCoplanarPoint(this.object.up,this.target),$s.intersectPlane(Zu,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>Ra||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Ra||this._lastTargetPosition.distanceToSquared(this.target)>Ra?(this.dispatchEvent($u),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?kt/60*this.autoRotateSpeed*e:kt/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Tt.setFromMatrixColumn(t,0),Tt.multiplyScalar(-e),this._panOffset.add(Tt)}_panUp(e,t){this.screenSpacePanning===!0?Tt.setFromMatrixColumn(t,1):(Tt.setFromMatrixColumn(t,0),Tt.crossVectors(this.object.up,Tt)),Tt.multiplyScalar(e),this._panOffset.add(Tt)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const r=this.object.position;Tt.copy(r).sub(this.target);let s=Tt.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/i.clientHeight,this.object.matrix),this._panUp(2*t*s/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),r=e-i.left,s=t-i.top,o=i.width,a=i.height;this._mouse.x=r/o*2-1,this._mouse.y=-(s/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(kt*this._rotateDelta.x/t.clientHeight),this._rotateUp(kt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(kt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-kt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(kt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-kt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(i,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(i,r)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(i*i+r*r);this._dollyStart.set(0,s)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),r=.5*(e.pageX+i.x),s=.5*(e.pageY+i.y);this._rotateEnd.set(r,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(kt*this._rotateDelta.x/t.clientHeight),this._rotateUp(kt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(i,r)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(i*i+r*r);this._dollyEnd.set(0,s),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new Ne,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,i={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:i.deltaY*=16;break;case 2:i.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(i.deltaY*=10),i}}function D0(n){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(n.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(n)&&(this._addPointer(n),n.pointerType==="touch"?this._onTouchStart(n):this._onMouseDown(n)))}function L0(n){this.enabled!==!1&&(n.pointerType==="touch"?this._onTouchMove(n):this._onMouseMove(n))}function O0(n){switch(this._removePointer(n),this._pointers.length){case 0:this.domElement.releasePointerCapture(n.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(df),this.state=it.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function I0(n){let e;switch(n.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case Mr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(n),this.state=it.DOLLY;break;case Mr.ROTATE:if(n.ctrlKey||n.metaKey||n.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(n),this.state=it.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(n),this.state=it.ROTATE}break;case Mr.PAN:if(n.ctrlKey||n.metaKey||n.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(n),this.state=it.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(n),this.state=it.PAN}break;default:this.state=it.NONE}this.state!==it.NONE&&this.dispatchEvent(xc)}function N0(n){switch(this.state){case it.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(n);break;case it.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(n);break;case it.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(n);break}}function U0(n){this.enabled===!1||this.enableZoom===!1||this.state!==it.NONE||(n.preventDefault(),this.dispatchEvent(xc),this._handleMouseWheel(this._customWheelEvent(n)),this.dispatchEvent(df))}function F0(n){this.enabled!==!1&&this._handleKeyDown(n)}function B0(n){switch(this._trackPointer(n),this._pointers.length){case 1:switch(this.touches.ONE){case mr.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(n),this.state=it.TOUCH_ROTATE;break;case mr.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(n),this.state=it.TOUCH_PAN;break;default:this.state=it.NONE}break;case 2:switch(this.touches.TWO){case mr.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(n),this.state=it.TOUCH_DOLLY_PAN;break;case mr.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(n),this.state=it.TOUCH_DOLLY_ROTATE;break;default:this.state=it.NONE}break;default:this.state=it.NONE}this.state!==it.NONE&&this.dispatchEvent(xc)}function z0(n){switch(this._trackPointer(n),this.state){case it.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(n),this.update();break;case it.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(n),this.update();break;case it.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(n),this.update();break;case it.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(n),this.update();break;default:this.state=it.NONE}}function V0(n){this.enabled!==!1&&n.preventDefault()}function H0(n){n.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function k0(n){n.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class G0 extends pf{isInteracting=!1;constructor(e,t){super(e,t),this.domElement?.addEventListener("mousedown",()=>this.isInteracting=!0),this.domElement?.addEventListener("mouseup",()=>this.isInteracting=!1),this.domElement?.addEventListener("touchstart",()=>this.isInteracting=!0),this.domElement?.addEventListener("touchend",()=>this.isInteracting=!1)}dispose(){this.domElement?.removeEventListener("mousedown",()=>this.isInteracting=!0),this.domElement?.removeEventListener("mouseup",()=>this.isInteracting=!1),this.domElement?.removeEventListener("touchstart",()=>this.isInteracting=!0),this.domElement?.removeEventListener("touchend",()=>this.isInteracting=!1)}}class W0 extends Kr{constructor(e=5){super();const t=[{dir:new O(1,0,0),color:16711680},{dir:new O(-1,0,0),color:16711680},{dir:new O(0,1,0),color:65280},{dir:new O(0,-1,0),color:65280},{dir:new O(0,0,1),color:255},{dir:new O(0,0,-1),color:255}];for(const{dir:i,color:r}of t){const s=new bt().setFromPoints([new O(0,0,0),i.clone().multiplyScalar(e)]),o=new $i({color:r}),a=new En(s,o);this.add(a)}}}const Pi=new sf,Ft=new O,li=new O,dt=new Dt,Ku={X:new O(1,0,0),Y:new O(0,1,0),Z:new O(0,0,1)},Ca={type:"change"},Ju={type:"mouseDown",mode:null},Qu={type:"mouseUp",mode:null},eh={type:"objectChange"};class X0 extends of{constructor(e,t=null){super(void 0,t);const i=new K0(this);this._root=i;const r=new J0;this._gizmo=r,i.add(r);const s=new Q0;this._plane=s,i.add(s);const o=this;function a(T,_){let S=_;Object.defineProperty(o,T,{get:function(){return S!==void 0?S:_},set:function(b){S!==b&&(S=b,s[T]=b,r[T]=b,o.dispatchEvent({type:T+"-changed",value:b}),o.dispatchEvent(Ca))}}),o[T]=_,s[T]=_,r[T]=_}a("camera",e),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0),a("minX",-1/0),a("maxX",1/0),a("minY",-1/0),a("maxY",1/0),a("minZ",-1/0),a("maxZ",1/0);const l=new O,c=new O,u=new Dt,h=new Dt,d=new O,p=new Dt,g=new O,y=new O,m=new O,f=0,w=new O;a("worldPosition",l),a("worldPositionStart",c),a("worldQuaternion",u),a("worldQuaternionStart",h),a("cameraPosition",d),a("cameraQuaternion",p),a("pointStart",g),a("pointEnd",y),a("rotationAxis",m),a("rotationAngle",f),a("eye",w),this._offset=new O,this._startNorm=new O,this._endNorm=new O,this._cameraScale=new O,this._parentPosition=new O,this._parentQuaternion=new Dt,this._parentQuaternionInv=new Dt,this._parentScale=new O,this._worldScaleStart=new O,this._worldQuaternionInv=new Dt,this._worldScale=new O,this._positionStart=new O,this._quaternionStart=new Dt,this._scaleStart=new O,this._getPointer=j0.bind(this),this._onPointerDown=q0.bind(this),this._onPointerHover=Y0.bind(this),this._onPointerMove=$0.bind(this),this._onPointerUp=Z0.bind(this),t!==null&&this.connect(t)}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&Pi.setFromCamera(e,this.camera);const t=Pa(this._gizmo.picker[this.mode],Pi);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&Pi.setFromCamera(e,this.camera);const t=Pa(this._plane,Pi,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,Ju.mode=this.mode,this.dispatchEvent(Ju)}}pointerMove(e){const t=this.axis,i=this.mode,r=this.object;let s=this.space;if(i==="scale"?s="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(s="world"),r===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&Pi.setFromCamera(e,this.camera);const o=Pa(this._plane,Pi,!0);if(o){if(this.pointEnd.copy(o.point).sub(this.worldPositionStart),i==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),s==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),s==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),r.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(s==="local"&&(r.position.applyQuaternion(dt.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.position.applyQuaternion(this._quaternionStart)),s==="world"&&(r.parent&&r.position.add(Ft.setFromMatrixPosition(r.parent.matrixWorld)),t.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.parent&&r.position.sub(Ft.setFromMatrixPosition(r.parent.matrixWorld)))),r.position.x=Math.max(this.minX,Math.min(this.maxX,r.position.x)),r.position.y=Math.max(this.minY,Math.min(this.maxY,r.position.y)),r.position.z=Math.max(this.minZ,Math.min(this.maxZ,r.position.z));else if(i==="scale"){if(t.search("XYZ")!==-1){let a=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(a*=-1),li.set(a,a,a)}else Ft.copy(this.pointStart),li.copy(this.pointEnd),Ft.applyQuaternion(this._worldQuaternionInv),li.applyQuaternion(this._worldQuaternionInv),li.divide(Ft),t.search("X")===-1&&(li.x=1),t.search("Y")===-1&&(li.y=1),t.search("Z")===-1&&(li.z=1);r.scale.copy(this._scaleStart).multiply(li),this.scaleSnap&&(t.search("X")!==-1&&(r.scale.x=Math.round(r.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(r.scale.y=Math.round(r.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(r.scale.z=Math.round(r.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(i==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const a=20/this.worldPosition.distanceTo(Ft.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(Ft.copy(this.rotationAxis).cross(this.eye))*a):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(Ku[t]),Ft.copy(Ku[t]),s==="local"&&Ft.applyQuaternion(this.worldQuaternion),Ft.cross(this.eye),Ft.length()===0?l=!0:this.rotationAngle=this._offset.dot(Ft.normalize())*a),(t==="E"||l)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),s==="local"&&t!=="E"&&t!=="XYZE"?(r.quaternion.copy(this._quaternionStart),r.quaternion.multiply(dt.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),r.quaternion.copy(dt.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),r.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Ca),this.dispatchEvent(eh)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(Qu.mode=this.mode,this.dispatchEvent(Qu)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(Ca),this.dispatchEvent(eh),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Pi}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}setColors(e,t,i,r){const s=this._gizmo.materialLib;s.xAxis.color.set(e),s.yAxis.color.set(t),s.zAxis.color.set(i),s.active.color.set(r),s.xAxisTransparent.color.set(e),s.yAxisTransparent.color.set(t),s.zAxisTransparent.color.set(i),s.activeTransparent.color.set(r),s.xAxis._color&&s.xAxis._color.set(e),s.yAxis._color&&s.yAxis._color.set(t),s.zAxis._color&&s.zAxis._color.set(i),s.active._color&&s.active._color.set(r),s.xAxisTransparent._color&&s.xAxisTransparent._color.set(e),s.yAxisTransparent._color&&s.yAxisTransparent._color.set(t),s.zAxisTransparent._color&&s.zAxisTransparent._color.set(i),s.activeTransparent._color&&s.activeTransparent._color.set(r)}}function j0(n){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:n.button};{const e=this.domElement.getBoundingClientRect();return{x:(n.clientX-e.left)/e.width*2-1,y:-(n.clientY-e.top)/e.height*2+1,button:n.button}}}function Y0(n){if(this.enabled)switch(n.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(n));break}}function q0(n){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(n.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(n)),this.pointerDown(this._getPointer(n)))}function $0(n){this.enabled&&this.pointerMove(this._getPointer(n))}function Z0(n){this.enabled&&(this.domElement.releasePointerCapture(n.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(n)))}function Pa(n,e,t){const i=e.intersectObject(n,!0);for(let r=0;r<i.length;r++)if(i[r].object.visible||t)return i[r];return!1}const Zs=new Pn,at=new O(0,1,0),th=new O(0,0,0),nh=new ft,Ks=new Dt,uo=new Dt,On=new O,ih=new ft,Qr=new O(1,0,0),Oi=new O(0,1,0),es=new O(0,0,1),Js=new O,Yr=new O,qr=new O;class K0 extends Mt{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){const t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),super.updateMatrixWorld(e)}dispose(){this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}}class J0 extends Mt{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new Io({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new $i({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=e.clone();i.opacity=.15;const r=t.clone();r.opacity=.5;const s=e.clone();s.color.setHex(16711680);const o=e.clone();o.color.setHex(65280);const a=e.clone();a.color.setHex(255);const l=e.clone();l.color.setHex(16711680),l.opacity=.5;const c=e.clone();c.color.setHex(65280),c.opacity=.5;const u=e.clone();u.color.setHex(255),u.opacity=.5;const h=e.clone();h.opacity=.25;const d=e.clone();d.color.setHex(16776960),d.opacity=.25;const p=e.clone();p.color.setHex(16776960);const g=e.clone();g.color.setHex(7895160),this.materialLib={xAxis:s,yAxis:o,zAxis:a,active:p,xAxisTransparent:l,yAxisTransparent:c,zAxisTransparent:u,activeTransparent:d};const y=new Pt(0,.04,.1,12);y.translate(0,.05,0);const m=new yt(.08,.08,.08);m.translate(0,.04,0);const f=new bt;f.setAttribute("position",new Ze([0,0,0,1,0,0],3));const w=new Pt(.0075,.0075,.5,3);w.translate(0,.25,0);function T(J,K){const se=new hi(J,.0075,3,64,K*Math.PI*2);return se.rotateY(Math.PI/2),se.rotateX(Math.PI/2),se}function _(){const J=new bt;return J.setAttribute("position",new Ze([0,0,0,1,1,1],3)),J}const S={X:[[new ge(y,s),[.5,0,0],[0,0,-Math.PI/2]],[new ge(y,s),[-.5,0,0],[0,0,Math.PI/2]],[new ge(w,s),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new ge(y,o),[0,.5,0]],[new ge(y,o),[0,-.5,0],[Math.PI,0,0]],[new ge(w,o)]],Z:[[new ge(y,a),[0,0,.5],[Math.PI/2,0,0]],[new ge(y,a),[0,0,-.5],[-Math.PI/2,0,0]],[new ge(w,a),null,[Math.PI/2,0,0]]],XYZ:[[new ge(new _r(.1,0),h),[0,0,0]]],XY:[[new ge(new yt(.15,.15,.01),u),[.15,.15,0]]],YZ:[[new ge(new yt(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new ge(new yt(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]]},b={X:[[new ge(new Pt(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new ge(new Pt(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new ge(new Pt(.2,0,.6,4),i),[0,.3,0]],[new ge(new Pt(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new ge(new Pt(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new ge(new Pt(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new ge(new _r(.2,0),i)]],XY:[[new ge(new yt(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new ge(new yt(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new ge(new yt(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},A={START:[[new ge(new _r(.01,2),r),null,null,null,"helper"]],END:[[new ge(new _r(.01,2),r),null,null,null,"helper"]],DELTA:[[new En(_(),r),null,null,null,"helper"]],X:[[new En(f,r),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new En(f,r),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new En(f,r),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},C={XYZE:[[new ge(T(.5,1),g),null,[0,Math.PI/2,0]]],X:[[new ge(T(.5,.5),s)]],Y:[[new ge(T(.5,.5),o),null,[0,0,-Math.PI/2]]],Z:[[new ge(T(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new ge(T(.75,1),d),null,[0,Math.PI/2,0]]]},M={AXIS:[[new En(f,r),[-1e3,0,0],null,[1e6,1,1],"helper"]]},x={XYZE:[[new ge(new ls(.25,10,8),i)]],X:[[new ge(new hi(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new ge(new hi(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new ge(new hi(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new ge(new hi(.75,.1,2,24),i)]]},N={X:[[new ge(m,s),[.5,0,0],[0,0,-Math.PI/2]],[new ge(w,s),[0,0,0],[0,0,-Math.PI/2]],[new ge(m,s),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new ge(m,o),[0,.5,0]],[new ge(w,o)],[new ge(m,o),[0,-.5,0],[0,0,Math.PI]]],Z:[[new ge(m,a),[0,0,.5],[Math.PI/2,0,0]],[new ge(w,a),[0,0,0],[Math.PI/2,0,0]],[new ge(m,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new ge(new yt(.15,.15,.01),u),[.15,.15,0]]],YZ:[[new ge(new yt(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new ge(new yt(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new ge(new yt(.1,.1,.1),h)]]},z={X:[[new ge(new Pt(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new ge(new Pt(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new ge(new Pt(.2,0,.6,4),i),[0,.3,0]],[new ge(new Pt(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new ge(new Pt(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new ge(new Pt(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new ge(new yt(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new ge(new yt(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new ge(new yt(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new ge(new yt(.2,.2,.2),i),[0,0,0]]]},Y={X:[[new En(f,r),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new En(f,r),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new En(f,r),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function q(J){const K=new Mt;for(const se in J)for(let $=J[se].length;$--;){const le=J[se][$][0].clone(),me=J[se][$][1],Ee=J[se][$][2],Be=J[se][$][3],de=J[se][$][4];le.name=se,le.tag=de,me&&le.position.set(me[0],me[1],me[2]),Ee&&le.rotation.set(Ee[0],Ee[1],Ee[2]),Be&&le.scale.set(Be[0],Be[1],Be[2]),le.updateMatrix();const qe=le.geometry.clone();qe.applyMatrix4(le.matrix),le.geometry=qe,le.renderOrder=1/0,le.position.set(0,0,0),le.rotation.set(0,0,0),le.scale.set(1,1,1),K.add(le)}return K}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=q(S)),this.add(this.gizmo.rotate=q(C)),this.add(this.gizmo.scale=q(N)),this.add(this.picker.translate=q(b)),this.add(this.picker.rotate=q(x)),this.add(this.picker.scale=q(z)),this.add(this.helper.translate=q(A)),this.add(this.helper.rotate=q(M)),this.add(this.helper.scale=q(Y)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const i=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:uo;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let r=[];r=r.concat(this.picker[this.mode].children),r=r.concat(this.gizmo[this.mode].children),r=r.concat(this.helper[this.mode].children);for(let s=0;s<r.length;s++){const o=r[s];o.visible=!0,o.rotation.set(0,0,0),o.position.copy(this.worldPosition);let a;if(this.camera.isOrthographicCamera?a=(this.camera.top-this.camera.bottom)/this.camera.zoom:a=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),o.scale.set(1,1,1).multiplyScalar(a*this.size/4),o.tag==="helper"){o.visible=!1,o.name==="AXIS"?(o.visible=!!this.axis,this.axis==="X"&&(dt.setFromEuler(Zs.set(0,0,0)),o.quaternion.copy(i).multiply(dt),Math.abs(at.copy(Qr).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Y"&&(dt.setFromEuler(Zs.set(0,0,Math.PI/2)),o.quaternion.copy(i).multiply(dt),Math.abs(at.copy(Oi).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Z"&&(dt.setFromEuler(Zs.set(0,Math.PI/2,0)),o.quaternion.copy(i).multiply(dt),Math.abs(at.copy(es).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="XYZE"&&(dt.setFromEuler(Zs.set(0,Math.PI/2,0)),at.copy(this.rotationAxis),o.quaternion.setFromRotationMatrix(nh.lookAt(th,at,Oi)),o.quaternion.multiply(dt),o.visible=this.dragging),this.axis==="E"&&(o.visible=!1)):o.name==="START"?(o.position.copy(this.worldPositionStart),o.visible=this.dragging):o.name==="END"?(o.position.copy(this.worldPosition),o.visible=this.dragging):o.name==="DELTA"?(o.position.copy(this.worldPositionStart),o.quaternion.copy(this.worldQuaternionStart),Ft.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),Ft.applyQuaternion(this.worldQuaternionStart.clone().invert()),o.scale.copy(Ft),o.visible=this.dragging):(o.quaternion.copy(i),this.dragging?o.position.copy(this.worldPositionStart):o.position.copy(this.worldPosition),this.axis&&(o.visible=this.axis.search(o.name)!==-1));continue}o.quaternion.copy(i),this.mode==="translate"||this.mode==="scale"?(o.name==="X"&&Math.abs(at.copy(Qr).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Y"&&Math.abs(at.copy(Oi).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Z"&&Math.abs(at.copy(es).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XY"&&Math.abs(at.copy(es).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="YZ"&&Math.abs(at.copy(Qr).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XZ"&&Math.abs(at.copy(Oi).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1)):this.mode==="rotate"&&(Ks.copy(i),at.copy(this.eye).applyQuaternion(dt.copy(i).invert()),o.name.search("E")!==-1&&o.quaternion.setFromRotationMatrix(nh.lookAt(this.eye,th,Oi)),o.name==="X"&&(dt.setFromAxisAngle(Qr,Math.atan2(-at.y,at.z)),dt.multiplyQuaternions(Ks,dt),o.quaternion.copy(dt)),o.name==="Y"&&(dt.setFromAxisAngle(Oi,Math.atan2(at.x,at.z)),dt.multiplyQuaternions(Ks,dt),o.quaternion.copy(dt)),o.name==="Z"&&(dt.setFromAxisAngle(es,Math.atan2(at.y,at.x)),dt.multiplyQuaternions(Ks,dt),o.quaternion.copy(dt))),o.visible=o.visible&&(o.name.indexOf("X")===-1||this.showX),o.visible=o.visible&&(o.name.indexOf("Y")===-1||this.showY),o.visible=o.visible&&(o.name.indexOf("Z")===-1||this.showZ),o.visible=o.visible&&(o.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),o.material._color=o.material._color||o.material.color.clone(),o.material._opacity=o.material._opacity||o.material.opacity,o.material.color.copy(o.material._color),o.material.opacity=o.material._opacity,this.enabled&&this.axis&&(o.name===this.axis?(o.material.color.copy(this.materialLib.active.color),o.material.opacity=1):this.axis.split("").some(function(l){return o.name===l})&&(o.material.color.copy(this.materialLib.active.color),o.material.opacity=1))}super.updateMatrixWorld(e)}}class Q0 extends ge{constructor(){super(new Ir(1e5,1e5,2,2),new Io({visible:!1,wireframe:!0,side:Nn,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),Js.copy(Qr).applyQuaternion(t==="local"?this.worldQuaternion:uo),Yr.copy(Oi).applyQuaternion(t==="local"?this.worldQuaternion:uo),qr.copy(es).applyQuaternion(t==="local"?this.worldQuaternion:uo),at.copy(Yr),this.mode){case"translate":case"scale":switch(this.axis){case"X":at.copy(this.eye).cross(Js),On.copy(Js).cross(at);break;case"Y":at.copy(this.eye).cross(Yr),On.copy(Yr).cross(at);break;case"Z":at.copy(this.eye).cross(qr),On.copy(qr).cross(at);break;case"XY":On.copy(qr);break;case"YZ":On.copy(Js);break;case"XZ":at.copy(qr),On.copy(Yr);break;case"XYZ":case"E":On.set(0,0,0);break}break;case"rotate":default:On.set(0,0,0)}On.length()===0?this.quaternion.copy(this.cameraQuaternion):(ih.lookAt(Ft.set(0,0,0),On,at),this.quaternion.setFromRotationMatrix(ih)),super.updateMatrixWorld(e)}}var Al;(function(n){n[n.Transient=0]="Transient",n[n.Singleton=1]="Singleton",n[n.ResolutionScoped=2]="ResolutionScoped",n[n.ContainerScoped=3]="ContainerScoped"})(Al||(Al={}));const Gt=Al;/*! *****************************************************************************
3968
+ }`;class Qy{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){const n=new Mp(t.texture);(t.depthNear!==e.depthNear||t.depthFar!==e.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=n}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,n=new Di({vertexShader:Ky,fragmentShader:Jy,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new gt(new Or(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class tb extends Ls{constructor(t,e){super();const n=this;let s=null,r=1,a=null,o="local-floor",l=1,c=null,h=null,u=null,d=null,f=null,m=null;const x=typeof XRWebGLBinding<"u",_=new Qy,p={},w=e.getContextAttributes();let S=null,y=null;const E=[],v=[],A=new Nt;let R=null;const M=new Cn;M.viewport=new Se;const g=new Cn;g.viewport=new Se;const O=[M,g],F=new g_;let k=null,G=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(J){let rt=E[J];return rt===void 0&&(rt=new Gl,E[J]=rt),rt.getTargetRaySpace()},this.getControllerGrip=function(J){let rt=E[J];return rt===void 0&&(rt=new Gl,E[J]=rt),rt.getGripSpace()},this.getHand=function(J){let rt=E[J];return rt===void 0&&(rt=new Gl,E[J]=rt),rt.getHandSpace()};function K(J){const rt=v.indexOf(J.inputSource);if(rt===-1)return;const Mt=E[rt];Mt!==void 0&&(Mt.update(J.inputSource,J.frame,c||a),Mt.dispatchEvent({type:J.type,data:J.inputSource}))}function tt(){s.removeEventListener("select",K),s.removeEventListener("selectstart",K),s.removeEventListener("selectend",K),s.removeEventListener("squeeze",K),s.removeEventListener("squeezestart",K),s.removeEventListener("squeezeend",K),s.removeEventListener("end",tt),s.removeEventListener("inputsourceschange",lt);for(let J=0;J<E.length;J++){const rt=v[J];rt!==null&&(v[J]=null,E[J].disconnect(rt))}k=null,G=null,_.reset();for(const J in p)delete p[J];t.setRenderTarget(S),f=null,d=null,u=null,s=null,y=null,se.stop(),n.isPresenting=!1,t.setPixelRatio(R),t.setSize(A.width,A.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(J){r=J,n.isPresenting===!0&&kt("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(J){o=J,n.isPresenting===!0&&kt("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(J){c=J},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u===null&&x&&(u=new XRWebGLBinding(s,e)),u},this.getFrame=function(){return m},this.getSession=function(){return s},this.setSession=async function(J){if(s=J,s!==null){if(S=t.getRenderTarget(),s.addEventListener("select",K),s.addEventListener("selectstart",K),s.addEventListener("selectend",K),s.addEventListener("squeeze",K),s.addEventListener("squeezestart",K),s.addEventListener("squeezeend",K),s.addEventListener("end",tt),s.addEventListener("inputsourceschange",lt),w.xrCompatible!==!0&&await e.makeXRCompatible(),R=t.getPixelRatio(),t.getSize(A),x&&"createProjectionLayer"in XRWebGLBinding.prototype){let Mt=null,Bt=null,Ct=null;w.depth&&(Ct=w.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,Mt=w.stencil?ha:ca,Bt=w.stencil?la:ws);const It={colorFormat:e.RGBA8,depthFormat:Ct,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(It),s.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),y=new Ts(d.textureWidth,d.textureHeight,{format:Xn,type:ui,depthTexture:new bp(d.textureWidth,d.textureHeight,Bt,void 0,void 0,void 0,void 0,void 0,void 0,Mt),stencilBuffer:w.stencil,colorSpace:t.outputColorSpace,samples:w.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const Mt={antialias:w.antialias,alpha:!0,depth:w.depth,stencil:w.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(s,e,Mt),s.updateRenderState({baseLayer:f}),t.setPixelRatio(1),t.setSize(f.framebufferWidth,f.framebufferHeight,!1),y=new Ts(f.framebufferWidth,f.framebufferHeight,{format:Xn,type:ui,colorSpace:t.outputColorSpace,stencilBuffer:w.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await s.requestReferenceSpace(o),se.setContext(s),se.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return _.getDepthTexture()};function lt(J){for(let rt=0;rt<J.removed.length;rt++){const Mt=J.removed[rt],Bt=v.indexOf(Mt);Bt>=0&&(v[Bt]=null,E[Bt].disconnect(Mt))}for(let rt=0;rt<J.added.length;rt++){const Mt=J.added[rt];let Bt=v.indexOf(Mt);if(Bt===-1){for(let It=0;It<E.length;It++)if(It>=v.length){v.push(Mt),Bt=It;break}else if(v[It]===null){v[It]=Mt,Bt=It;break}if(Bt===-1)break}const Ct=E[Bt];Ct&&Ct.connect(Mt)}}const $=new I,st=new I;function ct(J,rt,Mt){$.setFromMatrixPosition(rt.matrixWorld),st.setFromMatrixPosition(Mt.matrixWorld);const Bt=$.distanceTo(st),Ct=rt.projectionMatrix.elements,It=Mt.projectionMatrix.elements,Ae=Ct[14]/(Ct[10]-1),Ht=Ct[14]/(Ct[10]+1),he=(Ct[9]+1)/Ct[5],N=(Ct[9]-1)/Ct[5],Wt=(Ct[8]-1)/Ct[0],jt=(It[8]+1)/It[0],ie=Ae*Wt,wt=Ae*jt,pe=Bt/(-Wt+jt),Rt=pe*-Wt;if(rt.matrixWorld.decompose(J.position,J.quaternion,J.scale),J.translateX(Rt),J.translateZ(pe),J.matrixWorld.compose(J.position,J.quaternion,J.scale),J.matrixWorldInverse.copy(J.matrixWorld).invert(),Ct[10]===-1)J.projectionMatrix.copy(rt.projectionMatrix),J.projectionMatrixInverse.copy(rt.projectionMatrixInverse);else{const Ut=Ae+pe,C=Ht+pe,b=ie-Rt,V=wt+(Bt-Rt),nt=he*Ht/C*Ut,it=N*Ht/C*Ut;J.projectionMatrix.makePerspective(b,V,nt,it,Ut,C),J.projectionMatrixInverse.copy(J.projectionMatrix).invert()}}function Et(J,rt){rt===null?J.matrixWorld.copy(J.matrix):J.matrixWorld.multiplyMatrices(rt.matrixWorld,J.matrix),J.matrixWorldInverse.copy(J.matrixWorld).invert()}this.updateCamera=function(J){if(s===null)return;let rt=J.near,Mt=J.far;_.texture!==null&&(_.depthNear>0&&(rt=_.depthNear),_.depthFar>0&&(Mt=_.depthFar)),F.near=g.near=M.near=rt,F.far=g.far=M.far=Mt,(k!==F.near||G!==F.far)&&(s.updateRenderState({depthNear:F.near,depthFar:F.far}),k=F.near,G=F.far),F.layers.mask=J.layers.mask|6,M.layers.mask=F.layers.mask&3,g.layers.mask=F.layers.mask&5;const Bt=J.parent,Ct=F.cameras;Et(F,Bt);for(let It=0;It<Ct.length;It++)Et(Ct[It],Bt);Ct.length===2?ct(F,M,g):F.projectionMatrix.copy(M.projectionMatrix),Vt(J,F,Bt)};function Vt(J,rt,Mt){Mt===null?J.matrix.copy(rt.matrixWorld):(J.matrix.copy(Mt.matrixWorld),J.matrix.invert(),J.matrix.multiply(rt.matrixWorld)),J.matrix.decompose(J.position,J.quaternion,J.scale),J.updateMatrixWorld(!0),J.projectionMatrix.copy(rt.projectionMatrix),J.projectionMatrixInverse.copy(rt.projectionMatrixInverse),J.isPerspectiveCamera&&(J.fov=dh*2*Math.atan(1/J.projectionMatrix.elements[5]),J.zoom=1)}this.getCamera=function(){return F},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function(J){l=J,d!==null&&(d.fixedFoveation=J),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=J)},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(F)},this.getCameraTexture=function(J){return p[J]};let pt=null;function $t(J,rt){if(h=rt.getViewerPose(c||a),m=rt,h!==null){const Mt=h.views;f!==null&&(t.setRenderTargetFramebuffer(y,f.framebuffer),t.setRenderTarget(y));let Bt=!1;Mt.length!==F.cameras.length&&(F.cameras.length=0,Bt=!0);for(let Ht=0;Ht<Mt.length;Ht++){const he=Mt[Ht];let N=null;if(f!==null)N=f.getViewport(he);else{const jt=u.getViewSubImage(d,he);N=jt.viewport,Ht===0&&(t.setRenderTargetTextures(y,jt.colorTexture,jt.depthStencilTexture),t.setRenderTarget(y))}let Wt=O[Ht];Wt===void 0&&(Wt=new Cn,Wt.layers.enable(Ht),Wt.viewport=new Se,O[Ht]=Wt),Wt.matrix.fromArray(he.transform.matrix),Wt.matrix.decompose(Wt.position,Wt.quaternion,Wt.scale),Wt.projectionMatrix.fromArray(he.projectionMatrix),Wt.projectionMatrixInverse.copy(Wt.projectionMatrix).invert(),Wt.viewport.set(N.x,N.y,N.width,N.height),Ht===0&&(F.matrix.copy(Wt.matrix),F.matrix.decompose(F.position,F.quaternion,F.scale)),Bt===!0&&F.cameras.push(Wt)}const Ct=s.enabledFeatures;if(Ct&&Ct.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&x){u=n.getBinding();const Ht=u.getDepthInformation(Mt[0]);Ht&&Ht.isValid&&Ht.texture&&_.init(Ht,s.renderState)}if(Ct&&Ct.includes("camera-access")&&x){t.state.unbindTexture(),u=n.getBinding();for(let Ht=0;Ht<Mt.length;Ht++){const he=Mt[Ht].camera;if(he){let N=p[he];N||(N=new Mp,p[he]=N);const Wt=u.getCameraImage(he);N.sourceTexture=Wt}}}}for(let Mt=0;Mt<E.length;Mt++){const Bt=v[Mt],Ct=E[Mt];Bt!==null&&Ct!==void 0&&Ct.update(Bt,rt,c||a)}pt&&pt(J,rt),rt.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:rt}),m=null}const se=new Ap;se.setAnimationLoop($t),this.setAnimationLoop=function(J){pt=J},this.dispose=function(){}}}const us=new Jn,eb=new _e;function nb(i,t){function e(_,p){_.matrixAutoUpdate===!0&&_.updateMatrix(),p.value.copy(_.matrix)}function n(_,p){p.color.getRGB(_.fogColor.value,gp(i)),p.isFog?(_.fogNear.value=p.near,_.fogFar.value=p.far):p.isFogExp2&&(_.fogDensity.value=p.density)}function s(_,p,w,S,y){p.isMeshBasicMaterial||p.isMeshLambertMaterial?r(_,p):p.isMeshToonMaterial?(r(_,p),u(_,p)):p.isMeshPhongMaterial?(r(_,p),h(_,p)):p.isMeshStandardMaterial?(r(_,p),d(_,p),p.isMeshPhysicalMaterial&&f(_,p,y)):p.isMeshMatcapMaterial?(r(_,p),m(_,p)):p.isMeshDepthMaterial?r(_,p):p.isMeshDistanceMaterial?(r(_,p),x(_,p)):p.isMeshNormalMaterial?r(_,p):p.isLineBasicMaterial?(a(_,p),p.isLineDashedMaterial&&o(_,p)):p.isPointsMaterial?l(_,p,w,S):p.isSpriteMaterial?c(_,p):p.isShadowMaterial?(_.color.value.copy(p.color),_.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function r(_,p){_.opacity.value=p.opacity,p.color&&_.diffuse.value.copy(p.color),p.emissive&&_.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(_.map.value=p.map,e(p.map,_.mapTransform)),p.alphaMap&&(_.alphaMap.value=p.alphaMap,e(p.alphaMap,_.alphaMapTransform)),p.bumpMap&&(_.bumpMap.value=p.bumpMap,e(p.bumpMap,_.bumpMapTransform),_.bumpScale.value=p.bumpScale,p.side===on&&(_.bumpScale.value*=-1)),p.normalMap&&(_.normalMap.value=p.normalMap,e(p.normalMap,_.normalMapTransform),_.normalScale.value.copy(p.normalScale),p.side===on&&_.normalScale.value.negate()),p.displacementMap&&(_.displacementMap.value=p.displacementMap,e(p.displacementMap,_.displacementMapTransform),_.displacementScale.value=p.displacementScale,_.displacementBias.value=p.displacementBias),p.emissiveMap&&(_.emissiveMap.value=p.emissiveMap,e(p.emissiveMap,_.emissiveMapTransform)),p.specularMap&&(_.specularMap.value=p.specularMap,e(p.specularMap,_.specularMapTransform)),p.alphaTest>0&&(_.alphaTest.value=p.alphaTest);const w=t.get(p),S=w.envMap,y=w.envMapRotation;S&&(_.envMap.value=S,us.copy(y),us.x*=-1,us.y*=-1,us.z*=-1,S.isCubeTexture&&S.isRenderTargetTexture===!1&&(us.y*=-1,us.z*=-1),_.envMapRotation.value.setFromMatrix4(eb.makeRotationFromEuler(us)),_.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,_.reflectivity.value=p.reflectivity,_.ior.value=p.ior,_.refractionRatio.value=p.refractionRatio),p.lightMap&&(_.lightMap.value=p.lightMap,_.lightMapIntensity.value=p.lightMapIntensity,e(p.lightMap,_.lightMapTransform)),p.aoMap&&(_.aoMap.value=p.aoMap,_.aoMapIntensity.value=p.aoMapIntensity,e(p.aoMap,_.aoMapTransform))}function a(_,p){_.diffuse.value.copy(p.color),_.opacity.value=p.opacity,p.map&&(_.map.value=p.map,e(p.map,_.mapTransform))}function o(_,p){_.dashSize.value=p.dashSize,_.totalSize.value=p.dashSize+p.gapSize,_.scale.value=p.scale}function l(_,p,w,S){_.diffuse.value.copy(p.color),_.opacity.value=p.opacity,_.size.value=p.size*w,_.scale.value=S*.5,p.map&&(_.map.value=p.map,e(p.map,_.uvTransform)),p.alphaMap&&(_.alphaMap.value=p.alphaMap,e(p.alphaMap,_.alphaMapTransform)),p.alphaTest>0&&(_.alphaTest.value=p.alphaTest)}function c(_,p){_.diffuse.value.copy(p.color),_.opacity.value=p.opacity,_.rotation.value=p.rotation,p.map&&(_.map.value=p.map,e(p.map,_.mapTransform)),p.alphaMap&&(_.alphaMap.value=p.alphaMap,e(p.alphaMap,_.alphaMapTransform)),p.alphaTest>0&&(_.alphaTest.value=p.alphaTest)}function h(_,p){_.specular.value.copy(p.specular),_.shininess.value=Math.max(p.shininess,1e-4)}function u(_,p){p.gradientMap&&(_.gradientMap.value=p.gradientMap)}function d(_,p){_.metalness.value=p.metalness,p.metalnessMap&&(_.metalnessMap.value=p.metalnessMap,e(p.metalnessMap,_.metalnessMapTransform)),_.roughness.value=p.roughness,p.roughnessMap&&(_.roughnessMap.value=p.roughnessMap,e(p.roughnessMap,_.roughnessMapTransform)),p.envMap&&(_.envMapIntensity.value=p.envMapIntensity)}function f(_,p,w){_.ior.value=p.ior,p.sheen>0&&(_.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),_.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(_.sheenColorMap.value=p.sheenColorMap,e(p.sheenColorMap,_.sheenColorMapTransform)),p.sheenRoughnessMap&&(_.sheenRoughnessMap.value=p.sheenRoughnessMap,e(p.sheenRoughnessMap,_.sheenRoughnessMapTransform))),p.clearcoat>0&&(_.clearcoat.value=p.clearcoat,_.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(_.clearcoatMap.value=p.clearcoatMap,e(p.clearcoatMap,_.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(_.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,e(p.clearcoatRoughnessMap,_.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(_.clearcoatNormalMap.value=p.clearcoatNormalMap,e(p.clearcoatNormalMap,_.clearcoatNormalMapTransform),_.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===on&&_.clearcoatNormalScale.value.negate())),p.dispersion>0&&(_.dispersion.value=p.dispersion),p.iridescence>0&&(_.iridescence.value=p.iridescence,_.iridescenceIOR.value=p.iridescenceIOR,_.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],_.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(_.iridescenceMap.value=p.iridescenceMap,e(p.iridescenceMap,_.iridescenceMapTransform)),p.iridescenceThicknessMap&&(_.iridescenceThicknessMap.value=p.iridescenceThicknessMap,e(p.iridescenceThicknessMap,_.iridescenceThicknessMapTransform))),p.transmission>0&&(_.transmission.value=p.transmission,_.transmissionSamplerMap.value=w.texture,_.transmissionSamplerSize.value.set(w.width,w.height),p.transmissionMap&&(_.transmissionMap.value=p.transmissionMap,e(p.transmissionMap,_.transmissionMapTransform)),_.thickness.value=p.thickness,p.thicknessMap&&(_.thicknessMap.value=p.thicknessMap,e(p.thicknessMap,_.thicknessMapTransform)),_.attenuationDistance.value=p.attenuationDistance,_.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(_.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(_.anisotropyMap.value=p.anisotropyMap,e(p.anisotropyMap,_.anisotropyMapTransform))),_.specularIntensity.value=p.specularIntensity,_.specularColor.value.copy(p.specularColor),p.specularColorMap&&(_.specularColorMap.value=p.specularColorMap,e(p.specularColorMap,_.specularColorMapTransform)),p.specularIntensityMap&&(_.specularIntensityMap.value=p.specularIntensityMap,e(p.specularIntensityMap,_.specularIntensityMapTransform))}function m(_,p){p.matcap&&(_.matcap.value=p.matcap)}function x(_,p){const w=t.get(p).light;_.referencePosition.value.setFromMatrixPosition(w.matrixWorld),_.nearDistance.value=w.shadow.camera.near,_.farDistance.value=w.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function ib(i,t,e,n){let s={},r={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(w,S){const y=S.program;n.uniformBlockBinding(w,y)}function c(w,S){let y=s[w.id];y===void 0&&(m(w),y=h(w),s[w.id]=y,w.addEventListener("dispose",_));const E=S.program;n.updateUBOMapping(w,E);const v=t.render.frame;r[w.id]!==v&&(d(w),r[w.id]=v)}function h(w){const S=u();w.__bindingPointIndex=S;const y=i.createBuffer(),E=w.__size,v=w.usage;return i.bindBuffer(i.UNIFORM_BUFFER,y),i.bufferData(i.UNIFORM_BUFFER,E,v),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,S,y),y}function u(){for(let w=0;w<o;w++)if(a.indexOf(w)===-1)return a.push(w),w;return Me("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(w){const S=s[w.id],y=w.uniforms,E=w.__cache;i.bindBuffer(i.UNIFORM_BUFFER,S);for(let v=0,A=y.length;v<A;v++){const R=Array.isArray(y[v])?y[v]:[y[v]];for(let M=0,g=R.length;M<g;M++){const O=R[M];if(f(O,v,M,E)===!0){const F=O.__offset,k=Array.isArray(O.value)?O.value:[O.value];let G=0;for(let K=0;K<k.length;K++){const tt=k[K],lt=x(tt);typeof tt=="number"||typeof tt=="boolean"?(O.__data[0]=tt,i.bufferSubData(i.UNIFORM_BUFFER,F+G,O.__data)):tt.isMatrix3?(O.__data[0]=tt.elements[0],O.__data[1]=tt.elements[1],O.__data[2]=tt.elements[2],O.__data[3]=0,O.__data[4]=tt.elements[3],O.__data[5]=tt.elements[4],O.__data[6]=tt.elements[5],O.__data[7]=0,O.__data[8]=tt.elements[6],O.__data[9]=tt.elements[7],O.__data[10]=tt.elements[8],O.__data[11]=0):(tt.toArray(O.__data,G),G+=lt.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,F,O.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function f(w,S,y,E){const v=w.value,A=S+"_"+y;if(E[A]===void 0)return typeof v=="number"||typeof v=="boolean"?E[A]=v:E[A]=v.clone(),!0;{const R=E[A];if(typeof v=="number"||typeof v=="boolean"){if(R!==v)return E[A]=v,!0}else if(R.equals(v)===!1)return R.copy(v),!0}return!1}function m(w){const S=w.uniforms;let y=0;const E=16;for(let A=0,R=S.length;A<R;A++){const M=Array.isArray(S[A])?S[A]:[S[A]];for(let g=0,O=M.length;g<O;g++){const F=M[g],k=Array.isArray(F.value)?F.value:[F.value];for(let G=0,K=k.length;G<K;G++){const tt=k[G],lt=x(tt),$=y%E,st=$%lt.boundary,ct=$+st;y+=st,ct!==0&&E-ct<lt.storage&&(y+=E-ct),F.__data=new Float32Array(lt.storage/Float32Array.BYTES_PER_ELEMENT),F.__offset=y,y+=lt.storage}}}const v=y%E;return v>0&&(y+=E-v),w.__size=y,w.__cache={},this}function x(w){const S={boundary:0,storage:0};return typeof w=="number"||typeof w=="boolean"?(S.boundary=4,S.storage=4):w.isVector2?(S.boundary=8,S.storage=8):w.isVector3||w.isColor?(S.boundary=16,S.storage=12):w.isVector4?(S.boundary=16,S.storage=16):w.isMatrix3?(S.boundary=48,S.storage=48):w.isMatrix4?(S.boundary=64,S.storage=64):w.isTexture?kt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):kt("WebGLRenderer: Unsupported uniform value type.",w),S}function _(w){const S=w.target;S.removeEventListener("dispose",_);const y=a.indexOf(S.__bindingPointIndex);a.splice(y,1),i.deleteBuffer(s[S.id]),delete s[S.id],delete r[S.id]}function p(){for(const w in s)i.deleteBuffer(s[w]);a=[],s={},r={}}return{bind:l,update:c,dispose:p}}const sb=new Uint16Array([11481,15204,11534,15171,11808,15015,12385,14843,12894,14716,13396,14600,13693,14483,13976,14366,14237,14171,14405,13961,14511,13770,14605,13598,14687,13444,14760,13305,14822,13066,14876,12857,14923,12675,14963,12517,14997,12379,15025,12230,15049,12023,15070,11843,15086,11687,15100,11551,15111,11433,15120,11330,15127,11217,15132,11060,15135,10922,15138,10801,15139,10695,15139,10600,13012,14923,13020,14917,13064,14886,13176,14800,13349,14666,13513,14526,13724,14398,13960,14230,14200,14020,14383,13827,14488,13651,14583,13491,14667,13348,14740,13132,14803,12908,14856,12713,14901,12542,14938,12394,14968,12241,14992,12017,15010,11822,15024,11654,15034,11507,15041,11380,15044,11269,15044,11081,15042,10913,15037,10764,15031,10635,15023,10520,15014,10419,15003,10330,13657,14676,13658,14673,13670,14660,13698,14622,13750,14547,13834,14442,13956,14317,14112,14093,14291,13889,14407,13704,14499,13538,14586,13389,14664,13201,14733,12966,14792,12758,14842,12577,14882,12418,14915,12272,14940,12033,14959,11826,14972,11646,14980,11490,14983,11355,14983,11212,14979,11008,14971,10830,14961,10675,14950,10540,14936,10420,14923,10315,14909,10204,14894,10041,14089,14460,14090,14459,14096,14452,14112,14431,14141,14388,14186,14305,14252,14130,14341,13941,14399,13756,14467,13585,14539,13430,14610,13272,14677,13026,14737,12808,14790,12617,14833,12449,14869,12303,14896,12065,14916,11845,14929,11655,14937,11490,14939,11347,14936,11184,14930,10970,14921,10783,14912,10621,14900,10480,14885,10356,14867,10247,14848,10062,14827,9894,14805,9745,14400,14208,14400,14206,14402,14198,14406,14174,14415,14122,14427,14035,14444,13913,14469,13767,14504,13613,14548,13463,14598,13324,14651,13082,14704,12858,14752,12658,14795,12483,14831,12330,14860,12106,14881,11875,14895,11675,14903,11501,14905,11351,14903,11178,14900,10953,14892,10757,14880,10589,14865,10442,14847,10313,14827,10162,14805,9965,14782,9792,14757,9642,14731,9507,14562,13883,14562,13883,14563,13877,14566,13862,14570,13830,14576,13773,14584,13689,14595,13582,14613,13461,14637,13336,14668,13120,14704,12897,14741,12695,14776,12516,14808,12358,14835,12150,14856,11910,14870,11701,14878,11519,14882,11361,14884,11187,14880,10951,14871,10748,14858,10572,14842,10418,14823,10286,14801,10099,14777,9897,14751,9722,14725,9567,14696,9430,14666,9309,14702,13604,14702,13604,14702,13600,14703,13591,14705,13570,14707,13533,14709,13477,14712,13400,14718,13305,14727,13106,14743,12907,14762,12716,14784,12539,14807,12380,14827,12190,14844,11943,14855,11727,14863,11539,14870,11376,14871,11204,14868,10960,14858,10748,14845,10565,14829,10406,14809,10269,14786,10058,14761,9852,14734,9671,14705,9512,14674,9374,14641,9253,14608,9076,14821,13366,14821,13365,14821,13364,14821,13358,14821,13344,14821,13320,14819,13252,14817,13145,14815,13011,14814,12858,14817,12698,14823,12539,14832,12389,14841,12214,14850,11968,14856,11750,14861,11558,14866,11390,14867,11226,14862,10972,14853,10754,14840,10565,14823,10401,14803,10259,14780,10032,14754,9820,14725,9635,14694,9473,14661,9333,14627,9203,14593,8988,14557,8798,14923,13014,14922,13014,14922,13012,14922,13004,14920,12987,14919,12957,14915,12907,14909,12834,14902,12738,14894,12623,14888,12498,14883,12370,14880,12203,14878,11970,14875,11759,14873,11569,14874,11401,14872,11243,14865,10986,14855,10762,14842,10568,14825,10401,14804,10255,14781,10017,14754,9799,14725,9611,14692,9445,14658,9301,14623,9139,14587,8920,14548,8729,14509,8562,15008,12672,15008,12672,15008,12671,15007,12667,15005,12656,15001,12637,14997,12605,14989,12556,14978,12490,14966,12407,14953,12313,14940,12136,14927,11934,14914,11742,14903,11563,14896,11401,14889,11247,14879,10992,14866,10767,14851,10570,14833,10400,14812,10252,14789,10007,14761,9784,14731,9592,14698,9424,14663,9279,14627,9088,14588,8868,14548,8676,14508,8508,14467,8360,15080,12386,15080,12386,15079,12385,15078,12383,15076,12378,15072,12367,15066,12347,15057,12315,15045,12253,15030,12138,15012,11998,14993,11845,14972,11685,14951,11530,14935,11383,14920,11228,14904,10981,14887,10762,14870,10567,14850,10397,14827,10248,14803,9997,14774,9771,14743,9578,14710,9407,14674,9259,14637,9048,14596,8826,14555,8632,14514,8464,14471,8317,14427,8182,15139,12008,15139,12008,15138,12008,15137,12007,15135,12003,15130,11990,15124,11969,15115,11929,15102,11872,15086,11794,15064,11693,15041,11581,15013,11459,14987,11336,14966,11170,14944,10944,14921,10738,14898,10552,14875,10387,14850,10239,14824,9983,14794,9758,14762,9563,14728,9392,14692,9244,14653,9014,14611,8791,14569,8597,14526,8427,14481,8281,14436,8110,14391,7885,15188,11617,15188,11617,15187,11617,15186,11618,15183,11617,15179,11612,15173,11601,15163,11581,15150,11546,15133,11495,15110,11427,15083,11346,15051,11246,15024,11057,14996,10868,14967,10687,14938,10517,14911,10362,14882,10206,14853,9956,14821,9737,14787,9543,14752,9375,14715,9228,14675,8980,14632,8760,14589,8565,14544,8395,14498,8248,14451,8049,14404,7824,14357,7630,15228,11298,15228,11298,15227,11299,15226,11301,15223,11303,15219,11302,15213,11299,15204,11290,15191,11271,15174,11217,15150,11129,15119,11015,15087,10886,15057,10744,15024,10599,14990,10455,14957,10318,14924,10143,14891,9911,14856,9701,14820,9516,14782,9352,14744,9200,14703,8946,14659,8725,14615,8533,14568,8366,14521,8220,14472,7992,14423,7770,14374,7578,14315,7408,15260,10819,15260,10819,15259,10822,15258,10826,15256,10832,15251,10836,15246,10841,15237,10838,15225,10821,15207,10788,15183,10734,15151,10660,15120,10571,15087,10469,15049,10359,15012,10249,14974,10041,14937,9837,14900,9647,14860,9475,14820,9320,14779,9147,14736,8902,14691,8688,14646,8499,14598,8335,14549,8189,14499,7940,14448,7720,14397,7529,14347,7363,14256,7218,15285,10410,15285,10411,15285,10413,15284,10418,15282,10425,15278,10434,15272,10442,15264,10449,15252,10445,15235,10433,15210,10403,15179,10358,15149,10301,15113,10218,15073,10059,15033,9894,14991,9726,14951,9565,14909,9413,14865,9273,14822,9073,14777,8845,14730,8641,14682,8459,14633,8300,14583,8129,14531,7883,14479,7670,14426,7482,14373,7321,14305,7176,14201,6939,15305,9939,15305,9940,15305,9945,15304,9955,15302,9967,15298,9989,15293,10010,15286,10033,15274,10044,15258,10045,15233,10022,15205,9975,15174,9903,15136,9808,15095,9697,15053,9578,15009,9451,14965,9327,14918,9198,14871,8973,14825,8766,14775,8579,14725,8408,14675,8259,14622,8058,14569,7821,14515,7615,14460,7435,14405,7276,14350,7108,14256,6866,14149,6653,15321,9444,15321,9445,15321,9448,15320,9458,15317,9470,15314,9490,15310,9515,15302,9540,15292,9562,15276,9579,15251,9577,15226,9559,15195,9519,15156,9463,15116,9389,15071,9304,15025,9208,14978,9023,14927,8838,14878,8661,14827,8496,14774,8344,14722,8206,14667,7973,14612,7749,14556,7555,14499,7382,14443,7229,14385,7025,14322,6791,14210,6588,14100,6409,15333,8920,15333,8921,15332,8927,15332,8943,15329,8965,15326,9002,15322,9048,15316,9106,15307,9162,15291,9204,15267,9221,15244,9221,15212,9196,15175,9134,15133,9043,15088,8930,15040,8801,14990,8665,14938,8526,14886,8391,14830,8261,14775,8087,14719,7866,14661,7664,14603,7482,14544,7322,14485,7178,14426,6936,14367,6713,14281,6517,14166,6348,14054,6198,15341,8360,15341,8361,15341,8366,15341,8379,15339,8399,15336,8431,15332,8473,15326,8527,15318,8585,15302,8632,15281,8670,15258,8690,15227,8690,15191,8664,15149,8612,15104,8543,15055,8456,15001,8360,14948,8259,14892,8122,14834,7923,14776,7734,14716,7558,14656,7397,14595,7250,14534,7070,14472,6835,14410,6628,14350,6443,14243,6283,14125,6135,14010,5889,15348,7715,15348,7717,15348,7725,15347,7745,15345,7780,15343,7836,15339,7905,15334,8e3,15326,8103,15310,8193,15293,8239,15270,8270,15240,8287,15204,8283,15163,8260,15118,8223,15067,8143,15014,8014,14958,7873,14899,7723,14839,7573,14778,7430,14715,7293,14652,7164,14588,6931,14524,6720,14460,6531,14396,6362,14330,6210,14207,6015,14086,5781,13969,5576,15352,7114,15352,7116,15352,7128,15352,7159,15350,7195,15348,7237,15345,7299,15340,7374,15332,7457,15317,7544,15301,7633,15280,7703,15251,7754,15216,7775,15176,7767,15131,7733,15079,7670,15026,7588,14967,7492,14906,7387,14844,7278,14779,7171,14714,6965,14648,6770,14581,6587,14515,6420,14448,6269,14382,6123,14299,5881,14172,5665,14049,5477,13929,5310,15355,6329,15355,6330,15355,6339,15355,6362,15353,6410,15351,6472,15349,6572,15344,6688,15337,6835,15323,6985,15309,7142,15287,7220,15260,7277,15226,7310,15188,7326,15142,7318,15090,7285,15036,7239,14976,7177,14914,7045,14849,6892,14782,6736,14714,6581,14645,6433,14576,6293,14506,6164,14438,5946,14369,5733,14270,5540,14140,5369,14014,5216,13892,5043,15357,5483,15357,5484,15357,5496,15357,5528,15356,5597,15354,5692,15351,5835,15347,6011,15339,6195,15328,6317,15314,6446,15293,6566,15268,6668,15235,6746,15197,6796,15152,6811,15101,6790,15046,6748,14985,6673,14921,6583,14854,6479,14785,6371,14714,6259,14643,6149,14571,5946,14499,5750,14428,5567,14358,5401,14242,5250,14109,5111,13980,4870,13856,4657,15359,4555,15359,4557,15358,4573,15358,4633,15357,4715,15355,4841,15353,5061,15349,5216,15342,5391,15331,5577,15318,5770,15299,5967,15274,6150,15243,6223,15206,6280,15161,6310,15111,6317,15055,6300,14994,6262,14928,6208,14860,6141,14788,5994,14715,5838,14641,5684,14566,5529,14492,5384,14418,5247,14346,5121,14216,4892,14079,4682,13948,4496,13822,4330,15359,3498,15359,3501,15359,3520,15359,3598,15358,3719,15356,3860,15355,4137,15351,4305,15344,4563,15334,4809,15321,5116,15303,5273,15280,5418,15250,5547,15214,5653,15170,5722,15120,5761,15064,5763,15002,5733,14935,5673,14865,5597,14792,5504,14716,5400,14640,5294,14563,5185,14486,5041,14410,4841,14335,4655,14191,4482,14051,4325,13918,4183,13790,4012,15360,2282,15360,2285,15360,2306,15360,2401,15359,2547,15357,2748,15355,3103,15352,3349,15345,3675,15336,4020,15324,4272,15307,4496,15285,4716,15255,4908,15220,5086,15178,5170,15128,5214,15072,5234,15010,5231,14943,5206,14871,5166,14796,5102,14718,4971,14639,4833,14559,4687,14480,4541,14402,4401,14315,4268,14167,4142,14025,3958,13888,3747,13759,3556,15360,923,15360,925,15360,946,15360,1052,15359,1214,15357,1494,15356,1892,15352,2274,15346,2663,15338,3099,15326,3393,15309,3679,15288,3980,15260,4183,15226,4325,15185,4437,15136,4517,15080,4570,15018,4591,14950,4581,14877,4545,14800,4485,14720,4411,14638,4325,14556,4231,14475,4136,14395,3988,14297,3803,14145,3628,13999,3465,13861,3314,13729,3177,15360,263,15360,264,15360,272,15360,325,15359,407,15358,548,15356,780,15352,1144,15347,1580,15339,2099,15328,2425,15312,2795,15292,3133,15264,3329,15232,3517,15191,3689,15143,3819,15088,3923,15025,3978,14956,3999,14882,3979,14804,3931,14722,3855,14639,3756,14554,3645,14470,3529,14388,3409,14279,3289,14124,3173,13975,3055,13834,2848,13701,2658,15360,49,15360,49,15360,52,15360,75,15359,111,15358,201,15356,283,15353,519,15348,726,15340,1045,15329,1415,15314,1795,15295,2173,15269,2410,15237,2649,15197,2866,15150,3054,15095,3140,15032,3196,14963,3228,14888,3236,14808,3224,14725,3191,14639,3146,14553,3088,14466,2976,14382,2836,14262,2692,14103,2549,13952,2409,13808,2278,13674,2154,15360,4,15360,4,15360,4,15360,13,15359,33,15358,59,15357,112,15353,199,15348,302,15341,456,15331,628,15316,827,15297,1082,15272,1332,15241,1601,15202,1851,15156,2069,15101,2172,15039,2256,14970,2314,14894,2348,14813,2358,14728,2344,14640,2311,14551,2263,14463,2203,14376,2133,14247,2059,14084,1915,13930,1761,13784,1609,13648,1464,15360,0,15360,0,15360,0,15360,3,15359,18,15358,26,15357,53,15354,80,15348,97,15341,165,15332,238,15318,326,15299,427,15275,529,15245,654,15207,771,15161,885,15108,994,15046,1089,14976,1170,14900,1229,14817,1266,14731,1284,14641,1282,14550,1260,14460,1223,14370,1174,14232,1116,14066,1050,13909,981,13761,910,13623,839]);let xi=null;function rb(){return xi===null&&(xi=new a_(sb,32,32,Zh,Rr),xi.minFilter=On,xi.magFilter=On,xi.wrapS=wi,xi.wrapT=wi,xi.generateMipmaps=!1,xi.needsUpdate=!0),xi}class ab{constructor(t={}){const{canvas:e=D0(),context:n=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1}=t;this.isWebGLRenderer=!0;let f;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=n.getContextAttributes().alpha}else f=a;const m=new Set([Kh,$h,qh]),x=new Set([ui,ws,oa,la,jh,Yh]),_=new Uint32Array(4),p=new Int32Array(4);let w=null,S=null;const y=[],E=[];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=Ki,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const v=this;let A=!1;this._outputColorSpace=An;let R=0,M=0,g=null,O=-1,F=null;const k=new Se,G=new Se;let K=null;const tt=new Zt(0);let lt=0,$=e.width,st=e.height,ct=1,Et=null,Vt=null;const pt=new Se(0,0,$,st),$t=new Se(0,0,$,st);let se=!1;const J=new tu;let rt=!1,Mt=!1;const Bt=new _e,Ct=new I,It=new Se,Ae={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ht=!1;function he(){return g===null?ct:1}let N=n;function Wt(T,z){return e.getContext(T,z)}try{const T={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${Wh}`),e.addEventListener("webglcontextlost",H,!1),e.addEventListener("webglcontextrestored",j,!1),e.addEventListener("webglcontextcreationerror",ut,!1),N===null){const z="webgl2";if(N=Wt(z,T),N===null)throw Wt(z)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(T){throw T("WebGLRenderer: "+T.message),T}let jt,ie,wt,pe,Rt,Ut,C,b,V,nt,it,Q,At,mt,Pt,L,D,U,et,ot,ht,yt,P,W;function X(){jt=new pv(N),jt.init(),yt=new $y(N,jt),ie=new rv(N,jt,t,yt),wt=new qy(N,jt),ie.reversedDepthBuffer&&d&&wt.buffers.depth.setReversed(!0),pe=new xv(N),Rt=new Iy,Ut=new Zy(N,jt,wt,Rt,ie,yt,pe),C=new ov(v),b=new fv(v),V=new b_(N),P=new iv(N,V),nt=new mv(N,V,pe,P),it=new vv(N,nt,V,pe),et=new gv(N,ie,Ut),L=new av(Rt),Q=new Ny(v,C,b,jt,ie,P,L),At=new nb(v,Rt),mt=new Fy,Pt=new Gy(jt),U=new nv(v,C,b,wt,it,f,l),D=new jy(v,it,ie),W=new ib(N,pe,ie,wt),ot=new sv(N,jt,pe),ht=new _v(N,jt,pe),pe.programs=Q.programs,v.capabilities=ie,v.extensions=jt,v.properties=Rt,v.renderLists=mt,v.shadowMap=D,v.state=wt,v.info=pe}X();const Y=new tb(v,N);this.xr=Y,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){const T=jt.get("WEBGL_lose_context");T&&T.loseContext()},this.forceContextRestore=function(){const T=jt.get("WEBGL_lose_context");T&&T.restoreContext()},this.getPixelRatio=function(){return ct},this.setPixelRatio=function(T){T!==void 0&&(ct=T,this.setSize($,st,!1))},this.getSize=function(T){return T.set($,st)},this.setSize=function(T,z,q=!0){if(Y.isPresenting){kt("WebGLRenderer: Can't change size while VR device is presenting.");return}$=T,st=z,e.width=Math.floor(T*ct),e.height=Math.floor(z*ct),q===!0&&(e.style.width=T+"px",e.style.height=z+"px"),this.setViewport(0,0,T,z)},this.getDrawingBufferSize=function(T){return T.set($*ct,st*ct).floor()},this.setDrawingBufferSize=function(T,z,q){$=T,st=z,ct=q,e.width=Math.floor(T*q),e.height=Math.floor(z*q),this.setViewport(0,0,T,z)},this.getCurrentViewport=function(T){return T.copy(k)},this.getViewport=function(T){return T.copy(pt)},this.setViewport=function(T,z,q,Z){T.isVector4?pt.set(T.x,T.y,T.z,T.w):pt.set(T,z,q,Z),wt.viewport(k.copy(pt).multiplyScalar(ct).round())},this.getScissor=function(T){return T.copy($t)},this.setScissor=function(T,z,q,Z){T.isVector4?$t.set(T.x,T.y,T.z,T.w):$t.set(T,z,q,Z),wt.scissor(G.copy($t).multiplyScalar(ct).round())},this.getScissorTest=function(){return se},this.setScissorTest=function(T){wt.setScissorTest(se=T)},this.setOpaqueSort=function(T){Et=T},this.setTransparentSort=function(T){Vt=T},this.getClearColor=function(T){return T.copy(U.getClearColor())},this.setClearColor=function(){U.setClearColor(...arguments)},this.getClearAlpha=function(){return U.getClearAlpha()},this.setClearAlpha=function(){U.setClearAlpha(...arguments)},this.clear=function(T=!0,z=!0,q=!0){let Z=0;if(T){let B=!1;if(g!==null){const ft=g.texture.format;B=m.has(ft)}if(B){const ft=g.texture.type,xt=x.has(ft),Tt=U.getClearColor(),St=U.getClearAlpha(),Lt=Tt.r,Ft=Tt.g,Dt=Tt.b;xt?(_[0]=Lt,_[1]=Ft,_[2]=Dt,_[3]=St,N.clearBufferuiv(N.COLOR,0,_)):(p[0]=Lt,p[1]=Ft,p[2]=Dt,p[3]=St,N.clearBufferiv(N.COLOR,0,p))}else Z|=N.COLOR_BUFFER_BIT}z&&(Z|=N.DEPTH_BUFFER_BIT),q&&(Z|=N.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),N.clear(Z)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",H,!1),e.removeEventListener("webglcontextrestored",j,!1),e.removeEventListener("webglcontextcreationerror",ut,!1),U.dispose(),mt.dispose(),Pt.dispose(),Rt.dispose(),C.dispose(),b.dispose(),it.dispose(),P.dispose(),W.dispose(),Q.dispose(),Y.dispose(),Y.removeEventListener("sessionstart",wu),Y.removeEventListener("sessionend",Tu),ss.stop()};function H(T){T.preventDefault(),Gu("WebGLRenderer: Context Lost."),A=!0}function j(){Gu("WebGLRenderer: Context Restored."),A=!1;const T=pe.autoReset,z=D.enabled,q=D.autoUpdate,Z=D.needsUpdate,B=D.type;X(),pe.autoReset=T,D.enabled=z,D.autoUpdate=q,D.needsUpdate=Z,D.type=B}function ut(T){Me("WebGLRenderer: A WebGL context could not be created. Reason: ",T.statusMessage)}function bt(T){const z=T.target;z.removeEventListener("dispose",bt),Yt(z)}function Yt(T){ne(T),Rt.remove(T)}function ne(T){const z=Rt.get(T).programs;z!==void 0&&(z.forEach(function(q){Q.releaseProgram(q)}),T.isShaderMaterial&&Q.releaseShaderCache(T))}this.renderBufferDirect=function(T,z,q,Z,B,ft){z===null&&(z=Ae);const xt=B.isMesh&&B.matrixWorld.determinant()<0,Tt=Um(T,z,q,Z,B);wt.setMaterial(Z,xt);let St=q.index,Lt=1;if(Z.wireframe===!0){if(St=nt.getWireframeAttribute(q),St===void 0)return;Lt=2}const Ft=q.drawRange,Dt=q.attributes.position;let Kt=Ft.start*Lt,re=(Ft.start+Ft.count)*Lt;ft!==null&&(Kt=Math.max(Kt,ft.start*Lt),re=Math.min(re,(ft.start+ft.count)*Lt)),St!==null?(Kt=Math.max(Kt,0),re=Math.min(re,St.count)):Dt!=null&&(Kt=Math.max(Kt,0),re=Math.min(re,Dt.count));const ye=re-Kt;if(ye<0||ye===1/0)return;P.setup(B,Z,Tt,q,St);let be,ue=ot;if(St!==null&&(be=V.get(St),ue=ht,ue.setIndex(be)),B.isMesh)Z.wireframe===!0?(wt.setLineWidth(Z.wireframeLinewidth*he()),ue.setMode(N.LINES)):ue.setMode(N.TRIANGLES);else if(B.isLine){let Ot=Z.linewidth;Ot===void 0&&(Ot=1),wt.setLineWidth(Ot*he()),B.isLineSegments?ue.setMode(N.LINES):B.isLineLoop?ue.setMode(N.LINE_LOOP):ue.setMode(N.LINE_STRIP)}else B.isPoints?ue.setMode(N.POINTS):B.isSprite&&ue.setMode(N.TRIANGLES);if(B.isBatchedMesh)if(B._multiDrawInstances!==null)ua("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),ue.renderMultiDrawInstances(B._multiDrawStarts,B._multiDrawCounts,B._multiDrawCount,B._multiDrawInstances);else if(jt.get("WEBGL_multi_draw"))ue.renderMultiDraw(B._multiDrawStarts,B._multiDrawCounts,B._multiDrawCount);else{const Ot=B._multiDrawStarts,ge=B._multiDrawCounts,Qt=B._multiDrawCount,cn=St?V.get(St).bytesPerElement:1,Fs=Rt.get(Z).currentProgram.getUniforms();for(let hn=0;hn<Qt;hn++)Fs.setValue(N,"_gl_DrawID",hn),ue.render(Ot[hn]/cn,ge[hn])}else if(B.isInstancedMesh)ue.renderInstances(Kt,ye,B.count);else if(q.isInstancedBufferGeometry){const Ot=q._maxInstanceCount!==void 0?q._maxInstanceCount:1/0,ge=Math.min(q.instanceCount,Ot);ue.renderInstances(Kt,ye,ge)}else ue.render(Kt,ye)};function Mn(T,z,q){T.transparent===!0&&T.side===si&&T.forceSinglePass===!1?(T.side=on,T.needsUpdate=!0,Ca(T,z,q),T.side=Ji,T.needsUpdate=!0,Ca(T,z,q),T.side=si):Ca(T,z,q)}this.compile=function(T,z,q=null){q===null&&(q=T),S=Pt.get(q),S.init(z),E.push(S),q.traverseVisible(function(B){B.isLight&&B.layers.test(z.layers)&&(S.pushLight(B),B.castShadow&&S.pushShadow(B))}),T!==q&&T.traverseVisible(function(B){B.isLight&&B.layers.test(z.layers)&&(S.pushLight(B),B.castShadow&&S.pushShadow(B))}),S.setupLights();const Z=new Set;return T.traverse(function(B){if(!(B.isMesh||B.isPoints||B.isLine||B.isSprite))return;const ft=B.material;if(ft)if(Array.isArray(ft))for(let xt=0;xt<ft.length;xt++){const Tt=ft[xt];Mn(Tt,q,B),Z.add(Tt)}else Mn(ft,q,B),Z.add(ft)}),S=E.pop(),Z},this.compileAsync=function(T,z,q=null){const Z=this.compile(T,z,q);return new Promise(B=>{function ft(){if(Z.forEach(function(xt){Rt.get(xt).currentProgram.isReady()&&Z.delete(xt)}),Z.size===0){B(T);return}setTimeout(ft,10)}jt.get("KHR_parallel_shader_compile")!==null?ft():setTimeout(ft,10)})};let ln=null;function Im(T){ln&&ln(T)}function wu(){ss.stop()}function Tu(){ss.start()}const ss=new Ap;ss.setAnimationLoop(Im),typeof self<"u"&&ss.setContext(self),this.setAnimationLoop=function(T){ln=T,Y.setAnimationLoop(T),T===null?ss.stop():ss.start()},Y.addEventListener("sessionstart",wu),Y.addEventListener("sessionend",Tu),this.render=function(T,z){if(z!==void 0&&z.isCamera!==!0){Me("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;if(T.matrixWorldAutoUpdate===!0&&T.updateMatrixWorld(),z.parent===null&&z.matrixWorldAutoUpdate===!0&&z.updateMatrixWorld(),Y.enabled===!0&&Y.isPresenting===!0&&(Y.cameraAutoUpdate===!0&&Y.updateCamera(z),z=Y.getCamera()),T.isScene===!0&&T.onBeforeRender(v,T,z,g),S=Pt.get(T,E.length),S.init(z),E.push(S),Bt.multiplyMatrices(z.projectionMatrix,z.matrixWorldInverse),J.setFromProjectionMatrix(Bt,ai,z.reversedDepth),Mt=this.localClippingEnabled,rt=L.init(this.clippingPlanes,Mt),w=mt.get(T,y.length),w.init(),y.push(w),Y.enabled===!0&&Y.isPresenting===!0){const ft=v.xr.getDepthSensingMesh();ft!==null&&vl(ft,z,-1/0,v.sortObjects)}vl(T,z,0,v.sortObjects),w.finish(),v.sortObjects===!0&&w.sort(Et,Vt),Ht=Y.enabled===!1||Y.isPresenting===!1||Y.hasDepthSensing()===!1,Ht&&U.addToRenderList(w,T),this.info.render.frame++,rt===!0&&L.beginShadows();const q=S.state.shadowsArray;D.render(q,T,z),rt===!0&&L.endShadows(),this.info.autoReset===!0&&this.info.reset();const Z=w.opaque,B=w.transmissive;if(S.setupLights(),z.isArrayCamera){const ft=z.cameras;if(B.length>0)for(let xt=0,Tt=ft.length;xt<Tt;xt++){const St=ft[xt];Cu(Z,B,T,St)}Ht&&U.render(T);for(let xt=0,Tt=ft.length;xt<Tt;xt++){const St=ft[xt];Au(w,T,St,St.viewport)}}else B.length>0&&Cu(Z,B,T,z),Ht&&U.render(T),Au(w,T,z);g!==null&&M===0&&(Ut.updateMultisampleRenderTarget(g),Ut.updateRenderTargetMipmap(g)),T.isScene===!0&&T.onAfterRender(v,T,z),P.resetDefaultState(),O=-1,F=null,E.pop(),E.length>0?(S=E[E.length-1],rt===!0&&L.setGlobalState(v.clippingPlanes,S.state.camera)):S=null,y.pop(),y.length>0?w=y[y.length-1]:w=null};function vl(T,z,q,Z){if(T.visible===!1)return;if(T.layers.test(z.layers)){if(T.isGroup)q=T.renderOrder;else if(T.isLOD)T.autoUpdate===!0&&T.update(z);else if(T.isLight)S.pushLight(T),T.castShadow&&S.pushShadow(T);else if(T.isSprite){if(!T.frustumCulled||J.intersectsSprite(T)){Z&&It.setFromMatrixPosition(T.matrixWorld).applyMatrix4(Bt);const xt=it.update(T),Tt=T.material;Tt.visible&&w.push(T,xt,Tt,q,It.z,null)}}else if((T.isMesh||T.isLine||T.isPoints)&&(!T.frustumCulled||J.intersectsObject(T))){const xt=it.update(T),Tt=T.material;if(Z&&(T.boundingSphere!==void 0?(T.boundingSphere===null&&T.computeBoundingSphere(),It.copy(T.boundingSphere.center)):(xt.boundingSphere===null&&xt.computeBoundingSphere(),It.copy(xt.boundingSphere.center)),It.applyMatrix4(T.matrixWorld).applyMatrix4(Bt)),Array.isArray(Tt)){const St=xt.groups;for(let Lt=0,Ft=St.length;Lt<Ft;Lt++){const Dt=St[Lt],Kt=Tt[Dt.materialIndex];Kt&&Kt.visible&&w.push(T,xt,Kt,q,It.z,Dt)}}else Tt.visible&&w.push(T,xt,Tt,q,It.z,null)}}const ft=T.children;for(let xt=0,Tt=ft.length;xt<Tt;xt++)vl(ft[xt],z,q,Z)}function Au(T,z,q,Z){const{opaque:B,transmissive:ft,transparent:xt}=T;S.setupLightsView(q),rt===!0&&L.setGlobalState(v.clippingPlanes,q),Z&&wt.viewport(k.copy(Z)),B.length>0&&Aa(B,z,q),ft.length>0&&Aa(ft,z,q),xt.length>0&&Aa(xt,z,q),wt.buffers.depth.setTest(!0),wt.buffers.depth.setMask(!0),wt.buffers.color.setMask(!0),wt.setPolygonOffset(!1)}function Cu(T,z,q,Z){if((q.isScene===!0?q.overrideMaterial:null)!==null)return;S.state.transmissionRenderTarget[Z.id]===void 0&&(S.state.transmissionRenderTarget[Z.id]=new Ts(1,1,{generateMipmaps:!0,type:jt.has("EXT_color_buffer_half_float")||jt.has("EXT_color_buffer_float")?Rr:ui,minFilter:bs,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:te.workingColorSpace}));const ft=S.state.transmissionRenderTarget[Z.id],xt=Z.viewport||k;ft.setSize(xt.z*v.transmissionResolutionScale,xt.w*v.transmissionResolutionScale);const Tt=v.getRenderTarget(),St=v.getActiveCubeFace(),Lt=v.getActiveMipmapLevel();v.setRenderTarget(ft),v.getClearColor(tt),lt=v.getClearAlpha(),lt<1&&v.setClearColor(16777215,.5),v.clear(),Ht&&U.render(q);const Ft=v.toneMapping;v.toneMapping=Ki;const Dt=Z.viewport;if(Z.viewport!==void 0&&(Z.viewport=void 0),S.setupLightsView(Z),rt===!0&&L.setGlobalState(v.clippingPlanes,Z),Aa(T,q,Z),Ut.updateMultisampleRenderTarget(ft),Ut.updateRenderTargetMipmap(ft),jt.has("WEBGL_multisampled_render_to_texture")===!1){let Kt=!1;for(let re=0,ye=z.length;re<ye;re++){const be=z[re],{object:ue,geometry:Ot,material:ge,group:Qt}=be;if(ge.side===si&&ue.layers.test(Z.layers)){const cn=ge.side;ge.side=on,ge.needsUpdate=!0,Ru(ue,q,Z,Ot,ge,Qt),ge.side=cn,ge.needsUpdate=!0,Kt=!0}}Kt===!0&&(Ut.updateMultisampleRenderTarget(ft),Ut.updateRenderTargetMipmap(ft))}v.setRenderTarget(Tt,St,Lt),v.setClearColor(tt,lt),Dt!==void 0&&(Z.viewport=Dt),v.toneMapping=Ft}function Aa(T,z,q){const Z=z.isScene===!0?z.overrideMaterial:null;for(let B=0,ft=T.length;B<ft;B++){const xt=T[B],{object:Tt,geometry:St,group:Lt}=xt;let Ft=xt.material;Ft.allowOverride===!0&&Z!==null&&(Ft=Z),Tt.layers.test(q.layers)&&Ru(Tt,z,q,St,Ft,Lt)}}function Ru(T,z,q,Z,B,ft){T.onBeforeRender(v,z,q,Z,B,ft),T.modelViewMatrix.multiplyMatrices(q.matrixWorldInverse,T.matrixWorld),T.normalMatrix.getNormalMatrix(T.modelViewMatrix),B.onBeforeRender(v,z,q,Z,T,ft),B.transparent===!0&&B.side===si&&B.forceSinglePass===!1?(B.side=on,B.needsUpdate=!0,v.renderBufferDirect(q,z,Z,B,T,ft),B.side=Ji,B.needsUpdate=!0,v.renderBufferDirect(q,z,Z,B,T,ft),B.side=si):v.renderBufferDirect(q,z,Z,B,T,ft),T.onAfterRender(v,z,q,Z,B,ft)}function Ca(T,z,q){z.isScene!==!0&&(z=Ae);const Z=Rt.get(T),B=S.state.lights,ft=S.state.shadowsArray,xt=B.state.version,Tt=Q.getParameters(T,B.state,ft,z,q),St=Q.getProgramCacheKey(Tt);let Lt=Z.programs;Z.environment=T.isMeshStandardMaterial?z.environment:null,Z.fog=z.fog,Z.envMap=(T.isMeshStandardMaterial?b:C).get(T.envMap||Z.environment),Z.envMapRotation=Z.environment!==null&&T.envMap===null?z.environmentRotation:T.envMapRotation,Lt===void 0&&(T.addEventListener("dispose",bt),Lt=new Map,Z.programs=Lt);let Ft=Lt.get(St);if(Ft!==void 0){if(Z.currentProgram===Ft&&Z.lightsStateVersion===xt)return Du(T,Tt),Ft}else Tt.uniforms=Q.getUniforms(T),T.onBeforeCompile(Tt,v),Ft=Q.acquireProgram(Tt,St),Lt.set(St,Ft),Z.uniforms=Tt.uniforms;const Dt=Z.uniforms;return(!T.isShaderMaterial&&!T.isRawShaderMaterial||T.clipping===!0)&&(Dt.clippingPlanes=L.uniform),Du(T,Tt),Z.needsLights=zm(T),Z.lightsStateVersion=xt,Z.needsLights&&(Dt.ambientLightColor.value=B.state.ambient,Dt.lightProbe.value=B.state.probe,Dt.directionalLights.value=B.state.directional,Dt.directionalLightShadows.value=B.state.directionalShadow,Dt.spotLights.value=B.state.spot,Dt.spotLightShadows.value=B.state.spotShadow,Dt.rectAreaLights.value=B.state.rectArea,Dt.ltc_1.value=B.state.rectAreaLTC1,Dt.ltc_2.value=B.state.rectAreaLTC2,Dt.pointLights.value=B.state.point,Dt.pointLightShadows.value=B.state.pointShadow,Dt.hemisphereLights.value=B.state.hemi,Dt.directionalShadowMap.value=B.state.directionalShadowMap,Dt.directionalShadowMatrix.value=B.state.directionalShadowMatrix,Dt.spotShadowMap.value=B.state.spotShadowMap,Dt.spotLightMatrix.value=B.state.spotLightMatrix,Dt.spotLightMap.value=B.state.spotLightMap,Dt.pointShadowMap.value=B.state.pointShadowMap,Dt.pointShadowMatrix.value=B.state.pointShadowMatrix),Z.currentProgram=Ft,Z.uniformsList=null,Ft}function Pu(T){if(T.uniformsList===null){const z=T.currentProgram.getUniforms();T.uniformsList=Po.seqWithValue(z.seq,T.uniforms)}return T.uniformsList}function Du(T,z){const q=Rt.get(T);q.outputColorSpace=z.outputColorSpace,q.batching=z.batching,q.batchingColor=z.batchingColor,q.instancing=z.instancing,q.instancingColor=z.instancingColor,q.instancingMorph=z.instancingMorph,q.skinning=z.skinning,q.morphTargets=z.morphTargets,q.morphNormals=z.morphNormals,q.morphColors=z.morphColors,q.morphTargetsCount=z.morphTargetsCount,q.numClippingPlanes=z.numClippingPlanes,q.numIntersection=z.numClipIntersection,q.vertexAlphas=z.vertexAlphas,q.vertexTangents=z.vertexTangents,q.toneMapping=z.toneMapping}function Um(T,z,q,Z,B){z.isScene!==!0&&(z=Ae),Ut.resetTextureUnits();const ft=z.fog,xt=Z.isMeshStandardMaterial?z.environment:null,Tt=g===null?v.outputColorSpace:g.isXRRenderTarget===!0?g.texture.colorSpace:wr,St=(Z.isMeshStandardMaterial?b:C).get(Z.envMap||xt),Lt=Z.vertexColors===!0&&!!q.attributes.color&&q.attributes.color.itemSize===4,Ft=!!q.attributes.tangent&&(!!Z.normalMap||Z.anisotropy>0),Dt=!!q.morphAttributes.position,Kt=!!q.morphAttributes.normal,re=!!q.morphAttributes.color;let ye=Ki;Z.toneMapped&&(g===null||g.isXRRenderTarget===!0)&&(ye=v.toneMapping);const be=q.morphAttributes.position||q.morphAttributes.normal||q.morphAttributes.color,ue=be!==void 0?be.length:0,Ot=Rt.get(Z),ge=S.state.lights;if(rt===!0&&(Mt===!0||T!==F)){const $e=T===F&&Z.id===O;L.setState(Z,T,$e)}let Qt=!1;Z.version===Ot.__version?(Ot.needsLights&&Ot.lightsStateVersion!==ge.state.version||Ot.outputColorSpace!==Tt||B.isBatchedMesh&&Ot.batching===!1||!B.isBatchedMesh&&Ot.batching===!0||B.isBatchedMesh&&Ot.batchingColor===!0&&B.colorTexture===null||B.isBatchedMesh&&Ot.batchingColor===!1&&B.colorTexture!==null||B.isInstancedMesh&&Ot.instancing===!1||!B.isInstancedMesh&&Ot.instancing===!0||B.isSkinnedMesh&&Ot.skinning===!1||!B.isSkinnedMesh&&Ot.skinning===!0||B.isInstancedMesh&&Ot.instancingColor===!0&&B.instanceColor===null||B.isInstancedMesh&&Ot.instancingColor===!1&&B.instanceColor!==null||B.isInstancedMesh&&Ot.instancingMorph===!0&&B.morphTexture===null||B.isInstancedMesh&&Ot.instancingMorph===!1&&B.morphTexture!==null||Ot.envMap!==St||Z.fog===!0&&Ot.fog!==ft||Ot.numClippingPlanes!==void 0&&(Ot.numClippingPlanes!==L.numPlanes||Ot.numIntersection!==L.numIntersection)||Ot.vertexAlphas!==Lt||Ot.vertexTangents!==Ft||Ot.morphTargets!==Dt||Ot.morphNormals!==Kt||Ot.morphColors!==re||Ot.toneMapping!==ye||Ot.morphTargetsCount!==ue)&&(Qt=!0):(Qt=!0,Ot.__version=Z.version);let cn=Ot.currentProgram;Qt===!0&&(cn=Ca(Z,z,B));let Fs=!1,hn=!1,zr=!1;const ve=cn.getUniforms(),Qe=Ot.uniforms;if(wt.useProgram(cn.program)&&(Fs=!0,hn=!0,zr=!0),Z.id!==O&&(O=Z.id,hn=!0),Fs||F!==T){wt.buffers.depth.getReversed()&&T.reversedDepth!==!0&&(T._reversedDepth=!0,T.updateProjectionMatrix()),ve.setValue(N,"projectionMatrix",T.projectionMatrix),ve.setValue(N,"viewMatrix",T.matrixWorldInverse);const tn=ve.map.cameraPosition;tn!==void 0&&tn.setValue(N,Ct.setFromMatrixPosition(T.matrixWorld)),ie.logarithmicDepthBuffer&&ve.setValue(N,"logDepthBufFC",2/(Math.log(T.far+1)/Math.LN2)),(Z.isMeshPhongMaterial||Z.isMeshToonMaterial||Z.isMeshLambertMaterial||Z.isMeshBasicMaterial||Z.isMeshStandardMaterial||Z.isShaderMaterial)&&ve.setValue(N,"isOrthographic",T.isOrthographicCamera===!0),F!==T&&(F=T,hn=!0,zr=!0)}if(B.isSkinnedMesh){ve.setOptional(N,B,"bindMatrix"),ve.setOptional(N,B,"bindMatrixInverse");const $e=B.skeleton;$e&&($e.boneTexture===null&&$e.computeBoneTexture(),ve.setValue(N,"boneTexture",$e.boneTexture,Ut))}B.isBatchedMesh&&(ve.setOptional(N,B,"batchingTexture"),ve.setValue(N,"batchingTexture",B._matricesTexture,Ut),ve.setOptional(N,B,"batchingIdTexture"),ve.setValue(N,"batchingIdTexture",B._indirectTexture,Ut),ve.setOptional(N,B,"batchingColorTexture"),B._colorsTexture!==null&&ve.setValue(N,"batchingColorTexture",B._colorsTexture,Ut));const Sn=q.morphAttributes;if((Sn.position!==void 0||Sn.normal!==void 0||Sn.color!==void 0)&&et.update(B,q,cn),(hn||Ot.receiveShadow!==B.receiveShadow)&&(Ot.receiveShadow=B.receiveShadow,ve.setValue(N,"receiveShadow",B.receiveShadow)),Z.isMeshGouraudMaterial&&Z.envMap!==null&&(Qe.envMap.value=St,Qe.flipEnvMap.value=St.isCubeTexture&&St.isRenderTargetTexture===!1?-1:1),Z.isMeshStandardMaterial&&Z.envMap===null&&z.environment!==null&&(Qe.envMapIntensity.value=z.environmentIntensity),Qe.dfgLUT!==void 0&&(Qe.dfgLUT.value=rb()),hn&&(ve.setValue(N,"toneMappingExposure",v.toneMappingExposure),Ot.needsLights&&Fm(Qe,zr),ft&&Z.fog===!0&&At.refreshFogUniforms(Qe,ft),At.refreshMaterialUniforms(Qe,Z,ct,st,S.state.transmissionRenderTarget[T.id]),Po.upload(N,Pu(Ot),Qe,Ut)),Z.isShaderMaterial&&Z.uniformsNeedUpdate===!0&&(Po.upload(N,Pu(Ot),Qe,Ut),Z.uniformsNeedUpdate=!1),Z.isSpriteMaterial&&ve.setValue(N,"center",B.center),ve.setValue(N,"modelViewMatrix",B.modelViewMatrix),ve.setValue(N,"normalMatrix",B.normalMatrix),ve.setValue(N,"modelMatrix",B.matrixWorld),Z.isShaderMaterial||Z.isRawShaderMaterial){const $e=Z.uniformsGroups;for(let tn=0,yl=$e.length;tn<yl;tn++){const rs=$e[tn];W.update(rs,cn),W.bind(rs,cn)}}return cn}function Fm(T,z){T.ambientLightColor.needsUpdate=z,T.lightProbe.needsUpdate=z,T.directionalLights.needsUpdate=z,T.directionalLightShadows.needsUpdate=z,T.pointLights.needsUpdate=z,T.pointLightShadows.needsUpdate=z,T.spotLights.needsUpdate=z,T.spotLightShadows.needsUpdate=z,T.rectAreaLights.needsUpdate=z,T.hemisphereLights.needsUpdate=z}function zm(T){return T.isMeshLambertMaterial||T.isMeshToonMaterial||T.isMeshPhongMaterial||T.isMeshStandardMaterial||T.isShadowMaterial||T.isShaderMaterial&&T.lights===!0}this.getActiveCubeFace=function(){return R},this.getActiveMipmapLevel=function(){return M},this.getRenderTarget=function(){return g},this.setRenderTargetTextures=function(T,z,q){const Z=Rt.get(T);Z.__autoAllocateDepthBuffer=T.resolveDepthBuffer===!1,Z.__autoAllocateDepthBuffer===!1&&(Z.__useRenderToTexture=!1),Rt.get(T.texture).__webglTexture=z,Rt.get(T.depthTexture).__webglTexture=Z.__autoAllocateDepthBuffer?void 0:q,Z.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(T,z){const q=Rt.get(T);q.__webglFramebuffer=z,q.__useDefaultFramebuffer=z===void 0};const Bm=N.createFramebuffer();this.setRenderTarget=function(T,z=0,q=0){g=T,R=z,M=q;let Z=!0,B=null,ft=!1,xt=!1;if(T){const St=Rt.get(T);if(St.__useDefaultFramebuffer!==void 0)wt.bindFramebuffer(N.FRAMEBUFFER,null),Z=!1;else if(St.__webglFramebuffer===void 0)Ut.setupRenderTarget(T);else if(St.__hasExternalTextures)Ut.rebindTextures(T,Rt.get(T.texture).__webglTexture,Rt.get(T.depthTexture).__webglTexture);else if(T.depthBuffer){const Dt=T.depthTexture;if(St.__boundDepthTexture!==Dt){if(Dt!==null&&Rt.has(Dt)&&(T.width!==Dt.image.width||T.height!==Dt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Ut.setupDepthRenderbuffer(T)}}const Lt=T.texture;(Lt.isData3DTexture||Lt.isDataArrayTexture||Lt.isCompressedArrayTexture)&&(xt=!0);const Ft=Rt.get(T).__webglFramebuffer;T.isWebGLCubeRenderTarget?(Array.isArray(Ft[z])?B=Ft[z][q]:B=Ft[z],ft=!0):T.samples>0&&Ut.useMultisampledRTT(T)===!1?B=Rt.get(T).__webglMultisampledFramebuffer:Array.isArray(Ft)?B=Ft[q]:B=Ft,k.copy(T.viewport),G.copy(T.scissor),K=T.scissorTest}else k.copy(pt).multiplyScalar(ct).floor(),G.copy($t).multiplyScalar(ct).floor(),K=se;if(q!==0&&(B=Bm),wt.bindFramebuffer(N.FRAMEBUFFER,B)&&Z&&wt.drawBuffers(T,B),wt.viewport(k),wt.scissor(G),wt.setScissorTest(K),ft){const St=Rt.get(T.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+z,St.__webglTexture,q)}else if(xt){const St=z;for(let Lt=0;Lt<T.textures.length;Lt++){const Ft=Rt.get(T.textures[Lt]);N.framebufferTextureLayer(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0+Lt,Ft.__webglTexture,q,St)}}else if(T!==null&&q!==0){const St=Rt.get(T.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,St.__webglTexture,q)}O=-1},this.readRenderTargetPixels=function(T,z,q,Z,B,ft,xt,Tt=0){if(!(T&&T.isWebGLRenderTarget)){Me("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let St=Rt.get(T).__webglFramebuffer;if(T.isWebGLCubeRenderTarget&&xt!==void 0&&(St=St[xt]),St){wt.bindFramebuffer(N.FRAMEBUFFER,St);try{const Lt=T.textures[Tt],Ft=Lt.format,Dt=Lt.type;if(!ie.textureFormatReadable(Ft)){Me("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!ie.textureTypeReadable(Dt)){Me("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}z>=0&&z<=T.width-Z&&q>=0&&q<=T.height-B&&(T.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+Tt),N.readPixels(z,q,Z,B,yt.convert(Ft),yt.convert(Dt),ft))}finally{const Lt=g!==null?Rt.get(g).__webglFramebuffer:null;wt.bindFramebuffer(N.FRAMEBUFFER,Lt)}}},this.readRenderTargetPixelsAsync=async function(T,z,q,Z,B,ft,xt,Tt=0){if(!(T&&T.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let St=Rt.get(T).__webglFramebuffer;if(T.isWebGLCubeRenderTarget&&xt!==void 0&&(St=St[xt]),St)if(z>=0&&z<=T.width-Z&&q>=0&&q<=T.height-B){wt.bindFramebuffer(N.FRAMEBUFFER,St);const Lt=T.textures[Tt],Ft=Lt.format,Dt=Lt.type;if(!ie.textureFormatReadable(Ft))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!ie.textureTypeReadable(Dt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Kt=N.createBuffer();N.bindBuffer(N.PIXEL_PACK_BUFFER,Kt),N.bufferData(N.PIXEL_PACK_BUFFER,ft.byteLength,N.STREAM_READ),T.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+Tt),N.readPixels(z,q,Z,B,yt.convert(Ft),yt.convert(Dt),0);const re=g!==null?Rt.get(g).__webglFramebuffer:null;wt.bindFramebuffer(N.FRAMEBUFFER,re);const ye=N.fenceSync(N.SYNC_GPU_COMMANDS_COMPLETE,0);return N.flush(),await O0(N,ye,4),N.bindBuffer(N.PIXEL_PACK_BUFFER,Kt),N.getBufferSubData(N.PIXEL_PACK_BUFFER,0,ft),N.deleteBuffer(Kt),N.deleteSync(ye),ft}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(T,z=null,q=0){const Z=Math.pow(2,-q),B=Math.floor(T.image.width*Z),ft=Math.floor(T.image.height*Z),xt=z!==null?z.x:0,Tt=z!==null?z.y:0;Ut.setTexture2D(T,0),N.copyTexSubImage2D(N.TEXTURE_2D,q,0,0,xt,Tt,B,ft),wt.unbindTexture()};const km=N.createFramebuffer(),Vm=N.createFramebuffer();this.copyTextureToTexture=function(T,z,q=null,Z=null,B=0,ft=null){ft===null&&(B!==0?(ua("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),ft=B,B=0):ft=0);let xt,Tt,St,Lt,Ft,Dt,Kt,re,ye;const be=T.isCompressedTexture?T.mipmaps[ft]:T.image;if(q!==null)xt=q.max.x-q.min.x,Tt=q.max.y-q.min.y,St=q.isBox3?q.max.z-q.min.z:1,Lt=q.min.x,Ft=q.min.y,Dt=q.isBox3?q.min.z:0;else{const Sn=Math.pow(2,-B);xt=Math.floor(be.width*Sn),Tt=Math.floor(be.height*Sn),T.isDataArrayTexture?St=be.depth:T.isData3DTexture?St=Math.floor(be.depth*Sn):St=1,Lt=0,Ft=0,Dt=0}Z!==null?(Kt=Z.x,re=Z.y,ye=Z.z):(Kt=0,re=0,ye=0);const ue=yt.convert(z.format),Ot=yt.convert(z.type);let ge;z.isData3DTexture?(Ut.setTexture3D(z,0),ge=N.TEXTURE_3D):z.isDataArrayTexture||z.isCompressedArrayTexture?(Ut.setTexture2DArray(z,0),ge=N.TEXTURE_2D_ARRAY):(Ut.setTexture2D(z,0),ge=N.TEXTURE_2D),N.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,z.flipY),N.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,z.premultiplyAlpha),N.pixelStorei(N.UNPACK_ALIGNMENT,z.unpackAlignment);const Qt=N.getParameter(N.UNPACK_ROW_LENGTH),cn=N.getParameter(N.UNPACK_IMAGE_HEIGHT),Fs=N.getParameter(N.UNPACK_SKIP_PIXELS),hn=N.getParameter(N.UNPACK_SKIP_ROWS),zr=N.getParameter(N.UNPACK_SKIP_IMAGES);N.pixelStorei(N.UNPACK_ROW_LENGTH,be.width),N.pixelStorei(N.UNPACK_IMAGE_HEIGHT,be.height),N.pixelStorei(N.UNPACK_SKIP_PIXELS,Lt),N.pixelStorei(N.UNPACK_SKIP_ROWS,Ft),N.pixelStorei(N.UNPACK_SKIP_IMAGES,Dt);const ve=T.isDataArrayTexture||T.isData3DTexture,Qe=z.isDataArrayTexture||z.isData3DTexture;if(T.isDepthTexture){const Sn=Rt.get(T),$e=Rt.get(z),tn=Rt.get(Sn.__renderTarget),yl=Rt.get($e.__renderTarget);wt.bindFramebuffer(N.READ_FRAMEBUFFER,tn.__webglFramebuffer),wt.bindFramebuffer(N.DRAW_FRAMEBUFFER,yl.__webglFramebuffer);for(let rs=0;rs<St;rs++)ve&&(N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Rt.get(T).__webglTexture,B,Dt+rs),N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Rt.get(z).__webglTexture,ft,ye+rs)),N.blitFramebuffer(Lt,Ft,xt,Tt,Kt,re,xt,Tt,N.DEPTH_BUFFER_BIT,N.NEAREST);wt.bindFramebuffer(N.READ_FRAMEBUFFER,null),wt.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else if(B!==0||T.isRenderTargetTexture||Rt.has(T)){const Sn=Rt.get(T),$e=Rt.get(z);wt.bindFramebuffer(N.READ_FRAMEBUFFER,km),wt.bindFramebuffer(N.DRAW_FRAMEBUFFER,Vm);for(let tn=0;tn<St;tn++)ve?N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Sn.__webglTexture,B,Dt+tn):N.framebufferTexture2D(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,Sn.__webglTexture,B),Qe?N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,$e.__webglTexture,ft,ye+tn):N.framebufferTexture2D(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,$e.__webglTexture,ft),B!==0?N.blitFramebuffer(Lt,Ft,xt,Tt,Kt,re,xt,Tt,N.COLOR_BUFFER_BIT,N.NEAREST):Qe?N.copyTexSubImage3D(ge,ft,Kt,re,ye+tn,Lt,Ft,xt,Tt):N.copyTexSubImage2D(ge,ft,Kt,re,Lt,Ft,xt,Tt);wt.bindFramebuffer(N.READ_FRAMEBUFFER,null),wt.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else Qe?T.isDataTexture||T.isData3DTexture?N.texSubImage3D(ge,ft,Kt,re,ye,xt,Tt,St,ue,Ot,be.data):z.isCompressedArrayTexture?N.compressedTexSubImage3D(ge,ft,Kt,re,ye,xt,Tt,St,ue,be.data):N.texSubImage3D(ge,ft,Kt,re,ye,xt,Tt,St,ue,Ot,be):T.isDataTexture?N.texSubImage2D(N.TEXTURE_2D,ft,Kt,re,xt,Tt,ue,Ot,be.data):T.isCompressedTexture?N.compressedTexSubImage2D(N.TEXTURE_2D,ft,Kt,re,be.width,be.height,ue,be.data):N.texSubImage2D(N.TEXTURE_2D,ft,Kt,re,xt,Tt,ue,Ot,be);N.pixelStorei(N.UNPACK_ROW_LENGTH,Qt),N.pixelStorei(N.UNPACK_IMAGE_HEIGHT,cn),N.pixelStorei(N.UNPACK_SKIP_PIXELS,Fs),N.pixelStorei(N.UNPACK_SKIP_ROWS,hn),N.pixelStorei(N.UNPACK_SKIP_IMAGES,zr),ft===0&&z.generateMipmaps&&N.generateMipmap(ge),wt.unbindTexture()},this.initRenderTarget=function(T){Rt.get(T).__webglFramebuffer===void 0&&Ut.setupRenderTarget(T)},this.initTexture=function(T){T.isCubeTexture?Ut.setTextureCube(T,0):T.isData3DTexture?Ut.setTexture3D(T,0):T.isDataArrayTexture||T.isCompressedArrayTexture?Ut.setTexture2DArray(T,0):Ut.setTexture2D(T,0),wt.unbindTexture()},this.resetState=function(){R=0,M=0,g=null,wt.reset(),P.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ai}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=te._getDrawingBufferColorSpace(t),e.unpackColorSpace=te._getUnpackColorSpace()}}let ob=class{type;position;normal;uv;material;constructor(t){this.type=t.type,this.position=t.position,this.normal=t.normal??[],this.uv=t.uv??[],this.material=t.material}};var Tn=(i=>(i[i.Cube=0]="Cube",i[i.Sphere=1]="Sphere",i[i.Plane=2]="Plane",i[i.Cylinder=3]="Cylinder",i[i.Cone=4]="Cone",i[i.Torus=5]="Torus",i[i.Circle=6]="Circle",i[i.Icosphere=7]="Icosphere",i[i.UVSphere=8]="UVSphere",i[i.Custom=9]="Custom",i))(Tn||{}),xr=(i=>(i.Plane="plane",i.Wireframe="wireframe",i.Texture="texture",i))(xr||{}),Ln=(i=>(i.Mesh="mesh",i.Face="face",i.Edge="edge",i.Vertex="vertex",i))(Ln||{}),Qi=(i=>(i.Translate="translate",i.Scale="scale",i.Rotate="rotate",i))(Qi||{}),gr=(i=>(i[i.AddFigure=0]="AddFigure",i[i.DeleteFigure=1]="DeleteFigure",i[i.LoadFigure=2]="LoadFigure",i[i.Load=3]="Load",i[i.Export=4]="Export",i))(gr||{});const lb={[Tn.Plane]:()=>new Or(1,1,1,1),[Tn.Cube]:()=>new we(1,1,1,1,1,1),[Tn.UVSphere]:()=>new da(.5,32,16),[Tn.Icosphere]:()=>new su(.5,0),[Tn.Cylinder]:()=>new Be(.5,.5,1,32,1,!1),[Tn.Cone]:()=>new iu(.5,1,32,1,!1),[Tn.Torus]:()=>new qi(.5,.2,16,64),[Tn.Circle]:()=>new nu(.5,32),[Tn.Sphere]:()=>new da(.5,32,16),[Tn.Custom]:function(){throw new Error("Custom geometry is not generated here.")}},Op=new h_({color:12566463,metalness:0,roughness:.6});class au{scene;camera;renderer;canvas;meshes=[];constructor(t){this.canvas=t,this.scene=new r_,this.scene.background=new Zt(1710618),this.camera=new Cn(45,t.clientWidth/t.clientHeight,.1,1e3),this.camera.position.set(1,1,7),this.renderer=new ab({canvas:t,antialias:!0}),this.renderer.setSize(t.clientWidth,t.clientHeight);const e=new x_(16777215,.5);this.scene.add(e);const n=new __(16777215,1);n.position.set(5,10,7),this.scene.add(n)}resize(){this.camera.aspect=this.canvas.clientWidth/this.canvas.clientHeight,this.camera.updateProjectionMatrix(),this.renderer.setSize(this.canvas.clientWidth,this.canvas.clientHeight)}render(){this.renderer.render(this.scene,this.camera)}update(){}loop(){this.update(),this.render(),requestAnimationFrame(()=>this.loop())}addFigure(t){const e=new De;e.setAttribute("position",new Jt(t.position,3)),t.normal&&e.setAttribute("normal",new Jt(t.normal,3)),t.uv&&e.setAttribute("uv",new Jt(t.uv,2));const n=new gt(e,Op);return this.scene.add(n),this.meshes.push(n),n}addMesh(t){this.scene&&(this.scene.add(t),this.meshes.push(t))}removeMesh(t){this.scene&&(this.scene.remove(t),this.meshes=this.meshes.filter(e=>e!==t))}getMeshes(){return this.meshes}addObject(t,e){this.scene&&(typeof e=="number"&&t.layers.set(e),this.scene.add(t))}removeObject(t){this.scene&&(t.parent?t.parent.remove(t):this.scene.remove(t))}enableCameraLayer(t){this.camera&&this.camera.layers.enable(t)}dispose(){this.meshes&&(this.meshes.length=0,this.meshes=[]),this.scene=null,this.camera=null,this.renderer?.dispose(),this.canvas=null}}/**
3969
+ * @license
3970
+ * Copyright 2010-2025 Three.js Authors
3971
+ * SPDX-License-Identifier: MIT
3972
+ */const vr={ROTATE:0,DOLLY:1,PAN:2},hr={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Bd=0,kd=1,Vd=100,Hd=204,Gd=205,Wd=3,Lp=300,Xd=1e3,eo=1001,jd=1002,cb=1006,hb=1008,ub=1009,db=1015,fb=1023,Np="",Wn="srgb",Yd="srgb-linear",qd="linear",Ql="srgb",Js=7680,Zd=519,$d=35044,no=2e3,Kd=2001;function pb(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function Jd(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}const Qd={};function Ve(...i){const t="THREE."+i.shift();console.warn(t,...i)}function vs(...i){const t="THREE."+i.shift();console.error(t,...i)}function tf(...i){const t=i.join(" ");t in Qd||(Qd[t]=!0,Ve(...i))}class va{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){const n=this._listeners;return n===void 0?!1:n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){const n=this._listeners;if(n===void 0)return;const s=n[t];if(s!==void 0){const r=s.indexOf(e);r!==-1&&s.splice(r,1)}}dispatchEvent(t){const e=this._listeners;if(e===void 0)return;const n=e[t.type];if(n!==void 0){t.target=this;const s=n.slice(0);for(let r=0,a=s.length;r<a;r++)s[r].call(this,t);t.target=null}}}const Ye=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],mb=Math.PI/180;function ya(){const i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Ye[i&255]+Ye[i>>8&255]+Ye[i>>16&255]+Ye[i>>24&255]+"-"+Ye[t&255]+Ye[t>>8&255]+"-"+Ye[t>>16&15|64]+Ye[t>>24&255]+"-"+Ye[e&63|128]+Ye[e>>8&255]+"-"+Ye[e>>16&255]+Ye[e>>24&255]+Ye[n&255]+Ye[n>>8&255]+Ye[n>>16&255]+Ye[n>>24&255]).toLowerCase()}function oe(i,t,e){return Math.max(t,Math.min(e,i))}function _b(i,t){return(i%t+t)%t}function tc(i,t,e){return(1-e)*i+e*t}function jr(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function nn(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const xb={DEG2RAD:mb};class Pe{constructor(t=0,e=0){Pe.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6],this.y=s[1]*e+s[4]*n+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=oe(this.x,t.x,e.x),this.y=oe(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=oe(this.x,t,e),this.y=oe(this.y,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(oe(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(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(oe(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),s=Math.sin(e),r=this.x-t.x,a=this.y-t.y;return this.x=r*n-a*s+t.x,this.y=r*s+a*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class As{constructor(t=0,e=0,n=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=s}static slerpFlat(t,e,n,s,r,a,o){let l=n[s+0],c=n[s+1],h=n[s+2],u=n[s+3],d=r[a+0],f=r[a+1],m=r[a+2],x=r[a+3];if(o<=0){t[e+0]=l,t[e+1]=c,t[e+2]=h,t[e+3]=u;return}if(o>=1){t[e+0]=d,t[e+1]=f,t[e+2]=m,t[e+3]=x;return}if(u!==x||l!==d||c!==f||h!==m){let _=l*d+c*f+h*m+u*x;_<0&&(d=-d,f=-f,m=-m,x=-x,_=-_);let p=1-o;if(_<.9995){const w=Math.acos(_),S=Math.sin(w);p=Math.sin(p*w)/S,o=Math.sin(o*w)/S,l=l*p+d*o,c=c*p+f*o,h=h*p+m*o,u=u*p+x*o}else{l=l*p+d*o,c=c*p+f*o,h=h*p+m*o,u=u*p+x*o;const w=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=w,c*=w,h*=w,u*=w}}t[e]=l,t[e+1]=c,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,s,r,a){const o=n[s],l=n[s+1],c=n[s+2],h=n[s+3],u=r[a],d=r[a+1],f=r[a+2],m=r[a+3];return t[e]=o*m+h*u+l*f-c*d,t[e+1]=l*m+h*d+c*u-o*f,t[e+2]=c*m+h*f+o*d-l*u,t[e+3]=h*m-o*u-l*d-c*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,s){return this._x=t,this._y=e,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,s=t._y,r=t._z,a=t._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(s/2),u=o(r/2),d=l(n/2),f=l(s/2),m=l(r/2);switch(a){case"XYZ":this._x=d*h*u+c*f*m,this._y=c*f*u-d*h*m,this._z=c*h*m+d*f*u,this._w=c*h*u-d*f*m;break;case"YXZ":this._x=d*h*u+c*f*m,this._y=c*f*u-d*h*m,this._z=c*h*m-d*f*u,this._w=c*h*u+d*f*m;break;case"ZXY":this._x=d*h*u-c*f*m,this._y=c*f*u+d*h*m,this._z=c*h*m+d*f*u,this._w=c*h*u-d*f*m;break;case"ZYX":this._x=d*h*u-c*f*m,this._y=c*f*u+d*h*m,this._z=c*h*m-d*f*u,this._w=c*h*u+d*f*m;break;case"YZX":this._x=d*h*u+c*f*m,this._y=c*f*u+d*h*m,this._z=c*h*m-d*f*u,this._w=c*h*u-d*f*m;break;case"XZY":this._x=d*h*u-c*f*m,this._y=c*f*u-d*h*m,this._z=c*h*m+d*f*u,this._w=c*h*u+d*f*m;break;default:Ve("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,s=Math.sin(n);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],s=e[4],r=e[8],a=e[1],o=e[5],l=e[9],c=e[2],h=e[6],u=e[10],d=n+o+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-l)*f,this._y=(r-c)*f,this._z=(a-s)*f}else if(n>o&&n>u){const f=2*Math.sqrt(1+n-o-u);this._w=(h-l)/f,this._x=.25*f,this._y=(s+a)/f,this._z=(r+c)/f}else if(o>u){const f=2*Math.sqrt(1+o-n-u);this._w=(r-c)/f,this._x=(s+a)/f,this._y=.25*f,this._z=(l+h)/f}else{const f=2*Math.sqrt(1+u-n-o);this._w=(a-s)/f,this._x=(r+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<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(oe(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const s=Math.min(1,e/n);return this.slerp(t,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,s=t._y,r=t._z,a=t._w,o=e._x,l=e._y,c=e._z,h=e._w;return this._x=n*h+a*o+s*c-r*l,this._y=s*h+a*l+r*o-n*c,this._z=r*h+a*c+n*l-s*o,this._w=a*h-n*o-s*l-r*c,this._onChangeCallback(),this}slerp(t,e){if(e<=0)return this;if(e>=1)return this.copy(t);let n=t._x,s=t._y,r=t._z,a=t._w,o=this.dot(t);o<0&&(n=-n,s=-s,r=-r,a=-a,o=-o);let l=1-e;if(o<.9995){const c=Math.acos(o),h=Math.sin(c);l=Math.sin(l*c)/h,e=Math.sin(e*c)/h,this._x=this._x*l+n*e,this._y=this._y*l+s*e,this._z=this._z*l+r*e,this._w=this._w*l+a*e,this._onChangeCallback()}else this._x=this._x*l+n*e,this._y=this._y*l+s*e,this._z=this._z*l+r*e,this._w=this._w*l+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(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(t),s*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class at{constructor(t=0,e=0,n=0){at.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(ef.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(ef.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*s,this.y=r[1]*e+r[4]*n+r[7]*s,this.z=r[2]*e+r[5]*n+r[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,s=this.z,r=t.elements,a=1/(r[3]*e+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*s+r[12])*a,this.y=(r[1]*e+r[5]*n+r[9]*s+r[13])*a,this.z=(r[2]*e+r[6]*n+r[10]*s+r[14])*a,this}applyQuaternion(t){const e=this.x,n=this.y,s=this.z,r=t.x,a=t.y,o=t.z,l=t.w,c=2*(a*s-o*n),h=2*(o*e-r*s),u=2*(r*n-a*e);return this.x=e+l*c+a*u-o*h,this.y=n+l*h+o*c-r*u,this.z=s+l*u+r*h-a*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*s,this.y=r[1]*e+r[5]*n+r[9]*s,this.z=r[2]*e+r[6]*n+r[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=oe(this.x,t.x,e.x),this.y=oe(this.y,t.y,e.y),this.z=oe(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=oe(this.x,t,e),this.y=oe(this.y,t,e),this.z=oe(this.z,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(oe(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,s=t.y,r=t.z,a=e.x,o=e.y,l=e.z;return this.x=s*l-r*o,this.y=r*a-n*l,this.z=n*o-s*a,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return ec.copy(this).projectOnVector(t),this.sub(ec)}reflect(t){return this.sub(ec.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(oe(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,s=this.z-t.z;return e*e+n*n+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const s=Math.sin(e)*t;return this.x=s*Math.sin(n),this.y=Math.cos(e)*t,this.z=s*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=s,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const ec=new at,ef=new As;class Li{constructor(t,e,n,s,r,a,o,l,c){Li.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,a,o,l,c)}set(t,e,n,s,r,a,o,l,c){const h=this.elements;return h[0]=t,h[1]=s,h[2]=o,h[3]=e,h[4]=r,h[5]=l,h[6]=n,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,s=e.elements,r=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],h=n[4],u=n[7],d=n[2],f=n[5],m=n[8],x=s[0],_=s[3],p=s[6],w=s[1],S=s[4],y=s[7],E=s[2],v=s[5],A=s[8];return r[0]=a*x+o*w+l*E,r[3]=a*_+o*S+l*v,r[6]=a*p+o*y+l*A,r[1]=c*x+h*w+u*E,r[4]=c*_+h*S+u*v,r[7]=c*p+h*y+u*A,r[2]=d*x+f*w+m*E,r[5]=d*_+f*S+m*v,r[8]=d*p+f*y+m*A,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8];return e*a*h-e*o*c-n*r*h+n*o*l+s*r*c-s*a*l}invert(){const t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8],u=h*a-o*c,d=o*l-h*r,f=c*r-a*l,m=e*u+n*d+s*f;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/m;return t[0]=u*x,t[1]=(s*c-h*n)*x,t[2]=(o*n-s*a)*x,t[3]=d*x,t[4]=(h*e-s*l)*x,t[5]=(s*r-o*e)*x,t[6]=f*x,t[7]=(n*l-c*e)*x,t[8]=(a*e-n*r)*x,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,s,r,a,o){const l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*a+c*o)+a+t,-s*c,s*l,-s*(-c*a+l*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(nc.makeScale(t,e)),this}rotate(t){return this.premultiply(nc.makeRotation(-t)),this}translate(t,e){return this.premultiply(nc.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let s=0;s<9;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const nc=new Li,nf=new Li().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),sf=new Li().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function gb(){const i={enabled:!0,workingColorSpace:Yd,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===Ql&&(s.r=Ri(s.r),s.g=Ri(s.g),s.b=Ri(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Ql&&(s.r=yr(s.r),s.g=yr(s.g),s.b=yr(s.b))),s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===Np?qd:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return tf("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return tf("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(s,r)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Yd]:{primaries:t,whitePoint:n,transfer:qd,toXYZ:nf,fromXYZ:sf,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Wn},outputColorSpaceConfig:{drawingBufferColorSpace:Wn}},[Wn]:{primaries:t,whitePoint:n,transfer:Ql,toXYZ:nf,fromXYZ:sf,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Wn}}}),i}const Vn=gb();function Ri(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function yr(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let Qs;class vb{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{Qs===void 0&&(Qs=Jd("canvas")),Qs.width=t.width,Qs.height=t.height;const s=Qs.getContext("2d");t instanceof ImageData?s.putImageData(t,0,0):s.drawImage(t,0,0,t.width,t.height),n=Qs}return n.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=Jd("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const s=n.getImageData(0,0,t.width,t.height),r=s.data;for(let a=0;a<r.length;a++)r[a]=Ri(r[a]/255)*255;return n.putImageData(s,0,0),e}else if(t.data){const e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(Ri(e[n]/255)*255):e[n]=Ri(e[n]);return{data:e,width:t.width,height:t.height}}else return Ve("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let yb=0;class bb{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:yb++}),this.uuid=ya(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):e instanceof VideoFrame?t.set(e.displayHeight,e.displayWidth,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const n={uuid:this.uuid,url:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let a=0,o=s.length;a<o;a++)s[a].isDataTexture?r.push(ic(s[a].image)):r.push(ic(s[a]))}else r=ic(s);n.url=r}return e||(t.images[this.uuid]=n),n}}function ic(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?vb.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(Ve("Texture: Unable to serialize Texture."),{})}let Mb=0;const sc=new at;class Ms extends va{constructor(t=Ms.DEFAULT_IMAGE,e=Ms.DEFAULT_MAPPING,n=eo,s=eo,r=cb,a=hb,o=fb,l=ub,c=Ms.DEFAULT_ANISOTROPY,h=Np){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Mb++}),this.uuid=ya(),this.name="",this.source=new bb(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Pe(0,0),this.repeat=new Pe(1,1),this.center=new Pe(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Li,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(sc).x}get height(){return this.source.getSize(sc).y}get depth(){return this.source.getSize(sc).z}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const n=t[e];if(n===void 0){Ve(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const s=this[e];if(s===void 0){Ve(`Texture.setValues(): property '${e}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Lp)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Xd:t.x=t.x-Math.floor(t.x);break;case eo:t.x=t.x<0?0:1;break;case jd:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Xd:t.y=t.y-Math.floor(t.y);break;case eo:t.y=t.y<0?0:1;break;case jd:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}Ms.DEFAULT_IMAGE=null;Ms.DEFAULT_MAPPING=Lp;Ms.DEFAULT_ANISOTROPY=1;class ba{constructor(t=new at(1/0,1/0,1/0),e=new at(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(Hn.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(Hn.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=Hn.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(n!==void 0){const r=n.getAttribute("position");if(e===!0&&r!==void 0&&t.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)t.isMesh===!0?t.getVertexPosition(a,Hn):Hn.fromBufferAttribute(r,a),Hn.applyMatrix4(t.matrixWorld),this.expandByPoint(Hn);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),io.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),io.copy(n.boundingBox)),io.applyMatrix4(t.matrixWorld),this.union(io)}const s=t.children;for(let r=0,a=s.length;r<a;r++)this.expandByObject(s[r],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,Hn),Hn.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Yr),so.subVectors(this.max,Yr),tr.subVectors(t.a,Yr),er.subVectors(t.b,Yr),nr.subVectors(t.c,Yr),ki.subVectors(er,tr),Vi.subVectors(nr,er),ds.subVectors(tr,nr);let e=[0,-ki.z,ki.y,0,-Vi.z,Vi.y,0,-ds.z,ds.y,ki.z,0,-ki.x,Vi.z,0,-Vi.x,ds.z,0,-ds.x,-ki.y,ki.x,0,-Vi.y,Vi.x,0,-ds.y,ds.x,0];return!rc(e,tr,er,nr,so)||(e=[1,0,0,0,1,0,0,0,1],!rc(e,tr,er,nr,so))?!1:(ro.crossVectors(ki,Vi),e=[ro.x,ro.y,ro.z],rc(e,tr,er,nr,so))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Hn).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Hn).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(gi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),gi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),gi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),gi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),gi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),gi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),gi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),gi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(gi),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 gi=[new at,new at,new at,new at,new at,new at,new at,new at],Hn=new at,io=new ba,tr=new at,er=new at,nr=new at,ki=new at,Vi=new at,ds=new at,Yr=new at,so=new at,ro=new at,fs=new at;function rc(i,t,e,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){fs.fromArray(i,r);const o=s.x*Math.abs(fs.x)+s.y*Math.abs(fs.y)+s.z*Math.abs(fs.z),l=t.dot(fs),c=e.dot(fs),h=n.dot(fs);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const Sb=new ba,qr=new at,ac=new at;class Ip{constructor(t=new at,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;e!==void 0?n.copy(e):Sb.setFromPoints(t).getCenter(n);let s=0;for(let r=0,a=t.length;r<a;r++)s=Math.max(s,n.distanceToSquared(t[r]));return this.radius=Math.sqrt(s),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;qr.subVectors(t,this.center);const e=qr.lengthSq();if(e>this.radius*this.radius){const n=Math.sqrt(e),s=(n-this.radius)*.5;this.center.addScaledVector(qr,s/n),this.radius+=s}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(ac.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(qr.copy(t.center).add(ac)),this.expandByPoint(qr.copy(t.center).sub(ac))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}}const vi=new at,oc=new at,ao=new at,Hi=new at,lc=new at,oo=new at,cc=new at;class Up{constructor(t=new at,e=new at(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,vi)),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=vi.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(vi.copy(this.origin).addScaledVector(this.direction,e),vi.distanceToSquared(t))}distanceSqToSegment(t,e,n,s){oc.copy(t).add(e).multiplyScalar(.5),ao.copy(e).sub(t).normalize(),Hi.copy(this.origin).sub(oc);const r=t.distanceTo(e)*.5,a=-this.direction.dot(ao),o=Hi.dot(this.direction),l=-Hi.dot(ao),c=Hi.lengthSq(),h=Math.abs(1-a*a);let u,d,f,m;if(h>0)if(u=a*l-o,d=a*o-l,m=r*h,u>=0)if(d>=-m)if(d<=m){const x=1/h;u*=x,d*=x,f=u*(u+a*d+2*o)+d*(a*u+d+2*l)+c}else d=r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;else d=-r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;else d<=-m?(u=Math.max(0,-(-a*r+o)),d=u>0?-r:Math.min(Math.max(-r,-l),r),f=-u*u+d*(d+2*l)+c):d<=m?(u=0,d=Math.min(Math.max(-r,-l),r),f=d*(d+2*l)+c):(u=Math.max(0,-(a*r+o)),d=u>0?r:Math.min(Math.max(-r,-l),r),f=-u*u+d*(d+2*l)+c);else d=a>0?-r:r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),s&&s.copy(oc).addScaledVector(ao,d),f}intersectSphere(t,e){vi.subVectors(t.center,this.origin);const n=vi.dot(this.direction),s=vi.dot(vi)-n*n,r=t.radius*t.radius;if(s>r)return null;const a=Math.sqrt(r-s),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,e):this.at(o,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,s,r,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(t.min.x-d.x)*c,s=(t.max.x-d.x)*c):(n=(t.max.x-d.x)*c,s=(t.min.x-d.x)*c),h>=0?(r=(t.min.y-d.y)*h,a=(t.max.y-d.y)*h):(r=(t.max.y-d.y)*h,a=(t.min.y-d.y)*h),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a<s||isNaN(s))&&(s=a),u>=0?(o=(t.min.z-d.z)*u,l=(t.max.z-d.z)*u):(o=(t.max.z-d.z)*u,l=(t.min.z-d.z)*u),n>l||o>s)||((o>n||n!==n)&&(n=o),(l<s||s!==s)&&(s=l),s<0)?null:this.at(n>=0?n:s,e)}intersectsBox(t){return this.intersectBox(t,vi)!==null}intersectTriangle(t,e,n,s,r){lc.subVectors(e,t),oo.subVectors(n,t),cc.crossVectors(lc,oo);let a=this.direction.dot(cc),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Hi.subVectors(this.origin,t);const l=o*this.direction.dot(oo.crossVectors(Hi,oo));if(l<0)return null;const c=o*this.direction.dot(lc.cross(Hi));if(c<0||l+c>a)return null;const h=-o*Hi.dot(cc);return h<0?null:this.at(h/a,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class qn{constructor(t,e,n,s,r,a,o,l,c,h,u,d,f,m,x,_){qn.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,a,o,l,c,h,u,d,f,m,x,_)}set(t,e,n,s,r,a,o,l,c,h,u,d,f,m,x,_){const p=this.elements;return p[0]=t,p[4]=e,p[8]=n,p[12]=s,p[1]=r,p[5]=a,p[9]=o,p[13]=l,p[2]=c,p[6]=h,p[10]=u,p[14]=d,p[3]=f,p[7]=m,p[11]=x,p[15]=_,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 qn().fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,s=1/ir.setFromMatrixColumn(t,0).length(),r=1/ir.setFromMatrixColumn(t,1).length(),a=1/ir.setFromMatrixColumn(t,2).length();return e[0]=n[0]*s,e[1]=n[1]*s,e[2]=n[2]*s,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,s=t.y,r=t.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(s),c=Math.sin(s),h=Math.cos(r),u=Math.sin(r);if(t.order==="XYZ"){const d=a*h,f=a*u,m=o*h,x=o*u;e[0]=l*h,e[4]=-l*u,e[8]=c,e[1]=f+m*c,e[5]=d-x*c,e[9]=-o*l,e[2]=x-d*c,e[6]=m+f*c,e[10]=a*l}else if(t.order==="YXZ"){const d=l*h,f=l*u,m=c*h,x=c*u;e[0]=d+x*o,e[4]=m*o-f,e[8]=a*c,e[1]=a*u,e[5]=a*h,e[9]=-o,e[2]=f*o-m,e[6]=x+d*o,e[10]=a*l}else if(t.order==="ZXY"){const d=l*h,f=l*u,m=c*h,x=c*u;e[0]=d-x*o,e[4]=-a*u,e[8]=m+f*o,e[1]=f+m*o,e[5]=a*h,e[9]=x-d*o,e[2]=-a*c,e[6]=o,e[10]=a*l}else if(t.order==="ZYX"){const d=a*h,f=a*u,m=o*h,x=o*u;e[0]=l*h,e[4]=m*c-f,e[8]=d*c+x,e[1]=l*u,e[5]=x*c+d,e[9]=f*c-m,e[2]=-c,e[6]=o*l,e[10]=a*l}else if(t.order==="YZX"){const d=a*l,f=a*c,m=o*l,x=o*c;e[0]=l*h,e[4]=x-d*u,e[8]=m*u+f,e[1]=u,e[5]=a*h,e[9]=-o*h,e[2]=-c*h,e[6]=f*u+m,e[10]=d-x*u}else if(t.order==="XZY"){const d=a*l,f=a*c,m=o*l,x=o*c;e[0]=l*h,e[4]=-u,e[8]=c*h,e[1]=d*u+x,e[5]=a*h,e[9]=f*u-m,e[2]=m*u-f,e[6]=o*h,e[10]=x*u+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Eb,t,wb)}lookAt(t,e,n){const s=this.elements;return fn.subVectors(t,e),fn.lengthSq()===0&&(fn.z=1),fn.normalize(),Gi.crossVectors(n,fn),Gi.lengthSq()===0&&(Math.abs(n.z)===1?fn.x+=1e-4:fn.z+=1e-4,fn.normalize(),Gi.crossVectors(n,fn)),Gi.normalize(),lo.crossVectors(fn,Gi),s[0]=Gi.x,s[4]=lo.x,s[8]=fn.x,s[1]=Gi.y,s[5]=lo.y,s[9]=fn.y,s[2]=Gi.z,s[6]=lo.z,s[10]=fn.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,s=e.elements,r=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],h=n[1],u=n[5],d=n[9],f=n[13],m=n[2],x=n[6],_=n[10],p=n[14],w=n[3],S=n[7],y=n[11],E=n[15],v=s[0],A=s[4],R=s[8],M=s[12],g=s[1],O=s[5],F=s[9],k=s[13],G=s[2],K=s[6],tt=s[10],lt=s[14],$=s[3],st=s[7],ct=s[11],Et=s[15];return r[0]=a*v+o*g+l*G+c*$,r[4]=a*A+o*O+l*K+c*st,r[8]=a*R+o*F+l*tt+c*ct,r[12]=a*M+o*k+l*lt+c*Et,r[1]=h*v+u*g+d*G+f*$,r[5]=h*A+u*O+d*K+f*st,r[9]=h*R+u*F+d*tt+f*ct,r[13]=h*M+u*k+d*lt+f*Et,r[2]=m*v+x*g+_*G+p*$,r[6]=m*A+x*O+_*K+p*st,r[10]=m*R+x*F+_*tt+p*ct,r[14]=m*M+x*k+_*lt+p*Et,r[3]=w*v+S*g+y*G+E*$,r[7]=w*A+S*O+y*K+E*st,r[11]=w*R+S*F+y*tt+E*ct,r[15]=w*M+S*k+y*lt+E*Et,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],s=t[8],r=t[12],a=t[1],o=t[5],l=t[9],c=t[13],h=t[2],u=t[6],d=t[10],f=t[14],m=t[3],x=t[7],_=t[11],p=t[15];return m*(+r*l*u-s*c*u-r*o*d+n*c*d+s*o*f-n*l*f)+x*(+e*l*f-e*c*d+r*a*d-s*a*f+s*c*h-r*l*h)+_*(+e*c*u-e*o*f-r*a*u+n*a*f+r*o*h-n*c*h)+p*(-s*o*h-e*l*u+e*o*d+s*a*u-n*a*d+n*l*h)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],f=t[11],m=t[12],x=t[13],_=t[14],p=t[15],w=u*_*c-x*d*c+x*l*f-o*_*f-u*l*p+o*d*p,S=m*d*c-h*_*c-m*l*f+a*_*f+h*l*p-a*d*p,y=h*x*c-m*u*c+m*o*f-a*x*f-h*o*p+a*u*p,E=m*u*l-h*x*l-m*o*d+a*x*d+h*o*_-a*u*_,v=e*w+n*S+s*y+r*E;if(v===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const A=1/v;return t[0]=w*A,t[1]=(x*d*r-u*_*r-x*s*f+n*_*f+u*s*p-n*d*p)*A,t[2]=(o*_*r-x*l*r+x*s*c-n*_*c-o*s*p+n*l*p)*A,t[3]=(u*l*r-o*d*r-u*s*c+n*d*c+o*s*f-n*l*f)*A,t[4]=S*A,t[5]=(h*_*r-m*d*r+m*s*f-e*_*f-h*s*p+e*d*p)*A,t[6]=(m*l*r-a*_*r-m*s*c+e*_*c+a*s*p-e*l*p)*A,t[7]=(a*d*r-h*l*r+h*s*c-e*d*c-a*s*f+e*l*f)*A,t[8]=y*A,t[9]=(m*u*r-h*x*r-m*n*f+e*x*f+h*n*p-e*u*p)*A,t[10]=(a*x*r-m*o*r+m*n*c-e*x*c-a*n*p+e*o*p)*A,t[11]=(h*o*r-a*u*r-h*n*c+e*u*c+a*n*f-e*o*f)*A,t[12]=E*A,t[13]=(h*x*s-m*u*s+m*n*d-e*x*d-h*n*_+e*u*_)*A,t[14]=(m*o*s-a*x*s-m*n*l+e*x*l+a*n*_-e*o*_)*A,t[15]=(a*u*s-h*o*s+h*n*l-e*u*l-a*n*d+e*o*d)*A,this}scale(t){const e=this.elements,n=t.x,s=t.y,r=t.z;return e[0]*=n,e[4]*=s,e[8]*=r,e[1]*=n,e[5]*=s,e[9]*=r,e[2]*=n,e[6]*=s,e[10]*=r,e[3]*=n,e[7]*=s,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,s))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),s=Math.sin(e),r=1-n,a=t.x,o=t.y,l=t.z,c=r*a,h=r*o;return this.set(c*a+n,c*o-s*l,c*l+s*o,0,c*o+s*l,h*o+n,h*l-s*a,0,c*l-s*o,h*l+s*a,r*l*l+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,s,r,a){return this.set(1,n,r,0,t,1,a,0,e,s,1,0,0,0,0,1),this}compose(t,e,n){const s=this.elements,r=e._x,a=e._y,o=e._z,l=e._w,c=r+r,h=a+a,u=o+o,d=r*c,f=r*h,m=r*u,x=a*h,_=a*u,p=o*u,w=l*c,S=l*h,y=l*u,E=n.x,v=n.y,A=n.z;return s[0]=(1-(x+p))*E,s[1]=(f+y)*E,s[2]=(m-S)*E,s[3]=0,s[4]=(f-y)*v,s[5]=(1-(d+p))*v,s[6]=(_+w)*v,s[7]=0,s[8]=(m+S)*A,s[9]=(_-w)*A,s[10]=(1-(d+x))*A,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,n){const s=this.elements;let r=ir.set(s[0],s[1],s[2]).length();const a=ir.set(s[4],s[5],s[6]).length(),o=ir.set(s[8],s[9],s[10]).length();this.determinant()<0&&(r=-r),t.x=s[12],t.y=s[13],t.z=s[14],Gn.copy(this);const l=1/r,c=1/a,h=1/o;return Gn.elements[0]*=l,Gn.elements[1]*=l,Gn.elements[2]*=l,Gn.elements[4]*=c,Gn.elements[5]*=c,Gn.elements[6]*=c,Gn.elements[8]*=h,Gn.elements[9]*=h,Gn.elements[10]*=h,e.setFromRotationMatrix(Gn),n.x=r,n.y=a,n.z=o,this}makePerspective(t,e,n,s,r,a,o=no,l=!1){const c=this.elements,h=2*r/(e-t),u=2*r/(n-s),d=(e+t)/(e-t),f=(n+s)/(n-s);let m,x;if(l)m=r/(a-r),x=a*r/(a-r);else if(o===no)m=-(a+r)/(a-r),x=-2*a*r/(a-r);else if(o===Kd)m=-a/(a-r),x=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,n,s,r,a,o=no,l=!1){const c=this.elements,h=2/(e-t),u=2/(n-s),d=-(e+t)/(e-t),f=-(n+s)/(n-s);let m,x;if(l)m=1/(a-r),x=a/(a-r);else if(o===no)m=-2/(a-r),x=-(a+r)/(a-r);else if(o===Kd)m=-1/(a-r),x=-r/(a-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=m,c[14]=x,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let s=0;s<16;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const ir=new at,Gn=new qn,Eb=new at(0,0,0),wb=new at(1,1,1),Gi=new at,lo=new at,fn=new at,rf=new qn,af=new As;class al{constructor(t=0,e=0,n=0,s=al.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,s=this._order){return this._x=t,this._y=e,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const s=t.elements,r=s[0],a=s[4],o=s[8],l=s[1],c=s[5],h=s[9],u=s[2],d=s[6],f=s[10];switch(e){case"XYZ":this._y=Math.asin(oe(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-oe(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(oe(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-oe(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(oe(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-oe(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,f),this._y=0);break;default:Ve("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return rf.makeRotationFromQuaternion(t),this.setFromRotationMatrix(rf,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return af.setFromEuler(this),this.setFromQuaternion(af,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}al.DEFAULT_ORDER="XYZ";class Tb{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let Ab=0;const of=new at,sr=new As,yi=new qn,co=new at,Zr=new at,Cb=new at,Rb=new As,lf=new at(1,0,0),cf=new at(0,1,0),hf=new at(0,0,1),uf={type:"added"},Pb={type:"removed"},rr={type:"childadded",child:null},hc={type:"childremoved",child:null};class li extends va{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Ab++}),this.uuid=ya(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=li.DEFAULT_UP.clone();const t=new at,e=new al,n=new As,s=new at(1,1,1);function r(){n.setFromEuler(e,!1)}function a(){e.setFromQuaternion(n,void 0,!1)}e._onChange(r),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new qn},normalMatrix:{value:new Li}}),this.matrix=new qn,this.matrixWorld=new qn,this.matrixAutoUpdate=li.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=li.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Tb,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return sr.setFromAxisAngle(t,e),this.quaternion.multiply(sr),this}rotateOnWorldAxis(t,e){return sr.setFromAxisAngle(t,e),this.quaternion.premultiply(sr),this}rotateX(t){return this.rotateOnAxis(lf,t)}rotateY(t){return this.rotateOnAxis(cf,t)}rotateZ(t){return this.rotateOnAxis(hf,t)}translateOnAxis(t,e){return of.copy(t).applyQuaternion(this.quaternion),this.position.add(of.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(lf,t)}translateY(t){return this.translateOnAxis(cf,t)}translateZ(t){return this.translateOnAxis(hf,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(yi.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?co.copy(t):co.set(t,e,n);const s=this.parent;this.updateWorldMatrix(!0,!1),Zr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?yi.lookAt(Zr,co,this.up):yi.lookAt(co,Zr,this.up),this.quaternion.setFromRotationMatrix(yi),s&&(yi.extractRotation(s.matrixWorld),sr.setFromRotationMatrix(yi),this.quaternion.premultiply(sr.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(vs("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(uf),rr.child=t,this.dispatchEvent(rr),rr.child=null):vs("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Pb),hc.child=t,this.dispatchEvent(hc),hc.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),yi.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),yi.multiply(t.parent.matrixWorld)),t.applyMatrix4(yi),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(uf),rr.child=t,this.dispatchEvent(rr),rr.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,s=this.children.length;n<s;n++){const r=this.children[n].getObjectByProperty(t,e);if(r!==void 0)return r}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Zr,t,Cb),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Zr,Rb,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e){const n=this.parent;if(t===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){const s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(t),s.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(t.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const u=l[c];r(t.shapes,u)}else r(t.shapes,l)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(t.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(r(t.materials,this.material[l]));s.material=o}else s.material=r(t.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];s.animations.push(r(t.animations,l))}}if(e){const o=a(t.geometries),l=a(t.materials),c=a(t.textures),h=a(t.images),u=a(t.shapes),d=a(t.skeletons),f=a(t.animations),m=a(t.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),m.length>0&&(n.nodes=m)}return n.object=s,n;function a(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){const s=t.children[n];this.add(s.clone())}return this}}li.DEFAULT_UP=new at(0,1,0);li.DEFAULT_MATRIX_AUTO_UPDATE=!0;li.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Fp={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Wi={h:0,s:0,l:0},ho={h:0,s:0,l:0};function uc(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+(t-i)*6*e:e<1/2?t:e<2/3?i+(t-i)*6*(2/3-e):i}class ol{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){const s=t;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Wn){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Vn.colorSpaceToWorking(this,e),this}setRGB(t,e,n,s=Vn.workingColorSpace){return this.r=t,this.g=e,this.b=n,Vn.colorSpaceToWorking(this,s),this}setHSL(t,e,n,s=Vn.workingColorSpace){if(t=_b(t,1),e=oe(e,0,1),n=oe(n,0,1),e===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+e):n+e-n*e,a=2*n-r;this.r=uc(a,r,t+1/3),this.g=uc(a,r,t),this.b=uc(a,r,t-1/3)}return Vn.colorSpaceToWorking(this,s),this}setStyle(t,e=Wn){function n(r){r!==void 0&&parseFloat(r)<1&&Ve("Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:Ve("Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){const r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(r,16),e);Ve("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Wn){const n=Fp[t.toLowerCase()];return n!==void 0?this.setHex(n,e):Ve("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=Ri(t.r),this.g=Ri(t.g),this.b=Ri(t.b),this}copyLinearToSRGB(t){return this.r=yr(t.r),this.g=yr(t.g),this.b=yr(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Wn){return Vn.workingToColorSpace(qe.copy(this),t),Math.round(oe(qe.r*255,0,255))*65536+Math.round(oe(qe.g*255,0,255))*256+Math.round(oe(qe.b*255,0,255))}getHexString(t=Wn){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Vn.workingColorSpace){Vn.workingToColorSpace(qe.copy(this),e);const n=qe.r,s=qe.g,r=qe.b,a=Math.max(n,s,r),o=Math.min(n,s,r);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const u=a-o;switch(c=h<=.5?u/(a+o):u/(2-a-o),a){case n:l=(s-r)/u+(s<r?6:0);break;case s:l=(r-n)/u+2;break;case r:l=(n-s)/u+4;break}l/=6}return t.h=l,t.s=c,t.l=h,t}getRGB(t,e=Vn.workingColorSpace){return Vn.workingToColorSpace(qe.copy(this),e),t.r=qe.r,t.g=qe.g,t.b=qe.b,t}getStyle(t=Wn){Vn.workingToColorSpace(qe.copy(this),t);const e=qe.r,n=qe.g,s=qe.b;return t!==Wn?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(t,e,n){return this.getHSL(Wi),this.setHSL(Wi.h+t,Wi.s+e,Wi.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(Wi),t.getHSL(ho);const n=tc(Wi.h,ho.h,e),s=tc(Wi.s,ho.s,e),r=tc(Wi.l,ho.l,e);return this.setHSL(n,s,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,s=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*s,this.g=r[1]*e+r[4]*n+r[7]*s,this.b=r[2]*e+r[5]*n+r[8]*s,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const qe=new ol;ol.NAMES=Fp;let Db=0;class Ob extends va{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Db++}),this.uuid=ya(),this.name="",this.type="Material",this.blending=kd,this.side=Bd,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Hd,this.blendDst=Gd,this.blendEquation=Vd,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ol(0,0,0),this.blendAlpha=0,this.depthFunc=Wd,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Zd,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Js,this.stencilZFail=Js,this.stencilZPass=Js,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const n=t[e];if(n===void 0){Ve(`Material: parameter '${e}' has value of undefined.`);continue}const s=this[e];if(s===void 0){Ve(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==kd&&(n.blending=this.blending),this.side!==Bd&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Hd&&(n.blendSrc=this.blendSrc),this.blendDst!==Gd&&(n.blendDst=this.blendDst),this.blendEquation!==Vd&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Wd&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Zd&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Js&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Js&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Js&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(e){const r=s(t.textures),a=s(t.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(e!==null){const s=e.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}}const Re=new at,uo=new Pe;let Lb=0;class br{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Lb++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=$d,this.updateRanges=[],this.gpuType=db,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let s=0,r=this.itemSize;s<r;s++)this.array[t+s]=e.array[n+s];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)uo.fromBufferAttribute(this,e),uo.applyMatrix3(t),this.setXY(e,uo.x,uo.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)Re.fromBufferAttribute(this,e),Re.applyMatrix3(t),this.setXYZ(e,Re.x,Re.y,Re.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)Re.fromBufferAttribute(this,e),Re.applyMatrix4(t),this.setXYZ(e,Re.x,Re.y,Re.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Re.fromBufferAttribute(this,e),Re.applyNormalMatrix(t),this.setXYZ(e,Re.x,Re.y,Re.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Re.fromBufferAttribute(this,e),Re.transformDirection(t),this.setXYZ(e,Re.x,Re.y,Re.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=jr(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=nn(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=jr(e,this.array)),e}setX(t,e){return this.normalized&&(e=nn(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=jr(e,this.array)),e}setY(t,e){return this.normalized&&(e=nn(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=jr(e,this.array)),e}setZ(t,e){return this.normalized&&(e=nn(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=jr(e,this.array)),e}setW(t,e){return this.normalized&&(e=nn(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=nn(e,this.array),n=nn(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,s){return t*=this.itemSize,this.normalized&&(e=nn(e,this.array),n=nn(n,this.array),s=nn(s,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=s,this}setXYZW(t,e,n,s,r){return t*=this.itemSize,this.normalized&&(e=nn(e,this.array),n=nn(n,this.array),s=nn(s,this.array),r=nn(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=s,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==$d&&(t.usage=this.usage),t}}class Nb extends br{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class Ib extends br{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class zp extends br{constructor(t,e,n){super(new Float32Array(t),e,n)}}let Ub=0;const wn=new qn,dc=new li,ar=new at,pn=new ba,$r=new ba,ze=new at;class ll extends va{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ub++}),this.uuid=ya(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(pb(t)?Ib:Nb)(t,1):this.index=t,this}setIndirect(t){return this.indirect=t,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new Li().getNormalMatrix(t);n.applyNormalMatrix(r),n.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(t),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return wn.makeRotationFromQuaternion(t),this.applyMatrix4(wn),this}rotateX(t){return wn.makeRotationX(t),this.applyMatrix4(wn),this}rotateY(t){return wn.makeRotationY(t),this.applyMatrix4(wn),this}rotateZ(t){return wn.makeRotationZ(t),this.applyMatrix4(wn),this}translate(t,e,n){return wn.makeTranslation(t,e,n),this.applyMatrix4(wn),this}scale(t,e,n){return wn.makeScale(t,e,n),this.applyMatrix4(wn),this}lookAt(t){return dc.lookAt(t),dc.updateMatrix(),this.applyMatrix4(dc.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ar).negate(),this.translate(ar.x,ar.y,ar.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const n=[];for(let s=0,r=t.length;s<r;s++){const a=t[s];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new zp(n,3))}else{const n=Math.min(t.length,e.count);for(let s=0;s<n;s++){const r=t[s];e.setXYZ(s,r.x,r.y,r.z||0)}t.length>e.count&&Ve("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ba);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){vs("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new at(-1/0,-1/0,-1/0),new at(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,s=e.length;n<s;n++){const r=e[n];pn.setFromBufferAttribute(r),this.morphTargetsRelative?(ze.addVectors(this.boundingBox.min,pn.min),this.boundingBox.expandByPoint(ze),ze.addVectors(this.boundingBox.max,pn.max),this.boundingBox.expandByPoint(ze)):(this.boundingBox.expandByPoint(pn.min),this.boundingBox.expandByPoint(pn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&vs('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ip);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){vs("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new at,1/0);return}if(t){const n=this.boundingSphere.center;if(pn.setFromBufferAttribute(t),e)for(let r=0,a=e.length;r<a;r++){const o=e[r];$r.setFromBufferAttribute(o),this.morphTargetsRelative?(ze.addVectors(pn.min,$r.min),pn.expandByPoint(ze),ze.addVectors(pn.max,$r.max),pn.expandByPoint(ze)):(pn.expandByPoint($r.min),pn.expandByPoint($r.max))}pn.getCenter(n);let s=0;for(let r=0,a=t.count;r<a;r++)ze.fromBufferAttribute(t,r),s=Math.max(s,n.distanceToSquared(ze));if(e)for(let r=0,a=e.length;r<a;r++){const o=e[r],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)ze.fromBufferAttribute(o,c),l&&(ar.fromBufferAttribute(t,c),ze.add(ar)),s=Math.max(s,n.distanceToSquared(ze))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&vs('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){vs("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.position,s=e.normal,r=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new br(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let R=0;R<n.count;R++)o[R]=new at,l[R]=new at;const c=new at,h=new at,u=new at,d=new Pe,f=new Pe,m=new Pe,x=new at,_=new at;function p(R,M,g){c.fromBufferAttribute(n,R),h.fromBufferAttribute(n,M),u.fromBufferAttribute(n,g),d.fromBufferAttribute(r,R),f.fromBufferAttribute(r,M),m.fromBufferAttribute(r,g),h.sub(c),u.sub(c),f.sub(d),m.sub(d);const O=1/(f.x*m.y-m.x*f.y);isFinite(O)&&(x.copy(h).multiplyScalar(m.y).addScaledVector(u,-f.y).multiplyScalar(O),_.copy(u).multiplyScalar(f.x).addScaledVector(h,-m.x).multiplyScalar(O),o[R].add(x),o[M].add(x),o[g].add(x),l[R].add(_),l[M].add(_),l[g].add(_))}let w=this.groups;w.length===0&&(w=[{start:0,count:t.count}]);for(let R=0,M=w.length;R<M;++R){const g=w[R],O=g.start,F=g.count;for(let k=O,G=O+F;k<G;k+=3)p(t.getX(k+0),t.getX(k+1),t.getX(k+2))}const S=new at,y=new at,E=new at,v=new at;function A(R){E.fromBufferAttribute(s,R),v.copy(E);const M=o[R];S.copy(M),S.sub(E.multiplyScalar(E.dot(M))).normalize(),y.crossVectors(v,M);const g=y.dot(l[R])<0?-1:1;a.setXYZW(R,S.x,S.y,S.z,g)}for(let R=0,M=w.length;R<M;++R){const g=w[R],O=g.start,F=g.count;for(let k=O,G=O+F;k<G;k+=3)A(t.getX(k+0)),A(t.getX(k+1)),A(t.getX(k+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new br(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);const s=new at,r=new at,a=new at,o=new at,l=new at,c=new at,h=new at,u=new at;if(t)for(let d=0,f=t.count;d<f;d+=3){const m=t.getX(d+0),x=t.getX(d+1),_=t.getX(d+2);s.fromBufferAttribute(e,m),r.fromBufferAttribute(e,x),a.fromBufferAttribute(e,_),h.subVectors(a,r),u.subVectors(s,r),h.cross(u),o.fromBufferAttribute(n,m),l.fromBufferAttribute(n,x),c.fromBufferAttribute(n,_),o.add(h),l.add(h),c.add(h),n.setXYZ(m,o.x,o.y,o.z),n.setXYZ(x,l.x,l.y,l.z),n.setXYZ(_,c.x,c.y,c.z)}else for(let d=0,f=e.count;d<f;d+=3)s.fromBufferAttribute(e,d+0),r.fromBufferAttribute(e,d+1),a.fromBufferAttribute(e,d+2),h.subVectors(a,r),u.subVectors(s,r),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)ze.fromBufferAttribute(t,e),ze.normalize(),t.setXYZ(e,ze.x,ze.y,ze.z)}toNonIndexed(){function t(o,l){const c=o.array,h=o.itemSize,u=o.normalized,d=new c.constructor(l.length*h);let f=0,m=0;for(let x=0,_=l.length;x<_;x++){o.isInterleavedBufferAttribute?f=l[x]*o.data.stride+o.offset:f=l[x]*h;for(let p=0;p<h;p++)d[m++]=c[f++]}return new br(d,h,u)}if(this.index===null)return Ve("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new ll,n=this.index.array,s=this.attributes;for(const o in s){const l=s[o],c=t(l,n);e.setAttribute(o,c)}const r=this.morphAttributes;for(const o in r){const l=[],c=r[o];for(let h=0,u=c.length;h<u;h++){const d=c[h],f=t(d,n);l.push(f)}e.morphAttributes[o]=l}e.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];e.addGroup(c.start,c.count,c.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(t[c]=l[c]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const l in n){const c=n[l];t.data.attributes[l]=c.toJSON(t.data)}const s={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let u=0,d=c.length;u<d;u++){const f=c[u];h.push(f.toJSON(t.data))}h.length>0&&(s[l]=h,r=!0)}r&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(t.data.boundingSphere=o.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;n!==null&&this.setIndex(n.clone());const s=t.attributes;for(const c in s){const h=s[c];this.setAttribute(c,h.clone(e))}const r=t.morphAttributes;for(const c in r){const h=[],u=r[c];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(e));this.morphAttributes[c]=h}this.morphTargetsRelative=t.morphTargetsRelative;const a=t.groups;for(let c=0,h=a.length;c<h;c++){const u=a[c];this.addGroup(u.start,u.count,u.materialIndex)}const o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=t.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Fb extends li{constructor(){super(),this.isGroup=!0,this.type="Group"}}const fc=new at,zb=new at,Bb=new Li;class kb{constructor(t=new at(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,s){return this.normal.set(t,e,n),this.constant=s,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const s=fc.subVectors(n,e).cross(zb.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(s,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const n=t.delta(fc),s=this.normal.dot(n);if(s===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const r=-(t.start.dot(this.normal)+this.constant)/s;return r<0||r>1?null:e.copy(t.start).addScaledVector(n,r)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||Bb.getNormalMatrix(t),s=this.coplanarPoint(fc).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}class Bp extends Ob{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ol(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 ko=new at,Vo=new at,df=new qn,Kr=new Up,fo=new Ip,pc=new at,ff=new at;class Vb extends li{constructor(t=new ll,e=new Bp){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(t.index===null){const e=t.attributes.position,n=[0];for(let s=1,r=e.count;s<r;s++)ko.fromBufferAttribute(e,s-1),Vo.fromBufferAttribute(e,s),n[s]=n[s-1],n[s]+=ko.distanceTo(Vo);t.setAttribute("lineDistance",new zp(n,1))}else Ve("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const n=this.geometry,s=this.matrixWorld,r=t.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),fo.copy(n.boundingSphere),fo.applyMatrix4(s),fo.radius+=r,t.ray.intersectsSphere(fo)===!1)return;df.copy(s).invert(),Kr.copy(t.ray).applyMatrix4(df);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,h=n.index,u=n.attributes.position;if(h!==null){const d=Math.max(0,a.start),f=Math.min(h.count,a.start+a.count);for(let m=d,x=f-1;m<x;m+=c){const _=h.getX(m),p=h.getX(m+1),w=po(this,t,Kr,l,_,p,m);w&&e.push(w)}if(this.isLineLoop){const m=h.getX(f-1),x=h.getX(d),_=po(this,t,Kr,l,m,x,f-1);_&&e.push(_)}}else{const d=Math.max(0,a.start),f=Math.min(u.count,a.start+a.count);for(let m=d,x=f-1;m<x;m+=c){const _=po(this,t,Kr,l,m,m+1,m);_&&e.push(_)}if(this.isLineLoop){const m=po(this,t,Kr,l,f-1,d,f-1);m&&e.push(m)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=n.length;s<r;s++){const a=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}}function po(i,t,e,n,s,r,a){const o=i.geometry.attributes.position;if(ko.fromBufferAttribute(o,s),Vo.fromBufferAttribute(o,r),e.distanceSqToSegment(ko,Vo,pc,ff)>n)return;pc.applyMatrix4(i.matrixWorld);const l=t.ray.origin.distanceTo(pc);if(!(l<t.near||l>t.far))return{distance:l,point:ff.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}class pf{constructor(t=1,e=0,n=0){this.radius=t,this.phi=e,this.theta=n}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=oe(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(oe(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class Hb extends va{constructor(t,e=null){super(),this.object=t,this.domElement=e,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(t){if(t===void 0){Ve("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=t}disconnect(){}dispose(){}update(){}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"181"}}));typeof window<"u"&&(window.__THREE__?Ve("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="181");const mf={type:"change"},ou={type:"start"},kp={type:"end"},mo=new Up,_f=new kb,Gb=Math.cos(70*xb.DEG2RAD),Oe=new at,sn=2*Math.PI,le={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},mc=1e-6;class Wb extends Hb{constructor(t,e=null){super(t,e),this.state=le.NONE,this.target=new at,this.cursor=new at,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:vr.ROTATE,MIDDLE:vr.DOLLY,RIGHT:vr.PAN},this.touches={ONE:hr.ROTATE,TWO:hr.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new at,this._lastQuaternion=new As,this._lastTargetPosition=new at,this._quat=new As().setFromUnitVectors(t.up,new at(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new pf,this._sphericalDelta=new pf,this._scale=1,this._panOffset=new at,this._rotateStart=new Pe,this._rotateEnd=new Pe,this._rotateDelta=new Pe,this._panStart=new Pe,this._panEnd=new Pe,this._panDelta=new Pe,this._dollyStart=new Pe,this._dollyEnd=new Pe,this._dollyDelta=new Pe,this._dollyDirection=new at,this._mouse=new Pe,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=jb.bind(this),this._onPointerDown=Xb.bind(this),this._onPointerUp=Yb.bind(this),this._onContextMenu=tM.bind(this),this._onMouseWheel=$b.bind(this),this._onKeyDown=Kb.bind(this),this._onTouchStart=Jb.bind(this),this._onTouchMove=Qb.bind(this),this._onMouseDown=qb.bind(this),this._onMouseMove=Zb.bind(this),this._interceptControlDown=eM.bind(this),this._interceptControlUp=nM.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(t){super.connect(t),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(t){t.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=t}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(mf),this.update(),this.state=le.NONE}update(t=null){const e=this.object.position;Oe.copy(e).sub(this.target),Oe.applyQuaternion(this._quat),this._spherical.setFromVector3(Oe),this.autoRotate&&this.state===le.NONE&&this._rotateLeft(this._getAutoRotationAngle(t)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(n)&&isFinite(s)&&(n<-Math.PI?n+=sn:n>Math.PI&&(n-=sn),s<-Math.PI?s+=sn:s>Math.PI&&(s-=sn),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(Oe.setFromSpherical(this._spherical),Oe.applyQuaternion(this._quatInverse),e.copy(this.target).add(Oe),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=Oe.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const o=new at(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new at(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=Oe.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(mo.origin.copy(this.object.position),mo.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(mo.direction))<Gb?this.object.lookAt(this.target):(_f.setFromNormalAndCoplanarPoint(this.object.up,this.target),mo.intersectPlane(_f,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>mc||8*(1-this._lastQuaternion.dot(this.object.quaternion))>mc||this._lastTargetPosition.distanceToSquared(this.target)>mc?(this.dispatchEvent(mf),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(t){return t!==null?sn/60*this.autoRotateSpeed*t:sn/60/60*this.autoRotateSpeed}_getZoomScale(t){const e=Math.abs(t*.01);return Math.pow(.95,this.zoomSpeed*e)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,e){Oe.setFromMatrixColumn(e,0),Oe.multiplyScalar(-t),this._panOffset.add(Oe)}_panUp(t,e){this.screenSpacePanning===!0?Oe.setFromMatrixColumn(e,1):(Oe.setFromMatrixColumn(e,0),Oe.crossVectors(this.object.up,Oe)),Oe.multiplyScalar(t),this._panOffset.add(Oe)}_pan(t,e){const n=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;Oe.copy(s).sub(this.target);let r=Oe.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*r/n.clientHeight,this.object.matrix),this._panUp(2*e*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(t,e){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),s=t-n.left,r=e-n.top,a=n.width,o=n.height;this._mouse.x=s/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(sn*this._rotateDelta.x/e.clientHeight),this._rotateUp(sn*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(t){this._panEnd.set(t.clientX,t.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let e=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(sn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(-sn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(sn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(-sn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),e=!0;break}e&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(this._pointers.length===1)this._rotateStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(t){if(this._pointers.length===1)this._panStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._panStart.set(n,s)}}_handleTouchStartDolly(t){const e=this._getSecondPointerPosition(t),n=t.pageX-e.x,s=t.pageY-e.y,r=Math.sqrt(n*n+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(this._pointers.length==1)this._rotateEnd.set(t.pageX,t.pageY);else{const n=this._getSecondPointerPosition(t),s=.5*(t.pageX+n.x),r=.5*(t.pageY+n.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(sn*this._rotateDelta.x/e.clientHeight),this._rotateUp(sn*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(this._pointers.length===1)this._panEnd.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(t){const e=this._getSecondPointerPosition(t),n=t.pageX-e.x,s=t.pageY-e.y,r=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(t.pageX+e.x)*.5,o=(t.pageY+e.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId){this._pointers.splice(e,1);return}}_isTrackingPointer(t){for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId)return!0;return!1}_trackPointer(t){let e=this._pointerPositions[t.pointerId];e===void 0&&(e=new Pe,this._pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}_getSecondPointerPosition(t){const e=t.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[e]}_customWheelEvent(t){const e=t.deltaMode,n={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(e){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return t.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function Xb(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i)))}function jb(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function Yb(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(kp),this.state=le.NONE;break;case 1:const t=this._pointers[0],e=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:e.x,pageY:e.y});break}}function qb(i){let t;switch(i.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case vr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=le.DOLLY;break;case vr.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=le.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=le.ROTATE}break;case vr.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=le.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=le.PAN}break;default:this.state=le.NONE}this.state!==le.NONE&&this.dispatchEvent(ou)}function Zb(i){switch(this.state){case le.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case le.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case le.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function $b(i){this.enabled===!1||this.enableZoom===!1||this.state!==le.NONE||(i.preventDefault(),this.dispatchEvent(ou),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(kp))}function Kb(i){this.enabled!==!1&&this._handleKeyDown(i)}function Jb(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case hr.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=le.TOUCH_ROTATE;break;case hr.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=le.TOUCH_PAN;break;default:this.state=le.NONE}break;case 2:switch(this.touches.TWO){case hr.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=le.TOUCH_DOLLY_PAN;break;case hr.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=le.TOUCH_DOLLY_ROTATE;break;default:this.state=le.NONE}break;default:this.state=le.NONE}this.state!==le.NONE&&this.dispatchEvent(ou)}function Qb(i){switch(this._trackPointer(i),this.state){case le.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case le.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case le.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case le.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=le.NONE}}function tM(i){this.enabled!==!1&&i.preventDefault()}function eM(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function nM(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class iM extends Wb{isInteracting=!1;constructor(t,e){super(t,e),this.domElement?.addEventListener("mousedown",()=>this.isInteracting=!0),this.domElement?.addEventListener("mouseup",()=>this.isInteracting=!1),this.domElement?.addEventListener("touchstart",()=>this.isInteracting=!0),this.domElement?.addEventListener("touchend",()=>this.isInteracting=!1)}dispose(){this.domElement?.removeEventListener("mousedown",()=>this.isInteracting=!0),this.domElement?.removeEventListener("mouseup",()=>this.isInteracting=!1),this.domElement?.removeEventListener("touchstart",()=>this.isInteracting=!0),this.domElement?.removeEventListener("touchend",()=>this.isInteracting=!1)}[Symbol.dispose](){this.dispose()}}class sM extends Fb{constructor(t=5){super();const e=[{dir:new at(1,0,0),color:16711680},{dir:new at(-1,0,0),color:16711680},{dir:new at(0,1,0),color:65280},{dir:new at(0,-1,0),color:65280},{dir:new at(0,0,1),color:255},{dir:new at(0,0,-1),color:255}];for(const{dir:n,color:s}of e){const r=new ll().setFromPoints([new at(0,0,0),n.clone().multiplyScalar(t)]),a=new Bp({color:s}),o=new Vb(r,a);this.add(o)}}}const ps=new wp,Ze=new I,Xi=new I,xe=new ke,xf={X:new I(1,0,0),Y:new I(0,1,0),Z:new I(0,0,1)},_c={type:"change"},gf={type:"mouseDown",mode:null},vf={type:"mouseUp",mode:null},yf={type:"objectChange"};class rM extends Tp{constructor(t,e=null){super(void 0,e);const n=new uM(this);this._root=n;const s=new dM;this._gizmo=s,n.add(s);const r=new fM;this._plane=r,n.add(r);const a=this;function o(S,y){let E=y;Object.defineProperty(a,S,{get:function(){return E!==void 0?E:y},set:function(v){E!==v&&(E=v,r[S]=v,s[S]=v,a.dispatchEvent({type:S+"-changed",value:v}),a.dispatchEvent(_c))}}),a[S]=y,r[S]=y,s[S]=y}o("camera",t),o("object",void 0),o("enabled",!0),o("axis",null),o("mode","translate"),o("translationSnap",null),o("rotationSnap",null),o("scaleSnap",null),o("space","world"),o("size",1),o("dragging",!1),o("showX",!0),o("showY",!0),o("showZ",!0),o("minX",-1/0),o("maxX",1/0),o("minY",-1/0),o("maxY",1/0),o("minZ",-1/0),o("maxZ",1/0);const l=new I,c=new I,h=new ke,u=new ke,d=new I,f=new ke,m=new I,x=new I,_=new I,p=0,w=new I;o("worldPosition",l),o("worldPositionStart",c),o("worldQuaternion",h),o("worldQuaternionStart",u),o("cameraPosition",d),o("cameraQuaternion",f),o("pointStart",m),o("pointEnd",x),o("rotationAxis",_),o("rotationAngle",p),o("eye",w),this._offset=new I,this._startNorm=new I,this._endNorm=new I,this._cameraScale=new I,this._parentPosition=new I,this._parentQuaternion=new ke,this._parentQuaternionInv=new ke,this._parentScale=new I,this._worldScaleStart=new I,this._worldQuaternionInv=new ke,this._worldScale=new I,this._positionStart=new I,this._quaternionStart=new ke,this._scaleStart=new I,this._getPointer=aM.bind(this),this._onPointerDown=lM.bind(this),this._onPointerHover=oM.bind(this),this._onPointerMove=cM.bind(this),this._onPointerUp=hM.bind(this),e!==null&&this.connect(e)}connect(t){super.connect(t),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(t){if(this.object===void 0||this.dragging===!0)return;t!==null&&ps.setFromCamera(t,this.camera);const e=xc(this._gizmo.picker[this.mode],ps);e?this.axis=e.object.name:this.axis=null}pointerDown(t){if(!(this.object===void 0||this.dragging===!0||t!=null&&t.button!==0)&&this.axis!==null){t!==null&&ps.setFromCamera(t,this.camera);const e=xc(this._plane,ps,!0);e&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(e.point).sub(this.worldPositionStart)),this.dragging=!0,gf.mode=this.mode,this.dispatchEvent(gf)}}pointerMove(t){const e=this.axis,n=this.mode,s=this.object;let r=this.space;if(n==="scale"?r="local":(e==="E"||e==="XYZE"||e==="XYZ")&&(r="world"),s===void 0||e===null||this.dragging===!1||t!==null&&t.button!==-1)return;t!==null&&ps.setFromCamera(t,this.camera);const a=xc(this._plane,ps,!0);if(a){if(this.pointEnd.copy(a.point).sub(this.worldPositionStart),n==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),r==="local"&&e!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),e.indexOf("X")===-1&&(this._offset.x=0),e.indexOf("Y")===-1&&(this._offset.y=0),e.indexOf("Z")===-1&&(this._offset.z=0),r==="local"&&e!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),s.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(r==="local"&&(s.position.applyQuaternion(xe.copy(this._quaternionStart).invert()),e.search("X")!==-1&&(s.position.x=Math.round(s.position.x/this.translationSnap)*this.translationSnap),e.search("Y")!==-1&&(s.position.y=Math.round(s.position.y/this.translationSnap)*this.translationSnap),e.search("Z")!==-1&&(s.position.z=Math.round(s.position.z/this.translationSnap)*this.translationSnap),s.position.applyQuaternion(this._quaternionStart)),r==="world"&&(s.parent&&s.position.add(Ze.setFromMatrixPosition(s.parent.matrixWorld)),e.search("X")!==-1&&(s.position.x=Math.round(s.position.x/this.translationSnap)*this.translationSnap),e.search("Y")!==-1&&(s.position.y=Math.round(s.position.y/this.translationSnap)*this.translationSnap),e.search("Z")!==-1&&(s.position.z=Math.round(s.position.z/this.translationSnap)*this.translationSnap),s.parent&&s.position.sub(Ze.setFromMatrixPosition(s.parent.matrixWorld)))),s.position.x=Math.max(this.minX,Math.min(this.maxX,s.position.x)),s.position.y=Math.max(this.minY,Math.min(this.maxY,s.position.y)),s.position.z=Math.max(this.minZ,Math.min(this.maxZ,s.position.z));else if(n==="scale"){if(e.search("XYZ")!==-1){let o=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(o*=-1),Xi.set(o,o,o)}else Ze.copy(this.pointStart),Xi.copy(this.pointEnd),Ze.applyQuaternion(this._worldQuaternionInv),Xi.applyQuaternion(this._worldQuaternionInv),Xi.divide(Ze),e.search("X")===-1&&(Xi.x=1),e.search("Y")===-1&&(Xi.y=1),e.search("Z")===-1&&(Xi.z=1);s.scale.copy(this._scaleStart).multiply(Xi),this.scaleSnap&&(e.search("X")!==-1&&(s.scale.x=Math.round(s.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),e.search("Y")!==-1&&(s.scale.y=Math.round(s.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),e.search("Z")!==-1&&(s.scale.z=Math.round(s.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(n==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const o=20/this.worldPosition.distanceTo(Ze.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;e==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(Ze.copy(this.rotationAxis).cross(this.eye))*o):(e==="X"||e==="Y"||e==="Z")&&(this.rotationAxis.copy(xf[e]),Ze.copy(xf[e]),r==="local"&&Ze.applyQuaternion(this.worldQuaternion),Ze.cross(this.eye),Ze.length()===0?l=!0:this.rotationAngle=this._offset.dot(Ze.normalize())*o),(e==="E"||l)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),r==="local"&&e!=="E"&&e!=="XYZE"?(s.quaternion.copy(this._quaternionStart),s.quaternion.multiply(xe.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),s.quaternion.copy(xe.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),s.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(_c),this.dispatchEvent(yf)}}pointerUp(t){t!==null&&t.button!==0||(this.dragging&&this.axis!==null&&(vf.mode=this.mode,this.dispatchEvent(vf)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(t){return this.object=t,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(_c),this.dispatchEvent(yf),this.pointStart.copy(this.pointEnd))}getRaycaster(){return ps}getMode(){return this.mode}setMode(t){this.mode=t}setTranslationSnap(t){this.translationSnap=t}setRotationSnap(t){this.rotationSnap=t}setScaleSnap(t){this.scaleSnap=t}setSize(t){this.size=t}setSpace(t){this.space=t}setColors(t,e,n,s){const r=this._gizmo.materialLib;r.xAxis.color.set(t),r.yAxis.color.set(e),r.zAxis.color.set(n),r.active.color.set(s),r.xAxisTransparent.color.set(t),r.yAxisTransparent.color.set(e),r.zAxisTransparent.color.set(n),r.activeTransparent.color.set(s),r.xAxis._color&&r.xAxis._color.set(t),r.yAxis._color&&r.yAxis._color.set(e),r.zAxis._color&&r.zAxis._color.set(n),r.active._color&&r.active._color.set(s),r.xAxisTransparent._color&&r.xAxisTransparent._color.set(t),r.yAxisTransparent._color&&r.yAxisTransparent._color.set(e),r.zAxisTransparent._color&&r.zAxisTransparent._color.set(n),r.activeTransparent._color&&r.activeTransparent._color.set(s)}}function aM(i){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:i.button};{const t=this.domElement.getBoundingClientRect();return{x:(i.clientX-t.left)/t.width*2-1,y:-(i.clientY-t.top)/t.height*2+1,button:i.button}}}function oM(i){if(this.enabled)switch(i.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(i));break}}function lM(i){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(i)),this.pointerDown(this._getPointer(i)))}function cM(i){this.enabled&&this.pointerMove(this._getPointer(i))}function hM(i){this.enabled&&(this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(i)))}function xc(i,t,e){const n=t.intersectObject(i,!0);for(let s=0;s<n.length;s++)if(n[s].object.visible||e)return n[s];return!1}const _o=new Jn,de=new I(0,1,0),bf=new I(0,0,0),Mf=new _e,xo=new ke,Do=new ke,ei=new I,Sf=new _e,ia=new I(1,0,0),_s=new I(0,1,0),sa=new I(0,0,1),go=new I,Jr=new I,Qr=new I;class uM extends Te{constructor(t){super(),this.isTransformControlsRoot=!0,this.controls=t,this.visible=!1}updateMatrixWorld(t){const e=this.controls;e.object!==void 0&&(e.object.updateMatrixWorld(),e.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):e.object.parent.matrixWorld.decompose(e._parentPosition,e._parentQuaternion,e._parentScale),e.object.matrixWorld.decompose(e.worldPosition,e.worldQuaternion,e._worldScale),e._parentQuaternionInv.copy(e._parentQuaternion).invert(),e._worldQuaternionInv.copy(e.worldQuaternion).invert()),e.camera.updateMatrixWorld(),e.camera.matrixWorld.decompose(e.cameraPosition,e.cameraQuaternion,e._cameraScale),e.camera.isOrthographicCamera?e.camera.getWorldDirection(e.eye).negate():e.eye.copy(e.cameraPosition).sub(e.worldPosition).normalize(),super.updateMatrixWorld(t)}dispose(){this.traverse(function(t){t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()})}}class dM extends Te{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const t=new nl({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),e=new Dr({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),n=t.clone();n.opacity=.15;const s=e.clone();s.opacity=.5;const r=t.clone();r.color.setHex(16711680);const a=t.clone();a.color.setHex(65280);const o=t.clone();o.color.setHex(255);const l=t.clone();l.color.setHex(16711680),l.opacity=.5;const c=t.clone();c.color.setHex(65280),c.opacity=.5;const h=t.clone();h.color.setHex(255),h.opacity=.5;const u=t.clone();u.opacity=.25;const d=t.clone();d.color.setHex(16776960),d.opacity=.25;const f=t.clone();f.color.setHex(16776960);const m=t.clone();m.color.setHex(7895160),this.materialLib={xAxis:r,yAxis:a,zAxis:o,active:f,xAxisTransparent:l,yAxisTransparent:c,zAxisTransparent:h,activeTransparent:d};const x=new Be(0,.04,.1,12);x.translate(0,.05,0);const _=new we(.08,.08,.08);_.translate(0,.04,0);const p=new De;p.setAttribute("position",new Jt([0,0,0,1,0,0],3));const w=new Be(.0075,.0075,.5,3);w.translate(0,.25,0);function S(K,tt){const lt=new qi(K,.0075,3,64,tt*Math.PI*2);return lt.rotateY(Math.PI/2),lt.rotateX(Math.PI/2),lt}function y(){const K=new De;return K.setAttribute("position",new Jt([0,0,0,1,1,1],3)),K}const E={X:[[new gt(x,r),[.5,0,0],[0,0,-Math.PI/2]],[new gt(x,r),[-.5,0,0],[0,0,Math.PI/2]],[new gt(w,r),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new gt(x,a),[0,.5,0]],[new gt(x,a),[0,-.5,0],[Math.PI,0,0]],[new gt(w,a)]],Z:[[new gt(x,o),[0,0,.5],[Math.PI/2,0,0]],[new gt(x,o),[0,0,-.5],[-Math.PI/2,0,0]],[new gt(w,o),null,[Math.PI/2,0,0]]],XYZ:[[new gt(new cr(.1,0),u),[0,0,0]]],XY:[[new gt(new we(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new gt(new we(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new gt(new we(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]]},v={X:[[new gt(new Be(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new gt(new Be(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new gt(new Be(.2,0,.6,4),n),[0,.3,0]],[new gt(new Be(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new gt(new Be(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new gt(new Be(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new gt(new cr(.2,0),n)]],XY:[[new gt(new we(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new gt(new we(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new gt(new we(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]]},A={START:[[new gt(new cr(.01,2),s),null,null,null,"helper"]],END:[[new gt(new cr(.01,2),s),null,null,null,"helper"]],DELTA:[[new ni(y(),s),null,null,null,"helper"]],X:[[new ni(p,s),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new ni(p,s),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new ni(p,s),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},R={XYZE:[[new gt(S(.5,1),m),null,[0,Math.PI/2,0]]],X:[[new gt(S(.5,.5),r)]],Y:[[new gt(S(.5,.5),a),null,[0,0,-Math.PI/2]]],Z:[[new gt(S(.5,.5),o),null,[0,Math.PI/2,0]]],E:[[new gt(S(.75,1),d),null,[0,Math.PI/2,0]]]},M={AXIS:[[new ni(p,s),[-1e3,0,0],null,[1e6,1,1],"helper"]]},g={XYZE:[[new gt(new da(.25,10,8),n)]],X:[[new gt(new qi(.5,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new gt(new qi(.5,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new gt(new qi(.5,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new gt(new qi(.75,.1,2,24),n)]]},O={X:[[new gt(_,r),[.5,0,0],[0,0,-Math.PI/2]],[new gt(w,r),[0,0,0],[0,0,-Math.PI/2]],[new gt(_,r),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new gt(_,a),[0,.5,0]],[new gt(w,a)],[new gt(_,a),[0,-.5,0],[0,0,Math.PI]]],Z:[[new gt(_,o),[0,0,.5],[Math.PI/2,0,0]],[new gt(w,o),[0,0,0],[Math.PI/2,0,0]],[new gt(_,o),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new gt(new we(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new gt(new we(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new gt(new we(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new gt(new we(.1,.1,.1),u)]]},F={X:[[new gt(new Be(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new gt(new Be(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new gt(new Be(.2,0,.6,4),n),[0,.3,0]],[new gt(new Be(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new gt(new Be(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new gt(new Be(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new gt(new we(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new gt(new we(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new gt(new we(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new gt(new we(.2,.2,.2),n),[0,0,0]]]},k={X:[[new ni(p,s),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new ni(p,s),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new ni(p,s),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function G(K){const tt=new Te;for(const lt in K)for(let $=K[lt].length;$--;){const st=K[lt][$][0].clone(),ct=K[lt][$][1],Et=K[lt][$][2],Vt=K[lt][$][3],pt=K[lt][$][4];st.name=lt,st.tag=pt,ct&&st.position.set(ct[0],ct[1],ct[2]),Et&&st.rotation.set(Et[0],Et[1],Et[2]),Vt&&st.scale.set(Vt[0],Vt[1],Vt[2]),st.updateMatrix();const $t=st.geometry.clone();$t.applyMatrix4(st.matrix),st.geometry=$t,st.renderOrder=1/0,st.position.set(0,0,0),st.rotation.set(0,0,0),st.scale.set(1,1,1),tt.add(st)}return tt}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=G(E)),this.add(this.gizmo.rotate=G(R)),this.add(this.gizmo.scale=G(O)),this.add(this.picker.translate=G(v)),this.add(this.picker.rotate=G(g)),this.add(this.picker.scale=G(F)),this.add(this.helper.translate=G(A)),this.add(this.helper.rotate=G(M)),this.add(this.helper.scale=G(k)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(t){const n=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:Do;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let s=[];s=s.concat(this.picker[this.mode].children),s=s.concat(this.gizmo[this.mode].children),s=s.concat(this.helper[this.mode].children);for(let r=0;r<s.length;r++){const a=s[r];a.visible=!0,a.rotation.set(0,0,0),a.position.copy(this.worldPosition);let o;if(this.camera.isOrthographicCamera?o=(this.camera.top-this.camera.bottom)/this.camera.zoom:o=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),a.scale.set(1,1,1).multiplyScalar(o*this.size/4),a.tag==="helper"){a.visible=!1,a.name==="AXIS"?(a.visible=!!this.axis,this.axis==="X"&&(xe.setFromEuler(_o.set(0,0,0)),a.quaternion.copy(n).multiply(xe),Math.abs(de.copy(ia).applyQuaternion(n).dot(this.eye))>.9&&(a.visible=!1)),this.axis==="Y"&&(xe.setFromEuler(_o.set(0,0,Math.PI/2)),a.quaternion.copy(n).multiply(xe),Math.abs(de.copy(_s).applyQuaternion(n).dot(this.eye))>.9&&(a.visible=!1)),this.axis==="Z"&&(xe.setFromEuler(_o.set(0,Math.PI/2,0)),a.quaternion.copy(n).multiply(xe),Math.abs(de.copy(sa).applyQuaternion(n).dot(this.eye))>.9&&(a.visible=!1)),this.axis==="XYZE"&&(xe.setFromEuler(_o.set(0,Math.PI/2,0)),de.copy(this.rotationAxis),a.quaternion.setFromRotationMatrix(Mf.lookAt(bf,de,_s)),a.quaternion.multiply(xe),a.visible=this.dragging),this.axis==="E"&&(a.visible=!1)):a.name==="START"?(a.position.copy(this.worldPositionStart),a.visible=this.dragging):a.name==="END"?(a.position.copy(this.worldPosition),a.visible=this.dragging):a.name==="DELTA"?(a.position.copy(this.worldPositionStart),a.quaternion.copy(this.worldQuaternionStart),Ze.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),Ze.applyQuaternion(this.worldQuaternionStart.clone().invert()),a.scale.copy(Ze),a.visible=this.dragging):(a.quaternion.copy(n),this.dragging?a.position.copy(this.worldPositionStart):a.position.copy(this.worldPosition),this.axis&&(a.visible=this.axis.search(a.name)!==-1));continue}a.quaternion.copy(n),this.mode==="translate"||this.mode==="scale"?(a.name==="X"&&Math.abs(de.copy(ia).applyQuaternion(n).dot(this.eye))>.99&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="Y"&&Math.abs(de.copy(_s).applyQuaternion(n).dot(this.eye))>.99&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="Z"&&Math.abs(de.copy(sa).applyQuaternion(n).dot(this.eye))>.99&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="XY"&&Math.abs(de.copy(sa).applyQuaternion(n).dot(this.eye))<.2&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="YZ"&&Math.abs(de.copy(ia).applyQuaternion(n).dot(this.eye))<.2&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="XZ"&&Math.abs(de.copy(_s).applyQuaternion(n).dot(this.eye))<.2&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1)):this.mode==="rotate"&&(xo.copy(n),de.copy(this.eye).applyQuaternion(xe.copy(n).invert()),a.name.search("E")!==-1&&a.quaternion.setFromRotationMatrix(Mf.lookAt(this.eye,bf,_s)),a.name==="X"&&(xe.setFromAxisAngle(ia,Math.atan2(-de.y,de.z)),xe.multiplyQuaternions(xo,xe),a.quaternion.copy(xe)),a.name==="Y"&&(xe.setFromAxisAngle(_s,Math.atan2(de.x,de.z)),xe.multiplyQuaternions(xo,xe),a.quaternion.copy(xe)),a.name==="Z"&&(xe.setFromAxisAngle(sa,Math.atan2(de.y,de.x)),xe.multiplyQuaternions(xo,xe),a.quaternion.copy(xe))),a.visible=a.visible&&(a.name.indexOf("X")===-1||this.showX),a.visible=a.visible&&(a.name.indexOf("Y")===-1||this.showY),a.visible=a.visible&&(a.name.indexOf("Z")===-1||this.showZ),a.visible=a.visible&&(a.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),a.material._color=a.material._color||a.material.color.clone(),a.material._opacity=a.material._opacity||a.material.opacity,a.material.color.copy(a.material._color),a.material.opacity=a.material._opacity,this.enabled&&this.axis&&(a.name===this.axis?(a.material.color.copy(this.materialLib.active.color),a.material.opacity=1):this.axis.split("").some(function(l){return a.name===l})&&(a.material.color.copy(this.materialLib.active.color),a.material.opacity=1))}super.updateMatrixWorld(t)}}class fM extends gt{constructor(){super(new Or(1e5,1e5,2,2),new nl({visible:!1,wireframe:!0,side:si,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(t){let e=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(e="local"),go.copy(ia).applyQuaternion(e==="local"?this.worldQuaternion:Do),Jr.copy(_s).applyQuaternion(e==="local"?this.worldQuaternion:Do),Qr.copy(sa).applyQuaternion(e==="local"?this.worldQuaternion:Do),de.copy(Jr),this.mode){case"translate":case"scale":switch(this.axis){case"X":de.copy(this.eye).cross(go),ei.copy(go).cross(de);break;case"Y":de.copy(this.eye).cross(Jr),ei.copy(Jr).cross(de);break;case"Z":de.copy(this.eye).cross(Qr),ei.copy(Qr).cross(de);break;case"XY":ei.copy(Qr);break;case"YZ":ei.copy(go);break;case"XZ":de.copy(Qr),ei.copy(Jr);break;case"XYZ":case"E":ei.set(0,0,0);break}break;case"rotate":default:ei.set(0,0,0)}ei.length()===0?this.quaternion.copy(this.cameraQuaternion):(Sf.lookAt(Ze.set(0,0,0),ei,de),this.quaternion.setFromRotationMatrix(Sf)),super.updateMatrixWorld(t)}}var mh;(function(i){i[i.Transient=0]="Transient",i[i.Singleton=1]="Singleton",i[i.ResolutionScoped=2]="ResolutionScoped",i[i.ContainerScoped=3]="ContainerScoped"})(mh||(mh={}));const rn=mh;/*! *****************************************************************************
3854
3973
  Copyright (c) Microsoft Corporation.
3855
3974
 
3856
3975
  Permission to use, copy, modify, and/or distribute this software for any
@@ -3863,36 +3982,36 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
3863
3982
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
3864
3983
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
3865
3984
  PERFORMANCE OF THIS SOFTWARE.
3866
- ***************************************************************************** */var Rl=function(n,e){return Rl=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var r in i)i.hasOwnProperty(r)&&(t[r]=i[r])},Rl(n,e)};function yc(n,e){Rl(n,e);function t(){this.constructor=n}n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function ex(n,e,t,i){function r(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(u){try{c(i.next(u))}catch(h){o(h)}}function l(u){try{c(i.throw(u))}catch(h){o(h)}}function c(u){u.done?s(u.value):r(u.value).then(a,l)}c((i=i.apply(n,[])).next())})}function tx(n,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(c){return function(u){return l([c,u])}}function l(c){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,r&&(s=c[0]&2?r.return:c[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,c[1])).done)return s;switch(r=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,r=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){t.label=c[1];break}if(c[0]===6&&t.label<s[1]){t.label=s[1],s=c;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(c);break}s[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(n,t)}catch(u){c=[6,u],r=0}finally{i=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function Qs(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function yo(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,s=[],o;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return s}function Ui(){for(var n=[],e=0;e<arguments.length;e++)n=n.concat(yo(arguments[e]));return n}var Cl="injectionTokens";function nx(n){var e=Reflect.getMetadata("design:paramtypes",n)||[],t=Reflect.getOwnMetadata(Cl,n)||{};return Object.keys(t).forEach(function(i){e[+i]=t[i]}),e}function mf(n,e){return function(t,i,r){var s=Reflect.getOwnMetadata(Cl,t)||{};s[r]=n,Reflect.defineMetadata(Cl,s,t)}}function _f(n){return!!n.useClass}function Pl(n){return!!n.useFactory}var gf=(function(){function n(e){this.wrap=e,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}return n.prototype.createProxy=function(e){var t=this,i={},r=!1,s,o=function(){return r||(s=e(t.wrap()),r=!0),s};return new Proxy(i,this.createHandler(o))},n.prototype.createHandler=function(e){var t={},i=function(r){t[r]=function(){for(var s=[],o=0;o<arguments.length;o++)s[o]=arguments[o];s[0]=e();var a=Reflect[r];return a.apply(void 0,Ui(s))}};return this.reflectMethods.forEach(i),t},n})();function pr(n){return typeof n=="string"||typeof n=="symbol"}function ix(n){return typeof n=="object"&&"token"in n&&"multiple"in n}function rh(n){return typeof n=="object"&&"token"in n&&"transform"in n}function rx(n){return typeof n=="function"||n instanceof gf}function ho(n){return!!n.useToken}function fo(n){return n.useValue!=null}function sx(n){return _f(n)||fo(n)||ho(n)||Pl(n)}var Mc=(function(){function n(){this._registryMap=new Map}return n.prototype.entries=function(){return this._registryMap.entries()},n.prototype.getAll=function(e){return this.ensure(e),this._registryMap.get(e)},n.prototype.get=function(e){this.ensure(e);var t=this._registryMap.get(e);return t[t.length-1]||null},n.prototype.set=function(e,t){this.ensure(e),this._registryMap.get(e).push(t)},n.prototype.setAll=function(e,t){this._registryMap.set(e,t)},n.prototype.has=function(e){return this.ensure(e),this._registryMap.get(e).length>0},n.prototype.clear=function(){this._registryMap.clear()},n.prototype.ensure=function(e){this._registryMap.has(e)||this._registryMap.set(e,[])},n})(),ox=(function(n){yc(e,n);function e(){return n!==null&&n.apply(this,arguments)||this}return e})(Mc),eo=(function(){function n(){this.scopedResolutions=new Map}return n})();function ax(n,e){if(n===null)return"at position #"+e;var t=n.split(",")[e].trim();return'"'+t+'" at position #'+e}function lx(n,e,t){return t===void 0&&(t=" "),Ui([n],e.message.split(`
3867
- `).map(function(i){return t+i})).join(`
3868
- `)}function cx(n,e,t){var i=yo(n.toString().match(/constructor\(([\w, ]+)\)/)||[],2),r=i[1],s=r===void 0?null:r,o=ax(s,e);return lx("Cannot inject the dependency "+o+' of "'+n.name+'" constructor. Reason:',t)}function ux(n){if(typeof n.dispose!="function")return!1;var e=n.dispose;return!(e.length>0)}var hx=(function(n){yc(e,n);function e(){return n!==null&&n.apply(this,arguments)||this}return e})(Mc),fx=(function(n){yc(e,n);function e(){return n!==null&&n.apply(this,arguments)||this}return e})(Mc),dx=(function(){function n(){this.preResolution=new hx,this.postResolution=new fx}return n})(),vf=new Map,px=(function(){function n(e){this.parent=e,this._registry=new ox,this.interceptors=new dx,this.disposed=!1,this.disposables=new Set}return n.prototype.register=function(e,t,i){i===void 0&&(i={lifecycle:Gt.Transient}),this.ensureNotDisposed();var r;if(sx(t)?r=t:r={useClass:t},ho(r))for(var s=[e],o=r;o!=null;){var a=o.useToken;if(s.includes(a))throw new Error("Token registration cycle detected! "+Ui(s,[a]).join(" -> "));s.push(a);var l=this._registry.get(a);l&&ho(l.provider)?o=l.provider:o=null}if((i.lifecycle===Gt.Singleton||i.lifecycle==Gt.ContainerScoped||i.lifecycle==Gt.ResolutionScoped)&&(fo(r)||Pl(r)))throw new Error('Cannot use lifecycle "'+Gt[i.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:r,options:i}),this},n.prototype.registerType=function(e,t){return this.ensureNotDisposed(),pr(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})},n.prototype.registerInstance=function(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})},n.prototype.registerSingleton=function(e,t){if(this.ensureNotDisposed(),pr(e)){if(pr(t))return this.register(e,{useToken:t},{lifecycle:Gt.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:Gt.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var i=e;return t&&!pr(t)&&(i=t),this.register(e,{useClass:i},{lifecycle:Gt.Singleton})},n.prototype.resolve=function(e,t,i){t===void 0&&(t=new eo),i===void 0&&(i=!1),this.ensureNotDisposed();var r=this.getRegistration(e);if(!r&&pr(e)){if(i)return;throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"')}if(this.executePreResolutionInterceptor(e,"Single"),r){var s=this.resolveRegistration(r,t);return this.executePostResolutionInterceptor(e,s,"Single"),s}if(rx(e)){var s=this.construct(e,t);return this.executePostResolutionInterceptor(e,s,"Single"),s}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")},n.prototype.executePreResolutionInterceptor=function(e,t){var i,r;if(this.interceptors.preResolution.has(e)){var s=[];try{for(var o=Qs(this.interceptors.preResolution.getAll(e)),a=o.next();!a.done;a=o.next()){var l=a.value;l.options.frequency!="Once"&&s.push(l),l.callback(e,t)}}catch(c){i={error:c}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}this.interceptors.preResolution.setAll(e,s)}},n.prototype.executePostResolutionInterceptor=function(e,t,i){var r,s;if(this.interceptors.postResolution.has(e)){var o=[];try{for(var a=Qs(this.interceptors.postResolution.getAll(e)),l=a.next();!l.done;l=a.next()){var c=l.value;c.options.frequency!="Once"&&o.push(c),c.callback(e,t,i)}}catch(u){r={error:u}}finally{try{l&&!l.done&&(s=a.return)&&s.call(a)}finally{if(r)throw r.error}}this.interceptors.postResolution.setAll(e,o)}},n.prototype.resolveRegistration=function(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===Gt.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var i=e.options.lifecycle===Gt.Singleton,r=e.options.lifecycle===Gt.ContainerScoped,s=i||r,o;return fo(e.provider)?o=e.provider.useValue:ho(e.provider)?o=s?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):_f(e.provider)?o=s?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):Pl(e.provider)?o=e.provider.useFactory(this):o=this.construct(e.provider,t),e.options.lifecycle===Gt.ResolutionScoped&&t.scopedResolutions.set(e,o),o},n.prototype.resolveAll=function(e,t,i){var r=this;t===void 0&&(t=new eo),i===void 0&&(i=!1),this.ensureNotDisposed();var s=this.getAllRegistrations(e);if(!s&&pr(e)){if(i)return[];throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"')}if(this.executePreResolutionInterceptor(e,"All"),s){var o=s.map(function(l){return r.resolveRegistration(l,t)});return this.executePostResolutionInterceptor(e,o,"All"),o}var a=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,a,"All"),a},n.prototype.isRegistered=function(e,t){return t===void 0&&(t=!1),this.ensureNotDisposed(),this._registry.has(e)||t&&(this.parent||!1)&&this.parent.isRegistered(e,!0)},n.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},n.prototype.clearInstances=function(){var e,t;this.ensureNotDisposed();try{for(var i=Qs(this._registry.entries()),r=i.next();!r.done;r=i.next()){var s=yo(r.value,2),o=s[0],a=s[1];this._registry.setAll(o,a.filter(function(l){return!fo(l.provider)}).map(function(l){return l.instance=void 0,l}))}}catch(l){e={error:l}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}},n.prototype.createChildContainer=function(){var e,t;this.ensureNotDisposed();var i=new n(this);try{for(var r=Qs(this._registry.entries()),s=r.next();!s.done;s=r.next()){var o=yo(s.value,2),a=o[0],l=o[1];l.some(function(c){var u=c.options;return u.lifecycle===Gt.ContainerScoped})&&i._registry.setAll(a,l.map(function(c){return c.options.lifecycle===Gt.ContainerScoped?{provider:c.provider,options:c.options}:c}))}}catch(c){e={error:c}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return i},n.prototype.beforeResolution=function(e,t,i){i===void 0&&(i={frequency:"Always"}),this.interceptors.preResolution.set(e,{callback:t,options:i})},n.prototype.afterResolution=function(e,t,i){i===void 0&&(i={frequency:"Always"}),this.interceptors.postResolution.set(e,{callback:t,options:i})},n.prototype.dispose=function(){return ex(this,void 0,void 0,function(){var e;return tx(this,function(t){switch(t.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach(function(i){var r=i.dispose();r&&e.push(r)}),[4,Promise.all(e)];case 1:return t.sent(),[2]}})})},n.prototype.getRegistration=function(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null},n.prototype.getAllRegistrations=function(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null},n.prototype.construct=function(e,t){var i=this;if(e instanceof gf)return e.createProxy(function(s){return i.resolve(s,t)});var r=(function(){var s=vf.get(e);if(!s||s.length===0){if(e.length===0)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var o=s.map(i.resolveParams(t,e));return new(e.bind.apply(e,Ui([void 0],o)))})();return ux(r)&&this.disposables.add(r),r},n.prototype.resolveParams=function(e,t){var i=this;return function(r,s){var o,a,l;try{return ix(r)?rh(r)?r.multiple?(o=i.resolve(r.transform)).transform.apply(o,Ui([i.resolveAll(r.token,new eo,r.isOptional)],r.transformArgs)):(a=i.resolve(r.transform)).transform.apply(a,Ui([i.resolve(r.token,e,r.isOptional)],r.transformArgs)):r.multiple?i.resolveAll(r.token,new eo,r.isOptional):i.resolve(r.token,e,r.isOptional):rh(r)?(l=i.resolve(r.transform,e)).transform.apply(l,Ui([i.resolve(r.token,e)],r.transformArgs)):i.resolve(r,e)}catch(c){throw new Error(cx(t,s,c))}}},n.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},n})(),mx=new px;function lt(n,e){var t={token:n,multiple:!1,isOptional:e};return mf(t)}function Lt(n){return function(e){vf.set(e,nx(e))}}function Fo(n,e){var t={token:n,multiple:!0,isOptional:e};return mf(t)}if(typeof Reflect>"u"||!Reflect.getMetadata)throw new Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);var to={exports:{}},sh;function _x(){if(sh)return to.exports;sh=1;var n=typeof Reflect=="object"?Reflect:null,e=n&&typeof n.apply=="function"?n.apply:function(S,b,A){return Function.prototype.apply.call(S,b,A)},t;n&&typeof n.ownKeys=="function"?t=n.ownKeys:Object.getOwnPropertySymbols?t=function(S){return Object.getOwnPropertyNames(S).concat(Object.getOwnPropertySymbols(S))}:t=function(S){return Object.getOwnPropertyNames(S)};function i(_){console&&console.warn&&console.warn(_)}var r=Number.isNaN||function(S){return S!==S};function s(){s.init.call(this)}to.exports=s,to.exports.once=f,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a(_){if(typeof _!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof _)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(_){if(typeof _!="number"||_<0||r(_))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+_+".");o=_}}),s.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(S){if(typeof S!="number"||S<0||r(S))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+S+".");return this._maxListeners=S,this};function l(_){return _._maxListeners===void 0?s.defaultMaxListeners:_._maxListeners}s.prototype.getMaxListeners=function(){return l(this)},s.prototype.emit=function(S){for(var b=[],A=1;A<arguments.length;A++)b.push(arguments[A]);var C=S==="error",M=this._events;if(M!==void 0)C=C&&M.error===void 0;else if(!C)return!1;if(C){var x;if(b.length>0&&(x=b[0]),x instanceof Error)throw x;var N=new Error("Unhandled error."+(x?" ("+x.message+")":""));throw N.context=x,N}var z=M[S];if(z===void 0)return!1;if(typeof z=="function")e(z,this,b);else for(var Y=z.length,q=g(z,Y),A=0;A<Y;++A)e(q[A],this,b);return!0};function c(_,S,b,A){var C,M,x;if(a(b),M=_._events,M===void 0?(M=_._events=Object.create(null),_._eventsCount=0):(M.newListener!==void 0&&(_.emit("newListener",S,b.listener?b.listener:b),M=_._events),x=M[S]),x===void 0)x=M[S]=b,++_._eventsCount;else if(typeof x=="function"?x=M[S]=A?[b,x]:[x,b]:A?x.unshift(b):x.push(b),C=l(_),C>0&&x.length>C&&!x.warned){x.warned=!0;var N=new Error("Possible EventEmitter memory leak detected. "+x.length+" "+String(S)+" listeners added. Use emitter.setMaxListeners() to increase limit");N.name="MaxListenersExceededWarning",N.emitter=_,N.type=S,N.count=x.length,i(N)}return _}s.prototype.addListener=function(S,b){return c(this,S,b,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(S,b){return c(this,S,b,!0)};function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(_,S,b){var A={fired:!1,wrapFn:void 0,target:_,type:S,listener:b},C=u.bind(A);return C.listener=b,A.wrapFn=C,C}s.prototype.once=function(S,b){return a(b),this.on(S,h(this,S,b)),this},s.prototype.prependOnceListener=function(S,b){return a(b),this.prependListener(S,h(this,S,b)),this},s.prototype.removeListener=function(S,b){var A,C,M,x,N;if(a(b),C=this._events,C===void 0)return this;if(A=C[S],A===void 0)return this;if(A===b||A.listener===b)--this._eventsCount===0?this._events=Object.create(null):(delete C[S],C.removeListener&&this.emit("removeListener",S,A.listener||b));else if(typeof A!="function"){for(M=-1,x=A.length-1;x>=0;x--)if(A[x]===b||A[x].listener===b){N=A[x].listener,M=x;break}if(M<0)return this;M===0?A.shift():y(A,M),A.length===1&&(C[S]=A[0]),C.removeListener!==void 0&&this.emit("removeListener",S,N||b)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(S){var b,A,C;if(A=this._events,A===void 0)return this;if(A.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):A[S]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete A[S]),this;if(arguments.length===0){var M=Object.keys(A),x;for(C=0;C<M.length;++C)x=M[C],x!=="removeListener"&&this.removeAllListeners(x);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(b=A[S],typeof b=="function")this.removeListener(S,b);else if(b!==void 0)for(C=b.length-1;C>=0;C--)this.removeListener(S,b[C]);return this};function d(_,S,b){var A=_._events;if(A===void 0)return[];var C=A[S];return C===void 0?[]:typeof C=="function"?b?[C.listener||C]:[C]:b?m(C):g(C,C.length)}s.prototype.listeners=function(S){return d(this,S,!0)},s.prototype.rawListeners=function(S){return d(this,S,!1)},s.listenerCount=function(_,S){return typeof _.listenerCount=="function"?_.listenerCount(S):p.call(_,S)},s.prototype.listenerCount=p;function p(_){var S=this._events;if(S!==void 0){var b=S[_];if(typeof b=="function")return 1;if(b!==void 0)return b.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function g(_,S){for(var b=new Array(S),A=0;A<S;++A)b[A]=_[A];return b}function y(_,S){for(;S+1<_.length;S++)_[S]=_[S+1];_.pop()}function m(_){for(var S=new Array(_.length),b=0;b<S.length;++b)S[b]=_[b].listener||_[b];return S}function f(_,S){return new Promise(function(b,A){function C(x){_.removeListener(S,M),A(x)}function M(){typeof _.removeListener=="function"&&_.removeListener("error",C),b([].slice.call(arguments))}T(_,S,M,{once:!0}),S!=="error"&&w(_,C,{once:!0})})}function w(_,S,b){typeof _.on=="function"&&T(_,"error",S,b)}function T(_,S,b,A){if(typeof _.on=="function")A.once?_.once(S,b):_.on(S,b);else if(typeof _.addEventListener=="function")_.addEventListener(S,function C(M){A.once&&_.removeEventListener(S,C),b(M)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof _)}return to.exports}var gx=_x(),vx=Object.getOwnPropertyDescriptor,xx=(n,e,t,i)=>{for(var r=i>1?void 0:i?vx(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r};exports.EventBus=class{_emitter;constructor(){this._emitter=new gx.EventEmitter}emit(e,t){this._emitter.emit(e,t)}on(e,t){this._emitter.on(e,t)}off(e,t){this._emitter.off(e,t)}};exports.EventBus=xx([Lt()],exports.EventBus);var zi=(n=>(n.SelectHover="select.hover",n.SelectClick="select.click",n.ToolSelect="tool.select",n))(zi||{});const yx=.03,Mx=10;var Ex=Object.getOwnPropertyDescriptor,bx=(n,e,t,i)=>{for(var r=i>1?void 0:i?Ex(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r},oh=(n,e)=>(t,i)=>e(t,i,n);exports.EditorRenderer=class extends vc{constructor(e,t){super(e),this._canvas=e,this._bus=t;const i=new Wp(10,10);i.position.y=-.001,this.scene.add(i);const r=new W0(6);this.scene.add(r),this._orbit=new G0(this.camera,this.renderer.domElement),this._orbit.enableDamping=!0,this._orbit.dampingFactor=.05,this._raycaster=new sf,this._mouse=new Ne,this.scene.add(new Bp(16777215,4473924,.6)),this.camera.layers.enable(0),this.camera.layers.enable(1),this._transform=new X0(this.camera,this.renderer.domElement),this._transformHelper=this._transform.getHelper(),this.scene.add(this._transformHelper),this._isEventListenersAdded||this._initMouseListeners()}_orbit;_transform;_transformHelper;_raycaster;_mouse;_isEventListenersAdded=!1;_lastHovered=null;update(){this._orbit.update()}addFigure(e){const t=super.addFigure(e);t.layers.enable(0);const i=new nf(t.geometry),r=new fc(i,new $i({color:8947848,linewidth:1}));return r.layers.set(1),t.add(r),t}setTransformControlsMode(e){this._transform.setMode(e)}attachTransformControls(e){this._transform.attach(e)}detachTransformControls(){this._transform.detach()}setRaycastMode(e){const t=this._raycaster;switch(t.params.Line.threshold=0,t.params.Points.threshold=0,e){case dn.Mesh:case dn.Face:t.layers.set(0);break;case dn.Edge:t.layers.set(1),t.params.Line.threshold=yx;break;case dn.Vertex:t.layers.set(2),t.params.Points.threshold=Mx;break}}dispose(){this._isEventListenersAdded&&(this.canvas.removeEventListener("mousemove",this._handleMouseMove,!1),this.canvas.removeEventListener("click",this._handleMouseClick,!1),this.canvas.removeEventListener("pointerdown",e=>this._transform.pointerDown(e)),this.canvas.removeEventListener("pointermove",e=>this._transform.pointerMove(e)),this.canvas.removeEventListener("pointerup",e=>this._transform.pointerUp(e)),this.canvas.removeEventListener("pointerleave",()=>this._transform.pointerHover(null)),this._transform.removeEventListener("dragging-changed",()=>{this._orbit.enabled=!this._transform.dragging}),this._isEventListenersAdded=!1),this._orbit?.dispose(),this._transform?.dispose(),this._transformHelper?.parent&&this._transformHelper.parent.remove(this._transformHelper),this._lastHovered=null,super.dispose()}_initMouseListeners(){this.canvas.addEventListener("mousemove",this._handleMouseMove,!1),this.canvas.addEventListener("click",this._handleMouseClick,!1),this.canvas.addEventListener("pointerdown",e=>this._transform.pointerDown(e)),this.canvas.addEventListener("pointermove",e=>this._transform.pointerMove(e)),this.canvas.addEventListener("pointerup",e=>this._transform.pointerUp(e)),this.canvas.addEventListener("pointerleave",()=>this._transform.pointerHover(null)),this._transform.addEventListener("dragging-changed",()=>{this._orbit.enabled=!this._transform.dragging}),this._isEventListenersAdded=!0}_handleMouseMove=e=>{this._processRaycastEvent(e,zi.SelectHover,!0)};_handleMouseClick=e=>{this._processRaycastEvent(e,zi.SelectClick,!1)};_processRaycastEvent(e,t,i){if(this._orbit.isInteracting||this._transform.dragging)return;const r=this._canvas.getBoundingClientRect();this._mouse.x=(e.clientX-r.left)/r.width*2-1,this._mouse.y=-((e.clientY-r.top)/r.height)*2+1,this._raycaster.setFromCamera(this._mouse,this.camera);const o=this._raycaster.intersectObjects(this.meshes,!0)[0]??null,a=o?.object??null;i?a!==this._lastHovered&&(this.meshes.forEach(l=>l.userData.isHit=!1),a&&(a.userData.isHit=!0),this._lastHovered=a,this._bus.emit(t,o?{intersection:o}:null)):this._bus.emit(t,o?{intersection:o}:null)}};exports.EditorRenderer=bx([Lt(),oh(0,lt("Canvas")),oh(1,lt("EventBus"))],exports.EditorRenderer);class Sx extends vc{_orbit;constructor(e){super(e),this.camera.position.set(1,1,7),this.camera.lookAt(0,0,0),this._orbit=new pf(this.camera,this.canvas),this._orbit.target.set(0,0,0),this._orbit.minPolarAngle=Math.PI/2,this._orbit.maxPolarAngle=Math.PI/2,this._orbit.enableRotate=!0,this._orbit.enableZoom=!1,this._orbit.enablePan=!1}update(){this._orbit?.update()}}class Tx{_positions=[];_normals=[];_uvs=[];_tmpPositions=[];_tmpNormals=[];_tmpUVs=[];load(e){const t=e.split(`
3869
- `);for(const r of t){if(!r.trim()||r.startsWith("#"))continue;const s=r.trim().split(/\s+/);switch(s[0]){case"v":this._tmpPositions.push(s.slice(1).map(Number));break;case"vn":this._tmpNormals.push(s.slice(1).map(Number));break;case"vt":this._tmpUVs.push(s.slice(1).map(Number));break;case"f":this.processFaceLine(s);break}}const i={type:an.Custom,position:this._positions,...this._normals.length>0&&{normal:this._normals},...this._uvs.length>0&&{uv:this._uvs}};return new R0(i)}processFaceLine(e){for(let t=1;t<e.length;t++){const i=e[t];if(!i)continue;const[r,s,o]=i.split("/"),a=r?parseInt(r,10):void 0,l=s?parseInt(s,10):void 0,c=o?parseInt(o,10):void 0;if(a!==void 0){const u=this._tmpPositions[a-1];u&&this._positions.push(...u)}if(l!==void 0){const u=this._tmpUVs[l-1];u&&this._uvs.push(...u)}if(c!==void 0){const u=this._tmpNormals[c-1];u&&this._normals.push(...u)}}}}var wx=Object.getOwnPropertyDescriptor,Ax=(n,e,t,i)=>{for(var r=i>1?void 0:i?wx(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r},ah=(n,e)=>(t,i)=>e(t,i,n);let Dl=class{constructor(n,e){this._store=e,this._handlers=new Map(n.map(t=>[t.mode,t]))}_currentMode=Sr.Plane;_handlers;manage(n){n!==this._currentMode&&(this._handlers.get(this._currentMode)?.rollback(),n!==Sr.Plane&&this._handlers.get(n)?.handle(),this._currentMode=n,this._store.setDisplayMode(this._currentMode))}dispose(){this._handlers&&this._handlers.clear(),this._currentMode=Sr.Plane,this._store.setDisplayMode(this._currentMode)}};Dl=Ax([Lt(),ah(0,Fo("IDisplayHandler")),ah(1,lt("IEditorStore"))],Dl);var ti=(n=>(n.Hover="hover",n.Click="click",n))(ti||{}),Rx=Object.getOwnPropertyDescriptor,Cx=(n,e,t,i)=>{for(var r=i>1?void 0:i?Rx(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r},Da=(n,e)=>(t,i)=>e(t,i,n);let Ll=class{constructor(n,e,t){this._eventBus=n,this._store=t,this._handlers=new Map(e.map(i=>[i.mode,i])),this._eventBus.on(zi.SelectHover,this._onHover),this._eventBus.on(zi.SelectClick,this._onClick)}_currentMode=dn.Mesh;_handlers;manage(n){n!==this._currentMode&&(this._handlers.get(this._currentMode)?.rollback(),this._currentMode=n,this._store.setSelectMode(this._currentMode))}_onHover=n=>{this._handlers.get(this._currentMode)?.handle(n,ti.Hover)};_onClick=n=>{this._handlers.get(this._currentMode)?.handle(n,ti.Click)};dispose(){this._handlers&&this._handlers.clear(),this._eventBus.off(zi.SelectHover,this._onHover),this._currentMode=dn.Mesh,this._store.setSelectMode(this._currentMode)}};Ll=Cx([Lt(),Da(0,lt("EventBus")),Da(1,Fo("ISelectHandler")),Da(2,lt("IEditorStore"))],Ll);var Px=Object.getOwnPropertyDescriptor,Dx=(n,e,t,i)=>{for(var r=i>1?void 0:i?Px(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r},lh=(n,e)=>(t,i)=>e(t,i,n);let Ol=class{constructor(n,e){this._store=e,this._handlers=new Map(n.map(t=>[t.mode,t])),this._unsubSelected=this._store.onSelectedObjectChange(()=>{this._handlers.get(this._currentTool)?.handle()})}_currentTool=gi.Translate;_handlers;_unsubSelected;manage(n){this._currentTool!==n&&(this._handlers.get(this._currentTool)?.rollback(),this._currentTool=n,this._store.setToolType(this._currentTool),this._handlers.get(this._currentTool)?.handle())}dispose(){this._unsubSelected?.(),this._handlers&&this._handlers.clear(),this._currentTool=gi.Translate,this._store.setToolType(this._currentTool)}};Ol=Dx([Lt(),lh(0,Fo("IToolHandler")),lh(1,lt("IEditorStore"))],Ol);var Lx=Object.getOwnPropertyDescriptor,Ox=(n,e,t,i)=>{for(var r=i>1?void 0:i?Lx(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r},Ix=(n,e)=>(t,i)=>e(t,i,n);let Il=class{_currentMode=Tr.AddFigure;_handlers;constructor(n){this._handlers=new Map(n.map(e=>[e.mode,e]))}manage(n,e){console.log("manage",n),n===Tr.AddFigure?this._handlers.get(n)?.handle(e):this._handlers.get(n)?.handle(),this._currentMode=n}dispose(){this._handlers&&this._handlers.clear(),this._currentMode=Tr.AddFigure}};Il=Ox([Lt(),Ix(0,Fo("ISceneHandler"))],Il);var Nx=Object.getOwnPropertyDescriptor,Ux=(n,e,t,i)=>{for(var r=i>1?void 0:i?Nx(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r},Fx=(n,e)=>(t,i)=>e(t,i,n);let Nl=class{constructor(n){this._api=n}mode=Sr.Wireframe;_prevWireframe=new Map;_prevColorMesh=new Map;_prevColorLines=new Map;_wireColor=new je(65535);handle(){const n=this._api.getMeshes();for(const e of n){const t=Array.isArray(e.material)?e.material:[e.material];for(const i of t)this._enableWireframeOnMaterial(i);e.traverse(i=>{if(i.isLineSegments){const r=i;if(!this._prevColorLines.has(r.material)){const o=r.material;this._prevColorLines.set(o,o.color.clone())}const s=r.material;s.color.copy(this._wireColor),s.needsUpdate=!0}})}}rollback(){for(const[n,e]of this._prevWireframe)"wireframe"in n&&(n.wireframe=e),n.needsUpdate=!0;this._prevWireframe.clear();for(const[n,e]of this._prevColorMesh){const t=n;t.color?.isColor&&t.color.copy(e)}this._prevColorMesh.clear();for(const[n,e]of this._prevColorLines)n.color.copy(e);this._prevColorLines.clear()}dispose(){this.rollback()}_enableWireframeOnMaterial(n){const e=n;"wireframe"in e&&!this._prevWireframe.has(n)&&(this._prevWireframe.set(n,!!e.wireframe),e.wireframe=!0,n.needsUpdate=!0),e.color?.isColor&&(this._prevColorMesh.has(n)||this._prevColorMesh.set(n,e.color.clone()),e.color.copy(this._wireColor))}};Nl=Ux([Lt(),Fx(0,lt("RendererApi"))],Nl);const Ec=16776960,bc=16755200,Bx=2236962;var zx=Object.getOwnPropertyDescriptor,Vx=(n,e,t,i)=>{for(var r=i>1?void 0:i?zx(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r},ch=(n,e)=>(t,i)=>e(t,i,n);let Ul=class{constructor(n,e){this._api=n,this._store=e}mode=dn.Mesh;_hoveredMesh=null;_selectedMesh=null;_hoverColor=Ec;_selectColor=bc;_origLineColors=new WeakMap;handle(n,e){if(this._api.setRaycastMode(this.mode),e===ti.Hover){if(!n){this._hoveredMesh&&this._hoveredMesh!==this._selectedMesh&&this._restoreEdgesColor(this._hoveredMesh),this._hoveredMesh=null;return}const t=n.intersection.object;this._hoveredMesh!==t&&(this._hoveredMesh&&this._hoveredMesh!==this._selectedMesh&&this._restoreEdgesColor(this._hoveredMesh),t!==this._selectedMesh&&this._paintEdges(t,this._hoverColor),this._hoveredMesh=t)}if(e===ti.Click){if(!n){this._selectedMesh&&(this._restoreEdgesColor(this._selectedMesh),this._selectedMesh=null,this._store.setSelectedObject(null));return}const t=n.intersection.object;this._selectedMesh&&this._selectedMesh!==t&&this._restoreEdgesColor(this._selectedMesh),this._paintEdges(t,this._selectColor),this._selectedMesh=t,this._store.setSelectedObject(t)}}rollback(){this._hoveredMesh&&this._restoreEdgesColor(this._hoveredMesh),this._selectedMesh&&this._restoreEdgesColor(this._selectedMesh),this._hoveredMesh=this._selectedMesh=null}dispose(){this.rollback()}_paintEdges(n,e){n.children.forEach(t=>{const i=t;if(i.isLineSegments&&i.material){const r=i.material;this._origLineColors.has(i)||this._origLineColors.set(i,r.color.clone()),r.color.setHex(e),r.needsUpdate=!0}})}_restoreEdgesColor(n){n.children.forEach(e=>{const t=e;if(t.isLineSegments&&t.material){const i=this._origLineColors.get(t);if(i){const r=t.material;r.color.copy(i),r.needsUpdate=!0}}})}};Ul=Vx([Lt(),ch(0,lt("RendererApi")),ch(1,lt("IEditorStore"))],Ul);var Hx=Object.getOwnPropertyDescriptor,kx=(n,e,t,i)=>{for(var r=i>1?void 0:i?Hx(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r},Gx=(n,e)=>(t,i)=>e(t,i,n);let Fl=class{constructor(n){this._api=n}mode=dn.Face;_hovered=null;_selected=null;_hoverColor=Ec;_selectColor=bc;_defaultColor=2236962;handle(n,e){this._api.setRaycastMode(this.mode),e===ti.Hover&&console.log(n),e===ti.Click&&console.log(n)}rollback(){throw new Error("Method not implemented.")}dispose(){throw new Error("Method not implemented.")}};Fl=kx([Lt(),Gx(0,lt("RendererApi"))],Fl);class Sc{constructor(e,t){this.api=e,this.store=t}handle(){const e=this.store.getSelectedObject();this.api.setMode(this.mode),e?this.api.attach(e):this.api.detach()}rollback(){this.api.detach()}dispose(){this.rollback()}}var Wx=Object.getOwnPropertyDescriptor,Xx=(n,e,t,i)=>{for(var r=i>1?void 0:i?Wx(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r},uh=(n,e)=>(t,i)=>e(t,i,n);let Bl=class extends Sc{mode=gi.Translate;constructor(n,e){super(n,e)}};Bl=Xx([Lt(),uh(0,lt("RendererApi")),uh(1,lt("IEditorStore"))],Bl);var jx=Object.getOwnPropertyDescriptor,Yx=(n,e,t,i)=>{for(var r=i>1?void 0:i?jx(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r},hh=(n,e)=>(t,i)=>e(t,i,n);let zl=class extends Sc{mode=gi.Scale;constructor(n,e){super(n,e)}};zl=Yx([Lt(),hh(0,lt("RendererApi")),hh(1,lt("IEditorStore"))],zl);var qx=Object.getOwnPropertyDescriptor,$x=(n,e,t,i)=>{for(var r=i>1?void 0:i?qx(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r},fh=(n,e)=>(t,i)=>e(t,i,n);let Vl=class extends Sc{mode=gi.Rotate;constructor(n,e){super(n,e)}};Vl=$x([Lt(),fh(0,lt("RendererApi")),fh(1,lt("IEditorStore"))],Vl);const no=31;var Zx=Object.getOwnPropertyDescriptor,Kx=(n,e,t,i)=>{for(var r=i>1?void 0:i?Zx(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r},dh=(n,e)=>(t,i)=>e(t,i,n);let Hl=class{constructor(n,e){this._api=n,this._store=e,this._api.enableCameraLayer(no),this._hoverLine=this._makeOverlayLine(this._hoverColor),this._selectLine=this._makeOverlayLine(this._selectColor),this._api.addObject(this._hoverLine,no),this._api.addObject(this._selectLine,no)}mode=dn.Edge;_hoverLine;_selectLine;_hovered=null;_selected=null;_hoverColor=Ec;_selectColor=bc;handle(n,e){if(this._api.setRaycastMode(this.mode),e===ti.Hover){if(!n){this._hoverLine.visible=!1,this._hovered=null;return}const t=n.intersection.object;if(!t?.isLineSegments)return;const i=t,r=Math.floor((n.intersection.index??-1)/2);if(r<0)return;this._selected&&this._same({lines:i,seg:r},this._selected)?this._hoverLine.visible=!1:(this._writeWorldSegment(this._hoverLine,i,r),this._hoverLine.visible=!0),this._hovered={lines:i,seg:r};return}if(e===ti.Click){if(!n){this._selectLine.visible=!1,this._selected=null,this._store.setSelectedObject(null);return}const t=n.intersection.object;if(!t?.isLineSegments)return;const i=t,r=Math.floor((n.intersection.index??-1)/2);if(r<0)return;this._writeWorldSegment(this._selectLine,i,r),this._centerAndOrientLineOnSegment(this._selectLine,i,r),this._selectLine.visible=!0,this._store.setSelectedObject(this._selectLine),this._selected={lines:i,seg:r},this._hovered&&this._same(this._hovered,this._selected)&&(this._hoverLine.visible=!1)}}rollback(){this._hoverLine.visible=!1,this._selectLine.visible=!1,this._hovered=this._selected=null}dispose(){this.rollback(),this._api.removeObject(this._hoverLine),this._api.removeObject(this._selectLine),this._hoverLine.geometry.dispose(),this._hoverLine.material.dispose(),this._selectLine.geometry.dispose(),this._selectLine.material.dispose()}_makeOverlayLine(n){const e=new bt;e.setAttribute("position",new Ze(6,3));const t=new $i({color:n,depthTest:!1,depthWrite:!1,transparent:!0,opacity:1}),i=new En(e,t);return i.renderOrder=1e3,i.raycast=()=>{},i.layers.set(no),i.visible=!1,i}_writeWorldSegment(n,e,t){const i=e.geometry.getAttribute("position"),r=t*2,s=r+1,o=new O(i.getX(r),i.getY(r),i.getZ(r)).applyMatrix4(e.matrixWorld),a=new O(i.getX(s),i.getY(s),i.getZ(s)).applyMatrix4(e.matrixWorld),l=n.geometry.getAttribute("position");l.setXYZ(0,o.x,o.y,o.z),l.setXYZ(1,a.x,a.y,a.z),l.needsUpdate=!0}_same(n,e){return!!n&&!!e&&n.lines===e.lines&&n.seg===e.seg}_centerAndOrientLineOnSegment(n,e,t){const i=e.geometry.getAttribute("position"),r=t*2,s=r+1,o=new O(i.getX(r),i.getY(r),i.getZ(r)).applyMatrix4(e.matrixWorld),a=new O(i.getX(s),i.getY(s),i.getZ(s)).applyMatrix4(e.matrixWorld),l=new O().subVectors(a,o),c=l.length();if(!isFinite(c)||c===0)return;const u=new O().addVectors(o,a).multiplyScalar(.5);n.position.copy(u);const h=n.geometry;let d=h.getAttribute("position");(!d||d.count<2)&&(h.setAttribute("position",new wn(new Float32Array(6),3)),d=h.getAttribute("position")),d.setXYZ(0,-c/2,0,0),d.setXYZ(1,c/2,0,0),d.needsUpdate=!0,l.normalize();const p=new Dt().setFromUnitVectors(new O(1,0,0),l);n.quaternion.copy(p),n.updateMatrixWorld(!0)}};Hl=Kx([Lt(),dh(0,lt("RendererApi")),dh(1,lt("IEditorStore"))],Hl);var Jx=Object.getOwnPropertyDescriptor,Qx=(n,e,t,i)=>{for(var r=i>1?void 0:i?Jx(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r},ey=(n,e)=>(t,i)=>e(t,i,n);let kl=class{constructor(n){this._api=n}mode=Tr.AddFigure;_lastAddedMesh=null;handle(n){const e=C0[n](),t=e.getAttribute("position");t&&t.setUsage&&t.setUsage(np);const i=new ge(e,ff);i.layers.enable(0);const r=new nf(i.geometry),s=new fc(r,new $i({color:Bx,linewidth:1}));s.layers.set(1),i.add(s),this._api.addMesh(i),this._lastAddedMesh=i}rollback(){this._lastAddedMesh!==null&&(this._api.removeMesh(this._lastAddedMesh),this._lastAddedMesh=null)}dispose(){this._lastAddedMesh=null}};kl=Qx([Lt(),ey(0,lt("RendererApi"))],kl);const ty=n=>!!n&&n.isMesh;var ny=Object.getOwnPropertyDescriptor,iy=(n,e,t,i)=>{for(var r=i>1?void 0:i?ny(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r},ph=(n,e)=>(t,i)=>e(t,i,n);let Gl=class{constructor(n,e){this._api=n,this._store=e}mode=Tr.DeleteFigure;_lastDeletedMesh=null;handle(){const n=this._store.getSelectedObject();ty(n)&&(this._api.removeMesh(n),this._store.setSelectedObject(null),this._lastDeletedMesh=n)}rollback(){this._lastDeletedMesh&&(this._api.addMesh(this._lastDeletedMesh),this._lastDeletedMesh=null)}dispose(){this._lastDeletedMesh=null}};Gl=iy([Lt(),ph(0,lt("RendererApi")),ph(1,lt("IEditorStore"))],Gl);var ry=Object.getOwnPropertyDescriptor,sy=(n,e,t,i)=>{for(var r=i>1?void 0:i?ry(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r},oy=(n,e)=>(t,i)=>e(t,i,n);let Wl=class{constructor(n){this._renderer=n}addMesh(n){this._renderer.addMesh(n)}addMeshes(n){for(const e of n)this._renderer.addMesh(e)}removeMesh(n){this._renderer.removeMesh(n)}removeMeshes(n){for(const e of n)this._renderer.removeMesh(e)}getMeshes(){return this._renderer.getMeshes()}setMode(n){this._renderer.setTransformControlsMode(n)}attach(n){this._renderer.attachTransformControls(n)}detach(){this._renderer.detachTransformControls()}setRaycastMode(n){this._renderer.setRaycastMode(n)}addObject(n,e){this._renderer.addObject(n,e)}removeObject(n){this._renderer.removeObject(n)}enableCameraLayer(n){this._renderer.enableCameraLayer(n)}};Wl=sy([Lt(),oy(0,lt("EditorRenderer"))],Wl);var ay=Object.getOwnPropertyDescriptor,ly=(n,e,t,i)=>{for(var r=i>1?void 0:i?ay(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r},$r=(n,e)=>(t,i)=>e(t,i,n);exports.EditorHub=class{constructor(e,t,i,r,s){this._displayManager=e,this._selectManager=t,this._toolManager=i,this._sceneManager=r,this._renderer=s,this.setSelectMode(dn.Mesh),this.setToolMode(gi.Translate)}setDisplayMode(e){this._displayManager.manage(e)}setSceneMode(e){this._sceneManager.manage(e)}setSelectMode(e){this._selectManager.manage(e)}setToolMode(e){this._toolManager.manage(e)}resizeRenderer(){this._renderer.resize()}updateRenderer(){this._renderer.loop()}addFigure(e,t){this._sceneManager.manage(e,t)}dispose(){this._displayManager.dispose(),this._selectManager.dispose(),this._renderer.dispose()}};exports.EditorHub=ly([Lt(),$r(0,lt("IDisplayManager")),$r(1,lt("ISelectManager")),$r(2,lt("IToolManager")),$r(3,lt("ISceneManager")),$r(4,lt("EditorRenderer"))],exports.EditorHub);var cy={0:"Invalid value for configuration 'enforceActions', expected 'never', 'always' or 'observed'",1:function(e,t){return"Cannot apply '"+e+"' to '"+t.toString()+"': Field not found."},5:"'keys()' can only be used on observable objects, arrays, sets and maps",6:"'values()' can only be used on observable objects, arrays, sets and maps",7:"'entries()' can only be used on observable objects, arrays and maps",8:"'set()' can only be used on observable objects, arrays and maps",9:"'remove()' can only be used on observable objects, arrays and maps",10:"'has()' can only be used on observable objects, arrays and maps",11:"'get()' can only be used on observable objects, arrays and maps",12:"Invalid annotation",13:"Dynamic observable objects cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)",14:"Intercept handlers should return nothing or a change object",15:"Observable arrays cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)",16:"Modification exception: the internal structure of an observable array was changed.",17:function(e,t){return"[mobx.array] Index out of bounds, "+e+" is larger than "+t},18:"mobx.map requires Map polyfill for the current browser. Check babel-polyfill or core-js/es6/map.js",19:function(e){return"Cannot initialize from classes that inherit from Map: "+e.constructor.name},20:function(e){return"Cannot initialize map from "+e},21:function(e){return"Cannot convert to map from '"+e+"'"},22:"mobx.set requires Set polyfill for the current browser. Check babel-polyfill or core-js/es6/set.js",23:"It is not possible to get index atoms from arrays",24:function(e){return"Cannot obtain administration from "+e},25:function(e,t){return"the entry '"+e+"' does not exist in the observable map '"+t+"'"},26:"please specify a property",27:function(e,t){return"no observable property '"+e.toString()+"' found on the observable object '"+t+"'"},28:function(e){return"Cannot obtain atom from "+e},29:"Expecting some object",30:"invalid action stack. did you forget to finish an action?",31:"missing option for computed: get",32:function(e,t){return"Cycle detected in computation "+e+": "+t},33:function(e){return"The setter of computed value '"+e+"' is trying to update itself. Did you intend to update an _observable_ value, instead of the computed property?"},34:function(e){return"[ComputedValue '"+e+"'] It is not possible to assign a new value to a computed value."},35:"There are multiple, different versions of MobX active. Make sure MobX is loaded only once or use `configure({ isolateGlobalState: true })`",36:"isolateGlobalState should be called before MobX is running any reactions",37:function(e){return"[mobx] `observableArray."+e+"()` mutates the array in-place, which is not allowed inside a derivation. Use `array.slice()."+e+"()` instead"},38:"'ownKeys()' can only be used on observable objects",39:"'defineProperty()' can only be used on observable objects"},uy=process.env.NODE_ENV!=="production"?cy:{};function ve(n){for(var e=arguments.length,t=new Array(e>1?e-1:0),i=1;i<e;i++)t[i-1]=arguments[i];if(process.env.NODE_ENV!=="production"){var r=typeof n=="string"?n:uy[n];throw typeof r=="function"&&(r=r.apply(null,t)),new Error("[MobX] "+r)}throw new Error(typeof n=="number"?"[MobX] minified error nr: "+n+(t.length?" "+t.map(String).join(","):"")+". Find the full error at: https://github.com/mobxjs/mobx/blob/main/packages/mobx/src/errors.ts":"[MobX] "+n)}var hy={};function Tc(){return typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:hy}var xf=Object.assign,Mo=Object.getOwnPropertyDescriptor,Vn=Object.defineProperty,Bo=Object.prototype,Eo=[];Object.freeze(Eo);var yf={};Object.freeze(yf);var fy=typeof Proxy<"u",dy=Object.toString();function Mf(){fy||ve(process.env.NODE_ENV!=="production"?"`Proxy` objects are not available in the current environment. Please configure MobX to enable a fallback implementation.`":"Proxy not available")}function Zr(n){process.env.NODE_ENV!=="production"&&he.verifyProxies&&ve("MobX is currently configured to be able to run in ES5 mode, but in ES5 MobX won't be able to "+n)}function Dn(){return++he.mobxGuid}function wc(n){var e=!1;return function(){if(!e)return e=!0,n.apply(this,arguments)}}var vr=function(){};function Rt(n){return typeof n=="function"}function Gi(n){var e=typeof n;switch(e){case"string":case"symbol":case"number":return!0}return!1}function zo(n){return n!==null&&typeof n=="object"}function Jt(n){if(!zo(n))return!1;var e=Object.getPrototypeOf(n);if(e==null)return!0;var t=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t.toString()===dy}function Ef(n){var e=n?.constructor;return e?e.name==="GeneratorFunction"||e.displayName==="GeneratorFunction":!1}function Vo(n,e,t){Vn(n,e,{enumerable:!1,writable:!0,configurable:!0,value:t})}function bf(n,e,t){Vn(n,e,{enumerable:!1,writable:!1,configurable:!0,value:t})}function Zi(n,e){var t="isMobX"+n;return e.prototype[t]=!0,function(i){return zo(i)&&i[t]===!0}}function Ur(n){return n!=null&&Object.prototype.toString.call(n)==="[object Map]"}function py(n){var e=Object.getPrototypeOf(n),t=Object.getPrototypeOf(e),i=Object.getPrototypeOf(t);return i===null}function $n(n){return n!=null&&Object.prototype.toString.call(n)==="[object Set]"}var Sf=typeof Object.getOwnPropertySymbols<"u";function my(n){var e=Object.keys(n);if(!Sf)return e;var t=Object.getOwnPropertySymbols(n);return t.length?[].concat(e,t.filter(function(i){return Bo.propertyIsEnumerable.call(n,i)})):e}var cs=typeof Reflect<"u"&&Reflect.ownKeys?Reflect.ownKeys:Sf?function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:Object.getOwnPropertyNames;function Xl(n){return typeof n=="string"?n:typeof n=="symbol"?n.toString():new String(n).toString()}function Tf(n){return n===null?null:typeof n=="object"?""+n:n}function An(n,e){return Bo.hasOwnProperty.call(n,e)}var _y=Object.getOwnPropertyDescriptors||function(e){var t={};return cs(e).forEach(function(i){t[i]=Mo(e,i)}),t};function Zt(n,e){return!!(n&e)}function Kt(n,e,t){return t?n|=e:n&=~e,n}function mh(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,i=Array(e);t<e;t++)i[t]=n[t];return i}function gy(n,e){for(var t=0;t<e.length;t++){var i=e[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(n,xy(i.key),i)}}function Fr(n,e,t){return e&&gy(n.prototype,e),Object.defineProperty(n,"prototype",{writable:!1}),n}function xr(n,e){var t=typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t)return(t=t.call(n)).next.bind(t);if(Array.isArray(n)||(t=yy(n))||e){t&&(n=t);var i=0;return function(){return i>=n.length?{done:!0}:{done:!1,value:n[i++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
3870
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function vi(){return vi=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},vi.apply(null,arguments)}function wf(n,e){n.prototype=Object.create(e.prototype),n.prototype.constructor=n,jl(n,e)}function jl(n,e){return jl=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},jl(n,e)}function vy(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var i=t.call(n,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}function xy(n){var e=vy(n,"string");return typeof e=="symbol"?e:e+""}function yy(n,e){if(n){if(typeof n=="string")return mh(n,e);var t={}.toString.call(n).slice(8,-1);return t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set"?Array.from(n):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?mh(n,e):void 0}}var Zn=Symbol("mobx-stored-annotations");function Hn(n){function e(t,i){if(gs(i))return n.decorate_20223_(t,i);_s(t,i,n)}return Object.assign(e,n)}function _s(n,e,t){if(An(n,Zn)||Vo(n,Zn,vi({},n[Zn])),process.env.NODE_ENV!=="production"&&So(t)&&!An(n[Zn],e)){var i=n.constructor.name+".prototype."+e.toString();ve("'"+i+"' is decorated with 'override', but no such decorated member was found on prototype.")}My(n,t,e),So(t)||(n[Zn][e]=t)}function My(n,e,t){if(process.env.NODE_ENV!=="production"&&!So(e)&&An(n[Zn],t)){var i=n.constructor.name+".prototype."+t.toString(),r=n[Zn][t].annotationType_,s=e.annotationType_;ve("Cannot apply '@"+s+"' to '"+i+"':"+(`
3871
- The field is already decorated with '@`+r+"'.")+`
3985
+ ***************************************************************************** */var _h=function(i,t){return _h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var s in n)n.hasOwnProperty(s)&&(e[s]=n[s])},_h(i,t)};function lu(i,t){_h(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function pM(i,t,e,n){function s(r){return r instanceof e?r:new e(function(a){a(r)})}return new(e||(e=Promise))(function(r,a){function o(h){try{c(n.next(h))}catch(u){a(u)}}function l(h){try{c(n.throw(h))}catch(u){a(u)}}function c(h){h.done?r(h.value):s(h.value).then(o,l)}c((n=n.apply(i,[])).next())})}function mM(i,t){var e={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},n,s,r,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(c){return function(h){return l([c,h])}}function l(c){if(n)throw new TypeError("Generator is already executing.");for(;e;)try{if(n=1,s&&(r=c[0]&2?s.return:c[0]?s.throw||((r=s.return)&&r.call(s),0):s.next)&&!(r=r.call(s,c[1])).done)return r;switch(s=0,r&&(c=[c[0]&2,r.value]),c[0]){case 0:case 1:r=c;break;case 4:return e.label++,{value:c[1],done:!1};case 5:e.label++,s=c[1],c=[0];continue;case 7:c=e.ops.pop(),e.trys.pop();continue;default:if(r=e.trys,!(r=r.length>0&&r[r.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!r||c[1]>r[0]&&c[1]<r[3])){e.label=c[1];break}if(c[0]===6&&e.label<r[1]){e.label=r[1],r=c;break}if(r&&e.label<r[2]){e.label=r[2],e.ops.push(c);break}r[2]&&e.ops.pop(),e.trys.pop();continue}c=t.call(i,e)}catch(h){c=[6,h],s=0}finally{n=r=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function vo(i){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&i[t],n=0;if(e)return e.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&n>=i.length&&(i=void 0),{value:i&&i[n++],done:!i}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ho(i,t){var e=typeof Symbol=="function"&&i[Symbol.iterator];if(!e)return i;var n=e.call(i),s,r=[],a;try{for(;(t===void 0||t-- >0)&&!(s=n.next()).done;)r.push(s.value)}catch(o){a={error:o}}finally{try{s&&!s.done&&(e=n.return)&&e.call(n)}finally{if(a)throw a.error}}return r}function ys(){for(var i=[],t=0;t<arguments.length;t++)i=i.concat(Ho(arguments[t]));return i}var xh="injectionTokens";function _M(i){var t=Reflect.getMetadata("design:paramtypes",i)||[],e=Reflect.getOwnMetadata(xh,i)||{};return Object.keys(e).forEach(function(n){t[+n]=e[n]}),t}function Vp(i,t){return function(e,n,s){var r=Reflect.getOwnMetadata(xh,e)||{};r[s]=i,Reflect.defineMetadata(xh,r,e)}}function Hp(i){return!!i.useClass}function gh(i){return!!i.useFactory}var Gp=(function(){function i(t){this.wrap=t,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}return i.prototype.createProxy=function(t){var e=this,n={},s=!1,r,a=function(){return s||(r=t(e.wrap()),s=!0),r};return new Proxy(n,this.createHandler(a))},i.prototype.createHandler=function(t){var e={},n=function(s){e[s]=function(){for(var r=[],a=0;a<arguments.length;a++)r[a]=arguments[a];r[0]=t();var o=Reflect[s];return o.apply(void 0,ys(r))}};return this.reflectMethods.forEach(n),e},i})();function or(i){return typeof i=="string"||typeof i=="symbol"}function xM(i){return typeof i=="object"&&"token"in i&&"multiple"in i}function Ef(i){return typeof i=="object"&&"token"in i&&"transform"in i}function gM(i){return typeof i=="function"||i instanceof Gp}function Oo(i){return!!i.useToken}function Lo(i){return i.useValue!=null}function vM(i){return Hp(i)||Lo(i)||Oo(i)||gh(i)}var cu=(function(){function i(){this._registryMap=new Map}return i.prototype.entries=function(){return this._registryMap.entries()},i.prototype.getAll=function(t){return this.ensure(t),this._registryMap.get(t)},i.prototype.get=function(t){this.ensure(t);var e=this._registryMap.get(t);return e[e.length-1]||null},i.prototype.set=function(t,e){this.ensure(t),this._registryMap.get(t).push(e)},i.prototype.setAll=function(t,e){this._registryMap.set(t,e)},i.prototype.has=function(t){return this.ensure(t),this._registryMap.get(t).length>0},i.prototype.clear=function(){this._registryMap.clear()},i.prototype.ensure=function(t){this._registryMap.has(t)||this._registryMap.set(t,[])},i})(),yM=(function(i){lu(t,i);function t(){return i!==null&&i.apply(this,arguments)||this}return t})(cu),yo=(function(){function i(){this.scopedResolutions=new Map}return i})();function bM(i,t){if(i===null)return"at position #"+t;var e=i.split(",")[t].trim();return'"'+e+'" at position #'+t}function MM(i,t,e){return e===void 0&&(e=" "),ys([i],t.message.split(`
3986
+ `).map(function(n){return e+n})).join(`
3987
+ `)}function SM(i,t,e){var n=Ho(i.toString().match(/constructor\(([\w, ]+)\)/)||[],2),s=n[1],r=s===void 0?null:s,a=bM(r,t);return MM("Cannot inject the dependency "+a+' of "'+i.name+'" constructor. Reason:',e)}function EM(i){if(typeof i.dispose!="function")return!1;var t=i.dispose;return!(t.length>0)}var wM=(function(i){lu(t,i);function t(){return i!==null&&i.apply(this,arguments)||this}return t})(cu),TM=(function(i){lu(t,i);function t(){return i!==null&&i.apply(this,arguments)||this}return t})(cu),AM=(function(){function i(){this.preResolution=new wM,this.postResolution=new TM}return i})(),Wp=new Map,CM=(function(){function i(t){this.parent=t,this._registry=new yM,this.interceptors=new AM,this.disposed=!1,this.disposables=new Set}return i.prototype.register=function(t,e,n){n===void 0&&(n={lifecycle:rn.Transient}),this.ensureNotDisposed();var s;if(vM(e)?s=e:s={useClass:e},Oo(s))for(var r=[t],a=s;a!=null;){var o=a.useToken;if(r.includes(o))throw new Error("Token registration cycle detected! "+ys(r,[o]).join(" -> "));r.push(o);var l=this._registry.get(o);l&&Oo(l.provider)?a=l.provider:a=null}if((n.lifecycle===rn.Singleton||n.lifecycle==rn.ContainerScoped||n.lifecycle==rn.ResolutionScoped)&&(Lo(s)||gh(s)))throw new Error('Cannot use lifecycle "'+rn[n.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(t,{provider:s,options:n}),this},i.prototype.registerType=function(t,e){return this.ensureNotDisposed(),or(e)?this.register(t,{useToken:e}):this.register(t,{useClass:e})},i.prototype.registerInstance=function(t,e){return this.ensureNotDisposed(),this.register(t,{useValue:e})},i.prototype.registerSingleton=function(t,e){if(this.ensureNotDisposed(),or(t)){if(or(e))return this.register(t,{useToken:e},{lifecycle:rn.Singleton});if(e)return this.register(t,{useClass:e},{lifecycle:rn.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var n=t;return e&&!or(e)&&(n=e),this.register(t,{useClass:n},{lifecycle:rn.Singleton})},i.prototype.resolve=function(t,e,n){e===void 0&&(e=new yo),n===void 0&&(n=!1),this.ensureNotDisposed();var s=this.getRegistration(t);if(!s&&or(t)){if(n)return;throw new Error('Attempted to resolve unregistered dependency token: "'+t.toString()+'"')}if(this.executePreResolutionInterceptor(t,"Single"),s){var r=this.resolveRegistration(s,e);return this.executePostResolutionInterceptor(t,r,"Single"),r}if(gM(t)){var r=this.construct(t,e);return this.executePostResolutionInterceptor(t,r,"Single"),r}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")},i.prototype.executePreResolutionInterceptor=function(t,e){var n,s;if(this.interceptors.preResolution.has(t)){var r=[];try{for(var a=vo(this.interceptors.preResolution.getAll(t)),o=a.next();!o.done;o=a.next()){var l=o.value;l.options.frequency!="Once"&&r.push(l),l.callback(t,e)}}catch(c){n={error:c}}finally{try{o&&!o.done&&(s=a.return)&&s.call(a)}finally{if(n)throw n.error}}this.interceptors.preResolution.setAll(t,r)}},i.prototype.executePostResolutionInterceptor=function(t,e,n){var s,r;if(this.interceptors.postResolution.has(t)){var a=[];try{for(var o=vo(this.interceptors.postResolution.getAll(t)),l=o.next();!l.done;l=o.next()){var c=l.value;c.options.frequency!="Once"&&a.push(c),c.callback(t,e,n)}}catch(h){s={error:h}}finally{try{l&&!l.done&&(r=o.return)&&r.call(o)}finally{if(s)throw s.error}}this.interceptors.postResolution.setAll(t,a)}},i.prototype.resolveRegistration=function(t,e){if(this.ensureNotDisposed(),t.options.lifecycle===rn.ResolutionScoped&&e.scopedResolutions.has(t))return e.scopedResolutions.get(t);var n=t.options.lifecycle===rn.Singleton,s=t.options.lifecycle===rn.ContainerScoped,r=n||s,a;return Lo(t.provider)?a=t.provider.useValue:Oo(t.provider)?a=r?t.instance||(t.instance=this.resolve(t.provider.useToken,e)):this.resolve(t.provider.useToken,e):Hp(t.provider)?a=r?t.instance||(t.instance=this.construct(t.provider.useClass,e)):this.construct(t.provider.useClass,e):gh(t.provider)?a=t.provider.useFactory(this):a=this.construct(t.provider,e),t.options.lifecycle===rn.ResolutionScoped&&e.scopedResolutions.set(t,a),a},i.prototype.resolveAll=function(t,e,n){var s=this;e===void 0&&(e=new yo),n===void 0&&(n=!1),this.ensureNotDisposed();var r=this.getAllRegistrations(t);if(!r&&or(t)){if(n)return[];throw new Error('Attempted to resolve unregistered dependency token: "'+t.toString()+'"')}if(this.executePreResolutionInterceptor(t,"All"),r){var a=r.map(function(l){return s.resolveRegistration(l,e)});return this.executePostResolutionInterceptor(t,a,"All"),a}var o=[this.construct(t,e)];return this.executePostResolutionInterceptor(t,o,"All"),o},i.prototype.isRegistered=function(t,e){return e===void 0&&(e=!1),this.ensureNotDisposed(),this._registry.has(t)||e&&(this.parent||!1)&&this.parent.isRegistered(t,!0)},i.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},i.prototype.clearInstances=function(){var t,e;this.ensureNotDisposed();try{for(var n=vo(this._registry.entries()),s=n.next();!s.done;s=n.next()){var r=Ho(s.value,2),a=r[0],o=r[1];this._registry.setAll(a,o.filter(function(l){return!Lo(l.provider)}).map(function(l){return l.instance=void 0,l}))}}catch(l){t={error:l}}finally{try{s&&!s.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}},i.prototype.createChildContainer=function(){var t,e;this.ensureNotDisposed();var n=new i(this);try{for(var s=vo(this._registry.entries()),r=s.next();!r.done;r=s.next()){var a=Ho(r.value,2),o=a[0],l=a[1];l.some(function(c){var h=c.options;return h.lifecycle===rn.ContainerScoped})&&n._registry.setAll(o,l.map(function(c){return c.options.lifecycle===rn.ContainerScoped?{provider:c.provider,options:c.options}:c}))}}catch(c){t={error:c}}finally{try{r&&!r.done&&(e=s.return)&&e.call(s)}finally{if(t)throw t.error}}return n},i.prototype.beforeResolution=function(t,e,n){n===void 0&&(n={frequency:"Always"}),this.interceptors.preResolution.set(t,{callback:e,options:n})},i.prototype.afterResolution=function(t,e,n){n===void 0&&(n={frequency:"Always"}),this.interceptors.postResolution.set(t,{callback:e,options:n})},i.prototype.dispose=function(){return pM(this,void 0,void 0,function(){var t;return mM(this,function(e){switch(e.label){case 0:return this.disposed=!0,t=[],this.disposables.forEach(function(n){var s=n.dispose();s&&t.push(s)}),[4,Promise.all(t)];case 1:return e.sent(),[2]}})})},i.prototype.getRegistration=function(t){return this.isRegistered(t)?this._registry.get(t):this.parent?this.parent.getRegistration(t):null},i.prototype.getAllRegistrations=function(t){return this.isRegistered(t)?this._registry.getAll(t):this.parent?this.parent.getAllRegistrations(t):null},i.prototype.construct=function(t,e){var n=this;if(t instanceof Gp)return t.createProxy(function(r){return n.resolve(r,e)});var s=(function(){var r=Wp.get(t);if(!r||r.length===0){if(t.length===0)return new t;throw new Error('TypeInfo not known for "'+t.name+'"')}var a=r.map(n.resolveParams(e,t));return new(t.bind.apply(t,ys([void 0],a)))})();return EM(s)&&this.disposables.add(s),s},i.prototype.resolveParams=function(t,e){var n=this;return function(s,r){var a,o,l;try{return xM(s)?Ef(s)?s.multiple?(a=n.resolve(s.transform)).transform.apply(a,ys([n.resolveAll(s.token,new yo,s.isOptional)],s.transformArgs)):(o=n.resolve(s.transform)).transform.apply(o,ys([n.resolve(s.token,t,s.isOptional)],s.transformArgs)):s.multiple?n.resolveAll(s.token,new yo,s.isOptional):n.resolve(s.token,t,s.isOptional):Ef(s)?(l=n.resolve(s.transform,t)).transform.apply(l,ys([n.resolve(s.token,t)],s.transformArgs)):n.resolve(s,t)}catch(c){throw new Error(SM(e,r,c))}}},i.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},i})(),RM=new CM;function fe(i,t){var e={token:i,multiple:!1,isOptional:t};return Vp(e)}function He(i){return function(t){Wp.set(t,_M(t))}}function cl(i,t){var e={token:i,multiple:!0,isOptional:t};return Vp(e)}if(typeof Reflect>"u"||!Reflect.getMetadata)throw new Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);var bo={exports:{}},wf;function PM(){if(wf)return bo.exports;wf=1;var i=typeof Reflect=="object"?Reflect:null,t=i&&typeof i.apply=="function"?i.apply:function(E,v,A){return Function.prototype.apply.call(E,v,A)},e;i&&typeof i.ownKeys=="function"?e=i.ownKeys:Object.getOwnPropertySymbols?e=function(E){return Object.getOwnPropertyNames(E).concat(Object.getOwnPropertySymbols(E))}:e=function(E){return Object.getOwnPropertyNames(E)};function n(y){console&&console.warn&&console.warn(y)}var s=Number.isNaN||function(E){return E!==E};function r(){r.init.call(this)}bo.exports=r,bo.exports.once=p,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._eventsCount=0,r.prototype._maxListeners=void 0;var a=10;function o(y){if(typeof y!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof y)}Object.defineProperty(r,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(y){if(typeof y!="number"||y<0||s(y))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+y+".");a=y}}),r.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},r.prototype.setMaxListeners=function(E){if(typeof E!="number"||E<0||s(E))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+E+".");return this._maxListeners=E,this};function l(y){return y._maxListeners===void 0?r.defaultMaxListeners:y._maxListeners}r.prototype.getMaxListeners=function(){return l(this)},r.prototype.emit=function(E){for(var v=[],A=1;A<arguments.length;A++)v.push(arguments[A]);var R=E==="error",M=this._events;if(M!==void 0)R=R&&M.error===void 0;else if(!R)return!1;if(R){var g;if(v.length>0&&(g=v[0]),g instanceof Error)throw g;var O=new Error("Unhandled error."+(g?" ("+g.message+")":""));throw O.context=g,O}var F=M[E];if(F===void 0)return!1;if(typeof F=="function")t(F,this,v);else for(var k=F.length,G=m(F,k),A=0;A<k;++A)t(G[A],this,v);return!0};function c(y,E,v,A){var R,M,g;if(o(v),M=y._events,M===void 0?(M=y._events=Object.create(null),y._eventsCount=0):(M.newListener!==void 0&&(y.emit("newListener",E,v.listener?v.listener:v),M=y._events),g=M[E]),g===void 0)g=M[E]=v,++y._eventsCount;else if(typeof g=="function"?g=M[E]=A?[v,g]:[g,v]:A?g.unshift(v):g.push(v),R=l(y),R>0&&g.length>R&&!g.warned){g.warned=!0;var O=new Error("Possible EventEmitter memory leak detected. "+g.length+" "+String(E)+" listeners added. Use emitter.setMaxListeners() to increase limit");O.name="MaxListenersExceededWarning",O.emitter=y,O.type=E,O.count=g.length,n(O)}return y}r.prototype.addListener=function(E,v){return c(this,E,v,!1)},r.prototype.on=r.prototype.addListener,r.prototype.prependListener=function(E,v){return c(this,E,v,!0)};function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function u(y,E,v){var A={fired:!1,wrapFn:void 0,target:y,type:E,listener:v},R=h.bind(A);return R.listener=v,A.wrapFn=R,R}r.prototype.once=function(E,v){return o(v),this.on(E,u(this,E,v)),this},r.prototype.prependOnceListener=function(E,v){return o(v),this.prependListener(E,u(this,E,v)),this},r.prototype.removeListener=function(E,v){var A,R,M,g,O;if(o(v),R=this._events,R===void 0)return this;if(A=R[E],A===void 0)return this;if(A===v||A.listener===v)--this._eventsCount===0?this._events=Object.create(null):(delete R[E],R.removeListener&&this.emit("removeListener",E,A.listener||v));else if(typeof A!="function"){for(M=-1,g=A.length-1;g>=0;g--)if(A[g]===v||A[g].listener===v){O=A[g].listener,M=g;break}if(M<0)return this;M===0?A.shift():x(A,M),A.length===1&&(R[E]=A[0]),R.removeListener!==void 0&&this.emit("removeListener",E,O||v)}return this},r.prototype.off=r.prototype.removeListener,r.prototype.removeAllListeners=function(E){var v,A,R;if(A=this._events,A===void 0)return this;if(A.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):A[E]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete A[E]),this;if(arguments.length===0){var M=Object.keys(A),g;for(R=0;R<M.length;++R)g=M[R],g!=="removeListener"&&this.removeAllListeners(g);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(v=A[E],typeof v=="function")this.removeListener(E,v);else if(v!==void 0)for(R=v.length-1;R>=0;R--)this.removeListener(E,v[R]);return this};function d(y,E,v){var A=y._events;if(A===void 0)return[];var R=A[E];return R===void 0?[]:typeof R=="function"?v?[R.listener||R]:[R]:v?_(R):m(R,R.length)}r.prototype.listeners=function(E){return d(this,E,!0)},r.prototype.rawListeners=function(E){return d(this,E,!1)},r.listenerCount=function(y,E){return typeof y.listenerCount=="function"?y.listenerCount(E):f.call(y,E)},r.prototype.listenerCount=f;function f(y){var E=this._events;if(E!==void 0){var v=E[y];if(typeof v=="function")return 1;if(v!==void 0)return v.length}return 0}r.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]};function m(y,E){for(var v=new Array(E),A=0;A<E;++A)v[A]=y[A];return v}function x(y,E){for(;E+1<y.length;E++)y[E]=y[E+1];y.pop()}function _(y){for(var E=new Array(y.length),v=0;v<E.length;++v)E[v]=y[v].listener||y[v];return E}function p(y,E){return new Promise(function(v,A){function R(g){y.removeListener(E,M),A(g)}function M(){typeof y.removeListener=="function"&&y.removeListener("error",R),v([].slice.call(arguments))}S(y,E,M,{once:!0}),E!=="error"&&w(y,R,{once:!0})})}function w(y,E,v){typeof y.on=="function"&&S(y,"error",E,v)}function S(y,E,v,A){if(typeof y.on=="function")A.once?y.once(E,v):y.on(E,v);else if(typeof y.addEventListener=="function")y.addEventListener(E,function R(M){A.once&&y.removeEventListener(E,R),v(M)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof y)}return bo.exports}var DM=PM(),OM=Object.getOwnPropertyDescriptor,LM=(i,t,e,n)=>{for(var s=n>1?void 0:n?OM(t,e):t,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=a(s)||s);return s};exports.EventBus=class{_emitter;constructor(){this._emitter=new DM.EventEmitter}emit(t,e){this._emitter.emit(t,e)}on(t,e){this._emitter.on(t,e)}off(t,e){this._emitter.off(t,e)}};exports.EventBus=LM([He()],exports.EventBus);var Ss=(i=>(i.SelectHover="select.hover",i.SelectClick="select.click",i.ToolSelect="tool.select",i))(Ss||{});const NM=.03,IM=10;var UM=Object.getOwnPropertyDescriptor,FM=(i,t,e,n)=>{for(var s=n>1?void 0:n?UM(t,e):t,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=a(s)||s);return s},Tf=(i,t)=>(e,n)=>t(e,n,i);exports.EditorRenderer=class extends au{constructor(t,e){super(t),this._canvas=t,this._bus=e;const n=new v_(10,10);n.position.y=-.001,this.scene.add(n);const s=new sM(6);this.scene.add(s),this._orbit=new iM(this.camera,this.renderer.domElement),this._orbit.enableDamping=!0,this._orbit.dampingFactor=.05,this._raycaster=new wp,this._mouse=new Nt,this.scene.add(new f_(16777215,4473924,.6)),this.camera.layers.enable(0),this.camera.layers.enable(1),this._transform=new rM(this.camera,this.renderer.domElement),this._transformHelper=this._transform.getHelper(),this.scene.add(this._transformHelper),this._isEventListenersAdded||this._initMouseListeners()}_orbit;_transform;_transformHelper;_raycaster;_mouse;_isEventListenersAdded=!1;_lastHovered=null;update(){this._orbit.update()}addFigure(t){const e=super.addFigure(t);e.layers.enable(0);const n=new Sp(e.geometry),s=new eu(n,new Dr({color:8947848,linewidth:1}));return s.layers.set(1),e.add(s),e}setTransformControlsMode(t){this._transform.setMode(t)}attachTransformControls(t){this._transform.attach(t)}detachTransformControls(){this._transform.detach()}setRaycastMode(t){const e=this._raycaster;switch(e.params.Line.threshold=0,e.params.Points.threshold=0,t){case Ln.Mesh:case Ln.Face:e.layers.set(0);break;case Ln.Edge:e.layers.set(1),e.params.Line.threshold=NM;break;case Ln.Vertex:e.layers.set(2),e.params.Points.threshold=IM;break}}dispose(){this._isEventListenersAdded&&(this.canvas.removeEventListener("mousemove",this._handleMouseMove,!1),this.canvas.removeEventListener("click",this._handleMouseClick,!1),this.canvas.removeEventListener("pointerdown",t=>this._transform.pointerDown(t)),this.canvas.removeEventListener("pointermove",t=>this._transform.pointerMove(t)),this.canvas.removeEventListener("pointerup",t=>this._transform.pointerUp(t)),this.canvas.removeEventListener("pointerleave",()=>this._transform.pointerHover(null)),this._transform.removeEventListener("dragging-changed",()=>{this._orbit.enabled=!this._transform.dragging}),this._isEventListenersAdded=!1),this._orbit?.dispose(),this._transform?.dispose(),this._transformHelper?.parent&&this._transformHelper.parent.remove(this._transformHelper),this._lastHovered=null,super.dispose()}_initMouseListeners(){this.canvas.addEventListener("mousemove",this._handleMouseMove,!1),this.canvas.addEventListener("click",this._handleMouseClick,!1),this.canvas.addEventListener("pointerdown",t=>this._transform.pointerDown(t)),this.canvas.addEventListener("pointermove",t=>this._transform.pointerMove(t)),this.canvas.addEventListener("pointerup",t=>this._transform.pointerUp(t)),this.canvas.addEventListener("pointerleave",()=>this._transform.pointerHover(null)),this._transform.addEventListener("dragging-changed",()=>{this._orbit.enabled=!this._transform.dragging}),this._isEventListenersAdded=!0}_handleMouseMove=t=>{this._processRaycastEvent(t,Ss.SelectHover,!0)};_handleMouseClick=t=>{this._processRaycastEvent(t,Ss.SelectClick,!1)};_processRaycastEvent(t,e,n){if(this._orbit.isInteracting||this._transform.dragging)return;const s=this._canvas.getBoundingClientRect();this._mouse.x=(t.clientX-s.left)/s.width*2-1,this._mouse.y=-((t.clientY-s.top)/s.height)*2+1,this._raycaster.setFromCamera(this._mouse,this.camera);const a=this._raycaster.intersectObjects(this.meshes,!0)[0]??null,o=a?.object??null;n?o!==this._lastHovered&&(this.meshes.forEach(l=>l.userData.isHit=!1),o&&(o.userData.isHit=!0),this._lastHovered=o,this._bus.emit(e,a?{intersection:a}:null)):this._bus.emit(e,a?{intersection:a}:null)}};exports.EditorRenderer=FM([He(),Tf(0,fe("Canvas")),Tf(1,fe("EventBus"))],exports.EditorRenderer);const Af={type:"change"},hu={type:"start"},Xp={type:"end"},Mo=new el,Cf=new ji,zM=Math.cos(70*N0.DEG2RAD),Le=new I,an=2*Math.PI,ce={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},gc=1e-6;class BM extends Tp{constructor(t,e=null){super(t,e),this.state=ce.NONE,this.target=new I,this.cursor=new I,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:pr.ROTATE,MIDDLE:pr.DOLLY,RIGHT:pr.PAN},this.touches={ONE:lr.ROTATE,TWO:lr.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new I,this._lastQuaternion=new ke,this._lastTargetPosition=new I,this._quat=new ke().setFromUnitVectors(t.up,new I(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new pd,this._sphericalDelta=new pd,this._scale=1,this._panOffset=new I,this._rotateStart=new Nt,this._rotateEnd=new Nt,this._rotateDelta=new Nt,this._panStart=new Nt,this._panEnd=new Nt,this._panDelta=new Nt,this._dollyStart=new Nt,this._dollyEnd=new Nt,this._dollyDelta=new Nt,this._dollyDirection=new I,this._mouse=new Nt,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=VM.bind(this),this._onPointerDown=kM.bind(this),this._onPointerUp=HM.bind(this),this._onContextMenu=ZM.bind(this),this._onMouseWheel=XM.bind(this),this._onKeyDown=jM.bind(this),this._onTouchStart=YM.bind(this),this._onTouchMove=qM.bind(this),this._onMouseDown=GM.bind(this),this._onMouseMove=WM.bind(this),this._interceptControlDown=$M.bind(this),this._interceptControlUp=KM.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(t){super.connect(t),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(t){t.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=t}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Af),this.update(),this.state=ce.NONE}update(t=null){const e=this.object.position;Le.copy(e).sub(this.target),Le.applyQuaternion(this._quat),this._spherical.setFromVector3(Le),this.autoRotate&&this.state===ce.NONE&&this._rotateLeft(this._getAutoRotationAngle(t)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(n)&&isFinite(s)&&(n<-Math.PI?n+=an:n>Math.PI&&(n-=an),s<-Math.PI?s+=an:s>Math.PI&&(s-=an),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(Le.setFromSpherical(this._spherical),Le.applyQuaternion(this._quatInverse),e.copy(this.target).add(Le),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=Le.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const o=new I(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new I(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=Le.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Mo.origin.copy(this.object.position),Mo.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Mo.direction))<zM?this.object.lookAt(this.target):(Cf.setFromNormalAndCoplanarPoint(this.object.up,this.target),Mo.intersectPlane(Cf,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>gc||8*(1-this._lastQuaternion.dot(this.object.quaternion))>gc||this._lastTargetPosition.distanceToSquared(this.target)>gc?(this.dispatchEvent(Af),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(t){return t!==null?an/60*this.autoRotateSpeed*t:an/60/60*this.autoRotateSpeed}_getZoomScale(t){const e=Math.abs(t*.01);return Math.pow(.95,this.zoomSpeed*e)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,e){Le.setFromMatrixColumn(e,0),Le.multiplyScalar(-t),this._panOffset.add(Le)}_panUp(t,e){this.screenSpacePanning===!0?Le.setFromMatrixColumn(e,1):(Le.setFromMatrixColumn(e,0),Le.crossVectors(this.object.up,Le)),Le.multiplyScalar(t),this._panOffset.add(Le)}_pan(t,e){const n=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;Le.copy(s).sub(this.target);let r=Le.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*r/n.clientHeight,this.object.matrix),this._panUp(2*e*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(t,e){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),s=t-n.left,r=e-n.top,a=n.width,o=n.height;this._mouse.x=s/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(an*this._rotateDelta.x/e.clientHeight),this._rotateUp(an*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(t){this._panEnd.set(t.clientX,t.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let e=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(an*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(-an*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(an*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(-an*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),e=!0;break}e&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(this._pointers.length===1)this._rotateStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(t){if(this._pointers.length===1)this._panStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._panStart.set(n,s)}}_handleTouchStartDolly(t){const e=this._getSecondPointerPosition(t),n=t.pageX-e.x,s=t.pageY-e.y,r=Math.sqrt(n*n+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(this._pointers.length==1)this._rotateEnd.set(t.pageX,t.pageY);else{const n=this._getSecondPointerPosition(t),s=.5*(t.pageX+n.x),r=.5*(t.pageY+n.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(an*this._rotateDelta.x/e.clientHeight),this._rotateUp(an*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(this._pointers.length===1)this._panEnd.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(t){const e=this._getSecondPointerPosition(t),n=t.pageX-e.x,s=t.pageY-e.y,r=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(t.pageX+e.x)*.5,o=(t.pageY+e.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId){this._pointers.splice(e,1);return}}_isTrackingPointer(t){for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId)return!0;return!1}_trackPointer(t){let e=this._pointerPositions[t.pointerId];e===void 0&&(e=new Nt,this._pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}_getSecondPointerPosition(t){const e=t.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[e]}_customWheelEvent(t){const e=t.deltaMode,n={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(e){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return t.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function kM(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i)))}function VM(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function HM(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Xp),this.state=ce.NONE;break;case 1:const t=this._pointers[0],e=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:e.x,pageY:e.y});break}}function GM(i){let t;switch(i.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case pr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=ce.DOLLY;break;case pr.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=ce.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=ce.ROTATE}break;case pr.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=ce.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=ce.PAN}break;default:this.state=ce.NONE}this.state!==ce.NONE&&this.dispatchEvent(hu)}function WM(i){switch(this.state){case ce.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case ce.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case ce.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function XM(i){this.enabled===!1||this.enableZoom===!1||this.state!==ce.NONE||(i.preventDefault(),this.dispatchEvent(hu),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(Xp))}function jM(i){this.enabled!==!1&&this._handleKeyDown(i)}function YM(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case lr.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=ce.TOUCH_ROTATE;break;case lr.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=ce.TOUCH_PAN;break;default:this.state=ce.NONE}break;case 2:switch(this.touches.TWO){case lr.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=ce.TOUCH_DOLLY_PAN;break;case lr.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=ce.TOUCH_DOLLY_ROTATE;break;default:this.state=ce.NONE}break;default:this.state=ce.NONE}this.state!==ce.NONE&&this.dispatchEvent(hu)}function qM(i){switch(this._trackPointer(i),this.state){case ce.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case ce.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case ce.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case ce.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=ce.NONE}}function ZM(i){this.enabled!==!1&&i.preventDefault()}function $M(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function KM(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class JM extends au{_orbit;constructor(t){super(t),this.camera.position.set(1,1,7),this.camera.lookAt(0,0,0),this._orbit=new BM(this.camera,this.canvas),this._orbit.target.set(0,0,0),this._orbit.minPolarAngle=Math.PI/2,this._orbit.maxPolarAngle=Math.PI/2,this._orbit.enableRotate=!0,this._orbit.enableZoom=!1,this._orbit.enablePan=!1}update(){this._orbit?.update()}}class QM{_positions=[];_normals=[];_uvs=[];_tmpPositions=[];_tmpNormals=[];_tmpUVs=[];load(t){const e=t.split(`
3988
+ `);for(const s of e){if(!s.trim()||s.startsWith("#"))continue;const r=s.trim().split(/\s+/);switch(r[0]){case"v":this._tmpPositions.push(r.slice(1).map(Number));break;case"vn":this._tmpNormals.push(r.slice(1).map(Number));break;case"vt":this._tmpUVs.push(r.slice(1).map(Number));break;case"f":this.processFaceLine(r);break}}const n={type:Tn.Custom,position:this._positions,...this._normals.length>0&&{normal:this._normals},...this._uvs.length>0&&{uv:this._uvs}};return new ob(n)}processFaceLine(t){for(let e=1;e<t.length;e++){const n=t[e];if(!n)continue;const[s,r,a]=n.split("/"),o=s?parseInt(s,10):void 0,l=r?parseInt(r,10):void 0,c=a?parseInt(a,10):void 0;if(o!==void 0){const h=this._tmpPositions[o-1];h&&this._positions.push(...h)}if(l!==void 0){const h=this._tmpUVs[l-1];h&&this._uvs.push(...h)}if(c!==void 0){const h=this._tmpNormals[c-1];h&&this._normals.push(...h)}}}}var tS=Object.getOwnPropertyDescriptor,eS=(i,t,e,n)=>{for(var s=n>1?void 0:n?tS(t,e):t,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=a(s)||s);return s},Rf=(i,t)=>(e,n)=>t(e,n,i);let vh=class{constructor(i,t){this._store=t,this._handlers=new Map(i.map(e=>[e.mode,e]))}_currentMode=xr.Plane;_handlers;manage(i){i!==this._currentMode&&(this._handlers.get(this._currentMode)?.rollback(),i!==xr.Plane&&this._handlers.get(i)?.handle(),this._currentMode=i,this._store.setDisplayMode(this._currentMode))}dispose(){this._handlers&&this._handlers.clear(),this._currentMode=xr.Plane,this._store.setDisplayMode(this._currentMode)}};vh=eS([He(),Rf(0,cl("IDisplayHandler")),Rf(1,fe("IEditorStore"))],vh);var Oi=(i=>(i.Hover="hover",i.Click="click",i))(Oi||{}),nS=Object.getOwnPropertyDescriptor,iS=(i,t,e,n)=>{for(var s=n>1?void 0:n?nS(t,e):t,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=a(s)||s);return s},vc=(i,t)=>(e,n)=>t(e,n,i);let yh=class{constructor(i,t,e){this._eventBus=i,this._store=e,this._handlers=new Map(t.map(n=>[n.mode,n])),this._eventBus.on(Ss.SelectHover,this._onHover),this._eventBus.on(Ss.SelectClick,this._onClick)}_currentMode=Ln.Mesh;_handlers;manage(i){i!==this._currentMode&&(this._handlers.get(this._currentMode)?.rollback(),this._currentMode=i,this._store.setSelectMode(this._currentMode))}_onHover=i=>{this._handlers.get(this._currentMode)?.handle(i,Oi.Hover)};_onClick=i=>{this._handlers.get(this._currentMode)?.handle(i,Oi.Click)};dispose(){this._handlers&&this._handlers.clear(),this._eventBus.off(Ss.SelectHover,this._onHover),this._currentMode=Ln.Mesh,this._store.setSelectMode(this._currentMode)}};yh=iS([He(),vc(0,fe("EventBus")),vc(1,cl("ISelectHandler")),vc(2,fe("IEditorStore"))],yh);var sS=Object.getOwnPropertyDescriptor,rS=(i,t,e,n)=>{for(var s=n>1?void 0:n?sS(t,e):t,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=a(s)||s);return s},Pf=(i,t)=>(e,n)=>t(e,n,i);let bh=class{constructor(i,t){this._store=t,this._handlers=new Map(i.map(e=>[e.mode,e])),this._unsubSelected=this._store.onSelectedObjectChange(()=>{this._handlers.get(this._currentTool)?.handle()})}_currentTool=Qi.Translate;_handlers;_unsubSelected;manage(i){this._currentTool!==i&&(this._handlers.get(this._currentTool)?.rollback(),this._currentTool=i,this._store.setToolType(this._currentTool),this._handlers.get(this._currentTool)?.handle())}dispose(){this._unsubSelected?.(),this._handlers&&this._handlers.clear(),this._currentTool=Qi.Translate,this._store.setToolType(this._currentTool)}};bh=rS([He(),Pf(0,cl("IToolHandler")),Pf(1,fe("IEditorStore"))],bh);var aS=Object.getOwnPropertyDescriptor,oS=(i,t,e,n)=>{for(var s=n>1?void 0:n?aS(t,e):t,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=a(s)||s);return s},lS=(i,t)=>(e,n)=>t(e,n,i);let Mh=class{_currentMode=gr.AddFigure;_handlers;constructor(i){this._handlers=new Map(i.map(t=>[t.mode,t]))}manage(i,t){console.log("manage",i),i===gr.AddFigure?this._handlers.get(i)?.handle(t):this._handlers.get(i)?.handle(),this._currentMode=i}dispose(){this._handlers&&this._handlers.clear(),this._currentMode=gr.AddFigure}};Mh=oS([He(),lS(0,cl("ISceneHandler"))],Mh);var cS=Object.getOwnPropertyDescriptor,hS=(i,t,e,n)=>{for(var s=n>1?void 0:n?cS(t,e):t,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=a(s)||s);return s},uS=(i,t)=>(e,n)=>t(e,n,i);let Sh=class{constructor(i){this._api=i}mode=xr.Wireframe;_prevWireframe=new Map;_prevColorMesh=new Map;_prevColorLines=new Map;_wireColor=new Zt(65535);handle(){const i=this._api.getMeshes();for(const t of i){const e=Array.isArray(t.material)?t.material:[t.material];for(const n of e)this._enableWireframeOnMaterial(n);t.traverse(n=>{if(n.isLineSegments){const s=n;if(!this._prevColorLines.has(s.material)){const a=s.material;this._prevColorLines.set(a,a.color.clone())}const r=s.material;r.color.copy(this._wireColor),r.needsUpdate=!0}})}}rollback(){for(const[i,t]of this._prevWireframe)"wireframe"in i&&(i.wireframe=t),i.needsUpdate=!0;this._prevWireframe.clear();for(const[i,t]of this._prevColorMesh){const e=i;e.color?.isColor&&e.color.copy(t)}this._prevColorMesh.clear();for(const[i,t]of this._prevColorLines)i.color.copy(t);this._prevColorLines.clear()}dispose(){this.rollback()}_enableWireframeOnMaterial(i){const t=i;"wireframe"in t&&!this._prevWireframe.has(i)&&(this._prevWireframe.set(i,!!t.wireframe),t.wireframe=!0,i.needsUpdate=!0),t.color?.isColor&&(this._prevColorMesh.has(i)||this._prevColorMesh.set(i,t.color.clone()),t.color.copy(this._wireColor))}};Sh=hS([He(),uS(0,fe("RendererApi"))],Sh);const uu=16776960,du=16755200,dS=2236962;var fS=Object.getOwnPropertyDescriptor,pS=(i,t,e,n)=>{for(var s=n>1?void 0:n?fS(t,e):t,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=a(s)||s);return s},Df=(i,t)=>(e,n)=>t(e,n,i);let Eh=class{constructor(i,t){this._api=i,this._store=t}mode=Ln.Mesh;_hoveredMesh=null;_selectedMesh=null;_hoverColor=uu;_selectColor=du;_origLineColors=new WeakMap;handle(i,t){if(this._api.setRaycastMode(this.mode),t===Oi.Hover){if(!i){this._hoveredMesh&&this._hoveredMesh!==this._selectedMesh&&this._restoreEdgesColor(this._hoveredMesh),this._hoveredMesh=null;return}const e=i.intersection.object;this._hoveredMesh!==e&&(this._hoveredMesh&&this._hoveredMesh!==this._selectedMesh&&this._restoreEdgesColor(this._hoveredMesh),e!==this._selectedMesh&&this._paintEdges(e,this._hoverColor),this._hoveredMesh=e)}if(t===Oi.Click){if(!i){this._selectedMesh&&(this._restoreEdgesColor(this._selectedMesh),this._selectedMesh=null,this._store.setSelectedObject(null));return}const e=i.intersection.object;this._selectedMesh&&this._selectedMesh!==e&&this._restoreEdgesColor(this._selectedMesh),this._paintEdges(e,this._selectColor),this._selectedMesh=e,this._store.setSelectedObject(e)}}rollback(){this._hoveredMesh&&this._restoreEdgesColor(this._hoveredMesh),this._selectedMesh&&this._restoreEdgesColor(this._selectedMesh),this._hoveredMesh=this._selectedMesh=null}dispose(){this.rollback()}_paintEdges(i,t){i.children.forEach(e=>{const n=e;if(n.isLineSegments&&n.material){const s=n.material;this._origLineColors.has(n)||this._origLineColors.set(n,s.color.clone()),s.color.setHex(t),s.needsUpdate=!0}})}_restoreEdgesColor(i){i.children.forEach(t=>{const e=t;if(e.isLineSegments&&e.material){const n=this._origLineColors.get(e);if(n){const s=e.material;s.color.copy(n),s.needsUpdate=!0}}})}};Eh=pS([He(),Df(0,fe("RendererApi")),Df(1,fe("IEditorStore"))],Eh);var mS=Object.getOwnPropertyDescriptor,_S=(i,t,e,n)=>{for(var s=n>1?void 0:n?mS(t,e):t,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=a(s)||s);return s},xS=(i,t)=>(e,n)=>t(e,n,i);let wh=class{constructor(i){this._api=i}mode=Ln.Face;_hovered=null;_selected=null;_hoverColor=uu;_selectColor=du;_defaultColor=2236962;handle(i,t){this._api.setRaycastMode(this.mode),t===Oi.Hover&&console.log(i),t===Oi.Click&&console.log(i)}rollback(){throw new Error("Method not implemented.")}dispose(){throw new Error("Method not implemented.")}};wh=_S([He(),xS(0,fe("RendererApi"))],wh);class fu{constructor(t,e){this.api=t,this.store=e}handle(){const t=this.store.getSelectedObject();this.api.setMode(this.mode),t?this.api.attach(t):this.api.detach()}rollback(){this.api.detach()}dispose(){this.rollback()}}var gS=Object.getOwnPropertyDescriptor,vS=(i,t,e,n)=>{for(var s=n>1?void 0:n?gS(t,e):t,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=a(s)||s);return s},Of=(i,t)=>(e,n)=>t(e,n,i);let Th=class extends fu{mode=Qi.Translate;constructor(i,t){super(i,t)}};Th=vS([He(),Of(0,fe("RendererApi")),Of(1,fe("IEditorStore"))],Th);var yS=Object.getOwnPropertyDescriptor,bS=(i,t,e,n)=>{for(var s=n>1?void 0:n?yS(t,e):t,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=a(s)||s);return s},Lf=(i,t)=>(e,n)=>t(e,n,i);let Ah=class extends fu{mode=Qi.Scale;constructor(i,t){super(i,t)}};Ah=bS([He(),Lf(0,fe("RendererApi")),Lf(1,fe("IEditorStore"))],Ah);var MS=Object.getOwnPropertyDescriptor,SS=(i,t,e,n)=>{for(var s=n>1?void 0:n?MS(t,e):t,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=a(s)||s);return s},Nf=(i,t)=>(e,n)=>t(e,n,i);let Ch=class extends fu{mode=Qi.Rotate;constructor(i,t){super(i,t)}};Ch=SS([He(),Nf(0,fe("RendererApi")),Nf(1,fe("IEditorStore"))],Ch);const So=31;var ES=Object.getOwnPropertyDescriptor,wS=(i,t,e,n)=>{for(var s=n>1?void 0:n?ES(t,e):t,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=a(s)||s);return s},If=(i,t)=>(e,n)=>t(e,n,i);let Rh=class{constructor(i,t){this._api=i,this._store=t,this._api.enableCameraLayer(So),this._hoverLine=this._makeOverlayLine(this._hoverColor),this._selectLine=this._makeOverlayLine(this._selectColor),this._api.addObject(this._hoverLine,So),this._api.addObject(this._selectLine,So)}mode=Ln.Edge;_hoverLine;_selectLine;_hovered=null;_selected=null;_hoverColor=uu;_selectColor=du;handle(i,t){if(this._api.setRaycastMode(this.mode),t===Oi.Hover){if(!i){this._hoverLine.visible=!1,this._hovered=null;return}const e=i.intersection.object;if(!e?.isLineSegments)return;const n=e,s=Math.floor((i.intersection.index??-1)/2);if(s<0)return;this._selected&&this._same({lines:n,seg:s},this._selected)?this._hoverLine.visible=!1:(this._writeWorldSegment(this._hoverLine,n,s),this._hoverLine.visible=!0),this._hovered={lines:n,seg:s};return}if(t===Oi.Click){if(!i){this._selectLine.visible=!1,this._selected=null,this._store.setSelectedObject(null);return}const e=i.intersection.object;if(!e?.isLineSegments)return;const n=e,s=Math.floor((i.intersection.index??-1)/2);if(s<0)return;this._writeWorldSegment(this._selectLine,n,s),this._centerAndOrientLineOnSegment(this._selectLine,n,s),this._selectLine.visible=!0,this._store.setSelectedObject(this._selectLine),this._selected={lines:n,seg:s},this._hovered&&this._same(this._hovered,this._selected)&&(this._hoverLine.visible=!1)}}rollback(){this._hoverLine.visible=!1,this._selectLine.visible=!1,this._hovered=this._selected=null}dispose(){this.rollback(),this._api.removeObject(this._hoverLine),this._api.removeObject(this._selectLine),this._hoverLine.geometry.dispose(),this._hoverLine.material.dispose(),this._selectLine.geometry.dispose(),this._selectLine.material.dispose()}_makeOverlayLine(i){const t=new De;t.setAttribute("position",new Jt(6,3));const e=new Dr({color:i,depthTest:!1,depthWrite:!1,transparent:!0,opacity:1}),n=new ni(t,e);return n.renderOrder=1e3,n.raycast=()=>{},n.layers.set(So),n.visible=!1,n}_writeWorldSegment(i,t,e){const n=t.geometry.getAttribute("position"),s=e*2,r=s+1,a=new I(n.getX(s),n.getY(s),n.getZ(s)).applyMatrix4(t.matrixWorld),o=new I(n.getX(r),n.getY(r),n.getZ(r)).applyMatrix4(t.matrixWorld),l=i.geometry.getAttribute("position");l.setXYZ(0,a.x,a.y,a.z),l.setXYZ(1,o.x,o.y,o.z),l.needsUpdate=!0}_same(i,t){return!!i&&!!t&&i.lines===t.lines&&i.seg===t.seg}_centerAndOrientLineOnSegment(i,t,e){const n=t.geometry.getAttribute("position"),s=e*2,r=s+1,a=new I(n.getX(s),n.getY(s),n.getZ(s)).applyMatrix4(t.matrixWorld),o=new I(n.getX(r),n.getY(r),n.getZ(r)).applyMatrix4(t.matrixWorld),l=new I().subVectors(o,a),c=l.length();if(!isFinite(c)||c===0)return;const h=new I().addVectors(a,o).multiplyScalar(.5);i.position.copy(h);const u=i.geometry;let d=u.getAttribute("position");(!d||d.count<2)&&(u.setAttribute("position",new Yn(new Float32Array(6),3)),d=u.getAttribute("position")),d.setXYZ(0,-c/2,0,0),d.setXYZ(1,c/2,0,0),d.needsUpdate=!0,l.normalize();const f=new ke().setFromUnitVectors(new I(1,0,0),l);i.quaternion.copy(f),i.updateMatrixWorld(!0)}};Rh=wS([He(),If(0,fe("RendererApi")),If(1,fe("IEditorStore"))],Rh);var TS=Object.getOwnPropertyDescriptor,AS=(i,t,e,n)=>{for(var s=n>1?void 0:n?TS(t,e):t,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=a(s)||s);return s},CS=(i,t)=>(e,n)=>t(e,n,i);let Ph=class{constructor(i){this._api=i}mode=gr.AddFigure;_lastAddedMesh=null;handle(i){const t=lb[i](),e=t.getAttribute("position");e&&e.setUsage&&e.setUsage(P0);const n=new gt(t,Op);n.layers.enable(0);const s=new Sp(n.geometry),r=new eu(s,new Dr({color:dS,linewidth:1}));r.layers.set(1),n.add(r),this._api.addMesh(n),this._lastAddedMesh=n}rollback(){this._lastAddedMesh!==null&&(this._api.removeMesh(this._lastAddedMesh),this._lastAddedMesh=null)}dispose(){this._lastAddedMesh=null}};Ph=AS([He(),CS(0,fe("RendererApi"))],Ph);const RS=i=>!!i&&i.isMesh;var PS=Object.getOwnPropertyDescriptor,DS=(i,t,e,n)=>{for(var s=n>1?void 0:n?PS(t,e):t,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=a(s)||s);return s},Uf=(i,t)=>(e,n)=>t(e,n,i);let Dh=class{constructor(i,t){this._api=i,this._store=t}mode=gr.DeleteFigure;_lastDeletedMesh=null;handle(){const i=this._store.getSelectedObject();RS(i)&&(this._api.removeMesh(i),this._store.setSelectedObject(null),this._lastDeletedMesh=i)}rollback(){this._lastDeletedMesh&&(this._api.addMesh(this._lastDeletedMesh),this._lastDeletedMesh=null)}dispose(){this._lastDeletedMesh=null}};Dh=DS([He(),Uf(0,fe("RendererApi")),Uf(1,fe("IEditorStore"))],Dh);var OS=Object.getOwnPropertyDescriptor,LS=(i,t,e,n)=>{for(var s=n>1?void 0:n?OS(t,e):t,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=a(s)||s);return s},NS=(i,t)=>(e,n)=>t(e,n,i);let Oh=class{constructor(i){this._renderer=i}addMesh(i){this._renderer.addMesh(i)}addMeshes(i){for(const t of i)this._renderer.addMesh(t)}removeMesh(i){this._renderer.removeMesh(i)}removeMeshes(i){for(const t of i)this._renderer.removeMesh(t)}getMeshes(){return this._renderer.getMeshes()}setMode(i){this._renderer.setTransformControlsMode(i)}attach(i){this._renderer.attachTransformControls(i)}detach(){this._renderer.detachTransformControls()}setRaycastMode(i){this._renderer.setRaycastMode(i)}addObject(i,t){this._renderer.addObject(i,t)}removeObject(i){this._renderer.removeObject(i)}enableCameraLayer(i){this._renderer.enableCameraLayer(i)}};Oh=LS([He(),NS(0,fe("EditorRenderer"))],Oh);var IS=Object.getOwnPropertyDescriptor,US=(i,t,e,n)=>{for(var s=n>1?void 0:n?IS(t,e):t,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=a(s)||s);return s},ta=(i,t)=>(e,n)=>t(e,n,i);exports.EditorHub=class{constructor(t,e,n,s,r){this._displayManager=t,this._selectManager=e,this._toolManager=n,this._sceneManager=s,this._renderer=r,this.setSelectMode(Ln.Mesh),this.setToolMode(Qi.Translate)}setDisplayMode(t){this._displayManager.manage(t)}setSceneMode(t){this._sceneManager.manage(t)}setSelectMode(t){this._selectManager.manage(t)}setToolMode(t){this._toolManager.manage(t)}resizeRenderer(){this._renderer.resize()}updateRenderer(){this._renderer.loop()}addFigure(t,e){this._sceneManager.manage(t,e)}dispose(){this._displayManager.dispose(),this._selectManager.dispose(),this._renderer.dispose()}};exports.EditorHub=US([He(),ta(0,fe("IDisplayManager")),ta(1,fe("ISelectManager")),ta(2,fe("IToolManager")),ta(3,fe("ISceneManager")),ta(4,fe("EditorRenderer"))],exports.EditorHub);var FS={0:"Invalid value for configuration 'enforceActions', expected 'never', 'always' or 'observed'",1:function(t,e){return"Cannot apply '"+t+"' to '"+e.toString()+"': Field not found."},5:"'keys()' can only be used on observable objects, arrays, sets and maps",6:"'values()' can only be used on observable objects, arrays, sets and maps",7:"'entries()' can only be used on observable objects, arrays and maps",8:"'set()' can only be used on observable objects, arrays and maps",9:"'remove()' can only be used on observable objects, arrays and maps",10:"'has()' can only be used on observable objects, arrays and maps",11:"'get()' can only be used on observable objects, arrays and maps",12:"Invalid annotation",13:"Dynamic observable objects cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)",14:"Intercept handlers should return nothing or a change object",15:"Observable arrays cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)",16:"Modification exception: the internal structure of an observable array was changed.",17:function(t,e){return"[mobx.array] Index out of bounds, "+t+" is larger than "+e},18:"mobx.map requires Map polyfill for the current browser. Check babel-polyfill or core-js/es6/map.js",19:function(t){return"Cannot initialize from classes that inherit from Map: "+t.constructor.name},20:function(t){return"Cannot initialize map from "+t},21:function(t){return"Cannot convert to map from '"+t+"'"},22:"mobx.set requires Set polyfill for the current browser. Check babel-polyfill or core-js/es6/set.js",23:"It is not possible to get index atoms from arrays",24:function(t){return"Cannot obtain administration from "+t},25:function(t,e){return"the entry '"+t+"' does not exist in the observable map '"+e+"'"},26:"please specify a property",27:function(t,e){return"no observable property '"+t.toString()+"' found on the observable object '"+e+"'"},28:function(t){return"Cannot obtain atom from "+t},29:"Expecting some object",30:"invalid action stack. did you forget to finish an action?",31:"missing option for computed: get",32:function(t,e){return"Cycle detected in computation "+t+": "+e},33:function(t){return"The setter of computed value '"+t+"' is trying to update itself. Did you intend to update an _observable_ value, instead of the computed property?"},34:function(t){return"[ComputedValue '"+t+"'] It is not possible to assign a new value to a computed value."},35:"There are multiple, different versions of MobX active. Make sure MobX is loaded only once or use `configure({ isolateGlobalState: true })`",36:"isolateGlobalState should be called before MobX is running any reactions",37:function(t){return"[mobx] `observableArray."+t+"()` mutates the array in-place, which is not allowed inside a derivation. Use `array.slice()."+t+"()` instead"},38:"'ownKeys()' can only be used on observable objects",39:"'defineProperty()' can only be used on observable objects"},zS=process.env.NODE_ENV!=="production"?FS:{};function vt(i){for(var t=arguments.length,e=new Array(t>1?t-1:0),n=1;n<t;n++)e[n-1]=arguments[n];if(process.env.NODE_ENV!=="production"){var s=typeof i=="string"?i:zS[i];throw typeof s=="function"&&(s=s.apply(null,e)),new Error("[MobX] "+s)}throw new Error(typeof i=="number"?"[MobX] minified error nr: "+i+(e.length?" "+e.map(String).join(","):"")+". Find the full error at: https://github.com/mobxjs/mobx/blob/main/packages/mobx/src/errors.ts":"[MobX] "+i)}var BS={};function pu(){return typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:BS}var jp=Object.assign,Go=Object.getOwnPropertyDescriptor,ci=Object.defineProperty,hl=Object.prototype,Wo=[];Object.freeze(Wo);var Yp={};Object.freeze(Yp);var kS=typeof Proxy<"u",VS=Object.toString();function qp(){kS||vt(process.env.NODE_ENV!=="production"?"`Proxy` objects are not available in the current environment. Please configure MobX to enable a fallback implementation.`":"Proxy not available")}function ea(i){process.env.NODE_ENV!=="production"&&dt.verifyProxies&&vt("MobX is currently configured to be able to run in ES5 mode, but in ES5 MobX won't be able to "+i)}function Qn(){return++dt.mobxGuid}function mu(i){var t=!1;return function(){if(!t)return t=!0,i.apply(this,arguments)}}var ur=function(){};function Ue(i){return typeof i=="function"}function Cs(i){var t=typeof i;switch(t){case"string":case"symbol":case"number":return!0}return!1}function ul(i){return i!==null&&typeof i=="object"}function gn(i){if(!ul(i))return!1;var t=Object.getPrototypeOf(i);if(t==null)return!0;var e=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e.toString()===VS}function Zp(i){var t=i?.constructor;return t?t.name==="GeneratorFunction"||t.displayName==="GeneratorFunction":!1}function dl(i,t,e){ci(i,t,{enumerable:!1,writable:!0,configurable:!0,value:e})}function $p(i,t,e){ci(i,t,{enumerable:!1,writable:!1,configurable:!0,value:e})}function Ns(i,t){var e="isMobX"+i;return t.prototype[e]=!0,function(n){return ul(n)&&n[e]===!0}}function Nr(i){return i!=null&&Object.prototype.toString.call(i)==="[object Map]"}function HS(i){var t=Object.getPrototypeOf(i),e=Object.getPrototypeOf(t),n=Object.getPrototypeOf(e);return n===null}function Mi(i){return i!=null&&Object.prototype.toString.call(i)==="[object Set]"}var Kp=typeof Object.getOwnPropertySymbols<"u";function GS(i){var t=Object.keys(i);if(!Kp)return t;var e=Object.getOwnPropertySymbols(i);return e.length?[].concat(t,e.filter(function(n){return hl.propertyIsEnumerable.call(i,n)})):t}var fa=typeof Reflect<"u"&&Reflect.ownKeys?Reflect.ownKeys:Kp?function(i){return Object.getOwnPropertyNames(i).concat(Object.getOwnPropertySymbols(i))}:Object.getOwnPropertyNames;function Lh(i){return typeof i=="string"?i:typeof i=="symbol"?i.toString():new String(i).toString()}function Jp(i){return i===null?null:typeof i=="object"?""+i:i}function Zn(i,t){return hl.hasOwnProperty.call(i,t)}var WS=Object.getOwnPropertyDescriptors||function(t){var e={};return fa(t).forEach(function(n){e[n]=Go(t,n)}),e};function mn(i,t){return!!(i&t)}function _n(i,t,e){return e?i|=t:i&=~t,i}function Ff(i,t){(t==null||t>i.length)&&(t=i.length);for(var e=0,n=Array(t);e<t;e++)n[e]=i[e];return n}function XS(i,t){for(var e=0;e<t.length;e++){var n=t[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(i,YS(n.key),n)}}function Ir(i,t,e){return t&&XS(i.prototype,t),Object.defineProperty(i,"prototype",{writable:!1}),i}function dr(i,t){var e=typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(e)return(e=e.call(i)).next.bind(e);if(Array.isArray(i)||(e=qS(i))||t){e&&(i=e);var n=0;return function(){return n>=i.length?{done:!0}:{done:!1,value:i[n++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
3989
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ts(){return ts=Object.assign?Object.assign.bind():function(i){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var n in e)({}).hasOwnProperty.call(e,n)&&(i[n]=e[n])}return i},ts.apply(null,arguments)}function Qp(i,t){i.prototype=Object.create(t.prototype),i.prototype.constructor=i,Nh(i,t)}function Nh(i,t){return Nh=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,n){return e.__proto__=n,e},Nh(i,t)}function jS(i,t){if(typeof i!="object"||!i)return i;var e=i[Symbol.toPrimitive];if(e!==void 0){var n=e.call(i,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(i)}function YS(i){var t=jS(i,"string");return typeof t=="symbol"?t:t+""}function qS(i,t){if(i){if(typeof i=="string")return Ff(i,t);var e={}.toString.call(i).slice(8,-1);return e==="Object"&&i.constructor&&(e=i.constructor.name),e==="Map"||e==="Set"?Array.from(i):e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Ff(i,t):void 0}}var Si=Symbol("mobx-stored-annotations");function hi(i){function t(e,n){if(Sa(n))return i.decorate_20223_(e,n);Ma(e,n,i)}return Object.assign(t,i)}function Ma(i,t,e){if(Zn(i,Si)||dl(i,Si,ts({},i[Si])),process.env.NODE_ENV!=="production"&&jo(e)&&!Zn(i[Si],t)){var n=i.constructor.name+".prototype."+t.toString();vt("'"+n+"' is decorated with 'override', but no such decorated member was found on prototype.")}ZS(i,e,t),jo(e)||(i[Si][t]=e)}function ZS(i,t,e){if(process.env.NODE_ENV!=="production"&&!jo(t)&&Zn(i[Si],e)){var n=i.constructor.name+".prototype."+e.toString(),s=i[Si][e].annotationType_,r=t.annotationType_;vt("Cannot apply '@"+r+"' to '"+n+"':"+(`
3990
+ The field is already decorated with '@`+s+"'.")+`
3872
3991
  Re-decorating fields is not allowed.
3873
- Use '@override' decorator for methods overridden by subclass.`)}}function gs(n){return typeof n=="object"&&typeof n.kind=="string"}function Ho(n,e){process.env.NODE_ENV!=="production"&&!e.includes(n.kind)&&ve("The decorator applied to '"+String(n.name)+"' cannot be used on a "+n.kind+" element")}var Fe=Symbol("mobx administration"),yi=(function(){function n(t){t===void 0&&(t=process.env.NODE_ENV!=="production"?"Atom@"+Dn():"Atom"),this.name_=void 0,this.flags_=0,this.observers_=new Set,this.lastAccessedBy_=0,this.lowestObserverState_=et.NOT_TRACKING_,this.onBOL=void 0,this.onBUOL=void 0,this.name_=t}var e=n.prototype;return e.onBO=function(){this.onBOL&&this.onBOL.forEach(function(i){return i()})},e.onBUO=function(){this.onBUOL&&this.onBUOL.forEach(function(i){return i()})},e.reportObserved=function(){return Hf(this)},e.reportChanged=function(){pn(),kf(this),mn()},e.toString=function(){return this.name_},Fr(n,[{key:"isBeingObserved",get:function(){return Zt(this.flags_,n.isBeingObservedMask_)},set:function(i){this.flags_=Kt(this.flags_,n.isBeingObservedMask_,i)}},{key:"isPendingUnobservation",get:function(){return Zt(this.flags_,n.isPendingUnobservationMask_)},set:function(i){this.flags_=Kt(this.flags_,n.isPendingUnobservationMask_,i)}},{key:"diffValue",get:function(){return Zt(this.flags_,n.diffValueMask_)?1:0},set:function(i){this.flags_=Kt(this.flags_,n.diffValueMask_,i===1)}}])})();yi.isBeingObservedMask_=1;yi.isPendingUnobservationMask_=2;yi.diffValueMask_=4;var Ac=Zi("Atom",yi);function Af(n,e,t){e===void 0&&(e=vr),t===void 0&&(t=vr);var i=new yi(n);return e!==vr&&LM(i,e),t!==vr&&qf(i,t),i}function Ey(n,e){return od(n,e)}function by(n,e){return Object.is?Object.is(n,e):n===e?n!==0||1/n===1/e:n!==n&&e!==e}var bo={structural:Ey,default:by};function Wi(n,e,t){return fs(n)?n:Array.isArray(n)?Ot.array(n,{name:t}):Jt(n)?Ot.object(n,void 0,{name:t}):Ur(n)?Ot.map(n,{name:t}):$n(n)?Ot.set(n,{name:t}):typeof n=="function"&&!Yi(n)&&!hs(n)?Ef(n)?Dr(n):us(t,n):n}function Sy(n,e,t){if(n==null||zr(n)||jo(n)||Mi(n)||Un(n))return n;if(Array.isArray(n))return Ot.array(n,{name:t,deep:!1});if(Jt(n))return Ot.object(n,void 0,{name:t,deep:!1});if(Ur(n))return Ot.map(n,{name:t,deep:!1});if($n(n))return Ot.set(n,{name:t,deep:!1});process.env.NODE_ENV!=="production"&&ve("The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets")}function ko(n){return n}function Ty(n,e){return process.env.NODE_ENV!=="production"&&fs(n)&&ve("observable.struct should not be used with observable values"),od(n,e)?e:n}var wy="override";function So(n){return n.annotationType_===wy}function vs(n,e){return{annotationType_:n,options_:e,make_:Ay,extend_:Ry,decorate_20223_:Cy}}function Ay(n,e,t,i){var r;if((r=this.options_)!=null&&r.bound)return this.extend_(n,e,t,!1)===null?0:1;if(i===n.target_)return this.extend_(n,e,t,!1)===null?0:2;if(Yi(t.value))return 1;var s=Rf(n,this,e,t,!1);return Vn(i,e,s),2}function Ry(n,e,t,i){var r=Rf(n,this,e,t);return n.defineProperty_(e,r,i)}function Cy(n,e){process.env.NODE_ENV!=="production"&&Ho(e,["method","field"]);var t=e.kind,i=e.name,r=e.addInitializer,s=this,o=function(c){var u,h,d,p;return Xi((u=(h=s.options_)==null?void 0:h.name)!=null?u:i.toString(),c,(d=(p=s.options_)==null?void 0:p.autoAction)!=null?d:!1)};if(t=="field")return function(l){var c,u=l;return Yi(u)||(u=o(u)),(c=s.options_)!=null&&c.bound&&(u=u.bind(this),u.isMobxAction=!0),u};if(t=="method"){var a;return Yi(n)||(n=o(n)),(a=this.options_)!=null&&a.bound&&r(function(){var l=this,c=l[i].bind(l);c.isMobxAction=!0,l[i]=c}),n}ve("Cannot apply '"+s.annotationType_+"' to '"+String(i)+"' (kind: "+t+"):"+(`
3874
- '`+s.annotationType_+"' can only be used on properties with a function value."))}function Py(n,e,t,i){var r=e.annotationType_,s=i.value;process.env.NODE_ENV!=="production"&&!Rt(s)&&ve("Cannot apply '"+r+"' to '"+n.name_+"."+t.toString()+"':"+(`
3875
- '`+r+"' can only be used on properties with a function value."))}function Rf(n,e,t,i,r){var s,o,a,l,c,u,h;r===void 0&&(r=he.safeDescriptors),Py(n,e,t,i);var d=i.value;if((s=e.options_)!=null&&s.bound){var p;d=d.bind((p=n.proxy_)!=null?p:n.target_)}return{value:Xi((o=(a=e.options_)==null?void 0:a.name)!=null?o:t.toString(),d,(l=(c=e.options_)==null?void 0:c.autoAction)!=null?l:!1,(u=e.options_)!=null&&u.bound?(h=n.proxy_)!=null?h:n.target_:void 0),configurable:r?n.isPlainObject_:!0,enumerable:!1,writable:!r}}function Cf(n,e){return{annotationType_:n,options_:e,make_:Dy,extend_:Ly,decorate_20223_:Oy}}function Dy(n,e,t,i){var r;if(i===n.target_)return this.extend_(n,e,t,!1)===null?0:2;if((r=this.options_)!=null&&r.bound&&(!An(n.target_,e)||!hs(n.target_[e]))&&this.extend_(n,e,t,!1)===null)return 0;if(hs(t.value))return 1;var s=Pf(n,this,e,t,!1,!1);return Vn(i,e,s),2}function Ly(n,e,t,i){var r,s=Pf(n,this,e,t,(r=this.options_)==null?void 0:r.bound);return n.defineProperty_(e,s,i)}function Oy(n,e){var t;process.env.NODE_ENV!=="production"&&Ho(e,["method"]);var i=e.name,r=e.addInitializer;return hs(n)||(n=Dr(n)),(t=this.options_)!=null&&t.bound&&r(function(){var s=this,o=s[i].bind(s);o.isMobXFlow=!0,s[i]=o}),n}function Iy(n,e,t,i){var r=e.annotationType_,s=i.value;process.env.NODE_ENV!=="production"&&!Rt(s)&&ve("Cannot apply '"+r+"' to '"+n.name_+"."+t.toString()+"':"+(`
3876
- '`+r+"' can only be used on properties with a generator function value."))}function Pf(n,e,t,i,r,s){s===void 0&&(s=he.safeDescriptors),Iy(n,e,t,i);var o=i.value;if(hs(o)||(o=Dr(o)),r){var a;o=o.bind((a=n.proxy_)!=null?a:n.target_),o.isMobXFlow=!0}return{value:o,configurable:s?n.isPlainObject_:!0,enumerable:!1,writable:!s}}function Rc(n,e){return{annotationType_:n,options_:e,make_:Ny,extend_:Uy,decorate_20223_:Fy}}function Ny(n,e,t){return this.extend_(n,e,t,!1)===null?0:1}function Uy(n,e,t,i){return By(n,this,e,t),n.defineComputedProperty_(e,vi({},this.options_,{get:t.get,set:t.set}),i)}function Fy(n,e){process.env.NODE_ENV!=="production"&&Ho(e,["getter"]);var t=this,i=e.name,r=e.addInitializer;return r(function(){var s=Br(this)[Fe],o=vi({},t.options_,{get:n,context:this});o.name||(o.name=process.env.NODE_ENV!=="production"?s.name_+"."+i.toString():"ObservableObject."+i.toString()),s.values_.set(i,new gn(o))}),function(){return this[Fe].getObservablePropValue_(i)}}function By(n,e,t,i){var r=e.annotationType_,s=i.get;process.env.NODE_ENV!=="production"&&!s&&ve("Cannot apply '"+r+"' to '"+n.name_+"."+t.toString()+"':"+(`
3877
- '`+r+"' can only be used on getter(+setter) properties."))}function Go(n,e){return{annotationType_:n,options_:e,make_:zy,extend_:Vy,decorate_20223_:Hy}}function zy(n,e,t){return this.extend_(n,e,t,!1)===null?0:1}function Vy(n,e,t,i){var r,s;return ky(n,this,e,t),n.defineObservableProperty_(e,t.value,(r=(s=this.options_)==null?void 0:s.enhancer)!=null?r:Wi,i)}function Hy(n,e){if(process.env.NODE_ENV!=="production"){if(e.kind==="field")throw ve("Please use `@observable accessor "+String(e.name)+"` instead of `@observable "+String(e.name)+"`");Ho(e,["accessor"])}var t=this,i=e.kind,r=e.name,s=new WeakSet;function o(a,l){var c,u,h=Br(a)[Fe],d=new Vi(l,(c=(u=t.options_)==null?void 0:u.enhancer)!=null?c:Wi,process.env.NODE_ENV!=="production"?h.name_+"."+r.toString():"ObservableObject."+r.toString(),!1);h.values_.set(r,d),s.add(a)}if(i=="accessor")return{get:function(){return s.has(this)||o(this,n.get.call(this)),this[Fe].getObservablePropValue_(r)},set:function(l){return s.has(this)||o(this,l),this[Fe].setObservablePropValue_(r,l)},init:function(l){return s.has(this)||o(this,l),l}}}function ky(n,e,t,i){var r=e.annotationType_;process.env.NODE_ENV!=="production"&&!("value"in i)&&ve("Cannot apply '"+r+"' to '"+n.name_+"."+t.toString()+"':"+(`
3878
- '`+r+"' cannot be used on getter/setter properties"))}var Gy="true",Wy=Df();function Df(n){return{annotationType_:Gy,options_:n,make_:Xy,extend_:jy,decorate_20223_:Yy}}function Xy(n,e,t,i){var r,s;if(t.get)return Wo.make_(n,e,t,i);if(t.set){var o=Yi(t.set)?t.set:Xi(e.toString(),t.set);return i===n.target_?n.defineProperty_(e,{configurable:he.safeDescriptors?n.isPlainObject_:!0,set:o})===null?0:2:(Vn(i,e,{configurable:!0,set:o}),2)}if(i!==n.target_&&typeof t.value=="function"){var a;if(Ef(t.value)){var l,c=(l=this.options_)!=null&&l.autoBind?Dr.bound:Dr;return c.make_(n,e,t,i)}var u=(a=this.options_)!=null&&a.autoBind?us.bound:us;return u.make_(n,e,t,i)}var h=((r=this.options_)==null?void 0:r.deep)===!1?Ot.ref:Ot;if(typeof t.value=="function"&&(s=this.options_)!=null&&s.autoBind){var d;t.value=t.value.bind((d=n.proxy_)!=null?d:n.target_)}return h.make_(n,e,t,i)}function jy(n,e,t,i){var r,s;if(t.get)return Wo.extend_(n,e,t,i);if(t.set)return n.defineProperty_(e,{configurable:he.safeDescriptors?n.isPlainObject_:!0,set:Xi(e.toString(),t.set)},i);if(typeof t.value=="function"&&(r=this.options_)!=null&&r.autoBind){var o;t.value=t.value.bind((o=n.proxy_)!=null?o:n.target_)}var a=((s=this.options_)==null?void 0:s.deep)===!1?Ot.ref:Ot;return a.extend_(n,e,t,i)}function Yy(n,e){ve("'"+this.annotationType_+"' cannot be used as a decorator")}var qy="observable",$y="observable.ref",Zy="observable.shallow",Ky="observable.struct",Lf={deep:!0,name:void 0,defaultDecorator:void 0,proxy:!0};Object.freeze(Lf);function io(n){return n||Lf}var Yl=Go(qy),Jy=Go($y,{enhancer:ko}),Qy=Go(Zy,{enhancer:Sy}),eM=Go(Ky,{enhancer:Ty}),Of=Hn(Yl);function ro(n){return n.deep===!0?Wi:n.deep===!1?ko:nM(n.defaultDecorator)}function tM(n){var e;return n?(e=n.defaultDecorator)!=null?e:Df(n):void 0}function nM(n){var e,t;return n&&(e=(t=n.options_)==null?void 0:t.enhancer)!=null?e:Wi}function If(n,e,t){if(gs(e))return Yl.decorate_20223_(n,e);if(Gi(e)){_s(n,e,Yl);return}return fs(n)?n:Jt(n)?Ot.object(n,e,t):Array.isArray(n)?Ot.array(n,e):Ur(n)?Ot.map(n,e):$n(n)?Ot.set(n,e):typeof n=="object"&&n!==null?n:Ot.box(n,e)}xf(If,Of);var iM={box:function(e,t){var i=io(t);return new Vi(e,ro(i),i.name,!0,i.equals)},array:function(e,t){var i=io(t);return(he.useProxies===!1||i.proxy===!1?tE:XM)(e,ro(i),i.name)},map:function(e,t){var i=io(t);return new ed(e,ro(i),i.name)},set:function(e,t){var i=io(t);return new td(e,ro(i),i.name)},object:function(e,t,i){return Ji(function(){return Zf(he.useProxies===!1||i?.proxy===!1?Br({},i):HM({},i),e,t)})},ref:Hn(Jy),shallow:Hn(Qy),deep:Of,struct:Hn(eM)},Ot=xf(If,iM),Nf="computed",rM="computed.struct",ql=Rc(Nf),sM=Rc(rM,{equals:bo.structural}),Wo=function(e,t){if(gs(t))return ql.decorate_20223_(e,t);if(Gi(t))return _s(e,t,ql);if(Jt(e))return Hn(Rc(Nf,e));process.env.NODE_ENV!=="production"&&(Rt(e)||ve("First argument to `computed` should be an expression."),Rt(t)&&ve("A setter as second argument is no longer supported, use `{ set: fn }` option instead"));var i=Jt(t)?t:{};return i.get=e,i.name||(i.name=e.name||""),new gn(i)};Object.assign(Wo,ql);Wo.struct=Hn(sM);var _h,gh,To=0,oM=1,aM=(_h=(gh=Mo(function(){},"name"))==null?void 0:gh.configurable)!=null?_h:!1,vh={value:"action",configurable:!0,writable:!1,enumerable:!1};function Xi(n,e,t,i){t===void 0&&(t=!1),process.env.NODE_ENV!=="production"&&(Rt(e)||ve("`action` can only be invoked on functions"),(typeof n!="string"||!n)&&ve("actions should have valid names, got: '"+n+"'"));function r(){return lM(n,t,e,i||this,arguments)}return r.isMobxAction=!0,r.toString=function(){return e.toString()},aM&&(vh.value=n,Vn(r,"name",vh)),r}function lM(n,e,t,i,r){var s=cM(n,e,i,r);try{return t.apply(i,r)}catch(o){throw s.error_=o,o}finally{uM(s)}}function cM(n,e,t,i){var r=process.env.NODE_ENV!=="production"&&It()&&!!n,s=0;if(process.env.NODE_ENV!=="production"&&r){s=Date.now();var o=i?Array.from(i):Eo;Qt({type:Lc,name:n,object:t,arguments:o})}var a=he.trackingDerivation,l=!e||!a;pn();var c=he.allowStateChanges;l&&(Ki(),c=Cc(!0));var u=Dc(!0),h={runAsAction_:l,prevDerivation_:a,prevAllowStateChanges_:c,prevAllowStateReads_:u,notifySpy_:r,startTime_:s,actionId_:oM++,parentActionId_:To};return To=h.actionId_,h}function uM(n){To!==n.actionId_&&ve(30),To=n.parentActionId_,n.error_!==void 0&&(he.suppressReactionErrors=!0),Pc(n.prevAllowStateChanges_),ns(n.prevAllowStateReads_),mn(),n.runAsAction_&&ei(n.prevDerivation_),process.env.NODE_ENV!=="production"&&n.notifySpy_&&en({time:Date.now()-n.startTime_}),he.suppressReactionErrors=!1}function Cc(n){var e=he.allowStateChanges;return he.allowStateChanges=n,e}function Pc(n){he.allowStateChanges=n}var hM="create",Vi=(function(n){function e(i,r,s,o,a){var l;if(s===void 0&&(s=process.env.NODE_ENV!=="production"?"ObservableValue@"+Dn():"ObservableValue"),o===void 0&&(o=!0),a===void 0&&(a=bo.default),l=n.call(this,s)||this,l.enhancer=void 0,l.name_=void 0,l.equals=void 0,l.hasUnreportedChange_=!1,l.interceptors_=void 0,l.changeListeners_=void 0,l.value_=void 0,l.dehancer=void 0,l.enhancer=r,l.name_=s,l.equals=a,l.value_=r(i,void 0,s),process.env.NODE_ENV!=="production"&&o&&It()){var c;ji({type:hM,object:l,observableKind:"value",debugObjectName:l.name_,newValue:""+((c=l.value_)==null?void 0:c.toString())})}return l}wf(e,n);var t=e.prototype;return t.dehanceValue=function(r){return this.dehancer!==void 0?this.dehancer(r):r},t.set=function(r){var s=this.value_;if(r=this.prepareNewValue_(r),r!==he.UNCHANGED){var o=It();process.env.NODE_ENV!=="production"&&o&&Qt({type:Sn,object:this,observableKind:"value",debugObjectName:this.name_,newValue:r,oldValue:s}),this.setNewValue_(r),process.env.NODE_ENV!=="production"&&o&&en()}},t.prepareNewValue_=function(r){if(zn(this),hn(this)){var s=fn(this,{object:this,type:Sn,newValue:r});if(!s)return he.UNCHANGED;r=s.newValue}return r=this.enhancer(r,this.value_,this.name_),this.equals(this.value_,r)?he.UNCHANGED:r},t.setNewValue_=function(r){var s=this.value_;this.value_=r,this.reportChanged(),Rn(this)&&Cn(this,{type:Sn,object:this,newValue:r,oldValue:s})},t.get=function(){return this.reportObserved(),this.dehanceValue(this.value_)},t.intercept_=function(r){return xs(this,r)},t.observe_=function(r,s){return s&&r({observableKind:"value",debugObjectName:this.name_,object:this,type:Sn,newValue:this.value_,oldValue:void 0}),ys(this,r)},t.raw=function(){return this.value_},t.toJSON=function(){return this.get()},t.toString=function(){return this.name_+"["+this.value_+"]"},t.valueOf=function(){return Tf(this.get())},t[Symbol.toPrimitive]=function(){return this.valueOf()},e})(yi),gn=(function(){function n(t){this.dependenciesState_=et.NOT_TRACKING_,this.observing_=[],this.newObserving_=null,this.observers_=new Set,this.runId_=0,this.lastAccessedBy_=0,this.lowestObserverState_=et.UP_TO_DATE_,this.unboundDepsCount_=0,this.value_=new wo(null),this.name_=void 0,this.triggeredBy_=void 0,this.flags_=0,this.derivation=void 0,this.setter_=void 0,this.isTracing_=_n.NONE,this.scope_=void 0,this.equals_=void 0,this.requiresReaction_=void 0,this.keepAlive_=void 0,this.onBOL=void 0,this.onBUOL=void 0,t.get||ve(31),this.derivation=t.get,this.name_=t.name||(process.env.NODE_ENV!=="production"?"ComputedValue@"+Dn():"ComputedValue"),t.set&&(this.setter_=Xi(process.env.NODE_ENV!=="production"?this.name_+"-setter":"ComputedValue-setter",t.set)),this.equals_=t.equals||(t.compareStructural||t.struct?bo.structural:bo.default),this.scope_=t.context,this.requiresReaction_=t.requiresReaction,this.keepAlive_=!!t.keepAlive}var e=n.prototype;return e.onBecomeStale_=function(){gM(this)},e.onBO=function(){this.onBOL&&this.onBOL.forEach(function(i){return i()})},e.onBUO=function(){this.onBUOL&&this.onBUOL.forEach(function(i){return i()})},e.get=function(){if(this.isComputing&&ve(32,this.name_,this.derivation),he.inBatch===0&&this.observers_.size===0&&!this.keepAlive_)$l(this)&&(this.warnAboutUntrackedRead_(),pn(),this.value_=this.computeValue_(!1),mn());else if(Hf(this),$l(this)){var i=he.trackingContext;this.keepAlive_&&!i&&(he.trackingContext=this),this.trackAndCompute()&&_M(this),he.trackingContext=i}var r=this.value_;if(po(r))throw r.cause;return r},e.set=function(i){if(this.setter_){this.isRunningSetter&&ve(33,this.name_),this.isRunningSetter=!0;try{this.setter_.call(this.scope_,i)}finally{this.isRunningSetter=!1}}else ve(34,this.name_)},e.trackAndCompute=function(){var i=this.value_,r=this.dependenciesState_===et.NOT_TRACKING_,s=this.computeValue_(!0),o=r||po(i)||po(s)||!this.equals_(i,s);return o&&(this.value_=s,process.env.NODE_ENV!=="production"&&It()&&ji({observableKind:"computed",debugObjectName:this.name_,object:this.scope_,type:"update",oldValue:i,newValue:s})),o},e.computeValue_=function(i){this.isComputing=!0;var r=Cc(!1),s;if(i)s=Uf(this,this.derivation,this.scope_);else if(he.disableErrorBoundaries===!0)s=this.derivation.call(this.scope_);else try{s=this.derivation.call(this.scope_)}catch(o){s=new wo(o)}return Pc(r),this.isComputing=!1,s},e.suspend_=function(){this.keepAlive_||(Zl(this),this.value_=void 0,process.env.NODE_ENV!=="production"&&this.isTracing_!==_n.NONE&&console.log("[mobx.trace] Computed value '"+this.name_+"' was suspended and it will recompute on the next access."))},e.observe_=function(i,r){var s=this,o=!0,a=void 0;return AM(function(){var l=s.get();if(!o||r){var c=Ki();i({observableKind:"computed",debugObjectName:s.name_,type:Sn,object:s,newValue:l,oldValue:a}),ei(c)}o=!1,a=l})},e.warnAboutUntrackedRead_=function(){process.env.NODE_ENV!=="production"&&(this.isTracing_!==_n.NONE&&console.log("[mobx.trace] Computed value '"+this.name_+"' is being read outside a reactive context. Doing a full recompute."),(typeof this.requiresReaction_=="boolean"?this.requiresReaction_:he.computedRequiresReaction)&&console.warn("[mobx] Computed value '"+this.name_+"' is being read outside a reactive context. Doing a full recompute."))},e.toString=function(){return this.name_+"["+this.derivation.toString()+"]"},e.valueOf=function(){return Tf(this.get())},e[Symbol.toPrimitive]=function(){return this.valueOf()},Fr(n,[{key:"isComputing",get:function(){return Zt(this.flags_,n.isComputingMask_)},set:function(i){this.flags_=Kt(this.flags_,n.isComputingMask_,i)}},{key:"isRunningSetter",get:function(){return Zt(this.flags_,n.isRunningSetterMask_)},set:function(i){this.flags_=Kt(this.flags_,n.isRunningSetterMask_,i)}},{key:"isBeingObserved",get:function(){return Zt(this.flags_,n.isBeingObservedMask_)},set:function(i){this.flags_=Kt(this.flags_,n.isBeingObservedMask_,i)}},{key:"isPendingUnobservation",get:function(){return Zt(this.flags_,n.isPendingUnobservationMask_)},set:function(i){this.flags_=Kt(this.flags_,n.isPendingUnobservationMask_,i)}},{key:"diffValue",get:function(){return Zt(this.flags_,n.diffValueMask_)?1:0},set:function(i){this.flags_=Kt(this.flags_,n.diffValueMask_,i===1)}}])})();gn.isComputingMask_=1;gn.isRunningSetterMask_=2;gn.isBeingObservedMask_=4;gn.isPendingUnobservationMask_=8;gn.diffValueMask_=16;var Xo=Zi("ComputedValue",gn),et;(function(n){n[n.NOT_TRACKING_=-1]="NOT_TRACKING_",n[n.UP_TO_DATE_=0]="UP_TO_DATE_",n[n.POSSIBLY_STALE_=1]="POSSIBLY_STALE_",n[n.STALE_=2]="STALE_"})(et||(et={}));var _n;(function(n){n[n.NONE=0]="NONE",n[n.LOG=1]="LOG",n[n.BREAK=2]="BREAK"})(_n||(_n={}));var wo=function(e){this.cause=void 0,this.cause=e};function po(n){return n instanceof wo}function $l(n){switch(n.dependenciesState_){case et.UP_TO_DATE_:return!1;case et.NOT_TRACKING_:case et.STALE_:return!0;case et.POSSIBLY_STALE_:{for(var e=Dc(!0),t=Ki(),i=n.observing_,r=i.length,s=0;s<r;s++){var o=i[s];if(Xo(o)){if(he.disableErrorBoundaries)o.get();else try{o.get()}catch{return ei(t),ns(e),!0}if(n.dependenciesState_===et.STALE_)return ei(t),ns(e),!0}}return Bf(n),ei(t),ns(e),!1}}}function zn(n){if(process.env.NODE_ENV!=="production"){var e=n.observers_.size>0;!he.allowStateChanges&&(e||he.enforceActions==="always")&&console.warn("[MobX] "+(he.enforceActions?"Since strict-mode is enabled, changing (observed) observable values without using an action is not allowed. Tried to modify: ":"Side effects like changing state are not allowed at this point. Are you trying to modify state from, for example, a computed value or the render function of a React component? You can wrap side effects in 'runInAction' (or decorate functions with 'action') if needed. Tried to modify: ")+n.name_)}}function fM(n){process.env.NODE_ENV!=="production"&&!he.allowStateReads&&he.observableRequiresReaction&&console.warn("[mobx] Observable '"+n.name_+"' being read outside a reactive context.")}function Uf(n,e,t){var i=Dc(!0);Bf(n),n.newObserving_=new Array(n.runId_===0?100:n.observing_.length),n.unboundDepsCount_=0,n.runId_=++he.runId;var r=he.trackingDerivation;he.trackingDerivation=n,he.inBatch++;var s;if(he.disableErrorBoundaries===!0)s=e.call(t);else try{s=e.call(t)}catch(o){s=new wo(o)}return he.inBatch--,he.trackingDerivation=r,pM(n),dM(n),ns(i),s}function dM(n){process.env.NODE_ENV!=="production"&&n.observing_.length===0&&(typeof n.requiresObservable_=="boolean"?n.requiresObservable_:he.reactionRequiresObservable)&&console.warn("[mobx] Derivation '"+n.name_+"' is created/updated without reading any observable value.")}function pM(n){for(var e=n.observing_,t=n.observing_=n.newObserving_,i=et.UP_TO_DATE_,r=0,s=n.unboundDepsCount_,o=0;o<s;o++){var a=t[o];a.diffValue===0&&(a.diffValue=1,r!==o&&(t[r]=a),r++),a.dependenciesState_>i&&(i=a.dependenciesState_)}for(t.length=r,n.newObserving_=null,s=e.length;s--;){var l=e[s];l.diffValue===0&&zf(l,n),l.diffValue=0}for(;r--;){var c=t[r];c.diffValue===1&&(c.diffValue=0,mM(c,n))}i!==et.UP_TO_DATE_&&(n.dependenciesState_=i,n.onBecomeStale_())}function Zl(n){var e=n.observing_;n.observing_=[];for(var t=e.length;t--;)zf(e[t],n);n.dependenciesState_=et.NOT_TRACKING_}function Ff(n){var e=Ki();try{return n()}finally{ei(e)}}function Ki(){var n=he.trackingDerivation;return he.trackingDerivation=null,n}function ei(n){he.trackingDerivation=n}function Dc(n){var e=he.allowStateReads;return he.allowStateReads=n,e}function ns(n){he.allowStateReads=n}function Bf(n){if(n.dependenciesState_!==et.UP_TO_DATE_){n.dependenciesState_=et.UP_TO_DATE_;for(var e=n.observing_,t=e.length;t--;)e[t].lowestObserverState_=et.UP_TO_DATE_}}var La=function(){this.version=6,this.UNCHANGED={},this.trackingDerivation=null,this.trackingContext=null,this.runId=0,this.mobxGuid=0,this.inBatch=0,this.pendingUnobservations=[],this.pendingReactions=[],this.isRunningReactions=!1,this.allowStateChanges=!1,this.allowStateReads=!0,this.enforceActions=!0,this.spyListeners=[],this.globalReactionErrorHandlers=[],this.computedRequiresReaction=!1,this.reactionRequiresObservable=!1,this.observableRequiresReaction=!1,this.disableErrorBoundaries=!1,this.suppressReactionErrors=!1,this.useProxies=!0,this.verifyProxies=!1,this.safeDescriptors=!0},Oa=!0,he=(function(){var n=Tc();return n.__mobxInstanceCount>0&&!n.__mobxGlobals&&(Oa=!1),n.__mobxGlobals&&n.__mobxGlobals.version!==new La().version&&(Oa=!1),Oa?n.__mobxGlobals?(n.__mobxInstanceCount+=1,n.__mobxGlobals.UNCHANGED||(n.__mobxGlobals.UNCHANGED={}),n.__mobxGlobals):(n.__mobxInstanceCount=1,n.__mobxGlobals=new La):(setTimeout(function(){ve(35)},1),new La)})();function mM(n,e){n.observers_.add(e),n.lowestObserverState_>e.dependenciesState_&&(n.lowestObserverState_=e.dependenciesState_)}function zf(n,e){n.observers_.delete(e),n.observers_.size===0&&Vf(n)}function Vf(n){n.isPendingUnobservation===!1&&(n.isPendingUnobservation=!0,he.pendingUnobservations.push(n))}function pn(){he.inBatch++}function mn(){if(--he.inBatch===0){Xf();for(var n=he.pendingUnobservations,e=0;e<n.length;e++){var t=n[e];t.isPendingUnobservation=!1,t.observers_.size===0&&(t.isBeingObserved&&(t.isBeingObserved=!1,t.onBUO()),t instanceof gn&&t.suspend_())}he.pendingUnobservations=[]}}function Hf(n){fM(n);var e=he.trackingDerivation;return e!==null?(e.runId_!==n.lastAccessedBy_&&(n.lastAccessedBy_=e.runId_,e.newObserving_[e.unboundDepsCount_++]=n,!n.isBeingObserved&&he.trackingContext&&(n.isBeingObserved=!0,n.onBO())),n.isBeingObserved):(n.observers_.size===0&&he.inBatch>0&&Vf(n),!1)}function kf(n){n.lowestObserverState_!==et.STALE_&&(n.lowestObserverState_=et.STALE_,n.observers_.forEach(function(e){e.dependenciesState_===et.UP_TO_DATE_&&(process.env.NODE_ENV!=="production"&&e.isTracing_!==_n.NONE&&Gf(e,n),e.onBecomeStale_()),e.dependenciesState_=et.STALE_}))}function _M(n){n.lowestObserverState_!==et.STALE_&&(n.lowestObserverState_=et.STALE_,n.observers_.forEach(function(e){e.dependenciesState_===et.POSSIBLY_STALE_?(e.dependenciesState_=et.STALE_,process.env.NODE_ENV!=="production"&&e.isTracing_!==_n.NONE&&Gf(e,n)):e.dependenciesState_===et.UP_TO_DATE_&&(n.lowestObserverState_=et.UP_TO_DATE_)}))}function gM(n){n.lowestObserverState_===et.UP_TO_DATE_&&(n.lowestObserverState_=et.POSSIBLY_STALE_,n.observers_.forEach(function(e){e.dependenciesState_===et.UP_TO_DATE_&&(e.dependenciesState_=et.POSSIBLY_STALE_,e.onBecomeStale_())}))}function Gf(n,e){if(console.log("[mobx.trace] '"+n.name_+"' is invalidated due to a change in: '"+e.name_+"'"),n.isTracing_===_n.BREAK){var t=[];Wf(OM(n),t,1),new Function(`debugger;
3992
+ Use '@override' decorator for methods overridden by subclass.`)}}function Sa(i){return typeof i=="object"&&typeof i.kind=="string"}function fl(i,t){process.env.NODE_ENV!=="production"&&!t.includes(i.kind)&&vt("The decorator applied to '"+String(i.name)+"' cannot be used on a "+i.kind+" element")}var zt=Symbol("mobx administration"),ns=(function(){function i(e){e===void 0&&(e=process.env.NODE_ENV!=="production"?"Atom@"+Qn():"Atom"),this.name_=void 0,this.flags_=0,this.observers_=new Set,this.lastAccessedBy_=0,this.lowestObserverState_=ee.NOT_TRACKING_,this.onBOL=void 0,this.onBUOL=void 0,this.name_=e}var t=i.prototype;return t.onBO=function(){this.onBOL&&this.onBOL.forEach(function(n){return n()})},t.onBUO=function(){this.onBUOL&&this.onBUOL.forEach(function(n){return n()})},t.reportObserved=function(){return pm(this)},t.reportChanged=function(){Nn(),mm(this),In()},t.toString=function(){return this.name_},Ir(i,[{key:"isBeingObserved",get:function(){return mn(this.flags_,i.isBeingObservedMask_)},set:function(n){this.flags_=_n(this.flags_,i.isBeingObservedMask_,n)}},{key:"isPendingUnobservation",get:function(){return mn(this.flags_,i.isPendingUnobservationMask_)},set:function(n){this.flags_=_n(this.flags_,i.isPendingUnobservationMask_,n)}},{key:"diffValue",get:function(){return mn(this.flags_,i.diffValueMask_)?1:0},set:function(n){this.flags_=_n(this.flags_,i.diffValueMask_,n===1)}}])})();ns.isBeingObservedMask_=1;ns.isPendingUnobservationMask_=2;ns.diffValueMask_=4;var _u=Ns("Atom",ns);function tm(i,t,e){t===void 0&&(t=ur),e===void 0&&(e=ur);var n=new ns(i);return t!==ur&&a1(n,t),e!==ur&&bm(n,e),n}function $S(i,t){return Lm(i,t)}function KS(i,t){return Object.is?Object.is(i,t):i===t?i!==0||1/i===1/t:i!==i&&t!==t}var Xo={structural:$S,default:KS};function Rs(i,t,e){return _a(i)?i:Array.isArray(i)?Ge.array(i,{name:e}):gn(i)?Ge.object(i,void 0,{name:e}):Nr(i)?Ge.map(i,{name:e}):Mi(i)?Ge.set(i,{name:e}):typeof i=="function"&&!Os(i)&&!ma(i)?Zp(i)?Ar(i):pa(e,i):i}function JS(i,t,e){if(i==null||Fr(i)||gl(i)||is(i)||ri(i))return i;if(Array.isArray(i))return Ge.array(i,{name:e,deep:!1});if(gn(i))return Ge.object(i,void 0,{name:e,deep:!1});if(Nr(i))return Ge.map(i,{name:e,deep:!1});if(Mi(i))return Ge.set(i,{name:e,deep:!1});process.env.NODE_ENV!=="production"&&vt("The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets")}function pl(i){return i}function QS(i,t){return process.env.NODE_ENV!=="production"&&_a(i)&&vt("observable.struct should not be used with observable values"),Lm(i,t)?t:i}var tE="override";function jo(i){return i.annotationType_===tE}function Ea(i,t){return{annotationType_:i,options_:t,make_:eE,extend_:nE,decorate_20223_:iE}}function eE(i,t,e,n){var s;if((s=this.options_)!=null&&s.bound)return this.extend_(i,t,e,!1)===null?0:1;if(n===i.target_)return this.extend_(i,t,e,!1)===null?0:2;if(Os(e.value))return 1;var r=em(i,this,t,e,!1);return ci(n,t,r),2}function nE(i,t,e,n){var s=em(i,this,t,e);return i.defineProperty_(t,s,n)}function iE(i,t){process.env.NODE_ENV!=="production"&&fl(t,["method","field"]);var e=t.kind,n=t.name,s=t.addInitializer,r=this,a=function(c){var h,u,d,f;return Ps((h=(u=r.options_)==null?void 0:u.name)!=null?h:n.toString(),c,(d=(f=r.options_)==null?void 0:f.autoAction)!=null?d:!1)};if(e=="field")return function(l){var c,h=l;return Os(h)||(h=a(h)),(c=r.options_)!=null&&c.bound&&(h=h.bind(this),h.isMobxAction=!0),h};if(e=="method"){var o;return Os(i)||(i=a(i)),(o=this.options_)!=null&&o.bound&&s(function(){var l=this,c=l[n].bind(l);c.isMobxAction=!0,l[n]=c}),i}vt("Cannot apply '"+r.annotationType_+"' to '"+String(n)+"' (kind: "+e+"):"+(`
3993
+ '`+r.annotationType_+"' can only be used on properties with a function value."))}function sE(i,t,e,n){var s=t.annotationType_,r=n.value;process.env.NODE_ENV!=="production"&&!Ue(r)&&vt("Cannot apply '"+s+"' to '"+i.name_+"."+e.toString()+"':"+(`
3994
+ '`+s+"' can only be used on properties with a function value."))}function em(i,t,e,n,s){var r,a,o,l,c,h,u;s===void 0&&(s=dt.safeDescriptors),sE(i,t,e,n);var d=n.value;if((r=t.options_)!=null&&r.bound){var f;d=d.bind((f=i.proxy_)!=null?f:i.target_)}return{value:Ps((a=(o=t.options_)==null?void 0:o.name)!=null?a:e.toString(),d,(l=(c=t.options_)==null?void 0:c.autoAction)!=null?l:!1,(h=t.options_)!=null&&h.bound?(u=i.proxy_)!=null?u:i.target_:void 0),configurable:s?i.isPlainObject_:!0,enumerable:!1,writable:!s}}function nm(i,t){return{annotationType_:i,options_:t,make_:rE,extend_:aE,decorate_20223_:oE}}function rE(i,t,e,n){var s;if(n===i.target_)return this.extend_(i,t,e,!1)===null?0:2;if((s=this.options_)!=null&&s.bound&&(!Zn(i.target_,t)||!ma(i.target_[t]))&&this.extend_(i,t,e,!1)===null)return 0;if(ma(e.value))return 1;var r=im(i,this,t,e,!1,!1);return ci(n,t,r),2}function aE(i,t,e,n){var s,r=im(i,this,t,e,(s=this.options_)==null?void 0:s.bound);return i.defineProperty_(t,r,n)}function oE(i,t){var e;process.env.NODE_ENV!=="production"&&fl(t,["method"]);var n=t.name,s=t.addInitializer;return ma(i)||(i=Ar(i)),(e=this.options_)!=null&&e.bound&&s(function(){var r=this,a=r[n].bind(r);a.isMobXFlow=!0,r[n]=a}),i}function lE(i,t,e,n){var s=t.annotationType_,r=n.value;process.env.NODE_ENV!=="production"&&!Ue(r)&&vt("Cannot apply '"+s+"' to '"+i.name_+"."+e.toString()+"':"+(`
3995
+ '`+s+"' can only be used on properties with a generator function value."))}function im(i,t,e,n,s,r){r===void 0&&(r=dt.safeDescriptors),lE(i,t,e,n);var a=n.value;if(ma(a)||(a=Ar(a)),s){var o;a=a.bind((o=i.proxy_)!=null?o:i.target_),a.isMobXFlow=!0}return{value:a,configurable:r?i.isPlainObject_:!0,enumerable:!1,writable:!r}}function xu(i,t){return{annotationType_:i,options_:t,make_:cE,extend_:hE,decorate_20223_:uE}}function cE(i,t,e){return this.extend_(i,t,e,!1)===null?0:1}function hE(i,t,e,n){return dE(i,this,t,e),i.defineComputedProperty_(t,ts({},this.options_,{get:e.get,set:e.set}),n)}function uE(i,t){process.env.NODE_ENV!=="production"&&fl(t,["getter"]);var e=this,n=t.name,s=t.addInitializer;return s(function(){var r=Ur(this)[zt],a=ts({},e.options_,{get:i,context:this});a.name||(a.name=process.env.NODE_ENV!=="production"?r.name_+"."+n.toString():"ObservableObject."+n.toString()),r.values_.set(n,new Fn(a))}),function(){return this[zt].getObservablePropValue_(n)}}function dE(i,t,e,n){var s=t.annotationType_,r=n.get;process.env.NODE_ENV!=="production"&&!r&&vt("Cannot apply '"+s+"' to '"+i.name_+"."+e.toString()+"':"+(`
3996
+ '`+s+"' can only be used on getter(+setter) properties."))}function ml(i,t){return{annotationType_:i,options_:t,make_:fE,extend_:pE,decorate_20223_:mE}}function fE(i,t,e){return this.extend_(i,t,e,!1)===null?0:1}function pE(i,t,e,n){var s,r;return _E(i,this,t,e),i.defineObservableProperty_(t,e.value,(s=(r=this.options_)==null?void 0:r.enhancer)!=null?s:Rs,n)}function mE(i,t){if(process.env.NODE_ENV!=="production"){if(t.kind==="field")throw vt("Please use `@observable accessor "+String(t.name)+"` instead of `@observable "+String(t.name)+"`");fl(t,["accessor"])}var e=this,n=t.kind,s=t.name,r=new WeakSet;function a(o,l){var c,h,u=Ur(o)[zt],d=new Es(l,(c=(h=e.options_)==null?void 0:h.enhancer)!=null?c:Rs,process.env.NODE_ENV!=="production"?u.name_+"."+s.toString():"ObservableObject."+s.toString(),!1);u.values_.set(s,d),r.add(o)}if(n=="accessor")return{get:function(){return r.has(this)||a(this,i.get.call(this)),this[zt].getObservablePropValue_(s)},set:function(l){return r.has(this)||a(this,l),this[zt].setObservablePropValue_(s,l)},init:function(l){return r.has(this)||a(this,l),l}}}function _E(i,t,e,n){var s=t.annotationType_;process.env.NODE_ENV!=="production"&&!("value"in n)&&vt("Cannot apply '"+s+"' to '"+i.name_+"."+e.toString()+"':"+(`
3997
+ '`+s+"' cannot be used on getter/setter properties"))}var xE="true",gE=sm();function sm(i){return{annotationType_:xE,options_:i,make_:vE,extend_:yE,decorate_20223_:bE}}function vE(i,t,e,n){var s,r;if(e.get)return _l.make_(i,t,e,n);if(e.set){var a=Os(e.set)?e.set:Ps(t.toString(),e.set);return n===i.target_?i.defineProperty_(t,{configurable:dt.safeDescriptors?i.isPlainObject_:!0,set:a})===null?0:2:(ci(n,t,{configurable:!0,set:a}),2)}if(n!==i.target_&&typeof e.value=="function"){var o;if(Zp(e.value)){var l,c=(l=this.options_)!=null&&l.autoBind?Ar.bound:Ar;return c.make_(i,t,e,n)}var h=(o=this.options_)!=null&&o.autoBind?pa.bound:pa;return h.make_(i,t,e,n)}var u=((s=this.options_)==null?void 0:s.deep)===!1?Ge.ref:Ge;if(typeof e.value=="function"&&(r=this.options_)!=null&&r.autoBind){var d;e.value=e.value.bind((d=i.proxy_)!=null?d:i.target_)}return u.make_(i,t,e,n)}function yE(i,t,e,n){var s,r;if(e.get)return _l.extend_(i,t,e,n);if(e.set)return i.defineProperty_(t,{configurable:dt.safeDescriptors?i.isPlainObject_:!0,set:Ps(t.toString(),e.set)},n);if(typeof e.value=="function"&&(s=this.options_)!=null&&s.autoBind){var a;e.value=e.value.bind((a=i.proxy_)!=null?a:i.target_)}var o=((r=this.options_)==null?void 0:r.deep)===!1?Ge.ref:Ge;return o.extend_(i,t,e,n)}function bE(i,t){vt("'"+this.annotationType_+"' cannot be used as a decorator")}var ME="observable",SE="observable.ref",EE="observable.shallow",wE="observable.struct",rm={deep:!0,name:void 0,defaultDecorator:void 0,proxy:!0};Object.freeze(rm);function Eo(i){return i||rm}var Ih=ml(ME),TE=ml(SE,{enhancer:pl}),AE=ml(EE,{enhancer:JS}),CE=ml(wE,{enhancer:QS}),am=hi(Ih);function wo(i){return i.deep===!0?Rs:i.deep===!1?pl:PE(i.defaultDecorator)}function RE(i){var t;return i?(t=i.defaultDecorator)!=null?t:sm(i):void 0}function PE(i){var t,e;return i&&(t=(e=i.options_)==null?void 0:e.enhancer)!=null?t:Rs}function om(i,t,e){if(Sa(t))return Ih.decorate_20223_(i,t);if(Cs(t)){Ma(i,t,Ih);return}return _a(i)?i:gn(i)?Ge.object(i,t,e):Array.isArray(i)?Ge.array(i,t):Nr(i)?Ge.map(i,t):Mi(i)?Ge.set(i,t):typeof i=="object"&&i!==null?i:Ge.box(i,t)}jp(om,am);var DE={box:function(t,e){var n=Eo(e);return new Es(t,wo(n),n.name,!0,n.equals)},array:function(t,e){var n=Eo(e);return(dt.useProxies===!1||n.proxy===!1?R1:v1)(t,wo(n),n.name)},map:function(t,e){var n=Eo(e);return new Am(t,wo(n),n.name)},set:function(t,e){var n=Eo(e);return new Cm(t,wo(n),n.name)},object:function(t,e,n){return Us(function(){return Sm(dt.useProxies===!1||n?.proxy===!1?Ur({},n):m1({},n),t,e)})},ref:hi(TE),shallow:hi(AE),deep:am,struct:hi(CE)},Ge=jp(om,DE),lm="computed",OE="computed.struct",Uh=xu(lm),LE=xu(OE,{equals:Xo.structural}),_l=function(t,e){if(Sa(e))return Uh.decorate_20223_(t,e);if(Cs(e))return Ma(t,e,Uh);if(gn(t))return hi(xu(lm,t));process.env.NODE_ENV!=="production"&&(Ue(t)||vt("First argument to `computed` should be an expression."),Ue(e)&&vt("A setter as second argument is no longer supported, use `{ set: fn }` option instead"));var n=gn(e)?e:{};return n.get=t,n.name||(n.name=t.name||""),new Fn(n)};Object.assign(_l,Uh);_l.struct=hi(LE);var zf,Bf,Yo=0,NE=1,IE=(zf=(Bf=Go(function(){},"name"))==null?void 0:Bf.configurable)!=null?zf:!1,kf={value:"action",configurable:!0,writable:!1,enumerable:!1};function Ps(i,t,e,n){e===void 0&&(e=!1),process.env.NODE_ENV!=="production"&&(Ue(t)||vt("`action` can only be invoked on functions"),(typeof i!="string"||!i)&&vt("actions should have valid names, got: '"+i+"'"));function s(){return UE(i,e,t,n||this,arguments)}return s.isMobxAction=!0,s.toString=function(){return t.toString()},IE&&(kf.value=i,ci(s,"name",kf)),s}function UE(i,t,e,n,s){var r=FE(i,t,n,s);try{return e.apply(n,s)}catch(a){throw r.error_=a,a}finally{zE(r)}}function FE(i,t,e,n){var s=process.env.NODE_ENV!=="production"&&We()&&!!i,r=0;if(process.env.NODE_ENV!=="production"&&s){r=Date.now();var a=n?Array.from(n):Wo;vn({type:bu,name:i,object:e,arguments:a})}var o=dt.trackingDerivation,l=!t||!o;Nn();var c=dt.allowStateChanges;l&&(Is(),c=gu(!0));var h=yu(!0),u={runAsAction_:l,prevDerivation_:o,prevAllowStateChanges_:c,prevAllowStateReads_:h,notifySpy_:s,startTime_:r,actionId_:NE++,parentActionId_:Yo};return Yo=u.actionId_,u}function zE(i){Yo!==i.actionId_&&vt(30),Yo=i.parentActionId_,i.error_!==void 0&&(dt.suppressReactionErrors=!0),vu(i.prevAllowStateChanges_),aa(i.prevAllowStateReads_),In(),i.runAsAction_&&Pi(i.prevDerivation_),process.env.NODE_ENV!=="production"&&i.notifySpy_&&yn({time:Date.now()-i.startTime_}),dt.suppressReactionErrors=!1}function gu(i){var t=dt.allowStateChanges;return dt.allowStateChanges=i,t}function vu(i){dt.allowStateChanges=i}var BE="create",Es=(function(i){function t(n,s,r,a,o){var l;if(r===void 0&&(r=process.env.NODE_ENV!=="production"?"ObservableValue@"+Qn():"ObservableValue"),a===void 0&&(a=!0),o===void 0&&(o=Xo.default),l=i.call(this,r)||this,l.enhancer=void 0,l.name_=void 0,l.equals=void 0,l.hasUnreportedChange_=!1,l.interceptors_=void 0,l.changeListeners_=void 0,l.value_=void 0,l.dehancer=void 0,l.enhancer=s,l.name_=r,l.equals=o,l.value_=s(n,void 0,r),process.env.NODE_ENV!=="production"&&a&&We()){var c;Ds({type:BE,object:l,observableKind:"value",debugObjectName:l.name_,newValue:""+((c=l.value_)==null?void 0:c.toString())})}return l}Qp(t,i);var e=t.prototype;return e.dehanceValue=function(s){return this.dehancer!==void 0?this.dehancer(s):s},e.set=function(s){var r=this.value_;if(s=this.prepareNewValue_(s),s!==dt.UNCHANGED){var a=We();process.env.NODE_ENV!=="production"&&a&&vn({type:jn,object:this,observableKind:"value",debugObjectName:this.name_,newValue:s,oldValue:r}),this.setNewValue_(s),process.env.NODE_ENV!=="production"&&a&&yn()}},e.prepareNewValue_=function(s){if(oi(this),Pn(this)){var r=Dn(this,{object:this,type:jn,newValue:s});if(!r)return dt.UNCHANGED;s=r.newValue}return s=this.enhancer(s,this.value_,this.name_),this.equals(this.value_,s)?dt.UNCHANGED:s},e.setNewValue_=function(s){var r=this.value_;this.value_=s,this.reportChanged(),$n(this)&&Kn(this,{type:jn,object:this,newValue:s,oldValue:r})},e.get=function(){return this.reportObserved(),this.dehanceValue(this.value_)},e.intercept_=function(s){return wa(this,s)},e.observe_=function(s,r){return r&&s({observableKind:"value",debugObjectName:this.name_,object:this,type:jn,newValue:this.value_,oldValue:void 0}),Ta(this,s)},e.raw=function(){return this.value_},e.toJSON=function(){return this.get()},e.toString=function(){return this.name_+"["+this.value_+"]"},e.valueOf=function(){return Jp(this.get())},e[Symbol.toPrimitive]=function(){return this.valueOf()},t})(ns),Fn=(function(){function i(e){this.dependenciesState_=ee.NOT_TRACKING_,this.observing_=[],this.newObserving_=null,this.observers_=new Set,this.runId_=0,this.lastAccessedBy_=0,this.lowestObserverState_=ee.UP_TO_DATE_,this.unboundDepsCount_=0,this.value_=new qo(null),this.name_=void 0,this.triggeredBy_=void 0,this.flags_=0,this.derivation=void 0,this.setter_=void 0,this.isTracing_=Un.NONE,this.scope_=void 0,this.equals_=void 0,this.requiresReaction_=void 0,this.keepAlive_=void 0,this.onBOL=void 0,this.onBUOL=void 0,e.get||vt(31),this.derivation=e.get,this.name_=e.name||(process.env.NODE_ENV!=="production"?"ComputedValue@"+Qn():"ComputedValue"),e.set&&(this.setter_=Ps(process.env.NODE_ENV!=="production"?this.name_+"-setter":"ComputedValue-setter",e.set)),this.equals_=e.equals||(e.compareStructural||e.struct?Xo.structural:Xo.default),this.scope_=e.context,this.requiresReaction_=e.requiresReaction,this.keepAlive_=!!e.keepAlive}var t=i.prototype;return t.onBecomeStale_=function(){XE(this)},t.onBO=function(){this.onBOL&&this.onBOL.forEach(function(n){return n()})},t.onBUO=function(){this.onBUOL&&this.onBUOL.forEach(function(n){return n()})},t.get=function(){if(this.isComputing&&vt(32,this.name_,this.derivation),dt.inBatch===0&&this.observers_.size===0&&!this.keepAlive_)Fh(this)&&(this.warnAboutUntrackedRead_(),Nn(),this.value_=this.computeValue_(!1),In());else if(pm(this),Fh(this)){var n=dt.trackingContext;this.keepAlive_&&!n&&(dt.trackingContext=this),this.trackAndCompute()&&WE(this),dt.trackingContext=n}var s=this.value_;if(No(s))throw s.cause;return s},t.set=function(n){if(this.setter_){this.isRunningSetter&&vt(33,this.name_),this.isRunningSetter=!0;try{this.setter_.call(this.scope_,n)}finally{this.isRunningSetter=!1}}else vt(34,this.name_)},t.trackAndCompute=function(){var n=this.value_,s=this.dependenciesState_===ee.NOT_TRACKING_,r=this.computeValue_(!0),a=s||No(n)||No(r)||!this.equals_(n,r);return a&&(this.value_=r,process.env.NODE_ENV!=="production"&&We()&&Ds({observableKind:"computed",debugObjectName:this.name_,object:this.scope_,type:"update",oldValue:n,newValue:r})),a},t.computeValue_=function(n){this.isComputing=!0;var s=gu(!1),r;if(n)r=cm(this,this.derivation,this.scope_);else if(dt.disableErrorBoundaries===!0)r=this.derivation.call(this.scope_);else try{r=this.derivation.call(this.scope_)}catch(a){r=new qo(a)}return vu(s),this.isComputing=!1,r},t.suspend_=function(){this.keepAlive_||(zh(this),this.value_=void 0,process.env.NODE_ENV!=="production"&&this.isTracing_!==Un.NONE&&console.log("[mobx.trace] Computed value '"+this.name_+"' was suspended and it will recompute on the next access."))},t.observe_=function(n,s){var r=this,a=!0,o=void 0;return e1(function(){var l=r.get();if(!a||s){var c=Is();n({observableKind:"computed",debugObjectName:r.name_,type:jn,object:r,newValue:l,oldValue:o}),Pi(c)}a=!1,o=l})},t.warnAboutUntrackedRead_=function(){process.env.NODE_ENV!=="production"&&(this.isTracing_!==Un.NONE&&console.log("[mobx.trace] Computed value '"+this.name_+"' is being read outside a reactive context. Doing a full recompute."),(typeof this.requiresReaction_=="boolean"?this.requiresReaction_:dt.computedRequiresReaction)&&console.warn("[mobx] Computed value '"+this.name_+"' is being read outside a reactive context. Doing a full recompute."))},t.toString=function(){return this.name_+"["+this.derivation.toString()+"]"},t.valueOf=function(){return Jp(this.get())},t[Symbol.toPrimitive]=function(){return this.valueOf()},Ir(i,[{key:"isComputing",get:function(){return mn(this.flags_,i.isComputingMask_)},set:function(n){this.flags_=_n(this.flags_,i.isComputingMask_,n)}},{key:"isRunningSetter",get:function(){return mn(this.flags_,i.isRunningSetterMask_)},set:function(n){this.flags_=_n(this.flags_,i.isRunningSetterMask_,n)}},{key:"isBeingObserved",get:function(){return mn(this.flags_,i.isBeingObservedMask_)},set:function(n){this.flags_=_n(this.flags_,i.isBeingObservedMask_,n)}},{key:"isPendingUnobservation",get:function(){return mn(this.flags_,i.isPendingUnobservationMask_)},set:function(n){this.flags_=_n(this.flags_,i.isPendingUnobservationMask_,n)}},{key:"diffValue",get:function(){return mn(this.flags_,i.diffValueMask_)?1:0},set:function(n){this.flags_=_n(this.flags_,i.diffValueMask_,n===1)}}])})();Fn.isComputingMask_=1;Fn.isRunningSetterMask_=2;Fn.isBeingObservedMask_=4;Fn.isPendingUnobservationMask_=8;Fn.diffValueMask_=16;var xl=Ns("ComputedValue",Fn),ee;(function(i){i[i.NOT_TRACKING_=-1]="NOT_TRACKING_",i[i.UP_TO_DATE_=0]="UP_TO_DATE_",i[i.POSSIBLY_STALE_=1]="POSSIBLY_STALE_",i[i.STALE_=2]="STALE_"})(ee||(ee={}));var Un;(function(i){i[i.NONE=0]="NONE",i[i.LOG=1]="LOG",i[i.BREAK=2]="BREAK"})(Un||(Un={}));var qo=function(t){this.cause=void 0,this.cause=t};function No(i){return i instanceof qo}function Fh(i){switch(i.dependenciesState_){case ee.UP_TO_DATE_:return!1;case ee.NOT_TRACKING_:case ee.STALE_:return!0;case ee.POSSIBLY_STALE_:{for(var t=yu(!0),e=Is(),n=i.observing_,s=n.length,r=0;r<s;r++){var a=n[r];if(xl(a)){if(dt.disableErrorBoundaries)a.get();else try{a.get()}catch{return Pi(e),aa(t),!0}if(i.dependenciesState_===ee.STALE_)return Pi(e),aa(t),!0}}return um(i),Pi(e),aa(t),!1}}}function oi(i){if(process.env.NODE_ENV!=="production"){var t=i.observers_.size>0;!dt.allowStateChanges&&(t||dt.enforceActions==="always")&&console.warn("[MobX] "+(dt.enforceActions?"Since strict-mode is enabled, changing (observed) observable values without using an action is not allowed. Tried to modify: ":"Side effects like changing state are not allowed at this point. Are you trying to modify state from, for example, a computed value or the render function of a React component? You can wrap side effects in 'runInAction' (or decorate functions with 'action') if needed. Tried to modify: ")+i.name_)}}function kE(i){process.env.NODE_ENV!=="production"&&!dt.allowStateReads&&dt.observableRequiresReaction&&console.warn("[mobx] Observable '"+i.name_+"' being read outside a reactive context.")}function cm(i,t,e){var n=yu(!0);um(i),i.newObserving_=new Array(i.runId_===0?100:i.observing_.length),i.unboundDepsCount_=0,i.runId_=++dt.runId;var s=dt.trackingDerivation;dt.trackingDerivation=i,dt.inBatch++;var r;if(dt.disableErrorBoundaries===!0)r=t.call(e);else try{r=t.call(e)}catch(a){r=new qo(a)}return dt.inBatch--,dt.trackingDerivation=s,HE(i),VE(i),aa(n),r}function VE(i){process.env.NODE_ENV!=="production"&&i.observing_.length===0&&(typeof i.requiresObservable_=="boolean"?i.requiresObservable_:dt.reactionRequiresObservable)&&console.warn("[mobx] Derivation '"+i.name_+"' is created/updated without reading any observable value.")}function HE(i){for(var t=i.observing_,e=i.observing_=i.newObserving_,n=ee.UP_TO_DATE_,s=0,r=i.unboundDepsCount_,a=0;a<r;a++){var o=e[a];o.diffValue===0&&(o.diffValue=1,s!==a&&(e[s]=o),s++),o.dependenciesState_>n&&(n=o.dependenciesState_)}for(e.length=s,i.newObserving_=null,r=t.length;r--;){var l=t[r];l.diffValue===0&&dm(l,i),l.diffValue=0}for(;s--;){var c=e[s];c.diffValue===1&&(c.diffValue=0,GE(c,i))}n!==ee.UP_TO_DATE_&&(i.dependenciesState_=n,i.onBecomeStale_())}function zh(i){var t=i.observing_;i.observing_=[];for(var e=t.length;e--;)dm(t[e],i);i.dependenciesState_=ee.NOT_TRACKING_}function hm(i){var t=Is();try{return i()}finally{Pi(t)}}function Is(){var i=dt.trackingDerivation;return dt.trackingDerivation=null,i}function Pi(i){dt.trackingDerivation=i}function yu(i){var t=dt.allowStateReads;return dt.allowStateReads=i,t}function aa(i){dt.allowStateReads=i}function um(i){if(i.dependenciesState_!==ee.UP_TO_DATE_){i.dependenciesState_=ee.UP_TO_DATE_;for(var t=i.observing_,e=t.length;e--;)t[e].lowestObserverState_=ee.UP_TO_DATE_}}var yc=function(){this.version=6,this.UNCHANGED={},this.trackingDerivation=null,this.trackingContext=null,this.runId=0,this.mobxGuid=0,this.inBatch=0,this.pendingUnobservations=[],this.pendingReactions=[],this.isRunningReactions=!1,this.allowStateChanges=!1,this.allowStateReads=!0,this.enforceActions=!0,this.spyListeners=[],this.globalReactionErrorHandlers=[],this.computedRequiresReaction=!1,this.reactionRequiresObservable=!1,this.observableRequiresReaction=!1,this.disableErrorBoundaries=!1,this.suppressReactionErrors=!1,this.useProxies=!0,this.verifyProxies=!1,this.safeDescriptors=!0},bc=!0,dt=(function(){var i=pu();return i.__mobxInstanceCount>0&&!i.__mobxGlobals&&(bc=!1),i.__mobxGlobals&&i.__mobxGlobals.version!==new yc().version&&(bc=!1),bc?i.__mobxGlobals?(i.__mobxInstanceCount+=1,i.__mobxGlobals.UNCHANGED||(i.__mobxGlobals.UNCHANGED={}),i.__mobxGlobals):(i.__mobxInstanceCount=1,i.__mobxGlobals=new yc):(setTimeout(function(){vt(35)},1),new yc)})();function GE(i,t){i.observers_.add(t),i.lowestObserverState_>t.dependenciesState_&&(i.lowestObserverState_=t.dependenciesState_)}function dm(i,t){i.observers_.delete(t),i.observers_.size===0&&fm(i)}function fm(i){i.isPendingUnobservation===!1&&(i.isPendingUnobservation=!0,dt.pendingUnobservations.push(i))}function Nn(){dt.inBatch++}function In(){if(--dt.inBatch===0){gm();for(var i=dt.pendingUnobservations,t=0;t<i.length;t++){var e=i[t];e.isPendingUnobservation=!1,e.observers_.size===0&&(e.isBeingObserved&&(e.isBeingObserved=!1,e.onBUO()),e instanceof Fn&&e.suspend_())}dt.pendingUnobservations=[]}}function pm(i){kE(i);var t=dt.trackingDerivation;return t!==null?(t.runId_!==i.lastAccessedBy_&&(i.lastAccessedBy_=t.runId_,t.newObserving_[t.unboundDepsCount_++]=i,!i.isBeingObserved&&dt.trackingContext&&(i.isBeingObserved=!0,i.onBO())),i.isBeingObserved):(i.observers_.size===0&&dt.inBatch>0&&fm(i),!1)}function mm(i){i.lowestObserverState_!==ee.STALE_&&(i.lowestObserverState_=ee.STALE_,i.observers_.forEach(function(t){t.dependenciesState_===ee.UP_TO_DATE_&&(process.env.NODE_ENV!=="production"&&t.isTracing_!==Un.NONE&&_m(t,i),t.onBecomeStale_()),t.dependenciesState_=ee.STALE_}))}function WE(i){i.lowestObserverState_!==ee.STALE_&&(i.lowestObserverState_=ee.STALE_,i.observers_.forEach(function(t){t.dependenciesState_===ee.POSSIBLY_STALE_?(t.dependenciesState_=ee.STALE_,process.env.NODE_ENV!=="production"&&t.isTracing_!==Un.NONE&&_m(t,i)):t.dependenciesState_===ee.UP_TO_DATE_&&(i.lowestObserverState_=ee.UP_TO_DATE_)}))}function XE(i){i.lowestObserverState_===ee.UP_TO_DATE_&&(i.lowestObserverState_=ee.POSSIBLY_STALE_,i.observers_.forEach(function(t){t.dependenciesState_===ee.UP_TO_DATE_&&(t.dependenciesState_=ee.POSSIBLY_STALE_,t.onBecomeStale_())}))}function _m(i,t){if(console.log("[mobx.trace] '"+i.name_+"' is invalidated due to a change in: '"+t.name_+"'"),i.isTracing_===Un.BREAK){var e=[];xm(o1(i),e,1),new Function(`debugger;
3879
3998
  /*
3880
- Tracing '`+n.name_+`'
3999
+ Tracing '`+i.name_+`'
3881
4000
 
3882
- You are entering this break point because derivation '`+n.name_+"' is being traced and '"+e.name_+`' is now forcing it to update.
4001
+ You are entering this break point because derivation '`+i.name_+"' is being traced and '"+t.name_+`' is now forcing it to update.
3883
4002
  Just follow the stacktrace you should now see in the devtools to see precisely what piece of your code is causing this update
3884
4003
  The stackframe you are looking for is at least ~6-8 stack-frames up.
3885
4004
 
3886
- `+(n instanceof gn?n.derivation.toString().replace(/[*]\//g,"/"):"")+`
4005
+ `+(i instanceof Fn?i.derivation.toString().replace(/[*]\//g,"/"):"")+`
3887
4006
 
3888
4007
  The dependencies for this derivation are:
3889
4008
 
3890
- `+t.join(`
4009
+ `+e.join(`
3891
4010
  `)+`
3892
4011
  */
3893
- `)()}}function Wf(n,e,t){if(e.length>=1e3){e.push("(and many more)");return}e.push(""+" ".repeat(t-1)+n.name),n.dependencies&&n.dependencies.forEach(function(i){return Wf(i,e,t+1)})}var xi=(function(){function n(t,i,r,s){t===void 0&&(t=process.env.NODE_ENV!=="production"?"Reaction@"+Dn():"Reaction"),this.name_=void 0,this.onInvalidate_=void 0,this.errorHandler_=void 0,this.requiresObservable_=void 0,this.observing_=[],this.newObserving_=[],this.dependenciesState_=et.NOT_TRACKING_,this.runId_=0,this.unboundDepsCount_=0,this.flags_=0,this.isTracing_=_n.NONE,this.name_=t,this.onInvalidate_=i,this.errorHandler_=r,this.requiresObservable_=s}var e=n.prototype;return e.onBecomeStale_=function(){this.schedule_()},e.schedule_=function(){this.isScheduled||(this.isScheduled=!0,he.pendingReactions.push(this),Xf())},e.runReaction_=function(){if(!this.isDisposed){pn(),this.isScheduled=!1;var i=he.trackingContext;if(he.trackingContext=this,$l(this)){this.isTrackPending=!0;try{this.onInvalidate_(),process.env.NODE_ENV!=="production"&&this.isTrackPending&&It()&&ji({name:this.name_,type:"scheduled-reaction"})}catch(r){this.reportExceptionInDerivation_(r)}}he.trackingContext=i,mn()}},e.track=function(i){if(!this.isDisposed){pn();var r=It(),s;process.env.NODE_ENV!=="production"&&r&&(s=Date.now(),Qt({name:this.name_,type:"reaction"})),this.isRunning=!0;var o=he.trackingContext;he.trackingContext=this;var a=Uf(this,i,void 0);he.trackingContext=o,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&Zl(this),po(a)&&this.reportExceptionInDerivation_(a.cause),process.env.NODE_ENV!=="production"&&r&&en({time:Date.now()-s}),mn()}},e.reportExceptionInDerivation_=function(i){var r=this;if(this.errorHandler_){this.errorHandler_(i,this);return}if(he.disableErrorBoundaries)throw i;var s=process.env.NODE_ENV!=="production"?"[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '"+this+"'":"[mobx] uncaught error in '"+this+"'";he.suppressReactionErrors?process.env.NODE_ENV!=="production"&&console.warn("[mobx] (error in reaction '"+this.name_+"' suppressed, fix error of causing action below)"):console.error(s,i),process.env.NODE_ENV!=="production"&&It()&&ji({type:"error",name:this.name_,message:s,error:""+i}),he.globalReactionErrorHandlers.forEach(function(o){return o(i,r)})},e.dispose=function(){this.isDisposed||(this.isDisposed=!0,this.isRunning||(pn(),Zl(this),mn()))},e.getDisposer_=function(i){var r=this,s=function o(){r.dispose(),i==null||i.removeEventListener==null||i.removeEventListener("abort",o)};return i==null||i.addEventListener==null||i.addEventListener("abort",s),s[Fe]=this,"dispose"in Symbol&&typeof Symbol.dispose=="symbol"&&(s[Symbol.dispose]=s),s},e.toString=function(){return"Reaction["+this.name_+"]"},e.trace=function(i){i===void 0&&(i=!1),BM(this,i)},Fr(n,[{key:"isDisposed",get:function(){return Zt(this.flags_,n.isDisposedMask_)},set:function(i){this.flags_=Kt(this.flags_,n.isDisposedMask_,i)}},{key:"isScheduled",get:function(){return Zt(this.flags_,n.isScheduledMask_)},set:function(i){this.flags_=Kt(this.flags_,n.isScheduledMask_,i)}},{key:"isTrackPending",get:function(){return Zt(this.flags_,n.isTrackPendingMask_)},set:function(i){this.flags_=Kt(this.flags_,n.isTrackPendingMask_,i)}},{key:"isRunning",get:function(){return Zt(this.flags_,n.isRunningMask_)},set:function(i){this.flags_=Kt(this.flags_,n.isRunningMask_,i)}},{key:"diffValue",get:function(){return Zt(this.flags_,n.diffValueMask_)?1:0},set:function(i){this.flags_=Kt(this.flags_,n.diffValueMask_,i===1)}}])})();xi.isDisposedMask_=1;xi.isScheduledMask_=2;xi.isTrackPendingMask_=4;xi.isRunningMask_=8;xi.diffValueMask_=16;var xh=100,vM=function(e){return e()};function Xf(){he.inBatch>0||he.isRunningReactions||vM(xM)}function xM(){he.isRunningReactions=!0;for(var n=he.pendingReactions,e=0;n.length>0;){++e===xh&&(console.error(process.env.NODE_ENV!=="production"?"Reaction doesn't converge to a stable state after "+xh+" iterations."+(" Probably there is a cycle in the reactive function: "+n[0]):"[mobx] cycle in reaction: "+n[0]),n.splice(0));for(var t=n.splice(0),i=0,r=t.length;i<r;i++)t[i].runReaction_()}he.isRunningReactions=!1}var Ao=Zi("Reaction",xi);function It(){return process.env.NODE_ENV!=="production"&&!!he.spyListeners.length}function ji(n){if(process.env.NODE_ENV!=="production"&&he.spyListeners.length)for(var e=he.spyListeners,t=0,i=e.length;t<i;t++)e[t](n)}function Qt(n){if(process.env.NODE_ENV!=="production"){var e=vi({},n,{spyReportStart:!0});ji(e)}}var yM={type:"report-end",spyReportEnd:!0};function en(n){process.env.NODE_ENV!=="production"&&ji(n?vi({},n,{type:"report-end",spyReportEnd:!0}):yM)}function MM(n){return process.env.NODE_ENV==="production"?(console.warn("[mobx.spy] Is a no-op in production builds"),function(){}):(he.spyListeners.push(n),wc(function(){he.spyListeners=he.spyListeners.filter(function(e){return e!==n})}))}var Lc="action",EM="action.bound",jf="autoAction",bM="autoAction.bound",SM="<unnamed action>",Kl=vs(Lc),TM=vs(EM,{bound:!0}),Jl=vs(jf,{autoAction:!0}),wM=vs(bM,{autoAction:!0,bound:!0});function Yf(n){var e=function(i,r){if(Rt(i))return Xi(i.name||SM,i,n);if(Rt(r))return Xi(i,r,n);if(gs(r))return(n?Jl:Kl).decorate_20223_(i,r);if(Gi(r))return _s(i,r,n?Jl:Kl);if(Gi(i))return Hn(vs(n?jf:Lc,{name:i,autoAction:n}));process.env.NODE_ENV!=="production"&&ve("Invalid arguments for `action`")};return e}var yr=Yf(!1);Object.assign(yr,Kl);var us=Yf(!0);Object.assign(us,Jl);yr.bound=Hn(TM);us.bound=Hn(wM);function Yi(n){return Rt(n)&&n.isMobxAction===!0}function AM(n,e){var t,i,r,s;e===void 0&&(e=yf),process.env.NODE_ENV!=="production"&&(Rt(n)||ve("Autorun expects a function as first argument"),Yi(n)&&ve("Autorun does not accept actions since actions are untrackable"));var o=(t=(i=e)==null?void 0:i.name)!=null?t:process.env.NODE_ENV!=="production"?n.name||"Autorun@"+Dn():"Autorun",a=!e.scheduler&&!e.delay,l;if(a)l=new xi(o,function(){this.track(h)},e.onError,e.requiresObservable);else{var c=CM(e),u=!1;l=new xi(o,function(){u||(u=!0,c(function(){u=!1,l.isDisposed||l.track(h)}))},e.onError,e.requiresObservable)}function h(){n(l)}return(r=e)!=null&&(r=r.signal)!=null&&r.aborted||l.schedule_(),l.getDisposer_((s=e)==null?void 0:s.signal)}var RM=function(e){return e()};function CM(n){return n.scheduler?n.scheduler:n.delay?function(e){return setTimeout(e,n.delay)}:RM}var PM="onBO",DM="onBUO";function LM(n,e,t){return $f(PM,n,e,t)}function qf(n,e,t){return $f(DM,n,e,t)}function $f(n,e,t,i){var r=Lr(e),s=Rt(i)?i:t,o=n+"L";return r[o]?r[o].add(s):r[o]=new Set([s]),function(){var a=r[o];a&&(a.delete(s),a.size===0&&delete r[o])}}function Zf(n,e,t,i){process.env.NODE_ENV!=="production"&&(arguments.length>4&&ve("'extendObservable' expected 2-4 arguments"),typeof n!="object"&&ve("'extendObservable' expects an object as first argument"),Mi(n)&&ve("'extendObservable' should not be used on maps, use map.merge instead"),Jt(e)||ve("'extendObservable' only accepts plain objects as second argument"),(fs(e)||fs(t))&&ve("Extending an object with another observable (object) is not supported"));var r=_y(e);return Ji(function(){var s=Br(n,i)[Fe];cs(r).forEach(function(o){s.extend_(o,r[o],t&&o in t?t[o]:!0)})}),n}function OM(n,e){return Kf(Lr(n,e))}function Kf(n){var e={name:n.name_};return n.observing_&&n.observing_.length>0&&(e.dependencies=IM(n.observing_).map(Kf)),e}function IM(n){return Array.from(new Set(n))}var NM=0;function Jf(){this.message="FLOW_CANCELLED"}Jf.prototype=Object.create(Error.prototype);var Ia=Cf("flow"),UM=Cf("flow.bound",{bound:!0}),Dr=Object.assign(function(e,t){if(gs(t))return Ia.decorate_20223_(e,t);if(Gi(t))return _s(e,t,Ia);process.env.NODE_ENV!=="production"&&arguments.length!==1&&ve("Flow expects single argument with generator function");var i=e,r=i.name||"<unnamed flow>",s=function(){var a=this,l=arguments,c=++NM,u=yr(r+" - runid: "+c+" - init",i).apply(a,l),h,d=void 0,p=new Promise(function(g,y){var m=0;h=y;function f(_){d=void 0;var S;try{S=yr(r+" - runid: "+c+" - yield "+m++,u.next).call(u,_)}catch(b){return y(b)}T(S)}function w(_){d=void 0;var S;try{S=yr(r+" - runid: "+c+" - yield "+m++,u.throw).call(u,_)}catch(b){return y(b)}T(S)}function T(_){if(Rt(_?.then)){_.then(T,y);return}return _.done?g(_.value):(d=Promise.resolve(_.value),d.then(f,w))}f(void 0)});return p.cancel=yr(r+" - runid: "+c+" - cancel",function(){try{d&&yh(d);var g=u.return(void 0),y=Promise.resolve(g.value);y.then(vr,vr),yh(y),h(new Jf)}catch(m){h(m)}}),p};return s.isMobXFlow=!0,s},Ia);Dr.bound=Hn(UM);function yh(n){Rt(n.cancel)&&n.cancel()}function hs(n){return n?.isMobXFlow===!0}function FM(n,e){return n?zr(n)||!!n[Fe]||Ac(n)||Ao(n)||Xo(n):!1}function fs(n){return process.env.NODE_ENV!=="production"&&arguments.length!==1&&ve("isObservable expects only 1 argument. Use isObservableProp to inspect the observability of a property"),FM(n)}function BM(){if(process.env.NODE_ENV!=="production"){for(var n=!1,e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];typeof t[t.length-1]=="boolean"&&(n=t.pop());var r=zM(t);if(!r)return ve("'trace(break?)' can only be used inside a tracked computed value or a Reaction. Consider passing in the computed value or reaction explicitly");r.isTracing_===_n.NONE&&console.log("[mobx.trace] '"+r.name_+"' tracing enabled"),r.isTracing_=n?_n.BREAK:_n.LOG}}function zM(n){switch(n.length){case 0:return he.trackingDerivation;case 1:return Lr(n[0]);case 2:return Lr(n[0],n[1])}}function Kn(n,e){e===void 0&&(e=void 0),pn();try{return n.apply(e)}finally{mn()}}function Di(n){return n[Fe]}var VM={has:function(e,t){return process.env.NODE_ENV!=="production"&&he.trackingDerivation&&Zr("detect new properties using the 'in' operator. Use 'has' from 'mobx' instead."),Di(e).has_(t)},get:function(e,t){return Di(e).get_(t)},set:function(e,t,i){var r;return Gi(t)?(process.env.NODE_ENV!=="production"&&!Di(e).values_.has(t)&&Zr("add a new observable property through direct assignment. Use 'set' from 'mobx' instead."),(r=Di(e).set_(t,i,!0))!=null?r:!0):!1},deleteProperty:function(e,t){var i;return process.env.NODE_ENV!=="production"&&Zr("delete properties from an observable object. Use 'remove' from 'mobx' instead."),Gi(t)?(i=Di(e).delete_(t,!0))!=null?i:!0:!1},defineProperty:function(e,t,i){var r;return process.env.NODE_ENV!=="production"&&Zr("define property on an observable object. Use 'defineProperty' from 'mobx' instead."),(r=Di(e).defineProperty_(t,i))!=null?r:!0},ownKeys:function(e){return process.env.NODE_ENV!=="production"&&he.trackingDerivation&&Zr("iterate keys to detect added / removed properties. Use 'keys' from 'mobx' instead."),Di(e).ownKeys_()},preventExtensions:function(e){ve(13)}};function HM(n,e){var t,i;return Mf(),n=Br(n,e),(i=(t=n[Fe]).proxy_)!=null?i:t.proxy_=new Proxy(n,VM)}function hn(n){return n.interceptors_!==void 0&&n.interceptors_.length>0}function xs(n,e){var t=n.interceptors_||(n.interceptors_=[]);return t.push(e),wc(function(){var i=t.indexOf(e);i!==-1&&t.splice(i,1)})}function fn(n,e){var t=Ki();try{for(var i=[].concat(n.interceptors_||[]),r=0,s=i.length;r<s&&(e=i[r](e),e&&!e.type&&ve(14),!!e);r++);return e}finally{ei(t)}}function Rn(n){return n.changeListeners_!==void 0&&n.changeListeners_.length>0}function ys(n,e){var t=n.changeListeners_||(n.changeListeners_=[]);return t.push(e),wc(function(){var i=t.indexOf(e);i!==-1&&t.splice(i,1)})}function Cn(n,e){var t=Ki(),i=n.changeListeners_;if(i){i=i.slice();for(var r=0,s=i.length;r<s;r++)i[r](e);ei(t)}}var Na=Symbol("mobx-keys");function kM(n,e,t){return process.env.NODE_ENV!=="production"&&(!Jt(n)&&!Jt(Object.getPrototypeOf(n))&&ve("'makeAutoObservable' can only be used for classes that don't have a superclass"),zr(n)&&ve("makeAutoObservable can only be used on objects not already made observable")),Jt(n)?Zf(n,n,e,t):(Ji(function(){var i=Br(n,t)[Fe];if(!n[Na]){var r=Object.getPrototypeOf(n),s=new Set([].concat(cs(n),cs(r)));s.delete("constructor"),s.delete(Fe),Vo(r,Na,s)}n[Na].forEach(function(o){return i.make_(o,e&&o in e?e[o]:!0)})}),n)}var Mh="splice",Sn="update",GM=1e4,WM={get:function(e,t){var i=e[Fe];return t===Fe?i:t==="length"?i.getArrayLength_():typeof t=="string"&&!isNaN(t)?i.get_(parseInt(t)):An(Ro,t)?Ro[t]:e[t]},set:function(e,t,i){var r=e[Fe];return t==="length"&&r.setArrayLength_(i),typeof t=="symbol"||isNaN(t)?e[t]=i:r.set_(parseInt(t),i),!0},preventExtensions:function(){ve(15)}},Oc=(function(){function n(t,i,r,s){t===void 0&&(t=process.env.NODE_ENV!=="production"?"ObservableArray@"+Dn():"ObservableArray"),this.owned_=void 0,this.legacyMode_=void 0,this.atom_=void 0,this.values_=[],this.interceptors_=void 0,this.changeListeners_=void 0,this.enhancer_=void 0,this.dehancer=void 0,this.proxy_=void 0,this.lastKnownLength_=0,this.owned_=r,this.legacyMode_=s,this.atom_=new yi(t),this.enhancer_=function(o,a){return i(o,a,process.env.NODE_ENV!=="production"?t+"[..]":"ObservableArray[..]")}}var e=n.prototype;return e.dehanceValue_=function(i){return this.dehancer!==void 0?this.dehancer(i):i},e.dehanceValues_=function(i){return this.dehancer!==void 0&&i.length>0?i.map(this.dehancer):i},e.intercept_=function(i){return xs(this,i)},e.observe_=function(i,r){return r===void 0&&(r=!1),r&&i({observableKind:"array",object:this.proxy_,debugObjectName:this.atom_.name_,type:"splice",index:0,added:this.values_.slice(),addedCount:this.values_.length,removed:[],removedCount:0}),ys(this,i)},e.getArrayLength_=function(){return this.atom_.reportObserved(),this.values_.length},e.setArrayLength_=function(i){(typeof i!="number"||isNaN(i)||i<0)&&ve("Out of range: "+i);var r=this.values_.length;if(i!==r)if(i>r){for(var s=new Array(i-r),o=0;o<i-r;o++)s[o]=void 0;this.spliceWithArray_(r,0,s)}else this.spliceWithArray_(i,r-i)},e.updateArrayLength_=function(i,r){i!==this.lastKnownLength_&&ve(16),this.lastKnownLength_+=r,this.legacyMode_&&r>0&&rd(i+r+1)},e.spliceWithArray_=function(i,r,s){var o=this;zn(this.atom_);var a=this.values_.length;if(i===void 0?i=0:i>a?i=a:i<0&&(i=Math.max(0,a+i)),arguments.length===1?r=a-i:r==null?r=0:r=Math.max(0,Math.min(r,a-i)),s===void 0&&(s=Eo),hn(this)){var l=fn(this,{object:this.proxy_,type:Mh,index:i,removedCount:r,added:s});if(!l)return Eo;r=l.removedCount,s=l.added}if(s=s.length===0?s:s.map(function(h){return o.enhancer_(h,void 0)}),this.legacyMode_||process.env.NODE_ENV!=="production"){var c=s.length-r;this.updateArrayLength_(a,c)}var u=this.spliceItemsIntoValues_(i,r,s);return(r!==0||s.length!==0)&&this.notifyArraySplice_(i,s,u),this.dehanceValues_(u)},e.spliceItemsIntoValues_=function(i,r,s){if(s.length<GM){var o;return(o=this.values_).splice.apply(o,[i,r].concat(s))}else{var a=this.values_.slice(i,i+r),l=this.values_.slice(i+r);this.values_.length+=s.length-r;for(var c=0;c<s.length;c++)this.values_[i+c]=s[c];for(var u=0;u<l.length;u++)this.values_[i+s.length+u]=l[u];return a}},e.notifyArrayChildUpdate_=function(i,r,s){var o=!this.owned_&&It(),a=Rn(this),l=a||o?{observableKind:"array",object:this.proxy_,type:Sn,debugObjectName:this.atom_.name_,index:i,newValue:r,oldValue:s}:null;process.env.NODE_ENV!=="production"&&o&&Qt(l),this.atom_.reportChanged(),a&&Cn(this,l),process.env.NODE_ENV!=="production"&&o&&en()},e.notifyArraySplice_=function(i,r,s){var o=!this.owned_&&It(),a=Rn(this),l=a||o?{observableKind:"array",object:this.proxy_,debugObjectName:this.atom_.name_,type:Mh,index:i,removed:s,added:r,removedCount:s.length,addedCount:r.length}:null;process.env.NODE_ENV!=="production"&&o&&Qt(l),this.atom_.reportChanged(),a&&Cn(this,l),process.env.NODE_ENV!=="production"&&o&&en()},e.get_=function(i){if(this.legacyMode_&&i>=this.values_.length){console.warn(process.env.NODE_ENV!=="production"?"[mobx.array] Attempt to read an array index ("+i+") that is out of bounds ("+this.values_.length+"). Please check length first. Out of bound indices will not be tracked by MobX":"[mobx] Out of bounds read: "+i);return}return this.atom_.reportObserved(),this.dehanceValue_(this.values_[i])},e.set_=function(i,r){var s=this.values_;if(this.legacyMode_&&i>s.length&&ve(17,i,s.length),i<s.length){zn(this.atom_);var o=s[i];if(hn(this)){var a=fn(this,{type:Sn,object:this.proxy_,index:i,newValue:r});if(!a)return;r=a.newValue}r=this.enhancer_(r,o);var l=r!==o;l&&(s[i]=r,this.notifyArrayChildUpdate_(i,r,o))}else{for(var c=new Array(i+1-s.length),u=0;u<c.length-1;u++)c[u]=void 0;c[c.length-1]=r,this.spliceWithArray_(s.length,0,c)}},n})();function XM(n,e,t,i){return t===void 0&&(t=process.env.NODE_ENV!=="production"?"ObservableArray@"+Dn():"ObservableArray"),i===void 0&&(i=!1),Mf(),Ji(function(){var r=new Oc(t,e,i,!1);bf(r.values_,Fe,r);var s=new Proxy(r.values_,WM);return r.proxy_=s,n&&n.length&&r.spliceWithArray_(0,0,n),s})}var Ro={clear:function(){return this.splice(0)},replace:function(e){var t=this[Fe];return t.spliceWithArray_(0,t.values_.length,e)},toJSON:function(){return this.slice()},splice:function(e,t){for(var i=arguments.length,r=new Array(i>2?i-2:0),s=2;s<i;s++)r[s-2]=arguments[s];var o=this[Fe];switch(arguments.length){case 0:return[];case 1:return o.spliceWithArray_(e);case 2:return o.spliceWithArray_(e,t)}return o.spliceWithArray_(e,t,r)},spliceWithArray:function(e,t,i){return this[Fe].spliceWithArray_(e,t,i)},push:function(){for(var e=this[Fe],t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];return e.spliceWithArray_(e.values_.length,0,i),e.values_.length},pop:function(){return this.splice(Math.max(this[Fe].values_.length-1,0),1)[0]},shift:function(){return this.splice(0,1)[0]},unshift:function(){for(var e=this[Fe],t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];return e.spliceWithArray_(0,0,i),e.values_.length},reverse:function(){return he.trackingDerivation&&ve(37,"reverse"),this.replace(this.slice().reverse()),this},sort:function(){he.trackingDerivation&&ve(37,"sort");var e=this.slice();return e.sort.apply(e,arguments),this.replace(e),this},remove:function(e){var t=this[Fe],i=t.dehanceValues_(t.values_).indexOf(e);return i>-1?(this.splice(i,1),!0):!1}};ct("at",tn);ct("concat",tn);ct("flat",tn);ct("includes",tn);ct("indexOf",tn);ct("join",tn);ct("lastIndexOf",tn);ct("slice",tn);ct("toString",tn);ct("toLocaleString",tn);ct("toSorted",tn);ct("toSpliced",tn);ct("with",tn);ct("every",Ln);ct("filter",Ln);ct("find",Ln);ct("findIndex",Ln);ct("findLast",Ln);ct("findLastIndex",Ln);ct("flatMap",Ln);ct("forEach",Ln);ct("map",Ln);ct("some",Ln);ct("toReversed",Ln);ct("reduce",Qf);ct("reduceRight",Qf);function ct(n,e){typeof Array.prototype[n]=="function"&&(Ro[n]=e(n))}function tn(n){return function(){var e=this[Fe];e.atom_.reportObserved();var t=e.dehanceValues_(e.values_);return t[n].apply(t,arguments)}}function Ln(n){return function(e,t){var i=this,r=this[Fe];r.atom_.reportObserved();var s=r.dehanceValues_(r.values_);return s[n](function(o,a){return e.call(t,o,a,i)})}}function Qf(n){return function(){var e=this,t=this[Fe];t.atom_.reportObserved();var i=t.dehanceValues_(t.values_),r=arguments[0];return arguments[0]=function(s,o,a){return r(s,o,a,e)},i[n].apply(i,arguments)}}var jM=Zi("ObservableArrayAdministration",Oc);function jo(n){return zo(n)&&jM(n[Fe])}var YM={},fi="add",Co="delete",ed=(function(){function n(t,i,r){var s=this;i===void 0&&(i=Wi),r===void 0&&(r=process.env.NODE_ENV!=="production"?"ObservableMap@"+Dn():"ObservableMap"),this.enhancer_=void 0,this.name_=void 0,this[Fe]=YM,this.data_=void 0,this.hasMap_=void 0,this.keysAtom_=void 0,this.interceptors_=void 0,this.changeListeners_=void 0,this.dehancer=void 0,this.enhancer_=i,this.name_=r,Rt(Map)||ve(18),Ji(function(){s.keysAtom_=Af(process.env.NODE_ENV!=="production"?s.name_+".keys()":"ObservableMap.keys()"),s.data_=new Map,s.hasMap_=new Map,t&&s.merge(t)})}var e=n.prototype;return e.has_=function(i){return this.data_.has(i)},e.has=function(i){var r=this;if(!he.trackingDerivation)return this.has_(i);var s=this.hasMap_.get(i);if(!s){var o=s=new Vi(this.has_(i),ko,process.env.NODE_ENV!=="production"?this.name_+"."+Xl(i)+"?":"ObservableMap.key?",!1);this.hasMap_.set(i,o),qf(o,function(){return r.hasMap_.delete(i)})}return s.get()},e.set=function(i,r){var s=this.has_(i);if(hn(this)){var o=fn(this,{type:s?Sn:fi,object:this,newValue:r,name:i});if(!o)return this;r=o.newValue}return s?this.updateValue_(i,r):this.addValue_(i,r),this},e.delete=function(i){var r=this;if(zn(this.keysAtom_),hn(this)){var s=fn(this,{type:Co,object:this,name:i});if(!s)return!1}if(this.has_(i)){var o=It(),a=Rn(this),l=a||o?{observableKind:"map",debugObjectName:this.name_,type:Co,object:this,oldValue:this.data_.get(i).value_,name:i}:null;return process.env.NODE_ENV!=="production"&&o&&Qt(l),Kn(function(){var c;r.keysAtom_.reportChanged(),(c=r.hasMap_.get(i))==null||c.setNewValue_(!1);var u=r.data_.get(i);u.setNewValue_(void 0),r.data_.delete(i)}),a&&Cn(this,l),process.env.NODE_ENV!=="production"&&o&&en(),!0}return!1},e.updateValue_=function(i,r){var s=this.data_.get(i);if(r=s.prepareNewValue_(r),r!==he.UNCHANGED){var o=It(),a=Rn(this),l=a||o?{observableKind:"map",debugObjectName:this.name_,type:Sn,object:this,oldValue:s.value_,name:i,newValue:r}:null;process.env.NODE_ENV!=="production"&&o&&Qt(l),s.setNewValue_(r),a&&Cn(this,l),process.env.NODE_ENV!=="production"&&o&&en()}},e.addValue_=function(i,r){var s=this;zn(this.keysAtom_),Kn(function(){var c,u=new Vi(r,s.enhancer_,process.env.NODE_ENV!=="production"?s.name_+"."+Xl(i):"ObservableMap.key",!1);s.data_.set(i,u),r=u.value_,(c=s.hasMap_.get(i))==null||c.setNewValue_(!0),s.keysAtom_.reportChanged()});var o=It(),a=Rn(this),l=a||o?{observableKind:"map",debugObjectName:this.name_,type:fi,object:this,name:i,newValue:r}:null;process.env.NODE_ENV!=="production"&&o&&Qt(l),a&&Cn(this,l),process.env.NODE_ENV!=="production"&&o&&en()},e.get=function(i){return this.has(i)?this.dehanceValue_(this.data_.get(i).get()):this.dehanceValue_(void 0)},e.dehanceValue_=function(i){return this.dehancer!==void 0?this.dehancer(i):i},e.keys=function(){return this.keysAtom_.reportObserved(),this.data_.keys()},e.values=function(){var i=this,r=this.keys();return Eh({next:function(){var o=r.next(),a=o.done,l=o.value;return{done:a,value:a?void 0:i.get(l)}}})},e.entries=function(){var i=this,r=this.keys();return Eh({next:function(){var o=r.next(),a=o.done,l=o.value;return{done:a,value:a?void 0:[l,i.get(l)]}}})},e[Symbol.iterator]=function(){return this.entries()},e.forEach=function(i,r){for(var s=xr(this),o;!(o=s()).done;){var a=o.value,l=a[0],c=a[1];i.call(r,c,l,this)}},e.merge=function(i){var r=this;return Mi(i)&&(i=new Map(i)),Kn(function(){Jt(i)?my(i).forEach(function(s){return r.set(s,i[s])}):Array.isArray(i)?i.forEach(function(s){var o=s[0],a=s[1];return r.set(o,a)}):Ur(i)?(py(i)||ve(19,i),i.forEach(function(s,o){return r.set(o,s)})):i!=null&&ve(20,i)}),this},e.clear=function(){var i=this;Kn(function(){Ff(function(){for(var r=xr(i.keys()),s;!(s=r()).done;){var o=s.value;i.delete(o)}})})},e.replace=function(i){var r=this;return Kn(function(){for(var s=qM(i),o=new Map,a=!1,l=xr(r.data_.keys()),c;!(c=l()).done;){var u=c.value;if(!s.has(u)){var h=r.delete(u);if(h)a=!0;else{var d=r.data_.get(u);o.set(u,d)}}}for(var p=xr(s.entries()),g;!(g=p()).done;){var y=g.value,m=y[0],f=y[1],w=r.data_.has(m);if(r.set(m,f),r.data_.has(m)){var T=r.data_.get(m);o.set(m,T),w||(a=!0)}}if(!a)if(r.data_.size!==o.size)r.keysAtom_.reportChanged();else for(var _=r.data_.keys(),S=o.keys(),b=_.next(),A=S.next();!b.done;){if(b.value!==A.value){r.keysAtom_.reportChanged();break}b=_.next(),A=S.next()}r.data_=o}),this},e.toString=function(){return"[object ObservableMap]"},e.toJSON=function(){return Array.from(this)},e.observe_=function(i,r){return process.env.NODE_ENV!=="production"&&r===!0&&ve("`observe` doesn't support fireImmediately=true in combination with maps."),ys(this,i)},e.intercept_=function(i){return xs(this,i)},Fr(n,[{key:"size",get:function(){return this.keysAtom_.reportObserved(),this.data_.size}},{key:Symbol.toStringTag,get:function(){return"Map"}}])})(),Mi=Zi("ObservableMap",ed);function Eh(n){return n[Symbol.toStringTag]="MapIterator",Nc(n)}function qM(n){if(Ur(n)||Mi(n))return n;if(Array.isArray(n))return new Map(n);if(Jt(n)){var e=new Map;for(var t in n)e.set(t,n[t]);return e}else return ve(21,n)}var $M={},td=(function(){function n(t,i,r){var s=this;i===void 0&&(i=Wi),r===void 0&&(r=process.env.NODE_ENV!=="production"?"ObservableSet@"+Dn():"ObservableSet"),this.name_=void 0,this[Fe]=$M,this.data_=new Set,this.atom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.dehancer=void 0,this.enhancer_=void 0,this.name_=r,Rt(Set)||ve(22),this.enhancer_=function(o,a){return i(o,a,r)},Ji(function(){s.atom_=Af(s.name_),t&&s.replace(t)})}var e=n.prototype;return e.dehanceValue_=function(i){return this.dehancer!==void 0?this.dehancer(i):i},e.clear=function(){var i=this;Kn(function(){Ff(function(){for(var r=xr(i.data_.values()),s;!(s=r()).done;){var o=s.value;i.delete(o)}})})},e.forEach=function(i,r){for(var s=xr(this),o;!(o=s()).done;){var a=o.value;i.call(r,a,a,this)}},e.add=function(i){var r=this;if(zn(this.atom_),hn(this)){var s=fn(this,{type:fi,object:this,newValue:i});if(!s)return this;i=s.newValue}if(!this.has(i)){Kn(function(){r.data_.add(r.enhancer_(i,void 0)),r.atom_.reportChanged()});var o=process.env.NODE_ENV!=="production"&&It(),a=Rn(this),l=a||o?{observableKind:"set",debugObjectName:this.name_,type:fi,object:this,newValue:i}:null;o&&process.env.NODE_ENV!=="production"&&Qt(l),a&&Cn(this,l),o&&process.env.NODE_ENV!=="production"&&en()}return this},e.delete=function(i){var r=this;if(hn(this)){var s=fn(this,{type:Co,object:this,oldValue:i});if(!s)return!1}if(this.has(i)){var o=process.env.NODE_ENV!=="production"&&It(),a=Rn(this),l=a||o?{observableKind:"set",debugObjectName:this.name_,type:Co,object:this,oldValue:i}:null;return o&&process.env.NODE_ENV!=="production"&&Qt(l),Kn(function(){r.atom_.reportChanged(),r.data_.delete(i)}),a&&Cn(this,l),o&&process.env.NODE_ENV!=="production"&&en(),!0}return!1},e.has=function(i){return this.atom_.reportObserved(),this.data_.has(this.dehanceValue_(i))},e.entries=function(){var i=this.values();return bh({next:function(){var s=i.next(),o=s.value,a=s.done;return a?{value:void 0,done:a}:{value:[o,o],done:a}}})},e.keys=function(){return this.values()},e.values=function(){this.atom_.reportObserved();var i=this,r=this.data_.values();return bh({next:function(){var o=r.next(),a=o.value,l=o.done;return l?{value:void 0,done:l}:{value:i.dehanceValue_(a),done:l}}})},e.intersection=function(i){if($n(i)&&!Un(i))return i.intersection(this);var r=new Set(this);return r.intersection(i)},e.union=function(i){if($n(i)&&!Un(i))return i.union(this);var r=new Set(this);return r.union(i)},e.difference=function(i){return new Set(this).difference(i)},e.symmetricDifference=function(i){if($n(i)&&!Un(i))return i.symmetricDifference(this);var r=new Set(this);return r.symmetricDifference(i)},e.isSubsetOf=function(i){return new Set(this).isSubsetOf(i)},e.isSupersetOf=function(i){return new Set(this).isSupersetOf(i)},e.isDisjointFrom=function(i){if($n(i)&&!Un(i))return i.isDisjointFrom(this);var r=new Set(this);return r.isDisjointFrom(i)},e.replace=function(i){var r=this;return Un(i)&&(i=new Set(i)),Kn(function(){Array.isArray(i)?(r.clear(),i.forEach(function(s){return r.add(s)})):$n(i)?(r.clear(),i.forEach(function(s){return r.add(s)})):i!=null&&ve("Cannot initialize set from "+i)}),this},e.observe_=function(i,r){return process.env.NODE_ENV!=="production"&&r===!0&&ve("`observe` doesn't support fireImmediately=true in combination with sets."),ys(this,i)},e.intercept_=function(i){return xs(this,i)},e.toJSON=function(){return Array.from(this)},e.toString=function(){return"[object ObservableSet]"},e[Symbol.iterator]=function(){return this.values()},Fr(n,[{key:"size",get:function(){return this.atom_.reportObserved(),this.data_.size}},{key:Symbol.toStringTag,get:function(){return"Set"}}])})(),Un=Zi("ObservableSet",td);function bh(n){return n[Symbol.toStringTag]="SetIterator",Nc(n)}var Sh=Object.create(null),Th="remove",Ql=(function(){function n(t,i,r,s){i===void 0&&(i=new Map),s===void 0&&(s=Wy),this.target_=void 0,this.values_=void 0,this.name_=void 0,this.defaultAnnotation_=void 0,this.keysAtom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.proxy_=void 0,this.isPlainObject_=void 0,this.appliedAnnotations_=void 0,this.pendingKeys_=void 0,this.target_=t,this.values_=i,this.name_=r,this.defaultAnnotation_=s,this.keysAtom_=new yi(process.env.NODE_ENV!=="production"?this.name_+".keys":"ObservableObject.keys"),this.isPlainObject_=Jt(this.target_),process.env.NODE_ENV!=="production"&&!ad(this.defaultAnnotation_)&&ve("defaultAnnotation must be valid annotation"),process.env.NODE_ENV!=="production"&&(this.appliedAnnotations_={})}var e=n.prototype;return e.getObservablePropValue_=function(i){return this.values_.get(i).get()},e.setObservablePropValue_=function(i,r){var s=this.values_.get(i);if(s instanceof gn)return s.set(r),!0;if(hn(this)){var o=fn(this,{type:Sn,object:this.proxy_||this.target_,name:i,newValue:r});if(!o)return null;r=o.newValue}if(r=s.prepareNewValue_(r),r!==he.UNCHANGED){var a=Rn(this),l=process.env.NODE_ENV!=="production"&&It(),c=a||l?{type:Sn,observableKind:"object",debugObjectName:this.name_,object:this.proxy_||this.target_,oldValue:s.value_,name:i,newValue:r}:null;process.env.NODE_ENV!=="production"&&l&&Qt(c),s.setNewValue_(r),a&&Cn(this,c),process.env.NODE_ENV!=="production"&&l&&en()}return!0},e.get_=function(i){return he.trackingDerivation&&!An(this.target_,i)&&this.has_(i),this.target_[i]},e.set_=function(i,r,s){return s===void 0&&(s=!1),An(this.target_,i)?this.values_.has(i)?this.setObservablePropValue_(i,r):s?Reflect.set(this.target_,i,r):(this.target_[i]=r,!0):this.extend_(i,{value:r,enumerable:!0,writable:!0,configurable:!0},this.defaultAnnotation_,s)},e.has_=function(i){if(!he.trackingDerivation)return i in this.target_;this.pendingKeys_||(this.pendingKeys_=new Map);var r=this.pendingKeys_.get(i);return r||(r=new Vi(i in this.target_,ko,process.env.NODE_ENV!=="production"?this.name_+"."+Xl(i)+"?":"ObservableObject.key?",!1),this.pendingKeys_.set(i,r)),r.get()},e.make_=function(i,r){if(r===!0&&(r=this.defaultAnnotation_),r!==!1){if(Rh(this,r,i),!(i in this.target_)){var s;if((s=this.target_[Zn])!=null&&s[i])return;ve(1,r.annotationType_,this.name_+"."+i.toString())}for(var o=this.target_;o&&o!==Bo;){var a=Mo(o,i);if(a){var l=r.make_(this,i,a,o);if(l===0)return;if(l===1)break}o=Object.getPrototypeOf(o)}Ah(this,r,i)}},e.extend_=function(i,r,s,o){if(o===void 0&&(o=!1),s===!0&&(s=this.defaultAnnotation_),s===!1)return this.defineProperty_(i,r,o);Rh(this,s,i);var a=s.extend_(this,i,r,o);return a&&Ah(this,s,i),a},e.defineProperty_=function(i,r,s){s===void 0&&(s=!1),zn(this.keysAtom_);try{pn();var o=this.delete_(i);if(!o)return o;if(hn(this)){var a=fn(this,{object:this.proxy_||this.target_,name:i,type:fi,newValue:r.value});if(!a)return null;var l=a.newValue;r.value!==l&&(r=vi({},r,{value:l}))}if(s){if(!Reflect.defineProperty(this.target_,i,r))return!1}else Vn(this.target_,i,r);this.notifyPropertyAddition_(i,r.value)}finally{mn()}return!0},e.defineObservableProperty_=function(i,r,s,o){o===void 0&&(o=!1),zn(this.keysAtom_);try{pn();var a=this.delete_(i);if(!a)return a;if(hn(this)){var l=fn(this,{object:this.proxy_||this.target_,name:i,type:fi,newValue:r});if(!l)return null;r=l.newValue}var c=wh(i),u={configurable:he.safeDescriptors?this.isPlainObject_:!0,enumerable:!0,get:c.get,set:c.set};if(o){if(!Reflect.defineProperty(this.target_,i,u))return!1}else Vn(this.target_,i,u);var h=new Vi(r,s,process.env.NODE_ENV!=="production"?this.name_+"."+i.toString():"ObservableObject.key",!1);this.values_.set(i,h),this.notifyPropertyAddition_(i,h.value_)}finally{mn()}return!0},e.defineComputedProperty_=function(i,r,s){s===void 0&&(s=!1),zn(this.keysAtom_);try{pn();var o=this.delete_(i);if(!o)return o;if(hn(this)){var a=fn(this,{object:this.proxy_||this.target_,name:i,type:fi,newValue:void 0});if(!a)return null}r.name||(r.name=process.env.NODE_ENV!=="production"?this.name_+"."+i.toString():"ObservableObject.key"),r.context=this.proxy_||this.target_;var l=wh(i),c={configurable:he.safeDescriptors?this.isPlainObject_:!0,enumerable:!1,get:l.get,set:l.set};if(s){if(!Reflect.defineProperty(this.target_,i,c))return!1}else Vn(this.target_,i,c);this.values_.set(i,new gn(r)),this.notifyPropertyAddition_(i,void 0)}finally{mn()}return!0},e.delete_=function(i,r){if(r===void 0&&(r=!1),zn(this.keysAtom_),!An(this.target_,i))return!0;if(hn(this)){var s=fn(this,{object:this.proxy_||this.target_,name:i,type:Th});if(!s)return null}try{var o;pn();var a=Rn(this),l=process.env.NODE_ENV!=="production"&&It(),c=this.values_.get(i),u=void 0;if(!c&&(a||l)){var h;u=(h=Mo(this.target_,i))==null?void 0:h.value}if(r){if(!Reflect.deleteProperty(this.target_,i))return!1}else delete this.target_[i];if(process.env.NODE_ENV!=="production"&&delete this.appliedAnnotations_[i],c&&(this.values_.delete(i),c instanceof Vi&&(u=c.value_),kf(c)),this.keysAtom_.reportChanged(),(o=this.pendingKeys_)==null||(o=o.get(i))==null||o.set(i in this.target_),a||l){var d={type:Th,observableKind:"object",object:this.proxy_||this.target_,debugObjectName:this.name_,oldValue:u,name:i};process.env.NODE_ENV!=="production"&&l&&Qt(d),a&&Cn(this,d),process.env.NODE_ENV!=="production"&&l&&en()}}finally{mn()}return!0},e.observe_=function(i,r){return process.env.NODE_ENV!=="production"&&r===!0&&ve("`observe` doesn't support the fire immediately property for observable objects."),ys(this,i)},e.intercept_=function(i){return xs(this,i)},e.notifyPropertyAddition_=function(i,r){var s,o=Rn(this),a=process.env.NODE_ENV!=="production"&&It();if(o||a){var l=o||a?{type:fi,observableKind:"object",debugObjectName:this.name_,object:this.proxy_||this.target_,name:i,newValue:r}:null;process.env.NODE_ENV!=="production"&&a&&Qt(l),o&&Cn(this,l),process.env.NODE_ENV!=="production"&&a&&en()}(s=this.pendingKeys_)==null||(s=s.get(i))==null||s.set(!0),this.keysAtom_.reportChanged()},e.ownKeys_=function(){return this.keysAtom_.reportObserved(),cs(this.target_)},e.keys_=function(){return this.keysAtom_.reportObserved(),Object.keys(this.target_)},n})();function Br(n,e){var t;if(process.env.NODE_ENV!=="production"&&e&&zr(n)&&ve("Options can't be provided for already observable objects."),An(n,Fe))return process.env.NODE_ENV!=="production"&&!(sd(n)instanceof Ql)&&ve("Cannot convert '"+Po(n)+`' into observable object:
4012
+ `)()}}function xm(i,t,e){if(t.length>=1e3){t.push("(and many more)");return}t.push(""+" ".repeat(e-1)+i.name),i.dependencies&&i.dependencies.forEach(function(n){return xm(n,t,e+1)})}var es=(function(){function i(e,n,s,r){e===void 0&&(e=process.env.NODE_ENV!=="production"?"Reaction@"+Qn():"Reaction"),this.name_=void 0,this.onInvalidate_=void 0,this.errorHandler_=void 0,this.requiresObservable_=void 0,this.observing_=[],this.newObserving_=[],this.dependenciesState_=ee.NOT_TRACKING_,this.runId_=0,this.unboundDepsCount_=0,this.flags_=0,this.isTracing_=Un.NONE,this.name_=e,this.onInvalidate_=n,this.errorHandler_=s,this.requiresObservable_=r}var t=i.prototype;return t.onBecomeStale_=function(){this.schedule_()},t.schedule_=function(){this.isScheduled||(this.isScheduled=!0,dt.pendingReactions.push(this),gm())},t.runReaction_=function(){if(!this.isDisposed){Nn(),this.isScheduled=!1;var n=dt.trackingContext;if(dt.trackingContext=this,Fh(this)){this.isTrackPending=!0;try{this.onInvalidate_(),process.env.NODE_ENV!=="production"&&this.isTrackPending&&We()&&Ds({name:this.name_,type:"scheduled-reaction"})}catch(s){this.reportExceptionInDerivation_(s)}}dt.trackingContext=n,In()}},t.track=function(n){if(!this.isDisposed){Nn();var s=We(),r;process.env.NODE_ENV!=="production"&&s&&(r=Date.now(),vn({name:this.name_,type:"reaction"})),this.isRunning=!0;var a=dt.trackingContext;dt.trackingContext=this;var o=cm(this,n,void 0);dt.trackingContext=a,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&zh(this),No(o)&&this.reportExceptionInDerivation_(o.cause),process.env.NODE_ENV!=="production"&&s&&yn({time:Date.now()-r}),In()}},t.reportExceptionInDerivation_=function(n){var s=this;if(this.errorHandler_){this.errorHandler_(n,this);return}if(dt.disableErrorBoundaries)throw n;var r=process.env.NODE_ENV!=="production"?"[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '"+this+"'":"[mobx] uncaught error in '"+this+"'";dt.suppressReactionErrors?process.env.NODE_ENV!=="production"&&console.warn("[mobx] (error in reaction '"+this.name_+"' suppressed, fix error of causing action below)"):console.error(r,n),process.env.NODE_ENV!=="production"&&We()&&Ds({type:"error",name:this.name_,message:r,error:""+n}),dt.globalReactionErrorHandlers.forEach(function(a){return a(n,s)})},t.dispose=function(){this.isDisposed||(this.isDisposed=!0,this.isRunning||(Nn(),zh(this),In()))},t.getDisposer_=function(n){var s=this,r=function a(){s.dispose(),n==null||n.removeEventListener==null||n.removeEventListener("abort",a)};return n==null||n.addEventListener==null||n.addEventListener("abort",r),r[zt]=this,"dispose"in Symbol&&typeof Symbol.dispose=="symbol"&&(r[Symbol.dispose]=r),r},t.toString=function(){return"Reaction["+this.name_+"]"},t.trace=function(n){n===void 0&&(n=!1),d1(this,n)},Ir(i,[{key:"isDisposed",get:function(){return mn(this.flags_,i.isDisposedMask_)},set:function(n){this.flags_=_n(this.flags_,i.isDisposedMask_,n)}},{key:"isScheduled",get:function(){return mn(this.flags_,i.isScheduledMask_)},set:function(n){this.flags_=_n(this.flags_,i.isScheduledMask_,n)}},{key:"isTrackPending",get:function(){return mn(this.flags_,i.isTrackPendingMask_)},set:function(n){this.flags_=_n(this.flags_,i.isTrackPendingMask_,n)}},{key:"isRunning",get:function(){return mn(this.flags_,i.isRunningMask_)},set:function(n){this.flags_=_n(this.flags_,i.isRunningMask_,n)}},{key:"diffValue",get:function(){return mn(this.flags_,i.diffValueMask_)?1:0},set:function(n){this.flags_=_n(this.flags_,i.diffValueMask_,n===1)}}])})();es.isDisposedMask_=1;es.isScheduledMask_=2;es.isTrackPendingMask_=4;es.isRunningMask_=8;es.diffValueMask_=16;var Vf=100,jE=function(t){return t()};function gm(){dt.inBatch>0||dt.isRunningReactions||jE(YE)}function YE(){dt.isRunningReactions=!0;for(var i=dt.pendingReactions,t=0;i.length>0;){++t===Vf&&(console.error(process.env.NODE_ENV!=="production"?"Reaction doesn't converge to a stable state after "+Vf+" iterations."+(" Probably there is a cycle in the reactive function: "+i[0]):"[mobx] cycle in reaction: "+i[0]),i.splice(0));for(var e=i.splice(0),n=0,s=e.length;n<s;n++)e[n].runReaction_()}dt.isRunningReactions=!1}var Zo=Ns("Reaction",es);function We(){return process.env.NODE_ENV!=="production"&&!!dt.spyListeners.length}function Ds(i){if(process.env.NODE_ENV!=="production"&&dt.spyListeners.length)for(var t=dt.spyListeners,e=0,n=t.length;e<n;e++)t[e](i)}function vn(i){if(process.env.NODE_ENV!=="production"){var t=ts({},i,{spyReportStart:!0});Ds(t)}}var qE={type:"report-end",spyReportEnd:!0};function yn(i){process.env.NODE_ENV!=="production"&&Ds(i?ts({},i,{type:"report-end",spyReportEnd:!0}):qE)}function ZE(i){return process.env.NODE_ENV==="production"?(console.warn("[mobx.spy] Is a no-op in production builds"),function(){}):(dt.spyListeners.push(i),mu(function(){dt.spyListeners=dt.spyListeners.filter(function(t){return t!==i})}))}var bu="action",$E="action.bound",vm="autoAction",KE="autoAction.bound",JE="<unnamed action>",Bh=Ea(bu),QE=Ea($E,{bound:!0}),kh=Ea(vm,{autoAction:!0}),t1=Ea(KE,{autoAction:!0,bound:!0});function ym(i){var t=function(n,s){if(Ue(n))return Ps(n.name||JE,n,i);if(Ue(s))return Ps(n,s,i);if(Sa(s))return(i?kh:Bh).decorate_20223_(n,s);if(Cs(s))return Ma(n,s,i?kh:Bh);if(Cs(n))return hi(Ea(i?vm:bu,{name:n,autoAction:i}));process.env.NODE_ENV!=="production"&&vt("Invalid arguments for `action`")};return t}var fr=ym(!1);Object.assign(fr,Bh);var pa=ym(!0);Object.assign(pa,kh);fr.bound=hi(QE);pa.bound=hi(t1);function Os(i){return Ue(i)&&i.isMobxAction===!0}function e1(i,t){var e,n,s,r;t===void 0&&(t=Yp),process.env.NODE_ENV!=="production"&&(Ue(i)||vt("Autorun expects a function as first argument"),Os(i)&&vt("Autorun does not accept actions since actions are untrackable"));var a=(e=(n=t)==null?void 0:n.name)!=null?e:process.env.NODE_ENV!=="production"?i.name||"Autorun@"+Qn():"Autorun",o=!t.scheduler&&!t.delay,l;if(o)l=new es(a,function(){this.track(u)},t.onError,t.requiresObservable);else{var c=i1(t),h=!1;l=new es(a,function(){h||(h=!0,c(function(){h=!1,l.isDisposed||l.track(u)}))},t.onError,t.requiresObservable)}function u(){i(l)}return(s=t)!=null&&(s=s.signal)!=null&&s.aborted||l.schedule_(),l.getDisposer_((r=t)==null?void 0:r.signal)}var n1=function(t){return t()};function i1(i){return i.scheduler?i.scheduler:i.delay?function(t){return setTimeout(t,i.delay)}:n1}var s1="onBO",r1="onBUO";function a1(i,t,e){return Mm(s1,i,t,e)}function bm(i,t,e){return Mm(r1,i,t,e)}function Mm(i,t,e,n){var s=Cr(t),r=Ue(n)?n:e,a=i+"L";return s[a]?s[a].add(r):s[a]=new Set([r]),function(){var o=s[a];o&&(o.delete(r),o.size===0&&delete s[a])}}function Sm(i,t,e,n){process.env.NODE_ENV!=="production"&&(arguments.length>4&&vt("'extendObservable' expected 2-4 arguments"),typeof i!="object"&&vt("'extendObservable' expects an object as first argument"),is(i)&&vt("'extendObservable' should not be used on maps, use map.merge instead"),gn(t)||vt("'extendObservable' only accepts plain objects as second argument"),(_a(t)||_a(e))&&vt("Extending an object with another observable (object) is not supported"));var s=WS(t);return Us(function(){var r=Ur(i,n)[zt];fa(s).forEach(function(a){r.extend_(a,s[a],e&&a in e?e[a]:!0)})}),i}function o1(i,t){return Em(Cr(i,t))}function Em(i){var t={name:i.name_};return i.observing_&&i.observing_.length>0&&(t.dependencies=l1(i.observing_).map(Em)),t}function l1(i){return Array.from(new Set(i))}var c1=0;function wm(){this.message="FLOW_CANCELLED"}wm.prototype=Object.create(Error.prototype);var Mc=nm("flow"),h1=nm("flow.bound",{bound:!0}),Ar=Object.assign(function(t,e){if(Sa(e))return Mc.decorate_20223_(t,e);if(Cs(e))return Ma(t,e,Mc);process.env.NODE_ENV!=="production"&&arguments.length!==1&&vt("Flow expects single argument with generator function");var n=t,s=n.name||"<unnamed flow>",r=function(){var o=this,l=arguments,c=++c1,h=fr(s+" - runid: "+c+" - init",n).apply(o,l),u,d=void 0,f=new Promise(function(m,x){var _=0;u=x;function p(y){d=void 0;var E;try{E=fr(s+" - runid: "+c+" - yield "+_++,h.next).call(h,y)}catch(v){return x(v)}S(E)}function w(y){d=void 0;var E;try{E=fr(s+" - runid: "+c+" - yield "+_++,h.throw).call(h,y)}catch(v){return x(v)}S(E)}function S(y){if(Ue(y?.then)){y.then(S,x);return}return y.done?m(y.value):(d=Promise.resolve(y.value),d.then(p,w))}p(void 0)});return f.cancel=fr(s+" - runid: "+c+" - cancel",function(){try{d&&Hf(d);var m=h.return(void 0),x=Promise.resolve(m.value);x.then(ur,ur),Hf(x),u(new wm)}catch(_){u(_)}}),f};return r.isMobXFlow=!0,r},Mc);Ar.bound=hi(h1);function Hf(i){Ue(i.cancel)&&i.cancel()}function ma(i){return i?.isMobXFlow===!0}function u1(i,t){return i?Fr(i)||!!i[zt]||_u(i)||Zo(i)||xl(i):!1}function _a(i){return process.env.NODE_ENV!=="production"&&arguments.length!==1&&vt("isObservable expects only 1 argument. Use isObservableProp to inspect the observability of a property"),u1(i)}function d1(){if(process.env.NODE_ENV!=="production"){for(var i=!1,t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];typeof e[e.length-1]=="boolean"&&(i=e.pop());var s=f1(e);if(!s)return vt("'trace(break?)' can only be used inside a tracked computed value or a Reaction. Consider passing in the computed value or reaction explicitly");s.isTracing_===Un.NONE&&console.log("[mobx.trace] '"+s.name_+"' tracing enabled"),s.isTracing_=i?Un.BREAK:Un.LOG}}function f1(i){switch(i.length){case 0:return dt.trackingDerivation;case 1:return Cr(i[0]);case 2:return Cr(i[0],i[1])}}function Ei(i,t){t===void 0&&(t=void 0),Nn();try{return i.apply(t)}finally{In()}}function ms(i){return i[zt]}var p1={has:function(t,e){return process.env.NODE_ENV!=="production"&&dt.trackingDerivation&&ea("detect new properties using the 'in' operator. Use 'has' from 'mobx' instead."),ms(t).has_(e)},get:function(t,e){return ms(t).get_(e)},set:function(t,e,n){var s;return Cs(e)?(process.env.NODE_ENV!=="production"&&!ms(t).values_.has(e)&&ea("add a new observable property through direct assignment. Use 'set' from 'mobx' instead."),(s=ms(t).set_(e,n,!0))!=null?s:!0):!1},deleteProperty:function(t,e){var n;return process.env.NODE_ENV!=="production"&&ea("delete properties from an observable object. Use 'remove' from 'mobx' instead."),Cs(e)?(n=ms(t).delete_(e,!0))!=null?n:!0:!1},defineProperty:function(t,e,n){var s;return process.env.NODE_ENV!=="production"&&ea("define property on an observable object. Use 'defineProperty' from 'mobx' instead."),(s=ms(t).defineProperty_(e,n))!=null?s:!0},ownKeys:function(t){return process.env.NODE_ENV!=="production"&&dt.trackingDerivation&&ea("iterate keys to detect added / removed properties. Use 'keys' from 'mobx' instead."),ms(t).ownKeys_()},preventExtensions:function(t){vt(13)}};function m1(i,t){var e,n;return qp(),i=Ur(i,t),(n=(e=i[zt]).proxy_)!=null?n:e.proxy_=new Proxy(i,p1)}function Pn(i){return i.interceptors_!==void 0&&i.interceptors_.length>0}function wa(i,t){var e=i.interceptors_||(i.interceptors_=[]);return e.push(t),mu(function(){var n=e.indexOf(t);n!==-1&&e.splice(n,1)})}function Dn(i,t){var e=Is();try{for(var n=[].concat(i.interceptors_||[]),s=0,r=n.length;s<r&&(t=n[s](t),t&&!t.type&&vt(14),!!t);s++);return t}finally{Pi(e)}}function $n(i){return i.changeListeners_!==void 0&&i.changeListeners_.length>0}function Ta(i,t){var e=i.changeListeners_||(i.changeListeners_=[]);return e.push(t),mu(function(){var n=e.indexOf(t);n!==-1&&e.splice(n,1)})}function Kn(i,t){var e=Is(),n=i.changeListeners_;if(n){n=n.slice();for(var s=0,r=n.length;s<r;s++)n[s](t);Pi(e)}}var Sc=Symbol("mobx-keys");function _1(i,t,e){return process.env.NODE_ENV!=="production"&&(!gn(i)&&!gn(Object.getPrototypeOf(i))&&vt("'makeAutoObservable' can only be used for classes that don't have a superclass"),Fr(i)&&vt("makeAutoObservable can only be used on objects not already made observable")),gn(i)?Sm(i,i,t,e):(Us(function(){var n=Ur(i,e)[zt];if(!i[Sc]){var s=Object.getPrototypeOf(i),r=new Set([].concat(fa(i),fa(s)));r.delete("constructor"),r.delete(zt),dl(s,Sc,r)}i[Sc].forEach(function(a){return n.make_(a,t&&a in t?t[a]:!0)})}),i)}var Gf="splice",jn="update",x1=1e4,g1={get:function(t,e){var n=t[zt];return e===zt?n:e==="length"?n.getArrayLength_():typeof e=="string"&&!isNaN(e)?n.get_(parseInt(e)):Zn($o,e)?$o[e]:t[e]},set:function(t,e,n){var s=t[zt];return e==="length"&&s.setArrayLength_(n),typeof e=="symbol"||isNaN(e)?t[e]=n:s.set_(parseInt(e),n),!0},preventExtensions:function(){vt(15)}},Mu=(function(){function i(e,n,s,r){e===void 0&&(e=process.env.NODE_ENV!=="production"?"ObservableArray@"+Qn():"ObservableArray"),this.owned_=void 0,this.legacyMode_=void 0,this.atom_=void 0,this.values_=[],this.interceptors_=void 0,this.changeListeners_=void 0,this.enhancer_=void 0,this.dehancer=void 0,this.proxy_=void 0,this.lastKnownLength_=0,this.owned_=s,this.legacyMode_=r,this.atom_=new ns(e),this.enhancer_=function(a,o){return n(a,o,process.env.NODE_ENV!=="production"?e+"[..]":"ObservableArray[..]")}}var t=i.prototype;return t.dehanceValue_=function(n){return this.dehancer!==void 0?this.dehancer(n):n},t.dehanceValues_=function(n){return this.dehancer!==void 0&&n.length>0?n.map(this.dehancer):n},t.intercept_=function(n){return wa(this,n)},t.observe_=function(n,s){return s===void 0&&(s=!1),s&&n({observableKind:"array",object:this.proxy_,debugObjectName:this.atom_.name_,type:"splice",index:0,added:this.values_.slice(),addedCount:this.values_.length,removed:[],removedCount:0}),Ta(this,n)},t.getArrayLength_=function(){return this.atom_.reportObserved(),this.values_.length},t.setArrayLength_=function(n){(typeof n!="number"||isNaN(n)||n<0)&&vt("Out of range: "+n);var s=this.values_.length;if(n!==s)if(n>s){for(var r=new Array(n-s),a=0;a<n-s;a++)r[a]=void 0;this.spliceWithArray_(s,0,r)}else this.spliceWithArray_(n,s-n)},t.updateArrayLength_=function(n,s){n!==this.lastKnownLength_&&vt(16),this.lastKnownLength_+=s,this.legacyMode_&&s>0&&Dm(n+s+1)},t.spliceWithArray_=function(n,s,r){var a=this;oi(this.atom_);var o=this.values_.length;if(n===void 0?n=0:n>o?n=o:n<0&&(n=Math.max(0,o+n)),arguments.length===1?s=o-n:s==null?s=0:s=Math.max(0,Math.min(s,o-n)),r===void 0&&(r=Wo),Pn(this)){var l=Dn(this,{object:this.proxy_,type:Gf,index:n,removedCount:s,added:r});if(!l)return Wo;s=l.removedCount,r=l.added}if(r=r.length===0?r:r.map(function(u){return a.enhancer_(u,void 0)}),this.legacyMode_||process.env.NODE_ENV!=="production"){var c=r.length-s;this.updateArrayLength_(o,c)}var h=this.spliceItemsIntoValues_(n,s,r);return(s!==0||r.length!==0)&&this.notifyArraySplice_(n,r,h),this.dehanceValues_(h)},t.spliceItemsIntoValues_=function(n,s,r){if(r.length<x1){var a;return(a=this.values_).splice.apply(a,[n,s].concat(r))}else{var o=this.values_.slice(n,n+s),l=this.values_.slice(n+s);this.values_.length+=r.length-s;for(var c=0;c<r.length;c++)this.values_[n+c]=r[c];for(var h=0;h<l.length;h++)this.values_[n+r.length+h]=l[h];return o}},t.notifyArrayChildUpdate_=function(n,s,r){var a=!this.owned_&&We(),o=$n(this),l=o||a?{observableKind:"array",object:this.proxy_,type:jn,debugObjectName:this.atom_.name_,index:n,newValue:s,oldValue:r}:null;process.env.NODE_ENV!=="production"&&a&&vn(l),this.atom_.reportChanged(),o&&Kn(this,l),process.env.NODE_ENV!=="production"&&a&&yn()},t.notifyArraySplice_=function(n,s,r){var a=!this.owned_&&We(),o=$n(this),l=o||a?{observableKind:"array",object:this.proxy_,debugObjectName:this.atom_.name_,type:Gf,index:n,removed:r,added:s,removedCount:r.length,addedCount:s.length}:null;process.env.NODE_ENV!=="production"&&a&&vn(l),this.atom_.reportChanged(),o&&Kn(this,l),process.env.NODE_ENV!=="production"&&a&&yn()},t.get_=function(n){if(this.legacyMode_&&n>=this.values_.length){console.warn(process.env.NODE_ENV!=="production"?"[mobx.array] Attempt to read an array index ("+n+") that is out of bounds ("+this.values_.length+"). Please check length first. Out of bound indices will not be tracked by MobX":"[mobx] Out of bounds read: "+n);return}return this.atom_.reportObserved(),this.dehanceValue_(this.values_[n])},t.set_=function(n,s){var r=this.values_;if(this.legacyMode_&&n>r.length&&vt(17,n,r.length),n<r.length){oi(this.atom_);var a=r[n];if(Pn(this)){var o=Dn(this,{type:jn,object:this.proxy_,index:n,newValue:s});if(!o)return;s=o.newValue}s=this.enhancer_(s,a);var l=s!==a;l&&(r[n]=s,this.notifyArrayChildUpdate_(n,s,a))}else{for(var c=new Array(n+1-r.length),h=0;h<c.length-1;h++)c[h]=void 0;c[c.length-1]=s,this.spliceWithArray_(r.length,0,c)}},i})();function v1(i,t,e,n){return e===void 0&&(e=process.env.NODE_ENV!=="production"?"ObservableArray@"+Qn():"ObservableArray"),n===void 0&&(n=!1),qp(),Us(function(){var s=new Mu(e,t,n,!1);$p(s.values_,zt,s);var r=new Proxy(s.values_,g1);return s.proxy_=r,i&&i.length&&s.spliceWithArray_(0,0,i),r})}var $o={clear:function(){return this.splice(0)},replace:function(t){var e=this[zt];return e.spliceWithArray_(0,e.values_.length,t)},toJSON:function(){return this.slice()},splice:function(t,e){for(var n=arguments.length,s=new Array(n>2?n-2:0),r=2;r<n;r++)s[r-2]=arguments[r];var a=this[zt];switch(arguments.length){case 0:return[];case 1:return a.spliceWithArray_(t);case 2:return a.spliceWithArray_(t,e)}return a.spliceWithArray_(t,e,s)},spliceWithArray:function(t,e,n){return this[zt].spliceWithArray_(t,e,n)},push:function(){for(var t=this[zt],e=arguments.length,n=new Array(e),s=0;s<e;s++)n[s]=arguments[s];return t.spliceWithArray_(t.values_.length,0,n),t.values_.length},pop:function(){return this.splice(Math.max(this[zt].values_.length-1,0),1)[0]},shift:function(){return this.splice(0,1)[0]},unshift:function(){for(var t=this[zt],e=arguments.length,n=new Array(e),s=0;s<e;s++)n[s]=arguments[s];return t.spliceWithArray_(0,0,n),t.values_.length},reverse:function(){return dt.trackingDerivation&&vt(37,"reverse"),this.replace(this.slice().reverse()),this},sort:function(){dt.trackingDerivation&&vt(37,"sort");var t=this.slice();return t.sort.apply(t,arguments),this.replace(t),this},remove:function(t){var e=this[zt],n=e.dehanceValues_(e.values_).indexOf(t);return n>-1?(this.splice(n,1),!0):!1}};me("at",bn);me("concat",bn);me("flat",bn);me("includes",bn);me("indexOf",bn);me("join",bn);me("lastIndexOf",bn);me("slice",bn);me("toString",bn);me("toLocaleString",bn);me("toSorted",bn);me("toSpliced",bn);me("with",bn);me("every",ti);me("filter",ti);me("find",ti);me("findIndex",ti);me("findLast",ti);me("findLastIndex",ti);me("flatMap",ti);me("forEach",ti);me("map",ti);me("some",ti);me("toReversed",ti);me("reduce",Tm);me("reduceRight",Tm);function me(i,t){typeof Array.prototype[i]=="function"&&($o[i]=t(i))}function bn(i){return function(){var t=this[zt];t.atom_.reportObserved();var e=t.dehanceValues_(t.values_);return e[i].apply(e,arguments)}}function ti(i){return function(t,e){var n=this,s=this[zt];s.atom_.reportObserved();var r=s.dehanceValues_(s.values_);return r[i](function(a,o){return t.call(e,a,o,n)})}}function Tm(i){return function(){var t=this,e=this[zt];e.atom_.reportObserved();var n=e.dehanceValues_(e.values_),s=arguments[0];return arguments[0]=function(r,a,o){return s(r,a,o,t)},n[i].apply(n,arguments)}}var y1=Ns("ObservableArrayAdministration",Mu);function gl(i){return ul(i)&&y1(i[zt])}var b1={},$i="add",Ko="delete",Am=(function(){function i(e,n,s){var r=this;n===void 0&&(n=Rs),s===void 0&&(s=process.env.NODE_ENV!=="production"?"ObservableMap@"+Qn():"ObservableMap"),this.enhancer_=void 0,this.name_=void 0,this[zt]=b1,this.data_=void 0,this.hasMap_=void 0,this.keysAtom_=void 0,this.interceptors_=void 0,this.changeListeners_=void 0,this.dehancer=void 0,this.enhancer_=n,this.name_=s,Ue(Map)||vt(18),Us(function(){r.keysAtom_=tm(process.env.NODE_ENV!=="production"?r.name_+".keys()":"ObservableMap.keys()"),r.data_=new Map,r.hasMap_=new Map,e&&r.merge(e)})}var t=i.prototype;return t.has_=function(n){return this.data_.has(n)},t.has=function(n){var s=this;if(!dt.trackingDerivation)return this.has_(n);var r=this.hasMap_.get(n);if(!r){var a=r=new Es(this.has_(n),pl,process.env.NODE_ENV!=="production"?this.name_+"."+Lh(n)+"?":"ObservableMap.key?",!1);this.hasMap_.set(n,a),bm(a,function(){return s.hasMap_.delete(n)})}return r.get()},t.set=function(n,s){var r=this.has_(n);if(Pn(this)){var a=Dn(this,{type:r?jn:$i,object:this,newValue:s,name:n});if(!a)return this;s=a.newValue}return r?this.updateValue_(n,s):this.addValue_(n,s),this},t.delete=function(n){var s=this;if(oi(this.keysAtom_),Pn(this)){var r=Dn(this,{type:Ko,object:this,name:n});if(!r)return!1}if(this.has_(n)){var a=We(),o=$n(this),l=o||a?{observableKind:"map",debugObjectName:this.name_,type:Ko,object:this,oldValue:this.data_.get(n).value_,name:n}:null;return process.env.NODE_ENV!=="production"&&a&&vn(l),Ei(function(){var c;s.keysAtom_.reportChanged(),(c=s.hasMap_.get(n))==null||c.setNewValue_(!1);var h=s.data_.get(n);h.setNewValue_(void 0),s.data_.delete(n)}),o&&Kn(this,l),process.env.NODE_ENV!=="production"&&a&&yn(),!0}return!1},t.updateValue_=function(n,s){var r=this.data_.get(n);if(s=r.prepareNewValue_(s),s!==dt.UNCHANGED){var a=We(),o=$n(this),l=o||a?{observableKind:"map",debugObjectName:this.name_,type:jn,object:this,oldValue:r.value_,name:n,newValue:s}:null;process.env.NODE_ENV!=="production"&&a&&vn(l),r.setNewValue_(s),o&&Kn(this,l),process.env.NODE_ENV!=="production"&&a&&yn()}},t.addValue_=function(n,s){var r=this;oi(this.keysAtom_),Ei(function(){var c,h=new Es(s,r.enhancer_,process.env.NODE_ENV!=="production"?r.name_+"."+Lh(n):"ObservableMap.key",!1);r.data_.set(n,h),s=h.value_,(c=r.hasMap_.get(n))==null||c.setNewValue_(!0),r.keysAtom_.reportChanged()});var a=We(),o=$n(this),l=o||a?{observableKind:"map",debugObjectName:this.name_,type:$i,object:this,name:n,newValue:s}:null;process.env.NODE_ENV!=="production"&&a&&vn(l),o&&Kn(this,l),process.env.NODE_ENV!=="production"&&a&&yn()},t.get=function(n){return this.has(n)?this.dehanceValue_(this.data_.get(n).get()):this.dehanceValue_(void 0)},t.dehanceValue_=function(n){return this.dehancer!==void 0?this.dehancer(n):n},t.keys=function(){return this.keysAtom_.reportObserved(),this.data_.keys()},t.values=function(){var n=this,s=this.keys();return Wf({next:function(){var a=s.next(),o=a.done,l=a.value;return{done:o,value:o?void 0:n.get(l)}}})},t.entries=function(){var n=this,s=this.keys();return Wf({next:function(){var a=s.next(),o=a.done,l=a.value;return{done:o,value:o?void 0:[l,n.get(l)]}}})},t[Symbol.iterator]=function(){return this.entries()},t.forEach=function(n,s){for(var r=dr(this),a;!(a=r()).done;){var o=a.value,l=o[0],c=o[1];n.call(s,c,l,this)}},t.merge=function(n){var s=this;return is(n)&&(n=new Map(n)),Ei(function(){gn(n)?GS(n).forEach(function(r){return s.set(r,n[r])}):Array.isArray(n)?n.forEach(function(r){var a=r[0],o=r[1];return s.set(a,o)}):Nr(n)?(HS(n)||vt(19,n),n.forEach(function(r,a){return s.set(a,r)})):n!=null&&vt(20,n)}),this},t.clear=function(){var n=this;Ei(function(){hm(function(){for(var s=dr(n.keys()),r;!(r=s()).done;){var a=r.value;n.delete(a)}})})},t.replace=function(n){var s=this;return Ei(function(){for(var r=M1(n),a=new Map,o=!1,l=dr(s.data_.keys()),c;!(c=l()).done;){var h=c.value;if(!r.has(h)){var u=s.delete(h);if(u)o=!0;else{var d=s.data_.get(h);a.set(h,d)}}}for(var f=dr(r.entries()),m;!(m=f()).done;){var x=m.value,_=x[0],p=x[1],w=s.data_.has(_);if(s.set(_,p),s.data_.has(_)){var S=s.data_.get(_);a.set(_,S),w||(o=!0)}}if(!o)if(s.data_.size!==a.size)s.keysAtom_.reportChanged();else for(var y=s.data_.keys(),E=a.keys(),v=y.next(),A=E.next();!v.done;){if(v.value!==A.value){s.keysAtom_.reportChanged();break}v=y.next(),A=E.next()}s.data_=a}),this},t.toString=function(){return"[object ObservableMap]"},t.toJSON=function(){return Array.from(this)},t.observe_=function(n,s){return process.env.NODE_ENV!=="production"&&s===!0&&vt("`observe` doesn't support fireImmediately=true in combination with maps."),Ta(this,n)},t.intercept_=function(n){return wa(this,n)},Ir(i,[{key:"size",get:function(){return this.keysAtom_.reportObserved(),this.data_.size}},{key:Symbol.toStringTag,get:function(){return"Map"}}])})(),is=Ns("ObservableMap",Am);function Wf(i){return i[Symbol.toStringTag]="MapIterator",Eu(i)}function M1(i){if(Nr(i)||is(i))return i;if(Array.isArray(i))return new Map(i);if(gn(i)){var t=new Map;for(var e in i)t.set(e,i[e]);return t}else return vt(21,i)}var S1={},Cm=(function(){function i(e,n,s){var r=this;n===void 0&&(n=Rs),s===void 0&&(s=process.env.NODE_ENV!=="production"?"ObservableSet@"+Qn():"ObservableSet"),this.name_=void 0,this[zt]=S1,this.data_=new Set,this.atom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.dehancer=void 0,this.enhancer_=void 0,this.name_=s,Ue(Set)||vt(22),this.enhancer_=function(a,o){return n(a,o,s)},Us(function(){r.atom_=tm(r.name_),e&&r.replace(e)})}var t=i.prototype;return t.dehanceValue_=function(n){return this.dehancer!==void 0?this.dehancer(n):n},t.clear=function(){var n=this;Ei(function(){hm(function(){for(var s=dr(n.data_.values()),r;!(r=s()).done;){var a=r.value;n.delete(a)}})})},t.forEach=function(n,s){for(var r=dr(this),a;!(a=r()).done;){var o=a.value;n.call(s,o,o,this)}},t.add=function(n){var s=this;if(oi(this.atom_),Pn(this)){var r=Dn(this,{type:$i,object:this,newValue:n});if(!r)return this;n=r.newValue}if(!this.has(n)){Ei(function(){s.data_.add(s.enhancer_(n,void 0)),s.atom_.reportChanged()});var a=process.env.NODE_ENV!=="production"&&We(),o=$n(this),l=o||a?{observableKind:"set",debugObjectName:this.name_,type:$i,object:this,newValue:n}:null;a&&process.env.NODE_ENV!=="production"&&vn(l),o&&Kn(this,l),a&&process.env.NODE_ENV!=="production"&&yn()}return this},t.delete=function(n){var s=this;if(Pn(this)){var r=Dn(this,{type:Ko,object:this,oldValue:n});if(!r)return!1}if(this.has(n)){var a=process.env.NODE_ENV!=="production"&&We(),o=$n(this),l=o||a?{observableKind:"set",debugObjectName:this.name_,type:Ko,object:this,oldValue:n}:null;return a&&process.env.NODE_ENV!=="production"&&vn(l),Ei(function(){s.atom_.reportChanged(),s.data_.delete(n)}),o&&Kn(this,l),a&&process.env.NODE_ENV!=="production"&&yn(),!0}return!1},t.has=function(n){return this.atom_.reportObserved(),this.data_.has(this.dehanceValue_(n))},t.entries=function(){var n=this.values();return Xf({next:function(){var r=n.next(),a=r.value,o=r.done;return o?{value:void 0,done:o}:{value:[a,a],done:o}}})},t.keys=function(){return this.values()},t.values=function(){this.atom_.reportObserved();var n=this,s=this.data_.values();return Xf({next:function(){var a=s.next(),o=a.value,l=a.done;return l?{value:void 0,done:l}:{value:n.dehanceValue_(o),done:l}}})},t.intersection=function(n){if(Mi(n)&&!ri(n))return n.intersection(this);var s=new Set(this);return s.intersection(n)},t.union=function(n){if(Mi(n)&&!ri(n))return n.union(this);var s=new Set(this);return s.union(n)},t.difference=function(n){return new Set(this).difference(n)},t.symmetricDifference=function(n){if(Mi(n)&&!ri(n))return n.symmetricDifference(this);var s=new Set(this);return s.symmetricDifference(n)},t.isSubsetOf=function(n){return new Set(this).isSubsetOf(n)},t.isSupersetOf=function(n){return new Set(this).isSupersetOf(n)},t.isDisjointFrom=function(n){if(Mi(n)&&!ri(n))return n.isDisjointFrom(this);var s=new Set(this);return s.isDisjointFrom(n)},t.replace=function(n){var s=this;return ri(n)&&(n=new Set(n)),Ei(function(){Array.isArray(n)?(s.clear(),n.forEach(function(r){return s.add(r)})):Mi(n)?(s.clear(),n.forEach(function(r){return s.add(r)})):n!=null&&vt("Cannot initialize set from "+n)}),this},t.observe_=function(n,s){return process.env.NODE_ENV!=="production"&&s===!0&&vt("`observe` doesn't support fireImmediately=true in combination with sets."),Ta(this,n)},t.intercept_=function(n){return wa(this,n)},t.toJSON=function(){return Array.from(this)},t.toString=function(){return"[object ObservableSet]"},t[Symbol.iterator]=function(){return this.values()},Ir(i,[{key:"size",get:function(){return this.atom_.reportObserved(),this.data_.size}},{key:Symbol.toStringTag,get:function(){return"Set"}}])})(),ri=Ns("ObservableSet",Cm);function Xf(i){return i[Symbol.toStringTag]="SetIterator",Eu(i)}var jf=Object.create(null),Yf="remove",Vh=(function(){function i(e,n,s,r){n===void 0&&(n=new Map),r===void 0&&(r=gE),this.target_=void 0,this.values_=void 0,this.name_=void 0,this.defaultAnnotation_=void 0,this.keysAtom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.proxy_=void 0,this.isPlainObject_=void 0,this.appliedAnnotations_=void 0,this.pendingKeys_=void 0,this.target_=e,this.values_=n,this.name_=s,this.defaultAnnotation_=r,this.keysAtom_=new ns(process.env.NODE_ENV!=="production"?this.name_+".keys":"ObservableObject.keys"),this.isPlainObject_=gn(this.target_),process.env.NODE_ENV!=="production"&&!Nm(this.defaultAnnotation_)&&vt("defaultAnnotation must be valid annotation"),process.env.NODE_ENV!=="production"&&(this.appliedAnnotations_={})}var t=i.prototype;return t.getObservablePropValue_=function(n){return this.values_.get(n).get()},t.setObservablePropValue_=function(n,s){var r=this.values_.get(n);if(r instanceof Fn)return r.set(s),!0;if(Pn(this)){var a=Dn(this,{type:jn,object:this.proxy_||this.target_,name:n,newValue:s});if(!a)return null;s=a.newValue}if(s=r.prepareNewValue_(s),s!==dt.UNCHANGED){var o=$n(this),l=process.env.NODE_ENV!=="production"&&We(),c=o||l?{type:jn,observableKind:"object",debugObjectName:this.name_,object:this.proxy_||this.target_,oldValue:r.value_,name:n,newValue:s}:null;process.env.NODE_ENV!=="production"&&l&&vn(c),r.setNewValue_(s),o&&Kn(this,c),process.env.NODE_ENV!=="production"&&l&&yn()}return!0},t.get_=function(n){return dt.trackingDerivation&&!Zn(this.target_,n)&&this.has_(n),this.target_[n]},t.set_=function(n,s,r){return r===void 0&&(r=!1),Zn(this.target_,n)?this.values_.has(n)?this.setObservablePropValue_(n,s):r?Reflect.set(this.target_,n,s):(this.target_[n]=s,!0):this.extend_(n,{value:s,enumerable:!0,writable:!0,configurable:!0},this.defaultAnnotation_,r)},t.has_=function(n){if(!dt.trackingDerivation)return n in this.target_;this.pendingKeys_||(this.pendingKeys_=new Map);var s=this.pendingKeys_.get(n);return s||(s=new Es(n in this.target_,pl,process.env.NODE_ENV!=="production"?this.name_+"."+Lh(n)+"?":"ObservableObject.key?",!1),this.pendingKeys_.set(n,s)),s.get()},t.make_=function(n,s){if(s===!0&&(s=this.defaultAnnotation_),s!==!1){if($f(this,s,n),!(n in this.target_)){var r;if((r=this.target_[Si])!=null&&r[n])return;vt(1,s.annotationType_,this.name_+"."+n.toString())}for(var a=this.target_;a&&a!==hl;){var o=Go(a,n);if(o){var l=s.make_(this,n,o,a);if(l===0)return;if(l===1)break}a=Object.getPrototypeOf(a)}Zf(this,s,n)}},t.extend_=function(n,s,r,a){if(a===void 0&&(a=!1),r===!0&&(r=this.defaultAnnotation_),r===!1)return this.defineProperty_(n,s,a);$f(this,r,n);var o=r.extend_(this,n,s,a);return o&&Zf(this,r,n),o},t.defineProperty_=function(n,s,r){r===void 0&&(r=!1),oi(this.keysAtom_);try{Nn();var a=this.delete_(n);if(!a)return a;if(Pn(this)){var o=Dn(this,{object:this.proxy_||this.target_,name:n,type:$i,newValue:s.value});if(!o)return null;var l=o.newValue;s.value!==l&&(s=ts({},s,{value:l}))}if(r){if(!Reflect.defineProperty(this.target_,n,s))return!1}else ci(this.target_,n,s);this.notifyPropertyAddition_(n,s.value)}finally{In()}return!0},t.defineObservableProperty_=function(n,s,r,a){a===void 0&&(a=!1),oi(this.keysAtom_);try{Nn();var o=this.delete_(n);if(!o)return o;if(Pn(this)){var l=Dn(this,{object:this.proxy_||this.target_,name:n,type:$i,newValue:s});if(!l)return null;s=l.newValue}var c=qf(n),h={configurable:dt.safeDescriptors?this.isPlainObject_:!0,enumerable:!0,get:c.get,set:c.set};if(a){if(!Reflect.defineProperty(this.target_,n,h))return!1}else ci(this.target_,n,h);var u=new Es(s,r,process.env.NODE_ENV!=="production"?this.name_+"."+n.toString():"ObservableObject.key",!1);this.values_.set(n,u),this.notifyPropertyAddition_(n,u.value_)}finally{In()}return!0},t.defineComputedProperty_=function(n,s,r){r===void 0&&(r=!1),oi(this.keysAtom_);try{Nn();var a=this.delete_(n);if(!a)return a;if(Pn(this)){var o=Dn(this,{object:this.proxy_||this.target_,name:n,type:$i,newValue:void 0});if(!o)return null}s.name||(s.name=process.env.NODE_ENV!=="production"?this.name_+"."+n.toString():"ObservableObject.key"),s.context=this.proxy_||this.target_;var l=qf(n),c={configurable:dt.safeDescriptors?this.isPlainObject_:!0,enumerable:!1,get:l.get,set:l.set};if(r){if(!Reflect.defineProperty(this.target_,n,c))return!1}else ci(this.target_,n,c);this.values_.set(n,new Fn(s)),this.notifyPropertyAddition_(n,void 0)}finally{In()}return!0},t.delete_=function(n,s){if(s===void 0&&(s=!1),oi(this.keysAtom_),!Zn(this.target_,n))return!0;if(Pn(this)){var r=Dn(this,{object:this.proxy_||this.target_,name:n,type:Yf});if(!r)return null}try{var a;Nn();var o=$n(this),l=process.env.NODE_ENV!=="production"&&We(),c=this.values_.get(n),h=void 0;if(!c&&(o||l)){var u;h=(u=Go(this.target_,n))==null?void 0:u.value}if(s){if(!Reflect.deleteProperty(this.target_,n))return!1}else delete this.target_[n];if(process.env.NODE_ENV!=="production"&&delete this.appliedAnnotations_[n],c&&(this.values_.delete(n),c instanceof Es&&(h=c.value_),mm(c)),this.keysAtom_.reportChanged(),(a=this.pendingKeys_)==null||(a=a.get(n))==null||a.set(n in this.target_),o||l){var d={type:Yf,observableKind:"object",object:this.proxy_||this.target_,debugObjectName:this.name_,oldValue:h,name:n};process.env.NODE_ENV!=="production"&&l&&vn(d),o&&Kn(this,d),process.env.NODE_ENV!=="production"&&l&&yn()}}finally{In()}return!0},t.observe_=function(n,s){return process.env.NODE_ENV!=="production"&&s===!0&&vt("`observe` doesn't support the fire immediately property for observable objects."),Ta(this,n)},t.intercept_=function(n){return wa(this,n)},t.notifyPropertyAddition_=function(n,s){var r,a=$n(this),o=process.env.NODE_ENV!=="production"&&We();if(a||o){var l=a||o?{type:$i,observableKind:"object",debugObjectName:this.name_,object:this.proxy_||this.target_,name:n,newValue:s}:null;process.env.NODE_ENV!=="production"&&o&&vn(l),a&&Kn(this,l),process.env.NODE_ENV!=="production"&&o&&yn()}(r=this.pendingKeys_)==null||(r=r.get(n))==null||r.set(!0),this.keysAtom_.reportChanged()},t.ownKeys_=function(){return this.keysAtom_.reportObserved(),fa(this.target_)},t.keys_=function(){return this.keysAtom_.reportObserved(),Object.keys(this.target_)},i})();function Ur(i,t){var e;if(process.env.NODE_ENV!=="production"&&t&&Fr(i)&&vt("Options can't be provided for already observable objects."),Zn(i,zt))return process.env.NODE_ENV!=="production"&&!(Om(i)instanceof Vh)&&vt("Cannot convert '"+Jo(i)+`' into observable object:
3894
4013
  The target is already observable of different type.
3895
- Extending builtins is not supported.`),n;process.env.NODE_ENV!=="production"&&!Object.isExtensible(n)&&ve("Cannot make the designated object observable; it is not extensible");var i=(t=e?.name)!=null?t:process.env.NODE_ENV!=="production"?(Jt(n)?"ObservableObject":n.constructor.name)+"@"+Dn():"ObservableObject",r=new Ql(n,new Map,String(i),tM(e));return Vo(n,Fe,r),n}var ZM=Zi("ObservableObjectAdministration",Ql);function wh(n){return Sh[n]||(Sh[n]={get:function(){return this[Fe].getObservablePropValue_(n)},set:function(t){return this[Fe].setObservablePropValue_(n,t)}})}function zr(n){return zo(n)?ZM(n[Fe]):!1}function Ah(n,e,t){var i;process.env.NODE_ENV!=="production"&&(n.appliedAnnotations_[t]=e),(i=n.target_[Zn])==null||delete i[t]}function Rh(n,e,t){if(process.env.NODE_ENV!=="production"&&!ad(e)&&ve("Cannot annotate '"+n.name_+"."+t.toString()+"': Invalid annotation."),process.env.NODE_ENV!=="production"&&!So(e)&&An(n.appliedAnnotations_,t)){var i=n.name_+"."+t.toString(),r=n.appliedAnnotations_[t].annotationType_,s=e.annotationType_;ve("Cannot apply '"+s+"' to '"+i+"':"+(`
3896
- The field is already annotated with '`+r+"'.")+`
4014
+ Extending builtins is not supported.`),i;process.env.NODE_ENV!=="production"&&!Object.isExtensible(i)&&vt("Cannot make the designated object observable; it is not extensible");var n=(e=t?.name)!=null?e:process.env.NODE_ENV!=="production"?(gn(i)?"ObservableObject":i.constructor.name)+"@"+Qn():"ObservableObject",s=new Vh(i,new Map,String(n),RE(t));return dl(i,zt,s),i}var E1=Ns("ObservableObjectAdministration",Vh);function qf(i){return jf[i]||(jf[i]={get:function(){return this[zt].getObservablePropValue_(i)},set:function(e){return this[zt].setObservablePropValue_(i,e)}})}function Fr(i){return ul(i)?E1(i[zt]):!1}function Zf(i,t,e){var n;process.env.NODE_ENV!=="production"&&(i.appliedAnnotations_[e]=t),(n=i.target_[Si])==null||delete n[e]}function $f(i,t,e){if(process.env.NODE_ENV!=="production"&&!Nm(t)&&vt("Cannot annotate '"+i.name_+"."+e.toString()+"': Invalid annotation."),process.env.NODE_ENV!=="production"&&!jo(t)&&Zn(i.appliedAnnotations_,e)){var n=i.name_+"."+e.toString(),s=i.appliedAnnotations_[e].annotationType_,r=t.annotationType_;vt("Cannot apply '"+r+"' to '"+n+"':"+(`
4015
+ The field is already annotated with '`+s+"'.")+`
3897
4016
  Re-annotating fields is not allowed.
3898
- Use 'override' annotation for methods overridden by subclass.`)}}var KM=id(0),JM=(function(){var n=!1,e={};return Object.defineProperty(e,"0",{set:function(){n=!0}}),Object.create(e)[0]=1,n===!1})(),Ua=0,nd=function(){};function QM(n,e){Object.setPrototypeOf?Object.setPrototypeOf(n.prototype,e):n.prototype.__proto__!==void 0?n.prototype.__proto__=e:n.prototype=e}QM(nd,Array.prototype);var Ic=(function(n){function e(i,r,s,o){var a;return s===void 0&&(s=process.env.NODE_ENV!=="production"?"ObservableArray@"+Dn():"ObservableArray"),o===void 0&&(o=!1),a=n.call(this)||this,Ji(function(){var l=new Oc(s,r,o,!0);l.proxy_=a,bf(a,Fe,l),i&&i.length&&a.spliceWithArray(0,0,i),JM&&Object.defineProperty(a,"0",KM)}),a}wf(e,n);var t=e.prototype;return t.concat=function(){this[Fe].atom_.reportObserved();for(var r=arguments.length,s=new Array(r),o=0;o<r;o++)s[o]=arguments[o];return Array.prototype.concat.apply(this.slice(),s.map(function(a){return jo(a)?a.slice():a}))},t[Symbol.iterator]=function(){var i=this,r=0;return Nc({next:function(){return r<i.length?{value:i[r++],done:!1}:{done:!0,value:void 0}}})},Fr(e,[{key:"length",get:function(){return this[Fe].getArrayLength_()},set:function(r){this[Fe].setArrayLength_(r)}},{key:Symbol.toStringTag,get:function(){return"Array"}}])})(nd);Object.entries(Ro).forEach(function(n){var e=n[0],t=n[1];e!=="concat"&&Vo(Ic.prototype,e,t)});function id(n){return{enumerable:!1,configurable:!0,get:function(){return this[Fe].get_(n)},set:function(t){this[Fe].set_(n,t)}}}function eE(n){Vn(Ic.prototype,""+n,id(n))}function rd(n){if(n>Ua){for(var e=Ua;e<n+100;e++)eE(e);Ua=n}}rd(1e3);function tE(n,e,t){return new Ic(n,e,t)}function Lr(n,e){if(typeof n=="object"&&n!==null){if(jo(n))return e!==void 0&&ve(23),n[Fe].atom_;if(Un(n))return n.atom_;if(Mi(n)){if(e===void 0)return n.keysAtom_;var t=n.data_.get(e)||n.hasMap_.get(e);return t||ve(25,e,Po(n)),t}if(zr(n)){if(!e)return ve(26);var i=n[Fe].values_.get(e);return i||ve(27,e,Po(n)),i}if(Ac(n)||Xo(n)||Ao(n))return n}else if(Rt(n)&&Ao(n[Fe]))return n[Fe];ve(28)}function sd(n,e){if(n||ve(29),Ac(n)||Xo(n)||Ao(n)||Mi(n)||Un(n))return n;if(n[Fe])return n[Fe];ve(24,n)}function Po(n,e){var t;if(e!==void 0)t=Lr(n,e);else{if(Yi(n))return n.name;zr(n)||Mi(n)||Un(n)?t=sd(n):t=Lr(n)}return t.name_}function Ji(n){var e=Ki(),t=Cc(!0);pn();try{return n()}finally{mn(),Pc(t),ei(e)}}var Ch=Bo.toString;function od(n,e,t){return t===void 0&&(t=-1),ec(n,e,t)}function ec(n,e,t,i,r){if(n===e)return n!==0||1/n===1/e;if(n==null||e==null)return!1;if(n!==n)return e!==e;var s=typeof n;if(s!=="function"&&s!=="object"&&typeof e!="object")return!1;var o=Ch.call(n);if(o!==Ch.call(e))return!1;switch(o){case"[object RegExp]":case"[object String]":return""+n==""+e;case"[object Number]":return+n!=+n?+e!=+e:+n==0?1/+n===1/e:+n==+e;case"[object Date]":case"[object Boolean]":return+n==+e;case"[object Symbol]":return typeof Symbol<"u"&&Symbol.valueOf.call(n)===Symbol.valueOf.call(e);case"[object Map]":case"[object Set]":t>=0&&t++;break}n=Ph(n),e=Ph(e);var a=o==="[object Array]";if(!a){if(typeof n!="object"||typeof e!="object")return!1;var l=n.constructor,c=e.constructor;if(l!==c&&!(Rt(l)&&l instanceof l&&Rt(c)&&c instanceof c)&&"constructor"in n&&"constructor"in e)return!1}if(t===0)return!1;t<0&&(t=-1),i=i||[],r=r||[];for(var u=i.length;u--;)if(i[u]===n)return r[u]===e;if(i.push(n),r.push(e),a){if(u=n.length,u!==e.length)return!1;for(;u--;)if(!ec(n[u],e[u],t-1,i,r))return!1}else{var h=Object.keys(n),d=h.length;if(Object.keys(e).length!==d)return!1;for(var p=0;p<d;p++){var g=h[p];if(!(An(e,g)&&ec(n[g],e[g],t-1,i,r)))return!1}}return i.pop(),r.pop(),!0}function Ph(n){return jo(n)?n.slice():Ur(n)||Mi(n)||$n(n)||Un(n)?Array.from(n.entries()):n}var Dh,nE=((Dh=Tc().Iterator)==null?void 0:Dh.prototype)||{};function Nc(n){return n[Symbol.iterator]=iE,Object.assign(Object.create(nE),n)}function iE(){return this}function ad(n){return n instanceof Object&&typeof n.annotationType_=="string"&&Rt(n.make_)&&Rt(n.extend_)}["Symbol","Map","Set"].forEach(function(n){var e=Tc();typeof e[n]>"u"&&ve("MobX requires global '"+n+"' to be available or polyfilled")});typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__=="object"&&__MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx({spy:MM,extras:{getDebugName:Po},$mobx:Fe});var rE=Object.getOwnPropertyDescriptor,sE=(n,e,t,i)=>{for(var r=i>1?void 0:i?rE(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r};let tc=class{_selectMode=dn.Mesh;_toolType=gi.Translate;_displayMode=Sr.Plane;_selectedObject=null;_selectedListeners=new Set;constructor(){kM(this,{},{autoBind:!0})}getSelectMode(){return this._selectMode}getToolType(){return this._toolType}getDisplayMode(){return this._displayMode}setSelectMode(n){this._selectMode=n}setToolType(n){this._toolType=n}setDisplayMode(n){this._displayMode=n}getSelectedObject(){return this._selectedObject}setSelectedObject(n){if(this._selectedObject!==n){this._selectedObject=n;for(const e of this._selectedListeners)e(this._selectedObject)}}onSelectedObjectChange(n){return this._selectedListeners.add(n),()=>this._selectedListeners.delete(n)}};tc=sE([Lt()],tc);let Lh=!1;const xt=mx.createChildContainer();function oE(n){return Lh||(xt.registerInstance("Canvas",n),xt.registerSingleton("EventBus",exports.EventBus),xt.registerSingleton("EditorRenderer",exports.EditorRenderer),xt.registerSingleton("RendererApi",Wl),xt.registerSingleton("IDisplayHandler",Nl),xt.registerSingleton("ISelectHandler",Ul),xt.registerSingleton("ISelectHandler",Fl),xt.registerSingleton("ISelectHandler",Hl),xt.registerSingleton("IToolHandler",Bl),xt.registerSingleton("IToolHandler",zl),xt.registerSingleton("IToolHandler",Vl),xt.registerSingleton("ISceneHandler",kl),xt.registerSingleton("ISceneHandler",Gl),xt.registerSingleton("IDisplayManager",Dl),xt.registerSingleton("ISelectManager",Ll),xt.registerSingleton("IToolManager",Ol),xt.registerSingleton("ISceneManager",Il),xt.registerSingleton("EditorHub",exports.EditorHub),xt.registerSingleton("IEditorStore",tc),Lh=!0),xt}function aE(n){return oE(n).resolve("EditorHub")}exports.EventTopics=zi;exports.ObjLoader=Tx;exports.PreviewRenderer=Sx;exports.Renderer=vc;exports.createAppHub=aE;
4017
+ Use 'override' annotation for methods overridden by subclass.`)}}var w1=Pm(0),T1=(function(){var i=!1,t={};return Object.defineProperty(t,"0",{set:function(){i=!0}}),Object.create(t)[0]=1,i===!1})(),Ec=0,Rm=function(){};function A1(i,t){Object.setPrototypeOf?Object.setPrototypeOf(i.prototype,t):i.prototype.__proto__!==void 0?i.prototype.__proto__=t:i.prototype=t}A1(Rm,Array.prototype);var Su=(function(i){function t(n,s,r,a){var o;return r===void 0&&(r=process.env.NODE_ENV!=="production"?"ObservableArray@"+Qn():"ObservableArray"),a===void 0&&(a=!1),o=i.call(this)||this,Us(function(){var l=new Mu(r,s,a,!0);l.proxy_=o,$p(o,zt,l),n&&n.length&&o.spliceWithArray(0,0,n),T1&&Object.defineProperty(o,"0",w1)}),o}Qp(t,i);var e=t.prototype;return e.concat=function(){this[zt].atom_.reportObserved();for(var s=arguments.length,r=new Array(s),a=0;a<s;a++)r[a]=arguments[a];return Array.prototype.concat.apply(this.slice(),r.map(function(o){return gl(o)?o.slice():o}))},e[Symbol.iterator]=function(){var n=this,s=0;return Eu({next:function(){return s<n.length?{value:n[s++],done:!1}:{done:!0,value:void 0}}})},Ir(t,[{key:"length",get:function(){return this[zt].getArrayLength_()},set:function(s){this[zt].setArrayLength_(s)}},{key:Symbol.toStringTag,get:function(){return"Array"}}])})(Rm);Object.entries($o).forEach(function(i){var t=i[0],e=i[1];t!=="concat"&&dl(Su.prototype,t,e)});function Pm(i){return{enumerable:!1,configurable:!0,get:function(){return this[zt].get_(i)},set:function(e){this[zt].set_(i,e)}}}function C1(i){ci(Su.prototype,""+i,Pm(i))}function Dm(i){if(i>Ec){for(var t=Ec;t<i+100;t++)C1(t);Ec=i}}Dm(1e3);function R1(i,t,e){return new Su(i,t,e)}function Cr(i,t){if(typeof i=="object"&&i!==null){if(gl(i))return t!==void 0&&vt(23),i[zt].atom_;if(ri(i))return i.atom_;if(is(i)){if(t===void 0)return i.keysAtom_;var e=i.data_.get(t)||i.hasMap_.get(t);return e||vt(25,t,Jo(i)),e}if(Fr(i)){if(!t)return vt(26);var n=i[zt].values_.get(t);return n||vt(27,t,Jo(i)),n}if(_u(i)||xl(i)||Zo(i))return i}else if(Ue(i)&&Zo(i[zt]))return i[zt];vt(28)}function Om(i,t){if(i||vt(29),_u(i)||xl(i)||Zo(i)||is(i)||ri(i))return i;if(i[zt])return i[zt];vt(24,i)}function Jo(i,t){var e;if(t!==void 0)e=Cr(i,t);else{if(Os(i))return i.name;Fr(i)||is(i)||ri(i)?e=Om(i):e=Cr(i)}return e.name_}function Us(i){var t=Is(),e=gu(!0);Nn();try{return i()}finally{In(),vu(e),Pi(t)}}var Kf=hl.toString;function Lm(i,t,e){return e===void 0&&(e=-1),Hh(i,t,e)}function Hh(i,t,e,n,s){if(i===t)return i!==0||1/i===1/t;if(i==null||t==null)return!1;if(i!==i)return t!==t;var r=typeof i;if(r!=="function"&&r!=="object"&&typeof t!="object")return!1;var a=Kf.call(i);if(a!==Kf.call(t))return!1;switch(a){case"[object RegExp]":case"[object String]":return""+i==""+t;case"[object Number]":return+i!=+i?+t!=+t:+i==0?1/+i===1/t:+i==+t;case"[object Date]":case"[object Boolean]":return+i==+t;case"[object Symbol]":return typeof Symbol<"u"&&Symbol.valueOf.call(i)===Symbol.valueOf.call(t);case"[object Map]":case"[object Set]":e>=0&&e++;break}i=Jf(i),t=Jf(t);var o=a==="[object Array]";if(!o){if(typeof i!="object"||typeof t!="object")return!1;var l=i.constructor,c=t.constructor;if(l!==c&&!(Ue(l)&&l instanceof l&&Ue(c)&&c instanceof c)&&"constructor"in i&&"constructor"in t)return!1}if(e===0)return!1;e<0&&(e=-1),n=n||[],s=s||[];for(var h=n.length;h--;)if(n[h]===i)return s[h]===t;if(n.push(i),s.push(t),o){if(h=i.length,h!==t.length)return!1;for(;h--;)if(!Hh(i[h],t[h],e-1,n,s))return!1}else{var u=Object.keys(i),d=u.length;if(Object.keys(t).length!==d)return!1;for(var f=0;f<d;f++){var m=u[f];if(!(Zn(t,m)&&Hh(i[m],t[m],e-1,n,s)))return!1}}return n.pop(),s.pop(),!0}function Jf(i){return gl(i)?i.slice():Nr(i)||is(i)||Mi(i)||ri(i)?Array.from(i.entries()):i}var Qf,P1=((Qf=pu().Iterator)==null?void 0:Qf.prototype)||{};function Eu(i){return i[Symbol.iterator]=D1,Object.assign(Object.create(P1),i)}function D1(){return this}function Nm(i){return i instanceof Object&&typeof i.annotationType_=="string"&&Ue(i.make_)&&Ue(i.extend_)}["Symbol","Map","Set"].forEach(function(i){var t=pu();typeof t[i]>"u"&&vt("MobX requires global '"+i+"' to be available or polyfilled")});typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__=="object"&&__MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx({spy:ZE,extras:{getDebugName:Jo},$mobx:zt});var O1=Object.getOwnPropertyDescriptor,L1=(i,t,e,n)=>{for(var s=n>1?void 0:n?O1(t,e):t,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=a(s)||s);return s};let Gh=class{_selectMode=Ln.Mesh;_toolType=Qi.Translate;_displayMode=xr.Plane;_selectedObject=null;_selectedListeners=new Set;constructor(){_1(this,{},{autoBind:!0})}getSelectMode(){return this._selectMode}getToolType(){return this._toolType}getDisplayMode(){return this._displayMode}setSelectMode(i){this._selectMode=i}setToolType(i){this._toolType=i}setDisplayMode(i){this._displayMode=i}getSelectedObject(){return this._selectedObject}setSelectedObject(i){if(this._selectedObject!==i){this._selectedObject=i;for(const t of this._selectedListeners)t(this._selectedObject)}}onSelectedObjectChange(i){return this._selectedListeners.add(i),()=>this._selectedListeners.delete(i)}};Gh=L1([He()],Gh);let tp=!1;const Ee=RM.createChildContainer();function N1(i){return tp||(Ee.registerInstance("Canvas",i),Ee.registerSingleton("EventBus",exports.EventBus),Ee.registerSingleton("EditorRenderer",exports.EditorRenderer),Ee.registerSingleton("RendererApi",Oh),Ee.registerSingleton("IDisplayHandler",Sh),Ee.registerSingleton("ISelectHandler",Eh),Ee.registerSingleton("ISelectHandler",wh),Ee.registerSingleton("ISelectHandler",Rh),Ee.registerSingleton("IToolHandler",Th),Ee.registerSingleton("IToolHandler",Ah),Ee.registerSingleton("IToolHandler",Ch),Ee.registerSingleton("ISceneHandler",Ph),Ee.registerSingleton("ISceneHandler",Dh),Ee.registerSingleton("IDisplayManager",vh),Ee.registerSingleton("ISelectManager",yh),Ee.registerSingleton("IToolManager",bh),Ee.registerSingleton("ISceneManager",Mh),Ee.registerSingleton("EditorHub",exports.EditorHub),Ee.registerSingleton("IEditorStore",Gh),tp=!0),Ee}function I1(i){return N1(i).resolve("EditorHub")}exports.EventTopics=Ss;exports.ObjLoader=QM;exports.PreviewRenderer=JM;exports.Renderer=au;exports.createAppHub=I1;