@planara/core 2.0.0 → 2.1.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.
Files changed (48) hide show
  1. package/dist/core/editor-renderer.d.ts +34 -2
  2. package/dist/core/editor-renderer.d.ts.map +1 -1
  3. package/dist/events/editor-events.d.ts +6 -0
  4. package/dist/events/editor-events.d.ts.map +1 -1
  5. package/dist/events/event-topics.d.ts +3 -1
  6. package/dist/events/event-topics.d.ts.map +1 -1
  7. package/dist/extensions/symmetric-axes-helper.d.ts.map +1 -0
  8. package/dist/handlers/display/wireframe-handler.d.ts +3 -4
  9. package/dist/handlers/display/wireframe-handler.d.ts.map +1 -1
  10. package/dist/handlers/select/mesh-select-handler.d.ts +1 -0
  11. package/dist/handlers/select/mesh-select-handler.d.ts.map +1 -1
  12. package/dist/handlers/tool/base-tool-handler.d.ts +25 -0
  13. package/dist/handlers/tool/base-tool-handler.d.ts.map +1 -0
  14. package/dist/handlers/tool/rotate-tool-handler.d.ts +19 -0
  15. package/dist/handlers/tool/rotate-tool-handler.d.ts.map +1 -0
  16. package/dist/handlers/tool/scale-tool-handler.d.ts +19 -0
  17. package/dist/handlers/tool/scale-tool-handler.d.ts.map +1 -0
  18. package/dist/handlers/tool/translate-tool-handler.d.ts +19 -0
  19. package/dist/handlers/tool/translate-tool-handler.d.ts.map +1 -0
  20. package/dist/hub/editor-hub.d.ts +5 -2
  21. package/dist/hub/editor-hub.d.ts.map +1 -1
  22. package/dist/index.cjs.js +180 -180
  23. package/dist/index.d.ts +1 -0
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.es.js +6231 -5157
  26. package/dist/index.full.d.ts +52 -3
  27. package/dist/index.public.d.ts +38 -3
  28. package/dist/index.umd.js +147 -147
  29. package/dist/interfaces/api/transform-helpers-api.d.ts +25 -0
  30. package/dist/interfaces/api/transform-helpers-api.d.ts.map +1 -0
  31. package/dist/interfaces/handler/display-handler.d.ts +1 -0
  32. package/dist/interfaces/handler/display-handler.d.ts.map +1 -1
  33. package/dist/interfaces/handler/select-handler.d.ts +1 -0
  34. package/dist/interfaces/handler/select-handler.d.ts.map +1 -1
  35. package/dist/interfaces/handler/tool-handler.d.ts +14 -0
  36. package/dist/interfaces/handler/tool-handler.d.ts.map +1 -0
  37. package/dist/interfaces/manager/tool-manager.d.ts +8 -0
  38. package/dist/interfaces/manager/tool-manager.d.ts.map +1 -0
  39. package/dist/ioc/container.d.ts.map +1 -1
  40. package/dist/managers/display/display-manager.d.ts.map +1 -1
  41. package/dist/managers/select/select-manager.d.ts.map +1 -1
  42. package/dist/managers/tool/tool-manager.d.ts +18 -0
  43. package/dist/managers/tool/tool-manager.d.ts.map +1 -0
  44. package/dist/utils/renderer-api.d.ts +6 -1
  45. package/dist/utils/renderer-api.d.ts.map +1 -1
  46. package/package.json +2 -2
  47. package/dist/helpers/symmetric-axes-helper.d.ts.map +0 -1
  48. /package/dist/{helpers → extensions}/symmetric-axes-helper.d.ts +0 -0
package/dist/index.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var Ha=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},ka={};/*! *****************************************************************************
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var va=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},xa={};/*! *****************************************************************************
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 Va;function Yl(){if(Va)return ka;Va=1;var i;return(function(e){(function(t){var n=typeof globalThis=="object"?globalThis:typeof Ha=="object"?Ha:typeof self=="object"?self:typeof this=="object"?this:c(),r=s(e);typeof n.Reflect<"u"&&(r=s(n.Reflect,r)),t(r,n),typeof n.Reflect>"u"&&(n.Reflect=e);function s(l,u){return function(f,d){Object.defineProperty(l,f,{configurable:!0,writable:!0,value:d}),u&&u(f,d)}}function a(){try{return Function("return this;")()}catch{}}function o(){try{return(0,eval)("(function() { return this; })()")}catch{}}function c(){return a()||o()}})(function(t,n){var r=Object.prototype.hasOwnProperty,s=typeof Symbol=="function",a=s&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",o=s&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",c=typeof Object.create=="function",l={__proto__:[]}instanceof Array,u=!c&&!l,f={create:c?function(){return Se(Object.create(null))}:l?function(){return Se({__proto__:null})}:function(){return Se({})},has:u?function(D,w){return r.call(D,w)}:function(D,w){return w in D},get:u?function(D,w){return r.call(D,w)?D[w]:void 0}:function(D,w){return D[w]}},d=Object.getPrototypeOf(Function),m=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:J(),v=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Te(),S=typeof WeakMap=="function"?WeakMap:he(),p=s?Symbol.for("@reflect-metadata:registry"):void 0,h=_(),L=H(h);function C(D,w,N,K){if(de(N)){if(!ht(D))throw new TypeError;if(!Je(w))throw new TypeError;return Z(D,w)}else{if(!ht(D))throw new TypeError;if(!Y(w))throw new TypeError;if(!Y(K)&&!de(K)&&!je(K))throw new TypeError;return je(K)&&(K=void 0),N=Ie(N),te(D,w,N,K)}}t("decorate",C);function g(D,w){function N(K,ie){if(!Y(K))throw new TypeError;if(!de(ie)&&!Ue(ie))throw new TypeError;ue(D,w,K,ie)}return N}t("metadata",g);function E(D,w,N,K){if(!Y(N))throw new TypeError;return de(K)||(K=Ie(K)),ue(D,w,N,K)}t("defineMetadata",E);function T(D,w,N){if(!Y(w))throw new TypeError;return de(N)||(N=Ie(N)),ne(D,w,N)}t("hasMetadata",T);function A(D,w,N){if(!Y(w))throw new TypeError;return de(N)||(N=Ie(N)),ee(D,w,N)}t("hasOwnMetadata",A);function I(D,w,N){if(!Y(w))throw new TypeError;return de(N)||(N=Ie(N)),le(D,w,N)}t("getMetadata",I);function y(D,w,N){if(!Y(w))throw new TypeError;return de(N)||(N=Ie(N)),j(D,w,N)}t("getOwnMetadata",y);function M(D,w){if(!Y(D))throw new TypeError;return de(w)||(w=Ie(w)),me(D,w)}t("getMetadataKeys",M);function U(D,w){if(!Y(D))throw new TypeError;return de(w)||(w=Ie(w)),be(D,w)}t("getOwnMetadataKeys",U);function W(D,w,N){if(!Y(w))throw new TypeError;if(de(N)||(N=Ie(N)),!Y(w))throw new TypeError;de(N)||(N=Ie(N));var K=re(w,N,!1);return de(K)?!1:K.OrdinaryDeleteMetadata(D,w,N)}t("deleteMetadata",W);function Z(D,w){for(var N=D.length-1;N>=0;--N){var K=D[N],ie=K(w);if(!de(ie)&&!je(ie)){if(!Je(ie))throw new TypeError;w=ie}}return w}function te(D,w,N,K){for(var ie=D.length-1;ie>=0;--ie){var ae=D[ie],ye=ae(w,N,K);if(!de(ye)&&!je(ye)){if(!Y(ye))throw new TypeError;K=ye}}return K}function ne(D,w,N){var K=ee(D,w,N);if(K)return!0;var ie=tt(w);return je(ie)?!1:ne(D,ie,N)}function ee(D,w,N){var K=re(w,N,!1);return de(K)?!1:De(K.OrdinaryHasOwnMetadata(D,w,N))}function le(D,w,N){var K=ee(D,w,N);if(K)return j(D,w,N);var ie=tt(w);if(!je(ie))return le(D,ie,N)}function j(D,w,N){var K=re(w,N,!1);if(!de(K))return K.OrdinaryGetOwnMetadata(D,w,N)}function ue(D,w,N,K){var ie=re(N,K,!0);ie.OrdinaryDefineOwnMetadata(D,w,N,K)}function me(D,w){var N=be(D,w),K=tt(D);if(K===null)return N;var ie=me(K,w);if(ie.length<=0)return N;if(N.length<=0)return ie;for(var ae=new v,ye=[],R=0,z=N;R<z.length;R++){var V=z[R],$=ae.has(V);$||(ae.add(V),ye.push(V))}for(var k=0,G=ie;k<G.length;k++){var V=G[k],$=ae.has(V);$||(ae.add(V),ye.push(V))}return ye}function be(D,w){var N=re(D,w,!1);return N?N.OrdinaryOwnMetadataKeys(D,w):[]}function Be(D){if(D===null)return 1;switch(typeof D){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return D===null?1:6;default:return 6}}function de(D){return D===void 0}function je(D){return D===null}function Xe(D){return typeof D=="symbol"}function Y(D){return typeof D=="object"?D!==null:typeof D=="function"}function se(D,w){switch(Be(D)){case 0:return D;case 1:return D;case 2:return D;case 3:return D;case 4:return D;case 5:return D}var N="string",K=xe(D,a);if(K!==void 0){var ie=K.call(D,N);if(Y(ie))throw new TypeError;return ie}return ve(D)}function ve(D,w){var N,K,ie;{var ae=D.toString;if(P(ae)){var K=ae.call(D);if(!Y(K))return K}var N=D.valueOf;if(P(N)){var K=N.call(D);if(!Y(K))return K}}throw new TypeError}function De(D){return!!D}function Ae(D){return""+D}function Ie(D){var w=se(D);return Xe(w)?w:Ae(w)}function ht(D){return Array.isArray?Array.isArray(D):D instanceof Object?D instanceof Array:Object.prototype.toString.call(D)==="[object Array]"}function P(D){return typeof D=="function"}function Je(D){return typeof D=="function"}function Ue(D){switch(Be(D)){case 3:return!0;case 4:return!0;default:return!1}}function Re(D,w){return D===w||D!==D&&w!==w}function xe(D,w){var N=D[w];if(N!=null){if(!P(N))throw new TypeError;return N}}function Qe(D){var w=xe(D,o);if(!P(w))throw new TypeError;var N=w.call(D);if(!Y(N))throw new TypeError;return N}function Me(D){return D.value}function Ne(D){var w=D.next();return w.done?!1:w}function lt(D){var w=D.return;w&&w.call(D)}function tt(D){var w=Object.getPrototypeOf(D);if(typeof D!="function"||D===d||w!==d)return w;var N=D.prototype,K=N&&Object.getPrototypeOf(N);if(K==null||K===Object.prototype)return w;var ie=K.constructor;return typeof ie!="function"||ie===D?w:ie}function b(){var D;!de(p)&&typeof n.Reflect<"u"&&!(p in n.Reflect)&&typeof n.Reflect.defineMetadata=="function"&&(D=Q(n.Reflect));var w,N,K,ie=new S,ae={registerProvider:ye,getProvider:z,setProvider:$};return ae;function ye(k){if(!Object.isExtensible(ae))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case D===k:break;case de(w):w=k;break;case w===k:break;case de(N):N=k;break;case N===k:break;default:K===void 0&&(K=new v),K.add(k);break}}function R(k,G){if(!de(w)){if(w.isProviderFor(k,G))return w;if(!de(N)){if(N.isProviderFor(k,G))return w;if(!de(K))for(var ce=Qe(K);;){var _e=Ne(ce);if(!_e)return;var He=Me(_e);if(He.isProviderFor(k,G))return lt(ce),He}}}if(!de(D)&&D.isProviderFor(k,G))return D}function z(k,G){var ce=ie.get(k),_e;return de(ce)||(_e=ce.get(G)),de(_e)&&(_e=R(k,G),de(_e)||(de(ce)&&(ce=new m,ie.set(k,ce)),ce.set(G,_e))),_e}function V(k){if(de(k))throw new TypeError;return w===k||N===k||!de(K)&&K.has(k)}function $(k,G,ce){if(!V(ce))throw new Error("Metadata provider not registered.");var _e=z(k,G);if(_e!==ce){if(!de(_e))return!1;var He=ie.get(k);de(He)&&(He=new m,ie.set(k,He)),He.set(G,ce)}return!0}}function _(){var D;return!de(p)&&Y(n.Reflect)&&Object.isExtensible(n.Reflect)&&(D=n.Reflect[p]),de(D)&&(D=b()),!de(p)&&Y(n.Reflect)&&Object.isExtensible(n.Reflect)&&Object.defineProperty(n.Reflect,p,{enumerable:!1,configurable:!1,writable:!1,value:D}),D}function H(D){var w=new S,N={isProviderFor:function(V,$){var k=w.get(V);return de(k)?!1:k.has($)},OrdinaryDefineOwnMetadata:ye,OrdinaryHasOwnMetadata:ie,OrdinaryGetOwnMetadata:ae,OrdinaryOwnMetadataKeys:R,OrdinaryDeleteMetadata:z};return h.registerProvider(N),N;function K(V,$,k){var G=w.get(V),ce=!1;if(de(G)){if(!k)return;G=new m,w.set(V,G),ce=!0}var _e=G.get($);if(de(_e)){if(!k)return;if(_e=new m,G.set($,_e),!D.setProvider(V,$,N))throw G.delete($),ce&&w.delete(V),new Error("Wrong provider for target.")}return _e}function ie(V,$,k){var G=K($,k,!1);return de(G)?!1:De(G.has(V))}function ae(V,$,k){var G=K($,k,!1);if(!de(G))return G.get(V)}function ye(V,$,k,G){var ce=K(k,G,!0);ce.set(V,$)}function R(V,$){var k=[],G=K(V,$,!1);if(de(G))return k;for(var ce=G.keys(),_e=Qe(ce),He=0;;){var We=Ne(_e);if(!We)return k.length=He,k;var zt=Me(We);try{k[He]=zt}catch(Lt){try{lt(_e)}finally{throw Lt}}He++}}function z(V,$,k){var G=K($,k,!1);if(de(G)||!G.delete(V))return!1;if(G.size===0){var ce=w.get($);de(ce)||(ce.delete(k),ce.size===0&&w.delete(ce))}return!0}}function Q(D){var w=D.defineMetadata,N=D.hasOwnMetadata,K=D.getOwnMetadata,ie=D.getOwnMetadataKeys,ae=D.deleteMetadata,ye=new S,R={isProviderFor:function(z,V){var $=ye.get(z);return!de($)&&$.has(V)?!0:ie(z,V).length?(de($)&&($=new v,ye.set(z,$)),$.add(V),!0):!1},OrdinaryDefineOwnMetadata:w,OrdinaryHasOwnMetadata:N,OrdinaryGetOwnMetadata:K,OrdinaryOwnMetadataKeys:ie,OrdinaryDeleteMetadata:ae};return R}function re(D,w,N){var K=h.getProvider(D,w);if(!de(K))return K;if(N){if(h.setProvider(D,w,L))return L;throw new Error("Illegal state.")}}function J(){var D={},w=[],N=(function(){function R(z,V,$){this._index=0,this._keys=z,this._values=V,this._selector=$}return R.prototype["@@iterator"]=function(){return this},R.prototype[o]=function(){return this},R.prototype.next=function(){var z=this._index;if(z>=0&&z<this._keys.length){var V=this._selector(this._keys[z],this._values[z]);return z+1>=this._keys.length?(this._index=-1,this._keys=w,this._values=w):this._index++,{value:V,done:!1}}return{value:void 0,done:!0}},R.prototype.throw=function(z){throw this._index>=0&&(this._index=-1,this._keys=w,this._values=w),z},R.prototype.return=function(z){return this._index>=0&&(this._index=-1,this._keys=w,this._values=w),{value:z,done:!0}},R})(),K=(function(){function R(){this._keys=[],this._values=[],this._cacheKey=D,this._cacheIndex=-2}return Object.defineProperty(R.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),R.prototype.has=function(z){return this._find(z,!1)>=0},R.prototype.get=function(z){var V=this._find(z,!1);return V>=0?this._values[V]:void 0},R.prototype.set=function(z,V){var $=this._find(z,!0);return this._values[$]=V,this},R.prototype.delete=function(z){var V=this._find(z,!1);if(V>=0){for(var $=this._keys.length,k=V+1;k<$;k++)this._keys[k-1]=this._keys[k],this._values[k-1]=this._values[k];return this._keys.length--,this._values.length--,Re(z,this._cacheKey)&&(this._cacheKey=D,this._cacheIndex=-2),!0}return!1},R.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=D,this._cacheIndex=-2},R.prototype.keys=function(){return new N(this._keys,this._values,ie)},R.prototype.values=function(){return new N(this._keys,this._values,ae)},R.prototype.entries=function(){return new N(this._keys,this._values,ye)},R.prototype["@@iterator"]=function(){return this.entries()},R.prototype[o]=function(){return this.entries()},R.prototype._find=function(z,V){if(!Re(this._cacheKey,z)){this._cacheIndex=-1;for(var $=0;$<this._keys.length;$++)if(Re(this._keys[$],z)){this._cacheIndex=$;break}}return this._cacheIndex<0&&V&&(this._cacheIndex=this._keys.length,this._keys.push(z),this._values.push(void 0)),this._cacheIndex},R})();return K;function ie(R,z){return R}function ae(R,z){return z}function ye(R,z){return[R,z]}}function Te(){var D=(function(){function w(){this._map=new m}return Object.defineProperty(w.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),w.prototype.has=function(N){return this._map.has(N)},w.prototype.add=function(N){return this._map.set(N,N),this},w.prototype.delete=function(N){return this._map.delete(N)},w.prototype.clear=function(){this._map.clear()},w.prototype.keys=function(){return this._map.keys()},w.prototype.values=function(){return this._map.keys()},w.prototype.entries=function(){return this._map.entries()},w.prototype["@@iterator"]=function(){return this.keys()},w.prototype[o]=function(){return this.keys()},w})();return D}function he(){var D=16,w=f.create(),N=K();return(function(){function z(){this._key=K()}return z.prototype.has=function(V){var $=ie(V,!1);return $!==void 0?f.has($,this._key):!1},z.prototype.get=function(V){var $=ie(V,!1);return $!==void 0?f.get($,this._key):void 0},z.prototype.set=function(V,$){var k=ie(V,!0);return k[this._key]=$,this},z.prototype.delete=function(V){var $=ie(V,!1);return $!==void 0?delete $[this._key]:!1},z.prototype.clear=function(){this._key=K()},z})();function K(){var z;do z="@@WeakMap@@"+R();while(f.has(w,z));return w[z]=!0,z}function ie(z,V){if(!r.call(z,N)){if(!V)return;Object.defineProperty(z,N,{value:f.create()})}return z[N]}function ae(z,V){for(var $=0;$<V;++$)z[$]=Math.random()*255|0;return z}function ye(z){if(typeof Uint8Array=="function"){var V=new Uint8Array(z);return typeof crypto<"u"?crypto.getRandomValues(V):typeof msCrypto<"u"?msCrypto.getRandomValues(V):ae(V,z),V}return ae(new Array(z),z)}function R(){var z=ye(D);z[6]=z[6]&79|64,z[8]=z[8]&191|128;for(var V="",$=0;$<D;++$){var k=z[$];($===4||$===6||$===8)&&(V+="-"),k<16&&(V+="0"),V+=k.toString(16).toLowerCase()}return V}}function Se(D){return D.__=void 0,delete D.__,D}})})(i||(i={})),ka}Yl();/**
14
+ ***************************************************************************** */var Ma;function Dc(){if(Ma)return xa;Ma=1;var i;return(function(e){(function(t){var n=typeof globalThis=="object"?globalThis:typeof va=="object"?va:typeof self=="object"?self:typeof this=="object"?this:c(),r=s(e);typeof n.Reflect<"u"&&(r=s(n.Reflect,r)),t(r,n),typeof n.Reflect>"u"&&(n.Reflect=e);function s(l,u){return function(f,d){Object.defineProperty(l,f,{configurable:!0,writable:!0,value:d}),u&&u(f,d)}}function o(){try{return Function("return this;")()}catch{}}function a(){try{return(0,eval)("(function() { return this; })()")}catch{}}function c(){return o()||a()}})(function(t,n){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",c=typeof Object.create=="function",l={__proto__:[]}instanceof Array,u=!c&&!l,f={create:c?function(){return Ee(Object.create(null))}:l?function(){return Ee({__proto__:null})}:function(){return Ee({})},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),m=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:te(),g=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:we(),y=typeof WeakMap=="function"?WeakMap:ue(),p=s?Symbol.for("@reflect-metadata:registry"):void 0,h=v(),w=k(h);function b(I,P,O,J){if(fe(O)){if(!_t(I))throw new TypeError;if(!et(P))throw new TypeError;return q(I,P)}else{if(!_t(I))throw new TypeError;if(!$(P))throw new TypeError;if(!$(J)&&!fe(J)&&!Xe(J))throw new TypeError;return Xe(J)&&(J=void 0),O=Oe(O),j(I,P,O,J)}}t("decorate",b);function _(I,P){function O(J,ie){if(!$(J))throw new TypeError;if(!fe(ie)&&!Fe(ie))throw new TypeError;le(I,P,J,ie)}return O}t("metadata",_);function T(I,P,O,J){if(!$(O))throw new TypeError;return fe(J)||(J=Oe(J)),le(I,P,O,J)}t("defineMetadata",T);function E(I,P,O){if(!$(P))throw new TypeError;return fe(O)||(O=Oe(O)),Q(I,P,O)}t("hasMetadata",E);function A(I,P,O){if(!$(P))throw new TypeError;return fe(O)||(O=Oe(O)),K(I,P,O)}t("hasOwnMetadata",A);function C(I,P,O){if(!$(P))throw new TypeError;return fe(O)||(O=Oe(O)),se(I,P,O)}t("getMetadata",C);function M(I,P,O){if(!$(P))throw new TypeError;return fe(O)||(O=Oe(O)),Z(I,P,O)}t("getOwnMetadata",M);function x(I,P){if(!$(I))throw new TypeError;return fe(P)||(P=Oe(P)),pe(I,P)}t("getMetadataKeys",x);function N(I,P){if(!$(I))throw new TypeError;return fe(P)||(P=Oe(P)),Me(I,P)}t("getOwnMetadataKeys",N);function z(I,P,O){if(!$(P))throw new TypeError;if(fe(O)||(O=Oe(O)),!$(P))throw new TypeError;fe(O)||(O=Oe(O));var J=re(P,O,!1);return fe(J)?!1:J.OrdinaryDeleteMetadata(I,P,O)}t("deleteMetadata",z);function q(I,P){for(var O=I.length-1;O>=0;--O){var J=I[O],ie=J(P);if(!fe(ie)&&!Xe(ie)){if(!et(ie))throw new TypeError;P=ie}}return P}function j(I,P,O,J){for(var ie=I.length-1;ie>=0;--ie){var ae=I[ie],Te=ae(P,O,J);if(!fe(Te)&&!Xe(Te)){if(!$(Te))throw new TypeError;J=Te}}return J}function Q(I,P,O){var J=K(I,P,O);if(J)return!0;var ie=rt(P);return Xe(ie)?!1:Q(I,ie,O)}function K(I,P,O){var J=re(P,O,!1);return fe(J)?!1:Le(J.OrdinaryHasOwnMetadata(I,P,O))}function se(I,P,O){var J=K(I,P,O);if(J)return Z(I,P,O);var ie=rt(P);if(!Xe(ie))return se(I,ie,O)}function Z(I,P,O){var J=re(P,O,!1);if(!fe(J))return J.OrdinaryGetOwnMetadata(I,P,O)}function le(I,P,O,J){var ie=re(O,J,!0);ie.OrdinaryDefineOwnMetadata(I,P,O,J)}function pe(I,P){var O=Me(I,P),J=rt(I);if(J===null)return O;var ie=pe(J,P);if(ie.length<=0)return O;if(O.length<=0)return ie;for(var ae=new g,Te=[],D=0,H=O;D<H.length;D++){var V=H[D],ee=ae.has(V);ee||(ae.add(V),Te.push(V))}for(var G=0,W=ie;G<W.length;G++){var V=W[G],ee=ae.has(V);ee||(ae.add(V),Te.push(V))}return Te}function Me(I,P){var O=re(I,P,!1);return O?O.OrdinaryOwnMetadataKeys(I,P):[]}function Ne(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 fe(I){return I===void 0}function Xe(I){return I===null}function qe(I){return typeof I=="symbol"}function $(I){return typeof I=="object"?I!==null:typeof I=="function"}function oe(I,P){switch(Ne(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 O="string",J=ye(I,o);if(J!==void 0){var ie=J.call(I,O);if($(ie))throw new TypeError;return ie}return xe(I)}function xe(I,P){var O,J,ie;{var ae=I.toString;if(L(ae)){var J=ae.call(I);if(!$(J))return J}var O=I.valueOf;if(L(O)){var J=O.call(I);if(!$(J))return J}}throw new TypeError}function Le(I){return!!I}function Ae(I){return""+I}function Oe(I){var P=oe(I);return qe(P)?P:Ae(P)}function _t(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 et(I){return typeof I=="function"}function Fe(I){switch(Ne(I)){case 3:return!0;case 4:return!0;default:return!1}}function Ce(I,P){return I===P||I!==I&&P!==P}function ye(I,P){var O=I[P];if(O!=null){if(!L(O))throw new TypeError;return O}}function tt(I){var P=ye(I,a);if(!L(P))throw new TypeError;var O=P.call(I);if(!$(O))throw new TypeError;return O}function Se(I){return I.value}function Be(I){var P=I.next();return P.done?!1:P}function ft(I){var P=I.return;P&&P.call(I)}function rt(I){var P=Object.getPrototypeOf(I);if(typeof I!="function"||I===d||P!==d)return P;var O=I.prototype,J=O&&Object.getPrototypeOf(O);if(J==null||J===Object.prototype)return P;var ie=J.constructor;return typeof ie!="function"||ie===I?P:ie}function R(){var I;!fe(p)&&typeof n.Reflect<"u"&&!(p in n.Reflect)&&typeof n.Reflect.defineMetadata=="function"&&(I=ne(n.Reflect));var P,O,J,ie=new y,ae={registerProvider:Te,getProvider:H,setProvider:ee};return ae;function Te(G){if(!Object.isExtensible(ae))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case I===G:break;case fe(P):P=G;break;case P===G:break;case fe(O):O=G;break;case O===G:break;default:J===void 0&&(J=new g),J.add(G);break}}function D(G,W){if(!fe(P)){if(P.isProviderFor(G,W))return P;if(!fe(O)){if(O.isProviderFor(G,W))return P;if(!fe(J))for(var he=tt(J);;){var ge=Be(he);if(!ge)return;var ke=Se(ge);if(ke.isProviderFor(G,W))return ft(he),ke}}}if(!fe(I)&&I.isProviderFor(G,W))return I}function H(G,W){var he=ie.get(G),ge;return fe(he)||(ge=he.get(W)),fe(ge)&&(ge=D(G,W),fe(ge)||(fe(he)&&(he=new m,ie.set(G,he)),he.set(W,ge))),ge}function V(G){if(fe(G))throw new TypeError;return P===G||O===G||!fe(J)&&J.has(G)}function ee(G,W,he){if(!V(he))throw new Error("Metadata provider not registered.");var ge=H(G,W);if(ge!==he){if(!fe(ge))return!1;var ke=ie.get(G);fe(ke)&&(ke=new m,ie.set(G,ke)),ke.set(W,he)}return!0}}function v(){var I;return!fe(p)&&$(n.Reflect)&&Object.isExtensible(n.Reflect)&&(I=n.Reflect[p]),fe(I)&&(I=R()),!fe(p)&&$(n.Reflect)&&Object.isExtensible(n.Reflect)&&Object.defineProperty(n.Reflect,p,{enumerable:!1,configurable:!1,writable:!1,value:I}),I}function k(I){var P=new y,O={isProviderFor:function(V,ee){var G=P.get(V);return fe(G)?!1:G.has(ee)},OrdinaryDefineOwnMetadata:Te,OrdinaryHasOwnMetadata:ie,OrdinaryGetOwnMetadata:ae,OrdinaryOwnMetadataKeys:D,OrdinaryDeleteMetadata:H};return h.registerProvider(O),O;function J(V,ee,G){var W=P.get(V),he=!1;if(fe(W)){if(!G)return;W=new m,P.set(V,W),he=!0}var ge=W.get(ee);if(fe(ge)){if(!G)return;if(ge=new m,W.set(ee,ge),!I.setProvider(V,ee,O))throw W.delete(ee),he&&P.delete(V),new Error("Wrong provider for target.")}return ge}function ie(V,ee,G){var W=J(ee,G,!1);return fe(W)?!1:Le(W.has(V))}function ae(V,ee,G){var W=J(ee,G,!1);if(!fe(W))return W.get(V)}function Te(V,ee,G,W){var he=J(G,W,!0);he.set(V,ee)}function D(V,ee){var G=[],W=J(V,ee,!1);if(fe(W))return G;for(var he=W.keys(),ge=tt(he),ke=0;;){var Ye=Be(ge);if(!Ye)return G.length=ke,G;var Zt=Se(Ye);try{G[ke]=Zt}catch(kt){try{ft(ge)}finally{throw kt}}ke++}}function H(V,ee,G){var W=J(ee,G,!1);if(fe(W)||!W.delete(V))return!1;if(W.size===0){var he=P.get(ee);fe(he)||(he.delete(G),he.size===0&&P.delete(he))}return!0}}function ne(I){var P=I.defineMetadata,O=I.hasOwnMetadata,J=I.getOwnMetadata,ie=I.getOwnMetadataKeys,ae=I.deleteMetadata,Te=new y,D={isProviderFor:function(H,V){var ee=Te.get(H);return!fe(ee)&&ee.has(V)?!0:ie(H,V).length?(fe(ee)&&(ee=new g,Te.set(H,ee)),ee.add(V),!0):!1},OrdinaryDefineOwnMetadata:P,OrdinaryHasOwnMetadata:O,OrdinaryGetOwnMetadata:J,OrdinaryOwnMetadataKeys:ie,OrdinaryDeleteMetadata:ae};return D}function re(I,P,O){var J=h.getProvider(I,P);if(!fe(J))return J;if(O){if(h.setProvider(I,P,w))return w;throw new Error("Illegal state.")}}function te(){var I={},P=[],O=(function(){function D(H,V,ee){this._index=0,this._keys=H,this._values=V,this._selector=ee}return D.prototype["@@iterator"]=function(){return this},D.prototype[a]=function(){return this},D.prototype.next=function(){var H=this._index;if(H>=0&&H<this._keys.length){var V=this._selector(this._keys[H],this._values[H]);return H+1>=this._keys.length?(this._index=-1,this._keys=P,this._values=P):this._index++,{value:V,done:!1}}return{value:void 0,done:!0}},D.prototype.throw=function(H){throw this._index>=0&&(this._index=-1,this._keys=P,this._values=P),H},D.prototype.return=function(H){return this._index>=0&&(this._index=-1,this._keys=P,this._values=P),{value:H,done:!0}},D})(),J=(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(H){return this._find(H,!1)>=0},D.prototype.get=function(H){var V=this._find(H,!1);return V>=0?this._values[V]:void 0},D.prototype.set=function(H,V){var ee=this._find(H,!0);return this._values[ee]=V,this},D.prototype.delete=function(H){var V=this._find(H,!1);if(V>=0){for(var ee=this._keys.length,G=V+1;G<ee;G++)this._keys[G-1]=this._keys[G],this._values[G-1]=this._values[G];return this._keys.length--,this._values.length--,Ce(H,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 O(this._keys,this._values,ie)},D.prototype.values=function(){return new O(this._keys,this._values,ae)},D.prototype.entries=function(){return new O(this._keys,this._values,Te)},D.prototype["@@iterator"]=function(){return this.entries()},D.prototype[a]=function(){return this.entries()},D.prototype._find=function(H,V){if(!Ce(this._cacheKey,H)){this._cacheIndex=-1;for(var ee=0;ee<this._keys.length;ee++)if(Ce(this._keys[ee],H)){this._cacheIndex=ee;break}}return this._cacheIndex<0&&V&&(this._cacheIndex=this._keys.length,this._keys.push(H),this._values.push(void 0)),this._cacheIndex},D})();return J;function ie(D,H){return D}function ae(D,H){return H}function Te(D,H){return[D,H]}}function we(){var I=(function(){function P(){this._map=new m}return Object.defineProperty(P.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),P.prototype.has=function(O){return this._map.has(O)},P.prototype.add=function(O){return this._map.set(O,O),this},P.prototype.delete=function(O){return this._map.delete(O)},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 ue(){var I=16,P=f.create(),O=J();return(function(){function H(){this._key=J()}return H.prototype.has=function(V){var ee=ie(V,!1);return ee!==void 0?f.has(ee,this._key):!1},H.prototype.get=function(V){var ee=ie(V,!1);return ee!==void 0?f.get(ee,this._key):void 0},H.prototype.set=function(V,ee){var G=ie(V,!0);return G[this._key]=ee,this},H.prototype.delete=function(V){var ee=ie(V,!1);return ee!==void 0?delete ee[this._key]:!1},H.prototype.clear=function(){this._key=J()},H})();function J(){var H;do H="@@WeakMap@@"+D();while(f.has(P,H));return P[H]=!0,H}function ie(H,V){if(!r.call(H,O)){if(!V)return;Object.defineProperty(H,O,{value:f.create()})}return H[O]}function ae(H,V){for(var ee=0;ee<V;++ee)H[ee]=Math.random()*255|0;return H}function Te(H){if(typeof Uint8Array=="function"){var V=new Uint8Array(H);return typeof crypto<"u"?crypto.getRandomValues(V):typeof msCrypto<"u"?msCrypto.getRandomValues(V):ae(V,H),V}return ae(new Array(H),H)}function D(){var H=Te(I);H[6]=H[6]&79|64,H[8]=H[8]&191|128;for(var V="",ee=0;ee<I;++ee){var G=H[ee];(ee===4||ee===6||ee===8)&&(V+="-"),G<16&&(V+="0"),V+=G.toString(16).toLowerCase()}return V}}function Ee(I){return I.__=void 0,delete I.__,I}})})(i||(i={})),xa}Dc();/**
15
15
  * @license
16
16
  * Copyright 2010-2025 Three.js Authors
17
17
  * SPDX-License-Identifier: MIT
18
- */const ga="180",ai={ROTATE:0,DOLLY:1,PAN:2},ri={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},jl=0,Ga=1,Kl=2,nl=1,$l=2,sn=3,Mn=0,bt=1,an=2,gn=0,oi=1,Wa=2,Xa=3,qa=4,Zl=5,Ln=100,Jl=101,Ql=102,ec=103,tc=104,nc=200,ic=201,rc=202,sc=203,vs=204,xs=205,ac=206,oc=207,lc=208,cc=209,hc=210,uc=211,fc=212,dc=213,pc=214,Ms=0,Ss=1,ys=2,ci=3,Es=4,Ts=5,bs=6,As=7,il=0,mc=1,_c=2,vn=0,gc=1,vc=2,xc=3,Mc=4,Sc=5,yc=6,Ec=7,rl=300,hi=301,ui=302,ws=303,Rs=304,Cr=306,Cs=1e3,Nn=1001,Ps=1002,Xt=1003,Tc=1004,Hi=1005,Yt=1006,Or=1007,Fn=1008,Zt=1009,sl=1010,al=1011,wi=1012,va=1013,Bn=1014,on=1015,Ii=1016,xa=1017,Ma=1018,Ri=1020,ol=35902,ll=35899,cl=1021,hl=1022,Wt=1023,Ci=1026,Pi=1027,ul=1028,Sa=1029,fl=1030,ya=1031,Ea=1033,_r=33776,gr=33777,vr=33778,xr=33779,Ds=35840,Ls=35841,Is=35842,Us=35843,Ns=36196,Fs=37492,Os=37496,Bs=37808,zs=37809,Hs=37810,ks=37811,Vs=37812,Gs=37813,Ws=37814,Xs=37815,qs=37816,Ys=37817,js=37818,Ks=37819,$s=37820,Zs=37821,Js=36492,Qs=36494,ea=36495,ta=36283,na=36284,ia=36285,ra=36286,bc=3200,Ac=3201,dl=0,wc=1,_n="",Ft="srgb",fi="srgb-linear",Er="linear",$e="srgb",Gn=7680,Ya=519,Rc=512,Cc=513,Pc=514,pl=515,Dc=516,Lc=517,Ic=518,Uc=519,ja=35044,Ka="300 es",jt=2e3,Tr=2001;class kn{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const r=n[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 n=t[e.type];if(n!==void 0){e.target=this;const r=n.slice(0);for(let s=0,a=r.length;s<a;s++)r[s].call(this,e);e.target=null}}}const _t=["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"],bi=Math.PI/180,sa=180/Math.PI;function Ui(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(_t[i&255]+_t[i>>8&255]+_t[i>>16&255]+_t[i>>24&255]+"-"+_t[e&255]+_t[e>>8&255]+"-"+_t[e>>16&15|64]+_t[e>>24&255]+"-"+_t[t&63|128]+_t[t>>8&255]+"-"+_t[t>>16&255]+_t[t>>24&255]+_t[n&255]+_t[n>>8&255]+_t[n>>16&255]+_t[n>>24&255]).toLowerCase()}function ke(i,e,t){return Math.max(e,Math.min(t,i))}function Nc(i,e){return(i%e+e)%e}function Br(i,e,t){return(1-t)*i+t*e}function gi(i,e){switch(e.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 yt(i,e){switch(e.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 Fc={DEG2RAD:bi};class Fe{constructor(e=0,t=0){Fe.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,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+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=ke(this.x,e.x,t.x),this.y=ke(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=ke(this.x,e,t),this.y=ke(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(ke(n,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 n=this.dot(e)/t;return Math.acos(ke(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,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 n=Math.cos(t),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*r+e.x,this.y=s*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class zn{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,s,a,o){let c=n[r+0],l=n[r+1],u=n[r+2],f=n[r+3];const d=s[a+0],m=s[a+1],v=s[a+2],S=s[a+3];if(o===0){e[t+0]=c,e[t+1]=l,e[t+2]=u,e[t+3]=f;return}if(o===1){e[t+0]=d,e[t+1]=m,e[t+2]=v,e[t+3]=S;return}if(f!==S||c!==d||l!==m||u!==v){let p=1-o;const h=c*d+l*m+u*v+f*S,L=h>=0?1:-1,C=1-h*h;if(C>Number.EPSILON){const E=Math.sqrt(C),T=Math.atan2(E,h*L);p=Math.sin(p*T)/E,o=Math.sin(o*T)/E}const g=o*L;if(c=c*p+d*g,l=l*p+m*g,u=u*p+v*g,f=f*p+S*g,p===1-o){const E=1/Math.sqrt(c*c+l*l+u*u+f*f);c*=E,l*=E,u*=E,f*=E}}e[t]=c,e[t+1]=l,e[t+2]=u,e[t+3]=f}static multiplyQuaternionsFlat(e,t,n,r,s,a){const o=n[r],c=n[r+1],l=n[r+2],u=n[r+3],f=s[a],d=s[a+1],m=s[a+2],v=s[a+3];return e[t]=o*v+u*f+c*m-l*d,e[t+1]=c*v+u*d+l*f-o*m,e[t+2]=l*v+u*m+o*d-c*f,e[t+3]=u*v-o*f-c*d-l*m,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,n,r){return this._x=e,this._y=t,this._z=n,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 n=e._x,r=e._y,s=e._z,a=e._order,o=Math.cos,c=Math.sin,l=o(n/2),u=o(r/2),f=o(s/2),d=c(n/2),m=c(r/2),v=c(s/2);switch(a){case"XYZ":this._x=d*u*f+l*m*v,this._y=l*m*f-d*u*v,this._z=l*u*v+d*m*f,this._w=l*u*f-d*m*v;break;case"YXZ":this._x=d*u*f+l*m*v,this._y=l*m*f-d*u*v,this._z=l*u*v-d*m*f,this._w=l*u*f+d*m*v;break;case"ZXY":this._x=d*u*f-l*m*v,this._y=l*m*f+d*u*v,this._z=l*u*v+d*m*f,this._w=l*u*f-d*m*v;break;case"ZYX":this._x=d*u*f-l*m*v,this._y=l*m*f+d*u*v,this._z=l*u*v-d*m*f,this._w=l*u*f+d*m*v;break;case"YZX":this._x=d*u*f+l*m*v,this._y=l*m*f+d*u*v,this._z=l*u*v-d*m*f,this._w=l*u*f-d*m*v;break;case"XZY":this._x=d*u*f-l*m*v,this._y=l*m*f-d*u*v,this._z=l*u*v+d*m*f,this._w=l*u*f+d*m*v;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],s=t[8],a=t[1],o=t[5],c=t[9],l=t[2],u=t[6],f=t[10],d=n+o+f;if(d>0){const m=.5/Math.sqrt(d+1);this._w=.25/m,this._x=(u-c)*m,this._y=(s-l)*m,this._z=(a-r)*m}else if(n>o&&n>f){const m=2*Math.sqrt(1+n-o-f);this._w=(u-c)/m,this._x=.25*m,this._y=(r+a)/m,this._z=(s+l)/m}else if(o>f){const m=2*Math.sqrt(1+o-n-f);this._w=(s-l)/m,this._x=(r+a)/m,this._y=.25*m,this._z=(c+u)/m}else{const m=2*Math.sqrt(1+f-n-o);this._w=(a-r)/m,this._x=(s+l)/m,this._y=(c+u)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(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=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ke(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const r=Math.min(1,t/n);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 n=e._x,r=e._y,s=e._z,a=e._w,o=t._x,c=t._y,l=t._z,u=t._w;return this._x=n*u+a*o+r*l-s*c,this._y=r*u+a*c+s*o-n*l,this._z=s*u+a*l+n*c-r*o,this._w=a*u-n*o-r*c-s*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,r=this._y,s=this._z,a=this._w;let o=a*e._w+n*e._x+r*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=r,this._z=s,this;const c=1-o*o;if(c<=Number.EPSILON){const m=1-t;return this._w=m*a+t*this._w,this._x=m*n+t*this._x,this._y=m*r+t*this._y,this._z=m*s+t*this._z,this.normalize(),this}const l=Math.sqrt(c),u=Math.atan2(l,o),f=Math.sin((1-t)*u)/l,d=Math.sin(t*u)/l;return this._w=a*f+this._w*d,this._x=n*f+this._x*d,this._y=r*f+this._y*d,this._z=s*f+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),s=Math.sqrt(n);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 B{constructor(e=0,t=0,n=0){B.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,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($a.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion($a.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*r,this.y=s[1]*t+s[4]*n+s[7]*r,this.z=s[2]*t+s[5]*n+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*r+s[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,s=e.x,a=e.y,o=e.z,c=e.w,l=2*(a*r-o*n),u=2*(o*t-s*r),f=2*(s*n-a*t);return this.x=t+c*l+a*f-o*u,this.y=n+c*u+o*l-s*f,this.z=r+c*f+s*u-a*l,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,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*r,this.y=s[1]*t+s[5]*n+s[9]*r,this.z=s[2]*t+s[6]*n+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=ke(this.x,e.x,t.x),this.y=ke(this.y,e.y,t.y),this.z=ke(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=ke(this.x,e,t),this.y=ke(this.y,e,t),this.z=ke(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(ke(n,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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,s=e.z,a=t.x,o=t.y,c=t.z;return this.x=r*c-s*o,this.y=s*a-n*c,this.z=n*o-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return zr.copy(this).projectOnVector(e),this.sub(zr)}reflect(e){return this.sub(zr.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 n=this.dot(e)/t;return Math.acos(ke(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+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,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,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(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,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,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const zr=new B,$a=new zn;class Oe{constructor(e,t,n,r,s,a,o,c,l){Oe.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,o,c,l)}set(e,t,n,r,s,a,o,c,l){const u=this.elements;return u[0]=e,u[1]=r,u[2]=o,u[3]=t,u[4]=s,u[5]=c,u[6]=n,u[7]=a,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.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 n=e.elements,r=t.elements,s=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],u=n[4],f=n[7],d=n[2],m=n[5],v=n[8],S=r[0],p=r[3],h=r[6],L=r[1],C=r[4],g=r[7],E=r[2],T=r[5],A=r[8];return s[0]=a*S+o*L+c*E,s[3]=a*p+o*C+c*T,s[6]=a*h+o*g+c*A,s[1]=l*S+u*L+f*E,s[4]=l*p+u*C+f*T,s[7]=l*h+u*g+f*A,s[2]=d*S+m*L+v*E,s[5]=d*p+m*C+v*T,s[8]=d*h+m*g+v*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],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],u=e[8];return t*a*u-t*o*l-n*s*u+n*o*c+r*s*l-r*a*c}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],u=e[8],f=u*a-o*l,d=o*c-u*s,m=l*s-a*c,v=t*f+n*d+r*m;if(v===0)return this.set(0,0,0,0,0,0,0,0,0);const S=1/v;return e[0]=f*S,e[1]=(r*l-u*n)*S,e[2]=(o*n-r*a)*S,e[3]=d*S,e[4]=(u*t-r*c)*S,e[5]=(r*s-o*t)*S,e[6]=m*S,e[7]=(n*c-l*t)*S,e[8]=(a*t-n*s)*S,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,n,r,s,a,o){const c=Math.cos(s),l=Math.sin(s);return this.set(n*c,n*l,-n*(c*a+l*o)+a+e,-r*l,r*c,-r*(-l*a+c*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Hr.makeScale(e,t)),this}rotate(e){return this.premultiply(Hr.makeRotation(-e)),this}translate(e,t){return this.premultiply(Hr.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),n=Math.sin(e);return this.set(t,-n,0,n,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,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Hr=new Oe;function ml(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function br(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Oc(){const i=br("canvas");return i.style.display="block",i}const Za={};function Di(i){i in Za||(Za[i]=!0,console.warn(i))}function Bc(i,e,t){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}const Ja=new Oe().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Qa=new Oe().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function zc(){const i={enabled:!0,workingColorSpace:fi,spaces:{},convert:function(r,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===$e&&(r.r=ln(r.r),r.g=ln(r.g),r.b=ln(r.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===$e&&(r.r=li(r.r),r.g=li(r.g),r.b=li(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===_n?Er: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,a){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].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 Di("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return Di("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(r,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[fi]:{primaries:e,whitePoint:n,transfer:Er,toXYZ:Ja,fromXYZ:Qa,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Ft},outputColorSpaceConfig:{drawingBufferColorSpace:Ft}},[Ft]:{primaries:e,whitePoint:n,transfer:$e,toXYZ:Ja,fromXYZ:Qa,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Ft}}}),i}const Ye=zc();function ln(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function li(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let Wn;class Hc{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Wn===void 0&&(Wn=br("canvas")),Wn.width=e.width,Wn.height=e.height;const r=Wn.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=Wn}return n.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=br("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),s=r.data;for(let a=0;a<s.length;a++)s[a]=ln(s[a]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(ln(t[n]/255)*255):t[n]=ln(t[n]);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 kc=0;class Ta{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:kc++}),this.uuid=Ui(),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 n={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let a=0,o=r.length;a<o;a++)r[a].isDataTexture?s.push(kr(r[a].image)):s.push(kr(r[a]))}else s=kr(r);n.url=s}return t||(e.images[this.uuid]=n),n}}function kr(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?Hc.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let Vc=0;const Vr=new B;class At extends kn{constructor(e=At.DEFAULT_IMAGE,t=At.DEFAULT_MAPPING,n=Nn,r=Nn,s=Yt,a=Fn,o=Wt,c=Zt,l=At.DEFAULT_ANISOTROPY,u=_n){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Vc++}),this.uuid=Ui(),this.name="",this.source=new Ta(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new Fe(0,0),this.repeat=new Fe(1,1),this.center=new Fe(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Oe,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(Vr).x}get height(){return this.source.getSize(Vr).y}get depth(){return this.source.getSize(Vr).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 n=e[t];if(n===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&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={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&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==rl)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Cs:e.x=e.x-Math.floor(e.x);break;case Nn:e.x=e.x<0?0:1;break;case Ps: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 Cs:e.y=e.y-Math.floor(e.y);break;case Nn:e.y=e.y<0?0:1;break;case Ps: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++}}At.DEFAULT_IMAGE=null;At.DEFAULT_MAPPING=rl;At.DEFAULT_ANISOTROPY=1;class ot{constructor(e=0,t=0,n=0,r=1){ot.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,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,n,r){return this.x=e,this.y=t,this.z=n,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,n=this.y,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*r+a[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,n,r,s;const c=e.elements,l=c[0],u=c[4],f=c[8],d=c[1],m=c[5],v=c[9],S=c[2],p=c[6],h=c[10];if(Math.abs(u-d)<.01&&Math.abs(f-S)<.01&&Math.abs(v-p)<.01){if(Math.abs(u+d)<.1&&Math.abs(f+S)<.1&&Math.abs(v+p)<.1&&Math.abs(l+m+h-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const C=(l+1)/2,g=(m+1)/2,E=(h+1)/2,T=(u+d)/4,A=(f+S)/4,I=(v+p)/4;return C>g&&C>E?C<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(C),r=T/n,s=A/n):g>E?g<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(g),n=T/r,s=I/r):E<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(E),n=A/s,r=I/s),this.set(n,r,s,t),this}let L=Math.sqrt((p-v)*(p-v)+(f-S)*(f-S)+(d-u)*(d-u));return Math.abs(L)<.001&&(L=1),this.x=(p-v)/L,this.y=(f-S)/L,this.z=(d-u)/L,this.w=Math.acos((l+m+h-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=ke(this.x,e.x,t.x),this.y=ke(this.y,e.y,t.y),this.z=ke(this.z,e.z,t.z),this.w=ke(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=ke(this.x,e,t),this.y=ke(this.y,e,t),this.z=ke(this.z,e,t),this.w=ke(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(ke(n,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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,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 Gc extends kn{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Yt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new ot(0,0,e,t),this.scissorTest=!1,this.viewport=new ot(0,0,e,t);const r={width:e,height:t,depth:n.depth},s=new At(r);this.textures=[];const a=n.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(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(e={}){const t={minFilter:Yt,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 n=0;n<this.textures.length;n++)this.textures[n].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,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;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=n,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,n=e.textures.length;t<n;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 Ta(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 Hn extends Gc{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class _l extends At{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=Xt,this.minFilter=Xt,this.wrapR=Nn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Wc extends At{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=Xt,this.minFilter=Xt,this.wrapR=Nn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ni{constructor(e=new B(1/0,1/0,1/0),t=new B(-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,n=e.length;t<n;t+=3)this.expandByPoint(Ht.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Ht.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Ht.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),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 n=e.geometry;if(n!==void 0){const s=n.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Ht):Ht.fromBufferAttribute(s,a),Ht.applyMatrix4(e.matrixWorld),this.expandByPoint(Ht);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),ki.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),ki.copy(n.boundingBox)),ki.applyMatrix4(e.matrixWorld),this.union(ki)}const r=e.children;for(let s=0,a=r.length;s<a;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,Ht),Ht.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(vi),Vi.subVectors(this.max,vi),Xn.subVectors(e.a,vi),qn.subVectors(e.b,vi),Yn.subVectors(e.c,vi),cn.subVectors(qn,Xn),hn.subVectors(Yn,qn),bn.subVectors(Xn,Yn);let t=[0,-cn.z,cn.y,0,-hn.z,hn.y,0,-bn.z,bn.y,cn.z,0,-cn.x,hn.z,0,-hn.x,bn.z,0,-bn.x,-cn.y,cn.x,0,-hn.y,hn.x,0,-bn.y,bn.x,0];return!Gr(t,Xn,qn,Yn,Vi)||(t=[1,0,0,0,1,0,0,0,1],!Gr(t,Xn,qn,Yn,Vi))?!1:(Gi.crossVectors(cn,hn),t=[Gi.x,Gi.y,Gi.z],Gr(t,Xn,qn,Yn,Vi))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ht).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ht).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:(Qt[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Qt[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Qt[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Qt[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Qt[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Qt[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Qt[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Qt[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Qt),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 Qt=[new B,new B,new B,new B,new B,new B,new B,new B],Ht=new B,ki=new Ni,Xn=new B,qn=new B,Yn=new B,cn=new B,hn=new B,bn=new B,vi=new B,Vi=new B,Gi=new B,An=new B;function Gr(i,e,t,n,r){for(let s=0,a=i.length-3;s<=a;s+=3){An.fromArray(i,s);const o=r.x*Math.abs(An.x)+r.y*Math.abs(An.y)+r.z*Math.abs(An.z),c=e.dot(An),l=t.dot(An),u=n.dot(An);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>o)return!1}return!0}const Xc=new Ni,xi=new B,Wr=new B;class Pr{constructor(e=new B,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 n=this.center;t!==void 0?n.copy(t):Xc.setFromPoints(e).getCenter(n);let r=0;for(let s=0,a=e.length;s<a;s++)r=Math.max(r,n.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 n=this.center.distanceToSquared(e);return t.copy(e),n>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;xi.subVectors(e,this.center);const t=xi.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(xi,r/n),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):(Wr.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(xi.copy(e.center).add(Wr)),this.expandByPoint(xi.copy(e.center).sub(Wr))),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 en=new B,Xr=new B,Wi=new B,un=new B,qr=new B,Xi=new B,Yr=new B;class Dr{constructor(e=new B,t=new B(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,en)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=en.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(en.copy(this.origin).addScaledVector(this.direction,t),en.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){Xr.copy(e).add(t).multiplyScalar(.5),Wi.copy(t).sub(e).normalize(),un.copy(this.origin).sub(Xr);const s=e.distanceTo(t)*.5,a=-this.direction.dot(Wi),o=un.dot(this.direction),c=-un.dot(Wi),l=un.lengthSq(),u=Math.abs(1-a*a);let f,d,m,v;if(u>0)if(f=a*c-o,d=a*o-c,v=s*u,f>=0)if(d>=-v)if(d<=v){const S=1/u;f*=S,d*=S,m=f*(f+a*d+2*o)+d*(a*f+d+2*c)+l}else d=s,f=Math.max(0,-(a*d+o)),m=-f*f+d*(d+2*c)+l;else d=-s,f=Math.max(0,-(a*d+o)),m=-f*f+d*(d+2*c)+l;else d<=-v?(f=Math.max(0,-(-a*s+o)),d=f>0?-s:Math.min(Math.max(-s,-c),s),m=-f*f+d*(d+2*c)+l):d<=v?(f=0,d=Math.min(Math.max(-s,-c),s),m=d*(d+2*c)+l):(f=Math.max(0,-(a*s+o)),d=f>0?s:Math.min(Math.max(-s,-c),s),m=-f*f+d*(d+2*c)+l);else d=a>0?-s:s,f=Math.max(0,-(a*d+o)),m=-f*f+d*(d+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,f),r&&r.copy(Xr).addScaledVector(Wi,d),m}intersectSphere(e,t){en.subVectors(e.center,this.origin);const n=en.dot(this.direction),r=en.dot(en)-n*n,s=e.radius*e.radius;if(r>s)return null;const a=Math.sqrt(s-r),o=n-a,c=n+a;return c<0?null:o<0?this.at(c,t):this.at(o,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 n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,s,a,o,c;const l=1/this.direction.x,u=1/this.direction.y,f=1/this.direction.z,d=this.origin;return l>=0?(n=(e.min.x-d.x)*l,r=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,r=(e.min.x-d.x)*l),u>=0?(s=(e.min.y-d.y)*u,a=(e.max.y-d.y)*u):(s=(e.max.y-d.y)*u,a=(e.min.y-d.y)*u),n>a||s>r||((s>n||isNaN(n))&&(n=s),(a<r||isNaN(r))&&(r=a),f>=0?(o=(e.min.z-d.z)*f,c=(e.max.z-d.z)*f):(o=(e.max.z-d.z)*f,c=(e.min.z-d.z)*f),n>c||o>r)||((o>n||n!==n)&&(n=o),(c<r||r!==r)&&(r=c),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,en)!==null}intersectTriangle(e,t,n,r,s){qr.subVectors(t,e),Xi.subVectors(n,e),Yr.crossVectors(qr,Xi);let a=this.direction.dot(Yr),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;un.subVectors(this.origin,e);const c=o*this.direction.dot(Xi.crossVectors(un,Xi));if(c<0)return null;const l=o*this.direction.dot(qr.cross(un));if(l<0||c+l>a)return null;const u=-o*un.dot(Yr);return u<0?null:this.at(u/a,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 st{constructor(e,t,n,r,s,a,o,c,l,u,f,d,m,v,S,p){st.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,n,r,s,a,o,c,l,u,f,d,m,v,S,p)}set(e,t,n,r,s,a,o,c,l,u,f,d,m,v,S,p){const h=this.elements;return h[0]=e,h[4]=t,h[8]=n,h[12]=r,h[1]=s,h[5]=a,h[9]=o,h[13]=c,h[2]=l,h[6]=u,h[10]=f,h[14]=d,h[3]=m,h[7]=v,h[11]=S,h[15]=p,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 st().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[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,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,r=1/jn.setFromMatrixColumn(e,0).length(),s=1/jn.setFromMatrixColumn(e,1).length(),a=1/jn.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,s=e.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(r),l=Math.sin(r),u=Math.cos(s),f=Math.sin(s);if(e.order==="XYZ"){const d=a*u,m=a*f,v=o*u,S=o*f;t[0]=c*u,t[4]=-c*f,t[8]=l,t[1]=m+v*l,t[5]=d-S*l,t[9]=-o*c,t[2]=S-d*l,t[6]=v+m*l,t[10]=a*c}else if(e.order==="YXZ"){const d=c*u,m=c*f,v=l*u,S=l*f;t[0]=d+S*o,t[4]=v*o-m,t[8]=a*l,t[1]=a*f,t[5]=a*u,t[9]=-o,t[2]=m*o-v,t[6]=S+d*o,t[10]=a*c}else if(e.order==="ZXY"){const d=c*u,m=c*f,v=l*u,S=l*f;t[0]=d-S*o,t[4]=-a*f,t[8]=v+m*o,t[1]=m+v*o,t[5]=a*u,t[9]=S-d*o,t[2]=-a*l,t[6]=o,t[10]=a*c}else if(e.order==="ZYX"){const d=a*u,m=a*f,v=o*u,S=o*f;t[0]=c*u,t[4]=v*l-m,t[8]=d*l+S,t[1]=c*f,t[5]=S*l+d,t[9]=m*l-v,t[2]=-l,t[6]=o*c,t[10]=a*c}else if(e.order==="YZX"){const d=a*c,m=a*l,v=o*c,S=o*l;t[0]=c*u,t[4]=S-d*f,t[8]=v*f+m,t[1]=f,t[5]=a*u,t[9]=-o*u,t[2]=-l*u,t[6]=m*f+v,t[10]=d-S*f}else if(e.order==="XZY"){const d=a*c,m=a*l,v=o*c,S=o*l;t[0]=c*u,t[4]=-f,t[8]=l*u,t[1]=d*f+S,t[5]=a*u,t[9]=m*f-v,t[2]=v*f-m,t[6]=o*u,t[10]=S*f+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(qc,e,Yc)}lookAt(e,t,n){const r=this.elements;return Ct.subVectors(e,t),Ct.lengthSq()===0&&(Ct.z=1),Ct.normalize(),fn.crossVectors(n,Ct),fn.lengthSq()===0&&(Math.abs(n.z)===1?Ct.x+=1e-4:Ct.z+=1e-4,Ct.normalize(),fn.crossVectors(n,Ct)),fn.normalize(),qi.crossVectors(Ct,fn),r[0]=fn.x,r[4]=qi.x,r[8]=Ct.x,r[1]=fn.y,r[5]=qi.y,r[9]=Ct.y,r[2]=fn.z,r[6]=qi.z,r[10]=Ct.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],u=n[1],f=n[5],d=n[9],m=n[13],v=n[2],S=n[6],p=n[10],h=n[14],L=n[3],C=n[7],g=n[11],E=n[15],T=r[0],A=r[4],I=r[8],y=r[12],M=r[1],U=r[5],W=r[9],Z=r[13],te=r[2],ne=r[6],ee=r[10],le=r[14],j=r[3],ue=r[7],me=r[11],be=r[15];return s[0]=a*T+o*M+c*te+l*j,s[4]=a*A+o*U+c*ne+l*ue,s[8]=a*I+o*W+c*ee+l*me,s[12]=a*y+o*Z+c*le+l*be,s[1]=u*T+f*M+d*te+m*j,s[5]=u*A+f*U+d*ne+m*ue,s[9]=u*I+f*W+d*ee+m*me,s[13]=u*y+f*Z+d*le+m*be,s[2]=v*T+S*M+p*te+h*j,s[6]=v*A+S*U+p*ne+h*ue,s[10]=v*I+S*W+p*ee+h*me,s[14]=v*y+S*Z+p*le+h*be,s[3]=L*T+C*M+g*te+E*j,s[7]=L*A+C*U+g*ne+E*ue,s[11]=L*I+C*W+g*ee+E*me,s[15]=L*y+C*Z+g*le+E*be,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],n=e[4],r=e[8],s=e[12],a=e[1],o=e[5],c=e[9],l=e[13],u=e[2],f=e[6],d=e[10],m=e[14],v=e[3],S=e[7],p=e[11],h=e[15];return v*(+s*c*f-r*l*f-s*o*d+n*l*d+r*o*m-n*c*m)+S*(+t*c*m-t*l*d+s*a*d-r*a*m+r*l*u-s*c*u)+p*(+t*l*f-t*o*m-s*a*f+n*a*m+s*o*u-n*l*u)+h*(-r*o*u-t*c*f+t*o*d+r*a*f-n*a*d+n*c*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,n){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]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],u=e[8],f=e[9],d=e[10],m=e[11],v=e[12],S=e[13],p=e[14],h=e[15],L=f*p*l-S*d*l+S*c*m-o*p*m-f*c*h+o*d*h,C=v*d*l-u*p*l-v*c*m+a*p*m+u*c*h-a*d*h,g=u*S*l-v*f*l+v*o*m-a*S*m-u*o*h+a*f*h,E=v*f*c-u*S*c-v*o*d+a*S*d+u*o*p-a*f*p,T=t*L+n*C+r*g+s*E;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const A=1/T;return e[0]=L*A,e[1]=(S*d*s-f*p*s-S*r*m+n*p*m+f*r*h-n*d*h)*A,e[2]=(o*p*s-S*c*s+S*r*l-n*p*l-o*r*h+n*c*h)*A,e[3]=(f*c*s-o*d*s-f*r*l+n*d*l+o*r*m-n*c*m)*A,e[4]=C*A,e[5]=(u*p*s-v*d*s+v*r*m-t*p*m-u*r*h+t*d*h)*A,e[6]=(v*c*s-a*p*s-v*r*l+t*p*l+a*r*h-t*c*h)*A,e[7]=(a*d*s-u*c*s+u*r*l-t*d*l-a*r*m+t*c*m)*A,e[8]=g*A,e[9]=(v*f*s-u*S*s-v*n*m+t*S*m+u*n*h-t*f*h)*A,e[10]=(a*S*s-v*o*s+v*n*l-t*S*l-a*n*h+t*o*h)*A,e[11]=(u*o*s-a*f*s-u*n*l+t*f*l+a*n*m-t*o*m)*A,e[12]=E*A,e[13]=(u*S*r-v*f*r+v*n*d-t*S*d-u*n*p+t*f*p)*A,e[14]=(v*o*r-a*S*r-v*n*c+t*S*c+a*n*p-t*o*p)*A,e[15]=(a*f*r-u*o*r+u*n*c-t*f*c-a*n*d+t*o*d)*A,this}scale(e){const t=this.elements,n=e.x,r=e.y,s=e.z;return t[0]*=n,t[4]*=r,t[8]*=s,t[1]*=n,t[5]*=r,t[9]*=s,t[2]*=n,t[6]*=r,t[10]*=s,t[3]*=n,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],n=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,n,r))}makeTranslation(e,t,n){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,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),r=Math.sin(t),s=1-n,a=e.x,o=e.y,c=e.z,l=s*a,u=s*o;return this.set(l*a+n,l*o-r*c,l*c+r*o,0,l*o+r*c,u*o+n,u*c-r*a,0,l*c-r*o,u*c+r*a,s*c*c+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,s,a){return this.set(1,n,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,s=t._x,a=t._y,o=t._z,c=t._w,l=s+s,u=a+a,f=o+o,d=s*l,m=s*u,v=s*f,S=a*u,p=a*f,h=o*f,L=c*l,C=c*u,g=c*f,E=n.x,T=n.y,A=n.z;return r[0]=(1-(S+h))*E,r[1]=(m+g)*E,r[2]=(v-C)*E,r[3]=0,r[4]=(m-g)*T,r[5]=(1-(d+h))*T,r[6]=(p+L)*T,r[7]=0,r[8]=(v+C)*A,r[9]=(p-L)*A,r[10]=(1-(d+S))*A,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;let s=jn.set(r[0],r[1],r[2]).length();const a=jn.set(r[4],r[5],r[6]).length(),o=jn.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],kt.copy(this);const l=1/s,u=1/a,f=1/o;return kt.elements[0]*=l,kt.elements[1]*=l,kt.elements[2]*=l,kt.elements[4]*=u,kt.elements[5]*=u,kt.elements[6]*=u,kt.elements[8]*=f,kt.elements[9]*=f,kt.elements[10]*=f,t.setFromRotationMatrix(kt),n.x=s,n.y=a,n.z=o,this}makePerspective(e,t,n,r,s,a,o=jt,c=!1){const l=this.elements,u=2*s/(t-e),f=2*s/(n-r),d=(t+e)/(t-e),m=(n+r)/(n-r);let v,S;if(c)v=s/(a-s),S=a*s/(a-s);else if(o===jt)v=-(a+s)/(a-s),S=-2*a*s/(a-s);else if(o===Tr)v=-a/(a-s),S=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=u,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=f,l[9]=m,l[13]=0,l[2]=0,l[6]=0,l[10]=v,l[14]=S,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,r,s,a,o=jt,c=!1){const l=this.elements,u=2/(t-e),f=2/(n-r),d=-(t+e)/(t-e),m=-(n+r)/(n-r);let v,S;if(c)v=1/(a-s),S=a/(a-s);else if(o===jt)v=-2/(a-s),S=-(a+s)/(a-s);else if(o===Tr)v=-1/(a-s),S=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=u,l[4]=0,l[8]=0,l[12]=d,l[1]=0,l[5]=f,l[9]=0,l[13]=m,l[2]=0,l[6]=0,l[10]=v,l[14]=S,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const jn=new B,kt=new st,qc=new B(0,0,0),Yc=new B(1,1,1),fn=new B,qi=new B,Ct=new B,eo=new st,to=new zn;class Jt{constructor(e=0,t=0,n=0,r=Jt.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,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,n,r=this._order){return this._x=e,this._y=t,this._z=n,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,n=!0){const r=e.elements,s=r[0],a=r[4],o=r[8],c=r[1],l=r[5],u=r[9],f=r[2],d=r[6],m=r[10];switch(t){case"XYZ":this._y=Math.asin(ke(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,m),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-ke(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(ke(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-ke(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(d,m),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(ke(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-f,s)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-ke(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-u,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return eo.makeRotationFromQuaternion(e),this.setFromRotationMatrix(eo,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return to.setFromEuler(this),this.setFromQuaternion(to,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}}Jt.DEFAULT_ORDER="XYZ";class ba{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 jc=0;const no=new B,Kn=new zn,tn=new st,Yi=new B,Mi=new B,Kc=new B,$c=new zn,io=new B(1,0,0),ro=new B(0,1,0),so=new B(0,0,1),ao={type:"added"},Zc={type:"removed"},$n={type:"childadded",child:null},jr={type:"childremoved",child:null};class mt extends kn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:jc++}),this.uuid=Ui(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=mt.DEFAULT_UP.clone();const e=new B,t=new Jt,n=new zn,r=new B(1,1,1);function s(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new st},normalMatrix:{value:new Oe}}),this.matrix=new st,this.matrixWorld=new st,this.matrixAutoUpdate=mt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=mt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new ba,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 Kn.setFromAxisAngle(e,t),this.quaternion.multiply(Kn),this}rotateOnWorldAxis(e,t){return Kn.setFromAxisAngle(e,t),this.quaternion.premultiply(Kn),this}rotateX(e){return this.rotateOnAxis(io,e)}rotateY(e){return this.rotateOnAxis(ro,e)}rotateZ(e){return this.rotateOnAxis(so,e)}translateOnAxis(e,t){return no.copy(e).applyQuaternion(this.quaternion),this.position.add(no.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(io,e)}translateY(e){return this.translateOnAxis(ro,e)}translateZ(e){return this.translateOnAxis(so,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(tn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Yi.copy(e):Yi.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),Mi.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?tn.lookAt(Mi,Yi,this.up):tn.lookAt(Yi,Mi,this.up),this.quaternion.setFromRotationMatrix(tn),r&&(tn.extractRotation(r.matrixWorld),Kn.setFromRotationMatrix(tn),this.quaternion.premultiply(Kn.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(ao),$n.child=e,this.dispatchEvent($n),$n.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Zc),jr.child=e,this.dispatchEvent(jr),jr.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),tn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),tn.multiply(e.parent.matrixWorld)),e.applyMatrix4(tn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(ao),$n.child=e,this.dispatchEvent($n),$n.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 n=0,r=this.children.length;n<r;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Mi,e,Kc),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Mi,$c,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 n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].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 n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){const n=this.parent;if(e===!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)),t===!0){const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.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(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(o=>({...o})),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(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.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 o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let l=0,u=c.length;l<u;l++){const f=c[l];s(e.shapes,f)}else s(e.shapes,c)}}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 o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(s(e.materials,this.material[c]));r.material=o}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];r.animations.push(s(e.animations,c))}}if(t){const o=a(e.geometries),c=a(e.materials),l=a(e.textures),u=a(e.images),f=a(e.shapes),d=a(e.skeletons),m=a(e.animations),v=a(e.nodes);o.length>0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),u.length>0&&(n.images=u),f.length>0&&(n.shapes=f),d.length>0&&(n.skeletons=d),m.length>0&&(n.animations=m),v.length>0&&(n.nodes=v)}return n.object=r,n;function a(o){const c=[];for(const l in o){const u=o[l];delete u.metadata,c.push(u)}return c}}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 n=0;n<e.children.length;n++){const r=e.children[n];this.add(r.clone())}return this}}mt.DEFAULT_UP=new B(0,1,0);mt.DEFAULT_MATRIX_AUTO_UPDATE=!0;mt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Vt=new B,nn=new B,Kr=new B,rn=new B,Zn=new B,Jn=new B,oo=new B,$r=new B,Zr=new B,Jr=new B,Qr=new ot,es=new ot,ts=new ot;class Bt{constructor(e=new B,t=new B,n=new B){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),Vt.subVectors(e,t),r.cross(Vt);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,n,r,s){Vt.subVectors(r,t),nn.subVectors(n,t),Kr.subVectors(e,t);const a=Vt.dot(Vt),o=Vt.dot(nn),c=Vt.dot(Kr),l=nn.dot(nn),u=nn.dot(Kr),f=a*l-o*o;if(f===0)return s.set(0,0,0),null;const d=1/f,m=(l*c-o*u)*d,v=(a*u-o*c)*d;return s.set(1-m-v,v,m)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,rn)===null?!1:rn.x>=0&&rn.y>=0&&rn.x+rn.y<=1}static getInterpolation(e,t,n,r,s,a,o,c){return this.getBarycoord(e,t,n,r,rn)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,rn.x),c.addScaledVector(a,rn.y),c.addScaledVector(o,rn.z),c)}static getInterpolatedAttribute(e,t,n,r,s,a){return Qr.setScalar(0),es.setScalar(0),ts.setScalar(0),Qr.fromBufferAttribute(e,t),es.fromBufferAttribute(e,n),ts.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(Qr,s.x),a.addScaledVector(es,s.y),a.addScaledVector(ts,s.z),a}static isFrontFacing(e,t,n,r){return Vt.subVectors(n,t),nn.subVectors(e,t),Vt.cross(nn).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),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 Vt.subVectors(this.c,this.b),nn.subVectors(this.a,this.b),Vt.cross(nn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Bt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Bt.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,s){return Bt.getInterpolation(e,this.a,this.b,this.c,t,n,r,s)}containsPoint(e){return Bt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Bt.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,s=this.c;let a,o;Zn.subVectors(r,n),Jn.subVectors(s,n),$r.subVectors(e,n);const c=Zn.dot($r),l=Jn.dot($r);if(c<=0&&l<=0)return t.copy(n);Zr.subVectors(e,r);const u=Zn.dot(Zr),f=Jn.dot(Zr);if(u>=0&&f<=u)return t.copy(r);const d=c*f-u*l;if(d<=0&&c>=0&&u<=0)return a=c/(c-u),t.copy(n).addScaledVector(Zn,a);Jr.subVectors(e,s);const m=Zn.dot(Jr),v=Jn.dot(Jr);if(v>=0&&m<=v)return t.copy(s);const S=m*l-c*v;if(S<=0&&l>=0&&v<=0)return o=l/(l-v),t.copy(n).addScaledVector(Jn,o);const p=u*v-m*f;if(p<=0&&f-u>=0&&m-v>=0)return oo.subVectors(s,r),o=(f-u)/(f-u+(m-v)),t.copy(r).addScaledVector(oo,o);const h=1/(p+S+d);return a=S*h,o=d*h,t.copy(n).addScaledVector(Zn,a).addScaledVector(Jn,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const gl={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},dn={h:0,s:0,l:0},ji={h:0,s:0,l:0};function ns(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}class Ge{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===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,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ft){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ye.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=Ye.workingColorSpace){return this.r=e,this.g=t,this.b=n,Ye.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=Ye.workingColorSpace){if(e=Nc(e,1),t=ke(t,0,1),n=ke(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,a=2*n-s;this.r=ns(a,s,e+1/3),this.g=ns(a,s,e),this.b=ns(a,s,e-1/3)}return Ye.colorSpaceToWorking(this,r),this}setStyle(e,t=Ft){function n(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 a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(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(o))return n(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(o))return n(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],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===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=Ft){const n=gl[e.toLowerCase()];return n!==void 0?this.setHex(n,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=ln(e.r),this.g=ln(e.g),this.b=ln(e.b),this}copyLinearToSRGB(e){return this.r=li(e.r),this.g=li(e.g),this.b=li(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ft){return Ye.workingToColorSpace(gt.copy(this),e),Math.round(ke(gt.r*255,0,255))*65536+Math.round(ke(gt.g*255,0,255))*256+Math.round(ke(gt.b*255,0,255))}getHexString(e=Ft){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ye.workingColorSpace){Ye.workingToColorSpace(gt.copy(this),t);const n=gt.r,r=gt.g,s=gt.b,a=Math.max(n,r,s),o=Math.min(n,r,s);let c,l;const u=(o+a)/2;if(o===a)c=0,l=0;else{const f=a-o;switch(l=u<=.5?f/(a+o):f/(2-a-o),a){case n:c=(r-s)/f+(r<s?6:0);break;case r:c=(s-n)/f+2;break;case s:c=(n-r)/f+4;break}c/=6}return e.h=c,e.s=l,e.l=u,e}getRGB(e,t=Ye.workingColorSpace){return Ye.workingToColorSpace(gt.copy(this),t),e.r=gt.r,e.g=gt.g,e.b=gt.b,e}getStyle(e=Ft){Ye.workingToColorSpace(gt.copy(this),e);const t=gt.r,n=gt.g,r=gt.b;return e!==Ft?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(e,t,n){return this.getHSL(dn),this.setHSL(dn.h+e,dn.s+t,dn.l+n)}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,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(dn),e.getHSL(ji);const n=Br(dn.h,ji.h,t),r=Br(dn.s,ji.s,t),s=Br(dn.l,ji.l,t);return this.setHSL(n,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,n=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*r,this.g=s[1]*t+s[4]*n+s[7]*r,this.b=s[2]*t+s[5]*n+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 gt=new Ge;Ge.NAMES=gl;let Jc=0;class pi extends kn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Jc++}),this.uuid=Ui(),this.name="",this.type="Material",this.blending=oi,this.side=Mn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=vs,this.blendDst=xs,this.blendEquation=Ln,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ge(0,0,0),this.blendAlpha=0,this.depthFunc=ci,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Ya,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Gn,this.stencilZFail=Gn,this.stencilZPass=Gn,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 n=e[t];if(n===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(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={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(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).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(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).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(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).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(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).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!==oi&&(n.blending=this.blending),this.side!==Mn&&(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!==vs&&(n.blendSrc=this.blendSrc),this.blendDst!==xs&&(n.blendDst=this.blendDst),this.blendEquation!==Ln&&(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!==ci&&(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!==Ya&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Gn&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Gn&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Gn&&(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 r(s){const a=[];for(const o in s){const c=s[o];delete c.metadata,a.push(c)}return a}if(t){const s=r(e.textures),a=r(e.images);s.length>0&&(n.textures=s),a.length>0&&(n.images=a)}return n}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 n=null;if(t!==null){const r=t.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,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 vl extends pi{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ge(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 Jt,this.combine=il,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 ct=new B,Ki=new Fe;let Qc=0;class $t{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Qc++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=ja,this.updateRanges=[],this.gpuType=on,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,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Ki.fromBufferAttribute(this,t),Ki.applyMatrix3(e),this.setXY(t,Ki.x,Ki.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)ct.fromBufferAttribute(this,t),ct.applyMatrix3(e),this.setXYZ(t,ct.x,ct.y,ct.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)ct.fromBufferAttribute(this,t),ct.applyMatrix4(e),this.setXYZ(t,ct.x,ct.y,ct.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)ct.fromBufferAttribute(this,t),ct.applyNormalMatrix(e),this.setXYZ(t,ct.x,ct.y,ct.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)ct.fromBufferAttribute(this,t),ct.transformDirection(e),this.setXYZ(t,ct.x,ct.y,ct.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=gi(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=yt(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=gi(t,this.array)),t}setX(e,t){return this.normalized&&(t=yt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=gi(t,this.array)),t}setY(e,t){return this.normalized&&(t=yt(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=gi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=yt(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=gi(t,this.array)),t}setW(e,t){return this.normalized&&(t=yt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=yt(t,this.array),n=yt(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=yt(t,this.array),n=yt(n,this.array),r=yt(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e*=this.itemSize,this.normalized&&(t=yt(t,this.array),n=yt(n,this.array),r=yt(r,this.array),s=yt(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,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!==ja&&(e.usage=this.usage),e}}class xl extends $t{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Ml extends $t{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class vt extends $t{constructor(e,t,n){super(new Float32Array(e),t,n)}}let eh=0;const Nt=new st,is=new mt,Qn=new B,Pt=new Ni,Si=new Ni,pt=new B;class Dt extends kn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:eh++}),this.uuid=Ui(),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(ml(e)?Ml:xl)(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,n=0){this.groups.push({start:e,count:t,materialIndex:n})}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 n=this.attributes.normal;if(n!==void 0){const s=new Oe().getNormalMatrix(e);n.applyNormalMatrix(s),n.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 Nt.makeRotationFromQuaternion(e),this.applyMatrix4(Nt),this}rotateX(e){return Nt.makeRotationX(e),this.applyMatrix4(Nt),this}rotateY(e){return Nt.makeRotationY(e),this.applyMatrix4(Nt),this}rotateZ(e){return Nt.makeRotationZ(e),this.applyMatrix4(Nt),this}translate(e,t,n){return Nt.makeTranslation(e,t,n),this.applyMatrix4(Nt),this}scale(e,t,n){return Nt.makeScale(e,t,n),this.applyMatrix4(Nt),this}lookAt(e){return is.lookAt(e),is.updateMatrix(),this.applyMatrix4(is.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Qn).negate(),this.translate(Qn.x,Qn.y,Qn.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let r=0,s=e.length;r<s;r++){const a=e[r];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new vt(n,3))}else{const n=Math.min(e.length,t.count);for(let r=0;r<n;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 Ni);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 B(-1/0,-1/0,-1/0),new B(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n<r;n++){const s=t[n];Pt.setFromBufferAttribute(s),this.morphTargetsRelative?(pt.addVectors(this.boundingBox.min,Pt.min),this.boundingBox.expandByPoint(pt),pt.addVectors(this.boundingBox.max,Pt.max),this.boundingBox.expandByPoint(pt)):(this.boundingBox.expandByPoint(Pt.min),this.boundingBox.expandByPoint(Pt.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 Pr);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 B,1/0);return}if(e){const n=this.boundingSphere.center;if(Pt.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];Si.setFromBufferAttribute(o),this.morphTargetsRelative?(pt.addVectors(Pt.min,Si.min),Pt.expandByPoint(pt),pt.addVectors(Pt.max,Si.max),Pt.expandByPoint(pt)):(Pt.expandByPoint(Si.min),Pt.expandByPoint(Si.max))}Pt.getCenter(n);let r=0;for(let s=0,a=e.count;s<a;s++)pt.fromBufferAttribute(e,s),r=Math.max(r,n.distanceToSquared(pt));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],c=this.morphTargetsRelative;for(let l=0,u=o.count;l<u;l++)pt.fromBufferAttribute(o,l),c&&(Qn.fromBufferAttribute(e,l),pt.add(Qn)),r=Math.max(r,n.distanceToSquared(pt))}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 n=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new $t(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),o=[],c=[];for(let I=0;I<n.count;I++)o[I]=new B,c[I]=new B;const l=new B,u=new B,f=new B,d=new Fe,m=new Fe,v=new Fe,S=new B,p=new B;function h(I,y,M){l.fromBufferAttribute(n,I),u.fromBufferAttribute(n,y),f.fromBufferAttribute(n,M),d.fromBufferAttribute(s,I),m.fromBufferAttribute(s,y),v.fromBufferAttribute(s,M),u.sub(l),f.sub(l),m.sub(d),v.sub(d);const U=1/(m.x*v.y-v.x*m.y);isFinite(U)&&(S.copy(u).multiplyScalar(v.y).addScaledVector(f,-m.y).multiplyScalar(U),p.copy(f).multiplyScalar(m.x).addScaledVector(u,-v.x).multiplyScalar(U),o[I].add(S),o[y].add(S),o[M].add(S),c[I].add(p),c[y].add(p),c[M].add(p))}let L=this.groups;L.length===0&&(L=[{start:0,count:e.count}]);for(let I=0,y=L.length;I<y;++I){const M=L[I],U=M.start,W=M.count;for(let Z=U,te=U+W;Z<te;Z+=3)h(e.getX(Z+0),e.getX(Z+1),e.getX(Z+2))}const C=new B,g=new B,E=new B,T=new B;function A(I){E.fromBufferAttribute(r,I),T.copy(E);const y=o[I];C.copy(y),C.sub(E.multiplyScalar(E.dot(y))).normalize(),g.crossVectors(T,y);const U=g.dot(c[I])<0?-1:1;a.setXYZW(I,C.x,C.y,C.z,U)}for(let I=0,y=L.length;I<y;++I){const M=L[I],U=M.start,W=M.count;for(let Z=U,te=U+W;Z<te;Z+=3)A(e.getX(Z+0)),A(e.getX(Z+1)),A(e.getX(Z+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new $t(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,m=n.count;d<m;d++)n.setXYZ(d,0,0,0);const r=new B,s=new B,a=new B,o=new B,c=new B,l=new B,u=new B,f=new B;if(e)for(let d=0,m=e.count;d<m;d+=3){const v=e.getX(d+0),S=e.getX(d+1),p=e.getX(d+2);r.fromBufferAttribute(t,v),s.fromBufferAttribute(t,S),a.fromBufferAttribute(t,p),u.subVectors(a,s),f.subVectors(r,s),u.cross(f),o.fromBufferAttribute(n,v),c.fromBufferAttribute(n,S),l.fromBufferAttribute(n,p),o.add(u),c.add(u),l.add(u),n.setXYZ(v,o.x,o.y,o.z),n.setXYZ(S,c.x,c.y,c.z),n.setXYZ(p,l.x,l.y,l.z)}else for(let d=0,m=t.count;d<m;d+=3)r.fromBufferAttribute(t,d+0),s.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,d+2),u.subVectors(a,s),f.subVectors(r,s),u.cross(f),n.setXYZ(d+0,u.x,u.y,u.z),n.setXYZ(d+1,u.x,u.y,u.z),n.setXYZ(d+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)pt.fromBufferAttribute(e,t),pt.normalize(),e.setXYZ(t,pt.x,pt.y,pt.z)}toNonIndexed(){function e(o,c){const l=o.array,u=o.itemSize,f=o.normalized,d=new l.constructor(c.length*u);let m=0,v=0;for(let S=0,p=c.length;S<p;S++){o.isInterleavedBufferAttribute?m=c[S]*o.data.stride+o.offset:m=c[S]*u;for(let h=0;h<u;h++)d[v++]=l[m++]}return new $t(d,u,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Dt,n=this.index.array,r=this.attributes;for(const o in r){const c=r[o],l=e(c,n);t.setAttribute(o,l)}const s=this.morphAttributes;for(const o in s){const c=[],l=s[o];for(let u=0,f=l.length;u<f;u++){const d=l[u],m=e(d,n);c.push(m)}t.morphAttributes[o]=c}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;o++){const l=a[o];t.addGroup(l.start,l.count,l.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 c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);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 n=this.attributes;for(const c in n){const l=n[c];e.data.attributes[c]=l.toJSON(e.data)}const r={};let s=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],u=[];for(let f=0,d=l.length;f<d;f++){const m=l[f];u.push(m.toJSON(e.data))}u.length>0&&(r[c]=u,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.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 n=e.index;n!==null&&this.setIndex(n.clone());const r=e.attributes;for(const l in r){const u=r[l];this.setAttribute(l,u.clone(t))}const s=e.morphAttributes;for(const l in s){const u=[],f=s[l];for(let d=0,m=f.length;d<m;d++)u.push(f[d].clone(t));this.morphAttributes[l]=u}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let l=0,u=a.length;l<u;l++){const f=a[l];this.addGroup(f.start,f.count,f.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const lo=new st,wn=new Dr,$i=new Pr,co=new B,Zi=new B,Ji=new B,Qi=new B,rs=new B,er=new B,ho=new B,tr=new B;class Kt extends mt{constructor(e=new Dt,t=new vl){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,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,t){const n=this.geometry,r=n.attributes.position,s=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);const o=this.morphTargetInfluences;if(s&&o){er.set(0,0,0);for(let c=0,l=s.length;c<l;c++){const u=o[c],f=s[c];u!==0&&(rs.fromBufferAttribute(f,e),a?er.addScaledVector(rs,u):er.addScaledVector(rs.sub(t),u))}t.add(er)}return t}raycast(e,t){const n=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),$i.copy(n.boundingSphere),$i.applyMatrix4(s),wn.copy(e.ray).recast(e.near),!($i.containsPoint(wn.origin)===!1&&(wn.intersectSphere($i,co)===null||wn.origin.distanceToSquared(co)>(e.far-e.near)**2))&&(lo.copy(s).invert(),wn.copy(e.ray).applyMatrix4(lo),!(n.boundingBox!==null&&wn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,wn)))}_computeIntersections(e,t,n){let r;const s=this.geometry,a=this.material,o=s.index,c=s.attributes.position,l=s.attributes.uv,u=s.attributes.uv1,f=s.attributes.normal,d=s.groups,m=s.drawRange;if(o!==null)if(Array.isArray(a))for(let v=0,S=d.length;v<S;v++){const p=d[v],h=a[p.materialIndex],L=Math.max(p.start,m.start),C=Math.min(o.count,Math.min(p.start+p.count,m.start+m.count));for(let g=L,E=C;g<E;g+=3){const T=o.getX(g),A=o.getX(g+1),I=o.getX(g+2);r=nr(this,h,e,n,l,u,f,T,A,I),r&&(r.faceIndex=Math.floor(g/3),r.face.materialIndex=p.materialIndex,t.push(r))}}else{const v=Math.max(0,m.start),S=Math.min(o.count,m.start+m.count);for(let p=v,h=S;p<h;p+=3){const L=o.getX(p),C=o.getX(p+1),g=o.getX(p+2);r=nr(this,a,e,n,l,u,f,L,C,g),r&&(r.faceIndex=Math.floor(p/3),t.push(r))}}else if(c!==void 0)if(Array.isArray(a))for(let v=0,S=d.length;v<S;v++){const p=d[v],h=a[p.materialIndex],L=Math.max(p.start,m.start),C=Math.min(c.count,Math.min(p.start+p.count,m.start+m.count));for(let g=L,E=C;g<E;g+=3){const T=g,A=g+1,I=g+2;r=nr(this,h,e,n,l,u,f,T,A,I),r&&(r.faceIndex=Math.floor(g/3),r.face.materialIndex=p.materialIndex,t.push(r))}}else{const v=Math.max(0,m.start),S=Math.min(c.count,m.start+m.count);for(let p=v,h=S;p<h;p+=3){const L=p,C=p+1,g=p+2;r=nr(this,a,e,n,l,u,f,L,C,g),r&&(r.faceIndex=Math.floor(p/3),t.push(r))}}}}function th(i,e,t,n,r,s,a,o){let c;if(e.side===bt?c=n.intersectTriangle(a,s,r,!0,o):c=n.intersectTriangle(r,s,a,e.side===Mn,o),c===null)return null;tr.copy(o),tr.applyMatrix4(i.matrixWorld);const l=t.ray.origin.distanceTo(tr);return l<t.near||l>t.far?null:{distance:l,point:tr.clone(),object:i}}function nr(i,e,t,n,r,s,a,o,c,l){i.getVertexPosition(o,Zi),i.getVertexPosition(c,Ji),i.getVertexPosition(l,Qi);const u=th(i,e,t,n,Zi,Ji,Qi,ho);if(u){const f=new B;Bt.getBarycoord(ho,Zi,Ji,Qi,f),r&&(u.uv=Bt.getInterpolatedAttribute(r,o,c,l,f,new Fe)),s&&(u.uv1=Bt.getInterpolatedAttribute(s,o,c,l,f,new Fe)),a&&(u.normal=Bt.getInterpolatedAttribute(a,o,c,l,f,new B),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));const d={a:o,b:c,c:l,normal:new B,materialIndex:0};Bt.getNormal(Zi,Ji,Qi,d.normal),u.face=d,u.barycoord=f}return u}class Fi extends Dt{constructor(e=1,t=1,n=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:s,depthSegments:a};const o=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);const c=[],l=[],u=[],f=[];let d=0,m=0;v("z","y","x",-1,-1,n,t,e,a,s,0),v("z","y","x",1,-1,n,t,-e,a,s,1),v("x","z","y",1,1,e,n,t,r,a,2),v("x","z","y",1,-1,e,n,-t,r,a,3),v("x","y","z",1,-1,e,t,n,r,s,4),v("x","y","z",-1,-1,e,t,-n,r,s,5),this.setIndex(c),this.setAttribute("position",new vt(l,3)),this.setAttribute("normal",new vt(u,3)),this.setAttribute("uv",new vt(f,2));function v(S,p,h,L,C,g,E,T,A,I,y){const M=g/A,U=E/I,W=g/2,Z=E/2,te=T/2,ne=A+1,ee=I+1;let le=0,j=0;const ue=new B;for(let me=0;me<ee;me++){const be=me*U-Z;for(let Be=0;Be<ne;Be++){const de=Be*M-W;ue[S]=de*L,ue[p]=be*C,ue[h]=te,l.push(ue.x,ue.y,ue.z),ue[S]=0,ue[p]=0,ue[h]=T>0?1:-1,u.push(ue.x,ue.y,ue.z),f.push(Be/A),f.push(1-me/I),le+=1}}for(let me=0;me<I;me++)for(let be=0;be<A;be++){const Be=d+be+ne*me,de=d+be+ne*(me+1),je=d+(be+1)+ne*(me+1),Xe=d+(be+1)+ne*me;c.push(Be,de,Xe),c.push(de,je,Xe),j+=6}o.addGroup(m,j,y),m+=j,d+=le}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Fi(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function di(i){const e={};for(const t in i){e[t]={};for(const n in i[t]){const r=i[t][n];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][n]=null):e[t][n]=r.clone():Array.isArray(r)?e[t][n]=r.slice():e[t][n]=r}}return e}function Mt(i){const e={};for(let t=0;t<i.length;t++){const n=di(i[t]);for(const r in n)e[r]=n[r]}return e}function nh(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function Sl(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Ye.workingColorSpace}const ih={clone:di,merge:Mt};var rh=`void main() {
18
+ */const Xo="180",xi={ROTATE:0,DOLLY:1,PAN:2},_i={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Lc=0,ya=1,Ic=2,kl=1,Uc=2,_n=3,Dn=0,Ut=1,on=2,Cn=0,Mi=1,Sa=2,Ea=3,Ta=4,Nc=5,Wn=100,Oc=101,Fc=102,Bc=103,zc=104,Hc=200,kc=201,Gc=202,Vc=203,ks=204,Gs=205,Wc=206,Xc=207,Yc=208,qc=209,jc=210,Zc=211,$c=212,Kc=213,Qc=214,Vs=0,Ws=1,Xs=2,Si=3,Ys=4,qs=5,js=6,Zs=7,Gl=0,Jc=1,eh=2,Pn=0,th=1,nh=2,ih=3,rh=4,sh=5,oh=6,ah=7,Vl=300,Ei=301,Ti=302,$s=303,Ks=304,Kr=306,Qs=1e3,jn=1001,Js=1002,en=1003,lh=1004,ir=1005,an=1006,ss=1007,Zn=1008,hn=1009,Wl=1010,Xl=1011,Xi=1012,Yo=1013,$n=1014,gn=1015,Ki=1016,qo=1017,jo=1018,Yi=1020,Yl=35902,ql=35899,jl=1021,Zl=1022,Jt=1023,qi=1026,ji=1027,$l=1028,Zo=1029,Kl=1030,$o=1031,Ko=1033,Fr=33776,Br=33777,zr=33778,Hr=33779,eo=35840,to=35841,no=35842,io=35843,ro=36196,so=37492,oo=37496,ao=37808,lo=37809,co=37810,ho=37811,uo=37812,fo=37813,po=37814,mo=37815,_o=37816,go=37817,vo=37818,xo=37819,Mo=37820,yo=37821,So=36492,Eo=36494,To=36495,bo=36283,wo=36284,Ao=36285,Ro=36286,ch=3200,hh=3201,Ql=0,uh=1,Rn="",Xt="srgb",bi="srgb-linear",Xr="linear",Qe="srgb",ti=7680,ba=519,fh=512,dh=513,ph=514,Jl=515,mh=516,_h=517,gh=518,vh=519,wa=35044,Aa="300 es",ln=2e3,Yr=2001;class Jn{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const r=n[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 n=t[e.type];if(n!==void 0){e.target=this;const r=n.slice(0);for(let s=0,o=r.length;s<o;s++)r[s].call(this,e);e.target=null}}}const Et=["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"],Vi=Math.PI/180,Co=180/Math.PI;function Qi(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Et[i&255]+Et[i>>8&255]+Et[i>>16&255]+Et[i>>24&255]+"-"+Et[e&255]+Et[e>>8&255]+"-"+Et[e>>16&15|64]+Et[e>>24&255]+"-"+Et[t&63|128]+Et[t>>8&255]+"-"+Et[t>>16&255]+Et[t>>24&255]+Et[n&255]+Et[n>>8&255]+Et[n>>16&255]+Et[n>>24&255]).toLowerCase()}function Ge(i,e,t){return Math.max(e,Math.min(t,i))}function xh(i,e){return(i%e+e)%e}function os(i,e,t){return(1-t)*i+t*e}function Di(i,e){switch(e.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 Dt(i,e){switch(e.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 Mh={DEG2RAD:Vi};class Ue{constructor(e=0,t=0){Ue.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,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+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=Ge(this.x,e.x,t.x),this.y=Ge(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Ge(this.x,e,t),this.y=Ge(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ge(n,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 n=this.dot(e)/t;return Math.acos(Ge(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,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 n=Math.cos(t),r=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*n-o*r+e.x,this.y=s*r+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class St{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,s,o,a){let c=n[r+0],l=n[r+1],u=n[r+2],f=n[r+3];const d=s[o+0],m=s[o+1],g=s[o+2],y=s[o+3];if(a===0){e[t+0]=c,e[t+1]=l,e[t+2]=u,e[t+3]=f;return}if(a===1){e[t+0]=d,e[t+1]=m,e[t+2]=g,e[t+3]=y;return}if(f!==y||c!==d||l!==m||u!==g){let p=1-a;const h=c*d+l*m+u*g+f*y,w=h>=0?1:-1,b=1-h*h;if(b>Number.EPSILON){const T=Math.sqrt(b),E=Math.atan2(T,h*w);p=Math.sin(p*E)/T,a=Math.sin(a*E)/T}const _=a*w;if(c=c*p+d*_,l=l*p+m*_,u=u*p+g*_,f=f*p+y*_,p===1-a){const T=1/Math.sqrt(c*c+l*l+u*u+f*f);c*=T,l*=T,u*=T,f*=T}}e[t]=c,e[t+1]=l,e[t+2]=u,e[t+3]=f}static multiplyQuaternionsFlat(e,t,n,r,s,o){const a=n[r],c=n[r+1],l=n[r+2],u=n[r+3],f=s[o],d=s[o+1],m=s[o+2],g=s[o+3];return e[t]=a*g+u*f+c*m-l*d,e[t+1]=c*g+u*d+l*f-a*m,e[t+2]=l*g+u*m+a*d-c*f,e[t+3]=u*g-a*f-c*d-l*m,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,n,r){return this._x=e,this._y=t,this._z=n,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 n=e._x,r=e._y,s=e._z,o=e._order,a=Math.cos,c=Math.sin,l=a(n/2),u=a(r/2),f=a(s/2),d=c(n/2),m=c(r/2),g=c(s/2);switch(o){case"XYZ":this._x=d*u*f+l*m*g,this._y=l*m*f-d*u*g,this._z=l*u*g+d*m*f,this._w=l*u*f-d*m*g;break;case"YXZ":this._x=d*u*f+l*m*g,this._y=l*m*f-d*u*g,this._z=l*u*g-d*m*f,this._w=l*u*f+d*m*g;break;case"ZXY":this._x=d*u*f-l*m*g,this._y=l*m*f+d*u*g,this._z=l*u*g+d*m*f,this._w=l*u*f-d*m*g;break;case"ZYX":this._x=d*u*f-l*m*g,this._y=l*m*f+d*u*g,this._z=l*u*g-d*m*f,this._w=l*u*f+d*m*g;break;case"YZX":this._x=d*u*f+l*m*g,this._y=l*m*f+d*u*g,this._z=l*u*g-d*m*f,this._w=l*u*f-d*m*g;break;case"XZY":this._x=d*u*f-l*m*g,this._y=l*m*f-d*u*g,this._z=l*u*g+d*m*f,this._w=l*u*f+d*m*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],s=t[8],o=t[1],a=t[5],c=t[9],l=t[2],u=t[6],f=t[10],d=n+a+f;if(d>0){const m=.5/Math.sqrt(d+1);this._w=.25/m,this._x=(u-c)*m,this._y=(s-l)*m,this._z=(o-r)*m}else if(n>a&&n>f){const m=2*Math.sqrt(1+n-a-f);this._w=(u-c)/m,this._x=.25*m,this._y=(r+o)/m,this._z=(s+l)/m}else if(a>f){const m=2*Math.sqrt(1+a-n-f);this._w=(s-l)/m,this._x=(r+o)/m,this._y=.25*m,this._z=(c+u)/m}else{const m=2*Math.sqrt(1+f-n-a);this._w=(o-r)/m,this._x=(s+l)/m,this._y=(c+u)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(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=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ge(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const r=Math.min(1,t/n);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 n=e._x,r=e._y,s=e._z,o=e._w,a=t._x,c=t._y,l=t._z,u=t._w;return this._x=n*u+o*a+r*l-s*c,this._y=r*u+o*c+s*a-n*l,this._z=s*u+o*l+n*c-r*a,this._w=o*u-n*a-r*c-s*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,r=this._y,s=this._z,o=this._w;let a=o*e._w+n*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=n,this._y=r,this._z=s,this;const c=1-a*a;if(c<=Number.EPSILON){const m=1-t;return this._w=m*o+t*this._w,this._x=m*n+t*this._x,this._y=m*r+t*this._y,this._z=m*s+t*this._z,this.normalize(),this}const l=Math.sqrt(c),u=Math.atan2(l,a),f=Math.sin((1-t)*u)/l,d=Math.sin(t*u)/l;return this._w=o*f+this._w*d,this._x=n*f+this._x*d,this._y=r*f+this._y*d,this._z=s*f+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),s=Math.sqrt(n);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 U{constructor(e=0,t=0,n=0){U.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,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(Ra.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ra.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*r,this.y=s[1]*t+s[4]*n+s[7]*r,this.z=s[2]*t+s[5]*n+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=e.elements,o=1/(s[3]*t+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*r+s[12])*o,this.y=(s[1]*t+s[5]*n+s[9]*r+s[13])*o,this.z=(s[2]*t+s[6]*n+s[10]*r+s[14])*o,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,s=e.x,o=e.y,a=e.z,c=e.w,l=2*(o*r-a*n),u=2*(a*t-s*r),f=2*(s*n-o*t);return this.x=t+c*l+o*f-a*u,this.y=n+c*u+a*l-s*f,this.z=r+c*f+s*u-o*l,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,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*r,this.y=s[1]*t+s[5]*n+s[9]*r,this.z=s[2]*t+s[6]*n+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=Ge(this.x,e.x,t.x),this.y=Ge(this.y,e.y,t.y),this.z=Ge(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Ge(this.x,e,t),this.y=Ge(this.y,e,t),this.z=Ge(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ge(n,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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,s=e.z,o=t.x,a=t.y,c=t.z;return this.x=r*c-s*a,this.y=s*o-n*c,this.z=n*a-r*o,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return as.copy(this).projectOnVector(e),this.sub(as)}reflect(e){return this.sub(as.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 n=this.dot(e)/t;return Math.acos(Ge(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+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,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,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(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,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,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const as=new U,Ra=new St;class ze{constructor(e,t,n,r,s,o,a,c,l){ze.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,o,a,c,l)}set(e,t,n,r,s,o,a,c,l){const u=this.elements;return u[0]=e,u[1]=r,u[2]=a,u[3]=t,u[4]=s,u[5]=c,u[6]=n,u[7]=o,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.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 n=e.elements,r=t.elements,s=this.elements,o=n[0],a=n[3],c=n[6],l=n[1],u=n[4],f=n[7],d=n[2],m=n[5],g=n[8],y=r[0],p=r[3],h=r[6],w=r[1],b=r[4],_=r[7],T=r[2],E=r[5],A=r[8];return s[0]=o*y+a*w+c*T,s[3]=o*p+a*b+c*E,s[6]=o*h+a*_+c*A,s[1]=l*y+u*w+f*T,s[4]=l*p+u*b+f*E,s[7]=l*h+u*_+f*A,s[2]=d*y+m*w+g*T,s[5]=d*p+m*b+g*E,s[8]=d*h+m*_+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],n=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8];return t*o*u-t*a*l-n*s*u+n*a*c+r*s*l-r*o*c}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],f=u*o-a*l,d=a*c-u*s,m=l*s-o*c,g=t*f+n*d+r*m;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/g;return e[0]=f*y,e[1]=(r*l-u*n)*y,e[2]=(a*n-r*o)*y,e[3]=d*y,e[4]=(u*t-r*c)*y,e[5]=(r*s-a*t)*y,e[6]=m*y,e[7]=(n*c-l*t)*y,e[8]=(o*t-n*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,n,r,s,o,a){const c=Math.cos(s),l=Math.sin(s);return this.set(n*c,n*l,-n*(c*o+l*a)+o+e,-r*l,r*c,-r*(-l*o+c*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(ls.makeScale(e,t)),this}rotate(e){return this.premultiply(ls.makeRotation(-e)),this}translate(e,t){return this.premultiply(ls.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),n=Math.sin(e);return this.set(t,-n,0,n,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,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const ls=new ze;function ec(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function qr(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function yh(){const i=qr("canvas");return i.style.display="block",i}const Ca={};function Zi(i){i in Ca||(Ca[i]=!0,console.warn(i))}function Sh(i,e,t){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}const Pa=new ze().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Da=new ze().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Eh(){const i={enabled:!0,workingColorSpace:bi,spaces:{},convert:function(r,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===Qe&&(r.r=xn(r.r),r.g=xn(r.g),r.b=xn(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===Qe&&(r.r=yi(r.r),r.g=yi(r.g),r.b=yi(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===Rn?Xr: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 Zi("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return Zi("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(r,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[bi]:{primaries:e,whitePoint:n,transfer:Xr,toXYZ:Pa,fromXYZ:Da,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Xt},outputColorSpaceConfig:{drawingBufferColorSpace:Xt}},[Xt]:{primaries:e,whitePoint:n,transfer:Qe,toXYZ:Pa,fromXYZ:Da,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Xt}}}),i}const Ze=Eh();function xn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function yi(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let ni;class Th{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{ni===void 0&&(ni=qr("canvas")),ni.width=e.width,ni.height=e.height;const r=ni.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=ni}return n.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=qr("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),s=r.data;for(let o=0;o<s.length;o++)s[o]=xn(s[o]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(xn(t[n]/255)*255):t[n]=xn(t[n]);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 bh=0;class Qo{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:bh++}),this.uuid=Qi(),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 n={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(cs(r[o].image)):s.push(cs(r[o]))}else s=cs(r);n.url=s}return t||(e.images[this.uuid]=n),n}}function cs(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?Th.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let wh=0;const hs=new U;class Nt extends Jn{constructor(e=Nt.DEFAULT_IMAGE,t=Nt.DEFAULT_MAPPING,n=jn,r=jn,s=an,o=Zn,a=Jt,c=hn,l=Nt.DEFAULT_ANISOTROPY,u=Rn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:wh++}),this.uuid=Qi(),this.name="",this.source=new Qo(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=s,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=c,this.offset=new Ue(0,0),this.repeat=new Ue(1,1),this.center=new Ue(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ze,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(hs).x}get height(){return this.source.getSize(hs).y}get depth(){return this.source.getSize(hs).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 n=e[t];if(n===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&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={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&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Vl)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Qs:e.x=e.x-Math.floor(e.x);break;case jn:e.x=e.x<0?0:1;break;case Js: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 Qs:e.y=e.y-Math.floor(e.y);break;case jn:e.y=e.y<0?0:1;break;case Js: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++}}Nt.DEFAULT_IMAGE=null;Nt.DEFAULT_MAPPING=Vl;Nt.DEFAULT_ANISOTROPY=1;class ut{constructor(e=0,t=0,n=0,r=1){ut.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,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,n,r){return this.x=e,this.y=t,this.z=n,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,n=this.y,r=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*r+o[12]*s,this.y=o[1]*t+o[5]*n+o[9]*r+o[13]*s,this.z=o[2]*t+o[6]*n+o[10]*r+o[14]*s,this.w=o[3]*t+o[7]*n+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,n,r,s;const c=e.elements,l=c[0],u=c[4],f=c[8],d=c[1],m=c[5],g=c[9],y=c[2],p=c[6],h=c[10];if(Math.abs(u-d)<.01&&Math.abs(f-y)<.01&&Math.abs(g-p)<.01){if(Math.abs(u+d)<.1&&Math.abs(f+y)<.1&&Math.abs(g+p)<.1&&Math.abs(l+m+h-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const b=(l+1)/2,_=(m+1)/2,T=(h+1)/2,E=(u+d)/4,A=(f+y)/4,C=(g+p)/4;return b>_&&b>T?b<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(b),r=E/n,s=A/n):_>T?_<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(_),n=E/r,s=C/r):T<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(T),n=A/s,r=C/s),this.set(n,r,s,t),this}let w=Math.sqrt((p-g)*(p-g)+(f-y)*(f-y)+(d-u)*(d-u));return Math.abs(w)<.001&&(w=1),this.x=(p-g)/w,this.y=(f-y)/w,this.z=(d-u)/w,this.w=Math.acos((l+m+h-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=Ge(this.x,e.x,t.x),this.y=Ge(this.y,e.y,t.y),this.z=Ge(this.z,e.z,t.z),this.w=Ge(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Ge(this.x,e,t),this.y=Ge(this.y,e,t),this.z=Ge(this.z,e,t),this.w=Ge(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ge(n,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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,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 Ah extends Jn{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:an,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new ut(0,0,e,t),this.scissorTest=!1,this.viewport=new ut(0,0,e,t);const r={width:e,height:t,depth:n.depth},s=new Nt(r);this.textures=[];const o=n.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(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(e={}){const t={minFilter:an,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 n=0;n<this.textures.length;n++)this.textures[n].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,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;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=n,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,n=e.textures.length;t<n;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 Qo(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 Kn extends Ah{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class tc extends Nt{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=en,this.minFilter=en,this.wrapR=jn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Rh extends Nt{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=en,this.minFilter=en,this.wrapR=jn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ji{constructor(e=new U(1/0,1/0,1/0),t=new U(-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,n=e.length;t<n;t+=3)this.expandByPoint($t.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint($t.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=$t.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),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 n=e.geometry;if(n!==void 0){const s=n.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,$t):$t.fromBufferAttribute(s,o),$t.applyMatrix4(e.matrixWorld),this.expandByPoint($t);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),rr.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),rr.copy(n.boundingBox)),rr.applyMatrix4(e.matrixWorld),this.union(rr)}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,$t),$t.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Li),sr.subVectors(this.max,Li),ii.subVectors(e.a,Li),ri.subVectors(e.b,Li),si.subVectors(e.c,Li),Mn.subVectors(ri,ii),yn.subVectors(si,ri),Nn.subVectors(ii,si);let t=[0,-Mn.z,Mn.y,0,-yn.z,yn.y,0,-Nn.z,Nn.y,Mn.z,0,-Mn.x,yn.z,0,-yn.x,Nn.z,0,-Nn.x,-Mn.y,Mn.x,0,-yn.y,yn.x,0,-Nn.y,Nn.x,0];return!us(t,ii,ri,si,sr)||(t=[1,0,0,0,1,0,0,0,1],!us(t,ii,ri,si,sr))?!1:(or.crossVectors(Mn,yn),t=[or.x,or.y,or.z],us(t,ii,ri,si,sr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,$t).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize($t).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:(un[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),un[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),un[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),un[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),un[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),un[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),un[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),un[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(un),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 un=[new U,new U,new U,new U,new U,new U,new U,new U],$t=new U,rr=new Ji,ii=new U,ri=new U,si=new U,Mn=new U,yn=new U,Nn=new U,Li=new U,sr=new U,or=new U,On=new U;function us(i,e,t,n,r){for(let s=0,o=i.length-3;s<=o;s+=3){On.fromArray(i,s);const a=r.x*Math.abs(On.x)+r.y*Math.abs(On.y)+r.z*Math.abs(On.z),c=e.dot(On),l=t.dot(On),u=n.dot(On);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}const Ch=new Ji,Ii=new U,fs=new U;class Qr{constructor(e=new U,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 n=this.center;t!==void 0?n.copy(t):Ch.setFromPoints(e).getCenter(n);let r=0;for(let s=0,o=e.length;s<o;s++)r=Math.max(r,n.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 n=this.center.distanceToSquared(e);return t.copy(e),n>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;Ii.subVectors(e,this.center);const t=Ii.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(Ii,r/n),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):(fs.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ii.copy(e.center).add(fs)),this.expandByPoint(Ii.copy(e.center).sub(fs))),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 fn=new U,ds=new U,ar=new U,Sn=new U,ps=new U,lr=new U,ms=new U;class Jr{constructor(e=new U,t=new U(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,fn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=fn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(fn.copy(this.origin).addScaledVector(this.direction,t),fn.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){ds.copy(e).add(t).multiplyScalar(.5),ar.copy(t).sub(e).normalize(),Sn.copy(this.origin).sub(ds);const s=e.distanceTo(t)*.5,o=-this.direction.dot(ar),a=Sn.dot(this.direction),c=-Sn.dot(ar),l=Sn.lengthSq(),u=Math.abs(1-o*o);let f,d,m,g;if(u>0)if(f=o*c-a,d=o*a-c,g=s*u,f>=0)if(d>=-g)if(d<=g){const y=1/u;f*=y,d*=y,m=f*(f+o*d+2*a)+d*(o*f+d+2*c)+l}else d=s,f=Math.max(0,-(o*d+a)),m=-f*f+d*(d+2*c)+l;else d=-s,f=Math.max(0,-(o*d+a)),m=-f*f+d*(d+2*c)+l;else d<=-g?(f=Math.max(0,-(-o*s+a)),d=f>0?-s:Math.min(Math.max(-s,-c),s),m=-f*f+d*(d+2*c)+l):d<=g?(f=0,d=Math.min(Math.max(-s,-c),s),m=d*(d+2*c)+l):(f=Math.max(0,-(o*s+a)),d=f>0?s:Math.min(Math.max(-s,-c),s),m=-f*f+d*(d+2*c)+l);else d=o>0?-s:s,f=Math.max(0,-(o*d+a)),m=-f*f+d*(d+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,f),r&&r.copy(ds).addScaledVector(ar,d),m}intersectSphere(e,t){fn.subVectors(e.center,this.origin);const n=fn.dot(this.direction),r=fn.dot(fn)-n*n,s=e.radius*e.radius;if(r>s)return null;const o=Math.sqrt(s-r),a=n-o,c=n+o;return c<0?null:a<0?this.at(c,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 n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,s,o,a,c;const l=1/this.direction.x,u=1/this.direction.y,f=1/this.direction.z,d=this.origin;return l>=0?(n=(e.min.x-d.x)*l,r=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,r=(e.min.x-d.x)*l),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),n>o||s>r||((s>n||isNaN(n))&&(n=s),(o<r||isNaN(r))&&(r=o),f>=0?(a=(e.min.z-d.z)*f,c=(e.max.z-d.z)*f):(a=(e.max.z-d.z)*f,c=(e.min.z-d.z)*f),n>c||a>r)||((a>n||n!==n)&&(n=a),(c<r||r!==r)&&(r=c),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,fn)!==null}intersectTriangle(e,t,n,r,s){ps.subVectors(t,e),lr.subVectors(n,e),ms.crossVectors(ps,lr);let o=this.direction.dot(ms),a;if(o>0){if(r)return null;a=1}else if(o<0)a=-1,o=-o;else return null;Sn.subVectors(this.origin,e);const c=a*this.direction.dot(lr.crossVectors(Sn,lr));if(c<0)return null;const l=a*this.direction.dot(ps.cross(Sn));if(l<0||c+l>o)return null;const u=-a*Sn.dot(ms);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 ot{constructor(e,t,n,r,s,o,a,c,l,u,f,d,m,g,y,p){ot.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,n,r,s,o,a,c,l,u,f,d,m,g,y,p)}set(e,t,n,r,s,o,a,c,l,u,f,d,m,g,y,p){const h=this.elements;return h[0]=e,h[4]=t,h[8]=n,h[12]=r,h[1]=s,h[5]=o,h[9]=a,h[13]=c,h[2]=l,h[6]=u,h[10]=f,h[14]=d,h[3]=m,h[7]=g,h[11]=y,h[15]=p,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 ot().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[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,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,r=1/oi.setFromMatrixColumn(e,0).length(),s=1/oi.setFromMatrixColumn(e,1).length(),o=1/oi.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,s=e.z,o=Math.cos(n),a=Math.sin(n),c=Math.cos(r),l=Math.sin(r),u=Math.cos(s),f=Math.sin(s);if(e.order==="XYZ"){const d=o*u,m=o*f,g=a*u,y=a*f;t[0]=c*u,t[4]=-c*f,t[8]=l,t[1]=m+g*l,t[5]=d-y*l,t[9]=-a*c,t[2]=y-d*l,t[6]=g+m*l,t[10]=o*c}else if(e.order==="YXZ"){const d=c*u,m=c*f,g=l*u,y=l*f;t[0]=d+y*a,t[4]=g*a-m,t[8]=o*l,t[1]=o*f,t[5]=o*u,t[9]=-a,t[2]=m*a-g,t[6]=y+d*a,t[10]=o*c}else if(e.order==="ZXY"){const d=c*u,m=c*f,g=l*u,y=l*f;t[0]=d-y*a,t[4]=-o*f,t[8]=g+m*a,t[1]=m+g*a,t[5]=o*u,t[9]=y-d*a,t[2]=-o*l,t[6]=a,t[10]=o*c}else if(e.order==="ZYX"){const d=o*u,m=o*f,g=a*u,y=a*f;t[0]=c*u,t[4]=g*l-m,t[8]=d*l+y,t[1]=c*f,t[5]=y*l+d,t[9]=m*l-g,t[2]=-l,t[6]=a*c,t[10]=o*c}else if(e.order==="YZX"){const d=o*c,m=o*l,g=a*c,y=a*l;t[0]=c*u,t[4]=y-d*f,t[8]=g*f+m,t[1]=f,t[5]=o*u,t[9]=-a*u,t[2]=-l*u,t[6]=m*f+g,t[10]=d-y*f}else if(e.order==="XZY"){const d=o*c,m=o*l,g=a*c,y=a*l;t[0]=c*u,t[4]=-f,t[8]=l*u,t[1]=d*f+y,t[5]=o*u,t[9]=m*f-g,t[2]=g*f-m,t[6]=a*u,t[10]=y*f+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(Ph,e,Dh)}lookAt(e,t,n){const r=this.elements;return Bt.subVectors(e,t),Bt.lengthSq()===0&&(Bt.z=1),Bt.normalize(),En.crossVectors(n,Bt),En.lengthSq()===0&&(Math.abs(n.z)===1?Bt.x+=1e-4:Bt.z+=1e-4,Bt.normalize(),En.crossVectors(n,Bt)),En.normalize(),cr.crossVectors(Bt,En),r[0]=En.x,r[4]=cr.x,r[8]=Bt.x,r[1]=En.y,r[5]=cr.y,r[9]=Bt.y,r[2]=En.z,r[6]=cr.z,r[10]=Bt.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,o=n[0],a=n[4],c=n[8],l=n[12],u=n[1],f=n[5],d=n[9],m=n[13],g=n[2],y=n[6],p=n[10],h=n[14],w=n[3],b=n[7],_=n[11],T=n[15],E=r[0],A=r[4],C=r[8],M=r[12],x=r[1],N=r[5],z=r[9],q=r[13],j=r[2],Q=r[6],K=r[10],se=r[14],Z=r[3],le=r[7],pe=r[11],Me=r[15];return s[0]=o*E+a*x+c*j+l*Z,s[4]=o*A+a*N+c*Q+l*le,s[8]=o*C+a*z+c*K+l*pe,s[12]=o*M+a*q+c*se+l*Me,s[1]=u*E+f*x+d*j+m*Z,s[5]=u*A+f*N+d*Q+m*le,s[9]=u*C+f*z+d*K+m*pe,s[13]=u*M+f*q+d*se+m*Me,s[2]=g*E+y*x+p*j+h*Z,s[6]=g*A+y*N+p*Q+h*le,s[10]=g*C+y*z+p*K+h*pe,s[14]=g*M+y*q+p*se+h*Me,s[3]=w*E+b*x+_*j+T*Z,s[7]=w*A+b*N+_*Q+T*le,s[11]=w*C+b*z+_*K+T*pe,s[15]=w*M+b*q+_*se+T*Me,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],n=e[4],r=e[8],s=e[12],o=e[1],a=e[5],c=e[9],l=e[13],u=e[2],f=e[6],d=e[10],m=e[14],g=e[3],y=e[7],p=e[11],h=e[15];return g*(+s*c*f-r*l*f-s*a*d+n*l*d+r*a*m-n*c*m)+y*(+t*c*m-t*l*d+s*o*d-r*o*m+r*l*u-s*c*u)+p*(+t*l*f-t*a*m-s*o*f+n*o*m+s*a*u-n*l*u)+h*(-r*a*u-t*c*f+t*a*d+r*o*f-n*o*d+n*c*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,n){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]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],f=e[9],d=e[10],m=e[11],g=e[12],y=e[13],p=e[14],h=e[15],w=f*p*l-y*d*l+y*c*m-a*p*m-f*c*h+a*d*h,b=g*d*l-u*p*l-g*c*m+o*p*m+u*c*h-o*d*h,_=u*y*l-g*f*l+g*a*m-o*y*m-u*a*h+o*f*h,T=g*f*c-u*y*c-g*a*d+o*y*d+u*a*p-o*f*p,E=t*w+n*b+r*_+s*T;if(E===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const A=1/E;return e[0]=w*A,e[1]=(y*d*s-f*p*s-y*r*m+n*p*m+f*r*h-n*d*h)*A,e[2]=(a*p*s-y*c*s+y*r*l-n*p*l-a*r*h+n*c*h)*A,e[3]=(f*c*s-a*d*s-f*r*l+n*d*l+a*r*m-n*c*m)*A,e[4]=b*A,e[5]=(u*p*s-g*d*s+g*r*m-t*p*m-u*r*h+t*d*h)*A,e[6]=(g*c*s-o*p*s-g*r*l+t*p*l+o*r*h-t*c*h)*A,e[7]=(o*d*s-u*c*s+u*r*l-t*d*l-o*r*m+t*c*m)*A,e[8]=_*A,e[9]=(g*f*s-u*y*s-g*n*m+t*y*m+u*n*h-t*f*h)*A,e[10]=(o*y*s-g*a*s+g*n*l-t*y*l-o*n*h+t*a*h)*A,e[11]=(u*a*s-o*f*s-u*n*l+t*f*l+o*n*m-t*a*m)*A,e[12]=T*A,e[13]=(u*y*r-g*f*r+g*n*d-t*y*d-u*n*p+t*f*p)*A,e[14]=(g*a*r-o*y*r-g*n*c+t*y*c+o*n*p-t*a*p)*A,e[15]=(o*f*r-u*a*r+u*n*c-t*f*c-o*n*d+t*a*d)*A,this}scale(e){const t=this.elements,n=e.x,r=e.y,s=e.z;return t[0]*=n,t[4]*=r,t[8]*=s,t[1]*=n,t[5]*=r,t[9]*=s,t[2]*=n,t[6]*=r,t[10]*=s,t[3]*=n,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],n=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,n,r))}makeTranslation(e,t,n){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,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),r=Math.sin(t),s=1-n,o=e.x,a=e.y,c=e.z,l=s*o,u=s*a;return this.set(l*o+n,l*a-r*c,l*c+r*a,0,l*a+r*c,u*a+n,u*c-r*o,0,l*c-r*a,u*c+r*o,s*c*c+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,s,o){return this.set(1,n,s,0,e,1,o,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,s=t._x,o=t._y,a=t._z,c=t._w,l=s+s,u=o+o,f=a+a,d=s*l,m=s*u,g=s*f,y=o*u,p=o*f,h=a*f,w=c*l,b=c*u,_=c*f,T=n.x,E=n.y,A=n.z;return r[0]=(1-(y+h))*T,r[1]=(m+_)*T,r[2]=(g-b)*T,r[3]=0,r[4]=(m-_)*E,r[5]=(1-(d+h))*E,r[6]=(p+w)*E,r[7]=0,r[8]=(g+b)*A,r[9]=(p-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,n){const r=this.elements;let s=oi.set(r[0],r[1],r[2]).length();const o=oi.set(r[4],r[5],r[6]).length(),a=oi.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],Kt.copy(this);const l=1/s,u=1/o,f=1/a;return Kt.elements[0]*=l,Kt.elements[1]*=l,Kt.elements[2]*=l,Kt.elements[4]*=u,Kt.elements[5]*=u,Kt.elements[6]*=u,Kt.elements[8]*=f,Kt.elements[9]*=f,Kt.elements[10]*=f,t.setFromRotationMatrix(Kt),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,r,s,o,a=ln,c=!1){const l=this.elements,u=2*s/(t-e),f=2*s/(n-r),d=(t+e)/(t-e),m=(n+r)/(n-r);let g,y;if(c)g=s/(o-s),y=o*s/(o-s);else if(a===ln)g=-(o+s)/(o-s),y=-2*o*s/(o-s);else if(a===Yr)g=-o/(o-s),y=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=u,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=f,l[9]=m,l[13]=0,l[2]=0,l[6]=0,l[10]=g,l[14]=y,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,r,s,o,a=ln,c=!1){const l=this.elements,u=2/(t-e),f=2/(n-r),d=-(t+e)/(t-e),m=-(n+r)/(n-r);let g,y;if(c)g=1/(o-s),y=o/(o-s);else if(a===ln)g=-2/(o-s),y=-(o+s)/(o-s);else if(a===Yr)g=-1/(o-s),y=-s/(o-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=u,l[4]=0,l[8]=0,l[12]=d,l[1]=0,l[5]=f,l[9]=0,l[13]=m,l[2]=0,l[6]=0,l[10]=g,l[14]=y,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const oi=new U,Kt=new ot,Ph=new U(0,0,0),Dh=new U(1,1,1),En=new U,cr=new U,Bt=new U,La=new ot,Ia=new St;class tn{constructor(e=0,t=0,n=0,r=tn.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,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,n,r=this._order){return this._x=e,this._y=t,this._z=n,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,n=!0){const r=e.elements,s=r[0],o=r[4],a=r[8],c=r[1],l=r[5],u=r[9],f=r[2],d=r[6],m=r[10];switch(t){case"XYZ":this._y=Math.asin(Ge(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,m),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Ge(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,m),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(Ge(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Ge(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(d,m),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(Ge(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-f,s)):(this._x=0,this._y=Math.atan2(a,m));break;case"XZY":this._z=Math.asin(-Ge(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return La.makeRotationFromQuaternion(e),this.setFromRotationMatrix(La,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Ia.setFromEuler(this),this.setFromQuaternion(Ia,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}}tn.DEFAULT_ORDER="XYZ";class Jo{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 Lh=0;const Ua=new U,ai=new St,dn=new ot,hr=new U,Ui=new U,Ih=new U,Uh=new St,Na=new U(1,0,0),Oa=new U(0,1,0),Fa=new U(0,0,1),Ba={type:"added"},Nh={type:"removed"},li={type:"childadded",child:null},_s={type:"childremoved",child:null};class dt extends Jn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Lh++}),this.uuid=Qi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=dt.DEFAULT_UP.clone();const e=new U,t=new tn,n=new St,r=new U(1,1,1);function s(){n.setFromEuler(t,!1)}function o(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._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:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new ot},normalMatrix:{value:new ze}}),this.matrix=new ot,this.matrixWorld=new ot,this.matrixAutoUpdate=dt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=dt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Jo,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 ai.setFromAxisAngle(e,t),this.quaternion.multiply(ai),this}rotateOnWorldAxis(e,t){return ai.setFromAxisAngle(e,t),this.quaternion.premultiply(ai),this}rotateX(e){return this.rotateOnAxis(Na,e)}rotateY(e){return this.rotateOnAxis(Oa,e)}rotateZ(e){return this.rotateOnAxis(Fa,e)}translateOnAxis(e,t){return Ua.copy(e).applyQuaternion(this.quaternion),this.position.add(Ua.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Na,e)}translateY(e){return this.translateOnAxis(Oa,e)}translateZ(e){return this.translateOnAxis(Fa,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(dn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?hr.copy(e):hr.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),Ui.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?dn.lookAt(Ui,hr,this.up):dn.lookAt(hr,Ui,this.up),this.quaternion.setFromRotationMatrix(dn),r&&(dn.extractRotation(r.matrixWorld),ai.setFromRotationMatrix(dn),this.quaternion.premultiply(ai.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(Ba),li.child=e,this.dispatchEvent(li),li.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Nh),_s.child=e,this.dispatchEvent(_s),_s.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),dn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),dn.multiply(e.parent.matrixWorld)),e.applyMatrix4(dn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Ba),li.child=e,this.dispatchEvent(li),li.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 n=0,r=this.children.length;n<r;n++){const o=this.children[n].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ui,e,Ih),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ui,Uh,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 n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].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 n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){const n=this.parent;if(e===!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)),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",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.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,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(e)),c.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 c=a.shapes;if(Array.isArray(c))for(let l=0,u=c.length;l<u;l++){const f=c[l];s(e.shapes,f)}else s(e.shapes,c)}}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 c=0,l=this.material.length;c<l;c++)a.push(s(e.materials,this.material[c]));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 c=this.animations[a];r.animations.push(s(e.animations,c))}}if(t){const a=o(e.geometries),c=o(e.materials),l=o(e.textures),u=o(e.images),f=o(e.shapes),d=o(e.skeletons),m=o(e.animations),g=o(e.nodes);a.length>0&&(n.geometries=a),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),u.length>0&&(n.images=u),f.length>0&&(n.shapes=f),d.length>0&&(n.skeletons=d),m.length>0&&(n.animations=m),g.length>0&&(n.nodes=g)}return n.object=r,n;function o(a){const c=[];for(const l in a){const u=a[l];delete u.metadata,c.push(u)}return c}}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 n=0;n<e.children.length;n++){const r=e.children[n];this.add(r.clone())}return this}}dt.DEFAULT_UP=new U(0,1,0);dt.DEFAULT_MATRIX_AUTO_UPDATE=!0;dt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Qt=new U,pn=new U,gs=new U,mn=new U,ci=new U,hi=new U,za=new U,vs=new U,xs=new U,Ms=new U,ys=new ut,Ss=new ut,Es=new ut;class qt{constructor(e=new U,t=new U,n=new U){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),Qt.subVectors(e,t),r.cross(Qt);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,n,r,s){Qt.subVectors(r,t),pn.subVectors(n,t),gs.subVectors(e,t);const o=Qt.dot(Qt),a=Qt.dot(pn),c=Qt.dot(gs),l=pn.dot(pn),u=pn.dot(gs),f=o*l-a*a;if(f===0)return s.set(0,0,0),null;const d=1/f,m=(l*c-a*u)*d,g=(o*u-a*c)*d;return s.set(1-m-g,g,m)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,mn)===null?!1:mn.x>=0&&mn.y>=0&&mn.x+mn.y<=1}static getInterpolation(e,t,n,r,s,o,a,c){return this.getBarycoord(e,t,n,r,mn)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,mn.x),c.addScaledVector(o,mn.y),c.addScaledVector(a,mn.z),c)}static getInterpolatedAttribute(e,t,n,r,s,o){return ys.setScalar(0),Ss.setScalar(0),Es.setScalar(0),ys.fromBufferAttribute(e,t),Ss.fromBufferAttribute(e,n),Es.fromBufferAttribute(e,r),o.setScalar(0),o.addScaledVector(ys,s.x),o.addScaledVector(Ss,s.y),o.addScaledVector(Es,s.z),o}static isFrontFacing(e,t,n,r){return Qt.subVectors(n,t),pn.subVectors(e,t),Qt.cross(pn).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),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 Qt.subVectors(this.c,this.b),pn.subVectors(this.a,this.b),Qt.cross(pn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return qt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return qt.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,s){return qt.getInterpolation(e,this.a,this.b,this.c,t,n,r,s)}containsPoint(e){return qt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return qt.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,s=this.c;let o,a;ci.subVectors(r,n),hi.subVectors(s,n),vs.subVectors(e,n);const c=ci.dot(vs),l=hi.dot(vs);if(c<=0&&l<=0)return t.copy(n);xs.subVectors(e,r);const u=ci.dot(xs),f=hi.dot(xs);if(u>=0&&f<=u)return t.copy(r);const d=c*f-u*l;if(d<=0&&c>=0&&u<=0)return o=c/(c-u),t.copy(n).addScaledVector(ci,o);Ms.subVectors(e,s);const m=ci.dot(Ms),g=hi.dot(Ms);if(g>=0&&m<=g)return t.copy(s);const y=m*l-c*g;if(y<=0&&l>=0&&g<=0)return a=l/(l-g),t.copy(n).addScaledVector(hi,a);const p=u*g-m*f;if(p<=0&&f-u>=0&&m-g>=0)return za.subVectors(s,r),a=(f-u)/(f-u+(m-g)),t.copy(r).addScaledVector(za,a);const h=1/(p+y+d);return o=y*h,a=d*h,t.copy(n).addScaledVector(ci,o).addScaledVector(hi,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const nc={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},Tn={h:0,s:0,l:0},ur={h:0,s:0,l:0};function Ts(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}class We{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===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,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Xt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ze.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=Ze.workingColorSpace){return this.r=e,this.g=t,this.b=n,Ze.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=Ze.workingColorSpace){if(e=xh(e,1),t=Ge(t,0,1),n=Ge(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,o=2*n-s;this.r=Ts(o,s,e+1/3),this.g=Ts(o,s,e),this.b=Ts(o,s,e-1/3)}return Ze.colorSpaceToWorking(this,r),this}setStyle(e,t=Xt){function n(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 n(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 n(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 n(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=Xt){const n=nc[e.toLowerCase()];return n!==void 0?this.setHex(n,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=xn(e.r),this.g=xn(e.g),this.b=xn(e.b),this}copyLinearToSRGB(e){return this.r=yi(e.r),this.g=yi(e.g),this.b=yi(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Xt){return Ze.workingToColorSpace(Tt.copy(this),e),Math.round(Ge(Tt.r*255,0,255))*65536+Math.round(Ge(Tt.g*255,0,255))*256+Math.round(Ge(Tt.b*255,0,255))}getHexString(e=Xt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ze.workingColorSpace){Ze.workingToColorSpace(Tt.copy(this),t);const n=Tt.r,r=Tt.g,s=Tt.b,o=Math.max(n,r,s),a=Math.min(n,r,s);let c,l;const u=(a+o)/2;if(a===o)c=0,l=0;else{const f=o-a;switch(l=u<=.5?f/(o+a):f/(2-o-a),o){case n:c=(r-s)/f+(r<s?6:0);break;case r:c=(s-n)/f+2;break;case s:c=(n-r)/f+4;break}c/=6}return e.h=c,e.s=l,e.l=u,e}getRGB(e,t=Ze.workingColorSpace){return Ze.workingToColorSpace(Tt.copy(this),t),e.r=Tt.r,e.g=Tt.g,e.b=Tt.b,e}getStyle(e=Xt){Ze.workingToColorSpace(Tt.copy(this),e);const t=Tt.r,n=Tt.g,r=Tt.b;return e!==Xt?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(e,t,n){return this.getHSL(Tn),this.setHSL(Tn.h+e,Tn.s+t,Tn.l+n)}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,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Tn),e.getHSL(ur);const n=os(Tn.h,ur.h,t),r=os(Tn.s,ur.s,t),s=os(Tn.l,ur.l,t);return this.setHSL(n,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,n=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*r,this.g=s[1]*t+s[4]*n+s[7]*r,this.b=s[2]*t+s[5]*n+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 Tt=new We;We.NAMES=nc;let Oh=0;class Ai extends Jn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Oh++}),this.uuid=Qi(),this.name="",this.type="Material",this.blending=Mi,this.side=Dn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=ks,this.blendDst=Gs,this.blendEquation=Wn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new We(0,0,0),this.blendAlpha=0,this.depthFunc=Si,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=ba,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ti,this.stencilZFail=ti,this.stencilZPass=ti,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 n=e[t];if(n===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(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={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(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).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(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).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(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).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(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).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!==Mi&&(n.blending=this.blending),this.side!==Dn&&(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!==ks&&(n.blendSrc=this.blendSrc),this.blendDst!==Gs&&(n.blendDst=this.blendDst),this.blendEquation!==Wn&&(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!==Si&&(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!==ba&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ti&&(n.stencilFail=this.stencilFail),this.stencilZFail!==ti&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==ti&&(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 r(s){const o=[];for(const a in s){const c=s[a];delete c.metadata,o.push(c)}return o}if(t){const s=r(e.textures),o=r(e.images);s.length>0&&(n.textures=s),o.length>0&&(n.images=o)}return n}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 n=null;if(t!==null){const r=t.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,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 es extends Ai{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new We(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 tn,this.combine=Gl,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 pt=new U,fr=new Ue;let Fh=0;class cn{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Fh++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=wa,this.updateRanges=[],this.gpuType=gn,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,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)fr.fromBufferAttribute(this,t),fr.applyMatrix3(e),this.setXY(t,fr.x,fr.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)pt.fromBufferAttribute(this,t),pt.applyMatrix3(e),this.setXYZ(t,pt.x,pt.y,pt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)pt.fromBufferAttribute(this,t),pt.applyMatrix4(e),this.setXYZ(t,pt.x,pt.y,pt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)pt.fromBufferAttribute(this,t),pt.applyNormalMatrix(e),this.setXYZ(t,pt.x,pt.y,pt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)pt.fromBufferAttribute(this,t),pt.transformDirection(e),this.setXYZ(t,pt.x,pt.y,pt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=Di(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Dt(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Di(t,this.array)),t}setX(e,t){return this.normalized&&(t=Dt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Di(t,this.array)),t}setY(e,t){return this.normalized&&(t=Dt(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=Di(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Dt(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=Di(t,this.array)),t}setW(e,t){return this.normalized&&(t=Dt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Dt(t,this.array),n=Dt(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Dt(t,this.array),n=Dt(n,this.array),r=Dt(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e*=this.itemSize,this.normalized&&(t=Dt(t,this.array),n=Dt(n,this.array),r=Dt(r,this.array),s=Dt(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,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!==wa&&(e.usage=this.usage),e}}class ic extends cn{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class rc extends cn{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class $e extends cn{constructor(e,t,n){super(new Float32Array(e),t,n)}}let Bh=0;const Wt=new ot,bs=new dt,ui=new U,zt=new Ji,Ni=new Ji,yt=new U;class vt extends Jn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Bh++}),this.uuid=Qi(),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(ec(e)?rc:ic)(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,n=0){this.groups.push({start:e,count:t,materialIndex:n})}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 n=this.attributes.normal;if(n!==void 0){const s=new ze().getNormalMatrix(e);n.applyNormalMatrix(s),n.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 Wt.makeRotationFromQuaternion(e),this.applyMatrix4(Wt),this}rotateX(e){return Wt.makeRotationX(e),this.applyMatrix4(Wt),this}rotateY(e){return Wt.makeRotationY(e),this.applyMatrix4(Wt),this}rotateZ(e){return Wt.makeRotationZ(e),this.applyMatrix4(Wt),this}translate(e,t,n){return Wt.makeTranslation(e,t,n),this.applyMatrix4(Wt),this}scale(e,t,n){return Wt.makeScale(e,t,n),this.applyMatrix4(Wt),this}lookAt(e){return bs.lookAt(e),bs.updateMatrix(),this.applyMatrix4(bs.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ui).negate(),this.translate(ui.x,ui.y,ui.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let r=0,s=e.length;r<s;r++){const o=e[r];n.push(o.x,o.y,o.z||0)}this.setAttribute("position",new $e(n,3))}else{const n=Math.min(e.length,t.count);for(let r=0;r<n;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 Ji);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 U(-1/0,-1/0,-1/0),new U(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n<r;n++){const s=t[n];zt.setFromBufferAttribute(s),this.morphTargetsRelative?(yt.addVectors(this.boundingBox.min,zt.min),this.boundingBox.expandByPoint(yt),yt.addVectors(this.boundingBox.max,zt.max),this.boundingBox.expandByPoint(yt)):(this.boundingBox.expandByPoint(zt.min),this.boundingBox.expandByPoint(zt.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 Qr);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 U,1/0);return}if(e){const n=this.boundingSphere.center;if(zt.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){const a=t[s];Ni.setFromBufferAttribute(a),this.morphTargetsRelative?(yt.addVectors(zt.min,Ni.min),zt.expandByPoint(yt),yt.addVectors(zt.max,Ni.max),zt.expandByPoint(yt)):(zt.expandByPoint(Ni.min),zt.expandByPoint(Ni.max))}zt.getCenter(n);let r=0;for(let s=0,o=e.count;s<o;s++)yt.fromBufferAttribute(e,s),r=Math.max(r,n.distanceToSquared(yt));if(t)for(let s=0,o=t.length;s<o;s++){const a=t[s],c=this.morphTargetsRelative;for(let l=0,u=a.count;l<u;l++)yt.fromBufferAttribute(a,l),c&&(ui.fromBufferAttribute(e,l),yt.add(ui)),r=Math.max(r,n.distanceToSquared(yt))}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 n=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new cn(new Float32Array(4*n.count),4));const o=this.getAttribute("tangent"),a=[],c=[];for(let C=0;C<n.count;C++)a[C]=new U,c[C]=new U;const l=new U,u=new U,f=new U,d=new Ue,m=new Ue,g=new Ue,y=new U,p=new U;function h(C,M,x){l.fromBufferAttribute(n,C),u.fromBufferAttribute(n,M),f.fromBufferAttribute(n,x),d.fromBufferAttribute(s,C),m.fromBufferAttribute(s,M),g.fromBufferAttribute(s,x),u.sub(l),f.sub(l),m.sub(d),g.sub(d);const N=1/(m.x*g.y-g.x*m.y);isFinite(N)&&(y.copy(u).multiplyScalar(g.y).addScaledVector(f,-m.y).multiplyScalar(N),p.copy(f).multiplyScalar(m.x).addScaledVector(u,-g.x).multiplyScalar(N),a[C].add(y),a[M].add(y),a[x].add(y),c[C].add(p),c[M].add(p),c[x].add(p))}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 q=N,j=N+z;q<j;q+=3)h(e.getX(q+0),e.getX(q+1),e.getX(q+2))}const b=new U,_=new U,T=new U,E=new U;function A(C){T.fromBufferAttribute(r,C),E.copy(T);const M=a[C];b.copy(M),b.sub(T.multiplyScalar(T.dot(M))).normalize(),_.crossVectors(E,M);const N=_.dot(c[C])<0?-1:1;o.setXYZW(C,b.x,b.y,b.z,N)}for(let C=0,M=w.length;C<M;++C){const x=w[C],N=x.start,z=x.count;for(let q=N,j=N+z;q<j;q+=3)A(e.getX(q+0)),A(e.getX(q+1)),A(e.getX(q+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new cn(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,m=n.count;d<m;d++)n.setXYZ(d,0,0,0);const r=new U,s=new U,o=new U,a=new U,c=new U,l=new U,u=new U,f=new U;if(e)for(let d=0,m=e.count;d<m;d+=3){const g=e.getX(d+0),y=e.getX(d+1),p=e.getX(d+2);r.fromBufferAttribute(t,g),s.fromBufferAttribute(t,y),o.fromBufferAttribute(t,p),u.subVectors(o,s),f.subVectors(r,s),u.cross(f),a.fromBufferAttribute(n,g),c.fromBufferAttribute(n,y),l.fromBufferAttribute(n,p),a.add(u),c.add(u),l.add(u),n.setXYZ(g,a.x,a.y,a.z),n.setXYZ(y,c.x,c.y,c.z),n.setXYZ(p,l.x,l.y,l.z)}else for(let d=0,m=t.count;d<m;d+=3)r.fromBufferAttribute(t,d+0),s.fromBufferAttribute(t,d+1),o.fromBufferAttribute(t,d+2),u.subVectors(o,s),f.subVectors(r,s),u.cross(f),n.setXYZ(d+0,u.x,u.y,u.z),n.setXYZ(d+1,u.x,u.y,u.z),n.setXYZ(d+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)yt.fromBufferAttribute(e,t),yt.normalize(),e.setXYZ(t,yt.x,yt.y,yt.z)}toNonIndexed(){function e(a,c){const l=a.array,u=a.itemSize,f=a.normalized,d=new l.constructor(c.length*u);let m=0,g=0;for(let y=0,p=c.length;y<p;y++){a.isInterleavedBufferAttribute?m=c[y]*a.data.stride+a.offset:m=c[y]*u;for(let h=0;h<u;h++)d[g++]=l[m++]}return new cn(d,u,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new vt,n=this.index.array,r=this.attributes;for(const a in r){const c=r[a],l=e(c,n);t.setAttribute(a,l)}const s=this.morphAttributes;for(const a in s){const c=[],l=s[a];for(let u=0,f=l.length;u<f;u++){const d=l[u],m=e(d,n);c.push(m)}t.morphAttributes[a]=c}t.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,c=o.length;a<c;a++){const l=o[a];t.addGroup(l.start,l.count,l.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 c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);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 n=this.attributes;for(const c in n){const l=n[c];e.data.attributes[c]=l.toJSON(e.data)}const r={};let s=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],u=[];for(let f=0,d=l.length;f<d;f++){const m=l[f];u.push(m.toJSON(e.data))}u.length>0&&(r[c]=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 n=e.index;n!==null&&this.setIndex(n.clone());const r=e.attributes;for(const l in r){const u=r[l];this.setAttribute(l,u.clone(t))}const s=e.morphAttributes;for(const l in s){const u=[],f=s[l];for(let d=0,m=f.length;d<m;d++)u.push(f[d].clone(t));this.morphAttributes[l]=u}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let l=0,u=o.length;l<u;l++){const f=o[l];this.addGroup(f.start,f.count,f.materialIndex)}const a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Ha=new ot,Fn=new Jr,dr=new Qr,ka=new U,pr=new U,mr=new U,_r=new U,ws=new U,gr=new U,Ga=new U,vr=new U;class _e extends dt{constructor(e=new vt,t=new es){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,n=Object.keys(t);if(n.length>0){const r=t[n[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 n=this.geometry,r=n.attributes.position,s=n.morphAttributes.position,o=n.morphTargetsRelative;t.fromBufferAttribute(r,e);const a=this.morphTargetInfluences;if(s&&a){gr.set(0,0,0);for(let c=0,l=s.length;c<l;c++){const u=a[c],f=s[c];u!==0&&(ws.fromBufferAttribute(f,e),o?gr.addScaledVector(ws,u):gr.addScaledVector(ws.sub(t),u))}t.add(gr)}return t}raycast(e,t){const n=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),dr.copy(n.boundingSphere),dr.applyMatrix4(s),Fn.copy(e.ray).recast(e.near),!(dr.containsPoint(Fn.origin)===!1&&(Fn.intersectSphere(dr,ka)===null||Fn.origin.distanceToSquared(ka)>(e.far-e.near)**2))&&(Ha.copy(s).invert(),Fn.copy(e.ray).applyMatrix4(Ha),!(n.boundingBox!==null&&Fn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Fn)))}_computeIntersections(e,t,n){let r;const s=this.geometry,o=this.material,a=s.index,c=s.attributes.position,l=s.attributes.uv,u=s.attributes.uv1,f=s.attributes.normal,d=s.groups,m=s.drawRange;if(a!==null)if(Array.isArray(o))for(let g=0,y=d.length;g<y;g++){const p=d[g],h=o[p.materialIndex],w=Math.max(p.start,m.start),b=Math.min(a.count,Math.min(p.start+p.count,m.start+m.count));for(let _=w,T=b;_<T;_+=3){const E=a.getX(_),A=a.getX(_+1),C=a.getX(_+2);r=xr(this,h,e,n,l,u,f,E,A,C),r&&(r.faceIndex=Math.floor(_/3),r.face.materialIndex=p.materialIndex,t.push(r))}}else{const g=Math.max(0,m.start),y=Math.min(a.count,m.start+m.count);for(let p=g,h=y;p<h;p+=3){const w=a.getX(p),b=a.getX(p+1),_=a.getX(p+2);r=xr(this,o,e,n,l,u,f,w,b,_),r&&(r.faceIndex=Math.floor(p/3),t.push(r))}}else if(c!==void 0)if(Array.isArray(o))for(let g=0,y=d.length;g<y;g++){const p=d[g],h=o[p.materialIndex],w=Math.max(p.start,m.start),b=Math.min(c.count,Math.min(p.start+p.count,m.start+m.count));for(let _=w,T=b;_<T;_+=3){const E=_,A=_+1,C=_+2;r=xr(this,h,e,n,l,u,f,E,A,C),r&&(r.faceIndex=Math.floor(_/3),r.face.materialIndex=p.materialIndex,t.push(r))}}else{const g=Math.max(0,m.start),y=Math.min(c.count,m.start+m.count);for(let p=g,h=y;p<h;p+=3){const w=p,b=p+1,_=p+2;r=xr(this,o,e,n,l,u,f,w,b,_),r&&(r.faceIndex=Math.floor(p/3),t.push(r))}}}}function zh(i,e,t,n,r,s,o,a){let c;if(e.side===Ut?c=n.intersectTriangle(o,s,r,!0,a):c=n.intersectTriangle(r,s,o,e.side===Dn,a),c===null)return null;vr.copy(a),vr.applyMatrix4(i.matrixWorld);const l=t.ray.origin.distanceTo(vr);return l<t.near||l>t.far?null:{distance:l,point:vr.clone(),object:i}}function xr(i,e,t,n,r,s,o,a,c,l){i.getVertexPosition(a,pr),i.getVertexPosition(c,mr),i.getVertexPosition(l,_r);const u=zh(i,e,t,n,pr,mr,_r,Ga);if(u){const f=new U;qt.getBarycoord(Ga,pr,mr,_r,f),r&&(u.uv=qt.getInterpolatedAttribute(r,a,c,l,f,new Ue)),s&&(u.uv1=qt.getInterpolatedAttribute(s,a,c,l,f,new Ue)),o&&(u.normal=qt.getInterpolatedAttribute(o,a,c,l,f,new U),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));const d={a,b:c,c:l,normal:new U,materialIndex:0};qt.getNormal(pr,mr,_r,d.normal),u.face=d,u.barycoord=f}return u}class mt extends vt{constructor(e=1,t=1,n=1,r=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:s,depthSegments:o};const a=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o);const c=[],l=[],u=[],f=[];let d=0,m=0;g("z","y","x",-1,-1,n,t,e,o,s,0),g("z","y","x",1,-1,n,t,-e,o,s,1),g("x","z","y",1,1,e,n,t,r,o,2),g("x","z","y",1,-1,e,n,-t,r,o,3),g("x","y","z",1,-1,e,t,n,r,s,4),g("x","y","z",-1,-1,e,t,-n,r,s,5),this.setIndex(c),this.setAttribute("position",new $e(l,3)),this.setAttribute("normal",new $e(u,3)),this.setAttribute("uv",new $e(f,2));function g(y,p,h,w,b,_,T,E,A,C,M){const x=_/A,N=T/C,z=_/2,q=T/2,j=E/2,Q=A+1,K=C+1;let se=0,Z=0;const le=new U;for(let pe=0;pe<K;pe++){const Me=pe*N-q;for(let Ne=0;Ne<Q;Ne++){const fe=Ne*x-z;le[y]=fe*w,le[p]=Me*b,le[h]=j,l.push(le.x,le.y,le.z),le[y]=0,le[p]=0,le[h]=E>0?1:-1,u.push(le.x,le.y,le.z),f.push(Ne/A),f.push(1-pe/C),se+=1}}for(let pe=0;pe<C;pe++)for(let Me=0;Me<A;Me++){const Ne=d+Me+Q*pe,fe=d+Me+Q*(pe+1),Xe=d+(Me+1)+Q*(pe+1),qe=d+(Me+1)+Q*pe;c.push(Ne,fe,qe),c.push(fe,Xe,qe),Z+=6}a.addGroup(m,Z,M),m+=Z,d+=se}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new mt(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function wi(i){const e={};for(const t in i){e[t]={};for(const n in i[t]){const r=i[t][n];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][n]=null):e[t][n]=r.clone():Array.isArray(r)?e[t][n]=r.slice():e[t][n]=r}}return e}function Ct(i){const e={};for(let t=0;t<i.length;t++){const n=wi(i[t]);for(const r in n)e[r]=n[r]}return e}function Hh(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function sc(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Ze.workingColorSpace}const kh={clone:wi,merge:Ct};var Gh=`void main() {
19
19
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
20
- }`,sh=`void main() {
20
+ }`,Vh=`void main() {
21
21
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
22
- }`;class Sn extends pi{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=rh,this.fragmentShader=sh,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=di(e.uniforms),this.uniformsGroups=nh(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 a=this.uniforms[r].value;a&&a.isTexture?t.uniforms[r]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[r]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[r]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[r]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[r]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[r]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[r]={type:"m4",value:a.toArray()}:t.uniforms[r]={value:a}}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 n={};for(const r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class yl extends mt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new st,this.projectionMatrix=new st,this.projectionMatrixInverse=new st,this.coordinateSystem=jt,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 pn=new B,uo=new Fe,fo=new Fe;class Ot extends yl{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,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=sa*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(bi*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return sa*2*Math.atan(Math.tan(bi*.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,n){pn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(pn.x,pn.y).multiplyScalar(-e/pn.z),pn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(pn.x,pn.y).multiplyScalar(-e/pn.z)}getViewSize(e,t){return this.getViewBounds(e,uo,fo),t.subVectors(fo,uo)}setViewOffset(e,t,n,r,s,a){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=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(bi*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,s=-.5*r;const a=this.view;if(this.view!==null&&this.view.enabled){const c=a.fullWidth,l=a.fullHeight;s+=a.offsetX*r/c,t-=a.offsetY*n/l,r*=a.width/c,n*=a.height/l}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-n,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 ei=-90,ti=1;class ah extends mt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Ot(ei,ti,e,t);r.layers=this.layers,this.add(r);const s=new Ot(ei,ti,e,t);s.layers=this.layers,this.add(s);const a=new Ot(ei,ti,e,t);a.layers=this.layers,this.add(a);const o=new Ot(ei,ti,e,t);o.layers=this.layers,this.add(o);const c=new Ot(ei,ti,e,t);c.layers=this.layers,this.add(c);const l=new Ot(ei,ti,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,r,s,a,o,c]=t;for(const l of t)this.remove(l);if(e===jt)n.up.set(0,1,0),n.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),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Tr)n.up.set(0,-1,0),n.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),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,c,l,u]=this.children,f=e.getRenderTarget(),d=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),v=e.xr.enabled;e.xr.enabled=!1;const S=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,r),e.render(t,s),e.setRenderTarget(n,1,r),e.render(t,a),e.setRenderTarget(n,2,r),e.render(t,o),e.setRenderTarget(n,3,r),e.render(t,c),e.setRenderTarget(n,4,r),e.render(t,l),n.texture.generateMipmaps=S,e.setRenderTarget(n,5,r),e.render(t,u),e.setRenderTarget(f,d,m),e.xr.enabled=v,n.texture.needsPMREMUpdate=!0}}class El extends At{constructor(e=[],t=hi,n,r,s,a,o,c,l,u){super(e,t,n,r,s,a,o,c,l,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class oh extends Hn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new El(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 n={uniforms:{tEquirect:{value:null}},vertexShader:`
22
+ }`;class Ln extends Ai{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Gh,this.fragmentShader=Vh,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=wi(e.uniforms),this.uniformsGroups=Hh(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 n={};for(const r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class oc extends dt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ot,this.projectionMatrix=new ot,this.projectionMatrixInverse=new ot,this.coordinateSystem=ln,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 bn=new U,Va=new Ue,Wa=new Ue;class Yt extends oc{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,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=Co*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Vi*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Co*2*Math.atan(Math.tan(Vi*.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,n){bn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(bn.x,bn.y).multiplyScalar(-e/bn.z),bn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(bn.x,bn.y).multiplyScalar(-e/bn.z)}getViewSize(e,t){return this.getViewBounds(e,Va,Wa),t.subVectors(Wa,Va)}setViewOffset(e,t,n,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=n,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(Vi*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,s=-.5*r;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,l=o.fullHeight;s+=o.offsetX*r/c,t-=o.offsetY*n/l,r*=o.width/c,n*=o.height/l}const a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-n,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 fi=-90,di=1;class Wh extends dt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Yt(fi,di,e,t);r.layers=this.layers,this.add(r);const s=new Yt(fi,di,e,t);s.layers=this.layers,this.add(s);const o=new Yt(fi,di,e,t);o.layers=this.layers,this.add(o);const a=new Yt(fi,di,e,t);a.layers=this.layers,this.add(a);const c=new Yt(fi,di,e,t);c.layers=this.layers,this.add(c);const l=new Yt(fi,di,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,r,s,o,a,c]=t;for(const l of t)this.remove(l);if(e===ln)n.up.set(0,1,0),n.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),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Yr)n.up.set(0,-1,0),n.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),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,o,a,c,l,u]=this.children,f=e.getRenderTarget(),d=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const y=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,r),e.render(t,s),e.setRenderTarget(n,1,r),e.render(t,o),e.setRenderTarget(n,2,r),e.render(t,a),e.setRenderTarget(n,3,r),e.render(t,c),e.setRenderTarget(n,4,r),e.render(t,l),n.texture.generateMipmaps=y,e.setRenderTarget(n,5,r),e.render(t,u),e.setRenderTarget(f,d,m),e.xr.enabled=g,n.texture.needsPMREMUpdate=!0}}class ac extends Nt{constructor(e=[],t=Ei,n,r,s,o,a,c,l,u){super(e,t,n,r,s,o,a,c,l,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Xh extends Kn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new ac(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 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 Fi(5,5,5),s=new Sn({name:"CubemapFromEquirect",uniforms:di(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:bt,blending:gn});s.uniforms.tEquirect.value=t;const a=new Kt(r,s),o=t.minFilter;return t.minFilter===Fn&&(t.minFilter=Yt),new ah(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,r);e.setRenderTarget(s)}}class Ei extends mt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const lh={type:"move"};class ss{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ei,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 Ei,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new B,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new B),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ei,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new B,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new B),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 n of e.hand.values())this._getHandJoint(t,n)}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,n){let r=null,s=null,a=null;const o=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(const S of e.hand.values()){const p=t.getJointPose(S,n),h=this._getHandJoint(l,S);p!==null&&(h.matrix.fromArray(p.transform.matrix),h.matrix.decompose(h.position,h.rotation,h.scale),h.matrixWorldNeedsUpdate=!0,h.jointRadius=p.radius),h.visible=p!==null}const u=l.joints["index-finger-tip"],f=l.joints["thumb-tip"],d=u.position.distanceTo(f.position),m=.02,v=.005;l.inputState.pinching&&d>m+v?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&d<=m-v&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(lh)))}return o!==null&&(o.visible=r!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Ei;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class ch 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 Jt,this.environmentIntensity=1,this.environmentRotation=new Jt,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 as=new B,hh=new B,uh=new Oe;class mn{constructor(e=new B(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,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const r=as.subVectors(n,t).cross(hh.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 n=e.delta(as),r=this.normal.dot(n);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(n,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<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 n=t||uh.getNormalMatrix(e),r=this.coplanarPoint(as).applyMatrix4(e),s=this.normal.applyMatrix3(n).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 Rn=new Pr,fh=new Fe(.5,.5),ir=new B;class Aa{constructor(e=new mn,t=new mn,n=new mn,r=new mn,s=new mn,a=new mn){this.planes=[e,t,n,r,s,a]}set(e,t,n,r,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(s),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=jt,n=!1){const r=this.planes,s=e.elements,a=s[0],o=s[1],c=s[2],l=s[3],u=s[4],f=s[5],d=s[6],m=s[7],v=s[8],S=s[9],p=s[10],h=s[11],L=s[12],C=s[13],g=s[14],E=s[15];if(r[0].setComponents(l-a,m-u,h-v,E-L).normalize(),r[1].setComponents(l+a,m+u,h+v,E+L).normalize(),r[2].setComponents(l+o,m+f,h+S,E+C).normalize(),r[3].setComponents(l-o,m-f,h-S,E-C).normalize(),n)r[4].setComponents(c,d,p,g).normalize(),r[5].setComponents(l-c,m-d,h-p,E-g).normalize();else if(r[4].setComponents(l-c,m-d,h-p,E-g).normalize(),t===jt)r[5].setComponents(l+c,m+d,h+p,E+g).normalize();else if(t===Tr)r[5].setComponents(c,d,p,g).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(),Rn.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Rn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Rn)}intersectsSprite(e){Rn.center.set(0,0,0);const t=fh.distanceTo(e.center);return Rn.radius=.7071067811865476+t,Rn.applyMatrix4(e.matrixWorld),this.intersectsSphere(Rn)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const r=t[n];if(ir.x=r.normal.x>0?e.max.x:e.min.x,ir.y=r.normal.y>0?e.max.y:e.min.y,ir.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(ir)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Oi extends pi{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ge(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 Ar=new B,wr=new B,po=new st,yi=new Dr,rr=new Pr,os=new B,mo=new B;class Tl extends mt{constructor(e=new Dt,t=new Oi){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,n=[0];for(let r=1,s=t.count;r<s;r++)Ar.fromBufferAttribute(t,r-1),wr.fromBufferAttribute(t,r),n[r]=n[r-1],n[r]+=Ar.distanceTo(wr);e.setAttribute("lineDistance",new vt(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),rr.copy(n.boundingSphere),rr.applyMatrix4(r),rr.radius+=s,e.ray.intersectsSphere(rr)===!1)return;po.copy(r).invert(),yi.copy(e.ray).applyMatrix4(po);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=this.isLineSegments?2:1,u=n.index,d=n.attributes.position;if(u!==null){const m=Math.max(0,a.start),v=Math.min(u.count,a.start+a.count);for(let S=m,p=v-1;S<p;S+=l){const h=u.getX(S),L=u.getX(S+1),C=sr(this,e,yi,c,h,L,S);C&&t.push(C)}if(this.isLineLoop){const S=u.getX(v-1),p=u.getX(m),h=sr(this,e,yi,c,S,p,v-1);h&&t.push(h)}}else{const m=Math.max(0,a.start),v=Math.min(d.count,a.start+a.count);for(let S=m,p=v-1;S<p;S+=l){const h=sr(this,e,yi,c,S,S+1,S);h&&t.push(h)}if(this.isLineLoop){const S=sr(this,e,yi,c,v-1,m,v-1);S&&t.push(S)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function sr(i,e,t,n,r,s,a){const o=i.geometry.attributes.position;if(Ar.fromBufferAttribute(o,r),wr.fromBufferAttribute(o,s),t.distanceSqToSegment(Ar,wr,os,mo)>n)return;os.applyMatrix4(i.matrixWorld);const l=e.ray.origin.distanceTo(os);if(!(l<e.near||l>e.far))return{distance:l,point:mo.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}const _o=new B,go=new B;class wa extends Tl{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,n=[];for(let r=0,s=t.count;r<s;r+=2)_o.fromBufferAttribute(t,r),go.fromBufferAttribute(t,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+_o.distanceTo(go);e.setAttribute("lineDistance",new vt(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class bl extends At{constructor(e,t,n=Bn,r,s,a,o=Xt,c=Xt,l,u=Ci,f=1){if(u!==Ci&&u!==Pi)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:e,height:t,depth:f};super(d,r,s,a,o,c,u,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Ta(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 Al extends At{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}const ar=new B,or=new B,ls=new B,lr=new Bt;class dh extends Dt{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(bi*t),a=e.getIndex(),o=e.getAttribute("position"),c=a?a.count:o.count,l=[0,0,0],u=["a","b","c"],f=new Array(3),d={},m=[];for(let v=0;v<c;v+=3){a?(l[0]=a.getX(v),l[1]=a.getX(v+1),l[2]=a.getX(v+2)):(l[0]=v,l[1]=v+1,l[2]=v+2);const{a:S,b:p,c:h}=lr;if(S.fromBufferAttribute(o,l[0]),p.fromBufferAttribute(o,l[1]),h.fromBufferAttribute(o,l[2]),lr.getNormal(ls),f[0]=`${Math.round(S.x*r)},${Math.round(S.y*r)},${Math.round(S.z*r)}`,f[1]=`${Math.round(p.x*r)},${Math.round(p.y*r)},${Math.round(p.z*r)}`,f[2]=`${Math.round(h.x*r)},${Math.round(h.y*r)},${Math.round(h.z*r)}`,!(f[0]===f[1]||f[1]===f[2]||f[2]===f[0]))for(let L=0;L<3;L++){const C=(L+1)%3,g=f[L],E=f[C],T=lr[u[L]],A=lr[u[C]],I=`${g}_${E}`,y=`${E}_${g}`;y in d&&d[y]?(ls.dot(d[y].normal)<=s&&(m.push(T.x,T.y,T.z),m.push(A.x,A.y,A.z)),d[y]=null):I in d||(d[I]={index0:l[L],index1:l[C],normal:ls.clone()})}}for(const v in d)if(d[v]){const{index0:S,index1:p}=d[v];ar.fromBufferAttribute(o,S),or.fromBufferAttribute(o,p),m.push(ar.x,ar.y,ar.z),m.push(or.x,or.y,or.z)}this.setAttribute("position",new vt(m,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class Lr extends Dt{constructor(e=1,t=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};const s=e/2,a=t/2,o=Math.floor(n),c=Math.floor(r),l=o+1,u=c+1,f=e/o,d=t/c,m=[],v=[],S=[],p=[];for(let h=0;h<u;h++){const L=h*d-a;for(let C=0;C<l;C++){const g=C*f-s;v.push(g,-L,0),S.push(0,0,1),p.push(C/o),p.push(1-h/c)}}for(let h=0;h<c;h++)for(let L=0;L<o;L++){const C=L+l*h,g=L+l*(h+1),E=L+1+l*(h+1),T=L+1+l*h;m.push(C,g,T),m.push(g,E,T)}this.setIndex(m),this.setAttribute("position",new vt(v,3)),this.setAttribute("normal",new vt(S,3)),this.setAttribute("uv",new vt(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Lr(e.width,e.height,e.widthSegments,e.heightSegments)}}class ph extends Dt{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],n=new Set,r=new B,s=new B;if(e.index!==null){const a=e.attributes.position,o=e.index;let c=e.groups;c.length===0&&(c=[{start:0,count:o.count,materialIndex:0}]);for(let l=0,u=c.length;l<u;++l){const f=c[l],d=f.start,m=f.count;for(let v=d,S=d+m;v<S;v+=3)for(let p=0;p<3;p++){const h=o.getX(v+p),L=o.getX(v+(p+1)%3);r.fromBufferAttribute(a,h),s.fromBufferAttribute(a,L),vo(r,s,n)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}}else{const a=e.attributes.position;for(let o=0,c=a.count/3;o<c;o++)for(let l=0;l<3;l++){const u=3*o+l,f=3*o+(l+1)%3;r.fromBufferAttribute(a,u),s.fromBufferAttribute(a,f),vo(r,s,n)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new vt(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function vo(i,e,t){const n=`${i.x},${i.y},${i.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${i.x},${i.y},${i.z}`;return t.has(n)===!0||t.has(r)===!0?!1:(t.add(n),t.add(r),!0)}class mh extends pi{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Ge(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 Ge(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=dl,this.normalScale=new Fe(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 Jt,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 _h extends pi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=bc,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 gh extends pi{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 Ra extends mt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ge(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 vh extends Ra{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(mt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ge(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const cs=new st,xo=new B,Mo=new B;class xh{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Fe(512,512),this.mapType=Zt,this.map=null,this.mapPass=null,this.matrix=new st,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Aa,this._frameExtents=new Fe(1,1),this._viewportCount=1,this._viewports=[new ot(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;xo.setFromMatrixPosition(e.matrixWorld),t.position.copy(xo),Mo.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Mo),t.updateMatrixWorld(),cs.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(cs,t.coordinateSystem,t.reversedDepth),t.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(cs)}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 wl extends yl{constructor(e=-1,t=1,n=1,r=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=s,this.far=a,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,n,r,s,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=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,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),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=n-e,a=n+e,o=r+t,c=r-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,a=s+l*this.view.width,o-=u*this.view.offsetY,c=o-u*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,c,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 Mh extends xh{constructor(){super(new wl(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Sh extends Ra{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 Mh}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class yh extends Ra{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Eh extends Ot{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const So=new st;class Th{constructor(e,t,n=0,r=1/0){this.ray=new Dr(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new ba,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 So.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(So),this}intersectObject(e,t=!0,n=[]){return aa(e,this,n,t),n.sort(yo),n}intersectObjects(e,t=!0,n=[]){for(let r=0,s=e.length;r<s;r++)aa(e[r],this,n,t);return n.sort(yo),n}}function yo(i,e){return i.distance-e.distance}function aa(i,e,t,n){let r=!0;if(i.layers.test(e.layers)&&i.raycast(e,t)===!1&&(r=!1),r===!0&&n===!0){const s=i.children;for(let a=0,o=s.length;a<o;a++)aa(s[a],e,t,!0)}}class Eo{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=ke(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(ke(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class bh extends wa{constructor(e=10,t=10,n=4473924,r=8947848){n=new Ge(n),r=new Ge(r);const s=t/2,a=e/t,o=e/2,c=[],l=[];for(let d=0,m=0,v=-o;d<=t;d++,v+=a){c.push(-o,0,v,o,0,v),c.push(v,0,-o,v,0,o);const S=d===s?n:r;S.toArray(l,m),m+=3,S.toArray(l,m),m+=3,S.toArray(l,m),m+=3,S.toArray(l,m),m+=3}const u=new Dt;u.setAttribute("position",new vt(c,3)),u.setAttribute("color",new vt(l,3));const f=new Oi({vertexColors:!0,toneMapped:!1});super(u,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class Ah extends kn{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 To(i,e,t,n){const r=wh(n);switch(t){case cl:return i*e;case ul:return i*e/r.components*r.byteLength;case Sa:return i*e/r.components*r.byteLength;case fl:return i*e*2/r.components*r.byteLength;case ya:return i*e*2/r.components*r.byteLength;case hl:return i*e*3/r.components*r.byteLength;case Wt:return i*e*4/r.components*r.byteLength;case Ea:return i*e*4/r.components*r.byteLength;case _r:case gr:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case vr:case xr:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Ls:case Us:return Math.max(i,16)*Math.max(e,8)/4;case Ds:case Is:return Math.max(i,8)*Math.max(e,8)/2;case Ns:case Fs:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Os:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Bs:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case zs:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case Hs:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case ks:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case Vs:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case Gs:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case Ws:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case Xs:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case qs:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case Ys:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case js:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case Ks:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case $s:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case Zs:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case Js:case Qs:case ea:return Math.ceil(i/4)*Math.ceil(e/4)*16;case ta:case na:return Math.ceil(i/4)*Math.ceil(e/4)*8;case ia:case ra:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function wh(i){switch(i){case Zt:case sl:return{byteLength:1,components:1};case wi:case al:case Ii:return{byteLength:2,components:1};case xa:case Ma:return{byteLength:2,components:4};case Bn:case va:case on:return{byteLength:4,components:1};case ol:case ll:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:ga}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=ga);/**
57
+ `},r=new mt(5,5,5),s=new Ln({name:"CubemapFromEquirect",uniforms:wi(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Ut,blending:Cn});s.uniforms.tEquirect.value=t;const o=new _e(r,s),a=t.minFilter;return t.minFilter===Zn&&(t.minFilter=an),new Wh(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){const s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,r);e.setRenderTarget(s)}}class zi extends dt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Yh={type:"move"};class As{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new zi,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 zi,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new U,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new U),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new zi,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new U,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new U),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 n of e.hand.values())this._getHandJoint(t,n)}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,n){let r=null,s=null,o=null;const a=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){o=!0;for(const y of e.hand.values()){const p=t.getJointPose(y,n),h=this._getHandJoint(l,y);p!==null&&(h.matrix.fromArray(p.transform.matrix),h.matrix.decompose(h.position,h.rotation,h.scale),h.matrixWorldNeedsUpdate=!0,h.jointRadius=p.radius),h.visible=p!==null}const u=l.joints["index-finger-tip"],f=l.joints["thumb-tip"],d=u.position.distanceTo(f.position),m=.02,g=.005;l.inputState.pinching&&d>m+g?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&d<=m-g&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));a!==null&&(r=t.getPose(e.targetRaySpace,n),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(Yh)))}return a!==null&&(a.visible=r!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new zi;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class qh extends dt{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 tn,this.environmentIntensity=1,this.environmentRotation=new tn,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 Rs=new U,jh=new U,Zh=new ze;class An{constructor(e=new U(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,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const r=Rs.subVectors(n,t).cross(jh.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 n=e.delta(Rs),r=this.normal.dot(n);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(n,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<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 n=t||Zh.getNormalMatrix(e),r=this.coplanarPoint(Rs).applyMatrix4(e),s=this.normal.applyMatrix3(n).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 Bn=new Qr,$h=new Ue(.5,.5),Mr=new U;class ea{constructor(e=new An,t=new An,n=new An,r=new An,s=new An,o=new An){this.planes=[e,t,n,r,s,o]}set(e,t,n,r,s,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(r),a[4].copy(s),a[5].copy(o),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=ln,n=!1){const r=this.planes,s=e.elements,o=s[0],a=s[1],c=s[2],l=s[3],u=s[4],f=s[5],d=s[6],m=s[7],g=s[8],y=s[9],p=s[10],h=s[11],w=s[12],b=s[13],_=s[14],T=s[15];if(r[0].setComponents(l-o,m-u,h-g,T-w).normalize(),r[1].setComponents(l+o,m+u,h+g,T+w).normalize(),r[2].setComponents(l+a,m+f,h+y,T+b).normalize(),r[3].setComponents(l-a,m-f,h-y,T-b).normalize(),n)r[4].setComponents(c,d,p,_).normalize(),r[5].setComponents(l-c,m-d,h-p,T-_).normalize();else if(r[4].setComponents(l-c,m-d,h-p,T-_).normalize(),t===ln)r[5].setComponents(l+c,m+d,h+p,T+_).normalize();else if(t===Yr)r[5].setComponents(c,d,p,_).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(),Bn.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Bn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Bn)}intersectsSprite(e){Bn.center.set(0,0,0);const t=$h.distanceTo(e.center);return Bn.radius=.7071067811865476+t,Bn.applyMatrix4(e.matrixWorld),this.intersectsSphere(Bn)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const r=t[n];if(Mr.x=r.normal.x>0?e.max.x:e.min.x,Mr.y=r.normal.y>0?e.max.y:e.min.y,Mr.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Mr)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Ri extends Ai{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new We(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 jr=new U,Zr=new U,Xa=new ot,Oi=new Jr,yr=new Qr,Cs=new U,Ya=new U;class rn extends dt{constructor(e=new vt,t=new Ri){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,n=[0];for(let r=1,s=t.count;r<s;r++)jr.fromBufferAttribute(t,r-1),Zr.fromBufferAttribute(t,r),n[r]=n[r-1],n[r]+=jr.distanceTo(Zr);e.setAttribute("lineDistance",new $e(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),yr.copy(n.boundingSphere),yr.applyMatrix4(r),yr.radius+=s,e.ray.intersectsSphere(yr)===!1)return;Xa.copy(r).invert(),Oi.copy(e.ray).applyMatrix4(Xa);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=this.isLineSegments?2:1,u=n.index,d=n.attributes.position;if(u!==null){const m=Math.max(0,o.start),g=Math.min(u.count,o.start+o.count);for(let y=m,p=g-1;y<p;y+=l){const h=u.getX(y),w=u.getX(y+1),b=Sr(this,e,Oi,c,h,w,y);b&&t.push(b)}if(this.isLineLoop){const y=u.getX(g-1),p=u.getX(m),h=Sr(this,e,Oi,c,y,p,g-1);h&&t.push(h)}}else{const m=Math.max(0,o.start),g=Math.min(d.count,o.start+o.count);for(let y=m,p=g-1;y<p;y+=l){const h=Sr(this,e,Oi,c,y,y+1,y);h&&t.push(h)}if(this.isLineLoop){const y=Sr(this,e,Oi,c,g-1,m,g-1);y&&t.push(y)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[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 Sr(i,e,t,n,r,s,o){const a=i.geometry.attributes.position;if(jr.fromBufferAttribute(a,r),Zr.fromBufferAttribute(a,s),t.distanceSqToSegment(jr,Zr,Cs,Ya)>n)return;Cs.applyMatrix4(i.matrixWorld);const l=e.ray.origin.distanceTo(Cs);if(!(l<e.near||l>e.far))return{distance:l,point:Ya.clone().applyMatrix4(i.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:i}}const qa=new U,ja=new U;class ta extends rn{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,n=[];for(let r=0,s=t.count;r<s;r+=2)qa.fromBufferAttribute(t,r),ja.fromBufferAttribute(t,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+qa.distanceTo(ja);e.setAttribute("lineDistance",new $e(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class lc extends Nt{constructor(e,t,n=$n,r,s,o,a=en,c=en,l,u=qi,f=1){if(u!==qi&&u!==ji)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:e,height:t,depth:f};super(d,r,s,o,a,c,u,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Qo(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 cc extends Nt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class bt extends vt{constructor(e=1,t=1,n=1,r=32,s=1,o=!1,a=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:c};const l=this;r=Math.floor(r),s=Math.floor(s);const u=[],f=[],d=[],m=[];let g=0;const y=[],p=n/2;let h=0;w(),o===!1&&(e>0&&b(!0),t>0&&b(!1)),this.setIndex(u),this.setAttribute("position",new $e(f,3)),this.setAttribute("normal",new $e(d,3)),this.setAttribute("uv",new $e(m,2));function w(){const _=new U,T=new U;let E=0;const A=(t-e)/n;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 q=z/r,j=q*c+a,Q=Math.sin(j),K=Math.cos(j);T.x=N*Q,T.y=-x*n+p,T.z=N*K,f.push(T.x,T.y,T.z),_.set(Q,A,K).normalize(),d.push(_.x,_.y,_.z),m.push(q,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],q=y[M][C+1];(e>0||M!==0)&&(u.push(x,N,q),E+=3),(t>0||M!==s-1)&&(u.push(N,z,q),E+=3)}l.addGroup(h,E,0),h+=E}function b(_){const T=g,E=new Ue,A=new U;let C=0;const M=_===!0?e:t,x=_===!0?1:-1;for(let z=1;z<=r;z++)f.push(0,p*x,0),d.push(0,x,0),m.push(.5,.5),g++;const N=g;for(let z=0;z<=r;z++){const j=z/r*c+a,Q=Math.cos(j),K=Math.sin(j);A.x=M*K,A.y=p*x,A.z=M*Q,f.push(A.x,A.y,A.z),d.push(0,x,0),E.x=Q*.5+.5,E.y=K*.5*x+.5,m.push(E.x,E.y),g++}for(let z=0;z<r;z++){const q=T+z,j=N+z;_===!0?u.push(j,j+1,q):u.push(j+1,j,q),C+=3}l.addGroup(h,C,_===!0?1:2),h+=C}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new bt(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class na extends vt{constructor(e=[],t=[],n=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:r};const s=[],o=[];a(r),l(n),u(),this.setAttribute("position",new $e(s,3)),this.setAttribute("normal",new $e(s.slice(),3)),this.setAttribute("uv",new $e(o,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(w){const b=new U,_=new U,T=new U;for(let E=0;E<t.length;E+=3)m(t[E+0],b),m(t[E+1],_),m(t[E+2],T),c(b,_,T,w)}function c(w,b,_,T){const E=T+1,A=[];for(let C=0;C<=E;C++){A[C]=[];const M=w.clone().lerp(_,C/E),x=b.clone().lerp(_,C/E),N=E-C;for(let z=0;z<=N;z++)z===0&&C===E?A[C][z]=M:A[C][z]=M.clone().lerp(x,z/N)}for(let C=0;C<E;C++)for(let M=0;M<2*(E-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 l(w){const b=new U;for(let _=0;_<s.length;_+=3)b.x=s[_+0],b.y=s[_+1],b.z=s[_+2],b.normalize().multiplyScalar(w),s[_+0]=b.x,s[_+1]=b.y,s[_+2]=b.z}function u(){const w=new U;for(let b=0;b<s.length;b+=3){w.x=s[b+0],w.y=s[b+1],w.z=s[b+2];const _=p(w)/2/Math.PI+.5,T=h(w)/Math.PI+.5;o.push(_,1-T)}g(),f()}function f(){for(let w=0;w<o.length;w+=6){const b=o[w+0],_=o[w+2],T=o[w+4],E=Math.max(b,_,T),A=Math.min(b,_,T);E>.9&&A<.1&&(b<.2&&(o[w+0]+=1),_<.2&&(o[w+2]+=1),T<.2&&(o[w+4]+=1))}}function d(w){s.push(w.x,w.y,w.z)}function m(w,b){const _=w*3;b.x=e[_+0],b.y=e[_+1],b.z=e[_+2]}function g(){const w=new U,b=new U,_=new U,T=new U,E=new Ue,A=new Ue,C=new Ue;for(let M=0,x=0;M<s.length;M+=9,x+=6){w.set(s[M+0],s[M+1],s[M+2]),b.set(s[M+3],s[M+4],s[M+5]),_.set(s[M+6],s[M+7],s[M+8]),E.set(o[x+0],o[x+1]),A.set(o[x+2],o[x+3]),C.set(o[x+4],o[x+5]),T.copy(w).add(b).add(_).divideScalar(3);const N=p(T);y(E,x+0,w,N),y(A,x+2,b,N),y(C,x+4,_,N)}}function y(w,b,_,T){T<0&&w.x===1&&(o[b]=w.x-1),_.x===0&&_.z===0&&(o[b]=T/2/Math.PI+.5)}function p(w){return Math.atan2(w.z,-w.x)}function h(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 na(e.vertices,e.indices,e.radius,e.details)}}const Er=new U,Tr=new U,Ps=new U,br=new qt;class Kh extends vt{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(Vi*t),o=e.getIndex(),a=e.getAttribute("position"),c=o?o.count:a.count,l=[0,0,0],u=["a","b","c"],f=new Array(3),d={},m=[];for(let g=0;g<c;g+=3){o?(l[0]=o.getX(g),l[1]=o.getX(g+1),l[2]=o.getX(g+2)):(l[0]=g,l[1]=g+1,l[2]=g+2);const{a:y,b:p,c:h}=br;if(y.fromBufferAttribute(a,l[0]),p.fromBufferAttribute(a,l[1]),h.fromBufferAttribute(a,l[2]),br.getNormal(Ps),f[0]=`${Math.round(y.x*r)},${Math.round(y.y*r)},${Math.round(y.z*r)}`,f[1]=`${Math.round(p.x*r)},${Math.round(p.y*r)},${Math.round(p.z*r)}`,f[2]=`${Math.round(h.x*r)},${Math.round(h.y*r)},${Math.round(h.z*r)}`,!(f[0]===f[1]||f[1]===f[2]||f[2]===f[0]))for(let w=0;w<3;w++){const b=(w+1)%3,_=f[w],T=f[b],E=br[u[w]],A=br[u[b]],C=`${_}_${T}`,M=`${T}_${_}`;M in d&&d[M]?(Ps.dot(d[M].normal)<=s&&(m.push(E.x,E.y,E.z),m.push(A.x,A.y,A.z)),d[M]=null):C in d||(d[C]={index0:l[w],index1:l[b],normal:Ps.clone()})}}for(const g in d)if(d[g]){const{index0:y,index1:p}=d[g];Er.fromBufferAttribute(a,y),Tr.fromBufferAttribute(a,p),m.push(Er.x,Er.y,Er.z),m.push(Tr.x,Tr.y,Tr.z)}this.setAttribute("position",new $e(m,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class gi extends na{constructor(e=1,t=0){const n=[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(n,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new gi(e.radius,e.detail)}}class er extends vt{constructor(e=1,t=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};const s=e/2,o=t/2,a=Math.floor(n),c=Math.floor(r),l=a+1,u=c+1,f=e/a,d=t/c,m=[],g=[],y=[],p=[];for(let h=0;h<u;h++){const w=h*d-o;for(let b=0;b<l;b++){const _=b*f-s;g.push(_,-w,0),y.push(0,0,1),p.push(b/a),p.push(1-h/c)}}for(let h=0;h<c;h++)for(let w=0;w<a;w++){const b=w+l*h,_=w+l*(h+1),T=w+1+l*(h+1),E=w+1+l*h;m.push(b,_,E),m.push(_,T,E)}this.setIndex(m),this.setAttribute("position",new $e(g,3)),this.setAttribute("normal",new $e(y,3)),this.setAttribute("uv",new $e(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new er(e.width,e.height,e.widthSegments,e.heightSegments)}}class ia extends vt{constructor(e=1,t=32,n=16,r=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:s,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const c=Math.min(o+a,Math.PI);let l=0;const u=[],f=new U,d=new U,m=[],g=[],y=[],p=[];for(let h=0;h<=n;h++){const w=[],b=h/n;let _=0;h===0&&o===0?_=.5/t:h===n&&c===Math.PI&&(_=-.5/t);for(let T=0;T<=t;T++){const E=T/t;f.x=-e*Math.cos(r+E*s)*Math.sin(o+b*a),f.y=e*Math.cos(o+b*a),f.z=e*Math.sin(r+E*s)*Math.sin(o+b*a),g.push(f.x,f.y,f.z),d.copy(f).normalize(),y.push(d.x,d.y,d.z),p.push(E+_,1-b),w.push(l++)}u.push(w)}for(let h=0;h<n;h++)for(let w=0;w<t;w++){const b=u[h][w+1],_=u[h][w],T=u[h+1][w],E=u[h+1][w+1];(h!==0||o>0)&&m.push(b,_,E),(h!==n-1||c<Math.PI)&&m.push(_,T,E)}this.setIndex(m),this.setAttribute("position",new $e(g,3)),this.setAttribute("normal",new $e(y,3)),this.setAttribute("uv",new $e(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ia(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class Xn extends vt{constructor(e=1,t=.4,n=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:r,arc:s},n=Math.floor(n),r=Math.floor(r);const o=[],a=[],c=[],l=[],u=new U,f=new U,d=new U;for(let m=0;m<=n;m++)for(let g=0;g<=r;g++){const y=g/r*s,p=m/n*Math.PI*2;f.x=(e+t*Math.cos(p))*Math.cos(y),f.y=(e+t*Math.cos(p))*Math.sin(y),f.z=t*Math.sin(p),a.push(f.x,f.y,f.z),u.x=e*Math.cos(y),u.y=e*Math.sin(y),d.subVectors(f,u).normalize(),c.push(d.x,d.y,d.z),l.push(g/r),l.push(m/n)}for(let m=1;m<=n;m++)for(let g=1;g<=r;g++){const y=(r+1)*m+g-1,p=(r+1)*(m-1)+g-1,h=(r+1)*(m-1)+g,w=(r+1)*m+g;o.push(y,p,w),o.push(p,h,w)}this.setIndex(o),this.setAttribute("position",new $e(a,3)),this.setAttribute("normal",new $e(c,3)),this.setAttribute("uv",new $e(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Xn(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class Qh extends vt{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],n=new Set,r=new U,s=new U;if(e.index!==null){const o=e.attributes.position,a=e.index;let c=e.groups;c.length===0&&(c=[{start:0,count:a.count,materialIndex:0}]);for(let l=0,u=c.length;l<u;++l){const f=c[l],d=f.start,m=f.count;for(let g=d,y=d+m;g<y;g+=3)for(let p=0;p<3;p++){const h=a.getX(g+p),w=a.getX(g+(p+1)%3);r.fromBufferAttribute(o,h),s.fromBufferAttribute(o,w),Za(r,s,n)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}}else{const o=e.attributes.position;for(let a=0,c=o.count/3;a<c;a++)for(let l=0;l<3;l++){const u=3*a+l,f=3*a+(l+1)%3;r.fromBufferAttribute(o,u),s.fromBufferAttribute(o,f),Za(r,s,n)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new $e(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function Za(i,e,t){const n=`${i.x},${i.y},${i.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${i.x},${i.y},${i.z}`;return t.has(n)===!0||t.has(r)===!0?!1:(t.add(n),t.add(r),!0)}class Jh extends Ai{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new We(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 We(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ql,this.normalScale=new Ue(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 tn,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 eu extends Ai{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=ch,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 tu extends Ai{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 ra extends dt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new We(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 nu extends ra{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(dt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new We(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const Ds=new ot,$a=new U,Ka=new U;class iu{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ue(512,512),this.mapType=hn,this.map=null,this.mapPass=null,this.matrix=new ot,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ea,this._frameExtents=new Ue(1,1),this._viewportCount=1,this._viewports=[new ut(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;$a.setFromMatrixPosition(e.matrixWorld),t.position.copy($a),Ka.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Ka),t.updateMatrixWorld(),Ds.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ds,t.coordinateSystem,t.reversedDepth),t.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(Ds)}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 hc extends oc{constructor(e=-1,t=1,n=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=n,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,n,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=n,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),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=n-e,o=n+e,a=r+t,c=r-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,o=s+l*this.view.width,a-=u*this.view.offsetY,c=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,c,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 ru extends iu{constructor(){super(new hc(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class su extends ra{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(dt.DEFAULT_UP),this.updateMatrix(),this.target=new dt,this.shadow=new ru}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class ou extends ra{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class au extends Yt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const Qa=new ot;class uc{constructor(e,t,n=0,r=1/0){this.ray=new Jr(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new Jo,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 Qa.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Qa),this}intersectObject(e,t=!0,n=[]){return Po(e,this,n,t),n.sort(Ja),n}intersectObjects(e,t=!0,n=[]){for(let r=0,s=e.length;r<s;r++)Po(e[r],this,n,t);return n.sort(Ja),n}}function Ja(i,e){return i.distance-e.distance}function Po(i,e,t,n){let r=!0;if(i.layers.test(e.layers)&&i.raycast(e,t)===!1&&(r=!1),r===!0&&n===!0){const s=i.children;for(let o=0,a=s.length;o<a;o++)Po(s[o],e,t,!0)}}class el{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Ge(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(Ge(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class lu extends ta{constructor(e=10,t=10,n=4473924,r=8947848){n=new We(n),r=new We(r);const s=t/2,o=e/t,a=e/2,c=[],l=[];for(let d=0,m=0,g=-a;d<=t;d++,g+=o){c.push(-a,0,g,a,0,g),c.push(g,0,-a,g,0,a);const y=d===s?n:r;y.toArray(l,m),m+=3,y.toArray(l,m),m+=3,y.toArray(l,m),m+=3,y.toArray(l,m),m+=3}const u=new vt;u.setAttribute("position",new $e(c,3)),u.setAttribute("color",new $e(l,3));const f=new Ri({vertexColors:!0,toneMapped:!1});super(u,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class fc extends Jn{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 tl(i,e,t,n){const r=cu(n);switch(t){case jl:return i*e;case $l:return i*e/r.components*r.byteLength;case Zo:return i*e/r.components*r.byteLength;case Kl:return i*e*2/r.components*r.byteLength;case $o:return i*e*2/r.components*r.byteLength;case Zl:return i*e*3/r.components*r.byteLength;case Jt:return i*e*4/r.components*r.byteLength;case Ko:return i*e*4/r.components*r.byteLength;case Fr:case Br:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case zr:case Hr:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case to:case io:return Math.max(i,16)*Math.max(e,8)/4;case eo:case no:return Math.max(i,8)*Math.max(e,8)/2;case ro:case so:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case oo:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case ao:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case lo:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case co:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case ho:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case uo:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case fo:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case po:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case mo:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case _o:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case go:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case vo:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case xo:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case Mo:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case yo:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case So:case Eo:case To:return Math.ceil(i/4)*Math.ceil(e/4)*16;case bo:case wo:return Math.ceil(i/4)*Math.ceil(e/4)*8;case Ao:case Ro:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function cu(i){switch(i){case hn:case Wl:return{byteLength:1,components:1};case Xi:case Xl:case Ki:return{byteLength:2,components:1};case qo:case jo:return{byteLength:2,components:4};case $n:case Yo:case gn:return{byteLength:4,components:1};case Yl:case ql:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Xo}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Xo);/**
58
58
  * @license
59
59
  * Copyright 2010-2025 Three.js Authors
60
60
  * SPDX-License-Identifier: MIT
61
- */function Rl(){let i=null,e=!1,t=null,n=null;function r(s,a){t(s,a),n=i.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(n=i.requestAnimationFrame(r),e=!0)},stop:function(){i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){i=s}}}function Rh(i){const e=new WeakMap;function t(o,c){const l=o.array,u=o.usage,f=l.byteLength,d=i.createBuffer();i.bindBuffer(c,d),i.bufferData(c,l,u),o.onUploadCallback();let m;if(l instanceof Float32Array)m=i.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)m=i.HALF_FLOAT;else if(l instanceof Uint16Array)o.isFloat16BufferAttribute?m=i.HALF_FLOAT:m=i.UNSIGNED_SHORT;else if(l instanceof Int16Array)m=i.SHORT;else if(l instanceof Uint32Array)m=i.UNSIGNED_INT;else if(l instanceof Int32Array)m=i.INT;else if(l instanceof Int8Array)m=i.BYTE;else if(l instanceof Uint8Array)m=i.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)m=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:d,type:m,bytesPerElement:l.BYTES_PER_ELEMENT,version:o.version,size:f}}function n(o,c,l){const u=c.array,f=c.updateRanges;if(i.bindBuffer(l,o),f.length===0)i.bufferSubData(l,0,u);else{f.sort((m,v)=>m.start-v.start);let d=0;for(let m=1;m<f.length;m++){const v=f[d],S=f[m];S.start<=v.start+v.count+1?v.count=Math.max(v.count,S.start+S.count-v.start):(++d,f[d]=S)}f.length=d+1;for(let m=0,v=f.length;m<v;m++){const S=f[m];i.bufferSubData(l,S.start*u.BYTES_PER_ELEMENT,u,S.start,S.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);const c=e.get(o);c&&(i.deleteBuffer(c.buffer),e.delete(o))}function a(o,c){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const u=e.get(o);(!u||u.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const l=e.get(o);if(l===void 0)e.set(o,t(o,c));else if(l.version<o.version){if(l.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(l.buffer,o,c),l.version=o.version}}return{get:r,remove:s,update:a}}var Ch=`#ifdef USE_ALPHAHASH
61
+ */function dc(){let i=null,e=!1,t=null,n=null;function r(s,o){t(s,o),n=i.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(n=i.requestAnimationFrame(r),e=!0)},stop:function(){i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){i=s}}}function hu(i){const e=new WeakMap;function t(a,c){const l=a.array,u=a.usage,f=l.byteLength,d=i.createBuffer();i.bindBuffer(c,d),i.bufferData(c,l,u),a.onUploadCallback();let m;if(l instanceof Float32Array)m=i.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)m=i.HALF_FLOAT;else if(l instanceof Uint16Array)a.isFloat16BufferAttribute?m=i.HALF_FLOAT:m=i.UNSIGNED_SHORT;else if(l instanceof Int16Array)m=i.SHORT;else if(l instanceof Uint32Array)m=i.UNSIGNED_INT;else if(l instanceof Int32Array)m=i.INT;else if(l instanceof Int8Array)m=i.BYTE;else if(l instanceof Uint8Array)m=i.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)m=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:d,type:m,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:f}}function n(a,c,l){const u=c.array,f=c.updateRanges;if(i.bindBuffer(l,a),f.length===0)i.bufferSubData(l,0,u);else{f.sort((m,g)=>m.start-g.start);let d=0;for(let m=1;m<f.length;m++){const g=f[d],y=f[m];y.start<=g.start+g.count+1?g.count=Math.max(g.count,y.start+y.count-g.start):(++d,f[d]=y)}f.length=d+1;for(let m=0,g=f.length;m<g;m++){const y=f[m];i.bufferSubData(l,y.start*u.BYTES_PER_ELEMENT,u,y.start,y.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function s(a){a.isInterleavedBufferAttribute&&(a=a.data);const c=e.get(a);c&&(i.deleteBuffer(c.buffer),e.delete(a))}function o(a,c){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 l=e.get(a);if(l===void 0)e.set(a,t(a,c));else if(l.version<a.version){if(l.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.");n(l.buffer,a,c),l.version=a.version}}return{get:r,remove:s,update:o}}var uu=`#ifdef USE_ALPHAHASH
62
62
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
63
- #endif`,Ph=`#ifdef USE_ALPHAHASH
63
+ #endif`,fu=`#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`,Dh=`#ifdef USE_ALPHAMAP
98
+ #endif`,du=`#ifdef USE_ALPHAMAP
99
99
  diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
100
- #endif`,Lh=`#ifdef USE_ALPHAMAP
100
+ #endif`,pu=`#ifdef USE_ALPHAMAP
101
101
  uniform sampler2D alphaMap;
102
- #endif`,Ih=`#ifdef USE_ALPHATEST
102
+ #endif`,mu=`#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`,Uh=`#ifdef USE_ALPHATEST
109
+ #endif`,_u=`#ifdef USE_ALPHATEST
110
110
  uniform float alphaTest;
111
- #endif`,Nh=`#ifdef USE_AOMAP
111
+ #endif`,gu=`#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`,Fh=`#ifdef USE_AOMAP
124
+ #endif`,vu=`#ifdef USE_AOMAP
125
125
  uniform sampler2D aoMap;
126
126
  uniform float aoMapIntensity;
127
- #endif`,Oh=`#ifdef USE_BATCHING
127
+ #endif`,xu=`#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`,Bh=`#ifdef USE_BATCHING
161
+ #endif`,Mu=`#ifdef USE_BATCHING
162
162
  mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
163
- #endif`,zh=`vec3 transformed = vec3( position );
163
+ #endif`,yu=`vec3 transformed = vec3( position );
164
164
  #ifdef USE_ALPHAHASH
165
165
  vPosition = vec3( position );
166
- #endif`,Hh=`vec3 objectNormal = vec3( normal );
166
+ #endif`,Su=`vec3 objectNormal = vec3( normal );
167
167
  #ifdef USE_TANGENT
168
168
  vec3 objectTangent = vec3( tangent.xyz );
169
- #endif`,kh=`float G_BlinnPhong_Implicit( ) {
169
+ #endif`,Eu=`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`,Vh=`#ifdef USE_IRIDESCENCE
183
+ } // validated`,Tu=`#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`,Gh=`#ifdef USE_BUMPMAP
246
+ #endif`,bu=`#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`,Wh=`#if NUM_CLIPPING_PLANES > 0
267
+ #endif`,wu=`#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`,Xh=`#if NUM_CLIPPING_PLANES > 0
313
+ #endif`,Au=`#if NUM_CLIPPING_PLANES > 0
314
314
  varying vec3 vClipPosition;
315
315
  uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
316
- #endif`,qh=`#if NUM_CLIPPING_PLANES > 0
316
+ #endif`,Ru=`#if NUM_CLIPPING_PLANES > 0
317
317
  varying vec3 vClipPosition;
318
- #endif`,Yh=`#if NUM_CLIPPING_PLANES > 0
318
+ #endif`,Cu=`#if NUM_CLIPPING_PLANES > 0
319
319
  vClipPosition = - mvPosition.xyz;
320
- #endif`,jh=`#if defined( USE_COLOR_ALPHA )
320
+ #endif`,Pu=`#if defined( USE_COLOR_ALPHA )
321
321
  diffuseColor *= vColor;
322
322
  #elif defined( USE_COLOR )
323
323
  diffuseColor.rgb *= vColor;
324
- #endif`,Kh=`#if defined( USE_COLOR_ALPHA )
324
+ #endif`,Du=`#if defined( USE_COLOR_ALPHA )
325
325
  varying vec4 vColor;
326
326
  #elif defined( USE_COLOR )
327
327
  varying vec3 vColor;
328
- #endif`,$h=`#if defined( USE_COLOR_ALPHA )
328
+ #endif`,Lu=`#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`,Zh=`#if defined( USE_COLOR_ALPHA )
332
+ #endif`,Iu=`#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`,Jh=`#define PI 3.141592653589793
346
+ #endif`,Uu=`#define PI 3.141592653589793
347
347
  #define PI2 6.283185307179586
348
348
  #define PI_HALF 1.5707963267948966
349
349
  #define RECIPROCAL_PI 0.3183098861837907
@@ -417,7 +417,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
417
417
  float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
418
418
  float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
419
419
  return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
420
- } // validated`,Qh=`#ifdef ENVMAP_TYPE_CUBE_UV
420
+ } // validated`,Nu=`#ifdef ENVMAP_TYPE_CUBE_UV
421
421
  #define cubeUV_minMipLevel 4.0
422
422
  #define cubeUV_minTileSize 16.0
423
423
  float getFace( vec3 direction ) {
@@ -510,7 +510,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
510
510
  return vec4( mix( color0, color1, mipF ), 1.0 );
511
511
  }
512
512
  }
513
- #endif`,eu=`vec3 transformedNormal = objectNormal;
513
+ #endif`,Ou=`vec3 transformedNormal = objectNormal;
514
514
  #ifdef USE_TANGENT
515
515
  vec3 transformedTangent = objectTangent;
516
516
  #endif
@@ -539,21 +539,21 @@ transformedNormal = normalMatrix * transformedNormal;
539
539
  #ifdef FLIP_SIDED
540
540
  transformedTangent = - transformedTangent;
541
541
  #endif
542
- #endif`,tu=`#ifdef USE_DISPLACEMENTMAP
542
+ #endif`,Fu=`#ifdef USE_DISPLACEMENTMAP
543
543
  uniform sampler2D displacementMap;
544
544
  uniform float displacementScale;
545
545
  uniform float displacementBias;
546
- #endif`,nu=`#ifdef USE_DISPLACEMENTMAP
546
+ #endif`,Bu=`#ifdef USE_DISPLACEMENTMAP
547
547
  transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
548
- #endif`,iu=`#ifdef USE_EMISSIVEMAP
548
+ #endif`,zu=`#ifdef USE_EMISSIVEMAP
549
549
  vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
550
550
  #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
551
551
  emissiveColor = sRGBTransferEOTF( emissiveColor );
552
552
  #endif
553
553
  totalEmissiveRadiance *= emissiveColor.rgb;
554
- #endif`,ru=`#ifdef USE_EMISSIVEMAP
554
+ #endif`,Hu=`#ifdef USE_EMISSIVEMAP
555
555
  uniform sampler2D emissiveMap;
556
- #endif`,su="gl_FragColor = linearToOutputTexel( gl_FragColor );",au=`vec4 LinearTransferOETF( in vec4 value ) {
556
+ #endif`,ku="gl_FragColor = linearToOutputTexel( gl_FragColor );",Gu=`vec4 LinearTransferOETF( in vec4 value ) {
557
557
  return value;
558
558
  }
559
559
  vec4 sRGBTransferEOTF( in vec4 value ) {
@@ -561,7 +561,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {
561
561
  }
562
562
  vec4 sRGBTransferOETF( in vec4 value ) {
563
563
  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
- }`,ou=`#ifdef USE_ENVMAP
564
+ }`,Vu=`#ifdef USE_ENVMAP
565
565
  #ifdef ENV_WORLDPOS
566
566
  vec3 cameraToFrag;
567
567
  if ( isOrthographic ) {
@@ -590,7 +590,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
590
590
  #elif defined( ENVMAP_BLENDING_ADD )
591
591
  outgoingLight += envColor.xyz * specularStrength * reflectivity;
592
592
  #endif
593
- #endif`,lu=`#ifdef USE_ENVMAP
593
+ #endif`,Wu=`#ifdef USE_ENVMAP
594
594
  uniform float envMapIntensity;
595
595
  uniform float flipEnvMap;
596
596
  uniform mat3 envMapRotation;
@@ -600,7 +600,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
600
600
  uniform sampler2D envMap;
601
601
  #endif
602
602
 
603
- #endif`,cu=`#ifdef USE_ENVMAP
603
+ #endif`,Xu=`#ifdef USE_ENVMAP
604
604
  uniform float reflectivity;
605
605
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
606
606
  #define ENV_WORLDPOS
@@ -611,7 +611,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
611
611
  #else
612
612
  varying vec3 vReflect;
613
613
  #endif
614
- #endif`,hu=`#ifdef USE_ENVMAP
614
+ #endif`,Yu=`#ifdef USE_ENVMAP
615
615
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
616
616
  #define ENV_WORLDPOS
617
617
  #endif
@@ -622,7 +622,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
622
622
  varying vec3 vReflect;
623
623
  uniform float refractionRatio;
624
624
  #endif
625
- #endif`,uu=`#ifdef USE_ENVMAP
625
+ #endif`,qu=`#ifdef USE_ENVMAP
626
626
  #ifdef ENV_WORLDPOS
627
627
  vWorldPosition = worldPosition.xyz;
628
628
  #else
@@ -639,18 +639,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
639
639
  vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
640
640
  #endif
641
641
  #endif
642
- #endif`,fu=`#ifdef USE_FOG
642
+ #endif`,ju=`#ifdef USE_FOG
643
643
  vFogDepth = - mvPosition.z;
644
- #endif`,du=`#ifdef USE_FOG
644
+ #endif`,Zu=`#ifdef USE_FOG
645
645
  varying float vFogDepth;
646
- #endif`,pu=`#ifdef USE_FOG
646
+ #endif`,$u=`#ifdef USE_FOG
647
647
  #ifdef FOG_EXP2
648
648
  float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
649
649
  #else
650
650
  float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
651
651
  #endif
652
652
  gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
653
- #endif`,mu=`#ifdef USE_FOG
653
+ #endif`,Ku=`#ifdef USE_FOG
654
654
  uniform vec3 fogColor;
655
655
  varying float vFogDepth;
656
656
  #ifdef FOG_EXP2
@@ -659,7 +659,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
659
659
  uniform float fogNear;
660
660
  uniform float fogFar;
661
661
  #endif
662
- #endif`,_u=`#ifdef USE_GRADIENTMAP
662
+ #endif`,Qu=`#ifdef USE_GRADIENTMAP
663
663
  uniform sampler2D gradientMap;
664
664
  #endif
665
665
  vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
@@ -671,12 +671,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
671
671
  vec2 fw = fwidth( coord ) * 0.5;
672
672
  return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
673
673
  #endif
674
- }`,gu=`#ifdef USE_LIGHTMAP
674
+ }`,Ju=`#ifdef USE_LIGHTMAP
675
675
  uniform sampler2D lightMap;
676
676
  uniform float lightMapIntensity;
677
- #endif`,vu=`LambertMaterial material;
677
+ #endif`,ef=`LambertMaterial material;
678
678
  material.diffuseColor = diffuseColor.rgb;
679
- material.specularStrength = specularStrength;`,xu=`varying vec3 vViewPosition;
679
+ material.specularStrength = specularStrength;`,tf=`varying vec3 vViewPosition;
680
680
  struct LambertMaterial {
681
681
  vec3 diffuseColor;
682
682
  float specularStrength;
@@ -690,7 +690,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
690
690
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
691
691
  }
692
692
  #define RE_Direct RE_Direct_Lambert
693
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Mu=`uniform bool receiveShadow;
693
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,nf=`uniform bool receiveShadow;
694
694
  uniform vec3 ambientLightColor;
695
695
  #if defined( USE_LIGHT_PROBES )
696
696
  uniform vec3 lightProbe[ 9 ];
@@ -806,7 +806,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
806
806
  vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
807
807
  return irradiance;
808
808
  }
809
- #endif`,Su=`#ifdef USE_ENVMAP
809
+ #endif`,rf=`#ifdef USE_ENVMAP
810
810
  vec3 getIBLIrradiance( const in vec3 normal ) {
811
811
  #ifdef ENVMAP_TYPE_CUBE_UV
812
812
  vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
@@ -839,8 +839,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
839
839
  #endif
840
840
  }
841
841
  #endif
842
- #endif`,yu=`ToonMaterial material;
843
- material.diffuseColor = diffuseColor.rgb;`,Eu=`varying vec3 vViewPosition;
842
+ #endif`,sf=`ToonMaterial material;
843
+ material.diffuseColor = diffuseColor.rgb;`,of=`varying vec3 vViewPosition;
844
844
  struct ToonMaterial {
845
845
  vec3 diffuseColor;
846
846
  };
@@ -852,11 +852,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
852
852
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
853
853
  }
854
854
  #define RE_Direct RE_Direct_Toon
855
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Tu=`BlinnPhongMaterial material;
855
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,af=`BlinnPhongMaterial material;
856
856
  material.diffuseColor = diffuseColor.rgb;
857
857
  material.specularColor = specular;
858
858
  material.specularShininess = shininess;
859
- material.specularStrength = specularStrength;`,bu=`varying vec3 vViewPosition;
859
+ material.specularStrength = specularStrength;`,lf=`varying vec3 vViewPosition;
860
860
  struct BlinnPhongMaterial {
861
861
  vec3 diffuseColor;
862
862
  vec3 specularColor;
@@ -873,7 +873,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
873
873
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
874
874
  }
875
875
  #define RE_Direct RE_Direct_BlinnPhong
876
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Au=`PhysicalMaterial material;
876
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,cf=`PhysicalMaterial material;
877
877
  material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
878
878
  vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
879
879
  float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
@@ -959,7 +959,7 @@ material.roughness = min( material.roughness, 1.0 );
959
959
  material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
960
960
  material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
961
961
  material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
962
- #endif`,wu=`struct PhysicalMaterial {
962
+ #endif`,hf=`struct PhysicalMaterial {
963
963
  vec3 diffuseColor;
964
964
  float roughness;
965
965
  vec3 specularColor;
@@ -1260,7 +1260,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
1260
1260
  #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1261
1261
  float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1262
1262
  return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1263
- }`,Ru=`
1263
+ }`,uf=`
1264
1264
  vec3 geometryPosition = - vViewPosition;
1265
1265
  vec3 geometryNormal = normal;
1266
1266
  vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
@@ -1375,7 +1375,7 @@ IncidentLight directLight;
1375
1375
  #if defined( RE_IndirectSpecular )
1376
1376
  vec3 radiance = vec3( 0.0 );
1377
1377
  vec3 clearcoatRadiance = vec3( 0.0 );
1378
- #endif`,Cu=`#if defined( RE_IndirectDiffuse )
1378
+ #endif`,ff=`#if defined( RE_IndirectDiffuse )
1379
1379
  #ifdef USE_LIGHTMAP
1380
1380
  vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1381
1381
  vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
@@ -1394,32 +1394,32 @@ IncidentLight directLight;
1394
1394
  #ifdef USE_CLEARCOAT
1395
1395
  clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
1396
1396
  #endif
1397
- #endif`,Pu=`#if defined( RE_IndirectDiffuse )
1397
+ #endif`,df=`#if defined( RE_IndirectDiffuse )
1398
1398
  RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1399
1399
  #endif
1400
1400
  #if defined( RE_IndirectSpecular )
1401
1401
  RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1402
- #endif`,Du=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1402
+ #endif`,pf=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1403
1403
  gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1404
- #endif`,Lu=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1404
+ #endif`,mf=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1405
1405
  uniform float logDepthBufFC;
1406
1406
  varying float vFragDepth;
1407
1407
  varying float vIsPerspective;
1408
- #endif`,Iu=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1408
+ #endif`,_f=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1409
1409
  varying float vFragDepth;
1410
1410
  varying float vIsPerspective;
1411
- #endif`,Uu=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1411
+ #endif`,gf=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1412
1412
  vFragDepth = 1.0 + gl_Position.w;
1413
1413
  vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1414
- #endif`,Nu=`#ifdef USE_MAP
1414
+ #endif`,vf=`#ifdef USE_MAP
1415
1415
  vec4 sampledDiffuseColor = texture2D( map, vMapUv );
1416
1416
  #ifdef DECODE_VIDEO_TEXTURE
1417
1417
  sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
1418
1418
  #endif
1419
1419
  diffuseColor *= sampledDiffuseColor;
1420
- #endif`,Fu=`#ifdef USE_MAP
1420
+ #endif`,xf=`#ifdef USE_MAP
1421
1421
  uniform sampler2D map;
1422
- #endif`,Ou=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1422
+ #endif`,Mf=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1423
1423
  #if defined( USE_POINTS_UV )
1424
1424
  vec2 uv = vUv;
1425
1425
  #else
@@ -1431,7 +1431,7 @@ IncidentLight directLight;
1431
1431
  #endif
1432
1432
  #ifdef USE_ALPHAMAP
1433
1433
  diffuseColor.a *= texture2D( alphaMap, uv ).g;
1434
- #endif`,Bu=`#if defined( USE_POINTS_UV )
1434
+ #endif`,yf=`#if defined( USE_POINTS_UV )
1435
1435
  varying vec2 vUv;
1436
1436
  #else
1437
1437
  #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
@@ -1443,19 +1443,19 @@ IncidentLight directLight;
1443
1443
  #endif
1444
1444
  #ifdef USE_ALPHAMAP
1445
1445
  uniform sampler2D alphaMap;
1446
- #endif`,zu=`float metalnessFactor = metalness;
1446
+ #endif`,Sf=`float metalnessFactor = metalness;
1447
1447
  #ifdef USE_METALNESSMAP
1448
1448
  vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1449
1449
  metalnessFactor *= texelMetalness.b;
1450
- #endif`,Hu=`#ifdef USE_METALNESSMAP
1450
+ #endif`,Ef=`#ifdef USE_METALNESSMAP
1451
1451
  uniform sampler2D metalnessMap;
1452
- #endif`,ku=`#ifdef USE_INSTANCING_MORPH
1452
+ #endif`,Tf=`#ifdef USE_INSTANCING_MORPH
1453
1453
  float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1454
1454
  float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
1455
1455
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1456
1456
  morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
1457
1457
  }
1458
- #endif`,Vu=`#if defined( USE_MORPHCOLORS )
1458
+ #endif`,bf=`#if defined( USE_MORPHCOLORS )
1459
1459
  vColor *= morphTargetBaseInfluence;
1460
1460
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1461
1461
  #if defined( USE_COLOR_ALPHA )
@@ -1464,12 +1464,12 @@ IncidentLight directLight;
1464
1464
  if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1465
1465
  #endif
1466
1466
  }
1467
- #endif`,Gu=`#ifdef USE_MORPHNORMALS
1467
+ #endif`,wf=`#ifdef USE_MORPHNORMALS
1468
1468
  objectNormal *= morphTargetBaseInfluence;
1469
1469
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1470
1470
  if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
1471
1471
  }
1472
- #endif`,Wu=`#ifdef USE_MORPHTARGETS
1472
+ #endif`,Af=`#ifdef USE_MORPHTARGETS
1473
1473
  #ifndef USE_INSTANCING_MORPH
1474
1474
  uniform float morphTargetBaseInfluence;
1475
1475
  uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
@@ -1483,12 +1483,12 @@ IncidentLight directLight;
1483
1483
  ivec3 morphUV = ivec3( x, y, morphTargetIndex );
1484
1484
  return texelFetch( morphTargetsTexture, morphUV, 0 );
1485
1485
  }
1486
- #endif`,Xu=`#ifdef USE_MORPHTARGETS
1486
+ #endif`,Rf=`#ifdef USE_MORPHTARGETS
1487
1487
  transformed *= morphTargetBaseInfluence;
1488
1488
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1489
1489
  if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
1490
1490
  }
1491
- #endif`,qu=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1491
+ #endif`,Cf=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1492
1492
  #ifdef FLAT_SHADED
1493
1493
  vec3 fdx = dFdx( vViewPosition );
1494
1494
  vec3 fdy = dFdy( vViewPosition );
@@ -1529,7 +1529,7 @@ IncidentLight directLight;
1529
1529
  tbn2[1] *= faceDirection;
1530
1530
  #endif
1531
1531
  #endif
1532
- vec3 nonPerturbedNormal = normal;`,Yu=`#ifdef USE_NORMALMAP_OBJECTSPACE
1532
+ vec3 nonPerturbedNormal = normal;`,Pf=`#ifdef USE_NORMALMAP_OBJECTSPACE
1533
1533
  normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1534
1534
  #ifdef FLIP_SIDED
1535
1535
  normal = - normal;
@@ -1544,25 +1544,25 @@ vec3 nonPerturbedNormal = normal;`,Yu=`#ifdef USE_NORMALMAP_OBJECTSPACE
1544
1544
  normal = normalize( tbn * mapN );
1545
1545
  #elif defined( USE_BUMPMAP )
1546
1546
  normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1547
- #endif`,ju=`#ifndef FLAT_SHADED
1547
+ #endif`,Df=`#ifndef FLAT_SHADED
1548
1548
  varying vec3 vNormal;
1549
1549
  #ifdef USE_TANGENT
1550
1550
  varying vec3 vTangent;
1551
1551
  varying vec3 vBitangent;
1552
1552
  #endif
1553
- #endif`,Ku=`#ifndef FLAT_SHADED
1553
+ #endif`,Lf=`#ifndef FLAT_SHADED
1554
1554
  varying vec3 vNormal;
1555
1555
  #ifdef USE_TANGENT
1556
1556
  varying vec3 vTangent;
1557
1557
  varying vec3 vBitangent;
1558
1558
  #endif
1559
- #endif`,$u=`#ifndef FLAT_SHADED
1559
+ #endif`,If=`#ifndef FLAT_SHADED
1560
1560
  vNormal = normalize( transformedNormal );
1561
1561
  #ifdef USE_TANGENT
1562
1562
  vTangent = normalize( transformedTangent );
1563
1563
  vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
1564
1564
  #endif
1565
- #endif`,Zu=`#ifdef USE_NORMALMAP
1565
+ #endif`,Uf=`#ifdef USE_NORMALMAP
1566
1566
  uniform sampler2D normalMap;
1567
1567
  uniform vec2 normalScale;
1568
1568
  #endif
@@ -1584,13 +1584,13 @@ vec3 nonPerturbedNormal = normal;`,Yu=`#ifdef USE_NORMALMAP_OBJECTSPACE
1584
1584
  float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1585
1585
  return mat3( T * scale, B * scale, N );
1586
1586
  }
1587
- #endif`,Ju=`#ifdef USE_CLEARCOAT
1587
+ #endif`,Nf=`#ifdef USE_CLEARCOAT
1588
1588
  vec3 clearcoatNormal = nonPerturbedNormal;
1589
- #endif`,Qu=`#ifdef USE_CLEARCOAT_NORMALMAP
1589
+ #endif`,Of=`#ifdef USE_CLEARCOAT_NORMALMAP
1590
1590
  vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1591
1591
  clearcoatMapN.xy *= clearcoatNormalScale;
1592
1592
  clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1593
- #endif`,ef=`#ifdef USE_CLEARCOATMAP
1593
+ #endif`,Ff=`#ifdef USE_CLEARCOATMAP
1594
1594
  uniform sampler2D clearcoatMap;
1595
1595
  #endif
1596
1596
  #ifdef USE_CLEARCOAT_NORMALMAP
@@ -1599,18 +1599,18 @@ vec3 nonPerturbedNormal = normal;`,Yu=`#ifdef USE_NORMALMAP_OBJECTSPACE
1599
1599
  #endif
1600
1600
  #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1601
1601
  uniform sampler2D clearcoatRoughnessMap;
1602
- #endif`,tf=`#ifdef USE_IRIDESCENCEMAP
1602
+ #endif`,Bf=`#ifdef USE_IRIDESCENCEMAP
1603
1603
  uniform sampler2D iridescenceMap;
1604
1604
  #endif
1605
1605
  #ifdef USE_IRIDESCENCE_THICKNESSMAP
1606
1606
  uniform sampler2D iridescenceThicknessMap;
1607
- #endif`,nf=`#ifdef OPAQUE
1607
+ #endif`,zf=`#ifdef OPAQUE
1608
1608
  diffuseColor.a = 1.0;
1609
1609
  #endif
1610
1610
  #ifdef USE_TRANSMISSION
1611
1611
  diffuseColor.a *= material.transmissionAlpha;
1612
1612
  #endif
1613
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,rf=`vec3 packNormalToRGB( const in vec3 normal ) {
1613
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Hf=`vec3 packNormalToRGB( const in vec3 normal ) {
1614
1614
  return normalize( normal ) * 0.5 + 0.5;
1615
1615
  }
1616
1616
  vec3 unpackRGBToNormal( const in vec3 rgb ) {
@@ -1679,9 +1679,9 @@ float viewZToPerspectiveDepth( const in float viewZ, const in float near, const
1679
1679
  }
1680
1680
  float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
1681
1681
  return ( near * far ) / ( ( far - near ) * depth - far );
1682
- }`,sf=`#ifdef PREMULTIPLIED_ALPHA
1682
+ }`,kf=`#ifdef PREMULTIPLIED_ALPHA
1683
1683
  gl_FragColor.rgb *= gl_FragColor.a;
1684
- #endif`,af=`vec4 mvPosition = vec4( transformed, 1.0 );
1684
+ #endif`,Gf=`vec4 mvPosition = vec4( transformed, 1.0 );
1685
1685
  #ifdef USE_BATCHING
1686
1686
  mvPosition = batchingMatrix * mvPosition;
1687
1687
  #endif
@@ -1689,22 +1689,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
1689
1689
  mvPosition = instanceMatrix * mvPosition;
1690
1690
  #endif
1691
1691
  mvPosition = modelViewMatrix * mvPosition;
1692
- gl_Position = projectionMatrix * mvPosition;`,of=`#ifdef DITHERING
1692
+ gl_Position = projectionMatrix * mvPosition;`,Vf=`#ifdef DITHERING
1693
1693
  gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1694
- #endif`,lf=`#ifdef DITHERING
1694
+ #endif`,Wf=`#ifdef DITHERING
1695
1695
  vec3 dithering( vec3 color ) {
1696
1696
  float grid_position = rand( gl_FragCoord.xy );
1697
1697
  vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
1698
1698
  dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
1699
1699
  return color + dither_shift_RGB;
1700
1700
  }
1701
- #endif`,cf=`float roughnessFactor = roughness;
1701
+ #endif`,Xf=`float roughnessFactor = roughness;
1702
1702
  #ifdef USE_ROUGHNESSMAP
1703
1703
  vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1704
1704
  roughnessFactor *= texelRoughness.g;
1705
- #endif`,hf=`#ifdef USE_ROUGHNESSMAP
1705
+ #endif`,Yf=`#ifdef USE_ROUGHNESSMAP
1706
1706
  uniform sampler2D roughnessMap;
1707
- #endif`,uf=`#if NUM_SPOT_LIGHT_COORDS > 0
1707
+ #endif`,qf=`#if NUM_SPOT_LIGHT_COORDS > 0
1708
1708
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1709
1709
  #endif
1710
1710
  #if NUM_SPOT_LIGHT_MAPS > 0
@@ -1899,7 +1899,7 @@ gl_Position = projectionMatrix * mvPosition;`,of=`#ifdef DITHERING
1899
1899
  }
1900
1900
  return mix( 1.0, shadow, shadowIntensity );
1901
1901
  }
1902
- #endif`,ff=`#if NUM_SPOT_LIGHT_COORDS > 0
1902
+ #endif`,jf=`#if NUM_SPOT_LIGHT_COORDS > 0
1903
1903
  uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
1904
1904
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1905
1905
  #endif
@@ -1940,7 +1940,7 @@ gl_Position = projectionMatrix * mvPosition;`,of=`#ifdef DITHERING
1940
1940
  };
1941
1941
  uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1942
1942
  #endif
1943
- #endif`,df=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
1943
+ #endif`,Zf=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
1944
1944
  vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
1945
1945
  vec4 shadowWorldPosition;
1946
1946
  #endif
@@ -1972,7 +1972,7 @@ gl_Position = projectionMatrix * mvPosition;`,of=`#ifdef DITHERING
1972
1972
  vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
1973
1973
  }
1974
1974
  #pragma unroll_loop_end
1975
- #endif`,pf=`float getShadowMask() {
1975
+ #endif`,$f=`float getShadowMask() {
1976
1976
  float shadow = 1.0;
1977
1977
  #ifdef USE_SHADOWMAP
1978
1978
  #if NUM_DIR_LIGHT_SHADOWS > 0
@@ -2004,12 +2004,12 @@ gl_Position = projectionMatrix * mvPosition;`,of=`#ifdef DITHERING
2004
2004
  #endif
2005
2005
  #endif
2006
2006
  return shadow;
2007
- }`,mf=`#ifdef USE_SKINNING
2007
+ }`,Kf=`#ifdef USE_SKINNING
2008
2008
  mat4 boneMatX = getBoneMatrix( skinIndex.x );
2009
2009
  mat4 boneMatY = getBoneMatrix( skinIndex.y );
2010
2010
  mat4 boneMatZ = getBoneMatrix( skinIndex.z );
2011
2011
  mat4 boneMatW = getBoneMatrix( skinIndex.w );
2012
- #endif`,_f=`#ifdef USE_SKINNING
2012
+ #endif`,Qf=`#ifdef USE_SKINNING
2013
2013
  uniform mat4 bindMatrix;
2014
2014
  uniform mat4 bindMatrixInverse;
2015
2015
  uniform highp sampler2D boneTexture;
@@ -2024,7 +2024,7 @@ gl_Position = projectionMatrix * mvPosition;`,of=`#ifdef DITHERING
2024
2024
  vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
2025
2025
  return mat4( v1, v2, v3, v4 );
2026
2026
  }
2027
- #endif`,gf=`#ifdef USE_SKINNING
2027
+ #endif`,Jf=`#ifdef USE_SKINNING
2028
2028
  vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
2029
2029
  vec4 skinned = vec4( 0.0 );
2030
2030
  skinned += boneMatX * skinVertex * skinWeight.x;
@@ -2032,7 +2032,7 @@ gl_Position = projectionMatrix * mvPosition;`,of=`#ifdef DITHERING
2032
2032
  skinned += boneMatZ * skinVertex * skinWeight.z;
2033
2033
  skinned += boneMatW * skinVertex * skinWeight.w;
2034
2034
  transformed = ( bindMatrixInverse * skinned ).xyz;
2035
- #endif`,vf=`#ifdef USE_SKINNING
2035
+ #endif`,ed=`#ifdef USE_SKINNING
2036
2036
  mat4 skinMatrix = mat4( 0.0 );
2037
2037
  skinMatrix += skinWeight.x * boneMatX;
2038
2038
  skinMatrix += skinWeight.y * boneMatY;
@@ -2043,17 +2043,17 @@ gl_Position = projectionMatrix * mvPosition;`,of=`#ifdef DITHERING
2043
2043
  #ifdef USE_TANGENT
2044
2044
  objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2045
2045
  #endif
2046
- #endif`,xf=`float specularStrength;
2046
+ #endif`,td=`float specularStrength;
2047
2047
  #ifdef USE_SPECULARMAP
2048
2048
  vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2049
2049
  specularStrength = texelSpecular.r;
2050
2050
  #else
2051
2051
  specularStrength = 1.0;
2052
- #endif`,Mf=`#ifdef USE_SPECULARMAP
2052
+ #endif`,nd=`#ifdef USE_SPECULARMAP
2053
2053
  uniform sampler2D specularMap;
2054
- #endif`,Sf=`#if defined( TONE_MAPPING )
2054
+ #endif`,id=`#if defined( TONE_MAPPING )
2055
2055
  gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2056
- #endif`,yf=`#ifndef saturate
2056
+ #endif`,rd=`#ifndef saturate
2057
2057
  #define saturate( a ) clamp( a, 0.0, 1.0 )
2058
2058
  #endif
2059
2059
  uniform float toneMappingExposure;
@@ -2150,7 +2150,7 @@ vec3 NeutralToneMapping( vec3 color ) {
2150
2150
  float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
2151
2151
  return mix( color, vec3( newPeak ), g );
2152
2152
  }
2153
- vec3 CustomToneMapping( vec3 color ) { return color; }`,Ef=`#ifdef USE_TRANSMISSION
2153
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,sd=`#ifdef USE_TRANSMISSION
2154
2154
  material.transmission = transmission;
2155
2155
  material.transmissionAlpha = 1.0;
2156
2156
  material.thickness = thickness;
@@ -2171,7 +2171,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Ef=`#ifdef USE_TRANSMISS
2171
2171
  material.attenuationColor, material.attenuationDistance );
2172
2172
  material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2173
2173
  totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2174
- #endif`,Tf=`#ifdef USE_TRANSMISSION
2174
+ #endif`,od=`#ifdef USE_TRANSMISSION
2175
2175
  uniform float transmission;
2176
2176
  uniform float thickness;
2177
2177
  uniform float attenuationDistance;
@@ -2297,7 +2297,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Ef=`#ifdef USE_TRANSMISS
2297
2297
  float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2298
2298
  return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2299
2299
  }
2300
- #endif`,bf=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2300
+ #endif`,ad=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2301
2301
  varying vec2 vUv;
2302
2302
  #endif
2303
2303
  #ifdef USE_MAP
@@ -2367,7 +2367,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Ef=`#ifdef USE_TRANSMISS
2367
2367
  #ifdef USE_THICKNESSMAP
2368
2368
  uniform mat3 thicknessMapTransform;
2369
2369
  varying vec2 vThicknessMapUv;
2370
- #endif`,Af=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2370
+ #endif`,ld=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2371
2371
  varying vec2 vUv;
2372
2372
  #endif
2373
2373
  #ifdef USE_MAP
@@ -2461,7 +2461,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Ef=`#ifdef USE_TRANSMISS
2461
2461
  #ifdef USE_THICKNESSMAP
2462
2462
  uniform mat3 thicknessMapTransform;
2463
2463
  varying vec2 vThicknessMapUv;
2464
- #endif`,wf=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2464
+ #endif`,cd=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2465
2465
  vUv = vec3( uv, 1 ).xy;
2466
2466
  #endif
2467
2467
  #ifdef USE_MAP
@@ -2532,7 +2532,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Ef=`#ifdef USE_TRANSMISS
2532
2532
  #endif
2533
2533
  #ifdef USE_THICKNESSMAP
2534
2534
  vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2535
- #endif`,Rf=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2535
+ #endif`,hd=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2536
2536
  vec4 worldPosition = vec4( transformed, 1.0 );
2537
2537
  #ifdef USE_BATCHING
2538
2538
  worldPosition = batchingMatrix * worldPosition;
@@ -2541,12 +2541,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Ef=`#ifdef USE_TRANSMISS
2541
2541
  worldPosition = instanceMatrix * worldPosition;
2542
2542
  #endif
2543
2543
  worldPosition = modelMatrix * worldPosition;
2544
- #endif`;const Cf=`varying vec2 vUv;
2544
+ #endif`;const ud=`varying vec2 vUv;
2545
2545
  uniform mat3 uvTransform;
2546
2546
  void main() {
2547
2547
  vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2548
2548
  gl_Position = vec4( position.xy, 1.0, 1.0 );
2549
- }`,Pf=`uniform sampler2D t2D;
2549
+ }`,fd=`uniform sampler2D t2D;
2550
2550
  uniform float backgroundIntensity;
2551
2551
  varying vec2 vUv;
2552
2552
  void main() {
@@ -2558,14 +2558,14 @@ void main() {
2558
2558
  gl_FragColor = texColor;
2559
2559
  #include <tonemapping_fragment>
2560
2560
  #include <colorspace_fragment>
2561
- }`,Df=`varying vec3 vWorldDirection;
2561
+ }`,dd=`varying vec3 vWorldDirection;
2562
2562
  #include <common>
2563
2563
  void main() {
2564
2564
  vWorldDirection = transformDirection( position, modelMatrix );
2565
2565
  #include <begin_vertex>
2566
2566
  #include <project_vertex>
2567
2567
  gl_Position.z = gl_Position.w;
2568
- }`,Lf=`#ifdef ENVMAP_TYPE_CUBE
2568
+ }`,pd=`#ifdef ENVMAP_TYPE_CUBE
2569
2569
  uniform samplerCube envMap;
2570
2570
  #elif defined( ENVMAP_TYPE_CUBE_UV )
2571
2571
  uniform sampler2D envMap;
@@ -2588,14 +2588,14 @@ void main() {
2588
2588
  gl_FragColor = texColor;
2589
2589
  #include <tonemapping_fragment>
2590
2590
  #include <colorspace_fragment>
2591
- }`,If=`varying vec3 vWorldDirection;
2591
+ }`,md=`varying vec3 vWorldDirection;
2592
2592
  #include <common>
2593
2593
  void main() {
2594
2594
  vWorldDirection = transformDirection( position, modelMatrix );
2595
2595
  #include <begin_vertex>
2596
2596
  #include <project_vertex>
2597
2597
  gl_Position.z = gl_Position.w;
2598
- }`,Uf=`uniform samplerCube tCube;
2598
+ }`,_d=`uniform samplerCube tCube;
2599
2599
  uniform float tFlip;
2600
2600
  uniform float opacity;
2601
2601
  varying vec3 vWorldDirection;
@@ -2605,7 +2605,7 @@ void main() {
2605
2605
  gl_FragColor.a *= opacity;
2606
2606
  #include <tonemapping_fragment>
2607
2607
  #include <colorspace_fragment>
2608
- }`,Nf=`#include <common>
2608
+ }`,gd=`#include <common>
2609
2609
  #include <batching_pars_vertex>
2610
2610
  #include <uv_pars_vertex>
2611
2611
  #include <displacementmap_pars_vertex>
@@ -2632,7 +2632,7 @@ void main() {
2632
2632
  #include <logdepthbuf_vertex>
2633
2633
  #include <clipping_planes_vertex>
2634
2634
  vHighPrecisionZW = gl_Position.zw;
2635
- }`,Ff=`#if DEPTH_PACKING == 3200
2635
+ }`,vd=`#if DEPTH_PACKING == 3200
2636
2636
  uniform float opacity;
2637
2637
  #endif
2638
2638
  #include <common>
@@ -2670,7 +2670,7 @@ void main() {
2670
2670
  #elif DEPTH_PACKING == 3203
2671
2671
  gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
2672
2672
  #endif
2673
- }`,Of=`#define DISTANCE
2673
+ }`,xd=`#define DISTANCE
2674
2674
  varying vec3 vWorldPosition;
2675
2675
  #include <common>
2676
2676
  #include <batching_pars_vertex>
@@ -2697,7 +2697,7 @@ void main() {
2697
2697
  #include <worldpos_vertex>
2698
2698
  #include <clipping_planes_vertex>
2699
2699
  vWorldPosition = worldPosition.xyz;
2700
- }`,Bf=`#define DISTANCE
2700
+ }`,Md=`#define DISTANCE
2701
2701
  uniform vec3 referencePosition;
2702
2702
  uniform float nearDistance;
2703
2703
  uniform float farDistance;
@@ -2721,13 +2721,13 @@ void main () {
2721
2721
  dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
2722
2722
  dist = saturate( dist );
2723
2723
  gl_FragColor = packDepthToRGBA( dist );
2724
- }`,zf=`varying vec3 vWorldDirection;
2724
+ }`,yd=`varying vec3 vWorldDirection;
2725
2725
  #include <common>
2726
2726
  void main() {
2727
2727
  vWorldDirection = transformDirection( position, modelMatrix );
2728
2728
  #include <begin_vertex>
2729
2729
  #include <project_vertex>
2730
- }`,Hf=`uniform sampler2D tEquirect;
2730
+ }`,Sd=`uniform sampler2D tEquirect;
2731
2731
  varying vec3 vWorldDirection;
2732
2732
  #include <common>
2733
2733
  void main() {
@@ -2736,7 +2736,7 @@ void main() {
2736
2736
  gl_FragColor = texture2D( tEquirect, sampleUV );
2737
2737
  #include <tonemapping_fragment>
2738
2738
  #include <colorspace_fragment>
2739
- }`,kf=`uniform float scale;
2739
+ }`,Ed=`uniform float scale;
2740
2740
  attribute float lineDistance;
2741
2741
  varying float vLineDistance;
2742
2742
  #include <common>
@@ -2758,7 +2758,7 @@ void main() {
2758
2758
  #include <logdepthbuf_vertex>
2759
2759
  #include <clipping_planes_vertex>
2760
2760
  #include <fog_vertex>
2761
- }`,Vf=`uniform vec3 diffuse;
2761
+ }`,Td=`uniform vec3 diffuse;
2762
2762
  uniform float opacity;
2763
2763
  uniform float dashSize;
2764
2764
  uniform float totalSize;
@@ -2786,7 +2786,7 @@ void main() {
2786
2786
  #include <colorspace_fragment>
2787
2787
  #include <fog_fragment>
2788
2788
  #include <premultiplied_alpha_fragment>
2789
- }`,Gf=`#include <common>
2789
+ }`,bd=`#include <common>
2790
2790
  #include <batching_pars_vertex>
2791
2791
  #include <uv_pars_vertex>
2792
2792
  #include <envmap_pars_vertex>
@@ -2818,7 +2818,7 @@ void main() {
2818
2818
  #include <worldpos_vertex>
2819
2819
  #include <envmap_vertex>
2820
2820
  #include <fog_vertex>
2821
- }`,Wf=`uniform vec3 diffuse;
2821
+ }`,wd=`uniform vec3 diffuse;
2822
2822
  uniform float opacity;
2823
2823
  #ifndef FLAT_SHADED
2824
2824
  varying vec3 vNormal;
@@ -2866,7 +2866,7 @@ void main() {
2866
2866
  #include <fog_fragment>
2867
2867
  #include <premultiplied_alpha_fragment>
2868
2868
  #include <dithering_fragment>
2869
- }`,Xf=`#define LAMBERT
2869
+ }`,Ad=`#define LAMBERT
2870
2870
  varying vec3 vViewPosition;
2871
2871
  #include <common>
2872
2872
  #include <batching_pars_vertex>
@@ -2905,7 +2905,7 @@ void main() {
2905
2905
  #include <envmap_vertex>
2906
2906
  #include <shadowmap_vertex>
2907
2907
  #include <fog_vertex>
2908
- }`,qf=`#define LAMBERT
2908
+ }`,Rd=`#define LAMBERT
2909
2909
  uniform vec3 diffuse;
2910
2910
  uniform vec3 emissive;
2911
2911
  uniform float opacity;
@@ -2962,7 +2962,7 @@ void main() {
2962
2962
  #include <fog_fragment>
2963
2963
  #include <premultiplied_alpha_fragment>
2964
2964
  #include <dithering_fragment>
2965
- }`,Yf=`#define MATCAP
2965
+ }`,Cd=`#define MATCAP
2966
2966
  varying vec3 vViewPosition;
2967
2967
  #include <common>
2968
2968
  #include <batching_pars_vertex>
@@ -2996,7 +2996,7 @@ void main() {
2996
2996
  #include <clipping_planes_vertex>
2997
2997
  #include <fog_vertex>
2998
2998
  vViewPosition = - mvPosition.xyz;
2999
- }`,jf=`#define MATCAP
2999
+ }`,Pd=`#define MATCAP
3000
3000
  uniform vec3 diffuse;
3001
3001
  uniform float opacity;
3002
3002
  uniform sampler2D matcap;
@@ -3042,7 +3042,7 @@ void main() {
3042
3042
  #include <fog_fragment>
3043
3043
  #include <premultiplied_alpha_fragment>
3044
3044
  #include <dithering_fragment>
3045
- }`,Kf=`#define NORMAL
3045
+ }`,Dd=`#define NORMAL
3046
3046
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3047
3047
  varying vec3 vViewPosition;
3048
3048
  #endif
@@ -3075,7 +3075,7 @@ void main() {
3075
3075
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3076
3076
  vViewPosition = - mvPosition.xyz;
3077
3077
  #endif
3078
- }`,$f=`#define NORMAL
3078
+ }`,Ld=`#define NORMAL
3079
3079
  uniform float opacity;
3080
3080
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3081
3081
  varying vec3 vViewPosition;
@@ -3097,7 +3097,7 @@ void main() {
3097
3097
  #ifdef OPAQUE
3098
3098
  gl_FragColor.a = 1.0;
3099
3099
  #endif
3100
- }`,Zf=`#define PHONG
3100
+ }`,Id=`#define PHONG
3101
3101
  varying vec3 vViewPosition;
3102
3102
  #include <common>
3103
3103
  #include <batching_pars_vertex>
@@ -3136,7 +3136,7 @@ void main() {
3136
3136
  #include <envmap_vertex>
3137
3137
  #include <shadowmap_vertex>
3138
3138
  #include <fog_vertex>
3139
- }`,Jf=`#define PHONG
3139
+ }`,Ud=`#define PHONG
3140
3140
  uniform vec3 diffuse;
3141
3141
  uniform vec3 emissive;
3142
3142
  uniform vec3 specular;
@@ -3195,7 +3195,7 @@ void main() {
3195
3195
  #include <fog_fragment>
3196
3196
  #include <premultiplied_alpha_fragment>
3197
3197
  #include <dithering_fragment>
3198
- }`,Qf=`#define STANDARD
3198
+ }`,Nd=`#define STANDARD
3199
3199
  varying vec3 vViewPosition;
3200
3200
  #ifdef USE_TRANSMISSION
3201
3201
  varying vec3 vWorldPosition;
@@ -3238,7 +3238,7 @@ void main() {
3238
3238
  #ifdef USE_TRANSMISSION
3239
3239
  vWorldPosition = worldPosition.xyz;
3240
3240
  #endif
3241
- }`,ed=`#define STANDARD
3241
+ }`,Od=`#define STANDARD
3242
3242
  #ifdef PHYSICAL
3243
3243
  #define IOR
3244
3244
  #define USE_SPECULAR
@@ -3363,7 +3363,7 @@ void main() {
3363
3363
  #include <fog_fragment>
3364
3364
  #include <premultiplied_alpha_fragment>
3365
3365
  #include <dithering_fragment>
3366
- }`,td=`#define TOON
3366
+ }`,Fd=`#define TOON
3367
3367
  varying vec3 vViewPosition;
3368
3368
  #include <common>
3369
3369
  #include <batching_pars_vertex>
@@ -3400,7 +3400,7 @@ void main() {
3400
3400
  #include <worldpos_vertex>
3401
3401
  #include <shadowmap_vertex>
3402
3402
  #include <fog_vertex>
3403
- }`,nd=`#define TOON
3403
+ }`,Bd=`#define TOON
3404
3404
  uniform vec3 diffuse;
3405
3405
  uniform vec3 emissive;
3406
3406
  uniform float opacity;
@@ -3453,7 +3453,7 @@ void main() {
3453
3453
  #include <fog_fragment>
3454
3454
  #include <premultiplied_alpha_fragment>
3455
3455
  #include <dithering_fragment>
3456
- }`,id=`uniform float size;
3456
+ }`,zd=`uniform float size;
3457
3457
  uniform float scale;
3458
3458
  #include <common>
3459
3459
  #include <color_pars_vertex>
@@ -3484,7 +3484,7 @@ void main() {
3484
3484
  #include <clipping_planes_vertex>
3485
3485
  #include <worldpos_vertex>
3486
3486
  #include <fog_vertex>
3487
- }`,rd=`uniform vec3 diffuse;
3487
+ }`,Hd=`uniform vec3 diffuse;
3488
3488
  uniform float opacity;
3489
3489
  #include <common>
3490
3490
  #include <color_pars_fragment>
@@ -3509,7 +3509,7 @@ void main() {
3509
3509
  #include <colorspace_fragment>
3510
3510
  #include <fog_fragment>
3511
3511
  #include <premultiplied_alpha_fragment>
3512
- }`,sd=`#include <common>
3512
+ }`,kd=`#include <common>
3513
3513
  #include <batching_pars_vertex>
3514
3514
  #include <fog_pars_vertex>
3515
3515
  #include <morphtarget_pars_vertex>
@@ -3532,7 +3532,7 @@ void main() {
3532
3532
  #include <worldpos_vertex>
3533
3533
  #include <shadowmap_vertex>
3534
3534
  #include <fog_vertex>
3535
- }`,ad=`uniform vec3 color;
3535
+ }`,Gd=`uniform vec3 color;
3536
3536
  uniform float opacity;
3537
3537
  #include <common>
3538
3538
  #include <packing>
@@ -3548,7 +3548,7 @@ void main() {
3548
3548
  #include <tonemapping_fragment>
3549
3549
  #include <colorspace_fragment>
3550
3550
  #include <fog_fragment>
3551
- }`,od=`uniform float rotation;
3551
+ }`,Vd=`uniform float rotation;
3552
3552
  uniform vec2 center;
3553
3553
  #include <common>
3554
3554
  #include <uv_pars_vertex>
@@ -3572,7 +3572,7 @@ void main() {
3572
3572
  #include <logdepthbuf_vertex>
3573
3573
  #include <clipping_planes_vertex>
3574
3574
  #include <fog_vertex>
3575
- }`,ld=`uniform vec3 diffuse;
3575
+ }`,Wd=`uniform vec3 diffuse;
3576
3576
  uniform float opacity;
3577
3577
  #include <common>
3578
3578
  #include <uv_pars_fragment>
@@ -3597,7 +3597,7 @@ void main() {
3597
3597
  #include <tonemapping_fragment>
3598
3598
  #include <colorspace_fragment>
3599
3599
  #include <fog_fragment>
3600
- }`,ze={alphahash_fragment:Ch,alphahash_pars_fragment:Ph,alphamap_fragment:Dh,alphamap_pars_fragment:Lh,alphatest_fragment:Ih,alphatest_pars_fragment:Uh,aomap_fragment:Nh,aomap_pars_fragment:Fh,batching_pars_vertex:Oh,batching_vertex:Bh,begin_vertex:zh,beginnormal_vertex:Hh,bsdfs:kh,iridescence_fragment:Vh,bumpmap_pars_fragment:Gh,clipping_planes_fragment:Wh,clipping_planes_pars_fragment:Xh,clipping_planes_pars_vertex:qh,clipping_planes_vertex:Yh,color_fragment:jh,color_pars_fragment:Kh,color_pars_vertex:$h,color_vertex:Zh,common:Jh,cube_uv_reflection_fragment:Qh,defaultnormal_vertex:eu,displacementmap_pars_vertex:tu,displacementmap_vertex:nu,emissivemap_fragment:iu,emissivemap_pars_fragment:ru,colorspace_fragment:su,colorspace_pars_fragment:au,envmap_fragment:ou,envmap_common_pars_fragment:lu,envmap_pars_fragment:cu,envmap_pars_vertex:hu,envmap_physical_pars_fragment:Su,envmap_vertex:uu,fog_vertex:fu,fog_pars_vertex:du,fog_fragment:pu,fog_pars_fragment:mu,gradientmap_pars_fragment:_u,lightmap_pars_fragment:gu,lights_lambert_fragment:vu,lights_lambert_pars_fragment:xu,lights_pars_begin:Mu,lights_toon_fragment:yu,lights_toon_pars_fragment:Eu,lights_phong_fragment:Tu,lights_phong_pars_fragment:bu,lights_physical_fragment:Au,lights_physical_pars_fragment:wu,lights_fragment_begin:Ru,lights_fragment_maps:Cu,lights_fragment_end:Pu,logdepthbuf_fragment:Du,logdepthbuf_pars_fragment:Lu,logdepthbuf_pars_vertex:Iu,logdepthbuf_vertex:Uu,map_fragment:Nu,map_pars_fragment:Fu,map_particle_fragment:Ou,map_particle_pars_fragment:Bu,metalnessmap_fragment:zu,metalnessmap_pars_fragment:Hu,morphinstance_vertex:ku,morphcolor_vertex:Vu,morphnormal_vertex:Gu,morphtarget_pars_vertex:Wu,morphtarget_vertex:Xu,normal_fragment_begin:qu,normal_fragment_maps:Yu,normal_pars_fragment:ju,normal_pars_vertex:Ku,normal_vertex:$u,normalmap_pars_fragment:Zu,clearcoat_normal_fragment_begin:Ju,clearcoat_normal_fragment_maps:Qu,clearcoat_pars_fragment:ef,iridescence_pars_fragment:tf,opaque_fragment:nf,packing:rf,premultiplied_alpha_fragment:sf,project_vertex:af,dithering_fragment:of,dithering_pars_fragment:lf,roughnessmap_fragment:cf,roughnessmap_pars_fragment:hf,shadowmap_pars_fragment:uf,shadowmap_pars_vertex:ff,shadowmap_vertex:df,shadowmask_pars_fragment:pf,skinbase_vertex:mf,skinning_pars_vertex:_f,skinning_vertex:gf,skinnormal_vertex:vf,specularmap_fragment:xf,specularmap_pars_fragment:Mf,tonemapping_fragment:Sf,tonemapping_pars_fragment:yf,transmission_fragment:Ef,transmission_pars_fragment:Tf,uv_pars_fragment:bf,uv_pars_vertex:Af,uv_vertex:wf,worldpos_vertex:Rf,background_vert:Cf,background_frag:Pf,backgroundCube_vert:Df,backgroundCube_frag:Lf,cube_vert:If,cube_frag:Uf,depth_vert:Nf,depth_frag:Ff,distanceRGBA_vert:Of,distanceRGBA_frag:Bf,equirect_vert:zf,equirect_frag:Hf,linedashed_vert:kf,linedashed_frag:Vf,meshbasic_vert:Gf,meshbasic_frag:Wf,meshlambert_vert:Xf,meshlambert_frag:qf,meshmatcap_vert:Yf,meshmatcap_frag:jf,meshnormal_vert:Kf,meshnormal_frag:$f,meshphong_vert:Zf,meshphong_frag:Jf,meshphysical_vert:Qf,meshphysical_frag:ed,meshtoon_vert:td,meshtoon_frag:nd,points_vert:id,points_frag:rd,shadow_vert:sd,shadow_frag:ad,sprite_vert:od,sprite_frag:ld},fe={common:{diffuse:{value:new Ge(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Oe},alphaMap:{value:null},alphaMapTransform:{value:new Oe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Oe}},envmap:{envMap:{value:null},envMapRotation:{value:new Oe},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Oe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Oe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Oe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Oe},normalScale:{value:new Fe(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Oe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Oe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Oe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Oe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ge(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 Ge(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Oe},alphaTest:{value:0},uvTransform:{value:new Oe}},sprite:{diffuse:{value:new Ge(16777215)},opacity:{value:1},center:{value:new Fe(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Oe},alphaMap:{value:null},alphaMapTransform:{value:new Oe},alphaTest:{value:0}}},qt={basic:{uniforms:Mt([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.fog]),vertexShader:ze.meshbasic_vert,fragmentShader:ze.meshbasic_frag},lambert:{uniforms:Mt([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,fe.lights,{emissive:{value:new Ge(0)}}]),vertexShader:ze.meshlambert_vert,fragmentShader:ze.meshlambert_frag},phong:{uniforms:Mt([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,fe.lights,{emissive:{value:new Ge(0)},specular:{value:new Ge(1118481)},shininess:{value:30}}]),vertexShader:ze.meshphong_vert,fragmentShader:ze.meshphong_frag},standard:{uniforms:Mt([fe.common,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.roughnessmap,fe.metalnessmap,fe.fog,fe.lights,{emissive:{value:new Ge(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ze.meshphysical_vert,fragmentShader:ze.meshphysical_frag},toon:{uniforms:Mt([fe.common,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.gradientmap,fe.fog,fe.lights,{emissive:{value:new Ge(0)}}]),vertexShader:ze.meshtoon_vert,fragmentShader:ze.meshtoon_frag},matcap:{uniforms:Mt([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,{matcap:{value:null}}]),vertexShader:ze.meshmatcap_vert,fragmentShader:ze.meshmatcap_frag},points:{uniforms:Mt([fe.points,fe.fog]),vertexShader:ze.points_vert,fragmentShader:ze.points_frag},dashed:{uniforms:Mt([fe.common,fe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ze.linedashed_vert,fragmentShader:ze.linedashed_frag},depth:{uniforms:Mt([fe.common,fe.displacementmap]),vertexShader:ze.depth_vert,fragmentShader:ze.depth_frag},normal:{uniforms:Mt([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,{opacity:{value:1}}]),vertexShader:ze.meshnormal_vert,fragmentShader:ze.meshnormal_frag},sprite:{uniforms:Mt([fe.sprite,fe.fog]),vertexShader:ze.sprite_vert,fragmentShader:ze.sprite_frag},background:{uniforms:{uvTransform:{value:new Oe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ze.background_vert,fragmentShader:ze.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Oe}},vertexShader:ze.backgroundCube_vert,fragmentShader:ze.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ze.cube_vert,fragmentShader:ze.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ze.equirect_vert,fragmentShader:ze.equirect_frag},distanceRGBA:{uniforms:Mt([fe.common,fe.displacementmap,{referencePosition:{value:new B},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ze.distanceRGBA_vert,fragmentShader:ze.distanceRGBA_frag},shadow:{uniforms:Mt([fe.lights,fe.fog,{color:{value:new Ge(0)},opacity:{value:1}}]),vertexShader:ze.shadow_vert,fragmentShader:ze.shadow_frag}};qt.physical={uniforms:Mt([qt.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Oe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Oe},clearcoatNormalScale:{value:new Fe(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Oe},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Oe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Oe},sheen:{value:0},sheenColor:{value:new Ge(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Oe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Oe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Oe},transmissionSamplerSize:{value:new Fe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Oe},attenuationDistance:{value:0},attenuationColor:{value:new Ge(0)},specularColor:{value:new Ge(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Oe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Oe},anisotropyVector:{value:new Fe},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Oe}}]),vertexShader:ze.meshphysical_vert,fragmentShader:ze.meshphysical_frag};const cr={r:0,b:0,g:0},Cn=new Jt,cd=new st;function hd(i,e,t,n,r,s,a){const o=new Ge(0);let c=s===!0?0:1,l,u,f=null,d=0,m=null;function v(C){let g=C.isScene===!0?C.background:null;return g&&g.isTexture&&(g=(C.backgroundBlurriness>0?t:e).get(g)),g}function S(C){let g=!1;const E=v(C);E===null?h(o,c):E&&E.isColor&&(h(E,1),g=!0);const T=i.xr.getEnvironmentBlendMode();T==="additive"?n.buffers.color.setClear(0,0,0,1,a):T==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||g)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function p(C,g){const E=v(g);E&&(E.isCubeTexture||E.mapping===Cr)?(u===void 0&&(u=new Kt(new Fi(1,1,1),new Sn({name:"BackgroundCubeMaterial",uniforms:di(qt.backgroundCube.uniforms),vertexShader:qt.backgroundCube.vertexShader,fragmentShader:qt.backgroundCube.fragmentShader,side:bt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(T,A,I){this.matrixWorld.copyPosition(I.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),Cn.copy(g.backgroundRotation),Cn.x*=-1,Cn.y*=-1,Cn.z*=-1,E.isCubeTexture&&E.isRenderTargetTexture===!1&&(Cn.y*=-1,Cn.z*=-1),u.material.uniforms.envMap.value=E,u.material.uniforms.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=g.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=g.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(cd.makeRotationFromEuler(Cn)),u.material.toneMapped=Ye.getTransfer(E.colorSpace)!==$e,(f!==E||d!==E.version||m!==i.toneMapping)&&(u.material.needsUpdate=!0,f=E,d=E.version,m=i.toneMapping),u.layers.enableAll(),C.unshift(u,u.geometry,u.material,0,0,null)):E&&E.isTexture&&(l===void 0&&(l=new Kt(new Lr(2,2),new Sn({name:"BackgroundMaterial",uniforms:di(qt.background.uniforms),vertexShader:qt.background.vertexShader,fragmentShader:qt.background.fragmentShader,side:Mn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=E,l.material.uniforms.backgroundIntensity.value=g.backgroundIntensity,l.material.toneMapped=Ye.getTransfer(E.colorSpace)!==$e,E.matrixAutoUpdate===!0&&E.updateMatrix(),l.material.uniforms.uvTransform.value.copy(E.matrix),(f!==E||d!==E.version||m!==i.toneMapping)&&(l.material.needsUpdate=!0,f=E,d=E.version,m=i.toneMapping),l.layers.enableAll(),C.unshift(l,l.geometry,l.material,0,0,null))}function h(C,g){C.getRGB(cr,Sl(i)),n.buffers.color.setClear(cr.r,cr.g,cr.b,g,a)}function L(){u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return o},setClearColor:function(C,g=1){o.set(C),c=g,h(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(C){c=C,h(o,c)},render:S,addToRenderList:p,dispose:L}}function ud(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=d(null);let s=r,a=!1;function o(M,U,W,Z,te){let ne=!1;const ee=f(Z,W,U);s!==ee&&(s=ee,l(s.object)),ne=m(M,Z,W,te),ne&&v(M,Z,W,te),te!==null&&e.update(te,i.ELEMENT_ARRAY_BUFFER),(ne||a)&&(a=!1,g(M,U,W,Z),te!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(te).buffer))}function c(){return i.createVertexArray()}function l(M){return i.bindVertexArray(M)}function u(M){return i.deleteVertexArray(M)}function f(M,U,W){const Z=W.wireframe===!0;let te=n[M.id];te===void 0&&(te={},n[M.id]=te);let ne=te[U.id];ne===void 0&&(ne={},te[U.id]=ne);let ee=ne[Z];return ee===void 0&&(ee=d(c()),ne[Z]=ee),ee}function d(M){const U=[],W=[],Z=[];for(let te=0;te<t;te++)U[te]=0,W[te]=0,Z[te]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:U,enabledAttributes:W,attributeDivisors:Z,object:M,attributes:{},index:null}}function m(M,U,W,Z){const te=s.attributes,ne=U.attributes;let ee=0;const le=W.getAttributes();for(const j in le)if(le[j].location>=0){const me=te[j];let be=ne[j];if(be===void 0&&(j==="instanceMatrix"&&M.instanceMatrix&&(be=M.instanceMatrix),j==="instanceColor"&&M.instanceColor&&(be=M.instanceColor)),me===void 0||me.attribute!==be||be&&me.data!==be.data)return!0;ee++}return s.attributesNum!==ee||s.index!==Z}function v(M,U,W,Z){const te={},ne=U.attributes;let ee=0;const le=W.getAttributes();for(const j in le)if(le[j].location>=0){let me=ne[j];me===void 0&&(j==="instanceMatrix"&&M.instanceMatrix&&(me=M.instanceMatrix),j==="instanceColor"&&M.instanceColor&&(me=M.instanceColor));const be={};be.attribute=me,me&&me.data&&(be.data=me.data),te[j]=be,ee++}s.attributes=te,s.attributesNum=ee,s.index=Z}function S(){const M=s.newAttributes;for(let U=0,W=M.length;U<W;U++)M[U]=0}function p(M){h(M,0)}function h(M,U){const W=s.newAttributes,Z=s.enabledAttributes,te=s.attributeDivisors;W[M]=1,Z[M]===0&&(i.enableVertexAttribArray(M),Z[M]=1),te[M]!==U&&(i.vertexAttribDivisor(M,U),te[M]=U)}function L(){const M=s.newAttributes,U=s.enabledAttributes;for(let W=0,Z=U.length;W<Z;W++)U[W]!==M[W]&&(i.disableVertexAttribArray(W),U[W]=0)}function C(M,U,W,Z,te,ne,ee){ee===!0?i.vertexAttribIPointer(M,U,W,te,ne):i.vertexAttribPointer(M,U,W,Z,te,ne)}function g(M,U,W,Z){S();const te=Z.attributes,ne=W.getAttributes(),ee=U.defaultAttributeValues;for(const le in ne){const j=ne[le];if(j.location>=0){let ue=te[le];if(ue===void 0&&(le==="instanceMatrix"&&M.instanceMatrix&&(ue=M.instanceMatrix),le==="instanceColor"&&M.instanceColor&&(ue=M.instanceColor)),ue!==void 0){const me=ue.normalized,be=ue.itemSize,Be=e.get(ue);if(Be===void 0)continue;const de=Be.buffer,je=Be.type,Xe=Be.bytesPerElement,Y=je===i.INT||je===i.UNSIGNED_INT||ue.gpuType===va;if(ue.isInterleavedBufferAttribute){const se=ue.data,ve=se.stride,De=ue.offset;if(se.isInstancedInterleavedBuffer){for(let Ae=0;Ae<j.locationSize;Ae++)h(j.location+Ae,se.meshPerAttribute);M.isInstancedMesh!==!0&&Z._maxInstanceCount===void 0&&(Z._maxInstanceCount=se.meshPerAttribute*se.count)}else for(let Ae=0;Ae<j.locationSize;Ae++)p(j.location+Ae);i.bindBuffer(i.ARRAY_BUFFER,de);for(let Ae=0;Ae<j.locationSize;Ae++)C(j.location+Ae,be/j.locationSize,je,me,ve*Xe,(De+be/j.locationSize*Ae)*Xe,Y)}else{if(ue.isInstancedBufferAttribute){for(let se=0;se<j.locationSize;se++)h(j.location+se,ue.meshPerAttribute);M.isInstancedMesh!==!0&&Z._maxInstanceCount===void 0&&(Z._maxInstanceCount=ue.meshPerAttribute*ue.count)}else for(let se=0;se<j.locationSize;se++)p(j.location+se);i.bindBuffer(i.ARRAY_BUFFER,de);for(let se=0;se<j.locationSize;se++)C(j.location+se,be/j.locationSize,je,me,be*Xe,be/j.locationSize*se*Xe,Y)}}else if(ee!==void 0){const me=ee[le];if(me!==void 0)switch(me.length){case 2:i.vertexAttrib2fv(j.location,me);break;case 3:i.vertexAttrib3fv(j.location,me);break;case 4:i.vertexAttrib4fv(j.location,me);break;default:i.vertexAttrib1fv(j.location,me)}}}}L()}function E(){I();for(const M in n){const U=n[M];for(const W in U){const Z=U[W];for(const te in Z)u(Z[te].object),delete Z[te];delete U[W]}delete n[M]}}function T(M){if(n[M.id]===void 0)return;const U=n[M.id];for(const W in U){const Z=U[W];for(const te in Z)u(Z[te].object),delete Z[te];delete U[W]}delete n[M.id]}function A(M){for(const U in n){const W=n[U];if(W[M.id]===void 0)continue;const Z=W[M.id];for(const te in Z)u(Z[te].object),delete Z[te];delete W[M.id]}}function I(){y(),a=!0,s!==r&&(s=r,l(s.object))}function y(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:I,resetDefaultState:y,dispose:E,releaseStatesOfGeometry:T,releaseStatesOfProgram:A,initAttributes:S,enableAttribute:p,disableUnusedAttributes:L}}function fd(i,e,t){let n;function r(l){n=l}function s(l,u){i.drawArrays(n,l,u),t.update(u,n,1)}function a(l,u,f){f!==0&&(i.drawArraysInstanced(n,l,u,f),t.update(u,n,f))}function o(l,u,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,u,0,f);let m=0;for(let v=0;v<f;v++)m+=u[v];t.update(m,n,1)}function c(l,u,f,d){if(f===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let v=0;v<l.length;v++)a(l[v],u[v],d[v]);else{m.multiDrawArraysInstancedWEBGL(n,l,0,u,0,d,0,f);let v=0;for(let S=0;S<f;S++)v+=u[S]*d[S];t.update(v,n,1)}}this.setMode=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=c}function dd(i,e,t,n){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=i.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(A){return!(A!==Wt&&n.convert(A)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(A){const I=A===Ii&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(A!==Zt&&n.convert(A)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&A!==on&&!I)}function c(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 l=t.precision!==void 0?t.precision:"highp";const u=c(l);u!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",u,"instead."),l=u);const f=t.logarithmicDepthBuffer===!0,d=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),m=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),v=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),S=i.getParameter(i.MAX_TEXTURE_SIZE),p=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),h=i.getParameter(i.MAX_VERTEX_ATTRIBS),L=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),C=i.getParameter(i.MAX_VARYING_VECTORS),g=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),E=v>0,T=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:f,reversedDepthBuffer:d,maxTextures:m,maxVertexTextures:v,maxTextureSize:S,maxCubemapSize:p,maxAttributes:h,maxVertexUniforms:L,maxVaryings:C,maxFragmentUniforms:g,vertexTextures:E,maxSamples:T}}function pd(i){const e=this;let t=null,n=0,r=!1,s=!1;const a=new mn,o=new Oe,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,d){const m=f.length!==0||d||n!==0||r;return r=d,n=f.length,m},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,d){t=u(f,d,0)},this.setState=function(f,d,m){const v=f.clippingPlanes,S=f.clipIntersection,p=f.clipShadows,h=i.get(f);if(!r||v===null||v.length===0||s&&!p)s?u(null):l();else{const L=s?0:n,C=L*4;let g=h.clippingState||null;c.value=g,g=u(v,d,C,m);for(let E=0;E!==C;++E)g[E]=t[E];h.clippingState=g,this.numIntersection=S?this.numPlanes:0,this.numPlanes+=L}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(f,d,m,v){const S=f!==null?f.length:0;let p=null;if(S!==0){if(p=c.value,v!==!0||p===null){const h=m+S*4,L=d.matrixWorldInverse;o.getNormalMatrix(L),(p===null||p.length<h)&&(p=new Float32Array(h));for(let C=0,g=m;C!==S;++C,g+=4)a.copy(f[C]).applyMatrix4(L,o),a.normal.toArray(p,g),p[g+3]=a.constant}c.value=p,c.needsUpdate=!0}return e.numPlanes=S,e.numIntersection=0,p}}function md(i){let e=new WeakMap;function t(a,o){return o===ws?a.mapping=hi:o===Rs&&(a.mapping=ui),a}function n(a){if(a&&a.isTexture){const o=a.mapping;if(o===ws||o===Rs)if(e.has(a)){const c=e.get(a).texture;return t(c,a.mapping)}else{const c=a.image;if(c&&c.height>0){const l=new oh(c.height);return l.fromEquirectangularTexture(i,a),e.set(a,l),a.addEventListener("dispose",r),t(l.texture,a.mapping)}else return null}}return a}function r(a){const o=a.target;o.removeEventListener("dispose",r);const c=e.get(o);c!==void 0&&(e.delete(o),c.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}const si=4,bo=[.125,.215,.35,.446,.526,.582],In=20,hs=new wl,Ao=new Ge;let us=null,fs=0,ds=0,ps=!1;const Dn=(1+Math.sqrt(5))/2,ni=1/Dn,wo=[new B(-Dn,ni,0),new B(Dn,ni,0),new B(-ni,0,Dn),new B(ni,0,Dn),new B(0,Dn,-ni),new B(0,Dn,ni),new B(-1,1,-1),new B(1,1,-1),new B(-1,1,1),new B(1,1,1)],_d=new B;class Ro{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,n=.1,r=100,s={}){const{size:a=256,position:o=_d}=s;us=this._renderer.getRenderTarget(),fs=this._renderer.getActiveCubeFace(),ds=this._renderer.getActiveMipmapLevel(),ps=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,n,r,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Do(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Po(),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(us,fs,ds),this._renderer.xr.enabled=ps,e.scissorTest=!1,hr(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===hi||e.mapping===ui?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),us=this._renderer.getRenderTarget(),fs=this._renderer.getActiveCubeFace(),ds=this._renderer.getActiveMipmapLevel(),ps=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Yt,minFilter:Yt,generateMipmaps:!1,type:Ii,format:Wt,colorSpace:fi,depthBuffer:!1},r=Co(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Co(e,t,n);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=gd(s)),this._blurMaterial=vd(s,e,t)}return r}_compileMaterial(e){const t=new Kt(this._lodPlanes[0],e);this._renderer.compile(t,hs)}_sceneToCubeUV(e,t,n,r,s){const c=new Ot(90,1,t,n),l=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],f=this._renderer,d=f.autoClear,m=f.toneMapping;f.getClearColor(Ao),f.toneMapping=vn,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(r),f.clearDepth(),f.setRenderTarget(null));const S=new vl({name:"PMREM.Background",side:bt,depthWrite:!1,depthTest:!1}),p=new Kt(new Fi,S);let h=!1;const L=e.background;L?L.isColor&&(S.color.copy(L),e.background=null,h=!0):(S.color.copy(Ao),h=!0);for(let C=0;C<6;C++){const g=C%3;g===0?(c.up.set(0,l[C],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x+u[C],s.y,s.z)):g===1?(c.up.set(0,0,l[C]),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y+u[C],s.z)):(c.up.set(0,l[C],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y,s.z+u[C]));const E=this._cubeSize;hr(r,g*E,C>2?E:0,E,E),f.setRenderTarget(r),h&&f.render(p,c),f.render(e,c)}p.geometry.dispose(),p.material.dispose(),f.toneMapping=m,f.autoClear=d,e.background=L}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===hi||e.mapping===ui;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Do()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Po());const s=r?this._cubemapMaterial:this._equirectMaterial,a=new Kt(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=e;const c=this._cubeSize;hr(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(a,hs)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;s<r;s++){const a=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),o=wo[(r-s-1)%wo.length];this._blur(e,s-1,s,a,o)}t.autoClear=n}_blur(e,t,n,r,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,"latitudinal",s),this._halfBlur(a,e,n,n,r,"longitudinal",s)}_halfBlur(e,t,n,r,s,a,o){const c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,f=new Kt(this._lodPlanes[r],l),d=l.uniforms,m=this._sizeLods[n]-1,v=isFinite(s)?Math.PI/(2*m):2*Math.PI/(2*In-1),S=s/v,p=isFinite(s)?1+Math.floor(u*S):In;p>In&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${p} samples when the maximum is set to ${In}`);const h=[];let L=0;for(let A=0;A<In;++A){const I=A/S,y=Math.exp(-I*I/2);h.push(y),A===0?L+=y:A<p&&(L+=2*y)}for(let A=0;A<h.length;A++)h[A]=h[A]/L;d.envMap.value=e.texture,d.samples.value=p,d.weights.value=h,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:C}=this;d.dTheta.value=v,d.mipInt.value=C-n;const g=this._sizeLods[r],E=3*g*(r>C-si?r-C+si:0),T=4*(this._cubeSize-g);hr(t,E,T,3*g,2*g),c.setRenderTarget(t),c.render(f,hs)}}function gd(i){const e=[],t=[],n=[];let r=i;const s=i-si+1+bo.length;for(let a=0;a<s;a++){const o=Math.pow(2,r);t.push(o);let c=1/o;a>i-si?c=bo[a-i+si-1]:a===0&&(c=0),n.push(c);const l=1/(o-2),u=-l,f=1+l,d=[u,u,f,u,f,f,u,u,f,f,u,f],m=6,v=6,S=3,p=2,h=1,L=new Float32Array(S*v*m),C=new Float32Array(p*v*m),g=new Float32Array(h*v*m);for(let T=0;T<m;T++){const A=T%3*2/3-1,I=T>2?0:-1,y=[A,I,0,A+2/3,I,0,A+2/3,I+1,0,A,I,0,A+2/3,I+1,0,A,I+1,0];L.set(y,S*v*T),C.set(d,p*v*T);const M=[T,T,T,T,T,T];g.set(M,h*v*T)}const E=new Dt;E.setAttribute("position",new $t(L,S)),E.setAttribute("uv",new $t(C,p)),E.setAttribute("faceIndex",new $t(g,h)),e.push(E),r>si&&r--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function Co(i,e,t){const n=new Hn(i,e,t);return n.texture.mapping=Cr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function hr(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function vd(i,e,t){const n=new Float32Array(In),r=new B(0,1,0);return new Sn({name:"SphericalGaussianBlur",defines:{n:In,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,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:r}},vertexShader:Ca(),fragmentShader:`
3600
+ }`,He={alphahash_fragment:uu,alphahash_pars_fragment:fu,alphamap_fragment:du,alphamap_pars_fragment:pu,alphatest_fragment:mu,alphatest_pars_fragment:_u,aomap_fragment:gu,aomap_pars_fragment:vu,batching_pars_vertex:xu,batching_vertex:Mu,begin_vertex:yu,beginnormal_vertex:Su,bsdfs:Eu,iridescence_fragment:Tu,bumpmap_pars_fragment:bu,clipping_planes_fragment:wu,clipping_planes_pars_fragment:Au,clipping_planes_pars_vertex:Ru,clipping_planes_vertex:Cu,color_fragment:Pu,color_pars_fragment:Du,color_pars_vertex:Lu,color_vertex:Iu,common:Uu,cube_uv_reflection_fragment:Nu,defaultnormal_vertex:Ou,displacementmap_pars_vertex:Fu,displacementmap_vertex:Bu,emissivemap_fragment:zu,emissivemap_pars_fragment:Hu,colorspace_fragment:ku,colorspace_pars_fragment:Gu,envmap_fragment:Vu,envmap_common_pars_fragment:Wu,envmap_pars_fragment:Xu,envmap_pars_vertex:Yu,envmap_physical_pars_fragment:rf,envmap_vertex:qu,fog_vertex:ju,fog_pars_vertex:Zu,fog_fragment:$u,fog_pars_fragment:Ku,gradientmap_pars_fragment:Qu,lightmap_pars_fragment:Ju,lights_lambert_fragment:ef,lights_lambert_pars_fragment:tf,lights_pars_begin:nf,lights_toon_fragment:sf,lights_toon_pars_fragment:of,lights_phong_fragment:af,lights_phong_pars_fragment:lf,lights_physical_fragment:cf,lights_physical_pars_fragment:hf,lights_fragment_begin:uf,lights_fragment_maps:ff,lights_fragment_end:df,logdepthbuf_fragment:pf,logdepthbuf_pars_fragment:mf,logdepthbuf_pars_vertex:_f,logdepthbuf_vertex:gf,map_fragment:vf,map_pars_fragment:xf,map_particle_fragment:Mf,map_particle_pars_fragment:yf,metalnessmap_fragment:Sf,metalnessmap_pars_fragment:Ef,morphinstance_vertex:Tf,morphcolor_vertex:bf,morphnormal_vertex:wf,morphtarget_pars_vertex:Af,morphtarget_vertex:Rf,normal_fragment_begin:Cf,normal_fragment_maps:Pf,normal_pars_fragment:Df,normal_pars_vertex:Lf,normal_vertex:If,normalmap_pars_fragment:Uf,clearcoat_normal_fragment_begin:Nf,clearcoat_normal_fragment_maps:Of,clearcoat_pars_fragment:Ff,iridescence_pars_fragment:Bf,opaque_fragment:zf,packing:Hf,premultiplied_alpha_fragment:kf,project_vertex:Gf,dithering_fragment:Vf,dithering_pars_fragment:Wf,roughnessmap_fragment:Xf,roughnessmap_pars_fragment:Yf,shadowmap_pars_fragment:qf,shadowmap_pars_vertex:jf,shadowmap_vertex:Zf,shadowmask_pars_fragment:$f,skinbase_vertex:Kf,skinning_pars_vertex:Qf,skinning_vertex:Jf,skinnormal_vertex:ed,specularmap_fragment:td,specularmap_pars_fragment:nd,tonemapping_fragment:id,tonemapping_pars_fragment:rd,transmission_fragment:sd,transmission_pars_fragment:od,uv_pars_fragment:ad,uv_pars_vertex:ld,uv_vertex:cd,worldpos_vertex:hd,background_vert:ud,background_frag:fd,backgroundCube_vert:dd,backgroundCube_frag:pd,cube_vert:md,cube_frag:_d,depth_vert:gd,depth_frag:vd,distanceRGBA_vert:xd,distanceRGBA_frag:Md,equirect_vert:yd,equirect_frag:Sd,linedashed_vert:Ed,linedashed_frag:Td,meshbasic_vert:bd,meshbasic_frag:wd,meshlambert_vert:Ad,meshlambert_frag:Rd,meshmatcap_vert:Cd,meshmatcap_frag:Pd,meshnormal_vert:Dd,meshnormal_frag:Ld,meshphong_vert:Id,meshphong_frag:Ud,meshphysical_vert:Nd,meshphysical_frag:Od,meshtoon_vert:Fd,meshtoon_frag:Bd,points_vert:zd,points_frag:Hd,shadow_vert:kd,shadow_frag:Gd,sprite_vert:Vd,sprite_frag:Wd},de={common:{diffuse:{value:new We(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ze},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ze}},envmap:{envMap:{value:null},envMapRotation:{value:new ze},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ze}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ze}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ze},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ze},normalScale:{value:new Ue(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ze},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ze}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ze}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ze}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new We(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 We(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0},uvTransform:{value:new ze}},sprite:{diffuse:{value:new We(16777215)},opacity:{value:1},center:{value:new Ue(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ze},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0}}},sn={basic:{uniforms:Ct([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.fog]),vertexShader:He.meshbasic_vert,fragmentShader:He.meshbasic_frag},lambert:{uniforms:Ct([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.fog,de.lights,{emissive:{value:new We(0)}}]),vertexShader:He.meshlambert_vert,fragmentShader:He.meshlambert_frag},phong:{uniforms:Ct([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.fog,de.lights,{emissive:{value:new We(0)},specular:{value:new We(1118481)},shininess:{value:30}}]),vertexShader:He.meshphong_vert,fragmentShader:He.meshphong_frag},standard:{uniforms:Ct([de.common,de.envmap,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.roughnessmap,de.metalnessmap,de.fog,de.lights,{emissive:{value:new We(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:He.meshphysical_vert,fragmentShader:He.meshphysical_frag},toon:{uniforms:Ct([de.common,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.gradientmap,de.fog,de.lights,{emissive:{value:new We(0)}}]),vertexShader:He.meshtoon_vert,fragmentShader:He.meshtoon_frag},matcap:{uniforms:Ct([de.common,de.bumpmap,de.normalmap,de.displacementmap,de.fog,{matcap:{value:null}}]),vertexShader:He.meshmatcap_vert,fragmentShader:He.meshmatcap_frag},points:{uniforms:Ct([de.points,de.fog]),vertexShader:He.points_vert,fragmentShader:He.points_frag},dashed:{uniforms:Ct([de.common,de.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:He.linedashed_vert,fragmentShader:He.linedashed_frag},depth:{uniforms:Ct([de.common,de.displacementmap]),vertexShader:He.depth_vert,fragmentShader:He.depth_frag},normal:{uniforms:Ct([de.common,de.bumpmap,de.normalmap,de.displacementmap,{opacity:{value:1}}]),vertexShader:He.meshnormal_vert,fragmentShader:He.meshnormal_frag},sprite:{uniforms:Ct([de.sprite,de.fog]),vertexShader:He.sprite_vert,fragmentShader:He.sprite_frag},background:{uniforms:{uvTransform:{value:new ze},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:He.background_vert,fragmentShader:He.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ze}},vertexShader:He.backgroundCube_vert,fragmentShader:He.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:He.cube_vert,fragmentShader:He.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:He.equirect_vert,fragmentShader:He.equirect_frag},distanceRGBA:{uniforms:Ct([de.common,de.displacementmap,{referencePosition:{value:new U},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:He.distanceRGBA_vert,fragmentShader:He.distanceRGBA_frag},shadow:{uniforms:Ct([de.lights,de.fog,{color:{value:new We(0)},opacity:{value:1}}]),vertexShader:He.shadow_vert,fragmentShader:He.shadow_frag}};sn.physical={uniforms:Ct([sn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ze},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ze},clearcoatNormalScale:{value:new Ue(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ze},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ze},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ze},sheen:{value:0},sheenColor:{value:new We(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ze},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ze},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ze},transmissionSamplerSize:{value:new Ue},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ze},attenuationDistance:{value:0},attenuationColor:{value:new We(0)},specularColor:{value:new We(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ze},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ze},anisotropyVector:{value:new Ue},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ze}}]),vertexShader:He.meshphysical_vert,fragmentShader:He.meshphysical_frag};const wr={r:0,b:0,g:0},zn=new tn,Xd=new ot;function Yd(i,e,t,n,r,s,o){const a=new We(0);let c=s===!0?0:1,l,u,f=null,d=0,m=null;function g(b){let _=b.isScene===!0?b.background:null;return _&&_.isTexture&&(_=(b.backgroundBlurriness>0?t:e).get(_)),_}function y(b){let _=!1;const T=g(b);T===null?h(a,c):T&&T.isColor&&(h(T,1),_=!0);const E=i.xr.getEnvironmentBlendMode();E==="additive"?n.buffers.color.setClear(0,0,0,1,o):E==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,o),(i.autoClear||_)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function p(b,_){const T=g(_);T&&(T.isCubeTexture||T.mapping===Kr)?(u===void 0&&(u=new _e(new mt(1,1,1),new Ln({name:"BackgroundCubeMaterial",uniforms:wi(sn.backgroundCube.uniforms),vertexShader:sn.backgroundCube.vertexShader,fragmentShader:sn.backgroundCube.fragmentShader,side:Ut,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(E,A,C){this.matrixWorld.copyPosition(C.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),zn.copy(_.backgroundRotation),zn.x*=-1,zn.y*=-1,zn.z*=-1,T.isCubeTexture&&T.isRenderTargetTexture===!1&&(zn.y*=-1,zn.z*=-1),u.material.uniforms.envMap.value=T,u.material.uniforms.flipEnvMap.value=T.isCubeTexture&&T.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=_.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(Xd.makeRotationFromEuler(zn)),u.material.toneMapped=Ze.getTransfer(T.colorSpace)!==Qe,(f!==T||d!==T.version||m!==i.toneMapping)&&(u.material.needsUpdate=!0,f=T,d=T.version,m=i.toneMapping),u.layers.enableAll(),b.unshift(u,u.geometry,u.material,0,0,null)):T&&T.isTexture&&(l===void 0&&(l=new _e(new er(2,2),new Ln({name:"BackgroundMaterial",uniforms:wi(sn.background.uniforms),vertexShader:sn.background.vertexShader,fragmentShader:sn.background.fragmentShader,side:Dn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=T,l.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,l.material.toneMapped=Ze.getTransfer(T.colorSpace)!==Qe,T.matrixAutoUpdate===!0&&T.updateMatrix(),l.material.uniforms.uvTransform.value.copy(T.matrix),(f!==T||d!==T.version||m!==i.toneMapping)&&(l.material.needsUpdate=!0,f=T,d=T.version,m=i.toneMapping),l.layers.enableAll(),b.unshift(l,l.geometry,l.material,0,0,null))}function h(b,_){b.getRGB(wr,sc(i)),n.buffers.color.setClear(wr.r,wr.g,wr.b,_,o)}function w(){u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return a},setClearColor:function(b,_=1){a.set(b),c=_,h(a,c)},getClearAlpha:function(){return c},setClearAlpha:function(b){c=b,h(a,c)},render:y,addToRenderList:p,dispose:w}}function qd(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=d(null);let s=r,o=!1;function a(x,N,z,q,j){let Q=!1;const K=f(q,z,N);s!==K&&(s=K,l(s.object)),Q=m(x,q,z,j),Q&&g(x,q,z,j),j!==null&&e.update(j,i.ELEMENT_ARRAY_BUFFER),(Q||o)&&(o=!1,_(x,N,z,q),j!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(j).buffer))}function c(){return i.createVertexArray()}function l(x){return i.bindVertexArray(x)}function u(x){return i.deleteVertexArray(x)}function f(x,N,z){const q=z.wireframe===!0;let j=n[x.id];j===void 0&&(j={},n[x.id]=j);let Q=j[N.id];Q===void 0&&(Q={},j[N.id]=Q);let K=Q[q];return K===void 0&&(K=d(c()),Q[q]=K),K}function d(x){const N=[],z=[],q=[];for(let j=0;j<t;j++)N[j]=0,z[j]=0,q[j]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:N,enabledAttributes:z,attributeDivisors:q,object:x,attributes:{},index:null}}function m(x,N,z,q){const j=s.attributes,Q=N.attributes;let K=0;const se=z.getAttributes();for(const Z in se)if(se[Z].location>=0){const pe=j[Z];let Me=Q[Z];if(Me===void 0&&(Z==="instanceMatrix"&&x.instanceMatrix&&(Me=x.instanceMatrix),Z==="instanceColor"&&x.instanceColor&&(Me=x.instanceColor)),pe===void 0||pe.attribute!==Me||Me&&pe.data!==Me.data)return!0;K++}return s.attributesNum!==K||s.index!==q}function g(x,N,z,q){const j={},Q=N.attributes;let K=0;const se=z.getAttributes();for(const Z in se)if(se[Z].location>=0){let pe=Q[Z];pe===void 0&&(Z==="instanceMatrix"&&x.instanceMatrix&&(pe=x.instanceMatrix),Z==="instanceColor"&&x.instanceColor&&(pe=x.instanceColor));const Me={};Me.attribute=pe,pe&&pe.data&&(Me.data=pe.data),j[Z]=Me,K++}s.attributes=j,s.attributesNum=K,s.index=q}function y(){const x=s.newAttributes;for(let N=0,z=x.length;N<z;N++)x[N]=0}function p(x){h(x,0)}function h(x,N){const z=s.newAttributes,q=s.enabledAttributes,j=s.attributeDivisors;z[x]=1,q[x]===0&&(i.enableVertexAttribArray(x),q[x]=1),j[x]!==N&&(i.vertexAttribDivisor(x,N),j[x]=N)}function w(){const x=s.newAttributes,N=s.enabledAttributes;for(let z=0,q=N.length;z<q;z++)N[z]!==x[z]&&(i.disableVertexAttribArray(z),N[z]=0)}function b(x,N,z,q,j,Q,K){K===!0?i.vertexAttribIPointer(x,N,z,j,Q):i.vertexAttribPointer(x,N,z,q,j,Q)}function _(x,N,z,q){y();const j=q.attributes,Q=z.getAttributes(),K=N.defaultAttributeValues;for(const se in Q){const Z=Q[se];if(Z.location>=0){let le=j[se];if(le===void 0&&(se==="instanceMatrix"&&x.instanceMatrix&&(le=x.instanceMatrix),se==="instanceColor"&&x.instanceColor&&(le=x.instanceColor)),le!==void 0){const pe=le.normalized,Me=le.itemSize,Ne=e.get(le);if(Ne===void 0)continue;const fe=Ne.buffer,Xe=Ne.type,qe=Ne.bytesPerElement,$=Xe===i.INT||Xe===i.UNSIGNED_INT||le.gpuType===Yo;if(le.isInterleavedBufferAttribute){const oe=le.data,xe=oe.stride,Le=le.offset;if(oe.isInstancedInterleavedBuffer){for(let Ae=0;Ae<Z.locationSize;Ae++)h(Z.location+Ae,oe.meshPerAttribute);x.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=oe.meshPerAttribute*oe.count)}else for(let Ae=0;Ae<Z.locationSize;Ae++)p(Z.location+Ae);i.bindBuffer(i.ARRAY_BUFFER,fe);for(let Ae=0;Ae<Z.locationSize;Ae++)b(Z.location+Ae,Me/Z.locationSize,Xe,pe,xe*qe,(Le+Me/Z.locationSize*Ae)*qe,$)}else{if(le.isInstancedBufferAttribute){for(let oe=0;oe<Z.locationSize;oe++)h(Z.location+oe,le.meshPerAttribute);x.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=le.meshPerAttribute*le.count)}else for(let oe=0;oe<Z.locationSize;oe++)p(Z.location+oe);i.bindBuffer(i.ARRAY_BUFFER,fe);for(let oe=0;oe<Z.locationSize;oe++)b(Z.location+oe,Me/Z.locationSize,Xe,pe,Me*qe,Me/Z.locationSize*oe*qe,$)}}else if(K!==void 0){const pe=K[se];if(pe!==void 0)switch(pe.length){case 2:i.vertexAttrib2fv(Z.location,pe);break;case 3:i.vertexAttrib3fv(Z.location,pe);break;case 4:i.vertexAttrib4fv(Z.location,pe);break;default:i.vertexAttrib1fv(Z.location,pe)}}}}w()}function T(){C();for(const x in n){const N=n[x];for(const z in N){const q=N[z];for(const j in q)u(q[j].object),delete q[j];delete N[z]}delete n[x]}}function E(x){if(n[x.id]===void 0)return;const N=n[x.id];for(const z in N){const q=N[z];for(const j in q)u(q[j].object),delete q[j];delete N[z]}delete n[x.id]}function A(x){for(const N in n){const z=n[N];if(z[x.id]===void 0)continue;const q=z[x.id];for(const j in q)u(q[j].object),delete q[j];delete z[x.id]}}function C(){M(),o=!0,s!==r&&(s=r,l(s.object))}function M(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:C,resetDefaultState:M,dispose:T,releaseStatesOfGeometry:E,releaseStatesOfProgram:A,initAttributes:y,enableAttribute:p,disableUnusedAttributes:w}}function jd(i,e,t){let n;function r(l){n=l}function s(l,u){i.drawArrays(n,l,u),t.update(u,n,1)}function o(l,u,f){f!==0&&(i.drawArraysInstanced(n,l,u,f),t.update(u,n,f))}function a(l,u,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,u,0,f);let m=0;for(let g=0;g<f;g++)m+=u[g];t.update(m,n,1)}function c(l,u,f,d){if(f===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let g=0;g<l.length;g++)o(l[g],u[g],d[g]);else{m.multiDrawArraysInstancedWEBGL(n,l,0,u,0,d,0,f);let g=0;for(let y=0;y<f;y++)g+=u[y]*d[y];t.update(g,n,1)}}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=c}function Zd(i,e,t,n){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=i.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(A){return!(A!==Jt&&n.convert(A)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(A){const C=A===Ki&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(A!==hn&&n.convert(A)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&A!==gn&&!C)}function c(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 l=t.precision!==void 0?t.precision:"highp";const u=c(l);u!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",u,"instead."),l=u);const f=t.logarithmicDepthBuffer===!0,d=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),m=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),g=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=i.getParameter(i.MAX_TEXTURE_SIZE),p=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),h=i.getParameter(i.MAX_VERTEX_ATTRIBS),w=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),b=i.getParameter(i.MAX_VARYING_VECTORS),_=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),T=g>0,E=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:f,reversedDepthBuffer:d,maxTextures:m,maxVertexTextures:g,maxTextureSize:y,maxCubemapSize:p,maxAttributes:h,maxVertexUniforms:w,maxVaryings:b,maxFragmentUniforms:_,vertexTextures:T,maxSamples:E}}function $d(i){const e=this;let t=null,n=0,r=!1,s=!1;const o=new An,a=new ze,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,d){const m=f.length!==0||d||n!==0||r;return r=d,n=f.length,m},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,d){t=u(f,d,0)},this.setState=function(f,d,m){const g=f.clippingPlanes,y=f.clipIntersection,p=f.clipShadows,h=i.get(f);if(!r||g===null||g.length===0||s&&!p)s?u(null):l();else{const w=s?0:n,b=w*4;let _=h.clippingState||null;c.value=_,_=u(g,d,b,m);for(let T=0;T!==b;++T)_[T]=t[T];h.clippingState=_,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=w}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(f,d,m,g){const y=f!==null?f.length:0;let p=null;if(y!==0){if(p=c.value,g!==!0||p===null){const h=m+y*4,w=d.matrixWorldInverse;a.getNormalMatrix(w),(p===null||p.length<h)&&(p=new Float32Array(h));for(let b=0,_=m;b!==y;++b,_+=4)o.copy(f[b]).applyMatrix4(w,a),o.normal.toArray(p,_),p[_+3]=o.constant}c.value=p,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,p}}function Kd(i){let e=new WeakMap;function t(o,a){return a===$s?o.mapping=Ei:a===Ks&&(o.mapping=Ti),o}function n(o){if(o&&o.isTexture){const a=o.mapping;if(a===$s||a===Ks)if(e.has(o)){const c=e.get(o).texture;return t(c,o.mapping)}else{const c=o.image;if(c&&c.height>0){const l=new Xh(c.height);return l.fromEquirectangularTexture(i,o),e.set(o,l),o.addEventListener("dispose",r),t(l.texture,o.mapping)}else return null}}return o}function r(o){const a=o.target;a.removeEventListener("dispose",r);const c=e.get(a);c!==void 0&&(e.delete(a),c.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}const vi=4,nl=[.125,.215,.35,.446,.526,.582],Yn=20,Ls=new hc,il=new We;let Is=null,Us=0,Ns=0,Os=!1;const Gn=(1+Math.sqrt(5))/2,pi=1/Gn,rl=[new U(-Gn,pi,0),new U(Gn,pi,0),new U(-pi,0,Gn),new U(pi,0,Gn),new U(0,Gn,-pi),new U(0,Gn,pi),new U(-1,1,-1),new U(1,1,-1),new U(-1,1,1),new U(1,1,1)],Qd=new U;class sl{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,n=.1,r=100,s={}){const{size:o=256,position:a=Qd}=s;Is=this._renderer.getRenderTarget(),Us=this._renderer.getActiveCubeFace(),Ns=this._renderer.getActiveMipmapLevel(),Os=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(o);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,n,r,c,a),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ll(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=al(),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(Is,Us,Ns),this._renderer.xr.enabled=Os,e.scissorTest=!1,Ar(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Ei||e.mapping===Ti?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Is=this._renderer.getRenderTarget(),Us=this._renderer.getActiveCubeFace(),Ns=this._renderer.getActiveMipmapLevel(),Os=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:an,minFilter:an,generateMipmaps:!1,type:Ki,format:Jt,colorSpace:bi,depthBuffer:!1},r=ol(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=ol(e,t,n);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Jd(s)),this._blurMaterial=ep(s,e,t)}return r}_compileMaterial(e){const t=new _e(this._lodPlanes[0],e);this._renderer.compile(t,Ls)}_sceneToCubeUV(e,t,n,r,s){const c=new Yt(90,1,t,n),l=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],f=this._renderer,d=f.autoClear,m=f.toneMapping;f.getClearColor(il),f.toneMapping=Pn,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(r),f.clearDepth(),f.setRenderTarget(null));const y=new es({name:"PMREM.Background",side:Ut,depthWrite:!1,depthTest:!1}),p=new _e(new mt,y);let h=!1;const w=e.background;w?w.isColor&&(y.color.copy(w),e.background=null,h=!0):(y.color.copy(il),h=!0);for(let b=0;b<6;b++){const _=b%3;_===0?(c.up.set(0,l[b],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x+u[b],s.y,s.z)):_===1?(c.up.set(0,0,l[b]),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y+u[b],s.z)):(c.up.set(0,l[b],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y,s.z+u[b]));const T=this._cubeSize;Ar(r,_*T,b>2?T:0,T,T),f.setRenderTarget(r),h&&f.render(p,c),f.render(e,c)}p.geometry.dispose(),p.material.dispose(),f.toneMapping=m,f.autoClear=d,e.background=w}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===Ei||e.mapping===Ti;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=ll()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=al());const s=r?this._cubemapMaterial:this._equirectMaterial,o=new _e(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;const c=this._cubeSize;Ar(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(o,Ls)}_applyPMREM(e){const t=this._renderer,n=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=rl[(r-s-1)%rl.length];this._blur(e,s-1,s,o,a)}t.autoClear=n}_blur(e,t,n,r,s){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,r,"latitudinal",s),this._halfBlur(o,e,n,n,r,"longitudinal",s)}_halfBlur(e,t,n,r,s,o,a){const c=this._renderer,l=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,f=new _e(this._lodPlanes[r],l),d=l.uniforms,m=this._sizeLods[n]-1,g=isFinite(s)?Math.PI/(2*m):2*Math.PI/(2*Yn-1),y=s/g,p=isFinite(s)?1+Math.floor(u*y):Yn;p>Yn&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${p} samples when the maximum is set to ${Yn}`);const h=[];let w=0;for(let A=0;A<Yn;++A){const C=A/y,M=Math.exp(-C*C/2);h.push(M),A===0?w+=M:A<p&&(w+=2*M)}for(let A=0;A<h.length;A++)h[A]=h[A]/w;d.envMap.value=e.texture,d.samples.value=p,d.weights.value=h,d.latitudinal.value=o==="latitudinal",a&&(d.poleAxis.value=a);const{_lodMax:b}=this;d.dTheta.value=g,d.mipInt.value=b-n;const _=this._sizeLods[r],T=3*_*(r>b-vi?r-b+vi:0),E=4*(this._cubeSize-_);Ar(t,T,E,3*_,2*_),c.setRenderTarget(t),c.render(f,Ls)}}function Jd(i){const e=[],t=[],n=[];let r=i;const s=i-vi+1+nl.length;for(let o=0;o<s;o++){const a=Math.pow(2,r);t.push(a);let c=1/a;o>i-vi?c=nl[o-i+vi-1]:o===0&&(c=0),n.push(c);const l=1/(a-2),u=-l,f=1+l,d=[u,u,f,u,f,f,u,u,f,f,u,f],m=6,g=6,y=3,p=2,h=1,w=new Float32Array(y*g*m),b=new Float32Array(p*g*m),_=new Float32Array(h*g*m);for(let E=0;E<m;E++){const A=E%3*2/3-1,C=E>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*E),b.set(d,p*g*E);const x=[E,E,E,E,E,E];_.set(x,h*g*E)}const T=new vt;T.setAttribute("position",new cn(w,y)),T.setAttribute("uv",new cn(b,p)),T.setAttribute("faceIndex",new cn(_,h)),e.push(T),r>vi&&r--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function ol(i,e,t){const n=new Kn(i,e,t);return n.texture.mapping=Kr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Ar(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function ep(i,e,t){const n=new Float32Array(Yn),r=new U(0,1,0);return new Ln({name:"SphericalGaussianBlur",defines:{n:Yn,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,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:r}},vertexShader:sa(),fragmentShader:`
3601
3601
 
3602
3602
  precision mediump float;
3603
3603
  precision mediump int;
@@ -3657,7 +3657,7 @@ void main() {
3657
3657
  }
3658
3658
 
3659
3659
  }
3660
- `,blending:gn,depthTest:!1,depthWrite:!1})}function Po(){return new Sn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Ca(),fragmentShader:`
3660
+ `,blending:Cn,depthTest:!1,depthWrite:!1})}function al(){return new Ln({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:sa(),fragmentShader:`
3661
3661
 
3662
3662
  precision mediump float;
3663
3663
  precision mediump int;
@@ -3676,7 +3676,7 @@ void main() {
3676
3676
  gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
3677
3677
 
3678
3678
  }
3679
- `,blending:gn,depthTest:!1,depthWrite:!1})}function Do(){return new Sn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Ca(),fragmentShader:`
3679
+ `,blending:Cn,depthTest:!1,depthWrite:!1})}function ll(){return new Ln({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:sa(),fragmentShader:`
3680
3680
 
3681
3681
  precision mediump float;
3682
3682
  precision mediump int;
@@ -3692,7 +3692,7 @@ void main() {
3692
3692
  gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
3693
3693
 
3694
3694
  }
3695
- `,blending:gn,depthTest:!1,depthWrite:!1})}function Ca(){return`
3695
+ `,blending:Cn,depthTest:!1,depthWrite:!1})}function sa(){return`
3696
3696
 
3697
3697
  precision mediump float;
3698
3698
  precision mediump int;
@@ -3747,17 +3747,17 @@ void main() {
3747
3747
  gl_Position = vec4( position, 1.0 );
3748
3748
 
3749
3749
  }
3750
- `}function xd(i){let e=new WeakMap,t=null;function n(o){if(o&&o.isTexture){const c=o.mapping,l=c===ws||c===Rs,u=c===hi||c===ui;if(l||u){let f=e.get(o);const d=f!==void 0?f.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==d)return t===null&&(t=new Ro(i)),f=l?t.fromEquirectangular(o,f):t.fromCubemap(o,f),f.texture.pmremVersion=o.pmremVersion,e.set(o,f),f.texture;if(f!==void 0)return f.texture;{const m=o.image;return l&&m&&m.height>0||u&&m&&r(m)?(t===null&&(t=new Ro(i)),f=l?t.fromEquirectangular(o):t.fromCubemap(o),f.texture.pmremVersion=o.pmremVersion,e.set(o,f),o.addEventListener("dispose",s),f.texture):null}}}return o}function r(o){let c=0;const l=6;for(let u=0;u<l;u++)o[u]!==void 0&&c++;return c===l}function s(o){const c=o.target;c.removeEventListener("dispose",s);const l=e.get(c);l!==void 0&&(e.delete(c),l.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:a}}function Md(i){const e={};function t(n){if(e[n]!==void 0)return e[n];let r;switch(n){case"WEBGL_depth_texture":r=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=i.getExtension(n)}return e[n]=r,r}return{has:function(n){return t(n)!==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(n){const r=t(n);return r===null&&Di("THREE.WebGLRenderer: "+n+" extension not supported."),r}}}function Sd(i,e,t,n){const r={},s=new WeakMap;function a(f){const d=f.target;d.index!==null&&e.remove(d.index);for(const v in d.attributes)e.remove(d.attributes[v]);d.removeEventListener("dispose",a),delete r[d.id];const m=s.get(d);m&&(e.remove(m),s.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function o(f,d){return r[d.id]===!0||(d.addEventListener("dispose",a),r[d.id]=!0,t.memory.geometries++),d}function c(f){const d=f.attributes;for(const m in d)e.update(d[m],i.ARRAY_BUFFER)}function l(f){const d=[],m=f.index,v=f.attributes.position;let S=0;if(m!==null){const L=m.array;S=m.version;for(let C=0,g=L.length;C<g;C+=3){const E=L[C+0],T=L[C+1],A=L[C+2];d.push(E,T,T,A,A,E)}}else if(v!==void 0){const L=v.array;S=v.version;for(let C=0,g=L.length/3-1;C<g;C+=3){const E=C+0,T=C+1,A=C+2;d.push(E,T,T,A,A,E)}}else return;const p=new(ml(d)?Ml:xl)(d,1);p.version=S;const h=s.get(f);h&&e.remove(h),s.set(f,p)}function u(f){const d=s.get(f);if(d){const m=f.index;m!==null&&d.version<m.version&&l(f)}else l(f);return s.get(f)}return{get:o,update:c,getWireframeAttribute:u}}function yd(i,e,t){let n;function r(d){n=d}let s,a;function o(d){s=d.type,a=d.bytesPerElement}function c(d,m){i.drawElements(n,m,s,d*a),t.update(m,n,1)}function l(d,m,v){v!==0&&(i.drawElementsInstanced(n,m,s,d*a,v),t.update(m,n,v))}function u(d,m,v){if(v===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,m,0,s,d,0,v);let p=0;for(let h=0;h<v;h++)p+=m[h];t.update(p,n,1)}function f(d,m,v,S){if(v===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let h=0;h<d.length;h++)l(d[h]/a,m[h],S[h]);else{p.multiDrawElementsInstancedWEBGL(n,m,0,s,d,0,S,0,v);let h=0;for(let L=0;L<v;L++)h+=m[L]*S[L];t.update(h,n,1)}}this.setMode=r,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=u,this.renderMultiDrawInstances=f}function Ed(i){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,a,o){switch(t.calls++,a){case i.TRIANGLES:t.triangles+=o*(s/3);break;case i.LINES:t.lines+=o*(s/2);break;case i.LINE_STRIP:t.lines+=o*(s-1);break;case i.LINE_LOOP:t.lines+=o*s;break;case i.POINTS:t.points+=o*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);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:n}}function Td(i,e,t){const n=new WeakMap,r=new ot;function s(a,o,c){const l=a.morphTargetInfluences,u=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,f=u!==void 0?u.length:0;let d=n.get(o);if(d===void 0||d.count!==f){let y=function(){A.dispose(),n.delete(o),o.removeEventListener("dispose",y)};d!==void 0&&d.texture.dispose();const m=o.morphAttributes.position!==void 0,v=o.morphAttributes.normal!==void 0,S=o.morphAttributes.color!==void 0,p=o.morphAttributes.position||[],h=o.morphAttributes.normal||[],L=o.morphAttributes.color||[];let C=0;m===!0&&(C=1),v===!0&&(C=2),S===!0&&(C=3);let g=o.attributes.position.count*C,E=1;g>e.maxTextureSize&&(E=Math.ceil(g/e.maxTextureSize),g=e.maxTextureSize);const T=new Float32Array(g*E*4*f),A=new _l(T,g,E,f);A.type=on,A.needsUpdate=!0;const I=C*4;for(let M=0;M<f;M++){const U=p[M],W=h[M],Z=L[M],te=g*E*4*M;for(let ne=0;ne<U.count;ne++){const ee=ne*I;m===!0&&(r.fromBufferAttribute(U,ne),T[te+ee+0]=r.x,T[te+ee+1]=r.y,T[te+ee+2]=r.z,T[te+ee+3]=0),v===!0&&(r.fromBufferAttribute(W,ne),T[te+ee+4]=r.x,T[te+ee+5]=r.y,T[te+ee+6]=r.z,T[te+ee+7]=0),S===!0&&(r.fromBufferAttribute(Z,ne),T[te+ee+8]=r.x,T[te+ee+9]=r.y,T[te+ee+10]=r.z,T[te+ee+11]=Z.itemSize===4?r.w:1)}}d={count:f,texture:A,size:new Fe(g,E)},n.set(o,d),o.addEventListener("dispose",y)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)c.getUniforms().setValue(i,"morphTexture",a.morphTexture,t);else{let m=0;for(let S=0;S<l.length;S++)m+=l[S];const v=o.morphTargetsRelative?1:1-m;c.getUniforms().setValue(i,"morphTargetBaseInfluence",v),c.getUniforms().setValue(i,"morphTargetInfluences",l)}c.getUniforms().setValue(i,"morphTargetsTexture",d.texture,t),c.getUniforms().setValue(i,"morphTargetsTextureSize",d.size)}return{update:s}}function bd(i,e,t,n){let r=new WeakMap;function s(c){const l=n.render.frame,u=c.geometry,f=e.get(c,u);if(r.get(f)!==l&&(e.update(f),r.set(f,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",o)===!1&&c.addEventListener("dispose",o),r.get(c)!==l&&(t.update(c.instanceMatrix,i.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,i.ARRAY_BUFFER),r.set(c,l))),c.isSkinnedMesh){const d=c.skeleton;r.get(d)!==l&&(d.update(),r.set(d,l))}return f}function a(){r=new WeakMap}function o(c){const l=c.target;l.removeEventListener("dispose",o),t.remove(l.instanceMatrix),l.instanceColor!==null&&t.remove(l.instanceColor)}return{update:s,dispose:a}}const Cl=new At,Lo=new bl(1,1),Pl=new _l,Dl=new Wc,Ll=new El,Io=[],Uo=[],No=new Float32Array(16),Fo=new Float32Array(9),Oo=new Float32Array(4);function mi(i,e,t){const n=i[0];if(n<=0||n>0)return i;const r=e*t;let s=Io[r];if(s===void 0&&(s=new Float32Array(r),Io[r]=s),e!==0){n.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,i[a].toArray(s,o)}return s}function ft(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function dt(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function Ir(i,e){let t=Uo[e];t===void 0&&(t=new Int32Array(e),Uo[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function Ad(i,e){const t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function wd(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(ft(t,e))return;i.uniform2fv(this.addr,e),dt(t,e)}}function Rd(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.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)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(ft(t,e))return;i.uniform3fv(this.addr,e),dt(t,e)}}function Cd(i,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)&&(i.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(ft(t,e))return;i.uniform4fv(this.addr,e),dt(t,e)}}function Pd(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(ft(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),dt(t,e)}else{if(ft(t,n))return;Oo.set(n),i.uniformMatrix2fv(this.addr,!1,Oo),dt(t,n)}}function Dd(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(ft(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),dt(t,e)}else{if(ft(t,n))return;Fo.set(n),i.uniformMatrix3fv(this.addr,!1,Fo),dt(t,n)}}function Ld(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(ft(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),dt(t,e)}else{if(ft(t,n))return;No.set(n),i.uniformMatrix4fv(this.addr,!1,No),dt(t,n)}}function Id(i,e){const t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function Ud(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(ft(t,e))return;i.uniform2iv(this.addr,e),dt(t,e)}}function Nd(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(ft(t,e))return;i.uniform3iv(this.addr,e),dt(t,e)}}function Fd(i,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)&&(i.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(ft(t,e))return;i.uniform4iv(this.addr,e),dt(t,e)}}function Od(i,e){const t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function Bd(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(ft(t,e))return;i.uniform2uiv(this.addr,e),dt(t,e)}}function zd(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(ft(t,e))return;i.uniform3uiv(this.addr,e),dt(t,e)}}function Hd(i,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)&&(i.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(ft(t,e))return;i.uniform4uiv(this.addr,e),dt(t,e)}}function kd(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r);let s;this.type===i.SAMPLER_2D_SHADOW?(Lo.compareFunction=pl,s=Lo):s=Cl,t.setTexture2D(e||s,r)}function Vd(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture3D(e||Dl,r)}function Gd(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTextureCube(e||Ll,r)}function Wd(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture2DArray(e||Pl,r)}function Xd(i){switch(i){case 5126:return Ad;case 35664:return wd;case 35665:return Rd;case 35666:return Cd;case 35674:return Pd;case 35675:return Dd;case 35676:return Ld;case 5124:case 35670:return Id;case 35667:case 35671:return Ud;case 35668:case 35672:return Nd;case 35669:case 35673:return Fd;case 5125:return Od;case 36294:return Bd;case 36295:return zd;case 36296:return Hd;case 35678:case 36198:case 36298:case 36306:case 35682:return kd;case 35679:case 36299:case 36307:return Vd;case 35680:case 36300:case 36308:case 36293:return Gd;case 36289:case 36303:case 36311:case 36292:return Wd}}function qd(i,e){i.uniform1fv(this.addr,e)}function Yd(i,e){const t=mi(e,this.size,2);i.uniform2fv(this.addr,t)}function jd(i,e){const t=mi(e,this.size,3);i.uniform3fv(this.addr,t)}function Kd(i,e){const t=mi(e,this.size,4);i.uniform4fv(this.addr,t)}function $d(i,e){const t=mi(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function Zd(i,e){const t=mi(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function Jd(i,e){const t=mi(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function Qd(i,e){i.uniform1iv(this.addr,e)}function ep(i,e){i.uniform2iv(this.addr,e)}function tp(i,e){i.uniform3iv(this.addr,e)}function np(i,e){i.uniform4iv(this.addr,e)}function ip(i,e){i.uniform1uiv(this.addr,e)}function rp(i,e){i.uniform2uiv(this.addr,e)}function sp(i,e){i.uniform3uiv(this.addr,e)}function ap(i,e){i.uniform4uiv(this.addr,e)}function op(i,e,t){const n=this.cache,r=e.length,s=Ir(t,r);ft(n,s)||(i.uniform1iv(this.addr,s),dt(n,s));for(let a=0;a!==r;++a)t.setTexture2D(e[a]||Cl,s[a])}function lp(i,e,t){const n=this.cache,r=e.length,s=Ir(t,r);ft(n,s)||(i.uniform1iv(this.addr,s),dt(n,s));for(let a=0;a!==r;++a)t.setTexture3D(e[a]||Dl,s[a])}function cp(i,e,t){const n=this.cache,r=e.length,s=Ir(t,r);ft(n,s)||(i.uniform1iv(this.addr,s),dt(n,s));for(let a=0;a!==r;++a)t.setTextureCube(e[a]||Ll,s[a])}function hp(i,e,t){const n=this.cache,r=e.length,s=Ir(t,r);ft(n,s)||(i.uniform1iv(this.addr,s),dt(n,s));for(let a=0;a!==r;++a)t.setTexture2DArray(e[a]||Pl,s[a])}function up(i){switch(i){case 5126:return qd;case 35664:return Yd;case 35665:return jd;case 35666:return Kd;case 35674:return $d;case 35675:return Zd;case 35676:return Jd;case 5124:case 35670:return Qd;case 35667:case 35671:return ep;case 35668:case 35672:return tp;case 35669:case 35673:return np;case 5125:return ip;case 36294:return rp;case 36295:return sp;case 36296:return ap;case 35678:case 36198:case 36298:case 36306:case 35682:return op;case 35679:case 36299:case 36307:return lp;case 35680:case 36300:case 36308:case 36293:return cp;case 36289:case 36303:case 36311:case 36292:return hp}}class fp{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=Xd(t.type)}}class dp{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=up(t.type)}}class pp{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const r=this.seq;for(let s=0,a=r.length;s!==a;++s){const o=r[s];o.setValue(e,t[o.id],n)}}}const ms=/(\w+)(\])?(\[|\.)?/g;function Bo(i,e){i.seq.push(e),i.map[e.id]=e}function mp(i,e,t){const n=i.name,r=n.length;for(ms.lastIndex=0;;){const s=ms.exec(n),a=ms.lastIndex;let o=s[1];const c=s[2]==="]",l=s[3];if(c&&(o=o|0),l===void 0||l==="["&&a+2===r){Bo(t,l===void 0?new fp(o,i,e):new dp(o,i,e));break}else{let f=t.map[o];f===void 0&&(f=new pp(o),Bo(t,f)),t=f}}}class Mr{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){const s=e.getActiveUniform(t,r),a=e.getUniformLocation(t,s.name);mp(s,a,this)}}setValue(e,t,n,r){const s=this.map[t];s!==void 0&&s.setValue(e,n,r)}setOptional(e,t,n){const r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let s=0,a=t.length;s!==a;++s){const o=t[s],c=n[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,r)}}static seqWithValue(e,t){const n=[];for(let r=0,s=e.length;r!==s;++r){const a=e[r];a.id in t&&n.push(a)}return n}}function zo(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const _p=37297;let gp=0;function vp(i,e){const t=i.split(`
3751
- `),n=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let a=r;a<s;a++){const o=a+1;n.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return n.join(`
3752
- `)}const Ho=new Oe;function xp(i){Ye._getMatrix(Ho,Ye.workingColorSpace,i);const e=`mat3( ${Ho.elements.map(t=>t.toFixed(4))} )`;switch(Ye.getTransfer(i)){case Er:return[e,"LinearTransferOETF"];case $e:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function ko(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),s=(i.getShaderInfoLog(e)||"").trim();if(n&&s==="")return"";const a=/ERROR: 0:(\d+)/.exec(s);if(a){const o=parseInt(a[1]);return t.toUpperCase()+`
3750
+ `}function tp(i){let e=new WeakMap,t=null;function n(a){if(a&&a.isTexture){const c=a.mapping,l=c===$s||c===Ks,u=c===Ei||c===Ti;if(l||u){let f=e.get(a);const d=f!==void 0?f.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==d)return t===null&&(t=new sl(i)),f=l?t.fromEquirectangular(a,f):t.fromCubemap(a,f),f.texture.pmremVersion=a.pmremVersion,e.set(a,f),f.texture;if(f!==void 0)return f.texture;{const m=a.image;return l&&m&&m.height>0||u&&m&&r(m)?(t===null&&(t=new sl(i)),f=l?t.fromEquirectangular(a):t.fromCubemap(a),f.texture.pmremVersion=a.pmremVersion,e.set(a,f),a.addEventListener("dispose",s),f.texture):null}}}return a}function r(a){let c=0;const l=6;for(let u=0;u<l;u++)a[u]!==void 0&&c++;return c===l}function s(a){const c=a.target;c.removeEventListener("dispose",s);const l=e.get(c);l!==void 0&&(e.delete(c),l.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:o}}function np(i){const e={};function t(n){if(e[n]!==void 0)return e[n];let r;switch(n){case"WEBGL_depth_texture":r=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=i.getExtension(n)}return e[n]=r,r}return{has:function(n){return t(n)!==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(n){const r=t(n);return r===null&&Zi("THREE.WebGLRenderer: "+n+" extension not supported."),r}}}function ip(i,e,t,n){const r={},s=new WeakMap;function o(f){const d=f.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 m=s.get(d);m&&(e.remove(m),s.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function a(f,d){return r[d.id]===!0||(d.addEventListener("dispose",o),r[d.id]=!0,t.memory.geometries++),d}function c(f){const d=f.attributes;for(const m in d)e.update(d[m],i.ARRAY_BUFFER)}function l(f){const d=[],m=f.index,g=f.attributes.position;let y=0;if(m!==null){const w=m.array;y=m.version;for(let b=0,_=w.length;b<_;b+=3){const T=w[b+0],E=w[b+1],A=w[b+2];d.push(T,E,E,A,A,T)}}else if(g!==void 0){const w=g.array;y=g.version;for(let b=0,_=w.length/3-1;b<_;b+=3){const T=b+0,E=b+1,A=b+2;d.push(T,E,E,A,A,T)}}else return;const p=new(ec(d)?rc:ic)(d,1);p.version=y;const h=s.get(f);h&&e.remove(h),s.set(f,p)}function u(f){const d=s.get(f);if(d){const m=f.index;m!==null&&d.version<m.version&&l(f)}else l(f);return s.get(f)}return{get:a,update:c,getWireframeAttribute:u}}function rp(i,e,t){let n;function r(d){n=d}let s,o;function a(d){s=d.type,o=d.bytesPerElement}function c(d,m){i.drawElements(n,m,s,d*o),t.update(m,n,1)}function l(d,m,g){g!==0&&(i.drawElementsInstanced(n,m,s,d*o,g),t.update(m,n,g))}function u(d,m,g){if(g===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,m,0,s,d,0,g);let p=0;for(let h=0;h<g;h++)p+=m[h];t.update(p,n,1)}function f(d,m,g,y){if(g===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let h=0;h<d.length;h++)l(d[h]/o,m[h],y[h]);else{p.multiDrawElementsInstancedWEBGL(n,m,0,s,d,0,y,0,g);let h=0;for(let w=0;w<g;w++)h+=m[w]*y[w];t.update(h,n,1)}}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u,this.renderMultiDrawInstances=f}function sp(i){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,o,a){switch(t.calls++,o){case i.TRIANGLES:t.triangles+=a*(s/3);break;case i.LINES:t.lines+=a*(s/2);break;case i.LINE_STRIP:t.lines+=a*(s-1);break;case i.LINE_LOOP:t.lines+=a*s;break;case i.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:n}}function op(i,e,t){const n=new WeakMap,r=new ut;function s(o,a,c){const l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,f=u!==void 0?u.length:0;let d=n.get(a);if(d===void 0||d.count!==f){let M=function(){A.dispose(),n.delete(a),a.removeEventListener("dispose",M)};d!==void 0&&d.texture.dispose();const m=a.morphAttributes.position!==void 0,g=a.morphAttributes.normal!==void 0,y=a.morphAttributes.color!==void 0,p=a.morphAttributes.position||[],h=a.morphAttributes.normal||[],w=a.morphAttributes.color||[];let b=0;m===!0&&(b=1),g===!0&&(b=2),y===!0&&(b=3);let _=a.attributes.position.count*b,T=1;_>e.maxTextureSize&&(T=Math.ceil(_/e.maxTextureSize),_=e.maxTextureSize);const E=new Float32Array(_*T*4*f),A=new tc(E,_,T,f);A.type=gn,A.needsUpdate=!0;const C=b*4;for(let x=0;x<f;x++){const N=p[x],z=h[x],q=w[x],j=_*T*4*x;for(let Q=0;Q<N.count;Q++){const K=Q*C;m===!0&&(r.fromBufferAttribute(N,Q),E[j+K+0]=r.x,E[j+K+1]=r.y,E[j+K+2]=r.z,E[j+K+3]=0),g===!0&&(r.fromBufferAttribute(z,Q),E[j+K+4]=r.x,E[j+K+5]=r.y,E[j+K+6]=r.z,E[j+K+7]=0),y===!0&&(r.fromBufferAttribute(q,Q),E[j+K+8]=r.x,E[j+K+9]=r.y,E[j+K+10]=r.z,E[j+K+11]=q.itemSize===4?r.w:1)}}d={count:f,texture:A,size:new Ue(_,T)},n.set(a,d),a.addEventListener("dispose",M)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(i,"morphTexture",o.morphTexture,t);else{let m=0;for(let y=0;y<l.length;y++)m+=l[y];const g=a.morphTargetsRelative?1:1-m;c.getUniforms().setValue(i,"morphTargetBaseInfluence",g),c.getUniforms().setValue(i,"morphTargetInfluences",l)}c.getUniforms().setValue(i,"morphTargetsTexture",d.texture,t),c.getUniforms().setValue(i,"morphTargetsTextureSize",d.size)}return{update:s}}function ap(i,e,t,n){let r=new WeakMap;function s(c){const l=n.render.frame,u=c.geometry,f=e.get(c,u);if(r.get(f)!==l&&(e.update(f),r.set(f,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",a)===!1&&c.addEventListener("dispose",a),r.get(c)!==l&&(t.update(c.instanceMatrix,i.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,i.ARRAY_BUFFER),r.set(c,l))),c.isSkinnedMesh){const d=c.skeleton;r.get(d)!==l&&(d.update(),r.set(d,l))}return f}function o(){r=new WeakMap}function a(c){const l=c.target;l.removeEventListener("dispose",a),t.remove(l.instanceMatrix),l.instanceColor!==null&&t.remove(l.instanceColor)}return{update:s,dispose:o}}const pc=new Nt,cl=new lc(1,1),mc=new tc,_c=new Rh,gc=new ac,hl=[],ul=[],fl=new Float32Array(16),dl=new Float32Array(9),pl=new Float32Array(4);function Ci(i,e,t){const n=i[0];if(n<=0||n>0)return i;const r=e*t;let s=hl[r];if(s===void 0&&(s=new Float32Array(r),hl[r]=s),e!==0){n.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,i[o].toArray(s,a)}return s}function xt(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function Mt(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function ts(i,e){let t=ul[e];t===void 0&&(t=new Int32Array(e),ul[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function lp(i,e){const t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function cp(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(xt(t,e))return;i.uniform2fv(this.addr,e),Mt(t,e)}}function hp(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.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)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(xt(t,e))return;i.uniform3fv(this.addr,e),Mt(t,e)}}function up(i,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)&&(i.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(xt(t,e))return;i.uniform4fv(this.addr,e),Mt(t,e)}}function fp(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(xt(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),Mt(t,e)}else{if(xt(t,n))return;pl.set(n),i.uniformMatrix2fv(this.addr,!1,pl),Mt(t,n)}}function dp(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(xt(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),Mt(t,e)}else{if(xt(t,n))return;dl.set(n),i.uniformMatrix3fv(this.addr,!1,dl),Mt(t,n)}}function pp(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(xt(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),Mt(t,e)}else{if(xt(t,n))return;fl.set(n),i.uniformMatrix4fv(this.addr,!1,fl),Mt(t,n)}}function mp(i,e){const t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function _p(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(xt(t,e))return;i.uniform2iv(this.addr,e),Mt(t,e)}}function gp(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(xt(t,e))return;i.uniform3iv(this.addr,e),Mt(t,e)}}function vp(i,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)&&(i.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(xt(t,e))return;i.uniform4iv(this.addr,e),Mt(t,e)}}function xp(i,e){const t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function Mp(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(xt(t,e))return;i.uniform2uiv(this.addr,e),Mt(t,e)}}function yp(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(xt(t,e))return;i.uniform3uiv(this.addr,e),Mt(t,e)}}function Sp(i,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)&&(i.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(xt(t,e))return;i.uniform4uiv(this.addr,e),Mt(t,e)}}function Ep(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r);let s;this.type===i.SAMPLER_2D_SHADOW?(cl.compareFunction=Jl,s=cl):s=pc,t.setTexture2D(e||s,r)}function Tp(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture3D(e||_c,r)}function bp(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTextureCube(e||gc,r)}function wp(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture2DArray(e||mc,r)}function Ap(i){switch(i){case 5126:return lp;case 35664:return cp;case 35665:return hp;case 35666:return up;case 35674:return fp;case 35675:return dp;case 35676:return pp;case 5124:case 35670:return mp;case 35667:case 35671:return _p;case 35668:case 35672:return gp;case 35669:case 35673:return vp;case 5125:return xp;case 36294:return Mp;case 36295:return yp;case 36296:return Sp;case 35678:case 36198:case 36298:case 36306:case 35682:return Ep;case 35679:case 36299:case 36307:return Tp;case 35680:case 36300:case 36308:case 36293:return bp;case 36289:case 36303:case 36311:case 36292:return wp}}function Rp(i,e){i.uniform1fv(this.addr,e)}function Cp(i,e){const t=Ci(e,this.size,2);i.uniform2fv(this.addr,t)}function Pp(i,e){const t=Ci(e,this.size,3);i.uniform3fv(this.addr,t)}function Dp(i,e){const t=Ci(e,this.size,4);i.uniform4fv(this.addr,t)}function Lp(i,e){const t=Ci(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function Ip(i,e){const t=Ci(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function Up(i,e){const t=Ci(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function Np(i,e){i.uniform1iv(this.addr,e)}function Op(i,e){i.uniform2iv(this.addr,e)}function Fp(i,e){i.uniform3iv(this.addr,e)}function Bp(i,e){i.uniform4iv(this.addr,e)}function zp(i,e){i.uniform1uiv(this.addr,e)}function Hp(i,e){i.uniform2uiv(this.addr,e)}function kp(i,e){i.uniform3uiv(this.addr,e)}function Gp(i,e){i.uniform4uiv(this.addr,e)}function Vp(i,e,t){const n=this.cache,r=e.length,s=ts(t,r);xt(n,s)||(i.uniform1iv(this.addr,s),Mt(n,s));for(let o=0;o!==r;++o)t.setTexture2D(e[o]||pc,s[o])}function Wp(i,e,t){const n=this.cache,r=e.length,s=ts(t,r);xt(n,s)||(i.uniform1iv(this.addr,s),Mt(n,s));for(let o=0;o!==r;++o)t.setTexture3D(e[o]||_c,s[o])}function Xp(i,e,t){const n=this.cache,r=e.length,s=ts(t,r);xt(n,s)||(i.uniform1iv(this.addr,s),Mt(n,s));for(let o=0;o!==r;++o)t.setTextureCube(e[o]||gc,s[o])}function Yp(i,e,t){const n=this.cache,r=e.length,s=ts(t,r);xt(n,s)||(i.uniform1iv(this.addr,s),Mt(n,s));for(let o=0;o!==r;++o)t.setTexture2DArray(e[o]||mc,s[o])}function qp(i){switch(i){case 5126:return Rp;case 35664:return Cp;case 35665:return Pp;case 35666:return Dp;case 35674:return Lp;case 35675:return Ip;case 35676:return Up;case 5124:case 35670:return Np;case 35667:case 35671:return Op;case 35668:case 35672:return Fp;case 35669:case 35673:return Bp;case 5125:return zp;case 36294:return Hp;case 36295:return kp;case 36296:return Gp;case 35678:case 36198:case 36298:case 36306:case 35682:return Vp;case 35679:case 36299:case 36307:return Wp;case 35680:case 36300:case 36308:case 36293:return Xp;case 36289:case 36303:case 36311:case 36292:return Yp}}class jp{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=Ap(t.type)}}class Zp{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=qp(t.type)}}class $p{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const r=this.seq;for(let s=0,o=r.length;s!==o;++s){const a=r[s];a.setValue(e,t[a.id],n)}}}const Fs=/(\w+)(\])?(\[|\.)?/g;function ml(i,e){i.seq.push(e),i.map[e.id]=e}function Kp(i,e,t){const n=i.name,r=n.length;for(Fs.lastIndex=0;;){const s=Fs.exec(n),o=Fs.lastIndex;let a=s[1];const c=s[2]==="]",l=s[3];if(c&&(a=a|0),l===void 0||l==="["&&o+2===r){ml(t,l===void 0?new jp(a,i,e):new Zp(a,i,e));break}else{let f=t.map[a];f===void 0&&(f=new $p(a),ml(t,f)),t=f}}}class kr{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){const s=e.getActiveUniform(t,r),o=e.getUniformLocation(t,s.name);Kp(s,o,this)}}setValue(e,t,n,r){const s=this.map[t];s!==void 0&&s.setValue(e,n,r)}setOptional(e,t,n){const r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let s=0,o=t.length;s!==o;++s){const a=t[s],c=n[a.id];c.needsUpdate!==!1&&a.setValue(e,c.value,r)}}static seqWithValue(e,t){const n=[];for(let r=0,s=e.length;r!==s;++r){const o=e[r];o.id in t&&n.push(o)}return n}}function _l(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const Qp=37297;let Jp=0;function em(i,e){const t=i.split(`
3751
+ `),n=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let o=r;o<s;o++){const a=o+1;n.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return n.join(`
3752
+ `)}const gl=new ze;function tm(i){Ze._getMatrix(gl,Ze.workingColorSpace,i);const e=`mat3( ${gl.elements.map(t=>t.toFixed(4))} )`;switch(Ze.getTransfer(i)){case Xr:return[e,"LinearTransferOETF"];case Qe:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function vl(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),s=(i.getShaderInfoLog(e)||"").trim();if(n&&s==="")return"";const o=/ERROR: 0:(\d+)/.exec(s);if(o){const a=parseInt(o[1]);return t.toUpperCase()+`
3753
3753
 
3754
3754
  `+s+`
3755
3755
 
3756
- `+vp(i.getShaderSource(e),o)}else return s}function Mp(i,e){const t=xp(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
3757
- `)}function Sp(i,e){let t;switch(e){case gc:t="Linear";break;case vc:t="Reinhard";break;case xc:t="Cineon";break;case Mc:t="ACESFilmic";break;case yc:t="AgX";break;case Ec:t="Neutral";break;case Sc:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const ur=new B;function yp(){Ye.getLuminanceCoefficients(ur);const i=ur.x.toFixed(4),e=ur.y.toFixed(4),t=ur.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
3758
- `)}function Ep(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Ti).join(`
3759
- `)}function Tp(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
3760
- `)}function bp(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){const s=i.getActiveAttrib(e,r),a=s.name;let o=1;s.type===i.FLOAT_MAT2&&(o=2),s.type===i.FLOAT_MAT3&&(o=3),s.type===i.FLOAT_MAT4&&(o=4),t[a]={type:s.type,location:i.getAttribLocation(e,a),locationSize:o}}return t}function Ti(i){return i!==""}function Vo(i,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.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 Go(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Ap=/^[ \t]*#include +<([\w\d./]+)>/gm;function oa(i){return i.replace(Ap,Rp)}const wp=new Map;function Rp(i,e){let t=ze[e];if(t===void 0){const n=wp.get(e);if(n!==void 0)t=ze[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return oa(t)}const Cp=/#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 Wo(i){return i.replace(Cp,Pp)}function Pp(i,e,t,n){let r="";for(let s=parseInt(e);s<parseInt(t);s++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function Xo(i){let e=`precision ${i.precision} float;
3756
+ `+em(i.getShaderSource(e),a)}else return s}function nm(i,e){const t=tm(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
3757
+ `)}function im(i,e){let t;switch(e){case th:t="Linear";break;case nh:t="Reinhard";break;case ih:t="Cineon";break;case rh:t="ACESFilmic";break;case oh:t="AgX";break;case ah:t="Neutral";break;case sh:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Rr=new U;function rm(){Ze.getLuminanceCoefficients(Rr);const i=Rr.x.toFixed(4),e=Rr.y.toFixed(4),t=Rr.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
3758
+ `)}function sm(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Hi).join(`
3759
+ `)}function om(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
3760
+ `)}function am(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){const s=i.getActiveAttrib(e,r),o=s.name;let a=1;s.type===i.FLOAT_MAT2&&(a=2),s.type===i.FLOAT_MAT3&&(a=3),s.type===i.FLOAT_MAT4&&(a=4),t[o]={type:s.type,location:i.getAttribLocation(e,o),locationSize:a}}return t}function Hi(i){return i!==""}function xl(i,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.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 Ml(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const lm=/^[ \t]*#include +<([\w\d./]+)>/gm;function Do(i){return i.replace(lm,hm)}const cm=new Map;function hm(i,e){let t=He[e];if(t===void 0){const n=cm.get(e);if(n!==void 0)t=He[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return Do(t)}const um=/#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 yl(i){return i.replace(um,fm)}function fm(i,e,t,n){let r="";for(let s=parseInt(e);s<parseInt(t);s++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function Sl(i){let e=`precision ${i.precision} float;
3761
3761
  precision ${i.precision} int;
3762
3762
  precision ${i.precision} sampler2D;
3763
3763
  precision ${i.precision} samplerCube;
@@ -3777,30 +3777,30 @@ void main() {
3777
3777
  `;return i.precision==="highp"?e+=`
3778
3778
  #define HIGH_PRECISION`:i.precision==="mediump"?e+=`
3779
3779
  #define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
3780
- #define LOW_PRECISION`),e}function Dp(i){let e="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===nl?e="SHADOWMAP_TYPE_PCF":i.shadowMapType===$l?e="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===sn&&(e="SHADOWMAP_TYPE_VSM"),e}function Lp(i){let e="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case hi:case ui:e="ENVMAP_TYPE_CUBE";break;case Cr:e="ENVMAP_TYPE_CUBE_UV";break}return e}function Ip(i){let e="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case ui:e="ENVMAP_MODE_REFRACTION";break}return e}function Up(i){let e="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case il:e="ENVMAP_BLENDING_MULTIPLY";break;case mc:e="ENVMAP_BLENDING_MIX";break;case _c:e="ENVMAP_BLENDING_ADD";break}return e}function Np(i){const e=i.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:n,maxMip:t}}function Fp(i,e,t,n){const r=i.getContext(),s=t.defines;let a=t.vertexShader,o=t.fragmentShader;const c=Dp(t),l=Lp(t),u=Ip(t),f=Up(t),d=Np(t),m=Ep(t),v=Tp(s),S=r.createProgram();let p,h,L=t.glslVersion?"#version "+t.glslVersion+`
3781
- `:"";t.isRawShaderMaterial?(p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v].filter(Ti).join(`
3780
+ #define LOW_PRECISION`),e}function dm(i){let e="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===kl?e="SHADOWMAP_TYPE_PCF":i.shadowMapType===Uc?e="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===_n&&(e="SHADOWMAP_TYPE_VSM"),e}function pm(i){let e="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case Ei:case Ti:e="ENVMAP_TYPE_CUBE";break;case Kr:e="ENVMAP_TYPE_CUBE_UV";break}return e}function mm(i){let e="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case Ti:e="ENVMAP_MODE_REFRACTION";break}return e}function _m(i){let e="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case Gl:e="ENVMAP_BLENDING_MULTIPLY";break;case Jc:e="ENVMAP_BLENDING_MIX";break;case eh:e="ENVMAP_BLENDING_ADD";break}return e}function gm(i){const e=i.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:n,maxMip:t}}function vm(i,e,t,n){const r=i.getContext(),s=t.defines;let o=t.vertexShader,a=t.fragmentShader;const c=dm(t),l=pm(t),u=mm(t),f=_m(t),d=gm(t),m=sm(t),g=om(s),y=r.createProgram();let p,h,w=t.glslVersion?"#version "+t.glslVersion+`
3781
+ `:"";t.isRawShaderMaterial?(p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(Hi).join(`
3782
3782
  `),p.length>0&&(p+=`
3783
- `),h=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v].filter(Ti).join(`
3783
+ `),h=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(Hi).join(`
3784
3784
  `),h.length>0&&(h+=`
3785
- `)):(p=[Xo(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v,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 "+c:"",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(Ti).join(`
3787
- `),h=[Xo(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v,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 "+l:"",t.envMap?"#define "+u:"",t.envMap?"#define "+f:"",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 "+c:"",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!==vn?"#define TONE_MAPPING":"",t.toneMapping!==vn?ze.tonemapping_pars_fragment:"",t.toneMapping!==vn?Sp("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",ze.colorspace_pars_fragment,Mp("linearToOutputTexel",t.outputColorSpace),yp(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
3788
- `].filter(Ti).join(`
3789
- `)),a=oa(a),a=Vo(a,t),a=Go(a,t),o=oa(o),o=Vo(o,t),o=Go(o,t),a=Wo(a),o=Wo(o),t.isRawShaderMaterial!==!0&&(L=`#version 300 es
3785
+ `)):(p=[Sl(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 "+c:"",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(Hi).join(`
3787
+ `),h=[Sl(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 "+l:"",t.envMap?"#define "+u:"",t.envMap?"#define "+f:"",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 "+c:"",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!==Pn?"#define TONE_MAPPING":"",t.toneMapping!==Pn?He.tonemapping_pars_fragment:"",t.toneMapping!==Pn?im("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",He.colorspace_pars_fragment,nm("linearToOutputTexel",t.outputColorSpace),rm(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
3788
+ `].filter(Hi).join(`
3789
+ `)),o=Do(o),o=xl(o,t),o=Ml(o,t),a=Do(a),a=xl(a,t),a=Ml(a,t),o=yl(o),a=yl(a),t.isRawShaderMaterial!==!0&&(w=`#version 300 es
3790
3790
  `,p=[m,"#define attribute in","#define varying out","#define texture2D texture"].join(`
3791
3791
  `)+`
3792
- `+p,h=["#define varying in",t.glslVersion===Ka?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Ka?"":"#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(`
3792
+ `+p,h=["#define varying in",t.glslVersion===Aa?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Aa?"":"#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
3793
  `)+`
3794
- `+h);const C=L+p+a,g=L+h+o,E=zo(r,r.VERTEX_SHADER,C),T=zo(r,r.FRAGMENT_SHADER,g);r.attachShader(S,E),r.attachShader(S,T),t.index0AttributeName!==void 0?r.bindAttribLocation(S,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(S,0,"position"),r.linkProgram(S);function A(U){if(i.debug.checkShaderErrors){const W=r.getProgramInfoLog(S)||"",Z=r.getShaderInfoLog(E)||"",te=r.getShaderInfoLog(T)||"",ne=W.trim(),ee=Z.trim(),le=te.trim();let j=!0,ue=!0;if(r.getProgramParameter(S,r.LINK_STATUS)===!1)if(j=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,S,E,T);else{const me=ko(r,E,"vertex"),be=ko(r,T,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(S,r.VALIDATE_STATUS)+`
3794
+ `+h);const b=w+p+o,_=w+h+a,T=_l(r,r.VERTEX_SHADER,b),E=_l(r,r.FRAGMENT_SHADER,_);r.attachShader(y,T),r.attachShader(y,E),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(i.debug.checkShaderErrors){const z=r.getProgramInfoLog(y)||"",q=r.getShaderInfoLog(T)||"",j=r.getShaderInfoLog(E)||"",Q=z.trim(),K=q.trim(),se=j.trim();let Z=!0,le=!0;if(r.getProgramParameter(y,r.LINK_STATUS)===!1)if(Z=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,y,T,E);else{const pe=vl(r,T,"vertex"),Me=vl(r,E,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(y,r.VALIDATE_STATUS)+`
3795
3795
 
3796
- Material Name: `+U.name+`
3797
- Material Type: `+U.type+`
3796
+ Material Name: `+N.name+`
3797
+ Material Type: `+N.type+`
3798
3798
 
3799
- Program Info Log: `+ne+`
3800
- `+me+`
3801
- `+be)}else ne!==""?console.warn("THREE.WebGLProgram: Program Info Log:",ne):(ee===""||le==="")&&(ue=!1);ue&&(U.diagnostics={runnable:j,programLog:ne,vertexShader:{log:ee,prefix:p},fragmentShader:{log:le,prefix:h}})}r.deleteShader(E),r.deleteShader(T),I=new Mr(r,S),y=bp(r,S)}let I;this.getUniforms=function(){return I===void 0&&A(this),I};let y;this.getAttributes=function(){return y===void 0&&A(this),y};let M=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return M===!1&&(M=r.getProgramParameter(S,_p)),M},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(S),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=gp++,this.cacheKey=e,this.usedTimes=1,this.program=S,this.vertexShader=E,this.fragmentShader=T,this}let Op=0;class Bp{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.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 n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new zp(e),t.set(e,n)),n}}class zp{constructor(e){this.id=Op++,this.code=e,this.usedTimes=0}}function Hp(i,e,t,n,r,s,a){const o=new ba,c=new Bp,l=new Set,u=[],f=r.logarithmicDepthBuffer,d=r.vertexTextures;let m=r.precision;const v={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 S(y){return l.add(y),y===0?"uv":`uv${y}`}function p(y,M,U,W,Z){const te=W.fog,ne=Z.geometry,ee=y.isMeshStandardMaterial?W.environment:null,le=(y.isMeshStandardMaterial?t:e).get(y.envMap||ee),j=le&&le.mapping===Cr?le.image.height:null,ue=v[y.type];y.precision!==null&&(m=r.getMaxPrecision(y.precision),m!==y.precision&&console.warn("THREE.WebGLProgram.getParameters:",y.precision,"not supported, using",m,"instead."));const me=ne.morphAttributes.position||ne.morphAttributes.normal||ne.morphAttributes.color,be=me!==void 0?me.length:0;let Be=0;ne.morphAttributes.position!==void 0&&(Be=1),ne.morphAttributes.normal!==void 0&&(Be=2),ne.morphAttributes.color!==void 0&&(Be=3);let de,je,Xe,Y;if(ue){const We=qt[ue];de=We.vertexShader,je=We.fragmentShader}else de=y.vertexShader,je=y.fragmentShader,c.update(y),Xe=c.getVertexShaderID(y),Y=c.getFragmentShaderID(y);const se=i.getRenderTarget(),ve=i.state.buffers.depth.getReversed(),De=Z.isInstancedMesh===!0,Ae=Z.isBatchedMesh===!0,Ie=!!y.map,ht=!!y.matcap,P=!!le,Je=!!y.aoMap,Ue=!!y.lightMap,Re=!!y.bumpMap,xe=!!y.normalMap,Qe=!!y.displacementMap,Me=!!y.emissiveMap,Ne=!!y.metalnessMap,lt=!!y.roughnessMap,tt=y.anisotropy>0,b=y.clearcoat>0,_=y.dispersion>0,H=y.iridescence>0,Q=y.sheen>0,re=y.transmission>0,J=tt&&!!y.anisotropyMap,Te=b&&!!y.clearcoatMap,he=b&&!!y.clearcoatNormalMap,Se=b&&!!y.clearcoatRoughnessMap,D=H&&!!y.iridescenceMap,w=H&&!!y.iridescenceThicknessMap,N=Q&&!!y.sheenColorMap,K=Q&&!!y.sheenRoughnessMap,ie=!!y.specularMap,ae=!!y.specularColorMap,ye=!!y.specularIntensityMap,R=re&&!!y.transmissionMap,z=re&&!!y.thicknessMap,V=!!y.gradientMap,$=!!y.alphaMap,k=y.alphaTest>0,G=!!y.alphaHash,ce=!!y.extensions;let _e=vn;y.toneMapped&&(se===null||se.isXRRenderTarget===!0)&&(_e=i.toneMapping);const He={shaderID:ue,shaderType:y.type,shaderName:y.name,vertexShader:de,fragmentShader:je,defines:y.defines,customVertexShaderID:Xe,customFragmentShaderID:Y,isRawShaderMaterial:y.isRawShaderMaterial===!0,glslVersion:y.glslVersion,precision:m,batching:Ae,batchingColor:Ae&&Z._colorsTexture!==null,instancing:De,instancingColor:De&&Z.instanceColor!==null,instancingMorph:De&&Z.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:se===null?i.outputColorSpace:se.isXRRenderTarget===!0?se.texture.colorSpace:fi,alphaToCoverage:!!y.alphaToCoverage,map:Ie,matcap:ht,envMap:P,envMapMode:P&&le.mapping,envMapCubeUVHeight:j,aoMap:Je,lightMap:Ue,bumpMap:Re,normalMap:xe,displacementMap:d&&Qe,emissiveMap:Me,normalMapObjectSpace:xe&&y.normalMapType===wc,normalMapTangentSpace:xe&&y.normalMapType===dl,metalnessMap:Ne,roughnessMap:lt,anisotropy:tt,anisotropyMap:J,clearcoat:b,clearcoatMap:Te,clearcoatNormalMap:he,clearcoatRoughnessMap:Se,dispersion:_,iridescence:H,iridescenceMap:D,iridescenceThicknessMap:w,sheen:Q,sheenColorMap:N,sheenRoughnessMap:K,specularMap:ie,specularColorMap:ae,specularIntensityMap:ye,transmission:re,transmissionMap:R,thicknessMap:z,gradientMap:V,opaque:y.transparent===!1&&y.blending===oi&&y.alphaToCoverage===!1,alphaMap:$,alphaTest:k,alphaHash:G,combine:y.combine,mapUv:Ie&&S(y.map.channel),aoMapUv:Je&&S(y.aoMap.channel),lightMapUv:Ue&&S(y.lightMap.channel),bumpMapUv:Re&&S(y.bumpMap.channel),normalMapUv:xe&&S(y.normalMap.channel),displacementMapUv:Qe&&S(y.displacementMap.channel),emissiveMapUv:Me&&S(y.emissiveMap.channel),metalnessMapUv:Ne&&S(y.metalnessMap.channel),roughnessMapUv:lt&&S(y.roughnessMap.channel),anisotropyMapUv:J&&S(y.anisotropyMap.channel),clearcoatMapUv:Te&&S(y.clearcoatMap.channel),clearcoatNormalMapUv:he&&S(y.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Se&&S(y.clearcoatRoughnessMap.channel),iridescenceMapUv:D&&S(y.iridescenceMap.channel),iridescenceThicknessMapUv:w&&S(y.iridescenceThicknessMap.channel),sheenColorMapUv:N&&S(y.sheenColorMap.channel),sheenRoughnessMapUv:K&&S(y.sheenRoughnessMap.channel),specularMapUv:ie&&S(y.specularMap.channel),specularColorMapUv:ae&&S(y.specularColorMap.channel),specularIntensityMapUv:ye&&S(y.specularIntensityMap.channel),transmissionMapUv:R&&S(y.transmissionMap.channel),thicknessMapUv:z&&S(y.thicknessMap.channel),alphaMapUv:$&&S(y.alphaMap.channel),vertexTangents:!!ne.attributes.tangent&&(xe||tt),vertexColors:y.vertexColors,vertexAlphas:y.vertexColors===!0&&!!ne.attributes.color&&ne.attributes.color.itemSize===4,pointsUvs:Z.isPoints===!0&&!!ne.attributes.uv&&(Ie||$),fog:!!te,useFog:y.fog===!0,fogExp2:!!te&&te.isFogExp2,flatShading:y.flatShading===!0&&y.wireframe===!1,sizeAttenuation:y.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:ve,skinning:Z.isSkinnedMesh===!0,morphTargets:ne.morphAttributes.position!==void 0,morphNormals:ne.morphAttributes.normal!==void 0,morphColors:ne.morphAttributes.color!==void 0,morphTargetsCount:be,morphTextureStride:Be,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:y.dithering,shadowMapEnabled:i.shadowMap.enabled&&U.length>0,shadowMapType:i.shadowMap.type,toneMapping:_e,decodeVideoTexture:Ie&&y.map.isVideoTexture===!0&&Ye.getTransfer(y.map.colorSpace)===$e,decodeVideoTextureEmissive:Me&&y.emissiveMap.isVideoTexture===!0&&Ye.getTransfer(y.emissiveMap.colorSpace)===$e,premultipliedAlpha:y.premultipliedAlpha,doubleSided:y.side===an,flipSided:y.side===bt,useDepthPacking:y.depthPacking>=0,depthPacking:y.depthPacking||0,index0AttributeName:y.index0AttributeName,extensionClipCullDistance:ce&&y.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ce&&y.extensions.multiDraw===!0||Ae)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:y.customProgramCacheKey()};return He.vertexUv1s=l.has(1),He.vertexUv2s=l.has(2),He.vertexUv3s=l.has(3),l.clear(),He}function h(y){const M=[];if(y.shaderID?M.push(y.shaderID):(M.push(y.customVertexShaderID),M.push(y.customFragmentShaderID)),y.defines!==void 0)for(const U in y.defines)M.push(U),M.push(y.defines[U]);return y.isRawShaderMaterial===!1&&(L(M,y),C(M,y),M.push(i.outputColorSpace)),M.push(y.customProgramCacheKey),M.join()}function L(y,M){y.push(M.precision),y.push(M.outputColorSpace),y.push(M.envMapMode),y.push(M.envMapCubeUVHeight),y.push(M.mapUv),y.push(M.alphaMapUv),y.push(M.lightMapUv),y.push(M.aoMapUv),y.push(M.bumpMapUv),y.push(M.normalMapUv),y.push(M.displacementMapUv),y.push(M.emissiveMapUv),y.push(M.metalnessMapUv),y.push(M.roughnessMapUv),y.push(M.anisotropyMapUv),y.push(M.clearcoatMapUv),y.push(M.clearcoatNormalMapUv),y.push(M.clearcoatRoughnessMapUv),y.push(M.iridescenceMapUv),y.push(M.iridescenceThicknessMapUv),y.push(M.sheenColorMapUv),y.push(M.sheenRoughnessMapUv),y.push(M.specularMapUv),y.push(M.specularColorMapUv),y.push(M.specularIntensityMapUv),y.push(M.transmissionMapUv),y.push(M.thicknessMapUv),y.push(M.combine),y.push(M.fogExp2),y.push(M.sizeAttenuation),y.push(M.morphTargetsCount),y.push(M.morphAttributeCount),y.push(M.numDirLights),y.push(M.numPointLights),y.push(M.numSpotLights),y.push(M.numSpotLightMaps),y.push(M.numHemiLights),y.push(M.numRectAreaLights),y.push(M.numDirLightShadows),y.push(M.numPointLightShadows),y.push(M.numSpotLightShadows),y.push(M.numSpotLightShadowsWithMaps),y.push(M.numLightProbes),y.push(M.shadowMapType),y.push(M.toneMapping),y.push(M.numClippingPlanes),y.push(M.numClipIntersection),y.push(M.depthPacking)}function C(y,M){o.disableAll(),M.supportsVertexTextures&&o.enable(0),M.instancing&&o.enable(1),M.instancingColor&&o.enable(2),M.instancingMorph&&o.enable(3),M.matcap&&o.enable(4),M.envMap&&o.enable(5),M.normalMapObjectSpace&&o.enable(6),M.normalMapTangentSpace&&o.enable(7),M.clearcoat&&o.enable(8),M.iridescence&&o.enable(9),M.alphaTest&&o.enable(10),M.vertexColors&&o.enable(11),M.vertexAlphas&&o.enable(12),M.vertexUv1s&&o.enable(13),M.vertexUv2s&&o.enable(14),M.vertexUv3s&&o.enable(15),M.vertexTangents&&o.enable(16),M.anisotropy&&o.enable(17),M.alphaHash&&o.enable(18),M.batching&&o.enable(19),M.dispersion&&o.enable(20),M.batchingColor&&o.enable(21),M.gradientMap&&o.enable(22),y.push(o.mask),o.disableAll(),M.fog&&o.enable(0),M.useFog&&o.enable(1),M.flatShading&&o.enable(2),M.logarithmicDepthBuffer&&o.enable(3),M.reversedDepthBuffer&&o.enable(4),M.skinning&&o.enable(5),M.morphTargets&&o.enable(6),M.morphNormals&&o.enable(7),M.morphColors&&o.enable(8),M.premultipliedAlpha&&o.enable(9),M.shadowMapEnabled&&o.enable(10),M.doubleSided&&o.enable(11),M.flipSided&&o.enable(12),M.useDepthPacking&&o.enable(13),M.dithering&&o.enable(14),M.transmission&&o.enable(15),M.sheen&&o.enable(16),M.opaque&&o.enable(17),M.pointsUvs&&o.enable(18),M.decodeVideoTexture&&o.enable(19),M.decodeVideoTextureEmissive&&o.enable(20),M.alphaToCoverage&&o.enable(21),y.push(o.mask)}function g(y){const M=v[y.type];let U;if(M){const W=qt[M];U=ih.clone(W.uniforms)}else U=y.uniforms;return U}function E(y,M){let U;for(let W=0,Z=u.length;W<Z;W++){const te=u[W];if(te.cacheKey===M){U=te,++U.usedTimes;break}}return U===void 0&&(U=new Fp(i,M,y,s),u.push(U)),U}function T(y){if(--y.usedTimes===0){const M=u.indexOf(y);u[M]=u[u.length-1],u.pop(),y.destroy()}}function A(y){c.remove(y)}function I(){c.dispose()}return{getParameters:p,getProgramCacheKey:h,getUniforms:g,acquireProgram:E,releaseProgram:T,releaseShaderCache:A,programs:u,dispose:I}}function kp(){let i=new WeakMap;function e(a){return i.has(a)}function t(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function r(a,o,c){i.get(a)[o]=c}function s(){i=new WeakMap}return{has:e,get:t,remove:n,update:r,dispose:s}}function Vp(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.z!==e.z?i.z-e.z:i.id-e.id}function qo(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function Yo(){const i=[];let e=0;const t=[],n=[],r=[];function s(){e=0,t.length=0,n.length=0,r.length=0}function a(f,d,m,v,S,p){let h=i[e];return h===void 0?(h={id:f.id,object:f,geometry:d,material:m,groupOrder:v,renderOrder:f.renderOrder,z:S,group:p},i[e]=h):(h.id=f.id,h.object=f,h.geometry=d,h.material=m,h.groupOrder=v,h.renderOrder=f.renderOrder,h.z=S,h.group=p),e++,h}function o(f,d,m,v,S,p){const h=a(f,d,m,v,S,p);m.transmission>0?n.push(h):m.transparent===!0?r.push(h):t.push(h)}function c(f,d,m,v,S,p){const h=a(f,d,m,v,S,p);m.transmission>0?n.unshift(h):m.transparent===!0?r.unshift(h):t.unshift(h)}function l(f,d){t.length>1&&t.sort(f||Vp),n.length>1&&n.sort(d||qo),r.length>1&&r.sort(d||qo)}function u(){for(let f=e,d=i.length;f<d;f++){const m=i[f];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:t,transmissive:n,transparent:r,init:s,push:o,unshift:c,finish:u,sort:l}}function Gp(){let i=new WeakMap;function e(n,r){const s=i.get(n);let a;return s===void 0?(a=new Yo,i.set(n,[a])):r>=s.length?(a=new Yo,s.push(a)):a=s[r],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function Wp(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new B,color:new Ge};break;case"SpotLight":t={position:new B,direction:new B,color:new Ge,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new B,color:new Ge,distance:0,decay:0};break;case"HemisphereLight":t={direction:new B,skyColor:new Ge,groundColor:new Ge};break;case"RectAreaLight":t={color:new Ge,position:new B,halfWidth:new B,halfHeight:new B};break}return i[e.id]=t,t}}}function Xp(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Fe};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Fe};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Fe,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let qp=0;function Yp(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function jp(i){const e=new Wp,t=Xp(),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 l=0;l<9;l++)n.probe.push(new B);const r=new B,s=new st,a=new st;function o(l){let u=0,f=0,d=0;for(let y=0;y<9;y++)n.probe[y].set(0,0,0);let m=0,v=0,S=0,p=0,h=0,L=0,C=0,g=0,E=0,T=0,A=0;l.sort(Yp);for(let y=0,M=l.length;y<M;y++){const U=l[y],W=U.color,Z=U.intensity,te=U.distance,ne=U.shadow&&U.shadow.map?U.shadow.map.texture:null;if(U.isAmbientLight)u+=W.r*Z,f+=W.g*Z,d+=W.b*Z;else if(U.isLightProbe){for(let ee=0;ee<9;ee++)n.probe[ee].addScaledVector(U.sh.coefficients[ee],Z);A++}else if(U.isDirectionalLight){const ee=e.get(U);if(ee.color.copy(U.color).multiplyScalar(U.intensity),U.castShadow){const le=U.shadow,j=t.get(U);j.shadowIntensity=le.intensity,j.shadowBias=le.bias,j.shadowNormalBias=le.normalBias,j.shadowRadius=le.radius,j.shadowMapSize=le.mapSize,n.directionalShadow[m]=j,n.directionalShadowMap[m]=ne,n.directionalShadowMatrix[m]=U.shadow.matrix,L++}n.directional[m]=ee,m++}else if(U.isSpotLight){const ee=e.get(U);ee.position.setFromMatrixPosition(U.matrixWorld),ee.color.copy(W).multiplyScalar(Z),ee.distance=te,ee.coneCos=Math.cos(U.angle),ee.penumbraCos=Math.cos(U.angle*(1-U.penumbra)),ee.decay=U.decay,n.spot[S]=ee;const le=U.shadow;if(U.map&&(n.spotLightMap[E]=U.map,E++,le.updateMatrices(U),U.castShadow&&T++),n.spotLightMatrix[S]=le.matrix,U.castShadow){const j=t.get(U);j.shadowIntensity=le.intensity,j.shadowBias=le.bias,j.shadowNormalBias=le.normalBias,j.shadowRadius=le.radius,j.shadowMapSize=le.mapSize,n.spotShadow[S]=j,n.spotShadowMap[S]=ne,g++}S++}else if(U.isRectAreaLight){const ee=e.get(U);ee.color.copy(W).multiplyScalar(Z),ee.halfWidth.set(U.width*.5,0,0),ee.halfHeight.set(0,U.height*.5,0),n.rectArea[p]=ee,p++}else if(U.isPointLight){const ee=e.get(U);if(ee.color.copy(U.color).multiplyScalar(U.intensity),ee.distance=U.distance,ee.decay=U.decay,U.castShadow){const le=U.shadow,j=t.get(U);j.shadowIntensity=le.intensity,j.shadowBias=le.bias,j.shadowNormalBias=le.normalBias,j.shadowRadius=le.radius,j.shadowMapSize=le.mapSize,j.shadowCameraNear=le.camera.near,j.shadowCameraFar=le.camera.far,n.pointShadow[v]=j,n.pointShadowMap[v]=ne,n.pointShadowMatrix[v]=U.shadow.matrix,C++}n.point[v]=ee,v++}else if(U.isHemisphereLight){const ee=e.get(U);ee.skyColor.copy(U.color).multiplyScalar(Z),ee.groundColor.copy(U.groundColor).multiplyScalar(Z),n.hemi[h]=ee,h++}}p>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=fe.LTC_FLOAT_1,n.rectAreaLTC2=fe.LTC_FLOAT_2):(n.rectAreaLTC1=fe.LTC_HALF_1,n.rectAreaLTC2=fe.LTC_HALF_2)),n.ambient[0]=u,n.ambient[1]=f,n.ambient[2]=d;const I=n.hash;(I.directionalLength!==m||I.pointLength!==v||I.spotLength!==S||I.rectAreaLength!==p||I.hemiLength!==h||I.numDirectionalShadows!==L||I.numPointShadows!==C||I.numSpotShadows!==g||I.numSpotMaps!==E||I.numLightProbes!==A)&&(n.directional.length=m,n.spot.length=S,n.rectArea.length=p,n.point.length=v,n.hemi.length=h,n.directionalShadow.length=L,n.directionalShadowMap.length=L,n.pointShadow.length=C,n.pointShadowMap.length=C,n.spotShadow.length=g,n.spotShadowMap.length=g,n.directionalShadowMatrix.length=L,n.pointShadowMatrix.length=C,n.spotLightMatrix.length=g+E-T,n.spotLightMap.length=E,n.numSpotLightShadowsWithMaps=T,n.numLightProbes=A,I.directionalLength=m,I.pointLength=v,I.spotLength=S,I.rectAreaLength=p,I.hemiLength=h,I.numDirectionalShadows=L,I.numPointShadows=C,I.numSpotShadows=g,I.numSpotMaps=E,I.numLightProbes=A,n.version=qp++)}function c(l,u){let f=0,d=0,m=0,v=0,S=0;const p=u.matrixWorldInverse;for(let h=0,L=l.length;h<L;h++){const C=l[h];if(C.isDirectionalLight){const g=n.directional[f];g.direction.setFromMatrixPosition(C.matrixWorld),r.setFromMatrixPosition(C.target.matrixWorld),g.direction.sub(r),g.direction.transformDirection(p),f++}else if(C.isSpotLight){const g=n.spot[m];g.position.setFromMatrixPosition(C.matrixWorld),g.position.applyMatrix4(p),g.direction.setFromMatrixPosition(C.matrixWorld),r.setFromMatrixPosition(C.target.matrixWorld),g.direction.sub(r),g.direction.transformDirection(p),m++}else if(C.isRectAreaLight){const g=n.rectArea[v];g.position.setFromMatrixPosition(C.matrixWorld),g.position.applyMatrix4(p),a.identity(),s.copy(C.matrixWorld),s.premultiply(p),a.extractRotation(s),g.halfWidth.set(C.width*.5,0,0),g.halfHeight.set(0,C.height*.5,0),g.halfWidth.applyMatrix4(a),g.halfHeight.applyMatrix4(a),v++}else if(C.isPointLight){const g=n.point[d];g.position.setFromMatrixPosition(C.matrixWorld),g.position.applyMatrix4(p),d++}else if(C.isHemisphereLight){const g=n.hemi[S];g.direction.setFromMatrixPosition(C.matrixWorld),g.direction.transformDirection(p),S++}}}return{setup:o,setupView:c,state:n}}function jo(i){const e=new jp(i),t=[],n=[];function r(u){l.camera=u,t.length=0,n.length=0}function s(u){t.push(u)}function a(u){n.push(u)}function o(){e.setup(t)}function c(u){e.setupView(t,u)}const l={lightsArray:t,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:l,setupLights:o,setupLightsView:c,pushLight:s,pushShadow:a}}function Kp(i){let e=new WeakMap;function t(r,s=0){const a=e.get(r);let o;return a===void 0?(o=new jo(i),e.set(r,[o])):s>=a.length?(o=new jo(i),a.push(o)):o=a[s],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const $p=`void main() {
3799
+ Program Info Log: `+Q+`
3800
+ `+pe+`
3801
+ `+Me)}else Q!==""?console.warn("THREE.WebGLProgram: Program Info Log:",Q):(K===""||se==="")&&(le=!1);le&&(N.diagnostics={runnable:Z,programLog:Q,vertexShader:{log:K,prefix:p},fragmentShader:{log:se,prefix:h}})}r.deleteShader(T),r.deleteShader(E),C=new kr(r,y),M=am(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,Qp)),x},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(y),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Jp++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=T,this.fragmentShader=E,this}let xm=0;class Mm{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(n),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 n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.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 n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new ym(e),t.set(e,n)),n}}class ym{constructor(e){this.id=xm++,this.code=e,this.usedTimes=0}}function Sm(i,e,t,n,r,s,o){const a=new Jo,c=new Mm,l=new Set,u=[],f=r.logarithmicDepthBuffer,d=r.vertexTextures;let m=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 l.add(M),M===0?"uv":`uv${M}`}function p(M,x,N,z,q){const j=z.fog,Q=q.geometry,K=M.isMeshStandardMaterial?z.environment:null,se=(M.isMeshStandardMaterial?t:e).get(M.envMap||K),Z=se&&se.mapping===Kr?se.image.height:null,le=g[M.type];M.precision!==null&&(m=r.getMaxPrecision(M.precision),m!==M.precision&&console.warn("THREE.WebGLProgram.getParameters:",M.precision,"not supported, using",m,"instead."));const pe=Q.morphAttributes.position||Q.morphAttributes.normal||Q.morphAttributes.color,Me=pe!==void 0?pe.length:0;let Ne=0;Q.morphAttributes.position!==void 0&&(Ne=1),Q.morphAttributes.normal!==void 0&&(Ne=2),Q.morphAttributes.color!==void 0&&(Ne=3);let fe,Xe,qe,$;if(le){const Ye=sn[le];fe=Ye.vertexShader,Xe=Ye.fragmentShader}else fe=M.vertexShader,Xe=M.fragmentShader,c.update(M),qe=c.getVertexShaderID(M),$=c.getFragmentShaderID(M);const oe=i.getRenderTarget(),xe=i.state.buffers.depth.getReversed(),Le=q.isInstancedMesh===!0,Ae=q.isBatchedMesh===!0,Oe=!!M.map,_t=!!M.matcap,L=!!se,et=!!M.aoMap,Fe=!!M.lightMap,Ce=!!M.bumpMap,ye=!!M.normalMap,tt=!!M.displacementMap,Se=!!M.emissiveMap,Be=!!M.metalnessMap,ft=!!M.roughnessMap,rt=M.anisotropy>0,R=M.clearcoat>0,v=M.dispersion>0,k=M.iridescence>0,ne=M.sheen>0,re=M.transmission>0,te=rt&&!!M.anisotropyMap,we=R&&!!M.clearcoatMap,ue=R&&!!M.clearcoatNormalMap,Ee=R&&!!M.clearcoatRoughnessMap,I=k&&!!M.iridescenceMap,P=k&&!!M.iridescenceThicknessMap,O=ne&&!!M.sheenColorMap,J=ne&&!!M.sheenRoughnessMap,ie=!!M.specularMap,ae=!!M.specularColorMap,Te=!!M.specularIntensityMap,D=re&&!!M.transmissionMap,H=re&&!!M.thicknessMap,V=!!M.gradientMap,ee=!!M.alphaMap,G=M.alphaTest>0,W=!!M.alphaHash,he=!!M.extensions;let ge=Pn;M.toneMapped&&(oe===null||oe.isXRRenderTarget===!0)&&(ge=i.toneMapping);const ke={shaderID:le,shaderType:M.type,shaderName:M.name,vertexShader:fe,fragmentShader:Xe,defines:M.defines,customVertexShaderID:qe,customFragmentShaderID:$,isRawShaderMaterial:M.isRawShaderMaterial===!0,glslVersion:M.glslVersion,precision:m,batching:Ae,batchingColor:Ae&&q._colorsTexture!==null,instancing:Le,instancingColor:Le&&q.instanceColor!==null,instancingMorph:Le&&q.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:oe===null?i.outputColorSpace:oe.isXRRenderTarget===!0?oe.texture.colorSpace:bi,alphaToCoverage:!!M.alphaToCoverage,map:Oe,matcap:_t,envMap:L,envMapMode:L&&se.mapping,envMapCubeUVHeight:Z,aoMap:et,lightMap:Fe,bumpMap:Ce,normalMap:ye,displacementMap:d&&tt,emissiveMap:Se,normalMapObjectSpace:ye&&M.normalMapType===uh,normalMapTangentSpace:ye&&M.normalMapType===Ql,metalnessMap:Be,roughnessMap:ft,anisotropy:rt,anisotropyMap:te,clearcoat:R,clearcoatMap:we,clearcoatNormalMap:ue,clearcoatRoughnessMap:Ee,dispersion:v,iridescence:k,iridescenceMap:I,iridescenceThicknessMap:P,sheen:ne,sheenColorMap:O,sheenRoughnessMap:J,specularMap:ie,specularColorMap:ae,specularIntensityMap:Te,transmission:re,transmissionMap:D,thicknessMap:H,gradientMap:V,opaque:M.transparent===!1&&M.blending===Mi&&M.alphaToCoverage===!1,alphaMap:ee,alphaTest:G,alphaHash:W,combine:M.combine,mapUv:Oe&&y(M.map.channel),aoMapUv:et&&y(M.aoMap.channel),lightMapUv:Fe&&y(M.lightMap.channel),bumpMapUv:Ce&&y(M.bumpMap.channel),normalMapUv:ye&&y(M.normalMap.channel),displacementMapUv:tt&&y(M.displacementMap.channel),emissiveMapUv:Se&&y(M.emissiveMap.channel),metalnessMapUv:Be&&y(M.metalnessMap.channel),roughnessMapUv:ft&&y(M.roughnessMap.channel),anisotropyMapUv:te&&y(M.anisotropyMap.channel),clearcoatMapUv:we&&y(M.clearcoatMap.channel),clearcoatNormalMapUv:ue&&y(M.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ee&&y(M.clearcoatRoughnessMap.channel),iridescenceMapUv:I&&y(M.iridescenceMap.channel),iridescenceThicknessMapUv:P&&y(M.iridescenceThicknessMap.channel),sheenColorMapUv:O&&y(M.sheenColorMap.channel),sheenRoughnessMapUv:J&&y(M.sheenRoughnessMap.channel),specularMapUv:ie&&y(M.specularMap.channel),specularColorMapUv:ae&&y(M.specularColorMap.channel),specularIntensityMapUv:Te&&y(M.specularIntensityMap.channel),transmissionMapUv:D&&y(M.transmissionMap.channel),thicknessMapUv:H&&y(M.thicknessMap.channel),alphaMapUv:ee&&y(M.alphaMap.channel),vertexTangents:!!Q.attributes.tangent&&(ye||rt),vertexColors:M.vertexColors,vertexAlphas:M.vertexColors===!0&&!!Q.attributes.color&&Q.attributes.color.itemSize===4,pointsUvs:q.isPoints===!0&&!!Q.attributes.uv&&(Oe||ee),fog:!!j,useFog:M.fog===!0,fogExp2:!!j&&j.isFogExp2,flatShading:M.flatShading===!0&&M.wireframe===!1,sizeAttenuation:M.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:xe,skinning:q.isSkinnedMesh===!0,morphTargets:Q.morphAttributes.position!==void 0,morphNormals:Q.morphAttributes.normal!==void 0,morphColors:Q.morphAttributes.color!==void 0,morphTargetsCount:Me,morphTextureStride:Ne,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:i.shadowMap.enabled&&N.length>0,shadowMapType:i.shadowMap.type,toneMapping:ge,decodeVideoTexture:Oe&&M.map.isVideoTexture===!0&&Ze.getTransfer(M.map.colorSpace)===Qe,decodeVideoTextureEmissive:Se&&M.emissiveMap.isVideoTexture===!0&&Ze.getTransfer(M.emissiveMap.colorSpace)===Qe,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===on,flipSided:M.side===Ut,useDepthPacking:M.depthPacking>=0,depthPacking:M.depthPacking||0,index0AttributeName:M.index0AttributeName,extensionClipCullDistance:he&&M.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(he&&M.extensions.multiDraw===!0||Ae)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:M.customProgramCacheKey()};return ke.vertexUv1s=l.has(1),ke.vertexUv2s=l.has(2),ke.vertexUv3s=l.has(3),l.clear(),ke}function h(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),b(x,M),x.push(i.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 b(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=sn[x];N=kh.clone(z.uniforms)}else N=M.uniforms;return N}function T(M,x){let N;for(let z=0,q=u.length;z<q;z++){const j=u[z];if(j.cacheKey===x){N=j,++N.usedTimes;break}}return N===void 0&&(N=new vm(i,x,M,s),u.push(N)),N}function E(M){if(--M.usedTimes===0){const x=u.indexOf(M);u[x]=u[u.length-1],u.pop(),M.destroy()}}function A(M){c.remove(M)}function C(){c.dispose()}return{getParameters:p,getProgramCacheKey:h,getUniforms:_,acquireProgram:T,releaseProgram:E,releaseShaderCache:A,programs:u,dispose:C}}function Em(){let i=new WeakMap;function e(o){return i.has(o)}function t(o){let a=i.get(o);return a===void 0&&(a={},i.set(o,a)),a}function n(o){i.delete(o)}function r(o,a,c){i.get(o)[a]=c}function s(){i=new WeakMap}return{has:e,get:t,remove:n,update:r,dispose:s}}function Tm(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.z!==e.z?i.z-e.z:i.id-e.id}function El(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function Tl(){const i=[];let e=0;const t=[],n=[],r=[];function s(){e=0,t.length=0,n.length=0,r.length=0}function o(f,d,m,g,y,p){let h=i[e];return h===void 0?(h={id:f.id,object:f,geometry:d,material:m,groupOrder:g,renderOrder:f.renderOrder,z:y,group:p},i[e]=h):(h.id=f.id,h.object=f,h.geometry=d,h.material=m,h.groupOrder=g,h.renderOrder=f.renderOrder,h.z=y,h.group=p),e++,h}function a(f,d,m,g,y,p){const h=o(f,d,m,g,y,p);m.transmission>0?n.push(h):m.transparent===!0?r.push(h):t.push(h)}function c(f,d,m,g,y,p){const h=o(f,d,m,g,y,p);m.transmission>0?n.unshift(h):m.transparent===!0?r.unshift(h):t.unshift(h)}function l(f,d){t.length>1&&t.sort(f||Tm),n.length>1&&n.sort(d||El),r.length>1&&r.sort(d||El)}function u(){for(let f=e,d=i.length;f<d;f++){const m=i[f];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:t,transmissive:n,transparent:r,init:s,push:a,unshift:c,finish:u,sort:l}}function bm(){let i=new WeakMap;function e(n,r){const s=i.get(n);let o;return s===void 0?(o=new Tl,i.set(n,[o])):r>=s.length?(o=new Tl,s.push(o)):o=s[r],o}function t(){i=new WeakMap}return{get:e,dispose:t}}function wm(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new U,color:new We};break;case"SpotLight":t={position:new U,direction:new U,color:new We,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new U,color:new We,distance:0,decay:0};break;case"HemisphereLight":t={direction:new U,skyColor:new We,groundColor:new We};break;case"RectAreaLight":t={color:new We,position:new U,halfWidth:new U,halfHeight:new U};break}return i[e.id]=t,t}}}function Am(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ue};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ue};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ue,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let Rm=0;function Cm(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function Pm(i){const e=new wm,t=Am(),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 l=0;l<9;l++)n.probe.push(new U);const r=new U,s=new ot,o=new ot;function a(l){let u=0,f=0,d=0;for(let M=0;M<9;M++)n.probe[M].set(0,0,0);let m=0,g=0,y=0,p=0,h=0,w=0,b=0,_=0,T=0,E=0,A=0;l.sort(Cm);for(let M=0,x=l.length;M<x;M++){const N=l[M],z=N.color,q=N.intensity,j=N.distance,Q=N.shadow&&N.shadow.map?N.shadow.map.texture:null;if(N.isAmbientLight)u+=z.r*q,f+=z.g*q,d+=z.b*q;else if(N.isLightProbe){for(let K=0;K<9;K++)n.probe[K].addScaledVector(N.sh.coefficients[K],q);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,Z=t.get(N);Z.shadowIntensity=se.intensity,Z.shadowBias=se.bias,Z.shadowNormalBias=se.normalBias,Z.shadowRadius=se.radius,Z.shadowMapSize=se.mapSize,n.directionalShadow[m]=Z,n.directionalShadowMap[m]=Q,n.directionalShadowMatrix[m]=N.shadow.matrix,w++}n.directional[m]=K,m++}else if(N.isSpotLight){const K=e.get(N);K.position.setFromMatrixPosition(N.matrixWorld),K.color.copy(z).multiplyScalar(q),K.distance=j,K.coneCos=Math.cos(N.angle),K.penumbraCos=Math.cos(N.angle*(1-N.penumbra)),K.decay=N.decay,n.spot[y]=K;const se=N.shadow;if(N.map&&(n.spotLightMap[T]=N.map,T++,se.updateMatrices(N),N.castShadow&&E++),n.spotLightMatrix[y]=se.matrix,N.castShadow){const Z=t.get(N);Z.shadowIntensity=se.intensity,Z.shadowBias=se.bias,Z.shadowNormalBias=se.normalBias,Z.shadowRadius=se.radius,Z.shadowMapSize=se.mapSize,n.spotShadow[y]=Z,n.spotShadowMap[y]=Q,_++}y++}else if(N.isRectAreaLight){const K=e.get(N);K.color.copy(z).multiplyScalar(q),K.halfWidth.set(N.width*.5,0,0),K.halfHeight.set(0,N.height*.5,0),n.rectArea[p]=K,p++}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,Z=t.get(N);Z.shadowIntensity=se.intensity,Z.shadowBias=se.bias,Z.shadowNormalBias=se.normalBias,Z.shadowRadius=se.radius,Z.shadowMapSize=se.mapSize,Z.shadowCameraNear=se.camera.near,Z.shadowCameraFar=se.camera.far,n.pointShadow[g]=Z,n.pointShadowMap[g]=Q,n.pointShadowMatrix[g]=N.shadow.matrix,b++}n.point[g]=K,g++}else if(N.isHemisphereLight){const K=e.get(N);K.skyColor.copy(N.color).multiplyScalar(q),K.groundColor.copy(N.groundColor).multiplyScalar(q),n.hemi[h]=K,h++}}p>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=de.LTC_FLOAT_1,n.rectAreaLTC2=de.LTC_FLOAT_2):(n.rectAreaLTC1=de.LTC_HALF_1,n.rectAreaLTC2=de.LTC_HALF_2)),n.ambient[0]=u,n.ambient[1]=f,n.ambient[2]=d;const C=n.hash;(C.directionalLength!==m||C.pointLength!==g||C.spotLength!==y||C.rectAreaLength!==p||C.hemiLength!==h||C.numDirectionalShadows!==w||C.numPointShadows!==b||C.numSpotShadows!==_||C.numSpotMaps!==T||C.numLightProbes!==A)&&(n.directional.length=m,n.spot.length=y,n.rectArea.length=p,n.point.length=g,n.hemi.length=h,n.directionalShadow.length=w,n.directionalShadowMap.length=w,n.pointShadow.length=b,n.pointShadowMap.length=b,n.spotShadow.length=_,n.spotShadowMap.length=_,n.directionalShadowMatrix.length=w,n.pointShadowMatrix.length=b,n.spotLightMatrix.length=_+T-E,n.spotLightMap.length=T,n.numSpotLightShadowsWithMaps=E,n.numLightProbes=A,C.directionalLength=m,C.pointLength=g,C.spotLength=y,C.rectAreaLength=p,C.hemiLength=h,C.numDirectionalShadows=w,C.numPointShadows=b,C.numSpotShadows=_,C.numSpotMaps=T,C.numLightProbes=A,n.version=Rm++)}function c(l,u){let f=0,d=0,m=0,g=0,y=0;const p=u.matrixWorldInverse;for(let h=0,w=l.length;h<w;h++){const b=l[h];if(b.isDirectionalLight){const _=n.directional[f];_.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),_.direction.sub(r),_.direction.transformDirection(p),f++}else if(b.isSpotLight){const _=n.spot[m];_.position.setFromMatrixPosition(b.matrixWorld),_.position.applyMatrix4(p),_.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),_.direction.sub(r),_.direction.transformDirection(p),m++}else if(b.isRectAreaLight){const _=n.rectArea[g];_.position.setFromMatrixPosition(b.matrixWorld),_.position.applyMatrix4(p),o.identity(),s.copy(b.matrixWorld),s.premultiply(p),o.extractRotation(s),_.halfWidth.set(b.width*.5,0,0),_.halfHeight.set(0,b.height*.5,0),_.halfWidth.applyMatrix4(o),_.halfHeight.applyMatrix4(o),g++}else if(b.isPointLight){const _=n.point[d];_.position.setFromMatrixPosition(b.matrixWorld),_.position.applyMatrix4(p),d++}else if(b.isHemisphereLight){const _=n.hemi[y];_.direction.setFromMatrixPosition(b.matrixWorld),_.direction.transformDirection(p),y++}}}return{setup:a,setupView:c,state:n}}function bl(i){const e=new Pm(i),t=[],n=[];function r(u){l.camera=u,t.length=0,n.length=0}function s(u){t.push(u)}function o(u){n.push(u)}function a(){e.setup(t)}function c(u){e.setupView(t,u)}const l={lightsArray:t,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:l,setupLights:a,setupLightsView:c,pushLight:s,pushShadow:o}}function Dm(i){let e=new WeakMap;function t(r,s=0){const o=e.get(r);let a;return o===void 0?(a=new bl(i),e.set(r,[a])):s>=o.length?(a=new bl(i),o.push(a)):a=o[s],a}function n(){e=new WeakMap}return{get:t,dispose:n}}const Lm=`void main() {
3802
3802
  gl_Position = vec4( position, 1.0 );
3803
- }`,Zp=`uniform sampler2D shadow_pass;
3803
+ }`,Im=`uniform sampler2D shadow_pass;
3804
3804
  uniform vec2 resolution;
3805
3805
  uniform float radius;
3806
3806
  #include <packing>
@@ -3826,12 +3826,12 @@ void main() {
3826
3826
  squared_mean = squared_mean / samples;
3827
3827
  float std_dev = sqrt( squared_mean - mean * mean );
3828
3828
  gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3829
- }`;function Jp(i,e,t){let n=new Aa;const r=new Fe,s=new Fe,a=new ot,o=new _h({depthPacking:Ac}),c=new gh,l={},u=t.maxTextureSize,f={[Mn]:bt,[bt]:Mn,[an]:an},d=new Sn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Fe},radius:{value:4}},vertexShader:$p,fragmentShader:Zp}),m=d.clone();m.defines.HORIZONTAL_PASS=1;const v=new Dt;v.setAttribute("position",new $t(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const S=new Kt(v,d),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=nl;let h=this.type;this.render=function(T,A,I){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||T.length===0)return;const y=i.getRenderTarget(),M=i.getActiveCubeFace(),U=i.getActiveMipmapLevel(),W=i.state;W.setBlending(gn),W.buffers.depth.getReversed()===!0?W.buffers.color.setClear(0,0,0,0):W.buffers.color.setClear(1,1,1,1),W.buffers.depth.setTest(!0),W.setScissorTest(!1);const Z=h!==sn&&this.type===sn,te=h===sn&&this.type!==sn;for(let ne=0,ee=T.length;ne<ee;ne++){const le=T[ne],j=le.shadow;if(j===void 0){console.warn("THREE.WebGLShadowMap:",le,"has no shadow.");continue}if(j.autoUpdate===!1&&j.needsUpdate===!1)continue;r.copy(j.mapSize);const ue=j.getFrameExtents();if(r.multiply(ue),s.copy(j.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/ue.x),r.x=s.x*ue.x,j.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/ue.y),r.y=s.y*ue.y,j.mapSize.y=s.y)),j.map===null||Z===!0||te===!0){const be=this.type!==sn?{minFilter:Xt,magFilter:Xt}:{};j.map!==null&&j.map.dispose(),j.map=new Hn(r.x,r.y,be),j.map.texture.name=le.name+".shadowMap",j.camera.updateProjectionMatrix()}i.setRenderTarget(j.map),i.clear();const me=j.getViewportCount();for(let be=0;be<me;be++){const Be=j.getViewport(be);a.set(s.x*Be.x,s.y*Be.y,s.x*Be.z,s.y*Be.w),W.viewport(a),j.updateMatrices(le,be),n=j.getFrustum(),g(A,I,j.camera,le,this.type)}j.isPointLightShadow!==!0&&this.type===sn&&L(j,I),j.needsUpdate=!1}h=this.type,p.needsUpdate=!1,i.setRenderTarget(y,M,U)};function L(T,A){const I=e.update(S);d.defines.VSM_SAMPLES!==T.blurSamples&&(d.defines.VSM_SAMPLES=T.blurSamples,m.defines.VSM_SAMPLES=T.blurSamples,d.needsUpdate=!0,m.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new Hn(r.x,r.y)),d.uniforms.shadow_pass.value=T.map.texture,d.uniforms.resolution.value=T.mapSize,d.uniforms.radius.value=T.radius,i.setRenderTarget(T.mapPass),i.clear(),i.renderBufferDirect(A,null,I,d,S,null),m.uniforms.shadow_pass.value=T.mapPass.texture,m.uniforms.resolution.value=T.mapSize,m.uniforms.radius.value=T.radius,i.setRenderTarget(T.map),i.clear(),i.renderBufferDirect(A,null,I,m,S,null)}function C(T,A,I,y){let M=null;const U=I.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(U!==void 0)M=U;else if(M=I.isPointLight===!0?c: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 W=M.uuid,Z=A.uuid;let te=l[W];te===void 0&&(te={},l[W]=te);let ne=te[Z];ne===void 0&&(ne=M.clone(),te[Z]=ne,A.addEventListener("dispose",E)),M=ne}if(M.visible=A.visible,M.wireframe=A.wireframe,y===sn?M.side=A.shadowSide!==null?A.shadowSide:A.side:M.side=A.shadowSide!==null?A.shadowSide:f[A.side],M.alphaMap=A.alphaMap,M.alphaTest=A.alphaToCoverage===!0?.5:A.alphaTest,M.map=A.map,M.clipShadows=A.clipShadows,M.clippingPlanes=A.clippingPlanes,M.clipIntersection=A.clipIntersection,M.displacementMap=A.displacementMap,M.displacementScale=A.displacementScale,M.displacementBias=A.displacementBias,M.wireframeLinewidth=A.wireframeLinewidth,M.linewidth=A.linewidth,I.isPointLight===!0&&M.isMeshDistanceMaterial===!0){const W=i.properties.get(M);W.light=I}return M}function g(T,A,I,y,M){if(T.visible===!1)return;if(T.layers.test(A.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&M===sn)&&(!T.frustumCulled||n.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(I.matrixWorldInverse,T.matrixWorld);const Z=e.update(T),te=T.material;if(Array.isArray(te)){const ne=Z.groups;for(let ee=0,le=ne.length;ee<le;ee++){const j=ne[ee],ue=te[j.materialIndex];if(ue&&ue.visible){const me=C(T,ue,y,M);T.onBeforeShadow(i,T,A,I,Z,me,j),i.renderBufferDirect(I,null,Z,me,T,j),T.onAfterShadow(i,T,A,I,Z,me,j)}}}else if(te.visible){const ne=C(T,te,y,M);T.onBeforeShadow(i,T,A,I,Z,ne,null),i.renderBufferDirect(I,null,Z,ne,T,null),T.onAfterShadow(i,T,A,I,Z,ne,null)}}const W=T.children;for(let Z=0,te=W.length;Z<te;Z++)g(W[Z],A,I,y,M)}function E(T){T.target.removeEventListener("dispose",E);for(const I in l){const y=l[I],M=T.target.uuid;M in y&&(y[M].dispose(),delete y[M])}}}const Qp={[Ms]:Ss,[ys]:bs,[Es]:As,[ci]:Ts,[Ss]:Ms,[bs]:ys,[As]:Es,[Ts]:ci};function em(i,e){function t(){let R=!1;const z=new ot;let V=null;const $=new ot(0,0,0,0);return{setMask:function(k){V!==k&&!R&&(i.colorMask(k,k,k,k),V=k)},setLocked:function(k){R=k},setClear:function(k,G,ce,_e,He){He===!0&&(k*=_e,G*=_e,ce*=_e),z.set(k,G,ce,_e),$.equals(z)===!1&&(i.clearColor(k,G,ce,_e),$.copy(z))},reset:function(){R=!1,V=null,$.set(-1,0,0,0)}}}function n(){let R=!1,z=!1,V=null,$=null,k=null;return{setReversed:function(G){if(z!==G){const ce=e.get("EXT_clip_control");G?ce.clipControlEXT(ce.LOWER_LEFT_EXT,ce.ZERO_TO_ONE_EXT):ce.clipControlEXT(ce.LOWER_LEFT_EXT,ce.NEGATIVE_ONE_TO_ONE_EXT),z=G;const _e=k;k=null,this.setClear(_e)}},getReversed:function(){return z},setTest:function(G){G?se(i.DEPTH_TEST):ve(i.DEPTH_TEST)},setMask:function(G){V!==G&&!R&&(i.depthMask(G),V=G)},setFunc:function(G){if(z&&(G=Qp[G]),$!==G){switch(G){case Ms:i.depthFunc(i.NEVER);break;case Ss:i.depthFunc(i.ALWAYS);break;case ys:i.depthFunc(i.LESS);break;case ci:i.depthFunc(i.LEQUAL);break;case Es:i.depthFunc(i.EQUAL);break;case Ts:i.depthFunc(i.GEQUAL);break;case bs:i.depthFunc(i.GREATER);break;case As:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}$=G}},setLocked:function(G){R=G},setClear:function(G){k!==G&&(z&&(G=1-G),i.clearDepth(G),k=G)},reset:function(){R=!1,V=null,$=null,k=null,z=!1}}}function r(){let R=!1,z=null,V=null,$=null,k=null,G=null,ce=null,_e=null,He=null;return{setTest:function(We){R||(We?se(i.STENCIL_TEST):ve(i.STENCIL_TEST))},setMask:function(We){z!==We&&!R&&(i.stencilMask(We),z=We)},setFunc:function(We,zt,Lt){(V!==We||$!==zt||k!==Lt)&&(i.stencilFunc(We,zt,Lt),V=We,$=zt,k=Lt)},setOp:function(We,zt,Lt){(G!==We||ce!==zt||_e!==Lt)&&(i.stencilOp(We,zt,Lt),G=We,ce=zt,_e=Lt)},setLocked:function(We){R=We},setClear:function(We){He!==We&&(i.clearStencil(We),He=We)},reset:function(){R=!1,z=null,V=null,$=null,k=null,G=null,ce=null,_e=null,He=null}}}const s=new t,a=new n,o=new r,c=new WeakMap,l=new WeakMap;let u={},f={},d=new WeakMap,m=[],v=null,S=!1,p=null,h=null,L=null,C=null,g=null,E=null,T=null,A=new Ge(0,0,0),I=0,y=!1,M=null,U=null,W=null,Z=null,te=null;const ne=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let ee=!1,le=0;const j=i.getParameter(i.VERSION);j.indexOf("WebGL")!==-1?(le=parseFloat(/^WebGL (\d)/.exec(j)[1]),ee=le>=1):j.indexOf("OpenGL ES")!==-1&&(le=parseFloat(/^OpenGL ES (\d)/.exec(j)[1]),ee=le>=2);let ue=null,me={};const be=i.getParameter(i.SCISSOR_BOX),Be=i.getParameter(i.VIEWPORT),de=new ot().fromArray(be),je=new ot().fromArray(Be);function Xe(R,z,V,$){const k=new Uint8Array(4),G=i.createTexture();i.bindTexture(R,G),i.texParameteri(R,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(R,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let ce=0;ce<V;ce++)R===i.TEXTURE_3D||R===i.TEXTURE_2D_ARRAY?i.texImage3D(z,0,i.RGBA,1,1,$,0,i.RGBA,i.UNSIGNED_BYTE,k):i.texImage2D(z+ce,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,k);return G}const Y={};Y[i.TEXTURE_2D]=Xe(i.TEXTURE_2D,i.TEXTURE_2D,1),Y[i.TEXTURE_CUBE_MAP]=Xe(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),Y[i.TEXTURE_2D_ARRAY]=Xe(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),Y[i.TEXTURE_3D]=Xe(i.TEXTURE_3D,i.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),se(i.DEPTH_TEST),a.setFunc(ci),Re(!1),xe(Ga),se(i.CULL_FACE),Je(gn);function se(R){u[R]!==!0&&(i.enable(R),u[R]=!0)}function ve(R){u[R]!==!1&&(i.disable(R),u[R]=!1)}function De(R,z){return f[R]!==z?(i.bindFramebuffer(R,z),f[R]=z,R===i.DRAW_FRAMEBUFFER&&(f[i.FRAMEBUFFER]=z),R===i.FRAMEBUFFER&&(f[i.DRAW_FRAMEBUFFER]=z),!0):!1}function Ae(R,z){let V=m,$=!1;if(R){V=d.get(z),V===void 0&&(V=[],d.set(z,V));const k=R.textures;if(V.length!==k.length||V[0]!==i.COLOR_ATTACHMENT0){for(let G=0,ce=k.length;G<ce;G++)V[G]=i.COLOR_ATTACHMENT0+G;V.length=k.length,$=!0}}else V[0]!==i.BACK&&(V[0]=i.BACK,$=!0);$&&i.drawBuffers(V)}function Ie(R){return v!==R?(i.useProgram(R),v=R,!0):!1}const ht={[Ln]:i.FUNC_ADD,[Jl]:i.FUNC_SUBTRACT,[Ql]:i.FUNC_REVERSE_SUBTRACT};ht[ec]=i.MIN,ht[tc]=i.MAX;const P={[nc]:i.ZERO,[ic]:i.ONE,[rc]:i.SRC_COLOR,[vs]:i.SRC_ALPHA,[hc]:i.SRC_ALPHA_SATURATE,[lc]:i.DST_COLOR,[ac]:i.DST_ALPHA,[sc]:i.ONE_MINUS_SRC_COLOR,[xs]:i.ONE_MINUS_SRC_ALPHA,[cc]:i.ONE_MINUS_DST_COLOR,[oc]:i.ONE_MINUS_DST_ALPHA,[uc]:i.CONSTANT_COLOR,[fc]:i.ONE_MINUS_CONSTANT_COLOR,[dc]:i.CONSTANT_ALPHA,[pc]:i.ONE_MINUS_CONSTANT_ALPHA};function Je(R,z,V,$,k,G,ce,_e,He,We){if(R===gn){S===!0&&(ve(i.BLEND),S=!1);return}if(S===!1&&(se(i.BLEND),S=!0),R!==Zl){if(R!==p||We!==y){if((h!==Ln||g!==Ln)&&(i.blendEquation(i.FUNC_ADD),h=Ln,g=Ln),We)switch(R){case oi:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Wa:i.blendFunc(i.ONE,i.ONE);break;case Xa:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case qa:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:console.error("THREE.WebGLState: Invalid blending: ",R);break}else switch(R){case oi:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Wa:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case Xa:console.error("THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case qa:console.error("THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:console.error("THREE.WebGLState: Invalid blending: ",R);break}L=null,C=null,E=null,T=null,A.set(0,0,0),I=0,p=R,y=We}return}k=k||z,G=G||V,ce=ce||$,(z!==h||k!==g)&&(i.blendEquationSeparate(ht[z],ht[k]),h=z,g=k),(V!==L||$!==C||G!==E||ce!==T)&&(i.blendFuncSeparate(P[V],P[$],P[G],P[ce]),L=V,C=$,E=G,T=ce),(_e.equals(A)===!1||He!==I)&&(i.blendColor(_e.r,_e.g,_e.b,He),A.copy(_e),I=He),p=R,y=!1}function Ue(R,z){R.side===an?ve(i.CULL_FACE):se(i.CULL_FACE);let V=R.side===bt;z&&(V=!V),Re(V),R.blending===oi&&R.transparent===!1?Je(gn):Je(R.blending,R.blendEquation,R.blendSrc,R.blendDst,R.blendEquationAlpha,R.blendSrcAlpha,R.blendDstAlpha,R.blendColor,R.blendAlpha,R.premultipliedAlpha),a.setFunc(R.depthFunc),a.setTest(R.depthTest),a.setMask(R.depthWrite),s.setMask(R.colorWrite);const $=R.stencilWrite;o.setTest($),$&&(o.setMask(R.stencilWriteMask),o.setFunc(R.stencilFunc,R.stencilRef,R.stencilFuncMask),o.setOp(R.stencilFail,R.stencilZFail,R.stencilZPass)),Me(R.polygonOffset,R.polygonOffsetFactor,R.polygonOffsetUnits),R.alphaToCoverage===!0?se(i.SAMPLE_ALPHA_TO_COVERAGE):ve(i.SAMPLE_ALPHA_TO_COVERAGE)}function Re(R){M!==R&&(R?i.frontFace(i.CW):i.frontFace(i.CCW),M=R)}function xe(R){R!==jl?(se(i.CULL_FACE),R!==U&&(R===Ga?i.cullFace(i.BACK):R===Kl?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):ve(i.CULL_FACE),U=R}function Qe(R){R!==W&&(ee&&i.lineWidth(R),W=R)}function Me(R,z,V){R?(se(i.POLYGON_OFFSET_FILL),(Z!==z||te!==V)&&(i.polygonOffset(z,V),Z=z,te=V)):ve(i.POLYGON_OFFSET_FILL)}function Ne(R){R?se(i.SCISSOR_TEST):ve(i.SCISSOR_TEST)}function lt(R){R===void 0&&(R=i.TEXTURE0+ne-1),ue!==R&&(i.activeTexture(R),ue=R)}function tt(R,z,V){V===void 0&&(ue===null?V=i.TEXTURE0+ne-1:V=ue);let $=me[V];$===void 0&&($={type:void 0,texture:void 0},me[V]=$),($.type!==R||$.texture!==z)&&(ue!==V&&(i.activeTexture(V),ue=V),i.bindTexture(R,z||Y[R]),$.type=R,$.texture=z)}function b(){const R=me[ue];R!==void 0&&R.type!==void 0&&(i.bindTexture(R.type,null),R.type=void 0,R.texture=void 0)}function _(){try{i.compressedTexImage2D(...arguments)}catch(R){console.error("THREE.WebGLState:",R)}}function H(){try{i.compressedTexImage3D(...arguments)}catch(R){console.error("THREE.WebGLState:",R)}}function Q(){try{i.texSubImage2D(...arguments)}catch(R){console.error("THREE.WebGLState:",R)}}function re(){try{i.texSubImage3D(...arguments)}catch(R){console.error("THREE.WebGLState:",R)}}function J(){try{i.compressedTexSubImage2D(...arguments)}catch(R){console.error("THREE.WebGLState:",R)}}function Te(){try{i.compressedTexSubImage3D(...arguments)}catch(R){console.error("THREE.WebGLState:",R)}}function he(){try{i.texStorage2D(...arguments)}catch(R){console.error("THREE.WebGLState:",R)}}function Se(){try{i.texStorage3D(...arguments)}catch(R){console.error("THREE.WebGLState:",R)}}function D(){try{i.texImage2D(...arguments)}catch(R){console.error("THREE.WebGLState:",R)}}function w(){try{i.texImage3D(...arguments)}catch(R){console.error("THREE.WebGLState:",R)}}function N(R){de.equals(R)===!1&&(i.scissor(R.x,R.y,R.z,R.w),de.copy(R))}function K(R){je.equals(R)===!1&&(i.viewport(R.x,R.y,R.z,R.w),je.copy(R))}function ie(R,z){let V=l.get(z);V===void 0&&(V=new WeakMap,l.set(z,V));let $=V.get(R);$===void 0&&($=i.getUniformBlockIndex(z,R.name),V.set(R,$))}function ae(R,z){const $=l.get(z).get(R);c.get(z)!==$&&(i.uniformBlockBinding(z,$,R.__bindingPointIndex),c.set(z,$))}function ye(){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),u={},ue=null,me={},f={},d=new WeakMap,m=[],v=null,S=!1,p=null,h=null,L=null,C=null,g=null,E=null,T=null,A=new Ge(0,0,0),I=0,y=!1,M=null,U=null,W=null,Z=null,te=null,de.set(0,0,i.canvas.width,i.canvas.height),je.set(0,0,i.canvas.width,i.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:se,disable:ve,bindFramebuffer:De,drawBuffers:Ae,useProgram:Ie,setBlending:Je,setMaterial:Ue,setFlipSided:Re,setCullFace:xe,setLineWidth:Qe,setPolygonOffset:Me,setScissorTest:Ne,activeTexture:lt,bindTexture:tt,unbindTexture:b,compressedTexImage2D:_,compressedTexImage3D:H,texImage2D:D,texImage3D:w,updateUBOMapping:ie,uniformBlockBinding:ae,texStorage2D:he,texStorage3D:Se,texSubImage2D:Q,texSubImage3D:re,compressedTexSubImage2D:J,compressedTexSubImage3D:Te,scissor:N,viewport:K,reset:ye}}function tm(i,e,t,n,r,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Fe,u=new WeakMap;let f;const d=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(b,_){return m?new OffscreenCanvas(b,_):br("canvas")}function S(b,_,H){let Q=1;const re=tt(b);if((re.width>H||re.height>H)&&(Q=H/Math.max(re.width,re.height)),Q<1)if(typeof HTMLImageElement<"u"&&b instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&b instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&b instanceof ImageBitmap||typeof VideoFrame<"u"&&b instanceof VideoFrame){const J=Math.floor(Q*re.width),Te=Math.floor(Q*re.height);f===void 0&&(f=v(J,Te));const he=_?v(J,Te):f;return he.width=J,he.height=Te,he.getContext("2d").drawImage(b,0,0,J,Te),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+re.width+"x"+re.height+") to ("+J+"x"+Te+")."),he}else return"data"in b&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+re.width+"x"+re.height+")."),b;return b}function p(b){return b.generateMipmaps}function h(b){i.generateMipmap(b)}function L(b){return b.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:b.isWebGL3DRenderTarget?i.TEXTURE_3D:b.isWebGLArrayRenderTarget||b.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function C(b,_,H,Q,re=!1){if(b!==null){if(i[b]!==void 0)return i[b];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+b+"'")}let J=_;if(_===i.RED&&(H===i.FLOAT&&(J=i.R32F),H===i.HALF_FLOAT&&(J=i.R16F),H===i.UNSIGNED_BYTE&&(J=i.R8)),_===i.RED_INTEGER&&(H===i.UNSIGNED_BYTE&&(J=i.R8UI),H===i.UNSIGNED_SHORT&&(J=i.R16UI),H===i.UNSIGNED_INT&&(J=i.R32UI),H===i.BYTE&&(J=i.R8I),H===i.SHORT&&(J=i.R16I),H===i.INT&&(J=i.R32I)),_===i.RG&&(H===i.FLOAT&&(J=i.RG32F),H===i.HALF_FLOAT&&(J=i.RG16F),H===i.UNSIGNED_BYTE&&(J=i.RG8)),_===i.RG_INTEGER&&(H===i.UNSIGNED_BYTE&&(J=i.RG8UI),H===i.UNSIGNED_SHORT&&(J=i.RG16UI),H===i.UNSIGNED_INT&&(J=i.RG32UI),H===i.BYTE&&(J=i.RG8I),H===i.SHORT&&(J=i.RG16I),H===i.INT&&(J=i.RG32I)),_===i.RGB_INTEGER&&(H===i.UNSIGNED_BYTE&&(J=i.RGB8UI),H===i.UNSIGNED_SHORT&&(J=i.RGB16UI),H===i.UNSIGNED_INT&&(J=i.RGB32UI),H===i.BYTE&&(J=i.RGB8I),H===i.SHORT&&(J=i.RGB16I),H===i.INT&&(J=i.RGB32I)),_===i.RGBA_INTEGER&&(H===i.UNSIGNED_BYTE&&(J=i.RGBA8UI),H===i.UNSIGNED_SHORT&&(J=i.RGBA16UI),H===i.UNSIGNED_INT&&(J=i.RGBA32UI),H===i.BYTE&&(J=i.RGBA8I),H===i.SHORT&&(J=i.RGBA16I),H===i.INT&&(J=i.RGBA32I)),_===i.RGB&&(H===i.UNSIGNED_INT_5_9_9_9_REV&&(J=i.RGB9_E5),H===i.UNSIGNED_INT_10F_11F_11F_REV&&(J=i.R11F_G11F_B10F)),_===i.RGBA){const Te=re?Er:Ye.getTransfer(Q);H===i.FLOAT&&(J=i.RGBA32F),H===i.HALF_FLOAT&&(J=i.RGBA16F),H===i.UNSIGNED_BYTE&&(J=Te===$e?i.SRGB8_ALPHA8:i.RGBA8),H===i.UNSIGNED_SHORT_4_4_4_4&&(J=i.RGBA4),H===i.UNSIGNED_SHORT_5_5_5_1&&(J=i.RGB5_A1)}return(J===i.R16F||J===i.R32F||J===i.RG16F||J===i.RG32F||J===i.RGBA16F||J===i.RGBA32F)&&e.get("EXT_color_buffer_float"),J}function g(b,_){let H;return b?_===null||_===Bn||_===Ri?H=i.DEPTH24_STENCIL8:_===on?H=i.DEPTH32F_STENCIL8:_===wi&&(H=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):_===null||_===Bn||_===Ri?H=i.DEPTH_COMPONENT24:_===on?H=i.DEPTH_COMPONENT32F:_===wi&&(H=i.DEPTH_COMPONENT16),H}function E(b,_){return p(b)===!0||b.isFramebufferTexture&&b.minFilter!==Xt&&b.minFilter!==Yt?Math.log2(Math.max(_.width,_.height))+1:b.mipmaps!==void 0&&b.mipmaps.length>0?b.mipmaps.length:b.isCompressedTexture&&Array.isArray(b.image)?_.mipmaps.length:1}function T(b){const _=b.target;_.removeEventListener("dispose",T),I(_),_.isVideoTexture&&u.delete(_)}function A(b){const _=b.target;_.removeEventListener("dispose",A),M(_)}function I(b){const _=n.get(b);if(_.__webglInit===void 0)return;const H=b.source,Q=d.get(H);if(Q){const re=Q[_.__cacheKey];re.usedTimes--,re.usedTimes===0&&y(b),Object.keys(Q).length===0&&d.delete(H)}n.remove(b)}function y(b){const _=n.get(b);i.deleteTexture(_.__webglTexture);const H=b.source,Q=d.get(H);delete Q[_.__cacheKey],a.memory.textures--}function M(b){const _=n.get(b);if(b.depthTexture&&(b.depthTexture.dispose(),n.remove(b.depthTexture)),b.isWebGLCubeRenderTarget)for(let Q=0;Q<6;Q++){if(Array.isArray(_.__webglFramebuffer[Q]))for(let re=0;re<_.__webglFramebuffer[Q].length;re++)i.deleteFramebuffer(_.__webglFramebuffer[Q][re]);else i.deleteFramebuffer(_.__webglFramebuffer[Q]);_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer[Q])}else{if(Array.isArray(_.__webglFramebuffer))for(let Q=0;Q<_.__webglFramebuffer.length;Q++)i.deleteFramebuffer(_.__webglFramebuffer[Q]);else i.deleteFramebuffer(_.__webglFramebuffer);if(_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer),_.__webglMultisampledFramebuffer&&i.deleteFramebuffer(_.__webglMultisampledFramebuffer),_.__webglColorRenderbuffer)for(let Q=0;Q<_.__webglColorRenderbuffer.length;Q++)_.__webglColorRenderbuffer[Q]&&i.deleteRenderbuffer(_.__webglColorRenderbuffer[Q]);_.__webglDepthRenderbuffer&&i.deleteRenderbuffer(_.__webglDepthRenderbuffer)}const H=b.textures;for(let Q=0,re=H.length;Q<re;Q++){const J=n.get(H[Q]);J.__webglTexture&&(i.deleteTexture(J.__webglTexture),a.memory.textures--),n.remove(H[Q])}n.remove(b)}let U=0;function W(){U=0}function Z(){const b=U;return b>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+b+" texture units while this GPU supports only "+r.maxTextures),U+=1,b}function te(b){const _=[];return _.push(b.wrapS),_.push(b.wrapT),_.push(b.wrapR||0),_.push(b.magFilter),_.push(b.minFilter),_.push(b.anisotropy),_.push(b.internalFormat),_.push(b.format),_.push(b.type),_.push(b.generateMipmaps),_.push(b.premultiplyAlpha),_.push(b.flipY),_.push(b.unpackAlignment),_.push(b.colorSpace),_.join()}function ne(b,_){const H=n.get(b);if(b.isVideoTexture&&Ne(b),b.isRenderTargetTexture===!1&&b.isExternalTexture!==!0&&b.version>0&&H.__version!==b.version){const Q=b.image;if(Q===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Q.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Y(H,b,_);return}}else b.isExternalTexture&&(H.__webglTexture=b.sourceTexture?b.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,H.__webglTexture,i.TEXTURE0+_)}function ee(b,_){const H=n.get(b);if(b.isRenderTargetTexture===!1&&b.version>0&&H.__version!==b.version){Y(H,b,_);return}t.bindTexture(i.TEXTURE_2D_ARRAY,H.__webglTexture,i.TEXTURE0+_)}function le(b,_){const H=n.get(b);if(b.isRenderTargetTexture===!1&&b.version>0&&H.__version!==b.version){Y(H,b,_);return}t.bindTexture(i.TEXTURE_3D,H.__webglTexture,i.TEXTURE0+_)}function j(b,_){const H=n.get(b);if(b.version>0&&H.__version!==b.version){se(H,b,_);return}t.bindTexture(i.TEXTURE_CUBE_MAP,H.__webglTexture,i.TEXTURE0+_)}const ue={[Cs]:i.REPEAT,[Nn]:i.CLAMP_TO_EDGE,[Ps]:i.MIRRORED_REPEAT},me={[Xt]:i.NEAREST,[Tc]:i.NEAREST_MIPMAP_NEAREST,[Hi]:i.NEAREST_MIPMAP_LINEAR,[Yt]:i.LINEAR,[Or]:i.LINEAR_MIPMAP_NEAREST,[Fn]:i.LINEAR_MIPMAP_LINEAR},be={[Rc]:i.NEVER,[Uc]:i.ALWAYS,[Cc]:i.LESS,[pl]:i.LEQUAL,[Pc]:i.EQUAL,[Ic]:i.GEQUAL,[Dc]:i.GREATER,[Lc]:i.NOTEQUAL};function Be(b,_){if(_.type===on&&e.has("OES_texture_float_linear")===!1&&(_.magFilter===Yt||_.magFilter===Or||_.magFilter===Hi||_.magFilter===Fn||_.minFilter===Yt||_.minFilter===Or||_.minFilter===Hi||_.minFilter===Fn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(b,i.TEXTURE_WRAP_S,ue[_.wrapS]),i.texParameteri(b,i.TEXTURE_WRAP_T,ue[_.wrapT]),(b===i.TEXTURE_3D||b===i.TEXTURE_2D_ARRAY)&&i.texParameteri(b,i.TEXTURE_WRAP_R,ue[_.wrapR]),i.texParameteri(b,i.TEXTURE_MAG_FILTER,me[_.magFilter]),i.texParameteri(b,i.TEXTURE_MIN_FILTER,me[_.minFilter]),_.compareFunction&&(i.texParameteri(b,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(b,i.TEXTURE_COMPARE_FUNC,be[_.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(_.magFilter===Xt||_.minFilter!==Hi&&_.minFilter!==Fn||_.type===on&&e.has("OES_texture_float_linear")===!1)return;if(_.anisotropy>1||n.get(_).__currentAnisotropy){const H=e.get("EXT_texture_filter_anisotropic");i.texParameterf(b,H.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(_.anisotropy,r.getMaxAnisotropy())),n.get(_).__currentAnisotropy=_.anisotropy}}}function de(b,_){let H=!1;b.__webglInit===void 0&&(b.__webglInit=!0,_.addEventListener("dispose",T));const Q=_.source;let re=d.get(Q);re===void 0&&(re={},d.set(Q,re));const J=te(_);if(J!==b.__cacheKey){re[J]===void 0&&(re[J]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,H=!0),re[J].usedTimes++;const Te=re[b.__cacheKey];Te!==void 0&&(re[b.__cacheKey].usedTimes--,Te.usedTimes===0&&y(_)),b.__cacheKey=J,b.__webglTexture=re[J].texture}return H}function je(b,_,H){return Math.floor(Math.floor(b/H)/_)}function Xe(b,_,H,Q){const J=b.updateRanges;if(J.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,_.width,_.height,H,Q,_.data);else{J.sort((w,N)=>w.start-N.start);let Te=0;for(let w=1;w<J.length;w++){const N=J[Te],K=J[w],ie=N.start+N.count,ae=je(K.start,_.width,4),ye=je(N.start,_.width,4);K.start<=ie+1&&ae===ye&&je(K.start+K.count-1,_.width,4)===ae?N.count=Math.max(N.count,K.start+K.count-N.start):(++Te,J[Te]=K)}J.length=Te+1;const he=i.getParameter(i.UNPACK_ROW_LENGTH),Se=i.getParameter(i.UNPACK_SKIP_PIXELS),D=i.getParameter(i.UNPACK_SKIP_ROWS);i.pixelStorei(i.UNPACK_ROW_LENGTH,_.width);for(let w=0,N=J.length;w<N;w++){const K=J[w],ie=Math.floor(K.start/4),ae=Math.ceil(K.count/4),ye=ie%_.width,R=Math.floor(ie/_.width),z=ae,V=1;i.pixelStorei(i.UNPACK_SKIP_PIXELS,ye),i.pixelStorei(i.UNPACK_SKIP_ROWS,R),t.texSubImage2D(i.TEXTURE_2D,0,ye,R,z,V,H,Q,_.data)}b.clearUpdateRanges(),i.pixelStorei(i.UNPACK_ROW_LENGTH,he),i.pixelStorei(i.UNPACK_SKIP_PIXELS,Se),i.pixelStorei(i.UNPACK_SKIP_ROWS,D)}}function Y(b,_,H){let Q=i.TEXTURE_2D;(_.isDataArrayTexture||_.isCompressedArrayTexture)&&(Q=i.TEXTURE_2D_ARRAY),_.isData3DTexture&&(Q=i.TEXTURE_3D);const re=de(b,_),J=_.source;t.bindTexture(Q,b.__webglTexture,i.TEXTURE0+H);const Te=n.get(J);if(J.version!==Te.__version||re===!0){t.activeTexture(i.TEXTURE0+H);const he=Ye.getPrimaries(Ye.workingColorSpace),Se=_.colorSpace===_n?null:Ye.getPrimaries(_.colorSpace),D=_.colorSpace===_n||he===Se?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,_.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,_.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,D);let w=S(_.image,!1,r.maxTextureSize);w=lt(_,w);const N=s.convert(_.format,_.colorSpace),K=s.convert(_.type);let ie=C(_.internalFormat,N,K,_.colorSpace,_.isVideoTexture);Be(Q,_);let ae;const ye=_.mipmaps,R=_.isVideoTexture!==!0,z=Te.__version===void 0||re===!0,V=J.dataReady,$=E(_,w);if(_.isDepthTexture)ie=g(_.format===Pi,_.type),z&&(R?t.texStorage2D(i.TEXTURE_2D,1,ie,w.width,w.height):t.texImage2D(i.TEXTURE_2D,0,ie,w.width,w.height,0,N,K,null));else if(_.isDataTexture)if(ye.length>0){R&&z&&t.texStorage2D(i.TEXTURE_2D,$,ie,ye[0].width,ye[0].height);for(let k=0,G=ye.length;k<G;k++)ae=ye[k],R?V&&t.texSubImage2D(i.TEXTURE_2D,k,0,0,ae.width,ae.height,N,K,ae.data):t.texImage2D(i.TEXTURE_2D,k,ie,ae.width,ae.height,0,N,K,ae.data);_.generateMipmaps=!1}else R?(z&&t.texStorage2D(i.TEXTURE_2D,$,ie,w.width,w.height),V&&Xe(_,w,N,K)):t.texImage2D(i.TEXTURE_2D,0,ie,w.width,w.height,0,N,K,w.data);else if(_.isCompressedTexture)if(_.isCompressedArrayTexture){R&&z&&t.texStorage3D(i.TEXTURE_2D_ARRAY,$,ie,ye[0].width,ye[0].height,w.depth);for(let k=0,G=ye.length;k<G;k++)if(ae=ye[k],_.format!==Wt)if(N!==null)if(R){if(V)if(_.layerUpdates.size>0){const ce=To(ae.width,ae.height,_.format,_.type);for(const _e of _.layerUpdates){const He=ae.data.subarray(_e*ce/ae.data.BYTES_PER_ELEMENT,(_e+1)*ce/ae.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,k,0,0,_e,ae.width,ae.height,1,N,He)}_.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,k,0,0,0,ae.width,ae.height,w.depth,N,ae.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,k,ie,ae.width,ae.height,w.depth,0,ae.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else R?V&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,k,0,0,0,ae.width,ae.height,w.depth,N,K,ae.data):t.texImage3D(i.TEXTURE_2D_ARRAY,k,ie,ae.width,ae.height,w.depth,0,N,K,ae.data)}else{R&&z&&t.texStorage2D(i.TEXTURE_2D,$,ie,ye[0].width,ye[0].height);for(let k=0,G=ye.length;k<G;k++)ae=ye[k],_.format!==Wt?N!==null?R?V&&t.compressedTexSubImage2D(i.TEXTURE_2D,k,0,0,ae.width,ae.height,N,ae.data):t.compressedTexImage2D(i.TEXTURE_2D,k,ie,ae.width,ae.height,0,ae.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):R?V&&t.texSubImage2D(i.TEXTURE_2D,k,0,0,ae.width,ae.height,N,K,ae.data):t.texImage2D(i.TEXTURE_2D,k,ie,ae.width,ae.height,0,N,K,ae.data)}else if(_.isDataArrayTexture)if(R){if(z&&t.texStorage3D(i.TEXTURE_2D_ARRAY,$,ie,w.width,w.height,w.depth),V)if(_.layerUpdates.size>0){const k=To(w.width,w.height,_.format,_.type);for(const G of _.layerUpdates){const ce=w.data.subarray(G*k/w.data.BYTES_PER_ELEMENT,(G+1)*k/w.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,G,w.width,w.height,1,N,K,ce)}_.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,w.width,w.height,w.depth,N,K,w.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,ie,w.width,w.height,w.depth,0,N,K,w.data);else if(_.isData3DTexture)R?(z&&t.texStorage3D(i.TEXTURE_3D,$,ie,w.width,w.height,w.depth),V&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,w.width,w.height,w.depth,N,K,w.data)):t.texImage3D(i.TEXTURE_3D,0,ie,w.width,w.height,w.depth,0,N,K,w.data);else if(_.isFramebufferTexture){if(z)if(R)t.texStorage2D(i.TEXTURE_2D,$,ie,w.width,w.height);else{let k=w.width,G=w.height;for(let ce=0;ce<$;ce++)t.texImage2D(i.TEXTURE_2D,ce,ie,k,G,0,N,K,null),k>>=1,G>>=1}}else if(ye.length>0){if(R&&z){const k=tt(ye[0]);t.texStorage2D(i.TEXTURE_2D,$,ie,k.width,k.height)}for(let k=0,G=ye.length;k<G;k++)ae=ye[k],R?V&&t.texSubImage2D(i.TEXTURE_2D,k,0,0,N,K,ae):t.texImage2D(i.TEXTURE_2D,k,ie,N,K,ae);_.generateMipmaps=!1}else if(R){if(z){const k=tt(w);t.texStorage2D(i.TEXTURE_2D,$,ie,k.width,k.height)}V&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,N,K,w)}else t.texImage2D(i.TEXTURE_2D,0,ie,N,K,w);p(_)&&h(Q),Te.__version=J.version,_.onUpdate&&_.onUpdate(_)}b.__version=_.version}function se(b,_,H){if(_.image.length!==6)return;const Q=de(b,_),re=_.source;t.bindTexture(i.TEXTURE_CUBE_MAP,b.__webglTexture,i.TEXTURE0+H);const J=n.get(re);if(re.version!==J.__version||Q===!0){t.activeTexture(i.TEXTURE0+H);const Te=Ye.getPrimaries(Ye.workingColorSpace),he=_.colorSpace===_n?null:Ye.getPrimaries(_.colorSpace),Se=_.colorSpace===_n||Te===he?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,_.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,_.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Se);const D=_.isCompressedTexture||_.image[0].isCompressedTexture,w=_.image[0]&&_.image[0].isDataTexture,N=[];for(let G=0;G<6;G++)!D&&!w?N[G]=S(_.image[G],!0,r.maxCubemapSize):N[G]=w?_.image[G].image:_.image[G],N[G]=lt(_,N[G]);const K=N[0],ie=s.convert(_.format,_.colorSpace),ae=s.convert(_.type),ye=C(_.internalFormat,ie,ae,_.colorSpace),R=_.isVideoTexture!==!0,z=J.__version===void 0||Q===!0,V=re.dataReady;let $=E(_,K);Be(i.TEXTURE_CUBE_MAP,_);let k;if(D){R&&z&&t.texStorage2D(i.TEXTURE_CUBE_MAP,$,ye,K.width,K.height);for(let G=0;G<6;G++){k=N[G].mipmaps;for(let ce=0;ce<k.length;ce++){const _e=k[ce];_.format!==Wt?ie!==null?R?V&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+G,ce,0,0,_e.width,_e.height,ie,_e.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+G,ce,ye,_e.width,_e.height,0,_e.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):R?V&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+G,ce,0,0,_e.width,_e.height,ie,ae,_e.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+G,ce,ye,_e.width,_e.height,0,ie,ae,_e.data)}}}else{if(k=_.mipmaps,R&&z){k.length>0&&$++;const G=tt(N[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,$,ye,G.width,G.height)}for(let G=0;G<6;G++)if(w){R?V&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+G,0,0,0,N[G].width,N[G].height,ie,ae,N[G].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+G,0,ye,N[G].width,N[G].height,0,ie,ae,N[G].data);for(let ce=0;ce<k.length;ce++){const He=k[ce].image[G].image;R?V&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+G,ce+1,0,0,He.width,He.height,ie,ae,He.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+G,ce+1,ye,He.width,He.height,0,ie,ae,He.data)}}else{R?V&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+G,0,0,0,ie,ae,N[G]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+G,0,ye,ie,ae,N[G]);for(let ce=0;ce<k.length;ce++){const _e=k[ce];R?V&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+G,ce+1,0,0,ie,ae,_e.image[G]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+G,ce+1,ye,ie,ae,_e.image[G])}}}p(_)&&h(i.TEXTURE_CUBE_MAP),J.__version=re.version,_.onUpdate&&_.onUpdate(_)}b.__version=_.version}function ve(b,_,H,Q,re,J){const Te=s.convert(H.format,H.colorSpace),he=s.convert(H.type),Se=C(H.internalFormat,Te,he,H.colorSpace),D=n.get(_),w=n.get(H);if(w.__renderTarget=_,!D.__hasExternalTextures){const N=Math.max(1,_.width>>J),K=Math.max(1,_.height>>J);re===i.TEXTURE_3D||re===i.TEXTURE_2D_ARRAY?t.texImage3D(re,J,Se,N,K,_.depth,0,Te,he,null):t.texImage2D(re,J,Se,N,K,0,Te,he,null)}t.bindFramebuffer(i.FRAMEBUFFER,b),Me(_)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Q,re,w.__webglTexture,0,Qe(_)):(re===i.TEXTURE_2D||re>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&re<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,Q,re,w.__webglTexture,J),t.bindFramebuffer(i.FRAMEBUFFER,null)}function De(b,_,H){if(i.bindRenderbuffer(i.RENDERBUFFER,b),_.depthBuffer){const Q=_.depthTexture,re=Q&&Q.isDepthTexture?Q.type:null,J=g(_.stencilBuffer,re),Te=_.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,he=Qe(_);Me(_)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,he,J,_.width,_.height):H?i.renderbufferStorageMultisample(i.RENDERBUFFER,he,J,_.width,_.height):i.renderbufferStorage(i.RENDERBUFFER,J,_.width,_.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,Te,i.RENDERBUFFER,b)}else{const Q=_.textures;for(let re=0;re<Q.length;re++){const J=Q[re],Te=s.convert(J.format,J.colorSpace),he=s.convert(J.type),Se=C(J.internalFormat,Te,he,J.colorSpace),D=Qe(_);H&&Me(_)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,D,Se,_.width,_.height):Me(_)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,D,Se,_.width,_.height):i.renderbufferStorage(i.RENDERBUFFER,Se,_.width,_.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Ae(b,_){if(_&&_.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(i.FRAMEBUFFER,b),!(_.depthTexture&&_.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const Q=n.get(_.depthTexture);Q.__renderTarget=_,(!Q.__webglTexture||_.depthTexture.image.width!==_.width||_.depthTexture.image.height!==_.height)&&(_.depthTexture.image.width=_.width,_.depthTexture.image.height=_.height,_.depthTexture.needsUpdate=!0),ne(_.depthTexture,0);const re=Q.__webglTexture,J=Qe(_);if(_.depthTexture.format===Ci)Me(_)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,re,0,J):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,re,0);else if(_.depthTexture.format===Pi)Me(_)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,re,0,J):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,re,0);else throw new Error("Unknown depthTexture format")}function Ie(b){const _=n.get(b),H=b.isWebGLCubeRenderTarget===!0;if(_.__boundDepthTexture!==b.depthTexture){const Q=b.depthTexture;if(_.__depthDisposeCallback&&_.__depthDisposeCallback(),Q){const re=()=>{delete _.__boundDepthTexture,delete _.__depthDisposeCallback,Q.removeEventListener("dispose",re)};Q.addEventListener("dispose",re),_.__depthDisposeCallback=re}_.__boundDepthTexture=Q}if(b.depthTexture&&!_.__autoAllocateDepthBuffer){if(H)throw new Error("target.depthTexture not supported in Cube render targets");const Q=b.texture.mipmaps;Q&&Q.length>0?Ae(_.__webglFramebuffer[0],b):Ae(_.__webglFramebuffer,b)}else if(H){_.__webglDepthbuffer=[];for(let Q=0;Q<6;Q++)if(t.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer[Q]),_.__webglDepthbuffer[Q]===void 0)_.__webglDepthbuffer[Q]=i.createRenderbuffer(),De(_.__webglDepthbuffer[Q],b,!1);else{const re=b.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,J=_.__webglDepthbuffer[Q];i.bindRenderbuffer(i.RENDERBUFFER,J),i.framebufferRenderbuffer(i.FRAMEBUFFER,re,i.RENDERBUFFER,J)}}else{const Q=b.texture.mipmaps;if(Q&&Q.length>0?t.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer),_.__webglDepthbuffer===void 0)_.__webglDepthbuffer=i.createRenderbuffer(),De(_.__webglDepthbuffer,b,!1);else{const re=b.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,J=_.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,J),i.framebufferRenderbuffer(i.FRAMEBUFFER,re,i.RENDERBUFFER,J)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function ht(b,_,H){const Q=n.get(b);_!==void 0&&ve(Q.__webglFramebuffer,b,b.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),H!==void 0&&Ie(b)}function P(b){const _=b.texture,H=n.get(b),Q=n.get(_);b.addEventListener("dispose",A);const re=b.textures,J=b.isWebGLCubeRenderTarget===!0,Te=re.length>1;if(Te||(Q.__webglTexture===void 0&&(Q.__webglTexture=i.createTexture()),Q.__version=_.version,a.memory.textures++),J){H.__webglFramebuffer=[];for(let he=0;he<6;he++)if(_.mipmaps&&_.mipmaps.length>0){H.__webglFramebuffer[he]=[];for(let Se=0;Se<_.mipmaps.length;Se++)H.__webglFramebuffer[he][Se]=i.createFramebuffer()}else H.__webglFramebuffer[he]=i.createFramebuffer()}else{if(_.mipmaps&&_.mipmaps.length>0){H.__webglFramebuffer=[];for(let he=0;he<_.mipmaps.length;he++)H.__webglFramebuffer[he]=i.createFramebuffer()}else H.__webglFramebuffer=i.createFramebuffer();if(Te)for(let he=0,Se=re.length;he<Se;he++){const D=n.get(re[he]);D.__webglTexture===void 0&&(D.__webglTexture=i.createTexture(),a.memory.textures++)}if(b.samples>0&&Me(b)===!1){H.__webglMultisampledFramebuffer=i.createFramebuffer(),H.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,H.__webglMultisampledFramebuffer);for(let he=0;he<re.length;he++){const Se=re[he];H.__webglColorRenderbuffer[he]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,H.__webglColorRenderbuffer[he]);const D=s.convert(Se.format,Se.colorSpace),w=s.convert(Se.type),N=C(Se.internalFormat,D,w,Se.colorSpace,b.isXRRenderTarget===!0),K=Qe(b);i.renderbufferStorageMultisample(i.RENDERBUFFER,K,N,b.width,b.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+he,i.RENDERBUFFER,H.__webglColorRenderbuffer[he])}i.bindRenderbuffer(i.RENDERBUFFER,null),b.depthBuffer&&(H.__webglDepthRenderbuffer=i.createRenderbuffer(),De(H.__webglDepthRenderbuffer,b,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(J){t.bindTexture(i.TEXTURE_CUBE_MAP,Q.__webglTexture),Be(i.TEXTURE_CUBE_MAP,_);for(let he=0;he<6;he++)if(_.mipmaps&&_.mipmaps.length>0)for(let Se=0;Se<_.mipmaps.length;Se++)ve(H.__webglFramebuffer[he][Se],b,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+he,Se);else ve(H.__webglFramebuffer[he],b,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+he,0);p(_)&&h(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Te){for(let he=0,Se=re.length;he<Se;he++){const D=re[he],w=n.get(D);let N=i.TEXTURE_2D;(b.isWebGL3DRenderTarget||b.isWebGLArrayRenderTarget)&&(N=b.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(N,w.__webglTexture),Be(N,D),ve(H.__webglFramebuffer,b,D,i.COLOR_ATTACHMENT0+he,N,0),p(D)&&h(N)}t.unbindTexture()}else{let he=i.TEXTURE_2D;if((b.isWebGL3DRenderTarget||b.isWebGLArrayRenderTarget)&&(he=b.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(he,Q.__webglTexture),Be(he,_),_.mipmaps&&_.mipmaps.length>0)for(let Se=0;Se<_.mipmaps.length;Se++)ve(H.__webglFramebuffer[Se],b,_,i.COLOR_ATTACHMENT0,he,Se);else ve(H.__webglFramebuffer,b,_,i.COLOR_ATTACHMENT0,he,0);p(_)&&h(he),t.unbindTexture()}b.depthBuffer&&Ie(b)}function Je(b){const _=b.textures;for(let H=0,Q=_.length;H<Q;H++){const re=_[H];if(p(re)){const J=L(b),Te=n.get(re).__webglTexture;t.bindTexture(J,Te),h(J),t.unbindTexture()}}}const Ue=[],Re=[];function xe(b){if(b.samples>0){if(Me(b)===!1){const _=b.textures,H=b.width,Q=b.height;let re=i.COLOR_BUFFER_BIT;const J=b.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Te=n.get(b),he=_.length>1;if(he)for(let D=0;D<_.length;D++)t.bindFramebuffer(i.FRAMEBUFFER,Te.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+D,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,Te.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+D,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,Te.__webglMultisampledFramebuffer);const Se=b.texture.mipmaps;Se&&Se.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,Te.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,Te.__webglFramebuffer);for(let D=0;D<_.length;D++){if(b.resolveDepthBuffer&&(b.depthBuffer&&(re|=i.DEPTH_BUFFER_BIT),b.stencilBuffer&&b.resolveStencilBuffer&&(re|=i.STENCIL_BUFFER_BIT)),he){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,Te.__webglColorRenderbuffer[D]);const w=n.get(_[D]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,w,0)}i.blitFramebuffer(0,0,H,Q,0,0,H,Q,re,i.NEAREST),c===!0&&(Ue.length=0,Re.length=0,Ue.push(i.COLOR_ATTACHMENT0+D),b.depthBuffer&&b.resolveDepthBuffer===!1&&(Ue.push(J),Re.push(J),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,Re)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,Ue))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),he)for(let D=0;D<_.length;D++){t.bindFramebuffer(i.FRAMEBUFFER,Te.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+D,i.RENDERBUFFER,Te.__webglColorRenderbuffer[D]);const w=n.get(_[D]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,Te.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+D,i.TEXTURE_2D,w,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,Te.__webglMultisampledFramebuffer)}else if(b.depthBuffer&&b.resolveDepthBuffer===!1&&c){const _=b.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[_])}}}function Qe(b){return Math.min(r.maxSamples,b.samples)}function Me(b){const _=n.get(b);return b.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&_.__useRenderToTexture!==!1}function Ne(b){const _=a.render.frame;u.get(b)!==_&&(u.set(b,_),b.update())}function lt(b,_){const H=b.colorSpace,Q=b.format,re=b.type;return b.isCompressedTexture===!0||b.isVideoTexture===!0||H!==fi&&H!==_n&&(Ye.getTransfer(H)===$e?(Q!==Wt||re!==Zt)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",H)),_}function tt(b){return typeof HTMLImageElement<"u"&&b instanceof HTMLImageElement?(l.width=b.naturalWidth||b.width,l.height=b.naturalHeight||b.height):typeof VideoFrame<"u"&&b instanceof VideoFrame?(l.width=b.displayWidth,l.height=b.displayHeight):(l.width=b.width,l.height=b.height),l}this.allocateTextureUnit=Z,this.resetTextureUnits=W,this.setTexture2D=ne,this.setTexture2DArray=ee,this.setTexture3D=le,this.setTextureCube=j,this.rebindTextures=ht,this.setupRenderTarget=P,this.updateRenderTargetMipmap=Je,this.updateMultisampleRenderTarget=xe,this.setupDepthRenderbuffer=Ie,this.setupFrameBufferTexture=ve,this.useMultisampledRTT=Me}function nm(i,e){function t(n,r=_n){let s;const a=Ye.getTransfer(r);if(n===Zt)return i.UNSIGNED_BYTE;if(n===xa)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Ma)return i.UNSIGNED_SHORT_5_5_5_1;if(n===ol)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===ll)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===sl)return i.BYTE;if(n===al)return i.SHORT;if(n===wi)return i.UNSIGNED_SHORT;if(n===va)return i.INT;if(n===Bn)return i.UNSIGNED_INT;if(n===on)return i.FLOAT;if(n===Ii)return i.HALF_FLOAT;if(n===cl)return i.ALPHA;if(n===hl)return i.RGB;if(n===Wt)return i.RGBA;if(n===Ci)return i.DEPTH_COMPONENT;if(n===Pi)return i.DEPTH_STENCIL;if(n===ul)return i.RED;if(n===Sa)return i.RED_INTEGER;if(n===fl)return i.RG;if(n===ya)return i.RG_INTEGER;if(n===Ea)return i.RGBA_INTEGER;if(n===_r||n===gr||n===vr||n===xr)if(a===$e)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===_r)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===gr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===vr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===xr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===_r)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===gr)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===vr)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===xr)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Ds||n===Ls||n===Is||n===Us)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===Ds)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Ls)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Is)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Us)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Ns||n===Fs||n===Os)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===Ns||n===Fs)return a===$e?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===Os)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===Bs||n===zs||n===Hs||n===ks||n===Vs||n===Gs||n===Ws||n===Xs||n===qs||n===Ys||n===js||n===Ks||n===$s||n===Zs)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===Bs)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===zs)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Hs)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===ks)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Vs)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Gs)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Ws)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Xs)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===qs)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Ys)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===js)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Ks)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===$s)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Zs)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Js||n===Qs||n===ea)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===Js)return a===$e?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Qs)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===ea)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===ta||n===na||n===ia||n===ra)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===ta)return s.COMPRESSED_RED_RGTC1_EXT;if(n===na)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===ia)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===ra)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ri?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const im=`
3829
+ }`;function Um(i,e,t){let n=new ea;const r=new Ue,s=new Ue,o=new ut,a=new eu({depthPacking:hh}),c=new tu,l={},u=t.maxTextureSize,f={[Dn]:Ut,[Ut]:Dn,[on]:on},d=new Ln({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ue},radius:{value:4}},vertexShader:Lm,fragmentShader:Im}),m=d.clone();m.defines.HORIZONTAL_PASS=1;const g=new vt;g.setAttribute("position",new cn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new _e(g,d),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=kl;let h=this.type;this.render=function(E,A,C){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||E.length===0)return;const M=i.getRenderTarget(),x=i.getActiveCubeFace(),N=i.getActiveMipmapLevel(),z=i.state;z.setBlending(Cn),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 q=h!==_n&&this.type===_n,j=h===_n&&this.type!==_n;for(let Q=0,K=E.length;Q<K;Q++){const se=E[Q],Z=se.shadow;if(Z===void 0){console.warn("THREE.WebGLShadowMap:",se,"has no shadow.");continue}if(Z.autoUpdate===!1&&Z.needsUpdate===!1)continue;r.copy(Z.mapSize);const le=Z.getFrameExtents();if(r.multiply(le),s.copy(Z.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/le.x),r.x=s.x*le.x,Z.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/le.y),r.y=s.y*le.y,Z.mapSize.y=s.y)),Z.map===null||q===!0||j===!0){const Me=this.type!==_n?{minFilter:en,magFilter:en}:{};Z.map!==null&&Z.map.dispose(),Z.map=new Kn(r.x,r.y,Me),Z.map.texture.name=se.name+".shadowMap",Z.camera.updateProjectionMatrix()}i.setRenderTarget(Z.map),i.clear();const pe=Z.getViewportCount();for(let Me=0;Me<pe;Me++){const Ne=Z.getViewport(Me);o.set(s.x*Ne.x,s.y*Ne.y,s.x*Ne.z,s.y*Ne.w),z.viewport(o),Z.updateMatrices(se,Me),n=Z.getFrustum(),_(A,C,Z.camera,se,this.type)}Z.isPointLightShadow!==!0&&this.type===_n&&w(Z,C),Z.needsUpdate=!1}h=this.type,p.needsUpdate=!1,i.setRenderTarget(M,x,N)};function w(E,A){const C=e.update(y);d.defines.VSM_SAMPLES!==E.blurSamples&&(d.defines.VSM_SAMPLES=E.blurSamples,m.defines.VSM_SAMPLES=E.blurSamples,d.needsUpdate=!0,m.needsUpdate=!0),E.mapPass===null&&(E.mapPass=new Kn(r.x,r.y)),d.uniforms.shadow_pass.value=E.map.texture,d.uniforms.resolution.value=E.mapSize,d.uniforms.radius.value=E.radius,i.setRenderTarget(E.mapPass),i.clear(),i.renderBufferDirect(A,null,C,d,y,null),m.uniforms.shadow_pass.value=E.mapPass.texture,m.uniforms.resolution.value=E.mapSize,m.uniforms.radius.value=E.radius,i.setRenderTarget(E.map),i.clear(),i.renderBufferDirect(A,null,C,m,y,null)}function b(E,A,C,M){let x=null;const N=C.isPointLight===!0?E.customDistanceMaterial:E.customDepthMaterial;if(N!==void 0)x=N;else if(x=C.isPointLight===!0?c:a,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 z=x.uuid,q=A.uuid;let j=l[z];j===void 0&&(j={},l[z]=j);let Q=j[q];Q===void 0&&(Q=x.clone(),j[q]=Q,A.addEventListener("dispose",T)),x=Q}if(x.visible=A.visible,x.wireframe=A.wireframe,M===_n?x.side=A.shadowSide!==null?A.shadowSide:A.side:x.side=A.shadowSide!==null?A.shadowSide:f[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=i.properties.get(x);z.light=C}return x}function _(E,A,C,M,x){if(E.visible===!1)return;if(E.layers.test(A.layers)&&(E.isMesh||E.isLine||E.isPoints)&&(E.castShadow||E.receiveShadow&&x===_n)&&(!E.frustumCulled||n.intersectsObject(E))){E.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,E.matrixWorld);const q=e.update(E),j=E.material;if(Array.isArray(j)){const Q=q.groups;for(let K=0,se=Q.length;K<se;K++){const Z=Q[K],le=j[Z.materialIndex];if(le&&le.visible){const pe=b(E,le,M,x);E.onBeforeShadow(i,E,A,C,q,pe,Z),i.renderBufferDirect(C,null,q,pe,E,Z),E.onAfterShadow(i,E,A,C,q,pe,Z)}}}else if(j.visible){const Q=b(E,j,M,x);E.onBeforeShadow(i,E,A,C,q,Q,null),i.renderBufferDirect(C,null,q,Q,E,null),E.onAfterShadow(i,E,A,C,q,Q,null)}}const z=E.children;for(let q=0,j=z.length;q<j;q++)_(z[q],A,C,M,x)}function T(E){E.target.removeEventListener("dispose",T);for(const C in l){const M=l[C],x=E.target.uuid;x in M&&(M[x].dispose(),delete M[x])}}}const Nm={[Vs]:Ws,[Xs]:js,[Ys]:Zs,[Si]:qs,[Ws]:Vs,[js]:Xs,[Zs]:Ys,[qs]:Si};function Om(i,e){function t(){let D=!1;const H=new ut;let V=null;const ee=new ut(0,0,0,0);return{setMask:function(G){V!==G&&!D&&(i.colorMask(G,G,G,G),V=G)},setLocked:function(G){D=G},setClear:function(G,W,he,ge,ke){ke===!0&&(G*=ge,W*=ge,he*=ge),H.set(G,W,he,ge),ee.equals(H)===!1&&(i.clearColor(G,W,he,ge),ee.copy(H))},reset:function(){D=!1,V=null,ee.set(-1,0,0,0)}}}function n(){let D=!1,H=!1,V=null,ee=null,G=null;return{setReversed:function(W){if(H!==W){const he=e.get("EXT_clip_control");W?he.clipControlEXT(he.LOWER_LEFT_EXT,he.ZERO_TO_ONE_EXT):he.clipControlEXT(he.LOWER_LEFT_EXT,he.NEGATIVE_ONE_TO_ONE_EXT),H=W;const ge=G;G=null,this.setClear(ge)}},getReversed:function(){return H},setTest:function(W){W?oe(i.DEPTH_TEST):xe(i.DEPTH_TEST)},setMask:function(W){V!==W&&!D&&(i.depthMask(W),V=W)},setFunc:function(W){if(H&&(W=Nm[W]),ee!==W){switch(W){case Vs:i.depthFunc(i.NEVER);break;case Ws:i.depthFunc(i.ALWAYS);break;case Xs:i.depthFunc(i.LESS);break;case Si:i.depthFunc(i.LEQUAL);break;case Ys:i.depthFunc(i.EQUAL);break;case qs:i.depthFunc(i.GEQUAL);break;case js:i.depthFunc(i.GREATER);break;case Zs:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}ee=W}},setLocked:function(W){D=W},setClear:function(W){G!==W&&(H&&(W=1-W),i.clearDepth(W),G=W)},reset:function(){D=!1,V=null,ee=null,G=null,H=!1}}}function r(){let D=!1,H=null,V=null,ee=null,G=null,W=null,he=null,ge=null,ke=null;return{setTest:function(Ye){D||(Ye?oe(i.STENCIL_TEST):xe(i.STENCIL_TEST))},setMask:function(Ye){H!==Ye&&!D&&(i.stencilMask(Ye),H=Ye)},setFunc:function(Ye,Zt,kt){(V!==Ye||ee!==Zt||G!==kt)&&(i.stencilFunc(Ye,Zt,kt),V=Ye,ee=Zt,G=kt)},setOp:function(Ye,Zt,kt){(W!==Ye||he!==Zt||ge!==kt)&&(i.stencilOp(Ye,Zt,kt),W=Ye,he=Zt,ge=kt)},setLocked:function(Ye){D=Ye},setClear:function(Ye){ke!==Ye&&(i.clearStencil(Ye),ke=Ye)},reset:function(){D=!1,H=null,V=null,ee=null,G=null,W=null,he=null,ge=null,ke=null}}}const s=new t,o=new n,a=new r,c=new WeakMap,l=new WeakMap;let u={},f={},d=new WeakMap,m=[],g=null,y=!1,p=null,h=null,w=null,b=null,_=null,T=null,E=null,A=new We(0,0,0),C=0,M=!1,x=null,N=null,z=null,q=null,j=null;const Q=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,se=0;const Z=i.getParameter(i.VERSION);Z.indexOf("WebGL")!==-1?(se=parseFloat(/^WebGL (\d)/.exec(Z)[1]),K=se>=1):Z.indexOf("OpenGL ES")!==-1&&(se=parseFloat(/^OpenGL ES (\d)/.exec(Z)[1]),K=se>=2);let le=null,pe={};const Me=i.getParameter(i.SCISSOR_BOX),Ne=i.getParameter(i.VIEWPORT),fe=new ut().fromArray(Me),Xe=new ut().fromArray(Ne);function qe(D,H,V,ee){const G=new Uint8Array(4),W=i.createTexture();i.bindTexture(D,W),i.texParameteri(D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(D,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let he=0;he<V;he++)D===i.TEXTURE_3D||D===i.TEXTURE_2D_ARRAY?i.texImage3D(H,0,i.RGBA,1,1,ee,0,i.RGBA,i.UNSIGNED_BYTE,G):i.texImage2D(H+he,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,G);return W}const $={};$[i.TEXTURE_2D]=qe(i.TEXTURE_2D,i.TEXTURE_2D,1),$[i.TEXTURE_CUBE_MAP]=qe(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),$[i.TEXTURE_2D_ARRAY]=qe(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),$[i.TEXTURE_3D]=qe(i.TEXTURE_3D,i.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),a.setClear(0),oe(i.DEPTH_TEST),o.setFunc(Si),Ce(!1),ye(ya),oe(i.CULL_FACE),et(Cn);function oe(D){u[D]!==!0&&(i.enable(D),u[D]=!0)}function xe(D){u[D]!==!1&&(i.disable(D),u[D]=!1)}function Le(D,H){return f[D]!==H?(i.bindFramebuffer(D,H),f[D]=H,D===i.DRAW_FRAMEBUFFER&&(f[i.FRAMEBUFFER]=H),D===i.FRAMEBUFFER&&(f[i.DRAW_FRAMEBUFFER]=H),!0):!1}function Ae(D,H){let V=m,ee=!1;if(D){V=d.get(H),V===void 0&&(V=[],d.set(H,V));const G=D.textures;if(V.length!==G.length||V[0]!==i.COLOR_ATTACHMENT0){for(let W=0,he=G.length;W<he;W++)V[W]=i.COLOR_ATTACHMENT0+W;V.length=G.length,ee=!0}}else V[0]!==i.BACK&&(V[0]=i.BACK,ee=!0);ee&&i.drawBuffers(V)}function Oe(D){return g!==D?(i.useProgram(D),g=D,!0):!1}const _t={[Wn]:i.FUNC_ADD,[Oc]:i.FUNC_SUBTRACT,[Fc]:i.FUNC_REVERSE_SUBTRACT};_t[Bc]=i.MIN,_t[zc]=i.MAX;const L={[Hc]:i.ZERO,[kc]:i.ONE,[Gc]:i.SRC_COLOR,[ks]:i.SRC_ALPHA,[jc]:i.SRC_ALPHA_SATURATE,[Yc]:i.DST_COLOR,[Wc]:i.DST_ALPHA,[Vc]:i.ONE_MINUS_SRC_COLOR,[Gs]:i.ONE_MINUS_SRC_ALPHA,[qc]:i.ONE_MINUS_DST_COLOR,[Xc]:i.ONE_MINUS_DST_ALPHA,[Zc]:i.CONSTANT_COLOR,[$c]:i.ONE_MINUS_CONSTANT_COLOR,[Kc]:i.CONSTANT_ALPHA,[Qc]:i.ONE_MINUS_CONSTANT_ALPHA};function et(D,H,V,ee,G,W,he,ge,ke,Ye){if(D===Cn){y===!0&&(xe(i.BLEND),y=!1);return}if(y===!1&&(oe(i.BLEND),y=!0),D!==Nc){if(D!==p||Ye!==M){if((h!==Wn||_!==Wn)&&(i.blendEquation(i.FUNC_ADD),h=Wn,_=Wn),Ye)switch(D){case Mi:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Sa:i.blendFunc(i.ONE,i.ONE);break;case Ea:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Ta:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:console.error("THREE.WebGLState: Invalid blending: ",D);break}else switch(D){case Mi:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Sa:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case Ea:console.error("THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Ta:console.error("THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:console.error("THREE.WebGLState: Invalid blending: ",D);break}w=null,b=null,T=null,E=null,A.set(0,0,0),C=0,p=D,M=Ye}return}G=G||H,W=W||V,he=he||ee,(H!==h||G!==_)&&(i.blendEquationSeparate(_t[H],_t[G]),h=H,_=G),(V!==w||ee!==b||W!==T||he!==E)&&(i.blendFuncSeparate(L[V],L[ee],L[W],L[he]),w=V,b=ee,T=W,E=he),(ge.equals(A)===!1||ke!==C)&&(i.blendColor(ge.r,ge.g,ge.b,ke),A.copy(ge),C=ke),p=D,M=!1}function Fe(D,H){D.side===on?xe(i.CULL_FACE):oe(i.CULL_FACE);let V=D.side===Ut;H&&(V=!V),Ce(V),D.blending===Mi&&D.transparent===!1?et(Cn):et(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(i.SAMPLE_ALPHA_TO_COVERAGE):xe(i.SAMPLE_ALPHA_TO_COVERAGE)}function Ce(D){x!==D&&(D?i.frontFace(i.CW):i.frontFace(i.CCW),x=D)}function ye(D){D!==Lc?(oe(i.CULL_FACE),D!==N&&(D===ya?i.cullFace(i.BACK):D===Ic?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):xe(i.CULL_FACE),N=D}function tt(D){D!==z&&(K&&i.lineWidth(D),z=D)}function Se(D,H,V){D?(oe(i.POLYGON_OFFSET_FILL),(q!==H||j!==V)&&(i.polygonOffset(H,V),q=H,j=V)):xe(i.POLYGON_OFFSET_FILL)}function Be(D){D?oe(i.SCISSOR_TEST):xe(i.SCISSOR_TEST)}function ft(D){D===void 0&&(D=i.TEXTURE0+Q-1),le!==D&&(i.activeTexture(D),le=D)}function rt(D,H,V){V===void 0&&(le===null?V=i.TEXTURE0+Q-1:V=le);let ee=pe[V];ee===void 0&&(ee={type:void 0,texture:void 0},pe[V]=ee),(ee.type!==D||ee.texture!==H)&&(le!==V&&(i.activeTexture(V),le=V),i.bindTexture(D,H||$[D]),ee.type=D,ee.texture=H)}function R(){const D=pe[le];D!==void 0&&D.type!==void 0&&(i.bindTexture(D.type,null),D.type=void 0,D.texture=void 0)}function v(){try{i.compressedTexImage2D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function k(){try{i.compressedTexImage3D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function ne(){try{i.texSubImage2D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function re(){try{i.texSubImage3D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function te(){try{i.compressedTexSubImage2D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function we(){try{i.compressedTexSubImage3D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function ue(){try{i.texStorage2D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function Ee(){try{i.texStorage3D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function I(){try{i.texImage2D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function P(){try{i.texImage3D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function O(D){fe.equals(D)===!1&&(i.scissor(D.x,D.y,D.z,D.w),fe.copy(D))}function J(D){Xe.equals(D)===!1&&(i.viewport(D.x,D.y,D.z,D.w),Xe.copy(D))}function ie(D,H){let V=l.get(H);V===void 0&&(V=new WeakMap,l.set(H,V));let ee=V.get(D);ee===void 0&&(ee=i.getUniformBlockIndex(H,D.name),V.set(D,ee))}function ae(D,H){const ee=l.get(H).get(D);c.get(H)!==ee&&(i.uniformBlockBinding(H,ee,D.__bindingPointIndex),c.set(H,ee))}function Te(){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),o.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),u={},le=null,pe={},f={},d=new WeakMap,m=[],g=null,y=!1,p=null,h=null,w=null,b=null,_=null,T=null,E=null,A=new We(0,0,0),C=0,M=!1,x=null,N=null,z=null,q=null,j=null,fe.set(0,0,i.canvas.width,i.canvas.height),Xe.set(0,0,i.canvas.width,i.canvas.height),s.reset(),o.reset(),a.reset()}return{buffers:{color:s,depth:o,stencil:a},enable:oe,disable:xe,bindFramebuffer:Le,drawBuffers:Ae,useProgram:Oe,setBlending:et,setMaterial:Fe,setFlipSided:Ce,setCullFace:ye,setLineWidth:tt,setPolygonOffset:Se,setScissorTest:Be,activeTexture:ft,bindTexture:rt,unbindTexture:R,compressedTexImage2D:v,compressedTexImage3D:k,texImage2D:I,texImage3D:P,updateUBOMapping:ie,uniformBlockBinding:ae,texStorage2D:ue,texStorage3D:Ee,texSubImage2D:ne,texSubImage3D:re,compressedTexSubImage2D:te,compressedTexSubImage3D:we,scissor:O,viewport:J,reset:Te}}function Fm(i,e,t,n,r,s,o){const a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Ue,u=new WeakMap;let f;const d=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(R,v){return m?new OffscreenCanvas(R,v):qr("canvas")}function y(R,v,k){let ne=1;const re=rt(R);if((re.width>k||re.height>k)&&(ne=k/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),we=Math.floor(ne*re.height);f===void 0&&(f=g(te,we));const ue=v?g(te,we):f;return ue.width=te,ue.height=we,ue.getContext("2d").drawImage(R,0,0,te,we),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+re.width+"x"+re.height+") to ("+te+"x"+we+")."),ue}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+re.width+"x"+re.height+")."),R;return R}function p(R){return R.generateMipmaps}function h(R){i.generateMipmap(R)}function w(R){return R.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:R.isWebGL3DRenderTarget?i.TEXTURE_3D:R.isWebGLArrayRenderTarget||R.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function b(R,v,k,ne,re=!1){if(R!==null){if(i[R]!==void 0)return i[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let te=v;if(v===i.RED&&(k===i.FLOAT&&(te=i.R32F),k===i.HALF_FLOAT&&(te=i.R16F),k===i.UNSIGNED_BYTE&&(te=i.R8)),v===i.RED_INTEGER&&(k===i.UNSIGNED_BYTE&&(te=i.R8UI),k===i.UNSIGNED_SHORT&&(te=i.R16UI),k===i.UNSIGNED_INT&&(te=i.R32UI),k===i.BYTE&&(te=i.R8I),k===i.SHORT&&(te=i.R16I),k===i.INT&&(te=i.R32I)),v===i.RG&&(k===i.FLOAT&&(te=i.RG32F),k===i.HALF_FLOAT&&(te=i.RG16F),k===i.UNSIGNED_BYTE&&(te=i.RG8)),v===i.RG_INTEGER&&(k===i.UNSIGNED_BYTE&&(te=i.RG8UI),k===i.UNSIGNED_SHORT&&(te=i.RG16UI),k===i.UNSIGNED_INT&&(te=i.RG32UI),k===i.BYTE&&(te=i.RG8I),k===i.SHORT&&(te=i.RG16I),k===i.INT&&(te=i.RG32I)),v===i.RGB_INTEGER&&(k===i.UNSIGNED_BYTE&&(te=i.RGB8UI),k===i.UNSIGNED_SHORT&&(te=i.RGB16UI),k===i.UNSIGNED_INT&&(te=i.RGB32UI),k===i.BYTE&&(te=i.RGB8I),k===i.SHORT&&(te=i.RGB16I),k===i.INT&&(te=i.RGB32I)),v===i.RGBA_INTEGER&&(k===i.UNSIGNED_BYTE&&(te=i.RGBA8UI),k===i.UNSIGNED_SHORT&&(te=i.RGBA16UI),k===i.UNSIGNED_INT&&(te=i.RGBA32UI),k===i.BYTE&&(te=i.RGBA8I),k===i.SHORT&&(te=i.RGBA16I),k===i.INT&&(te=i.RGBA32I)),v===i.RGB&&(k===i.UNSIGNED_INT_5_9_9_9_REV&&(te=i.RGB9_E5),k===i.UNSIGNED_INT_10F_11F_11F_REV&&(te=i.R11F_G11F_B10F)),v===i.RGBA){const we=re?Xr:Ze.getTransfer(ne);k===i.FLOAT&&(te=i.RGBA32F),k===i.HALF_FLOAT&&(te=i.RGBA16F),k===i.UNSIGNED_BYTE&&(te=we===Qe?i.SRGB8_ALPHA8:i.RGBA8),k===i.UNSIGNED_SHORT_4_4_4_4&&(te=i.RGBA4),k===i.UNSIGNED_SHORT_5_5_5_1&&(te=i.RGB5_A1)}return(te===i.R16F||te===i.R32F||te===i.RG16F||te===i.RG32F||te===i.RGBA16F||te===i.RGBA32F)&&e.get("EXT_color_buffer_float"),te}function _(R,v){let k;return R?v===null||v===$n||v===Yi?k=i.DEPTH24_STENCIL8:v===gn?k=i.DEPTH32F_STENCIL8:v===Xi&&(k=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):v===null||v===$n||v===Yi?k=i.DEPTH_COMPONENT24:v===gn?k=i.DEPTH_COMPONENT32F:v===Xi&&(k=i.DEPTH_COMPONENT16),k}function T(R,v){return p(R)===!0||R.isFramebufferTexture&&R.minFilter!==en&&R.minFilter!==an?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 E(R){const v=R.target;v.removeEventListener("dispose",E),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=n.get(R);if(v.__webglInit===void 0)return;const k=R.source,ne=d.get(k);if(ne){const re=ne[v.__cacheKey];re.usedTimes--,re.usedTimes===0&&M(R),Object.keys(ne).length===0&&d.delete(k)}n.remove(R)}function M(R){const v=n.get(R);i.deleteTexture(v.__webglTexture);const k=R.source,ne=d.get(k);delete ne[v.__cacheKey],o.memory.textures--}function x(R){const v=n.get(R);if(R.depthTexture&&(R.depthTexture.dispose(),n.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++)i.deleteFramebuffer(v.__webglFramebuffer[ne][re]);else i.deleteFramebuffer(v.__webglFramebuffer[ne]);v.__webglDepthbuffer&&i.deleteRenderbuffer(v.__webglDepthbuffer[ne])}else{if(Array.isArray(v.__webglFramebuffer))for(let ne=0;ne<v.__webglFramebuffer.length;ne++)i.deleteFramebuffer(v.__webglFramebuffer[ne]);else i.deleteFramebuffer(v.__webglFramebuffer);if(v.__webglDepthbuffer&&i.deleteRenderbuffer(v.__webglDepthbuffer),v.__webglMultisampledFramebuffer&&i.deleteFramebuffer(v.__webglMultisampledFramebuffer),v.__webglColorRenderbuffer)for(let ne=0;ne<v.__webglColorRenderbuffer.length;ne++)v.__webglColorRenderbuffer[ne]&&i.deleteRenderbuffer(v.__webglColorRenderbuffer[ne]);v.__webglDepthRenderbuffer&&i.deleteRenderbuffer(v.__webglDepthRenderbuffer)}const k=R.textures;for(let ne=0,re=k.length;ne<re;ne++){const te=n.get(k[ne]);te.__webglTexture&&(i.deleteTexture(te.__webglTexture),o.memory.textures--),n.remove(k[ne])}n.remove(R)}let N=0;function z(){N=0}function q(){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 j(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 Q(R,v){const k=n.get(R);if(R.isVideoTexture&&Be(R),R.isRenderTargetTexture===!1&&R.isExternalTexture!==!0&&R.version>0&&k.__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{$(k,R,v);return}}else R.isExternalTexture&&(k.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,k.__webglTexture,i.TEXTURE0+v)}function K(R,v){const k=n.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&k.__version!==R.version){$(k,R,v);return}t.bindTexture(i.TEXTURE_2D_ARRAY,k.__webglTexture,i.TEXTURE0+v)}function se(R,v){const k=n.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&k.__version!==R.version){$(k,R,v);return}t.bindTexture(i.TEXTURE_3D,k.__webglTexture,i.TEXTURE0+v)}function Z(R,v){const k=n.get(R);if(R.version>0&&k.__version!==R.version){oe(k,R,v);return}t.bindTexture(i.TEXTURE_CUBE_MAP,k.__webglTexture,i.TEXTURE0+v)}const le={[Qs]:i.REPEAT,[jn]:i.CLAMP_TO_EDGE,[Js]:i.MIRRORED_REPEAT},pe={[en]:i.NEAREST,[lh]:i.NEAREST_MIPMAP_NEAREST,[ir]:i.NEAREST_MIPMAP_LINEAR,[an]:i.LINEAR,[ss]:i.LINEAR_MIPMAP_NEAREST,[Zn]:i.LINEAR_MIPMAP_LINEAR},Me={[fh]:i.NEVER,[vh]:i.ALWAYS,[dh]:i.LESS,[Jl]:i.LEQUAL,[ph]:i.EQUAL,[gh]:i.GEQUAL,[mh]:i.GREATER,[_h]:i.NOTEQUAL};function Ne(R,v){if(v.type===gn&&e.has("OES_texture_float_linear")===!1&&(v.magFilter===an||v.magFilter===ss||v.magFilter===ir||v.magFilter===Zn||v.minFilter===an||v.minFilter===ss||v.minFilter===ir||v.minFilter===Zn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(R,i.TEXTURE_WRAP_S,le[v.wrapS]),i.texParameteri(R,i.TEXTURE_WRAP_T,le[v.wrapT]),(R===i.TEXTURE_3D||R===i.TEXTURE_2D_ARRAY)&&i.texParameteri(R,i.TEXTURE_WRAP_R,le[v.wrapR]),i.texParameteri(R,i.TEXTURE_MAG_FILTER,pe[v.magFilter]),i.texParameteri(R,i.TEXTURE_MIN_FILTER,pe[v.minFilter]),v.compareFunction&&(i.texParameteri(R,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(R,i.TEXTURE_COMPARE_FUNC,Me[v.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(v.magFilter===en||v.minFilter!==ir&&v.minFilter!==Zn||v.type===gn&&e.has("OES_texture_float_linear")===!1)return;if(v.anisotropy>1||n.get(v).__currentAnisotropy){const k=e.get("EXT_texture_filter_anisotropic");i.texParameterf(R,k.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(v.anisotropy,r.getMaxAnisotropy())),n.get(v).__currentAnisotropy=v.anisotropy}}}function fe(R,v){let k=!1;R.__webglInit===void 0&&(R.__webglInit=!0,v.addEventListener("dispose",E));const ne=v.source;let re=d.get(ne);re===void 0&&(re={},d.set(ne,re));const te=j(v);if(te!==R.__cacheKey){re[te]===void 0&&(re[te]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,k=!0),re[te].usedTimes++;const we=re[R.__cacheKey];we!==void 0&&(re[R.__cacheKey].usedTimes--,we.usedTimes===0&&M(v)),R.__cacheKey=te,R.__webglTexture=re[te].texture}return k}function Xe(R,v,k){return Math.floor(Math.floor(R/k)/v)}function qe(R,v,k,ne){const te=R.updateRanges;if(te.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,v.width,v.height,k,ne,v.data);else{te.sort((P,O)=>P.start-O.start);let we=0;for(let P=1;P<te.length;P++){const O=te[we],J=te[P],ie=O.start+O.count,ae=Xe(J.start,v.width,4),Te=Xe(O.start,v.width,4);J.start<=ie+1&&ae===Te&&Xe(J.start+J.count-1,v.width,4)===ae?O.count=Math.max(O.count,J.start+J.count-O.start):(++we,te[we]=J)}te.length=we+1;const ue=i.getParameter(i.UNPACK_ROW_LENGTH),Ee=i.getParameter(i.UNPACK_SKIP_PIXELS),I=i.getParameter(i.UNPACK_SKIP_ROWS);i.pixelStorei(i.UNPACK_ROW_LENGTH,v.width);for(let P=0,O=te.length;P<O;P++){const J=te[P],ie=Math.floor(J.start/4),ae=Math.ceil(J.count/4),Te=ie%v.width,D=Math.floor(ie/v.width),H=ae,V=1;i.pixelStorei(i.UNPACK_SKIP_PIXELS,Te),i.pixelStorei(i.UNPACK_SKIP_ROWS,D),t.texSubImage2D(i.TEXTURE_2D,0,Te,D,H,V,k,ne,v.data)}R.clearUpdateRanges(),i.pixelStorei(i.UNPACK_ROW_LENGTH,ue),i.pixelStorei(i.UNPACK_SKIP_PIXELS,Ee),i.pixelStorei(i.UNPACK_SKIP_ROWS,I)}}function $(R,v,k){let ne=i.TEXTURE_2D;(v.isDataArrayTexture||v.isCompressedArrayTexture)&&(ne=i.TEXTURE_2D_ARRAY),v.isData3DTexture&&(ne=i.TEXTURE_3D);const re=fe(R,v),te=v.source;t.bindTexture(ne,R.__webglTexture,i.TEXTURE0+k);const we=n.get(te);if(te.version!==we.__version||re===!0){t.activeTexture(i.TEXTURE0+k);const ue=Ze.getPrimaries(Ze.workingColorSpace),Ee=v.colorSpace===Rn?null:Ze.getPrimaries(v.colorSpace),I=v.colorSpace===Rn||ue===Ee?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,v.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,v.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,I);let P=y(v.image,!1,r.maxTextureSize);P=ft(v,P);const O=s.convert(v.format,v.colorSpace),J=s.convert(v.type);let ie=b(v.internalFormat,O,J,v.colorSpace,v.isVideoTexture);Ne(ne,v);let ae;const Te=v.mipmaps,D=v.isVideoTexture!==!0,H=we.__version===void 0||re===!0,V=te.dataReady,ee=T(v,P);if(v.isDepthTexture)ie=_(v.format===ji,v.type),H&&(D?t.texStorage2D(i.TEXTURE_2D,1,ie,P.width,P.height):t.texImage2D(i.TEXTURE_2D,0,ie,P.width,P.height,0,O,J,null));else if(v.isDataTexture)if(Te.length>0){D&&H&&t.texStorage2D(i.TEXTURE_2D,ee,ie,Te[0].width,Te[0].height);for(let G=0,W=Te.length;G<W;G++)ae=Te[G],D?V&&t.texSubImage2D(i.TEXTURE_2D,G,0,0,ae.width,ae.height,O,J,ae.data):t.texImage2D(i.TEXTURE_2D,G,ie,ae.width,ae.height,0,O,J,ae.data);v.generateMipmaps=!1}else D?(H&&t.texStorage2D(i.TEXTURE_2D,ee,ie,P.width,P.height),V&&qe(v,P,O,J)):t.texImage2D(i.TEXTURE_2D,0,ie,P.width,P.height,0,O,J,P.data);else if(v.isCompressedTexture)if(v.isCompressedArrayTexture){D&&H&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ee,ie,Te[0].width,Te[0].height,P.depth);for(let G=0,W=Te.length;G<W;G++)if(ae=Te[G],v.format!==Jt)if(O!==null)if(D){if(V)if(v.layerUpdates.size>0){const he=tl(ae.width,ae.height,v.format,v.type);for(const ge of v.layerUpdates){const ke=ae.data.subarray(ge*he/ae.data.BYTES_PER_ELEMENT,(ge+1)*he/ae.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,G,0,0,ge,ae.width,ae.height,1,O,ke)}v.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,G,0,0,0,ae.width,ae.height,P.depth,O,ae.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,G,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?V&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,G,0,0,0,ae.width,ae.height,P.depth,O,J,ae.data):t.texImage3D(i.TEXTURE_2D_ARRAY,G,ie,ae.width,ae.height,P.depth,0,O,J,ae.data)}else{D&&H&&t.texStorage2D(i.TEXTURE_2D,ee,ie,Te[0].width,Te[0].height);for(let G=0,W=Te.length;G<W;G++)ae=Te[G],v.format!==Jt?O!==null?D?V&&t.compressedTexSubImage2D(i.TEXTURE_2D,G,0,0,ae.width,ae.height,O,ae.data):t.compressedTexImage2D(i.TEXTURE_2D,G,ie,ae.width,ae.height,0,ae.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):D?V&&t.texSubImage2D(i.TEXTURE_2D,G,0,0,ae.width,ae.height,O,J,ae.data):t.texImage2D(i.TEXTURE_2D,G,ie,ae.width,ae.height,0,O,J,ae.data)}else if(v.isDataArrayTexture)if(D){if(H&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ee,ie,P.width,P.height,P.depth),V)if(v.layerUpdates.size>0){const G=tl(P.width,P.height,v.format,v.type);for(const W of v.layerUpdates){const he=P.data.subarray(W*G/P.data.BYTES_PER_ELEMENT,(W+1)*G/P.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,W,P.width,P.height,1,O,J,he)}v.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,P.width,P.height,P.depth,O,J,P.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,ie,P.width,P.height,P.depth,0,O,J,P.data);else if(v.isData3DTexture)D?(H&&t.texStorage3D(i.TEXTURE_3D,ee,ie,P.width,P.height,P.depth),V&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,P.width,P.height,P.depth,O,J,P.data)):t.texImage3D(i.TEXTURE_3D,0,ie,P.width,P.height,P.depth,0,O,J,P.data);else if(v.isFramebufferTexture){if(H)if(D)t.texStorage2D(i.TEXTURE_2D,ee,ie,P.width,P.height);else{let G=P.width,W=P.height;for(let he=0;he<ee;he++)t.texImage2D(i.TEXTURE_2D,he,ie,G,W,0,O,J,null),G>>=1,W>>=1}}else if(Te.length>0){if(D&&H){const G=rt(Te[0]);t.texStorage2D(i.TEXTURE_2D,ee,ie,G.width,G.height)}for(let G=0,W=Te.length;G<W;G++)ae=Te[G],D?V&&t.texSubImage2D(i.TEXTURE_2D,G,0,0,O,J,ae):t.texImage2D(i.TEXTURE_2D,G,ie,O,J,ae);v.generateMipmaps=!1}else if(D){if(H){const G=rt(P);t.texStorage2D(i.TEXTURE_2D,ee,ie,G.width,G.height)}V&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,O,J,P)}else t.texImage2D(i.TEXTURE_2D,0,ie,O,J,P);p(v)&&h(ne),we.__version=te.version,v.onUpdate&&v.onUpdate(v)}R.__version=v.version}function oe(R,v,k){if(v.image.length!==6)return;const ne=fe(R,v),re=v.source;t.bindTexture(i.TEXTURE_CUBE_MAP,R.__webglTexture,i.TEXTURE0+k);const te=n.get(re);if(re.version!==te.__version||ne===!0){t.activeTexture(i.TEXTURE0+k);const we=Ze.getPrimaries(Ze.workingColorSpace),ue=v.colorSpace===Rn?null:Ze.getPrimaries(v.colorSpace),Ee=v.colorSpace===Rn||we===ue?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,v.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,v.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ee);const I=v.isCompressedTexture||v.image[0].isCompressedTexture,P=v.image[0]&&v.image[0].isDataTexture,O=[];for(let W=0;W<6;W++)!I&&!P?O[W]=y(v.image[W],!0,r.maxCubemapSize):O[W]=P?v.image[W].image:v.image[W],O[W]=ft(v,O[W]);const J=O[0],ie=s.convert(v.format,v.colorSpace),ae=s.convert(v.type),Te=b(v.internalFormat,ie,ae,v.colorSpace),D=v.isVideoTexture!==!0,H=te.__version===void 0||ne===!0,V=re.dataReady;let ee=T(v,J);Ne(i.TEXTURE_CUBE_MAP,v);let G;if(I){D&&H&&t.texStorage2D(i.TEXTURE_CUBE_MAP,ee,Te,J.width,J.height);for(let W=0;W<6;W++){G=O[W].mipmaps;for(let he=0;he<G.length;he++){const ge=G[he];v.format!==Jt?ie!==null?D?V&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+W,he,0,0,ge.width,ge.height,ie,ge.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+W,he,Te,ge.width,ge.height,0,ge.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):D?V&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+W,he,0,0,ge.width,ge.height,ie,ae,ge.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+W,he,Te,ge.width,ge.height,0,ie,ae,ge.data)}}}else{if(G=v.mipmaps,D&&H){G.length>0&&ee++;const W=rt(O[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,ee,Te,W.width,W.height)}for(let W=0;W<6;W++)if(P){D?V&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,0,0,O[W].width,O[W].height,ie,ae,O[W].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,Te,O[W].width,O[W].height,0,ie,ae,O[W].data);for(let he=0;he<G.length;he++){const ke=G[he].image[W].image;D?V&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+W,he+1,0,0,ke.width,ke.height,ie,ae,ke.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+W,he+1,Te,ke.width,ke.height,0,ie,ae,ke.data)}}else{D?V&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,0,0,ie,ae,O[W]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,Te,ie,ae,O[W]);for(let he=0;he<G.length;he++){const ge=G[he];D?V&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+W,he+1,0,0,ie,ae,ge.image[W]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+W,he+1,Te,ie,ae,ge.image[W])}}}p(v)&&h(i.TEXTURE_CUBE_MAP),te.__version=re.version,v.onUpdate&&v.onUpdate(v)}R.__version=v.version}function xe(R,v,k,ne,re,te){const we=s.convert(k.format,k.colorSpace),ue=s.convert(k.type),Ee=b(k.internalFormat,we,ue,k.colorSpace),I=n.get(v),P=n.get(k);if(P.__renderTarget=v,!I.__hasExternalTextures){const O=Math.max(1,v.width>>te),J=Math.max(1,v.height>>te);re===i.TEXTURE_3D||re===i.TEXTURE_2D_ARRAY?t.texImage3D(re,te,Ee,O,J,v.depth,0,we,ue,null):t.texImage2D(re,te,Ee,O,J,0,we,ue,null)}t.bindFramebuffer(i.FRAMEBUFFER,R),Se(v)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,ne,re,P.__webglTexture,0,tt(v)):(re===i.TEXTURE_2D||re>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&re<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,ne,re,P.__webglTexture,te),t.bindFramebuffer(i.FRAMEBUFFER,null)}function Le(R,v,k){if(i.bindRenderbuffer(i.RENDERBUFFER,R),v.depthBuffer){const ne=v.depthTexture,re=ne&&ne.isDepthTexture?ne.type:null,te=_(v.stencilBuffer,re),we=v.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ue=tt(v);Se(v)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ue,te,v.width,v.height):k?i.renderbufferStorageMultisample(i.RENDERBUFFER,ue,te,v.width,v.height):i.renderbufferStorage(i.RENDERBUFFER,te,v.width,v.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,we,i.RENDERBUFFER,R)}else{const ne=v.textures;for(let re=0;re<ne.length;re++){const te=ne[re],we=s.convert(te.format,te.colorSpace),ue=s.convert(te.type),Ee=b(te.internalFormat,we,ue,te.colorSpace),I=tt(v);k&&Se(v)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,I,Ee,v.width,v.height):Se(v)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,I,Ee,v.width,v.height):i.renderbufferStorage(i.RENDERBUFFER,Ee,v.width,v.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Ae(R,v){if(v&&v.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(i.FRAMEBUFFER,R),!(v.depthTexture&&v.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const ne=n.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),Q(v.depthTexture,0);const re=ne.__webglTexture,te=tt(v);if(v.depthTexture.format===qi)Se(v)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,re,0,te):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,re,0);else if(v.depthTexture.format===ji)Se(v)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,re,0,te):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,re,0);else throw new Error("Unknown depthTexture format")}function Oe(R){const v=n.get(R),k=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(k)throw new Error("target.depthTexture not supported in Cube render targets");const ne=R.texture.mipmaps;ne&&ne.length>0?Ae(v.__webglFramebuffer[0],R):Ae(v.__webglFramebuffer,R)}else if(k){v.__webglDepthbuffer=[];for(let ne=0;ne<6;ne++)if(t.bindFramebuffer(i.FRAMEBUFFER,v.__webglFramebuffer[ne]),v.__webglDepthbuffer[ne]===void 0)v.__webglDepthbuffer[ne]=i.createRenderbuffer(),Le(v.__webglDepthbuffer[ne],R,!1);else{const re=R.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,te=v.__webglDepthbuffer[ne];i.bindRenderbuffer(i.RENDERBUFFER,te),i.framebufferRenderbuffer(i.FRAMEBUFFER,re,i.RENDERBUFFER,te)}}else{const ne=R.texture.mipmaps;if(ne&&ne.length>0?t.bindFramebuffer(i.FRAMEBUFFER,v.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,v.__webglFramebuffer),v.__webglDepthbuffer===void 0)v.__webglDepthbuffer=i.createRenderbuffer(),Le(v.__webglDepthbuffer,R,!1);else{const re=R.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,te=v.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,te),i.framebufferRenderbuffer(i.FRAMEBUFFER,re,i.RENDERBUFFER,te)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function _t(R,v,k){const ne=n.get(R);v!==void 0&&xe(ne.__webglFramebuffer,R,R.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),k!==void 0&&Oe(R)}function L(R){const v=R.texture,k=n.get(R),ne=n.get(v);R.addEventListener("dispose",A);const re=R.textures,te=R.isWebGLCubeRenderTarget===!0,we=re.length>1;if(we||(ne.__webglTexture===void 0&&(ne.__webglTexture=i.createTexture()),ne.__version=v.version,o.memory.textures++),te){k.__webglFramebuffer=[];for(let ue=0;ue<6;ue++)if(v.mipmaps&&v.mipmaps.length>0){k.__webglFramebuffer[ue]=[];for(let Ee=0;Ee<v.mipmaps.length;Ee++)k.__webglFramebuffer[ue][Ee]=i.createFramebuffer()}else k.__webglFramebuffer[ue]=i.createFramebuffer()}else{if(v.mipmaps&&v.mipmaps.length>0){k.__webglFramebuffer=[];for(let ue=0;ue<v.mipmaps.length;ue++)k.__webglFramebuffer[ue]=i.createFramebuffer()}else k.__webglFramebuffer=i.createFramebuffer();if(we)for(let ue=0,Ee=re.length;ue<Ee;ue++){const I=n.get(re[ue]);I.__webglTexture===void 0&&(I.__webglTexture=i.createTexture(),o.memory.textures++)}if(R.samples>0&&Se(R)===!1){k.__webglMultisampledFramebuffer=i.createFramebuffer(),k.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,k.__webglMultisampledFramebuffer);for(let ue=0;ue<re.length;ue++){const Ee=re[ue];k.__webglColorRenderbuffer[ue]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,k.__webglColorRenderbuffer[ue]);const I=s.convert(Ee.format,Ee.colorSpace),P=s.convert(Ee.type),O=b(Ee.internalFormat,I,P,Ee.colorSpace,R.isXRRenderTarget===!0),J=tt(R);i.renderbufferStorageMultisample(i.RENDERBUFFER,J,O,R.width,R.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ue,i.RENDERBUFFER,k.__webglColorRenderbuffer[ue])}i.bindRenderbuffer(i.RENDERBUFFER,null),R.depthBuffer&&(k.__webglDepthRenderbuffer=i.createRenderbuffer(),Le(k.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(te){t.bindTexture(i.TEXTURE_CUBE_MAP,ne.__webglTexture),Ne(i.TEXTURE_CUBE_MAP,v);for(let ue=0;ue<6;ue++)if(v.mipmaps&&v.mipmaps.length>0)for(let Ee=0;Ee<v.mipmaps.length;Ee++)xe(k.__webglFramebuffer[ue][Ee],R,v,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+ue,Ee);else xe(k.__webglFramebuffer[ue],R,v,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+ue,0);p(v)&&h(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(we){for(let ue=0,Ee=re.length;ue<Ee;ue++){const I=re[ue],P=n.get(I);let O=i.TEXTURE_2D;(R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(O=R.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(O,P.__webglTexture),Ne(O,I),xe(k.__webglFramebuffer,R,I,i.COLOR_ATTACHMENT0+ue,O,0),p(I)&&h(O)}t.unbindTexture()}else{let ue=i.TEXTURE_2D;if((R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(ue=R.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(ue,ne.__webglTexture),Ne(ue,v),v.mipmaps&&v.mipmaps.length>0)for(let Ee=0;Ee<v.mipmaps.length;Ee++)xe(k.__webglFramebuffer[Ee],R,v,i.COLOR_ATTACHMENT0,ue,Ee);else xe(k.__webglFramebuffer,R,v,i.COLOR_ATTACHMENT0,ue,0);p(v)&&h(ue),t.unbindTexture()}R.depthBuffer&&Oe(R)}function et(R){const v=R.textures;for(let k=0,ne=v.length;k<ne;k++){const re=v[k];if(p(re)){const te=w(R),we=n.get(re).__webglTexture;t.bindTexture(te,we),h(te),t.unbindTexture()}}}const Fe=[],Ce=[];function ye(R){if(R.samples>0){if(Se(R)===!1){const v=R.textures,k=R.width,ne=R.height;let re=i.COLOR_BUFFER_BIT;const te=R.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,we=n.get(R),ue=v.length>1;if(ue)for(let I=0;I<v.length;I++)t.bindFramebuffer(i.FRAMEBUFFER,we.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+I,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,we.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+I,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,we.__webglMultisampledFramebuffer);const Ee=R.texture.mipmaps;Ee&&Ee.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,we.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,we.__webglFramebuffer);for(let I=0;I<v.length;I++){if(R.resolveDepthBuffer&&(R.depthBuffer&&(re|=i.DEPTH_BUFFER_BIT),R.stencilBuffer&&R.resolveStencilBuffer&&(re|=i.STENCIL_BUFFER_BIT)),ue){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,we.__webglColorRenderbuffer[I]);const P=n.get(v[I]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,P,0)}i.blitFramebuffer(0,0,k,ne,0,0,k,ne,re,i.NEAREST),c===!0&&(Fe.length=0,Ce.length=0,Fe.push(i.COLOR_ATTACHMENT0+I),R.depthBuffer&&R.resolveDepthBuffer===!1&&(Fe.push(te),Ce.push(te),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,Ce)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,Fe))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),ue)for(let I=0;I<v.length;I++){t.bindFramebuffer(i.FRAMEBUFFER,we.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+I,i.RENDERBUFFER,we.__webglColorRenderbuffer[I]);const P=n.get(v[I]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,we.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+I,i.TEXTURE_2D,P,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,we.__webglMultisampledFramebuffer)}else if(R.depthBuffer&&R.resolveDepthBuffer===!1&&c){const v=R.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[v])}}}function tt(R){return Math.min(r.maxSamples,R.samples)}function Se(R){const v=n.get(R);return R.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&v.__useRenderToTexture!==!1}function Be(R){const v=o.render.frame;u.get(R)!==v&&(u.set(R,v),R.update())}function ft(R,v){const k=R.colorSpace,ne=R.format,re=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||k!==bi&&k!==Rn&&(Ze.getTransfer(k)===Qe?(ne!==Jt||re!==hn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",k)),v}function rt(R){return typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement?(l.width=R.naturalWidth||R.width,l.height=R.naturalHeight||R.height):typeof VideoFrame<"u"&&R instanceof VideoFrame?(l.width=R.displayWidth,l.height=R.displayHeight):(l.width=R.width,l.height=R.height),l}this.allocateTextureUnit=q,this.resetTextureUnits=z,this.setTexture2D=Q,this.setTexture2DArray=K,this.setTexture3D=se,this.setTextureCube=Z,this.rebindTextures=_t,this.setupRenderTarget=L,this.updateRenderTargetMipmap=et,this.updateMultisampleRenderTarget=ye,this.setupDepthRenderbuffer=Oe,this.setupFrameBufferTexture=xe,this.useMultisampledRTT=Se}function Bm(i,e){function t(n,r=Rn){let s;const o=Ze.getTransfer(r);if(n===hn)return i.UNSIGNED_BYTE;if(n===qo)return i.UNSIGNED_SHORT_4_4_4_4;if(n===jo)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Yl)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===ql)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===Wl)return i.BYTE;if(n===Xl)return i.SHORT;if(n===Xi)return i.UNSIGNED_SHORT;if(n===Yo)return i.INT;if(n===$n)return i.UNSIGNED_INT;if(n===gn)return i.FLOAT;if(n===Ki)return i.HALF_FLOAT;if(n===jl)return i.ALPHA;if(n===Zl)return i.RGB;if(n===Jt)return i.RGBA;if(n===qi)return i.DEPTH_COMPONENT;if(n===ji)return i.DEPTH_STENCIL;if(n===$l)return i.RED;if(n===Zo)return i.RED_INTEGER;if(n===Kl)return i.RG;if(n===$o)return i.RG_INTEGER;if(n===Ko)return i.RGBA_INTEGER;if(n===Fr||n===Br||n===zr||n===Hr)if(o===Qe)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===Fr)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Br)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===zr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Hr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===Fr)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Br)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===zr)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Hr)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===eo||n===to||n===no||n===io)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===eo)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===to)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===no)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===io)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===ro||n===so||n===oo)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===ro||n===so)return o===Qe?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===oo)return o===Qe?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===ao||n===lo||n===co||n===ho||n===uo||n===fo||n===po||n===mo||n===_o||n===go||n===vo||n===xo||n===Mo||n===yo)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===ao)return o===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===lo)return o===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===co)return o===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===ho)return o===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===uo)return o===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===fo)return o===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===po)return o===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===mo)return o===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===_o)return o===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===go)return o===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===vo)return o===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===xo)return o===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Mo)return o===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===yo)return o===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===So||n===Eo||n===To)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===So)return o===Qe?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Eo)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===To)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===bo||n===wo||n===Ao||n===Ro)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===bo)return s.COMPRESSED_RED_RGTC1_EXT;if(n===wo)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Ao)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Ro)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Yi?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const zm=`
3830
3830
  void main() {
3831
3831
 
3832
3832
  gl_Position = vec4( position, 1.0 );
3833
3833
 
3834
- }`,rm=`
3834
+ }`,Hm=`
3835
3835
  uniform sampler2DArray depthColor;
3836
3836
  uniform float depthWidth;
3837
3837
  uniform float depthHeight;
@@ -3850,7 +3850,7 @@ void main() {
3850
3850
 
3851
3851
  }
3852
3852
 
3853
- }`;class sm{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new Al(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new Sn({vertexShader:im,fragmentShader:rm,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Kt(new Lr(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class am extends kn{constructor(e,t){super();const n=this;let r=null,s=1,a=null,o="local-floor",c=1,l=null,u=null,f=null,d=null,m=null,v=null;const S=typeof XRWebGLBinding<"u",p=new sm,h={},L=t.getContextAttributes();let C=null,g=null;const E=[],T=[],A=new Fe;let I=null;const y=new Ot;y.viewport=new ot;const M=new Ot;M.viewport=new ot;const U=[y,M],W=new Eh;let Z=null,te=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let se=E[Y];return se===void 0&&(se=new ss,E[Y]=se),se.getTargetRaySpace()},this.getControllerGrip=function(Y){let se=E[Y];return se===void 0&&(se=new ss,E[Y]=se),se.getGripSpace()},this.getHand=function(Y){let se=E[Y];return se===void 0&&(se=new ss,E[Y]=se),se.getHandSpace()};function ne(Y){const se=T.indexOf(Y.inputSource);if(se===-1)return;const ve=E[se];ve!==void 0&&(ve.update(Y.inputSource,Y.frame,l||a),ve.dispatchEvent({type:Y.type,data:Y.inputSource}))}function ee(){r.removeEventListener("select",ne),r.removeEventListener("selectstart",ne),r.removeEventListener("selectend",ne),r.removeEventListener("squeeze",ne),r.removeEventListener("squeezestart",ne),r.removeEventListener("squeezeend",ne),r.removeEventListener("end",ee),r.removeEventListener("inputsourceschange",le);for(let Y=0;Y<E.length;Y++){const se=T[Y];se!==null&&(T[Y]=null,E[Y].disconnect(se))}Z=null,te=null,p.reset();for(const Y in h)delete h[Y];e.setRenderTarget(C),m=null,d=null,f=null,r=null,g=null,Xe.stop(),n.isPresenting=!1,e.setPixelRatio(I),e.setSize(A.width,A.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){s=Y,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){o=Y,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(Y){l=Y},this.getBaseLayer=function(){return d!==null?d:m},this.getBinding=function(){return f===null&&S&&(f=new XRWebGLBinding(r,t)),f},this.getFrame=function(){return v},this.getSession=function(){return r},this.setSession=async function(Y){if(r=Y,r!==null){if(C=e.getRenderTarget(),r.addEventListener("select",ne),r.addEventListener("selectstart",ne),r.addEventListener("selectend",ne),r.addEventListener("squeeze",ne),r.addEventListener("squeezestart",ne),r.addEventListener("squeezeend",ne),r.addEventListener("end",ee),r.addEventListener("inputsourceschange",le),L.xrCompatible!==!0&&await t.makeXRCompatible(),I=e.getPixelRatio(),e.getSize(A),S&&"createProjectionLayer"in XRWebGLBinding.prototype){let ve=null,De=null,Ae=null;L.depth&&(Ae=L.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ve=L.stencil?Pi:Ci,De=L.stencil?Ri:Bn);const Ie={colorFormat:t.RGBA8,depthFormat:Ae,scaleFactor:s};f=this.getBinding(),d=f.createProjectionLayer(Ie),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),g=new Hn(d.textureWidth,d.textureHeight,{format:Wt,type:Zt,depthTexture:new bl(d.textureWidth,d.textureHeight,De,void 0,void 0,void 0,void 0,void 0,void 0,ve),stencilBuffer:L.stencil,colorSpace:e.outputColorSpace,samples:L.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const ve={antialias:L.antialias,alpha:!0,depth:L.depth,stencil:L.stencil,framebufferScaleFactor:s};m=new XRWebGLLayer(r,t,ve),r.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),g=new Hn(m.framebufferWidth,m.framebufferHeight,{format:Wt,type:Zt,colorSpace:e.outputColorSpace,stencilBuffer:L.stencil,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}g.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await r.requestReferenceSpace(o),Xe.setContext(r),Xe.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return p.getDepthTexture()};function le(Y){for(let se=0;se<Y.removed.length;se++){const ve=Y.removed[se],De=T.indexOf(ve);De>=0&&(T[De]=null,E[De].disconnect(ve))}for(let se=0;se<Y.added.length;se++){const ve=Y.added[se];let De=T.indexOf(ve);if(De===-1){for(let Ie=0;Ie<E.length;Ie++)if(Ie>=T.length){T.push(ve),De=Ie;break}else if(T[Ie]===null){T[Ie]=ve,De=Ie;break}if(De===-1)break}const Ae=E[De];Ae&&Ae.connect(ve)}}const j=new B,ue=new B;function me(Y,se,ve){j.setFromMatrixPosition(se.matrixWorld),ue.setFromMatrixPosition(ve.matrixWorld);const De=j.distanceTo(ue),Ae=se.projectionMatrix.elements,Ie=ve.projectionMatrix.elements,ht=Ae[14]/(Ae[10]-1),P=Ae[14]/(Ae[10]+1),Je=(Ae[9]+1)/Ae[5],Ue=(Ae[9]-1)/Ae[5],Re=(Ae[8]-1)/Ae[0],xe=(Ie[8]+1)/Ie[0],Qe=ht*Re,Me=ht*xe,Ne=De/(-Re+xe),lt=Ne*-Re;if(se.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(lt),Y.translateZ(Ne),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),Ae[10]===-1)Y.projectionMatrix.copy(se.projectionMatrix),Y.projectionMatrixInverse.copy(se.projectionMatrixInverse);else{const tt=ht+Ne,b=P+Ne,_=Qe-lt,H=Me+(De-lt),Q=Je*P/b*tt,re=Ue*P/b*tt;Y.projectionMatrix.makePerspective(_,H,Q,re,tt,b),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert()}}function be(Y,se){se===null?Y.matrixWorld.copy(Y.matrix):Y.matrixWorld.multiplyMatrices(se.matrixWorld,Y.matrix),Y.matrixWorldInverse.copy(Y.matrixWorld).invert()}this.updateCamera=function(Y){if(r===null)return;let se=Y.near,ve=Y.far;p.texture!==null&&(p.depthNear>0&&(se=p.depthNear),p.depthFar>0&&(ve=p.depthFar)),W.near=M.near=y.near=se,W.far=M.far=y.far=ve,(Z!==W.near||te!==W.far)&&(r.updateRenderState({depthNear:W.near,depthFar:W.far}),Z=W.near,te=W.far),W.layers.mask=Y.layers.mask|6,y.layers.mask=W.layers.mask&3,M.layers.mask=W.layers.mask&5;const De=Y.parent,Ae=W.cameras;be(W,De);for(let Ie=0;Ie<Ae.length;Ie++)be(Ae[Ie],De);Ae.length===2?me(W,y,M):W.projectionMatrix.copy(y.projectionMatrix),Be(Y,W,De)};function Be(Y,se,ve){ve===null?Y.matrix.copy(se.matrixWorld):(Y.matrix.copy(ve.matrixWorld),Y.matrix.invert(),Y.matrix.multiply(se.matrixWorld)),Y.matrix.decompose(Y.position,Y.quaternion,Y.scale),Y.updateMatrixWorld(!0),Y.projectionMatrix.copy(se.projectionMatrix),Y.projectionMatrixInverse.copy(se.projectionMatrixInverse),Y.isPerspectiveCamera&&(Y.fov=sa*2*Math.atan(1/Y.projectionMatrix.elements[5]),Y.zoom=1)}this.getCamera=function(){return W},this.getFoveation=function(){if(!(d===null&&m===null))return c},this.setFoveation=function(Y){c=Y,d!==null&&(d.fixedFoveation=Y),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=Y)},this.hasDepthSensing=function(){return p.texture!==null},this.getDepthSensingMesh=function(){return p.getMesh(W)},this.getCameraTexture=function(Y){return h[Y]};let de=null;function je(Y,se){if(u=se.getViewerPose(l||a),v=se,u!==null){const ve=u.views;m!==null&&(e.setRenderTargetFramebuffer(g,m.framebuffer),e.setRenderTarget(g));let De=!1;ve.length!==W.cameras.length&&(W.cameras.length=0,De=!0);for(let P=0;P<ve.length;P++){const Je=ve[P];let Ue=null;if(m!==null)Ue=m.getViewport(Je);else{const xe=f.getViewSubImage(d,Je);Ue=xe.viewport,P===0&&(e.setRenderTargetTextures(g,xe.colorTexture,xe.depthStencilTexture),e.setRenderTarget(g))}let Re=U[P];Re===void 0&&(Re=new Ot,Re.layers.enable(P),Re.viewport=new ot,U[P]=Re),Re.matrix.fromArray(Je.transform.matrix),Re.matrix.decompose(Re.position,Re.quaternion,Re.scale),Re.projectionMatrix.fromArray(Je.projectionMatrix),Re.projectionMatrixInverse.copy(Re.projectionMatrix).invert(),Re.viewport.set(Ue.x,Ue.y,Ue.width,Ue.height),P===0&&(W.matrix.copy(Re.matrix),W.matrix.decompose(W.position,W.quaternion,W.scale)),De===!0&&W.cameras.push(Re)}const Ae=r.enabledFeatures;if(Ae&&Ae.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&S){f=n.getBinding();const P=f.getDepthInformation(ve[0]);P&&P.isValid&&P.texture&&p.init(P,r.renderState)}if(Ae&&Ae.includes("camera-access")&&S){e.state.unbindTexture(),f=n.getBinding();for(let P=0;P<ve.length;P++){const Je=ve[P].camera;if(Je){let Ue=h[Je];Ue||(Ue=new Al,h[Je]=Ue);const Re=f.getCameraImage(Je);Ue.sourceTexture=Re}}}}for(let ve=0;ve<E.length;ve++){const De=T[ve],Ae=E[ve];De!==null&&Ae!==void 0&&Ae.update(De,se,l||a)}de&&de(Y,se),se.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:se}),v=null}const Xe=new Rl;Xe.setAnimationLoop(je),this.setAnimationLoop=function(Y){de=Y},this.dispose=function(){}}}const Pn=new Jt,om=new st;function lm(i,e){function t(p,h){p.matrixAutoUpdate===!0&&p.updateMatrix(),h.value.copy(p.matrix)}function n(p,h){h.color.getRGB(p.fogColor.value,Sl(i)),h.isFog?(p.fogNear.value=h.near,p.fogFar.value=h.far):h.isFogExp2&&(p.fogDensity.value=h.density)}function r(p,h,L,C,g){h.isMeshBasicMaterial||h.isMeshLambertMaterial?s(p,h):h.isMeshToonMaterial?(s(p,h),f(p,h)):h.isMeshPhongMaterial?(s(p,h),u(p,h)):h.isMeshStandardMaterial?(s(p,h),d(p,h),h.isMeshPhysicalMaterial&&m(p,h,g)):h.isMeshMatcapMaterial?(s(p,h),v(p,h)):h.isMeshDepthMaterial?s(p,h):h.isMeshDistanceMaterial?(s(p,h),S(p,h)):h.isMeshNormalMaterial?s(p,h):h.isLineBasicMaterial?(a(p,h),h.isLineDashedMaterial&&o(p,h)):h.isPointsMaterial?c(p,h,L,C):h.isSpriteMaterial?l(p,h):h.isShadowMaterial?(p.color.value.copy(h.color),p.opacity.value=h.opacity):h.isShaderMaterial&&(h.uniformsNeedUpdate=!1)}function s(p,h){p.opacity.value=h.opacity,h.color&&p.diffuse.value.copy(h.color),h.emissive&&p.emissive.value.copy(h.emissive).multiplyScalar(h.emissiveIntensity),h.map&&(p.map.value=h.map,t(h.map,p.mapTransform)),h.alphaMap&&(p.alphaMap.value=h.alphaMap,t(h.alphaMap,p.alphaMapTransform)),h.bumpMap&&(p.bumpMap.value=h.bumpMap,t(h.bumpMap,p.bumpMapTransform),p.bumpScale.value=h.bumpScale,h.side===bt&&(p.bumpScale.value*=-1)),h.normalMap&&(p.normalMap.value=h.normalMap,t(h.normalMap,p.normalMapTransform),p.normalScale.value.copy(h.normalScale),h.side===bt&&p.normalScale.value.negate()),h.displacementMap&&(p.displacementMap.value=h.displacementMap,t(h.displacementMap,p.displacementMapTransform),p.displacementScale.value=h.displacementScale,p.displacementBias.value=h.displacementBias),h.emissiveMap&&(p.emissiveMap.value=h.emissiveMap,t(h.emissiveMap,p.emissiveMapTransform)),h.specularMap&&(p.specularMap.value=h.specularMap,t(h.specularMap,p.specularMapTransform)),h.alphaTest>0&&(p.alphaTest.value=h.alphaTest);const L=e.get(h),C=L.envMap,g=L.envMapRotation;C&&(p.envMap.value=C,Pn.copy(g),Pn.x*=-1,Pn.y*=-1,Pn.z*=-1,C.isCubeTexture&&C.isRenderTargetTexture===!1&&(Pn.y*=-1,Pn.z*=-1),p.envMapRotation.value.setFromMatrix4(om.makeRotationFromEuler(Pn)),p.flipEnvMap.value=C.isCubeTexture&&C.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=h.reflectivity,p.ior.value=h.ior,p.refractionRatio.value=h.refractionRatio),h.lightMap&&(p.lightMap.value=h.lightMap,p.lightMapIntensity.value=h.lightMapIntensity,t(h.lightMap,p.lightMapTransform)),h.aoMap&&(p.aoMap.value=h.aoMap,p.aoMapIntensity.value=h.aoMapIntensity,t(h.aoMap,p.aoMapTransform))}function a(p,h){p.diffuse.value.copy(h.color),p.opacity.value=h.opacity,h.map&&(p.map.value=h.map,t(h.map,p.mapTransform))}function o(p,h){p.dashSize.value=h.dashSize,p.totalSize.value=h.dashSize+h.gapSize,p.scale.value=h.scale}function c(p,h,L,C){p.diffuse.value.copy(h.color),p.opacity.value=h.opacity,p.size.value=h.size*L,p.scale.value=C*.5,h.map&&(p.map.value=h.map,t(h.map,p.uvTransform)),h.alphaMap&&(p.alphaMap.value=h.alphaMap,t(h.alphaMap,p.alphaMapTransform)),h.alphaTest>0&&(p.alphaTest.value=h.alphaTest)}function l(p,h){p.diffuse.value.copy(h.color),p.opacity.value=h.opacity,p.rotation.value=h.rotation,h.map&&(p.map.value=h.map,t(h.map,p.mapTransform)),h.alphaMap&&(p.alphaMap.value=h.alphaMap,t(h.alphaMap,p.alphaMapTransform)),h.alphaTest>0&&(p.alphaTest.value=h.alphaTest)}function u(p,h){p.specular.value.copy(h.specular),p.shininess.value=Math.max(h.shininess,1e-4)}function f(p,h){h.gradientMap&&(p.gradientMap.value=h.gradientMap)}function d(p,h){p.metalness.value=h.metalness,h.metalnessMap&&(p.metalnessMap.value=h.metalnessMap,t(h.metalnessMap,p.metalnessMapTransform)),p.roughness.value=h.roughness,h.roughnessMap&&(p.roughnessMap.value=h.roughnessMap,t(h.roughnessMap,p.roughnessMapTransform)),h.envMap&&(p.envMapIntensity.value=h.envMapIntensity)}function m(p,h,L){p.ior.value=h.ior,h.sheen>0&&(p.sheenColor.value.copy(h.sheenColor).multiplyScalar(h.sheen),p.sheenRoughness.value=h.sheenRoughness,h.sheenColorMap&&(p.sheenColorMap.value=h.sheenColorMap,t(h.sheenColorMap,p.sheenColorMapTransform)),h.sheenRoughnessMap&&(p.sheenRoughnessMap.value=h.sheenRoughnessMap,t(h.sheenRoughnessMap,p.sheenRoughnessMapTransform))),h.clearcoat>0&&(p.clearcoat.value=h.clearcoat,p.clearcoatRoughness.value=h.clearcoatRoughness,h.clearcoatMap&&(p.clearcoatMap.value=h.clearcoatMap,t(h.clearcoatMap,p.clearcoatMapTransform)),h.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=h.clearcoatRoughnessMap,t(h.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),h.clearcoatNormalMap&&(p.clearcoatNormalMap.value=h.clearcoatNormalMap,t(h.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(h.clearcoatNormalScale),h.side===bt&&p.clearcoatNormalScale.value.negate())),h.dispersion>0&&(p.dispersion.value=h.dispersion),h.iridescence>0&&(p.iridescence.value=h.iridescence,p.iridescenceIOR.value=h.iridescenceIOR,p.iridescenceThicknessMinimum.value=h.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=h.iridescenceThicknessRange[1],h.iridescenceMap&&(p.iridescenceMap.value=h.iridescenceMap,t(h.iridescenceMap,p.iridescenceMapTransform)),h.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=h.iridescenceThicknessMap,t(h.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),h.transmission>0&&(p.transmission.value=h.transmission,p.transmissionSamplerMap.value=L.texture,p.transmissionSamplerSize.value.set(L.width,L.height),h.transmissionMap&&(p.transmissionMap.value=h.transmissionMap,t(h.transmissionMap,p.transmissionMapTransform)),p.thickness.value=h.thickness,h.thicknessMap&&(p.thicknessMap.value=h.thicknessMap,t(h.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=h.attenuationDistance,p.attenuationColor.value.copy(h.attenuationColor)),h.anisotropy>0&&(p.anisotropyVector.value.set(h.anisotropy*Math.cos(h.anisotropyRotation),h.anisotropy*Math.sin(h.anisotropyRotation)),h.anisotropyMap&&(p.anisotropyMap.value=h.anisotropyMap,t(h.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=h.specularIntensity,p.specularColor.value.copy(h.specularColor),h.specularColorMap&&(p.specularColorMap.value=h.specularColorMap,t(h.specularColorMap,p.specularColorMapTransform)),h.specularIntensityMap&&(p.specularIntensityMap.value=h.specularIntensityMap,t(h.specularIntensityMap,p.specularIntensityMapTransform))}function v(p,h){h.matcap&&(p.matcap.value=h.matcap)}function S(p,h){const L=e.get(h).light;p.referencePosition.value.setFromMatrixPosition(L.matrixWorld),p.nearDistance.value=L.shadow.camera.near,p.farDistance.value=L.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function cm(i,e,t,n){let r={},s={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function c(L,C){const g=C.program;n.uniformBlockBinding(L,g)}function l(L,C){let g=r[L.id];g===void 0&&(v(L),g=u(L),r[L.id]=g,L.addEventListener("dispose",p));const E=C.program;n.updateUBOMapping(L,E);const T=e.render.frame;s[L.id]!==T&&(d(L),s[L.id]=T)}function u(L){const C=f();L.__bindingPointIndex=C;const g=i.createBuffer(),E=L.__size,T=L.usage;return i.bindBuffer(i.UNIFORM_BUFFER,g),i.bufferData(i.UNIFORM_BUFFER,E,T),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,C,g),g}function f(){for(let L=0;L<o;L++)if(a.indexOf(L)===-1)return a.push(L),L;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(L){const C=r[L.id],g=L.uniforms,E=L.__cache;i.bindBuffer(i.UNIFORM_BUFFER,C);for(let T=0,A=g.length;T<A;T++){const I=Array.isArray(g[T])?g[T]:[g[T]];for(let y=0,M=I.length;y<M;y++){const U=I[y];if(m(U,T,y,E)===!0){const W=U.__offset,Z=Array.isArray(U.value)?U.value:[U.value];let te=0;for(let ne=0;ne<Z.length;ne++){const ee=Z[ne],le=S(ee);typeof ee=="number"||typeof ee=="boolean"?(U.__data[0]=ee,i.bufferSubData(i.UNIFORM_BUFFER,W+te,U.__data)):ee.isMatrix3?(U.__data[0]=ee.elements[0],U.__data[1]=ee.elements[1],U.__data[2]=ee.elements[2],U.__data[3]=0,U.__data[4]=ee.elements[3],U.__data[5]=ee.elements[4],U.__data[6]=ee.elements[5],U.__data[7]=0,U.__data[8]=ee.elements[6],U.__data[9]=ee.elements[7],U.__data[10]=ee.elements[8],U.__data[11]=0):(ee.toArray(U.__data,te),te+=le.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,W,U.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function m(L,C,g,E){const T=L.value,A=C+"_"+g;if(E[A]===void 0)return typeof T=="number"||typeof T=="boolean"?E[A]=T:E[A]=T.clone(),!0;{const I=E[A];if(typeof T=="number"||typeof T=="boolean"){if(I!==T)return E[A]=T,!0}else if(I.equals(T)===!1)return I.copy(T),!0}return!1}function v(L){const C=L.uniforms;let g=0;const E=16;for(let A=0,I=C.length;A<I;A++){const y=Array.isArray(C[A])?C[A]:[C[A]];for(let M=0,U=y.length;M<U;M++){const W=y[M],Z=Array.isArray(W.value)?W.value:[W.value];for(let te=0,ne=Z.length;te<ne;te++){const ee=Z[te],le=S(ee),j=g%E,ue=j%le.boundary,me=j+ue;g+=ue,me!==0&&E-me<le.storage&&(g+=E-me),W.__data=new Float32Array(le.storage/Float32Array.BYTES_PER_ELEMENT),W.__offset=g,g+=le.storage}}}const T=g%E;return T>0&&(g+=E-T),L.__size=g,L.__cache={},this}function S(L){const C={boundary:0,storage:0};return typeof L=="number"||typeof L=="boolean"?(C.boundary=4,C.storage=4):L.isVector2?(C.boundary=8,C.storage=8):L.isVector3||L.isColor?(C.boundary=16,C.storage=12):L.isVector4?(C.boundary=16,C.storage=16):L.isMatrix3?(C.boundary=48,C.storage=48):L.isMatrix4?(C.boundary=64,C.storage=64):L.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",L),C}function p(L){const C=L.target;C.removeEventListener("dispose",p);const g=a.indexOf(C.__bindingPointIndex);a.splice(g,1),i.deleteBuffer(r[C.id]),delete r[C.id],delete s[C.id]}function h(){for(const L in r)i.deleteBuffer(r[L]);a=[],r={},s={}}return{bind:c,update:l,dispose:h}}class hm{constructor(e={}){const{canvas:t=Oc(),context:n=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:d=!1}=e;this.isWebGLRenderer=!0;let m;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=n.getContextAttributes().alpha}else m=a;const v=new Uint32Array(4),S=new Int32Array(4);let p=null,h=null;const L=[],C=[];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=vn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const g=this;let E=!1;this._outputColorSpace=Ft;let T=0,A=0,I=null,y=-1,M=null;const U=new ot,W=new ot;let Z=null;const te=new Ge(0);let ne=0,ee=t.width,le=t.height,j=1,ue=null,me=null;const be=new ot(0,0,ee,le),Be=new ot(0,0,ee,le);let de=!1;const je=new Aa;let Xe=!1,Y=!1;const se=new st,ve=new B,De=new ot,Ae={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ie=!1;function ht(){return I===null?j:1}let P=n;function Je(x,F){return t.getContext(x,F)}try{const x={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:u,failIfMajorPerformanceCaveat:f};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${ga}`),t.addEventListener("webglcontextlost",V,!1),t.addEventListener("webglcontextrestored",$,!1),t.addEventListener("webglcontextcreationerror",k,!1),P===null){const F="webgl2";if(P=Je(F,x),P===null)throw Je(F)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(x){throw console.error("THREE.WebGLRenderer: "+x.message),x}let Ue,Re,xe,Qe,Me,Ne,lt,tt,b,_,H,Q,re,J,Te,he,Se,D,w,N,K,ie,ae,ye;function R(){Ue=new Md(P),Ue.init(),ie=new nm(P,Ue),Re=new dd(P,Ue,e,ie),xe=new em(P,Ue),Re.reversedDepthBuffer&&d&&xe.buffers.depth.setReversed(!0),Qe=new Ed(P),Me=new kp,Ne=new tm(P,Ue,xe,Me,Re,ie,Qe),lt=new md(g),tt=new xd(g),b=new Rh(P),ae=new ud(P,b),_=new Sd(P,b,Qe,ae),H=new bd(P,_,b,Qe),w=new Td(P,Re,Ne),he=new pd(Me),Q=new Hp(g,lt,tt,Ue,Re,ae,he),re=new lm(g,Me),J=new Gp,Te=new Kp(Ue),D=new hd(g,lt,tt,xe,H,m,c),Se=new Jp(g,H,Re),ye=new cm(P,Qe,Re,xe),N=new fd(P,Ue,Qe),K=new yd(P,Ue,Qe),Qe.programs=Q.programs,g.capabilities=Re,g.extensions=Ue,g.properties=Me,g.renderLists=J,g.shadowMap=Se,g.state=xe,g.info=Qe}R();const z=new am(g,P);this.xr=z,this.getContext=function(){return P},this.getContextAttributes=function(){return P.getContextAttributes()},this.forceContextLoss=function(){const x=Ue.get("WEBGL_lose_context");x&&x.loseContext()},this.forceContextRestore=function(){const x=Ue.get("WEBGL_lose_context");x&&x.restoreContext()},this.getPixelRatio=function(){return j},this.setPixelRatio=function(x){x!==void 0&&(j=x,this.setSize(ee,le,!1))},this.getSize=function(x){return x.set(ee,le)},this.setSize=function(x,F,X=!0){if(z.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}ee=x,le=F,t.width=Math.floor(x*j),t.height=Math.floor(F*j),X===!0&&(t.style.width=x+"px",t.style.height=F+"px"),this.setViewport(0,0,x,F)},this.getDrawingBufferSize=function(x){return x.set(ee*j,le*j).floor()},this.setDrawingBufferSize=function(x,F,X){ee=x,le=F,j=X,t.width=Math.floor(x*X),t.height=Math.floor(F*X),this.setViewport(0,0,x,F)},this.getCurrentViewport=function(x){return x.copy(U)},this.getViewport=function(x){return x.copy(be)},this.setViewport=function(x,F,X,q){x.isVector4?be.set(x.x,x.y,x.z,x.w):be.set(x,F,X,q),xe.viewport(U.copy(be).multiplyScalar(j).round())},this.getScissor=function(x){return x.copy(Be)},this.setScissor=function(x,F,X,q){x.isVector4?Be.set(x.x,x.y,x.z,x.w):Be.set(x,F,X,q),xe.scissor(W.copy(Be).multiplyScalar(j).round())},this.getScissorTest=function(){return de},this.setScissorTest=function(x){xe.setScissorTest(de=x)},this.setOpaqueSort=function(x){ue=x},this.setTransparentSort=function(x){me=x},this.getClearColor=function(x){return x.copy(D.getClearColor())},this.setClearColor=function(){D.setClearColor(...arguments)},this.getClearAlpha=function(){return D.getClearAlpha()},this.setClearAlpha=function(){D.setClearAlpha(...arguments)},this.clear=function(x=!0,F=!0,X=!0){let q=0;if(x){let O=!1;if(I!==null){const oe=I.texture.format;O=oe===Ea||oe===ya||oe===Sa}if(O){const oe=I.texture.type,pe=oe===Zt||oe===Bn||oe===wi||oe===Ri||oe===xa||oe===Ma,Ee=D.getClearColor(),ge=D.getClearAlpha(),Pe=Ee.r,Le=Ee.g,we=Ee.b;pe?(v[0]=Pe,v[1]=Le,v[2]=we,v[3]=ge,P.clearBufferuiv(P.COLOR,0,v)):(S[0]=Pe,S[1]=Le,S[2]=we,S[3]=ge,P.clearBufferiv(P.COLOR,0,S))}else q|=P.COLOR_BUFFER_BIT}F&&(q|=P.DEPTH_BUFFER_BIT),X&&(q|=P.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),P.clear(q)},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",V,!1),t.removeEventListener("webglcontextrestored",$,!1),t.removeEventListener("webglcontextcreationerror",k,!1),D.dispose(),J.dispose(),Te.dispose(),Me.dispose(),lt.dispose(),tt.dispose(),H.dispose(),ae.dispose(),ye.dispose(),Q.dispose(),z.dispose(),z.removeEventListener("sessionstart",Lt),z.removeEventListener("sessionend",Ua),En.stop()};function V(x){x.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),E=!0}function $(){console.log("THREE.WebGLRenderer: Context Restored."),E=!1;const x=Qe.autoReset,F=Se.enabled,X=Se.autoUpdate,q=Se.needsUpdate,O=Se.type;R(),Qe.autoReset=x,Se.enabled=F,Se.autoUpdate=X,Se.needsUpdate=q,Se.type=O}function k(x){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",x.statusMessage)}function G(x){const F=x.target;F.removeEventListener("dispose",G),ce(F)}function ce(x){_e(x),Me.remove(x)}function _e(x){const F=Me.get(x).programs;F!==void 0&&(F.forEach(function(X){Q.releaseProgram(X)}),x.isShaderMaterial&&Q.releaseShaderCache(x))}this.renderBufferDirect=function(x,F,X,q,O,oe){F===null&&(F=Ae);const pe=O.isMesh&&O.matrixWorld.determinant()<0,Ee=kl(x,F,X,q,O);xe.setMaterial(q,pe);let ge=X.index,Pe=1;if(q.wireframe===!0){if(ge=_.getWireframeAttribute(X),ge===void 0)return;Pe=2}const Le=X.drawRange,we=X.attributes.position;let Ve=Le.start*Pe,Ke=(Le.start+Le.count)*Pe;oe!==null&&(Ve=Math.max(Ve,oe.start*Pe),Ke=Math.min(Ke,(oe.start+oe.count)*Pe)),ge!==null?(Ve=Math.max(Ve,0),Ke=Math.min(Ke,ge.count)):we!=null&&(Ve=Math.max(Ve,0),Ke=Math.min(Ke,we.count));const at=Ke-Ve;if(at<0||at===1/0)return;ae.setup(O,q,Ee,X,ge);let nt,et=N;if(ge!==null&&(nt=b.get(ge),et=K,et.setIndex(nt)),O.isMesh)q.wireframe===!0?(xe.setLineWidth(q.wireframeLinewidth*ht()),et.setMode(P.LINES)):et.setMode(P.TRIANGLES);else if(O.isLine){let Ce=q.linewidth;Ce===void 0&&(Ce=1),xe.setLineWidth(Ce*ht()),O.isLineSegments?et.setMode(P.LINES):O.isLineLoop?et.setMode(P.LINE_LOOP):et.setMode(P.LINE_STRIP)}else O.isPoints?et.setMode(P.POINTS):O.isSprite&&et.setMode(P.TRIANGLES);if(O.isBatchedMesh)if(O._multiDrawInstances!==null)Di("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),et.renderMultiDrawInstances(O._multiDrawStarts,O._multiDrawCounts,O._multiDrawCount,O._multiDrawInstances);else if(Ue.get("WEBGL_multi_draw"))et.renderMultiDraw(O._multiDrawStarts,O._multiDrawCounts,O._multiDrawCount);else{const Ce=O._multiDrawStarts,it=O._multiDrawCounts,qe=O._multiDrawCount,wt=ge?b.get(ge).bytesPerElement:1,Vn=Me.get(q).currentProgram.getUniforms();for(let Rt=0;Rt<qe;Rt++)Vn.setValue(P,"_gl_DrawID",Rt),et.render(Ce[Rt]/wt,it[Rt])}else if(O.isInstancedMesh)et.renderInstances(Ve,at,O.count);else if(X.isInstancedBufferGeometry){const Ce=X._maxInstanceCount!==void 0?X._maxInstanceCount:1/0,it=Math.min(X.instanceCount,Ce);et.renderInstances(Ve,at,it)}else et.render(Ve,at)};function He(x,F,X){x.transparent===!0&&x.side===an&&x.forceSinglePass===!1?(x.side=bt,x.needsUpdate=!0,zi(x,F,X),x.side=Mn,x.needsUpdate=!0,zi(x,F,X),x.side=an):zi(x,F,X)}this.compile=function(x,F,X=null){X===null&&(X=x),h=Te.get(X),h.init(F),C.push(h),X.traverseVisible(function(O){O.isLight&&O.layers.test(F.layers)&&(h.pushLight(O),O.castShadow&&h.pushShadow(O))}),x!==X&&x.traverseVisible(function(O){O.isLight&&O.layers.test(F.layers)&&(h.pushLight(O),O.castShadow&&h.pushShadow(O))}),h.setupLights();const q=new Set;return x.traverse(function(O){if(!(O.isMesh||O.isPoints||O.isLine||O.isSprite))return;const oe=O.material;if(oe)if(Array.isArray(oe))for(let pe=0;pe<oe.length;pe++){const Ee=oe[pe];He(Ee,X,O),q.add(Ee)}else He(oe,X,O),q.add(oe)}),h=C.pop(),q},this.compileAsync=function(x,F,X=null){const q=this.compile(x,F,X);return new Promise(O=>{function oe(){if(q.forEach(function(pe){Me.get(pe).currentProgram.isReady()&&q.delete(pe)}),q.size===0){O(x);return}setTimeout(oe,10)}Ue.get("KHR_parallel_shader_compile")!==null?oe():setTimeout(oe,10)})};let We=null;function zt(x){We&&We(x)}function Lt(){En.stop()}function Ua(){En.start()}const En=new Rl;En.setAnimationLoop(zt),typeof self<"u"&&En.setContext(self),this.setAnimationLoop=function(x){We=x,z.setAnimationLoop(x),x===null?En.stop():En.start()},z.addEventListener("sessionstart",Lt),z.addEventListener("sessionend",Ua),this.render=function(x,F){if(F!==void 0&&F.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(E===!0)return;if(x.matrixWorldAutoUpdate===!0&&x.updateMatrixWorld(),F.parent===null&&F.matrixWorldAutoUpdate===!0&&F.updateMatrixWorld(),z.enabled===!0&&z.isPresenting===!0&&(z.cameraAutoUpdate===!0&&z.updateCamera(F),F=z.getCamera()),x.isScene===!0&&x.onBeforeRender(g,x,F,I),h=Te.get(x,C.length),h.init(F),C.push(h),se.multiplyMatrices(F.projectionMatrix,F.matrixWorldInverse),je.setFromProjectionMatrix(se,jt,F.reversedDepth),Y=this.localClippingEnabled,Xe=he.init(this.clippingPlanes,Y),p=J.get(x,L.length),p.init(),L.push(p),z.enabled===!0&&z.isPresenting===!0){const oe=g.xr.getDepthSensingMesh();oe!==null&&Nr(oe,F,-1/0,g.sortObjects)}Nr(x,F,0,g.sortObjects),p.finish(),g.sortObjects===!0&&p.sort(ue,me),Ie=z.enabled===!1||z.isPresenting===!1||z.hasDepthSensing()===!1,Ie&&D.addToRenderList(p,x),this.info.render.frame++,Xe===!0&&he.beginShadows();const X=h.state.shadowsArray;Se.render(X,x,F),Xe===!0&&he.endShadows(),this.info.autoReset===!0&&this.info.reset();const q=p.opaque,O=p.transmissive;if(h.setupLights(),F.isArrayCamera){const oe=F.cameras;if(O.length>0)for(let pe=0,Ee=oe.length;pe<Ee;pe++){const ge=oe[pe];Fa(q,O,x,ge)}Ie&&D.render(x);for(let pe=0,Ee=oe.length;pe<Ee;pe++){const ge=oe[pe];Na(p,x,ge,ge.viewport)}}else O.length>0&&Fa(q,O,x,F),Ie&&D.render(x),Na(p,x,F);I!==null&&A===0&&(Ne.updateMultisampleRenderTarget(I),Ne.updateRenderTargetMipmap(I)),x.isScene===!0&&x.onAfterRender(g,x,F),ae.resetDefaultState(),y=-1,M=null,C.pop(),C.length>0?(h=C[C.length-1],Xe===!0&&he.setGlobalState(g.clippingPlanes,h.state.camera)):h=null,L.pop(),L.length>0?p=L[L.length-1]:p=null};function Nr(x,F,X,q){if(x.visible===!1)return;if(x.layers.test(F.layers)){if(x.isGroup)X=x.renderOrder;else if(x.isLOD)x.autoUpdate===!0&&x.update(F);else if(x.isLight)h.pushLight(x),x.castShadow&&h.pushShadow(x);else if(x.isSprite){if(!x.frustumCulled||je.intersectsSprite(x)){q&&De.setFromMatrixPosition(x.matrixWorld).applyMatrix4(se);const pe=H.update(x),Ee=x.material;Ee.visible&&p.push(x,pe,Ee,X,De.z,null)}}else if((x.isMesh||x.isLine||x.isPoints)&&(!x.frustumCulled||je.intersectsObject(x))){const pe=H.update(x),Ee=x.material;if(q&&(x.boundingSphere!==void 0?(x.boundingSphere===null&&x.computeBoundingSphere(),De.copy(x.boundingSphere.center)):(pe.boundingSphere===null&&pe.computeBoundingSphere(),De.copy(pe.boundingSphere.center)),De.applyMatrix4(x.matrixWorld).applyMatrix4(se)),Array.isArray(Ee)){const ge=pe.groups;for(let Pe=0,Le=ge.length;Pe<Le;Pe++){const we=ge[Pe],Ve=Ee[we.materialIndex];Ve&&Ve.visible&&p.push(x,pe,Ve,X,De.z,we)}}else Ee.visible&&p.push(x,pe,Ee,X,De.z,null)}}const oe=x.children;for(let pe=0,Ee=oe.length;pe<Ee;pe++)Nr(oe[pe],F,X,q)}function Na(x,F,X,q){const O=x.opaque,oe=x.transmissive,pe=x.transparent;h.setupLightsView(X),Xe===!0&&he.setGlobalState(g.clippingPlanes,X),q&&xe.viewport(U.copy(q)),O.length>0&&Bi(O,F,X),oe.length>0&&Bi(oe,F,X),pe.length>0&&Bi(pe,F,X),xe.buffers.depth.setTest(!0),xe.buffers.depth.setMask(!0),xe.buffers.color.setMask(!0),xe.setPolygonOffset(!1)}function Fa(x,F,X,q){if((X.isScene===!0?X.overrideMaterial:null)!==null)return;h.state.transmissionRenderTarget[q.id]===void 0&&(h.state.transmissionRenderTarget[q.id]=new Hn(1,1,{generateMipmaps:!0,type:Ue.has("EXT_color_buffer_half_float")||Ue.has("EXT_color_buffer_float")?Ii:Zt,minFilter:Fn,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ye.workingColorSpace}));const oe=h.state.transmissionRenderTarget[q.id],pe=q.viewport||U;oe.setSize(pe.z*g.transmissionResolutionScale,pe.w*g.transmissionResolutionScale);const Ee=g.getRenderTarget(),ge=g.getActiveCubeFace(),Pe=g.getActiveMipmapLevel();g.setRenderTarget(oe),g.getClearColor(te),ne=g.getClearAlpha(),ne<1&&g.setClearColor(16777215,.5),g.clear(),Ie&&D.render(X);const Le=g.toneMapping;g.toneMapping=vn;const we=q.viewport;if(q.viewport!==void 0&&(q.viewport=void 0),h.setupLightsView(q),Xe===!0&&he.setGlobalState(g.clippingPlanes,q),Bi(x,X,q),Ne.updateMultisampleRenderTarget(oe),Ne.updateRenderTargetMipmap(oe),Ue.has("WEBGL_multisampled_render_to_texture")===!1){let Ve=!1;for(let Ke=0,at=F.length;Ke<at;Ke++){const nt=F[Ke],et=nt.object,Ce=nt.geometry,it=nt.material,qe=nt.group;if(it.side===an&&et.layers.test(q.layers)){const wt=it.side;it.side=bt,it.needsUpdate=!0,Oa(et,X,q,Ce,it,qe),it.side=wt,it.needsUpdate=!0,Ve=!0}}Ve===!0&&(Ne.updateMultisampleRenderTarget(oe),Ne.updateRenderTargetMipmap(oe))}g.setRenderTarget(Ee,ge,Pe),g.setClearColor(te,ne),we!==void 0&&(q.viewport=we),g.toneMapping=Le}function Bi(x,F,X){const q=F.isScene===!0?F.overrideMaterial:null;for(let O=0,oe=x.length;O<oe;O++){const pe=x[O],Ee=pe.object,ge=pe.geometry,Pe=pe.group;let Le=pe.material;Le.allowOverride===!0&&q!==null&&(Le=q),Ee.layers.test(X.layers)&&Oa(Ee,F,X,ge,Le,Pe)}}function Oa(x,F,X,q,O,oe){x.onBeforeRender(g,F,X,q,O,oe),x.modelViewMatrix.multiplyMatrices(X.matrixWorldInverse,x.matrixWorld),x.normalMatrix.getNormalMatrix(x.modelViewMatrix),O.onBeforeRender(g,F,X,q,x,oe),O.transparent===!0&&O.side===an&&O.forceSinglePass===!1?(O.side=bt,O.needsUpdate=!0,g.renderBufferDirect(X,F,q,O,x,oe),O.side=Mn,O.needsUpdate=!0,g.renderBufferDirect(X,F,q,O,x,oe),O.side=an):g.renderBufferDirect(X,F,q,O,x,oe),x.onAfterRender(g,F,X,q,O,oe)}function zi(x,F,X){F.isScene!==!0&&(F=Ae);const q=Me.get(x),O=h.state.lights,oe=h.state.shadowsArray,pe=O.state.version,Ee=Q.getParameters(x,O.state,oe,F,X),ge=Q.getProgramCacheKey(Ee);let Pe=q.programs;q.environment=x.isMeshStandardMaterial?F.environment:null,q.fog=F.fog,q.envMap=(x.isMeshStandardMaterial?tt:lt).get(x.envMap||q.environment),q.envMapRotation=q.environment!==null&&x.envMap===null?F.environmentRotation:x.envMapRotation,Pe===void 0&&(x.addEventListener("dispose",G),Pe=new Map,q.programs=Pe);let Le=Pe.get(ge);if(Le!==void 0){if(q.currentProgram===Le&&q.lightsStateVersion===pe)return za(x,Ee),Le}else Ee.uniforms=Q.getUniforms(x),x.onBeforeCompile(Ee,g),Le=Q.acquireProgram(Ee,ge),Pe.set(ge,Le),q.uniforms=Ee.uniforms;const we=q.uniforms;return(!x.isShaderMaterial&&!x.isRawShaderMaterial||x.clipping===!0)&&(we.clippingPlanes=he.uniform),za(x,Ee),q.needsLights=Gl(x),q.lightsStateVersion=pe,q.needsLights&&(we.ambientLightColor.value=O.state.ambient,we.lightProbe.value=O.state.probe,we.directionalLights.value=O.state.directional,we.directionalLightShadows.value=O.state.directionalShadow,we.spotLights.value=O.state.spot,we.spotLightShadows.value=O.state.spotShadow,we.rectAreaLights.value=O.state.rectArea,we.ltc_1.value=O.state.rectAreaLTC1,we.ltc_2.value=O.state.rectAreaLTC2,we.pointLights.value=O.state.point,we.pointLightShadows.value=O.state.pointShadow,we.hemisphereLights.value=O.state.hemi,we.directionalShadowMap.value=O.state.directionalShadowMap,we.directionalShadowMatrix.value=O.state.directionalShadowMatrix,we.spotShadowMap.value=O.state.spotShadowMap,we.spotLightMatrix.value=O.state.spotLightMatrix,we.spotLightMap.value=O.state.spotLightMap,we.pointShadowMap.value=O.state.pointShadowMap,we.pointShadowMatrix.value=O.state.pointShadowMatrix),q.currentProgram=Le,q.uniformsList=null,Le}function Ba(x){if(x.uniformsList===null){const F=x.currentProgram.getUniforms();x.uniformsList=Mr.seqWithValue(F.seq,x.uniforms)}return x.uniformsList}function za(x,F){const X=Me.get(x);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 kl(x,F,X,q,O){F.isScene!==!0&&(F=Ae),Ne.resetTextureUnits();const oe=F.fog,pe=q.isMeshStandardMaterial?F.environment:null,Ee=I===null?g.outputColorSpace:I.isXRRenderTarget===!0?I.texture.colorSpace:fi,ge=(q.isMeshStandardMaterial?tt:lt).get(q.envMap||pe),Pe=q.vertexColors===!0&&!!X.attributes.color&&X.attributes.color.itemSize===4,Le=!!X.attributes.tangent&&(!!q.normalMap||q.anisotropy>0),we=!!X.morphAttributes.position,Ve=!!X.morphAttributes.normal,Ke=!!X.morphAttributes.color;let at=vn;q.toneMapped&&(I===null||I.isXRRenderTarget===!0)&&(at=g.toneMapping);const nt=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,et=nt!==void 0?nt.length:0,Ce=Me.get(q),it=h.state.lights;if(Xe===!0&&(Y===!0||x!==M)){const xt=x===M&&q.id===y;he.setState(q,x,xt)}let qe=!1;q.version===Ce.__version?(Ce.needsLights&&Ce.lightsStateVersion!==it.state.version||Ce.outputColorSpace!==Ee||O.isBatchedMesh&&Ce.batching===!1||!O.isBatchedMesh&&Ce.batching===!0||O.isBatchedMesh&&Ce.batchingColor===!0&&O.colorTexture===null||O.isBatchedMesh&&Ce.batchingColor===!1&&O.colorTexture!==null||O.isInstancedMesh&&Ce.instancing===!1||!O.isInstancedMesh&&Ce.instancing===!0||O.isSkinnedMesh&&Ce.skinning===!1||!O.isSkinnedMesh&&Ce.skinning===!0||O.isInstancedMesh&&Ce.instancingColor===!0&&O.instanceColor===null||O.isInstancedMesh&&Ce.instancingColor===!1&&O.instanceColor!==null||O.isInstancedMesh&&Ce.instancingMorph===!0&&O.morphTexture===null||O.isInstancedMesh&&Ce.instancingMorph===!1&&O.morphTexture!==null||Ce.envMap!==ge||q.fog===!0&&Ce.fog!==oe||Ce.numClippingPlanes!==void 0&&(Ce.numClippingPlanes!==he.numPlanes||Ce.numIntersection!==he.numIntersection)||Ce.vertexAlphas!==Pe||Ce.vertexTangents!==Le||Ce.morphTargets!==we||Ce.morphNormals!==Ve||Ce.morphColors!==Ke||Ce.toneMapping!==at||Ce.morphTargetsCount!==et)&&(qe=!0):(qe=!0,Ce.__version=q.version);let wt=Ce.currentProgram;qe===!0&&(wt=zi(q,F,O));let Vn=!1,Rt=!1,_i=!1;const rt=wt.getUniforms(),It=Ce.uniforms;if(xe.useProgram(wt.program)&&(Vn=!0,Rt=!0,_i=!0),q.id!==y&&(y=q.id,Rt=!0),Vn||M!==x){xe.buffers.depth.getReversed()&&x.reversedDepth!==!0&&(x._reversedDepth=!0,x.updateProjectionMatrix()),rt.setValue(P,"projectionMatrix",x.projectionMatrix),rt.setValue(P,"viewMatrix",x.matrixWorldInverse);const St=rt.map.cameraPosition;St!==void 0&&St.setValue(P,ve.setFromMatrixPosition(x.matrixWorld)),Re.logarithmicDepthBuffer&&rt.setValue(P,"logDepthBufFC",2/(Math.log(x.far+1)/Math.LN2)),(q.isMeshPhongMaterial||q.isMeshToonMaterial||q.isMeshLambertMaterial||q.isMeshBasicMaterial||q.isMeshStandardMaterial||q.isShaderMaterial)&&rt.setValue(P,"isOrthographic",x.isOrthographicCamera===!0),M!==x&&(M=x,Rt=!0,_i=!0)}if(O.isSkinnedMesh){rt.setOptional(P,O,"bindMatrix"),rt.setOptional(P,O,"bindMatrixInverse");const xt=O.skeleton;xt&&(xt.boneTexture===null&&xt.computeBoneTexture(),rt.setValue(P,"boneTexture",xt.boneTexture,Ne))}O.isBatchedMesh&&(rt.setOptional(P,O,"batchingTexture"),rt.setValue(P,"batchingTexture",O._matricesTexture,Ne),rt.setOptional(P,O,"batchingIdTexture"),rt.setValue(P,"batchingIdTexture",O._indirectTexture,Ne),rt.setOptional(P,O,"batchingColorTexture"),O._colorsTexture!==null&&rt.setValue(P,"batchingColorTexture",O._colorsTexture,Ne));const Ut=X.morphAttributes;if((Ut.position!==void 0||Ut.normal!==void 0||Ut.color!==void 0)&&w.update(O,X,wt),(Rt||Ce.receiveShadow!==O.receiveShadow)&&(Ce.receiveShadow=O.receiveShadow,rt.setValue(P,"receiveShadow",O.receiveShadow)),q.isMeshGouraudMaterial&&q.envMap!==null&&(It.envMap.value=ge,It.flipEnvMap.value=ge.isCubeTexture&&ge.isRenderTargetTexture===!1?-1:1),q.isMeshStandardMaterial&&q.envMap===null&&F.environment!==null&&(It.envMapIntensity.value=F.environmentIntensity),Rt&&(rt.setValue(P,"toneMappingExposure",g.toneMappingExposure),Ce.needsLights&&Vl(It,_i),oe&&q.fog===!0&&re.refreshFogUniforms(It,oe),re.refreshMaterialUniforms(It,q,j,le,h.state.transmissionRenderTarget[x.id]),Mr.upload(P,Ba(Ce),It,Ne)),q.isShaderMaterial&&q.uniformsNeedUpdate===!0&&(Mr.upload(P,Ba(Ce),It,Ne),q.uniformsNeedUpdate=!1),q.isSpriteMaterial&&rt.setValue(P,"center",O.center),rt.setValue(P,"modelViewMatrix",O.modelViewMatrix),rt.setValue(P,"normalMatrix",O.normalMatrix),rt.setValue(P,"modelMatrix",O.matrixWorld),q.isShaderMaterial||q.isRawShaderMaterial){const xt=q.uniformsGroups;for(let St=0,Fr=xt.length;St<Fr;St++){const Tn=xt[St];ye.update(Tn,wt),ye.bind(Tn,wt)}}return wt}function Vl(x,F){x.ambientLightColor.needsUpdate=F,x.lightProbe.needsUpdate=F,x.directionalLights.needsUpdate=F,x.directionalLightShadows.needsUpdate=F,x.pointLights.needsUpdate=F,x.pointLightShadows.needsUpdate=F,x.spotLights.needsUpdate=F,x.spotLightShadows.needsUpdate=F,x.rectAreaLights.needsUpdate=F,x.hemisphereLights.needsUpdate=F}function Gl(x){return x.isMeshLambertMaterial||x.isMeshToonMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isShadowMaterial||x.isShaderMaterial&&x.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return A},this.getRenderTarget=function(){return I},this.setRenderTargetTextures=function(x,F,X){const q=Me.get(x);q.__autoAllocateDepthBuffer=x.resolveDepthBuffer===!1,q.__autoAllocateDepthBuffer===!1&&(q.__useRenderToTexture=!1),Me.get(x.texture).__webglTexture=F,Me.get(x.depthTexture).__webglTexture=q.__autoAllocateDepthBuffer?void 0:X,q.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(x,F){const X=Me.get(x);X.__webglFramebuffer=F,X.__useDefaultFramebuffer=F===void 0};const Wl=P.createFramebuffer();this.setRenderTarget=function(x,F=0,X=0){I=x,T=F,A=X;let q=!0,O=null,oe=!1,pe=!1;if(x){const ge=Me.get(x);if(ge.__useDefaultFramebuffer!==void 0)xe.bindFramebuffer(P.FRAMEBUFFER,null),q=!1;else if(ge.__webglFramebuffer===void 0)Ne.setupRenderTarget(x);else if(ge.__hasExternalTextures)Ne.rebindTextures(x,Me.get(x.texture).__webglTexture,Me.get(x.depthTexture).__webglTexture);else if(x.depthBuffer){const we=x.depthTexture;if(ge.__boundDepthTexture!==we){if(we!==null&&Me.has(we)&&(x.width!==we.image.width||x.height!==we.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Ne.setupDepthRenderbuffer(x)}}const Pe=x.texture;(Pe.isData3DTexture||Pe.isDataArrayTexture||Pe.isCompressedArrayTexture)&&(pe=!0);const Le=Me.get(x).__webglFramebuffer;x.isWebGLCubeRenderTarget?(Array.isArray(Le[F])?O=Le[F][X]:O=Le[F],oe=!0):x.samples>0&&Ne.useMultisampledRTT(x)===!1?O=Me.get(x).__webglMultisampledFramebuffer:Array.isArray(Le)?O=Le[X]:O=Le,U.copy(x.viewport),W.copy(x.scissor),Z=x.scissorTest}else U.copy(be).multiplyScalar(j).floor(),W.copy(Be).multiplyScalar(j).floor(),Z=de;if(X!==0&&(O=Wl),xe.bindFramebuffer(P.FRAMEBUFFER,O)&&q&&xe.drawBuffers(x,O),xe.viewport(U),xe.scissor(W),xe.setScissorTest(Z),oe){const ge=Me.get(x.texture);P.framebufferTexture2D(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_CUBE_MAP_POSITIVE_X+F,ge.__webglTexture,X)}else if(pe){const ge=F;for(let Pe=0;Pe<x.textures.length;Pe++){const Le=Me.get(x.textures[Pe]);P.framebufferTextureLayer(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0+Pe,Le.__webglTexture,X,ge)}}else if(x!==null&&X!==0){const ge=Me.get(x.texture);P.framebufferTexture2D(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_2D,ge.__webglTexture,X)}y=-1},this.readRenderTargetPixels=function(x,F,X,q,O,oe,pe,Ee=0){if(!(x&&x.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ge=Me.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&pe!==void 0&&(ge=ge[pe]),ge){xe.bindFramebuffer(P.FRAMEBUFFER,ge);try{const Pe=x.textures[Ee],Le=Pe.format,we=Pe.type;if(!Re.textureFormatReadable(Le)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Re.textureTypeReadable(we)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}F>=0&&F<=x.width-q&&X>=0&&X<=x.height-O&&(x.textures.length>1&&P.readBuffer(P.COLOR_ATTACHMENT0+Ee),P.readPixels(F,X,q,O,ie.convert(Le),ie.convert(we),oe))}finally{const Pe=I!==null?Me.get(I).__webglFramebuffer:null;xe.bindFramebuffer(P.FRAMEBUFFER,Pe)}}},this.readRenderTargetPixelsAsync=async function(x,F,X,q,O,oe,pe,Ee=0){if(!(x&&x.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ge=Me.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&pe!==void 0&&(ge=ge[pe]),ge)if(F>=0&&F<=x.width-q&&X>=0&&X<=x.height-O){xe.bindFramebuffer(P.FRAMEBUFFER,ge);const Pe=x.textures[Ee],Le=Pe.format,we=Pe.type;if(!Re.textureFormatReadable(Le))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Re.textureTypeReadable(we))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ve=P.createBuffer();P.bindBuffer(P.PIXEL_PACK_BUFFER,Ve),P.bufferData(P.PIXEL_PACK_BUFFER,oe.byteLength,P.STREAM_READ),x.textures.length>1&&P.readBuffer(P.COLOR_ATTACHMENT0+Ee),P.readPixels(F,X,q,O,ie.convert(Le),ie.convert(we),0);const Ke=I!==null?Me.get(I).__webglFramebuffer:null;xe.bindFramebuffer(P.FRAMEBUFFER,Ke);const at=P.fenceSync(P.SYNC_GPU_COMMANDS_COMPLETE,0);return P.flush(),await Bc(P,at,4),P.bindBuffer(P.PIXEL_PACK_BUFFER,Ve),P.getBufferSubData(P.PIXEL_PACK_BUFFER,0,oe),P.deleteBuffer(Ve),P.deleteSync(at),oe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(x,F=null,X=0){const q=Math.pow(2,-X),O=Math.floor(x.image.width*q),oe=Math.floor(x.image.height*q),pe=F!==null?F.x:0,Ee=F!==null?F.y:0;Ne.setTexture2D(x,0),P.copyTexSubImage2D(P.TEXTURE_2D,X,0,0,pe,Ee,O,oe),xe.unbindTexture()};const Xl=P.createFramebuffer(),ql=P.createFramebuffer();this.copyTextureToTexture=function(x,F,X=null,q=null,O=0,oe=null){oe===null&&(O!==0?(Di("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),oe=O,O=0):oe=0);let pe,Ee,ge,Pe,Le,we,Ve,Ke,at;const nt=x.isCompressedTexture?x.mipmaps[oe]:x.image;if(X!==null)pe=X.max.x-X.min.x,Ee=X.max.y-X.min.y,ge=X.isBox3?X.max.z-X.min.z:1,Pe=X.min.x,Le=X.min.y,we=X.isBox3?X.min.z:0;else{const Ut=Math.pow(2,-O);pe=Math.floor(nt.width*Ut),Ee=Math.floor(nt.height*Ut),x.isDataArrayTexture?ge=nt.depth:x.isData3DTexture?ge=Math.floor(nt.depth*Ut):ge=1,Pe=0,Le=0,we=0}q!==null?(Ve=q.x,Ke=q.y,at=q.z):(Ve=0,Ke=0,at=0);const et=ie.convert(F.format),Ce=ie.convert(F.type);let it;F.isData3DTexture?(Ne.setTexture3D(F,0),it=P.TEXTURE_3D):F.isDataArrayTexture||F.isCompressedArrayTexture?(Ne.setTexture2DArray(F,0),it=P.TEXTURE_2D_ARRAY):(Ne.setTexture2D(F,0),it=P.TEXTURE_2D),P.pixelStorei(P.UNPACK_FLIP_Y_WEBGL,F.flipY),P.pixelStorei(P.UNPACK_PREMULTIPLY_ALPHA_WEBGL,F.premultiplyAlpha),P.pixelStorei(P.UNPACK_ALIGNMENT,F.unpackAlignment);const qe=P.getParameter(P.UNPACK_ROW_LENGTH),wt=P.getParameter(P.UNPACK_IMAGE_HEIGHT),Vn=P.getParameter(P.UNPACK_SKIP_PIXELS),Rt=P.getParameter(P.UNPACK_SKIP_ROWS),_i=P.getParameter(P.UNPACK_SKIP_IMAGES);P.pixelStorei(P.UNPACK_ROW_LENGTH,nt.width),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,nt.height),P.pixelStorei(P.UNPACK_SKIP_PIXELS,Pe),P.pixelStorei(P.UNPACK_SKIP_ROWS,Le),P.pixelStorei(P.UNPACK_SKIP_IMAGES,we);const rt=x.isDataArrayTexture||x.isData3DTexture,It=F.isDataArrayTexture||F.isData3DTexture;if(x.isDepthTexture){const Ut=Me.get(x),xt=Me.get(F),St=Me.get(Ut.__renderTarget),Fr=Me.get(xt.__renderTarget);xe.bindFramebuffer(P.READ_FRAMEBUFFER,St.__webglFramebuffer),xe.bindFramebuffer(P.DRAW_FRAMEBUFFER,Fr.__webglFramebuffer);for(let Tn=0;Tn<ge;Tn++)rt&&(P.framebufferTextureLayer(P.READ_FRAMEBUFFER,P.COLOR_ATTACHMENT0,Me.get(x).__webglTexture,O,we+Tn),P.framebufferTextureLayer(P.DRAW_FRAMEBUFFER,P.COLOR_ATTACHMENT0,Me.get(F).__webglTexture,oe,at+Tn)),P.blitFramebuffer(Pe,Le,pe,Ee,Ve,Ke,pe,Ee,P.DEPTH_BUFFER_BIT,P.NEAREST);xe.bindFramebuffer(P.READ_FRAMEBUFFER,null),xe.bindFramebuffer(P.DRAW_FRAMEBUFFER,null)}else if(O!==0||x.isRenderTargetTexture||Me.has(x)){const Ut=Me.get(x),xt=Me.get(F);xe.bindFramebuffer(P.READ_FRAMEBUFFER,Xl),xe.bindFramebuffer(P.DRAW_FRAMEBUFFER,ql);for(let St=0;St<ge;St++)rt?P.framebufferTextureLayer(P.READ_FRAMEBUFFER,P.COLOR_ATTACHMENT0,Ut.__webglTexture,O,we+St):P.framebufferTexture2D(P.READ_FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_2D,Ut.__webglTexture,O),It?P.framebufferTextureLayer(P.DRAW_FRAMEBUFFER,P.COLOR_ATTACHMENT0,xt.__webglTexture,oe,at+St):P.framebufferTexture2D(P.DRAW_FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_2D,xt.__webglTexture,oe),O!==0?P.blitFramebuffer(Pe,Le,pe,Ee,Ve,Ke,pe,Ee,P.COLOR_BUFFER_BIT,P.NEAREST):It?P.copyTexSubImage3D(it,oe,Ve,Ke,at+St,Pe,Le,pe,Ee):P.copyTexSubImage2D(it,oe,Ve,Ke,Pe,Le,pe,Ee);xe.bindFramebuffer(P.READ_FRAMEBUFFER,null),xe.bindFramebuffer(P.DRAW_FRAMEBUFFER,null)}else It?x.isDataTexture||x.isData3DTexture?P.texSubImage3D(it,oe,Ve,Ke,at,pe,Ee,ge,et,Ce,nt.data):F.isCompressedArrayTexture?P.compressedTexSubImage3D(it,oe,Ve,Ke,at,pe,Ee,ge,et,nt.data):P.texSubImage3D(it,oe,Ve,Ke,at,pe,Ee,ge,et,Ce,nt):x.isDataTexture?P.texSubImage2D(P.TEXTURE_2D,oe,Ve,Ke,pe,Ee,et,Ce,nt.data):x.isCompressedTexture?P.compressedTexSubImage2D(P.TEXTURE_2D,oe,Ve,Ke,nt.width,nt.height,et,nt.data):P.texSubImage2D(P.TEXTURE_2D,oe,Ve,Ke,pe,Ee,et,Ce,nt);P.pixelStorei(P.UNPACK_ROW_LENGTH,qe),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,wt),P.pixelStorei(P.UNPACK_SKIP_PIXELS,Vn),P.pixelStorei(P.UNPACK_SKIP_ROWS,Rt),P.pixelStorei(P.UNPACK_SKIP_IMAGES,_i),oe===0&&F.generateMipmaps&&P.generateMipmap(it),xe.unbindTexture()},this.initRenderTarget=function(x){Me.get(x).__webglFramebuffer===void 0&&Ne.setupRenderTarget(x)},this.initTexture=function(x){x.isCubeTexture?Ne.setTextureCube(x,0):x.isData3DTexture?Ne.setTexture3D(x,0):x.isDataArrayTexture||x.isCompressedArrayTexture?Ne.setTexture2DArray(x,0):Ne.setTexture2D(x,0),xe.unbindTexture()},this.resetState=function(){T=0,A=0,I=null,xe.reset(),ae.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return jt}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=Ye._getDrawingBufferColorSpace(e),t.unpackColorSpace=Ye._getUnpackColorSpace()}}class Pa{scene;camera;renderer;canvas;meshes=[];constructor(e){this.canvas=e,this.scene=new ch,this.scene.background=new Ge(1710618),this.camera=new Ot(45,e.clientWidth/e.clientHeight,.1,1e3),this.camera.position.set(1,1,7),this.renderer=new hm({canvas:e,antialias:!0}),this.renderer.setSize(e.clientWidth,e.clientHeight);const t=new yh(16777215,.5);this.scene.add(t);const n=new Sh(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(e){const t=new Dt;t.setAttribute("position",new vt(e.position,3)),e.normal&&t.setAttribute("normal",new vt(e.normal,3)),e.uv&&t.setAttribute("uv",new vt(e.uv,2));const n=new mh({color:12566463,metalness:0,roughness:.6}),r=new Kt(t,n);return this.scene.add(r),this.meshes.push(r),r}addMesh(e){this.scene.add(e),this.meshes.push(e)}removeMesh(e){this.scene.remove(e),this.meshes=this.meshes.filter(t=>t!==e)}getMeshes(){return this.meshes}destroy(){this.meshes&&(this.meshes.length=0,this.meshes=[]),this.scene=null,this.camera=null,this.renderer=null,this.canvas=null}}const Ko={type:"change"},Da={type:"start"},Il={type:"end"},fr=new Dr,$o=new mn,um=Math.cos(70*Fc.DEG2RAD),ut=new B,Et=2*Math.PI,Ze={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},_s=1e-6;class Ul extends Ah{constructor(e,t=null){super(e,t),this.state=Ze.NONE,this.target=new B,this.cursor=new B,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:ai.ROTATE,MIDDLE:ai.DOLLY,RIGHT:ai.PAN},this.touches={ONE:ri.ROTATE,TWO:ri.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new B,this._lastQuaternion=new zn,this._lastTargetPosition=new B,this._quat=new zn().setFromUnitVectors(e.up,new B(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Eo,this._sphericalDelta=new Eo,this._scale=1,this._panOffset=new B,this._rotateStart=new Fe,this._rotateEnd=new Fe,this._rotateDelta=new Fe,this._panStart=new Fe,this._panEnd=new Fe,this._panDelta=new Fe,this._dollyStart=new Fe,this._dollyEnd=new Fe,this._dollyDelta=new Fe,this._dollyDirection=new B,this._mouse=new Fe,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=dm.bind(this),this._onPointerDown=fm.bind(this),this._onPointerUp=pm.bind(this),this._onContextMenu=Sm.bind(this),this._onMouseWheel=gm.bind(this),this._onKeyDown=vm.bind(this),this._onTouchStart=xm.bind(this),this._onTouchMove=Mm.bind(this),this._onMouseDown=mm.bind(this),this._onMouseMove=_m.bind(this),this._interceptControlDown=ym.bind(this),this._interceptControlUp=Em.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(Ko),this.update(),this.state=Ze.NONE}update(e=null){const t=this.object.position;ut.copy(t).sub(this.target),ut.applyQuaternion(this._quat),this._spherical.setFromVector3(ut),this.autoRotate&&this.state===Ze.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 n=this.minAzimuthAngle,r=this.maxAzimuthAngle;isFinite(n)&&isFinite(r)&&(n<-Math.PI?n+=Et:n>Math.PI&&(n-=Et),r<-Math.PI?r+=Et:r>Math.PI&&(r-=Et),n<=r?this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,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 a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=a!=this._spherical.radius}if(ut.setFromSpherical(this._spherical),ut.applyQuaternion(this._quatInverse),t.copy(this.target).add(ut),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=ut.length();a=this._clampDistance(o*this._scale);const c=o-a;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),s=!!c}else if(this.object.isOrthographicCamera){const o=new B(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=c!==this.object.zoom;const l=new B(this._mouse.x,this._mouse.y,0);l.unproject(this.object),this.object.position.sub(l).add(o),this.object.updateMatrixWorld(),a=ut.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):(fr.origin.copy(this.object.position),fr.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(fr.direction))<um?this.object.lookAt(this.target):($o.setFromNormalAndCoplanarPoint(this.object.up,this.target),fr.intersectPlane($o,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(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>_s||8*(1-this._lastQuaternion.dot(this.object.quaternion))>_s||this._lastTargetPosition.distanceToSquared(this.target)>_s?(this.dispatchEvent(Ko),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Et/60*this.autoRotateSpeed*e:Et/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){ut.setFromMatrixColumn(t,0),ut.multiplyScalar(-e),this._panOffset.add(ut)}_panUp(e,t){this.screenSpacePanning===!0?ut.setFromMatrixColumn(t,1):(ut.setFromMatrixColumn(t,0),ut.crossVectors(this.object.up,ut)),ut.multiplyScalar(e),this._panOffset.add(ut)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const r=this.object.position;ut.copy(r).sub(this.target);let s=ut.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/n.clientHeight,this.object.matrix),this._panUp(2*t*s/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(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(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 n=this.domElement.getBoundingClientRect(),r=e-n.left,s=t-n.top,a=n.width,o=n.height;this._mouse.x=r/a*2-1,this._mouse.y=-(s/o)*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(Et*this._rotateDelta.x/t.clientHeight),this._rotateUp(Et*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(Et*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(-Et*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(Et*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(-Et*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),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+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 n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),s=.5*(e.pageY+n.y);this._rotateEnd.set(r,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Et*this._rotateDelta.x/t.clientHeight),this._rotateUp(Et*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),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,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),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+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 a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_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 Fe,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,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function fm(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 dm(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function pm(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(Il),this.state=Ze.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 mm(i){let e;switch(i.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 ai.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=Ze.DOLLY;break;case ai.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Ze.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Ze.ROTATE}break;case ai.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Ze.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Ze.PAN}break;default:this.state=Ze.NONE}this.state!==Ze.NONE&&this.dispatchEvent(Da)}function _m(i){switch(this.state){case Ze.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case Ze.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case Ze.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function gm(i){this.enabled===!1||this.enableZoom===!1||this.state!==Ze.NONE||(i.preventDefault(),this.dispatchEvent(Da),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(Il))}function vm(i){this.enabled!==!1&&this._handleKeyDown(i)}function xm(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case ri.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=Ze.TOUCH_ROTATE;break;case ri.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=Ze.TOUCH_PAN;break;default:this.state=Ze.NONE}break;case 2:switch(this.touches.TWO){case ri.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=Ze.TOUCH_DOLLY_PAN;break;case ri.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=Ze.TOUCH_DOLLY_ROTATE;break;default:this.state=Ze.NONE}break;default:this.state=Ze.NONE}this.state!==Ze.NONE&&this.dispatchEvent(Da)}function Mm(i){switch(this._trackPointer(i),this.state){case Ze.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case Ze.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case Ze.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case Ze.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=Ze.NONE}}function Sm(i){this.enabled!==!1&&i.preventDefault()}function ym(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Em(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class Tm extends Ul{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)}destroy(){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 bm extends Ei{constructor(e=5){super();const t=[{dir:new B(1,0,0),color:16711680},{dir:new B(-1,0,0),color:16711680},{dir:new B(0,1,0),color:65280},{dir:new B(0,-1,0),color:65280},{dir:new B(0,0,1),color:255},{dir:new B(0,0,-1),color:255}];for(const{dir:n,color:r}of t){const s=new Dt().setFromPoints([new B(0,0,0),n.clone().multiplyScalar(e)]),a=new Oi({color:r}),o=new Tl(s,a);this.add(o)}}}var la;(function(i){i[i.Transient=0]="Transient",i[i.Singleton=1]="Singleton",i[i.ResolutionScoped=2]="ResolutionScoped",i[i.ContainerScoped=3]="ContainerScoped"})(la||(la={}));const Tt=la;/*! *****************************************************************************
3853
+ }`;class km{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new cc(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new Ln({vertexShader:zm,fragmentShader:Hm,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new _e(new er(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Gm extends Jn{constructor(e,t){super();const n=this;let r=null,s=1,o=null,a="local-floor",c=1,l=null,u=null,f=null,d=null,m=null,g=null;const y=typeof XRWebGLBinding<"u",p=new km,h={},w=t.getContextAttributes();let b=null,_=null;const T=[],E=[],A=new Ue;let C=null;const M=new Yt;M.viewport=new ut;const x=new Yt;x.viewport=new ut;const N=[M,x],z=new au;let q=null,j=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function($){let oe=T[$];return oe===void 0&&(oe=new As,T[$]=oe),oe.getTargetRaySpace()},this.getControllerGrip=function($){let oe=T[$];return oe===void 0&&(oe=new As,T[$]=oe),oe.getGripSpace()},this.getHand=function($){let oe=T[$];return oe===void 0&&(oe=new As,T[$]=oe),oe.getHandSpace()};function Q($){const oe=E.indexOf($.inputSource);if(oe===-1)return;const xe=T[oe];xe!==void 0&&(xe.update($.inputSource,$.frame,l||o),xe.dispatchEvent({type:$.type,data:$.inputSource}))}function K(){r.removeEventListener("select",Q),r.removeEventListener("selectstart",Q),r.removeEventListener("selectend",Q),r.removeEventListener("squeeze",Q),r.removeEventListener("squeezestart",Q),r.removeEventListener("squeezeend",Q),r.removeEventListener("end",K),r.removeEventListener("inputsourceschange",se);for(let $=0;$<T.length;$++){const oe=E[$];oe!==null&&(E[$]=null,T[$].disconnect(oe))}q=null,j=null,p.reset();for(const $ in h)delete h[$];e.setRenderTarget(b),m=null,d=null,f=null,r=null,_=null,qe.stop(),n.isPresenting=!1,e.setPixelRatio(C),e.setSize(A.width,A.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function($){s=$,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function($){a=$,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function($){l=$},this.getBaseLayer=function(){return d!==null?d:m},this.getBinding=function(){return f===null&&y&&(f=new XRWebGLBinding(r,t)),f},this.getFrame=function(){return g},this.getSession=function(){return r},this.setSession=async function($){if(r=$,r!==null){if(b=e.getRenderTarget(),r.addEventListener("select",Q),r.addEventListener("selectstart",Q),r.addEventListener("selectend",Q),r.addEventListener("squeeze",Q),r.addEventListener("squeezestart",Q),r.addEventListener("squeezeend",Q),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 xe=null,Le=null,Ae=null;w.depth&&(Ae=w.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,xe=w.stencil?ji:qi,Le=w.stencil?Yi:$n);const Oe={colorFormat:t.RGBA8,depthFormat:Ae,scaleFactor:s};f=this.getBinding(),d=f.createProjectionLayer(Oe),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),_=new Kn(d.textureWidth,d.textureHeight,{format:Jt,type:hn,depthTexture:new lc(d.textureWidth,d.textureHeight,Le,void 0,void 0,void 0,void 0,void 0,void 0,xe),stencilBuffer:w.stencil,colorSpace:e.outputColorSpace,samples:w.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const xe={antialias:w.antialias,alpha:!0,depth:w.depth,stencil:w.stencil,framebufferScaleFactor:s};m=new XRWebGLLayer(r,t,xe),r.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),_=new Kn(m.framebufferWidth,m.framebufferHeight,{format:Jt,type:hn,colorSpace:e.outputColorSpace,stencilBuffer:w.stencil,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}_.isXRRenderTarget=!0,this.setFoveation(c),l=null,o=await r.requestReferenceSpace(a),qe.setContext(r),qe.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return p.getDepthTexture()};function se($){for(let oe=0;oe<$.removed.length;oe++){const xe=$.removed[oe],Le=E.indexOf(xe);Le>=0&&(E[Le]=null,T[Le].disconnect(xe))}for(let oe=0;oe<$.added.length;oe++){const xe=$.added[oe];let Le=E.indexOf(xe);if(Le===-1){for(let Oe=0;Oe<T.length;Oe++)if(Oe>=E.length){E.push(xe),Le=Oe;break}else if(E[Oe]===null){E[Oe]=xe,Le=Oe;break}if(Le===-1)break}const Ae=T[Le];Ae&&Ae.connect(xe)}}const Z=new U,le=new U;function pe($,oe,xe){Z.setFromMatrixPosition(oe.matrixWorld),le.setFromMatrixPosition(xe.matrixWorld);const Le=Z.distanceTo(le),Ae=oe.projectionMatrix.elements,Oe=xe.projectionMatrix.elements,_t=Ae[14]/(Ae[10]-1),L=Ae[14]/(Ae[10]+1),et=(Ae[9]+1)/Ae[5],Fe=(Ae[9]-1)/Ae[5],Ce=(Ae[8]-1)/Ae[0],ye=(Oe[8]+1)/Oe[0],tt=_t*Ce,Se=_t*ye,Be=Le/(-Ce+ye),ft=Be*-Ce;if(oe.matrixWorld.decompose($.position,$.quaternion,$.scale),$.translateX(ft),$.translateZ(Be),$.matrixWorld.compose($.position,$.quaternion,$.scale),$.matrixWorldInverse.copy($.matrixWorld).invert(),Ae[10]===-1)$.projectionMatrix.copy(oe.projectionMatrix),$.projectionMatrixInverse.copy(oe.projectionMatrixInverse);else{const rt=_t+Be,R=L+Be,v=tt-ft,k=Se+(Le-ft),ne=et*L/R*rt,re=Fe*L/R*rt;$.projectionMatrix.makePerspective(v,k,ne,re,rt,R),$.projectionMatrixInverse.copy($.projectionMatrix).invert()}}function Me($,oe){oe===null?$.matrixWorld.copy($.matrix):$.matrixWorld.multiplyMatrices(oe.matrixWorld,$.matrix),$.matrixWorldInverse.copy($.matrixWorld).invert()}this.updateCamera=function($){if(r===null)return;let oe=$.near,xe=$.far;p.texture!==null&&(p.depthNear>0&&(oe=p.depthNear),p.depthFar>0&&(xe=p.depthFar)),z.near=x.near=M.near=oe,z.far=x.far=M.far=xe,(q!==z.near||j!==z.far)&&(r.updateRenderState({depthNear:z.near,depthFar:z.far}),q=z.near,j=z.far),z.layers.mask=$.layers.mask|6,M.layers.mask=z.layers.mask&3,x.layers.mask=z.layers.mask&5;const Le=$.parent,Ae=z.cameras;Me(z,Le);for(let Oe=0;Oe<Ae.length;Oe++)Me(Ae[Oe],Le);Ae.length===2?pe(z,M,x):z.projectionMatrix.copy(M.projectionMatrix),Ne($,z,Le)};function Ne($,oe,xe){xe===null?$.matrix.copy(oe.matrixWorld):($.matrix.copy(xe.matrixWorld),$.matrix.invert(),$.matrix.multiply(oe.matrixWorld)),$.matrix.decompose($.position,$.quaternion,$.scale),$.updateMatrixWorld(!0),$.projectionMatrix.copy(oe.projectionMatrix),$.projectionMatrixInverse.copy(oe.projectionMatrixInverse),$.isPerspectiveCamera&&($.fov=Co*2*Math.atan(1/$.projectionMatrix.elements[5]),$.zoom=1)}this.getCamera=function(){return z},this.getFoveation=function(){if(!(d===null&&m===null))return c},this.setFoveation=function($){c=$,d!==null&&(d.fixedFoveation=$),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=$)},this.hasDepthSensing=function(){return p.texture!==null},this.getDepthSensingMesh=function(){return p.getMesh(z)},this.getCameraTexture=function($){return h[$]};let fe=null;function Xe($,oe){if(u=oe.getViewerPose(l||o),g=oe,u!==null){const xe=u.views;m!==null&&(e.setRenderTargetFramebuffer(_,m.framebuffer),e.setRenderTarget(_));let Le=!1;xe.length!==z.cameras.length&&(z.cameras.length=0,Le=!0);for(let L=0;L<xe.length;L++){const et=xe[L];let Fe=null;if(m!==null)Fe=m.getViewport(et);else{const ye=f.getViewSubImage(d,et);Fe=ye.viewport,L===0&&(e.setRenderTargetTextures(_,ye.colorTexture,ye.depthStencilTexture),e.setRenderTarget(_))}let Ce=N[L];Ce===void 0&&(Ce=new Yt,Ce.layers.enable(L),Ce.viewport=new ut,N[L]=Ce),Ce.matrix.fromArray(et.transform.matrix),Ce.matrix.decompose(Ce.position,Ce.quaternion,Ce.scale),Ce.projectionMatrix.fromArray(et.projectionMatrix),Ce.projectionMatrixInverse.copy(Ce.projectionMatrix).invert(),Ce.viewport.set(Fe.x,Fe.y,Fe.width,Fe.height),L===0&&(z.matrix.copy(Ce.matrix),z.matrix.decompose(z.position,z.quaternion,z.scale)),Le===!0&&z.cameras.push(Ce)}const Ae=r.enabledFeatures;if(Ae&&Ae.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&y){f=n.getBinding();const L=f.getDepthInformation(xe[0]);L&&L.isValid&&L.texture&&p.init(L,r.renderState)}if(Ae&&Ae.includes("camera-access")&&y){e.state.unbindTexture(),f=n.getBinding();for(let L=0;L<xe.length;L++){const et=xe[L].camera;if(et){let Fe=h[et];Fe||(Fe=new cc,h[et]=Fe);const Ce=f.getCameraImage(et);Fe.sourceTexture=Ce}}}}for(let xe=0;xe<T.length;xe++){const Le=E[xe],Ae=T[xe];Le!==null&&Ae!==void 0&&Ae.update(Le,oe,l||o)}fe&&fe($,oe),oe.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:oe}),g=null}const qe=new dc;qe.setAnimationLoop(Xe),this.setAnimationLoop=function($){fe=$},this.dispose=function(){}}}const Hn=new tn,Vm=new ot;function Wm(i,e){function t(p,h){p.matrixAutoUpdate===!0&&p.updateMatrix(),h.value.copy(p.matrix)}function n(p,h){h.color.getRGB(p.fogColor.value,sc(i)),h.isFog?(p.fogNear.value=h.near,p.fogFar.value=h.far):h.isFogExp2&&(p.fogDensity.value=h.density)}function r(p,h,w,b,_){h.isMeshBasicMaterial||h.isMeshLambertMaterial?s(p,h):h.isMeshToonMaterial?(s(p,h),f(p,h)):h.isMeshPhongMaterial?(s(p,h),u(p,h)):h.isMeshStandardMaterial?(s(p,h),d(p,h),h.isMeshPhysicalMaterial&&m(p,h,_)):h.isMeshMatcapMaterial?(s(p,h),g(p,h)):h.isMeshDepthMaterial?s(p,h):h.isMeshDistanceMaterial?(s(p,h),y(p,h)):h.isMeshNormalMaterial?s(p,h):h.isLineBasicMaterial?(o(p,h),h.isLineDashedMaterial&&a(p,h)):h.isPointsMaterial?c(p,h,w,b):h.isSpriteMaterial?l(p,h):h.isShadowMaterial?(p.color.value.copy(h.color),p.opacity.value=h.opacity):h.isShaderMaterial&&(h.uniformsNeedUpdate=!1)}function s(p,h){p.opacity.value=h.opacity,h.color&&p.diffuse.value.copy(h.color),h.emissive&&p.emissive.value.copy(h.emissive).multiplyScalar(h.emissiveIntensity),h.map&&(p.map.value=h.map,t(h.map,p.mapTransform)),h.alphaMap&&(p.alphaMap.value=h.alphaMap,t(h.alphaMap,p.alphaMapTransform)),h.bumpMap&&(p.bumpMap.value=h.bumpMap,t(h.bumpMap,p.bumpMapTransform),p.bumpScale.value=h.bumpScale,h.side===Ut&&(p.bumpScale.value*=-1)),h.normalMap&&(p.normalMap.value=h.normalMap,t(h.normalMap,p.normalMapTransform),p.normalScale.value.copy(h.normalScale),h.side===Ut&&p.normalScale.value.negate()),h.displacementMap&&(p.displacementMap.value=h.displacementMap,t(h.displacementMap,p.displacementMapTransform),p.displacementScale.value=h.displacementScale,p.displacementBias.value=h.displacementBias),h.emissiveMap&&(p.emissiveMap.value=h.emissiveMap,t(h.emissiveMap,p.emissiveMapTransform)),h.specularMap&&(p.specularMap.value=h.specularMap,t(h.specularMap,p.specularMapTransform)),h.alphaTest>0&&(p.alphaTest.value=h.alphaTest);const w=e.get(h),b=w.envMap,_=w.envMapRotation;b&&(p.envMap.value=b,Hn.copy(_),Hn.x*=-1,Hn.y*=-1,Hn.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(Hn.y*=-1,Hn.z*=-1),p.envMapRotation.value.setFromMatrix4(Vm.makeRotationFromEuler(Hn)),p.flipEnvMap.value=b.isCubeTexture&&b.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=h.reflectivity,p.ior.value=h.ior,p.refractionRatio.value=h.refractionRatio),h.lightMap&&(p.lightMap.value=h.lightMap,p.lightMapIntensity.value=h.lightMapIntensity,t(h.lightMap,p.lightMapTransform)),h.aoMap&&(p.aoMap.value=h.aoMap,p.aoMapIntensity.value=h.aoMapIntensity,t(h.aoMap,p.aoMapTransform))}function o(p,h){p.diffuse.value.copy(h.color),p.opacity.value=h.opacity,h.map&&(p.map.value=h.map,t(h.map,p.mapTransform))}function a(p,h){p.dashSize.value=h.dashSize,p.totalSize.value=h.dashSize+h.gapSize,p.scale.value=h.scale}function c(p,h,w,b){p.diffuse.value.copy(h.color),p.opacity.value=h.opacity,p.size.value=h.size*w,p.scale.value=b*.5,h.map&&(p.map.value=h.map,t(h.map,p.uvTransform)),h.alphaMap&&(p.alphaMap.value=h.alphaMap,t(h.alphaMap,p.alphaMapTransform)),h.alphaTest>0&&(p.alphaTest.value=h.alphaTest)}function l(p,h){p.diffuse.value.copy(h.color),p.opacity.value=h.opacity,p.rotation.value=h.rotation,h.map&&(p.map.value=h.map,t(h.map,p.mapTransform)),h.alphaMap&&(p.alphaMap.value=h.alphaMap,t(h.alphaMap,p.alphaMapTransform)),h.alphaTest>0&&(p.alphaTest.value=h.alphaTest)}function u(p,h){p.specular.value.copy(h.specular),p.shininess.value=Math.max(h.shininess,1e-4)}function f(p,h){h.gradientMap&&(p.gradientMap.value=h.gradientMap)}function d(p,h){p.metalness.value=h.metalness,h.metalnessMap&&(p.metalnessMap.value=h.metalnessMap,t(h.metalnessMap,p.metalnessMapTransform)),p.roughness.value=h.roughness,h.roughnessMap&&(p.roughnessMap.value=h.roughnessMap,t(h.roughnessMap,p.roughnessMapTransform)),h.envMap&&(p.envMapIntensity.value=h.envMapIntensity)}function m(p,h,w){p.ior.value=h.ior,h.sheen>0&&(p.sheenColor.value.copy(h.sheenColor).multiplyScalar(h.sheen),p.sheenRoughness.value=h.sheenRoughness,h.sheenColorMap&&(p.sheenColorMap.value=h.sheenColorMap,t(h.sheenColorMap,p.sheenColorMapTransform)),h.sheenRoughnessMap&&(p.sheenRoughnessMap.value=h.sheenRoughnessMap,t(h.sheenRoughnessMap,p.sheenRoughnessMapTransform))),h.clearcoat>0&&(p.clearcoat.value=h.clearcoat,p.clearcoatRoughness.value=h.clearcoatRoughness,h.clearcoatMap&&(p.clearcoatMap.value=h.clearcoatMap,t(h.clearcoatMap,p.clearcoatMapTransform)),h.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=h.clearcoatRoughnessMap,t(h.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),h.clearcoatNormalMap&&(p.clearcoatNormalMap.value=h.clearcoatNormalMap,t(h.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(h.clearcoatNormalScale),h.side===Ut&&p.clearcoatNormalScale.value.negate())),h.dispersion>0&&(p.dispersion.value=h.dispersion),h.iridescence>0&&(p.iridescence.value=h.iridescence,p.iridescenceIOR.value=h.iridescenceIOR,p.iridescenceThicknessMinimum.value=h.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=h.iridescenceThicknessRange[1],h.iridescenceMap&&(p.iridescenceMap.value=h.iridescenceMap,t(h.iridescenceMap,p.iridescenceMapTransform)),h.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=h.iridescenceThicknessMap,t(h.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),h.transmission>0&&(p.transmission.value=h.transmission,p.transmissionSamplerMap.value=w.texture,p.transmissionSamplerSize.value.set(w.width,w.height),h.transmissionMap&&(p.transmissionMap.value=h.transmissionMap,t(h.transmissionMap,p.transmissionMapTransform)),p.thickness.value=h.thickness,h.thicknessMap&&(p.thicknessMap.value=h.thicknessMap,t(h.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=h.attenuationDistance,p.attenuationColor.value.copy(h.attenuationColor)),h.anisotropy>0&&(p.anisotropyVector.value.set(h.anisotropy*Math.cos(h.anisotropyRotation),h.anisotropy*Math.sin(h.anisotropyRotation)),h.anisotropyMap&&(p.anisotropyMap.value=h.anisotropyMap,t(h.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=h.specularIntensity,p.specularColor.value.copy(h.specularColor),h.specularColorMap&&(p.specularColorMap.value=h.specularColorMap,t(h.specularColorMap,p.specularColorMapTransform)),h.specularIntensityMap&&(p.specularIntensityMap.value=h.specularIntensityMap,t(h.specularIntensityMap,p.specularIntensityMapTransform))}function g(p,h){h.matcap&&(p.matcap.value=h.matcap)}function y(p,h){const w=e.get(h).light;p.referencePosition.value.setFromMatrixPosition(w.matrixWorld),p.nearDistance.value=w.shadow.camera.near,p.farDistance.value=w.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function Xm(i,e,t,n){let r={},s={},o=[];const a=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function c(w,b){const _=b.program;n.uniformBlockBinding(w,_)}function l(w,b){let _=r[w.id];_===void 0&&(g(w),_=u(w),r[w.id]=_,w.addEventListener("dispose",p));const T=b.program;n.updateUBOMapping(w,T);const E=e.render.frame;s[w.id]!==E&&(d(w),s[w.id]=E)}function u(w){const b=f();w.__bindingPointIndex=b;const _=i.createBuffer(),T=w.__size,E=w.usage;return i.bindBuffer(i.UNIFORM_BUFFER,_),i.bufferData(i.UNIFORM_BUFFER,T,E),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,b,_),_}function f(){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 b=r[w.id],_=w.uniforms,T=w.__cache;i.bindBuffer(i.UNIFORM_BUFFER,b);for(let E=0,A=_.length;E<A;E++){const C=Array.isArray(_[E])?_[E]:[_[E]];for(let M=0,x=C.length;M<x;M++){const N=C[M];if(m(N,E,M,T)===!0){const z=N.__offset,q=Array.isArray(N.value)?N.value:[N.value];let j=0;for(let Q=0;Q<q.length;Q++){const K=q[Q],se=y(K);typeof K=="number"||typeof K=="boolean"?(N.__data[0]=K,i.bufferSubData(i.UNIFORM_BUFFER,z+j,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,j),j+=se.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,z,N.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function m(w,b,_,T){const E=w.value,A=b+"_"+_;if(T[A]===void 0)return typeof E=="number"||typeof E=="boolean"?T[A]=E:T[A]=E.clone(),!0;{const C=T[A];if(typeof E=="number"||typeof E=="boolean"){if(C!==E)return T[A]=E,!0}else if(C.equals(E)===!1)return C.copy(E),!0}return!1}function g(w){const b=w.uniforms;let _=0;const T=16;for(let A=0,C=b.length;A<C;A++){const M=Array.isArray(b[A])?b[A]:[b[A]];for(let x=0,N=M.length;x<N;x++){const z=M[x],q=Array.isArray(z.value)?z.value:[z.value];for(let j=0,Q=q.length;j<Q;j++){const K=q[j],se=y(K),Z=_%T,le=Z%se.boundary,pe=Z+le;_+=le,pe!==0&&T-pe<se.storage&&(_+=T-pe),z.__data=new Float32Array(se.storage/Float32Array.BYTES_PER_ELEMENT),z.__offset=_,_+=se.storage}}}const E=_%T;return E>0&&(_+=T-E),w.__size=_,w.__cache={},this}function y(w){const b={boundary:0,storage:0};return typeof w=="number"||typeof w=="boolean"?(b.boundary=4,b.storage=4):w.isVector2?(b.boundary=8,b.storage=8):w.isVector3||w.isColor?(b.boundary=16,b.storage=12):w.isVector4?(b.boundary=16,b.storage=16):w.isMatrix3?(b.boundary=48,b.storage=48):w.isMatrix4?(b.boundary=64,b.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),b}function p(w){const b=w.target;b.removeEventListener("dispose",p);const _=o.indexOf(b.__bindingPointIndex);o.splice(_,1),i.deleteBuffer(r[b.id]),delete r[b.id],delete s[b.id]}function h(){for(const w in r)i.deleteBuffer(r[w]);o=[],r={},s={}}return{bind:c,update:l,dispose:h}}class Ym{constructor(e={}){const{canvas:t=yh(),context:n=null,depth:r=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:d=!1}=e;this.isWebGLRenderer=!0;let m;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=n.getContextAttributes().alpha}else m=o;const g=new Uint32Array(4),y=new Int32Array(4);let p=null,h=null;const w=[],b=[];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=Pn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const _=this;let T=!1;this._outputColorSpace=Xt;let E=0,A=0,C=null,M=-1,x=null;const N=new ut,z=new ut;let q=null;const j=new We(0);let Q=0,K=t.width,se=t.height,Z=1,le=null,pe=null;const Me=new ut(0,0,K,se),Ne=new ut(0,0,K,se);let fe=!1;const Xe=new ea;let qe=!1,$=!1;const oe=new ot,xe=new U,Le=new ut,Ae={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Oe=!1;function _t(){return C===null?Z:1}let L=n;function et(S,F){return t.getContext(S,F)}try{const S={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:u,failIfMajorPerformanceCaveat:f};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Xo}`),t.addEventListener("webglcontextlost",V,!1),t.addEventListener("webglcontextrestored",ee,!1),t.addEventListener("webglcontextcreationerror",G,!1),L===null){const F="webgl2";if(L=et(F,S),L===null)throw et(F)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(S){throw console.error("THREE.WebGLRenderer: "+S.message),S}let Fe,Ce,ye,tt,Se,Be,ft,rt,R,v,k,ne,re,te,we,ue,Ee,I,P,O,J,ie,ae,Te;function D(){Fe=new np(L),Fe.init(),ie=new Bm(L,Fe),Ce=new Zd(L,Fe,e,ie),ye=new Om(L,Fe),Ce.reversedDepthBuffer&&d&&ye.buffers.depth.setReversed(!0),tt=new sp(L),Se=new Em,Be=new Fm(L,Fe,ye,Se,Ce,ie,tt),ft=new Kd(_),rt=new tp(_),R=new hu(L),ae=new qd(L,R),v=new ip(L,R,tt,ae),k=new ap(L,v,R,tt),P=new op(L,Ce,Be),ue=new $d(Se),ne=new Sm(_,ft,rt,Fe,Ce,ae,ue),re=new Wm(_,Se),te=new bm,we=new Dm(Fe),I=new Yd(_,ft,rt,ye,k,m,c),Ee=new Um(_,k,Ce),Te=new Xm(L,tt,Ce,ye),O=new jd(L,Fe,tt),J=new rp(L,Fe,tt),tt.programs=ne.programs,_.capabilities=Ce,_.extensions=Fe,_.properties=Se,_.renderLists=te,_.shadowMap=Ee,_.state=ye,_.info=tt}D();const H=new Gm(_,L);this.xr=H,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){const S=Fe.get("WEBGL_lose_context");S&&S.loseContext()},this.forceContextRestore=function(){const S=Fe.get("WEBGL_lose_context");S&&S.restoreContext()},this.getPixelRatio=function(){return Z},this.setPixelRatio=function(S){S!==void 0&&(Z=S,this.setSize(K,se,!1))},this.getSize=function(S){return S.set(K,se)},this.setSize=function(S,F,X=!0){if(H.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}K=S,se=F,t.width=Math.floor(S*Z),t.height=Math.floor(F*Z),X===!0&&(t.style.width=S+"px",t.style.height=F+"px"),this.setViewport(0,0,S,F)},this.getDrawingBufferSize=function(S){return S.set(K*Z,se*Z).floor()},this.setDrawingBufferSize=function(S,F,X){K=S,se=F,Z=X,t.width=Math.floor(S*X),t.height=Math.floor(F*X),this.setViewport(0,0,S,F)},this.getCurrentViewport=function(S){return S.copy(N)},this.getViewport=function(S){return S.copy(Me)},this.setViewport=function(S,F,X,Y){S.isVector4?Me.set(S.x,S.y,S.z,S.w):Me.set(S,F,X,Y),ye.viewport(N.copy(Me).multiplyScalar(Z).round())},this.getScissor=function(S){return S.copy(Ne)},this.setScissor=function(S,F,X,Y){S.isVector4?Ne.set(S.x,S.y,S.z,S.w):Ne.set(S,F,X,Y),ye.scissor(z.copy(Ne).multiplyScalar(Z).round())},this.getScissorTest=function(){return fe},this.setScissorTest=function(S){ye.setScissorTest(fe=S)},this.setOpaqueSort=function(S){le=S},this.setTransparentSort=function(S){pe=S},this.getClearColor=function(S){return S.copy(I.getClearColor())},this.setClearColor=function(){I.setClearColor(...arguments)},this.getClearAlpha=function(){return I.getClearAlpha()},this.setClearAlpha=function(){I.setClearAlpha(...arguments)},this.clear=function(S=!0,F=!0,X=!0){let Y=0;if(S){let B=!1;if(C!==null){const ce=C.texture.format;B=ce===Ko||ce===$o||ce===Zo}if(B){const ce=C.texture.type,me=ce===hn||ce===$n||ce===Xi||ce===Yi||ce===qo||ce===jo,be=I.getClearColor(),ve=I.getClearAlpha(),De=be.r,Ie=be.g,Re=be.b;me?(g[0]=De,g[1]=Ie,g[2]=Re,g[3]=ve,L.clearBufferuiv(L.COLOR,0,g)):(y[0]=De,y[1]=Ie,y[2]=Re,y[3]=ve,L.clearBufferiv(L.COLOR,0,y))}else Y|=L.COLOR_BUFFER_BIT}F&&(Y|=L.DEPTH_BUFFER_BIT),X&&(Y|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),L.clear(Y)},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",V,!1),t.removeEventListener("webglcontextrestored",ee,!1),t.removeEventListener("webglcontextcreationerror",G,!1),I.dispose(),te.dispose(),we.dispose(),Se.dispose(),ft.dispose(),rt.dispose(),k.dispose(),ae.dispose(),Te.dispose(),ne.dispose(),H.dispose(),H.removeEventListener("sessionstart",kt),H.removeEventListener("sessionend",fa),In.stop()};function V(S){S.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),T=!0}function ee(){console.log("THREE.WebGLRenderer: Context Restored."),T=!1;const S=tt.autoReset,F=Ee.enabled,X=Ee.autoUpdate,Y=Ee.needsUpdate,B=Ee.type;D(),tt.autoReset=S,Ee.enabled=F,Ee.autoUpdate=X,Ee.needsUpdate=Y,Ee.type=B}function G(S){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",S.statusMessage)}function W(S){const F=S.target;F.removeEventListener("dispose",W),he(F)}function he(S){ge(S),Se.remove(S)}function ge(S){const F=Se.get(S).programs;F!==void 0&&(F.forEach(function(X){ne.releaseProgram(X)}),S.isShaderMaterial&&ne.releaseShaderCache(S))}this.renderBufferDirect=function(S,F,X,Y,B,ce){F===null&&(F=Ae);const me=B.isMesh&&B.matrixWorld.determinant()<0,be=bc(S,F,X,Y,B);ye.setMaterial(Y,me);let ve=X.index,De=1;if(Y.wireframe===!0){if(ve=v.getWireframeAttribute(X),ve===void 0)return;De=2}const Ie=X.drawRange,Re=X.attributes.position;let Ve=Ie.start*De,Ke=(Ie.start+Ie.count)*De;ce!==null&&(Ve=Math.max(Ve,ce.start*De),Ke=Math.min(Ke,(ce.start+ce.count)*De)),ve!==null?(Ve=Math.max(Ve,0),Ke=Math.min(Ke,ve.count)):Re!=null&&(Ve=Math.max(Ve,0),Ke=Math.min(Ke,Re.count));const ht=Ke-Ve;if(ht<0||ht===1/0)return;ae.setup(B,Y,be,X,ve);let st,nt=O;if(ve!==null&&(st=R.get(ve),nt=J,nt.setIndex(st)),B.isMesh)Y.wireframe===!0?(ye.setLineWidth(Y.wireframeLinewidth*_t()),nt.setMode(L.LINES)):nt.setMode(L.TRIANGLES);else if(B.isLine){let Pe=Y.linewidth;Pe===void 0&&(Pe=1),ye.setLineWidth(Pe*_t()),B.isLineSegments?nt.setMode(L.LINES):B.isLineLoop?nt.setMode(L.LINE_LOOP):nt.setMode(L.LINE_STRIP)}else B.isPoints?nt.setMode(L.POINTS):B.isSprite&&nt.setMode(L.TRIANGLES);if(B.isBatchedMesh)if(B._multiDrawInstances!==null)Zi("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),nt.renderMultiDrawInstances(B._multiDrawStarts,B._multiDrawCounts,B._multiDrawCount,B._multiDrawInstances);else if(Fe.get("WEBGL_multi_draw"))nt.renderMultiDraw(B._multiDrawStarts,B._multiDrawCounts,B._multiDrawCount);else{const Pe=B._multiDrawStarts,lt=B._multiDrawCounts,je=B._multiDrawCount,Ot=ve?R.get(ve).bytesPerElement:1,ei=Se.get(Y).currentProgram.getUniforms();for(let Ft=0;Ft<je;Ft++)ei.setValue(L,"_gl_DrawID",Ft),nt.render(Pe[Ft]/Ot,lt[Ft])}else if(B.isInstancedMesh)nt.renderInstances(Ve,ht,B.count);else if(X.isInstancedBufferGeometry){const Pe=X._maxInstanceCount!==void 0?X._maxInstanceCount:1/0,lt=Math.min(X.instanceCount,Pe);nt.renderInstances(Ve,ht,lt)}else nt.render(Ve,ht)};function ke(S,F,X){S.transparent===!0&&S.side===on&&S.forceSinglePass===!1?(S.side=Ut,S.needsUpdate=!0,nr(S,F,X),S.side=Dn,S.needsUpdate=!0,nr(S,F,X),S.side=on):nr(S,F,X)}this.compile=function(S,F,X=null){X===null&&(X=S),h=we.get(X),h.init(F),b.push(h),X.traverseVisible(function(B){B.isLight&&B.layers.test(F.layers)&&(h.pushLight(B),B.castShadow&&h.pushShadow(B))}),S!==X&&S.traverseVisible(function(B){B.isLight&&B.layers.test(F.layers)&&(h.pushLight(B),B.castShadow&&h.pushShadow(B))}),h.setupLights();const Y=new Set;return S.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 me=0;me<ce.length;me++){const be=ce[me];ke(be,X,B),Y.add(be)}else ke(ce,X,B),Y.add(ce)}),h=b.pop(),Y},this.compileAsync=function(S,F,X=null){const Y=this.compile(S,F,X);return new Promise(B=>{function ce(){if(Y.forEach(function(me){Se.get(me).currentProgram.isReady()&&Y.delete(me)}),Y.size===0){B(S);return}setTimeout(ce,10)}Fe.get("KHR_parallel_shader_compile")!==null?ce():setTimeout(ce,10)})};let Ye=null;function Zt(S){Ye&&Ye(S)}function kt(){In.stop()}function fa(){In.start()}const In=new dc;In.setAnimationLoop(Zt),typeof self<"u"&&In.setContext(self),this.setAnimationLoop=function(S){Ye=S,H.setAnimationLoop(S),S===null?In.stop():In.start()},H.addEventListener("sessionstart",kt),H.addEventListener("sessionend",fa),this.render=function(S,F){if(F!==void 0&&F.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(T===!0)return;if(S.matrixWorldAutoUpdate===!0&&S.updateMatrixWorld(),F.parent===null&&F.matrixWorldAutoUpdate===!0&&F.updateMatrixWorld(),H.enabled===!0&&H.isPresenting===!0&&(H.cameraAutoUpdate===!0&&H.updateCamera(F),F=H.getCamera()),S.isScene===!0&&S.onBeforeRender(_,S,F,C),h=we.get(S,b.length),h.init(F),b.push(h),oe.multiplyMatrices(F.projectionMatrix,F.matrixWorldInverse),Xe.setFromProjectionMatrix(oe,ln,F.reversedDepth),$=this.localClippingEnabled,qe=ue.init(this.clippingPlanes,$),p=te.get(S,w.length),p.init(),w.push(p),H.enabled===!0&&H.isPresenting===!0){const ce=_.xr.getDepthSensingMesh();ce!==null&&is(ce,F,-1/0,_.sortObjects)}is(S,F,0,_.sortObjects),p.finish(),_.sortObjects===!0&&p.sort(le,pe),Oe=H.enabled===!1||H.isPresenting===!1||H.hasDepthSensing()===!1,Oe&&I.addToRenderList(p,S),this.info.render.frame++,qe===!0&&ue.beginShadows();const X=h.state.shadowsArray;Ee.render(X,S,F),qe===!0&&ue.endShadows(),this.info.autoReset===!0&&this.info.reset();const Y=p.opaque,B=p.transmissive;if(h.setupLights(),F.isArrayCamera){const ce=F.cameras;if(B.length>0)for(let me=0,be=ce.length;me<be;me++){const ve=ce[me];pa(Y,B,S,ve)}Oe&&I.render(S);for(let me=0,be=ce.length;me<be;me++){const ve=ce[me];da(p,S,ve,ve.viewport)}}else B.length>0&&pa(Y,B,S,F),Oe&&I.render(S),da(p,S,F);C!==null&&A===0&&(Be.updateMultisampleRenderTarget(C),Be.updateRenderTargetMipmap(C)),S.isScene===!0&&S.onAfterRender(_,S,F),ae.resetDefaultState(),M=-1,x=null,b.pop(),b.length>0?(h=b[b.length-1],qe===!0&&ue.setGlobalState(_.clippingPlanes,h.state.camera)):h=null,w.pop(),w.length>0?p=w[w.length-1]:p=null};function is(S,F,X,Y){if(S.visible===!1)return;if(S.layers.test(F.layers)){if(S.isGroup)X=S.renderOrder;else if(S.isLOD)S.autoUpdate===!0&&S.update(F);else if(S.isLight)h.pushLight(S),S.castShadow&&h.pushShadow(S);else if(S.isSprite){if(!S.frustumCulled||Xe.intersectsSprite(S)){Y&&Le.setFromMatrixPosition(S.matrixWorld).applyMatrix4(oe);const me=k.update(S),be=S.material;be.visible&&p.push(S,me,be,X,Le.z,null)}}else if((S.isMesh||S.isLine||S.isPoints)&&(!S.frustumCulled||Xe.intersectsObject(S))){const me=k.update(S),be=S.material;if(Y&&(S.boundingSphere!==void 0?(S.boundingSphere===null&&S.computeBoundingSphere(),Le.copy(S.boundingSphere.center)):(me.boundingSphere===null&&me.computeBoundingSphere(),Le.copy(me.boundingSphere.center)),Le.applyMatrix4(S.matrixWorld).applyMatrix4(oe)),Array.isArray(be)){const ve=me.groups;for(let De=0,Ie=ve.length;De<Ie;De++){const Re=ve[De],Ve=be[Re.materialIndex];Ve&&Ve.visible&&p.push(S,me,Ve,X,Le.z,Re)}}else be.visible&&p.push(S,me,be,X,Le.z,null)}}const ce=S.children;for(let me=0,be=ce.length;me<be;me++)is(ce[me],F,X,Y)}function da(S,F,X,Y){const B=S.opaque,ce=S.transmissive,me=S.transparent;h.setupLightsView(X),qe===!0&&ue.setGlobalState(_.clippingPlanes,X),Y&&ye.viewport(N.copy(Y)),B.length>0&&tr(B,F,X),ce.length>0&&tr(ce,F,X),me.length>0&&tr(me,F,X),ye.buffers.depth.setTest(!0),ye.buffers.depth.setMask(!0),ye.buffers.color.setMask(!0),ye.setPolygonOffset(!1)}function pa(S,F,X,Y){if((X.isScene===!0?X.overrideMaterial:null)!==null)return;h.state.transmissionRenderTarget[Y.id]===void 0&&(h.state.transmissionRenderTarget[Y.id]=new Kn(1,1,{generateMipmaps:!0,type:Fe.has("EXT_color_buffer_half_float")||Fe.has("EXT_color_buffer_float")?Ki:hn,minFilter:Zn,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ze.workingColorSpace}));const ce=h.state.transmissionRenderTarget[Y.id],me=Y.viewport||N;ce.setSize(me.z*_.transmissionResolutionScale,me.w*_.transmissionResolutionScale);const be=_.getRenderTarget(),ve=_.getActiveCubeFace(),De=_.getActiveMipmapLevel();_.setRenderTarget(ce),_.getClearColor(j),Q=_.getClearAlpha(),Q<1&&_.setClearColor(16777215,.5),_.clear(),Oe&&I.render(X);const Ie=_.toneMapping;_.toneMapping=Pn;const Re=Y.viewport;if(Y.viewport!==void 0&&(Y.viewport=void 0),h.setupLightsView(Y),qe===!0&&ue.setGlobalState(_.clippingPlanes,Y),tr(S,X,Y),Be.updateMultisampleRenderTarget(ce),Be.updateRenderTargetMipmap(ce),Fe.has("WEBGL_multisampled_render_to_texture")===!1){let Ve=!1;for(let Ke=0,ht=F.length;Ke<ht;Ke++){const st=F[Ke],nt=st.object,Pe=st.geometry,lt=st.material,je=st.group;if(lt.side===on&&nt.layers.test(Y.layers)){const Ot=lt.side;lt.side=Ut,lt.needsUpdate=!0,ma(nt,X,Y,Pe,lt,je),lt.side=Ot,lt.needsUpdate=!0,Ve=!0}}Ve===!0&&(Be.updateMultisampleRenderTarget(ce),Be.updateRenderTargetMipmap(ce))}_.setRenderTarget(be,ve,De),_.setClearColor(j,Q),Re!==void 0&&(Y.viewport=Re),_.toneMapping=Ie}function tr(S,F,X){const Y=F.isScene===!0?F.overrideMaterial:null;for(let B=0,ce=S.length;B<ce;B++){const me=S[B],be=me.object,ve=me.geometry,De=me.group;let Ie=me.material;Ie.allowOverride===!0&&Y!==null&&(Ie=Y),be.layers.test(X.layers)&&ma(be,F,X,ve,Ie,De)}}function ma(S,F,X,Y,B,ce){S.onBeforeRender(_,F,X,Y,B,ce),S.modelViewMatrix.multiplyMatrices(X.matrixWorldInverse,S.matrixWorld),S.normalMatrix.getNormalMatrix(S.modelViewMatrix),B.onBeforeRender(_,F,X,Y,S,ce),B.transparent===!0&&B.side===on&&B.forceSinglePass===!1?(B.side=Ut,B.needsUpdate=!0,_.renderBufferDirect(X,F,Y,B,S,ce),B.side=Dn,B.needsUpdate=!0,_.renderBufferDirect(X,F,Y,B,S,ce),B.side=on):_.renderBufferDirect(X,F,Y,B,S,ce),S.onAfterRender(_,F,X,Y,B,ce)}function nr(S,F,X){F.isScene!==!0&&(F=Ae);const Y=Se.get(S),B=h.state.lights,ce=h.state.shadowsArray,me=B.state.version,be=ne.getParameters(S,B.state,ce,F,X),ve=ne.getProgramCacheKey(be);let De=Y.programs;Y.environment=S.isMeshStandardMaterial?F.environment:null,Y.fog=F.fog,Y.envMap=(S.isMeshStandardMaterial?rt:ft).get(S.envMap||Y.environment),Y.envMapRotation=Y.environment!==null&&S.envMap===null?F.environmentRotation:S.envMapRotation,De===void 0&&(S.addEventListener("dispose",W),De=new Map,Y.programs=De);let Ie=De.get(ve);if(Ie!==void 0){if(Y.currentProgram===Ie&&Y.lightsStateVersion===me)return ga(S,be),Ie}else be.uniforms=ne.getUniforms(S),S.onBeforeCompile(be,_),Ie=ne.acquireProgram(be,ve),De.set(ve,Ie),Y.uniforms=be.uniforms;const Re=Y.uniforms;return(!S.isShaderMaterial&&!S.isRawShaderMaterial||S.clipping===!0)&&(Re.clippingPlanes=ue.uniform),ga(S,be),Y.needsLights=Ac(S),Y.lightsStateVersion=me,Y.needsLights&&(Re.ambientLightColor.value=B.state.ambient,Re.lightProbe.value=B.state.probe,Re.directionalLights.value=B.state.directional,Re.directionalLightShadows.value=B.state.directionalShadow,Re.spotLights.value=B.state.spot,Re.spotLightShadows.value=B.state.spotShadow,Re.rectAreaLights.value=B.state.rectArea,Re.ltc_1.value=B.state.rectAreaLTC1,Re.ltc_2.value=B.state.rectAreaLTC2,Re.pointLights.value=B.state.point,Re.pointLightShadows.value=B.state.pointShadow,Re.hemisphereLights.value=B.state.hemi,Re.directionalShadowMap.value=B.state.directionalShadowMap,Re.directionalShadowMatrix.value=B.state.directionalShadowMatrix,Re.spotShadowMap.value=B.state.spotShadowMap,Re.spotLightMatrix.value=B.state.spotLightMatrix,Re.spotLightMap.value=B.state.spotLightMap,Re.pointShadowMap.value=B.state.pointShadowMap,Re.pointShadowMatrix.value=B.state.pointShadowMatrix),Y.currentProgram=Ie,Y.uniformsList=null,Ie}function _a(S){if(S.uniformsList===null){const F=S.currentProgram.getUniforms();S.uniformsList=kr.seqWithValue(F.seq,S.uniforms)}return S.uniformsList}function ga(S,F){const X=Se.get(S);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 bc(S,F,X,Y,B){F.isScene!==!0&&(F=Ae),Be.resetTextureUnits();const ce=F.fog,me=Y.isMeshStandardMaterial?F.environment:null,be=C===null?_.outputColorSpace:C.isXRRenderTarget===!0?C.texture.colorSpace:bi,ve=(Y.isMeshStandardMaterial?rt:ft).get(Y.envMap||me),De=Y.vertexColors===!0&&!!X.attributes.color&&X.attributes.color.itemSize===4,Ie=!!X.attributes.tangent&&(!!Y.normalMap||Y.anisotropy>0),Re=!!X.morphAttributes.position,Ve=!!X.morphAttributes.normal,Ke=!!X.morphAttributes.color;let ht=Pn;Y.toneMapped&&(C===null||C.isXRRenderTarget===!0)&&(ht=_.toneMapping);const st=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,nt=st!==void 0?st.length:0,Pe=Se.get(Y),lt=h.state.lights;if(qe===!0&&($===!0||S!==x)){const At=S===x&&Y.id===M;ue.setState(Y,S,At)}let je=!1;Y.version===Pe.__version?(Pe.needsLights&&Pe.lightsStateVersion!==lt.state.version||Pe.outputColorSpace!==be||B.isBatchedMesh&&Pe.batching===!1||!B.isBatchedMesh&&Pe.batching===!0||B.isBatchedMesh&&Pe.batchingColor===!0&&B.colorTexture===null||B.isBatchedMesh&&Pe.batchingColor===!1&&B.colorTexture!==null||B.isInstancedMesh&&Pe.instancing===!1||!B.isInstancedMesh&&Pe.instancing===!0||B.isSkinnedMesh&&Pe.skinning===!1||!B.isSkinnedMesh&&Pe.skinning===!0||B.isInstancedMesh&&Pe.instancingColor===!0&&B.instanceColor===null||B.isInstancedMesh&&Pe.instancingColor===!1&&B.instanceColor!==null||B.isInstancedMesh&&Pe.instancingMorph===!0&&B.morphTexture===null||B.isInstancedMesh&&Pe.instancingMorph===!1&&B.morphTexture!==null||Pe.envMap!==ve||Y.fog===!0&&Pe.fog!==ce||Pe.numClippingPlanes!==void 0&&(Pe.numClippingPlanes!==ue.numPlanes||Pe.numIntersection!==ue.numIntersection)||Pe.vertexAlphas!==De||Pe.vertexTangents!==Ie||Pe.morphTargets!==Re||Pe.morphNormals!==Ve||Pe.morphColors!==Ke||Pe.toneMapping!==ht||Pe.morphTargetsCount!==nt)&&(je=!0):(je=!0,Pe.__version=Y.version);let Ot=Pe.currentProgram;je===!0&&(Ot=nr(Y,F,B));let ei=!1,Ft=!1,Pi=!1;const ct=Ot.getUniforms(),Gt=Pe.uniforms;if(ye.useProgram(Ot.program)&&(ei=!0,Ft=!0,Pi=!0),Y.id!==M&&(M=Y.id,Ft=!0),ei||x!==S){ye.buffers.depth.getReversed()&&S.reversedDepth!==!0&&(S._reversedDepth=!0,S.updateProjectionMatrix()),ct.setValue(L,"projectionMatrix",S.projectionMatrix),ct.setValue(L,"viewMatrix",S.matrixWorldInverse);const Pt=ct.map.cameraPosition;Pt!==void 0&&Pt.setValue(L,xe.setFromMatrixPosition(S.matrixWorld)),Ce.logarithmicDepthBuffer&&ct.setValue(L,"logDepthBufFC",2/(Math.log(S.far+1)/Math.LN2)),(Y.isMeshPhongMaterial||Y.isMeshToonMaterial||Y.isMeshLambertMaterial||Y.isMeshBasicMaterial||Y.isMeshStandardMaterial||Y.isShaderMaterial)&&ct.setValue(L,"isOrthographic",S.isOrthographicCamera===!0),x!==S&&(x=S,Ft=!0,Pi=!0)}if(B.isSkinnedMesh){ct.setOptional(L,B,"bindMatrix"),ct.setOptional(L,B,"bindMatrixInverse");const At=B.skeleton;At&&(At.boneTexture===null&&At.computeBoneTexture(),ct.setValue(L,"boneTexture",At.boneTexture,Be))}B.isBatchedMesh&&(ct.setOptional(L,B,"batchingTexture"),ct.setValue(L,"batchingTexture",B._matricesTexture,Be),ct.setOptional(L,B,"batchingIdTexture"),ct.setValue(L,"batchingIdTexture",B._indirectTexture,Be),ct.setOptional(L,B,"batchingColorTexture"),B._colorsTexture!==null&&ct.setValue(L,"batchingColorTexture",B._colorsTexture,Be));const Vt=X.morphAttributes;if((Vt.position!==void 0||Vt.normal!==void 0||Vt.color!==void 0)&&P.update(B,X,Ot),(Ft||Pe.receiveShadow!==B.receiveShadow)&&(Pe.receiveShadow=B.receiveShadow,ct.setValue(L,"receiveShadow",B.receiveShadow)),Y.isMeshGouraudMaterial&&Y.envMap!==null&&(Gt.envMap.value=ve,Gt.flipEnvMap.value=ve.isCubeTexture&&ve.isRenderTargetTexture===!1?-1:1),Y.isMeshStandardMaterial&&Y.envMap===null&&F.environment!==null&&(Gt.envMapIntensity.value=F.environmentIntensity),Ft&&(ct.setValue(L,"toneMappingExposure",_.toneMappingExposure),Pe.needsLights&&wc(Gt,Pi),ce&&Y.fog===!0&&re.refreshFogUniforms(Gt,ce),re.refreshMaterialUniforms(Gt,Y,Z,se,h.state.transmissionRenderTarget[S.id]),kr.upload(L,_a(Pe),Gt,Be)),Y.isShaderMaterial&&Y.uniformsNeedUpdate===!0&&(kr.upload(L,_a(Pe),Gt,Be),Y.uniformsNeedUpdate=!1),Y.isSpriteMaterial&&ct.setValue(L,"center",B.center),ct.setValue(L,"modelViewMatrix",B.modelViewMatrix),ct.setValue(L,"normalMatrix",B.normalMatrix),ct.setValue(L,"modelMatrix",B.matrixWorld),Y.isShaderMaterial||Y.isRawShaderMaterial){const At=Y.uniformsGroups;for(let Pt=0,rs=At.length;Pt<rs;Pt++){const Un=At[Pt];Te.update(Un,Ot),Te.bind(Un,Ot)}}return Ot}function wc(S,F){S.ambientLightColor.needsUpdate=F,S.lightProbe.needsUpdate=F,S.directionalLights.needsUpdate=F,S.directionalLightShadows.needsUpdate=F,S.pointLights.needsUpdate=F,S.pointLightShadows.needsUpdate=F,S.spotLights.needsUpdate=F,S.spotLightShadows.needsUpdate=F,S.rectAreaLights.needsUpdate=F,S.hemisphereLights.needsUpdate=F}function Ac(S){return S.isMeshLambertMaterial||S.isMeshToonMaterial||S.isMeshPhongMaterial||S.isMeshStandardMaterial||S.isShadowMaterial||S.isShaderMaterial&&S.lights===!0}this.getActiveCubeFace=function(){return E},this.getActiveMipmapLevel=function(){return A},this.getRenderTarget=function(){return C},this.setRenderTargetTextures=function(S,F,X){const Y=Se.get(S);Y.__autoAllocateDepthBuffer=S.resolveDepthBuffer===!1,Y.__autoAllocateDepthBuffer===!1&&(Y.__useRenderToTexture=!1),Se.get(S.texture).__webglTexture=F,Se.get(S.depthTexture).__webglTexture=Y.__autoAllocateDepthBuffer?void 0:X,Y.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(S,F){const X=Se.get(S);X.__webglFramebuffer=F,X.__useDefaultFramebuffer=F===void 0};const Rc=L.createFramebuffer();this.setRenderTarget=function(S,F=0,X=0){C=S,E=F,A=X;let Y=!0,B=null,ce=!1,me=!1;if(S){const ve=Se.get(S);if(ve.__useDefaultFramebuffer!==void 0)ye.bindFramebuffer(L.FRAMEBUFFER,null),Y=!1;else if(ve.__webglFramebuffer===void 0)Be.setupRenderTarget(S);else if(ve.__hasExternalTextures)Be.rebindTextures(S,Se.get(S.texture).__webglTexture,Se.get(S.depthTexture).__webglTexture);else if(S.depthBuffer){const Re=S.depthTexture;if(ve.__boundDepthTexture!==Re){if(Re!==null&&Se.has(Re)&&(S.width!==Re.image.width||S.height!==Re.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Be.setupDepthRenderbuffer(S)}}const De=S.texture;(De.isData3DTexture||De.isDataArrayTexture||De.isCompressedArrayTexture)&&(me=!0);const Ie=Se.get(S).__webglFramebuffer;S.isWebGLCubeRenderTarget?(Array.isArray(Ie[F])?B=Ie[F][X]:B=Ie[F],ce=!0):S.samples>0&&Be.useMultisampledRTT(S)===!1?B=Se.get(S).__webglMultisampledFramebuffer:Array.isArray(Ie)?B=Ie[X]:B=Ie,N.copy(S.viewport),z.copy(S.scissor),q=S.scissorTest}else N.copy(Me).multiplyScalar(Z).floor(),z.copy(Ne).multiplyScalar(Z).floor(),q=fe;if(X!==0&&(B=Rc),ye.bindFramebuffer(L.FRAMEBUFFER,B)&&Y&&ye.drawBuffers(S,B),ye.viewport(N),ye.scissor(z),ye.setScissorTest(q),ce){const ve=Se.get(S.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+F,ve.__webglTexture,X)}else if(me){const ve=F;for(let De=0;De<S.textures.length;De++){const Ie=Se.get(S.textures[De]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+De,Ie.__webglTexture,X,ve)}}else if(S!==null&&X!==0){const ve=Se.get(S.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,ve.__webglTexture,X)}M=-1},this.readRenderTargetPixels=function(S,F,X,Y,B,ce,me,be=0){if(!(S&&S.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ve=Se.get(S).__webglFramebuffer;if(S.isWebGLCubeRenderTarget&&me!==void 0&&(ve=ve[me]),ve){ye.bindFramebuffer(L.FRAMEBUFFER,ve);try{const De=S.textures[be],Ie=De.format,Re=De.type;if(!Ce.textureFormatReadable(Ie)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Ce.textureTypeReadable(Re)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}F>=0&&F<=S.width-Y&&X>=0&&X<=S.height-B&&(S.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+be),L.readPixels(F,X,Y,B,ie.convert(Ie),ie.convert(Re),ce))}finally{const De=C!==null?Se.get(C).__webglFramebuffer:null;ye.bindFramebuffer(L.FRAMEBUFFER,De)}}},this.readRenderTargetPixelsAsync=async function(S,F,X,Y,B,ce,me,be=0){if(!(S&&S.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ve=Se.get(S).__webglFramebuffer;if(S.isWebGLCubeRenderTarget&&me!==void 0&&(ve=ve[me]),ve)if(F>=0&&F<=S.width-Y&&X>=0&&X<=S.height-B){ye.bindFramebuffer(L.FRAMEBUFFER,ve);const De=S.textures[be],Ie=De.format,Re=De.type;if(!Ce.textureFormatReadable(Ie))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Ce.textureTypeReadable(Re))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ve=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,Ve),L.bufferData(L.PIXEL_PACK_BUFFER,ce.byteLength,L.STREAM_READ),S.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+be),L.readPixels(F,X,Y,B,ie.convert(Ie),ie.convert(Re),0);const Ke=C!==null?Se.get(C).__webglFramebuffer:null;ye.bindFramebuffer(L.FRAMEBUFFER,Ke);const ht=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await Sh(L,ht,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,Ve),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,ce),L.deleteBuffer(Ve),L.deleteSync(ht),ce}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(S,F=null,X=0){const Y=Math.pow(2,-X),B=Math.floor(S.image.width*Y),ce=Math.floor(S.image.height*Y),me=F!==null?F.x:0,be=F!==null?F.y:0;Be.setTexture2D(S,0),L.copyTexSubImage2D(L.TEXTURE_2D,X,0,0,me,be,B,ce),ye.unbindTexture()};const Cc=L.createFramebuffer(),Pc=L.createFramebuffer();this.copyTextureToTexture=function(S,F,X=null,Y=null,B=0,ce=null){ce===null&&(B!==0?(Zi("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),ce=B,B=0):ce=0);let me,be,ve,De,Ie,Re,Ve,Ke,ht;const st=S.isCompressedTexture?S.mipmaps[ce]:S.image;if(X!==null)me=X.max.x-X.min.x,be=X.max.y-X.min.y,ve=X.isBox3?X.max.z-X.min.z:1,De=X.min.x,Ie=X.min.y,Re=X.isBox3?X.min.z:0;else{const Vt=Math.pow(2,-B);me=Math.floor(st.width*Vt),be=Math.floor(st.height*Vt),S.isDataArrayTexture?ve=st.depth:S.isData3DTexture?ve=Math.floor(st.depth*Vt):ve=1,De=0,Ie=0,Re=0}Y!==null?(Ve=Y.x,Ke=Y.y,ht=Y.z):(Ve=0,Ke=0,ht=0);const nt=ie.convert(F.format),Pe=ie.convert(F.type);let lt;F.isData3DTexture?(Be.setTexture3D(F,0),lt=L.TEXTURE_3D):F.isDataArrayTexture||F.isCompressedArrayTexture?(Be.setTexture2DArray(F,0),lt=L.TEXTURE_2D_ARRAY):(Be.setTexture2D(F,0),lt=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),Ot=L.getParameter(L.UNPACK_IMAGE_HEIGHT),ei=L.getParameter(L.UNPACK_SKIP_PIXELS),Ft=L.getParameter(L.UNPACK_SKIP_ROWS),Pi=L.getParameter(L.UNPACK_SKIP_IMAGES);L.pixelStorei(L.UNPACK_ROW_LENGTH,st.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,st.height),L.pixelStorei(L.UNPACK_SKIP_PIXELS,De),L.pixelStorei(L.UNPACK_SKIP_ROWS,Ie),L.pixelStorei(L.UNPACK_SKIP_IMAGES,Re);const ct=S.isDataArrayTexture||S.isData3DTexture,Gt=F.isDataArrayTexture||F.isData3DTexture;if(S.isDepthTexture){const Vt=Se.get(S),At=Se.get(F),Pt=Se.get(Vt.__renderTarget),rs=Se.get(At.__renderTarget);ye.bindFramebuffer(L.READ_FRAMEBUFFER,Pt.__webglFramebuffer),ye.bindFramebuffer(L.DRAW_FRAMEBUFFER,rs.__webglFramebuffer);for(let Un=0;Un<ve;Un++)ct&&(L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Se.get(S).__webglTexture,B,Re+Un),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Se.get(F).__webglTexture,ce,ht+Un)),L.blitFramebuffer(De,Ie,me,be,Ve,Ke,me,be,L.DEPTH_BUFFER_BIT,L.NEAREST);ye.bindFramebuffer(L.READ_FRAMEBUFFER,null),ye.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(B!==0||S.isRenderTargetTexture||Se.has(S)){const Vt=Se.get(S),At=Se.get(F);ye.bindFramebuffer(L.READ_FRAMEBUFFER,Cc),ye.bindFramebuffer(L.DRAW_FRAMEBUFFER,Pc);for(let Pt=0;Pt<ve;Pt++)ct?L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Vt.__webglTexture,B,Re+Pt):L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,Vt.__webglTexture,B),Gt?L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,At.__webglTexture,ce,ht+Pt):L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,At.__webglTexture,ce),B!==0?L.blitFramebuffer(De,Ie,me,be,Ve,Ke,me,be,L.COLOR_BUFFER_BIT,L.NEAREST):Gt?L.copyTexSubImage3D(lt,ce,Ve,Ke,ht+Pt,De,Ie,me,be):L.copyTexSubImage2D(lt,ce,Ve,Ke,De,Ie,me,be);ye.bindFramebuffer(L.READ_FRAMEBUFFER,null),ye.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else Gt?S.isDataTexture||S.isData3DTexture?L.texSubImage3D(lt,ce,Ve,Ke,ht,me,be,ve,nt,Pe,st.data):F.isCompressedArrayTexture?L.compressedTexSubImage3D(lt,ce,Ve,Ke,ht,me,be,ve,nt,st.data):L.texSubImage3D(lt,ce,Ve,Ke,ht,me,be,ve,nt,Pe,st):S.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,ce,Ve,Ke,me,be,nt,Pe,st.data):S.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,ce,Ve,Ke,st.width,st.height,nt,st.data):L.texSubImage2D(L.TEXTURE_2D,ce,Ve,Ke,me,be,nt,Pe,st);L.pixelStorei(L.UNPACK_ROW_LENGTH,je),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Ot),L.pixelStorei(L.UNPACK_SKIP_PIXELS,ei),L.pixelStorei(L.UNPACK_SKIP_ROWS,Ft),L.pixelStorei(L.UNPACK_SKIP_IMAGES,Pi),ce===0&&F.generateMipmaps&&L.generateMipmap(lt),ye.unbindTexture()},this.initRenderTarget=function(S){Se.get(S).__webglFramebuffer===void 0&&Be.setupRenderTarget(S)},this.initTexture=function(S){S.isCubeTexture?Be.setTextureCube(S,0):S.isData3DTexture?Be.setTexture3D(S,0):S.isDataArrayTexture||S.isCompressedArrayTexture?Be.setTexture2DArray(S,0):Be.setTexture2D(S,0),ye.unbindTexture()},this.resetState=function(){E=0,A=0,C=null,ye.reset(),ae.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ln}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=Ze._getDrawingBufferColorSpace(e),t.unpackColorSpace=Ze._getUnpackColorSpace()}}class oa{scene;camera;renderer;canvas;meshes=[];constructor(e){this.canvas=e,this.scene=new qh,this.scene.background=new We(1710618),this.camera=new Yt(45,e.clientWidth/e.clientHeight,.1,1e3),this.camera.position.set(1,1,7),this.renderer=new Ym({canvas:e,antialias:!0}),this.renderer.setSize(e.clientWidth,e.clientHeight);const t=new ou(16777215,.5);this.scene.add(t);const n=new su(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(e){const t=new vt;t.setAttribute("position",new $e(e.position,3)),e.normal&&t.setAttribute("normal",new $e(e.normal,3)),e.uv&&t.setAttribute("uv",new $e(e.uv,2));const n=new Jh({color:12566463,metalness:0,roughness:.6}),r=new _e(t,n);return this.scene.add(r),this.meshes.push(r),r}addMesh(e){this.scene.add(e),this.meshes.push(e)}removeMesh(e){this.scene.remove(e),this.meshes=this.meshes.filter(t=>t!==e)}getMeshes(){return this.meshes}destroy(){this.meshes&&(this.meshes.length=0,this.meshes=[]),this.scene=null,this.camera=null,this.renderer=null,this.canvas=null}}const wl={type:"change"},aa={type:"start"},vc={type:"end"},Cr=new Jr,Al=new An,qm=Math.cos(70*Mh.DEG2RAD),gt=new U,Lt=2*Math.PI,Je={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Bs=1e-6;class xc extends fc{constructor(e,t=null){super(e,t),this.state=Je.NONE,this.target=new U,this.cursor=new U,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:xi.ROTATE,MIDDLE:xi.DOLLY,RIGHT:xi.PAN},this.touches={ONE:_i.ROTATE,TWO:_i.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new U,this._lastQuaternion=new St,this._lastTargetPosition=new U,this._quat=new St().setFromUnitVectors(e.up,new U(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new el,this._sphericalDelta=new el,this._scale=1,this._panOffset=new U,this._rotateStart=new Ue,this._rotateEnd=new Ue,this._rotateDelta=new Ue,this._panStart=new Ue,this._panEnd=new Ue,this._panDelta=new Ue,this._dollyStart=new Ue,this._dollyEnd=new Ue,this._dollyDelta=new Ue,this._dollyDirection=new U,this._mouse=new Ue,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Zm.bind(this),this._onPointerDown=jm.bind(this),this._onPointerUp=$m.bind(this),this._onContextMenu=i_.bind(this),this._onMouseWheel=Jm.bind(this),this._onKeyDown=e_.bind(this),this._onTouchStart=t_.bind(this),this._onTouchMove=n_.bind(this),this._onMouseDown=Km.bind(this),this._onMouseMove=Qm.bind(this),this._interceptControlDown=r_.bind(this),this._interceptControlUp=s_.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(wl),this.update(),this.state=Je.NONE}update(e=null){const t=this.object.position;gt.copy(t).sub(this.target),gt.applyQuaternion(this._quat),this._spherical.setFromVector3(gt),this.autoRotate&&this.state===Je.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 n=this.minAzimuthAngle,r=this.maxAzimuthAngle;isFinite(n)&&isFinite(r)&&(n<-Math.PI?n+=Lt:n>Math.PI&&(n-=Lt),r<-Math.PI?r+=Lt:r>Math.PI&&(r-=Lt),n<=r?this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,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(gt.setFromSpherical(this._spherical),gt.applyQuaternion(this._quatInverse),t.copy(this.target).add(gt),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=gt.length();o=this._clampDistance(a*this._scale);const c=a-o;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),s=!!c}else if(this.object.isOrthographicCamera){const a=new U(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=c!==this.object.zoom;const l=new U(this._mouse.x,this._mouse.y,0);l.unproject(this.object),this.object.position.sub(l).add(a),this.object.updateMatrixWorld(),o=gt.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):(Cr.origin.copy(this.object.position),Cr.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Cr.direction))<qm?this.object.lookAt(this.target):(Al.setFromNormalAndCoplanarPoint(this.object.up,this.target),Cr.intersectPlane(Al,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)>Bs||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Bs||this._lastTargetPosition.distanceToSquared(this.target)>Bs?(this.dispatchEvent(wl),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Lt/60*this.autoRotateSpeed*e:Lt/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){gt.setFromMatrixColumn(t,0),gt.multiplyScalar(-e),this._panOffset.add(gt)}_panUp(e,t){this.screenSpacePanning===!0?gt.setFromMatrixColumn(t,1):(gt.setFromMatrixColumn(t,0),gt.crossVectors(this.object.up,gt)),gt.multiplyScalar(e),this._panOffset.add(gt)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const r=this.object.position;gt.copy(r).sub(this.target);let s=gt.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/n.clientHeight,this.object.matrix),this._panUp(2*t*s/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(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(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 n=this.domElement.getBoundingClientRect(),r=e-n.left,s=t-n.top,o=n.width,a=n.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(Lt*this._rotateDelta.x/t.clientHeight),this._rotateUp(Lt*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(Lt*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(-Lt*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(Lt*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(-Lt*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),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+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 n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),s=.5*(e.pageY+n.y);this._rotateEnd.set(r,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Lt*this._rotateDelta.x/t.clientHeight),this._rotateUp(Lt*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),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,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),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+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 Ue,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,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function jm(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 Zm(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function $m(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(vc),this.state=Je.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 Km(i){let e;switch(i.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 xi.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=Je.DOLLY;break;case xi.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Je.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Je.ROTATE}break;case xi.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Je.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Je.PAN}break;default:this.state=Je.NONE}this.state!==Je.NONE&&this.dispatchEvent(aa)}function Qm(i){switch(this.state){case Je.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case Je.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case Je.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function Jm(i){this.enabled===!1||this.enableZoom===!1||this.state!==Je.NONE||(i.preventDefault(),this.dispatchEvent(aa),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(vc))}function e_(i){this.enabled!==!1&&this._handleKeyDown(i)}function t_(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case _i.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=Je.TOUCH_ROTATE;break;case _i.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=Je.TOUCH_PAN;break;default:this.state=Je.NONE}break;case 2:switch(this.touches.TWO){case _i.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=Je.TOUCH_DOLLY_PAN;break;case _i.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=Je.TOUCH_DOLLY_ROTATE;break;default:this.state=Je.NONE}break;default:this.state=Je.NONE}this.state!==Je.NONE&&this.dispatchEvent(aa)}function n_(i){switch(this._trackPointer(i),this.state){case Je.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case Je.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case Je.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case Je.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=Je.NONE}}function i_(i){this.enabled!==!1&&i.preventDefault()}function r_(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function s_(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class o_ extends xc{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)}destroy(){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 a_ extends zi{constructor(e=5){super();const t=[{dir:new U(1,0,0),color:16711680},{dir:new U(-1,0,0),color:16711680},{dir:new U(0,1,0),color:65280},{dir:new U(0,-1,0),color:65280},{dir:new U(0,0,1),color:255},{dir:new U(0,0,-1),color:255}];for(const{dir:n,color:r}of t){const s=new vt().setFromPoints([new U(0,0,0),n.clone().multiplyScalar(e)]),o=new Ri({color:r}),a=new rn(s,o);this.add(a)}}}const kn=new uc,wt=new U,wn=new U,at=new St,Rl={X:new U(1,0,0),Y:new U(0,1,0),Z:new U(0,0,1)},zs={type:"change"},Cl={type:"mouseDown",mode:null},Pl={type:"mouseUp",mode:null},Dl={type:"objectChange"};class l_ extends fc{constructor(e,t=null){super(void 0,t);const n=new p_(this);this._root=n;const r=new m_;this._gizmo=r,n.add(r);const s=new __;this._plane=s,n.add(s);const o=this;function a(b,_){let T=_;Object.defineProperty(o,b,{get:function(){return T!==void 0?T:_},set:function(E){T!==E&&(T=E,s[b]=E,r[b]=E,o.dispatchEvent({type:b+"-changed",value:E}),o.dispatchEvent(zs))}}),o[b]=_,s[b]=_,r[b]=_}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 c=new U,l=new U,u=new St,f=new St,d=new U,m=new St,g=new U,y=new U,p=new U,h=0,w=new U;a("worldPosition",c),a("worldPositionStart",l),a("worldQuaternion",u),a("worldQuaternionStart",f),a("cameraPosition",d),a("cameraQuaternion",m),a("pointStart",g),a("pointEnd",y),a("rotationAxis",p),a("rotationAngle",h),a("eye",w),this._offset=new U,this._startNorm=new U,this._endNorm=new U,this._cameraScale=new U,this._parentPosition=new U,this._parentQuaternion=new St,this._parentQuaternionInv=new St,this._parentScale=new U,this._worldScaleStart=new U,this._worldQuaternionInv=new St,this._worldScale=new U,this._positionStart=new U,this._quaternionStart=new St,this._scaleStart=new U,this._getPointer=c_.bind(this),this._onPointerDown=u_.bind(this),this._onPointerHover=h_.bind(this),this._onPointerMove=f_.bind(this),this._onPointerUp=d_.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&&kn.setFromCamera(e,this.camera);const t=Hs(this._gizmo.picker[this.mode],kn);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&&kn.setFromCamera(e,this.camera);const t=Hs(this._plane,kn,!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,Cl.mode=this.mode,this.dispatchEvent(Cl)}}pointerMove(e){const t=this.axis,n=this.mode,r=this.object;let s=this.space;if(n==="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&&kn.setFromCamera(e,this.camera);const o=Hs(this._plane,kn,!0);if(o){if(this.pointEnd.copy(o.point).sub(this.worldPositionStart),n==="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(at.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(wt.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(wt.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(n==="scale"){if(t.search("XYZ")!==-1){let a=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(a*=-1),wn.set(a,a,a)}else wt.copy(this.pointStart),wn.copy(this.pointEnd),wt.applyQuaternion(this._worldQuaternionInv),wn.applyQuaternion(this._worldQuaternionInv),wn.divide(wt),t.search("X")===-1&&(wn.x=1),t.search("Y")===-1&&(wn.y=1),t.search("Z")===-1&&(wn.z=1);r.scale.copy(this._scaleStart).multiply(wn),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(n==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const a=20/this.worldPosition.distanceTo(wt.setFromMatrixPosition(this.camera.matrixWorld));let c=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(wt.copy(this.rotationAxis).cross(this.eye))*a):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(Rl[t]),wt.copy(Rl[t]),s==="local"&&wt.applyQuaternion(this.worldQuaternion),wt.cross(this.eye),wt.length()===0?c=!0:this.rotationAngle=this._offset.dot(wt.normalize())*a),(t==="E"||c)&&(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(at.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),r.quaternion.copy(at.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),r.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(zs),this.dispatchEvent(Dl)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(Pl.mode=this.mode,this.dispatchEvent(Pl)),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(zs),this.dispatchEvent(Dl),this.pointStart.copy(this.pointEnd))}getRaycaster(){return kn}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,n,r){const s=this._gizmo.materialLib;s.xAxis.color.set(e),s.yAxis.color.set(t),s.zAxis.color.set(n),s.active.color.set(r),s.xAxisTransparent.color.set(e),s.yAxisTransparent.color.set(t),s.zAxisTransparent.color.set(n),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(n),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(n),s.activeTransparent._color&&s.activeTransparent._color.set(r)}}function c_(i){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:i.button};{const e=this.domElement.getBoundingClientRect();return{x:(i.clientX-e.left)/e.width*2-1,y:-(i.clientY-e.top)/e.height*2+1,button:i.button}}}function h_(i){if(this.enabled)switch(i.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(i));break}}function u_(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 f_(i){this.enabled&&this.pointerMove(this._getPointer(i))}function d_(i){this.enabled&&(this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(i)))}function Hs(i,e,t){const n=e.intersectObject(i,!0);for(let r=0;r<n.length;r++)if(n[r].object.visible||t)return n[r];return!1}const Pr=new tn,it=new U(0,1,0),Ll=new U(0,0,0),Il=new ot,Dr=new St,Gr=new St,nn=new U,Ul=new ot,ki=new U(1,0,0),Vn=new U(0,1,0),Gi=new U(0,0,1),Lr=new U,Fi=new U,Bi=new U;class p_ extends dt{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 m_ extends dt{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new es({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new Ri({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),n=e.clone();n.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 c=e.clone();c.color.setHex(16711680),c.opacity=.5;const l=e.clone();l.color.setHex(65280),l.opacity=.5;const u=e.clone();u.color.setHex(255),u.opacity=.5;const f=e.clone();f.opacity=.25;const d=e.clone();d.color.setHex(16776960),d.opacity=.25;const m=e.clone();m.color.setHex(16776960);const g=e.clone();g.color.setHex(7895160),this.materialLib={xAxis:s,yAxis:o,zAxis:a,active:m,xAxisTransparent:c,yAxisTransparent:l,zAxisTransparent:u,activeTransparent:d};const y=new bt(0,.04,.1,12);y.translate(0,.05,0);const p=new mt(.08,.08,.08);p.translate(0,.04,0);const h=new vt;h.setAttribute("position",new $e([0,0,0,1,0,0],3));const w=new bt(.0075,.0075,.5,3);w.translate(0,.25,0);function b(Q,K){const se=new Xn(Q,.0075,3,64,K*Math.PI*2);return se.rotateY(Math.PI/2),se.rotateX(Math.PI/2),se}function _(){const Q=new vt;return Q.setAttribute("position",new $e([0,0,0,1,1,1],3)),Q}const T={X:[[new _e(y,s),[.5,0,0],[0,0,-Math.PI/2]],[new _e(y,s),[-.5,0,0],[0,0,Math.PI/2]],[new _e(w,s),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new _e(y,o),[0,.5,0]],[new _e(y,o),[0,-.5,0],[Math.PI,0,0]],[new _e(w,o)]],Z:[[new _e(y,a),[0,0,.5],[Math.PI/2,0,0]],[new _e(y,a),[0,0,-.5],[-Math.PI/2,0,0]],[new _e(w,a),null,[Math.PI/2,0,0]]],XYZ:[[new _e(new gi(.1,0),f),[0,0,0]]],XY:[[new _e(new mt(.15,.15,.01),u),[.15,.15,0]]],YZ:[[new _e(new mt(.15,.15,.01),c),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new _e(new mt(.15,.15,.01),l),[.15,0,.15],[-Math.PI/2,0,0]]]},E={X:[[new _e(new bt(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new _e(new bt(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new _e(new bt(.2,0,.6,4),n),[0,.3,0]],[new _e(new bt(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new _e(new bt(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new _e(new bt(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new _e(new gi(.2,0),n)]],XY:[[new _e(new mt(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new _e(new mt(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new _e(new mt(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]]},A={START:[[new _e(new gi(.01,2),r),null,null,null,"helper"]],END:[[new _e(new gi(.01,2),r),null,null,null,"helper"]],DELTA:[[new rn(_(),r),null,null,null,"helper"]],X:[[new rn(h,r),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new rn(h,r),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new rn(h,r),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},C={XYZE:[[new _e(b(.5,1),g),null,[0,Math.PI/2,0]]],X:[[new _e(b(.5,.5),s)]],Y:[[new _e(b(.5,.5),o),null,[0,0,-Math.PI/2]]],Z:[[new _e(b(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new _e(b(.75,1),d),null,[0,Math.PI/2,0]]]},M={AXIS:[[new rn(h,r),[-1e3,0,0],null,[1e6,1,1],"helper"]]},x={XYZE:[[new _e(new ia(.25,10,8),n)]],X:[[new _e(new Xn(.5,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new _e(new Xn(.5,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new _e(new Xn(.5,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new _e(new Xn(.75,.1,2,24),n)]]},N={X:[[new _e(p,s),[.5,0,0],[0,0,-Math.PI/2]],[new _e(w,s),[0,0,0],[0,0,-Math.PI/2]],[new _e(p,s),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new _e(p,o),[0,.5,0]],[new _e(w,o)],[new _e(p,o),[0,-.5,0],[0,0,Math.PI]]],Z:[[new _e(p,a),[0,0,.5],[Math.PI/2,0,0]],[new _e(w,a),[0,0,0],[Math.PI/2,0,0]],[new _e(p,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new _e(new mt(.15,.15,.01),u),[.15,.15,0]]],YZ:[[new _e(new mt(.15,.15,.01),c),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new _e(new mt(.15,.15,.01),l),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new _e(new mt(.1,.1,.1),f)]]},z={X:[[new _e(new bt(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new _e(new bt(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new _e(new bt(.2,0,.6,4),n),[0,.3,0]],[new _e(new bt(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new _e(new bt(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new _e(new bt(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new _e(new mt(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new _e(new mt(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new _e(new mt(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new _e(new mt(.2,.2,.2),n),[0,0,0]]]},q={X:[[new rn(h,r),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new rn(h,r),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new rn(h,r),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function j(Q){const K=new dt;for(const se in Q)for(let Z=Q[se].length;Z--;){const le=Q[se][Z][0].clone(),pe=Q[se][Z][1],Me=Q[se][Z][2],Ne=Q[se][Z][3],fe=Q[se][Z][4];le.name=se,le.tag=fe,pe&&le.position.set(pe[0],pe[1],pe[2]),Me&&le.rotation.set(Me[0],Me[1],Me[2]),Ne&&le.scale.set(Ne[0],Ne[1],Ne[2]),le.updateMatrix();const Xe=le.geometry.clone();Xe.applyMatrix4(le.matrix),le.geometry=Xe,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=j(T)),this.add(this.gizmo.rotate=j(C)),this.add(this.gizmo.scale=j(N)),this.add(this.picker.translate=j(E)),this.add(this.picker.rotate=j(x)),this.add(this.picker.scale=j(z)),this.add(this.helper.translate=j(A)),this.add(this.helper.rotate=j(M)),this.add(this.helper.scale=j(q)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const n=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:Gr;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"&&(at.setFromEuler(Pr.set(0,0,0)),o.quaternion.copy(n).multiply(at),Math.abs(it.copy(ki).applyQuaternion(n).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Y"&&(at.setFromEuler(Pr.set(0,0,Math.PI/2)),o.quaternion.copy(n).multiply(at),Math.abs(it.copy(Vn).applyQuaternion(n).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Z"&&(at.setFromEuler(Pr.set(0,Math.PI/2,0)),o.quaternion.copy(n).multiply(at),Math.abs(it.copy(Gi).applyQuaternion(n).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="XYZE"&&(at.setFromEuler(Pr.set(0,Math.PI/2,0)),it.copy(this.rotationAxis),o.quaternion.setFromRotationMatrix(Il.lookAt(Ll,it,Vn)),o.quaternion.multiply(at),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),wt.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),wt.applyQuaternion(this.worldQuaternionStart.clone().invert()),o.scale.copy(wt),o.visible=this.dragging):(o.quaternion.copy(n),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(n),this.mode==="translate"||this.mode==="scale"?(o.name==="X"&&Math.abs(it.copy(ki).applyQuaternion(n).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Y"&&Math.abs(it.copy(Vn).applyQuaternion(n).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Z"&&Math.abs(it.copy(Gi).applyQuaternion(n).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XY"&&Math.abs(it.copy(Gi).applyQuaternion(n).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="YZ"&&Math.abs(it.copy(ki).applyQuaternion(n).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XZ"&&Math.abs(it.copy(Vn).applyQuaternion(n).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1)):this.mode==="rotate"&&(Dr.copy(n),it.copy(this.eye).applyQuaternion(at.copy(n).invert()),o.name.search("E")!==-1&&o.quaternion.setFromRotationMatrix(Il.lookAt(this.eye,Ll,Vn)),o.name==="X"&&(at.setFromAxisAngle(ki,Math.atan2(-it.y,it.z)),at.multiplyQuaternions(Dr,at),o.quaternion.copy(at)),o.name==="Y"&&(at.setFromAxisAngle(Vn,Math.atan2(it.x,it.z)),at.multiplyQuaternions(Dr,at),o.quaternion.copy(at)),o.name==="Z"&&(at.setFromAxisAngle(Gi,Math.atan2(it.y,it.x)),at.multiplyQuaternions(Dr,at),o.quaternion.copy(at))),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(c){return o.name===c})&&(o.material.color.copy(this.materialLib.active.color),o.material.opacity=1))}super.updateMatrixWorld(e)}}class __ extends _e{constructor(){super(new er(1e5,1e5,2,2),new es({visible:!1,wireframe:!0,side:on,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"),Lr.copy(ki).applyQuaternion(t==="local"?this.worldQuaternion:Gr),Fi.copy(Vn).applyQuaternion(t==="local"?this.worldQuaternion:Gr),Bi.copy(Gi).applyQuaternion(t==="local"?this.worldQuaternion:Gr),it.copy(Fi),this.mode){case"translate":case"scale":switch(this.axis){case"X":it.copy(this.eye).cross(Lr),nn.copy(Lr).cross(it);break;case"Y":it.copy(this.eye).cross(Fi),nn.copy(Fi).cross(it);break;case"Z":it.copy(this.eye).cross(Bi),nn.copy(Bi).cross(it);break;case"XY":nn.copy(Bi);break;case"YZ":nn.copy(Lr);break;case"XZ":it.copy(Bi),nn.copy(Fi);break;case"XYZ":case"E":nn.set(0,0,0);break}break;case"rotate":default:nn.set(0,0,0)}nn.length()===0?this.quaternion.copy(this.cameraQuaternion):(Ul.lookAt(wt.set(0,0,0),nn,it),this.quaternion.setFromRotationMatrix(Ul)),super.updateMatrixWorld(e)}}var Lo;(function(i){i[i.Transient=0]="Transient",i[i.Singleton=1]="Singleton",i[i.ResolutionScoped=2]="ResolutionScoped",i[i.ContainerScoped=3]="ContainerScoped"})(Lo||(Lo={}));const It=Lo;/*! *****************************************************************************
3854
3854
  Copyright (c) Microsoft Corporation.
3855
3855
 
3856
3856
  Permission to use, copy, modify, and/or distribute this software for any
@@ -3863,7 +3863,7 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
3863
3863
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
3864
3864
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
3865
3865
  PERFORMANCE OF THIS SOFTWARE.
3866
- ***************************************************************************** */var ca=function(i,e){return ca=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var r in n)n.hasOwnProperty(r)&&(t[r]=n[r])},ca(i,e)};function La(i,e){ca(i,e);function t(){this.constructor=i}i.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Am(i,e,t,n){function r(s){return s instanceof t?s:new t(function(a){a(s)})}return new(t||(t=Promise))(function(s,a){function o(u){try{l(n.next(u))}catch(f){a(f)}}function c(u){try{l(n.throw(u))}catch(f){a(f)}}function l(u){u.done?s(u.value):r(u.value).then(o,c)}l((n=n.apply(i,[])).next())})}function wm(i,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,r,s,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(u){return c([l,u])}}function c(l){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,r&&(s=l[0]&2?r.return:l[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,l[1])).done)return s;switch(r=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,r=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){t.label=l[1];break}if(l[0]===6&&t.label<s[1]){t.label=s[1],s=l;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(l);break}s[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(i,t)}catch(u){l=[6,u],r=0}finally{n=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function dr(i){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&i[e],n=0;if(t)return t.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(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Rr(i,e){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var n=t.call(i),r,s=[],a;try{for(;(e===void 0||e-- >0)&&!(r=n.next()).done;)s.push(r.value)}catch(o){a={error:o}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return s}function Un(){for(var i=[],e=0;e<arguments.length;e++)i=i.concat(Rr(arguments[e]));return i}var ha="injectionTokens";function Rm(i){var e=Reflect.getMetadata("design:paramtypes",i)||[],t=Reflect.getOwnMetadata(ha,i)||{};return Object.keys(t).forEach(function(n){e[+n]=t[n]}),e}function Nl(i,e){return function(t,n,r){var s=Reflect.getOwnMetadata(ha,t)||{};s[r]=i,Reflect.defineMetadata(ha,s,t)}}function Fl(i){return!!i.useClass}function ua(i){return!!i.useFactory}var Ol=(function(){function i(e){this.wrap=e,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}return i.prototype.createProxy=function(e){var t=this,n={},r=!1,s,a=function(){return r||(s=e(t.wrap()),r=!0),s};return new Proxy(n,this.createHandler(a))},i.prototype.createHandler=function(e){var t={},n=function(r){t[r]=function(){for(var s=[],a=0;a<arguments.length;a++)s[a]=arguments[a];s[0]=e();var o=Reflect[r];return o.apply(void 0,Un(s))}};return this.reflectMethods.forEach(n),t},i})();function ii(i){return typeof i=="string"||typeof i=="symbol"}function Cm(i){return typeof i=="object"&&"token"in i&&"multiple"in i}function Zo(i){return typeof i=="object"&&"token"in i&&"transform"in i}function Pm(i){return typeof i=="function"||i instanceof Ol}function Sr(i){return!!i.useToken}function yr(i){return i.useValue!=null}function Dm(i){return Fl(i)||yr(i)||Sr(i)||ua(i)}var Ia=(function(){function i(){this._registryMap=new Map}return i.prototype.entries=function(){return this._registryMap.entries()},i.prototype.getAll=function(e){return this.ensure(e),this._registryMap.get(e)},i.prototype.get=function(e){this.ensure(e);var t=this._registryMap.get(e);return t[t.length-1]||null},i.prototype.set=function(e,t){this.ensure(e),this._registryMap.get(e).push(t)},i.prototype.setAll=function(e,t){this._registryMap.set(e,t)},i.prototype.has=function(e){return this.ensure(e),this._registryMap.get(e).length>0},i.prototype.clear=function(){this._registryMap.clear()},i.prototype.ensure=function(e){this._registryMap.has(e)||this._registryMap.set(e,[])},i})(),Lm=(function(i){La(e,i);function e(){return i!==null&&i.apply(this,arguments)||this}return e})(Ia),pr=(function(){function i(){this.scopedResolutions=new Map}return i})();function Im(i,e){if(i===null)return"at position #"+e;var t=i.split(",")[e].trim();return'"'+t+'" at position #'+e}function Um(i,e,t){return t===void 0&&(t=" "),Un([i],e.message.split(`
3866
+ ***************************************************************************** */var Io=function(i,e){return Io=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var r in n)n.hasOwnProperty(r)&&(t[r]=n[r])},Io(i,e)};function la(i,e){Io(i,e);function t(){this.constructor=i}i.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function g_(i,e,t,n){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{l(n.next(u))}catch(f){o(f)}}function c(u){try{l(n.throw(u))}catch(f){o(f)}}function l(u){u.done?s(u.value):r(u.value).then(a,c)}l((n=n.apply(i,[])).next())})}function v_(i,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,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(l){return function(u){return c([l,u])}}function c(l){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,r&&(s=l[0]&2?r.return:l[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,l[1])).done)return s;switch(r=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,r=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){t.label=l[1];break}if(l[0]===6&&t.label<s[1]){t.label=s[1],s=l;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(l);break}s[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(i,t)}catch(u){l=[6,u],r=0}finally{n=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function Ir(i){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&i[e],n=0;if(t)return t.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(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function $r(i,e){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var n=t.call(i),r,s=[],o;try{for(;(e===void 0||e-- >0)&&!(r=n.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return s}function qn(){for(var i=[],e=0;e<arguments.length;e++)i=i.concat($r(arguments[e]));return i}var Uo="injectionTokens";function x_(i){var e=Reflect.getMetadata("design:paramtypes",i)||[],t=Reflect.getOwnMetadata(Uo,i)||{};return Object.keys(t).forEach(function(n){e[+n]=t[n]}),e}function Mc(i,e){return function(t,n,r){var s=Reflect.getOwnMetadata(Uo,t)||{};s[r]=i,Reflect.defineMetadata(Uo,s,t)}}function yc(i){return!!i.useClass}function No(i){return!!i.useFactory}var Sc=(function(){function i(e){this.wrap=e,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}return i.prototype.createProxy=function(e){var t=this,n={},r=!1,s,o=function(){return r||(s=e(t.wrap()),r=!0),s};return new Proxy(n,this.createHandler(o))},i.prototype.createHandler=function(e){var t={},n=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,qn(s))}};return this.reflectMethods.forEach(n),t},i})();function mi(i){return typeof i=="string"||typeof i=="symbol"}function M_(i){return typeof i=="object"&&"token"in i&&"multiple"in i}function Nl(i){return typeof i=="object"&&"token"in i&&"transform"in i}function y_(i){return typeof i=="function"||i instanceof Sc}function Vr(i){return!!i.useToken}function Wr(i){return i.useValue!=null}function S_(i){return yc(i)||Wr(i)||Vr(i)||No(i)}var ca=(function(){function i(){this._registryMap=new Map}return i.prototype.entries=function(){return this._registryMap.entries()},i.prototype.getAll=function(e){return this.ensure(e),this._registryMap.get(e)},i.prototype.get=function(e){this.ensure(e);var t=this._registryMap.get(e);return t[t.length-1]||null},i.prototype.set=function(e,t){this.ensure(e),this._registryMap.get(e).push(t)},i.prototype.setAll=function(e,t){this._registryMap.set(e,t)},i.prototype.has=function(e){return this.ensure(e),this._registryMap.get(e).length>0},i.prototype.clear=function(){this._registryMap.clear()},i.prototype.ensure=function(e){this._registryMap.has(e)||this._registryMap.set(e,[])},i})(),E_=(function(i){la(e,i);function e(){return i!==null&&i.apply(this,arguments)||this}return e})(ca),Ur=(function(){function i(){this.scopedResolutions=new Map}return i})();function T_(i,e){if(i===null)return"at position #"+e;var t=i.split(",")[e].trim();return'"'+t+'" at position #'+e}function b_(i,e,t){return t===void 0&&(t=" "),qn([i],e.message.split(`
3867
3867
  `).map(function(n){return t+n})).join(`
3868
- `)}function Nm(i,e,t){var n=Rr(i.toString().match(/constructor\(([\w, ]+)\)/)||[],2),r=n[1],s=r===void 0?null:r,a=Im(s,e);return Um("Cannot inject the dependency "+a+' of "'+i.name+'" constructor. Reason:',t)}function Fm(i){if(typeof i.dispose!="function")return!1;var e=i.dispose;return!(e.length>0)}var Om=(function(i){La(e,i);function e(){return i!==null&&i.apply(this,arguments)||this}return e})(Ia),Bm=(function(i){La(e,i);function e(){return i!==null&&i.apply(this,arguments)||this}return e})(Ia),zm=(function(){function i(){this.preResolution=new Om,this.postResolution=new Bm}return i})(),Bl=new Map,Hm=(function(){function i(e){this.parent=e,this._registry=new Lm,this.interceptors=new zm,this.disposed=!1,this.disposables=new Set}return i.prototype.register=function(e,t,n){n===void 0&&(n={lifecycle:Tt.Transient}),this.ensureNotDisposed();var r;if(Dm(t)?r=t:r={useClass:t},Sr(r))for(var s=[e],a=r;a!=null;){var o=a.useToken;if(s.includes(o))throw new Error("Token registration cycle detected! "+Un(s,[o]).join(" -> "));s.push(o);var c=this._registry.get(o);c&&Sr(c.provider)?a=c.provider:a=null}if((n.lifecycle===Tt.Singleton||n.lifecycle==Tt.ContainerScoped||n.lifecycle==Tt.ResolutionScoped)&&(yr(r)||ua(r)))throw new Error('Cannot use lifecycle "'+Tt[n.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:r,options:n}),this},i.prototype.registerType=function(e,t){return this.ensureNotDisposed(),ii(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})},i.prototype.registerInstance=function(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})},i.prototype.registerSingleton=function(e,t){if(this.ensureNotDisposed(),ii(e)){if(ii(t))return this.register(e,{useToken:t},{lifecycle:Tt.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:Tt.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var n=e;return t&&!ii(t)&&(n=t),this.register(e,{useClass:n},{lifecycle:Tt.Singleton})},i.prototype.resolve=function(e,t,n){t===void 0&&(t=new pr),n===void 0&&(n=!1),this.ensureNotDisposed();var r=this.getRegistration(e);if(!r&&ii(e)){if(n)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(Pm(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.")},i.prototype.executePreResolutionInterceptor=function(e,t){var n,r;if(this.interceptors.preResolution.has(e)){var s=[];try{for(var a=dr(this.interceptors.preResolution.getAll(e)),o=a.next();!o.done;o=a.next()){var c=o.value;c.options.frequency!="Once"&&s.push(c),c.callback(e,t)}}catch(l){n={error:l}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}this.interceptors.preResolution.setAll(e,s)}},i.prototype.executePostResolutionInterceptor=function(e,t,n){var r,s;if(this.interceptors.postResolution.has(e)){var a=[];try{for(var o=dr(this.interceptors.postResolution.getAll(e)),c=o.next();!c.done;c=o.next()){var l=c.value;l.options.frequency!="Once"&&a.push(l),l.callback(e,t,n)}}catch(u){r={error:u}}finally{try{c&&!c.done&&(s=o.return)&&s.call(o)}finally{if(r)throw r.error}}this.interceptors.postResolution.setAll(e,a)}},i.prototype.resolveRegistration=function(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===Tt.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var n=e.options.lifecycle===Tt.Singleton,r=e.options.lifecycle===Tt.ContainerScoped,s=n||r,a;return yr(e.provider)?a=e.provider.useValue:Sr(e.provider)?a=s?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):Fl(e.provider)?a=s?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):ua(e.provider)?a=e.provider.useFactory(this):a=this.construct(e.provider,t),e.options.lifecycle===Tt.ResolutionScoped&&t.scopedResolutions.set(e,a),a},i.prototype.resolveAll=function(e,t,n){var r=this;t===void 0&&(t=new pr),n===void 0&&(n=!1),this.ensureNotDisposed();var s=this.getAllRegistrations(e);if(!s&&ii(e)){if(n)return[];throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"')}if(this.executePreResolutionInterceptor(e,"All"),s){var a=s.map(function(c){return r.resolveRegistration(c,t)});return this.executePostResolutionInterceptor(e,a,"All"),a}var o=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,o,"All"),o},i.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)},i.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},i.prototype.clearInstances=function(){var e,t;this.ensureNotDisposed();try{for(var n=dr(this._registry.entries()),r=n.next();!r.done;r=n.next()){var s=Rr(r.value,2),a=s[0],o=s[1];this._registry.setAll(a,o.filter(function(c){return!yr(c.provider)}).map(function(c){return c.instance=void 0,c}))}}catch(c){e={error:c}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},i.prototype.createChildContainer=function(){var e,t;this.ensureNotDisposed();var n=new i(this);try{for(var r=dr(this._registry.entries()),s=r.next();!s.done;s=r.next()){var a=Rr(s.value,2),o=a[0],c=a[1];c.some(function(l){var u=l.options;return u.lifecycle===Tt.ContainerScoped})&&n._registry.setAll(o,c.map(function(l){return l.options.lifecycle===Tt.ContainerScoped?{provider:l.provider,options:l.options}:l}))}}catch(l){e={error:l}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return n},i.prototype.beforeResolution=function(e,t,n){n===void 0&&(n={frequency:"Always"}),this.interceptors.preResolution.set(e,{callback:t,options:n})},i.prototype.afterResolution=function(e,t,n){n===void 0&&(n={frequency:"Always"}),this.interceptors.postResolution.set(e,{callback:t,options:n})},i.prototype.dispose=function(){return Am(this,void 0,void 0,function(){var e;return wm(this,function(t){switch(t.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach(function(n){var r=n.dispose();r&&e.push(r)}),[4,Promise.all(e)];case 1:return t.sent(),[2]}})})},i.prototype.getRegistration=function(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null},i.prototype.getAllRegistrations=function(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null},i.prototype.construct=function(e,t){var n=this;if(e instanceof Ol)return e.createProxy(function(s){return n.resolve(s,t)});var r=(function(){var s=Bl.get(e);if(!s||s.length===0){if(e.length===0)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var a=s.map(n.resolveParams(t,e));return new(e.bind.apply(e,Un([void 0],a)))})();return Fm(r)&&this.disposables.add(r),r},i.prototype.resolveParams=function(e,t){var n=this;return function(r,s){var a,o,c;try{return Cm(r)?Zo(r)?r.multiple?(a=n.resolve(r.transform)).transform.apply(a,Un([n.resolveAll(r.token,new pr,r.isOptional)],r.transformArgs)):(o=n.resolve(r.transform)).transform.apply(o,Un([n.resolve(r.token,e,r.isOptional)],r.transformArgs)):r.multiple?n.resolveAll(r.token,new pr,r.isOptional):n.resolve(r.token,e,r.isOptional):Zo(r)?(c=n.resolve(r.transform,e)).transform.apply(c,Un([n.resolve(r.token,e)],r.transformArgs)):n.resolve(r,e)}catch(l){throw new Error(Nm(t,s,l))}}},i.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},i})(),km=new Hm;function xn(i,e){var t={token:i,multiple:!1,isOptional:e};return Nl(t)}function yn(i){return function(e){Bl.set(e,Rm(e))}}function zl(i,e){var t={token:i,multiple:!0,isOptional:e};return Nl(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 mr={exports:{}},Jo;function Vm(){if(Jo)return mr.exports;Jo=1;var i=typeof Reflect=="object"?Reflect:null,e=i&&typeof i.apply=="function"?i.apply:function(E,T,A){return Function.prototype.apply.call(E,T,A)},t;i&&typeof i.ownKeys=="function"?t=i.ownKeys:Object.getOwnPropertySymbols?t=function(E){return Object.getOwnPropertyNames(E).concat(Object.getOwnPropertySymbols(E))}:t=function(E){return Object.getOwnPropertyNames(E)};function n(g){console&&console.warn&&console.warn(g)}var r=Number.isNaN||function(E){return E!==E};function s(){s.init.call(this)}mr.exports=s,mr.exports.once=h,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var a=10;function o(g){if(typeof g!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof g)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(g){if(typeof g!="number"||g<0||r(g))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+g+".");a=g}}),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(E){if(typeof E!="number"||E<0||r(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 c(g){return g._maxListeners===void 0?s.defaultMaxListeners:g._maxListeners}s.prototype.getMaxListeners=function(){return c(this)},s.prototype.emit=function(E){for(var T=[],A=1;A<arguments.length;A++)T.push(arguments[A]);var I=E==="error",y=this._events;if(y!==void 0)I=I&&y.error===void 0;else if(!I)return!1;if(I){var M;if(T.length>0&&(M=T[0]),M instanceof Error)throw M;var U=new Error("Unhandled error."+(M?" ("+M.message+")":""));throw U.context=M,U}var W=y[E];if(W===void 0)return!1;if(typeof W=="function")e(W,this,T);else for(var Z=W.length,te=v(W,Z),A=0;A<Z;++A)e(te[A],this,T);return!0};function l(g,E,T,A){var I,y,M;if(o(T),y=g._events,y===void 0?(y=g._events=Object.create(null),g._eventsCount=0):(y.newListener!==void 0&&(g.emit("newListener",E,T.listener?T.listener:T),y=g._events),M=y[E]),M===void 0)M=y[E]=T,++g._eventsCount;else if(typeof M=="function"?M=y[E]=A?[T,M]:[M,T]:A?M.unshift(T):M.push(T),I=c(g),I>0&&M.length>I&&!M.warned){M.warned=!0;var U=new Error("Possible EventEmitter memory leak detected. "+M.length+" "+String(E)+" listeners added. Use emitter.setMaxListeners() to increase limit");U.name="MaxListenersExceededWarning",U.emitter=g,U.type=E,U.count=M.length,n(U)}return g}s.prototype.addListener=function(E,T){return l(this,E,T,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(E,T){return l(this,E,T,!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 f(g,E,T){var A={fired:!1,wrapFn:void 0,target:g,type:E,listener:T},I=u.bind(A);return I.listener=T,A.wrapFn=I,I}s.prototype.once=function(E,T){return o(T),this.on(E,f(this,E,T)),this},s.prototype.prependOnceListener=function(E,T){return o(T),this.prependListener(E,f(this,E,T)),this},s.prototype.removeListener=function(E,T){var A,I,y,M,U;if(o(T),I=this._events,I===void 0)return this;if(A=I[E],A===void 0)return this;if(A===T||A.listener===T)--this._eventsCount===0?this._events=Object.create(null):(delete I[E],I.removeListener&&this.emit("removeListener",E,A.listener||T));else if(typeof A!="function"){for(y=-1,M=A.length-1;M>=0;M--)if(A[M]===T||A[M].listener===T){U=A[M].listener,y=M;break}if(y<0)return this;y===0?A.shift():S(A,y),A.length===1&&(I[E]=A[0]),I.removeListener!==void 0&&this.emit("removeListener",E,U||T)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(E){var T,A,I;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 y=Object.keys(A),M;for(I=0;I<y.length;++I)M=y[I],M!=="removeListener"&&this.removeAllListeners(M);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(T=A[E],typeof T=="function")this.removeListener(E,T);else if(T!==void 0)for(I=T.length-1;I>=0;I--)this.removeListener(E,T[I]);return this};function d(g,E,T){var A=g._events;if(A===void 0)return[];var I=A[E];return I===void 0?[]:typeof I=="function"?T?[I.listener||I]:[I]:T?p(I):v(I,I.length)}s.prototype.listeners=function(E){return d(this,E,!0)},s.prototype.rawListeners=function(E){return d(this,E,!1)},s.listenerCount=function(g,E){return typeof g.listenerCount=="function"?g.listenerCount(E):m.call(g,E)},s.prototype.listenerCount=m;function m(g){var E=this._events;if(E!==void 0){var T=E[g];if(typeof T=="function")return 1;if(T!==void 0)return T.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function v(g,E){for(var T=new Array(E),A=0;A<E;++A)T[A]=g[A];return T}function S(g,E){for(;E+1<g.length;E++)g[E]=g[E+1];g.pop()}function p(g){for(var E=new Array(g.length),T=0;T<E.length;++T)E[T]=g[T].listener||g[T];return E}function h(g,E){return new Promise(function(T,A){function I(M){g.removeListener(E,y),A(M)}function y(){typeof g.removeListener=="function"&&g.removeListener("error",I),T([].slice.call(arguments))}C(g,E,y,{once:!0}),E!=="error"&&L(g,I,{once:!0})})}function L(g,E,T){typeof g.on=="function"&&C(g,"error",E,T)}function C(g,E,T,A){if(typeof g.on=="function")A.once?g.once(E,T):g.on(E,T);else if(typeof g.addEventListener=="function")g.addEventListener(E,function I(y){A.once&&g.removeEventListener(E,I),T(y)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof g)}return mr.exports}var Gm=Vm(),Wm=Object.getOwnPropertyDescriptor,Xm=(i,e,t,n)=>{for(var r=n>1?void 0:n?Wm(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=a(r)||r);return r};exports.EventBus=class{_emitter;constructor(){this._emitter=new Gm.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=Xm([yn()],exports.EventBus);var On=(i=>(i.SelectHover="select.hover",i.SelectClick="select.click",i))(On||{}),qm=Object.getOwnPropertyDescriptor,Ym=(i,e,t,n)=>{for(var r=n>1?void 0:n?qm(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=a(r)||r);return r},Qo=(i,e)=>(t,n)=>e(t,n,i);exports.EditorRenderer=class extends Pa{constructor(e,t){super(e),this._canvas=e,this._bus=t,console.log("renderer");const n=new bh(10,10);n.position.y=-.001,this.scene.add(n);const r=new bm(6);this.scene.add(r),this._orbit=new Tm(this.camera,this.renderer.domElement),this._orbit.enableDamping=!0,this._orbit.dampingFactor=.05,this._raycaster=new Th,this._mouse=new Fe,this.scene.add(new vh(16777215,4473924,.6))}_orbit;_raycaster;_mouse;_isEventListenersAdded=!1;_lastHovered=null;update(){this._orbit.update()}addFigure(e){const t=super.addFigure(e),n=new dh(t.geometry),r=new wa(n,new Oi({color:8947848,linewidth:1}));return t.add(r),this._isEventListenersAdded||this.initMouseListeners(),t}initMouseListeners(){document.addEventListener("mousemove",this._handleMouseMove,!1),document.addEventListener("click",this._handleMouseClick,!1),this._isEventListenersAdded=!0}_handleMouseMove=e=>{this._processRaycastEvent(e,On.SelectHover,!0)};_handleMouseClick=e=>{this._processRaycastEvent(e,On.SelectClick,!1)};_processRaycastEvent(e,t,n){if(this._orbit.isInteracting)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 a=this._raycaster.intersectObjects(this.meshes,!1)[0]?.object??null;n?a!==this._lastHovered&&(this.meshes.forEach(o=>o.userData.isHit=!1),a&&(a.userData.isHit=!0),this._lastHovered=a,this._bus.emit(t,a?{mesh:a}:null),console.log("[hover]:",a?"hit":"cleared",a?.name)):(this._bus.emit(t,a?{mesh:a}:null),console.log("[click]:",a?"hit":"cleared",a?.name))}};exports.EditorRenderer=Ym([yn(),Qo(0,xn("Canvas")),Qo(1,xn("EventBus"))],exports.EditorRenderer);class jm extends Pa{_orbit;constructor(e){super(e),this.camera.position.set(1,1,7),this.camera.lookAt(0,0,0),this._orbit=new Ul(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 Km{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 Hl=(i=>(i[i.Cube=0]="Cube",i[i.Sphere=1]="Sphere",i[i.Plane=2]="Plane",i[i.Cylinder=3]="Cylinder",i[i.Custom=4]="Custom",i))(Hl||{}),Ai=(i=>(i.Plane="plane",i.Wireframe="wireframe",i.Texture="texture",i))(Ai||{}),Ur=(i=>(i.Mesh="mesh",i.Face="face",i.Edge="edge",i.Vertex="vertex",i))(Ur||{});class $m{_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 n={type:Hl.Custom,position:this._positions,...this._normals.length>0&&{normal:this._normals},...this._uvs.length>0&&{uv:this._uvs}};return new Km(n)}processFaceLine(e){for(let t=1;t<e.length;t++){const n=e[t];if(!n)continue;const[r,s,a]=n.split("/"),o=r?parseInt(r,10):void 0,c=s?parseInt(s,10):void 0,l=a?parseInt(a,10):void 0;if(o!==void 0){const u=this._tmpPositions[o-1];u&&this._positions.push(...u)}if(c!==void 0){const u=this._tmpUVs[c-1];u&&this._uvs.push(...u)}if(l!==void 0){const u=this._tmpNormals[l-1];u&&this._normals.push(...u)}}}}var Zm=Object.getOwnPropertyDescriptor,Jm=(i,e,t,n)=>{for(var r=n>1?void 0:n?Zm(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=a(r)||r);return r},Qm=(i,e)=>(t,n)=>e(t,n,i);let fa=class{_currentMode=Ai.Plane;_handlers;constructor(i){console.log("displayManager"),this._handlers=new Map(i.map(e=>[e.mode,e]))}manage(i){i!==this._currentMode&&(this._handlers.get(this._currentMode)?.rollback(),i!==Ai.Plane&&this._handlers.get(i)?.handle(),this._currentMode=i)}destroy(){this._handlers&&this._handlers.clear(),this._currentMode=Ai.Plane}};fa=Jm([yn(),Qm(0,zl("IDisplayHandler"))],fa);var Li=(i=>(i.Hover="hover",i.Click="click",i))(Li||{}),e_=Object.getOwnPropertyDescriptor,t_=(i,e,t,n)=>{for(var r=n>1?void 0:n?e_(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=a(r)||r);return r},el=(i,e)=>(t,n)=>e(t,n,i);let da=class{constructor(i,e){this._eventBus=i,this._handlers=new Map(e.map(t=>[t.mode,t])),this._eventBus.on(On.SelectHover,this._onHover),this._eventBus.on(On.SelectClick,this._onClick)}_currentMode=Ur.Mesh;_handlers;manage(i){i!==this._currentMode&&(this._handlers.get(this._currentMode)?.rollback(),this._currentMode=i)}_onHover=i=>{this._handlers.get(this._currentMode)?.handle(i,Li.Hover)};_onClick=i=>{this._handlers.get(this._currentMode)?.handle(i,Li.Click)};destroy(){this._eventBus.off(On.SelectHover,this._onHover)}};da=t_([yn(),el(0,xn("EventBus")),el(1,zl("ISelectHandler"))],da);var n_=Object.getOwnPropertyDescriptor,i_=(i,e,t,n)=>{for(var r=n>1?void 0:n?n_(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=a(r)||r);return r},r_=(i,e)=>(t,n)=>e(t,n,i);let pa=class{mode=Ai.Wireframe;_wireframes=[];_api;constructor(i){this._api=i}handle(){const i=this._api.getMeshes();this._wireframes.length>0||(this._wireframes=i.map(e=>{const t=new ph(e.geometry),n=new Oi({color:65535,linewidth:1}),r=new wa(t,n);return r.position.copy(e.position),r.rotation.copy(e.rotation),r.scale.copy(e.scale),e.add(r),r}),i.forEach(e=>{const t=e.material;t.visible=!1}))}rollback(){const i=this._api.getMeshes();for(const e of i){const t=this._wireframes.find(r=>r.parent===e);t&&(e.remove(t),t.geometry.dispose(),t.material.dispose());const n=e.material;n.visible=!0}this._wireframes=[]}destroy(){for(const i of this._wireframes)i.geometry.dispose(),i.material.dispose();this._wireframes=[]}};pa=i_([yn(),r_(0,xn("RendererApi"))],pa);var s_=Object.getOwnPropertyDescriptor,a_=(i,e,t,n)=>{for(var r=n>1?void 0:n?s_(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=a(r)||r);return r};let ma=class{mode=Ur.Mesh;_hoveredMesh=null;_selectedMesh=null;_hoverColor=16776960;_selectColor=16755200;_defaultColor=2236962;constructor(){}handle(i,e){if(e===Li.Hover){if(!i){this._hoveredMesh&&this._hoveredMesh!==this._selectedMesh&&this._setEdgesColor(this._hoveredMesh,this._defaultColor),this._hoveredMesh=null,console.log("hover out");return}const{mesh:t}=i;this._hoveredMesh!==t&&(this._hoveredMesh&&this._hoveredMesh!==this._selectedMesh&&this._setEdgesColor(this._hoveredMesh,this._defaultColor),t!==this._selectedMesh&&this._setEdgesColor(t,this._hoverColor),this._hoveredMesh=t,console.log("hover in",t.name))}else if(e===Li.Click){if(!i){this._selectedMesh&&(this._setEdgesColor(this._selectedMesh,this._defaultColor),this._selectedMesh=null,console.log("click cleared"));return}const{mesh:t}=i;this._selectedMesh&&this._selectedMesh!==t&&this._setEdgesColor(this._selectedMesh,this._defaultColor),this._setEdgesColor(t,this._selectColor),this._selectedMesh=t}}rollback(){this._hoveredMesh&&this._setEdgesColor(this._hoveredMesh,this._defaultColor),this._selectedMesh&&this._setEdgesColor(this._selectedMesh,this._defaultColor),this._hoveredMesh=null,this._selectedMesh=null}destroy(){this.rollback()}_setEdgesColor(i,e){i.children.forEach(t=>{t.type==="LineSegments"&&t.material.color.setHex(e)})}};ma=a_([yn()],ma);var o_=Object.getOwnPropertyDescriptor,l_=(i,e,t,n)=>{for(var r=n>1?void 0:n?o_(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=a(r)||r);return r},c_=(i,e)=>(t,n)=>e(t,n,i);let _a=class{constructor(i){this._renderer=i}addMesh(i){this._renderer.addMesh(i)}addMeshes(i){for(const e of i)this._renderer.addMesh(e)}removeMesh(i){this._renderer.removeMesh(i)}removeMeshes(i){for(const e of i)this._renderer.removeMesh(e)}getMeshes(){return this._renderer.getMeshes()}};_a=l_([yn(),c_(0,xn("EditorRenderer"))],_a);var h_=Object.getOwnPropertyDescriptor,u_=(i,e,t,n)=>{for(var r=n>1?void 0:n?h_(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=a(r)||r);return r},gs=(i,e)=>(t,n)=>e(t,n,i);exports.EditorHub=class{constructor(e,t,n){this._displayManager=e,this._selectManager=t,this._renderer=n,this.setSelectMode(Ur.Mesh)}setDisplayMode(e){this._displayManager.manage(e)}setSelectMode(e){this._selectManager.manage(e)}resizeRenderer(){this._renderer.resize()}updateRenderer(){this._renderer.loop()}addFigure(e){this._renderer.addFigure(e)}destroy(){this._displayManager.destroy(),this._selectManager.destroy(),this._renderer.destroy()}};exports.EditorHub=u_([yn(),gs(0,xn("IDisplayManager")),gs(1,xn("ISelectManager")),gs(2,xn("EditorRenderer"))],exports.EditorHub);let tl=!1;const Gt=km.createChildContainer();function f_(i){return tl||(Gt.registerInstance("Canvas",i),Gt.registerSingleton("EventBus",exports.EventBus),Gt.registerSingleton("EditorRenderer",exports.EditorRenderer),Gt.registerSingleton("RendererApi",_a),Gt.registerSingleton("IDisplayHandler",pa),Gt.registerSingleton("ISelectHandler",ma),Gt.registerSingleton("IDisplayManager",fa),Gt.registerSingleton("ISelectManager",da),Gt.registerSingleton("EditorHub",exports.EditorHub),tl=!0),Gt}function d_(i){return f_(i).resolve("EditorHub")}exports.EventTopics=On;exports.ObjLoader=$m;exports.PreviewRenderer=jm;exports.Renderer=Pa;exports.createAppHub=d_;
3868
+ `)}function w_(i,e,t){var n=$r(i.toString().match(/constructor\(([\w, ]+)\)/)||[],2),r=n[1],s=r===void 0?null:r,o=T_(s,e);return b_("Cannot inject the dependency "+o+' of "'+i.name+'" constructor. Reason:',t)}function A_(i){if(typeof i.dispose!="function")return!1;var e=i.dispose;return!(e.length>0)}var R_=(function(i){la(e,i);function e(){return i!==null&&i.apply(this,arguments)||this}return e})(ca),C_=(function(i){la(e,i);function e(){return i!==null&&i.apply(this,arguments)||this}return e})(ca),P_=(function(){function i(){this.preResolution=new R_,this.postResolution=new C_}return i})(),Ec=new Map,D_=(function(){function i(e){this.parent=e,this._registry=new E_,this.interceptors=new P_,this.disposed=!1,this.disposables=new Set}return i.prototype.register=function(e,t,n){n===void 0&&(n={lifecycle:It.Transient}),this.ensureNotDisposed();var r;if(S_(t)?r=t:r={useClass:t},Vr(r))for(var s=[e],o=r;o!=null;){var a=o.useToken;if(s.includes(a))throw new Error("Token registration cycle detected! "+qn(s,[a]).join(" -> "));s.push(a);var c=this._registry.get(a);c&&Vr(c.provider)?o=c.provider:o=null}if((n.lifecycle===It.Singleton||n.lifecycle==It.ContainerScoped||n.lifecycle==It.ResolutionScoped)&&(Wr(r)||No(r)))throw new Error('Cannot use lifecycle "'+It[n.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:r,options:n}),this},i.prototype.registerType=function(e,t){return this.ensureNotDisposed(),mi(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})},i.prototype.registerInstance=function(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})},i.prototype.registerSingleton=function(e,t){if(this.ensureNotDisposed(),mi(e)){if(mi(t))return this.register(e,{useToken:t},{lifecycle:It.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:It.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var n=e;return t&&!mi(t)&&(n=t),this.register(e,{useClass:n},{lifecycle:It.Singleton})},i.prototype.resolve=function(e,t,n){t===void 0&&(t=new Ur),n===void 0&&(n=!1),this.ensureNotDisposed();var r=this.getRegistration(e);if(!r&&mi(e)){if(n)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(y_(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.")},i.prototype.executePreResolutionInterceptor=function(e,t){var n,r;if(this.interceptors.preResolution.has(e)){var s=[];try{for(var o=Ir(this.interceptors.preResolution.getAll(e)),a=o.next();!a.done;a=o.next()){var c=a.value;c.options.frequency!="Once"&&s.push(c),c.callback(e,t)}}catch(l){n={error:l}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}this.interceptors.preResolution.setAll(e,s)}},i.prototype.executePostResolutionInterceptor=function(e,t,n){var r,s;if(this.interceptors.postResolution.has(e)){var o=[];try{for(var a=Ir(this.interceptors.postResolution.getAll(e)),c=a.next();!c.done;c=a.next()){var l=c.value;l.options.frequency!="Once"&&o.push(l),l.callback(e,t,n)}}catch(u){r={error:u}}finally{try{c&&!c.done&&(s=a.return)&&s.call(a)}finally{if(r)throw r.error}}this.interceptors.postResolution.setAll(e,o)}},i.prototype.resolveRegistration=function(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===It.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var n=e.options.lifecycle===It.Singleton,r=e.options.lifecycle===It.ContainerScoped,s=n||r,o;return Wr(e.provider)?o=e.provider.useValue:Vr(e.provider)?o=s?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):yc(e.provider)?o=s?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):No(e.provider)?o=e.provider.useFactory(this):o=this.construct(e.provider,t),e.options.lifecycle===It.ResolutionScoped&&t.scopedResolutions.set(e,o),o},i.prototype.resolveAll=function(e,t,n){var r=this;t===void 0&&(t=new Ur),n===void 0&&(n=!1),this.ensureNotDisposed();var s=this.getAllRegistrations(e);if(!s&&mi(e)){if(n)return[];throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"')}if(this.executePreResolutionInterceptor(e,"All"),s){var o=s.map(function(c){return r.resolveRegistration(c,t)});return this.executePostResolutionInterceptor(e,o,"All"),o}var a=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,a,"All"),a},i.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)},i.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},i.prototype.clearInstances=function(){var e,t;this.ensureNotDisposed();try{for(var n=Ir(this._registry.entries()),r=n.next();!r.done;r=n.next()){var s=$r(r.value,2),o=s[0],a=s[1];this._registry.setAll(o,a.filter(function(c){return!Wr(c.provider)}).map(function(c){return c.instance=void 0,c}))}}catch(c){e={error:c}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},i.prototype.createChildContainer=function(){var e,t;this.ensureNotDisposed();var n=new i(this);try{for(var r=Ir(this._registry.entries()),s=r.next();!s.done;s=r.next()){var o=$r(s.value,2),a=o[0],c=o[1];c.some(function(l){var u=l.options;return u.lifecycle===It.ContainerScoped})&&n._registry.setAll(a,c.map(function(l){return l.options.lifecycle===It.ContainerScoped?{provider:l.provider,options:l.options}:l}))}}catch(l){e={error:l}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return n},i.prototype.beforeResolution=function(e,t,n){n===void 0&&(n={frequency:"Always"}),this.interceptors.preResolution.set(e,{callback:t,options:n})},i.prototype.afterResolution=function(e,t,n){n===void 0&&(n={frequency:"Always"}),this.interceptors.postResolution.set(e,{callback:t,options:n})},i.prototype.dispose=function(){return g_(this,void 0,void 0,function(){var e;return v_(this,function(t){switch(t.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach(function(n){var r=n.dispose();r&&e.push(r)}),[4,Promise.all(e)];case 1:return t.sent(),[2]}})})},i.prototype.getRegistration=function(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null},i.prototype.getAllRegistrations=function(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null},i.prototype.construct=function(e,t){var n=this;if(e instanceof Sc)return e.createProxy(function(s){return n.resolve(s,t)});var r=(function(){var s=Ec.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(n.resolveParams(t,e));return new(e.bind.apply(e,qn([void 0],o)))})();return A_(r)&&this.disposables.add(r),r},i.prototype.resolveParams=function(e,t){var n=this;return function(r,s){var o,a,c;try{return M_(r)?Nl(r)?r.multiple?(o=n.resolve(r.transform)).transform.apply(o,qn([n.resolveAll(r.token,new Ur,r.isOptional)],r.transformArgs)):(a=n.resolve(r.transform)).transform.apply(a,qn([n.resolve(r.token,e,r.isOptional)],r.transformArgs)):r.multiple?n.resolveAll(r.token,new Ur,r.isOptional):n.resolve(r.token,e,r.isOptional):Nl(r)?(c=n.resolve(r.transform,e)).transform.apply(c,qn([n.resolve(r.token,e)],r.transformArgs)):n.resolve(r,e)}catch(l){throw new Error(w_(t,s,l))}}},i.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},i})(),L_=new D_;function Ht(i,e){var t={token:i,multiple:!1,isOptional:e};return Mc(t)}function jt(i){return function(e){Ec.set(e,x_(e))}}function ha(i,e){var t={token:i,multiple:!0,isOptional:e};return Mc(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 Nr={exports:{}},Ol;function I_(){if(Ol)return Nr.exports;Ol=1;var i=typeof Reflect=="object"?Reflect:null,e=i&&typeof i.apply=="function"?i.apply:function(T,E,A){return Function.prototype.apply.call(T,E,A)},t;i&&typeof i.ownKeys=="function"?t=i.ownKeys:Object.getOwnPropertySymbols?t=function(T){return Object.getOwnPropertyNames(T).concat(Object.getOwnPropertySymbols(T))}:t=function(T){return Object.getOwnPropertyNames(T)};function n(_){console&&console.warn&&console.warn(_)}var r=Number.isNaN||function(T){return T!==T};function s(){s.init.call(this)}Nr.exports=s,Nr.exports.once=h,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(T){if(typeof T!="number"||T<0||r(T))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+T+".");return this._maxListeners=T,this};function c(_){return _._maxListeners===void 0?s.defaultMaxListeners:_._maxListeners}s.prototype.getMaxListeners=function(){return c(this)},s.prototype.emit=function(T){for(var E=[],A=1;A<arguments.length;A++)E.push(arguments[A]);var C=T==="error",M=this._events;if(M!==void 0)C=C&&M.error===void 0;else if(!C)return!1;if(C){var x;if(E.length>0&&(x=E[0]),x instanceof Error)throw x;var N=new Error("Unhandled error."+(x?" ("+x.message+")":""));throw N.context=x,N}var z=M[T];if(z===void 0)return!1;if(typeof z=="function")e(z,this,E);else for(var q=z.length,j=g(z,q),A=0;A<q;++A)e(j[A],this,E);return!0};function l(_,T,E,A){var C,M,x;if(a(E),M=_._events,M===void 0?(M=_._events=Object.create(null),_._eventsCount=0):(M.newListener!==void 0&&(_.emit("newListener",T,E.listener?E.listener:E),M=_._events),x=M[T]),x===void 0)x=M[T]=E,++_._eventsCount;else if(typeof x=="function"?x=M[T]=A?[E,x]:[x,E]:A?x.unshift(E):x.push(E),C=c(_),C>0&&x.length>C&&!x.warned){x.warned=!0;var N=new Error("Possible EventEmitter memory leak detected. "+x.length+" "+String(T)+" listeners added. Use emitter.setMaxListeners() to increase limit");N.name="MaxListenersExceededWarning",N.emitter=_,N.type=T,N.count=x.length,n(N)}return _}s.prototype.addListener=function(T,E){return l(this,T,E,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(T,E){return l(this,T,E,!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 f(_,T,E){var A={fired:!1,wrapFn:void 0,target:_,type:T,listener:E},C=u.bind(A);return C.listener=E,A.wrapFn=C,C}s.prototype.once=function(T,E){return a(E),this.on(T,f(this,T,E)),this},s.prototype.prependOnceListener=function(T,E){return a(E),this.prependListener(T,f(this,T,E)),this},s.prototype.removeListener=function(T,E){var A,C,M,x,N;if(a(E),C=this._events,C===void 0)return this;if(A=C[T],A===void 0)return this;if(A===E||A.listener===E)--this._eventsCount===0?this._events=Object.create(null):(delete C[T],C.removeListener&&this.emit("removeListener",T,A.listener||E));else if(typeof A!="function"){for(M=-1,x=A.length-1;x>=0;x--)if(A[x]===E||A[x].listener===E){N=A[x].listener,M=x;break}if(M<0)return this;M===0?A.shift():y(A,M),A.length===1&&(C[T]=A[0]),C.removeListener!==void 0&&this.emit("removeListener",T,N||E)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(T){var E,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[T]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete A[T]),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(E=A[T],typeof E=="function")this.removeListener(T,E);else if(E!==void 0)for(C=E.length-1;C>=0;C--)this.removeListener(T,E[C]);return this};function d(_,T,E){var A=_._events;if(A===void 0)return[];var C=A[T];return C===void 0?[]:typeof C=="function"?E?[C.listener||C]:[C]:E?p(C):g(C,C.length)}s.prototype.listeners=function(T){return d(this,T,!0)},s.prototype.rawListeners=function(T){return d(this,T,!1)},s.listenerCount=function(_,T){return typeof _.listenerCount=="function"?_.listenerCount(T):m.call(_,T)},s.prototype.listenerCount=m;function m(_){var T=this._events;if(T!==void 0){var E=T[_];if(typeof E=="function")return 1;if(E!==void 0)return E.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function g(_,T){for(var E=new Array(T),A=0;A<T;++A)E[A]=_[A];return E}function y(_,T){for(;T+1<_.length;T++)_[T]=_[T+1];_.pop()}function p(_){for(var T=new Array(_.length),E=0;E<T.length;++E)T[E]=_[E].listener||_[E];return T}function h(_,T){return new Promise(function(E,A){function C(x){_.removeListener(T,M),A(x)}function M(){typeof _.removeListener=="function"&&_.removeListener("error",C),E([].slice.call(arguments))}b(_,T,M,{once:!0}),T!=="error"&&w(_,C,{once:!0})})}function w(_,T,E){typeof _.on=="function"&&b(_,"error",T,E)}function b(_,T,E,A){if(typeof _.on=="function")A.once?_.once(T,E):_.on(T,E);else if(typeof _.addEventListener=="function")_.addEventListener(T,function C(M){A.once&&_.removeEventListener(T,C),E(M)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof _)}return Nr.exports}var U_=I_(),N_=Object.getOwnPropertyDescriptor,O_=(i,e,t,n)=>{for(var r=n>1?void 0:n?N_(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=o(r)||r);return r};exports.EventBus=class{_emitter;constructor(){this._emitter=new U_.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=O_([jt()],exports.EventBus);var vn=(i=>(i.SelectHover="select.hover",i.SelectClick="select.click",i.ToolSelect="tool.select",i))(vn||{});class F_{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 Tc=(i=>(i[i.Cube=0]="Cube",i[i.Sphere=1]="Sphere",i[i.Plane=2]="Plane",i[i.Cylinder=3]="Cylinder",i[i.Custom=4]="Custom",i))(Tc||{}),Wi=(i=>(i.Plane="plane",i.Wireframe="wireframe",i.Texture="texture",i))(Wi||{}),ns=(i=>(i.Mesh="mesh",i.Face="face",i.Edge="edge",i.Vertex="vertex",i))(ns||{}),Qn=(i=>(i.Translate="translate",i.Scale="scale",i.Rotate="rotate",i))(Qn||{}),B_=Object.getOwnPropertyDescriptor,z_=(i,e,t,n)=>{for(var r=n>1?void 0:n?B_(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=o(r)||r);return r},Fl=(i,e)=>(t,n)=>e(t,n,i);exports.EditorRenderer=class extends oa{constructor(e,t){super(e),this._canvas=e,this._bus=t;const n=new lu(10,10);n.position.y=-.001,this.scene.add(n);const r=new a_(6);this.scene.add(r),this._orbit=new o_(this.camera,this.renderer.domElement),this._orbit.enableDamping=!0,this._orbit.dampingFactor=.05,this._raycaster=new uc,this._mouse=new Ue,this.scene.add(new nu(16777215,4473924,.6)),this._transform=new l_(this.camera,this.renderer.domElement),this._transformHelper=this._transform.getHelper(),this.scene.add(this._transformHelper)}_orbit;_transform;_transformHelper;_raycaster;_mouse;_isEventListenersAdded=!1;_lastHovered=null;update(){this._orbit.update()}addFigure(e){const t=super.addFigure(e),n=new Kh(t.geometry),r=new ta(n,new Ri({color:8947848,linewidth:1}));return t.add(r),this._isEventListenersAdded||this._initMouseListeners(),t}setTransformControlsMode(e){this._transform.setMode(e)}attachTransformControls(e){this._transform.attach(e)}detachTransformControls(){this._transform.detach()}_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,vn.SelectHover,!0)};_handleMouseClick=e=>{this._processRaycastEvent(e,vn.SelectClick,!1)};_processRaycastEvent(e,t,n){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,!1)[0]?.object??null;n?o!==this._lastHovered&&(this.meshes.forEach(a=>a.userData.isHit=!1),o&&(o.userData.isHit=!0),this._lastHovered=o,this._bus.emit(t,o?{mesh:o}:null)):this._bus.emit(t,o?{mesh:o}:null)}};exports.EditorRenderer=z_([jt(),Fl(0,Ht("Canvas")),Fl(1,Ht("EventBus"))],exports.EditorRenderer);class H_ extends oa{_orbit;constructor(e){super(e),this.camera.position.set(1,1,7),this.camera.lookAt(0,0,0),this._orbit=new xc(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 k_{_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 n={type:Tc.Custom,position:this._positions,...this._normals.length>0&&{normal:this._normals},...this._uvs.length>0&&{uv:this._uvs}};return new F_(n)}processFaceLine(e){for(let t=1;t<e.length;t++){const n=e[t];if(!n)continue;const[r,s,o]=n.split("/"),a=r?parseInt(r,10):void 0,c=s?parseInt(s,10):void 0,l=o?parseInt(o,10):void 0;if(a!==void 0){const u=this._tmpPositions[a-1];u&&this._positions.push(...u)}if(c!==void 0){const u=this._tmpUVs[c-1];u&&this._uvs.push(...u)}if(l!==void 0){const u=this._tmpNormals[l-1];u&&this._normals.push(...u)}}}}var G_=Object.getOwnPropertyDescriptor,V_=(i,e,t,n)=>{for(var r=n>1?void 0:n?G_(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=o(r)||r);return r},W_=(i,e)=>(t,n)=>e(t,n,i);let Oo=class{_currentMode=Wi.Plane;_handlers;constructor(i){this._handlers=new Map(i.map(e=>[e.mode,e]))}manage(i){i!==this._currentMode&&(this._handlers.get(this._currentMode)?.rollback(),i!==Wi.Plane&&this._handlers.get(i)?.handle(),this._currentMode=i)}destroy(){this._handlers&&this._handlers.clear(),this._currentMode=Wi.Plane}};Oo=V_([jt(),W_(0,ha("IDisplayHandler"))],Oo);var $i=(i=>(i.Hover="hover",i.Click="click",i))($i||{}),X_=Object.getOwnPropertyDescriptor,Y_=(i,e,t,n)=>{for(var r=n>1?void 0:n?X_(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=o(r)||r);return r},Bl=(i,e)=>(t,n)=>e(t,n,i);let Fo=class{constructor(i,e){this._eventBus=i,this._handlers=new Map(e.map(t=>[t.mode,t])),this._eventBus.on(vn.SelectHover,this._onHover),this._eventBus.on(vn.SelectClick,this._onClick)}_currentMode=ns.Mesh;_handlers;manage(i){i!==this._currentMode&&(this._handlers.get(this._currentMode)?.rollback(),this._currentMode=i)}_onHover=i=>{this._handlers.get(this._currentMode)?.handle(i,$i.Hover)};_onClick=i=>{const e=i?.mesh??null;this._eventBus.emit(vn.ToolSelect,{mode:this._currentMode,mesh:e}),this._handlers.get(this._currentMode)?.handle(i,$i.Click)};destroy(){this._handlers&&this._handlers.clear(),this._eventBus.off(vn.SelectHover,this._onHover)}};Fo=Y_([jt(),Bl(0,Ht("EventBus")),Bl(1,ha("ISelectHandler"))],Fo);var q_=Object.getOwnPropertyDescriptor,j_=(i,e,t,n)=>{for(var r=n>1?void 0:n?q_(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=o(r)||r);return r},zl=(i,e)=>(t,n)=>e(t,n,i);let Bo=class{constructor(i,e){this._eventBus=i,this._handlers=new Map(e.map(t=>[t.mode,t])),this._currentObject=null,this._eventBus.on(vn.ToolSelect,this._onSelect)}_currentTool=Qn.Translate;_handlers;_currentObject;manage(i){this._currentTool!==i&&(this._handlers.get(this._currentTool)?.rollback(),this._handlers.get(i)?.handle(this._currentObject),this._currentTool=i)}_onSelect=i=>{if(this._currentObject===i.mesh)return;const e=this._handlers.get(this._currentTool);if(this._currentObject=i.mesh,i.mesh===null){e?.rollback();return}e?.handle(this._currentObject)};destroy(){this._handlers&&this._handlers.clear(),this._currentTool=Qn.Translate}};Bo=j_([jt(),zl(0,Ht("EventBus")),zl(1,ha("IToolHandler"))],Bo);var Z_=Object.getOwnPropertyDescriptor,$_=(i,e,t,n)=>{for(var r=n>1?void 0:n?Z_(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=o(r)||r);return r},K_=(i,e)=>(t,n)=>e(t,n,i);let zo=class{constructor(i){this._api=i}mode=Wi.Wireframe;_wireframes=[];handle(){const i=this._api.getMeshes();this._wireframes.length>0||(this._wireframes=i.map(e=>{const t=new Qh(e.geometry),n=new Ri({color:65535,linewidth:1}),r=new ta(t,n);return r.position.copy(e.position),r.rotation.copy(e.rotation),r.scale.copy(e.scale),e.add(r),r}),i.forEach(e=>{const t=e.material;t.visible=!1}))}rollback(){const i=this._api.getMeshes();for(const e of i){const t=this._wireframes.find(r=>r.parent===e);t&&(e.remove(t),t.geometry.dispose(),t.material.dispose());const n=e.material;n.visible=!0}this._wireframes=[]}destroy(){for(const i of this._wireframes)i.geometry.dispose(),i.material.dispose();this._wireframes=[]}};zo=$_([jt(),K_(0,Ht("RendererApi"))],zo);var Q_=Object.getOwnPropertyDescriptor,J_=(i,e,t,n)=>{for(var r=n>1?void 0:n?Q_(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=o(r)||r);return r};let Ho=class{mode=ns.Mesh;_hoveredMesh=null;_selectedMesh=null;_hoverColor=16776960;_selectColor=16755200;_defaultColor=2236962;constructor(){}handle(i,e){if(e===$i.Hover){if(!i){this._hoveredMesh&&this._hoveredMesh!==this._selectedMesh&&this._setEdgesColor(this._hoveredMesh,this._defaultColor),this._hoveredMesh=null;return}const{mesh:t}=i;this._hoveredMesh!==t&&(this._hoveredMesh&&this._hoveredMesh!==this._selectedMesh&&this._setEdgesColor(this._hoveredMesh,this._defaultColor),t!==this._selectedMesh&&this._setEdgesColor(t,this._hoverColor),this._hoveredMesh=t)}else if(e===$i.Click){if(!i){this._selectedMesh&&(this._setEdgesColor(this._selectedMesh,this._defaultColor),this._selectedMesh=null);return}const{mesh:t}=i;this._selectedMesh&&this._selectedMesh!==t&&this._setEdgesColor(this._selectedMesh,this._defaultColor),this._setEdgesColor(t,this._selectColor),this._selectedMesh=t}}rollback(){this._hoveredMesh&&this._setEdgesColor(this._hoveredMesh,this._defaultColor),this._selectedMesh&&this._setEdgesColor(this._selectedMesh,this._defaultColor),this._hoveredMesh=null,this._selectedMesh=null}destroy(){this.rollback()}_setEdgesColor(i,e){i.children.forEach(t=>{t.type==="LineSegments"&&t.material.color.setHex(e)})}};Ho=J_([jt()],Ho);class ua{constructor(e){this.api=e}handle(e){this.api.setMode(this.mode),e?this.api.attach(e):this.api.detach()}rollback(){this.api.detach()}destroy(){this.rollback()}}var eg=Object.getOwnPropertyDescriptor,tg=(i,e,t,n)=>{for(var r=n>1?void 0:n?eg(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=o(r)||r);return r},ng=(i,e)=>(t,n)=>e(t,n,i);let ko=class extends ua{mode=Qn.Translate;constructor(i){super(i)}};ko=tg([jt(),ng(0,Ht("RendererApi"))],ko);var ig=Object.getOwnPropertyDescriptor,rg=(i,e,t,n)=>{for(var r=n>1?void 0:n?ig(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=o(r)||r);return r},sg=(i,e)=>(t,n)=>e(t,n,i);let Go=class extends ua{mode=Qn.Scale;constructor(i){super(i)}};Go=rg([jt(),sg(0,Ht("RendererApi"))],Go);var og=Object.getOwnPropertyDescriptor,ag=(i,e,t,n)=>{for(var r=n>1?void 0:n?og(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=o(r)||r);return r},lg=(i,e)=>(t,n)=>e(t,n,i);let Vo=class extends ua{mode=Qn.Rotate;constructor(i){super(i)}};Vo=ag([jt(),lg(0,Ht("RendererApi"))],Vo);var cg=Object.getOwnPropertyDescriptor,hg=(i,e,t,n)=>{for(var r=n>1?void 0:n?cg(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=o(r)||r);return r},ug=(i,e)=>(t,n)=>e(t,n,i);let Wo=class{constructor(i){this._renderer=i}addMesh(i){this._renderer.addMesh(i)}addMeshes(i){for(const e of i)this._renderer.addMesh(e)}removeMesh(i){this._renderer.removeMesh(i)}removeMeshes(i){for(const e of i)this._renderer.removeMesh(e)}getMeshes(){return this._renderer.getMeshes()}setMode(i){this._renderer.setTransformControlsMode(i)}attach(i){this._renderer.attachTransformControls(i)}detach(){this._renderer.detachTransformControls()}};Wo=hg([jt(),ug(0,Ht("EditorRenderer"))],Wo);var fg=Object.getOwnPropertyDescriptor,dg=(i,e,t,n)=>{for(var r=n>1?void 0:n?fg(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=o(r)||r);return r},Or=(i,e)=>(t,n)=>e(t,n,i);exports.EditorHub=class{constructor(e,t,n,r){this._displayManager=e,this._selectManager=t,this._toolManager=n,this._renderer=r,this.setSelectMode(ns.Mesh),this.setToolMode(Qn.Translate)}setDisplayMode(e){this._displayManager.manage(e)}setSelectMode(e){this._selectManager.manage(e)}setToolMode(e){this._toolManager.manage(e)}resizeRenderer(){this._renderer.resize()}updateRenderer(){this._renderer.loop()}addFigure(e){this._renderer.addFigure(e)}destroy(){this._displayManager.destroy(),this._selectManager.destroy(),this._renderer.destroy()}};exports.EditorHub=dg([jt(),Or(0,Ht("IDisplayManager")),Or(1,Ht("ISelectManager")),Or(2,Ht("IToolManager")),Or(3,Ht("EditorRenderer"))],exports.EditorHub);let Hl=!1;const Rt=L_.createChildContainer();function pg(i){return Hl||(Rt.registerInstance("Canvas",i),Rt.registerSingleton("EventBus",exports.EventBus),Rt.registerSingleton("EditorRenderer",exports.EditorRenderer),Rt.registerSingleton("RendererApi",Wo),Rt.registerSingleton("IDisplayHandler",zo),Rt.registerSingleton("ISelectHandler",Ho),Rt.registerSingleton("IToolHandler",ko),Rt.registerSingleton("IToolHandler",Go),Rt.registerSingleton("IToolHandler",Vo),Rt.registerSingleton("IDisplayManager",Oo),Rt.registerSingleton("ISelectManager",Fo),Rt.registerSingleton("IToolManager",Bo),Rt.registerSingleton("EditorHub",exports.EditorHub),Hl=!0),Rt}function mg(i){return pg(i).resolve("EditorHub")}exports.EventTopics=vn;exports.ObjLoader=k_;exports.PreviewRenderer=H_;exports.Renderer=oa;exports.createAppHub=mg;