@planara/core 2.1.1 → 2.2.0

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 (66) hide show
  1. package/dist/constants/colors.d.ts +24 -0
  2. package/dist/constants/colors.d.ts.map +1 -0
  3. package/dist/constants/layers.d.ts +39 -0
  4. package/dist/constants/layers.d.ts.map +1 -0
  5. package/dist/constants/threshold.d.ts +5 -0
  6. package/dist/constants/threshold.d.ts.map +1 -0
  7. package/dist/core/editor-renderer.d.ts +8 -2
  8. package/dist/core/editor-renderer.d.ts.map +1 -1
  9. package/dist/core/preview-renderer.d.ts.map +1 -1
  10. package/dist/core/renderer.d.ts +55 -4
  11. package/dist/core/renderer.d.ts.map +1 -1
  12. package/dist/events/editor-events.d.ts +4 -4
  13. package/dist/events/editor-events.d.ts.map +1 -1
  14. package/dist/events/event-topics.d.ts +2 -2
  15. package/dist/events/event-topics.d.ts.map +1 -1
  16. package/dist/extensions/orbit-extension.d.ts +3 -2
  17. package/dist/extensions/orbit-extension.d.ts.map +1 -1
  18. package/dist/handlers/display/wireframe-handler.d.ts +2 -4
  19. package/dist/handlers/display/wireframe-handler.d.ts.map +1 -1
  20. package/dist/handlers/select/edge-select-handler.d.ts +46 -0
  21. package/dist/handlers/select/edge-select-handler.d.ts.map +1 -0
  22. package/dist/handlers/select/face-select-handler.d.ts +34 -0
  23. package/dist/handlers/select/face-select-handler.d.ts.map +1 -0
  24. package/dist/handlers/select/mesh-select-handler.d.ts +10 -5
  25. package/dist/handlers/select/mesh-select-handler.d.ts.map +1 -1
  26. package/dist/handlers/tool/base-tool-handler.d.ts +6 -4
  27. package/dist/handlers/tool/base-tool-handler.d.ts.map +1 -1
  28. package/dist/handlers/tool/rotate-tool-handler.d.ts +2 -1
  29. package/dist/handlers/tool/rotate-tool-handler.d.ts.map +1 -1
  30. package/dist/handlers/tool/scale-tool-handler.d.ts +2 -1
  31. package/dist/handlers/tool/scale-tool-handler.d.ts.map +1 -1
  32. package/dist/handlers/tool/translate-tool-handler.d.ts +2 -1
  33. package/dist/handlers/tool/translate-tool-handler.d.ts.map +1 -1
  34. package/dist/hub/editor-hub.d.ts +3 -2
  35. package/dist/hub/editor-hub.d.ts.map +1 -1
  36. package/dist/index.cjs.js +230 -201
  37. package/dist/index.es.js +9106 -5883
  38. package/dist/index.full.d.ts +71 -18
  39. package/dist/index.public.d.ts +20 -18
  40. package/dist/index.umd.js +197 -168
  41. package/dist/interfaces/api/raycast-api.d.ts +23 -0
  42. package/dist/interfaces/api/raycast-api.d.ts.map +1 -0
  43. package/dist/interfaces/api/scene-api.d.ts +50 -0
  44. package/dist/interfaces/api/scene-api.d.ts.map +1 -0
  45. package/dist/interfaces/handler/handler.d.ts +2 -5
  46. package/dist/interfaces/handler/handler.d.ts.map +1 -1
  47. package/dist/interfaces/manager/manager.d.ts +2 -5
  48. package/dist/interfaces/manager/manager.d.ts.map +1 -1
  49. package/dist/interfaces/store/editor-store.d.ts +44 -0
  50. package/dist/interfaces/store/editor-store.d.ts.map +1 -0
  51. package/dist/ioc/container.d.ts.map +1 -1
  52. package/dist/managers/display/display-manager.d.ts +6 -4
  53. package/dist/managers/display/display-manager.d.ts.map +1 -1
  54. package/dist/managers/select/select-manager.d.ts +11 -2
  55. package/dist/managers/select/select-manager.d.ts.map +1 -1
  56. package/dist/managers/tool/tool-manager.d.ts +6 -7
  57. package/dist/managers/tool/tool-manager.d.ts.map +1 -1
  58. package/dist/store/index.d.ts +37 -0
  59. package/dist/store/index.d.ts.map +1 -0
  60. package/dist/types/api/editor-api.d.ts +4 -0
  61. package/dist/types/api/editor-api.d.ts.map +1 -0
  62. package/dist/types/listener/selected-listener.d.ts +3 -0
  63. package/dist/types/listener/selected-listener.d.ts.map +1 -0
  64. package/dist/utils/renderer-api.d.ts +20 -2
  65. package/dist/utils/renderer-api.d.ts.map +1 -1
  66. package/package.json +2 -1
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(ht,ti){typeof exports=="object"&&typeof module<"u"?ti(exports):typeof define=="function"&&define.amd?define(["exports"],ti):(ht=typeof globalThis<"u"?globalThis:ht||self,ti(ht.PlanaraCore={}))})(this,(function(ht){"use strict";var ti=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},pa={};/*! *****************************************************************************
1
+ (function(_t,Qi){typeof exports=="object"&&typeof module<"u"?Qi(exports):typeof define=="function"&&define.amd?define(["exports"],Qi):(_t=typeof globalThis<"u"?globalThis:_t||self,Qi(_t.PlanaraCore={}))})(this,(function(_t){"use strict";var Qi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Pc={};/*! *****************************************************************************
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 @@
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 ma;function wc(){if(ma)return pa;ma=1;var i;return(function(e){(function(t){var n=typeof globalThis=="object"?globalThis:typeof ti=="object"?ti: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(de(O)){if(!yt(I))throw new TypeError;if(!tt(P))throw new TypeError;return q(I,P)}else{if(!yt(I))throw new TypeError;if(!Z(P))throw new TypeError;if(!Z(J)&&!de(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(!Z(J))throw new TypeError;if(!de(ie)&&!Fe(ie))throw new TypeError;le(I,P,J,ie)}return O}t("metadata",_);function T(I,P,O,J){if(!Z(O))throw new TypeError;return de(J)||(J=Oe(J)),le(I,P,O,J)}t("defineMetadata",T);function E(I,P,O){if(!Z(P))throw new TypeError;return de(O)||(O=Oe(O)),Q(I,P,O)}t("hasMetadata",E);function A(I,P,O){if(!Z(P))throw new TypeError;return de(O)||(O=Oe(O)),K(I,P,O)}t("hasOwnMetadata",A);function C(I,P,O){if(!Z(P))throw new TypeError;return de(O)||(O=Oe(O)),se(I,P,O)}t("getMetadata",C);function M(I,P,O){if(!Z(P))throw new TypeError;return de(O)||(O=Oe(O)),$(I,P,O)}t("getOwnMetadata",M);function x(I,P){if(!Z(I))throw new TypeError;return de(P)||(P=Oe(P)),pe(I,P)}t("getMetadataKeys",x);function N(I,P){if(!Z(I))throw new TypeError;return de(P)||(P=Oe(P)),Me(I,P)}t("getOwnMetadataKeys",N);function z(I,P,O){if(!Z(P))throw new TypeError;if(de(O)||(O=Oe(O)),!Z(P))throw new TypeError;de(O)||(O=Oe(O));var J=re(P,O,!1);return de(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(!de(ie)&&!Xe(ie)){if(!tt(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(!de(Te)&&!Xe(Te)){if(!Z(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=st(P);return Xe(ie)?!1:Q(I,ie,O)}function K(I,P,O){var J=re(P,O,!1);return de(J)?!1:Le(J.OrdinaryHasOwnMetadata(I,P,O))}function se(I,P,O){var J=K(I,P,O);if(J)return $(I,P,O);var ie=st(P);if(!Xe(ie))return se(I,ie,O)}function $(I,P,O){var J=re(P,O,!1);if(!de(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=st(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 de(I){return I===void 0}function Xe(I){return I===null}function je(I){return typeof I=="symbol"}function Z(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(Z(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(!Z(J))return J}var O=I.valueOf;if(L(O)){var J=O.call(I);if(!Z(J))return J}}throw new TypeError}function Le(I){return!!I}function Ae(I){return""+I}function Oe(I){var P=oe(I);return je(P)?P:Ae(P)}function yt(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 tt(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 nt(I){var P=ye(I,a);if(!L(P))throw new TypeError;var O=P.call(I);if(!Z(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 pt(I){var P=I.return;P&&P.call(I)}function st(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;!de(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 de(P):P=G;break;case P===G:break;case de(O):O=G;break;case O===G:break;default:J===void 0&&(J=new g),J.add(G);break}}function D(G,W){if(!de(P)){if(P.isProviderFor(G,W))return P;if(!de(O)){if(O.isProviderFor(G,W))return P;if(!de(J))for(var he=nt(J);;){var ge=Be(he);if(!ge)return;var ke=Se(ge);if(ke.isProviderFor(G,W))return pt(he),ke}}}if(!de(I)&&I.isProviderFor(G,W))return I}function H(G,W){var he=ie.get(G),ge;return de(he)||(ge=he.get(W)),de(ge)&&(ge=D(G,W),de(ge)||(de(he)&&(he=new m,ie.set(G,he)),he.set(W,ge))),ge}function V(G){if(de(G))throw new TypeError;return P===G||O===G||!de(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(!de(ge))return!1;var ke=ie.get(G);de(ke)&&(ke=new m,ie.set(G,ke)),ke.set(W,he)}return!0}}function v(){var I;return!de(p)&&Z(n.Reflect)&&Object.isExtensible(n.Reflect)&&(I=n.Reflect[p]),de(I)&&(I=R()),!de(p)&&Z(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 de(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(de(W)){if(!G)return;W=new m,P.set(V,W),he=!0}var ge=W.get(ee);if(de(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 de(W)?!1:Le(W.has(V))}function ae(V,ee,G){var W=J(ee,G,!1);if(!de(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(de(W))return G;for(var he=W.keys(),ge=nt(he),ke=0;;){var Ye=Be(ge);if(!Ye)return G.length=ke,G;var nn=Se(Ye);try{G[ke]=nn}catch(qt){try{pt(ge)}finally{throw qt}}ke++}}function H(V,ee,G){var W=J(ee,G,!1);if(de(W)||!W.delete(V))return!1;if(W.size===0){var he=P.get(ee);de(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!de(ee)&&ee.has(V)?!0:ie(H,V).length?(de(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(!de(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={})),pa}wc();/**
14
+ ***************************************************************************** */var Dc;function ed(){if(Dc)return Pc;Dc=1;var n;return(function(e){(function(t){var i=typeof globalThis=="object"?globalThis:typeof Qi=="object"?Qi:typeof self=="object"?self:typeof this=="object"?this:l(),r=s(e);typeof i.Reflect<"u"&&(r=s(i.Reflect,r)),t(r,i),typeof i.Reflect>"u"&&(i.Reflect=e);function s(c,u){return function(h,d){Object.defineProperty(c,h,{configurable:!0,writable:!0,value:d}),u&&u(h,d)}}function o(){try{return Function("return this;")()}catch{}}function a(){try{return(0,eval)("(function() { return this; })()")}catch{}}function l(){return o()||a()}})(function(t,i){var r=Object.prototype.hasOwnProperty,s=typeof Symbol=="function",o=s&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",a=s&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",l=typeof Object.create=="function",c={__proto__:[]}instanceof Array,u=!l&&!c,h={create:l?function(){return Te(Object.create(null))}:c?function(){return Te({__proto__:null})}:function(){return Te({})},has:u?function(I,P){return r.call(I,P)}:function(I,P){return P in I},get:u?function(I,P){return r.call(I,P)?I[P]:void 0}:function(I,P){return I[P]}},d=Object.getPrototypeOf(Function),p=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:te(),g=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Re(),y=typeof WeakMap=="function"?WeakMap:fe(),m=s?Symbol.for("@reflect-metadata:registry"):void 0,f=v(),w=H(f);function T(I,P,U,Q){if(pe(U)){if(!Rt(I))throw new TypeError;if(!st(P))throw new TypeError;return Y(I,P)}else{if(!Rt(I))throw new TypeError;if(!Z(P))throw new TypeError;if(!Z(Q)&&!pe(Q)&&!qe(Q))throw new TypeError;return qe(Q)&&(Q=void 0),U=ze(U),q(I,P,U,Q)}}t("decorate",T);function _(I,P){function U(Q,ie){if(!Z(Q))throw new TypeError;if(!pe(ie)&&!Ve(ie))throw new TypeError;le(I,P,Q,ie)}return U}t("metadata",_);function S(I,P,U,Q){if(!Z(U))throw new TypeError;return pe(Q)||(Q=ze(Q)),le(I,P,U,Q)}t("defineMetadata",S);function b(I,P,U){if(!Z(P))throw new TypeError;return pe(U)||(U=ze(U)),J(I,P,U)}t("hasMetadata",b);function A(I,P,U){if(!Z(P))throw new TypeError;return pe(U)||(U=ze(U)),K(I,P,U)}t("hasOwnMetadata",A);function C(I,P,U){if(!Z(P))throw new TypeError;return pe(U)||(U=ze(U)),se(I,P,U)}t("getMetadata",C);function M(I,P,U){if(!Z(P))throw new TypeError;return pe(U)||(U=ze(U)),$(I,P,U)}t("getOwnMetadata",M);function x(I,P){if(!Z(I))throw new TypeError;return pe(P)||(P=ze(P)),me(I,P)}t("getMetadataKeys",x);function N(I,P){if(!Z(I))throw new TypeError;return pe(P)||(P=ze(P)),Ee(I,P)}t("getOwnMetadataKeys",N);function z(I,P,U){if(!Z(P))throw new TypeError;if(pe(U)||(U=ze(U)),!Z(P))throw new TypeError;pe(U)||(U=ze(U));var Q=re(P,U,!1);return pe(Q)?!1:Q.OrdinaryDeleteMetadata(I,P,U)}t("deleteMetadata",z);function Y(I,P){for(var U=I.length-1;U>=0;--U){var Q=I[U],ie=Q(P);if(!pe(ie)&&!qe(ie)){if(!st(ie))throw new TypeError;P=ie}}return P}function q(I,P,U,Q){for(var ie=I.length-1;ie>=0;--ie){var ae=I[ie],we=ae(P,U,Q);if(!pe(we)&&!qe(we)){if(!Z(we))throw new TypeError;Q=we}}return Q}function J(I,P,U){var Q=K(I,P,U);if(Q)return!0;var ie=ut(P);return qe(ie)?!1:J(I,ie,U)}function K(I,P,U){var Q=re(P,U,!1);return pe(Q)?!1:Ie(Q.OrdinaryHasOwnMetadata(I,P,U))}function se(I,P,U){var Q=K(I,P,U);if(Q)return $(I,P,U);var ie=ut(P);if(!qe(ie))return se(I,ie,U)}function $(I,P,U){var Q=re(P,U,!1);if(!pe(Q))return Q.OrdinaryGetOwnMetadata(I,P,U)}function le(I,P,U,Q){var ie=re(U,Q,!0);ie.OrdinaryDefineOwnMetadata(I,P,U,Q)}function me(I,P){var U=Ee(I,P),Q=ut(I);if(Q===null)return U;var ie=me(Q,P);if(ie.length<=0)return U;if(U.length<=0)return ie;for(var ae=new g,we=[],D=0,V=U;D<V.length;D++){var G=V[D],ee=ae.has(G);ee||(ae.add(G),we.push(G))}for(var k=0,W=ie;k<W.length;k++){var G=W[k],ee=ae.has(G);ee||(ae.add(G),we.push(G))}return we}function Ee(I,P){var U=re(I,P,!1);return U?U.OrdinaryOwnMetadataKeys(I,P):[]}function Be(I){if(I===null)return 1;switch(typeof I){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return I===null?1:6;default:return 6}}function pe(I){return I===void 0}function qe(I){return I===null}function Je(I){return typeof I=="symbol"}function Z(I){return typeof I=="object"?I!==null:typeof I=="function"}function oe(I,P){switch(Be(I)){case 0:return I;case 1:return I;case 2:return I;case 3:return I;case 4:return I;case 5:return I}var U="string",Q=be(I,o);if(Q!==void 0){var ie=Q.call(I,U);if(Z(ie))throw new TypeError;return ie}return Me(I)}function Me(I,P){var U,Q,ie;{var ae=I.toString;if(O(ae)){var Q=ae.call(I);if(!Z(Q))return Q}var U=I.valueOf;if(O(U)){var Q=U.call(I);if(!Z(Q))return Q}}throw new TypeError}function Ie(I){return!!I}function Ce(I){return""+I}function ze(I){var P=oe(I);return Je(P)?P:Ce(P)}function Rt(I){return Array.isArray?Array.isArray(I):I instanceof Object?I instanceof Array:Object.prototype.toString.call(I)==="[object Array]"}function O(I){return typeof I=="function"}function st(I){return typeof I=="function"}function Ve(I){switch(Be(I)){case 3:return!0;case 4:return!0;default:return!1}}function De(I,P){return I===P||I!==I&&P!==P}function be(I,P){var U=I[P];if(U!=null){if(!O(U))throw new TypeError;return U}}function ot(I){var P=be(I,a);if(!O(P))throw new TypeError;var U=P.call(I);if(!Z(U))throw new TypeError;return U}function Se(I){return I.value}function He(I){var P=I.next();return P.done?!1:P}function yt(I){var P=I.return;P&&P.call(I)}function ut(I){var P=Object.getPrototypeOf(I);if(typeof I!="function"||I===d||P!==d)return P;var U=I.prototype,Q=U&&Object.getPrototypeOf(U);if(Q==null||Q===Object.prototype)return P;var ie=Q.constructor;return typeof ie!="function"||ie===I?P:ie}function R(){var I;!pe(m)&&typeof i.Reflect<"u"&&!(m in i.Reflect)&&typeof i.Reflect.defineMetadata=="function"&&(I=ne(i.Reflect));var P,U,Q,ie=new y,ae={registerProvider:we,getProvider:V,setProvider:ee};return ae;function we(k){if(!Object.isExtensible(ae))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case I===k:break;case pe(P):P=k;break;case P===k:break;case pe(U):U=k;break;case U===k:break;default:Q===void 0&&(Q=new g),Q.add(k);break}}function D(k,W){if(!pe(P)){if(P.isProviderFor(k,W))return P;if(!pe(U)){if(U.isProviderFor(k,W))return P;if(!pe(Q))for(var ue=ot(Q);;){var xe=He(ue);if(!xe)return;var We=Se(xe);if(We.isProviderFor(k,W))return yt(ue),We}}}if(!pe(I)&&I.isProviderFor(k,W))return I}function V(k,W){var ue=ie.get(k),xe;return pe(ue)||(xe=ue.get(W)),pe(xe)&&(xe=D(k,W),pe(xe)||(pe(ue)&&(ue=new p,ie.set(k,ue)),ue.set(W,xe))),xe}function G(k){if(pe(k))throw new TypeError;return P===k||U===k||!pe(Q)&&Q.has(k)}function ee(k,W,ue){if(!G(ue))throw new Error("Metadata provider not registered.");var xe=V(k,W);if(xe!==ue){if(!pe(xe))return!1;var We=ie.get(k);pe(We)&&(We=new p,ie.set(k,We)),We.set(W,ue)}return!0}}function v(){var I;return!pe(m)&&Z(i.Reflect)&&Object.isExtensible(i.Reflect)&&(I=i.Reflect[m]),pe(I)&&(I=R()),!pe(m)&&Z(i.Reflect)&&Object.isExtensible(i.Reflect)&&Object.defineProperty(i.Reflect,m,{enumerable:!1,configurable:!1,writable:!1,value:I}),I}function H(I){var P=new y,U={isProviderFor:function(G,ee){var k=P.get(G);return pe(k)?!1:k.has(ee)},OrdinaryDefineOwnMetadata:we,OrdinaryHasOwnMetadata:ie,OrdinaryGetOwnMetadata:ae,OrdinaryOwnMetadataKeys:D,OrdinaryDeleteMetadata:V};return f.registerProvider(U),U;function Q(G,ee,k){var W=P.get(G),ue=!1;if(pe(W)){if(!k)return;W=new p,P.set(G,W),ue=!0}var xe=W.get(ee);if(pe(xe)){if(!k)return;if(xe=new p,W.set(ee,xe),!I.setProvider(G,ee,U))throw W.delete(ee),ue&&P.delete(G),new Error("Wrong provider for target.")}return xe}function ie(G,ee,k){var W=Q(ee,k,!1);return pe(W)?!1:Ie(W.has(G))}function ae(G,ee,k){var W=Q(ee,k,!1);if(!pe(W))return W.get(G)}function we(G,ee,k,W){var ue=Q(k,W,!0);ue.set(G,ee)}function D(G,ee){var k=[],W=Q(G,ee,!1);if(pe(W))return k;for(var ue=W.keys(),xe=ot(ue),We=0;;){var $e=He(xe);if(!$e)return k.length=We,k;var Ln=Se($e);try{k[We]=Ln}catch(mn){try{yt(xe)}finally{throw mn}}We++}}function V(G,ee,k){var W=Q(ee,k,!1);if(pe(W)||!W.delete(G))return!1;if(W.size===0){var ue=P.get(ee);pe(ue)||(ue.delete(k),ue.size===0&&P.delete(ue))}return!0}}function ne(I){var P=I.defineMetadata,U=I.hasOwnMetadata,Q=I.getOwnMetadata,ie=I.getOwnMetadataKeys,ae=I.deleteMetadata,we=new y,D={isProviderFor:function(V,G){var ee=we.get(V);return!pe(ee)&&ee.has(G)?!0:ie(V,G).length?(pe(ee)&&(ee=new g,we.set(V,ee)),ee.add(G),!0):!1},OrdinaryDefineOwnMetadata:P,OrdinaryHasOwnMetadata:U,OrdinaryGetOwnMetadata:Q,OrdinaryOwnMetadataKeys:ie,OrdinaryDeleteMetadata:ae};return D}function re(I,P,U){var Q=f.getProvider(I,P);if(!pe(Q))return Q;if(U){if(f.setProvider(I,P,w))return w;throw new Error("Illegal state.")}}function te(){var I={},P=[],U=(function(){function D(V,G,ee){this._index=0,this._keys=V,this._values=G,this._selector=ee}return D.prototype["@@iterator"]=function(){return this},D.prototype[a]=function(){return this},D.prototype.next=function(){var V=this._index;if(V>=0&&V<this._keys.length){var G=this._selector(this._keys[V],this._values[V]);return V+1>=this._keys.length?(this._index=-1,this._keys=P,this._values=P):this._index++,{value:G,done:!1}}return{value:void 0,done:!0}},D.prototype.throw=function(V){throw this._index>=0&&(this._index=-1,this._keys=P,this._values=P),V},D.prototype.return=function(V){return this._index>=0&&(this._index=-1,this._keys=P,this._values=P),{value:V,done:!0}},D})(),Q=(function(){function D(){this._keys=[],this._values=[],this._cacheKey=I,this._cacheIndex=-2}return Object.defineProperty(D.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),D.prototype.has=function(V){return this._find(V,!1)>=0},D.prototype.get=function(V){var G=this._find(V,!1);return G>=0?this._values[G]:void 0},D.prototype.set=function(V,G){var ee=this._find(V,!0);return this._values[ee]=G,this},D.prototype.delete=function(V){var G=this._find(V,!1);if(G>=0){for(var ee=this._keys.length,k=G+1;k<ee;k++)this._keys[k-1]=this._keys[k],this._values[k-1]=this._values[k];return this._keys.length--,this._values.length--,De(V,this._cacheKey)&&(this._cacheKey=I,this._cacheIndex=-2),!0}return!1},D.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=I,this._cacheIndex=-2},D.prototype.keys=function(){return new U(this._keys,this._values,ie)},D.prototype.values=function(){return new U(this._keys,this._values,ae)},D.prototype.entries=function(){return new U(this._keys,this._values,we)},D.prototype["@@iterator"]=function(){return this.entries()},D.prototype[a]=function(){return this.entries()},D.prototype._find=function(V,G){if(!De(this._cacheKey,V)){this._cacheIndex=-1;for(var ee=0;ee<this._keys.length;ee++)if(De(this._keys[ee],V)){this._cacheIndex=ee;break}}return this._cacheIndex<0&&G&&(this._cacheIndex=this._keys.length,this._keys.push(V),this._values.push(void 0)),this._cacheIndex},D})();return Q;function ie(D,V){return D}function ae(D,V){return V}function we(D,V){return[D,V]}}function Re(){var I=(function(){function P(){this._map=new p}return Object.defineProperty(P.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),P.prototype.has=function(U){return this._map.has(U)},P.prototype.add=function(U){return this._map.set(U,U),this},P.prototype.delete=function(U){return this._map.delete(U)},P.prototype.clear=function(){this._map.clear()},P.prototype.keys=function(){return this._map.keys()},P.prototype.values=function(){return this._map.keys()},P.prototype.entries=function(){return this._map.entries()},P.prototype["@@iterator"]=function(){return this.keys()},P.prototype[a]=function(){return this.keys()},P})();return I}function fe(){var I=16,P=h.create(),U=Q();return(function(){function V(){this._key=Q()}return V.prototype.has=function(G){var ee=ie(G,!1);return ee!==void 0?h.has(ee,this._key):!1},V.prototype.get=function(G){var ee=ie(G,!1);return ee!==void 0?h.get(ee,this._key):void 0},V.prototype.set=function(G,ee){var k=ie(G,!0);return k[this._key]=ee,this},V.prototype.delete=function(G){var ee=ie(G,!1);return ee!==void 0?delete ee[this._key]:!1},V.prototype.clear=function(){this._key=Q()},V})();function Q(){var V;do V="@@WeakMap@@"+D();while(h.has(P,V));return P[V]=!0,V}function ie(V,G){if(!r.call(V,U)){if(!G)return;Object.defineProperty(V,U,{value:h.create()})}return V[U]}function ae(V,G){for(var ee=0;ee<G;++ee)V[ee]=Math.random()*255|0;return V}function we(V){if(typeof Uint8Array=="function"){var G=new Uint8Array(V);return typeof crypto<"u"?crypto.getRandomValues(G):typeof msCrypto<"u"?msCrypto.getRandomValues(G):ae(G,V),G}return ae(new Array(V),V)}function D(){var V=we(I);V[6]=V[6]&79|64,V[8]=V[8]&191|128;for(var G="",ee=0;ee<I;++ee){var k=V[ee];(ee===4||ee===6||ee===8)&&(G+="-"),k<16&&(G+="0"),G+=k.toString(16).toLowerCase()}return G}}function Te(I){return I.__=void 0,delete I.__,I}})})(n||(n={})),Pc}ed();/**
15
15
  * @license
16
16
  * Copyright 2010-2025 Three.js Authors
17
17
  * SPDX-License-Identifier: MIT
18
- */const ss="180",ni={ROTATE:0,DOLLY:1,PAN:2},ii={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Ac=0,_a=1,Rc=2,ga=1,Cc=2,fn=3,yn=0,Dt=1,rn=2,Sn=0,ri=1,va=2,xa=3,Ma=4,Pc=5,Un=100,Dc=101,Lc=102,Ic=103,Uc=104,Nc=200,Oc=201,Fc=202,Bc=203,os=204,as=205,zc=206,Hc=207,kc=208,Gc=209,Vc=210,Wc=211,Xc=212,Yc=213,qc=214,ls=0,cs=1,hs=2,si=3,us=4,fs=5,ds=6,ps=7,ya=0,jc=1,$c=2,En=0,Zc=1,Kc=2,Qc=3,Jc=4,eh=5,th=6,nh=7,Sa=300,oi=301,ai=302,ms=303,_s=304,ir=306,gs=1e3,Nn=1001,vs=1002,Zt=1003,ih=1004,rr=1005,sn=1006,xs=1007,On=1008,on=1009,Ea=1010,Ta=1011,Li=1012,Ms=1013,Fn=1014,dn=1015,Ii=1016,ys=1017,Ss=1018,Ui=1020,ba=35902,wa=35899,Aa=1021,Ra=1022,Kt=1023,Ni=1026,Oi=1027,Ca=1028,Es=1029,Pa=1030,Ts=1031,bs=1033,sr=33776,or=33777,ar=33778,lr=33779,ws=35840,As=35841,Rs=35842,Cs=35843,Ps=36196,Ds=37492,Ls=37496,Is=37808,Us=37809,Ns=37810,Os=37811,Fs=37812,Bs=37813,zs=37814,Hs=37815,ks=37816,Gs=37817,Vs=37818,Ws=37819,Xs=37820,Ys=37821,qs=36492,js=36494,$s=36495,Zs=36283,Ks=36284,Qs=36285,Js=36286,rh=3200,sh=3201,Da=0,oh=1,Tn="",Gt="srgb",li="srgb-linear",cr="linear",Ke="srgb",ci=7680,La=519,ah=512,lh=513,ch=514,Ia=515,hh=516,uh=517,fh=518,dh=519,Ua=35044,Na="300 es",an=2e3,hr=2001;class Bn{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 Tt=["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"],Fi=Math.PI/180,eo=180/Math.PI;function Bi(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Tt[i&255]+Tt[i>>8&255]+Tt[i>>16&255]+Tt[i>>24&255]+"-"+Tt[e&255]+Tt[e>>8&255]+"-"+Tt[e>>16&15|64]+Tt[e>>24&255]+"-"+Tt[t&63|128]+Tt[t>>8&255]+"-"+Tt[t>>16&255]+Tt[t>>24&255]+Tt[n&255]+Tt[n>>8&255]+Tt[n>>16&255]+Tt[n>>24&255]).toLowerCase()}function Ge(i,e,t){return Math.max(e,Math.min(t,i))}function ph(i,e){return(i%e+e)%e}function to(i,e,t){return(1-t)*i+t*e}function zi(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 Lt(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:Fi};class Ie{constructor(e=0,t=0){Ie.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 Et{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(Oa.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Oa.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 no.copy(this).projectOnVector(e),this.sub(no)}reflect(e){return this.sub(no.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 no=new U,Oa=new Et;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(io.makeScale(e,t)),this}rotate(e){return this.premultiply(io.makeRotation(-e)),this}translate(e,t){return this.premultiply(io.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 io=new ze;function Fa(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function ur(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function _h(){const i=ur("canvas");return i.style.display="block",i}const Ba={};function Hi(i){i in Ba||(Ba[i]=!0,console.warn(i))}function gh(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 za=new ze().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Ha=new ze().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function vh(){const i={enabled:!0,workingColorSpace:li,spaces:{},convert:function(r,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===Ke&&(r.r=pn(r.r),r.g=pn(r.g),r.b=pn(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===Ke&&(r.r=hi(r.r),r.g=hi(r.g),r.b=hi(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===Tn?cr: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 Hi("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return Hi("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({[li]:{primaries:e,whitePoint:n,transfer:cr,toXYZ:za,fromXYZ:Ha,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Gt},outputColorSpaceConfig:{drawingBufferColorSpace:Gt}},[Gt]:{primaries:e,whitePoint:n,transfer:Ke,toXYZ:za,fromXYZ:Ha,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Gt}}}),i}const qe=vh();function pn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function hi(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let ui;class xh{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{ui===void 0&&(ui=ur("canvas")),ui.width=e.width,ui.height=e.height;const r=ui.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=ui}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=ur("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]=pn(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(pn(t[n]/255)*255):t[n]=pn(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 Mh=0;class ro{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Mh++}),this.uuid=Bi(),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(so(r[o].image)):s.push(so(r[o]))}else s=so(r);n.url=s}return t||(e.images[this.uuid]=n),n}}function so(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?xh.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 yh=0;const oo=new U;class It extends Bn{constructor(e=It.DEFAULT_IMAGE,t=It.DEFAULT_MAPPING,n=Nn,r=Nn,s=sn,o=On,a=Kt,c=on,l=It.DEFAULT_ANISOTROPY,u=Tn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:yh++}),this.uuid=Bi(),this.name="",this.source=new ro(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 Ie(0,0),this.repeat=new Ie(1,1),this.center=new Ie(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(oo).x}get height(){return this.source.getSize(oo).y}get depth(){return this.source.getSize(oo).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!==Sa)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case gs:e.x=e.x-Math.floor(e.x);break;case Nn:e.x=e.x<0?0:1;break;case vs: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 gs:e.y=e.y-Math.floor(e.y);break;case Nn:e.y=e.y<0?0:1;break;case vs: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++}}It.DEFAULT_IMAGE=null,It.DEFAULT_MAPPING=Sa,It.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 Sh extends Bn{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:sn,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 It(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:sn,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 ro(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 zn extends Sh{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class ka extends It{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=Zt,this.minFilter=Zt,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 Eh extends It{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=Zt,this.minFilter=Zt,this.wrapR=Nn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class ki{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(Qt.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Qt.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=Qt.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,Qt):Qt.fromBufferAttribute(s,o),Qt.applyMatrix4(e.matrixWorld),this.expandByPoint(Qt);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),fr.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),fr.copy(n.boundingBox)),fr.applyMatrix4(e.matrixWorld),this.union(fr)}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,Qt),Qt.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(Gi),dr.subVectors(this.max,Gi),fi.subVectors(e.a,Gi),di.subVectors(e.b,Gi),pi.subVectors(e.c,Gi),bn.subVectors(di,fi),wn.subVectors(pi,di),Hn.subVectors(fi,pi);let t=[0,-bn.z,bn.y,0,-wn.z,wn.y,0,-Hn.z,Hn.y,bn.z,0,-bn.x,wn.z,0,-wn.x,Hn.z,0,-Hn.x,-bn.y,bn.x,0,-wn.y,wn.x,0,-Hn.y,Hn.x,0];return!ao(t,fi,di,pi,dr)||(t=[1,0,0,0,1,0,0,0,1],!ao(t,fi,di,pi,dr))?!1:(pr.crossVectors(bn,wn),t=[pr.x,pr.y,pr.z],ao(t,fi,di,pi,dr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Qt).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Qt).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:(mn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),mn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),mn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),mn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),mn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),mn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),mn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),mn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(mn),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 mn=[new U,new U,new U,new U,new U,new U,new U,new U],Qt=new U,fr=new ki,fi=new U,di=new U,pi=new U,bn=new U,wn=new U,Hn=new U,Gi=new U,dr=new U,pr=new U,kn=new U;function ao(i,e,t,n,r){for(let s=0,o=i.length-3;s<=o;s+=3){kn.fromArray(i,s);const a=r.x*Math.abs(kn.x)+r.y*Math.abs(kn.y)+r.z*Math.abs(kn.z),c=e.dot(kn),l=t.dot(kn),u=n.dot(kn);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}const Th=new ki,Vi=new U,lo=new U;class mr{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):Th.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;Vi.subVectors(e,this.center);const t=Vi.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(Vi,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):(lo.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Vi.copy(e.center).add(lo)),this.expandByPoint(Vi.copy(e.center).sub(lo))),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 _n=new U,co=new U,_r=new U,An=new U,ho=new U,gr=new U,uo=new U;class vr{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,_n)),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=_n.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(_n.copy(this.origin).addScaledVector(this.direction,t),_n.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){co.copy(e).add(t).multiplyScalar(.5),_r.copy(t).sub(e).normalize(),An.copy(this.origin).sub(co);const s=e.distanceTo(t)*.5,o=-this.direction.dot(_r),a=An.dot(this.direction),c=-An.dot(_r),l=An.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(co).addScaledVector(_r,d),m}intersectSphere(e,t){_n.subVectors(e.center,this.origin);const n=_n.dot(this.direction),r=_n.dot(_n)-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,_n)!==null}intersectTriangle(e,t,n,r,s){ho.subVectors(t,e),gr.subVectors(n,e),uo.crossVectors(ho,gr);let o=this.direction.dot(uo),a;if(o>0){if(r)return null;a=1}else if(o<0)a=-1,o=-o;else return null;An.subVectors(this.origin,e);const c=a*this.direction.dot(gr.crossVectors(An,gr));if(c<0)return null;const l=a*this.direction.dot(ho.cross(An));if(l<0||c+l>o)return null;const u=-a*An.dot(uo);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 rt{constructor(e,t,n,r,s,o,a,c,l,u,f,d,m,g,y,p){rt.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 rt().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/mi.setFromMatrixColumn(e,0).length(),s=1/mi.setFromMatrixColumn(e,1).length(),o=1/mi.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(bh,e,wh)}lookAt(e,t,n){const r=this.elements;return Ft.subVectors(e,t),Ft.lengthSq()===0&&(Ft.z=1),Ft.normalize(),Rn.crossVectors(n,Ft),Rn.lengthSq()===0&&(Math.abs(n.z)===1?Ft.x+=1e-4:Ft.z+=1e-4,Ft.normalize(),Rn.crossVectors(n,Ft)),Rn.normalize(),xr.crossVectors(Ft,Rn),r[0]=Rn.x,r[4]=xr.x,r[8]=Ft.x,r[1]=Rn.y,r[5]=xr.y,r[9]=Ft.y,r[2]=Rn.z,r[6]=xr.z,r[10]=Ft.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],$=r[3],le=r[7],pe=r[11],Me=r[15];return s[0]=o*E+a*x+c*j+l*$,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*$,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*$,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*$,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=mi.set(r[0],r[1],r[2]).length();const o=mi.set(r[4],r[5],r[6]).length(),a=mi.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],Jt.copy(this);const l=1/s,u=1/o,f=1/a;return Jt.elements[0]*=l,Jt.elements[1]*=l,Jt.elements[2]*=l,Jt.elements[4]*=u,Jt.elements[5]*=u,Jt.elements[6]*=u,Jt.elements[8]*=f,Jt.elements[9]*=f,Jt.elements[10]*=f,t.setFromRotationMatrix(Jt),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,r,s,o,a=an,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===an)g=-(o+s)/(o-s),y=-2*o*s/(o-s);else if(a===hr)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=an,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===an)g=-2/(o-s),y=-(o+s)/(o-s);else if(a===hr)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 mi=new U,Jt=new rt,bh=new U(0,0,0),wh=new U(1,1,1),Rn=new U,xr=new U,Ft=new U,Ga=new rt,Va=new Et;class en{constructor(e=0,t=0,n=0,r=en.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 Ga.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Ga,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Va.setFromEuler(this),this.setFromQuaternion(Va,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}}en.DEFAULT_ORDER="XYZ";class fo{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 Ah=0;const Wa=new U,_i=new Et,gn=new rt,Mr=new U,Wi=new U,Rh=new U,Ch=new Et,Xa=new U(1,0,0),Ya=new U(0,1,0),qa=new U(0,0,1),ja={type:"added"},Ph={type:"removed"},gi={type:"childadded",child:null},po={type:"childremoved",child:null};class dt extends Bn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Ah++}),this.uuid=Bi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=dt.DEFAULT_UP.clone();const e=new U,t=new en,n=new Et,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 rt},normalMatrix:{value:new ze}}),this.matrix=new rt,this.matrixWorld=new rt,this.matrixAutoUpdate=dt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=dt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new fo,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 _i.setFromAxisAngle(e,t),this.quaternion.multiply(_i),this}rotateOnWorldAxis(e,t){return _i.setFromAxisAngle(e,t),this.quaternion.premultiply(_i),this}rotateX(e){return this.rotateOnAxis(Xa,e)}rotateY(e){return this.rotateOnAxis(Ya,e)}rotateZ(e){return this.rotateOnAxis(qa,e)}translateOnAxis(e,t){return Wa.copy(e).applyQuaternion(this.quaternion),this.position.add(Wa.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Xa,e)}translateY(e){return this.translateOnAxis(Ya,e)}translateZ(e){return this.translateOnAxis(qa,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(gn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Mr.copy(e):Mr.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),Wi.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?gn.lookAt(Wi,Mr,this.up):gn.lookAt(Mr,Wi,this.up),this.quaternion.setFromRotationMatrix(gn),r&&(gn.extractRotation(r.matrixWorld),_i.setFromRotationMatrix(gn),this.quaternion.premultiply(_i.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(ja),gi.child=e,this.dispatchEvent(gi),gi.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(Ph),po.child=e,this.dispatchEvent(po),po.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),gn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),gn.multiply(e.parent.matrixWorld)),e.applyMatrix4(gn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(ja),gi.child=e,this.dispatchEvent(gi),gi.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(Wi,e,Rh),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Wi,Ch,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 tn=new U,vn=new U,mo=new U,xn=new U,vi=new U,xi=new U,$a=new U,_o=new U,go=new U,vo=new U,xo=new ut,Mo=new ut,yo=new ut;class Vt{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),tn.subVectors(e,t),r.cross(tn);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){tn.subVectors(r,t),vn.subVectors(n,t),mo.subVectors(e,t);const o=tn.dot(tn),a=tn.dot(vn),c=tn.dot(mo),l=vn.dot(vn),u=vn.dot(mo),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,xn)===null?!1:xn.x>=0&&xn.y>=0&&xn.x+xn.y<=1}static getInterpolation(e,t,n,r,s,o,a,c){return this.getBarycoord(e,t,n,r,xn)===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,xn.x),c.addScaledVector(o,xn.y),c.addScaledVector(a,xn.z),c)}static getInterpolatedAttribute(e,t,n,r,s,o){return xo.setScalar(0),Mo.setScalar(0),yo.setScalar(0),xo.fromBufferAttribute(e,t),Mo.fromBufferAttribute(e,n),yo.fromBufferAttribute(e,r),o.setScalar(0),o.addScaledVector(xo,s.x),o.addScaledVector(Mo,s.y),o.addScaledVector(yo,s.z),o}static isFrontFacing(e,t,n,r){return tn.subVectors(n,t),vn.subVectors(e,t),tn.cross(vn).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 tn.subVectors(this.c,this.b),vn.subVectors(this.a,this.b),tn.cross(vn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Vt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Vt.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,s){return Vt.getInterpolation(e,this.a,this.b,this.c,t,n,r,s)}containsPoint(e){return Vt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Vt.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;vi.subVectors(r,n),xi.subVectors(s,n),_o.subVectors(e,n);const c=vi.dot(_o),l=xi.dot(_o);if(c<=0&&l<=0)return t.copy(n);go.subVectors(e,r);const u=vi.dot(go),f=xi.dot(go);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(vi,o);vo.subVectors(e,s);const m=vi.dot(vo),g=xi.dot(vo);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(xi,a);const p=u*g-m*f;if(p<=0&&f-u>=0&&m-g>=0)return $a.subVectors(s,r),a=(f-u)/(f-u+(m-g)),t.copy(r).addScaledVector($a,a);const h=1/(p+y+d);return o=y*h,a=d*h,t.copy(n).addScaledVector(vi,o).addScaledVector(xi,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const Za={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},Cn={h:0,s:0,l:0},yr={h:0,s:0,l:0};function So(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 Ve{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=Gt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,qe.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=qe.workingColorSpace){return this.r=e,this.g=t,this.b=n,qe.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=qe.workingColorSpace){if(e=ph(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=So(o,s,e+1/3),this.g=So(o,s,e),this.b=So(o,s,e-1/3)}return qe.colorSpaceToWorking(this,r),this}setStyle(e,t=Gt){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=Gt){const n=Za[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=pn(e.r),this.g=pn(e.g),this.b=pn(e.b),this}copyLinearToSRGB(e){return this.r=hi(e.r),this.g=hi(e.g),this.b=hi(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Gt){return qe.workingToColorSpace(bt.copy(this),e),Math.round(Ge(bt.r*255,0,255))*65536+Math.round(Ge(bt.g*255,0,255))*256+Math.round(Ge(bt.b*255,0,255))}getHexString(e=Gt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=qe.workingColorSpace){qe.workingToColorSpace(bt.copy(this),t);const n=bt.r,r=bt.g,s=bt.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=qe.workingColorSpace){return qe.workingToColorSpace(bt.copy(this),t),e.r=bt.r,e.g=bt.g,e.b=bt.b,e}getStyle(e=Gt){qe.workingToColorSpace(bt.copy(this),e);const t=bt.r,n=bt.g,r=bt.b;return e!==Gt?`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(Cn),this.setHSL(Cn.h+e,Cn.s+t,Cn.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(Cn),e.getHSL(yr);const n=to(Cn.h,yr.h,t),r=to(Cn.s,yr.s,t),s=to(Cn.l,yr.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 bt=new Ve;Ve.NAMES=Za;let Dh=0;class Mi extends Bn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Dh++}),this.uuid=Bi(),this.name="",this.type="Material",this.blending=ri,this.side=yn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=os,this.blendDst=as,this.blendEquation=Un,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ve(0,0,0),this.blendAlpha=0,this.depthFunc=si,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=La,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ci,this.stencilZFail=ci,this.stencilZPass=ci,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!==ri&&(n.blending=this.blending),this.side!==yn&&(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!==os&&(n.blendSrc=this.blendSrc),this.blendDst!==as&&(n.blendDst=this.blendDst),this.blendEquation!==Un&&(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!==La&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ci&&(n.stencilFail=this.stencilFail),this.stencilZFail!==ci&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==ci&&(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 Sr extends Mi{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ve(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 en,this.combine=ya,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 mt=new U,Er=new Ie;let Lh=0;class ln{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:Lh++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Ua,this.updateRanges=[],this.gpuType=dn,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++)Er.fromBufferAttribute(this,t),Er.applyMatrix3(e),this.setXY(t,Er.x,Er.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)mt.fromBufferAttribute(this,t),mt.applyMatrix3(e),this.setXYZ(t,mt.x,mt.y,mt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)mt.fromBufferAttribute(this,t),mt.applyMatrix4(e),this.setXYZ(t,mt.x,mt.y,mt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)mt.fromBufferAttribute(this,t),mt.applyNormalMatrix(e),this.setXYZ(t,mt.x,mt.y,mt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)mt.fromBufferAttribute(this,t),mt.transformDirection(e),this.setXYZ(t,mt.x,mt.y,mt.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=zi(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Lt(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=zi(t,this.array)),t}setX(e,t){return this.normalized&&(t=Lt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=zi(t,this.array)),t}setY(e,t){return this.normalized&&(t=Lt(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=zi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Lt(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=zi(t,this.array)),t}setW(e,t){return this.normalized&&(t=Lt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Lt(t,this.array),n=Lt(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=Lt(t,this.array),n=Lt(n,this.array),r=Lt(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=Lt(t,this.array),n=Lt(n,this.array),r=Lt(r,this.array),s=Lt(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!==Ua&&(e.usage=this.usage),e}}class Ka extends ln{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Qa extends ln{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Ze extends ln{constructor(e,t,n){super(new Float32Array(e),t,n)}}let Ih=0;const Wt=new rt,Eo=new dt,yi=new U,Bt=new ki,Xi=new ki,St=new U;class gt extends Bn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ih++}),this.uuid=Bi(),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(Fa(e)?Qa:Ka)(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 Eo.lookAt(e),Eo.updateMatrix(),this.applyMatrix4(Eo.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(yi).negate(),this.translate(yi.x,yi.y,yi.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 Ze(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 ki);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];Bt.setFromBufferAttribute(s),this.morphTargetsRelative?(St.addVectors(this.boundingBox.min,Bt.min),this.boundingBox.expandByPoint(St),St.addVectors(this.boundingBox.max,Bt.max),this.boundingBox.expandByPoint(St)):(this.boundingBox.expandByPoint(Bt.min),this.boundingBox.expandByPoint(Bt.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 mr);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(Bt.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){const a=t[s];Xi.setFromBufferAttribute(a),this.morphTargetsRelative?(St.addVectors(Bt.min,Xi.min),Bt.expandByPoint(St),St.addVectors(Bt.max,Xi.max),Bt.expandByPoint(St)):(Bt.expandByPoint(Xi.min),Bt.expandByPoint(Xi.max))}Bt.getCenter(n);let r=0;for(let s=0,o=e.count;s<o;s++)St.fromBufferAttribute(e,s),r=Math.max(r,n.distanceToSquared(St));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++)St.fromBufferAttribute(a,l),c&&(yi.fromBufferAttribute(e,l),St.add(yi)),r=Math.max(r,n.distanceToSquared(St))}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 ln(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 Ie,m=new Ie,g=new Ie,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 ln(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++)St.fromBufferAttribute(e,t),St.normalize(),e.setXYZ(t,St.x,St.y,St.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 ln(d,u,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new gt,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 Ja=new rt,Gn=new vr,Tr=new mr,el=new U,br=new U,wr=new U,Ar=new U,To=new U,Rr=new U,tl=new U,Cr=new U;class _e extends dt{constructor(e=new gt,t=new Sr){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){Rr.set(0,0,0);for(let c=0,l=s.length;c<l;c++){const u=a[c],f=s[c];u!==0&&(To.fromBufferAttribute(f,e),o?Rr.addScaledVector(To,u):Rr.addScaledVector(To.sub(t),u))}t.add(Rr)}return t}raycast(e,t){const n=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Tr.copy(n.boundingSphere),Tr.applyMatrix4(s),Gn.copy(e.ray).recast(e.near),!(Tr.containsPoint(Gn.origin)===!1&&(Gn.intersectSphere(Tr,el)===null||Gn.origin.distanceToSquared(el)>(e.far-e.near)**2))&&(Ja.copy(s).invert(),Gn.copy(e.ray).applyMatrix4(Ja),!(n.boundingBox!==null&&Gn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Gn)))}_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=Pr(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=Pr(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=Pr(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=Pr(this,o,e,n,l,u,f,w,b,_),r&&(r.faceIndex=Math.floor(p/3),t.push(r))}}}}function Uh(i,e,t,n,r,s,o,a){let c;if(e.side===Dt?c=n.intersectTriangle(o,s,r,!0,a):c=n.intersectTriangle(r,s,o,e.side===yn,a),c===null)return null;Cr.copy(a),Cr.applyMatrix4(i.matrixWorld);const l=t.ray.origin.distanceTo(Cr);return l<t.near||l>t.far?null:{distance:l,point:Cr.clone(),object:i}}function Pr(i,e,t,n,r,s,o,a,c,l){i.getVertexPosition(a,br),i.getVertexPosition(c,wr),i.getVertexPosition(l,Ar);const u=Uh(i,e,t,n,br,wr,Ar,tl);if(u){const f=new U;Vt.getBarycoord(tl,br,wr,Ar,f),r&&(u.uv=Vt.getInterpolatedAttribute(r,a,c,l,f,new Ie)),s&&(u.uv1=Vt.getInterpolatedAttribute(s,a,c,l,f,new Ie)),o&&(u.normal=Vt.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};Vt.getNormal(br,wr,Ar,d.normal),u.face=d,u.barycoord=f}return u}class _t extends gt{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 Ze(l,3)),this.setAttribute("normal",new Ze(u,3)),this.setAttribute("uv",new Ze(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,$=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 de=Ne*x-z;le[y]=de*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,de=d+Me+Q*(pe+1),Xe=d+(Me+1)+Q*(pe+1),je=d+(Me+1)+Q*pe;c.push(Ne,de,je),c.push(de,Xe,je),$+=6}a.addGroup(m,$,M),m+=$,d+=se}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new _t(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Si(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 Rt(i){const e={};for(let t=0;t<i.length;t++){const n=Si(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 nl(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:qe.workingColorSpace}const Oh={clone:Si,merge:Rt};var Fh=`void main() {
18
+ */const Wo="180",er={ROTATE:0,DOLLY:1,PAN:2},tr={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},td=0,Lc=1,nd=2,Oc=1,id=2,Gn=3,ni=0,Ht=1,On=2,ii=0,nr=1,Ic=2,Nc=3,Uc=4,rd=5,Mi=100,sd=101,od=102,ad=103,ld=104,cd=200,ud=201,hd=202,fd=203,Xo=204,jo=205,dd=206,pd=207,md=208,_d=209,gd=210,vd=211,xd=212,yd=213,Md=214,Yo=0,qo=1,$o=2,ir=3,Zo=4,Ko=5,Jo=6,Qo=7,Fc=0,Ed=1,bd=2,ri=0,Sd=1,Td=2,wd=3,Ad=4,Rd=5,Cd=6,Pd=7,Bc=300,rr=301,sr=302,ea=303,ta=304,xs=306,na=1e3,Ei=1001,ia=1002,vn=1003,Dd=1004,ys=1005,In=1006,ra=1007,bi=1008,Nn=1009,zc=1010,Vc=1011,zr=1012,sa=1013,Si=1014,Wn=1015,Vr=1016,oa=1017,aa=1018,Hr=1020,Hc=35902,kc=35899,Gc=1021,Wc=1022,xn=1023,kr=1026,Gr=1027,Xc=1028,la=1029,jc=1030,ca=1031,ua=1033,Ms=33776,Es=33777,bs=33778,Ss=33779,ha=35840,fa=35841,da=35842,pa=35843,ma=36196,_a=37492,ga=37496,va=37808,xa=37809,ya=37810,Ma=37811,Ea=37812,ba=37813,Sa=37814,Ta=37815,wa=37816,Aa=37817,Ra=37818,Ca=37819,Pa=37820,Da=37821,La=36492,Oa=36494,Ia=36495,Na=36283,Ua=36284,Fa=36285,Ba=36286,Ld=3200,Od=3201,Yc=0,Id=1,si="",rn="srgb",or="srgb-linear",Ts="linear",tt="srgb",ar=7680,qc=519,Nd=512,Ud=513,Fd=514,$c=515,Bd=516,zd=517,Vd=518,Hd=519,Zc=35044,Kc="300 es",Un=2e3,ws=2001;class Ti{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const r=i[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const r=i.slice(0);for(let s=0,o=r.length;s<o;s++)r[s].call(this,e);e.target=null}}}const It=["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"],Wr=Math.PI/180,za=180/Math.PI;function Xr(){const n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(It[n&255]+It[n>>8&255]+It[n>>16&255]+It[n>>24&255]+"-"+It[e&255]+It[e>>8&255]+"-"+It[e>>16&15|64]+It[e>>24&255]+"-"+It[t&63|128]+It[t>>8&255]+"-"+It[t>>16&255]+It[t>>24&255]+It[i&255]+It[i>>8&255]+It[i>>16&255]+It[i>>24&255]).toLowerCase()}function Xe(n,e,t){return Math.max(e,Math.min(t,n))}function kd(n,e){return(n%e+e)%e}function Va(n,e,t){return(1-t)*n+t*e}function jr(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function kt(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}const Gd={DEG2RAD:Wr};class Ne{constructor(e=0,t=0){Ne.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Xe(this.x,e.x,t.x),this.y=Xe(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Xe(this.x,e,t),this.y=Xe(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Xe(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Xe(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),r=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*i-o*r+e.x,this.y=s*r+o*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ct{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,s,o,a){let l=i[r+0],c=i[r+1],u=i[r+2],h=i[r+3];const d=s[o+0],p=s[o+1],g=s[o+2],y=s[o+3];if(a===0){e[t+0]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h;return}if(a===1){e[t+0]=d,e[t+1]=p,e[t+2]=g,e[t+3]=y;return}if(h!==y||l!==d||c!==p||u!==g){let m=1-a;const f=l*d+c*p+u*g+h*y,w=f>=0?1:-1,T=1-f*f;if(T>Number.EPSILON){const S=Math.sqrt(T),b=Math.atan2(S,f*w);m=Math.sin(m*b)/S,a=Math.sin(a*b)/S}const _=a*w;if(l=l*m+d*_,c=c*m+p*_,u=u*m+g*_,h=h*m+y*_,m===1-a){const S=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=S,c*=S,u*=S,h*=S}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,i,r,s,o){const a=i[r],l=i[r+1],c=i[r+2],u=i[r+3],h=s[o],d=s[o+1],p=s[o+2],g=s[o+3];return e[t]=a*g+u*h+l*p-c*d,e[t+1]=l*g+u*d+c*h-a*p,e[t+2]=c*g+u*p+a*d-l*h,e[t+3]=u*g-a*h-l*d-c*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,r=e._y,s=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(i/2),u=a(r/2),h=a(s/2),d=l(i/2),p=l(r/2),g=l(s/2);switch(o){case"XYZ":this._x=d*u*h+c*p*g,this._y=c*p*h-d*u*g,this._z=c*u*g+d*p*h,this._w=c*u*h-d*p*g;break;case"YXZ":this._x=d*u*h+c*p*g,this._y=c*p*h-d*u*g,this._z=c*u*g-d*p*h,this._w=c*u*h+d*p*g;break;case"ZXY":this._x=d*u*h-c*p*g,this._y=c*p*h+d*u*g,this._z=c*u*g+d*p*h,this._w=c*u*h-d*p*g;break;case"ZYX":this._x=d*u*h-c*p*g,this._y=c*p*h+d*u*g,this._z=c*u*g-d*p*h,this._w=c*u*h+d*p*g;break;case"YZX":this._x=d*u*h+c*p*g,this._y=c*p*h+d*u*g,this._z=c*u*g-d*p*h,this._w=c*u*h-d*p*g;break;case"XZY":this._x=d*u*h-c*p*g,this._y=c*p*h-d*u*g,this._z=c*u*g+d*p*h,this._w=c*u*h+d*p*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],r=t[4],s=t[8],o=t[1],a=t[5],l=t[9],c=t[2],u=t[6],h=t[10],d=i+a+h;if(d>0){const p=.5/Math.sqrt(d+1);this._w=.25/p,this._x=(u-l)*p,this._y=(s-c)*p,this._z=(o-r)*p}else if(i>a&&i>h){const p=2*Math.sqrt(1+i-a-h);this._w=(u-l)/p,this._x=.25*p,this._y=(r+o)/p,this._z=(s+c)/p}else if(a>h){const p=2*Math.sqrt(1+a-i-h);this._w=(s-c)/p,this._x=(r+o)/p,this._y=.25*p,this._z=(l+u)/p}else{const p=2*Math.sqrt(1+h-i-a);this._w=(o-r)/p,this._x=(s+c)/p,this._y=(l+u)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Xe(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const r=Math.min(1,t/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,r=e._y,s=e._z,o=e._w,a=t._x,l=t._y,c=t._z,u=t._w;return this._x=i*u+o*a+r*c-s*l,this._y=r*u+o*l+s*a-i*c,this._z=s*u+o*c+i*l-r*a,this._w=o*u-i*a-r*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const i=this._x,r=this._y,s=this._z,o=this._w;let a=o*e._w+i*e._x+r*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=i,this._y=r,this._z=s,this;const l=1-a*a;if(l<=Number.EPSILON){const p=1-t;return this._w=p*o+t*this._w,this._x=p*i+t*this._x,this._y=p*r+t*this._y,this._z=p*s+t*this._z,this.normalize(),this}const c=Math.sqrt(l),u=Math.atan2(c,a),h=Math.sin((1-t)*u)/c,d=Math.sin(t*u)/c;return this._w=o*h+this._w*d,this._x=i*h+this._x*d,this._y=r*h+this._y*d,this._z=s*h+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class L{constructor(e=0,t=0,i=0){L.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Jc.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Jc.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*r,this.y=s[1]*t+s[4]*i+s[7]*r,this.z=s[2]*t+s[5]*i+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,s=e.elements,o=1/(s[3]*t+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*r+s[12])*o,this.y=(s[1]*t+s[5]*i+s[9]*r+s[13])*o,this.z=(s[2]*t+s[6]*i+s[10]*r+s[14])*o,this}applyQuaternion(e){const t=this.x,i=this.y,r=this.z,s=e.x,o=e.y,a=e.z,l=e.w,c=2*(o*r-a*i),u=2*(a*t-s*r),h=2*(s*i-o*t);return this.x=t+l*c+o*h-a*u,this.y=i+l*u+a*c-s*h,this.z=r+l*h+s*u-o*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r,this.y=s[1]*t+s[5]*i+s[9]*r,this.z=s[2]*t+s[6]*i+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Xe(this.x,e.x,t.x),this.y=Xe(this.y,e.y,t.y),this.z=Xe(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Xe(this.x,e,t),this.y=Xe(this.y,e,t),this.z=Xe(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Xe(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,r=e.y,s=e.z,o=t.x,a=t.y,l=t.z;return this.x=r*l-s*a,this.y=s*o-i*l,this.z=i*a-r*o,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Ha.copy(this).projectOnVector(e),this.sub(Ha)}reflect(e){return this.sub(Ha.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Xe(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Ha=new L,Jc=new Ct;class ke{constructor(e,t,i,r,s,o,a,l,c){ke.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,o,a,l,c)}set(e,t,i,r,s,o,a,l,c){const u=this.elements;return u[0]=e,u[1]=r,u[2]=a,u[3]=t,u[4]=s,u[5]=l,u[6]=i,u[7]=o,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,s=this.elements,o=i[0],a=i[3],l=i[6],c=i[1],u=i[4],h=i[7],d=i[2],p=i[5],g=i[8],y=r[0],m=r[3],f=r[6],w=r[1],T=r[4],_=r[7],S=r[2],b=r[5],A=r[8];return s[0]=o*y+a*w+l*S,s[3]=o*m+a*T+l*b,s[6]=o*f+a*_+l*A,s[1]=c*y+u*w+h*S,s[4]=c*m+u*T+h*b,s[7]=c*f+u*_+h*A,s[2]=d*y+p*w+g*S,s[5]=d*m+p*T+g*b,s[8]=d*f+p*_+g*A,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8];return t*o*u-t*a*c-i*s*u+i*a*l+r*s*c-r*o*l}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=u*o-a*c,d=a*l-u*s,p=c*s-o*l,g=t*h+i*d+r*p;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/g;return e[0]=h*y,e[1]=(r*c-u*i)*y,e[2]=(a*i-r*o)*y,e[3]=d*y,e[4]=(u*t-r*l)*y,e[5]=(r*s-a*t)*y,e[6]=p*y,e[7]=(i*l-c*t)*y,e[8]=(o*t-i*s)*y,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,s,o,a){const l=Math.cos(s),c=Math.sin(s);return this.set(i*l,i*c,-i*(l*o+c*a)+o+e,-r*c,r*l,-r*(-c*o+l*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(ka.makeScale(e,t)),this}rotate(e){return this.premultiply(ka.makeRotation(-e)),this}translate(e,t){return this.premultiply(ka.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const ka=new ke;function Qc(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function As(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function Wd(){const n=As("canvas");return n.style.display="block",n}const eu={};function Yr(n){n in eu||(eu[n]=!0,console.warn(n))}function Xd(n,e,t){return new Promise(function(i,r){function s(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:r();break;case n.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:i()}}setTimeout(s,t)})}const tu=new ke().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),nu=new ke().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function jd(){const n={enabled:!0,workingColorSpace:or,spaces:{},convert:function(r,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===tt&&(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===tt&&(r.r=lr(r.r),r.g=lr(r.g),r.b=lr(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===si?Ts: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 Yr("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return Yr("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(r,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return n.define({[or]:{primaries:e,whitePoint:i,transfer:Ts,toXYZ:tu,fromXYZ:nu,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:rn},outputColorSpaceConfig:{drawingBufferColorSpace:rn}},[rn]:{primaries:e,whitePoint:i,transfer:tt,toXYZ:tu,fromXYZ:nu,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:rn}}}),n}const Ze=jd();function Xn(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function lr(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let cr;class Yd{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{cr===void 0&&(cr=As("canvas")),cr.width=e.width,cr.height=e.height;const r=cr.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),i=cr}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=As("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const r=i.getImageData(0,0,e.width,e.height),s=r.data;for(let o=0;o<s.length;o++)s[o]=Xn(s[o]/255)*255;return i.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(Xn(t[i]/255)*255):t[i]=Xn(t[i]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let qd=0;class Ga{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:qd++}),this.uuid=Xr(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let o=0,a=r.length;o<a;o++)r[o].isDataTexture?s.push(Wa(r[o].image)):s.push(Wa(r[o]))}else s=Wa(r);i.url=s}return t||(e.images[this.uuid]=i),i}}function Wa(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?Yd.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let $d=0;const Xa=new L;class Gt extends Ti{constructor(e=Gt.DEFAULT_IMAGE,t=Gt.DEFAULT_MAPPING,i=Ei,r=Ei,s=In,o=bi,a=xn,l=Nn,c=Gt.DEFAULT_ANISOTROPY,u=si){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:$d++}),this.uuid=Xr(),this.name="",this.source=new Ga(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=s,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new Ne(0,0),this.repeat=new Ne(1,1),this.center=new Ne(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ke,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Xa).x}get height(){return this.source.getSize(Xa).y}get depth(){return this.source.getSize(Xa).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(i===void 0){console.warn(`THREE.Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Texture.setValues(): property '${t}' does not exist.`);continue}r&&i&&r.isVector2&&i.isVector2||r&&i&&r.isVector3&&i.isVector3||r&&i&&r.isMatrix3&&i.isMatrix3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Bc)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case na:e.x=e.x-Math.floor(e.x);break;case Ei:e.x=e.x<0?0:1;break;case ia: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 na:e.y=e.y-Math.floor(e.y);break;case Ei:e.y=e.y<0?0:1;break;case ia: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++}}Gt.DEFAULT_IMAGE=null,Gt.DEFAULT_MAPPING=Bc,Gt.DEFAULT_ANISOTROPY=1;class gt{constructor(e=0,t=0,i=0,r=1){gt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*r+o[12]*s,this.y=o[1]*t+o[5]*i+o[9]*r+o[13]*s,this.z=o[2]*t+o[6]*i+o[10]*r+o[14]*s,this.w=o[3]*t+o[7]*i+o[11]*r+o[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,s;const l=e.elements,c=l[0],u=l[4],h=l[8],d=l[1],p=l[5],g=l[9],y=l[2],m=l[6],f=l[10];if(Math.abs(u-d)<.01&&Math.abs(h-y)<.01&&Math.abs(g-m)<.01){if(Math.abs(u+d)<.1&&Math.abs(h+y)<.1&&Math.abs(g+m)<.1&&Math.abs(c+p+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const T=(c+1)/2,_=(p+1)/2,S=(f+1)/2,b=(u+d)/4,A=(h+y)/4,C=(g+m)/4;return T>_&&T>S?T<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(T),r=b/i,s=A/i):_>S?_<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(_),i=b/r,s=C/r):S<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(S),i=A/s,r=C/s),this.set(i,r,s,t),this}let w=Math.sqrt((m-g)*(m-g)+(h-y)*(h-y)+(d-u)*(d-u));return Math.abs(w)<.001&&(w=1),this.x=(m-g)/w,this.y=(h-y)/w,this.z=(d-u)/w,this.w=Math.acos((c+p+f-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Xe(this.x,e.x,t.x),this.y=Xe(this.y,e.y,t.y),this.z=Xe(this.z,e.z,t.z),this.w=Xe(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Xe(this.x,e,t),this.y=Xe(this.y,e,t),this.z=Xe(this.z,e,t),this.w=Xe(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Xe(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Zd extends Ti{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:In,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new gt(0,0,e,t),this.scissorTest=!1,this.viewport=new gt(0,0,e,t);const r={width:e,height:t,depth:i.depth},s=new Gt(r);this.textures=[];const o=i.count;for(let a=0;a<o;a++)this.textures[a]=s.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview}_setTextureOptions(e={}){const t={minFilter:In,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let i=0;i<this.textures.length;i++)this.textures[i].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=i,this.textures[r].isArrayTexture=this.textures[r].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t<i;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const r=Object.assign({},e.textures[t].image);this.textures[t].source=new Ga(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 wi extends Zd{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class iu extends Gt{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=vn,this.minFilter=vn,this.wrapR=Ei,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Kd extends Gt{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=vn,this.minFilter=vn,this.wrapR=Ei,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class qr{constructor(e=new L(1/0,1/0,1/0),t=new L(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(yn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(yn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=yn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const i=e.geometry;if(i!==void 0){const s=i.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=s.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,yn):yn.fromBufferAttribute(s,o),yn.applyMatrix4(e.matrixWorld),this.expandByPoint(yn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Rs.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Rs.copy(i.boundingBox)),Rs.applyMatrix4(e.matrixWorld),this.union(Rs)}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,yn),yn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter($r),Cs.subVectors(this.max,$r),ur.subVectors(e.a,$r),hr.subVectors(e.b,$r),fr.subVectors(e.c,$r),oi.subVectors(hr,ur),ai.subVectors(fr,hr),Ai.subVectors(ur,fr);let t=[0,-oi.z,oi.y,0,-ai.z,ai.y,0,-Ai.z,Ai.y,oi.z,0,-oi.x,ai.z,0,-ai.x,Ai.z,0,-Ai.x,-oi.y,oi.x,0,-ai.y,ai.x,0,-Ai.y,Ai.x,0];return!ja(t,ur,hr,fr,Cs)||(t=[1,0,0,0,1,0,0,0,1],!ja(t,ur,hr,fr,Cs))?!1:(Ps.crossVectors(oi,ai),t=[Ps.x,Ps.y,Ps.z],ja(t,ur,hr,fr,Cs))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,yn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(yn).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:(jn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),jn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),jn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),jn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),jn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),jn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),jn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),jn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(jn),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 jn=[new L,new L,new L,new L,new L,new L,new L,new L],yn=new L,Rs=new qr,ur=new L,hr=new L,fr=new L,oi=new L,ai=new L,Ai=new L,$r=new L,Cs=new L,Ps=new L,Ri=new L;function ja(n,e,t,i,r){for(let s=0,o=n.length-3;s<=o;s+=3){Ri.fromArray(n,s);const a=r.x*Math.abs(Ri.x)+r.y*Math.abs(Ri.y)+r.z*Math.abs(Ri.z),l=e.dot(Ri),c=t.dot(Ri),u=i.dot(Ri);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>a)return!1}return!0}const Jd=new qr,Zr=new L,Ya=new L;class Ds{constructor(e=new L,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;t!==void 0?i.copy(t):Jd.setFromPoints(e).getCenter(i);let r=0;for(let s=0,o=e.length;s<o;s++)r=Math.max(r,i.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Zr.subVectors(e,this.center);const t=Zr.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(Zr,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Ya.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Zr.copy(e.center).add(Ya)),this.expandByPoint(Zr.copy(e.center).sub(Ya))),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 Yn=new L,qa=new L,Ls=new L,li=new L,$a=new L,Os=new L,Za=new L;class Is{constructor(e=new L,t=new L(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,Yn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Yn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Yn.copy(this.origin).addScaledVector(this.direction,t),Yn.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){qa.copy(e).add(t).multiplyScalar(.5),Ls.copy(t).sub(e).normalize(),li.copy(this.origin).sub(qa);const s=e.distanceTo(t)*.5,o=-this.direction.dot(Ls),a=li.dot(this.direction),l=-li.dot(Ls),c=li.lengthSq(),u=Math.abs(1-o*o);let h,d,p,g;if(u>0)if(h=o*l-a,d=o*a-l,g=s*u,h>=0)if(d>=-g)if(d<=g){const y=1/u;h*=y,d*=y,p=h*(h+o*d+2*a)+d*(o*h+d+2*l)+c}else d=s,h=Math.max(0,-(o*d+a)),p=-h*h+d*(d+2*l)+c;else d=-s,h=Math.max(0,-(o*d+a)),p=-h*h+d*(d+2*l)+c;else d<=-g?(h=Math.max(0,-(-o*s+a)),d=h>0?-s:Math.min(Math.max(-s,-l),s),p=-h*h+d*(d+2*l)+c):d<=g?(h=0,d=Math.min(Math.max(-s,-l),s),p=d*(d+2*l)+c):(h=Math.max(0,-(o*s+a)),d=h>0?s:Math.min(Math.max(-s,-l),s),p=-h*h+d*(d+2*l)+c);else d=o>0?-s:s,h=Math.max(0,-(o*d+a)),p=-h*h+d*(d+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,h),r&&r.copy(qa).addScaledVector(Ls,d),p}intersectSphere(e,t){Yn.subVectors(e.center,this.origin);const i=Yn.dot(this.direction),r=Yn.dot(Yn)-i*i,s=e.radius*e.radius;if(r>s)return null;const o=Math.sqrt(s-r),a=i-o,l=i+o;return l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,s,o,a,l;const c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,d=this.origin;return c>=0?(i=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(i=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),u>=0?(s=(e.min.y-d.y)*u,o=(e.max.y-d.y)*u):(s=(e.max.y-d.y)*u,o=(e.min.y-d.y)*u),i>o||s>r||((s>i||isNaN(i))&&(i=s),(o<r||isNaN(r))&&(r=o),h>=0?(a=(e.min.z-d.z)*h,l=(e.max.z-d.z)*h):(a=(e.max.z-d.z)*h,l=(e.min.z-d.z)*h),i>l||a>r)||((a>i||i!==i)&&(i=a),(l<r||r!==r)&&(r=l),r<0)?null:this.at(i>=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,Yn)!==null}intersectTriangle(e,t,i,r,s){$a.subVectors(t,e),Os.subVectors(i,e),Za.crossVectors($a,Os);let o=this.direction.dot(Za),a;if(o>0){if(r)return null;a=1}else if(o<0)a=-1,o=-o;else return null;li.subVectors(this.origin,e);const l=a*this.direction.dot(Os.crossVectors(li,Os));if(l<0)return null;const c=a*this.direction.dot($a.cross(li));if(c<0||l+c>o)return null;const u=-a*li.dot(Za);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 ct{constructor(e,t,i,r,s,o,a,l,c,u,h,d,p,g,y,m){ct.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,o,a,l,c,u,h,d,p,g,y,m)}set(e,t,i,r,s,o,a,l,c,u,h,d,p,g,y,m){const f=this.elements;return f[0]=e,f[4]=t,f[8]=i,f[12]=r,f[1]=s,f[5]=o,f[9]=a,f[13]=l,f[2]=c,f[6]=u,f[10]=h,f[14]=d,f[3]=p,f[7]=g,f[11]=y,f[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new ct().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,i=e.elements,r=1/dr.setFromMatrixColumn(e,0).length(),s=1/dr.setFromMatrixColumn(e,1).length(),o=1/dr.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*o,t[9]=i[9]*o,t[10]=i[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,r=e.y,s=e.z,o=Math.cos(i),a=Math.sin(i),l=Math.cos(r),c=Math.sin(r),u=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const d=o*u,p=o*h,g=a*u,y=a*h;t[0]=l*u,t[4]=-l*h,t[8]=c,t[1]=p+g*c,t[5]=d-y*c,t[9]=-a*l,t[2]=y-d*c,t[6]=g+p*c,t[10]=o*l}else if(e.order==="YXZ"){const d=l*u,p=l*h,g=c*u,y=c*h;t[0]=d+y*a,t[4]=g*a-p,t[8]=o*c,t[1]=o*h,t[5]=o*u,t[9]=-a,t[2]=p*a-g,t[6]=y+d*a,t[10]=o*l}else if(e.order==="ZXY"){const d=l*u,p=l*h,g=c*u,y=c*h;t[0]=d-y*a,t[4]=-o*h,t[8]=g+p*a,t[1]=p+g*a,t[5]=o*u,t[9]=y-d*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){const d=o*u,p=o*h,g=a*u,y=a*h;t[0]=l*u,t[4]=g*c-p,t[8]=d*c+y,t[1]=l*h,t[5]=y*c+d,t[9]=p*c-g,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){const d=o*l,p=o*c,g=a*l,y=a*c;t[0]=l*u,t[4]=y-d*h,t[8]=g*h+p,t[1]=h,t[5]=o*u,t[9]=-a*u,t[2]=-c*u,t[6]=p*h+g,t[10]=d-y*h}else if(e.order==="XZY"){const d=o*l,p=o*c,g=a*l,y=a*c;t[0]=l*u,t[4]=-h,t[8]=c*u,t[1]=d*h+y,t[5]=o*u,t[9]=p*h-g,t[2]=g*h-p,t[6]=a*u,t[10]=y*h+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Qd,e,ep)}lookAt(e,t,i){const r=this.elements;return Yt.subVectors(e,t),Yt.lengthSq()===0&&(Yt.z=1),Yt.normalize(),ci.crossVectors(i,Yt),ci.lengthSq()===0&&(Math.abs(i.z)===1?Yt.x+=1e-4:Yt.z+=1e-4,Yt.normalize(),ci.crossVectors(i,Yt)),ci.normalize(),Ns.crossVectors(Yt,ci),r[0]=ci.x,r[4]=Ns.x,r[8]=Yt.x,r[1]=ci.y,r[5]=Ns.y,r[9]=Yt.y,r[2]=ci.z,r[6]=Ns.z,r[10]=Yt.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,s=this.elements,o=i[0],a=i[4],l=i[8],c=i[12],u=i[1],h=i[5],d=i[9],p=i[13],g=i[2],y=i[6],m=i[10],f=i[14],w=i[3],T=i[7],_=i[11],S=i[15],b=r[0],A=r[4],C=r[8],M=r[12],x=r[1],N=r[5],z=r[9],Y=r[13],q=r[2],J=r[6],K=r[10],se=r[14],$=r[3],le=r[7],me=r[11],Ee=r[15];return s[0]=o*b+a*x+l*q+c*$,s[4]=o*A+a*N+l*J+c*le,s[8]=o*C+a*z+l*K+c*me,s[12]=o*M+a*Y+l*se+c*Ee,s[1]=u*b+h*x+d*q+p*$,s[5]=u*A+h*N+d*J+p*le,s[9]=u*C+h*z+d*K+p*me,s[13]=u*M+h*Y+d*se+p*Ee,s[2]=g*b+y*x+m*q+f*$,s[6]=g*A+y*N+m*J+f*le,s[10]=g*C+y*z+m*K+f*me,s[14]=g*M+y*Y+m*se+f*Ee,s[3]=w*b+T*x+_*q+S*$,s[7]=w*A+T*N+_*J+S*le,s[11]=w*C+T*z+_*K+S*me,s[15]=w*M+T*Y+_*se+S*Ee,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],r=e[8],s=e[12],o=e[1],a=e[5],l=e[9],c=e[13],u=e[2],h=e[6],d=e[10],p=e[14],g=e[3],y=e[7],m=e[11],f=e[15];return g*(+s*l*h-r*c*h-s*a*d+i*c*d+r*a*p-i*l*p)+y*(+t*l*p-t*c*d+s*o*d-r*o*p+r*c*u-s*l*u)+m*(+t*c*h-t*a*p-s*o*h+i*o*p+s*a*u-i*c*u)+f*(-r*a*u-t*l*h+t*a*d+r*o*h-i*o*d+i*l*u)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=e[9],d=e[10],p=e[11],g=e[12],y=e[13],m=e[14],f=e[15],w=h*m*c-y*d*c+y*l*p-a*m*p-h*l*f+a*d*f,T=g*d*c-u*m*c-g*l*p+o*m*p+u*l*f-o*d*f,_=u*y*c-g*h*c+g*a*p-o*y*p-u*a*f+o*h*f,S=g*h*l-u*y*l-g*a*d+o*y*d+u*a*m-o*h*m,b=t*w+i*T+r*_+s*S;if(b===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const A=1/b;return e[0]=w*A,e[1]=(y*d*s-h*m*s-y*r*p+i*m*p+h*r*f-i*d*f)*A,e[2]=(a*m*s-y*l*s+y*r*c-i*m*c-a*r*f+i*l*f)*A,e[3]=(h*l*s-a*d*s-h*r*c+i*d*c+a*r*p-i*l*p)*A,e[4]=T*A,e[5]=(u*m*s-g*d*s+g*r*p-t*m*p-u*r*f+t*d*f)*A,e[6]=(g*l*s-o*m*s-g*r*c+t*m*c+o*r*f-t*l*f)*A,e[7]=(o*d*s-u*l*s+u*r*c-t*d*c-o*r*p+t*l*p)*A,e[8]=_*A,e[9]=(g*h*s-u*y*s-g*i*p+t*y*p+u*i*f-t*h*f)*A,e[10]=(o*y*s-g*a*s+g*i*c-t*y*c-o*i*f+t*a*f)*A,e[11]=(u*a*s-o*h*s-u*i*c+t*h*c+o*i*p-t*a*p)*A,e[12]=S*A,e[13]=(u*y*r-g*h*r+g*i*d-t*y*d-u*i*m+t*h*m)*A,e[14]=(g*a*r-o*y*r-g*i*l+t*y*l+o*i*m-t*a*m)*A,e[15]=(o*h*r-u*a*r+u*i*l-t*h*l-o*i*d+t*a*d)*A,this}scale(e){const t=this.elements,i=e.x,r=e.y,s=e.z;return t[0]*=i,t[4]*=r,t[8]*=s,t[1]*=i,t[5]*=r,t[9]*=s,t[2]*=i,t[6]*=r,t[10]*=s,t[3]*=i,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),r=Math.sin(t),s=1-i,o=e.x,a=e.y,l=e.z,c=s*o,u=s*a;return this.set(c*o+i,c*a-r*l,c*l+r*a,0,c*a+r*l,u*a+i,u*l-r*o,0,c*l-r*a,u*l+r*o,s*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,s,o){return this.set(1,i,s,0,e,1,o,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){const r=this.elements,s=t._x,o=t._y,a=t._z,l=t._w,c=s+s,u=o+o,h=a+a,d=s*c,p=s*u,g=s*h,y=o*u,m=o*h,f=a*h,w=l*c,T=l*u,_=l*h,S=i.x,b=i.y,A=i.z;return r[0]=(1-(y+f))*S,r[1]=(p+_)*S,r[2]=(g-T)*S,r[3]=0,r[4]=(p-_)*b,r[5]=(1-(d+f))*b,r[6]=(m+w)*b,r[7]=0,r[8]=(g+T)*A,r[9]=(m-w)*A,r[10]=(1-(d+y))*A,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){const r=this.elements;let s=dr.set(r[0],r[1],r[2]).length();const o=dr.set(r[4],r[5],r[6]).length(),a=dr.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],Mn.copy(this);const c=1/s,u=1/o,h=1/a;return Mn.elements[0]*=c,Mn.elements[1]*=c,Mn.elements[2]*=c,Mn.elements[4]*=u,Mn.elements[5]*=u,Mn.elements[6]*=u,Mn.elements[8]*=h,Mn.elements[9]*=h,Mn.elements[10]*=h,t.setFromRotationMatrix(Mn),i.x=s,i.y=o,i.z=a,this}makePerspective(e,t,i,r,s,o,a=Un,l=!1){const c=this.elements,u=2*s/(t-e),h=2*s/(i-r),d=(t+e)/(t-e),p=(i+r)/(i-r);let g,y;if(l)g=s/(o-s),y=o*s/(o-s);else if(a===Un)g=-(o+s)/(o-s),y=-2*o*s/(o-s);else if(a===ws)g=-o/(o-s),y=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=u,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=h,c[9]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=g,c[14]=y,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,i,r,s,o,a=Un,l=!1){const c=this.elements,u=2/(t-e),h=2/(i-r),d=-(t+e)/(t-e),p=-(i+r)/(i-r);let g,y;if(l)g=1/(o-s),y=o/(o-s);else if(a===Un)g=-2/(o-s),y=-(o+s)/(o-s);else if(a===ws)g=-1/(o-s),y=-s/(o-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=u,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=h,c[9]=0,c[13]=p,c[2]=0,c[6]=0,c[10]=g,c[14]=y,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const dr=new L,Mn=new ct,Qd=new L(0,0,0),ep=new L(1,1,1),ci=new L,Ns=new L,Yt=new L,ru=new ct,su=new Ct;class En{constructor(e=0,t=0,i=0,r=En.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const r=e.elements,s=r[0],o=r[4],a=r[8],l=r[1],c=r[5],u=r[9],h=r[2],d=r[6],p=r[10];switch(t){case"XYZ":this._y=Math.asin(Xe(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Xe(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Xe(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,p),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Xe(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(Xe(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-Xe(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return ru.makeRotationFromQuaternion(e),this.setFromRotationMatrix(ru,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return su.setFromEuler(this),this.setFromQuaternion(su,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}}En.DEFAULT_ORDER="XYZ";class Ka{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 tp=0;const ou=new L,pr=new Ct,qn=new ct,Us=new L,Kr=new L,np=new L,ip=new Ct,au=new L(1,0,0),lu=new L(0,1,0),cu=new L(0,0,1),uu={type:"added"},rp={type:"removed"},mr={type:"childadded",child:null},Ja={type:"childremoved",child:null};class xt extends Ti{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:tp++}),this.uuid=Xr(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=xt.DEFAULT_UP.clone();const e=new L,t=new En,i=new Ct,r=new L(1,1,1);function s(){i.setFromEuler(t,!1)}function o(){t.setFromQuaternion(i,void 0,!1)}t._onChange(s),i._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new ct},normalMatrix:{value:new ke}}),this.matrix=new ct,this.matrixWorld=new ct,this.matrixAutoUpdate=xt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=xt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Ka,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 pr.setFromAxisAngle(e,t),this.quaternion.multiply(pr),this}rotateOnWorldAxis(e,t){return pr.setFromAxisAngle(e,t),this.quaternion.premultiply(pr),this}rotateX(e){return this.rotateOnAxis(au,e)}rotateY(e){return this.rotateOnAxis(lu,e)}rotateZ(e){return this.rotateOnAxis(cu,e)}translateOnAxis(e,t){return ou.copy(e).applyQuaternion(this.quaternion),this.position.add(ou.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(au,e)}translateY(e){return this.translateOnAxis(lu,e)}translateZ(e){return this.translateOnAxis(cu,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(qn.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?Us.copy(e):Us.set(e,t,i);const r=this.parent;this.updateWorldMatrix(!0,!1),Kr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?qn.lookAt(Kr,Us,this.up):qn.lookAt(Us,Kr,this.up),this.quaternion.setFromRotationMatrix(qn),r&&(qn.extractRotation(r.matrixWorld),pr.setFromRotationMatrix(qn),this.quaternion.premultiply(pr.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(uu),mr.child=e,this.dispatchEvent(mr),mr.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(rp),Ja.child=e,this.dispatchEvent(Ja),Ja.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),qn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),qn.multiply(e.parent.matrixWorld)),e.applyMatrix4(qn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(uu),mr.child=e,this.dispatchEvent(mr),mr.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,r=this.children.length;i<r;i++){const o=this.children[i].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Kr,e,np),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Kr,ip,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t){const i=this.parent;if(e===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(a=>({...a})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c<u;c++){const h=l[c];s(e.shapes,h)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(s(e.materials,this.material[l]));r.material=a}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let a=0;a<this.children.length;a++)r.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let a=0;a<this.animations.length;a++){const l=this.animations[a];r.animations.push(s(e.animations,l))}}if(t){const a=o(e.geometries),l=o(e.materials),c=o(e.textures),u=o(e.images),h=o(e.shapes),d=o(e.skeletons),p=o(e.animations),g=o(e.nodes);a.length>0&&(i.geometries=a),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),u.length>0&&(i.images=u),h.length>0&&(i.shapes=h),d.length>0&&(i.skeletons=d),p.length>0&&(i.animations=p),g.length>0&&(i.nodes=g)}return i.object=r,i;function o(a){const l=[];for(const c in a){const u=a[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){const r=e.children[i];this.add(r.clone())}return this}}xt.DEFAULT_UP=new L(0,1,0),xt.DEFAULT_MATRIX_AUTO_UPDATE=!0,xt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const bn=new L,$n=new L,Qa=new L,Zn=new L,_r=new L,gr=new L,hu=new L,el=new L,tl=new L,nl=new L,il=new gt,rl=new gt,sl=new gt;class sn{constructor(e=new L,t=new L,i=new L){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),bn.subVectors(e,t),r.cross(bn);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,i,r,s){bn.subVectors(r,t),$n.subVectors(i,t),Qa.subVectors(e,t);const o=bn.dot(bn),a=bn.dot($n),l=bn.dot(Qa),c=$n.dot($n),u=$n.dot(Qa),h=o*c-a*a;if(h===0)return s.set(0,0,0),null;const d=1/h,p=(c*l-a*u)*d,g=(o*u-a*l)*d;return s.set(1-p-g,g,p)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,Zn)===null?!1:Zn.x>=0&&Zn.y>=0&&Zn.x+Zn.y<=1}static getInterpolation(e,t,i,r,s,o,a,l){return this.getBarycoord(e,t,i,r,Zn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,Zn.x),l.addScaledVector(o,Zn.y),l.addScaledVector(a,Zn.z),l)}static getInterpolatedAttribute(e,t,i,r,s,o){return il.setScalar(0),rl.setScalar(0),sl.setScalar(0),il.fromBufferAttribute(e,t),rl.fromBufferAttribute(e,i),sl.fromBufferAttribute(e,r),o.setScalar(0),o.addScaledVector(il,s.x),o.addScaledVector(rl,s.y),o.addScaledVector(sl,s.z),o}static isFrontFacing(e,t,i,r){return bn.subVectors(i,t),$n.subVectors(e,t),bn.cross($n).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return bn.subVectors(this.c,this.b),$n.subVectors(this.a,this.b),bn.cross($n).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return sn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return sn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,s){return sn.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}containsPoint(e){return sn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return sn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,r=this.b,s=this.c;let o,a;_r.subVectors(r,i),gr.subVectors(s,i),el.subVectors(e,i);const l=_r.dot(el),c=gr.dot(el);if(l<=0&&c<=0)return t.copy(i);tl.subVectors(e,r);const u=_r.dot(tl),h=gr.dot(tl);if(u>=0&&h<=u)return t.copy(r);const d=l*h-u*c;if(d<=0&&l>=0&&u<=0)return o=l/(l-u),t.copy(i).addScaledVector(_r,o);nl.subVectors(e,s);const p=_r.dot(nl),g=gr.dot(nl);if(g>=0&&p<=g)return t.copy(s);const y=p*c-l*g;if(y<=0&&c>=0&&g<=0)return a=c/(c-g),t.copy(i).addScaledVector(gr,a);const m=u*g-p*h;if(m<=0&&h-u>=0&&p-g>=0)return hu.subVectors(s,r),a=(h-u)/(h-u+(p-g)),t.copy(r).addScaledVector(hu,a);const f=1/(m+y+d);return o=y*f,a=d*f,t.copy(i).addScaledVector(_r,o).addScaledVector(gr,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const fu={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},ui={h:0,s:0,l:0},Fs={h:0,s:0,l:0};function ol(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class je{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=rn){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,i,r=Ze.workingColorSpace){return this.r=e,this.g=t,this.b=i,Ze.colorSpaceToWorking(this,r),this}setHSL(e,t,i,r=Ze.workingColorSpace){if(e=kd(e,1),t=Xe(t,0,1),i=Xe(i,0,1),t===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+t):i+t-i*t,o=2*i-s;this.r=ol(o,s,e+1/3),this.g=ol(o,s,e),this.b=ol(o,s,e-1/3)}return Ze.colorSpaceToWorking(this,r),this}setStyle(e,t=rn){function i(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const o=r[1],a=r[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=rn){const i=fu[e.toLowerCase()];return i!==void 0?this.setHex(i,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Xn(e.r),this.g=Xn(e.g),this.b=Xn(e.b),this}copyLinearToSRGB(e){return this.r=lr(e.r),this.g=lr(e.g),this.b=lr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=rn){return Ze.workingToColorSpace(Nt.copy(this),e),Math.round(Xe(Nt.r*255,0,255))*65536+Math.round(Xe(Nt.g*255,0,255))*256+Math.round(Xe(Nt.b*255,0,255))}getHexString(e=rn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ze.workingColorSpace){Ze.workingToColorSpace(Nt.copy(this),t);const i=Nt.r,r=Nt.g,s=Nt.b,o=Math.max(i,r,s),a=Math.min(i,r,s);let l,c;const u=(a+o)/2;if(a===o)l=0,c=0;else{const h=o-a;switch(c=u<=.5?h/(o+a):h/(2-o-a),o){case i:l=(r-s)/h+(r<s?6:0);break;case r:l=(s-i)/h+2;break;case s:l=(i-r)/h+4;break}l/=6}return e.h=l,e.s=c,e.l=u,e}getRGB(e,t=Ze.workingColorSpace){return Ze.workingToColorSpace(Nt.copy(this),t),e.r=Nt.r,e.g=Nt.g,e.b=Nt.b,e}getStyle(e=rn){Ze.workingToColorSpace(Nt.copy(this),e);const t=Nt.r,i=Nt.g,r=Nt.b;return e!==rn?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,t,i){return this.getHSL(ui),this.setHSL(ui.h+e,ui.s+t,ui.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(ui),e.getHSL(Fs);const i=Va(ui.h,Fs.h,t),r=Va(ui.s,Fs.s,t),s=Va(ui.l,Fs.l,t);return this.setHSL(i,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,i=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*i+s[6]*r,this.g=s[1]*t+s[4]*i+s[7]*r,this.b=s[2]*t+s[5]*i+s[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Nt=new je;je.NAMES=fu;let sp=0;class vr extends Ti{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:sp++}),this.uuid=Xr(),this.name="",this.type="Material",this.blending=nr,this.side=ni,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Xo,this.blendDst=jo,this.blendEquation=Mi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new je(0,0,0),this.blendAlpha=0,this.depthFunc=ir,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=qc,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ar,this.stencilZFail=ar,this.stencilZPass=ar,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==nr&&(i.blending=this.blending),this.side!==ni&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Xo&&(i.blendSrc=this.blendSrc),this.blendDst!==jo&&(i.blendDst=this.blendDst),this.blendEquation!==Mi&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==ir&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==qc&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ar&&(i.stencilFail=this.stencilFail),this.stencilZFail!==ar&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==ar&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(s){const o=[];for(const a in s){const l=s[a];delete l.metadata,o.push(l)}return o}if(t){const s=r(e.textures),o=r(e.images);s.length>0&&(i.textures=s),o.length>0&&(i.images=o)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const r=t.length;i=new Array(r);for(let s=0;s!==r;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Bs extends vr{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new je(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new En,this.combine=Fc,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 Mt=new L,zs=new Ne;let op=0;class Sn{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:op++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=Zc,this.updateRanges=[],this.gpuType=Wn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)zs.fromBufferAttribute(this,t),zs.applyMatrix3(e),this.setXY(t,zs.x,zs.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)Mt.fromBufferAttribute(this,t),Mt.applyMatrix3(e),this.setXYZ(t,Mt.x,Mt.y,Mt.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Mt.fromBufferAttribute(this,t),Mt.applyMatrix4(e),this.setXYZ(t,Mt.x,Mt.y,Mt.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Mt.fromBufferAttribute(this,t),Mt.applyNormalMatrix(e),this.setXYZ(t,Mt.x,Mt.y,Mt.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Mt.fromBufferAttribute(this,t),Mt.transformDirection(e),this.setXYZ(t,Mt.x,Mt.y,Mt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=jr(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=kt(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=jr(t,this.array)),t}setX(e,t){return this.normalized&&(t=kt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=jr(t,this.array)),t}setY(e,t){return this.normalized&&(t=kt(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=jr(t,this.array)),t}setZ(e,t){return this.normalized&&(t=kt(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=jr(t,this.array)),t}setW(e,t){return this.normalized&&(t=kt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=kt(t,this.array),i=kt(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=kt(t,this.array),i=kt(i,this.array),r=kt(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=kt(t,this.array),i=kt(i,this.array),r=kt(r,this.array),s=kt(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Zc&&(e.usage=this.usage),e}}class du extends Sn{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class pu extends Sn{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class et extends Sn{constructor(e,t,i){super(new Float32Array(e),t,i)}}let ap=0;const on=new ct,al=new xt,xr=new L,qt=new qr,Jr=new qr,Pt=new L;class Et extends Ti{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:ap++}),this.uuid=Xr(),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(Qc(e)?pu:du)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const s=new ke().getNormalMatrix(e);i.applyNormalMatrix(s),i.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return on.makeRotationFromQuaternion(e),this.applyMatrix4(on),this}rotateX(e){return on.makeRotationX(e),this.applyMatrix4(on),this}rotateY(e){return on.makeRotationY(e),this.applyMatrix4(on),this}rotateZ(e){return on.makeRotationZ(e),this.applyMatrix4(on),this}translate(e,t,i){return on.makeTranslation(e,t,i),this.applyMatrix4(on),this}scale(e,t,i){return on.makeScale(e,t,i),this.applyMatrix4(on),this}lookAt(e){return al.lookAt(e),al.updateMatrix(),this.applyMatrix4(al.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(xr).negate(),this.translate(xr.x,xr.y,xr.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let r=0,s=e.length;r<s;r++){const o=e[r];i.push(o.x,o.y,o.z||0)}this.setAttribute("position",new et(i,3))}else{const i=Math.min(e.length,t.count);for(let r=0;r<i;r++){const s=e[r];t.setXYZ(r,s.x,s.y,s.z||0)}e.length>t.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new qr);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 L(-1/0,-1/0,-1/0),new L(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,r=t.length;i<r;i++){const s=t[i];qt.setFromBufferAttribute(s),this.morphTargetsRelative?(Pt.addVectors(this.boundingBox.min,qt.min),this.boundingBox.expandByPoint(Pt),Pt.addVectors(this.boundingBox.max,qt.max),this.boundingBox.expandByPoint(Pt)):(this.boundingBox.expandByPoint(qt.min),this.boundingBox.expandByPoint(qt.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 Ds);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 L,1/0);return}if(e){const i=this.boundingSphere.center;if(qt.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){const a=t[s];Jr.setFromBufferAttribute(a),this.morphTargetsRelative?(Pt.addVectors(qt.min,Jr.min),qt.expandByPoint(Pt),Pt.addVectors(qt.max,Jr.max),qt.expandByPoint(Pt)):(qt.expandByPoint(Jr.min),qt.expandByPoint(Jr.max))}qt.getCenter(i);let r=0;for(let s=0,o=e.count;s<o;s++)Pt.fromBufferAttribute(e,s),r=Math.max(r,i.distanceToSquared(Pt));if(t)for(let s=0,o=t.length;s<o;s++){const a=t[s],l=this.morphTargetsRelative;for(let c=0,u=a.count;c<u;c++)Pt.fromBufferAttribute(a,c),l&&(xr.fromBufferAttribute(e,c),Pt.add(xr)),r=Math.max(r,i.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 i=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Sn(new Float32Array(4*i.count),4));const o=this.getAttribute("tangent"),a=[],l=[];for(let C=0;C<i.count;C++)a[C]=new L,l[C]=new L;const c=new L,u=new L,h=new L,d=new Ne,p=new Ne,g=new Ne,y=new L,m=new L;function f(C,M,x){c.fromBufferAttribute(i,C),u.fromBufferAttribute(i,M),h.fromBufferAttribute(i,x),d.fromBufferAttribute(s,C),p.fromBufferAttribute(s,M),g.fromBufferAttribute(s,x),u.sub(c),h.sub(c),p.sub(d),g.sub(d);const N=1/(p.x*g.y-g.x*p.y);isFinite(N)&&(y.copy(u).multiplyScalar(g.y).addScaledVector(h,-p.y).multiplyScalar(N),m.copy(h).multiplyScalar(p.x).addScaledVector(u,-g.x).multiplyScalar(N),a[C].add(y),a[M].add(y),a[x].add(y),l[C].add(m),l[M].add(m),l[x].add(m))}let w=this.groups;w.length===0&&(w=[{start:0,count:e.count}]);for(let C=0,M=w.length;C<M;++C){const x=w[C],N=x.start,z=x.count;for(let Y=N,q=N+z;Y<q;Y+=3)f(e.getX(Y+0),e.getX(Y+1),e.getX(Y+2))}const T=new L,_=new L,S=new L,b=new L;function A(C){S.fromBufferAttribute(r,C),b.copy(S);const M=a[C];T.copy(M),T.sub(S.multiplyScalar(S.dot(M))).normalize(),_.crossVectors(b,M);const N=_.dot(l[C])<0?-1:1;o.setXYZW(C,T.x,T.y,T.z,N)}for(let C=0,M=w.length;C<M;++C){const x=w[C],N=x.start,z=x.count;for(let Y=N,q=N+z;Y<q;Y+=3)A(e.getX(Y+0)),A(e.getX(Y+1)),A(e.getX(Y+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new Sn(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let d=0,p=i.count;d<p;d++)i.setXYZ(d,0,0,0);const r=new L,s=new L,o=new L,a=new L,l=new L,c=new L,u=new L,h=new L;if(e)for(let d=0,p=e.count;d<p;d+=3){const g=e.getX(d+0),y=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,g),s.fromBufferAttribute(t,y),o.fromBufferAttribute(t,m),u.subVectors(o,s),h.subVectors(r,s),u.cross(h),a.fromBufferAttribute(i,g),l.fromBufferAttribute(i,y),c.fromBufferAttribute(i,m),a.add(u),l.add(u),c.add(u),i.setXYZ(g,a.x,a.y,a.z),i.setXYZ(y,l.x,l.y,l.z),i.setXYZ(m,c.x,c.y,c.z)}else for(let d=0,p=t.count;d<p;d+=3)r.fromBufferAttribute(t,d+0),s.fromBufferAttribute(t,d+1),o.fromBufferAttribute(t,d+2),u.subVectors(o,s),h.subVectors(r,s),u.cross(h),i.setXYZ(d+0,u.x,u.y,u.z),i.setXYZ(d+1,u.x,u.y,u.z),i.setXYZ(d+2,u.x,u.y,u.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)Pt.fromBufferAttribute(e,t),Pt.normalize(),e.setXYZ(t,Pt.x,Pt.y,Pt.z)}toNonIndexed(){function e(a,l){const c=a.array,u=a.itemSize,h=a.normalized,d=new c.constructor(l.length*u);let p=0,g=0;for(let y=0,m=l.length;y<m;y++){a.isInterleavedBufferAttribute?p=l[y]*a.data.stride+a.offset:p=l[y]*u;for(let f=0;f<u;f++)d[g++]=c[p++]}return new Sn(d,u,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Et,i=this.index.array,r=this.attributes;for(const a in r){const l=r[a],c=e(l,i);t.setAttribute(a,c)}const s=this.morphAttributes;for(const a in s){const l=[],c=s[a];for(let u=0,h=c.length;u<h;u++){const d=c[u],p=e(d,i);l.push(p)}t.morphAttributes[a]=l}t.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,l=o.length;a<l;a++){const c=o[a];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const r={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let h=0,d=c.length;h<d;h++){const p=c[h];u.push(p.toJSON(e.data))}u.length>0&&(r[l]=u,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere=a.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const r=e.attributes;for(const c in r){const u=r[c];this.setAttribute(c,u.clone(t))}const s=e.morphAttributes;for(const c in s){const u=[],h=s[c];for(let d=0,p=h.length;d<p;d++)u.push(h[d].clone(t));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let c=0,u=o.length;c<u;c++){const h=o[c];this.addGroup(h.start,h.count,h.materialIndex)}const a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const mu=new ct,Ci=new Is,Vs=new Ds,_u=new L,Hs=new L,ks=new L,Gs=new L,ll=new L,Ws=new L,gu=new L,Xs=new L;class ge extends xt{constructor(e=new Et,t=new Bs){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){const a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(e,t){const i=this.geometry,r=i.attributes.position,s=i.morphAttributes.position,o=i.morphTargetsRelative;t.fromBufferAttribute(r,e);const a=this.morphTargetInfluences;if(s&&a){Ws.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const u=a[l],h=s[l];u!==0&&(ll.fromBufferAttribute(h,e),o?Ws.addScaledVector(ll,u):Ws.addScaledVector(ll.sub(t),u))}t.add(Ws)}return t}raycast(e,t){const i=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Vs.copy(i.boundingSphere),Vs.applyMatrix4(s),Ci.copy(e.ray).recast(e.near),!(Vs.containsPoint(Ci.origin)===!1&&(Ci.intersectSphere(Vs,_u)===null||Ci.origin.distanceToSquared(_u)>(e.far-e.near)**2))&&(mu.copy(s).invert(),Ci.copy(e.ray).applyMatrix4(mu),!(i.boundingBox!==null&&Ci.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Ci)))}_computeIntersections(e,t,i){let r;const s=this.geometry,o=this.material,a=s.index,l=s.attributes.position,c=s.attributes.uv,u=s.attributes.uv1,h=s.attributes.normal,d=s.groups,p=s.drawRange;if(a!==null)if(Array.isArray(o))for(let g=0,y=d.length;g<y;g++){const m=d[g],f=o[m.materialIndex],w=Math.max(m.start,p.start),T=Math.min(a.count,Math.min(m.start+m.count,p.start+p.count));for(let _=w,S=T;_<S;_+=3){const b=a.getX(_),A=a.getX(_+1),C=a.getX(_+2);r=js(this,f,e,i,c,u,h,b,A,C),r&&(r.faceIndex=Math.floor(_/3),r.face.materialIndex=m.materialIndex,t.push(r))}}else{const g=Math.max(0,p.start),y=Math.min(a.count,p.start+p.count);for(let m=g,f=y;m<f;m+=3){const w=a.getX(m),T=a.getX(m+1),_=a.getX(m+2);r=js(this,o,e,i,c,u,h,w,T,_),r&&(r.faceIndex=Math.floor(m/3),t.push(r))}}else if(l!==void 0)if(Array.isArray(o))for(let g=0,y=d.length;g<y;g++){const m=d[g],f=o[m.materialIndex],w=Math.max(m.start,p.start),T=Math.min(l.count,Math.min(m.start+m.count,p.start+p.count));for(let _=w,S=T;_<S;_+=3){const b=_,A=_+1,C=_+2;r=js(this,f,e,i,c,u,h,b,A,C),r&&(r.faceIndex=Math.floor(_/3),r.face.materialIndex=m.materialIndex,t.push(r))}}else{const g=Math.max(0,p.start),y=Math.min(l.count,p.start+p.count);for(let m=g,f=y;m<f;m+=3){const w=m,T=m+1,_=m+2;r=js(this,o,e,i,c,u,h,w,T,_),r&&(r.faceIndex=Math.floor(m/3),t.push(r))}}}}function lp(n,e,t,i,r,s,o,a){let l;if(e.side===Ht?l=i.intersectTriangle(o,s,r,!0,a):l=i.intersectTriangle(r,s,o,e.side===ni,a),l===null)return null;Xs.copy(a),Xs.applyMatrix4(n.matrixWorld);const c=t.ray.origin.distanceTo(Xs);return c<t.near||c>t.far?null:{distance:c,point:Xs.clone(),object:n}}function js(n,e,t,i,r,s,o,a,l,c){n.getVertexPosition(a,Hs),n.getVertexPosition(l,ks),n.getVertexPosition(c,Gs);const u=lp(n,e,t,i,Hs,ks,Gs,gu);if(u){const h=new L;sn.getBarycoord(gu,Hs,ks,Gs,h),r&&(u.uv=sn.getInterpolatedAttribute(r,a,l,c,h,new Ne)),s&&(u.uv1=sn.getInterpolatedAttribute(s,a,l,c,h,new Ne)),o&&(u.normal=sn.getInterpolatedAttribute(o,a,l,c,h,new L),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const d={a,b:l,c,normal:new L,materialIndex:0};sn.getNormal(Hs,ks,Gs,d.normal),u.face=d,u.barycoord=h}return u}class bt extends Et{constructor(e=1,t=1,i=1,r=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:s,depthSegments:o};const a=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o);const l=[],c=[],u=[],h=[];let d=0,p=0;g("z","y","x",-1,-1,i,t,e,o,s,0),g("z","y","x",1,-1,i,t,-e,o,s,1),g("x","z","y",1,1,e,i,t,r,o,2),g("x","z","y",1,-1,e,i,-t,r,o,3),g("x","y","z",1,-1,e,t,i,r,s,4),g("x","y","z",-1,-1,e,t,-i,r,s,5),this.setIndex(l),this.setAttribute("position",new et(c,3)),this.setAttribute("normal",new et(u,3)),this.setAttribute("uv",new et(h,2));function g(y,m,f,w,T,_,S,b,A,C,M){const x=_/A,N=S/C,z=_/2,Y=S/2,q=b/2,J=A+1,K=C+1;let se=0,$=0;const le=new L;for(let me=0;me<K;me++){const Ee=me*N-Y;for(let Be=0;Be<J;Be++){const pe=Be*x-z;le[y]=pe*w,le[m]=Ee*T,le[f]=q,c.push(le.x,le.y,le.z),le[y]=0,le[m]=0,le[f]=b>0?1:-1,u.push(le.x,le.y,le.z),h.push(Be/A),h.push(1-me/C),se+=1}}for(let me=0;me<C;me++)for(let Ee=0;Ee<A;Ee++){const Be=d+Ee+J*me,pe=d+Ee+J*(me+1),qe=d+(Ee+1)+J*(me+1),Je=d+(Ee+1)+J*me;l.push(Be,pe,Je),l.push(pe,qe,Je),$+=6}a.addGroup(p,$,M),p+=$,d+=se}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new bt(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function yr(n){const e={};for(const t in n){e[t]={};for(const i in n[t]){const r=n[t][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=r.clone():Array.isArray(r)?e[t][i]=r.slice():e[t][i]=r}}return e}function Bt(n){const e={};for(let t=0;t<n.length;t++){const i=yr(n[t]);for(const r in i)e[r]=i[r]}return e}function cp(n){const e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function vu(n){const e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Ze.workingColorSpace}const up={clone:yr,merge:Bt};var hp=`void main() {
19
19
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
20
- }`,Bh=`void main() {
20
+ }`,fp=`void main() {
21
21
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
22
- }`;class Pn extends Mi{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Fh,this.fragmentShader=Bh,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=Si(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 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 il extends dt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new rt,this.projectionMatrix=new rt,this.projectionMatrixInverse=new rt,this.coordinateSystem=an,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 Dn=new U,rl=new Ie,sl=new Ie;class Xt extends il{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=eo*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Fi*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return eo*2*Math.atan(Math.tan(Fi*.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){Dn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Dn.x,Dn.y).multiplyScalar(-e/Dn.z),Dn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Dn.x,Dn.y).multiplyScalar(-e/Dn.z)}getViewSize(e,t){return this.getViewBounds(e,rl,sl),t.subVectors(sl,rl)}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(Fi*.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 Ei=-90,Ti=1;class zh extends dt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Xt(Ei,Ti,e,t);r.layers=this.layers,this.add(r);const s=new Xt(Ei,Ti,e,t);s.layers=this.layers,this.add(s);const o=new Xt(Ei,Ti,e,t);o.layers=this.layers,this.add(o);const a=new Xt(Ei,Ti,e,t);a.layers=this.layers,this.add(a);const c=new Xt(Ei,Ti,e,t);c.layers=this.layers,this.add(c);const l=new Xt(Ei,Ti,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===an)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===hr)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 ol extends It{constructor(e=[],t=oi,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 Hh extends zn{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 ol(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 hi extends vr{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=hp,this.fragmentShader=fp,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=yr(e.uniforms),this.uniformsGroups=cp(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const r in this.uniforms){const o=this.uniforms[r].value;o&&o.isTexture?t.uniforms[r]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[r]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[r]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[r]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[r]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[r]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[r]={type:"m4",value:o.toArray()}:t.uniforms[r]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class xu extends xt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ct,this.projectionMatrix=new ct,this.projectionMatrixInverse=new ct,this.coordinateSystem=Un,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 fi=new L,yu=new Ne,Mu=new Ne;class an extends xu{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=za*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Wr*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return za*2*Math.atan(Math.tan(Wr*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){fi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(fi.x,fi.y).multiplyScalar(-e/fi.z),fi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(fi.x,fi.y).multiplyScalar(-e/fi.z)}getViewSize(e,t){return this.getViewBounds(e,yu,Mu),t.subVectors(Mu,yu)}setViewOffset(e,t,i,r,s,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Wr*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,s=-.5*r;const o=this.view;if(this.view!==null&&this.view.enabled){const l=o.fullWidth,c=o.fullHeight;s+=o.offsetX*r/l,t-=o.offsetY*i/c,r*=o.width/l,i*=o.height/c}const a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const Mr=-90,Er=1;class dp extends xt{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new an(Mr,Er,e,t);r.layers=this.layers,this.add(r);const s=new an(Mr,Er,e,t);s.layers=this.layers,this.add(s);const o=new an(Mr,Er,e,t);o.layers=this.layers,this.add(o);const a=new an(Mr,Er,e,t);a.layers=this.layers,this.add(a);const l=new an(Mr,Er,e,t);l.layers=this.layers,this.add(l);const c=new an(Mr,Er,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,r,s,o,a,l]=t;for(const c of t)this.remove(c);if(e===Un)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===ws)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,o,a,l,c,u]=this.children,h=e.getRenderTarget(),d=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const y=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,r),e.render(t,s),e.setRenderTarget(i,1,r),e.render(t,o),e.setRenderTarget(i,2,r),e.render(t,a),e.setRenderTarget(i,3,r),e.render(t,l),e.setRenderTarget(i,4,r),e.render(t,c),i.texture.generateMipmaps=y,e.setRenderTarget(i,5,r),e.render(t,u),e.setRenderTarget(h,d,p),e.xr.enabled=g,i.texture.needsPMREMUpdate=!0}}class Eu extends Gt{constructor(e=[],t=rr,i,r,s,o,a,l,c,u){super(e,t,i,r,s,o,a,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class pp extends wi{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];this.texture=new Eu(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:`
23
23
 
24
24
  varying vec3 vWorldDirection;
25
25
 
@@ -54,13 +54,13 @@
54
54
  gl_FragColor = texture2D( tEquirect, sampleUV );
55
55
 
56
56
  }
57
- `},r=new _t(5,5,5),s=new Pn({name:"CubemapFromEquirect",uniforms:Si(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Dt,blending:Sn});s.uniforms.tEquirect.value=t;const o=new _e(r,s),a=t.minFilter;return t.minFilter===On&&(t.minFilter=sn),new zh(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 Yi extends dt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const kh={type:"move"};class bo{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Yi,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 Yi,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 Yi,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(kh)))}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 Yi;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class Gh 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 en,this.environmentIntensity=1,this.environmentRotation=new en,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 wo=new U,Vh=new U,Wh=new ze;class Ln{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=wo.subVectors(n,t).cross(Vh.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(wo),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||Wh.getNormalMatrix(e),r=this.coplanarPoint(wo).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 Vn=new mr,Xh=new Ie(.5,.5),Dr=new U;class Ao{constructor(e=new Ln,t=new Ln,n=new Ln,r=new Ln,s=new Ln,o=new Ln){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=an,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===an)r[5].setComponents(l+c,m+d,h+p,T+_).normalize();else if(t===hr)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(),Vn.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Vn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Vn)}intersectsSprite(e){Vn.center.set(0,0,0);const t=Xh.distanceTo(e.center);return Vn.radius=.7071067811865476+t,Vn.applyMatrix4(e.matrixWorld),this.intersectsSphere(Vn)}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(Dr.x=r.normal.x>0?e.max.x:e.min.x,Dr.y=r.normal.y>0?e.max.y:e.min.y,Dr.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Dr)<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 bi extends Mi{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ve(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 Lr=new U,Ir=new U,al=new rt,qi=new vr,Ur=new mr,Ro=new U,ll=new U;class cn extends dt{constructor(e=new gt,t=new bi){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++)Lr.fromBufferAttribute(t,r-1),Ir.fromBufferAttribute(t,r),n[r]=n[r-1],n[r]+=Lr.distanceTo(Ir);e.setAttribute("lineDistance",new Ze(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(),Ur.copy(n.boundingSphere),Ur.applyMatrix4(r),Ur.radius+=s,e.ray.intersectsSphere(Ur)===!1)return;al.copy(r).invert(),qi.copy(e.ray).applyMatrix4(al);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=Nr(this,e,qi,c,h,w,y);b&&t.push(b)}if(this.isLineLoop){const y=u.getX(g-1),p=u.getX(m),h=Nr(this,e,qi,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=Nr(this,e,qi,c,y,y+1,y);h&&t.push(h)}if(this.isLineLoop){const y=Nr(this,e,qi,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 Nr(i,e,t,n,r,s,o){const a=i.geometry.attributes.position;if(Lr.fromBufferAttribute(a,r),Ir.fromBufferAttribute(a,s),t.distanceSqToSegment(Lr,Ir,Ro,ll)>n)return;Ro.applyMatrix4(i.matrixWorld);const l=e.ray.origin.distanceTo(Ro);if(!(l<e.near||l>e.far))return{distance:l,point:ll.clone().applyMatrix4(i.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:i}}const cl=new U,hl=new U;class Co extends cn{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)cl.fromBufferAttribute(t,r),hl.fromBufferAttribute(t,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+cl.distanceTo(hl);e.setAttribute("lineDistance",new Ze(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class ul extends It{constructor(e,t,n=Fn,r,s,o,a=Zt,c=Zt,l,u=Ni,f=1){if(u!==Ni&&u!==Oi)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 ro(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 fl extends It{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class wt extends gt{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 Ze(f,3)),this.setAttribute("normal",new Ze(d,3)),this.setAttribute("uv",new Ze(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 Ie,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 wt(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Po extends gt{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 Ze(s,3)),this.setAttribute("normal",new Ze(s.slice(),3)),this.setAttribute("uv",new Ze(o,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(w){const 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 Ie,A=new Ie,C=new Ie;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 Po(e.vertices,e.indices,e.radius,e.details)}}const Or=new U,Fr=new U,Do=new U,Br=new Vt;class Yh extends gt{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(Fi*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(Do),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]?(Do.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:Do.clone()})}}for(const g in d)if(d[g]){const{index0:y,index1:p}=d[g];Or.fromBufferAttribute(a,y),Fr.fromBufferAttribute(a,p),m.push(Or.x,Or.y,Or.z),m.push(Fr.x,Fr.y,Fr.z)}this.setAttribute("position",new Ze(m,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class wi extends Po{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 wi(e.radius,e.detail)}}class ji extends gt{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 Ze(g,3)),this.setAttribute("normal",new Ze(y,3)),this.setAttribute("uv",new Ze(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ji(e.width,e.height,e.widthSegments,e.heightSegments)}}class Lo extends gt{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 Ze(g,3)),this.setAttribute("normal",new Ze(y,3)),this.setAttribute("uv",new Ze(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Lo(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class Wn extends gt{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 Ze(a,3)),this.setAttribute("normal",new Ze(c,3)),this.setAttribute("uv",new Ze(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Wn(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class qh extends gt{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),dl(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),dl(r,s,n)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new Ze(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function dl(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 Mi{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Ve(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 Ve(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Da,this.normalScale=new Ie(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 en,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 Mi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=rh,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 Zh extends Mi{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 Io extends dt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ve(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 Kh extends Io{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(dt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ve(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const Uo=new rt,pl=new U,ml=new U;class Qh{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ie(512,512),this.mapType=on,this.map=null,this.mapPass=null,this.matrix=new rt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Ao,this._frameExtents=new Ie(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;pl.setFromMatrixPosition(e.matrixWorld),t.position.copy(pl),ml.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ml),t.updateMatrixWorld(),Uo.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Uo,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(Uo)}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 _l extends il{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 Jh extends Qh{constructor(){super(new _l(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class eu extends Io{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 Jh}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class tu extends Io{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class nu extends Xt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const gl=new rt;class vl{constructor(e,t,n=0,r=1/0){this.ray=new vr(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new fo,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 gl.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(gl),this}intersectObject(e,t=!0,n=[]){return No(e,this,n,t),n.sort(xl),n}intersectObjects(e,t=!0,n=[]){for(let r=0,s=e.length;r<s;r++)No(e[r],this,n,t);return n.sort(xl),n}}function xl(i,e){return i.distance-e.distance}function No(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++)No(s[o],e,t,!0)}}class Ml{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 iu extends Co{constructor(e=10,t=10,n=4473924,r=8947848){n=new Ve(n),r=new Ve(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 gt;u.setAttribute("position",new Ze(c,3)),u.setAttribute("color",new Ze(l,3));const f=new bi({vertexColors:!0,toneMapped:!1});super(u,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class yl extends Bn{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 Sl(i,e,t,n){const r=ru(n);switch(t){case Aa:return i*e;case Ca:return i*e/r.components*r.byteLength;case Es:return i*e/r.components*r.byteLength;case Pa:return i*e*2/r.components*r.byteLength;case Ts:return i*e*2/r.components*r.byteLength;case Ra:return i*e*3/r.components*r.byteLength;case Kt:return i*e*4/r.components*r.byteLength;case bs:return i*e*4/r.components*r.byteLength;case sr:case or:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case ar:case lr:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case As:case Cs:return Math.max(i,16)*Math.max(e,8)/4;case ws:case Rs:return Math.max(i,8)*Math.max(e,8)/2;case Ps:case Ds:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Ls:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Is:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Us:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case Ns:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case Os:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case Fs:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case Bs:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case zs:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case Hs:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case ks:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case Gs:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case Vs:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case Ws:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case Xs:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case Ys:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case qs:case js:case $s:return Math.ceil(i/4)*Math.ceil(e/4)*16;case Zs:case Ks:return Math.ceil(i/4)*Math.ceil(e/4)*8;case Qs:case Js:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function ru(i){switch(i){case on:case Ea:return{byteLength:1,components:1};case Li:case Ta:case Ii:return{byteLength:2,components:1};case ys:case Ss:return{byteLength:2,components:4};case Fn:case Ms:case dn:return{byteLength:4,components:1};case ba:case wa:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:ss}})),typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=ss);/**
57
+ `},r=new bt(5,5,5),s=new hi({name:"CubemapFromEquirect",uniforms:yr(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:Ht,blending:ii});s.uniforms.tEquirect.value=t;const o=new ge(r,s),a=t.minFilter;return t.minFilter===bi&&(t.minFilter=In),new dp(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t=!0,i=!0,r=!0){const s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,i,r);e.setRenderTarget(s)}}class Qr extends xt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const mp={type:"move"};class cl{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Qr,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 Qr,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new L,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new L),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Qr,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new L,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new L),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,o=null;const a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(const y of e.hand.values()){const m=t.getJointPose(y,i),f=this._getHandJoint(c,y);m!==null&&(f.matrix.fromArray(m.transform.matrix),f.matrix.decompose(f.position,f.rotation,f.scale),f.matrixWorldNeedsUpdate=!0,f.jointRadius=m.radius),f.visible=m!==null}const u=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],d=u.position.distanceTo(h.position),p=.02,g=.005;c.inputState.pinching&&d>p+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=p-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(mp)))}return a!==null&&(a.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new Qr;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}class _p extends xt{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 En,this.environmentIntensity=1,this.environmentRotation=new En,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 ul=new L,gp=new L,vp=new ke;class di{constructor(e=new L(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const r=ul.subVectors(i,t).cross(gp.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const i=e.delta(ul),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||vp.getNormalMatrix(e),r=this.coplanarPoint(ul).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Pi=new Ds,xp=new Ne(.5,.5),Ys=new L;class hl{constructor(e=new di,t=new di,i=new di,r=new di,s=new di,o=new di){this.planes=[e,t,i,r,s,o]}set(e,t,i,r,s,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(i),a[3].copy(r),a[4].copy(s),a[5].copy(o),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Un,i=!1){const r=this.planes,s=e.elements,o=s[0],a=s[1],l=s[2],c=s[3],u=s[4],h=s[5],d=s[6],p=s[7],g=s[8],y=s[9],m=s[10],f=s[11],w=s[12],T=s[13],_=s[14],S=s[15];if(r[0].setComponents(c-o,p-u,f-g,S-w).normalize(),r[1].setComponents(c+o,p+u,f+g,S+w).normalize(),r[2].setComponents(c+a,p+h,f+y,S+T).normalize(),r[3].setComponents(c-a,p-h,f-y,S-T).normalize(),i)r[4].setComponents(l,d,m,_).normalize(),r[5].setComponents(c-l,p-d,f-m,S-_).normalize();else if(r[4].setComponents(c-l,p-d,f-m,S-_).normalize(),t===Un)r[5].setComponents(c+l,p+d,f+m,S+_).normalize();else if(t===ws)r[5].setComponents(l,d,m,_).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Pi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Pi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Pi)}intersectsSprite(e){Pi.center.set(0,0,0);const t=xp.distanceTo(e.center);return Pi.radius=.7071067811865476+t,Pi.applyMatrix4(e.matrixWorld),this.intersectsSphere(Pi)}intersectsSphere(e){const t=this.planes,i=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const r=t[i];if(Ys.x=r.normal.x>0?e.max.x:e.min.x,Ys.y=r.normal.y>0?e.max.y:e.min.y,Ys.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Ys)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Di extends vr{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new je(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const qs=new L,$s=new L,bu=new ct,es=new Is,Zs=new Ds,fl=new L,Su=new L;class Tn extends xt{constructor(e=new Et,t=new Di){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let r=1,s=t.count;r<s;r++)qs.fromBufferAttribute(t,r-1),$s.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=qs.distanceTo($s);e.setAttribute("lineDistance",new et(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Zs.copy(i.boundingSphere),Zs.applyMatrix4(r),Zs.radius+=s,e.ray.intersectsSphere(Zs)===!1)return;bu.copy(r).invert(),es.copy(e.ray).applyMatrix4(bu);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=this.isLineSegments?2:1,u=i.index,d=i.attributes.position;if(u!==null){const p=Math.max(0,o.start),g=Math.min(u.count,o.start+o.count);for(let y=p,m=g-1;y<m;y+=c){const f=u.getX(y),w=u.getX(y+1),T=Ks(this,e,es,l,f,w,y);T&&t.push(T)}if(this.isLineLoop){const y=u.getX(g-1),m=u.getX(p),f=Ks(this,e,es,l,y,m,g-1);f&&t.push(f)}}else{const p=Math.max(0,o.start),g=Math.min(d.count,o.start+o.count);for(let y=p,m=g-1;y<m;y+=c){const f=Ks(this,e,es,l,y,y+1,y);f&&t.push(f)}if(this.isLineLoop){const y=Ks(this,e,es,l,g-1,p,g-1);y&&t.push(y)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){const a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}}function Ks(n,e,t,i,r,s,o){const a=n.geometry.attributes.position;if(qs.fromBufferAttribute(a,r),$s.fromBufferAttribute(a,s),t.distanceSqToSegment(qs,$s,fl,Su)>i)return;fl.applyMatrix4(n.matrixWorld);const c=e.ray.origin.distanceTo(fl);if(!(c<e.near||c>e.far))return{distance:c,point:Su.clone().applyMatrix4(n.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:n}}const Tu=new L,wu=new L;class dl extends Tn{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let r=0,s=t.count;r<s;r+=2)Tu.fromBufferAttribute(t,r),wu.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+Tu.distanceTo(wu);e.setAttribute("lineDistance",new et(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Au extends Gt{constructor(e,t,i=Si,r,s,o,a=vn,l=vn,c,u=kr,h=1){if(u!==kr&&u!==Gr)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:e,height:t,depth:h};super(d,r,s,o,a,l,u,i,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Ga(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 Ru extends Gt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Ut extends Et{constructor(e=1,t=1,i=1,r=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};const c=this;r=Math.floor(r),s=Math.floor(s);const u=[],h=[],d=[],p=[];let g=0;const y=[],m=i/2;let f=0;w(),o===!1&&(e>0&&T(!0),t>0&&T(!1)),this.setIndex(u),this.setAttribute("position",new et(h,3)),this.setAttribute("normal",new et(d,3)),this.setAttribute("uv",new et(p,2));function w(){const _=new L,S=new L;let b=0;const A=(t-e)/i;for(let C=0;C<=s;C++){const M=[],x=C/s,N=x*(t-e)+e;for(let z=0;z<=r;z++){const Y=z/r,q=Y*l+a,J=Math.sin(q),K=Math.cos(q);S.x=N*J,S.y=-x*i+m,S.z=N*K,h.push(S.x,S.y,S.z),_.set(J,A,K).normalize(),d.push(_.x,_.y,_.z),p.push(Y,1-x),M.push(g++)}y.push(M)}for(let C=0;C<r;C++)for(let M=0;M<s;M++){const x=y[M][C],N=y[M+1][C],z=y[M+1][C+1],Y=y[M][C+1];(e>0||M!==0)&&(u.push(x,N,Y),b+=3),(t>0||M!==s-1)&&(u.push(N,z,Y),b+=3)}c.addGroup(f,b,0),f+=b}function T(_){const S=g,b=new Ne,A=new L;let C=0;const M=_===!0?e:t,x=_===!0?1:-1;for(let z=1;z<=r;z++)h.push(0,m*x,0),d.push(0,x,0),p.push(.5,.5),g++;const N=g;for(let z=0;z<=r;z++){const q=z/r*l+a,J=Math.cos(q),K=Math.sin(q);A.x=M*K,A.y=m*x,A.z=M*J,h.push(A.x,A.y,A.z),d.push(0,x,0),b.x=J*.5+.5,b.y=K*.5*x+.5,p.push(b.x,b.y),g++}for(let z=0;z<r;z++){const Y=S+z,q=N+z;_===!0?u.push(q,q+1,Y):u.push(q+1,q,Y),C+=3}c.addGroup(f,C,_===!0?1:2),f+=C}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ut(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class pl extends Et{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};const s=[],o=[];a(r),c(i),u(),this.setAttribute("position",new et(s,3)),this.setAttribute("normal",new et(s.slice(),3)),this.setAttribute("uv",new et(o,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(w){const T=new L,_=new L,S=new L;for(let b=0;b<t.length;b+=3)p(t[b+0],T),p(t[b+1],_),p(t[b+2],S),l(T,_,S,w)}function l(w,T,_,S){const b=S+1,A=[];for(let C=0;C<=b;C++){A[C]=[];const M=w.clone().lerp(_,C/b),x=T.clone().lerp(_,C/b),N=b-C;for(let z=0;z<=N;z++)z===0&&C===b?A[C][z]=M:A[C][z]=M.clone().lerp(x,z/N)}for(let C=0;C<b;C++)for(let M=0;M<2*(b-C)-1;M++){const x=Math.floor(M/2);M%2===0?(d(A[C][x+1]),d(A[C+1][x]),d(A[C][x])):(d(A[C][x+1]),d(A[C+1][x+1]),d(A[C+1][x]))}}function c(w){const T=new L;for(let _=0;_<s.length;_+=3)T.x=s[_+0],T.y=s[_+1],T.z=s[_+2],T.normalize().multiplyScalar(w),s[_+0]=T.x,s[_+1]=T.y,s[_+2]=T.z}function u(){const w=new L;for(let T=0;T<s.length;T+=3){w.x=s[T+0],w.y=s[T+1],w.z=s[T+2];const _=m(w)/2/Math.PI+.5,S=f(w)/Math.PI+.5;o.push(_,1-S)}g(),h()}function h(){for(let w=0;w<o.length;w+=6){const T=o[w+0],_=o[w+2],S=o[w+4],b=Math.max(T,_,S),A=Math.min(T,_,S);b>.9&&A<.1&&(T<.2&&(o[w+0]+=1),_<.2&&(o[w+2]+=1),S<.2&&(o[w+4]+=1))}}function d(w){s.push(w.x,w.y,w.z)}function p(w,T){const _=w*3;T.x=e[_+0],T.y=e[_+1],T.z=e[_+2]}function g(){const w=new L,T=new L,_=new L,S=new L,b=new Ne,A=new Ne,C=new Ne;for(let M=0,x=0;M<s.length;M+=9,x+=6){w.set(s[M+0],s[M+1],s[M+2]),T.set(s[M+3],s[M+4],s[M+5]),_.set(s[M+6],s[M+7],s[M+8]),b.set(o[x+0],o[x+1]),A.set(o[x+2],o[x+3]),C.set(o[x+4],o[x+5]),S.copy(w).add(T).add(_).divideScalar(3);const N=m(S);y(b,x+0,w,N),y(A,x+2,T,N),y(C,x+4,_,N)}}function y(w,T,_,S){S<0&&w.x===1&&(o[T]=w.x-1),_.x===0&&_.z===0&&(o[T]=S/2/Math.PI+.5)}function m(w){return Math.atan2(w.z,-w.x)}function f(w){return Math.atan2(-w.y,Math.sqrt(w.x*w.x+w.z*w.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new pl(e.vertices,e.indices,e.radius,e.details)}}const Js=new L,Qs=new L,ml=new L,eo=new sn;class yp extends Et{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(Wr*t),o=e.getIndex(),a=e.getAttribute("position"),l=o?o.count:a.count,c=[0,0,0],u=["a","b","c"],h=new Array(3),d={},p=[];for(let g=0;g<l;g+=3){o?(c[0]=o.getX(g),c[1]=o.getX(g+1),c[2]=o.getX(g+2)):(c[0]=g,c[1]=g+1,c[2]=g+2);const{a:y,b:m,c:f}=eo;if(y.fromBufferAttribute(a,c[0]),m.fromBufferAttribute(a,c[1]),f.fromBufferAttribute(a,c[2]),eo.getNormal(ml),h[0]=`${Math.round(y.x*r)},${Math.round(y.y*r)},${Math.round(y.z*r)}`,h[1]=`${Math.round(m.x*r)},${Math.round(m.y*r)},${Math.round(m.z*r)}`,h[2]=`${Math.round(f.x*r)},${Math.round(f.y*r)},${Math.round(f.z*r)}`,!(h[0]===h[1]||h[1]===h[2]||h[2]===h[0]))for(let w=0;w<3;w++){const T=(w+1)%3,_=h[w],S=h[T],b=eo[u[w]],A=eo[u[T]],C=`${_}_${S}`,M=`${S}_${_}`;M in d&&d[M]?(ml.dot(d[M].normal)<=s&&(p.push(b.x,b.y,b.z),p.push(A.x,A.y,A.z)),d[M]=null):C in d||(d[C]={index0:c[w],index1:c[T],normal:ml.clone()})}}for(const g in d)if(d[g]){const{index0:y,index1:m}=d[g];Js.fromBufferAttribute(a,y),Qs.fromBufferAttribute(a,m),p.push(Js.x,Js.y,Js.z),p.push(Qs.x,Qs.y,Qs.z)}this.setAttribute("position",new et(p,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class br extends pl{constructor(e=1,t=0){const i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(i,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new br(e.radius,e.detail)}}class ts extends Et{constructor(e=1,t=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};const s=e/2,o=t/2,a=Math.floor(i),l=Math.floor(r),c=a+1,u=l+1,h=e/a,d=t/l,p=[],g=[],y=[],m=[];for(let f=0;f<u;f++){const w=f*d-o;for(let T=0;T<c;T++){const _=T*h-s;g.push(_,-w,0),y.push(0,0,1),m.push(T/a),m.push(1-f/l)}}for(let f=0;f<l;f++)for(let w=0;w<a;w++){const T=w+c*f,_=w+c*(f+1),S=w+1+c*(f+1),b=w+1+c*f;p.push(T,_,b),p.push(_,S,b)}this.setIndex(p),this.setAttribute("position",new et(g,3)),this.setAttribute("normal",new et(y,3)),this.setAttribute("uv",new et(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ts(e.width,e.height,e.widthSegments,e.heightSegments)}}class _l extends Et{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const l=Math.min(o+a,Math.PI);let c=0;const u=[],h=new L,d=new L,p=[],g=[],y=[],m=[];for(let f=0;f<=i;f++){const w=[],T=f/i;let _=0;f===0&&o===0?_=.5/t:f===i&&l===Math.PI&&(_=-.5/t);for(let S=0;S<=t;S++){const b=S/t;h.x=-e*Math.cos(r+b*s)*Math.sin(o+T*a),h.y=e*Math.cos(o+T*a),h.z=e*Math.sin(r+b*s)*Math.sin(o+T*a),g.push(h.x,h.y,h.z),d.copy(h).normalize(),y.push(d.x,d.y,d.z),m.push(b+_,1-T),w.push(c++)}u.push(w)}for(let f=0;f<i;f++)for(let w=0;w<t;w++){const T=u[f][w+1],_=u[f][w],S=u[f+1][w],b=u[f+1][w+1];(f!==0||o>0)&&p.push(T,_,b),(f!==i-1||l<Math.PI)&&p.push(_,S,b)}this.setIndex(p),this.setAttribute("position",new et(g,3)),this.setAttribute("normal",new et(y,3)),this.setAttribute("uv",new et(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new _l(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class Li extends Et{constructor(e=1,t=.4,i=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:s},i=Math.floor(i),r=Math.floor(r);const o=[],a=[],l=[],c=[],u=new L,h=new L,d=new L;for(let p=0;p<=i;p++)for(let g=0;g<=r;g++){const y=g/r*s,m=p/i*Math.PI*2;h.x=(e+t*Math.cos(m))*Math.cos(y),h.y=(e+t*Math.cos(m))*Math.sin(y),h.z=t*Math.sin(m),a.push(h.x,h.y,h.z),u.x=e*Math.cos(y),u.y=e*Math.sin(y),d.subVectors(h,u).normalize(),l.push(d.x,d.y,d.z),c.push(g/r),c.push(p/i)}for(let p=1;p<=i;p++)for(let g=1;g<=r;g++){const y=(r+1)*p+g-1,m=(r+1)*(p-1)+g-1,f=(r+1)*(p-1)+g,w=(r+1)*p+g;o.push(y,m,w),o.push(m,f,w)}this.setIndex(o),this.setAttribute("position",new et(a,3)),this.setAttribute("normal",new et(l,3)),this.setAttribute("uv",new et(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Li(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class Mp extends Et{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],i=new Set,r=new L,s=new L;if(e.index!==null){const o=e.attributes.position,a=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:a.count,materialIndex:0}]);for(let c=0,u=l.length;c<u;++c){const h=l[c],d=h.start,p=h.count;for(let g=d,y=d+p;g<y;g+=3)for(let m=0;m<3;m++){const f=a.getX(g+m),w=a.getX(g+(m+1)%3);r.fromBufferAttribute(o,f),s.fromBufferAttribute(o,w),Cu(r,s,i)===!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,l=o.count/3;a<l;a++)for(let c=0;c<3;c++){const u=3*a+c,h=3*a+(c+1)%3;r.fromBufferAttribute(o,u),s.fromBufferAttribute(o,h),Cu(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new et(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function Cu(n,e,t){const i=`${n.x},${n.y},${n.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${n.x},${n.y},${n.z}`;return t.has(i)===!0||t.has(r)===!0?!1:(t.add(i),t.add(r),!0)}class Ep extends vr{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new je(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new je(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Yc,this.normalScale=new Ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new En,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 bp extends vr{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Ld,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 Sp extends vr{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 gl extends xt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new je(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}class Tp extends gl{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(xt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new je(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const vl=new ct,Pu=new L,Du=new L;class wp{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ne(512,512),this.mapType=Nn,this.map=null,this.mapPass=null,this.matrix=new ct,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new hl,this._frameExtents=new Ne(1,1),this._viewportCount=1,this._viewports=[new gt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;Pu.setFromMatrixPosition(e.matrixWorld),t.position.copy(Pu),Du.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Du),t.updateMatrixWorld(),vl.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(vl,t.coordinateSystem,t.reversedDepth),t.reversedDepth?i.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(vl)}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 Lu extends xu{constructor(e=-1,t=1,i=1,r=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=i-e,o=i+e,a=r+t,l=r-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=u*this.view.offsetY,l=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class Ap extends wp{constructor(){super(new Lu(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Rp extends gl{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(xt.DEFAULT_UP),this.updateMatrix(),this.target=new xt,this.shadow=new Ap}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class Cp extends gl{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Pp extends an{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const Ou=new ct;class Iu{constructor(e,t,i=0,r=1/0){this.ray=new Is(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new Ka,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 Ou.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Ou),this}intersectObject(e,t=!0,i=[]){return xl(e,this,i,t),i.sort(Nu),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)xl(e[r],this,i,t);return i.sort(Nu),i}}function Nu(n,e){return n.distance-e.distance}function xl(n,e,t,i){let r=!0;if(n.layers.test(e.layers)&&n.raycast(e,t)===!1&&(r=!1),r===!0&&i===!0){const s=n.children;for(let o=0,a=s.length;o<a;o++)xl(s[o],e,t,!0)}}class Uu{constructor(e=1,t=0,i=0){this.radius=e,this.phi=t,this.theta=i}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Xe(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Xe(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class Dp extends dl{constructor(e=10,t=10,i=4473924,r=8947848){i=new je(i),r=new je(r);const s=t/2,o=e/t,a=e/2,l=[],c=[];for(let d=0,p=0,g=-a;d<=t;d++,g+=o){l.push(-a,0,g,a,0,g),l.push(g,0,-a,g,0,a);const y=d===s?i:r;y.toArray(c,p),p+=3,y.toArray(c,p),p+=3,y.toArray(c,p),p+=3,y.toArray(c,p),p+=3}const u=new Et;u.setAttribute("position",new et(l,3)),u.setAttribute("color",new et(c,3));const h=new Di({vertexColors:!0,toneMapped:!1});super(u,h),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class Fu extends Ti{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 Bu(n,e,t,i){const r=Lp(i);switch(t){case Gc:return n*e;case Xc:return n*e/r.components*r.byteLength;case la:return n*e/r.components*r.byteLength;case jc:return n*e*2/r.components*r.byteLength;case ca:return n*e*2/r.components*r.byteLength;case Wc:return n*e*3/r.components*r.byteLength;case xn:return n*e*4/r.components*r.byteLength;case ua:return n*e*4/r.components*r.byteLength;case Ms:case Es:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case bs:case Ss:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case fa:case pa:return Math.max(n,16)*Math.max(e,8)/4;case ha:case da:return Math.max(n,8)*Math.max(e,8)/2;case ma:case _a:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case ga:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case va:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case xa:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case ya:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case Ma:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case Ea:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case ba:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case Sa:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case Ta:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case wa:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case Aa:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case Ra:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case Ca:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case Pa:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case Da:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case La:case Oa:case Ia:return Math.ceil(n/4)*Math.ceil(e/4)*16;case Na:case Ua:return Math.ceil(n/4)*Math.ceil(e/4)*8;case Fa:case Ba:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Lp(n){switch(n){case Nn:case zc:return{byteLength:1,components:1};case zr:case Vc:case Vr:return{byteLength:2,components:1};case oa:case aa:return{byteLength:2,components:4};case Si:case sa:case Wn:return{byteLength:4,components:1};case Hc:case kc:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${n}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Wo}})),typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Wo);/**
58
58
  * @license
59
59
  * Copyright 2010-2025 Three.js Authors
60
60
  * SPDX-License-Identifier: MIT
61
- */function El(){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 su(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 ou=`#ifdef USE_ALPHAHASH
61
+ */function zu(){let n=null,e=!1,t=null,i=null;function r(s,o){t(s,o),i=n.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(r),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){n=s}}}function Op(n){const e=new WeakMap;function t(a,l){const c=a.array,u=a.usage,h=c.byteLength,d=n.createBuffer();n.bindBuffer(l,d),n.bufferData(l,c,u),a.onUploadCallback();let p;if(c instanceof Float32Array)p=n.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)p=n.HALF_FLOAT;else if(c instanceof Uint16Array)a.isFloat16BufferAttribute?p=n.HALF_FLOAT:p=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)p=n.SHORT;else if(c instanceof Uint32Array)p=n.UNSIGNED_INT;else if(c instanceof Int32Array)p=n.INT;else if(c instanceof Int8Array)p=n.BYTE;else if(c instanceof Uint8Array)p=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)p=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:p,bytesPerElement:c.BYTES_PER_ELEMENT,version:a.version,size:h}}function i(a,l,c){const u=l.array,h=l.updateRanges;if(n.bindBuffer(c,a),h.length===0)n.bufferSubData(c,0,u);else{h.sort((p,g)=>p.start-g.start);let d=0;for(let p=1;p<h.length;p++){const g=h[d],y=h[p];y.start<=g.start+g.count+1?g.count=Math.max(g.count,y.start+y.count-g.start):(++d,h[d]=y)}h.length=d+1;for(let p=0,g=h.length;p<g;p++){const y=h[p];n.bufferSubData(c,y.start*u.BYTES_PER_ELEMENT,u,y.start,y.count)}l.clearUpdateRanges()}l.onUploadCallback()}function r(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function s(a){a.isInterleavedBufferAttribute&&(a=a.data);const l=e.get(a);l&&(n.deleteBuffer(l.buffer),e.delete(a))}function o(a,l){if(a.isInterleavedBufferAttribute&&(a=a.data),a.isGLBufferAttribute){const u=e.get(a);(!u||u.version<a.version)&&e.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}const c=e.get(a);if(c===void 0)e.set(a,t(a,l));else if(c.version<a.version){if(c.size!==a.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(c.buffer,a,l),c.version=a.version}}return{get:r,remove:s,update:o}}var Ip=`#ifdef USE_ALPHAHASH
62
62
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
63
- #endif`,au=`#ifdef USE_ALPHAHASH
63
+ #endif`,Np=`#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 @@
95
95
  : cases.z;
96
96
  return clamp( threshold , 1.0e-6, 1.0 );
97
97
  }
98
- #endif`,lu=`#ifdef USE_ALPHAMAP
98
+ #endif`,Up=`#ifdef USE_ALPHAMAP
99
99
  diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
100
- #endif`,cu=`#ifdef USE_ALPHAMAP
100
+ #endif`,Fp=`#ifdef USE_ALPHAMAP
101
101
  uniform sampler2D alphaMap;
102
- #endif`,hu=`#ifdef USE_ALPHATEST
102
+ #endif`,Bp=`#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`,uu=`#ifdef USE_ALPHATEST
109
+ #endif`,zp=`#ifdef USE_ALPHATEST
110
110
  uniform float alphaTest;
111
- #endif`,fu=`#ifdef USE_AOMAP
111
+ #endif`,Vp=`#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 @@
121
121
  float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
122
122
  reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
123
123
  #endif
124
- #endif`,du=`#ifdef USE_AOMAP
124
+ #endif`,Hp=`#ifdef USE_AOMAP
125
125
  uniform sampler2D aoMap;
126
126
  uniform float aoMapIntensity;
127
- #endif`,pu=`#ifdef USE_BATCHING
127
+ #endif`,kp=`#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 @@
158
158
  int y = j / size;
159
159
  return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
160
160
  }
161
- #endif`,mu=`#ifdef USE_BATCHING
161
+ #endif`,Gp=`#ifdef USE_BATCHING
162
162
  mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
163
- #endif`,_u=`vec3 transformed = vec3( position );
163
+ #endif`,Wp=`vec3 transformed = vec3( position );
164
164
  #ifdef USE_ALPHAHASH
165
165
  vPosition = vec3( position );
166
- #endif`,gu=`vec3 objectNormal = vec3( normal );
166
+ #endif`,Xp=`vec3 objectNormal = vec3( normal );
167
167
  #ifdef USE_TANGENT
168
168
  vec3 objectTangent = vec3( tangent.xyz );
169
- #endif`,vu=`float G_BlinnPhong_Implicit( ) {
169
+ #endif`,jp=`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`,xu=`#ifdef USE_IRIDESCENCE
183
+ } // validated`,Yp=`#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`,Mu=`#ifdef USE_BUMPMAP
246
+ #endif`,qp=`#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`,yu=`#if NUM_CLIPPING_PLANES > 0
267
+ #endif`,$p=`#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`,Su=`#if NUM_CLIPPING_PLANES > 0
313
+ #endif`,Zp=`#if NUM_CLIPPING_PLANES > 0
314
314
  varying vec3 vClipPosition;
315
315
  uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
316
- #endif`,Eu=`#if NUM_CLIPPING_PLANES > 0
316
+ #endif`,Kp=`#if NUM_CLIPPING_PLANES > 0
317
317
  varying vec3 vClipPosition;
318
- #endif`,Tu=`#if NUM_CLIPPING_PLANES > 0
318
+ #endif`,Jp=`#if NUM_CLIPPING_PLANES > 0
319
319
  vClipPosition = - mvPosition.xyz;
320
- #endif`,bu=`#if defined( USE_COLOR_ALPHA )
320
+ #endif`,Qp=`#if defined( USE_COLOR_ALPHA )
321
321
  diffuseColor *= vColor;
322
322
  #elif defined( USE_COLOR )
323
323
  diffuseColor.rgb *= vColor;
324
- #endif`,wu=`#if defined( USE_COLOR_ALPHA )
324
+ #endif`,em=`#if defined( USE_COLOR_ALPHA )
325
325
  varying vec4 vColor;
326
326
  #elif defined( USE_COLOR )
327
327
  varying vec3 vColor;
328
- #endif`,Au=`#if defined( USE_COLOR_ALPHA )
328
+ #endif`,tm=`#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`,Ru=`#if defined( USE_COLOR_ALPHA )
332
+ #endif`,nm=`#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`,Cu=`#define PI 3.141592653589793
346
+ #endif`,im=`#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`,Pu=`#ifdef ENVMAP_TYPE_CUBE_UV
420
+ } // validated`,rm=`#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`,Du=`vec3 transformedNormal = objectNormal;
513
+ #endif`,sm=`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`,Lu=`#ifdef USE_DISPLACEMENTMAP
542
+ #endif`,om=`#ifdef USE_DISPLACEMENTMAP
543
543
  uniform sampler2D displacementMap;
544
544
  uniform float displacementScale;
545
545
  uniform float displacementBias;
546
- #endif`,Iu=`#ifdef USE_DISPLACEMENTMAP
546
+ #endif`,am=`#ifdef USE_DISPLACEMENTMAP
547
547
  transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
548
- #endif`,Uu=`#ifdef USE_EMISSIVEMAP
548
+ #endif`,lm=`#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`,Nu=`#ifdef USE_EMISSIVEMAP
554
+ #endif`,cm=`#ifdef USE_EMISSIVEMAP
555
555
  uniform sampler2D emissiveMap;
556
- #endif`,Ou="gl_FragColor = linearToOutputTexel( gl_FragColor );",Fu=`vec4 LinearTransferOETF( in vec4 value ) {
556
+ #endif`,um="gl_FragColor = linearToOutputTexel( gl_FragColor );",hm=`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
- }`,Bu=`#ifdef USE_ENVMAP
564
+ }`,fm=`#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`,zu=`#ifdef USE_ENVMAP
593
+ #endif`,dm=`#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`,Hu=`#ifdef USE_ENVMAP
603
+ #endif`,pm=`#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`,ku=`#ifdef USE_ENVMAP
614
+ #endif`,mm=`#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`,Gu=`#ifdef USE_ENVMAP
625
+ #endif`,_m=`#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`,Vu=`#ifdef USE_FOG
642
+ #endif`,gm=`#ifdef USE_FOG
643
643
  vFogDepth = - mvPosition.z;
644
- #endif`,Wu=`#ifdef USE_FOG
644
+ #endif`,vm=`#ifdef USE_FOG
645
645
  varying float vFogDepth;
646
- #endif`,Xu=`#ifdef USE_FOG
646
+ #endif`,xm=`#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`,Yu=`#ifdef USE_FOG
653
+ #endif`,ym=`#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`,qu=`#ifdef USE_GRADIENTMAP
662
+ #endif`,Mm=`#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
- }`,ju=`#ifdef USE_LIGHTMAP
674
+ }`,Em=`#ifdef USE_LIGHTMAP
675
675
  uniform sampler2D lightMap;
676
676
  uniform float lightMapIntensity;
677
- #endif`,$u=`LambertMaterial material;
677
+ #endif`,bm=`LambertMaterial material;
678
678
  material.diffuseColor = diffuseColor.rgb;
679
- material.specularStrength = specularStrength;`,Zu=`varying vec3 vViewPosition;
679
+ material.specularStrength = specularStrength;`,Sm=`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`,Ku=`uniform bool receiveShadow;
693
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Tm=`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`,Qu=`#ifdef USE_ENVMAP
809
+ #endif`,wm=`#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`,Ju=`ToonMaterial material;
843
- material.diffuseColor = diffuseColor.rgb;`,ef=`varying vec3 vViewPosition;
842
+ #endif`,Am=`ToonMaterial material;
843
+ material.diffuseColor = diffuseColor.rgb;`,Rm=`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`,tf=`BlinnPhongMaterial material;
855
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Cm=`BlinnPhongMaterial material;
856
856
  material.diffuseColor = diffuseColor.rgb;
857
857
  material.specularColor = specular;
858
858
  material.specularShininess = shininess;
859
- material.specularStrength = specularStrength;`,nf=`varying vec3 vViewPosition;
859
+ material.specularStrength = specularStrength;`,Pm=`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`,rf=`PhysicalMaterial material;
876
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Dm=`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`,sf=`struct PhysicalMaterial {
962
+ #endif`,Lm=`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
- }`,of=`
1263
+ }`,Om=`
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`,af=`#if defined( RE_IndirectDiffuse )
1378
+ #endif`,Im=`#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`,lf=`#if defined( RE_IndirectDiffuse )
1397
+ #endif`,Nm=`#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`,cf=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1402
+ #endif`,Um=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1403
1403
  gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1404
- #endif`,hf=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1404
+ #endif`,Fm=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1405
1405
  uniform float logDepthBufFC;
1406
1406
  varying float vFragDepth;
1407
1407
  varying float vIsPerspective;
1408
- #endif`,uf=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1408
+ #endif`,Bm=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1409
1409
  varying float vFragDepth;
1410
1410
  varying float vIsPerspective;
1411
- #endif`,ff=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1411
+ #endif`,zm=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1412
1412
  vFragDepth = 1.0 + gl_Position.w;
1413
1413
  vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1414
- #endif`,df=`#ifdef USE_MAP
1414
+ #endif`,Vm=`#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`,pf=`#ifdef USE_MAP
1420
+ #endif`,Hm=`#ifdef USE_MAP
1421
1421
  uniform sampler2D map;
1422
- #endif`,mf=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1422
+ #endif`,km=`#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`,_f=`#if defined( USE_POINTS_UV )
1434
+ #endif`,Gm=`#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`,gf=`float metalnessFactor = metalness;
1446
+ #endif`,Wm=`float metalnessFactor = metalness;
1447
1447
  #ifdef USE_METALNESSMAP
1448
1448
  vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1449
1449
  metalnessFactor *= texelMetalness.b;
1450
- #endif`,vf=`#ifdef USE_METALNESSMAP
1450
+ #endif`,Xm=`#ifdef USE_METALNESSMAP
1451
1451
  uniform sampler2D metalnessMap;
1452
- #endif`,xf=`#ifdef USE_INSTANCING_MORPH
1452
+ #endif`,jm=`#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`,Mf=`#if defined( USE_MORPHCOLORS )
1458
+ #endif`,Ym=`#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`,yf=`#ifdef USE_MORPHNORMALS
1467
+ #endif`,qm=`#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`,Sf=`#ifdef USE_MORPHTARGETS
1472
+ #endif`,$m=`#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`,Ef=`#ifdef USE_MORPHTARGETS
1486
+ #endif`,Zm=`#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`,Tf=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1491
+ #endif`,Km=`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;`,bf=`#ifdef USE_NORMALMAP_OBJECTSPACE
1532
+ vec3 nonPerturbedNormal = normal;`,Jm=`#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;`,bf=`#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`,wf=`#ifndef FLAT_SHADED
1547
+ #endif`,Qm=`#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`,Af=`#ifndef FLAT_SHADED
1553
+ #endif`,e_=`#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`,Rf=`#ifndef FLAT_SHADED
1559
+ #endif`,t_=`#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`,Cf=`#ifdef USE_NORMALMAP
1565
+ #endif`,n_=`#ifdef USE_NORMALMAP
1566
1566
  uniform sampler2D normalMap;
1567
1567
  uniform vec2 normalScale;
1568
1568
  #endif
@@ -1584,13 +1584,13 @@ vec3 nonPerturbedNormal = normal;`,bf=`#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`,Pf=`#ifdef USE_CLEARCOAT
1587
+ #endif`,i_=`#ifdef USE_CLEARCOAT
1588
1588
  vec3 clearcoatNormal = nonPerturbedNormal;
1589
- #endif`,Df=`#ifdef USE_CLEARCOAT_NORMALMAP
1589
+ #endif`,r_=`#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`,Lf=`#ifdef USE_CLEARCOATMAP
1593
+ #endif`,s_=`#ifdef USE_CLEARCOATMAP
1594
1594
  uniform sampler2D clearcoatMap;
1595
1595
  #endif
1596
1596
  #ifdef USE_CLEARCOAT_NORMALMAP
@@ -1599,18 +1599,18 @@ vec3 nonPerturbedNormal = normal;`,bf=`#ifdef USE_NORMALMAP_OBJECTSPACE
1599
1599
  #endif
1600
1600
  #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1601
1601
  uniform sampler2D clearcoatRoughnessMap;
1602
- #endif`,If=`#ifdef USE_IRIDESCENCEMAP
1602
+ #endif`,o_=`#ifdef USE_IRIDESCENCEMAP
1603
1603
  uniform sampler2D iridescenceMap;
1604
1604
  #endif
1605
1605
  #ifdef USE_IRIDESCENCE_THICKNESSMAP
1606
1606
  uniform sampler2D iridescenceThicknessMap;
1607
- #endif`,Uf=`#ifdef OPAQUE
1607
+ #endif`,a_=`#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 );`,Nf=`vec3 packNormalToRGB( const in vec3 normal ) {
1613
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,l_=`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
- }`,Of=`#ifdef PREMULTIPLIED_ALPHA
1682
+ }`,c_=`#ifdef PREMULTIPLIED_ALPHA
1683
1683
  gl_FragColor.rgb *= gl_FragColor.a;
1684
- #endif`,Ff=`vec4 mvPosition = vec4( transformed, 1.0 );
1684
+ #endif`,u_=`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;`,Bf=`#ifdef DITHERING
1692
+ gl_Position = projectionMatrix * mvPosition;`,h_=`#ifdef DITHERING
1693
1693
  gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1694
- #endif`,zf=`#ifdef DITHERING
1694
+ #endif`,f_=`#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`,Hf=`float roughnessFactor = roughness;
1701
+ #endif`,d_=`float roughnessFactor = roughness;
1702
1702
  #ifdef USE_ROUGHNESSMAP
1703
1703
  vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1704
1704
  roughnessFactor *= texelRoughness.g;
1705
- #endif`,kf=`#ifdef USE_ROUGHNESSMAP
1705
+ #endif`,p_=`#ifdef USE_ROUGHNESSMAP
1706
1706
  uniform sampler2D roughnessMap;
1707
- #endif`,Gf=`#if NUM_SPOT_LIGHT_COORDS > 0
1707
+ #endif`,m_=`#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;`,Bf=`#ifdef DITHERING
1899
1899
  }
1900
1900
  return mix( 1.0, shadow, shadowIntensity );
1901
1901
  }
1902
- #endif`,Vf=`#if NUM_SPOT_LIGHT_COORDS > 0
1902
+ #endif`,__=`#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;`,Bf=`#ifdef DITHERING
1940
1940
  };
1941
1941
  uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1942
1942
  #endif
1943
- #endif`,Wf=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
1943
+ #endif`,g_=`#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;`,Bf=`#ifdef DITHERING
1972
1972
  vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
1973
1973
  }
1974
1974
  #pragma unroll_loop_end
1975
- #endif`,Xf=`float getShadowMask() {
1975
+ #endif`,v_=`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;`,Bf=`#ifdef DITHERING
2004
2004
  #endif
2005
2005
  #endif
2006
2006
  return shadow;
2007
- }`,Yf=`#ifdef USE_SKINNING
2007
+ }`,x_=`#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`,qf=`#ifdef USE_SKINNING
2012
+ #endif`,y_=`#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;`,Bf=`#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`,jf=`#ifdef USE_SKINNING
2027
+ #endif`,M_=`#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;`,Bf=`#ifdef DITHERING
2032
2032
  skinned += boneMatZ * skinVertex * skinWeight.z;
2033
2033
  skinned += boneMatW * skinVertex * skinWeight.w;
2034
2034
  transformed = ( bindMatrixInverse * skinned ).xyz;
2035
- #endif`,$f=`#ifdef USE_SKINNING
2035
+ #endif`,E_=`#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;`,Bf=`#ifdef DITHERING
2043
2043
  #ifdef USE_TANGENT
2044
2044
  objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2045
2045
  #endif
2046
- #endif`,Zf=`float specularStrength;
2046
+ #endif`,b_=`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`,Kf=`#ifdef USE_SPECULARMAP
2052
+ #endif`,S_=`#ifdef USE_SPECULARMAP
2053
2053
  uniform sampler2D specularMap;
2054
- #endif`,Qf=`#if defined( TONE_MAPPING )
2054
+ #endif`,T_=`#if defined( TONE_MAPPING )
2055
2055
  gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2056
- #endif`,Jf=`#ifndef saturate
2056
+ #endif`,w_=`#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; }`,ed=`#ifdef USE_TRANSMISSION
2153
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,A_=`#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; }`,ed=`#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`,td=`#ifdef USE_TRANSMISSION
2174
+ #endif`,R_=`#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; }`,ed=`#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`,nd=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2300
+ #endif`,C_=`#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; }`,ed=`#ifdef USE_TRANSMISS
2367
2367
  #ifdef USE_THICKNESSMAP
2368
2368
  uniform mat3 thicknessMapTransform;
2369
2369
  varying vec2 vThicknessMapUv;
2370
- #endif`,id=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2370
+ #endif`,P_=`#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; }`,ed=`#ifdef USE_TRANSMISS
2461
2461
  #ifdef USE_THICKNESSMAP
2462
2462
  uniform mat3 thicknessMapTransform;
2463
2463
  varying vec2 vThicknessMapUv;
2464
- #endif`,rd=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2464
+ #endif`,D_=`#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; }`,ed=`#ifdef USE_TRANSMISS
2532
2532
  #endif
2533
2533
  #ifdef USE_THICKNESSMAP
2534
2534
  vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2535
- #endif`,sd=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2535
+ #endif`,L_=`#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,7 +2541,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,ed=`#ifdef USE_TRANSMISS
2541
2541
  worldPosition = instanceMatrix * worldPosition;
2542
2542
  #endif
2543
2543
  worldPosition = modelMatrix * worldPosition;
2544
- #endif`;const He={alphahash_fragment:ou,alphahash_pars_fragment:au,alphamap_fragment:lu,alphamap_pars_fragment:cu,alphatest_fragment:hu,alphatest_pars_fragment:uu,aomap_fragment:fu,aomap_pars_fragment:du,batching_pars_vertex:pu,batching_vertex:mu,begin_vertex:_u,beginnormal_vertex:gu,bsdfs:vu,iridescence_fragment:xu,bumpmap_pars_fragment:Mu,clipping_planes_fragment:yu,clipping_planes_pars_fragment:Su,clipping_planes_pars_vertex:Eu,clipping_planes_vertex:Tu,color_fragment:bu,color_pars_fragment:wu,color_pars_vertex:Au,color_vertex:Ru,common:Cu,cube_uv_reflection_fragment:Pu,defaultnormal_vertex:Du,displacementmap_pars_vertex:Lu,displacementmap_vertex:Iu,emissivemap_fragment:Uu,emissivemap_pars_fragment:Nu,colorspace_fragment:Ou,colorspace_pars_fragment:Fu,envmap_fragment:Bu,envmap_common_pars_fragment:zu,envmap_pars_fragment:Hu,envmap_pars_vertex:ku,envmap_physical_pars_fragment:Qu,envmap_vertex:Gu,fog_vertex:Vu,fog_pars_vertex:Wu,fog_fragment:Xu,fog_pars_fragment:Yu,gradientmap_pars_fragment:qu,lightmap_pars_fragment:ju,lights_lambert_fragment:$u,lights_lambert_pars_fragment:Zu,lights_pars_begin:Ku,lights_toon_fragment:Ju,lights_toon_pars_fragment:ef,lights_phong_fragment:tf,lights_phong_pars_fragment:nf,lights_physical_fragment:rf,lights_physical_pars_fragment:sf,lights_fragment_begin:of,lights_fragment_maps:af,lights_fragment_end:lf,logdepthbuf_fragment:cf,logdepthbuf_pars_fragment:hf,logdepthbuf_pars_vertex:uf,logdepthbuf_vertex:ff,map_fragment:df,map_pars_fragment:pf,map_particle_fragment:mf,map_particle_pars_fragment:_f,metalnessmap_fragment:gf,metalnessmap_pars_fragment:vf,morphinstance_vertex:xf,morphcolor_vertex:Mf,morphnormal_vertex:yf,morphtarget_pars_vertex:Sf,morphtarget_vertex:Ef,normal_fragment_begin:Tf,normal_fragment_maps:bf,normal_pars_fragment:wf,normal_pars_vertex:Af,normal_vertex:Rf,normalmap_pars_fragment:Cf,clearcoat_normal_fragment_begin:Pf,clearcoat_normal_fragment_maps:Df,clearcoat_pars_fragment:Lf,iridescence_pars_fragment:If,opaque_fragment:Uf,packing:Nf,premultiplied_alpha_fragment:Of,project_vertex:Ff,dithering_fragment:Bf,dithering_pars_fragment:zf,roughnessmap_fragment:Hf,roughnessmap_pars_fragment:kf,shadowmap_pars_fragment:Gf,shadowmap_pars_vertex:Vf,shadowmap_vertex:Wf,shadowmask_pars_fragment:Xf,skinbase_vertex:Yf,skinning_pars_vertex:qf,skinning_vertex:jf,skinnormal_vertex:$f,specularmap_fragment:Zf,specularmap_pars_fragment:Kf,tonemapping_fragment:Qf,tonemapping_pars_fragment:Jf,transmission_fragment:ed,transmission_pars_fragment:td,uv_pars_fragment:nd,uv_pars_vertex:id,uv_vertex:rd,worldpos_vertex:sd,background_vert:`varying vec2 vUv;
2544
+ #endif`;const Ge={alphahash_fragment:Ip,alphahash_pars_fragment:Np,alphamap_fragment:Up,alphamap_pars_fragment:Fp,alphatest_fragment:Bp,alphatest_pars_fragment:zp,aomap_fragment:Vp,aomap_pars_fragment:Hp,batching_pars_vertex:kp,batching_vertex:Gp,begin_vertex:Wp,beginnormal_vertex:Xp,bsdfs:jp,iridescence_fragment:Yp,bumpmap_pars_fragment:qp,clipping_planes_fragment:$p,clipping_planes_pars_fragment:Zp,clipping_planes_pars_vertex:Kp,clipping_planes_vertex:Jp,color_fragment:Qp,color_pars_fragment:em,color_pars_vertex:tm,color_vertex:nm,common:im,cube_uv_reflection_fragment:rm,defaultnormal_vertex:sm,displacementmap_pars_vertex:om,displacementmap_vertex:am,emissivemap_fragment:lm,emissivemap_pars_fragment:cm,colorspace_fragment:um,colorspace_pars_fragment:hm,envmap_fragment:fm,envmap_common_pars_fragment:dm,envmap_pars_fragment:pm,envmap_pars_vertex:mm,envmap_physical_pars_fragment:wm,envmap_vertex:_m,fog_vertex:gm,fog_pars_vertex:vm,fog_fragment:xm,fog_pars_fragment:ym,gradientmap_pars_fragment:Mm,lightmap_pars_fragment:Em,lights_lambert_fragment:bm,lights_lambert_pars_fragment:Sm,lights_pars_begin:Tm,lights_toon_fragment:Am,lights_toon_pars_fragment:Rm,lights_phong_fragment:Cm,lights_phong_pars_fragment:Pm,lights_physical_fragment:Dm,lights_physical_pars_fragment:Lm,lights_fragment_begin:Om,lights_fragment_maps:Im,lights_fragment_end:Nm,logdepthbuf_fragment:Um,logdepthbuf_pars_fragment:Fm,logdepthbuf_pars_vertex:Bm,logdepthbuf_vertex:zm,map_fragment:Vm,map_pars_fragment:Hm,map_particle_fragment:km,map_particle_pars_fragment:Gm,metalnessmap_fragment:Wm,metalnessmap_pars_fragment:Xm,morphinstance_vertex:jm,morphcolor_vertex:Ym,morphnormal_vertex:qm,morphtarget_pars_vertex:$m,morphtarget_vertex:Zm,normal_fragment_begin:Km,normal_fragment_maps:Jm,normal_pars_fragment:Qm,normal_pars_vertex:e_,normal_vertex:t_,normalmap_pars_fragment:n_,clearcoat_normal_fragment_begin:i_,clearcoat_normal_fragment_maps:r_,clearcoat_pars_fragment:s_,iridescence_pars_fragment:o_,opaque_fragment:a_,packing:l_,premultiplied_alpha_fragment:c_,project_vertex:u_,dithering_fragment:h_,dithering_pars_fragment:f_,roughnessmap_fragment:d_,roughnessmap_pars_fragment:p_,shadowmap_pars_fragment:m_,shadowmap_pars_vertex:__,shadowmap_vertex:g_,shadowmask_pars_fragment:v_,skinbase_vertex:x_,skinning_pars_vertex:y_,skinning_vertex:M_,skinnormal_vertex:E_,specularmap_fragment:b_,specularmap_pars_fragment:S_,tonemapping_fragment:T_,tonemapping_pars_fragment:w_,transmission_fragment:A_,transmission_pars_fragment:R_,uv_pars_fragment:C_,uv_pars_vertex:P_,uv_vertex:D_,worldpos_vertex:L_,background_vert:`varying vec2 vUv;
2545
2545
  uniform mat3 uvTransform;
2546
2546
  void main() {
2547
2547
  vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
@@ -3597,7 +3597,7 @@ void main() {
3597
3597
  #include <tonemapping_fragment>
3598
3598
  #include <colorspace_fragment>
3599
3599
  #include <fog_fragment>
3600
- }`},fe={common:{diffuse:{value:new Ve(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 Ie(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 Ve(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 Ve(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 Ve(16777215)},opacity:{value:1},center:{value:new Ie(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ze},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0}}},hn={basic:{uniforms:Rt([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.fog]),vertexShader:He.meshbasic_vert,fragmentShader:He.meshbasic_frag},lambert:{uniforms:Rt([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 Ve(0)}}]),vertexShader:He.meshlambert_vert,fragmentShader:He.meshlambert_frag},phong:{uniforms:Rt([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 Ve(0)},specular:{value:new Ve(1118481)},shininess:{value:30}}]),vertexShader:He.meshphong_vert,fragmentShader:He.meshphong_frag},standard:{uniforms:Rt([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 Ve(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:He.meshphysical_vert,fragmentShader:He.meshphysical_frag},toon:{uniforms:Rt([fe.common,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.gradientmap,fe.fog,fe.lights,{emissive:{value:new Ve(0)}}]),vertexShader:He.meshtoon_vert,fragmentShader:He.meshtoon_frag},matcap:{uniforms:Rt([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,{matcap:{value:null}}]),vertexShader:He.meshmatcap_vert,fragmentShader:He.meshmatcap_frag},points:{uniforms:Rt([fe.points,fe.fog]),vertexShader:He.points_vert,fragmentShader:He.points_frag},dashed:{uniforms:Rt([fe.common,fe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:He.linedashed_vert,fragmentShader:He.linedashed_frag},depth:{uniforms:Rt([fe.common,fe.displacementmap]),vertexShader:He.depth_vert,fragmentShader:He.depth_frag},normal:{uniforms:Rt([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,{opacity:{value:1}}]),vertexShader:He.meshnormal_vert,fragmentShader:He.meshnormal_frag},sprite:{uniforms:Rt([fe.sprite,fe.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:Rt([fe.common,fe.displacementmap,{referencePosition:{value:new U},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:He.distanceRGBA_vert,fragmentShader:He.distanceRGBA_frag},shadow:{uniforms:Rt([fe.lights,fe.fog,{color:{value:new Ve(0)},opacity:{value:1}}]),vertexShader:He.shadow_vert,fragmentShader:He.shadow_frag}};hn.physical={uniforms:Rt([hn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ze},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ze},clearcoatNormalScale:{value:new Ie(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 Ve(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 Ie},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ze},attenuationDistance:{value:0},attenuationColor:{value:new Ve(0)},specularColor:{value:new Ve(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ze},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ze},anisotropyVector:{value:new Ie},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ze}}]),vertexShader:He.meshphysical_vert,fragmentShader:He.meshphysical_frag};const zr={r:0,b:0,g:0},Xn=new en,od=new rt;function ad(i,e,t,n,r,s,o){const a=new Ve(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===ir)?(u===void 0&&(u=new _e(new _t(1,1,1),new Pn({name:"BackgroundCubeMaterial",uniforms:Si(hn.backgroundCube.uniforms),vertexShader:hn.backgroundCube.vertexShader,fragmentShader:hn.backgroundCube.fragmentShader,side:Dt,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)),Xn.copy(_.backgroundRotation),Xn.x*=-1,Xn.y*=-1,Xn.z*=-1,T.isCubeTexture&&T.isRenderTargetTexture===!1&&(Xn.y*=-1,Xn.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(od.makeRotationFromEuler(Xn)),u.material.toneMapped=qe.getTransfer(T.colorSpace)!==Ke,(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 ji(2,2),new Pn({name:"BackgroundMaterial",uniforms:Si(hn.background.uniforms),vertexShader:hn.background.vertexShader,fragmentShader:hn.background.fragmentShader,side:yn,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=qe.getTransfer(T.colorSpace)!==Ke,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(zr,nl(i)),n.buffers.color.setClear(zr.r,zr.g,zr.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 ld(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 $ in se)if(se[$].location>=0){const pe=j[$];let Me=Q[$];if(Me===void 0&&($==="instanceMatrix"&&x.instanceMatrix&&(Me=x.instanceMatrix),$==="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 $ in se)if(se[$].location>=0){let pe=Q[$];pe===void 0&&($==="instanceMatrix"&&x.instanceMatrix&&(pe=x.instanceMatrix),$==="instanceColor"&&x.instanceColor&&(pe=x.instanceColor));const Me={};Me.attribute=pe,pe&&pe.data&&(Me.data=pe.data),j[$]=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 $=Q[se];if($.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 de=Ne.buffer,Xe=Ne.type,je=Ne.bytesPerElement,Z=Xe===i.INT||Xe===i.UNSIGNED_INT||le.gpuType===Ms;if(le.isInterleavedBufferAttribute){const oe=le.data,xe=oe.stride,Le=le.offset;if(oe.isInstancedInterleavedBuffer){for(let Ae=0;Ae<$.locationSize;Ae++)h($.location+Ae,oe.meshPerAttribute);x.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=oe.meshPerAttribute*oe.count)}else for(let Ae=0;Ae<$.locationSize;Ae++)p($.location+Ae);i.bindBuffer(i.ARRAY_BUFFER,de);for(let Ae=0;Ae<$.locationSize;Ae++)b($.location+Ae,Me/$.locationSize,Xe,pe,xe*je,(Le+Me/$.locationSize*Ae)*je,Z)}else{if(le.isInstancedBufferAttribute){for(let oe=0;oe<$.locationSize;oe++)h($.location+oe,le.meshPerAttribute);x.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=le.meshPerAttribute*le.count)}else for(let oe=0;oe<$.locationSize;oe++)p($.location+oe);i.bindBuffer(i.ARRAY_BUFFER,de);for(let oe=0;oe<$.locationSize;oe++)b($.location+oe,Me/$.locationSize,Xe,pe,Me*je,Me/$.locationSize*oe*je,Z)}}else if(K!==void 0){const pe=K[se];if(pe!==void 0)switch(pe.length){case 2:i.vertexAttrib2fv($.location,pe);break;case 3:i.vertexAttrib3fv($.location,pe);break;case 4:i.vertexAttrib4fv($.location,pe);break;default:i.vertexAttrib1fv($.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 cd(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 hd(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!==Kt&&n.convert(A)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(A){const C=A===Ii&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(A!==on&&n.convert(A)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&A!==dn&&!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 ud(i){const e=this;let t=null,n=0,r=!1,s=!1;const o=new Ln,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 fd(i){let e=new WeakMap;function t(o,a){return a===ms?o.mapping=oi:a===_s&&(o.mapping=ai),o}function n(o){if(o&&o.isTexture){const a=o.mapping;if(a===ms||a===_s)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 Hh(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 Ai=4,Tl=[.125,.215,.35,.446,.526,.582],Yn=20,Oo=new _l,bl=new Ve;let Fo=null,Bo=0,zo=0,Ho=!1;const qn=(1+Math.sqrt(5))/2,Ri=1/qn,wl=[new U(-qn,Ri,0),new U(qn,Ri,0),new U(-Ri,0,qn),new U(Ri,0,qn),new U(0,qn,-Ri),new U(0,qn,Ri),new U(-1,1,-1),new U(1,1,-1),new U(-1,1,1),new U(1,1,1)],dd=new U;class Al{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=dd}=s;Fo=this._renderer.getRenderTarget(),Bo=this._renderer.getActiveCubeFace(),zo=this._renderer.getActiveMipmapLevel(),Ho=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=Pl(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Cl(),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(Fo,Bo,zo),this._renderer.xr.enabled=Ho,e.scissorTest=!1,Hr(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===oi||e.mapping===ai?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Fo=this._renderer.getRenderTarget(),Bo=this._renderer.getActiveCubeFace(),zo=this._renderer.getActiveMipmapLevel(),Ho=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:sn,minFilter:sn,generateMipmaps:!1,type:Ii,format:Kt,colorSpace:li,depthBuffer:!1},r=Rl(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Rl(e,t,n);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=pd(s)),this._blurMaterial=md(s,e,t)}return r}_compileMaterial(e){const t=new _e(this._lodPlanes[0],e);this._renderer.compile(t,Oo)}_sceneToCubeUV(e,t,n,r,s){const c=new Xt(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(bl),f.toneMapping=En,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(r),f.clearDepth(),f.setRenderTarget(null));const y=new Sr({name:"PMREM.Background",side:Dt,depthWrite:!1,depthTest:!1}),p=new _e(new _t,y);let h=!1;const w=e.background;w?w.isColor&&(y.color.copy(w),e.background=null,h=!0):(y.color.copy(bl),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;Hr(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===oi||e.mapping===ai;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Pl()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Cl());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;Hr(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(o,Oo)}_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=wl[(r-s-1)%wl.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-Ai?r-b+Ai:0),E=4*(this._cubeSize-_);Hr(t,T,E,3*_,2*_),c.setRenderTarget(t),c.render(f,Oo)}}function pd(i){const e=[],t=[],n=[];let r=i;const s=i-Ai+1+Tl.length;for(let o=0;o<s;o++){const a=Math.pow(2,r);t.push(a);let c=1/a;o>i-Ai?c=Tl[o-i+Ai-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 gt;T.setAttribute("position",new ln(w,y)),T.setAttribute("uv",new ln(b,p)),T.setAttribute("faceIndex",new ln(_,h)),e.push(T),r>Ai&&r--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function Rl(i,e,t){const n=new zn(i,e,t);return n.texture.mapping=ir,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 md(i,e,t){const n=new Float32Array(Yn),r=new U(0,1,0);return new Pn({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:ko(),fragmentShader:`
3600
+ }`},de={common:{diffuse:{value:new je(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ke},alphaMap:{value:null},alphaMapTransform:{value:new ke},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ke}},envmap:{envMap:{value:null},envMapRotation:{value:new ke},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ke}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ke}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ke},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ke},normalScale:{value:new Ne(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ke},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ke}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ke}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ke}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new je(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new je(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ke},alphaTest:{value:0},uvTransform:{value:new ke}},sprite:{diffuse:{value:new je(16777215)},opacity:{value:1},center:{value:new Ne(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ke},alphaMap:{value:null},alphaMapTransform:{value:new ke},alphaTest:{value:0}}},Fn={basic:{uniforms:Bt([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.fog]),vertexShader:Ge.meshbasic_vert,fragmentShader:Ge.meshbasic_frag},lambert:{uniforms:Bt([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 je(0)}}]),vertexShader:Ge.meshlambert_vert,fragmentShader:Ge.meshlambert_frag},phong:{uniforms:Bt([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 je(0)},specular:{value:new je(1118481)},shininess:{value:30}}]),vertexShader:Ge.meshphong_vert,fragmentShader:Ge.meshphong_frag},standard:{uniforms:Bt([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 je(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ge.meshphysical_vert,fragmentShader:Ge.meshphysical_frag},toon:{uniforms:Bt([de.common,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.gradientmap,de.fog,de.lights,{emissive:{value:new je(0)}}]),vertexShader:Ge.meshtoon_vert,fragmentShader:Ge.meshtoon_frag},matcap:{uniforms:Bt([de.common,de.bumpmap,de.normalmap,de.displacementmap,de.fog,{matcap:{value:null}}]),vertexShader:Ge.meshmatcap_vert,fragmentShader:Ge.meshmatcap_frag},points:{uniforms:Bt([de.points,de.fog]),vertexShader:Ge.points_vert,fragmentShader:Ge.points_frag},dashed:{uniforms:Bt([de.common,de.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ge.linedashed_vert,fragmentShader:Ge.linedashed_frag},depth:{uniforms:Bt([de.common,de.displacementmap]),vertexShader:Ge.depth_vert,fragmentShader:Ge.depth_frag},normal:{uniforms:Bt([de.common,de.bumpmap,de.normalmap,de.displacementmap,{opacity:{value:1}}]),vertexShader:Ge.meshnormal_vert,fragmentShader:Ge.meshnormal_frag},sprite:{uniforms:Bt([de.sprite,de.fog]),vertexShader:Ge.sprite_vert,fragmentShader:Ge.sprite_frag},background:{uniforms:{uvTransform:{value:new ke},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ge.background_vert,fragmentShader:Ge.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ke}},vertexShader:Ge.backgroundCube_vert,fragmentShader:Ge.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ge.cube_vert,fragmentShader:Ge.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ge.equirect_vert,fragmentShader:Ge.equirect_frag},distanceRGBA:{uniforms:Bt([de.common,de.displacementmap,{referencePosition:{value:new L},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ge.distanceRGBA_vert,fragmentShader:Ge.distanceRGBA_frag},shadow:{uniforms:Bt([de.lights,de.fog,{color:{value:new je(0)},opacity:{value:1}}]),vertexShader:Ge.shadow_vert,fragmentShader:Ge.shadow_frag}};Fn.physical={uniforms:Bt([Fn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ke},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ke},clearcoatNormalScale:{value:new Ne(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ke},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ke},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ke},sheen:{value:0},sheenColor:{value:new je(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ke},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ke},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ke},transmissionSamplerSize:{value:new Ne},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ke},attenuationDistance:{value:0},attenuationColor:{value:new je(0)},specularColor:{value:new je(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ke},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ke},anisotropyVector:{value:new Ne},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ke}}]),vertexShader:Ge.meshphysical_vert,fragmentShader:Ge.meshphysical_frag};const to={r:0,b:0,g:0},Oi=new En,O_=new ct;function I_(n,e,t,i,r,s,o){const a=new je(0);let l=s===!0?0:1,c,u,h=null,d=0,p=null;function g(T){let _=T.isScene===!0?T.background:null;return _&&_.isTexture&&(_=(T.backgroundBlurriness>0?t:e).get(_)),_}function y(T){let _=!1;const S=g(T);S===null?f(a,l):S&&S.isColor&&(f(S,1),_=!0);const b=n.xr.getEnvironmentBlendMode();b==="additive"?i.buffers.color.setClear(0,0,0,1,o):b==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,o),(n.autoClear||_)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function m(T,_){const S=g(_);S&&(S.isCubeTexture||S.mapping===xs)?(u===void 0&&(u=new ge(new bt(1,1,1),new hi({name:"BackgroundCubeMaterial",uniforms:yr(Fn.backgroundCube.uniforms),vertexShader:Fn.backgroundCube.vertexShader,fragmentShader:Fn.backgroundCube.fragmentShader,side:Ht,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(b,A,C){this.matrixWorld.copyPosition(C.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),Oi.copy(_.backgroundRotation),Oi.x*=-1,Oi.y*=-1,Oi.z*=-1,S.isCubeTexture&&S.isRenderTargetTexture===!1&&(Oi.y*=-1,Oi.z*=-1),u.material.uniforms.envMap.value=S,u.material.uniforms.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=_.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(O_.makeRotationFromEuler(Oi)),u.material.toneMapped=Ze.getTransfer(S.colorSpace)!==tt,(h!==S||d!==S.version||p!==n.toneMapping)&&(u.material.needsUpdate=!0,h=S,d=S.version,p=n.toneMapping),u.layers.enableAll(),T.unshift(u,u.geometry,u.material,0,0,null)):S&&S.isTexture&&(c===void 0&&(c=new ge(new ts(2,2),new hi({name:"BackgroundMaterial",uniforms:yr(Fn.background.uniforms),vertexShader:Fn.background.vertexShader,fragmentShader:Fn.background.fragmentShader,side:ni,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=S,c.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,c.material.toneMapped=Ze.getTransfer(S.colorSpace)!==tt,S.matrixAutoUpdate===!0&&S.updateMatrix(),c.material.uniforms.uvTransform.value.copy(S.matrix),(h!==S||d!==S.version||p!==n.toneMapping)&&(c.material.needsUpdate=!0,h=S,d=S.version,p=n.toneMapping),c.layers.enableAll(),T.unshift(c,c.geometry,c.material,0,0,null))}function f(T,_){T.getRGB(to,vu(n)),i.buffers.color.setClear(to.r,to.g,to.b,_,o)}function w(){u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return a},setClearColor:function(T,_=1){a.set(T),l=_,f(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(T){l=T,f(a,l)},render:y,addToRenderList:m,dispose:w}}function N_(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},r=d(null);let s=r,o=!1;function a(x,N,z,Y,q){let J=!1;const K=h(Y,z,N);s!==K&&(s=K,c(s.object)),J=p(x,Y,z,q),J&&g(x,Y,z,q),q!==null&&e.update(q,n.ELEMENT_ARRAY_BUFFER),(J||o)&&(o=!1,_(x,N,z,Y),q!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(q).buffer))}function l(){return n.createVertexArray()}function c(x){return n.bindVertexArray(x)}function u(x){return n.deleteVertexArray(x)}function h(x,N,z){const Y=z.wireframe===!0;let q=i[x.id];q===void 0&&(q={},i[x.id]=q);let J=q[N.id];J===void 0&&(J={},q[N.id]=J);let K=J[Y];return K===void 0&&(K=d(l()),J[Y]=K),K}function d(x){const N=[],z=[],Y=[];for(let q=0;q<t;q++)N[q]=0,z[q]=0,Y[q]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:N,enabledAttributes:z,attributeDivisors:Y,object:x,attributes:{},index:null}}function p(x,N,z,Y){const q=s.attributes,J=N.attributes;let K=0;const se=z.getAttributes();for(const $ in se)if(se[$].location>=0){const me=q[$];let Ee=J[$];if(Ee===void 0&&($==="instanceMatrix"&&x.instanceMatrix&&(Ee=x.instanceMatrix),$==="instanceColor"&&x.instanceColor&&(Ee=x.instanceColor)),me===void 0||me.attribute!==Ee||Ee&&me.data!==Ee.data)return!0;K++}return s.attributesNum!==K||s.index!==Y}function g(x,N,z,Y){const q={},J=N.attributes;let K=0;const se=z.getAttributes();for(const $ in se)if(se[$].location>=0){let me=J[$];me===void 0&&($==="instanceMatrix"&&x.instanceMatrix&&(me=x.instanceMatrix),$==="instanceColor"&&x.instanceColor&&(me=x.instanceColor));const Ee={};Ee.attribute=me,me&&me.data&&(Ee.data=me.data),q[$]=Ee,K++}s.attributes=q,s.attributesNum=K,s.index=Y}function y(){const x=s.newAttributes;for(let N=0,z=x.length;N<z;N++)x[N]=0}function m(x){f(x,0)}function f(x,N){const z=s.newAttributes,Y=s.enabledAttributes,q=s.attributeDivisors;z[x]=1,Y[x]===0&&(n.enableVertexAttribArray(x),Y[x]=1),q[x]!==N&&(n.vertexAttribDivisor(x,N),q[x]=N)}function w(){const x=s.newAttributes,N=s.enabledAttributes;for(let z=0,Y=N.length;z<Y;z++)N[z]!==x[z]&&(n.disableVertexAttribArray(z),N[z]=0)}function T(x,N,z,Y,q,J,K){K===!0?n.vertexAttribIPointer(x,N,z,q,J):n.vertexAttribPointer(x,N,z,Y,q,J)}function _(x,N,z,Y){y();const q=Y.attributes,J=z.getAttributes(),K=N.defaultAttributeValues;for(const se in J){const $=J[se];if($.location>=0){let le=q[se];if(le===void 0&&(se==="instanceMatrix"&&x.instanceMatrix&&(le=x.instanceMatrix),se==="instanceColor"&&x.instanceColor&&(le=x.instanceColor)),le!==void 0){const me=le.normalized,Ee=le.itemSize,Be=e.get(le);if(Be===void 0)continue;const pe=Be.buffer,qe=Be.type,Je=Be.bytesPerElement,Z=qe===n.INT||qe===n.UNSIGNED_INT||le.gpuType===sa;if(le.isInterleavedBufferAttribute){const oe=le.data,Me=oe.stride,Ie=le.offset;if(oe.isInstancedInterleavedBuffer){for(let Ce=0;Ce<$.locationSize;Ce++)f($.location+Ce,oe.meshPerAttribute);x.isInstancedMesh!==!0&&Y._maxInstanceCount===void 0&&(Y._maxInstanceCount=oe.meshPerAttribute*oe.count)}else for(let Ce=0;Ce<$.locationSize;Ce++)m($.location+Ce);n.bindBuffer(n.ARRAY_BUFFER,pe);for(let Ce=0;Ce<$.locationSize;Ce++)T($.location+Ce,Ee/$.locationSize,qe,me,Me*Je,(Ie+Ee/$.locationSize*Ce)*Je,Z)}else{if(le.isInstancedBufferAttribute){for(let oe=0;oe<$.locationSize;oe++)f($.location+oe,le.meshPerAttribute);x.isInstancedMesh!==!0&&Y._maxInstanceCount===void 0&&(Y._maxInstanceCount=le.meshPerAttribute*le.count)}else for(let oe=0;oe<$.locationSize;oe++)m($.location+oe);n.bindBuffer(n.ARRAY_BUFFER,pe);for(let oe=0;oe<$.locationSize;oe++)T($.location+oe,Ee/$.locationSize,qe,me,Ee*Je,Ee/$.locationSize*oe*Je,Z)}}else if(K!==void 0){const me=K[se];if(me!==void 0)switch(me.length){case 2:n.vertexAttrib2fv($.location,me);break;case 3:n.vertexAttrib3fv($.location,me);break;case 4:n.vertexAttrib4fv($.location,me);break;default:n.vertexAttrib1fv($.location,me)}}}}w()}function S(){C();for(const x in i){const N=i[x];for(const z in N){const Y=N[z];for(const q in Y)u(Y[q].object),delete Y[q];delete N[z]}delete i[x]}}function b(x){if(i[x.id]===void 0)return;const N=i[x.id];for(const z in N){const Y=N[z];for(const q in Y)u(Y[q].object),delete Y[q];delete N[z]}delete i[x.id]}function A(x){for(const N in i){const z=i[N];if(z[x.id]===void 0)continue;const Y=z[x.id];for(const q in Y)u(Y[q].object),delete Y[q];delete z[x.id]}}function C(){M(),o=!0,s!==r&&(s=r,c(s.object))}function M(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:C,resetDefaultState:M,dispose:S,releaseStatesOfGeometry:b,releaseStatesOfProgram:A,initAttributes:y,enableAttribute:m,disableUnusedAttributes:w}}function U_(n,e,t){let i;function r(c){i=c}function s(c,u){n.drawArrays(i,c,u),t.update(u,i,1)}function o(c,u,h){h!==0&&(n.drawArraysInstanced(i,c,u,h),t.update(u,i,h))}function a(c,u,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,u,0,h);let p=0;for(let g=0;g<h;g++)p+=u[g];t.update(p,i,1)}function l(c,u,h,d){if(h===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let g=0;g<c.length;g++)o(c[g],u[g],d[g]);else{p.multiDrawArraysInstancedWEBGL(i,c,0,u,0,d,0,h);let g=0;for(let y=0;y<h;y++)g+=u[y]*d[y];t.update(g,i,1)}}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=l}function F_(n,e,t,i){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const A=e.get("EXT_texture_filter_anisotropic");r=n.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(A){return!(A!==xn&&i.convert(A)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(A){const C=A===Vr&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(A!==Nn&&i.convert(A)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&A!==Wn&&!C)}function l(A){if(A==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const u=l(c);u!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const h=t.logarithmicDepthBuffer===!0,d=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),p=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),g=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=n.getParameter(n.MAX_TEXTURE_SIZE),m=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),f=n.getParameter(n.MAX_VERTEX_ATTRIBS),w=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),T=n.getParameter(n.MAX_VARYING_VECTORS),_=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),S=g>0,b=n.getParameter(n.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:h,reversedDepthBuffer:d,maxTextures:p,maxVertexTextures:g,maxTextureSize:y,maxCubemapSize:m,maxAttributes:f,maxVertexUniforms:w,maxVaryings:T,maxFragmentUniforms:_,vertexTextures:S,maxSamples:b}}function B_(n){const e=this;let t=null,i=0,r=!1,s=!1;const o=new di,a=new ke,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d){const p=h.length!==0||d||i!==0||r;return r=d,i=h.length,p},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,d){t=u(h,d,0)},this.setState=function(h,d,p){const g=h.clippingPlanes,y=h.clipIntersection,m=h.clipShadows,f=n.get(h);if(!r||g===null||g.length===0||s&&!m)s?u(null):c();else{const w=s?0:i,T=w*4;let _=f.clippingState||null;l.value=_,_=u(g,d,T,p);for(let S=0;S!==T;++S)_[S]=t[S];f.clippingState=_,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=w}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(h,d,p,g){const y=h!==null?h.length:0;let m=null;if(y!==0){if(m=l.value,g!==!0||m===null){const f=p+y*4,w=d.matrixWorldInverse;a.getNormalMatrix(w),(m===null||m.length<f)&&(m=new Float32Array(f));for(let T=0,_=p;T!==y;++T,_+=4)o.copy(h[T]).applyMatrix4(w,a),o.normal.toArray(m,_),m[_+3]=o.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,m}}function z_(n){let e=new WeakMap;function t(o,a){return a===ea?o.mapping=rr:a===ta&&(o.mapping=sr),o}function i(o){if(o&&o.isTexture){const a=o.mapping;if(a===ea||a===ta)if(e.has(o)){const l=e.get(o).texture;return t(l,o.mapping)}else{const l=o.image;if(l&&l.height>0){const c=new pp(l.height);return c.fromEquirectangularTexture(n,o),e.set(o,c),o.addEventListener("dispose",r),t(c.texture,o.mapping)}else return null}}return o}function r(o){const a=o.target;a.removeEventListener("dispose",r);const l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function s(){e=new WeakMap}return{get:i,dispose:s}}const Sr=4,Vu=[.125,.215,.35,.446,.526,.582],Ii=20,yl=new Lu,Hu=new je;let Ml=null,El=0,bl=0,Sl=!1;const Ni=(1+Math.sqrt(5))/2,Tr=1/Ni,ku=[new L(-Ni,Tr,0),new L(Ni,Tr,0),new L(-Tr,0,Ni),new L(Tr,0,Ni),new L(0,Ni,-Tr),new L(0,Ni,Tr),new L(-1,1,-1),new L(1,1,-1),new L(-1,1,1),new L(1,1,1)],V_=new L;class Gu{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,r=100,s={}){const{size:o=256,position:a=V_}=s;Ml=this._renderer.getRenderTarget(),El=this._renderer.getActiveCubeFace(),bl=this._renderer.getActiveMipmapLevel(),Sl=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(o);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,i,r,l,a),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ju(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Xu(),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(Ml,El,bl),this._renderer.xr.enabled=Sl,e.scissorTest=!1,no(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===rr||e.mapping===sr?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Ml=this._renderer.getRenderTarget(),El=this._renderer.getActiveCubeFace(),bl=this._renderer.getActiveMipmapLevel(),Sl=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:In,minFilter:In,generateMipmaps:!1,type:Vr,format:xn,colorSpace:or,depthBuffer:!1},r=Wu(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Wu(e,t,i);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=H_(s)),this._blurMaterial=k_(s,e,t)}return r}_compileMaterial(e){const t=new ge(this._lodPlanes[0],e);this._renderer.compile(t,yl)}_sceneToCubeUV(e,t,i,r,s){const l=new an(90,1,t,i),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],h=this._renderer,d=h.autoClear,p=h.toneMapping;h.getClearColor(Hu),h.toneMapping=ri,h.autoClear=!1,h.state.buffers.depth.getReversed()&&(h.setRenderTarget(r),h.clearDepth(),h.setRenderTarget(null));const y=new Bs({name:"PMREM.Background",side:Ht,depthWrite:!1,depthTest:!1}),m=new ge(new bt,y);let f=!1;const w=e.background;w?w.isColor&&(y.color.copy(w),e.background=null,f=!0):(y.color.copy(Hu),f=!0);for(let T=0;T<6;T++){const _=T%3;_===0?(l.up.set(0,c[T],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x+u[T],s.y,s.z)):_===1?(l.up.set(0,0,c[T]),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y+u[T],s.z)):(l.up.set(0,c[T],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y,s.z+u[T]));const S=this._cubeSize;no(r,_*S,T>2?S:0,S,S),h.setRenderTarget(r),f&&h.render(m,l),h.render(e,l)}m.geometry.dispose(),m.material.dispose(),h.toneMapping=p,h.autoClear=d,e.background=w}_textureToCubeUV(e,t){const i=this._renderer,r=e.mapping===rr||e.mapping===sr;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=ju()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Xu());const s=r?this._cubemapMaterial:this._equirectMaterial,o=new ge(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;const l=this._cubeSize;no(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(o,yl)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;s<r;s++){const o=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),a=ku[(r-s-1)%ku.length];this._blur(e,s-1,s,o,a)}t.autoClear=i}_blur(e,t,i,r,s){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,i,r,"latitudinal",s),this._halfBlur(o,e,i,i,r,"longitudinal",s)}_halfBlur(e,t,i,r,s,o,a){const l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,h=new ge(this._lodPlanes[r],c),d=c.uniforms,p=this._sizeLods[i]-1,g=isFinite(s)?Math.PI/(2*p):2*Math.PI/(2*Ii-1),y=s/g,m=isFinite(s)?1+Math.floor(u*y):Ii;m>Ii&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Ii}`);const f=[];let w=0;for(let A=0;A<Ii;++A){const C=A/y,M=Math.exp(-C*C/2);f.push(M),A===0?w+=M:A<m&&(w+=2*M)}for(let A=0;A<f.length;A++)f[A]=f[A]/w;d.envMap.value=e.texture,d.samples.value=m,d.weights.value=f,d.latitudinal.value=o==="latitudinal",a&&(d.poleAxis.value=a);const{_lodMax:T}=this;d.dTheta.value=g,d.mipInt.value=T-i;const _=this._sizeLods[r],S=3*_*(r>T-Sr?r-T+Sr:0),b=4*(this._cubeSize-_);no(t,S,b,3*_,2*_),l.setRenderTarget(t),l.render(h,yl)}}function H_(n){const e=[],t=[],i=[];let r=n;const s=n-Sr+1+Vu.length;for(let o=0;o<s;o++){const a=Math.pow(2,r);t.push(a);let l=1/a;o>n-Sr?l=Vu[o-n+Sr-1]:o===0&&(l=0),i.push(l);const c=1/(a-2),u=-c,h=1+c,d=[u,u,h,u,h,h,u,u,h,h,u,h],p=6,g=6,y=3,m=2,f=1,w=new Float32Array(y*g*p),T=new Float32Array(m*g*p),_=new Float32Array(f*g*p);for(let b=0;b<p;b++){const A=b%3*2/3-1,C=b>2?0:-1,M=[A,C,0,A+2/3,C,0,A+2/3,C+1,0,A,C,0,A+2/3,C+1,0,A,C+1,0];w.set(M,y*g*b),T.set(d,m*g*b);const x=[b,b,b,b,b,b];_.set(x,f*g*b)}const S=new Et;S.setAttribute("position",new Sn(w,y)),S.setAttribute("uv",new Sn(T,m)),S.setAttribute("faceIndex",new Sn(_,f)),e.push(S),r>Sr&&r--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function Wu(n,e,t){const i=new wi(n,e,t);return i.texture.mapping=xs,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function no(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function k_(n,e,t){const i=new Float32Array(Ii),r=new L(0,1,0);return new hi({name:"SphericalGaussianBlur",defines:{n:Ii,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Tl(),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:Sn,depthTest:!1,depthWrite:!1})}function Cl(){return new Pn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ko(),fragmentShader:`
3660
+ `,blending:ii,depthTest:!1,depthWrite:!1})}function Xu(){return new hi({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Tl(),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:Sn,depthTest:!1,depthWrite:!1})}function Pl(){return new Pn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ko(),fragmentShader:`
3679
+ `,blending:ii,depthTest:!1,depthWrite:!1})}function ju(){return new hi({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Tl(),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:Sn,depthTest:!1,depthWrite:!1})}function ko(){return`
3695
+ `,blending:ii,depthTest:!1,depthWrite:!1})}function Tl(){return`
3696
3696
 
3697
3697
  precision mediump float;
3698
3698
  precision mediump int;
@@ -3747,60 +3747,60 @@ void main() {
3747
3747
  gl_Position = vec4( position, 1.0 );
3748
3748
 
3749
3749
  }
3750
- `}function _d(i){let e=new WeakMap,t=null;function n(a){if(a&&a.isTexture){const c=a.mapping,l=c===ms||c===_s,u=c===oi||c===ai;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 Al(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 Al(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 gd(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&&Hi("THREE.WebGLRenderer: "+n+" extension not supported."),r}}}function vd(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(Fa(d)?Qa:Ka)(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 xd(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 Md(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 yd(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 ka(E,_,T,f);A.type=dn,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 Ie(_,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 Sd(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 Dl=new It,Ll=new ul(1,1),Il=new ka,Ul=new Eh,Nl=new ol,Ol=[],Fl=[],Bl=new Float32Array(16),zl=new Float32Array(9),Hl=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=Ol[r];if(s===void 0&&(s=new Float32Array(r),Ol[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 vt(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 xt(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function kr(i,e){let t=Fl[e];t===void 0&&(t=new Int32Array(e),Fl[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function Ed(i,e){const t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function Td(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(vt(t,e))return;i.uniform2fv(this.addr,e),xt(t,e)}}function bd(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(vt(t,e))return;i.uniform3fv(this.addr,e),xt(t,e)}}function wd(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(vt(t,e))return;i.uniform4fv(this.addr,e),xt(t,e)}}function Ad(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(vt(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),xt(t,e)}else{if(vt(t,n))return;Hl.set(n),i.uniformMatrix2fv(this.addr,!1,Hl),xt(t,n)}}function Rd(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(vt(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),xt(t,e)}else{if(vt(t,n))return;zl.set(n),i.uniformMatrix3fv(this.addr,!1,zl),xt(t,n)}}function Cd(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(vt(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),xt(t,e)}else{if(vt(t,n))return;Bl.set(n),i.uniformMatrix4fv(this.addr,!1,Bl),xt(t,n)}}function Pd(i,e){const t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function Dd(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(vt(t,e))return;i.uniform2iv(this.addr,e),xt(t,e)}}function Ld(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(vt(t,e))return;i.uniform3iv(this.addr,e),xt(t,e)}}function Id(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(vt(t,e))return;i.uniform4iv(this.addr,e),xt(t,e)}}function Ud(i,e){const t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function Nd(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(vt(t,e))return;i.uniform2uiv(this.addr,e),xt(t,e)}}function Od(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(vt(t,e))return;i.uniform3uiv(this.addr,e),xt(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.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(vt(t,e))return;i.uniform4uiv(this.addr,e),xt(t,e)}}function Bd(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?(Ll.compareFunction=Ia,s=Ll):s=Dl,t.setTexture2D(e||s,r)}function zd(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture3D(e||Ul,r)}function Hd(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTextureCube(e||Nl,r)}function kd(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture2DArray(e||Il,r)}function Gd(i){switch(i){case 5126:return Ed;case 35664:return Td;case 35665:return bd;case 35666:return wd;case 35674:return Ad;case 35675:return Rd;case 35676:return Cd;case 5124:case 35670:return Pd;case 35667:case 35671:return Dd;case 35668:case 35672:return Ld;case 35669:case 35673:return Id;case 5125:return Ud;case 36294:return Nd;case 36295:return Od;case 36296:return Fd;case 35678:case 36198:case 36298:case 36306:case 35682:return Bd;case 35679:case 36299:case 36307:return zd;case 35680:case 36300:case 36308:case 36293:return Hd;case 36289:case 36303:case 36311:case 36292:return kd}}function Vd(i,e){i.uniform1fv(this.addr,e)}function Wd(i,e){const t=Ci(e,this.size,2);i.uniform2fv(this.addr,t)}function Xd(i,e){const t=Ci(e,this.size,3);i.uniform3fv(this.addr,t)}function Yd(i,e){const t=Ci(e,this.size,4);i.uniform4fv(this.addr,t)}function qd(i,e){const t=Ci(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function jd(i,e){const t=Ci(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function $d(i,e){const t=Ci(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function Zd(i,e){i.uniform1iv(this.addr,e)}function Kd(i,e){i.uniform2iv(this.addr,e)}function Qd(i,e){i.uniform3iv(this.addr,e)}function Jd(i,e){i.uniform4iv(this.addr,e)}function ep(i,e){i.uniform1uiv(this.addr,e)}function tp(i,e){i.uniform2uiv(this.addr,e)}function np(i,e){i.uniform3uiv(this.addr,e)}function ip(i,e){i.uniform4uiv(this.addr,e)}function rp(i,e,t){const n=this.cache,r=e.length,s=kr(t,r);vt(n,s)||(i.uniform1iv(this.addr,s),xt(n,s));for(let o=0;o!==r;++o)t.setTexture2D(e[o]||Dl,s[o])}function sp(i,e,t){const n=this.cache,r=e.length,s=kr(t,r);vt(n,s)||(i.uniform1iv(this.addr,s),xt(n,s));for(let o=0;o!==r;++o)t.setTexture3D(e[o]||Ul,s[o])}function op(i,e,t){const n=this.cache,r=e.length,s=kr(t,r);vt(n,s)||(i.uniform1iv(this.addr,s),xt(n,s));for(let o=0;o!==r;++o)t.setTextureCube(e[o]||Nl,s[o])}function ap(i,e,t){const n=this.cache,r=e.length,s=kr(t,r);vt(n,s)||(i.uniform1iv(this.addr,s),xt(n,s));for(let o=0;o!==r;++o)t.setTexture2DArray(e[o]||Il,s[o])}function lp(i){switch(i){case 5126:return Vd;case 35664:return Wd;case 35665:return Xd;case 35666:return Yd;case 35674:return qd;case 35675:return jd;case 35676:return $d;case 5124:case 35670:return Zd;case 35667:case 35671:return Kd;case 35668:case 35672:return Qd;case 35669:case 35673:return Jd;case 5125:return ep;case 36294:return tp;case 36295:return np;case 36296:return ip;case 35678:case 36198:case 36298:case 36306:case 35682:return rp;case 35679:case 36299:case 36307:return sp;case 35680:case 36300:case 36308:case 36293:return op;case 36289:case 36303:case 36311:case 36292:return ap}}class cp{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=Gd(t.type)}}class hp{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=lp(t.type)}}class up{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 Go=/(\w+)(\])?(\[|\.)?/g;function kl(i,e){i.seq.push(e),i.map[e.id]=e}function fp(i,e,t){const n=i.name,r=n.length;for(Go.lastIndex=0;;){const s=Go.exec(n),o=Go.lastIndex;let a=s[1];const c=s[2]==="]",l=s[3];if(c&&(a=a|0),l===void 0||l==="["&&o+2===r){kl(t,l===void 0?new cp(a,i,e):new hp(a,i,e));break}else{let f=t.map[a];f===void 0&&(f=new up(a),kl(t,f)),t=f}}}class Gr{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);fp(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 Gl(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const dp=37297;let pp=0;function mp(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 Vl=new ze;function _p(i){qe._getMatrix(Vl,qe.workingColorSpace,i);const e=`mat3( ${Vl.elements.map(t=>t.toFixed(4))} )`;switch(qe.getTransfer(i)){case cr:return[e,"LinearTransferOETF"];case Ke:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function Wl(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()+`
3750
+ `}function G_(n){let e=new WeakMap,t=null;function i(a){if(a&&a.isTexture){const l=a.mapping,c=l===ea||l===ta,u=l===rr||l===sr;if(c||u){let h=e.get(a);const d=h!==void 0?h.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==d)return t===null&&(t=new Gu(n)),h=c?t.fromEquirectangular(a,h):t.fromCubemap(a,h),h.texture.pmremVersion=a.pmremVersion,e.set(a,h),h.texture;if(h!==void 0)return h.texture;{const p=a.image;return c&&p&&p.height>0||u&&p&&r(p)?(t===null&&(t=new Gu(n)),h=c?t.fromEquirectangular(a):t.fromCubemap(a),h.texture.pmremVersion=a.pmremVersion,e.set(a,h),a.addEventListener("dispose",s),h.texture):null}}}return a}function r(a){let l=0;const c=6;for(let u=0;u<c;u++)a[u]!==void 0&&l++;return l===c}function s(a){const l=a.target;l.removeEventListener("dispose",s);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:o}}function W_(n){const e={};function t(i){if(e[i]!==void 0)return e[i];let r;switch(i){case"WEBGL_depth_texture":r=n.getExtension("WEBGL_depth_texture")||n.getExtension("MOZ_WEBGL_depth_texture")||n.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=n.getExtension("EXT_texture_filter_anisotropic")||n.getExtension("MOZ_EXT_texture_filter_anisotropic")||n.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=n.getExtension("WEBGL_compressed_texture_s3tc")||n.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=n.getExtension("WEBGL_compressed_texture_pvrtc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=n.getExtension(i)}return e[i]=r,r}return{has:function(i){return t(i)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(i){const r=t(i);return r===null&&Yr("THREE.WebGLRenderer: "+i+" extension not supported."),r}}}function X_(n,e,t,i){const r={},s=new WeakMap;function o(h){const d=h.target;d.index!==null&&e.remove(d.index);for(const g in d.attributes)e.remove(d.attributes[g]);d.removeEventListener("dispose",o),delete r[d.id];const p=s.get(d);p&&(e.remove(p),s.delete(d)),i.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function a(h,d){return r[d.id]===!0||(d.addEventListener("dispose",o),r[d.id]=!0,t.memory.geometries++),d}function l(h){const d=h.attributes;for(const p in d)e.update(d[p],n.ARRAY_BUFFER)}function c(h){const d=[],p=h.index,g=h.attributes.position;let y=0;if(p!==null){const w=p.array;y=p.version;for(let T=0,_=w.length;T<_;T+=3){const S=w[T+0],b=w[T+1],A=w[T+2];d.push(S,b,b,A,A,S)}}else if(g!==void 0){const w=g.array;y=g.version;for(let T=0,_=w.length/3-1;T<_;T+=3){const S=T+0,b=T+1,A=T+2;d.push(S,b,b,A,A,S)}}else return;const m=new(Qc(d)?pu:du)(d,1);m.version=y;const f=s.get(h);f&&e.remove(f),s.set(h,m)}function u(h){const d=s.get(h);if(d){const p=h.index;p!==null&&d.version<p.version&&c(h)}else c(h);return s.get(h)}return{get:a,update:l,getWireframeAttribute:u}}function j_(n,e,t){let i;function r(d){i=d}let s,o;function a(d){s=d.type,o=d.bytesPerElement}function l(d,p){n.drawElements(i,p,s,d*o),t.update(p,i,1)}function c(d,p,g){g!==0&&(n.drawElementsInstanced(i,p,s,d*o,g),t.update(p,i,g))}function u(d,p,g){if(g===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,p,0,s,d,0,g);let m=0;for(let f=0;f<g;f++)m+=p[f];t.update(m,i,1)}function h(d,p,g,y){if(g===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let f=0;f<d.length;f++)c(d[f]/o,p[f],y[f]);else{m.multiDrawElementsInstancedWEBGL(i,p,0,s,d,0,y,0,g);let f=0;for(let w=0;w<g;w++)f+=p[w]*y[w];t.update(f,i,1)}}this.setMode=r,this.setIndex=a,this.render=l,this.renderInstances=c,this.renderMultiDraw=u,this.renderMultiDrawInstances=h}function Y_(n){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,o,a){switch(t.calls++,o){case n.TRIANGLES:t.triangles+=a*(s/3);break;case n.LINES:t.lines+=a*(s/2);break;case n.LINE_STRIP:t.lines+=a*(s-1);break;case n.LINE_LOOP:t.lines+=a*s;break;case n.POINTS:t.points+=a*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:i}}function q_(n,e,t){const i=new WeakMap,r=new gt;function s(o,a,l){const c=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,h=u!==void 0?u.length:0;let d=i.get(a);if(d===void 0||d.count!==h){let M=function(){A.dispose(),i.delete(a),a.removeEventListener("dispose",M)};d!==void 0&&d.texture.dispose();const p=a.morphAttributes.position!==void 0,g=a.morphAttributes.normal!==void 0,y=a.morphAttributes.color!==void 0,m=a.morphAttributes.position||[],f=a.morphAttributes.normal||[],w=a.morphAttributes.color||[];let T=0;p===!0&&(T=1),g===!0&&(T=2),y===!0&&(T=3);let _=a.attributes.position.count*T,S=1;_>e.maxTextureSize&&(S=Math.ceil(_/e.maxTextureSize),_=e.maxTextureSize);const b=new Float32Array(_*S*4*h),A=new iu(b,_,S,h);A.type=Wn,A.needsUpdate=!0;const C=T*4;for(let x=0;x<h;x++){const N=m[x],z=f[x],Y=w[x],q=_*S*4*x;for(let J=0;J<N.count;J++){const K=J*C;p===!0&&(r.fromBufferAttribute(N,J),b[q+K+0]=r.x,b[q+K+1]=r.y,b[q+K+2]=r.z,b[q+K+3]=0),g===!0&&(r.fromBufferAttribute(z,J),b[q+K+4]=r.x,b[q+K+5]=r.y,b[q+K+6]=r.z,b[q+K+7]=0),y===!0&&(r.fromBufferAttribute(Y,J),b[q+K+8]=r.x,b[q+K+9]=r.y,b[q+K+10]=r.z,b[q+K+11]=Y.itemSize===4?r.w:1)}}d={count:h,texture:A,size:new Ne(_,S)},i.set(a,d),a.addEventListener("dispose",M)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)l.getUniforms().setValue(n,"morphTexture",o.morphTexture,t);else{let p=0;for(let y=0;y<c.length;y++)p+=c[y];const g=a.morphTargetsRelative?1:1-p;l.getUniforms().setValue(n,"morphTargetBaseInfluence",g),l.getUniforms().setValue(n,"morphTargetInfluences",c)}l.getUniforms().setValue(n,"morphTargetsTexture",d.texture,t),l.getUniforms().setValue(n,"morphTargetsTextureSize",d.size)}return{update:s}}function $_(n,e,t,i){let r=new WeakMap;function s(l){const c=i.render.frame,u=l.geometry,h=e.get(l,u);if(r.get(h)!==c&&(e.update(h),r.set(h,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",a)===!1&&l.addEventListener("dispose",a),r.get(l)!==c&&(t.update(l.instanceMatrix,n.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,n.ARRAY_BUFFER),r.set(l,c))),l.isSkinnedMesh){const d=l.skeleton;r.get(d)!==c&&(d.update(),r.set(d,c))}return h}function o(){r=new WeakMap}function a(l){const c=l.target;c.removeEventListener("dispose",a),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:s,dispose:o}}const Yu=new Gt,qu=new Au(1,1),$u=new iu,Zu=new Kd,Ku=new Eu,Ju=[],Qu=[],eh=new Float32Array(16),th=new Float32Array(9),nh=new Float32Array(4);function wr(n,e,t){const i=n[0];if(i<=0||i>0)return n;const r=e*t;let s=Ju[r];if(s===void 0&&(s=new Float32Array(r),Ju[r]=s),e!==0){i.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,n[o].toArray(s,a)}return s}function St(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function Tt(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function io(n,e){let t=Qu[e];t===void 0&&(t=new Int32Array(e),Qu[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function Z_(n,e){const t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function K_(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(St(t,e))return;n.uniform2fv(this.addr,e),Tt(t,e)}}function J_(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(St(t,e))return;n.uniform3fv(this.addr,e),Tt(t,e)}}function Q_(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(St(t,e))return;n.uniform4fv(this.addr,e),Tt(t,e)}}function eg(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(St(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),Tt(t,e)}else{if(St(t,i))return;nh.set(i),n.uniformMatrix2fv(this.addr,!1,nh),Tt(t,i)}}function tg(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(St(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),Tt(t,e)}else{if(St(t,i))return;th.set(i),n.uniformMatrix3fv(this.addr,!1,th),Tt(t,i)}}function ng(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(St(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),Tt(t,e)}else{if(St(t,i))return;eh.set(i),n.uniformMatrix4fv(this.addr,!1,eh),Tt(t,i)}}function ig(n,e){const t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function rg(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(St(t,e))return;n.uniform2iv(this.addr,e),Tt(t,e)}}function sg(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(St(t,e))return;n.uniform3iv(this.addr,e),Tt(t,e)}}function og(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(St(t,e))return;n.uniform4iv(this.addr,e),Tt(t,e)}}function ag(n,e){const t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function lg(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(St(t,e))return;n.uniform2uiv(this.addr,e),Tt(t,e)}}function cg(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(St(t,e))return;n.uniform3uiv(this.addr,e),Tt(t,e)}}function ug(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(St(t,e))return;n.uniform4uiv(this.addr,e),Tt(t,e)}}function hg(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r);let s;this.type===n.SAMPLER_2D_SHADOW?(qu.compareFunction=$c,s=qu):s=Yu,t.setTexture2D(e||s,r)}function fg(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture3D(e||Zu,r)}function dg(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||Ku,r)}function pg(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||$u,r)}function mg(n){switch(n){case 5126:return Z_;case 35664:return K_;case 35665:return J_;case 35666:return Q_;case 35674:return eg;case 35675:return tg;case 35676:return ng;case 5124:case 35670:return ig;case 35667:case 35671:return rg;case 35668:case 35672:return sg;case 35669:case 35673:return og;case 5125:return ag;case 36294:return lg;case 36295:return cg;case 36296:return ug;case 35678:case 36198:case 36298:case 36306:case 35682:return hg;case 35679:case 36299:case 36307:return fg;case 35680:case 36300:case 36308:case 36293:return dg;case 36289:case 36303:case 36311:case 36292:return pg}}function _g(n,e){n.uniform1fv(this.addr,e)}function gg(n,e){const t=wr(e,this.size,2);n.uniform2fv(this.addr,t)}function vg(n,e){const t=wr(e,this.size,3);n.uniform3fv(this.addr,t)}function xg(n,e){const t=wr(e,this.size,4);n.uniform4fv(this.addr,t)}function yg(n,e){const t=wr(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function Mg(n,e){const t=wr(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function Eg(n,e){const t=wr(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function bg(n,e){n.uniform1iv(this.addr,e)}function Sg(n,e){n.uniform2iv(this.addr,e)}function Tg(n,e){n.uniform3iv(this.addr,e)}function wg(n,e){n.uniform4iv(this.addr,e)}function Ag(n,e){n.uniform1uiv(this.addr,e)}function Rg(n,e){n.uniform2uiv(this.addr,e)}function Cg(n,e){n.uniform3uiv(this.addr,e)}function Pg(n,e){n.uniform4uiv(this.addr,e)}function Dg(n,e,t){const i=this.cache,r=e.length,s=io(t,r);St(i,s)||(n.uniform1iv(this.addr,s),Tt(i,s));for(let o=0;o!==r;++o)t.setTexture2D(e[o]||Yu,s[o])}function Lg(n,e,t){const i=this.cache,r=e.length,s=io(t,r);St(i,s)||(n.uniform1iv(this.addr,s),Tt(i,s));for(let o=0;o!==r;++o)t.setTexture3D(e[o]||Zu,s[o])}function Og(n,e,t){const i=this.cache,r=e.length,s=io(t,r);St(i,s)||(n.uniform1iv(this.addr,s),Tt(i,s));for(let o=0;o!==r;++o)t.setTextureCube(e[o]||Ku,s[o])}function Ig(n,e,t){const i=this.cache,r=e.length,s=io(t,r);St(i,s)||(n.uniform1iv(this.addr,s),Tt(i,s));for(let o=0;o!==r;++o)t.setTexture2DArray(e[o]||$u,s[o])}function Ng(n){switch(n){case 5126:return _g;case 35664:return gg;case 35665:return vg;case 35666:return xg;case 35674:return yg;case 35675:return Mg;case 35676:return Eg;case 5124:case 35670:return bg;case 35667:case 35671:return Sg;case 35668:case 35672:return Tg;case 35669:case 35673:return wg;case 5125:return Ag;case 36294:return Rg;case 36295:return Cg;case 36296:return Pg;case 35678:case 36198:case 36298:case 36306:case 35682:return Dg;case 35679:case 36299:case 36307:return Lg;case 35680:case 36300:case 36308:case 36293:return Og;case 36289:case 36303:case 36311:case 36292:return Ig}}class Ug{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=mg(t.type)}}class Fg{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=Ng(t.type)}}class Bg{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const r=this.seq;for(let s=0,o=r.length;s!==o;++s){const a=r[s];a.setValue(e,t[a.id],i)}}}const wl=/(\w+)(\])?(\[|\.)?/g;function ih(n,e){n.seq.push(e),n.map[e.id]=e}function zg(n,e,t){const i=n.name,r=i.length;for(wl.lastIndex=0;;){const s=wl.exec(i),o=wl.lastIndex;let a=s[1];const l=s[2]==="]",c=s[3];if(l&&(a=a|0),c===void 0||c==="["&&o+2===r){ih(t,c===void 0?new Ug(a,n,e):new Fg(a,n,e));break}else{let h=t.map[a];h===void 0&&(h=new Bg(a),ih(t,h)),t=h}}}class ro{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<i;++r){const s=e.getActiveUniform(t,r),o=e.getUniformLocation(t,s.name);zg(s,o,this)}}setValue(e,t,i,r){const s=this.map[t];s!==void 0&&s.setValue(e,i,r)}setOptional(e,t,i){const r=t[i];r!==void 0&&this.setValue(e,i,r)}static upload(e,t,i,r){for(let s=0,o=t.length;s!==o;++s){const a=t[s],l=i[a.id];l.needsUpdate!==!1&&a.setValue(e,l.value,r)}}static seqWithValue(e,t){const i=[];for(let r=0,s=e.length;r!==s;++r){const o=e[r];o.id in t&&i.push(o)}return i}}function rh(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const Vg=37297;let Hg=0;function kg(n,e){const t=n.split(`
3751
+ `),i=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let o=r;o<s;o++){const a=o+1;i.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return i.join(`
3752
+ `)}const sh=new ke;function Gg(n){Ze._getMatrix(sh,Ze.workingColorSpace,n);const e=`mat3( ${sh.elements.map(t=>t.toFixed(4))} )`;switch(Ze.getTransfer(n)){case Ts:return[e,"LinearTransferOETF"];case tt:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function oh(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),s=(n.getShaderInfoLog(e)||"").trim();if(i&&s==="")return"";const o=/ERROR: 0:(\d+)/.exec(s);if(o){const a=parseInt(o[1]);return t.toUpperCase()+`
3753
3753
 
3754
3754
  `+s+`
3755
3755
 
3756
- `+mp(i.getShaderSource(e),a)}else return s}function gp(i,e){const t=_p(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
3757
- `)}function vp(i,e){let t;switch(e){case Zc:t="Linear";break;case Kc:t="Reinhard";break;case Qc:t="Cineon";break;case Jc:t="ACESFilmic";break;case th:t="AgX";break;case nh:t="Neutral";break;case eh:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Vr=new U;function xp(){qe.getLuminanceCoefficients(Vr);const i=Vr.x.toFixed(4),e=Vr.y.toFixed(4),t=Vr.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
3758
- `)}function Mp(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter($i).join(`
3759
- `)}function yp(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
3760
- `)}function Sp(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 $i(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 Yl(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Ep=/^[ \t]*#include +<([\w\d./]+)>/gm;function Vo(i){return i.replace(Ep,bp)}const Tp=new Map;function bp(i,e){let t=He[e];if(t===void 0){const n=Tp.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 Vo(t)}const wp=/#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 ql(i){return i.replace(wp,Ap)}function Ap(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 jl(i){let e=`precision ${i.precision} float;
3761
- precision ${i.precision} int;
3762
- precision ${i.precision} sampler2D;
3763
- precision ${i.precision} samplerCube;
3764
- precision ${i.precision} sampler3D;
3765
- precision ${i.precision} sampler2DArray;
3766
- precision ${i.precision} sampler2DShadow;
3767
- precision ${i.precision} samplerCubeShadow;
3768
- precision ${i.precision} sampler2DArrayShadow;
3769
- precision ${i.precision} isampler2D;
3770
- precision ${i.precision} isampler3D;
3771
- precision ${i.precision} isamplerCube;
3772
- precision ${i.precision} isampler2DArray;
3773
- precision ${i.precision} usampler2D;
3774
- precision ${i.precision} usampler3D;
3775
- precision ${i.precision} usamplerCube;
3776
- precision ${i.precision} usampler2DArray;
3777
- `;return i.precision==="highp"?e+=`
3778
- #define HIGH_PRECISION`:i.precision==="mediump"?e+=`
3779
- #define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
3780
- #define LOW_PRECISION`),e}function Rp(i){let e="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===ga?e="SHADOWMAP_TYPE_PCF":i.shadowMapType===Cc?e="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===fn&&(e="SHADOWMAP_TYPE_VSM"),e}function Cp(i){let e="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case oi:case ai:e="ENVMAP_TYPE_CUBE";break;case ir:e="ENVMAP_TYPE_CUBE_UV";break}return e}function Pp(i){let e="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case ai:e="ENVMAP_MODE_REFRACTION";break}return e}function Dp(i){let e="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case ya:e="ENVMAP_BLENDING_MULTIPLY";break;case jc:e="ENVMAP_BLENDING_MIX";break;case $c:e="ENVMAP_BLENDING_ADD";break}return e}function Lp(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 Ip(i,e,t,n){const r=i.getContext(),s=t.defines;let o=t.vertexShader,a=t.fragmentShader;const c=Rp(t),l=Cp(t),u=Pp(t),f=Dp(t),d=Lp(t),m=Mp(t),g=yp(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($i).join(`
3782
- `),p.length>0&&(p+=`
3783
- `),h=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter($i).join(`
3784
- `),h.length>0&&(h+=`
3785
- `)):(p=[jl(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($i).join(`
3787
- `),h=[jl(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!==En?"#define TONE_MAPPING":"",t.toneMapping!==En?He.tonemapping_pars_fragment:"",t.toneMapping!==En?vp("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",He.colorspace_pars_fragment,gp("linearToOutputTexel",t.outputColorSpace),xp(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
3788
- `].filter($i).join(`
3789
- `)),o=Vo(o),o=Xl(o,t),o=Yl(o,t),a=Vo(a),a=Xl(a,t),a=Yl(a,t),o=ql(o),a=ql(a),t.isRawShaderMaterial!==!0&&(w=`#version 300 es
3790
- `,p=[m,"#define attribute in","#define varying out","#define texture2D texture"].join(`
3756
+ `+kg(n.getShaderSource(e),a)}else return s}function Wg(n,e){const t=Gg(e);return[`vec4 ${n}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
3757
+ `)}function Xg(n,e){let t;switch(e){case Sd:t="Linear";break;case Td:t="Reinhard";break;case wd:t="Cineon";break;case Ad:t="ACESFilmic";break;case Cd:t="AgX";break;case Pd:t="Neutral";break;case Rd:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const so=new L;function jg(){Ze.getLuminanceCoefficients(so);const n=so.x.toFixed(4),e=so.y.toFixed(4),t=so.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
3758
+ `)}function Yg(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(ns).join(`
3759
+ `)}function qg(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
3760
+ `)}function $g(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const s=n.getActiveAttrib(e,r),o=s.name;let a=1;s.type===n.FLOAT_MAT2&&(a=2),s.type===n.FLOAT_MAT3&&(a=3),s.type===n.FLOAT_MAT4&&(a=4),t[o]={type:s.type,location:n.getAttribLocation(e,o),locationSize:a}}return t}function ns(n){return n!==""}function ah(n,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return n.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function lh(n,e){return n.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Zg=/^[ \t]*#include +<([\w\d./]+)>/gm;function Al(n){return n.replace(Zg,Jg)}const Kg=new Map;function Jg(n,e){let t=Ge[e];if(t===void 0){const i=Kg.get(e);if(i!==void 0)t=Ge[i],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return Al(t)}const Qg=/#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 ch(n){return n.replace(Qg,ev)}function ev(n,e,t,i){let r="";for(let s=parseInt(e);s<parseInt(t);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function uh(n){let e=`precision ${n.precision} float;
3761
+ precision ${n.precision} int;
3762
+ precision ${n.precision} sampler2D;
3763
+ precision ${n.precision} samplerCube;
3764
+ precision ${n.precision} sampler3D;
3765
+ precision ${n.precision} sampler2DArray;
3766
+ precision ${n.precision} sampler2DShadow;
3767
+ precision ${n.precision} samplerCubeShadow;
3768
+ precision ${n.precision} sampler2DArrayShadow;
3769
+ precision ${n.precision} isampler2D;
3770
+ precision ${n.precision} isampler3D;
3771
+ precision ${n.precision} isamplerCube;
3772
+ precision ${n.precision} isampler2DArray;
3773
+ precision ${n.precision} usampler2D;
3774
+ precision ${n.precision} usampler3D;
3775
+ precision ${n.precision} usamplerCube;
3776
+ precision ${n.precision} usampler2DArray;
3777
+ `;return n.precision==="highp"?e+=`
3778
+ #define HIGH_PRECISION`:n.precision==="mediump"?e+=`
3779
+ #define MEDIUM_PRECISION`:n.precision==="lowp"&&(e+=`
3780
+ #define LOW_PRECISION`),e}function tv(n){let e="SHADOWMAP_TYPE_BASIC";return n.shadowMapType===Oc?e="SHADOWMAP_TYPE_PCF":n.shadowMapType===id?e="SHADOWMAP_TYPE_PCF_SOFT":n.shadowMapType===Gn&&(e="SHADOWMAP_TYPE_VSM"),e}function nv(n){let e="ENVMAP_TYPE_CUBE";if(n.envMap)switch(n.envMapMode){case rr:case sr:e="ENVMAP_TYPE_CUBE";break;case xs:e="ENVMAP_TYPE_CUBE_UV";break}return e}function iv(n){let e="ENVMAP_MODE_REFLECTION";if(n.envMap)switch(n.envMapMode){case sr:e="ENVMAP_MODE_REFRACTION";break}return e}function rv(n){let e="ENVMAP_BLENDING_NONE";if(n.envMap)switch(n.combine){case Fc:e="ENVMAP_BLENDING_MULTIPLY";break;case Ed:e="ENVMAP_BLENDING_MIX";break;case bd:e="ENVMAP_BLENDING_ADD";break}return e}function sv(n){const e=n.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:i,maxMip:t}}function ov(n,e,t,i){const r=n.getContext(),s=t.defines;let o=t.vertexShader,a=t.fragmentShader;const l=tv(t),c=nv(t),u=iv(t),h=rv(t),d=sv(t),p=Yg(t),g=qg(s),y=r.createProgram();let m,f,w=t.glslVersion?"#version "+t.glslVersion+`
3781
+ `:"";t.isRawShaderMaterial?(m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(ns).join(`
3782
+ `),m.length>0&&(m+=`
3783
+ `),f=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(ns).join(`
3784
+ `),f.length>0&&(f+=`
3785
+ `)):(m=[uh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
3786
+ `].filter(ns).join(`
3787
+ `),f=[uh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+h:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==ri?"#define TONE_MAPPING":"",t.toneMapping!==ri?Ge.tonemapping_pars_fragment:"",t.toneMapping!==ri?Xg("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ge.colorspace_pars_fragment,Wg("linearToOutputTexel",t.outputColorSpace),jg(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
3788
+ `].filter(ns).join(`
3789
+ `)),o=Al(o),o=ah(o,t),o=lh(o,t),a=Al(a),a=ah(a,t),a=lh(a,t),o=ch(o),a=ch(a),t.isRawShaderMaterial!==!0&&(w=`#version 300 es
3790
+ `,m=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
3791
3791
  `)+`
3792
- `+p,h=["#define varying in",t.glslVersion===Na?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Na?"":"#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
+ `+m,f=["#define varying in",t.glslVersion===Kc?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Kc?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
3793
3793
  `)+`
3794
- `+h);const b=w+p+o,_=w+h+a,T=Gl(r,r.VERTEX_SHADER,b),E=Gl(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 $=!0,le=!0;if(r.getProgramParameter(y,r.LINK_STATUS)===!1)if($=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,y,T,E);else{const pe=Wl(r,T,"vertex"),Me=Wl(r,E,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(y,r.VALIDATE_STATUS)+`
3794
+ `+f);const T=w+m+o,_=w+f+a,S=rh(r,r.VERTEX_SHADER,T),b=rh(r,r.FRAGMENT_SHADER,_);r.attachShader(y,S),r.attachShader(y,b),t.index0AttributeName!==void 0?r.bindAttribLocation(y,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(y,0,"position"),r.linkProgram(y);function A(N){if(n.debug.checkShaderErrors){const z=r.getProgramInfoLog(y)||"",Y=r.getShaderInfoLog(S)||"",q=r.getShaderInfoLog(b)||"",J=z.trim(),K=Y.trim(),se=q.trim();let $=!0,le=!0;if(r.getProgramParameter(y,r.LINK_STATUS)===!1)if($=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(r,y,S,b);else{const me=oh(r,S,"vertex"),Ee=oh(r,b,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(y,r.VALIDATE_STATUS)+`
3795
3795
 
3796
3796
  Material Name: `+N.name+`
3797
3797
  Material Type: `+N.type+`
3798
3798
 
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:$,programLog:Q,vertexShader:{log:K,prefix:p},fragmentShader:{log:se,prefix:h}})}r.deleteShader(T),r.deleteShader(E),C=new Gr(r,y),M=Sp(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,dp)),x},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(y),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=pp++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=T,this.fragmentShader=E,this}let Up=0;class Np{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 Op(e),t.set(e,n)),n}}class Op{constructor(e){this.id=Up++,this.code=e,this.usedTimes=0}}function Fp(i,e,t,n,r,s,o){const a=new fo,c=new Np,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),$=se&&se.mapping===ir?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 de,Xe,je,Z;if(le){const Ye=hn[le];de=Ye.vertexShader,Xe=Ye.fragmentShader}else de=M.vertexShader,Xe=M.fragmentShader,c.update(M),je=c.getVertexShaderID(M),Z=c.getFragmentShaderID(M);const oe=i.getRenderTarget(),xe=i.state.buffers.depth.getReversed(),Le=q.isInstancedMesh===!0,Ae=q.isBatchedMesh===!0,Oe=!!M.map,yt=!!M.matcap,L=!!se,tt=!!M.aoMap,Fe=!!M.lightMap,Ce=!!M.bumpMap,ye=!!M.normalMap,nt=!!M.displacementMap,Se=!!M.emissiveMap,Be=!!M.metalnessMap,pt=!!M.roughnessMap,st=M.anisotropy>0,R=M.clearcoat>0,v=M.dispersion>0,k=M.iridescence>0,ne=M.sheen>0,re=M.transmission>0,te=st&&!!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=En;M.toneMapped&&(oe===null||oe.isXRRenderTarget===!0)&&(ge=i.toneMapping);const ke={shaderID:le,shaderType:M.type,shaderName:M.name,vertexShader:de,fragmentShader:Xe,defines:M.defines,customVertexShaderID:je,customFragmentShaderID:Z,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:li,alphaToCoverage:!!M.alphaToCoverage,map:Oe,matcap:yt,envMap:L,envMapMode:L&&se.mapping,envMapCubeUVHeight:$,aoMap:tt,lightMap:Fe,bumpMap:Ce,normalMap:ye,displacementMap:d&&nt,emissiveMap:Se,normalMapObjectSpace:ye&&M.normalMapType===oh,normalMapTangentSpace:ye&&M.normalMapType===Da,metalnessMap:Be,roughnessMap:pt,anisotropy:st,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===ri&&M.alphaToCoverage===!1,alphaMap:ee,alphaTest:G,alphaHash:W,combine:M.combine,mapUv:Oe&&y(M.map.channel),aoMapUv:tt&&y(M.aoMap.channel),lightMapUv:Fe&&y(M.lightMap.channel),bumpMapUv:Ce&&y(M.bumpMap.channel),normalMapUv:ye&&y(M.normalMap.channel),displacementMapUv:nt&&y(M.displacementMap.channel),emissiveMapUv:Se&&y(M.emissiveMap.channel),metalnessMapUv:Be&&y(M.metalnessMap.channel),roughnessMapUv:pt&&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||st),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&&qe.getTransfer(M.map.colorSpace)===Ke,decodeVideoTextureEmissive:Se&&M.emissiveMap.isVideoTexture===!0&&qe.getTransfer(M.emissiveMap.colorSpace)===Ke,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===rn,flipSided:M.side===Dt,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=hn[x];N=Oh.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 Ip(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 Bp(){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 zp(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 $l(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 Zl(){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||zp),n.length>1&&n.sort(d||$l),r.length>1&&r.sort(d||$l)}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 Hp(){let i=new WeakMap;function e(n,r){const s=i.get(n);let o;return s===void 0?(o=new Zl,i.set(n,[o])):r>=s.length?(o=new Zl,s.push(o)):o=s[r],o}function t(){i=new WeakMap}return{get:e,dispose:t}}function kp(){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 Ve};break;case"SpotLight":t={position:new U,direction:new U,color:new Ve,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new U,color:new Ve,distance:0,decay:0};break;case"HemisphereLight":t={direction:new U,skyColor:new Ve,groundColor:new Ve};break;case"RectAreaLight":t={color:new Ve,position:new U,halfWidth:new U,halfHeight:new U};break}return i[e.id]=t,t}}}function Gp(){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 Ie};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ie};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ie,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let Vp=0;function Wp(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function Xp(i){const e=new kp,t=Gp(),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 rt,o=new rt;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(Wp);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,$=t.get(N);$.shadowIntensity=se.intensity,$.shadowBias=se.bias,$.shadowNormalBias=se.normalBias,$.shadowRadius=se.radius,$.shadowMapSize=se.mapSize,n.directionalShadow[m]=$,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 $=t.get(N);$.shadowIntensity=se.intensity,$.shadowBias=se.bias,$.shadowNormalBias=se.normalBias,$.shadowRadius=se.radius,$.shadowMapSize=se.mapSize,n.spotShadow[y]=$,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,$=t.get(N);$.shadowIntensity=se.intensity,$.shadowBias=se.bias,$.shadowNormalBias=se.normalBias,$.shadowRadius=se.radius,$.shadowMapSize=se.mapSize,$.shadowCameraNear=se.camera.near,$.shadowCameraFar=se.camera.far,n.pointShadow[g]=$,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=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 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=Vp++)}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 Kl(i){const e=new Xp(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 Yp(i){let e=new WeakMap;function t(r,s=0){const o=e.get(r);let a;return o===void 0?(a=new Kl(i),e.set(r,[a])):s>=o.length?(a=new Kl(i),o.push(a)):a=o[s],a}function n(){e=new WeakMap}return{get:t,dispose:n}}const qp=`void main() {
3799
+ Program Info Log: `+J+`
3800
+ `+me+`
3801
+ `+Ee)}else J!==""?console.warn("THREE.WebGLProgram: Program Info Log:",J):(K===""||se==="")&&(le=!1);le&&(N.diagnostics={runnable:$,programLog:J,vertexShader:{log:K,prefix:m},fragmentShader:{log:se,prefix:f}})}r.deleteShader(S),r.deleteShader(b),C=new ro(r,y),M=$g(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,Vg)),x},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(y),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Hg++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=S,this.fragmentShader=b,this}let av=0;class lv{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(i),o=this._getShaderCacheForMaterial(e);return o.has(r)===!1&&(o.add(r),r.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new cv(e),t.set(e,i)),i}}class cv{constructor(e){this.id=av++,this.code=e,this.usedTimes=0}}function uv(n,e,t,i,r,s,o){const a=new Ka,l=new lv,c=new Set,u=[],h=r.logarithmicDepthBuffer,d=r.vertexTextures;let p=r.precision;const g={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(M){return c.add(M),M===0?"uv":`uv${M}`}function m(M,x,N,z,Y){const q=z.fog,J=Y.geometry,K=M.isMeshStandardMaterial?z.environment:null,se=(M.isMeshStandardMaterial?t:e).get(M.envMap||K),$=se&&se.mapping===xs?se.image.height:null,le=g[M.type];M.precision!==null&&(p=r.getMaxPrecision(M.precision),p!==M.precision&&console.warn("THREE.WebGLProgram.getParameters:",M.precision,"not supported, using",p,"instead."));const me=J.morphAttributes.position||J.morphAttributes.normal||J.morphAttributes.color,Ee=me!==void 0?me.length:0;let Be=0;J.morphAttributes.position!==void 0&&(Be=1),J.morphAttributes.normal!==void 0&&(Be=2),J.morphAttributes.color!==void 0&&(Be=3);let pe,qe,Je,Z;if(le){const $e=Fn[le];pe=$e.vertexShader,qe=$e.fragmentShader}else pe=M.vertexShader,qe=M.fragmentShader,l.update(M),Je=l.getVertexShaderID(M),Z=l.getFragmentShaderID(M);const oe=n.getRenderTarget(),Me=n.state.buffers.depth.getReversed(),Ie=Y.isInstancedMesh===!0,Ce=Y.isBatchedMesh===!0,ze=!!M.map,Rt=!!M.matcap,O=!!se,st=!!M.aoMap,Ve=!!M.lightMap,De=!!M.bumpMap,be=!!M.normalMap,ot=!!M.displacementMap,Se=!!M.emissiveMap,He=!!M.metalnessMap,yt=!!M.roughnessMap,ut=M.anisotropy>0,R=M.clearcoat>0,v=M.dispersion>0,H=M.iridescence>0,ne=M.sheen>0,re=M.transmission>0,te=ut&&!!M.anisotropyMap,Re=R&&!!M.clearcoatMap,fe=R&&!!M.clearcoatNormalMap,Te=R&&!!M.clearcoatRoughnessMap,I=H&&!!M.iridescenceMap,P=H&&!!M.iridescenceThicknessMap,U=ne&&!!M.sheenColorMap,Q=ne&&!!M.sheenRoughnessMap,ie=!!M.specularMap,ae=!!M.specularColorMap,we=!!M.specularIntensityMap,D=re&&!!M.transmissionMap,V=re&&!!M.thicknessMap,G=!!M.gradientMap,ee=!!M.alphaMap,k=M.alphaTest>0,W=!!M.alphaHash,ue=!!M.extensions;let xe=ri;M.toneMapped&&(oe===null||oe.isXRRenderTarget===!0)&&(xe=n.toneMapping);const We={shaderID:le,shaderType:M.type,shaderName:M.name,vertexShader:pe,fragmentShader:qe,defines:M.defines,customVertexShaderID:Je,customFragmentShaderID:Z,isRawShaderMaterial:M.isRawShaderMaterial===!0,glslVersion:M.glslVersion,precision:p,batching:Ce,batchingColor:Ce&&Y._colorsTexture!==null,instancing:Ie,instancingColor:Ie&&Y.instanceColor!==null,instancingMorph:Ie&&Y.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:oe===null?n.outputColorSpace:oe.isXRRenderTarget===!0?oe.texture.colorSpace:or,alphaToCoverage:!!M.alphaToCoverage,map:ze,matcap:Rt,envMap:O,envMapMode:O&&se.mapping,envMapCubeUVHeight:$,aoMap:st,lightMap:Ve,bumpMap:De,normalMap:be,displacementMap:d&&ot,emissiveMap:Se,normalMapObjectSpace:be&&M.normalMapType===Id,normalMapTangentSpace:be&&M.normalMapType===Yc,metalnessMap:He,roughnessMap:yt,anisotropy:ut,anisotropyMap:te,clearcoat:R,clearcoatMap:Re,clearcoatNormalMap:fe,clearcoatRoughnessMap:Te,dispersion:v,iridescence:H,iridescenceMap:I,iridescenceThicknessMap:P,sheen:ne,sheenColorMap:U,sheenRoughnessMap:Q,specularMap:ie,specularColorMap:ae,specularIntensityMap:we,transmission:re,transmissionMap:D,thicknessMap:V,gradientMap:G,opaque:M.transparent===!1&&M.blending===nr&&M.alphaToCoverage===!1,alphaMap:ee,alphaTest:k,alphaHash:W,combine:M.combine,mapUv:ze&&y(M.map.channel),aoMapUv:st&&y(M.aoMap.channel),lightMapUv:Ve&&y(M.lightMap.channel),bumpMapUv:De&&y(M.bumpMap.channel),normalMapUv:be&&y(M.normalMap.channel),displacementMapUv:ot&&y(M.displacementMap.channel),emissiveMapUv:Se&&y(M.emissiveMap.channel),metalnessMapUv:He&&y(M.metalnessMap.channel),roughnessMapUv:yt&&y(M.roughnessMap.channel),anisotropyMapUv:te&&y(M.anisotropyMap.channel),clearcoatMapUv:Re&&y(M.clearcoatMap.channel),clearcoatNormalMapUv:fe&&y(M.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Te&&y(M.clearcoatRoughnessMap.channel),iridescenceMapUv:I&&y(M.iridescenceMap.channel),iridescenceThicknessMapUv:P&&y(M.iridescenceThicknessMap.channel),sheenColorMapUv:U&&y(M.sheenColorMap.channel),sheenRoughnessMapUv:Q&&y(M.sheenRoughnessMap.channel),specularMapUv:ie&&y(M.specularMap.channel),specularColorMapUv:ae&&y(M.specularColorMap.channel),specularIntensityMapUv:we&&y(M.specularIntensityMap.channel),transmissionMapUv:D&&y(M.transmissionMap.channel),thicknessMapUv:V&&y(M.thicknessMap.channel),alphaMapUv:ee&&y(M.alphaMap.channel),vertexTangents:!!J.attributes.tangent&&(be||ut),vertexColors:M.vertexColors,vertexAlphas:M.vertexColors===!0&&!!J.attributes.color&&J.attributes.color.itemSize===4,pointsUvs:Y.isPoints===!0&&!!J.attributes.uv&&(ze||ee),fog:!!q,useFog:M.fog===!0,fogExp2:!!q&&q.isFogExp2,flatShading:M.flatShading===!0&&M.wireframe===!1,sizeAttenuation:M.sizeAttenuation===!0,logarithmicDepthBuffer:h,reversedDepthBuffer:Me,skinning:Y.isSkinnedMesh===!0,morphTargets:J.morphAttributes.position!==void 0,morphNormals:J.morphAttributes.normal!==void 0,morphColors:J.morphAttributes.color!==void 0,morphTargetsCount:Ee,morphTextureStride:Be,numDirLights:x.directional.length,numPointLights:x.point.length,numSpotLights:x.spot.length,numSpotLightMaps:x.spotLightMap.length,numRectAreaLights:x.rectArea.length,numHemiLights:x.hemi.length,numDirLightShadows:x.directionalShadowMap.length,numPointLightShadows:x.pointShadowMap.length,numSpotLightShadows:x.spotShadowMap.length,numSpotLightShadowsWithMaps:x.numSpotLightShadowsWithMaps,numLightProbes:x.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:M.dithering,shadowMapEnabled:n.shadowMap.enabled&&N.length>0,shadowMapType:n.shadowMap.type,toneMapping:xe,decodeVideoTexture:ze&&M.map.isVideoTexture===!0&&Ze.getTransfer(M.map.colorSpace)===tt,decodeVideoTextureEmissive:Se&&M.emissiveMap.isVideoTexture===!0&&Ze.getTransfer(M.emissiveMap.colorSpace)===tt,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===On,flipSided:M.side===Ht,useDepthPacking:M.depthPacking>=0,depthPacking:M.depthPacking||0,index0AttributeName:M.index0AttributeName,extensionClipCullDistance:ue&&M.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ue&&M.extensions.multiDraw===!0||Ce)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:M.customProgramCacheKey()};return We.vertexUv1s=c.has(1),We.vertexUv2s=c.has(2),We.vertexUv3s=c.has(3),c.clear(),We}function f(M){const x=[];if(M.shaderID?x.push(M.shaderID):(x.push(M.customVertexShaderID),x.push(M.customFragmentShaderID)),M.defines!==void 0)for(const N in M.defines)x.push(N),x.push(M.defines[N]);return M.isRawShaderMaterial===!1&&(w(x,M),T(x,M),x.push(n.outputColorSpace)),x.push(M.customProgramCacheKey),x.join()}function w(M,x){M.push(x.precision),M.push(x.outputColorSpace),M.push(x.envMapMode),M.push(x.envMapCubeUVHeight),M.push(x.mapUv),M.push(x.alphaMapUv),M.push(x.lightMapUv),M.push(x.aoMapUv),M.push(x.bumpMapUv),M.push(x.normalMapUv),M.push(x.displacementMapUv),M.push(x.emissiveMapUv),M.push(x.metalnessMapUv),M.push(x.roughnessMapUv),M.push(x.anisotropyMapUv),M.push(x.clearcoatMapUv),M.push(x.clearcoatNormalMapUv),M.push(x.clearcoatRoughnessMapUv),M.push(x.iridescenceMapUv),M.push(x.iridescenceThicknessMapUv),M.push(x.sheenColorMapUv),M.push(x.sheenRoughnessMapUv),M.push(x.specularMapUv),M.push(x.specularColorMapUv),M.push(x.specularIntensityMapUv),M.push(x.transmissionMapUv),M.push(x.thicknessMapUv),M.push(x.combine),M.push(x.fogExp2),M.push(x.sizeAttenuation),M.push(x.morphTargetsCount),M.push(x.morphAttributeCount),M.push(x.numDirLights),M.push(x.numPointLights),M.push(x.numSpotLights),M.push(x.numSpotLightMaps),M.push(x.numHemiLights),M.push(x.numRectAreaLights),M.push(x.numDirLightShadows),M.push(x.numPointLightShadows),M.push(x.numSpotLightShadows),M.push(x.numSpotLightShadowsWithMaps),M.push(x.numLightProbes),M.push(x.shadowMapType),M.push(x.toneMapping),M.push(x.numClippingPlanes),M.push(x.numClipIntersection),M.push(x.depthPacking)}function T(M,x){a.disableAll(),x.supportsVertexTextures&&a.enable(0),x.instancing&&a.enable(1),x.instancingColor&&a.enable(2),x.instancingMorph&&a.enable(3),x.matcap&&a.enable(4),x.envMap&&a.enable(5),x.normalMapObjectSpace&&a.enable(6),x.normalMapTangentSpace&&a.enable(7),x.clearcoat&&a.enable(8),x.iridescence&&a.enable(9),x.alphaTest&&a.enable(10),x.vertexColors&&a.enable(11),x.vertexAlphas&&a.enable(12),x.vertexUv1s&&a.enable(13),x.vertexUv2s&&a.enable(14),x.vertexUv3s&&a.enable(15),x.vertexTangents&&a.enable(16),x.anisotropy&&a.enable(17),x.alphaHash&&a.enable(18),x.batching&&a.enable(19),x.dispersion&&a.enable(20),x.batchingColor&&a.enable(21),x.gradientMap&&a.enable(22),M.push(a.mask),a.disableAll(),x.fog&&a.enable(0),x.useFog&&a.enable(1),x.flatShading&&a.enable(2),x.logarithmicDepthBuffer&&a.enable(3),x.reversedDepthBuffer&&a.enable(4),x.skinning&&a.enable(5),x.morphTargets&&a.enable(6),x.morphNormals&&a.enable(7),x.morphColors&&a.enable(8),x.premultipliedAlpha&&a.enable(9),x.shadowMapEnabled&&a.enable(10),x.doubleSided&&a.enable(11),x.flipSided&&a.enable(12),x.useDepthPacking&&a.enable(13),x.dithering&&a.enable(14),x.transmission&&a.enable(15),x.sheen&&a.enable(16),x.opaque&&a.enable(17),x.pointsUvs&&a.enable(18),x.decodeVideoTexture&&a.enable(19),x.decodeVideoTextureEmissive&&a.enable(20),x.alphaToCoverage&&a.enable(21),M.push(a.mask)}function _(M){const x=g[M.type];let N;if(x){const z=Fn[x];N=up.clone(z.uniforms)}else N=M.uniforms;return N}function S(M,x){let N;for(let z=0,Y=u.length;z<Y;z++){const q=u[z];if(q.cacheKey===x){N=q,++N.usedTimes;break}}return N===void 0&&(N=new ov(n,x,M,s),u.push(N)),N}function b(M){if(--M.usedTimes===0){const x=u.indexOf(M);u[x]=u[u.length-1],u.pop(),M.destroy()}}function A(M){l.remove(M)}function C(){l.dispose()}return{getParameters:m,getProgramCacheKey:f,getUniforms:_,acquireProgram:S,releaseProgram:b,releaseShaderCache:A,programs:u,dispose:C}}function hv(){let n=new WeakMap;function e(o){return n.has(o)}function t(o){let a=n.get(o);return a===void 0&&(a={},n.set(o,a)),a}function i(o){n.delete(o)}function r(o,a,l){n.get(o)[a]=l}function s(){n=new WeakMap}return{has:e,get:t,remove:i,update:r,dispose:s}}function fv(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.z!==e.z?n.z-e.z:n.id-e.id}function hh(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function fh(){const n=[];let e=0;const t=[],i=[],r=[];function s(){e=0,t.length=0,i.length=0,r.length=0}function o(h,d,p,g,y,m){let f=n[e];return f===void 0?(f={id:h.id,object:h,geometry:d,material:p,groupOrder:g,renderOrder:h.renderOrder,z:y,group:m},n[e]=f):(f.id=h.id,f.object=h,f.geometry=d,f.material=p,f.groupOrder=g,f.renderOrder=h.renderOrder,f.z=y,f.group=m),e++,f}function a(h,d,p,g,y,m){const f=o(h,d,p,g,y,m);p.transmission>0?i.push(f):p.transparent===!0?r.push(f):t.push(f)}function l(h,d,p,g,y,m){const f=o(h,d,p,g,y,m);p.transmission>0?i.unshift(f):p.transparent===!0?r.unshift(f):t.unshift(f)}function c(h,d){t.length>1&&t.sort(h||fv),i.length>1&&i.sort(d||hh),r.length>1&&r.sort(d||hh)}function u(){for(let h=e,d=n.length;h<d;h++){const p=n[h];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:t,transmissive:i,transparent:r,init:s,push:a,unshift:l,finish:u,sort:c}}function dv(){let n=new WeakMap;function e(i,r){const s=n.get(i);let o;return s===void 0?(o=new fh,n.set(i,[o])):r>=s.length?(o=new fh,s.push(o)):o=s[r],o}function t(){n=new WeakMap}return{get:e,dispose:t}}function pv(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new L,color:new je};break;case"SpotLight":t={position:new L,direction:new L,color:new je,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new L,color:new je,distance:0,decay:0};break;case"HemisphereLight":t={direction:new L,skyColor:new je,groundColor:new je};break;case"RectAreaLight":t={color:new je,position:new L,halfWidth:new L,halfHeight:new L};break}return n[e.id]=t,t}}}function mv(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let _v=0;function gv(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function vv(n){const e=new pv,t=mv(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)i.probe.push(new L);const r=new L,s=new ct,o=new ct;function a(c){let u=0,h=0,d=0;for(let M=0;M<9;M++)i.probe[M].set(0,0,0);let p=0,g=0,y=0,m=0,f=0,w=0,T=0,_=0,S=0,b=0,A=0;c.sort(gv);for(let M=0,x=c.length;M<x;M++){const N=c[M],z=N.color,Y=N.intensity,q=N.distance,J=N.shadow&&N.shadow.map?N.shadow.map.texture:null;if(N.isAmbientLight)u+=z.r*Y,h+=z.g*Y,d+=z.b*Y;else if(N.isLightProbe){for(let K=0;K<9;K++)i.probe[K].addScaledVector(N.sh.coefficients[K],Y);A++}else if(N.isDirectionalLight){const K=e.get(N);if(K.color.copy(N.color).multiplyScalar(N.intensity),N.castShadow){const se=N.shadow,$=t.get(N);$.shadowIntensity=se.intensity,$.shadowBias=se.bias,$.shadowNormalBias=se.normalBias,$.shadowRadius=se.radius,$.shadowMapSize=se.mapSize,i.directionalShadow[p]=$,i.directionalShadowMap[p]=J,i.directionalShadowMatrix[p]=N.shadow.matrix,w++}i.directional[p]=K,p++}else if(N.isSpotLight){const K=e.get(N);K.position.setFromMatrixPosition(N.matrixWorld),K.color.copy(z).multiplyScalar(Y),K.distance=q,K.coneCos=Math.cos(N.angle),K.penumbraCos=Math.cos(N.angle*(1-N.penumbra)),K.decay=N.decay,i.spot[y]=K;const se=N.shadow;if(N.map&&(i.spotLightMap[S]=N.map,S++,se.updateMatrices(N),N.castShadow&&b++),i.spotLightMatrix[y]=se.matrix,N.castShadow){const $=t.get(N);$.shadowIntensity=se.intensity,$.shadowBias=se.bias,$.shadowNormalBias=se.normalBias,$.shadowRadius=se.radius,$.shadowMapSize=se.mapSize,i.spotShadow[y]=$,i.spotShadowMap[y]=J,_++}y++}else if(N.isRectAreaLight){const K=e.get(N);K.color.copy(z).multiplyScalar(Y),K.halfWidth.set(N.width*.5,0,0),K.halfHeight.set(0,N.height*.5,0),i.rectArea[m]=K,m++}else if(N.isPointLight){const K=e.get(N);if(K.color.copy(N.color).multiplyScalar(N.intensity),K.distance=N.distance,K.decay=N.decay,N.castShadow){const se=N.shadow,$=t.get(N);$.shadowIntensity=se.intensity,$.shadowBias=se.bias,$.shadowNormalBias=se.normalBias,$.shadowRadius=se.radius,$.shadowMapSize=se.mapSize,$.shadowCameraNear=se.camera.near,$.shadowCameraFar=se.camera.far,i.pointShadow[g]=$,i.pointShadowMap[g]=J,i.pointShadowMatrix[g]=N.shadow.matrix,T++}i.point[g]=K,g++}else if(N.isHemisphereLight){const K=e.get(N);K.skyColor.copy(N.color).multiplyScalar(Y),K.groundColor.copy(N.groundColor).multiplyScalar(Y),i.hemi[f]=K,f++}}m>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=de.LTC_FLOAT_1,i.rectAreaLTC2=de.LTC_FLOAT_2):(i.rectAreaLTC1=de.LTC_HALF_1,i.rectAreaLTC2=de.LTC_HALF_2)),i.ambient[0]=u,i.ambient[1]=h,i.ambient[2]=d;const C=i.hash;(C.directionalLength!==p||C.pointLength!==g||C.spotLength!==y||C.rectAreaLength!==m||C.hemiLength!==f||C.numDirectionalShadows!==w||C.numPointShadows!==T||C.numSpotShadows!==_||C.numSpotMaps!==S||C.numLightProbes!==A)&&(i.directional.length=p,i.spot.length=y,i.rectArea.length=m,i.point.length=g,i.hemi.length=f,i.directionalShadow.length=w,i.directionalShadowMap.length=w,i.pointShadow.length=T,i.pointShadowMap.length=T,i.spotShadow.length=_,i.spotShadowMap.length=_,i.directionalShadowMatrix.length=w,i.pointShadowMatrix.length=T,i.spotLightMatrix.length=_+S-b,i.spotLightMap.length=S,i.numSpotLightShadowsWithMaps=b,i.numLightProbes=A,C.directionalLength=p,C.pointLength=g,C.spotLength=y,C.rectAreaLength=m,C.hemiLength=f,C.numDirectionalShadows=w,C.numPointShadows=T,C.numSpotShadows=_,C.numSpotMaps=S,C.numLightProbes=A,i.version=_v++)}function l(c,u){let h=0,d=0,p=0,g=0,y=0;const m=u.matrixWorldInverse;for(let f=0,w=c.length;f<w;f++){const T=c[f];if(T.isDirectionalLight){const _=i.directional[h];_.direction.setFromMatrixPosition(T.matrixWorld),r.setFromMatrixPosition(T.target.matrixWorld),_.direction.sub(r),_.direction.transformDirection(m),h++}else if(T.isSpotLight){const _=i.spot[p];_.position.setFromMatrixPosition(T.matrixWorld),_.position.applyMatrix4(m),_.direction.setFromMatrixPosition(T.matrixWorld),r.setFromMatrixPosition(T.target.matrixWorld),_.direction.sub(r),_.direction.transformDirection(m),p++}else if(T.isRectAreaLight){const _=i.rectArea[g];_.position.setFromMatrixPosition(T.matrixWorld),_.position.applyMatrix4(m),o.identity(),s.copy(T.matrixWorld),s.premultiply(m),o.extractRotation(s),_.halfWidth.set(T.width*.5,0,0),_.halfHeight.set(0,T.height*.5,0),_.halfWidth.applyMatrix4(o),_.halfHeight.applyMatrix4(o),g++}else if(T.isPointLight){const _=i.point[d];_.position.setFromMatrixPosition(T.matrixWorld),_.position.applyMatrix4(m),d++}else if(T.isHemisphereLight){const _=i.hemi[y];_.direction.setFromMatrixPosition(T.matrixWorld),_.direction.transformDirection(m),y++}}}return{setup:a,setupView:l,state:i}}function dh(n){const e=new vv(n),t=[],i=[];function r(u){c.camera=u,t.length=0,i.length=0}function s(u){t.push(u)}function o(u){i.push(u)}function a(){e.setup(t)}function l(u){e.setupView(t,u)}const c={lightsArray:t,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:c,setupLights:a,setupLightsView:l,pushLight:s,pushShadow:o}}function xv(n){let e=new WeakMap;function t(r,s=0){const o=e.get(r);let a;return o===void 0?(a=new dh(n),e.set(r,[a])):s>=o.length?(a=new dh(n),o.push(a)):a=o[s],a}function i(){e=new WeakMap}return{get:t,dispose:i}}const yv=`void main() {
3802
3802
  gl_Position = vec4( position, 1.0 );
3803
- }`,jp=`uniform sampler2D shadow_pass;
3803
+ }`,Mv=`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 $p(i,e,t){let n=new Ao;const r=new Ie,s=new Ie,o=new ut,a=new $h({depthPacking:sh}),c=new Zh,l={},u=t.maxTextureSize,f={[yn]:Dt,[Dt]:yn,[rn]:rn},d=new Pn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ie},radius:{value:4}},vertexShader:qp,fragmentShader:jp}),m=d.clone();m.defines.HORIZONTAL_PASS=1;const g=new gt;g.setAttribute("position",new ln(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=ga;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(Sn),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!==fn&&this.type===fn,j=h===fn&&this.type!==fn;for(let Q=0,K=E.length;Q<K;Q++){const se=E[Q],$=se.shadow;if($===void 0){console.warn("THREE.WebGLShadowMap:",se,"has no shadow.");continue}if($.autoUpdate===!1&&$.needsUpdate===!1)continue;r.copy($.mapSize);const le=$.getFrameExtents();if(r.multiply(le),s.copy($.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/le.x),r.x=s.x*le.x,$.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/le.y),r.y=s.y*le.y,$.mapSize.y=s.y)),$.map===null||q===!0||j===!0){const Me=this.type!==fn?{minFilter:Zt,magFilter:Zt}:{};$.map!==null&&$.map.dispose(),$.map=new zn(r.x,r.y,Me),$.map.texture.name=se.name+".shadowMap",$.camera.updateProjectionMatrix()}i.setRenderTarget($.map),i.clear();const pe=$.getViewportCount();for(let Me=0;Me<pe;Me++){const Ne=$.getViewport(Me);o.set(s.x*Ne.x,s.y*Ne.y,s.x*Ne.z,s.y*Ne.w),z.viewport(o),$.updateMatrices(se,Me),n=$.getFrustum(),_(A,C,$.camera,se,this.type)}$.isPointLightShadow!==!0&&this.type===fn&&w($,C),$.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 zn(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===fn?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===fn)&&(!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 $=Q[K],le=j[$.materialIndex];if(le&&le.visible){const pe=b(E,le,M,x);E.onBeforeShadow(i,E,A,C,q,pe,$),i.renderBufferDirect(C,null,q,pe,E,$),E.onAfterShadow(i,E,A,C,q,pe,$)}}}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 Zp={[ls]:cs,[hs]:ds,[us]:ps,[si]:fs,[cs]:ls,[ds]:hs,[ps]:us,[fs]:si};function Kp(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=Zp[W]),ee!==W){switch(W){case ls:i.depthFunc(i.NEVER);break;case cs:i.depthFunc(i.ALWAYS);break;case hs:i.depthFunc(i.LESS);break;case si:i.depthFunc(i.LEQUAL);break;case us:i.depthFunc(i.EQUAL);break;case fs:i.depthFunc(i.GEQUAL);break;case ds:i.depthFunc(i.GREATER);break;case ps: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,nn,qt){(V!==Ye||ee!==nn||G!==qt)&&(i.stencilFunc(Ye,nn,qt),V=Ye,ee=nn,G=qt)},setOp:function(Ye,nn,qt){(W!==Ye||he!==nn||ge!==qt)&&(i.stencilOp(Ye,nn,qt),W=Ye,he=nn,ge=qt)},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 Ve(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 $=i.getParameter(i.VERSION);$.indexOf("WebGL")!==-1?(se=parseFloat(/^WebGL (\d)/.exec($)[1]),K=se>=1):$.indexOf("OpenGL ES")!==-1&&(se=parseFloat(/^OpenGL ES (\d)/.exec($)[1]),K=se>=2);let le=null,pe={};const Me=i.getParameter(i.SCISSOR_BOX),Ne=i.getParameter(i.VIEWPORT),de=new ut().fromArray(Me),Xe=new ut().fromArray(Ne);function je(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 Z={};Z[i.TEXTURE_2D]=je(i.TEXTURE_2D,i.TEXTURE_2D,1),Z[i.TEXTURE_CUBE_MAP]=je(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),Z[i.TEXTURE_2D_ARRAY]=je(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),Z[i.TEXTURE_3D]=je(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(_a),oe(i.CULL_FACE),tt(Sn);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 yt={[Un]:i.FUNC_ADD,[Dc]:i.FUNC_SUBTRACT,[Lc]:i.FUNC_REVERSE_SUBTRACT};yt[Ic]=i.MIN,yt[Uc]=i.MAX;const L={[Nc]:i.ZERO,[Oc]:i.ONE,[Fc]:i.SRC_COLOR,[os]:i.SRC_ALPHA,[Vc]:i.SRC_ALPHA_SATURATE,[kc]:i.DST_COLOR,[zc]:i.DST_ALPHA,[Bc]:i.ONE_MINUS_SRC_COLOR,[as]:i.ONE_MINUS_SRC_ALPHA,[Gc]:i.ONE_MINUS_DST_COLOR,[Hc]:i.ONE_MINUS_DST_ALPHA,[Wc]:i.CONSTANT_COLOR,[Xc]:i.ONE_MINUS_CONSTANT_COLOR,[Yc]:i.CONSTANT_ALPHA,[qc]:i.ONE_MINUS_CONSTANT_ALPHA};function tt(D,H,V,ee,G,W,he,ge,ke,Ye){if(D===Sn){y===!0&&(xe(i.BLEND),y=!1);return}if(y===!1&&(oe(i.BLEND),y=!0),D!==Pc){if(D!==p||Ye!==M){if((h!==Un||_!==Un)&&(i.blendEquation(i.FUNC_ADD),h=Un,_=Un),Ye)switch(D){case ri:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case va:i.blendFunc(i.ONE,i.ONE);break;case xa:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Ma: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 ri:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case va: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 Ma: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(yt[H],yt[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===rn?xe(i.CULL_FACE):oe(i.CULL_FACE);let V=D.side===Dt;H&&(V=!V),Ce(V),D.blending===ri&&D.transparent===!1?tt(Sn):tt(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!==Ac?(oe(i.CULL_FACE),D!==N&&(D===_a?i.cullFace(i.BACK):D===Rc?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):xe(i.CULL_FACE),N=D}function nt(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 pt(D){D===void 0&&(D=i.TEXTURE0+Q-1),le!==D&&(i.activeTexture(D),le=D)}function st(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||Z[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){de.equals(D)===!1&&(i.scissor(D.x,D.y,D.z,D.w),de.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 Ve(0,0,0),C=0,M=!1,x=null,N=null,z=null,q=null,j=null,de.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:tt,setMaterial:Fe,setFlipSided:Ce,setCullFace:ye,setLineWidth:nt,setPolygonOffset:Se,setScissorTest:Be,activeTexture:pt,bindTexture:st,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 Qp(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 Ie,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):ur("canvas")}function y(R,v,k){let ne=1;const re=st(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?cr:qe.getTransfer(ne);k===i.FLOAT&&(te=i.RGBA32F),k===i.HALF_FLOAT&&(te=i.RGBA16F),k===i.UNSIGNED_BYTE&&(te=we===Ke?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===Fn||v===Ui?k=i.DEPTH24_STENCIL8:v===dn?k=i.DEPTH32F_STENCIL8:v===Li&&(k=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):v===null||v===Fn||v===Ui?k=i.DEPTH_COMPONENT24:v===dn?k=i.DEPTH_COMPONENT32F:v===Li&&(k=i.DEPTH_COMPONENT16),k}function T(R,v){return p(R)===!0||R.isFramebufferTexture&&R.minFilter!==Zt&&R.minFilter!==sn?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{Z(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){Z(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){Z(k,R,v);return}t.bindTexture(i.TEXTURE_3D,k.__webglTexture,i.TEXTURE0+v)}function $(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={[gs]:i.REPEAT,[Nn]:i.CLAMP_TO_EDGE,[vs]:i.MIRRORED_REPEAT},pe={[Zt]:i.NEAREST,[ih]:i.NEAREST_MIPMAP_NEAREST,[rr]:i.NEAREST_MIPMAP_LINEAR,[sn]:i.LINEAR,[xs]:i.LINEAR_MIPMAP_NEAREST,[On]:i.LINEAR_MIPMAP_LINEAR},Me={[ah]:i.NEVER,[dh]:i.ALWAYS,[lh]:i.LESS,[Ia]:i.LEQUAL,[ch]:i.EQUAL,[fh]:i.GEQUAL,[hh]:i.GREATER,[uh]:i.NOTEQUAL};function Ne(R,v){if(v.type===dn&&e.has("OES_texture_float_linear")===!1&&(v.magFilter===sn||v.magFilter===xs||v.magFilter===rr||v.magFilter===On||v.minFilter===sn||v.minFilter===xs||v.minFilter===rr||v.minFilter===On)&&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===Zt||v.minFilter!==rr&&v.minFilter!==On||v.type===dn&&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 de(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 je(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 Z(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=de(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=qe.getPrimaries(qe.workingColorSpace),Ee=v.colorSpace===Tn?null:qe.getPrimaries(v.colorSpace),I=v.colorSpace===Tn||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=pt(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===Oi,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&&je(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!==Kt)if(O!==null)if(D){if(V)if(v.layerUpdates.size>0){const he=Sl(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!==Kt?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=Sl(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=st(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=st(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=de(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=qe.getPrimaries(qe.workingColorSpace),ue=v.colorSpace===Tn?null:qe.getPrimaries(v.colorSpace),Ee=v.colorSpace===Tn||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]=pt(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!==Kt?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=st(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,nt(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=nt(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=nt(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=nt(v);if(v.depthTexture.format===Ni)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===Oi)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 yt(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=nt(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 tt(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 nt(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 pt(R,v){const k=R.colorSpace,ne=R.format,re=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||k!==li&&k!==Tn&&(qe.getTransfer(k)===Ke?(ne!==Kt||re!==on)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",k)),v}function st(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=$,this.rebindTextures=yt,this.setupRenderTarget=L,this.updateRenderTargetMipmap=tt,this.updateMultisampleRenderTarget=ye,this.setupDepthRenderbuffer=Oe,this.setupFrameBufferTexture=xe,this.useMultisampledRTT=Se}function Jp(i,e){function t(n,r=Tn){let s;const o=qe.getTransfer(r);if(n===on)return i.UNSIGNED_BYTE;if(n===ys)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Ss)return i.UNSIGNED_SHORT_5_5_5_1;if(n===ba)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===wa)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===Ea)return i.BYTE;if(n===Ta)return i.SHORT;if(n===Li)return i.UNSIGNED_SHORT;if(n===Ms)return i.INT;if(n===Fn)return i.UNSIGNED_INT;if(n===dn)return i.FLOAT;if(n===Ii)return i.HALF_FLOAT;if(n===Aa)return i.ALPHA;if(n===Ra)return i.RGB;if(n===Kt)return i.RGBA;if(n===Ni)return i.DEPTH_COMPONENT;if(n===Oi)return i.DEPTH_STENCIL;if(n===Ca)return i.RED;if(n===Es)return i.RED_INTEGER;if(n===Pa)return i.RG;if(n===Ts)return i.RG_INTEGER;if(n===bs)return i.RGBA_INTEGER;if(n===sr||n===or||n===ar||n===lr)if(o===Ke)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===sr)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===or)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===ar)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===lr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===sr)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===or)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===ar)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===lr)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===ws||n===As||n===Rs||n===Cs)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===ws)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===As)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Rs)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Cs)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Ps||n===Ds||n===Ls)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===Ps||n===Ds)return o===Ke?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===Ls)return o===Ke?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===Is||n===Us||n===Ns||n===Os||n===Fs||n===Bs||n===zs||n===Hs||n===ks||n===Gs||n===Vs||n===Ws||n===Xs||n===Ys)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===Is)return o===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Us)return o===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Ns)return o===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Os)return o===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Fs)return o===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Bs)return o===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===zs)return o===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Hs)return o===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===ks)return o===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Gs)return o===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Vs)return o===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Ws)return o===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Xs)return o===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Ys)return o===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===qs||n===js||n===$s)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===qs)return o===Ke?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===js)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===$s)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Zs||n===Ks||n===Qs||n===Js)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===Zs)return s.COMPRESSED_RED_RGTC1_EXT;if(n===Ks)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Qs)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Js)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ui?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const em=`
3829
+ }`;function Ev(n,e,t){let i=new hl;const r=new Ne,s=new Ne,o=new gt,a=new bp({depthPacking:Od}),l=new Sp,c={},u=t.maxTextureSize,h={[ni]:Ht,[Ht]:ni,[On]:On},d=new hi({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ne},radius:{value:4}},vertexShader:yv,fragmentShader:Mv}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const g=new Et;g.setAttribute("position",new Sn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new ge(g,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Oc;let f=this.type;this.render=function(b,A,C){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||b.length===0)return;const M=n.getRenderTarget(),x=n.getActiveCubeFace(),N=n.getActiveMipmapLevel(),z=n.state;z.setBlending(ii),z.buffers.depth.getReversed()===!0?z.buffers.color.setClear(0,0,0,0):z.buffers.color.setClear(1,1,1,1),z.buffers.depth.setTest(!0),z.setScissorTest(!1);const Y=f!==Gn&&this.type===Gn,q=f===Gn&&this.type!==Gn;for(let J=0,K=b.length;J<K;J++){const se=b[J],$=se.shadow;if($===void 0){console.warn("THREE.WebGLShadowMap:",se,"has no shadow.");continue}if($.autoUpdate===!1&&$.needsUpdate===!1)continue;r.copy($.mapSize);const le=$.getFrameExtents();if(r.multiply(le),s.copy($.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/le.x),r.x=s.x*le.x,$.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/le.y),r.y=s.y*le.y,$.mapSize.y=s.y)),$.map===null||Y===!0||q===!0){const Ee=this.type!==Gn?{minFilter:vn,magFilter:vn}:{};$.map!==null&&$.map.dispose(),$.map=new wi(r.x,r.y,Ee),$.map.texture.name=se.name+".shadowMap",$.camera.updateProjectionMatrix()}n.setRenderTarget($.map),n.clear();const me=$.getViewportCount();for(let Ee=0;Ee<me;Ee++){const Be=$.getViewport(Ee);o.set(s.x*Be.x,s.y*Be.y,s.x*Be.z,s.y*Be.w),z.viewport(o),$.updateMatrices(se,Ee),i=$.getFrustum(),_(A,C,$.camera,se,this.type)}$.isPointLightShadow!==!0&&this.type===Gn&&w($,C),$.needsUpdate=!1}f=this.type,m.needsUpdate=!1,n.setRenderTarget(M,x,N)};function w(b,A){const C=e.update(y);d.defines.VSM_SAMPLES!==b.blurSamples&&(d.defines.VSM_SAMPLES=b.blurSamples,p.defines.VSM_SAMPLES=b.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new wi(r.x,r.y)),d.uniforms.shadow_pass.value=b.map.texture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,n.setRenderTarget(b.mapPass),n.clear(),n.renderBufferDirect(A,null,C,d,y,null),p.uniforms.shadow_pass.value=b.mapPass.texture,p.uniforms.resolution.value=b.mapSize,p.uniforms.radius.value=b.radius,n.setRenderTarget(b.map),n.clear(),n.renderBufferDirect(A,null,C,p,y,null)}function T(b,A,C,M){let x=null;const N=C.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(N!==void 0)x=N;else if(x=C.isPointLight===!0?l:a,n.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){const z=x.uuid,Y=A.uuid;let q=c[z];q===void 0&&(q={},c[z]=q);let J=q[Y];J===void 0&&(J=x.clone(),q[Y]=J,A.addEventListener("dispose",S)),x=J}if(x.visible=A.visible,x.wireframe=A.wireframe,M===Gn?x.side=A.shadowSide!==null?A.shadowSide:A.side:x.side=A.shadowSide!==null?A.shadowSide:h[A.side],x.alphaMap=A.alphaMap,x.alphaTest=A.alphaToCoverage===!0?.5:A.alphaTest,x.map=A.map,x.clipShadows=A.clipShadows,x.clippingPlanes=A.clippingPlanes,x.clipIntersection=A.clipIntersection,x.displacementMap=A.displacementMap,x.displacementScale=A.displacementScale,x.displacementBias=A.displacementBias,x.wireframeLinewidth=A.wireframeLinewidth,x.linewidth=A.linewidth,C.isPointLight===!0&&x.isMeshDistanceMaterial===!0){const z=n.properties.get(x);z.light=C}return x}function _(b,A,C,M,x){if(b.visible===!1)return;if(b.layers.test(A.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&x===Gn)&&(!b.frustumCulled||i.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,b.matrixWorld);const Y=e.update(b),q=b.material;if(Array.isArray(q)){const J=Y.groups;for(let K=0,se=J.length;K<se;K++){const $=J[K],le=q[$.materialIndex];if(le&&le.visible){const me=T(b,le,M,x);b.onBeforeShadow(n,b,A,C,Y,me,$),n.renderBufferDirect(C,null,Y,me,b,$),b.onAfterShadow(n,b,A,C,Y,me,$)}}}else if(q.visible){const J=T(b,q,M,x);b.onBeforeShadow(n,b,A,C,Y,J,null),n.renderBufferDirect(C,null,Y,J,b,null),b.onAfterShadow(n,b,A,C,Y,J,null)}}const z=b.children;for(let Y=0,q=z.length;Y<q;Y++)_(z[Y],A,C,M,x)}function S(b){b.target.removeEventListener("dispose",S);for(const C in c){const M=c[C],x=b.target.uuid;x in M&&(M[x].dispose(),delete M[x])}}}const bv={[Yo]:qo,[$o]:Jo,[Zo]:Qo,[ir]:Ko,[qo]:Yo,[Jo]:$o,[Qo]:Zo,[Ko]:ir};function Sv(n,e){function t(){let D=!1;const V=new gt;let G=null;const ee=new gt(0,0,0,0);return{setMask:function(k){G!==k&&!D&&(n.colorMask(k,k,k,k),G=k)},setLocked:function(k){D=k},setClear:function(k,W,ue,xe,We){We===!0&&(k*=xe,W*=xe,ue*=xe),V.set(k,W,ue,xe),ee.equals(V)===!1&&(n.clearColor(k,W,ue,xe),ee.copy(V))},reset:function(){D=!1,G=null,ee.set(-1,0,0,0)}}}function i(){let D=!1,V=!1,G=null,ee=null,k=null;return{setReversed:function(W){if(V!==W){const ue=e.get("EXT_clip_control");W?ue.clipControlEXT(ue.LOWER_LEFT_EXT,ue.ZERO_TO_ONE_EXT):ue.clipControlEXT(ue.LOWER_LEFT_EXT,ue.NEGATIVE_ONE_TO_ONE_EXT),V=W;const xe=k;k=null,this.setClear(xe)}},getReversed:function(){return V},setTest:function(W){W?oe(n.DEPTH_TEST):Me(n.DEPTH_TEST)},setMask:function(W){G!==W&&!D&&(n.depthMask(W),G=W)},setFunc:function(W){if(V&&(W=bv[W]),ee!==W){switch(W){case Yo:n.depthFunc(n.NEVER);break;case qo:n.depthFunc(n.ALWAYS);break;case $o:n.depthFunc(n.LESS);break;case ir:n.depthFunc(n.LEQUAL);break;case Zo:n.depthFunc(n.EQUAL);break;case Ko:n.depthFunc(n.GEQUAL);break;case Jo:n.depthFunc(n.GREATER);break;case Qo:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}ee=W}},setLocked:function(W){D=W},setClear:function(W){k!==W&&(V&&(W=1-W),n.clearDepth(W),k=W)},reset:function(){D=!1,G=null,ee=null,k=null,V=!1}}}function r(){let D=!1,V=null,G=null,ee=null,k=null,W=null,ue=null,xe=null,We=null;return{setTest:function($e){D||($e?oe(n.STENCIL_TEST):Me(n.STENCIL_TEST))},setMask:function($e){V!==$e&&!D&&(n.stencilMask($e),V=$e)},setFunc:function($e,Ln,mn){(G!==$e||ee!==Ln||k!==mn)&&(n.stencilFunc($e,Ln,mn),G=$e,ee=Ln,k=mn)},setOp:function($e,Ln,mn){(W!==$e||ue!==Ln||xe!==mn)&&(n.stencilOp($e,Ln,mn),W=$e,ue=Ln,xe=mn)},setLocked:function($e){D=$e},setClear:function($e){We!==$e&&(n.clearStencil($e),We=$e)},reset:function(){D=!1,V=null,G=null,ee=null,k=null,W=null,ue=null,xe=null,We=null}}}const s=new t,o=new i,a=new r,l=new WeakMap,c=new WeakMap;let u={},h={},d=new WeakMap,p=[],g=null,y=!1,m=null,f=null,w=null,T=null,_=null,S=null,b=null,A=new je(0,0,0),C=0,M=!1,x=null,N=null,z=null,Y=null,q=null;const J=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,se=0;const $=n.getParameter(n.VERSION);$.indexOf("WebGL")!==-1?(se=parseFloat(/^WebGL (\d)/.exec($)[1]),K=se>=1):$.indexOf("OpenGL ES")!==-1&&(se=parseFloat(/^OpenGL ES (\d)/.exec($)[1]),K=se>=2);let le=null,me={};const Ee=n.getParameter(n.SCISSOR_BOX),Be=n.getParameter(n.VIEWPORT),pe=new gt().fromArray(Ee),qe=new gt().fromArray(Be);function Je(D,V,G,ee){const k=new Uint8Array(4),W=n.createTexture();n.bindTexture(D,W),n.texParameteri(D,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(D,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let ue=0;ue<G;ue++)D===n.TEXTURE_3D||D===n.TEXTURE_2D_ARRAY?n.texImage3D(V,0,n.RGBA,1,1,ee,0,n.RGBA,n.UNSIGNED_BYTE,k):n.texImage2D(V+ue,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,k);return W}const Z={};Z[n.TEXTURE_2D]=Je(n.TEXTURE_2D,n.TEXTURE_2D,1),Z[n.TEXTURE_CUBE_MAP]=Je(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),Z[n.TEXTURE_2D_ARRAY]=Je(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),Z[n.TEXTURE_3D]=Je(n.TEXTURE_3D,n.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),a.setClear(0),oe(n.DEPTH_TEST),o.setFunc(ir),De(!1),be(Lc),oe(n.CULL_FACE),st(ii);function oe(D){u[D]!==!0&&(n.enable(D),u[D]=!0)}function Me(D){u[D]!==!1&&(n.disable(D),u[D]=!1)}function Ie(D,V){return h[D]!==V?(n.bindFramebuffer(D,V),h[D]=V,D===n.DRAW_FRAMEBUFFER&&(h[n.FRAMEBUFFER]=V),D===n.FRAMEBUFFER&&(h[n.DRAW_FRAMEBUFFER]=V),!0):!1}function Ce(D,V){let G=p,ee=!1;if(D){G=d.get(V),G===void 0&&(G=[],d.set(V,G));const k=D.textures;if(G.length!==k.length||G[0]!==n.COLOR_ATTACHMENT0){for(let W=0,ue=k.length;W<ue;W++)G[W]=n.COLOR_ATTACHMENT0+W;G.length=k.length,ee=!0}}else G[0]!==n.BACK&&(G[0]=n.BACK,ee=!0);ee&&n.drawBuffers(G)}function ze(D){return g!==D?(n.useProgram(D),g=D,!0):!1}const Rt={[Mi]:n.FUNC_ADD,[sd]:n.FUNC_SUBTRACT,[od]:n.FUNC_REVERSE_SUBTRACT};Rt[ad]=n.MIN,Rt[ld]=n.MAX;const O={[cd]:n.ZERO,[ud]:n.ONE,[hd]:n.SRC_COLOR,[Xo]:n.SRC_ALPHA,[gd]:n.SRC_ALPHA_SATURATE,[md]:n.DST_COLOR,[dd]:n.DST_ALPHA,[fd]:n.ONE_MINUS_SRC_COLOR,[jo]:n.ONE_MINUS_SRC_ALPHA,[_d]:n.ONE_MINUS_DST_COLOR,[pd]:n.ONE_MINUS_DST_ALPHA,[vd]:n.CONSTANT_COLOR,[xd]:n.ONE_MINUS_CONSTANT_COLOR,[yd]:n.CONSTANT_ALPHA,[Md]:n.ONE_MINUS_CONSTANT_ALPHA};function st(D,V,G,ee,k,W,ue,xe,We,$e){if(D===ii){y===!0&&(Me(n.BLEND),y=!1);return}if(y===!1&&(oe(n.BLEND),y=!0),D!==rd){if(D!==m||$e!==M){if((f!==Mi||_!==Mi)&&(n.blendEquation(n.FUNC_ADD),f=Mi,_=Mi),$e)switch(D){case nr:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Ic:n.blendFunc(n.ONE,n.ONE);break;case Nc:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Uc:n.blendFuncSeparate(n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:console.error("THREE.WebGLState: Invalid blending: ",D);break}else switch(D){case nr:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Ic:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE,n.ONE,n.ONE);break;case Nc:console.error("THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Uc:console.error("THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:console.error("THREE.WebGLState: Invalid blending: ",D);break}w=null,T=null,S=null,b=null,A.set(0,0,0),C=0,m=D,M=$e}return}k=k||V,W=W||G,ue=ue||ee,(V!==f||k!==_)&&(n.blendEquationSeparate(Rt[V],Rt[k]),f=V,_=k),(G!==w||ee!==T||W!==S||ue!==b)&&(n.blendFuncSeparate(O[G],O[ee],O[W],O[ue]),w=G,T=ee,S=W,b=ue),(xe.equals(A)===!1||We!==C)&&(n.blendColor(xe.r,xe.g,xe.b,We),A.copy(xe),C=We),m=D,M=!1}function Ve(D,V){D.side===On?Me(n.CULL_FACE):oe(n.CULL_FACE);let G=D.side===Ht;V&&(G=!G),De(G),D.blending===nr&&D.transparent===!1?st(ii):st(D.blending,D.blendEquation,D.blendSrc,D.blendDst,D.blendEquationAlpha,D.blendSrcAlpha,D.blendDstAlpha,D.blendColor,D.blendAlpha,D.premultipliedAlpha),o.setFunc(D.depthFunc),o.setTest(D.depthTest),o.setMask(D.depthWrite),s.setMask(D.colorWrite);const ee=D.stencilWrite;a.setTest(ee),ee&&(a.setMask(D.stencilWriteMask),a.setFunc(D.stencilFunc,D.stencilRef,D.stencilFuncMask),a.setOp(D.stencilFail,D.stencilZFail,D.stencilZPass)),Se(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),D.alphaToCoverage===!0?oe(n.SAMPLE_ALPHA_TO_COVERAGE):Me(n.SAMPLE_ALPHA_TO_COVERAGE)}function De(D){x!==D&&(D?n.frontFace(n.CW):n.frontFace(n.CCW),x=D)}function be(D){D!==td?(oe(n.CULL_FACE),D!==N&&(D===Lc?n.cullFace(n.BACK):D===nd?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):Me(n.CULL_FACE),N=D}function ot(D){D!==z&&(K&&n.lineWidth(D),z=D)}function Se(D,V,G){D?(oe(n.POLYGON_OFFSET_FILL),(Y!==V||q!==G)&&(n.polygonOffset(V,G),Y=V,q=G)):Me(n.POLYGON_OFFSET_FILL)}function He(D){D?oe(n.SCISSOR_TEST):Me(n.SCISSOR_TEST)}function yt(D){D===void 0&&(D=n.TEXTURE0+J-1),le!==D&&(n.activeTexture(D),le=D)}function ut(D,V,G){G===void 0&&(le===null?G=n.TEXTURE0+J-1:G=le);let ee=me[G];ee===void 0&&(ee={type:void 0,texture:void 0},me[G]=ee),(ee.type!==D||ee.texture!==V)&&(le!==G&&(n.activeTexture(G),le=G),n.bindTexture(D,V||Z[D]),ee.type=D,ee.texture=V)}function R(){const D=me[le];D!==void 0&&D.type!==void 0&&(n.bindTexture(D.type,null),D.type=void 0,D.texture=void 0)}function v(){try{n.compressedTexImage2D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function H(){try{n.compressedTexImage3D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function ne(){try{n.texSubImage2D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function re(){try{n.texSubImage3D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function te(){try{n.compressedTexSubImage2D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function Re(){try{n.compressedTexSubImage3D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function fe(){try{n.texStorage2D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function Te(){try{n.texStorage3D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function I(){try{n.texImage2D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function P(){try{n.texImage3D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function U(D){pe.equals(D)===!1&&(n.scissor(D.x,D.y,D.z,D.w),pe.copy(D))}function Q(D){qe.equals(D)===!1&&(n.viewport(D.x,D.y,D.z,D.w),qe.copy(D))}function ie(D,V){let G=c.get(V);G===void 0&&(G=new WeakMap,c.set(V,G));let ee=G.get(D);ee===void 0&&(ee=n.getUniformBlockIndex(V,D.name),G.set(D,ee))}function ae(D,V){const ee=c.get(V).get(D);l.get(V)!==ee&&(n.uniformBlockBinding(V,ee,D.__bindingPointIndex),l.set(V,ee))}function we(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),o.setReversed(!1),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),u={},le=null,me={},h={},d=new WeakMap,p=[],g=null,y=!1,m=null,f=null,w=null,T=null,_=null,S=null,b=null,A=new je(0,0,0),C=0,M=!1,x=null,N=null,z=null,Y=null,q=null,pe.set(0,0,n.canvas.width,n.canvas.height),qe.set(0,0,n.canvas.width,n.canvas.height),s.reset(),o.reset(),a.reset()}return{buffers:{color:s,depth:o,stencil:a},enable:oe,disable:Me,bindFramebuffer:Ie,drawBuffers:Ce,useProgram:ze,setBlending:st,setMaterial:Ve,setFlipSided:De,setCullFace:be,setLineWidth:ot,setPolygonOffset:Se,setScissorTest:He,activeTexture:yt,bindTexture:ut,unbindTexture:R,compressedTexImage2D:v,compressedTexImage3D:H,texImage2D:I,texImage3D:P,updateUBOMapping:ie,uniformBlockBinding:ae,texStorage2D:fe,texStorage3D:Te,texSubImage2D:ne,texSubImage3D:re,compressedTexSubImage2D:te,compressedTexSubImage3D:Re,scissor:U,viewport:Q,reset:we}}function Tv(n,e,t,i,r,s,o){const a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Ne,u=new WeakMap;let h;const d=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(R,v){return p?new OffscreenCanvas(R,v):As("canvas")}function y(R,v,H){let ne=1;const re=ut(R);if((re.width>H||re.height>H)&&(ne=H/Math.max(re.width,re.height)),ne<1)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap||typeof VideoFrame<"u"&&R instanceof VideoFrame){const te=Math.floor(ne*re.width),Re=Math.floor(ne*re.height);h===void 0&&(h=g(te,Re));const fe=v?g(te,Re):h;return fe.width=te,fe.height=Re,fe.getContext("2d").drawImage(R,0,0,te,Re),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+re.width+"x"+re.height+") to ("+te+"x"+Re+")."),fe}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+re.width+"x"+re.height+")."),R;return R}function m(R){return R.generateMipmaps}function f(R){n.generateMipmap(R)}function w(R){return R.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:R.isWebGL3DRenderTarget?n.TEXTURE_3D:R.isWebGLArrayRenderTarget||R.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function T(R,v,H,ne,re=!1){if(R!==null){if(n[R]!==void 0)return n[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let te=v;if(v===n.RED&&(H===n.FLOAT&&(te=n.R32F),H===n.HALF_FLOAT&&(te=n.R16F),H===n.UNSIGNED_BYTE&&(te=n.R8)),v===n.RED_INTEGER&&(H===n.UNSIGNED_BYTE&&(te=n.R8UI),H===n.UNSIGNED_SHORT&&(te=n.R16UI),H===n.UNSIGNED_INT&&(te=n.R32UI),H===n.BYTE&&(te=n.R8I),H===n.SHORT&&(te=n.R16I),H===n.INT&&(te=n.R32I)),v===n.RG&&(H===n.FLOAT&&(te=n.RG32F),H===n.HALF_FLOAT&&(te=n.RG16F),H===n.UNSIGNED_BYTE&&(te=n.RG8)),v===n.RG_INTEGER&&(H===n.UNSIGNED_BYTE&&(te=n.RG8UI),H===n.UNSIGNED_SHORT&&(te=n.RG16UI),H===n.UNSIGNED_INT&&(te=n.RG32UI),H===n.BYTE&&(te=n.RG8I),H===n.SHORT&&(te=n.RG16I),H===n.INT&&(te=n.RG32I)),v===n.RGB_INTEGER&&(H===n.UNSIGNED_BYTE&&(te=n.RGB8UI),H===n.UNSIGNED_SHORT&&(te=n.RGB16UI),H===n.UNSIGNED_INT&&(te=n.RGB32UI),H===n.BYTE&&(te=n.RGB8I),H===n.SHORT&&(te=n.RGB16I),H===n.INT&&(te=n.RGB32I)),v===n.RGBA_INTEGER&&(H===n.UNSIGNED_BYTE&&(te=n.RGBA8UI),H===n.UNSIGNED_SHORT&&(te=n.RGBA16UI),H===n.UNSIGNED_INT&&(te=n.RGBA32UI),H===n.BYTE&&(te=n.RGBA8I),H===n.SHORT&&(te=n.RGBA16I),H===n.INT&&(te=n.RGBA32I)),v===n.RGB&&(H===n.UNSIGNED_INT_5_9_9_9_REV&&(te=n.RGB9_E5),H===n.UNSIGNED_INT_10F_11F_11F_REV&&(te=n.R11F_G11F_B10F)),v===n.RGBA){const Re=re?Ts:Ze.getTransfer(ne);H===n.FLOAT&&(te=n.RGBA32F),H===n.HALF_FLOAT&&(te=n.RGBA16F),H===n.UNSIGNED_BYTE&&(te=Re===tt?n.SRGB8_ALPHA8:n.RGBA8),H===n.UNSIGNED_SHORT_4_4_4_4&&(te=n.RGBA4),H===n.UNSIGNED_SHORT_5_5_5_1&&(te=n.RGB5_A1)}return(te===n.R16F||te===n.R32F||te===n.RG16F||te===n.RG32F||te===n.RGBA16F||te===n.RGBA32F)&&e.get("EXT_color_buffer_float"),te}function _(R,v){let H;return R?v===null||v===Si||v===Hr?H=n.DEPTH24_STENCIL8:v===Wn?H=n.DEPTH32F_STENCIL8:v===zr&&(H=n.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):v===null||v===Si||v===Hr?H=n.DEPTH_COMPONENT24:v===Wn?H=n.DEPTH_COMPONENT32F:v===zr&&(H=n.DEPTH_COMPONENT16),H}function S(R,v){return m(R)===!0||R.isFramebufferTexture&&R.minFilter!==vn&&R.minFilter!==In?Math.log2(Math.max(v.width,v.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?v.mipmaps.length:1}function b(R){const v=R.target;v.removeEventListener("dispose",b),C(v),v.isVideoTexture&&u.delete(v)}function A(R){const v=R.target;v.removeEventListener("dispose",A),x(v)}function C(R){const v=i.get(R);if(v.__webglInit===void 0)return;const H=R.source,ne=d.get(H);if(ne){const re=ne[v.__cacheKey];re.usedTimes--,re.usedTimes===0&&M(R),Object.keys(ne).length===0&&d.delete(H)}i.remove(R)}function M(R){const v=i.get(R);n.deleteTexture(v.__webglTexture);const H=R.source,ne=d.get(H);delete ne[v.__cacheKey],o.memory.textures--}function x(R){const v=i.get(R);if(R.depthTexture&&(R.depthTexture.dispose(),i.remove(R.depthTexture)),R.isWebGLCubeRenderTarget)for(let ne=0;ne<6;ne++){if(Array.isArray(v.__webglFramebuffer[ne]))for(let re=0;re<v.__webglFramebuffer[ne].length;re++)n.deleteFramebuffer(v.__webglFramebuffer[ne][re]);else n.deleteFramebuffer(v.__webglFramebuffer[ne]);v.__webglDepthbuffer&&n.deleteRenderbuffer(v.__webglDepthbuffer[ne])}else{if(Array.isArray(v.__webglFramebuffer))for(let ne=0;ne<v.__webglFramebuffer.length;ne++)n.deleteFramebuffer(v.__webglFramebuffer[ne]);else n.deleteFramebuffer(v.__webglFramebuffer);if(v.__webglDepthbuffer&&n.deleteRenderbuffer(v.__webglDepthbuffer),v.__webglMultisampledFramebuffer&&n.deleteFramebuffer(v.__webglMultisampledFramebuffer),v.__webglColorRenderbuffer)for(let ne=0;ne<v.__webglColorRenderbuffer.length;ne++)v.__webglColorRenderbuffer[ne]&&n.deleteRenderbuffer(v.__webglColorRenderbuffer[ne]);v.__webglDepthRenderbuffer&&n.deleteRenderbuffer(v.__webglDepthRenderbuffer)}const H=R.textures;for(let ne=0,re=H.length;ne<re;ne++){const te=i.get(H[ne]);te.__webglTexture&&(n.deleteTexture(te.__webglTexture),o.memory.textures--),i.remove(H[ne])}i.remove(R)}let N=0;function z(){N=0}function Y(){const R=N;return R>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+r.maxTextures),N+=1,R}function q(R){const v=[];return v.push(R.wrapS),v.push(R.wrapT),v.push(R.wrapR||0),v.push(R.magFilter),v.push(R.minFilter),v.push(R.anisotropy),v.push(R.internalFormat),v.push(R.format),v.push(R.type),v.push(R.generateMipmaps),v.push(R.premultiplyAlpha),v.push(R.flipY),v.push(R.unpackAlignment),v.push(R.colorSpace),v.join()}function J(R,v){const H=i.get(R);if(R.isVideoTexture&&He(R),R.isRenderTargetTexture===!1&&R.isExternalTexture!==!0&&R.version>0&&H.__version!==R.version){const ne=R.image;if(ne===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ne.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Z(H,R,v);return}}else R.isExternalTexture&&(H.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,H.__webglTexture,n.TEXTURE0+v)}function K(R,v){const H=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&H.__version!==R.version){Z(H,R,v);return}t.bindTexture(n.TEXTURE_2D_ARRAY,H.__webglTexture,n.TEXTURE0+v)}function se(R,v){const H=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&H.__version!==R.version){Z(H,R,v);return}t.bindTexture(n.TEXTURE_3D,H.__webglTexture,n.TEXTURE0+v)}function $(R,v){const H=i.get(R);if(R.version>0&&H.__version!==R.version){oe(H,R,v);return}t.bindTexture(n.TEXTURE_CUBE_MAP,H.__webglTexture,n.TEXTURE0+v)}const le={[na]:n.REPEAT,[Ei]:n.CLAMP_TO_EDGE,[ia]:n.MIRRORED_REPEAT},me={[vn]:n.NEAREST,[Dd]:n.NEAREST_MIPMAP_NEAREST,[ys]:n.NEAREST_MIPMAP_LINEAR,[In]:n.LINEAR,[ra]:n.LINEAR_MIPMAP_NEAREST,[bi]:n.LINEAR_MIPMAP_LINEAR},Ee={[Nd]:n.NEVER,[Hd]:n.ALWAYS,[Ud]:n.LESS,[$c]:n.LEQUAL,[Fd]:n.EQUAL,[Vd]:n.GEQUAL,[Bd]:n.GREATER,[zd]:n.NOTEQUAL};function Be(R,v){if(v.type===Wn&&e.has("OES_texture_float_linear")===!1&&(v.magFilter===In||v.magFilter===ra||v.magFilter===ys||v.magFilter===bi||v.minFilter===In||v.minFilter===ra||v.minFilter===ys||v.minFilter===bi)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(R,n.TEXTURE_WRAP_S,le[v.wrapS]),n.texParameteri(R,n.TEXTURE_WRAP_T,le[v.wrapT]),(R===n.TEXTURE_3D||R===n.TEXTURE_2D_ARRAY)&&n.texParameteri(R,n.TEXTURE_WRAP_R,le[v.wrapR]),n.texParameteri(R,n.TEXTURE_MAG_FILTER,me[v.magFilter]),n.texParameteri(R,n.TEXTURE_MIN_FILTER,me[v.minFilter]),v.compareFunction&&(n.texParameteri(R,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(R,n.TEXTURE_COMPARE_FUNC,Ee[v.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(v.magFilter===vn||v.minFilter!==ys&&v.minFilter!==bi||v.type===Wn&&e.has("OES_texture_float_linear")===!1)return;if(v.anisotropy>1||i.get(v).__currentAnisotropy){const H=e.get("EXT_texture_filter_anisotropic");n.texParameterf(R,H.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(v.anisotropy,r.getMaxAnisotropy())),i.get(v).__currentAnisotropy=v.anisotropy}}}function pe(R,v){let H=!1;R.__webglInit===void 0&&(R.__webglInit=!0,v.addEventListener("dispose",b));const ne=v.source;let re=d.get(ne);re===void 0&&(re={},d.set(ne,re));const te=q(v);if(te!==R.__cacheKey){re[te]===void 0&&(re[te]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,H=!0),re[te].usedTimes++;const Re=re[R.__cacheKey];Re!==void 0&&(re[R.__cacheKey].usedTimes--,Re.usedTimes===0&&M(v)),R.__cacheKey=te,R.__webglTexture=re[te].texture}return H}function qe(R,v,H){return Math.floor(Math.floor(R/H)/v)}function Je(R,v,H,ne){const te=R.updateRanges;if(te.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,v.width,v.height,H,ne,v.data);else{te.sort((P,U)=>P.start-U.start);let Re=0;for(let P=1;P<te.length;P++){const U=te[Re],Q=te[P],ie=U.start+U.count,ae=qe(Q.start,v.width,4),we=qe(U.start,v.width,4);Q.start<=ie+1&&ae===we&&qe(Q.start+Q.count-1,v.width,4)===ae?U.count=Math.max(U.count,Q.start+Q.count-U.start):(++Re,te[Re]=Q)}te.length=Re+1;const fe=n.getParameter(n.UNPACK_ROW_LENGTH),Te=n.getParameter(n.UNPACK_SKIP_PIXELS),I=n.getParameter(n.UNPACK_SKIP_ROWS);n.pixelStorei(n.UNPACK_ROW_LENGTH,v.width);for(let P=0,U=te.length;P<U;P++){const Q=te[P],ie=Math.floor(Q.start/4),ae=Math.ceil(Q.count/4),we=ie%v.width,D=Math.floor(ie/v.width),V=ae,G=1;n.pixelStorei(n.UNPACK_SKIP_PIXELS,we),n.pixelStorei(n.UNPACK_SKIP_ROWS,D),t.texSubImage2D(n.TEXTURE_2D,0,we,D,V,G,H,ne,v.data)}R.clearUpdateRanges(),n.pixelStorei(n.UNPACK_ROW_LENGTH,fe),n.pixelStorei(n.UNPACK_SKIP_PIXELS,Te),n.pixelStorei(n.UNPACK_SKIP_ROWS,I)}}function Z(R,v,H){let ne=n.TEXTURE_2D;(v.isDataArrayTexture||v.isCompressedArrayTexture)&&(ne=n.TEXTURE_2D_ARRAY),v.isData3DTexture&&(ne=n.TEXTURE_3D);const re=pe(R,v),te=v.source;t.bindTexture(ne,R.__webglTexture,n.TEXTURE0+H);const Re=i.get(te);if(te.version!==Re.__version||re===!0){t.activeTexture(n.TEXTURE0+H);const fe=Ze.getPrimaries(Ze.workingColorSpace),Te=v.colorSpace===si?null:Ze.getPrimaries(v.colorSpace),I=v.colorSpace===si||fe===Te?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,v.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,v.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,I);let P=y(v.image,!1,r.maxTextureSize);P=yt(v,P);const U=s.convert(v.format,v.colorSpace),Q=s.convert(v.type);let ie=T(v.internalFormat,U,Q,v.colorSpace,v.isVideoTexture);Be(ne,v);let ae;const we=v.mipmaps,D=v.isVideoTexture!==!0,V=Re.__version===void 0||re===!0,G=te.dataReady,ee=S(v,P);if(v.isDepthTexture)ie=_(v.format===Gr,v.type),V&&(D?t.texStorage2D(n.TEXTURE_2D,1,ie,P.width,P.height):t.texImage2D(n.TEXTURE_2D,0,ie,P.width,P.height,0,U,Q,null));else if(v.isDataTexture)if(we.length>0){D&&V&&t.texStorage2D(n.TEXTURE_2D,ee,ie,we[0].width,we[0].height);for(let k=0,W=we.length;k<W;k++)ae=we[k],D?G&&t.texSubImage2D(n.TEXTURE_2D,k,0,0,ae.width,ae.height,U,Q,ae.data):t.texImage2D(n.TEXTURE_2D,k,ie,ae.width,ae.height,0,U,Q,ae.data);v.generateMipmaps=!1}else D?(V&&t.texStorage2D(n.TEXTURE_2D,ee,ie,P.width,P.height),G&&Je(v,P,U,Q)):t.texImage2D(n.TEXTURE_2D,0,ie,P.width,P.height,0,U,Q,P.data);else if(v.isCompressedTexture)if(v.isCompressedArrayTexture){D&&V&&t.texStorage3D(n.TEXTURE_2D_ARRAY,ee,ie,we[0].width,we[0].height,P.depth);for(let k=0,W=we.length;k<W;k++)if(ae=we[k],v.format!==xn)if(U!==null)if(D){if(G)if(v.layerUpdates.size>0){const ue=Bu(ae.width,ae.height,v.format,v.type);for(const xe of v.layerUpdates){const We=ae.data.subarray(xe*ue/ae.data.BYTES_PER_ELEMENT,(xe+1)*ue/ae.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,k,0,0,xe,ae.width,ae.height,1,U,We)}v.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,k,0,0,0,ae.width,ae.height,P.depth,U,ae.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,k,ie,ae.width,ae.height,P.depth,0,ae.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else D?G&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,k,0,0,0,ae.width,ae.height,P.depth,U,Q,ae.data):t.texImage3D(n.TEXTURE_2D_ARRAY,k,ie,ae.width,ae.height,P.depth,0,U,Q,ae.data)}else{D&&V&&t.texStorage2D(n.TEXTURE_2D,ee,ie,we[0].width,we[0].height);for(let k=0,W=we.length;k<W;k++)ae=we[k],v.format!==xn?U!==null?D?G&&t.compressedTexSubImage2D(n.TEXTURE_2D,k,0,0,ae.width,ae.height,U,ae.data):t.compressedTexImage2D(n.TEXTURE_2D,k,ie,ae.width,ae.height,0,ae.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):D?G&&t.texSubImage2D(n.TEXTURE_2D,k,0,0,ae.width,ae.height,U,Q,ae.data):t.texImage2D(n.TEXTURE_2D,k,ie,ae.width,ae.height,0,U,Q,ae.data)}else if(v.isDataArrayTexture)if(D){if(V&&t.texStorage3D(n.TEXTURE_2D_ARRAY,ee,ie,P.width,P.height,P.depth),G)if(v.layerUpdates.size>0){const k=Bu(P.width,P.height,v.format,v.type);for(const W of v.layerUpdates){const ue=P.data.subarray(W*k/P.data.BYTES_PER_ELEMENT,(W+1)*k/P.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,W,P.width,P.height,1,U,Q,ue)}v.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,P.width,P.height,P.depth,U,Q,P.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,ie,P.width,P.height,P.depth,0,U,Q,P.data);else if(v.isData3DTexture)D?(V&&t.texStorage3D(n.TEXTURE_3D,ee,ie,P.width,P.height,P.depth),G&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,P.width,P.height,P.depth,U,Q,P.data)):t.texImage3D(n.TEXTURE_3D,0,ie,P.width,P.height,P.depth,0,U,Q,P.data);else if(v.isFramebufferTexture){if(V)if(D)t.texStorage2D(n.TEXTURE_2D,ee,ie,P.width,P.height);else{let k=P.width,W=P.height;for(let ue=0;ue<ee;ue++)t.texImage2D(n.TEXTURE_2D,ue,ie,k,W,0,U,Q,null),k>>=1,W>>=1}}else if(we.length>0){if(D&&V){const k=ut(we[0]);t.texStorage2D(n.TEXTURE_2D,ee,ie,k.width,k.height)}for(let k=0,W=we.length;k<W;k++)ae=we[k],D?G&&t.texSubImage2D(n.TEXTURE_2D,k,0,0,U,Q,ae):t.texImage2D(n.TEXTURE_2D,k,ie,U,Q,ae);v.generateMipmaps=!1}else if(D){if(V){const k=ut(P);t.texStorage2D(n.TEXTURE_2D,ee,ie,k.width,k.height)}G&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,U,Q,P)}else t.texImage2D(n.TEXTURE_2D,0,ie,U,Q,P);m(v)&&f(ne),Re.__version=te.version,v.onUpdate&&v.onUpdate(v)}R.__version=v.version}function oe(R,v,H){if(v.image.length!==6)return;const ne=pe(R,v),re=v.source;t.bindTexture(n.TEXTURE_CUBE_MAP,R.__webglTexture,n.TEXTURE0+H);const te=i.get(re);if(re.version!==te.__version||ne===!0){t.activeTexture(n.TEXTURE0+H);const Re=Ze.getPrimaries(Ze.workingColorSpace),fe=v.colorSpace===si?null:Ze.getPrimaries(v.colorSpace),Te=v.colorSpace===si||Re===fe?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,v.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,v.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Te);const I=v.isCompressedTexture||v.image[0].isCompressedTexture,P=v.image[0]&&v.image[0].isDataTexture,U=[];for(let W=0;W<6;W++)!I&&!P?U[W]=y(v.image[W],!0,r.maxCubemapSize):U[W]=P?v.image[W].image:v.image[W],U[W]=yt(v,U[W]);const Q=U[0],ie=s.convert(v.format,v.colorSpace),ae=s.convert(v.type),we=T(v.internalFormat,ie,ae,v.colorSpace),D=v.isVideoTexture!==!0,V=te.__version===void 0||ne===!0,G=re.dataReady;let ee=S(v,Q);Be(n.TEXTURE_CUBE_MAP,v);let k;if(I){D&&V&&t.texStorage2D(n.TEXTURE_CUBE_MAP,ee,we,Q.width,Q.height);for(let W=0;W<6;W++){k=U[W].mipmaps;for(let ue=0;ue<k.length;ue++){const xe=k[ue];v.format!==xn?ie!==null?D?G&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+W,ue,0,0,xe.width,xe.height,ie,xe.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+W,ue,we,xe.width,xe.height,0,xe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):D?G&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+W,ue,0,0,xe.width,xe.height,ie,ae,xe.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+W,ue,we,xe.width,xe.height,0,ie,ae,xe.data)}}}else{if(k=v.mipmaps,D&&V){k.length>0&&ee++;const W=ut(U[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,ee,we,W.width,W.height)}for(let W=0;W<6;W++)if(P){D?G&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,0,0,U[W].width,U[W].height,ie,ae,U[W].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,we,U[W].width,U[W].height,0,ie,ae,U[W].data);for(let ue=0;ue<k.length;ue++){const We=k[ue].image[W].image;D?G&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+W,ue+1,0,0,We.width,We.height,ie,ae,We.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+W,ue+1,we,We.width,We.height,0,ie,ae,We.data)}}else{D?G&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,0,0,ie,ae,U[W]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,we,ie,ae,U[W]);for(let ue=0;ue<k.length;ue++){const xe=k[ue];D?G&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+W,ue+1,0,0,ie,ae,xe.image[W]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+W,ue+1,we,ie,ae,xe.image[W])}}}m(v)&&f(n.TEXTURE_CUBE_MAP),te.__version=re.version,v.onUpdate&&v.onUpdate(v)}R.__version=v.version}function Me(R,v,H,ne,re,te){const Re=s.convert(H.format,H.colorSpace),fe=s.convert(H.type),Te=T(H.internalFormat,Re,fe,H.colorSpace),I=i.get(v),P=i.get(H);if(P.__renderTarget=v,!I.__hasExternalTextures){const U=Math.max(1,v.width>>te),Q=Math.max(1,v.height>>te);re===n.TEXTURE_3D||re===n.TEXTURE_2D_ARRAY?t.texImage3D(re,te,Te,U,Q,v.depth,0,Re,fe,null):t.texImage2D(re,te,Te,U,Q,0,Re,fe,null)}t.bindFramebuffer(n.FRAMEBUFFER,R),Se(v)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,ne,re,P.__webglTexture,0,ot(v)):(re===n.TEXTURE_2D||re>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&re<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,ne,re,P.__webglTexture,te),t.bindFramebuffer(n.FRAMEBUFFER,null)}function Ie(R,v,H){if(n.bindRenderbuffer(n.RENDERBUFFER,R),v.depthBuffer){const ne=v.depthTexture,re=ne&&ne.isDepthTexture?ne.type:null,te=_(v.stencilBuffer,re),Re=v.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,fe=ot(v);Se(v)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,fe,te,v.width,v.height):H?n.renderbufferStorageMultisample(n.RENDERBUFFER,fe,te,v.width,v.height):n.renderbufferStorage(n.RENDERBUFFER,te,v.width,v.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,Re,n.RENDERBUFFER,R)}else{const ne=v.textures;for(let re=0;re<ne.length;re++){const te=ne[re],Re=s.convert(te.format,te.colorSpace),fe=s.convert(te.type),Te=T(te.internalFormat,Re,fe,te.colorSpace),I=ot(v);H&&Se(v)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,I,Te,v.width,v.height):Se(v)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,I,Te,v.width,v.height):n.renderbufferStorage(n.RENDERBUFFER,Te,v.width,v.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function Ce(R,v){if(v&&v.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(n.FRAMEBUFFER,R),!(v.depthTexture&&v.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const ne=i.get(v.depthTexture);ne.__renderTarget=v,(!ne.__webglTexture||v.depthTexture.image.width!==v.width||v.depthTexture.image.height!==v.height)&&(v.depthTexture.image.width=v.width,v.depthTexture.image.height=v.height,v.depthTexture.needsUpdate=!0),J(v.depthTexture,0);const re=ne.__webglTexture,te=ot(v);if(v.depthTexture.format===kr)Se(v)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,re,0,te):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,re,0);else if(v.depthTexture.format===Gr)Se(v)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,re,0,te):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,re,0);else throw new Error("Unknown depthTexture format")}function ze(R){const v=i.get(R),H=R.isWebGLCubeRenderTarget===!0;if(v.__boundDepthTexture!==R.depthTexture){const ne=R.depthTexture;if(v.__depthDisposeCallback&&v.__depthDisposeCallback(),ne){const re=()=>{delete v.__boundDepthTexture,delete v.__depthDisposeCallback,ne.removeEventListener("dispose",re)};ne.addEventListener("dispose",re),v.__depthDisposeCallback=re}v.__boundDepthTexture=ne}if(R.depthTexture&&!v.__autoAllocateDepthBuffer){if(H)throw new Error("target.depthTexture not supported in Cube render targets");const ne=R.texture.mipmaps;ne&&ne.length>0?Ce(v.__webglFramebuffer[0],R):Ce(v.__webglFramebuffer,R)}else if(H){v.__webglDepthbuffer=[];for(let ne=0;ne<6;ne++)if(t.bindFramebuffer(n.FRAMEBUFFER,v.__webglFramebuffer[ne]),v.__webglDepthbuffer[ne]===void 0)v.__webglDepthbuffer[ne]=n.createRenderbuffer(),Ie(v.__webglDepthbuffer[ne],R,!1);else{const re=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,te=v.__webglDepthbuffer[ne];n.bindRenderbuffer(n.RENDERBUFFER,te),n.framebufferRenderbuffer(n.FRAMEBUFFER,re,n.RENDERBUFFER,te)}}else{const ne=R.texture.mipmaps;if(ne&&ne.length>0?t.bindFramebuffer(n.FRAMEBUFFER,v.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,v.__webglFramebuffer),v.__webglDepthbuffer===void 0)v.__webglDepthbuffer=n.createRenderbuffer(),Ie(v.__webglDepthbuffer,R,!1);else{const re=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,te=v.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,te),n.framebufferRenderbuffer(n.FRAMEBUFFER,re,n.RENDERBUFFER,te)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function Rt(R,v,H){const ne=i.get(R);v!==void 0&&Me(ne.__webglFramebuffer,R,R.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),H!==void 0&&ze(R)}function O(R){const v=R.texture,H=i.get(R),ne=i.get(v);R.addEventListener("dispose",A);const re=R.textures,te=R.isWebGLCubeRenderTarget===!0,Re=re.length>1;if(Re||(ne.__webglTexture===void 0&&(ne.__webglTexture=n.createTexture()),ne.__version=v.version,o.memory.textures++),te){H.__webglFramebuffer=[];for(let fe=0;fe<6;fe++)if(v.mipmaps&&v.mipmaps.length>0){H.__webglFramebuffer[fe]=[];for(let Te=0;Te<v.mipmaps.length;Te++)H.__webglFramebuffer[fe][Te]=n.createFramebuffer()}else H.__webglFramebuffer[fe]=n.createFramebuffer()}else{if(v.mipmaps&&v.mipmaps.length>0){H.__webglFramebuffer=[];for(let fe=0;fe<v.mipmaps.length;fe++)H.__webglFramebuffer[fe]=n.createFramebuffer()}else H.__webglFramebuffer=n.createFramebuffer();if(Re)for(let fe=0,Te=re.length;fe<Te;fe++){const I=i.get(re[fe]);I.__webglTexture===void 0&&(I.__webglTexture=n.createTexture(),o.memory.textures++)}if(R.samples>0&&Se(R)===!1){H.__webglMultisampledFramebuffer=n.createFramebuffer(),H.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,H.__webglMultisampledFramebuffer);for(let fe=0;fe<re.length;fe++){const Te=re[fe];H.__webglColorRenderbuffer[fe]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,H.__webglColorRenderbuffer[fe]);const I=s.convert(Te.format,Te.colorSpace),P=s.convert(Te.type),U=T(Te.internalFormat,I,P,Te.colorSpace,R.isXRRenderTarget===!0),Q=ot(R);n.renderbufferStorageMultisample(n.RENDERBUFFER,Q,U,R.width,R.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+fe,n.RENDERBUFFER,H.__webglColorRenderbuffer[fe])}n.bindRenderbuffer(n.RENDERBUFFER,null),R.depthBuffer&&(H.__webglDepthRenderbuffer=n.createRenderbuffer(),Ie(H.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(te){t.bindTexture(n.TEXTURE_CUBE_MAP,ne.__webglTexture),Be(n.TEXTURE_CUBE_MAP,v);for(let fe=0;fe<6;fe++)if(v.mipmaps&&v.mipmaps.length>0)for(let Te=0;Te<v.mipmaps.length;Te++)Me(H.__webglFramebuffer[fe][Te],R,v,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Te);else Me(H.__webglFramebuffer[fe],R,v,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+fe,0);m(v)&&f(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Re){for(let fe=0,Te=re.length;fe<Te;fe++){const I=re[fe],P=i.get(I);let U=n.TEXTURE_2D;(R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(U=R.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(U,P.__webglTexture),Be(U,I),Me(H.__webglFramebuffer,R,I,n.COLOR_ATTACHMENT0+fe,U,0),m(I)&&f(U)}t.unbindTexture()}else{let fe=n.TEXTURE_2D;if((R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(fe=R.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(fe,ne.__webglTexture),Be(fe,v),v.mipmaps&&v.mipmaps.length>0)for(let Te=0;Te<v.mipmaps.length;Te++)Me(H.__webglFramebuffer[Te],R,v,n.COLOR_ATTACHMENT0,fe,Te);else Me(H.__webglFramebuffer,R,v,n.COLOR_ATTACHMENT0,fe,0);m(v)&&f(fe),t.unbindTexture()}R.depthBuffer&&ze(R)}function st(R){const v=R.textures;for(let H=0,ne=v.length;H<ne;H++){const re=v[H];if(m(re)){const te=w(R),Re=i.get(re).__webglTexture;t.bindTexture(te,Re),f(te),t.unbindTexture()}}}const Ve=[],De=[];function be(R){if(R.samples>0){if(Se(R)===!1){const v=R.textures,H=R.width,ne=R.height;let re=n.COLOR_BUFFER_BIT;const te=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Re=i.get(R),fe=v.length>1;if(fe)for(let I=0;I<v.length;I++)t.bindFramebuffer(n.FRAMEBUFFER,Re.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+I,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,Re.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+I,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,Re.__webglMultisampledFramebuffer);const Te=R.texture.mipmaps;Te&&Te.length>0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Re.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Re.__webglFramebuffer);for(let I=0;I<v.length;I++){if(R.resolveDepthBuffer&&(R.depthBuffer&&(re|=n.DEPTH_BUFFER_BIT),R.stencilBuffer&&R.resolveStencilBuffer&&(re|=n.STENCIL_BUFFER_BIT)),fe){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,Re.__webglColorRenderbuffer[I]);const P=i.get(v[I]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,P,0)}n.blitFramebuffer(0,0,H,ne,0,0,H,ne,re,n.NEAREST),l===!0&&(Ve.length=0,De.length=0,Ve.push(n.COLOR_ATTACHMENT0+I),R.depthBuffer&&R.resolveDepthBuffer===!1&&(Ve.push(te),De.push(te),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,De)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,Ve))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),fe)for(let I=0;I<v.length;I++){t.bindFramebuffer(n.FRAMEBUFFER,Re.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+I,n.RENDERBUFFER,Re.__webglColorRenderbuffer[I]);const P=i.get(v[I]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,Re.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+I,n.TEXTURE_2D,P,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Re.__webglMultisampledFramebuffer)}else if(R.depthBuffer&&R.resolveDepthBuffer===!1&&l){const v=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[v])}}}function ot(R){return Math.min(r.maxSamples,R.samples)}function Se(R){const v=i.get(R);return R.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&v.__useRenderToTexture!==!1}function He(R){const v=o.render.frame;u.get(R)!==v&&(u.set(R,v),R.update())}function yt(R,v){const H=R.colorSpace,ne=R.format,re=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||H!==or&&H!==si&&(Ze.getTransfer(H)===tt?(ne!==xn||re!==Nn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",H)),v}function ut(R){return typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement?(c.width=R.naturalWidth||R.width,c.height=R.naturalHeight||R.height):typeof VideoFrame<"u"&&R instanceof VideoFrame?(c.width=R.displayWidth,c.height=R.displayHeight):(c.width=R.width,c.height=R.height),c}this.allocateTextureUnit=Y,this.resetTextureUnits=z,this.setTexture2D=J,this.setTexture2DArray=K,this.setTexture3D=se,this.setTextureCube=$,this.rebindTextures=Rt,this.setupRenderTarget=O,this.updateRenderTargetMipmap=st,this.updateMultisampleRenderTarget=be,this.setupDepthRenderbuffer=ze,this.setupFrameBufferTexture=Me,this.useMultisampledRTT=Se}function wv(n,e){function t(i,r=si){let s;const o=Ze.getTransfer(r);if(i===Nn)return n.UNSIGNED_BYTE;if(i===oa)return n.UNSIGNED_SHORT_4_4_4_4;if(i===aa)return n.UNSIGNED_SHORT_5_5_5_1;if(i===Hc)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===kc)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===zc)return n.BYTE;if(i===Vc)return n.SHORT;if(i===zr)return n.UNSIGNED_SHORT;if(i===sa)return n.INT;if(i===Si)return n.UNSIGNED_INT;if(i===Wn)return n.FLOAT;if(i===Vr)return n.HALF_FLOAT;if(i===Gc)return n.ALPHA;if(i===Wc)return n.RGB;if(i===xn)return n.RGBA;if(i===kr)return n.DEPTH_COMPONENT;if(i===Gr)return n.DEPTH_STENCIL;if(i===Xc)return n.RED;if(i===la)return n.RED_INTEGER;if(i===jc)return n.RG;if(i===ca)return n.RG_INTEGER;if(i===ua)return n.RGBA_INTEGER;if(i===Ms||i===Es||i===bs||i===Ss)if(o===tt)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===Ms)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Es)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===bs)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Ss)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===Ms)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Es)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===bs)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Ss)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===ha||i===fa||i===da||i===pa)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===ha)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===fa)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===da)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===pa)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===ma||i===_a||i===ga)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(i===ma||i===_a)return o===tt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===ga)return o===tt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===va||i===xa||i===ya||i===Ma||i===Ea||i===ba||i===Sa||i===Ta||i===wa||i===Aa||i===Ra||i===Ca||i===Pa||i===Da)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(i===va)return o===tt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===xa)return o===tt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===ya)return o===tt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Ma)return o===tt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Ea)return o===tt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===ba)return o===tt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Sa)return o===tt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Ta)return o===tt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===wa)return o===tt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Aa)return o===tt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Ra)return o===tt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Ca)return o===tt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Pa)return o===tt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Da)return o===tt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===La||i===Oa||i===Ia)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===La)return o===tt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Oa)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Ia)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Na||i===Ua||i===Fa||i===Ba)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(i===Na)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Ua)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Fa)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Ba)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Hr?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}const Av=`
3830
3830
  void main() {
3831
3831
 
3832
3832
  gl_Position = vec4( position, 1.0 );
3833
3833
 
3834
- }`,tm=`
3834
+ }`,Rv=`
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 nm{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new fl(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 Pn({vertexShader:em,fragmentShader:tm,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new _e(new ji(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class im extends Bn{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 nm,h={},w=t.getContextAttributes();let b=null,_=null;const T=[],E=[],A=new Ie;let C=null;const M=new Xt;M.viewport=new ut;const x=new Xt;x.viewport=new ut;const N=[M,x],z=new nu;let q=null,j=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let oe=T[Z];return oe===void 0&&(oe=new bo,T[Z]=oe),oe.getTargetRaySpace()},this.getControllerGrip=function(Z){let oe=T[Z];return oe===void 0&&(oe=new bo,T[Z]=oe),oe.getGripSpace()},this.getHand=function(Z){let oe=T[Z];return oe===void 0&&(oe=new bo,T[Z]=oe),oe.getHandSpace()};function Q(Z){const oe=E.indexOf(Z.inputSource);if(oe===-1)return;const xe=T[oe];xe!==void 0&&(xe.update(Z.inputSource,Z.frame,l||o),xe.dispatchEvent({type:Z.type,data:Z.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 Z=0;Z<T.length;Z++){const oe=E[Z];oe!==null&&(E[Z]=null,T[Z].disconnect(oe))}q=null,j=null,p.reset();for(const Z in h)delete h[Z];e.setRenderTarget(b),m=null,d=null,f=null,r=null,_=null,je.stop(),n.isPresenting=!1,e.setPixelRatio(C),e.setSize(A.width,A.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Z){s=Z,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Z){a=Z,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(Z){l=Z},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(Z){if(r=Z,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?Oi:Ni,Le=w.stencil?Ui:Fn);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 zn(d.textureWidth,d.textureHeight,{format:Kt,type:on,depthTexture:new ul(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 zn(m.framebufferWidth,m.framebufferHeight,{format:Kt,type:on,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),je.setContext(r),je.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(Z){for(let oe=0;oe<Z.removed.length;oe++){const xe=Z.removed[oe],Le=E.indexOf(xe);Le>=0&&(E[Le]=null,T[Le].disconnect(xe))}for(let oe=0;oe<Z.added.length;oe++){const xe=Z.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 $=new U,le=new U;function pe(Z,oe,xe){$.setFromMatrixPosition(oe.matrixWorld),le.setFromMatrixPosition(xe.matrixWorld);const Le=$.distanceTo(le),Ae=oe.projectionMatrix.elements,Oe=xe.projectionMatrix.elements,yt=Ae[14]/(Ae[10]-1),L=Ae[14]/(Ae[10]+1),tt=(Ae[9]+1)/Ae[5],Fe=(Ae[9]-1)/Ae[5],Ce=(Ae[8]-1)/Ae[0],ye=(Oe[8]+1)/Oe[0],nt=yt*Ce,Se=yt*ye,Be=Le/(-Ce+ye),pt=Be*-Ce;if(oe.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(pt),Z.translateZ(Be),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert(),Ae[10]===-1)Z.projectionMatrix.copy(oe.projectionMatrix),Z.projectionMatrixInverse.copy(oe.projectionMatrixInverse);else{const st=yt+Be,R=L+Be,v=nt-pt,k=Se+(Le-pt),ne=tt*L/R*st,re=Fe*L/R*st;Z.projectionMatrix.makePerspective(v,k,ne,re,st,R),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert()}}function Me(Z,oe){oe===null?Z.matrixWorld.copy(Z.matrix):Z.matrixWorld.multiplyMatrices(oe.matrixWorld,Z.matrix),Z.matrixWorldInverse.copy(Z.matrixWorld).invert()}this.updateCamera=function(Z){if(r===null)return;let oe=Z.near,xe=Z.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=Z.layers.mask|6,M.layers.mask=z.layers.mask&3,x.layers.mask=z.layers.mask&5;const Le=Z.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,z,Le)};function Ne(Z,oe,xe){xe===null?Z.matrix.copy(oe.matrixWorld):(Z.matrix.copy(xe.matrixWorld),Z.matrix.invert(),Z.matrix.multiply(oe.matrixWorld)),Z.matrix.decompose(Z.position,Z.quaternion,Z.scale),Z.updateMatrixWorld(!0),Z.projectionMatrix.copy(oe.projectionMatrix),Z.projectionMatrixInverse.copy(oe.projectionMatrixInverse),Z.isPerspectiveCamera&&(Z.fov=eo*2*Math.atan(1/Z.projectionMatrix.elements[5]),Z.zoom=1)}this.getCamera=function(){return z},this.getFoveation=function(){if(!(d===null&&m===null))return c},this.setFoveation=function(Z){c=Z,d!==null&&(d.fixedFoveation=Z),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=Z)},this.hasDepthSensing=function(){return p.texture!==null},this.getDepthSensingMesh=function(){return p.getMesh(z)},this.getCameraTexture=function(Z){return h[Z]};let de=null;function Xe(Z,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 tt=xe[L];let Fe=null;if(m!==null)Fe=m.getViewport(tt);else{const ye=f.getViewSubImage(d,tt);Fe=ye.viewport,L===0&&(e.setRenderTargetTextures(_,ye.colorTexture,ye.depthStencilTexture),e.setRenderTarget(_))}let Ce=N[L];Ce===void 0&&(Ce=new Xt,Ce.layers.enable(L),Ce.viewport=new ut,N[L]=Ce),Ce.matrix.fromArray(tt.transform.matrix),Ce.matrix.decompose(Ce.position,Ce.quaternion,Ce.scale),Ce.projectionMatrix.fromArray(tt.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 tt=xe[L].camera;if(tt){let Fe=h[tt];Fe||(Fe=new fl,h[tt]=Fe);const Ce=f.getCameraImage(tt);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)}de&&de(Z,oe),oe.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:oe}),g=null}const je=new El;je.setAnimationLoop(Xe),this.setAnimationLoop=function(Z){de=Z},this.dispose=function(){}}}const jn=new en,rm=new rt;function sm(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,nl(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===Dt&&(p.bumpScale.value*=-1)),h.normalMap&&(p.normalMap.value=h.normalMap,t(h.normalMap,p.normalMapTransform),p.normalScale.value.copy(h.normalScale),h.side===Dt&&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,jn.copy(_),jn.x*=-1,jn.y*=-1,jn.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(jn.y*=-1,jn.z*=-1),p.envMapRotation.value.setFromMatrix4(rm.makeRotationFromEuler(jn)),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===Dt&&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 om(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),$=_%T,le=$%se.boundary,pe=$+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 am{constructor(e={}){const{canvas:t=_h(),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=En,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const _=this;let T=!1;this._outputColorSpace=Gt;let E=0,A=0,C=null,M=-1,x=null;const N=new ut,z=new ut;let q=null;const j=new Ve(0);let Q=0,K=t.width,se=t.height,$=1,le=null,pe=null;const Me=new ut(0,0,K,se),Ne=new ut(0,0,K,se);let de=!1;const Xe=new Ao;let je=!1,Z=!1;const oe=new rt,xe=new U,Le=new ut,Ae={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Oe=!1;function yt(){return C===null?$:1}let L=n;function tt(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${ss}`),t.addEventListener("webglcontextlost",V,!1),t.addEventListener("webglcontextrestored",ee,!1),t.addEventListener("webglcontextcreationerror",G,!1),L===null){const F="webgl2";if(L=tt(F,S),L===null)throw tt(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,nt,Se,Be,pt,st,R,v,k,ne,re,te,we,ue,Ee,I,P,O,J,ie,ae,Te;function D(){Fe=new gd(L),Fe.init(),ie=new Jp(L,Fe),Ce=new hd(L,Fe,e,ie),ye=new Kp(L,Fe),Ce.reversedDepthBuffer&&d&&ye.buffers.depth.setReversed(!0),nt=new Md(L),Se=new Bp,Be=new Qp(L,Fe,ye,Se,Ce,ie,nt),pt=new fd(_),st=new _d(_),R=new su(L),ae=new ld(L,R),v=new vd(L,R,nt,ae),k=new Sd(L,v,R,nt),P=new yd(L,Ce,Be),ue=new ud(Se),ne=new Fp(_,pt,st,Fe,Ce,ae,ue),re=new sm(_,Se),te=new Hp,we=new Yp(Fe),I=new ad(_,pt,st,ye,k,m,c),Ee=new $p(_,k,Ce),Te=new om(L,nt,Ce,ye),O=new cd(L,Fe,nt),J=new xd(L,Fe,nt),nt.programs=ne.programs,_.capabilities=Ce,_.extensions=Fe,_.properties=Se,_.renderLists=te,_.shadowMap=Ee,_.state=ye,_.info=nt}D();const H=new im(_,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 $},this.setPixelRatio=function(S){S!==void 0&&($=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*$),t.height=Math.floor(F*$),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*$,se*$).floor()},this.setDrawingBufferSize=function(S,F,X){K=S,se=F,$=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($).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($).round())},this.getScissorTest=function(){return de},this.setScissorTest=function(S){ye.setScissorTest(de=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===bs||ce===Ts||ce===Es}if(B){const ce=C.texture.type,me=ce===on||ce===Fn||ce===Li||ce===Ui||ce===ys||ce===Ss,be=I.getClearColor(),ve=I.getClearAlpha(),De=be.r,Ue=be.g,Re=be.b;me?(g[0]=De,g[1]=Ue,g[2]=Re,g[3]=ve,L.clearBufferuiv(L.COLOR,0,g)):(y[0]=De,y[1]=Ue,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(),pt.dispose(),st.dispose(),k.dispose(),ae.dispose(),Te.dispose(),ne.dispose(),H.dispose(),H.removeEventListener("sessionstart",qt),H.removeEventListener("sessionend",Mc),Jn.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=nt.autoReset,F=Ee.enabled,X=Ee.autoUpdate,Y=Ee.needsUpdate,B=Ee.type;D(),nt.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=D_(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 Ue=X.drawRange,Re=X.attributes.position;let We=Ue.start*De,Je=(Ue.start+Ue.count)*De;ce!==null&&(We=Math.max(We,ce.start*De),Je=Math.min(Je,(ce.start+ce.count)*De)),ve!==null?(We=Math.max(We,0),Je=Math.min(Je,ve.count)):Re!=null&&(We=Math.max(We,0),Je=Math.min(Je,Re.count));const ft=Je-We;if(ft<0||ft===1/0)return;ae.setup(B,Y,be,X,ve);let ot,it=O;if(ve!==null&&(ot=R.get(ve),it=J,it.setIndex(ot)),B.isMesh)Y.wireframe===!0?(ye.setLineWidth(Y.wireframeLinewidth*yt()),it.setMode(L.LINES)):it.setMode(L.TRIANGLES);else if(B.isLine){let Pe=Y.linewidth;Pe===void 0&&(Pe=1),ye.setLineWidth(Pe*yt()),B.isLineSegments?it.setMode(L.LINES):B.isLineLoop?it.setMode(L.LINE_LOOP):it.setMode(L.LINE_STRIP)}else B.isPoints?it.setMode(L.POINTS):B.isSprite&&it.setMode(L.TRIANGLES);if(B.isBatchedMesh)if(B._multiDrawInstances!==null)Hi("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),it.renderMultiDrawInstances(B._multiDrawStarts,B._multiDrawCounts,B._multiDrawCount,B._multiDrawInstances);else if(Fe.get("WEBGL_multi_draw"))it.renderMultiDraw(B._multiDrawStarts,B._multiDrawCounts,B._multiDrawCount);else{const Pe=B._multiDrawStarts,lt=B._multiDrawCounts,$e=B._multiDrawCount,Ht=ve?R.get(ve).bytesPerElement:1,Di=Se.get(Y).currentProgram.getUniforms();for(let kt=0;kt<$e;kt++)Di.setValue(L,"_gl_DrawID",kt),it.render(Pe[kt]/Ht,lt[kt])}else if(B.isInstancedMesh)it.renderInstances(We,ft,B.count);else if(X.isInstancedBufferGeometry){const Pe=X._maxInstanceCount!==void 0?X._maxInstanceCount:1/0,lt=Math.min(X.instanceCount,Pe);it.renderInstances(We,ft,lt)}else it.render(We,ft)};function ke(S,F,X){S.transparent===!0&&S.side===rn&&S.forceSinglePass===!1?(S.side=Dt,S.needsUpdate=!0,rs(S,F,X),S.side=yn,S.needsUpdate=!0,rs(S,F,X),S.side=rn):rs(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 nn(S){Ye&&Ye(S)}function qt(){Jn.stop()}function Mc(){Jn.start()}const Jn=new El;Jn.setAnimationLoop(nn),typeof self<"u"&&Jn.setContext(self),this.setAnimationLoop=function(S){Ye=S,H.setAnimationLoop(S),S===null?Jn.stop():Jn.start()},H.addEventListener("sessionstart",qt),H.addEventListener("sessionend",Mc),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,an,F.reversedDepth),Z=this.localClippingEnabled,je=ue.init(this.clippingPlanes,Z),p=te.get(S,w.length),p.init(),w.push(p),H.enabled===!0&&H.isPresenting===!0){const ce=_.xr.getDepthSensingMesh();ce!==null&&fa(ce,F,-1/0,_.sortObjects)}fa(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++,je===!0&&ue.beginShadows();const X=h.state.shadowsArray;Ee.render(X,S,F),je===!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];Sc(Y,B,S,ve)}Oe&&I.render(S);for(let me=0,be=ce.length;me<be;me++){const ve=ce[me];yc(p,S,ve,ve.viewport)}}else B.length>0&&Sc(Y,B,S,F),Oe&&I.render(S),yc(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],je===!0&&ue.setGlobalState(_.clippingPlanes,h.state.camera)):h=null,w.pop(),w.length>0?p=w[w.length-1]:p=null};function fa(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,Ue=ve.length;De<Ue;De++){const Re=ve[De],We=be[Re.materialIndex];We&&We.visible&&p.push(S,me,We,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++)fa(ce[me],F,X,Y)}function yc(S,F,X,Y){const B=S.opaque,ce=S.transmissive,me=S.transparent;h.setupLightsView(X),je===!0&&ue.setGlobalState(_.clippingPlanes,X),Y&&ye.viewport(N.copy(Y)),B.length>0&&is(B,F,X),ce.length>0&&is(ce,F,X),me.length>0&&is(me,F,X),ye.buffers.depth.setTest(!0),ye.buffers.depth.setMask(!0),ye.buffers.color.setMask(!0),ye.setPolygonOffset(!1)}function Sc(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 zn(1,1,{generateMipmaps:!0,type:Fe.has("EXT_color_buffer_half_float")||Fe.has("EXT_color_buffer_float")?Ii:on,minFilter:On,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:qe.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 Ue=_.toneMapping;_.toneMapping=En;const Re=Y.viewport;if(Y.viewport!==void 0&&(Y.viewport=void 0),h.setupLightsView(Y),je===!0&&ue.setGlobalState(_.clippingPlanes,Y),is(S,X,Y),Be.updateMultisampleRenderTarget(ce),Be.updateRenderTargetMipmap(ce),Fe.has("WEBGL_multisampled_render_to_texture")===!1){let We=!1;for(let Je=0,ft=F.length;Je<ft;Je++){const ot=F[Je],it=ot.object,Pe=ot.geometry,lt=ot.material,$e=ot.group;if(lt.side===rn&&it.layers.test(Y.layers)){const Ht=lt.side;lt.side=Dt,lt.needsUpdate=!0,Ec(it,X,Y,Pe,lt,$e),lt.side=Ht,lt.needsUpdate=!0,We=!0}}We===!0&&(Be.updateMultisampleRenderTarget(ce),Be.updateRenderTargetMipmap(ce))}_.setRenderTarget(be,ve,De),_.setClearColor(j,Q),Re!==void 0&&(Y.viewport=Re),_.toneMapping=Ue}function is(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 Ue=me.material;Ue.allowOverride===!0&&Y!==null&&(Ue=Y),be.layers.test(X.layers)&&Ec(be,F,X,ve,Ue,De)}}function Ec(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===rn&&B.forceSinglePass===!1?(B.side=Dt,B.needsUpdate=!0,_.renderBufferDirect(X,F,Y,B,S,ce),B.side=yn,B.needsUpdate=!0,_.renderBufferDirect(X,F,Y,B,S,ce),B.side=rn):_.renderBufferDirect(X,F,Y,B,S,ce),S.onAfterRender(_,F,X,Y,B,ce)}function rs(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?st:pt).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 Ue=De.get(ve);if(Ue!==void 0){if(Y.currentProgram===Ue&&Y.lightsStateVersion===me)return bc(S,be),Ue}else be.uniforms=ne.getUniforms(S),S.onBeforeCompile(be,_),Ue=ne.acquireProgram(be,ve),De.set(ve,Ue),Y.uniforms=be.uniforms;const Re=Y.uniforms;return(!S.isShaderMaterial&&!S.isRawShaderMaterial||S.clipping===!0)&&(Re.clippingPlanes=ue.uniform),bc(S,be),Y.needsLights=I_(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=Ue,Y.uniformsList=null,Ue}function Tc(S){if(S.uniformsList===null){const F=S.currentProgram.getUniforms();S.uniformsList=Gr.seqWithValue(F.seq,S.uniforms)}return S.uniformsList}function bc(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 D_(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:li,ve=(Y.isMeshStandardMaterial?st:pt).get(Y.envMap||me),De=Y.vertexColors===!0&&!!X.attributes.color&&X.attributes.color.itemSize===4,Ue=!!X.attributes.tangent&&(!!Y.normalMap||Y.anisotropy>0),Re=!!X.morphAttributes.position,We=!!X.morphAttributes.normal,Je=!!X.morphAttributes.color;let ft=En;Y.toneMapped&&(C===null||C.isXRRenderTarget===!0)&&(ft=_.toneMapping);const ot=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,it=ot!==void 0?ot.length:0,Pe=Se.get(Y),lt=h.state.lights;if(je===!0&&(Z===!0||S!==x)){const Pt=S===x&&Y.id===M;ue.setState(Y,S,Pt)}let $e=!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!==Ue||Pe.morphTargets!==Re||Pe.morphNormals!==We||Pe.morphColors!==Je||Pe.toneMapping!==ft||Pe.morphTargetsCount!==it)&&($e=!0):($e=!0,Pe.__version=Y.version);let Ht=Pe.currentProgram;$e===!0&&(Ht=rs(Y,F,B));let Di=!1,kt=!1,nr=!1;const ct=Ht.getUniforms(),jt=Pe.uniforms;if(ye.useProgram(Ht.program)&&(Di=!0,kt=!0,nr=!0),Y.id!==M&&(M=Y.id,kt=!0),Di||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 Ot=ct.map.cameraPosition;Ot!==void 0&&Ot.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,kt=!0,nr=!0)}if(B.isSkinnedMesh){ct.setOptional(L,B,"bindMatrix"),ct.setOptional(L,B,"bindMatrixInverse");const Pt=B.skeleton;Pt&&(Pt.boneTexture===null&&Pt.computeBoneTexture(),ct.setValue(L,"boneTexture",Pt.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 $t=X.morphAttributes;if(($t.position!==void 0||$t.normal!==void 0||$t.color!==void 0)&&P.update(B,X,Ht),(kt||Pe.receiveShadow!==B.receiveShadow)&&(Pe.receiveShadow=B.receiveShadow,ct.setValue(L,"receiveShadow",B.receiveShadow)),Y.isMeshGouraudMaterial&&Y.envMap!==null&&(jt.envMap.value=ve,jt.flipEnvMap.value=ve.isCubeTexture&&ve.isRenderTargetTexture===!1?-1:1),Y.isMeshStandardMaterial&&Y.envMap===null&&F.environment!==null&&(jt.envMapIntensity.value=F.environmentIntensity),kt&&(ct.setValue(L,"toneMappingExposure",_.toneMappingExposure),Pe.needsLights&&L_(jt,nr),ce&&Y.fog===!0&&re.refreshFogUniforms(jt,ce),re.refreshMaterialUniforms(jt,Y,$,se,h.state.transmissionRenderTarget[S.id]),Gr.upload(L,Tc(Pe),jt,Be)),Y.isShaderMaterial&&Y.uniformsNeedUpdate===!0&&(Gr.upload(L,Tc(Pe),jt,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 Pt=Y.uniformsGroups;for(let Ot=0,da=Pt.length;Ot<da;Ot++){const ei=Pt[Ot];Te.update(ei,Ht),Te.bind(ei,Ht)}}return Ht}function L_(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 I_(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 U_=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 Ue=Se.get(S).__webglFramebuffer;S.isWebGLCubeRenderTarget?(Array.isArray(Ue[F])?B=Ue[F][X]:B=Ue[F],ce=!0):S.samples>0&&Be.useMultisampledRTT(S)===!1?B=Se.get(S).__webglMultisampledFramebuffer:Array.isArray(Ue)?B=Ue[X]:B=Ue,N.copy(S.viewport),z.copy(S.scissor),q=S.scissorTest}else N.copy(Me).multiplyScalar($).floor(),z.copy(Ne).multiplyScalar($).floor(),q=de;if(X!==0&&(B=U_),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 Ue=Se.get(S.textures[De]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+De,Ue.__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],Ue=De.format,Re=De.type;if(!Ce.textureFormatReadable(Ue)){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(Ue),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],Ue=De.format,Re=De.type;if(!Ce.textureFormatReadable(Ue))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 We=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,We),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(Ue),ie.convert(Re),0);const Je=C!==null?Se.get(C).__webglFramebuffer:null;ye.bindFramebuffer(L.FRAMEBUFFER,Je);const ft=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await gh(L,ft,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,We),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,ce),L.deleteBuffer(We),L.deleteSync(ft),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 N_=L.createFramebuffer(),O_=L.createFramebuffer();this.copyTextureToTexture=function(S,F,X=null,Y=null,B=0,ce=null){ce===null&&(B!==0?(Hi("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),ce=B,B=0):ce=0);let me,be,ve,De,Ue,Re,We,Je,ft;const ot=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,Ue=X.min.y,Re=X.isBox3?X.min.z:0;else{const $t=Math.pow(2,-B);me=Math.floor(ot.width*$t),be=Math.floor(ot.height*$t),S.isDataArrayTexture?ve=ot.depth:S.isData3DTexture?ve=Math.floor(ot.depth*$t):ve=1,De=0,Ue=0,Re=0}Y!==null?(We=Y.x,Je=Y.y,ft=Y.z):(We=0,Je=0,ft=0);const it=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 $e=L.getParameter(L.UNPACK_ROW_LENGTH),Ht=L.getParameter(L.UNPACK_IMAGE_HEIGHT),Di=L.getParameter(L.UNPACK_SKIP_PIXELS),kt=L.getParameter(L.UNPACK_SKIP_ROWS),nr=L.getParameter(L.UNPACK_SKIP_IMAGES);L.pixelStorei(L.UNPACK_ROW_LENGTH,ot.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,ot.height),L.pixelStorei(L.UNPACK_SKIP_PIXELS,De),L.pixelStorei(L.UNPACK_SKIP_ROWS,Ue),L.pixelStorei(L.UNPACK_SKIP_IMAGES,Re);const ct=S.isDataArrayTexture||S.isData3DTexture,jt=F.isDataArrayTexture||F.isData3DTexture;if(S.isDepthTexture){const $t=Se.get(S),Pt=Se.get(F),Ot=Se.get($t.__renderTarget),da=Se.get(Pt.__renderTarget);ye.bindFramebuffer(L.READ_FRAMEBUFFER,Ot.__webglFramebuffer),ye.bindFramebuffer(L.DRAW_FRAMEBUFFER,da.__webglFramebuffer);for(let ei=0;ei<ve;ei++)ct&&(L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Se.get(S).__webglTexture,B,Re+ei),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Se.get(F).__webglTexture,ce,ft+ei)),L.blitFramebuffer(De,Ue,me,be,We,Je,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 $t=Se.get(S),Pt=Se.get(F);ye.bindFramebuffer(L.READ_FRAMEBUFFER,N_),ye.bindFramebuffer(L.DRAW_FRAMEBUFFER,O_);for(let Ot=0;Ot<ve;Ot++)ct?L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,$t.__webglTexture,B,Re+Ot):L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,$t.__webglTexture,B),jt?L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Pt.__webglTexture,ce,ft+Ot):L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,Pt.__webglTexture,ce),B!==0?L.blitFramebuffer(De,Ue,me,be,We,Je,me,be,L.COLOR_BUFFER_BIT,L.NEAREST):jt?L.copyTexSubImage3D(lt,ce,We,Je,ft+Ot,De,Ue,me,be):L.copyTexSubImage2D(lt,ce,We,Je,De,Ue,me,be);ye.bindFramebuffer(L.READ_FRAMEBUFFER,null),ye.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else jt?S.isDataTexture||S.isData3DTexture?L.texSubImage3D(lt,ce,We,Je,ft,me,be,ve,it,Pe,ot.data):F.isCompressedArrayTexture?L.compressedTexSubImage3D(lt,ce,We,Je,ft,me,be,ve,it,ot.data):L.texSubImage3D(lt,ce,We,Je,ft,me,be,ve,it,Pe,ot):S.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,ce,We,Je,me,be,it,Pe,ot.data):S.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,ce,We,Je,ot.width,ot.height,it,ot.data):L.texSubImage2D(L.TEXTURE_2D,ce,We,Je,me,be,it,Pe,ot);L.pixelStorei(L.UNPACK_ROW_LENGTH,$e),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Ht),L.pixelStorei(L.UNPACK_SKIP_PIXELS,Di),L.pixelStorei(L.UNPACK_SKIP_ROWS,kt),L.pixelStorei(L.UNPACK_SKIP_IMAGES,nr),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 an}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=qe._getDrawingBufferColorSpace(e),t.unpackColorSpace=qe._getUnpackColorSpace()}}class Wo{scene;camera;renderer;canvas;meshes=[];constructor(e){this.canvas=e,this.scene=new Gh,this.scene.background=new Ve(1710618),this.camera=new Xt(45,e.clientWidth/e.clientHeight,.1,1e3),this.camera.position.set(1,1,7),this.renderer=new am({canvas:e,antialias:!0}),this.renderer.setSize(e.clientWidth,e.clientHeight);const t=new tu(16777215,.5);this.scene.add(t);const n=new eu(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 gt;t.setAttribute("position",new Ze(e.position,3)),e.normal&&t.setAttribute("normal",new Ze(e.normal,3)),e.uv&&t.setAttribute("uv",new Ze(e.uv,2));const 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 Ql={type:"change"},Xo={type:"start"},Jl={type:"end"},Wr=new vr,ec=new Ln,lm=Math.cos(70*mh.DEG2RAD),Mt=new U,Ut=2*Math.PI,Qe={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Yo=1e-6;class tc extends yl{constructor(e,t=null){super(e,t),this.state=Qe.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:ni.ROTATE,MIDDLE:ni.DOLLY,RIGHT:ni.PAN},this.touches={ONE:ii.ROTATE,TWO:ii.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 Et,this._lastTargetPosition=new U,this._quat=new Et().setFromUnitVectors(e.up,new U(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Ml,this._sphericalDelta=new Ml,this._scale=1,this._panOffset=new U,this._rotateStart=new Ie,this._rotateEnd=new Ie,this._rotateDelta=new Ie,this._panStart=new Ie,this._panEnd=new Ie,this._panDelta=new Ie,this._dollyStart=new Ie,this._dollyEnd=new Ie,this._dollyDelta=new Ie,this._dollyDirection=new U,this._mouse=new Ie,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=hm.bind(this),this._onPointerDown=cm.bind(this),this._onPointerUp=um.bind(this),this._onContextMenu=vm.bind(this),this._onMouseWheel=pm.bind(this),this._onKeyDown=mm.bind(this),this._onTouchStart=_m.bind(this),this._onTouchMove=gm.bind(this),this._onMouseDown=fm.bind(this),this._onMouseMove=dm.bind(this),this._interceptControlDown=xm.bind(this),this._interceptControlUp=Mm.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(Ql),this.update(),this.state=Qe.NONE}update(e=null){const t=this.object.position;Mt.copy(t).sub(this.target),Mt.applyQuaternion(this._quat),this._spherical.setFromVector3(Mt),this.autoRotate&&this.state===Qe.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+=Ut:n>Math.PI&&(n-=Ut),r<-Math.PI?r+=Ut:r>Math.PI&&(r-=Ut),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(Mt.setFromSpherical(this._spherical),Mt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Mt),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=Mt.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=Mt.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):(Wr.origin.copy(this.object.position),Wr.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Wr.direction))<lm?this.object.lookAt(this.target):(ec.setFromNormalAndCoplanarPoint(this.object.up,this.target),Wr.intersectPlane(ec,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)>Yo||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Yo||this._lastTargetPosition.distanceToSquared(this.target)>Yo?(this.dispatchEvent(Ql),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Ut/60*this.autoRotateSpeed*e:Ut/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){Mt.setFromMatrixColumn(t,0),Mt.multiplyScalar(-e),this._panOffset.add(Mt)}_panUp(e,t){this.screenSpacePanning===!0?Mt.setFromMatrixColumn(t,1):(Mt.setFromMatrixColumn(t,0),Mt.crossVectors(this.object.up,Mt)),Mt.multiplyScalar(e),this._panOffset.add(Mt)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const r=this.object.position;Mt.copy(r).sub(this.target);let s=Mt.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(Ut*this._rotateDelta.x/t.clientHeight),this._rotateUp(Ut*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(Ut*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(-Ut*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(Ut*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(-Ut*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(Ut*this._rotateDelta.x/t.clientHeight),this._rotateUp(Ut*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 Ie,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 cm(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 hm(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function um(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(Jl),this.state=Qe.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 fm(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 ni.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=Qe.DOLLY;break;case ni.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Qe.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Qe.ROTATE}break;case ni.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Qe.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Qe.PAN}break;default:this.state=Qe.NONE}this.state!==Qe.NONE&&this.dispatchEvent(Xo)}function dm(i){switch(this.state){case Qe.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case Qe.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case Qe.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function pm(i){this.enabled===!1||this.enableZoom===!1||this.state!==Qe.NONE||(i.preventDefault(),this.dispatchEvent(Xo),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(Jl))}function mm(i){this.enabled!==!1&&this._handleKeyDown(i)}function _m(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case ii.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=Qe.TOUCH_ROTATE;break;case ii.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=Qe.TOUCH_PAN;break;default:this.state=Qe.NONE}break;case 2:switch(this.touches.TWO){case ii.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=Qe.TOUCH_DOLLY_PAN;break;case ii.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=Qe.TOUCH_DOLLY_ROTATE;break;default:this.state=Qe.NONE}break;default:this.state=Qe.NONE}this.state!==Qe.NONE&&this.dispatchEvent(Xo)}function gm(i){switch(this._trackPointer(i),this.state){case Qe.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case Qe.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case Qe.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case Qe.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=Qe.NONE}}function vm(i){this.enabled!==!1&&i.preventDefault()}function xm(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Mm(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class ym extends tc{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 Sm extends Yi{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 gt().setFromPoints([new U(0,0,0),n.clone().multiplyScalar(e)]),o=new bi({color:r}),a=new cn(s,o);this.add(a)}}}const $n=new vl,At=new U,In=new U,at=new Et,nc={X:new U(1,0,0),Y:new U(0,1,0),Z:new U(0,0,1)},qo={type:"change"},ic={type:"mouseDown",mode:null},rc={type:"mouseUp",mode:null},sc={type:"objectChange"};class Em extends yl{constructor(e,t=null){super(void 0,t);const n=new Cm(this);this._root=n;const r=new Pm;this._gizmo=r,n.add(r);const s=new Dm;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(qo))}}),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 Et,f=new Et,d=new U,m=new Et,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 Et,this._parentQuaternionInv=new Et,this._parentScale=new U,this._worldScaleStart=new U,this._worldQuaternionInv=new Et,this._worldScale=new U,this._positionStart=new U,this._quaternionStart=new Et,this._scaleStart=new U,this._getPointer=Tm.bind(this),this._onPointerDown=wm.bind(this),this._onPointerHover=bm.bind(this),this._onPointerMove=Am.bind(this),this._onPointerUp=Rm.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&&$n.setFromCamera(e,this.camera);const t=jo(this._gizmo.picker[this.mode],$n);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&&$n.setFromCamera(e,this.camera);const t=jo(this._plane,$n,!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,ic.mode=this.mode,this.dispatchEvent(ic)}}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&&$n.setFromCamera(e,this.camera);const o=jo(this._plane,$n,!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(At.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(At.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),In.set(a,a,a)}else At.copy(this.pointStart),In.copy(this.pointEnd),At.applyQuaternion(this._worldQuaternionInv),In.applyQuaternion(this._worldQuaternionInv),In.divide(At),t.search("X")===-1&&(In.x=1),t.search("Y")===-1&&(In.y=1),t.search("Z")===-1&&(In.z=1);r.scale.copy(this._scaleStart).multiply(In),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(At.setFromMatrixPosition(this.camera.matrixWorld));let c=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(At.copy(this.rotationAxis).cross(this.eye))*a):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(nc[t]),At.copy(nc[t]),s==="local"&&At.applyQuaternion(this.worldQuaternion),At.cross(this.eye),At.length()===0?c=!0:this.rotationAngle=this._offset.dot(At.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(qo),this.dispatchEvent(sc)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(rc.mode=this.mode,this.dispatchEvent(rc)),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(qo),this.dispatchEvent(sc),this.pointStart.copy(this.pointEnd))}getRaycaster(){return $n}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 Tm(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 bm(i){if(this.enabled)switch(i.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(i));break}}function wm(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 Am(i){this.enabled&&this.pointerMove(this._getPointer(i))}function Rm(i){this.enabled&&(this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(i)))}function jo(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 Xr=new en,et=new U(0,1,0),oc=new U(0,0,0),ac=new rt,Yr=new Et,qr=new Et,un=new U,lc=new rt,Zi=new U(1,0,0),Zn=new U(0,1,0),Ki=new U(0,0,1),jr=new U,Qi=new U,Ji=new U;class Cm 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 Pm extends dt{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new Sr({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new bi({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 wt(0,.04,.1,12);y.translate(0,.05,0);const p=new _t(.08,.08,.08);p.translate(0,.04,0);const h=new gt;h.setAttribute("position",new Ze([0,0,0,1,0,0],3));const w=new wt(.0075,.0075,.5,3);w.translate(0,.25,0);function b(Q,K){const se=new Wn(Q,.0075,3,64,K*Math.PI*2);return se.rotateY(Math.PI/2),se.rotateX(Math.PI/2),se}function _(){const Q=new gt;return Q.setAttribute("position",new Ze([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 wi(.1,0),f),[0,0,0]]],XY:[[new _e(new _t(.15,.15,.01),u),[.15,.15,0]]],YZ:[[new _e(new _t(.15,.15,.01),c),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new _e(new _t(.15,.15,.01),l),[.15,0,.15],[-Math.PI/2,0,0]]]},E={X:[[new _e(new wt(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new _e(new wt(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new _e(new wt(.2,0,.6,4),n),[0,.3,0]],[new _e(new wt(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new _e(new wt(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new _e(new wt(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new _e(new wi(.2,0),n)]],XY:[[new _e(new _t(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new _e(new _t(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new _e(new _t(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]]},A={START:[[new _e(new wi(.01,2),r),null,null,null,"helper"]],END:[[new _e(new wi(.01,2),r),null,null,null,"helper"]],DELTA:[[new cn(_(),r),null,null,null,"helper"]],X:[[new cn(h,r),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new cn(h,r),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new cn(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 cn(h,r),[-1e3,0,0],null,[1e6,1,1],"helper"]]},x={XYZE:[[new _e(new Lo(.25,10,8),n)]],X:[[new _e(new Wn(.5,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new _e(new Wn(.5,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new _e(new Wn(.5,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new _e(new Wn(.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 _t(.15,.15,.01),u),[.15,.15,0]]],YZ:[[new _e(new _t(.15,.15,.01),c),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new _e(new _t(.15,.15,.01),l),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new _e(new _t(.1,.1,.1),f)]]},z={X:[[new _e(new wt(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new _e(new wt(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new _e(new wt(.2,0,.6,4),n),[0,.3,0]],[new _e(new wt(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new _e(new wt(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new _e(new wt(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new _e(new _t(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new _e(new _t(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new _e(new _t(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new _e(new _t(.2,.2,.2),n),[0,0,0]]]},q={X:[[new cn(h,r),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new cn(h,r),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new cn(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 $=Q[se].length;$--;){const le=Q[se][$][0].clone(),pe=Q[se][$][1],Me=Q[se][$][2],Ne=Q[se][$][3],de=Q[se][$][4];le.name=se,le.tag=de,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:qr;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(Xr.set(0,0,0)),o.quaternion.copy(n).multiply(at),Math.abs(et.copy(Zi).applyQuaternion(n).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Y"&&(at.setFromEuler(Xr.set(0,0,Math.PI/2)),o.quaternion.copy(n).multiply(at),Math.abs(et.copy(Zn).applyQuaternion(n).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Z"&&(at.setFromEuler(Xr.set(0,Math.PI/2,0)),o.quaternion.copy(n).multiply(at),Math.abs(et.copy(Ki).applyQuaternion(n).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="XYZE"&&(at.setFromEuler(Xr.set(0,Math.PI/2,0)),et.copy(this.rotationAxis),o.quaternion.setFromRotationMatrix(ac.lookAt(oc,et,Zn)),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),At.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),At.applyQuaternion(this.worldQuaternionStart.clone().invert()),o.scale.copy(At),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(et.copy(Zi).applyQuaternion(n).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Y"&&Math.abs(et.copy(Zn).applyQuaternion(n).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Z"&&Math.abs(et.copy(Ki).applyQuaternion(n).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XY"&&Math.abs(et.copy(Ki).applyQuaternion(n).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="YZ"&&Math.abs(et.copy(Zi).applyQuaternion(n).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XZ"&&Math.abs(et.copy(Zn).applyQuaternion(n).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1)):this.mode==="rotate"&&(Yr.copy(n),et.copy(this.eye).applyQuaternion(at.copy(n).invert()),o.name.search("E")!==-1&&o.quaternion.setFromRotationMatrix(ac.lookAt(this.eye,oc,Zn)),o.name==="X"&&(at.setFromAxisAngle(Zi,Math.atan2(-et.y,et.z)),at.multiplyQuaternions(Yr,at),o.quaternion.copy(at)),o.name==="Y"&&(at.setFromAxisAngle(Zn,Math.atan2(et.x,et.z)),at.multiplyQuaternions(Yr,at),o.quaternion.copy(at)),o.name==="Z"&&(at.setFromAxisAngle(Ki,Math.atan2(et.y,et.x)),at.multiplyQuaternions(Yr,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 Dm extends _e{constructor(){super(new ji(1e5,1e5,2,2),new Sr({visible:!1,wireframe:!0,side:rn,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"),jr.copy(Zi).applyQuaternion(t==="local"?this.worldQuaternion:qr),Qi.copy(Zn).applyQuaternion(t==="local"?this.worldQuaternion:qr),Ji.copy(Ki).applyQuaternion(t==="local"?this.worldQuaternion:qr),et.copy(Qi),this.mode){case"translate":case"scale":switch(this.axis){case"X":et.copy(this.eye).cross(jr),un.copy(jr).cross(et);break;case"Y":et.copy(this.eye).cross(Qi),un.copy(Qi).cross(et);break;case"Z":et.copy(this.eye).cross(Ji),un.copy(Ji).cross(et);break;case"XY":un.copy(Ji);break;case"YZ":un.copy(jr);break;case"XZ":et.copy(Ji),un.copy(Qi);break;case"XYZ":case"E":un.set(0,0,0);break}break;case"rotate":default:un.set(0,0,0)}un.length()===0?this.quaternion.copy(this.cameraQuaternion):(lc.lookAt(At.set(0,0,0),un,et),this.quaternion.setFromRotationMatrix(lc)),super.updateMatrixWorld(e)}}var $o;(function(i){i[i.Transient=0]="Transient",i[i.Singleton=1]="Singleton",i[i.ResolutionScoped=2]="ResolutionScoped",i[i.ContainerScoped=3]="ContainerScoped"})($o||($o={}));const Nt=$o;/*! *****************************************************************************
3853
+ }`;class Cv{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new Ru(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new hi({vertexShader:Av,fragmentShader:Rv,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new ge(new ts(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Pv extends Ti{constructor(e,t){super();const i=this;let r=null,s=1,o=null,a="local-floor",l=1,c=null,u=null,h=null,d=null,p=null,g=null;const y=typeof XRWebGLBinding<"u",m=new Cv,f={},w=t.getContextAttributes();let T=null,_=null;const S=[],b=[],A=new Ne;let C=null;const M=new an;M.viewport=new gt;const x=new an;x.viewport=new gt;const N=[M,x],z=new Pp;let Y=null,q=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let oe=S[Z];return oe===void 0&&(oe=new cl,S[Z]=oe),oe.getTargetRaySpace()},this.getControllerGrip=function(Z){let oe=S[Z];return oe===void 0&&(oe=new cl,S[Z]=oe),oe.getGripSpace()},this.getHand=function(Z){let oe=S[Z];return oe===void 0&&(oe=new cl,S[Z]=oe),oe.getHandSpace()};function J(Z){const oe=b.indexOf(Z.inputSource);if(oe===-1)return;const Me=S[oe];Me!==void 0&&(Me.update(Z.inputSource,Z.frame,c||o),Me.dispatchEvent({type:Z.type,data:Z.inputSource}))}function K(){r.removeEventListener("select",J),r.removeEventListener("selectstart",J),r.removeEventListener("selectend",J),r.removeEventListener("squeeze",J),r.removeEventListener("squeezestart",J),r.removeEventListener("squeezeend",J),r.removeEventListener("end",K),r.removeEventListener("inputsourceschange",se);for(let Z=0;Z<S.length;Z++){const oe=b[Z];oe!==null&&(b[Z]=null,S[Z].disconnect(oe))}Y=null,q=null,m.reset();for(const Z in f)delete f[Z];e.setRenderTarget(T),p=null,d=null,h=null,r=null,_=null,Je.stop(),i.isPresenting=!1,e.setPixelRatio(C),e.setSize(A.width,A.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Z){s=Z,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Z){a=Z,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(Z){c=Z},this.getBaseLayer=function(){return d!==null?d:p},this.getBinding=function(){return h===null&&y&&(h=new XRWebGLBinding(r,t)),h},this.getFrame=function(){return g},this.getSession=function(){return r},this.setSession=async function(Z){if(r=Z,r!==null){if(T=e.getRenderTarget(),r.addEventListener("select",J),r.addEventListener("selectstart",J),r.addEventListener("selectend",J),r.addEventListener("squeeze",J),r.addEventListener("squeezestart",J),r.addEventListener("squeezeend",J),r.addEventListener("end",K),r.addEventListener("inputsourceschange",se),w.xrCompatible!==!0&&await t.makeXRCompatible(),C=e.getPixelRatio(),e.getSize(A),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let Me=null,Ie=null,Ce=null;w.depth&&(Ce=w.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Me=w.stencil?Gr:kr,Ie=w.stencil?Hr:Si);const ze={colorFormat:t.RGBA8,depthFormat:Ce,scaleFactor:s};h=this.getBinding(),d=h.createProjectionLayer(ze),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),_=new wi(d.textureWidth,d.textureHeight,{format:xn,type:Nn,depthTexture:new Au(d.textureWidth,d.textureHeight,Ie,void 0,void 0,void 0,void 0,void 0,void 0,Me),stencilBuffer:w.stencil,colorSpace:e.outputColorSpace,samples:w.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const Me={antialias:w.antialias,alpha:!0,depth:w.depth,stencil:w.stencil,framebufferScaleFactor:s};p=new XRWebGLLayer(r,t,Me),r.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),_=new wi(p.framebufferWidth,p.framebufferHeight,{format:xn,type:Nn,colorSpace:e.outputColorSpace,stencilBuffer:w.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}_.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await r.requestReferenceSpace(a),Je.setContext(r),Je.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function se(Z){for(let oe=0;oe<Z.removed.length;oe++){const Me=Z.removed[oe],Ie=b.indexOf(Me);Ie>=0&&(b[Ie]=null,S[Ie].disconnect(Me))}for(let oe=0;oe<Z.added.length;oe++){const Me=Z.added[oe];let Ie=b.indexOf(Me);if(Ie===-1){for(let ze=0;ze<S.length;ze++)if(ze>=b.length){b.push(Me),Ie=ze;break}else if(b[ze]===null){b[ze]=Me,Ie=ze;break}if(Ie===-1)break}const Ce=S[Ie];Ce&&Ce.connect(Me)}}const $=new L,le=new L;function me(Z,oe,Me){$.setFromMatrixPosition(oe.matrixWorld),le.setFromMatrixPosition(Me.matrixWorld);const Ie=$.distanceTo(le),Ce=oe.projectionMatrix.elements,ze=Me.projectionMatrix.elements,Rt=Ce[14]/(Ce[10]-1),O=Ce[14]/(Ce[10]+1),st=(Ce[9]+1)/Ce[5],Ve=(Ce[9]-1)/Ce[5],De=(Ce[8]-1)/Ce[0],be=(ze[8]+1)/ze[0],ot=Rt*De,Se=Rt*be,He=Ie/(-De+be),yt=He*-De;if(oe.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(yt),Z.translateZ(He),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert(),Ce[10]===-1)Z.projectionMatrix.copy(oe.projectionMatrix),Z.projectionMatrixInverse.copy(oe.projectionMatrixInverse);else{const ut=Rt+He,R=O+He,v=ot-yt,H=Se+(Ie-yt),ne=st*O/R*ut,re=Ve*O/R*ut;Z.projectionMatrix.makePerspective(v,H,ne,re,ut,R),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert()}}function Ee(Z,oe){oe===null?Z.matrixWorld.copy(Z.matrix):Z.matrixWorld.multiplyMatrices(oe.matrixWorld,Z.matrix),Z.matrixWorldInverse.copy(Z.matrixWorld).invert()}this.updateCamera=function(Z){if(r===null)return;let oe=Z.near,Me=Z.far;m.texture!==null&&(m.depthNear>0&&(oe=m.depthNear),m.depthFar>0&&(Me=m.depthFar)),z.near=x.near=M.near=oe,z.far=x.far=M.far=Me,(Y!==z.near||q!==z.far)&&(r.updateRenderState({depthNear:z.near,depthFar:z.far}),Y=z.near,q=z.far),z.layers.mask=Z.layers.mask|6,M.layers.mask=z.layers.mask&3,x.layers.mask=z.layers.mask&5;const Ie=Z.parent,Ce=z.cameras;Ee(z,Ie);for(let ze=0;ze<Ce.length;ze++)Ee(Ce[ze],Ie);Ce.length===2?me(z,M,x):z.projectionMatrix.copy(M.projectionMatrix),Be(Z,z,Ie)};function Be(Z,oe,Me){Me===null?Z.matrix.copy(oe.matrixWorld):(Z.matrix.copy(Me.matrixWorld),Z.matrix.invert(),Z.matrix.multiply(oe.matrixWorld)),Z.matrix.decompose(Z.position,Z.quaternion,Z.scale),Z.updateMatrixWorld(!0),Z.projectionMatrix.copy(oe.projectionMatrix),Z.projectionMatrixInverse.copy(oe.projectionMatrixInverse),Z.isPerspectiveCamera&&(Z.fov=za*2*Math.atan(1/Z.projectionMatrix.elements[5]),Z.zoom=1)}this.getCamera=function(){return z},this.getFoveation=function(){if(!(d===null&&p===null))return l},this.setFoveation=function(Z){l=Z,d!==null&&(d.fixedFoveation=Z),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=Z)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(z)},this.getCameraTexture=function(Z){return f[Z]};let pe=null;function qe(Z,oe){if(u=oe.getViewerPose(c||o),g=oe,u!==null){const Me=u.views;p!==null&&(e.setRenderTargetFramebuffer(_,p.framebuffer),e.setRenderTarget(_));let Ie=!1;Me.length!==z.cameras.length&&(z.cameras.length=0,Ie=!0);for(let O=0;O<Me.length;O++){const st=Me[O];let Ve=null;if(p!==null)Ve=p.getViewport(st);else{const be=h.getViewSubImage(d,st);Ve=be.viewport,O===0&&(e.setRenderTargetTextures(_,be.colorTexture,be.depthStencilTexture),e.setRenderTarget(_))}let De=N[O];De===void 0&&(De=new an,De.layers.enable(O),De.viewport=new gt,N[O]=De),De.matrix.fromArray(st.transform.matrix),De.matrix.decompose(De.position,De.quaternion,De.scale),De.projectionMatrix.fromArray(st.projectionMatrix),De.projectionMatrixInverse.copy(De.projectionMatrix).invert(),De.viewport.set(Ve.x,Ve.y,Ve.width,Ve.height),O===0&&(z.matrix.copy(De.matrix),z.matrix.decompose(z.position,z.quaternion,z.scale)),Ie===!0&&z.cameras.push(De)}const Ce=r.enabledFeatures;if(Ce&&Ce.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&y){h=i.getBinding();const O=h.getDepthInformation(Me[0]);O&&O.isValid&&O.texture&&m.init(O,r.renderState)}if(Ce&&Ce.includes("camera-access")&&y){e.state.unbindTexture(),h=i.getBinding();for(let O=0;O<Me.length;O++){const st=Me[O].camera;if(st){let Ve=f[st];Ve||(Ve=new Ru,f[st]=Ve);const De=h.getCameraImage(st);Ve.sourceTexture=De}}}}for(let Me=0;Me<S.length;Me++){const Ie=b[Me],Ce=S[Me];Ie!==null&&Ce!==void 0&&Ce.update(Ie,oe,c||o)}pe&&pe(Z,oe),oe.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:oe}),g=null}const Je=new zu;Je.setAnimationLoop(qe),this.setAnimationLoop=function(Z){pe=Z},this.dispose=function(){}}}const Ui=new En,Dv=new ct;function Lv(n,e){function t(m,f){m.matrixAutoUpdate===!0&&m.updateMatrix(),f.value.copy(m.matrix)}function i(m,f){f.color.getRGB(m.fogColor.value,vu(n)),f.isFog?(m.fogNear.value=f.near,m.fogFar.value=f.far):f.isFogExp2&&(m.fogDensity.value=f.density)}function r(m,f,w,T,_){f.isMeshBasicMaterial||f.isMeshLambertMaterial?s(m,f):f.isMeshToonMaterial?(s(m,f),h(m,f)):f.isMeshPhongMaterial?(s(m,f),u(m,f)):f.isMeshStandardMaterial?(s(m,f),d(m,f),f.isMeshPhysicalMaterial&&p(m,f,_)):f.isMeshMatcapMaterial?(s(m,f),g(m,f)):f.isMeshDepthMaterial?s(m,f):f.isMeshDistanceMaterial?(s(m,f),y(m,f)):f.isMeshNormalMaterial?s(m,f):f.isLineBasicMaterial?(o(m,f),f.isLineDashedMaterial&&a(m,f)):f.isPointsMaterial?l(m,f,w,T):f.isSpriteMaterial?c(m,f):f.isShadowMaterial?(m.color.value.copy(f.color),m.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function s(m,f){m.opacity.value=f.opacity,f.color&&m.diffuse.value.copy(f.color),f.emissive&&m.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(m.map.value=f.map,t(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.bumpMap&&(m.bumpMap.value=f.bumpMap,t(f.bumpMap,m.bumpMapTransform),m.bumpScale.value=f.bumpScale,f.side===Ht&&(m.bumpScale.value*=-1)),f.normalMap&&(m.normalMap.value=f.normalMap,t(f.normalMap,m.normalMapTransform),m.normalScale.value.copy(f.normalScale),f.side===Ht&&m.normalScale.value.negate()),f.displacementMap&&(m.displacementMap.value=f.displacementMap,t(f.displacementMap,m.displacementMapTransform),m.displacementScale.value=f.displacementScale,m.displacementBias.value=f.displacementBias),f.emissiveMap&&(m.emissiveMap.value=f.emissiveMap,t(f.emissiveMap,m.emissiveMapTransform)),f.specularMap&&(m.specularMap.value=f.specularMap,t(f.specularMap,m.specularMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest);const w=e.get(f),T=w.envMap,_=w.envMapRotation;T&&(m.envMap.value=T,Ui.copy(_),Ui.x*=-1,Ui.y*=-1,Ui.z*=-1,T.isCubeTexture&&T.isRenderTargetTexture===!1&&(Ui.y*=-1,Ui.z*=-1),m.envMapRotation.value.setFromMatrix4(Dv.makeRotationFromEuler(Ui)),m.flipEnvMap.value=T.isCubeTexture&&T.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=f.reflectivity,m.ior.value=f.ior,m.refractionRatio.value=f.refractionRatio),f.lightMap&&(m.lightMap.value=f.lightMap,m.lightMapIntensity.value=f.lightMapIntensity,t(f.lightMap,m.lightMapTransform)),f.aoMap&&(m.aoMap.value=f.aoMap,m.aoMapIntensity.value=f.aoMapIntensity,t(f.aoMap,m.aoMapTransform))}function o(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,f.map&&(m.map.value=f.map,t(f.map,m.mapTransform))}function a(m,f){m.dashSize.value=f.dashSize,m.totalSize.value=f.dashSize+f.gapSize,m.scale.value=f.scale}function l(m,f,w,T){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.size.value=f.size*w,m.scale.value=T*.5,f.map&&(m.map.value=f.map,t(f.map,m.uvTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function c(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.rotation.value=f.rotation,f.map&&(m.map.value=f.map,t(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function u(m,f){m.specular.value.copy(f.specular),m.shininess.value=Math.max(f.shininess,1e-4)}function h(m,f){f.gradientMap&&(m.gradientMap.value=f.gradientMap)}function d(m,f){m.metalness.value=f.metalness,f.metalnessMap&&(m.metalnessMap.value=f.metalnessMap,t(f.metalnessMap,m.metalnessMapTransform)),m.roughness.value=f.roughness,f.roughnessMap&&(m.roughnessMap.value=f.roughnessMap,t(f.roughnessMap,m.roughnessMapTransform)),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)}function p(m,f,w){m.ior.value=f.ior,f.sheen>0&&(m.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),m.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(m.sheenColorMap.value=f.sheenColorMap,t(f.sheenColorMap,m.sheenColorMapTransform)),f.sheenRoughnessMap&&(m.sheenRoughnessMap.value=f.sheenRoughnessMap,t(f.sheenRoughnessMap,m.sheenRoughnessMapTransform))),f.clearcoat>0&&(m.clearcoat.value=f.clearcoat,m.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(m.clearcoatMap.value=f.clearcoatMap,t(f.clearcoatMap,m.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,t(f.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(m.clearcoatNormalMap.value=f.clearcoatNormalMap,t(f.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===Ht&&m.clearcoatNormalScale.value.negate())),f.dispersion>0&&(m.dispersion.value=f.dispersion),f.iridescence>0&&(m.iridescence.value=f.iridescence,m.iridescenceIOR.value=f.iridescenceIOR,m.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(m.iridescenceMap.value=f.iridescenceMap,t(f.iridescenceMap,m.iridescenceMapTransform)),f.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=f.iridescenceThicknessMap,t(f.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),f.transmission>0&&(m.transmission.value=f.transmission,m.transmissionSamplerMap.value=w.texture,m.transmissionSamplerSize.value.set(w.width,w.height),f.transmissionMap&&(m.transmissionMap.value=f.transmissionMap,t(f.transmissionMap,m.transmissionMapTransform)),m.thickness.value=f.thickness,f.thicknessMap&&(m.thicknessMap.value=f.thicknessMap,t(f.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=f.attenuationDistance,m.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(m.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(m.anisotropyMap.value=f.anisotropyMap,t(f.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=f.specularIntensity,m.specularColor.value.copy(f.specularColor),f.specularColorMap&&(m.specularColorMap.value=f.specularColorMap,t(f.specularColorMap,m.specularColorMapTransform)),f.specularIntensityMap&&(m.specularIntensityMap.value=f.specularIntensityMap,t(f.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,f){f.matcap&&(m.matcap.value=f.matcap)}function y(m,f){const w=e.get(f).light;m.referencePosition.value.setFromMatrixPosition(w.matrixWorld),m.nearDistance.value=w.shadow.camera.near,m.farDistance.value=w.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function Ov(n,e,t,i){let r={},s={},o=[];const a=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(w,T){const _=T.program;i.uniformBlockBinding(w,_)}function c(w,T){let _=r[w.id];_===void 0&&(g(w),_=u(w),r[w.id]=_,w.addEventListener("dispose",m));const S=T.program;i.updateUBOMapping(w,S);const b=e.render.frame;s[w.id]!==b&&(d(w),s[w.id]=b)}function u(w){const T=h();w.__bindingPointIndex=T;const _=n.createBuffer(),S=w.__size,b=w.usage;return n.bindBuffer(n.UNIFORM_BUFFER,_),n.bufferData(n.UNIFORM_BUFFER,S,b),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,T,_),_}function h(){for(let w=0;w<a;w++)if(o.indexOf(w)===-1)return o.push(w),w;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(w){const T=r[w.id],_=w.uniforms,S=w.__cache;n.bindBuffer(n.UNIFORM_BUFFER,T);for(let b=0,A=_.length;b<A;b++){const C=Array.isArray(_[b])?_[b]:[_[b]];for(let M=0,x=C.length;M<x;M++){const N=C[M];if(p(N,b,M,S)===!0){const z=N.__offset,Y=Array.isArray(N.value)?N.value:[N.value];let q=0;for(let J=0;J<Y.length;J++){const K=Y[J],se=y(K);typeof K=="number"||typeof K=="boolean"?(N.__data[0]=K,n.bufferSubData(n.UNIFORM_BUFFER,z+q,N.__data)):K.isMatrix3?(N.__data[0]=K.elements[0],N.__data[1]=K.elements[1],N.__data[2]=K.elements[2],N.__data[3]=0,N.__data[4]=K.elements[3],N.__data[5]=K.elements[4],N.__data[6]=K.elements[5],N.__data[7]=0,N.__data[8]=K.elements[6],N.__data[9]=K.elements[7],N.__data[10]=K.elements[8],N.__data[11]=0):(K.toArray(N.__data,q),q+=se.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,z,N.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function p(w,T,_,S){const b=w.value,A=T+"_"+_;if(S[A]===void 0)return typeof b=="number"||typeof b=="boolean"?S[A]=b:S[A]=b.clone(),!0;{const C=S[A];if(typeof b=="number"||typeof b=="boolean"){if(C!==b)return S[A]=b,!0}else if(C.equals(b)===!1)return C.copy(b),!0}return!1}function g(w){const T=w.uniforms;let _=0;const S=16;for(let A=0,C=T.length;A<C;A++){const M=Array.isArray(T[A])?T[A]:[T[A]];for(let x=0,N=M.length;x<N;x++){const z=M[x],Y=Array.isArray(z.value)?z.value:[z.value];for(let q=0,J=Y.length;q<J;q++){const K=Y[q],se=y(K),$=_%S,le=$%se.boundary,me=$+le;_+=le,me!==0&&S-me<se.storage&&(_+=S-me),z.__data=new Float32Array(se.storage/Float32Array.BYTES_PER_ELEMENT),z.__offset=_,_+=se.storage}}}const b=_%S;return b>0&&(_+=S-b),w.__size=_,w.__cache={},this}function y(w){const T={boundary:0,storage:0};return typeof w=="number"||typeof w=="boolean"?(T.boundary=4,T.storage=4):w.isVector2?(T.boundary=8,T.storage=8):w.isVector3||w.isColor?(T.boundary=16,T.storage=12):w.isVector4?(T.boundary=16,T.storage=16):w.isMatrix3?(T.boundary=48,T.storage=48):w.isMatrix4?(T.boundary=64,T.storage=64):w.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",w),T}function m(w){const T=w.target;T.removeEventListener("dispose",m);const _=o.indexOf(T.__bindingPointIndex);o.splice(_,1),n.deleteBuffer(r[T.id]),delete r[T.id],delete s[T.id]}function f(){for(const w in r)n.deleteBuffer(r[w]);o=[],r={},s={}}return{bind:l,update:c,dispose:f}}class Iv{constructor(e={}){const{canvas:t=Wd(),context:i=null,depth:r=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1,reversedDepthBuffer:d=!1}=e;this.isWebGLRenderer=!0;let p;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=i.getContextAttributes().alpha}else p=o;const g=new Uint32Array(4),y=new Int32Array(4);let m=null,f=null;const w=[],T=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=ri,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const _=this;let S=!1;this._outputColorSpace=rn;let b=0,A=0,C=null,M=-1,x=null;const N=new gt,z=new gt;let Y=null;const q=new je(0);let J=0,K=t.width,se=t.height,$=1,le=null,me=null;const Ee=new gt(0,0,K,se),Be=new gt(0,0,K,se);let pe=!1;const qe=new hl;let Je=!1,Z=!1;const oe=new ct,Me=new L,Ie=new gt,Ce={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ze=!1;function Rt(){return C===null?$:1}let O=i;function st(E,F){return t.getContext(E,F)}try{const E={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Wo}`),t.addEventListener("webglcontextlost",G,!1),t.addEventListener("webglcontextrestored",ee,!1),t.addEventListener("webglcontextcreationerror",k,!1),O===null){const F="webgl2";if(O=st(F,E),O===null)throw st(F)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(E){throw console.error("THREE.WebGLRenderer: "+E.message),E}let Ve,De,be,ot,Se,He,yt,ut,R,v,H,ne,re,te,Re,fe,Te,I,P,U,Q,ie,ae,we;function D(){Ve=new W_(O),Ve.init(),ie=new wv(O,Ve),De=new F_(O,Ve,e,ie),be=new Sv(O,Ve),De.reversedDepthBuffer&&d&&be.buffers.depth.setReversed(!0),ot=new Y_(O),Se=new hv,He=new Tv(O,Ve,be,Se,De,ie,ot),yt=new z_(_),ut=new G_(_),R=new Op(O),ae=new N_(O,R),v=new X_(O,R,ot,ae),H=new $_(O,v,R,ot),P=new q_(O,De,He),fe=new B_(Se),ne=new uv(_,yt,ut,Ve,De,ae,fe),re=new Lv(_,Se),te=new dv,Re=new xv(Ve),I=new I_(_,yt,ut,be,H,p,l),Te=new Ev(_,H,De),we=new Ov(O,ot,De,be),U=new U_(O,Ve,ot),Q=new j_(O,Ve,ot),ot.programs=ne.programs,_.capabilities=De,_.extensions=Ve,_.properties=Se,_.renderLists=te,_.shadowMap=Te,_.state=be,_.info=ot}D();const V=new Pv(_,O);this.xr=V,this.getContext=function(){return O},this.getContextAttributes=function(){return O.getContextAttributes()},this.forceContextLoss=function(){const E=Ve.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){const E=Ve.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return $},this.setPixelRatio=function(E){E!==void 0&&($=E,this.setSize(K,se,!1))},this.getSize=function(E){return E.set(K,se)},this.setSize=function(E,F,X=!0){if(V.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}K=E,se=F,t.width=Math.floor(E*$),t.height=Math.floor(F*$),X===!0&&(t.style.width=E+"px",t.style.height=F+"px"),this.setViewport(0,0,E,F)},this.getDrawingBufferSize=function(E){return E.set(K*$,se*$).floor()},this.setDrawingBufferSize=function(E,F,X){K=E,se=F,$=X,t.width=Math.floor(E*X),t.height=Math.floor(F*X),this.setViewport(0,0,E,F)},this.getCurrentViewport=function(E){return E.copy(N)},this.getViewport=function(E){return E.copy(Ee)},this.setViewport=function(E,F,X,j){E.isVector4?Ee.set(E.x,E.y,E.z,E.w):Ee.set(E,F,X,j),be.viewport(N.copy(Ee).multiplyScalar($).round())},this.getScissor=function(E){return E.copy(Be)},this.setScissor=function(E,F,X,j){E.isVector4?Be.set(E.x,E.y,E.z,E.w):Be.set(E,F,X,j),be.scissor(z.copy(Be).multiplyScalar($).round())},this.getScissorTest=function(){return pe},this.setScissorTest=function(E){be.setScissorTest(pe=E)},this.setOpaqueSort=function(E){le=E},this.setTransparentSort=function(E){me=E},this.getClearColor=function(E){return E.copy(I.getClearColor())},this.setClearColor=function(){I.setClearColor(...arguments)},this.getClearAlpha=function(){return I.getClearAlpha()},this.setClearAlpha=function(){I.setClearAlpha(...arguments)},this.clear=function(E=!0,F=!0,X=!0){let j=0;if(E){let B=!1;if(C!==null){const ce=C.texture.format;B=ce===ua||ce===ca||ce===la}if(B){const ce=C.texture.type,_e=ce===Nn||ce===Si||ce===zr||ce===Hr||ce===oa||ce===aa,Ae=I.getClearColor(),ye=I.getClearAlpha(),Oe=Ae.r,Fe=Ae.g,Pe=Ae.b;_e?(g[0]=Oe,g[1]=Fe,g[2]=Pe,g[3]=ye,O.clearBufferuiv(O.COLOR,0,g)):(y[0]=Oe,y[1]=Fe,y[2]=Pe,y[3]=ye,O.clearBufferiv(O.COLOR,0,y))}else j|=O.COLOR_BUFFER_BIT}F&&(j|=O.DEPTH_BUFFER_BIT),X&&(j|=O.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),O.clear(j)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",G,!1),t.removeEventListener("webglcontextrestored",ee,!1),t.removeEventListener("webglcontextcreationerror",k,!1),I.dispose(),te.dispose(),Re.dispose(),Se.dispose(),yt.dispose(),ut.dispose(),H.dispose(),ae.dispose(),we.dispose(),ne.dispose(),V.dispose(),V.removeEventListener("sessionstart",mn),V.removeEventListener("sessionend",qf),Ki.stop()};function G(E){E.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),S=!0}function ee(){console.log("THREE.WebGLRenderer: Context Restored."),S=!1;const E=ot.autoReset,F=Te.enabled,X=Te.autoUpdate,j=Te.needsUpdate,B=Te.type;D(),ot.autoReset=E,Te.enabled=F,Te.autoUpdate=X,Te.needsUpdate=j,Te.type=B}function k(E){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",E.statusMessage)}function W(E){const F=E.target;F.removeEventListener("dispose",W),ue(F)}function ue(E){xe(E),Se.remove(E)}function xe(E){const F=Se.get(E).programs;F!==void 0&&(F.forEach(function(X){ne.releaseProgram(X)}),E.isShaderMaterial&&ne.releaseShaderCache(E))}this.renderBufferDirect=function(E,F,X,j,B,ce){F===null&&(F=Ce);const _e=B.isMesh&&B.matrixWorld.determinant()<0,Ae=rM(E,F,X,j,B);be.setMaterial(j,_e);let ye=X.index,Oe=1;if(j.wireframe===!0){if(ye=v.getWireframeAttribute(X),ye===void 0)return;Oe=2}const Fe=X.drawRange,Pe=X.attributes.position;let Ye=Fe.start*Oe,it=(Fe.start+Fe.count)*Oe;ce!==null&&(Ye=Math.max(Ye,ce.start*Oe),it=Math.min(it,(ce.start+ce.count)*Oe)),ye!==null?(Ye=Math.max(Ye,0),it=Math.min(it,ye.count)):Pe!=null&&(Ye=Math.max(Ye,0),it=Math.min(it,Pe.count));const vt=it-Ye;if(vt<0||vt===1/0)return;ae.setup(B,j,Ae,X,ye);let ht,at=U;if(ye!==null&&(ht=R.get(ye),at=Q,at.setIndex(ht)),B.isMesh)j.wireframe===!0?(be.setLineWidth(j.wireframeLinewidth*Rt()),at.setMode(O.LINES)):at.setMode(O.TRIANGLES);else if(B.isLine){let Le=j.linewidth;Le===void 0&&(Le=1),be.setLineWidth(Le*Rt()),B.isLineSegments?at.setMode(O.LINES):B.isLineLoop?at.setMode(O.LINE_LOOP):at.setMode(O.LINE_STRIP)}else B.isPoints?at.setMode(O.POINTS):B.isSprite&&at.setMode(O.TRIANGLES);if(B.isBatchedMesh)if(B._multiDrawInstances!==null)Yr("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),at.renderMultiDrawInstances(B._multiDrawStarts,B._multiDrawCounts,B._multiDrawCount,B._multiDrawInstances);else if(Ve.get("WEBGL_multi_draw"))at.renderMultiDraw(B._multiDrawStarts,B._multiDrawCounts,B._multiDrawCount);else{const Le=B._multiDrawStarts,pt=B._multiDrawCounts,Qe=B._multiDrawCount,tn=ye?R.get(ye).bytesPerElement:1,Br=Se.get(j).currentProgram.getUniforms();for(let nn=0;nn<Qe;nn++)Br.setValue(O,"_gl_DrawID",nn),at.render(Le[nn]/tn,pt[nn])}else if(B.isInstancedMesh)at.renderInstances(Ye,vt,B.count);else if(X.isInstancedBufferGeometry){const Le=X._maxInstanceCount!==void 0?X._maxInstanceCount:1/0,pt=Math.min(X.instanceCount,Le);at.renderInstances(Ye,vt,pt)}else at.render(Ye,vt)};function We(E,F,X){E.transparent===!0&&E.side===On&&E.forceSinglePass===!1?(E.side=Ht,E.needsUpdate=!0,Go(E,F,X),E.side=ni,E.needsUpdate=!0,Go(E,F,X),E.side=On):Go(E,F,X)}this.compile=function(E,F,X=null){X===null&&(X=E),f=Re.get(X),f.init(F),T.push(f),X.traverseVisible(function(B){B.isLight&&B.layers.test(F.layers)&&(f.pushLight(B),B.castShadow&&f.pushShadow(B))}),E!==X&&E.traverseVisible(function(B){B.isLight&&B.layers.test(F.layers)&&(f.pushLight(B),B.castShadow&&f.pushShadow(B))}),f.setupLights();const j=new Set;return E.traverse(function(B){if(!(B.isMesh||B.isPoints||B.isLine||B.isSprite))return;const ce=B.material;if(ce)if(Array.isArray(ce))for(let _e=0;_e<ce.length;_e++){const Ae=ce[_e];We(Ae,X,B),j.add(Ae)}else We(ce,X,B),j.add(ce)}),f=T.pop(),j},this.compileAsync=function(E,F,X=null){const j=this.compile(E,F,X);return new Promise(B=>{function ce(){if(j.forEach(function(_e){Se.get(_e).currentProgram.isReady()&&j.delete(_e)}),j.size===0){B(E);return}setTimeout(ce,10)}Ve.get("KHR_parallel_shader_compile")!==null?ce():setTimeout(ce,10)})};let $e=null;function Ln(E){$e&&$e(E)}function mn(){Ki.stop()}function qf(){Ki.start()}const Ki=new zu;Ki.setAnimationLoop(Ln),typeof self<"u"&&Ki.setContext(self),this.setAnimationLoop=function(E){$e=E,V.setAnimationLoop(E),E===null?Ki.stop():Ki.start()},V.addEventListener("sessionstart",mn),V.addEventListener("sessionend",qf),this.render=function(E,F){if(F!==void 0&&F.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(S===!0)return;if(E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),F.parent===null&&F.matrixWorldAutoUpdate===!0&&F.updateMatrixWorld(),V.enabled===!0&&V.isPresenting===!0&&(V.cameraAutoUpdate===!0&&V.updateCamera(F),F=V.getCamera()),E.isScene===!0&&E.onBeforeRender(_,E,F,C),f=Re.get(E,T.length),f.init(F),T.push(f),oe.multiplyMatrices(F.projectionMatrix,F.matrixWorldInverse),qe.setFromProjectionMatrix(oe,Un,F.reversedDepth),Z=this.localClippingEnabled,Je=fe.init(this.clippingPlanes,Z),m=te.get(E,w.length),m.init(),w.push(m),V.enabled===!0&&V.isPresenting===!0){const ce=_.xr.getDepthSensingMesh();ce!==null&&Rc(ce,F,-1/0,_.sortObjects)}Rc(E,F,0,_.sortObjects),m.finish(),_.sortObjects===!0&&m.sort(le,me),ze=V.enabled===!1||V.isPresenting===!1||V.hasDepthSensing()===!1,ze&&I.addToRenderList(m,E),this.info.render.frame++,Je===!0&&fe.beginShadows();const X=f.state.shadowsArray;Te.render(X,E,F),Je===!0&&fe.endShadows(),this.info.autoReset===!0&&this.info.reset();const j=m.opaque,B=m.transmissive;if(f.setupLights(),F.isArrayCamera){const ce=F.cameras;if(B.length>0)for(let _e=0,Ae=ce.length;_e<Ae;_e++){const ye=ce[_e];Zf(j,B,E,ye)}ze&&I.render(E);for(let _e=0,Ae=ce.length;_e<Ae;_e++){const ye=ce[_e];$f(m,E,ye,ye.viewport)}}else B.length>0&&Zf(j,B,E,F),ze&&I.render(E),$f(m,E,F);C!==null&&A===0&&(He.updateMultisampleRenderTarget(C),He.updateRenderTargetMipmap(C)),E.isScene===!0&&E.onAfterRender(_,E,F),ae.resetDefaultState(),M=-1,x=null,T.pop(),T.length>0?(f=T[T.length-1],Je===!0&&fe.setGlobalState(_.clippingPlanes,f.state.camera)):f=null,w.pop(),w.length>0?m=w[w.length-1]:m=null};function Rc(E,F,X,j){if(E.visible===!1)return;if(E.layers.test(F.layers)){if(E.isGroup)X=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(F);else if(E.isLight)f.pushLight(E),E.castShadow&&f.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||qe.intersectsSprite(E)){j&&Ie.setFromMatrixPosition(E.matrixWorld).applyMatrix4(oe);const _e=H.update(E),Ae=E.material;Ae.visible&&m.push(E,_e,Ae,X,Ie.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||qe.intersectsObject(E))){const _e=H.update(E),Ae=E.material;if(j&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),Ie.copy(E.boundingSphere.center)):(_e.boundingSphere===null&&_e.computeBoundingSphere(),Ie.copy(_e.boundingSphere.center)),Ie.applyMatrix4(E.matrixWorld).applyMatrix4(oe)),Array.isArray(Ae)){const ye=_e.groups;for(let Oe=0,Fe=ye.length;Oe<Fe;Oe++){const Pe=ye[Oe],Ye=Ae[Pe.materialIndex];Ye&&Ye.visible&&m.push(E,_e,Ye,X,Ie.z,Pe)}}else Ae.visible&&m.push(E,_e,Ae,X,Ie.z,null)}}const ce=E.children;for(let _e=0,Ae=ce.length;_e<Ae;_e++)Rc(ce[_e],F,X,j)}function $f(E,F,X,j){const B=E.opaque,ce=E.transmissive,_e=E.transparent;f.setupLightsView(X),Je===!0&&fe.setGlobalState(_.clippingPlanes,X),j&&be.viewport(N.copy(j)),B.length>0&&ko(B,F,X),ce.length>0&&ko(ce,F,X),_e.length>0&&ko(_e,F,X),be.buffers.depth.setTest(!0),be.buffers.depth.setMask(!0),be.buffers.color.setMask(!0),be.setPolygonOffset(!1)}function Zf(E,F,X,j){if((X.isScene===!0?X.overrideMaterial:null)!==null)return;f.state.transmissionRenderTarget[j.id]===void 0&&(f.state.transmissionRenderTarget[j.id]=new wi(1,1,{generateMipmaps:!0,type:Ve.has("EXT_color_buffer_half_float")||Ve.has("EXT_color_buffer_float")?Vr:Nn,minFilter:bi,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ze.workingColorSpace}));const ce=f.state.transmissionRenderTarget[j.id],_e=j.viewport||N;ce.setSize(_e.z*_.transmissionResolutionScale,_e.w*_.transmissionResolutionScale);const Ae=_.getRenderTarget(),ye=_.getActiveCubeFace(),Oe=_.getActiveMipmapLevel();_.setRenderTarget(ce),_.getClearColor(q),J=_.getClearAlpha(),J<1&&_.setClearColor(16777215,.5),_.clear(),ze&&I.render(X);const Fe=_.toneMapping;_.toneMapping=ri;const Pe=j.viewport;if(j.viewport!==void 0&&(j.viewport=void 0),f.setupLightsView(j),Je===!0&&fe.setGlobalState(_.clippingPlanes,j),ko(E,X,j),He.updateMultisampleRenderTarget(ce),He.updateRenderTargetMipmap(ce),Ve.has("WEBGL_multisampled_render_to_texture")===!1){let Ye=!1;for(let it=0,vt=F.length;it<vt;it++){const ht=F[it],at=ht.object,Le=ht.geometry,pt=ht.material,Qe=ht.group;if(pt.side===On&&at.layers.test(j.layers)){const tn=pt.side;pt.side=Ht,pt.needsUpdate=!0,Kf(at,X,j,Le,pt,Qe),pt.side=tn,pt.needsUpdate=!0,Ye=!0}}Ye===!0&&(He.updateMultisampleRenderTarget(ce),He.updateRenderTargetMipmap(ce))}_.setRenderTarget(Ae,ye,Oe),_.setClearColor(q,J),Pe!==void 0&&(j.viewport=Pe),_.toneMapping=Fe}function ko(E,F,X){const j=F.isScene===!0?F.overrideMaterial:null;for(let B=0,ce=E.length;B<ce;B++){const _e=E[B],Ae=_e.object,ye=_e.geometry,Oe=_e.group;let Fe=_e.material;Fe.allowOverride===!0&&j!==null&&(Fe=j),Ae.layers.test(X.layers)&&Kf(Ae,F,X,ye,Fe,Oe)}}function Kf(E,F,X,j,B,ce){E.onBeforeRender(_,F,X,j,B,ce),E.modelViewMatrix.multiplyMatrices(X.matrixWorldInverse,E.matrixWorld),E.normalMatrix.getNormalMatrix(E.modelViewMatrix),B.onBeforeRender(_,F,X,j,E,ce),B.transparent===!0&&B.side===On&&B.forceSinglePass===!1?(B.side=Ht,B.needsUpdate=!0,_.renderBufferDirect(X,F,j,B,E,ce),B.side=ni,B.needsUpdate=!0,_.renderBufferDirect(X,F,j,B,E,ce),B.side=On):_.renderBufferDirect(X,F,j,B,E,ce),E.onAfterRender(_,F,X,j,B,ce)}function Go(E,F,X){F.isScene!==!0&&(F=Ce);const j=Se.get(E),B=f.state.lights,ce=f.state.shadowsArray,_e=B.state.version,Ae=ne.getParameters(E,B.state,ce,F,X),ye=ne.getProgramCacheKey(Ae);let Oe=j.programs;j.environment=E.isMeshStandardMaterial?F.environment:null,j.fog=F.fog,j.envMap=(E.isMeshStandardMaterial?ut:yt).get(E.envMap||j.environment),j.envMapRotation=j.environment!==null&&E.envMap===null?F.environmentRotation:E.envMapRotation,Oe===void 0&&(E.addEventListener("dispose",W),Oe=new Map,j.programs=Oe);let Fe=Oe.get(ye);if(Fe!==void 0){if(j.currentProgram===Fe&&j.lightsStateVersion===_e)return Qf(E,Ae),Fe}else Ae.uniforms=ne.getUniforms(E),E.onBeforeCompile(Ae,_),Fe=ne.acquireProgram(Ae,ye),Oe.set(ye,Fe),j.uniforms=Ae.uniforms;const Pe=j.uniforms;return(!E.isShaderMaterial&&!E.isRawShaderMaterial||E.clipping===!0)&&(Pe.clippingPlanes=fe.uniform),Qf(E,Ae),j.needsLights=oM(E),j.lightsStateVersion=_e,j.needsLights&&(Pe.ambientLightColor.value=B.state.ambient,Pe.lightProbe.value=B.state.probe,Pe.directionalLights.value=B.state.directional,Pe.directionalLightShadows.value=B.state.directionalShadow,Pe.spotLights.value=B.state.spot,Pe.spotLightShadows.value=B.state.spotShadow,Pe.rectAreaLights.value=B.state.rectArea,Pe.ltc_1.value=B.state.rectAreaLTC1,Pe.ltc_2.value=B.state.rectAreaLTC2,Pe.pointLights.value=B.state.point,Pe.pointLightShadows.value=B.state.pointShadow,Pe.hemisphereLights.value=B.state.hemi,Pe.directionalShadowMap.value=B.state.directionalShadowMap,Pe.directionalShadowMatrix.value=B.state.directionalShadowMatrix,Pe.spotShadowMap.value=B.state.spotShadowMap,Pe.spotLightMatrix.value=B.state.spotLightMatrix,Pe.spotLightMap.value=B.state.spotLightMap,Pe.pointShadowMap.value=B.state.pointShadowMap,Pe.pointShadowMatrix.value=B.state.pointShadowMatrix),j.currentProgram=Fe,j.uniformsList=null,Fe}function Jf(E){if(E.uniformsList===null){const F=E.currentProgram.getUniforms();E.uniformsList=ro.seqWithValue(F.seq,E.uniforms)}return E.uniformsList}function Qf(E,F){const X=Se.get(E);X.outputColorSpace=F.outputColorSpace,X.batching=F.batching,X.batchingColor=F.batchingColor,X.instancing=F.instancing,X.instancingColor=F.instancingColor,X.instancingMorph=F.instancingMorph,X.skinning=F.skinning,X.morphTargets=F.morphTargets,X.morphNormals=F.morphNormals,X.morphColors=F.morphColors,X.morphTargetsCount=F.morphTargetsCount,X.numClippingPlanes=F.numClippingPlanes,X.numIntersection=F.numClipIntersection,X.vertexAlphas=F.vertexAlphas,X.vertexTangents=F.vertexTangents,X.toneMapping=F.toneMapping}function rM(E,F,X,j,B){F.isScene!==!0&&(F=Ce),He.resetTextureUnits();const ce=F.fog,_e=j.isMeshStandardMaterial?F.environment:null,Ae=C===null?_.outputColorSpace:C.isXRRenderTarget===!0?C.texture.colorSpace:or,ye=(j.isMeshStandardMaterial?ut:yt).get(j.envMap||_e),Oe=j.vertexColors===!0&&!!X.attributes.color&&X.attributes.color.itemSize===4,Fe=!!X.attributes.tangent&&(!!j.normalMap||j.anisotropy>0),Pe=!!X.morphAttributes.position,Ye=!!X.morphAttributes.normal,it=!!X.morphAttributes.color;let vt=ri;j.toneMapped&&(C===null||C.isXRRenderTarget===!0)&&(vt=_.toneMapping);const ht=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,at=ht!==void 0?ht.length:0,Le=Se.get(j),pt=f.state.lights;if(Je===!0&&(Z===!0||E!==x)){const Vt=E===x&&j.id===M;fe.setState(j,E,Vt)}let Qe=!1;j.version===Le.__version?(Le.needsLights&&Le.lightsStateVersion!==pt.state.version||Le.outputColorSpace!==Ae||B.isBatchedMesh&&Le.batching===!1||!B.isBatchedMesh&&Le.batching===!0||B.isBatchedMesh&&Le.batchingColor===!0&&B.colorTexture===null||B.isBatchedMesh&&Le.batchingColor===!1&&B.colorTexture!==null||B.isInstancedMesh&&Le.instancing===!1||!B.isInstancedMesh&&Le.instancing===!0||B.isSkinnedMesh&&Le.skinning===!1||!B.isSkinnedMesh&&Le.skinning===!0||B.isInstancedMesh&&Le.instancingColor===!0&&B.instanceColor===null||B.isInstancedMesh&&Le.instancingColor===!1&&B.instanceColor!==null||B.isInstancedMesh&&Le.instancingMorph===!0&&B.morphTexture===null||B.isInstancedMesh&&Le.instancingMorph===!1&&B.morphTexture!==null||Le.envMap!==ye||j.fog===!0&&Le.fog!==ce||Le.numClippingPlanes!==void 0&&(Le.numClippingPlanes!==fe.numPlanes||Le.numIntersection!==fe.numIntersection)||Le.vertexAlphas!==Oe||Le.vertexTangents!==Fe||Le.morphTargets!==Pe||Le.morphNormals!==Ye||Le.morphColors!==it||Le.toneMapping!==vt||Le.morphTargetsCount!==at)&&(Qe=!0):(Qe=!0,Le.__version=j.version);let tn=Le.currentProgram;Qe===!0&&(tn=Go(j,F,B));let Br=!1,nn=!1,vs=!1;const mt=tn.getUniforms(),_n=Le.uniforms;if(be.useProgram(tn.program)&&(Br=!0,nn=!0,vs=!0),j.id!==M&&(M=j.id,nn=!0),Br||x!==E){be.buffers.depth.getReversed()&&E.reversedDepth!==!0&&(E._reversedDepth=!0,E.updateProjectionMatrix()),mt.setValue(O,"projectionMatrix",E.projectionMatrix),mt.setValue(O,"viewMatrix",E.matrixWorldInverse);const jt=mt.map.cameraPosition;jt!==void 0&&jt.setValue(O,Me.setFromMatrixPosition(E.matrixWorld)),De.logarithmicDepthBuffer&&mt.setValue(O,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),(j.isMeshPhongMaterial||j.isMeshToonMaterial||j.isMeshLambertMaterial||j.isMeshBasicMaterial||j.isMeshStandardMaterial||j.isShaderMaterial)&&mt.setValue(O,"isOrthographic",E.isOrthographicCamera===!0),x!==E&&(x=E,nn=!0,vs=!0)}if(B.isSkinnedMesh){mt.setOptional(O,B,"bindMatrix"),mt.setOptional(O,B,"bindMatrixInverse");const Vt=B.skeleton;Vt&&(Vt.boneTexture===null&&Vt.computeBoneTexture(),mt.setValue(O,"boneTexture",Vt.boneTexture,He))}B.isBatchedMesh&&(mt.setOptional(O,B,"batchingTexture"),mt.setValue(O,"batchingTexture",B._matricesTexture,He),mt.setOptional(O,B,"batchingIdTexture"),mt.setValue(O,"batchingIdTexture",B._indirectTexture,He),mt.setOptional(O,B,"batchingColorTexture"),B._colorsTexture!==null&&mt.setValue(O,"batchingColorTexture",B._colorsTexture,He));const gn=X.morphAttributes;if((gn.position!==void 0||gn.normal!==void 0||gn.color!==void 0)&&P.update(B,X,tn),(nn||Le.receiveShadow!==B.receiveShadow)&&(Le.receiveShadow=B.receiveShadow,mt.setValue(O,"receiveShadow",B.receiveShadow)),j.isMeshGouraudMaterial&&j.envMap!==null&&(_n.envMap.value=ye,_n.flipEnvMap.value=ye.isCubeTexture&&ye.isRenderTargetTexture===!1?-1:1),j.isMeshStandardMaterial&&j.envMap===null&&F.environment!==null&&(_n.envMapIntensity.value=F.environmentIntensity),nn&&(mt.setValue(O,"toneMappingExposure",_.toneMappingExposure),Le.needsLights&&sM(_n,vs),ce&&j.fog===!0&&re.refreshFogUniforms(_n,ce),re.refreshMaterialUniforms(_n,j,$,se,f.state.transmissionRenderTarget[E.id]),ro.upload(O,Jf(Le),_n,He)),j.isShaderMaterial&&j.uniformsNeedUpdate===!0&&(ro.upload(O,Jf(Le),_n,He),j.uniformsNeedUpdate=!1),j.isSpriteMaterial&&mt.setValue(O,"center",B.center),mt.setValue(O,"modelViewMatrix",B.modelViewMatrix),mt.setValue(O,"normalMatrix",B.normalMatrix),mt.setValue(O,"modelMatrix",B.matrixWorld),j.isShaderMaterial||j.isRawShaderMaterial){const Vt=j.uniformsGroups;for(let jt=0,Cc=Vt.length;jt<Cc;jt++){const Ji=Vt[jt];we.update(Ji,tn),we.bind(Ji,tn)}}return tn}function sM(E,F){E.ambientLightColor.needsUpdate=F,E.lightProbe.needsUpdate=F,E.directionalLights.needsUpdate=F,E.directionalLightShadows.needsUpdate=F,E.pointLights.needsUpdate=F,E.pointLightShadows.needsUpdate=F,E.spotLights.needsUpdate=F,E.spotLightShadows.needsUpdate=F,E.rectAreaLights.needsUpdate=F,E.hemisphereLights.needsUpdate=F}function oM(E){return E.isMeshLambertMaterial||E.isMeshToonMaterial||E.isMeshPhongMaterial||E.isMeshStandardMaterial||E.isShadowMaterial||E.isShaderMaterial&&E.lights===!0}this.getActiveCubeFace=function(){return b},this.getActiveMipmapLevel=function(){return A},this.getRenderTarget=function(){return C},this.setRenderTargetTextures=function(E,F,X){const j=Se.get(E);j.__autoAllocateDepthBuffer=E.resolveDepthBuffer===!1,j.__autoAllocateDepthBuffer===!1&&(j.__useRenderToTexture=!1),Se.get(E.texture).__webglTexture=F,Se.get(E.depthTexture).__webglTexture=j.__autoAllocateDepthBuffer?void 0:X,j.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(E,F){const X=Se.get(E);X.__webglFramebuffer=F,X.__useDefaultFramebuffer=F===void 0};const aM=O.createFramebuffer();this.setRenderTarget=function(E,F=0,X=0){C=E,b=F,A=X;let j=!0,B=null,ce=!1,_e=!1;if(E){const ye=Se.get(E);if(ye.__useDefaultFramebuffer!==void 0)be.bindFramebuffer(O.FRAMEBUFFER,null),j=!1;else if(ye.__webglFramebuffer===void 0)He.setupRenderTarget(E);else if(ye.__hasExternalTextures)He.rebindTextures(E,Se.get(E.texture).__webglTexture,Se.get(E.depthTexture).__webglTexture);else if(E.depthBuffer){const Pe=E.depthTexture;if(ye.__boundDepthTexture!==Pe){if(Pe!==null&&Se.has(Pe)&&(E.width!==Pe.image.width||E.height!==Pe.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");He.setupDepthRenderbuffer(E)}}const Oe=E.texture;(Oe.isData3DTexture||Oe.isDataArrayTexture||Oe.isCompressedArrayTexture)&&(_e=!0);const Fe=Se.get(E).__webglFramebuffer;E.isWebGLCubeRenderTarget?(Array.isArray(Fe[F])?B=Fe[F][X]:B=Fe[F],ce=!0):E.samples>0&&He.useMultisampledRTT(E)===!1?B=Se.get(E).__webglMultisampledFramebuffer:Array.isArray(Fe)?B=Fe[X]:B=Fe,N.copy(E.viewport),z.copy(E.scissor),Y=E.scissorTest}else N.copy(Ee).multiplyScalar($).floor(),z.copy(Be).multiplyScalar($).floor(),Y=pe;if(X!==0&&(B=aM),be.bindFramebuffer(O.FRAMEBUFFER,B)&&j&&be.drawBuffers(E,B),be.viewport(N),be.scissor(z),be.setScissorTest(Y),ce){const ye=Se.get(E.texture);O.framebufferTexture2D(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_CUBE_MAP_POSITIVE_X+F,ye.__webglTexture,X)}else if(_e){const ye=F;for(let Oe=0;Oe<E.textures.length;Oe++){const Fe=Se.get(E.textures[Oe]);O.framebufferTextureLayer(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0+Oe,Fe.__webglTexture,X,ye)}}else if(E!==null&&X!==0){const ye=Se.get(E.texture);O.framebufferTexture2D(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,ye.__webglTexture,X)}M=-1},this.readRenderTargetPixels=function(E,F,X,j,B,ce,_e,Ae=0){if(!(E&&E.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ye=Se.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&_e!==void 0&&(ye=ye[_e]),ye){be.bindFramebuffer(O.FRAMEBUFFER,ye);try{const Oe=E.textures[Ae],Fe=Oe.format,Pe=Oe.type;if(!De.textureFormatReadable(Fe)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!De.textureTypeReadable(Pe)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}F>=0&&F<=E.width-j&&X>=0&&X<=E.height-B&&(E.textures.length>1&&O.readBuffer(O.COLOR_ATTACHMENT0+Ae),O.readPixels(F,X,j,B,ie.convert(Fe),ie.convert(Pe),ce))}finally{const Oe=C!==null?Se.get(C).__webglFramebuffer:null;be.bindFramebuffer(O.FRAMEBUFFER,Oe)}}},this.readRenderTargetPixelsAsync=async function(E,F,X,j,B,ce,_e,Ae=0){if(!(E&&E.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ye=Se.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&_e!==void 0&&(ye=ye[_e]),ye)if(F>=0&&F<=E.width-j&&X>=0&&X<=E.height-B){be.bindFramebuffer(O.FRAMEBUFFER,ye);const Oe=E.textures[Ae],Fe=Oe.format,Pe=Oe.type;if(!De.textureFormatReadable(Fe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!De.textureTypeReadable(Pe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ye=O.createBuffer();O.bindBuffer(O.PIXEL_PACK_BUFFER,Ye),O.bufferData(O.PIXEL_PACK_BUFFER,ce.byteLength,O.STREAM_READ),E.textures.length>1&&O.readBuffer(O.COLOR_ATTACHMENT0+Ae),O.readPixels(F,X,j,B,ie.convert(Fe),ie.convert(Pe),0);const it=C!==null?Se.get(C).__webglFramebuffer:null;be.bindFramebuffer(O.FRAMEBUFFER,it);const vt=O.fenceSync(O.SYNC_GPU_COMMANDS_COMPLETE,0);return O.flush(),await Xd(O,vt,4),O.bindBuffer(O.PIXEL_PACK_BUFFER,Ye),O.getBufferSubData(O.PIXEL_PACK_BUFFER,0,ce),O.deleteBuffer(Ye),O.deleteSync(vt),ce}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(E,F=null,X=0){const j=Math.pow(2,-X),B=Math.floor(E.image.width*j),ce=Math.floor(E.image.height*j),_e=F!==null?F.x:0,Ae=F!==null?F.y:0;He.setTexture2D(E,0),O.copyTexSubImage2D(O.TEXTURE_2D,X,0,0,_e,Ae,B,ce),be.unbindTexture()};const lM=O.createFramebuffer(),cM=O.createFramebuffer();this.copyTextureToTexture=function(E,F,X=null,j=null,B=0,ce=null){ce===null&&(B!==0?(Yr("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),ce=B,B=0):ce=0);let _e,Ae,ye,Oe,Fe,Pe,Ye,it,vt;const ht=E.isCompressedTexture?E.mipmaps[ce]:E.image;if(X!==null)_e=X.max.x-X.min.x,Ae=X.max.y-X.min.y,ye=X.isBox3?X.max.z-X.min.z:1,Oe=X.min.x,Fe=X.min.y,Pe=X.isBox3?X.min.z:0;else{const gn=Math.pow(2,-B);_e=Math.floor(ht.width*gn),Ae=Math.floor(ht.height*gn),E.isDataArrayTexture?ye=ht.depth:E.isData3DTexture?ye=Math.floor(ht.depth*gn):ye=1,Oe=0,Fe=0,Pe=0}j!==null?(Ye=j.x,it=j.y,vt=j.z):(Ye=0,it=0,vt=0);const at=ie.convert(F.format),Le=ie.convert(F.type);let pt;F.isData3DTexture?(He.setTexture3D(F,0),pt=O.TEXTURE_3D):F.isDataArrayTexture||F.isCompressedArrayTexture?(He.setTexture2DArray(F,0),pt=O.TEXTURE_2D_ARRAY):(He.setTexture2D(F,0),pt=O.TEXTURE_2D),O.pixelStorei(O.UNPACK_FLIP_Y_WEBGL,F.flipY),O.pixelStorei(O.UNPACK_PREMULTIPLY_ALPHA_WEBGL,F.premultiplyAlpha),O.pixelStorei(O.UNPACK_ALIGNMENT,F.unpackAlignment);const Qe=O.getParameter(O.UNPACK_ROW_LENGTH),tn=O.getParameter(O.UNPACK_IMAGE_HEIGHT),Br=O.getParameter(O.UNPACK_SKIP_PIXELS),nn=O.getParameter(O.UNPACK_SKIP_ROWS),vs=O.getParameter(O.UNPACK_SKIP_IMAGES);O.pixelStorei(O.UNPACK_ROW_LENGTH,ht.width),O.pixelStorei(O.UNPACK_IMAGE_HEIGHT,ht.height),O.pixelStorei(O.UNPACK_SKIP_PIXELS,Oe),O.pixelStorei(O.UNPACK_SKIP_ROWS,Fe),O.pixelStorei(O.UNPACK_SKIP_IMAGES,Pe);const mt=E.isDataArrayTexture||E.isData3DTexture,_n=F.isDataArrayTexture||F.isData3DTexture;if(E.isDepthTexture){const gn=Se.get(E),Vt=Se.get(F),jt=Se.get(gn.__renderTarget),Cc=Se.get(Vt.__renderTarget);be.bindFramebuffer(O.READ_FRAMEBUFFER,jt.__webglFramebuffer),be.bindFramebuffer(O.DRAW_FRAMEBUFFER,Cc.__webglFramebuffer);for(let Ji=0;Ji<ye;Ji++)mt&&(O.framebufferTextureLayer(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,Se.get(E).__webglTexture,B,Pe+Ji),O.framebufferTextureLayer(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,Se.get(F).__webglTexture,ce,vt+Ji)),O.blitFramebuffer(Oe,Fe,_e,Ae,Ye,it,_e,Ae,O.DEPTH_BUFFER_BIT,O.NEAREST);be.bindFramebuffer(O.READ_FRAMEBUFFER,null),be.bindFramebuffer(O.DRAW_FRAMEBUFFER,null)}else if(B!==0||E.isRenderTargetTexture||Se.has(E)){const gn=Se.get(E),Vt=Se.get(F);be.bindFramebuffer(O.READ_FRAMEBUFFER,lM),be.bindFramebuffer(O.DRAW_FRAMEBUFFER,cM);for(let jt=0;jt<ye;jt++)mt?O.framebufferTextureLayer(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,gn.__webglTexture,B,Pe+jt):O.framebufferTexture2D(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,gn.__webglTexture,B),_n?O.framebufferTextureLayer(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,Vt.__webglTexture,ce,vt+jt):O.framebufferTexture2D(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,Vt.__webglTexture,ce),B!==0?O.blitFramebuffer(Oe,Fe,_e,Ae,Ye,it,_e,Ae,O.COLOR_BUFFER_BIT,O.NEAREST):_n?O.copyTexSubImage3D(pt,ce,Ye,it,vt+jt,Oe,Fe,_e,Ae):O.copyTexSubImage2D(pt,ce,Ye,it,Oe,Fe,_e,Ae);be.bindFramebuffer(O.READ_FRAMEBUFFER,null),be.bindFramebuffer(O.DRAW_FRAMEBUFFER,null)}else _n?E.isDataTexture||E.isData3DTexture?O.texSubImage3D(pt,ce,Ye,it,vt,_e,Ae,ye,at,Le,ht.data):F.isCompressedArrayTexture?O.compressedTexSubImage3D(pt,ce,Ye,it,vt,_e,Ae,ye,at,ht.data):O.texSubImage3D(pt,ce,Ye,it,vt,_e,Ae,ye,at,Le,ht):E.isDataTexture?O.texSubImage2D(O.TEXTURE_2D,ce,Ye,it,_e,Ae,at,Le,ht.data):E.isCompressedTexture?O.compressedTexSubImage2D(O.TEXTURE_2D,ce,Ye,it,ht.width,ht.height,at,ht.data):O.texSubImage2D(O.TEXTURE_2D,ce,Ye,it,_e,Ae,at,Le,ht);O.pixelStorei(O.UNPACK_ROW_LENGTH,Qe),O.pixelStorei(O.UNPACK_IMAGE_HEIGHT,tn),O.pixelStorei(O.UNPACK_SKIP_PIXELS,Br),O.pixelStorei(O.UNPACK_SKIP_ROWS,nn),O.pixelStorei(O.UNPACK_SKIP_IMAGES,vs),ce===0&&F.generateMipmaps&&O.generateMipmap(pt),be.unbindTexture()},this.initRenderTarget=function(E){Se.get(E).__webglFramebuffer===void 0&&He.setupRenderTarget(E)},this.initTexture=function(E){E.isCubeTexture?He.setTextureCube(E,0):E.isData3DTexture?He.setTexture3D(E,0):E.isDataArrayTexture||E.isCompressedArrayTexture?He.setTexture2DArray(E,0):He.setTexture2D(E,0),be.unbindTexture()},this.resetState=function(){b=0,A=0,C=null,be.reset(),ae.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Un}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 Rl{scene;camera;renderer;canvas;meshes=[];constructor(e){this.canvas=e,this.scene=new _p,this.scene.background=new je(1710618),this.camera=new an(45,e.clientWidth/e.clientHeight,.1,1e3),this.camera.position.set(1,1,7),this.renderer=new Iv({canvas:e,antialias:!0}),this.renderer.setSize(e.clientWidth,e.clientHeight);const t=new Cp(16777215,.5);this.scene.add(t);const i=new Rp(16777215,1);i.position.set(5,10,7),this.scene.add(i)}resize(){this.camera.aspect=this.canvas.clientWidth/this.canvas.clientHeight,this.camera.updateProjectionMatrix(),this.renderer.setSize(this.canvas.clientWidth,this.canvas.clientHeight)}render(){this.renderer.render(this.scene,this.camera)}update(){}loop(){this.update(),this.render(),requestAnimationFrame(()=>this.loop())}addFigure(e){const t=new Et;t.setAttribute("position",new et(e.position,3)),e.normal&&t.setAttribute("normal",new et(e.normal,3)),e.uv&&t.setAttribute("uv",new et(e.uv,2));const i=new Ep({color:12566463,metalness:0,roughness:.6}),r=new ge(t,i);return this.scene.add(r),this.meshes.push(r),r}addMesh(e){this.scene&&(this.scene.add(e),this.meshes.push(e))}removeMesh(e){this.scene&&(this.scene.remove(e),this.meshes=this.meshes.filter(t=>t!==e))}getMeshes(){return this.meshes}addObject(e,t){this.scene&&(typeof t=="number"&&e.layers.set(t),this.scene.add(e))}removeObject(e){this.scene&&(e.parent?e.parent.remove(e):this.scene.remove(e))}enableCameraLayer(e){this.camera&&this.camera.layers.enable(e)}dispose(){this.meshes&&(this.meshes.length=0,this.meshes=[]),this.scene=null,this.camera=null,this.renderer?.dispose(),this.canvas=null}}const ph={type:"change"},Cl={type:"start"},mh={type:"end"},oo=new Is,_h=new di,Nv=Math.cos(70*Gd.DEG2RAD),wt=new L,Wt=2*Math.PI,nt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Pl=1e-6;class gh extends Fu{constructor(e,t=null){super(e,t),this.state=nt.NONE,this.target=new L,this.cursor=new L,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:er.ROTATE,MIDDLE:er.DOLLY,RIGHT:er.PAN},this.touches={ONE:tr.ROTATE,TWO:tr.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new L,this._lastQuaternion=new Ct,this._lastTargetPosition=new L,this._quat=new Ct().setFromUnitVectors(e.up,new L(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Uu,this._sphericalDelta=new Uu,this._scale=1,this._panOffset=new L,this._rotateStart=new Ne,this._rotateEnd=new Ne,this._rotateDelta=new Ne,this._panStart=new Ne,this._panEnd=new Ne,this._panDelta=new Ne,this._dollyStart=new Ne,this._dollyEnd=new Ne,this._dollyDelta=new Ne,this._dollyDirection=new L,this._mouse=new Ne,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Fv.bind(this),this._onPointerDown=Uv.bind(this),this._onPointerUp=Bv.bind(this),this._onContextMenu=Xv.bind(this),this._onMouseWheel=Hv.bind(this),this._onKeyDown=kv.bind(this),this._onTouchStart=Gv.bind(this),this._onTouchMove=Wv.bind(this),this._onMouseDown=zv.bind(this),this._onMouseMove=Vv.bind(this),this._interceptControlDown=jv.bind(this),this._interceptControlUp=Yv.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(ph),this.update(),this.state=nt.NONE}update(e=null){const t=this.object.position;wt.copy(t).sub(this.target),wt.applyQuaternion(this._quat),this._spherical.setFromVector3(wt),this.autoRotate&&this.state===nt.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let i=this.minAzimuthAngle,r=this.maxAzimuthAngle;isFinite(i)&&isFinite(r)&&(i<-Math.PI?i+=Wt:i>Math.PI&&(i-=Wt),r<-Math.PI?r+=Wt:r>Math.PI&&(r-=Wt),i<=r?this._spherical.theta=Math.max(i,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+r)/2?Math.max(i,this._spherical.theta):Math.min(r,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=o!=this._spherical.radius}if(wt.setFromSpherical(this._spherical),wt.applyQuaternion(this._quatInverse),t.copy(this.target).add(wt),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=wt.length();o=this._clampDistance(a*this._scale);const l=a-o;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),s=!!l}else if(this.object.isOrthographicCamera){const a=new L(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=l!==this.object.zoom;const c=new L(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),o=wt.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):(oo.origin.copy(this.object.position),oo.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(oo.direction))<Nv?this.object.lookAt(this.target):(_h.setFromNormalAndCoplanarPoint(this.object.up,this.target),oo.intersectPlane(_h,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)>Pl||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Pl||this._lastTargetPosition.distanceToSquared(this.target)>Pl?(this.dispatchEvent(ph),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Wt/60*this.autoRotateSpeed*e:Wt/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){wt.setFromMatrixColumn(t,0),wt.multiplyScalar(-e),this._panOffset.add(wt)}_panUp(e,t){this.screenSpacePanning===!0?wt.setFromMatrixColumn(t,1):(wt.setFromMatrixColumn(t,0),wt.crossVectors(this.object.up,wt)),wt.multiplyScalar(e),this._panOffset.add(wt)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const r=this.object.position;wt.copy(r).sub(this.target);let s=wt.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/i.clientHeight,this.object.matrix),this._panUp(2*t*s/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),r=e-i.left,s=t-i.top,o=i.width,a=i.height;this._mouse.x=r/o*2-1,this._mouse.y=-(s/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Wt*this._rotateDelta.x/t.clientHeight),this._rotateUp(Wt*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(Wt*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(-Wt*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(Wt*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(-Wt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(i,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(i,r)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(i*i+r*r);this._dollyStart.set(0,s)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),r=.5*(e.pageX+i.x),s=.5*(e.pageY+i.y);this._rotateEnd.set(r,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Wt*this._rotateDelta.x/t.clientHeight),this._rotateUp(Wt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(i,r)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(i*i+r*r);this._dollyEnd.set(0,s),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new Ne,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,i={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:i.deltaY*=16;break;case 2:i.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(i.deltaY*=10),i}}function Uv(n){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(n.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(n)&&(this._addPointer(n),n.pointerType==="touch"?this._onTouchStart(n):this._onMouseDown(n)))}function Fv(n){this.enabled!==!1&&(n.pointerType==="touch"?this._onTouchMove(n):this._onMouseMove(n))}function Bv(n){switch(this._removePointer(n),this._pointers.length){case 0:this.domElement.releasePointerCapture(n.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(mh),this.state=nt.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 zv(n){let e;switch(n.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case er.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(n),this.state=nt.DOLLY;break;case er.ROTATE:if(n.ctrlKey||n.metaKey||n.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(n),this.state=nt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(n),this.state=nt.ROTATE}break;case er.PAN:if(n.ctrlKey||n.metaKey||n.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(n),this.state=nt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(n),this.state=nt.PAN}break;default:this.state=nt.NONE}this.state!==nt.NONE&&this.dispatchEvent(Cl)}function Vv(n){switch(this.state){case nt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(n);break;case nt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(n);break;case nt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(n);break}}function Hv(n){this.enabled===!1||this.enableZoom===!1||this.state!==nt.NONE||(n.preventDefault(),this.dispatchEvent(Cl),this._handleMouseWheel(this._customWheelEvent(n)),this.dispatchEvent(mh))}function kv(n){this.enabled!==!1&&this._handleKeyDown(n)}function Gv(n){switch(this._trackPointer(n),this._pointers.length){case 1:switch(this.touches.ONE){case tr.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(n),this.state=nt.TOUCH_ROTATE;break;case tr.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(n),this.state=nt.TOUCH_PAN;break;default:this.state=nt.NONE}break;case 2:switch(this.touches.TWO){case tr.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(n),this.state=nt.TOUCH_DOLLY_PAN;break;case tr.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(n),this.state=nt.TOUCH_DOLLY_ROTATE;break;default:this.state=nt.NONE}break;default:this.state=nt.NONE}this.state!==nt.NONE&&this.dispatchEvent(Cl)}function Wv(n){switch(this._trackPointer(n),this.state){case nt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(n),this.update();break;case nt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(n),this.update();break;case nt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(n),this.update();break;case nt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(n),this.update();break;default:this.state=nt.NONE}}function Xv(n){this.enabled!==!1&&n.preventDefault()}function jv(n){n.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Yv(n){n.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class qv extends gh{isInteracting=!1;constructor(e,t){super(e,t),this.domElement?.addEventListener("mousedown",()=>this.isInteracting=!0),this.domElement?.addEventListener("mouseup",()=>this.isInteracting=!1),this.domElement?.addEventListener("touchstart",()=>this.isInteracting=!0),this.domElement?.addEventListener("touchend",()=>this.isInteracting=!1)}dispose(){this.domElement?.removeEventListener("mousedown",()=>this.isInteracting=!0),this.domElement?.removeEventListener("mouseup",()=>this.isInteracting=!1),this.domElement?.removeEventListener("touchstart",()=>this.isInteracting=!0),this.domElement?.removeEventListener("touchend",()=>this.isInteracting=!1)}}class $v extends Qr{constructor(e=5){super();const t=[{dir:new L(1,0,0),color:16711680},{dir:new L(-1,0,0),color:16711680},{dir:new L(0,1,0),color:65280},{dir:new L(0,-1,0),color:65280},{dir:new L(0,0,1),color:255},{dir:new L(0,0,-1),color:255}];for(const{dir:i,color:r}of t){const s=new Et().setFromPoints([new L(0,0,0),i.clone().multiplyScalar(e)]),o=new Di({color:r}),a=new Tn(s,o);this.add(a)}}}const Fi=new Iu,Ft=new L,pi=new L,ft=new Ct,vh={X:new L(1,0,0),Y:new L(0,1,0),Z:new L(0,0,1)},Dl={type:"change"},xh={type:"mouseDown",mode:null},yh={type:"mouseUp",mode:null},Mh={type:"objectChange"};class Zv extends Fu{constructor(e,t=null){super(void 0,t);const i=new n0(this);this._root=i;const r=new i0;this._gizmo=r,i.add(r);const s=new r0;this._plane=s,i.add(s);const o=this;function a(T,_){let S=_;Object.defineProperty(o,T,{get:function(){return S!==void 0?S:_},set:function(b){S!==b&&(S=b,s[T]=b,r[T]=b,o.dispatchEvent({type:T+"-changed",value:b}),o.dispatchEvent(Dl))}}),o[T]=_,s[T]=_,r[T]=_}a("camera",e),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0),a("minX",-1/0),a("maxX",1/0),a("minY",-1/0),a("maxY",1/0),a("minZ",-1/0),a("maxZ",1/0);const l=new L,c=new L,u=new Ct,h=new Ct,d=new L,p=new Ct,g=new L,y=new L,m=new L,f=0,w=new L;a("worldPosition",l),a("worldPositionStart",c),a("worldQuaternion",u),a("worldQuaternionStart",h),a("cameraPosition",d),a("cameraQuaternion",p),a("pointStart",g),a("pointEnd",y),a("rotationAxis",m),a("rotationAngle",f),a("eye",w),this._offset=new L,this._startNorm=new L,this._endNorm=new L,this._cameraScale=new L,this._parentPosition=new L,this._parentQuaternion=new Ct,this._parentQuaternionInv=new Ct,this._parentScale=new L,this._worldScaleStart=new L,this._worldQuaternionInv=new Ct,this._worldScale=new L,this._positionStart=new L,this._quaternionStart=new Ct,this._scaleStart=new L,this._getPointer=Kv.bind(this),this._onPointerDown=Qv.bind(this),this._onPointerHover=Jv.bind(this),this._onPointerMove=e0.bind(this),this._onPointerUp=t0.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&&Fi.setFromCamera(e,this.camera);const t=Ll(this._gizmo.picker[this.mode],Fi);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&&Fi.setFromCamera(e,this.camera);const t=Ll(this._plane,Fi,!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,xh.mode=this.mode,this.dispatchEvent(xh)}}pointerMove(e){const t=this.axis,i=this.mode,r=this.object;let s=this.space;if(i==="scale"?s="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(s="world"),r===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&Fi.setFromCamera(e,this.camera);const o=Ll(this._plane,Fi,!0);if(o){if(this.pointEnd.copy(o.point).sub(this.worldPositionStart),i==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),s==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),s==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),r.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(s==="local"&&(r.position.applyQuaternion(ft.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.position.applyQuaternion(this._quaternionStart)),s==="world"&&(r.parent&&r.position.add(Ft.setFromMatrixPosition(r.parent.matrixWorld)),t.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.parent&&r.position.sub(Ft.setFromMatrixPosition(r.parent.matrixWorld)))),r.position.x=Math.max(this.minX,Math.min(this.maxX,r.position.x)),r.position.y=Math.max(this.minY,Math.min(this.maxY,r.position.y)),r.position.z=Math.max(this.minZ,Math.min(this.maxZ,r.position.z));else if(i==="scale"){if(t.search("XYZ")!==-1){let a=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(a*=-1),pi.set(a,a,a)}else Ft.copy(this.pointStart),pi.copy(this.pointEnd),Ft.applyQuaternion(this._worldQuaternionInv),pi.applyQuaternion(this._worldQuaternionInv),pi.divide(Ft),t.search("X")===-1&&(pi.x=1),t.search("Y")===-1&&(pi.y=1),t.search("Z")===-1&&(pi.z=1);r.scale.copy(this._scaleStart).multiply(pi),this.scaleSnap&&(t.search("X")!==-1&&(r.scale.x=Math.round(r.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(r.scale.y=Math.round(r.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(r.scale.z=Math.round(r.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(i==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const a=20/this.worldPosition.distanceTo(Ft.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(Ft.copy(this.rotationAxis).cross(this.eye))*a):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(vh[t]),Ft.copy(vh[t]),s==="local"&&Ft.applyQuaternion(this.worldQuaternion),Ft.cross(this.eye),Ft.length()===0?l=!0:this.rotationAngle=this._offset.dot(Ft.normalize())*a),(t==="E"||l)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),s==="local"&&t!=="E"&&t!=="XYZE"?(r.quaternion.copy(this._quaternionStart),r.quaternion.multiply(ft.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),r.quaternion.copy(ft.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),r.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Dl),this.dispatchEvent(Mh)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(yh.mode=this.mode,this.dispatchEvent(yh)),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(Dl),this.dispatchEvent(Mh),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Fi}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}setColors(e,t,i,r){const s=this._gizmo.materialLib;s.xAxis.color.set(e),s.yAxis.color.set(t),s.zAxis.color.set(i),s.active.color.set(r),s.xAxisTransparent.color.set(e),s.yAxisTransparent.color.set(t),s.zAxisTransparent.color.set(i),s.activeTransparent.color.set(r),s.xAxis._color&&s.xAxis._color.set(e),s.yAxis._color&&s.yAxis._color.set(t),s.zAxis._color&&s.zAxis._color.set(i),s.active._color&&s.active._color.set(r),s.xAxisTransparent._color&&s.xAxisTransparent._color.set(e),s.yAxisTransparent._color&&s.yAxisTransparent._color.set(t),s.zAxisTransparent._color&&s.zAxisTransparent._color.set(i),s.activeTransparent._color&&s.activeTransparent._color.set(r)}}function Kv(n){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:n.button};{const e=this.domElement.getBoundingClientRect();return{x:(n.clientX-e.left)/e.width*2-1,y:-(n.clientY-e.top)/e.height*2+1,button:n.button}}}function Jv(n){if(this.enabled)switch(n.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(n));break}}function Qv(n){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(n.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(n)),this.pointerDown(this._getPointer(n)))}function e0(n){this.enabled&&this.pointerMove(this._getPointer(n))}function t0(n){this.enabled&&(this.domElement.releasePointerCapture(n.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(n)))}function Ll(n,e,t){const i=e.intersectObject(n,!0);for(let r=0;r<i.length;r++)if(i[r].object.visible||t)return i[r];return!1}const ao=new En,rt=new L(0,1,0),Eh=new L(0,0,0),bh=new ct,lo=new Ct,co=new Ct,Bn=new L,Sh=new ct,is=new L(1,0,0),Bi=new L(0,1,0),rs=new L(0,0,1),uo=new L,ss=new L,os=new L;class n0 extends xt{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 i0 extends xt{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new Bs({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new Di({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=e.clone();i.opacity=.15;const r=t.clone();r.opacity=.5;const s=e.clone();s.color.setHex(16711680);const o=e.clone();o.color.setHex(65280);const a=e.clone();a.color.setHex(255);const l=e.clone();l.color.setHex(16711680),l.opacity=.5;const c=e.clone();c.color.setHex(65280),c.opacity=.5;const u=e.clone();u.color.setHex(255),u.opacity=.5;const h=e.clone();h.opacity=.25;const d=e.clone();d.color.setHex(16776960),d.opacity=.25;const p=e.clone();p.color.setHex(16776960);const g=e.clone();g.color.setHex(7895160),this.materialLib={xAxis:s,yAxis:o,zAxis:a,active:p,xAxisTransparent:l,yAxisTransparent:c,zAxisTransparent:u,activeTransparent:d};const y=new Ut(0,.04,.1,12);y.translate(0,.05,0);const m=new bt(.08,.08,.08);m.translate(0,.04,0);const f=new Et;f.setAttribute("position",new et([0,0,0,1,0,0],3));const w=new Ut(.0075,.0075,.5,3);w.translate(0,.25,0);function T(J,K){const se=new Li(J,.0075,3,64,K*Math.PI*2);return se.rotateY(Math.PI/2),se.rotateX(Math.PI/2),se}function _(){const J=new Et;return J.setAttribute("position",new et([0,0,0,1,1,1],3)),J}const S={X:[[new ge(y,s),[.5,0,0],[0,0,-Math.PI/2]],[new ge(y,s),[-.5,0,0],[0,0,Math.PI/2]],[new ge(w,s),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new ge(y,o),[0,.5,0]],[new ge(y,o),[0,-.5,0],[Math.PI,0,0]],[new ge(w,o)]],Z:[[new ge(y,a),[0,0,.5],[Math.PI/2,0,0]],[new ge(y,a),[0,0,-.5],[-Math.PI/2,0,0]],[new ge(w,a),null,[Math.PI/2,0,0]]],XYZ:[[new ge(new br(.1,0),h),[0,0,0]]],XY:[[new ge(new bt(.15,.15,.01),u),[.15,.15,0]]],YZ:[[new ge(new bt(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new ge(new bt(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]]},b={X:[[new ge(new Ut(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new ge(new Ut(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new ge(new Ut(.2,0,.6,4),i),[0,.3,0]],[new ge(new Ut(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new ge(new Ut(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new ge(new Ut(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new ge(new br(.2,0),i)]],XY:[[new ge(new bt(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new ge(new bt(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new ge(new bt(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},A={START:[[new ge(new br(.01,2),r),null,null,null,"helper"]],END:[[new ge(new br(.01,2),r),null,null,null,"helper"]],DELTA:[[new Tn(_(),r),null,null,null,"helper"]],X:[[new Tn(f,r),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Tn(f,r),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Tn(f,r),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},C={XYZE:[[new ge(T(.5,1),g),null,[0,Math.PI/2,0]]],X:[[new ge(T(.5,.5),s)]],Y:[[new ge(T(.5,.5),o),null,[0,0,-Math.PI/2]]],Z:[[new ge(T(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new ge(T(.75,1),d),null,[0,Math.PI/2,0]]]},M={AXIS:[[new Tn(f,r),[-1e3,0,0],null,[1e6,1,1],"helper"]]},x={XYZE:[[new ge(new _l(.25,10,8),i)]],X:[[new ge(new Li(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new ge(new Li(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new ge(new Li(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new ge(new Li(.75,.1,2,24),i)]]},N={X:[[new ge(m,s),[.5,0,0],[0,0,-Math.PI/2]],[new ge(w,s),[0,0,0],[0,0,-Math.PI/2]],[new ge(m,s),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new ge(m,o),[0,.5,0]],[new ge(w,o)],[new ge(m,o),[0,-.5,0],[0,0,Math.PI]]],Z:[[new ge(m,a),[0,0,.5],[Math.PI/2,0,0]],[new ge(w,a),[0,0,0],[Math.PI/2,0,0]],[new ge(m,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new ge(new bt(.15,.15,.01),u),[.15,.15,0]]],YZ:[[new ge(new bt(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new ge(new bt(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new ge(new bt(.1,.1,.1),h)]]},z={X:[[new ge(new Ut(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new ge(new Ut(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new ge(new Ut(.2,0,.6,4),i),[0,.3,0]],[new ge(new Ut(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new ge(new Ut(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new ge(new Ut(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new ge(new bt(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new ge(new bt(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new ge(new bt(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new ge(new bt(.2,.2,.2),i),[0,0,0]]]},Y={X:[[new Tn(f,r),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Tn(f,r),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Tn(f,r),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function q(J){const K=new xt;for(const se in J)for(let $=J[se].length;$--;){const le=J[se][$][0].clone(),me=J[se][$][1],Ee=J[se][$][2],Be=J[se][$][3],pe=J[se][$][4];le.name=se,le.tag=pe,me&&le.position.set(me[0],me[1],me[2]),Ee&&le.rotation.set(Ee[0],Ee[1],Ee[2]),Be&&le.scale.set(Be[0],Be[1],Be[2]),le.updateMatrix();const qe=le.geometry.clone();qe.applyMatrix4(le.matrix),le.geometry=qe,le.renderOrder=1/0,le.position.set(0,0,0),le.rotation.set(0,0,0),le.scale.set(1,1,1),K.add(le)}return K}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=q(S)),this.add(this.gizmo.rotate=q(C)),this.add(this.gizmo.scale=q(N)),this.add(this.picker.translate=q(b)),this.add(this.picker.rotate=q(x)),this.add(this.picker.scale=q(z)),this.add(this.helper.translate=q(A)),this.add(this.helper.rotate=q(M)),this.add(this.helper.scale=q(Y)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const i=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:co;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"&&(ft.setFromEuler(ao.set(0,0,0)),o.quaternion.copy(i).multiply(ft),Math.abs(rt.copy(is).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Y"&&(ft.setFromEuler(ao.set(0,0,Math.PI/2)),o.quaternion.copy(i).multiply(ft),Math.abs(rt.copy(Bi).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Z"&&(ft.setFromEuler(ao.set(0,Math.PI/2,0)),o.quaternion.copy(i).multiply(ft),Math.abs(rt.copy(rs).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="XYZE"&&(ft.setFromEuler(ao.set(0,Math.PI/2,0)),rt.copy(this.rotationAxis),o.quaternion.setFromRotationMatrix(bh.lookAt(Eh,rt,Bi)),o.quaternion.multiply(ft),o.visible=this.dragging),this.axis==="E"&&(o.visible=!1)):o.name==="START"?(o.position.copy(this.worldPositionStart),o.visible=this.dragging):o.name==="END"?(o.position.copy(this.worldPosition),o.visible=this.dragging):o.name==="DELTA"?(o.position.copy(this.worldPositionStart),o.quaternion.copy(this.worldQuaternionStart),Ft.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),Ft.applyQuaternion(this.worldQuaternionStart.clone().invert()),o.scale.copy(Ft),o.visible=this.dragging):(o.quaternion.copy(i),this.dragging?o.position.copy(this.worldPositionStart):o.position.copy(this.worldPosition),this.axis&&(o.visible=this.axis.search(o.name)!==-1));continue}o.quaternion.copy(i),this.mode==="translate"||this.mode==="scale"?(o.name==="X"&&Math.abs(rt.copy(is).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Y"&&Math.abs(rt.copy(Bi).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Z"&&Math.abs(rt.copy(rs).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XY"&&Math.abs(rt.copy(rs).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="YZ"&&Math.abs(rt.copy(is).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XZ"&&Math.abs(rt.copy(Bi).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1)):this.mode==="rotate"&&(lo.copy(i),rt.copy(this.eye).applyQuaternion(ft.copy(i).invert()),o.name.search("E")!==-1&&o.quaternion.setFromRotationMatrix(bh.lookAt(this.eye,Eh,Bi)),o.name==="X"&&(ft.setFromAxisAngle(is,Math.atan2(-rt.y,rt.z)),ft.multiplyQuaternions(lo,ft),o.quaternion.copy(ft)),o.name==="Y"&&(ft.setFromAxisAngle(Bi,Math.atan2(rt.x,rt.z)),ft.multiplyQuaternions(lo,ft),o.quaternion.copy(ft)),o.name==="Z"&&(ft.setFromAxisAngle(rs,Math.atan2(rt.y,rt.x)),ft.multiplyQuaternions(lo,ft),o.quaternion.copy(ft))),o.visible=o.visible&&(o.name.indexOf("X")===-1||this.showX),o.visible=o.visible&&(o.name.indexOf("Y")===-1||this.showY),o.visible=o.visible&&(o.name.indexOf("Z")===-1||this.showZ),o.visible=o.visible&&(o.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),o.material._color=o.material._color||o.material.color.clone(),o.material._opacity=o.material._opacity||o.material.opacity,o.material.color.copy(o.material._color),o.material.opacity=o.material._opacity,this.enabled&&this.axis&&(o.name===this.axis?(o.material.color.copy(this.materialLib.active.color),o.material.opacity=1):this.axis.split("").some(function(l){return o.name===l})&&(o.material.color.copy(this.materialLib.active.color),o.material.opacity=1))}super.updateMatrixWorld(e)}}class r0 extends ge{constructor(){super(new ts(1e5,1e5,2,2),new Bs({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"),uo.copy(is).applyQuaternion(t==="local"?this.worldQuaternion:co),ss.copy(Bi).applyQuaternion(t==="local"?this.worldQuaternion:co),os.copy(rs).applyQuaternion(t==="local"?this.worldQuaternion:co),rt.copy(ss),this.mode){case"translate":case"scale":switch(this.axis){case"X":rt.copy(this.eye).cross(uo),Bn.copy(uo).cross(rt);break;case"Y":rt.copy(this.eye).cross(ss),Bn.copy(ss).cross(rt);break;case"Z":rt.copy(this.eye).cross(os),Bn.copy(os).cross(rt);break;case"XY":Bn.copy(os);break;case"YZ":Bn.copy(uo);break;case"XZ":rt.copy(os),Bn.copy(ss);break;case"XYZ":case"E":Bn.set(0,0,0);break}break;case"rotate":default:Bn.set(0,0,0)}Bn.length()===0?this.quaternion.copy(this.cameraQuaternion):(Sh.lookAt(Ft.set(0,0,0),Bn,rt),this.quaternion.setFromRotationMatrix(Sh)),super.updateMatrixWorld(e)}}var Ol;(function(n){n[n.Transient=0]="Transient",n[n.Singleton=1]="Singleton",n[n.ResolutionScoped=2]="ResolutionScoped",n[n.ContainerScoped=3]="ContainerScoped"})(Ol||(Ol={}));const Xt=Ol;/*! *****************************************************************************
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,36 @@ void main() {
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 Zo=function(i,e){return Zo=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])},Zo(i,e)};function Ko(i,e){Zo(i,e);function t(){this.constructor=i}i.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Lm(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 Im(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 $r(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 Zr(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 Kn(){for(var i=[],e=0;e<arguments.length;e++)i=i.concat(Zr(arguments[e]));return i}var Qo="injectionTokens";function Um(i){var e=Reflect.getMetadata("design:paramtypes",i)||[],t=Reflect.getOwnMetadata(Qo,i)||{};return Object.keys(t).forEach(function(n){e[+n]=t[n]}),e}function cc(i,e){return function(t,n,r){var s=Reflect.getOwnMetadata(Qo,t)||{};s[r]=i,Reflect.defineMetadata(Qo,s,t)}}function hc(i){return!!i.useClass}function Jo(i){return!!i.useFactory}var uc=(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,Kn(s))}};return this.reflectMethods.forEach(n),t},i})();function Pi(i){return typeof i=="string"||typeof i=="symbol"}function Nm(i){return typeof i=="object"&&"token"in i&&"multiple"in i}function fc(i){return typeof i=="object"&&"token"in i&&"transform"in i}function Om(i){return typeof i=="function"||i instanceof uc}function Kr(i){return!!i.useToken}function Qr(i){return i.useValue!=null}function Fm(i){return hc(i)||Qr(i)||Kr(i)||Jo(i)}var ea=(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})(),Bm=(function(i){Ko(e,i);function e(){return i!==null&&i.apply(this,arguments)||this}return e})(ea),Jr=(function(){function i(){this.scopedResolutions=new Map}return i})();function zm(i,e){if(i===null)return"at position #"+e;var t=i.split(",")[e].trim();return'"'+t+'" at position #'+e}function Hm(i,e,t){return t===void 0&&(t=" "),Kn([i],e.message.split(`
3867
- `).map(function(n){return t+n})).join(`
3868
- `)}function km(i,e,t){var n=Zr(i.toString().match(/constructor\(([\w, ]+)\)/)||[],2),r=n[1],s=r===void 0?null:r,o=zm(s,e);return Hm("Cannot inject the dependency "+o+' of "'+i.name+'" constructor. Reason:',t)}function Gm(i){if(typeof i.dispose!="function")return!1;var e=i.dispose;return!(e.length>0)}var Vm=(function(i){Ko(e,i);function e(){return i!==null&&i.apply(this,arguments)||this}return e})(ea),Wm=(function(i){Ko(e,i);function e(){return i!==null&&i.apply(this,arguments)||this}return e})(ea),Xm=(function(){function i(){this.preResolution=new Vm,this.postResolution=new Wm}return i})(),dc=new Map,Ym=(function(){function i(e){this.parent=e,this._registry=new Bm,this.interceptors=new Xm,this.disposed=!1,this.disposables=new Set}return i.prototype.register=function(e,t,n){n===void 0&&(n={lifecycle:Nt.Transient}),this.ensureNotDisposed();var r;if(Fm(t)?r=t:r={useClass:t},Kr(r))for(var s=[e],o=r;o!=null;){var a=o.useToken;if(s.includes(a))throw new Error("Token registration cycle detected! "+Kn(s,[a]).join(" -> "));s.push(a);var c=this._registry.get(a);c&&Kr(c.provider)?o=c.provider:o=null}if((n.lifecycle===Nt.Singleton||n.lifecycle==Nt.ContainerScoped||n.lifecycle==Nt.ResolutionScoped)&&(Qr(r)||Jo(r)))throw new Error('Cannot use lifecycle "'+Nt[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(),Pi(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(),Pi(e)){if(Pi(t))return this.register(e,{useToken:t},{lifecycle:Nt.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:Nt.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var n=e;return t&&!Pi(t)&&(n=t),this.register(e,{useClass:n},{lifecycle:Nt.Singleton})},i.prototype.resolve=function(e,t,n){t===void 0&&(t=new Jr),n===void 0&&(n=!1),this.ensureNotDisposed();var r=this.getRegistration(e);if(!r&&Pi(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(Om(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=$r(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=$r(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===Nt.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var n=e.options.lifecycle===Nt.Singleton,r=e.options.lifecycle===Nt.ContainerScoped,s=n||r,o;return Qr(e.provider)?o=e.provider.useValue:Kr(e.provider)?o=s?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):hc(e.provider)?o=s?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):Jo(e.provider)?o=e.provider.useFactory(this):o=this.construct(e.provider,t),e.options.lifecycle===Nt.ResolutionScoped&&t.scopedResolutions.set(e,o),o},i.prototype.resolveAll=function(e,t,n){var r=this;t===void 0&&(t=new Jr),n===void 0&&(n=!1),this.ensureNotDisposed();var s=this.getAllRegistrations(e);if(!s&&Pi(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=$r(this._registry.entries()),r=n.next();!r.done;r=n.next()){var s=Zr(r.value,2),o=s[0],a=s[1];this._registry.setAll(o,a.filter(function(c){return!Qr(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=$r(this._registry.entries()),s=r.next();!s.done;s=r.next()){var o=Zr(s.value,2),a=o[0],c=o[1];c.some(function(l){var u=l.options;return u.lifecycle===Nt.ContainerScoped})&&n._registry.setAll(a,c.map(function(l){return l.options.lifecycle===Nt.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 Lm(this,void 0,void 0,function(){var e;return Im(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 uc)return e.createProxy(function(s){return n.resolve(s,t)});var r=(function(){var s=dc.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,Kn([void 0],o)))})();return Gm(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 Nm(r)?fc(r)?r.multiple?(o=n.resolve(r.transform)).transform.apply(o,Kn([n.resolveAll(r.token,new Jr,r.isOptional)],r.transformArgs)):(a=n.resolve(r.transform)).transform.apply(a,Kn([n.resolve(r.token,e,r.isOptional)],r.transformArgs)):r.multiple?n.resolveAll(r.token,new Jr,r.isOptional):n.resolve(r.token,e,r.isOptional):fc(r)?(c=n.resolve(r.transform,e)).transform.apply(c,Kn([n.resolve(r.token,e)],r.transformArgs)):n.resolve(r,e)}catch(l){throw new Error(km(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})(),qm=new Ym;function zt(i,e){var t={token:i,multiple:!1,isOptional:e};return cc(t)}function Yt(i){return function(e){dc.set(e,Um(e))}}function ta(i,e){var t={token:i,multiple:!0,isOptional:e};return cc(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 es={exports:{}},pc;function jm(){if(pc)return es.exports;pc=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)}es.exports=s,es.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 es.exports}var $m=jm(),Zm=Object.getOwnPropertyDescriptor,Km=(i,e,t,n)=>{for(var r=n>1?void 0:n?Zm(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=o(r)||r);return r};ht.EventBus=class{_emitter;constructor(){this._emitter=new $m.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)}},ht.EventBus=Km([Yt()],ht.EventBus);var Mn=(i=>(i.SelectHover="select.hover",i.SelectClick="select.click",i.ToolSelect="tool.select",i))(Mn||{});class Qm{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 mc=(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))(mc||{}),er=(i=>(i.Plane="plane",i.Wireframe="wireframe",i.Texture="texture",i))(er||{}),ts=(i=>(i.Mesh="mesh",i.Face="face",i.Edge="edge",i.Vertex="vertex",i))(ts||{}),Qn=(i=>(i.Translate="translate",i.Scale="scale",i.Rotate="rotate",i))(Qn||{}),Jm=Object.getOwnPropertyDescriptor,e_=(i,e,t,n)=>{for(var r=n>1?void 0:n?Jm(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=o(r)||r);return r},_c=(i,e)=>(t,n)=>e(t,n,i);ht.EditorRenderer=class extends Wo{constructor(e,t){super(e),this._canvas=e,this._bus=t;const n=new iu(10,10);n.position.y=-.001,this.scene.add(n);const r=new Sm(6);this.scene.add(r),this._orbit=new ym(this.camera,this.renderer.domElement),this._orbit.enableDamping=!0,this._orbit.dampingFactor=.05,this._raycaster=new vl,this._mouse=new Ie,this.scene.add(new Kh(16777215,4473924,.6)),this._transform=new Em(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 Yh(t.geometry),r=new Co(n,new bi({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,Mn.SelectHover,!0)};_handleMouseClick=e=>{this._processRaycastEvent(e,Mn.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)}},ht.EditorRenderer=e_([Yt(),_c(0,zt("Canvas")),_c(1,zt("EventBus"))],ht.EditorRenderer);class t_ extends Wo{_orbit;constructor(e){super(e),this.camera.position.set(1,1,7),this.camera.lookAt(0,0,0),this._orbit=new tc(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 n_{_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:mc.Custom,position:this._positions,...this._normals.length>0&&{normal:this._normals},...this._uvs.length>0&&{uv:this._uvs}};return new Qm(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 i_=Object.getOwnPropertyDescriptor,r_=(i,e,t,n)=>{for(var r=n>1?void 0:n?i_(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=o(r)||r);return r},s_=(i,e)=>(t,n)=>e(t,n,i);let na=class{_currentMode=er.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!==er.Plane&&this._handlers.get(i)?.handle(),this._currentMode=i)}destroy(){this._handlers&&this._handlers.clear(),this._currentMode=er.Plane}};na=r_([Yt(),s_(0,ta("IDisplayHandler"))],na);var tr=(i=>(i.Hover="hover",i.Click="click",i))(tr||{}),o_=Object.getOwnPropertyDescriptor,a_=(i,e,t,n)=>{for(var r=n>1?void 0:n?o_(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=o(r)||r);return r},gc=(i,e)=>(t,n)=>e(t,n,i);let ia=class{constructor(i,e){this._eventBus=i,this._handlers=new Map(e.map(t=>[t.mode,t])),this._eventBus.on(Mn.SelectHover,this._onHover),this._eventBus.on(Mn.SelectClick,this._onClick)}_currentMode=ts.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,tr.Hover)};_onClick=i=>{const e=i?.mesh??null;this._eventBus.emit(Mn.ToolSelect,{mode:this._currentMode,mesh:e}),this._handlers.get(this._currentMode)?.handle(i,tr.Click)};destroy(){this._handlers&&this._handlers.clear(),this._eventBus.off(Mn.SelectHover,this._onHover)}};ia=a_([Yt(),gc(0,zt("EventBus")),gc(1,ta("ISelectHandler"))],ia);var l_=Object.getOwnPropertyDescriptor,c_=(i,e,t,n)=>{for(var r=n>1?void 0:n?l_(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=o(r)||r);return r},vc=(i,e)=>(t,n)=>e(t,n,i);let ra=class{constructor(i,e){this._eventBus=i,this._handlers=new Map(e.map(t=>[t.mode,t])),this._currentObject=null,this._eventBus.on(Mn.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}};ra=c_([Yt(),vc(0,zt("EventBus")),vc(1,ta("IToolHandler"))],ra);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,o;s>=0;s--)(o=i[s])&&(r=o(r)||r);return r},f_=(i,e)=>(t,n)=>e(t,n,i);let sa=class{constructor(i){this._api=i}mode=er.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 bi({color:65535,linewidth:1}),r=new Co(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=[]}};sa=u_([Yt(),f_(0,zt("RendererApi"))],sa);var d_=Object.getOwnPropertyDescriptor,p_=(i,e,t,n)=>{for(var r=n>1?void 0:n?d_(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=o(r)||r);return r};let oa=class{mode=ts.Mesh;_hoveredMesh=null;_selectedMesh=null;_hoverColor=16776960;_selectColor=16755200;_defaultColor=2236962;constructor(){}handle(i,e){if(e===tr.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===tr.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)})}};oa=p_([Yt()],oa);class aa{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 m_=Object.getOwnPropertyDescriptor,__=(i,e,t,n)=>{for(var r=n>1?void 0:n?m_(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=o(r)||r);return r},g_=(i,e)=>(t,n)=>e(t,n,i);let la=class extends aa{mode=Qn.Translate;constructor(i){super(i)}};la=__([Yt(),g_(0,zt("RendererApi"))],la);var v_=Object.getOwnPropertyDescriptor,x_=(i,e,t,n)=>{for(var r=n>1?void 0:n?v_(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=o(r)||r);return r},M_=(i,e)=>(t,n)=>e(t,n,i);let ca=class extends aa{mode=Qn.Scale;constructor(i){super(i)}};ca=x_([Yt(),M_(0,zt("RendererApi"))],ca);var y_=Object.getOwnPropertyDescriptor,S_=(i,e,t,n)=>{for(var r=n>1?void 0:n?y_(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=o(r)||r);return r},E_=(i,e)=>(t,n)=>e(t,n,i);let ha=class extends aa{mode=Qn.Rotate;constructor(i){super(i)}};ha=S_([Yt(),E_(0,zt("RendererApi"))],ha);var T_=Object.getOwnPropertyDescriptor,b_=(i,e,t,n)=>{for(var r=n>1?void 0:n?T_(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 ua=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()}};ua=b_([Yt(),w_(0,zt("EditorRenderer"))],ua);var A_=Object.getOwnPropertyDescriptor,R_=(i,e,t,n)=>{for(var r=n>1?void 0:n?A_(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=o(r)||r);return r},ns=(i,e)=>(t,n)=>e(t,n,i);ht.EditorHub=class{constructor(e,t,n,r){this._displayManager=e,this._selectManager=t,this._toolManager=n,this._renderer=r,this.setSelectMode(ts.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()}},ht.EditorHub=R_([Yt(),ns(0,zt("IDisplayManager")),ns(1,zt("ISelectManager")),ns(2,zt("IToolManager")),ns(3,zt("EditorRenderer"))],ht.EditorHub);let xc=!1;const Ct=qm.createChildContainer();function C_(i){return xc||(Ct.registerInstance("Canvas",i),Ct.registerSingleton("EventBus",ht.EventBus),Ct.registerSingleton("EditorRenderer",ht.EditorRenderer),Ct.registerSingleton("RendererApi",ua),Ct.registerSingleton("IDisplayHandler",sa),Ct.registerSingleton("ISelectHandler",oa),Ct.registerSingleton("IToolHandler",la),Ct.registerSingleton("IToolHandler",ca),Ct.registerSingleton("IToolHandler",ha),Ct.registerSingleton("IDisplayManager",na),Ct.registerSingleton("ISelectManager",ia),Ct.registerSingleton("IToolManager",ra),Ct.registerSingleton("EditorHub",ht.EditorHub),xc=!0),Ct}function P_(i){return C_(i).resolve("EditorHub")}ht.EventTopics=Mn,ht.ObjLoader=n_,ht.PreviewRenderer=t_,ht.Renderer=Wo,ht.createAppHub=P_,Object.defineProperty(ht,Symbol.toStringTag,{value:"Module"})}));
3866
+ ***************************************************************************** */var Il=function(n,e){return Il=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var r in i)i.hasOwnProperty(r)&&(t[r]=i[r])},Il(n,e)};function Nl(n,e){Il(n,e);function t(){this.constructor=n}n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function s0(n,e,t,i){function r(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(u){try{c(i.next(u))}catch(h){o(h)}}function l(u){try{c(i.throw(u))}catch(h){o(h)}}function c(u){u.done?s(u.value):r(u.value).then(a,l)}c((i=i.apply(n,[])).next())})}function o0(n,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(c){return function(u){return l([c,u])}}function l(c){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,r&&(s=c[0]&2?r.return:c[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,c[1])).done)return s;switch(r=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,r=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){t.label=c[1];break}if(c[0]===6&&t.label<s[1]){t.label=s[1],s=c;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(c);break}s[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(n,t)}catch(u){c=[6,u],r=0}finally{i=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function ho(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function fo(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,s=[],o;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return s}function zi(){for(var n=[],e=0;e<arguments.length;e++)n=n.concat(fo(arguments[e]));return n}var Ul="injectionTokens";function a0(n){var e=Reflect.getMetadata("design:paramtypes",n)||[],t=Reflect.getOwnMetadata(Ul,n)||{};return Object.keys(t).forEach(function(i){e[+i]=t[i]}),e}function Th(n,e){return function(t,i,r){var s=Reflect.getOwnMetadata(Ul,t)||{};s[r]=n,Reflect.defineMetadata(Ul,s,t)}}function wh(n){return!!n.useClass}function Fl(n){return!!n.useFactory}var Ah=(function(){function n(e){this.wrap=e,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}return n.prototype.createProxy=function(e){var t=this,i={},r=!1,s,o=function(){return r||(s=e(t.wrap()),r=!0),s};return new Proxy(i,this.createHandler(o))},n.prototype.createHandler=function(e){var t={},i=function(r){t[r]=function(){for(var s=[],o=0;o<arguments.length;o++)s[o]=arguments[o];s[0]=e();var a=Reflect[r];return a.apply(void 0,zi(s))}};return this.reflectMethods.forEach(i),t},n})();function Ar(n){return typeof n=="string"||typeof n=="symbol"}function l0(n){return typeof n=="object"&&"token"in n&&"multiple"in n}function Rh(n){return typeof n=="object"&&"token"in n&&"transform"in n}function c0(n){return typeof n=="function"||n instanceof Ah}function po(n){return!!n.useToken}function mo(n){return n.useValue!=null}function u0(n){return wh(n)||mo(n)||po(n)||Fl(n)}var Bl=(function(){function n(){this._registryMap=new Map}return n.prototype.entries=function(){return this._registryMap.entries()},n.prototype.getAll=function(e){return this.ensure(e),this._registryMap.get(e)},n.prototype.get=function(e){this.ensure(e);var t=this._registryMap.get(e);return t[t.length-1]||null},n.prototype.set=function(e,t){this.ensure(e),this._registryMap.get(e).push(t)},n.prototype.setAll=function(e,t){this._registryMap.set(e,t)},n.prototype.has=function(e){return this.ensure(e),this._registryMap.get(e).length>0},n.prototype.clear=function(){this._registryMap.clear()},n.prototype.ensure=function(e){this._registryMap.has(e)||this._registryMap.set(e,[])},n})(),h0=(function(n){Nl(e,n);function e(){return n!==null&&n.apply(this,arguments)||this}return e})(Bl),_o=(function(){function n(){this.scopedResolutions=new Map}return n})();function f0(n,e){if(n===null)return"at position #"+e;var t=n.split(",")[e].trim();return'"'+t+'" at position #'+e}function d0(n,e,t){return t===void 0&&(t=" "),zi([n],e.message.split(`
3867
+ `).map(function(i){return t+i})).join(`
3868
+ `)}function p0(n,e,t){var i=fo(n.toString().match(/constructor\(([\w, ]+)\)/)||[],2),r=i[1],s=r===void 0?null:r,o=f0(s,e);return d0("Cannot inject the dependency "+o+' of "'+n.name+'" constructor. Reason:',t)}function m0(n){if(typeof n.dispose!="function")return!1;var e=n.dispose;return!(e.length>0)}var _0=(function(n){Nl(e,n);function e(){return n!==null&&n.apply(this,arguments)||this}return e})(Bl),g0=(function(n){Nl(e,n);function e(){return n!==null&&n.apply(this,arguments)||this}return e})(Bl),v0=(function(){function n(){this.preResolution=new _0,this.postResolution=new g0}return n})(),Ch=new Map,x0=(function(){function n(e){this.parent=e,this._registry=new h0,this.interceptors=new v0,this.disposed=!1,this.disposables=new Set}return n.prototype.register=function(e,t,i){i===void 0&&(i={lifecycle:Xt.Transient}),this.ensureNotDisposed();var r;if(u0(t)?r=t:r={useClass:t},po(r))for(var s=[e],o=r;o!=null;){var a=o.useToken;if(s.includes(a))throw new Error("Token registration cycle detected! "+zi(s,[a]).join(" -> "));s.push(a);var l=this._registry.get(a);l&&po(l.provider)?o=l.provider:o=null}if((i.lifecycle===Xt.Singleton||i.lifecycle==Xt.ContainerScoped||i.lifecycle==Xt.ResolutionScoped)&&(mo(r)||Fl(r)))throw new Error('Cannot use lifecycle "'+Xt[i.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:r,options:i}),this},n.prototype.registerType=function(e,t){return this.ensureNotDisposed(),Ar(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})},n.prototype.registerInstance=function(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})},n.prototype.registerSingleton=function(e,t){if(this.ensureNotDisposed(),Ar(e)){if(Ar(t))return this.register(e,{useToken:t},{lifecycle:Xt.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:Xt.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var i=e;return t&&!Ar(t)&&(i=t),this.register(e,{useClass:i},{lifecycle:Xt.Singleton})},n.prototype.resolve=function(e,t,i){t===void 0&&(t=new _o),i===void 0&&(i=!1),this.ensureNotDisposed();var r=this.getRegistration(e);if(!r&&Ar(e)){if(i)return;throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"')}if(this.executePreResolutionInterceptor(e,"Single"),r){var s=this.resolveRegistration(r,t);return this.executePostResolutionInterceptor(e,s,"Single"),s}if(c0(e)){var s=this.construct(e,t);return this.executePostResolutionInterceptor(e,s,"Single"),s}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")},n.prototype.executePreResolutionInterceptor=function(e,t){var i,r;if(this.interceptors.preResolution.has(e)){var s=[];try{for(var o=ho(this.interceptors.preResolution.getAll(e)),a=o.next();!a.done;a=o.next()){var l=a.value;l.options.frequency!="Once"&&s.push(l),l.callback(e,t)}}catch(c){i={error:c}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}this.interceptors.preResolution.setAll(e,s)}},n.prototype.executePostResolutionInterceptor=function(e,t,i){var r,s;if(this.interceptors.postResolution.has(e)){var o=[];try{for(var a=ho(this.interceptors.postResolution.getAll(e)),l=a.next();!l.done;l=a.next()){var c=l.value;c.options.frequency!="Once"&&o.push(c),c.callback(e,t,i)}}catch(u){r={error:u}}finally{try{l&&!l.done&&(s=a.return)&&s.call(a)}finally{if(r)throw r.error}}this.interceptors.postResolution.setAll(e,o)}},n.prototype.resolveRegistration=function(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===Xt.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var i=e.options.lifecycle===Xt.Singleton,r=e.options.lifecycle===Xt.ContainerScoped,s=i||r,o;return mo(e.provider)?o=e.provider.useValue:po(e.provider)?o=s?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):wh(e.provider)?o=s?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):Fl(e.provider)?o=e.provider.useFactory(this):o=this.construct(e.provider,t),e.options.lifecycle===Xt.ResolutionScoped&&t.scopedResolutions.set(e,o),o},n.prototype.resolveAll=function(e,t,i){var r=this;t===void 0&&(t=new _o),i===void 0&&(i=!1),this.ensureNotDisposed();var s=this.getAllRegistrations(e);if(!s&&Ar(e)){if(i)return[];throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"')}if(this.executePreResolutionInterceptor(e,"All"),s){var o=s.map(function(l){return r.resolveRegistration(l,t)});return this.executePostResolutionInterceptor(e,o,"All"),o}var a=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,a,"All"),a},n.prototype.isRegistered=function(e,t){return t===void 0&&(t=!1),this.ensureNotDisposed(),this._registry.has(e)||t&&(this.parent||!1)&&this.parent.isRegistered(e,!0)},n.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},n.prototype.clearInstances=function(){var e,t;this.ensureNotDisposed();try{for(var i=ho(this._registry.entries()),r=i.next();!r.done;r=i.next()){var s=fo(r.value,2),o=s[0],a=s[1];this._registry.setAll(o,a.filter(function(l){return!mo(l.provider)}).map(function(l){return l.instance=void 0,l}))}}catch(l){e={error:l}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}},n.prototype.createChildContainer=function(){var e,t;this.ensureNotDisposed();var i=new n(this);try{for(var r=ho(this._registry.entries()),s=r.next();!s.done;s=r.next()){var o=fo(s.value,2),a=o[0],l=o[1];l.some(function(c){var u=c.options;return u.lifecycle===Xt.ContainerScoped})&&i._registry.setAll(a,l.map(function(c){return c.options.lifecycle===Xt.ContainerScoped?{provider:c.provider,options:c.options}:c}))}}catch(c){e={error:c}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return i},n.prototype.beforeResolution=function(e,t,i){i===void 0&&(i={frequency:"Always"}),this.interceptors.preResolution.set(e,{callback:t,options:i})},n.prototype.afterResolution=function(e,t,i){i===void 0&&(i={frequency:"Always"}),this.interceptors.postResolution.set(e,{callback:t,options:i})},n.prototype.dispose=function(){return s0(this,void 0,void 0,function(){var e;return o0(this,function(t){switch(t.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach(function(i){var r=i.dispose();r&&e.push(r)}),[4,Promise.all(e)];case 1:return t.sent(),[2]}})})},n.prototype.getRegistration=function(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null},n.prototype.getAllRegistrations=function(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null},n.prototype.construct=function(e,t){var i=this;if(e instanceof Ah)return e.createProxy(function(s){return i.resolve(s,t)});var r=(function(){var s=Ch.get(e);if(!s||s.length===0){if(e.length===0)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var o=s.map(i.resolveParams(t,e));return new(e.bind.apply(e,zi([void 0],o)))})();return m0(r)&&this.disposables.add(r),r},n.prototype.resolveParams=function(e,t){var i=this;return function(r,s){var o,a,l;try{return l0(r)?Rh(r)?r.multiple?(o=i.resolve(r.transform)).transform.apply(o,zi([i.resolveAll(r.token,new _o,r.isOptional)],r.transformArgs)):(a=i.resolve(r.transform)).transform.apply(a,zi([i.resolve(r.token,e,r.isOptional)],r.transformArgs)):r.multiple?i.resolveAll(r.token,new _o,r.isOptional):i.resolve(r.token,e,r.isOptional):Rh(r)?(l=i.resolve(r.transform,e)).transform.apply(l,zi([i.resolve(r.token,e)],r.transformArgs)):i.resolve(r,e)}catch(c){throw new Error(p0(t,s,c))}}},n.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},n})(),y0=new x0;function dt(n,e){var t={token:n,multiple:!1,isOptional:e};return Th(t)}function zt(n){return function(e){Ch.set(e,a0(e))}}function zl(n,e){var t={token:n,multiple:!0,isOptional:e};return Th(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 go={exports:{}},Ph;function M0(){if(Ph)return go.exports;Ph=1;var n=typeof Reflect=="object"?Reflect:null,e=n&&typeof n.apply=="function"?n.apply:function(S,b,A){return Function.prototype.apply.call(S,b,A)},t;n&&typeof n.ownKeys=="function"?t=n.ownKeys:Object.getOwnPropertySymbols?t=function(S){return Object.getOwnPropertyNames(S).concat(Object.getOwnPropertySymbols(S))}:t=function(S){return Object.getOwnPropertyNames(S)};function i(_){console&&console.warn&&console.warn(_)}var r=Number.isNaN||function(S){return S!==S};function s(){s.init.call(this)}go.exports=s,go.exports.once=f,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a(_){if(typeof _!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof _)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(_){if(typeof _!="number"||_<0||r(_))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+_+".");o=_}}),s.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(S){if(typeof S!="number"||S<0||r(S))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+S+".");return this._maxListeners=S,this};function l(_){return _._maxListeners===void 0?s.defaultMaxListeners:_._maxListeners}s.prototype.getMaxListeners=function(){return l(this)},s.prototype.emit=function(S){for(var b=[],A=1;A<arguments.length;A++)b.push(arguments[A]);var C=S==="error",M=this._events;if(M!==void 0)C=C&&M.error===void 0;else if(!C)return!1;if(C){var x;if(b.length>0&&(x=b[0]),x instanceof Error)throw x;var N=new Error("Unhandled error."+(x?" ("+x.message+")":""));throw N.context=x,N}var z=M[S];if(z===void 0)return!1;if(typeof z=="function")e(z,this,b);else for(var Y=z.length,q=g(z,Y),A=0;A<Y;++A)e(q[A],this,b);return!0};function c(_,S,b,A){var C,M,x;if(a(b),M=_._events,M===void 0?(M=_._events=Object.create(null),_._eventsCount=0):(M.newListener!==void 0&&(_.emit("newListener",S,b.listener?b.listener:b),M=_._events),x=M[S]),x===void 0)x=M[S]=b,++_._eventsCount;else if(typeof x=="function"?x=M[S]=A?[b,x]:[x,b]:A?x.unshift(b):x.push(b),C=l(_),C>0&&x.length>C&&!x.warned){x.warned=!0;var N=new Error("Possible EventEmitter memory leak detected. "+x.length+" "+String(S)+" listeners added. Use emitter.setMaxListeners() to increase limit");N.name="MaxListenersExceededWarning",N.emitter=_,N.type=S,N.count=x.length,i(N)}return _}s.prototype.addListener=function(S,b){return c(this,S,b,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(S,b){return c(this,S,b,!0)};function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(_,S,b){var A={fired:!1,wrapFn:void 0,target:_,type:S,listener:b},C=u.bind(A);return C.listener=b,A.wrapFn=C,C}s.prototype.once=function(S,b){return a(b),this.on(S,h(this,S,b)),this},s.prototype.prependOnceListener=function(S,b){return a(b),this.prependListener(S,h(this,S,b)),this},s.prototype.removeListener=function(S,b){var A,C,M,x,N;if(a(b),C=this._events,C===void 0)return this;if(A=C[S],A===void 0)return this;if(A===b||A.listener===b)--this._eventsCount===0?this._events=Object.create(null):(delete C[S],C.removeListener&&this.emit("removeListener",S,A.listener||b));else if(typeof A!="function"){for(M=-1,x=A.length-1;x>=0;x--)if(A[x]===b||A[x].listener===b){N=A[x].listener,M=x;break}if(M<0)return this;M===0?A.shift():y(A,M),A.length===1&&(C[S]=A[0]),C.removeListener!==void 0&&this.emit("removeListener",S,N||b)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(S){var b,A,C;if(A=this._events,A===void 0)return this;if(A.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):A[S]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete A[S]),this;if(arguments.length===0){var M=Object.keys(A),x;for(C=0;C<M.length;++C)x=M[C],x!=="removeListener"&&this.removeAllListeners(x);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(b=A[S],typeof b=="function")this.removeListener(S,b);else if(b!==void 0)for(C=b.length-1;C>=0;C--)this.removeListener(S,b[C]);return this};function d(_,S,b){var A=_._events;if(A===void 0)return[];var C=A[S];return C===void 0?[]:typeof C=="function"?b?[C.listener||C]:[C]:b?m(C):g(C,C.length)}s.prototype.listeners=function(S){return d(this,S,!0)},s.prototype.rawListeners=function(S){return d(this,S,!1)},s.listenerCount=function(_,S){return typeof _.listenerCount=="function"?_.listenerCount(S):p.call(_,S)},s.prototype.listenerCount=p;function p(_){var S=this._events;if(S!==void 0){var b=S[_];if(typeof b=="function")return 1;if(b!==void 0)return b.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function g(_,S){for(var b=new Array(S),A=0;A<S;++A)b[A]=_[A];return b}function y(_,S){for(;S+1<_.length;S++)_[S]=_[S+1];_.pop()}function m(_){for(var S=new Array(_.length),b=0;b<S.length;++b)S[b]=_[b].listener||_[b];return S}function f(_,S){return new Promise(function(b,A){function C(x){_.removeListener(S,M),A(x)}function M(){typeof _.removeListener=="function"&&_.removeListener("error",C),b([].slice.call(arguments))}T(_,S,M,{once:!0}),S!=="error"&&w(_,C,{once:!0})})}function w(_,S,b){typeof _.on=="function"&&T(_,"error",S,b)}function T(_,S,b,A){if(typeof _.on=="function")A.once?_.once(S,b):_.on(S,b);else if(typeof _.addEventListener=="function")_.addEventListener(S,function C(M){A.once&&_.removeEventListener(S,C),b(M)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof _)}return go.exports}var E0=M0(),b0=Object.getOwnPropertyDescriptor,S0=(n,e,t,i)=>{for(var r=i>1?void 0:i?b0(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r};_t.EventBus=class{_emitter;constructor(){this._emitter=new E0.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)}},_t.EventBus=S0([zt()],_t.EventBus);var Vi=(n=>(n.SelectHover="select.hover",n.SelectClick="select.click",n.ToolSelect="tool.select",n))(Vi||{});class T0{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 Dh=(n=>(n[n.Cube=0]="Cube",n[n.Sphere=1]="Sphere",n[n.Plane=2]="Plane",n[n.Cylinder=3]="Cylinder",n[n.Custom=4]="Custom",n))(Dh||{}),Rr=(n=>(n.Plane="plane",n.Wireframe="wireframe",n.Texture="texture",n))(Rr||{}),ln=(n=>(n.Mesh="mesh",n.Face="face",n.Edge="edge",n.Vertex="vertex",n))(ln||{}),mi=(n=>(n.Translate="translate",n.Scale="scale",n.Rotate="rotate",n))(mi||{});const w0=.03,A0=10;var R0=Object.getOwnPropertyDescriptor,C0=(n,e,t,i)=>{for(var r=i>1?void 0:i?R0(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r},Lh=(n,e)=>(t,i)=>e(t,i,n);_t.EditorRenderer=class extends Rl{constructor(e,t){super(e),this._canvas=e,this._bus=t;const i=new Dp(10,10);i.position.y=-.001,this.scene.add(i);const r=new $v(6);this.scene.add(r),this._orbit=new qv(this.camera,this.renderer.domElement),this._orbit.enableDamping=!0,this._orbit.dampingFactor=.05,this._raycaster=new Iu,this._mouse=new Ne,this.scene.add(new Tp(16777215,4473924,.6)),this.camera.layers.enable(0),this.camera.layers.enable(1),this._transform=new Zv(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);t.layers.enable(0);const i=new yp(t.geometry),r=new dl(i,new Di({color:8947848,linewidth:1}));return r.layers.set(1),t.add(r),this._isEventListenersAdded||this._initMouseListeners(),t}setTransformControlsMode(e){this._transform.setMode(e)}attachTransformControls(e){this._transform.attach(e)}detachTransformControls(){this._transform.detach()}setRaycastMode(e){const t=this._raycaster;switch(t.params.Line.threshold=0,t.params.Points.threshold=0,e){case ln.Mesh:case ln.Face:t.layers.set(0);break;case ln.Edge:t.layers.set(1),t.params.Line.threshold=w0;break;case ln.Vertex:t.layers.set(2),t.params.Points.threshold=A0;break}}dispose(){this._isEventListenersAdded&&(this.canvas.removeEventListener("mousemove",this._handleMouseMove,!1),this.canvas.removeEventListener("click",this._handleMouseClick,!1),this.canvas.removeEventListener("pointerdown",e=>this._transform.pointerDown(e)),this.canvas.removeEventListener("pointermove",e=>this._transform.pointerMove(e)),this.canvas.removeEventListener("pointerup",e=>this._transform.pointerUp(e)),this.canvas.removeEventListener("pointerleave",()=>this._transform.pointerHover(null)),this._transform.removeEventListener("dragging-changed",()=>{this._orbit.enabled=!this._transform.dragging}),this._isEventListenersAdded=!1),this._orbit?.dispose(),this._transform?.dispose(),this._transformHelper?.parent&&this._transformHelper.parent.remove(this._transformHelper),this._lastHovered=null,super.dispose()}_initMouseListeners(){this.canvas.addEventListener("mousemove",this._handleMouseMove,!1),this.canvas.addEventListener("click",this._handleMouseClick,!1),this.canvas.addEventListener("pointerdown",e=>this._transform.pointerDown(e)),this.canvas.addEventListener("pointermove",e=>this._transform.pointerMove(e)),this.canvas.addEventListener("pointerup",e=>this._transform.pointerUp(e)),this.canvas.addEventListener("pointerleave",()=>this._transform.pointerHover(null)),this._transform.addEventListener("dragging-changed",()=>{this._orbit.enabled=!this._transform.dragging}),this._isEventListenersAdded=!0}_handleMouseMove=e=>{this._processRaycastEvent(e,Vi.SelectHover,!0)};_handleMouseClick=e=>{this._processRaycastEvent(e,Vi.SelectClick,!1)};_processRaycastEvent(e,t,i){if(this._orbit.isInteracting||this._transform.dragging)return;const r=this._canvas.getBoundingClientRect();this._mouse.x=(e.clientX-r.left)/r.width*2-1,this._mouse.y=-((e.clientY-r.top)/r.height)*2+1,this._raycaster.setFromCamera(this._mouse,this.camera);const o=this._raycaster.intersectObjects(this.meshes,!0)[0]??null,a=o?.object??null;i?a!==this._lastHovered&&(this.meshes.forEach(l=>l.userData.isHit=!1),a&&(a.userData.isHit=!0),this._lastHovered=a,this._bus.emit(t,o?{intersection:o}:null)):this._bus.emit(t,o?{intersection:o}:null)}},_t.EditorRenderer=C0([zt(),Lh(0,dt("Canvas")),Lh(1,dt("EventBus"))],_t.EditorRenderer);class P0 extends Rl{_orbit;constructor(e){super(e),this.camera.position.set(1,1,7),this.camera.lookAt(0,0,0),this._orbit=new gh(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 D0{_positions=[];_normals=[];_uvs=[];_tmpPositions=[];_tmpNormals=[];_tmpUVs=[];load(e){const t=e.split(`
3869
+ `);for(const r of t){if(!r.trim()||r.startsWith("#"))continue;const s=r.trim().split(/\s+/);switch(s[0]){case"v":this._tmpPositions.push(s.slice(1).map(Number));break;case"vn":this._tmpNormals.push(s.slice(1).map(Number));break;case"vt":this._tmpUVs.push(s.slice(1).map(Number));break;case"f":this.processFaceLine(s);break}}const i={type:Dh.Custom,position:this._positions,...this._normals.length>0&&{normal:this._normals},...this._uvs.length>0&&{uv:this._uvs}};return new T0(i)}processFaceLine(e){for(let t=1;t<e.length;t++){const i=e[t];if(!i)continue;const[r,s,o]=i.split("/"),a=r?parseInt(r,10):void 0,l=s?parseInt(s,10):void 0,c=o?parseInt(o,10):void 0;if(a!==void 0){const u=this._tmpPositions[a-1];u&&this._positions.push(...u)}if(l!==void 0){const u=this._tmpUVs[l-1];u&&this._uvs.push(...u)}if(c!==void 0){const u=this._tmpNormals[c-1];u&&this._normals.push(...u)}}}}var L0=Object.getOwnPropertyDescriptor,O0=(n,e,t,i)=>{for(var r=i>1?void 0:i?L0(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r},Oh=(n,e)=>(t,i)=>e(t,i,n);let Vl=class{constructor(n,e){this._store=e,this._handlers=new Map(n.map(t=>[t.mode,t]))}_currentMode=Rr.Plane;_handlers;manage(n){n!==this._currentMode&&(this._handlers.get(this._currentMode)?.rollback(),n!==Rr.Plane&&this._handlers.get(n)?.handle(),this._currentMode=n,this._store.setDisplayMode(this._currentMode))}dispose(){this._handlers&&this._handlers.clear(),this._currentMode=Rr.Plane,this._store.setDisplayMode(this._currentMode)}};Vl=O0([zt(),Oh(0,zl("IDisplayHandler")),Oh(1,dt("IEditorStore"))],Vl);var Kn=(n=>(n.Hover="hover",n.Click="click",n))(Kn||{}),I0=Object.getOwnPropertyDescriptor,N0=(n,e,t,i)=>{for(var r=i>1?void 0:i?I0(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r},Hl=(n,e)=>(t,i)=>e(t,i,n);let kl=class{constructor(n,e,t){this._eventBus=n,this._store=t,this._handlers=new Map(e.map(i=>[i.mode,i])),this._eventBus.on(Vi.SelectHover,this._onHover),this._eventBus.on(Vi.SelectClick,this._onClick)}_currentMode=ln.Mesh;_handlers;manage(n){n!==this._currentMode&&(this._handlers.get(this._currentMode)?.rollback(),this._currentMode=n,this._store.setSelectMode(this._currentMode))}_onHover=n=>{this._handlers.get(this._currentMode)?.handle(n,Kn.Hover)};_onClick=n=>{this._handlers.get(this._currentMode)?.handle(n,Kn.Click)};dispose(){this._handlers&&this._handlers.clear(),this._eventBus.off(Vi.SelectHover,this._onHover),this._currentMode=ln.Mesh,this._store.setSelectMode(this._currentMode)}};kl=N0([zt(),Hl(0,dt("EventBus")),Hl(1,zl("ISelectHandler")),Hl(2,dt("IEditorStore"))],kl);var U0=Object.getOwnPropertyDescriptor,F0=(n,e,t,i)=>{for(var r=i>1?void 0:i?U0(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r},Ih=(n,e)=>(t,i)=>e(t,i,n);let Gl=class{constructor(n,e){this._store=e,this._handlers=new Map(n.map(t=>[t.mode,t])),this._unsubSelected=this._store.onSelectedObjectChange(()=>{this._handlers.get(this._currentTool)?.handle()})}_currentTool=mi.Translate;_handlers;_unsubSelected;manage(n){this._currentTool!==n&&(this._handlers.get(this._currentTool)?.rollback(),this._currentTool=n,this._store.setToolType(this._currentTool),this._handlers.get(this._currentTool)?.handle())}dispose(){this._unsubSelected?.(),this._handlers&&this._handlers.clear(),this._currentTool=mi.Translate,this._store.setToolType(this._currentTool)}};Gl=F0([zt(),Ih(0,zl("IToolHandler")),Ih(1,dt("IEditorStore"))],Gl);var B0=Object.getOwnPropertyDescriptor,z0=(n,e,t,i)=>{for(var r=i>1?void 0:i?B0(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r},V0=(n,e)=>(t,i)=>e(t,i,n);let Wl=class{constructor(n){this._api=n}mode=Rr.Wireframe;_wireframes=[];handle(){const n=this._api.getMeshes();this._wireframes.length>0||(this._wireframes=n.map(e=>{const t=new Mp(e.geometry),i=new Di({color:65535,linewidth:1}),r=new dl(t,i);return r.position.copy(e.position),r.rotation.copy(e.rotation),r.scale.copy(e.scale),e.add(r),r}),n.forEach(e=>{const t=e.material;t.visible=!1}))}rollback(){const n=this._api.getMeshes();for(const e of n){const t=this._wireframes.find(r=>r.parent===e);t&&(e.remove(t),t.geometry.dispose(),t.material.dispose());const i=e.material;i.visible=!0}this._wireframes=[]}dispose(){for(const n of this._wireframes)n.geometry.dispose(),n.material.dispose();this._wireframes=[]}};Wl=z0([zt(),V0(0,dt("RendererApi"))],Wl);const Xl=16776960,jl=16755200;var H0=Object.getOwnPropertyDescriptor,k0=(n,e,t,i)=>{for(var r=i>1?void 0:i?H0(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r},Nh=(n,e)=>(t,i)=>e(t,i,n);let Yl=class{constructor(n,e){this._api=n,this._store=e}mode=ln.Mesh;_hoveredMesh=null;_selectedMesh=null;_hoverColor=Xl;_selectColor=jl;_defaultColor=2236962;handle(n,e){if(this._api.setRaycastMode(this.mode),e===Kn.Hover){if(!n){this._hoveredMesh&&this._hoveredMesh!==this._selectedMesh&&this._setEdgesColor(this._hoveredMesh,this._defaultColor),this._hoveredMesh=null;return}const t=n.intersection.object;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)}if(e===Kn.Click){if(!n){this._selectedMesh&&(this._setEdgesColor(this._selectedMesh,this._defaultColor),this._selectedMesh=null,this._store.setSelectedObject(null));return}const t=n.intersection.object;this._selectedMesh&&this._selectedMesh!==t&&this._setEdgesColor(this._selectedMesh,this._defaultColor),this._setEdgesColor(t,this._selectColor),this._selectedMesh=t,this._store.setSelectedObject(t)}}rollback(){this._hoveredMesh&&this._setEdgesColor(this._hoveredMesh,this._defaultColor),this._selectedMesh&&this._setEdgesColor(this._selectedMesh,this._defaultColor),this._hoveredMesh=this._selectedMesh=null}dispose(){this.rollback()}_setEdgesColor(n,e){n.children.forEach(t=>{t.type==="LineSegments"&&t.material.color.setHex(e)})}};Yl=k0([zt(),Nh(0,dt("RendererApi")),Nh(1,dt("IEditorStore"))],Yl);var G0=Object.getOwnPropertyDescriptor,W0=(n,e,t,i)=>{for(var r=i>1?void 0:i?G0(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r},X0=(n,e)=>(t,i)=>e(t,i,n);let ql=class{constructor(n){this._api=n}mode=ln.Face;_hovered=null;_selected=null;_hoverColor=Xl;_selectColor=jl;_defaultColor=2236962;handle(n,e){this._api.setRaycastMode(this.mode),e===Kn.Hover&&console.log(n),e===Kn.Click&&console.log(n)}rollback(){throw new Error("Method not implemented.")}dispose(){throw new Error("Method not implemented.")}};ql=W0([zt(),X0(0,dt("RendererApi"))],ql);class $l{constructor(e,t){this.api=e,this.store=t}handle(){const e=this.store.getSelectedObject();this.api.setMode(this.mode),e?this.api.attach(e):this.api.detach()}rollback(){this.api.detach()}dispose(){this.rollback()}}var j0=Object.getOwnPropertyDescriptor,Y0=(n,e,t,i)=>{for(var r=i>1?void 0:i?j0(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r},Uh=(n,e)=>(t,i)=>e(t,i,n);let Zl=class extends $l{mode=mi.Translate;constructor(n,e){super(n,e)}};Zl=Y0([zt(),Uh(0,dt("RendererApi")),Uh(1,dt("IEditorStore"))],Zl);var q0=Object.getOwnPropertyDescriptor,$0=(n,e,t,i)=>{for(var r=i>1?void 0:i?q0(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r},Fh=(n,e)=>(t,i)=>e(t,i,n);let Kl=class extends $l{mode=mi.Scale;constructor(n,e){super(n,e)}};Kl=$0([zt(),Fh(0,dt("RendererApi")),Fh(1,dt("IEditorStore"))],Kl);var Z0=Object.getOwnPropertyDescriptor,K0=(n,e,t,i)=>{for(var r=i>1?void 0:i?Z0(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r},Bh=(n,e)=>(t,i)=>e(t,i,n);let Jl=class extends $l{mode=mi.Rotate;constructor(n,e){super(n,e)}};Jl=K0([zt(),Bh(0,dt("RendererApi")),Bh(1,dt("IEditorStore"))],Jl);const vo=31;var J0=Object.getOwnPropertyDescriptor,Q0=(n,e,t,i)=>{for(var r=i>1?void 0:i?J0(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r},zh=(n,e)=>(t,i)=>e(t,i,n);let Ql=class{constructor(n,e){this._api=n,this._store=e,this._api.enableCameraLayer(vo),this._hoverLine=this._makeOverlayLine(this._hoverColor),this._selectLine=this._makeOverlayLine(this._selectColor),this._api.addObject(this._hoverLine,vo),this._api.addObject(this._selectLine,vo)}mode=ln.Edge;_hoverLine;_selectLine;_hovered=null;_selected=null;_hoverColor=Xl;_selectColor=jl;handle(n,e){if(this._api.setRaycastMode(this.mode),e===Kn.Hover){if(!n){this._hoverLine.visible=!1,this._hovered=null;return}const t=n.intersection.object;if(!t?.isLineSegments)return;const i=t,r=Math.floor((n.intersection.index??-1)/2);if(r<0)return;this._selected&&this._same({lines:i,seg:r},this._selected)?this._hoverLine.visible=!1:(this._writeWorldSegment(this._hoverLine,i,r),this._hoverLine.visible=!0),this._hovered={lines:i,seg:r};return}if(e===Kn.Click){if(!n){this._selectLine.visible=!1,this._selected=null,this._store.setSelectedObject(null);return}const t=n.intersection.object;if(!t?.isLineSegments)return;const i=t,r=Math.floor((n.intersection.index??-1)/2);if(r<0)return;this._writeWorldSegment(this._selectLine,i,r),this._centerAndOrientLineOnSegment(this._selectLine,i,r),this._selectLine.visible=!0,this._store.setSelectedObject(this._selectLine),this._selected={lines:i,seg:r},this._hovered&&this._same(this._hovered,this._selected)&&(this._hoverLine.visible=!1)}}rollback(){this._hoverLine.visible=!1,this._selectLine.visible=!1,this._hovered=this._selected=null}dispose(){this.rollback(),this._api.removeObject(this._hoverLine),this._api.removeObject(this._selectLine),this._hoverLine.geometry.dispose(),this._hoverLine.material.dispose(),this._selectLine.geometry.dispose(),this._selectLine.material.dispose()}_makeOverlayLine(n){const e=new Et;e.setAttribute("position",new et(6,3));const t=new Di({color:n,depthTest:!1,depthWrite:!1,transparent:!0,opacity:1}),i=new Tn(e,t);return i.renderOrder=1e3,i.raycast=()=>{},i.layers.set(vo),i.visible=!1,i}_writeWorldSegment(n,e,t){const i=e.geometry.getAttribute("position"),r=t*2,s=r+1,o=new L(i.getX(r),i.getY(r),i.getZ(r)).applyMatrix4(e.matrixWorld),a=new L(i.getX(s),i.getY(s),i.getZ(s)).applyMatrix4(e.matrixWorld),l=n.geometry.getAttribute("position");l.setXYZ(0,o.x,o.y,o.z),l.setXYZ(1,a.x,a.y,a.z),l.needsUpdate=!0}_same(n,e){return!!n&&!!e&&n.lines===e.lines&&n.seg===e.seg}_centerAndOrientLineOnSegment(n,e,t){const i=e.geometry.getAttribute("position"),r=t*2,s=r+1,o=new L(i.getX(r),i.getY(r),i.getZ(r)).applyMatrix4(e.matrixWorld),a=new L(i.getX(s),i.getY(s),i.getZ(s)).applyMatrix4(e.matrixWorld),l=new L().subVectors(a,o),c=l.length();if(!isFinite(c)||c===0)return;const u=new L().addVectors(o,a).multiplyScalar(.5);n.position.copy(u);const h=n.geometry;let d=h.getAttribute("position");(!d||d.count<2)&&(h.setAttribute("position",new Sn(new Float32Array(6),3)),d=h.getAttribute("position")),d.setXYZ(0,-c/2,0,0),d.setXYZ(1,c/2,0,0),d.needsUpdate=!0,l.normalize();const p=new Ct().setFromUnitVectors(new L(1,0,0),l);n.quaternion.copy(p),n.updateMatrixWorld(!0)}};Ql=Q0([zt(),zh(0,dt("RendererApi")),zh(1,dt("IEditorStore"))],Ql);var ex=Object.getOwnPropertyDescriptor,tx=(n,e,t,i)=>{for(var r=i>1?void 0:i?ex(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r},nx=(n,e)=>(t,i)=>e(t,i,n);let ec=class{constructor(n){this._renderer=n}addMesh(n){this._renderer.addMesh(n)}addMeshes(n){for(const e of n)this._renderer.addMesh(e)}removeMesh(n){this._renderer.removeMesh(n)}removeMeshes(n){for(const e of n)this._renderer.removeMesh(e)}getMeshes(){return this._renderer.getMeshes()}setMode(n){this._renderer.setTransformControlsMode(n)}attach(n){this._renderer.attachTransformControls(n)}detach(){this._renderer.detachTransformControls()}setRaycastMode(n){this._renderer.setRaycastMode(n)}addObject(n,e){this._renderer.addObject(n,e)}removeObject(n){this._renderer.removeObject(n)}enableCameraLayer(n){this._renderer.enableCameraLayer(n)}};ec=tx([zt(),nx(0,dt("EditorRenderer"))],ec);var ix=Object.getOwnPropertyDescriptor,rx=(n,e,t,i)=>{for(var r=i>1?void 0:i?ix(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r},xo=(n,e)=>(t,i)=>e(t,i,n);_t.EditorHub=class{constructor(e,t,i,r){this._displayManager=e,this._selectManager=t,this._toolManager=i,this._renderer=r,this.setSelectMode(ln.Mesh),this.setToolMode(mi.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)}dispose(){this._displayManager.dispose(),this._selectManager.dispose(),this._renderer.dispose()}},_t.EditorHub=rx([zt(),xo(0,dt("IDisplayManager")),xo(1,dt("ISelectManager")),xo(2,dt("IToolManager")),xo(3,dt("EditorRenderer"))],_t.EditorHub);var sx={0:"Invalid value for configuration 'enforceActions', expected 'never', 'always' or 'observed'",1:function(e,t){return"Cannot apply '"+e+"' to '"+t.toString()+"': Field not found."},5:"'keys()' can only be used on observable objects, arrays, sets and maps",6:"'values()' can only be used on observable objects, arrays, sets and maps",7:"'entries()' can only be used on observable objects, arrays and maps",8:"'set()' can only be used on observable objects, arrays and maps",9:"'remove()' can only be used on observable objects, arrays and maps",10:"'has()' can only be used on observable objects, arrays and maps",11:"'get()' can only be used on observable objects, arrays and maps",12:"Invalid annotation",13:"Dynamic observable objects cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)",14:"Intercept handlers should return nothing or a change object",15:"Observable arrays cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)",16:"Modification exception: the internal structure of an observable array was changed.",17:function(e,t){return"[mobx.array] Index out of bounds, "+e+" is larger than "+t},18:"mobx.map requires Map polyfill for the current browser. Check babel-polyfill or core-js/es6/map.js",19:function(e){return"Cannot initialize from classes that inherit from Map: "+e.constructor.name},20:function(e){return"Cannot initialize map from "+e},21:function(e){return"Cannot convert to map from '"+e+"'"},22:"mobx.set requires Set polyfill for the current browser. Check babel-polyfill or core-js/es6/set.js",23:"It is not possible to get index atoms from arrays",24:function(e){return"Cannot obtain administration from "+e},25:function(e,t){return"the entry '"+e+"' does not exist in the observable map '"+t+"'"},26:"please specify a property",27:function(e,t){return"no observable property '"+e.toString()+"' found on the observable object '"+t+"'"},28:function(e){return"Cannot obtain atom from "+e},29:"Expecting some object",30:"invalid action stack. did you forget to finish an action?",31:"missing option for computed: get",32:function(e,t){return"Cycle detected in computation "+e+": "+t},33:function(e){return"The setter of computed value '"+e+"' is trying to update itself. Did you intend to update an _observable_ value, instead of the computed property?"},34:function(e){return"[ComputedValue '"+e+"'] It is not possible to assign a new value to a computed value."},35:"There are multiple, different versions of MobX active. Make sure MobX is loaded only once or use `configure({ isolateGlobalState: true })`",36:"isolateGlobalState should be called before MobX is running any reactions",37:function(e){return"[mobx] `observableArray."+e+"()` mutates the array in-place, which is not allowed inside a derivation. Use `array.slice()."+e+"()` instead"},38:"'ownKeys()' can only be used on observable objects",39:"'defineProperty()' can only be used on observable objects"},ox=process.env.NODE_ENV!=="production"?sx:{};function ve(n){for(var e=arguments.length,t=new Array(e>1?e-1:0),i=1;i<e;i++)t[i-1]=arguments[i];if(process.env.NODE_ENV!=="production"){var r=typeof n=="string"?n:ox[n];throw typeof r=="function"&&(r=r.apply(null,t)),new Error("[MobX] "+r)}throw new Error(typeof n=="number"?"[MobX] minified error nr: "+n+(t.length?" "+t.map(String).join(","):"")+". Find the full error at: https://github.com/mobxjs/mobx/blob/main/packages/mobx/src/errors.ts":"[MobX] "+n)}var ax={};function tc(){return typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:ax}var Vh=Object.assign,yo=Object.getOwnPropertyDescriptor,zn=Object.defineProperty,Mo=Object.prototype,Eo=[];Object.freeze(Eo);var Hh={};Object.freeze(Hh);var lx=typeof Proxy<"u",cx=Object.toString();function kh(){lx||ve(process.env.NODE_ENV!=="production"?"`Proxy` objects are not available in the current environment. Please configure MobX to enable a fallback implementation.`":"Proxy not available")}function as(n){process.env.NODE_ENV!=="production"&&he.verifyProxies&&ve("MobX is currently configured to be able to run in ES5 mode, but in ES5 MobX won't be able to "+n)}function wn(){return++he.mobxGuid}function nc(n){var e=!1;return function(){if(!e)return e=!0,n.apply(this,arguments)}}var Cr=function(){};function At(n){return typeof n=="function"}function Hi(n){var e=typeof n;switch(e){case"string":case"symbol":case"number":return!0}return!1}function bo(n){return n!==null&&typeof n=="object"}function $t(n){if(!bo(n))return!1;var e=Object.getPrototypeOf(n);if(e==null)return!0;var t=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t.toString()===cx}function Gh(n){var e=n?.constructor;return e?e.name==="GeneratorFunction"||e.displayName==="GeneratorFunction":!1}function So(n,e,t){zn(n,e,{enumerable:!1,writable:!0,configurable:!0,value:t})}function Wh(n,e,t){zn(n,e,{enumerable:!1,writable:!1,configurable:!0,value:t})}function ki(n,e){var t="isMobX"+n;return e.prototype[t]=!0,function(i){return bo(i)&&i[t]===!0}}function Pr(n){return n!=null&&Object.prototype.toString.call(n)==="[object Map]"}function ux(n){var e=Object.getPrototypeOf(n),t=Object.getPrototypeOf(e),i=Object.getPrototypeOf(t);return i===null}function Jn(n){return n!=null&&Object.prototype.toString.call(n)==="[object Set]"}var Xh=typeof Object.getOwnPropertySymbols<"u";function hx(n){var e=Object.keys(n);if(!Xh)return e;var t=Object.getOwnPropertySymbols(n);return t.length?[].concat(e,t.filter(function(i){return Mo.propertyIsEnumerable.call(n,i)})):e}var ls=typeof Reflect<"u"&&Reflect.ownKeys?Reflect.ownKeys:Xh?function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:Object.getOwnPropertyNames;function ic(n){return typeof n=="string"?n:typeof n=="symbol"?n.toString():new String(n).toString()}function jh(n){return n===null?null:typeof n=="object"?""+n:n}function An(n,e){return Mo.hasOwnProperty.call(n,e)}var fx=Object.getOwnPropertyDescriptors||function(e){var t={};return ls(e).forEach(function(i){t[i]=yo(e,i)}),t};function Zt(n,e){return!!(n&e)}function Kt(n,e,t){return t?n|=e:n&=~e,n}function Yh(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,i=Array(e);t<e;t++)i[t]=n[t];return i}function dx(n,e){for(var t=0;t<e.length;t++){var i=e[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(n,mx(i.key),i)}}function Dr(n,e,t){return e&&dx(n.prototype,e),Object.defineProperty(n,"prototype",{writable:!1}),n}function Lr(n,e){var t=typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t)return(t=t.call(n)).next.bind(t);if(Array.isArray(n)||(t=_x(n))||e){t&&(n=t);var i=0;return function(){return i>=n.length?{done:!0}:{done:!1,value:n[i++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
3870
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _i(){return _i=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},_i.apply(null,arguments)}function qh(n,e){n.prototype=Object.create(e.prototype),n.prototype.constructor=n,rc(n,e)}function rc(n,e){return rc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},rc(n,e)}function px(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var i=t.call(n,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}function mx(n){var e=px(n,"string");return typeof e=="symbol"?e:e+""}function _x(n,e){if(n){if(typeof n=="string")return Yh(n,e);var t={}.toString.call(n).slice(8,-1);return t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set"?Array.from(n):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Yh(n,e):void 0}}var Qn=Symbol("mobx-stored-annotations");function Vn(n){function e(t,i){if(us(i))return n.decorate_20223_(t,i);cs(t,i,n)}return Object.assign(e,n)}function cs(n,e,t){if(An(n,Qn)||So(n,Qn,_i({},n[Qn])),process.env.NODE_ENV!=="production"&&Ro(t)&&!An(n[Qn],e)){var i=n.constructor.name+".prototype."+e.toString();ve("'"+i+"' is decorated with 'override', but no such decorated member was found on prototype.")}gx(n,t,e),Ro(t)||(n[Qn][e]=t)}function gx(n,e,t){if(process.env.NODE_ENV!=="production"&&!Ro(e)&&An(n[Qn],t)){var i=n.constructor.name+".prototype."+t.toString(),r=n[Qn][t].annotationType_,s=e.annotationType_;ve("Cannot apply '@"+s+"' to '"+i+"':"+(`
3871
+ The field is already decorated with '@`+r+"'.")+`
3872
+ Re-decorating fields is not allowed.
3873
+ Use '@override' decorator for methods overridden by subclass.`)}}function us(n){return typeof n=="object"&&typeof n.kind=="string"}function To(n,e){process.env.NODE_ENV!=="production"&&!e.includes(n.kind)&&ve("The decorator applied to '"+String(n.name)+"' cannot be used on a "+n.kind+" element")}var Ue=Symbol("mobx administration"),gi=(function(){function n(t){t===void 0&&(t=process.env.NODE_ENV!=="production"?"Atom@"+wn():"Atom"),this.name_=void 0,this.flags_=0,this.observers_=new Set,this.lastAccessedBy_=0,this.lowestObserverState_=Ke.NOT_TRACKING_,this.onBOL=void 0,this.onBUOL=void 0,this.name_=t}var e=n.prototype;return e.onBO=function(){this.onBOL&&this.onBOL.forEach(function(i){return i()})},e.onBUO=function(){this.onBUOL&&this.onBUOL.forEach(function(i){return i()})},e.reportObserved=function(){return df(this)},e.reportChanged=function(){hn(),pf(this),fn()},e.toString=function(){return this.name_},Dr(n,[{key:"isBeingObserved",get:function(){return Zt(this.flags_,n.isBeingObservedMask_)},set:function(i){this.flags_=Kt(this.flags_,n.isBeingObservedMask_,i)}},{key:"isPendingUnobservation",get:function(){return Zt(this.flags_,n.isPendingUnobservationMask_)},set:function(i){this.flags_=Kt(this.flags_,n.isPendingUnobservationMask_,i)}},{key:"diffValue",get:function(){return Zt(this.flags_,n.diffValueMask_)?1:0},set:function(i){this.flags_=Kt(this.flags_,n.diffValueMask_,i===1)}}])})();gi.isBeingObservedMask_=1,gi.isPendingUnobservationMask_=2,gi.diffValueMask_=4;var sc=ki("Atom",gi);function $h(n,e,t){e===void 0&&(e=Cr),t===void 0&&(t=Cr);var i=new gi(n);return e!==Cr&&Ry(i,e),t!==Cr&&Mf(i,t),i}function vx(n,e){return Gf(n,e)}function xx(n,e){return Object.is?Object.is(n,e):n===e?n!==0||1/n===1/e:n!==n&&e!==e}var wo={structural:vx,default:xx};function Gi(n,e,t){return ms(n)?n:Array.isArray(n)?Lt.array(n,{name:t}):$t(n)?Lt.object(n,void 0,{name:t}):Pr(n)?Lt.map(n,{name:t}):Jn(n)?Lt.set(n,{name:t}):typeof n=="function"&&!qi(n)&&!ps(n)?Gh(n)?Ir(n):ds(t,n):n}function yx(n,e,t){if(n==null||Ur(n)||zo(n)||yi(n)||kn(n))return n;if(Array.isArray(n))return Lt.array(n,{name:t,deep:!1});if($t(n))return Lt.object(n,void 0,{name:t,deep:!1});if(Pr(n))return Lt.map(n,{name:t,deep:!1});if(Jn(n))return Lt.set(n,{name:t,deep:!1});process.env.NODE_ENV!=="production"&&ve("The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets")}function Ao(n){return n}function Mx(n,e){return process.env.NODE_ENV!=="production"&&ms(n)&&ve("observable.struct should not be used with observable values"),Gf(n,e)?e:n}var Ex="override";function Ro(n){return n.annotationType_===Ex}function hs(n,e){return{annotationType_:n,options_:e,make_:bx,extend_:Sx,decorate_20223_:Tx}}function bx(n,e,t,i){var r;if((r=this.options_)!=null&&r.bound)return this.extend_(n,e,t,!1)===null?0:1;if(i===n.target_)return this.extend_(n,e,t,!1)===null?0:2;if(qi(t.value))return 1;var s=Zh(n,this,e,t,!1);return zn(i,e,s),2}function Sx(n,e,t,i){var r=Zh(n,this,e,t);return n.defineProperty_(e,r,i)}function Tx(n,e){process.env.NODE_ENV!=="production"&&To(e,["method","field"]);var t=e.kind,i=e.name,r=e.addInitializer,s=this,o=function(c){var u,h,d,p;return Wi((u=(h=s.options_)==null?void 0:h.name)!=null?u:i.toString(),c,(d=(p=s.options_)==null?void 0:p.autoAction)!=null?d:!1)};if(t=="field")return function(l){var c,u=l;return qi(u)||(u=o(u)),(c=s.options_)!=null&&c.bound&&(u=u.bind(this),u.isMobxAction=!0),u};if(t=="method"){var a;return qi(n)||(n=o(n)),(a=this.options_)!=null&&a.bound&&r(function(){var l=this,c=l[i].bind(l);c.isMobxAction=!0,l[i]=c}),n}ve("Cannot apply '"+s.annotationType_+"' to '"+String(i)+"' (kind: "+t+"):"+(`
3874
+ '`+s.annotationType_+"' can only be used on properties with a function value."))}function wx(n,e,t,i){var r=e.annotationType_,s=i.value;process.env.NODE_ENV!=="production"&&!At(s)&&ve("Cannot apply '"+r+"' to '"+n.name_+"."+t.toString()+"':"+(`
3875
+ '`+r+"' can only be used on properties with a function value."))}function Zh(n,e,t,i,r){var s,o,a,l,c,u,h;r===void 0&&(r=he.safeDescriptors),wx(n,e,t,i);var d=i.value;if((s=e.options_)!=null&&s.bound){var p;d=d.bind((p=n.proxy_)!=null?p:n.target_)}return{value:Wi((o=(a=e.options_)==null?void 0:a.name)!=null?o:t.toString(),d,(l=(c=e.options_)==null?void 0:c.autoAction)!=null?l:!1,(u=e.options_)!=null&&u.bound?(h=n.proxy_)!=null?h:n.target_:void 0),configurable:r?n.isPlainObject_:!0,enumerable:!1,writable:!r}}function Kh(n,e){return{annotationType_:n,options_:e,make_:Ax,extend_:Rx,decorate_20223_:Cx}}function Ax(n,e,t,i){var r;if(i===n.target_)return this.extend_(n,e,t,!1)===null?0:2;if((r=this.options_)!=null&&r.bound&&(!An(n.target_,e)||!ps(n.target_[e]))&&this.extend_(n,e,t,!1)===null)return 0;if(ps(t.value))return 1;var s=Jh(n,this,e,t,!1,!1);return zn(i,e,s),2}function Rx(n,e,t,i){var r,s=Jh(n,this,e,t,(r=this.options_)==null?void 0:r.bound);return n.defineProperty_(e,s,i)}function Cx(n,e){var t;process.env.NODE_ENV!=="production"&&To(e,["method"]);var i=e.name,r=e.addInitializer;return ps(n)||(n=Ir(n)),(t=this.options_)!=null&&t.bound&&r(function(){var s=this,o=s[i].bind(s);o.isMobXFlow=!0,s[i]=o}),n}function Px(n,e,t,i){var r=e.annotationType_,s=i.value;process.env.NODE_ENV!=="production"&&!At(s)&&ve("Cannot apply '"+r+"' to '"+n.name_+"."+t.toString()+"':"+(`
3876
+ '`+r+"' can only be used on properties with a generator function value."))}function Jh(n,e,t,i,r,s){s===void 0&&(s=he.safeDescriptors),Px(n,e,t,i);var o=i.value;if(ps(o)||(o=Ir(o)),r){var a;o=o.bind((a=n.proxy_)!=null?a:n.target_),o.isMobXFlow=!0}return{value:o,configurable:s?n.isPlainObject_:!0,enumerable:!1,writable:!s}}function oc(n,e){return{annotationType_:n,options_:e,make_:Dx,extend_:Lx,decorate_20223_:Ox}}function Dx(n,e,t){return this.extend_(n,e,t,!1)===null?0:1}function Lx(n,e,t,i){return Ix(n,this,e,t),n.defineComputedProperty_(e,_i({},this.options_,{get:t.get,set:t.set}),i)}function Ox(n,e){process.env.NODE_ENV!=="production"&&To(e,["getter"]);var t=this,i=e.name,r=e.addInitializer;return r(function(){var s=Nr(this)[Ue],o=_i({},t.options_,{get:n,context:this});o.name||(o.name=process.env.NODE_ENV!=="production"?s.name_+"."+i.toString():"ObservableObject."+i.toString()),s.values_.set(i,new cn(o))}),function(){return this[Ue].getObservablePropValue_(i)}}function Ix(n,e,t,i){var r=e.annotationType_,s=i.get;process.env.NODE_ENV!=="production"&&!s&&ve("Cannot apply '"+r+"' to '"+n.name_+"."+t.toString()+"':"+(`
3877
+ '`+r+"' can only be used on getter(+setter) properties."))}function Co(n,e){return{annotationType_:n,options_:e,make_:Nx,extend_:Ux,decorate_20223_:Fx}}function Nx(n,e,t){return this.extend_(n,e,t,!1)===null?0:1}function Ux(n,e,t,i){var r,s;return Bx(n,this,e,t),n.defineObservableProperty_(e,t.value,(r=(s=this.options_)==null?void 0:s.enhancer)!=null?r:Gi,i)}function Fx(n,e){if(process.env.NODE_ENV!=="production"){if(e.kind==="field")throw ve("Please use `@observable accessor "+String(e.name)+"` instead of `@observable "+String(e.name)+"`");To(e,["accessor"])}var t=this,i=e.kind,r=e.name,s=new WeakSet;function o(a,l){var c,u,h=Nr(a)[Ue],d=new Xi(l,(c=(u=t.options_)==null?void 0:u.enhancer)!=null?c:Gi,process.env.NODE_ENV!=="production"?h.name_+"."+r.toString():"ObservableObject."+r.toString(),!1);h.values_.set(r,d),s.add(a)}if(i=="accessor")return{get:function(){return s.has(this)||o(this,n.get.call(this)),this[Ue].getObservablePropValue_(r)},set:function(l){return s.has(this)||o(this,l),this[Ue].setObservablePropValue_(r,l)},init:function(l){return s.has(this)||o(this,l),l}}}function Bx(n,e,t,i){var r=e.annotationType_;process.env.NODE_ENV!=="production"&&!("value"in i)&&ve("Cannot apply '"+r+"' to '"+n.name_+"."+t.toString()+"':"+(`
3878
+ '`+r+"' cannot be used on getter/setter properties"))}var zx="true",Vx=Qh();function Qh(n){return{annotationType_:zx,options_:n,make_:Hx,extend_:kx,decorate_20223_:Gx}}function Hx(n,e,t,i){var r,s;if(t.get)return Lo.make_(n,e,t,i);if(t.set){var o=qi(t.set)?t.set:Wi(e.toString(),t.set);return i===n.target_?n.defineProperty_(e,{configurable:he.safeDescriptors?n.isPlainObject_:!0,set:o})===null?0:2:(zn(i,e,{configurable:!0,set:o}),2)}if(i!==n.target_&&typeof t.value=="function"){var a;if(Gh(t.value)){var l,c=(l=this.options_)!=null&&l.autoBind?Ir.bound:Ir;return c.make_(n,e,t,i)}var u=(a=this.options_)!=null&&a.autoBind?ds.bound:ds;return u.make_(n,e,t,i)}var h=((r=this.options_)==null?void 0:r.deep)===!1?Lt.ref:Lt;if(typeof t.value=="function"&&(s=this.options_)!=null&&s.autoBind){var d;t.value=t.value.bind((d=n.proxy_)!=null?d:n.target_)}return h.make_(n,e,t,i)}function kx(n,e,t,i){var r,s;if(t.get)return Lo.extend_(n,e,t,i);if(t.set)return n.defineProperty_(e,{configurable:he.safeDescriptors?n.isPlainObject_:!0,set:Wi(e.toString(),t.set)},i);if(typeof t.value=="function"&&(r=this.options_)!=null&&r.autoBind){var o;t.value=t.value.bind((o=n.proxy_)!=null?o:n.target_)}var a=((s=this.options_)==null?void 0:s.deep)===!1?Lt.ref:Lt;return a.extend_(n,e,t,i)}function Gx(n,e){ve("'"+this.annotationType_+"' cannot be used as a decorator")}var Wx="observable",Xx="observable.ref",jx="observable.shallow",Yx="observable.struct",ef={deep:!0,name:void 0,defaultDecorator:void 0,proxy:!0};Object.freeze(ef);function Po(n){return n||ef}var ac=Co(Wx),qx=Co(Xx,{enhancer:Ao}),$x=Co(jx,{enhancer:yx}),Zx=Co(Yx,{enhancer:Mx}),tf=Vn(ac);function Do(n){return n.deep===!0?Gi:n.deep===!1?Ao:Jx(n.defaultDecorator)}function Kx(n){var e;return n?(e=n.defaultDecorator)!=null?e:Qh(n):void 0}function Jx(n){var e,t;return n&&(e=(t=n.options_)==null?void 0:t.enhancer)!=null?e:Gi}function nf(n,e,t){if(us(e))return ac.decorate_20223_(n,e);if(Hi(e)){cs(n,e,ac);return}return ms(n)?n:$t(n)?Lt.object(n,e,t):Array.isArray(n)?Lt.array(n,e):Pr(n)?Lt.map(n,e):Jn(n)?Lt.set(n,e):typeof n=="object"&&n!==null?n:Lt.box(n,e)}Vh(nf,tf);var Qx={box:function(e,t){var i=Po(t);return new Xi(e,Do(i),i.name,!0,i.equals)},array:function(e,t){var i=Po(t);return(he.useProxies===!1||i.proxy===!1?Ky:Hy)(e,Do(i),i.name)},map:function(e,t){var i=Po(t);return new Cf(e,Do(i),i.name)},set:function(e,t){var i=Po(t);return new Df(e,Do(i),i.name)},object:function(e,t,i){return Zi(function(){return bf(he.useProxies===!1||i?.proxy===!1?Nr({},i):Fy({},i),e,t)})},ref:Vn(qx),shallow:Vn($x),deep:tf,struct:Vn(Zx)},Lt=Vh(nf,Qx),rf="computed",ey="computed.struct",lc=oc(rf),ty=oc(ey,{equals:wo.structural}),Lo=function(e,t){if(us(t))return lc.decorate_20223_(e,t);if(Hi(t))return cs(e,t,lc);if($t(e))return Vn(oc(rf,e));process.env.NODE_ENV!=="production"&&(At(e)||ve("First argument to `computed` should be an expression."),At(t)&&ve("A setter as second argument is no longer supported, use `{ set: fn }` option instead"));var i=$t(t)?t:{};return i.get=e,i.name||(i.name=e.name||""),new cn(i)};Object.assign(Lo,lc),Lo.struct=Vn(ty);var sf,of,Oo=0,ny=1,iy=(sf=(of=yo(function(){},"name"))==null?void 0:of.configurable)!=null?sf:!1,af={value:"action",configurable:!0,writable:!1,enumerable:!1};function Wi(n,e,t,i){t===void 0&&(t=!1),process.env.NODE_ENV!=="production"&&(At(e)||ve("`action` can only be invoked on functions"),(typeof n!="string"||!n)&&ve("actions should have valid names, got: '"+n+"'"));function r(){return ry(n,t,e,i||this,arguments)}return r.isMobxAction=!0,r.toString=function(){return e.toString()},iy&&(af.value=n,zn(r,"name",af)),r}function ry(n,e,t,i,r){var s=sy(n,e,i,r);try{return t.apply(i,r)}catch(o){throw s.error_=o,o}finally{oy(s)}}function sy(n,e,t,i){var r=process.env.NODE_ENV!=="production"&&Ot()&&!!n,s=0;if(process.env.NODE_ENV!=="production"&&r){s=Date.now();var o=i?Array.from(i):Eo;Jt({type:_c,name:n,object:t,arguments:o})}var a=he.trackingDerivation,l=!e||!a;hn();var c=he.allowStateChanges;l&&(ji(),c=cc(!0));var u=dc(!0),h={runAsAction_:l,prevDerivation_:a,prevAllowStateChanges_:c,prevAllowStateReads_:u,notifySpy_:r,startTime_:s,actionId_:ny++,parentActionId_:Oo};return Oo=h.actionId_,h}function oy(n){Oo!==n.actionId_&&ve(30),Oo=n.parentActionId_,n.error_!==void 0&&(he.suppressReactionErrors=!0),uc(n.prevAllowStateChanges_),fs(n.prevAllowStateReads_),fn(),n.runAsAction_&&ei(n.prevDerivation_),process.env.NODE_ENV!=="production"&&n.notifySpy_&&Qt({time:Date.now()-n.startTime_}),he.suppressReactionErrors=!1}function cc(n){var e=he.allowStateChanges;return he.allowStateChanges=n,e}function uc(n){he.allowStateChanges=n}var ay="create",Xi=(function(n){function e(i,r,s,o,a){var l;if(s===void 0&&(s=process.env.NODE_ENV!=="production"?"ObservableValue@"+wn():"ObservableValue"),o===void 0&&(o=!0),a===void 0&&(a=wo.default),l=n.call(this,s)||this,l.enhancer=void 0,l.name_=void 0,l.equals=void 0,l.hasUnreportedChange_=!1,l.interceptors_=void 0,l.changeListeners_=void 0,l.value_=void 0,l.dehancer=void 0,l.enhancer=r,l.name_=s,l.equals=a,l.value_=r(i,void 0,s),process.env.NODE_ENV!=="production"&&o&&Ot()){var c;Yi({type:ay,object:l,observableKind:"value",debugObjectName:l.name_,newValue:""+((c=l.value_)==null?void 0:c.toString())})}return l}qh(e,n);var t=e.prototype;return t.dehanceValue=function(r){return this.dehancer!==void 0?this.dehancer(r):r},t.set=function(r){var s=this.value_;if(r=this.prepareNewValue_(r),r!==he.UNCHANGED){var o=Ot();process.env.NODE_ENV!=="production"&&o&&Jt({type:Pn,object:this,observableKind:"value",debugObjectName:this.name_,newValue:r,oldValue:s}),this.setNewValue_(r),process.env.NODE_ENV!=="production"&&o&&Qt()}},t.prepareNewValue_=function(r){if(Hn(this),dn(this)){var s=pn(this,{object:this,type:Pn,newValue:r});if(!s)return he.UNCHANGED;r=s.newValue}return r=this.enhancer(r,this.value_,this.name_),this.equals(this.value_,r)?he.UNCHANGED:r},t.setNewValue_=function(r){var s=this.value_;this.value_=r,this.reportChanged(),Rn(this)&&Cn(this,{type:Pn,object:this,newValue:r,oldValue:s})},t.get=function(){return this.reportObserved(),this.dehanceValue(this.value_)},t.intercept_=function(r){return _s(this,r)},t.observe_=function(r,s){return s&&r({observableKind:"value",debugObjectName:this.name_,object:this,type:Pn,newValue:this.value_,oldValue:void 0}),gs(this,r)},t.raw=function(){return this.value_},t.toJSON=function(){return this.get()},t.toString=function(){return this.name_+"["+this.value_+"]"},t.valueOf=function(){return jh(this.get())},t[Symbol.toPrimitive]=function(){return this.valueOf()},e})(gi),cn=(function(){function n(t){this.dependenciesState_=Ke.NOT_TRACKING_,this.observing_=[],this.newObserving_=null,this.observers_=new Set,this.runId_=0,this.lastAccessedBy_=0,this.lowestObserverState_=Ke.UP_TO_DATE_,this.unboundDepsCount_=0,this.value_=new No(null),this.name_=void 0,this.triggeredBy_=void 0,this.flags_=0,this.derivation=void 0,this.setter_=void 0,this.isTracing_=un.NONE,this.scope_=void 0,this.equals_=void 0,this.requiresReaction_=void 0,this.keepAlive_=void 0,this.onBOL=void 0,this.onBUOL=void 0,t.get||ve(31),this.derivation=t.get,this.name_=t.name||(process.env.NODE_ENV!=="production"?"ComputedValue@"+wn():"ComputedValue"),t.set&&(this.setter_=Wi(process.env.NODE_ENV!=="production"?this.name_+"-setter":"ComputedValue-setter",t.set)),this.equals_=t.equals||(t.compareStructural||t.struct?wo.structural:wo.default),this.scope_=t.context,this.requiresReaction_=t.requiresReaction,this.keepAlive_=!!t.keepAlive}var e=n.prototype;return e.onBecomeStale_=function(){dy(this)},e.onBO=function(){this.onBOL&&this.onBOL.forEach(function(i){return i()})},e.onBUO=function(){this.onBUOL&&this.onBUOL.forEach(function(i){return i()})},e.get=function(){if(this.isComputing&&ve(32,this.name_,this.derivation),he.inBatch===0&&this.observers_.size===0&&!this.keepAlive_)hc(this)&&(this.warnAboutUntrackedRead_(),hn(),this.value_=this.computeValue_(!1),fn());else if(df(this),hc(this)){var i=he.trackingContext;this.keepAlive_&&!i&&(he.trackingContext=this),this.trackAndCompute()&&fy(this),he.trackingContext=i}var r=this.value_;if(Uo(r))throw r.cause;return r},e.set=function(i){if(this.setter_){this.isRunningSetter&&ve(33,this.name_),this.isRunningSetter=!0;try{this.setter_.call(this.scope_,i)}finally{this.isRunningSetter=!1}}else ve(34,this.name_)},e.trackAndCompute=function(){var i=this.value_,r=this.dependenciesState_===Ke.NOT_TRACKING_,s=this.computeValue_(!0),o=r||Uo(i)||Uo(s)||!this.equals_(i,s);return o&&(this.value_=s,process.env.NODE_ENV!=="production"&&Ot()&&Yi({observableKind:"computed",debugObjectName:this.name_,object:this.scope_,type:"update",oldValue:i,newValue:s})),o},e.computeValue_=function(i){this.isComputing=!0;var r=cc(!1),s;if(i)s=lf(this,this.derivation,this.scope_);else if(he.disableErrorBoundaries===!0)s=this.derivation.call(this.scope_);else try{s=this.derivation.call(this.scope_)}catch(o){s=new No(o)}return uc(r),this.isComputing=!1,s},e.suspend_=function(){this.keepAlive_||(fc(this),this.value_=void 0,process.env.NODE_ENV!=="production"&&this.isTracing_!==un.NONE&&console.log("[mobx.trace] Computed value '"+this.name_+"' was suspended and it will recompute on the next access."))},e.observe_=function(i,r){var s=this,o=!0,a=void 0;return by(function(){var l=s.get();if(!o||r){var c=ji();i({observableKind:"computed",debugObjectName:s.name_,type:Pn,object:s,newValue:l,oldValue:a}),ei(c)}o=!1,a=l})},e.warnAboutUntrackedRead_=function(){process.env.NODE_ENV!=="production"&&(this.isTracing_!==un.NONE&&console.log("[mobx.trace] Computed value '"+this.name_+"' is being read outside a reactive context. Doing a full recompute."),(typeof this.requiresReaction_=="boolean"?this.requiresReaction_:he.computedRequiresReaction)&&console.warn("[mobx] Computed value '"+this.name_+"' is being read outside a reactive context. Doing a full recompute."))},e.toString=function(){return this.name_+"["+this.derivation.toString()+"]"},e.valueOf=function(){return jh(this.get())},e[Symbol.toPrimitive]=function(){return this.valueOf()},Dr(n,[{key:"isComputing",get:function(){return Zt(this.flags_,n.isComputingMask_)},set:function(i){this.flags_=Kt(this.flags_,n.isComputingMask_,i)}},{key:"isRunningSetter",get:function(){return Zt(this.flags_,n.isRunningSetterMask_)},set:function(i){this.flags_=Kt(this.flags_,n.isRunningSetterMask_,i)}},{key:"isBeingObserved",get:function(){return Zt(this.flags_,n.isBeingObservedMask_)},set:function(i){this.flags_=Kt(this.flags_,n.isBeingObservedMask_,i)}},{key:"isPendingUnobservation",get:function(){return Zt(this.flags_,n.isPendingUnobservationMask_)},set:function(i){this.flags_=Kt(this.flags_,n.isPendingUnobservationMask_,i)}},{key:"diffValue",get:function(){return Zt(this.flags_,n.diffValueMask_)?1:0},set:function(i){this.flags_=Kt(this.flags_,n.diffValueMask_,i===1)}}])})();cn.isComputingMask_=1,cn.isRunningSetterMask_=2,cn.isBeingObservedMask_=4,cn.isPendingUnobservationMask_=8,cn.diffValueMask_=16;var Io=ki("ComputedValue",cn),Ke;(function(n){n[n.NOT_TRACKING_=-1]="NOT_TRACKING_",n[n.UP_TO_DATE_=0]="UP_TO_DATE_",n[n.POSSIBLY_STALE_=1]="POSSIBLY_STALE_",n[n.STALE_=2]="STALE_"})(Ke||(Ke={}));var un;(function(n){n[n.NONE=0]="NONE",n[n.LOG=1]="LOG",n[n.BREAK=2]="BREAK"})(un||(un={}));var No=function(e){this.cause=void 0,this.cause=e};function Uo(n){return n instanceof No}function hc(n){switch(n.dependenciesState_){case Ke.UP_TO_DATE_:return!1;case Ke.NOT_TRACKING_:case Ke.STALE_:return!0;case Ke.POSSIBLY_STALE_:{for(var e=dc(!0),t=ji(),i=n.observing_,r=i.length,s=0;s<r;s++){var o=i[s];if(Io(o)){if(he.disableErrorBoundaries)o.get();else try{o.get()}catch{return ei(t),fs(e),!0}if(n.dependenciesState_===Ke.STALE_)return ei(t),fs(e),!0}}return uf(n),ei(t),fs(e),!1}}}function Hn(n){if(process.env.NODE_ENV!=="production"){var e=n.observers_.size>0;!he.allowStateChanges&&(e||he.enforceActions==="always")&&console.warn("[MobX] "+(he.enforceActions?"Since strict-mode is enabled, changing (observed) observable values without using an action is not allowed. Tried to modify: ":"Side effects like changing state are not allowed at this point. Are you trying to modify state from, for example, a computed value or the render function of a React component? You can wrap side effects in 'runInAction' (or decorate functions with 'action') if needed. Tried to modify: ")+n.name_)}}function ly(n){process.env.NODE_ENV!=="production"&&!he.allowStateReads&&he.observableRequiresReaction&&console.warn("[mobx] Observable '"+n.name_+"' being read outside a reactive context.")}function lf(n,e,t){var i=dc(!0);uf(n),n.newObserving_=new Array(n.runId_===0?100:n.observing_.length),n.unboundDepsCount_=0,n.runId_=++he.runId;var r=he.trackingDerivation;he.trackingDerivation=n,he.inBatch++;var s;if(he.disableErrorBoundaries===!0)s=e.call(t);else try{s=e.call(t)}catch(o){s=new No(o)}return he.inBatch--,he.trackingDerivation=r,uy(n),cy(n),fs(i),s}function cy(n){process.env.NODE_ENV!=="production"&&n.observing_.length===0&&(typeof n.requiresObservable_=="boolean"?n.requiresObservable_:he.reactionRequiresObservable)&&console.warn("[mobx] Derivation '"+n.name_+"' is created/updated without reading any observable value.")}function uy(n){for(var e=n.observing_,t=n.observing_=n.newObserving_,i=Ke.UP_TO_DATE_,r=0,s=n.unboundDepsCount_,o=0;o<s;o++){var a=t[o];a.diffValue===0&&(a.diffValue=1,r!==o&&(t[r]=a),r++),a.dependenciesState_>i&&(i=a.dependenciesState_)}for(t.length=r,n.newObserving_=null,s=e.length;s--;){var l=e[s];l.diffValue===0&&hf(l,n),l.diffValue=0}for(;r--;){var c=t[r];c.diffValue===1&&(c.diffValue=0,hy(c,n))}i!==Ke.UP_TO_DATE_&&(n.dependenciesState_=i,n.onBecomeStale_())}function fc(n){var e=n.observing_;n.observing_=[];for(var t=e.length;t--;)hf(e[t],n);n.dependenciesState_=Ke.NOT_TRACKING_}function cf(n){var e=ji();try{return n()}finally{ei(e)}}function ji(){var n=he.trackingDerivation;return he.trackingDerivation=null,n}function ei(n){he.trackingDerivation=n}function dc(n){var e=he.allowStateReads;return he.allowStateReads=n,e}function fs(n){he.allowStateReads=n}function uf(n){if(n.dependenciesState_!==Ke.UP_TO_DATE_){n.dependenciesState_=Ke.UP_TO_DATE_;for(var e=n.observing_,t=e.length;t--;)e[t].lowestObserverState_=Ke.UP_TO_DATE_}}var pc=function(){this.version=6,this.UNCHANGED={},this.trackingDerivation=null,this.trackingContext=null,this.runId=0,this.mobxGuid=0,this.inBatch=0,this.pendingUnobservations=[],this.pendingReactions=[],this.isRunningReactions=!1,this.allowStateChanges=!1,this.allowStateReads=!0,this.enforceActions=!0,this.spyListeners=[],this.globalReactionErrorHandlers=[],this.computedRequiresReaction=!1,this.reactionRequiresObservable=!1,this.observableRequiresReaction=!1,this.disableErrorBoundaries=!1,this.suppressReactionErrors=!1,this.useProxies=!0,this.verifyProxies=!1,this.safeDescriptors=!0},mc=!0,he=(function(){var n=tc();return n.__mobxInstanceCount>0&&!n.__mobxGlobals&&(mc=!1),n.__mobxGlobals&&n.__mobxGlobals.version!==new pc().version&&(mc=!1),mc?n.__mobxGlobals?(n.__mobxInstanceCount+=1,n.__mobxGlobals.UNCHANGED||(n.__mobxGlobals.UNCHANGED={}),n.__mobxGlobals):(n.__mobxInstanceCount=1,n.__mobxGlobals=new pc):(setTimeout(function(){ve(35)},1),new pc)})();function hy(n,e){n.observers_.add(e),n.lowestObserverState_>e.dependenciesState_&&(n.lowestObserverState_=e.dependenciesState_)}function hf(n,e){n.observers_.delete(e),n.observers_.size===0&&ff(n)}function ff(n){n.isPendingUnobservation===!1&&(n.isPendingUnobservation=!0,he.pendingUnobservations.push(n))}function hn(){he.inBatch++}function fn(){if(--he.inBatch===0){vf();for(var n=he.pendingUnobservations,e=0;e<n.length;e++){var t=n[e];t.isPendingUnobservation=!1,t.observers_.size===0&&(t.isBeingObserved&&(t.isBeingObserved=!1,t.onBUO()),t instanceof cn&&t.suspend_())}he.pendingUnobservations=[]}}function df(n){ly(n);var e=he.trackingDerivation;return e!==null?(e.runId_!==n.lastAccessedBy_&&(n.lastAccessedBy_=e.runId_,e.newObserving_[e.unboundDepsCount_++]=n,!n.isBeingObserved&&he.trackingContext&&(n.isBeingObserved=!0,n.onBO())),n.isBeingObserved):(n.observers_.size===0&&he.inBatch>0&&ff(n),!1)}function pf(n){n.lowestObserverState_!==Ke.STALE_&&(n.lowestObserverState_=Ke.STALE_,n.observers_.forEach(function(e){e.dependenciesState_===Ke.UP_TO_DATE_&&(process.env.NODE_ENV!=="production"&&e.isTracing_!==un.NONE&&mf(e,n),e.onBecomeStale_()),e.dependenciesState_=Ke.STALE_}))}function fy(n){n.lowestObserverState_!==Ke.STALE_&&(n.lowestObserverState_=Ke.STALE_,n.observers_.forEach(function(e){e.dependenciesState_===Ke.POSSIBLY_STALE_?(e.dependenciesState_=Ke.STALE_,process.env.NODE_ENV!=="production"&&e.isTracing_!==un.NONE&&mf(e,n)):e.dependenciesState_===Ke.UP_TO_DATE_&&(n.lowestObserverState_=Ke.UP_TO_DATE_)}))}function dy(n){n.lowestObserverState_===Ke.UP_TO_DATE_&&(n.lowestObserverState_=Ke.POSSIBLY_STALE_,n.observers_.forEach(function(e){e.dependenciesState_===Ke.UP_TO_DATE_&&(e.dependenciesState_=Ke.POSSIBLY_STALE_,e.onBecomeStale_())}))}function mf(n,e){if(console.log("[mobx.trace] '"+n.name_+"' is invalidated due to a change in: '"+e.name_+"'"),n.isTracing_===un.BREAK){var t=[];_f(Cy(n),t,1),new Function(`debugger;
3879
+ /*
3880
+ Tracing '`+n.name_+`'
3881
+
3882
+ You are entering this break point because derivation '`+n.name_+"' is being traced and '"+e.name_+`' is now forcing it to update.
3883
+ Just follow the stacktrace you should now see in the devtools to see precisely what piece of your code is causing this update
3884
+ The stackframe you are looking for is at least ~6-8 stack-frames up.
3885
+
3886
+ `+(n instanceof cn?n.derivation.toString().replace(/[*]\//g,"/"):"")+`
3887
+
3888
+ The dependencies for this derivation are:
3889
+
3890
+ `+t.join(`
3891
+ `)+`
3892
+ */
3893
+ `)()}}function _f(n,e,t){if(e.length>=1e3){e.push("(and many more)");return}e.push(""+" ".repeat(t-1)+n.name),n.dependencies&&n.dependencies.forEach(function(i){return _f(i,e,t+1)})}var vi=(function(){function n(t,i,r,s){t===void 0&&(t=process.env.NODE_ENV!=="production"?"Reaction@"+wn():"Reaction"),this.name_=void 0,this.onInvalidate_=void 0,this.errorHandler_=void 0,this.requiresObservable_=void 0,this.observing_=[],this.newObserving_=[],this.dependenciesState_=Ke.NOT_TRACKING_,this.runId_=0,this.unboundDepsCount_=0,this.flags_=0,this.isTracing_=un.NONE,this.name_=t,this.onInvalidate_=i,this.errorHandler_=r,this.requiresObservable_=s}var e=n.prototype;return e.onBecomeStale_=function(){this.schedule_()},e.schedule_=function(){this.isScheduled||(this.isScheduled=!0,he.pendingReactions.push(this),vf())},e.runReaction_=function(){if(!this.isDisposed){hn(),this.isScheduled=!1;var i=he.trackingContext;if(he.trackingContext=this,hc(this)){this.isTrackPending=!0;try{this.onInvalidate_(),process.env.NODE_ENV!=="production"&&this.isTrackPending&&Ot()&&Yi({name:this.name_,type:"scheduled-reaction"})}catch(r){this.reportExceptionInDerivation_(r)}}he.trackingContext=i,fn()}},e.track=function(i){if(!this.isDisposed){hn();var r=Ot(),s;process.env.NODE_ENV!=="production"&&r&&(s=Date.now(),Jt({name:this.name_,type:"reaction"})),this.isRunning=!0;var o=he.trackingContext;he.trackingContext=this;var a=lf(this,i,void 0);he.trackingContext=o,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&fc(this),Uo(a)&&this.reportExceptionInDerivation_(a.cause),process.env.NODE_ENV!=="production"&&r&&Qt({time:Date.now()-s}),fn()}},e.reportExceptionInDerivation_=function(i){var r=this;if(this.errorHandler_){this.errorHandler_(i,this);return}if(he.disableErrorBoundaries)throw i;var s=process.env.NODE_ENV!=="production"?"[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '"+this+"'":"[mobx] uncaught error in '"+this+"'";he.suppressReactionErrors?process.env.NODE_ENV!=="production"&&console.warn("[mobx] (error in reaction '"+this.name_+"' suppressed, fix error of causing action below)"):console.error(s,i),process.env.NODE_ENV!=="production"&&Ot()&&Yi({type:"error",name:this.name_,message:s,error:""+i}),he.globalReactionErrorHandlers.forEach(function(o){return o(i,r)})},e.dispose=function(){this.isDisposed||(this.isDisposed=!0,this.isRunning||(hn(),fc(this),fn()))},e.getDisposer_=function(i){var r=this,s=function o(){r.dispose(),i==null||i.removeEventListener==null||i.removeEventListener("abort",o)};return i==null||i.addEventListener==null||i.addEventListener("abort",s),s[Ue]=this,"dispose"in Symbol&&typeof Symbol.dispose=="symbol"&&(s[Symbol.dispose]=s),s},e.toString=function(){return"Reaction["+this.name_+"]"},e.trace=function(i){i===void 0&&(i=!1),Iy(this,i)},Dr(n,[{key:"isDisposed",get:function(){return Zt(this.flags_,n.isDisposedMask_)},set:function(i){this.flags_=Kt(this.flags_,n.isDisposedMask_,i)}},{key:"isScheduled",get:function(){return Zt(this.flags_,n.isScheduledMask_)},set:function(i){this.flags_=Kt(this.flags_,n.isScheduledMask_,i)}},{key:"isTrackPending",get:function(){return Zt(this.flags_,n.isTrackPendingMask_)},set:function(i){this.flags_=Kt(this.flags_,n.isTrackPendingMask_,i)}},{key:"isRunning",get:function(){return Zt(this.flags_,n.isRunningMask_)},set:function(i){this.flags_=Kt(this.flags_,n.isRunningMask_,i)}},{key:"diffValue",get:function(){return Zt(this.flags_,n.diffValueMask_)?1:0},set:function(i){this.flags_=Kt(this.flags_,n.diffValueMask_,i===1)}}])})();vi.isDisposedMask_=1,vi.isScheduledMask_=2,vi.isTrackPendingMask_=4,vi.isRunningMask_=8,vi.diffValueMask_=16;var gf=100,py=function(e){return e()};function vf(){he.inBatch>0||he.isRunningReactions||py(my)}function my(){he.isRunningReactions=!0;for(var n=he.pendingReactions,e=0;n.length>0;){++e===gf&&(console.error(process.env.NODE_ENV!=="production"?"Reaction doesn't converge to a stable state after "+gf+" iterations."+(" Probably there is a cycle in the reactive function: "+n[0]):"[mobx] cycle in reaction: "+n[0]),n.splice(0));for(var t=n.splice(0),i=0,r=t.length;i<r;i++)t[i].runReaction_()}he.isRunningReactions=!1}var Fo=ki("Reaction",vi);function Ot(){return process.env.NODE_ENV!=="production"&&!!he.spyListeners.length}function Yi(n){if(process.env.NODE_ENV!=="production"&&he.spyListeners.length)for(var e=he.spyListeners,t=0,i=e.length;t<i;t++)e[t](n)}function Jt(n){if(process.env.NODE_ENV!=="production"){var e=_i({},n,{spyReportStart:!0});Yi(e)}}var _y={type:"report-end",spyReportEnd:!0};function Qt(n){process.env.NODE_ENV!=="production"&&Yi(n?_i({},n,{type:"report-end",spyReportEnd:!0}):_y)}function gy(n){return process.env.NODE_ENV==="production"?(console.warn("[mobx.spy] Is a no-op in production builds"),function(){}):(he.spyListeners.push(n),nc(function(){he.spyListeners=he.spyListeners.filter(function(e){return e!==n})}))}var _c="action",vy="action.bound",xf="autoAction",xy="autoAction.bound",yy="<unnamed action>",gc=hs(_c),My=hs(vy,{bound:!0}),vc=hs(xf,{autoAction:!0}),Ey=hs(xy,{autoAction:!0,bound:!0});function yf(n){var e=function(i,r){if(At(i))return Wi(i.name||yy,i,n);if(At(r))return Wi(i,r,n);if(us(r))return(n?vc:gc).decorate_20223_(i,r);if(Hi(r))return cs(i,r,n?vc:gc);if(Hi(i))return Vn(hs(n?xf:_c,{name:i,autoAction:n}));process.env.NODE_ENV!=="production"&&ve("Invalid arguments for `action`")};return e}var Or=yf(!1);Object.assign(Or,gc);var ds=yf(!0);Object.assign(ds,vc),Or.bound=Vn(My),ds.bound=Vn(Ey);function qi(n){return At(n)&&n.isMobxAction===!0}function by(n,e){var t,i,r,s;e===void 0&&(e=Hh),process.env.NODE_ENV!=="production"&&(At(n)||ve("Autorun expects a function as first argument"),qi(n)&&ve("Autorun does not accept actions since actions are untrackable"));var o=(t=(i=e)==null?void 0:i.name)!=null?t:process.env.NODE_ENV!=="production"?n.name||"Autorun@"+wn():"Autorun",a=!e.scheduler&&!e.delay,l;if(a)l=new vi(o,function(){this.track(h)},e.onError,e.requiresObservable);else{var c=Ty(e),u=!1;l=new vi(o,function(){u||(u=!0,c(function(){u=!1,l.isDisposed||l.track(h)}))},e.onError,e.requiresObservable)}function h(){n(l)}return(r=e)!=null&&(r=r.signal)!=null&&r.aborted||l.schedule_(),l.getDisposer_((s=e)==null?void 0:s.signal)}var Sy=function(e){return e()};function Ty(n){return n.scheduler?n.scheduler:n.delay?function(e){return setTimeout(e,n.delay)}:Sy}var wy="onBO",Ay="onBUO";function Ry(n,e,t){return Ef(wy,n,e,t)}function Mf(n,e,t){return Ef(Ay,n,e,t)}function Ef(n,e,t,i){var r=Fr(e),s=At(i)?i:t,o=n+"L";return r[o]?r[o].add(s):r[o]=new Set([s]),function(){var a=r[o];a&&(a.delete(s),a.size===0&&delete r[o])}}function bf(n,e,t,i){process.env.NODE_ENV!=="production"&&(arguments.length>4&&ve("'extendObservable' expected 2-4 arguments"),typeof n!="object"&&ve("'extendObservable' expects an object as first argument"),yi(n)&&ve("'extendObservable' should not be used on maps, use map.merge instead"),$t(e)||ve("'extendObservable' only accepts plain objects as second argument"),(ms(e)||ms(t))&&ve("Extending an object with another observable (object) is not supported"));var r=fx(e);return Zi(function(){var s=Nr(n,i)[Ue];ls(r).forEach(function(o){s.extend_(o,r[o],t&&o in t?t[o]:!0)})}),n}function Cy(n,e){return Sf(Fr(n,e))}function Sf(n){var e={name:n.name_};return n.observing_&&n.observing_.length>0&&(e.dependencies=Py(n.observing_).map(Sf)),e}function Py(n){return Array.from(new Set(n))}var Dy=0;function Tf(){this.message="FLOW_CANCELLED"}Tf.prototype=Object.create(Error.prototype);var xc=Kh("flow"),Ly=Kh("flow.bound",{bound:!0}),Ir=Object.assign(function(e,t){if(us(t))return xc.decorate_20223_(e,t);if(Hi(t))return cs(e,t,xc);process.env.NODE_ENV!=="production"&&arguments.length!==1&&ve("Flow expects single argument with generator function");var i=e,r=i.name||"<unnamed flow>",s=function(){var a=this,l=arguments,c=++Dy,u=Or(r+" - runid: "+c+" - init",i).apply(a,l),h,d=void 0,p=new Promise(function(g,y){var m=0;h=y;function f(_){d=void 0;var S;try{S=Or(r+" - runid: "+c+" - yield "+m++,u.next).call(u,_)}catch(b){return y(b)}T(S)}function w(_){d=void 0;var S;try{S=Or(r+" - runid: "+c+" - yield "+m++,u.throw).call(u,_)}catch(b){return y(b)}T(S)}function T(_){if(At(_?.then)){_.then(T,y);return}return _.done?g(_.value):(d=Promise.resolve(_.value),d.then(f,w))}f(void 0)});return p.cancel=Or(r+" - runid: "+c+" - cancel",function(){try{d&&wf(d);var g=u.return(void 0),y=Promise.resolve(g.value);y.then(Cr,Cr),wf(y),h(new Tf)}catch(m){h(m)}}),p};return s.isMobXFlow=!0,s},xc);Ir.bound=Vn(Ly);function wf(n){At(n.cancel)&&n.cancel()}function ps(n){return n?.isMobXFlow===!0}function Oy(n,e){return n?Ur(n)||!!n[Ue]||sc(n)||Fo(n)||Io(n):!1}function ms(n){return process.env.NODE_ENV!=="production"&&arguments.length!==1&&ve("isObservable expects only 1 argument. Use isObservableProp to inspect the observability of a property"),Oy(n)}function Iy(){if(process.env.NODE_ENV!=="production"){for(var n=!1,e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];typeof t[t.length-1]=="boolean"&&(n=t.pop());var r=Ny(t);if(!r)return ve("'trace(break?)' can only be used inside a tracked computed value or a Reaction. Consider passing in the computed value or reaction explicitly");r.isTracing_===un.NONE&&console.log("[mobx.trace] '"+r.name_+"' tracing enabled"),r.isTracing_=n?un.BREAK:un.LOG}}function Ny(n){switch(n.length){case 0:return he.trackingDerivation;case 1:return Fr(n[0]);case 2:return Fr(n[0],n[1])}}function ti(n,e){e===void 0&&(e=void 0),hn();try{return n.apply(e)}finally{fn()}}function $i(n){return n[Ue]}var Uy={has:function(e,t){return process.env.NODE_ENV!=="production"&&he.trackingDerivation&&as("detect new properties using the 'in' operator. Use 'has' from 'mobx' instead."),$i(e).has_(t)},get:function(e,t){return $i(e).get_(t)},set:function(e,t,i){var r;return Hi(t)?(process.env.NODE_ENV!=="production"&&!$i(e).values_.has(t)&&as("add a new observable property through direct assignment. Use 'set' from 'mobx' instead."),(r=$i(e).set_(t,i,!0))!=null?r:!0):!1},deleteProperty:function(e,t){var i;return process.env.NODE_ENV!=="production"&&as("delete properties from an observable object. Use 'remove' from 'mobx' instead."),Hi(t)?(i=$i(e).delete_(t,!0))!=null?i:!0:!1},defineProperty:function(e,t,i){var r;return process.env.NODE_ENV!=="production"&&as("define property on an observable object. Use 'defineProperty' from 'mobx' instead."),(r=$i(e).defineProperty_(t,i))!=null?r:!0},ownKeys:function(e){return process.env.NODE_ENV!=="production"&&he.trackingDerivation&&as("iterate keys to detect added / removed properties. Use 'keys' from 'mobx' instead."),$i(e).ownKeys_()},preventExtensions:function(e){ve(13)}};function Fy(n,e){var t,i;return kh(),n=Nr(n,e),(i=(t=n[Ue]).proxy_)!=null?i:t.proxy_=new Proxy(n,Uy)}function dn(n){return n.interceptors_!==void 0&&n.interceptors_.length>0}function _s(n,e){var t=n.interceptors_||(n.interceptors_=[]);return t.push(e),nc(function(){var i=t.indexOf(e);i!==-1&&t.splice(i,1)})}function pn(n,e){var t=ji();try{for(var i=[].concat(n.interceptors_||[]),r=0,s=i.length;r<s&&(e=i[r](e),e&&!e.type&&ve(14),!!e);r++);return e}finally{ei(t)}}function Rn(n){return n.changeListeners_!==void 0&&n.changeListeners_.length>0}function gs(n,e){var t=n.changeListeners_||(n.changeListeners_=[]);return t.push(e),nc(function(){var i=t.indexOf(e);i!==-1&&t.splice(i,1)})}function Cn(n,e){var t=ji(),i=n.changeListeners_;if(i){i=i.slice();for(var r=0,s=i.length;r<s;r++)i[r](e);ei(t)}}var yc=Symbol("mobx-keys");function By(n,e,t){return process.env.NODE_ENV!=="production"&&(!$t(n)&&!$t(Object.getPrototypeOf(n))&&ve("'makeAutoObservable' can only be used for classes that don't have a superclass"),Ur(n)&&ve("makeAutoObservable can only be used on objects not already made observable")),$t(n)?bf(n,n,e,t):(Zi(function(){var i=Nr(n,t)[Ue];if(!n[yc]){var r=Object.getPrototypeOf(n),s=new Set([].concat(ls(n),ls(r)));s.delete("constructor"),s.delete(Ue),So(r,yc,s)}n[yc].forEach(function(o){return i.make_(o,e&&o in e?e[o]:!0)})}),n)}var Af="splice",Pn="update",zy=1e4,Vy={get:function(e,t){var i=e[Ue];return t===Ue?i:t==="length"?i.getArrayLength_():typeof t=="string"&&!isNaN(t)?i.get_(parseInt(t)):An(Bo,t)?Bo[t]:e[t]},set:function(e,t,i){var r=e[Ue];return t==="length"&&r.setArrayLength_(i),typeof t=="symbol"||isNaN(t)?e[t]=i:r.set_(parseInt(t),i),!0},preventExtensions:function(){ve(15)}},Mc=(function(){function n(t,i,r,s){t===void 0&&(t=process.env.NODE_ENV!=="production"?"ObservableArray@"+wn():"ObservableArray"),this.owned_=void 0,this.legacyMode_=void 0,this.atom_=void 0,this.values_=[],this.interceptors_=void 0,this.changeListeners_=void 0,this.enhancer_=void 0,this.dehancer=void 0,this.proxy_=void 0,this.lastKnownLength_=0,this.owned_=r,this.legacyMode_=s,this.atom_=new gi(t),this.enhancer_=function(o,a){return i(o,a,process.env.NODE_ENV!=="production"?t+"[..]":"ObservableArray[..]")}}var e=n.prototype;return e.dehanceValue_=function(i){return this.dehancer!==void 0?this.dehancer(i):i},e.dehanceValues_=function(i){return this.dehancer!==void 0&&i.length>0?i.map(this.dehancer):i},e.intercept_=function(i){return _s(this,i)},e.observe_=function(i,r){return r===void 0&&(r=!1),r&&i({observableKind:"array",object:this.proxy_,debugObjectName:this.atom_.name_,type:"splice",index:0,added:this.values_.slice(),addedCount:this.values_.length,removed:[],removedCount:0}),gs(this,i)},e.getArrayLength_=function(){return this.atom_.reportObserved(),this.values_.length},e.setArrayLength_=function(i){(typeof i!="number"||isNaN(i)||i<0)&&ve("Out of range: "+i);var r=this.values_.length;if(i!==r)if(i>r){for(var s=new Array(i-r),o=0;o<i-r;o++)s[o]=void 0;this.spliceWithArray_(r,0,s)}else this.spliceWithArray_(i,r-i)},e.updateArrayLength_=function(i,r){i!==this.lastKnownLength_&&ve(16),this.lastKnownLength_+=r,this.legacyMode_&&r>0&&Vf(i+r+1)},e.spliceWithArray_=function(i,r,s){var o=this;Hn(this.atom_);var a=this.values_.length;if(i===void 0?i=0:i>a?i=a:i<0&&(i=Math.max(0,a+i)),arguments.length===1?r=a-i:r==null?r=0:r=Math.max(0,Math.min(r,a-i)),s===void 0&&(s=Eo),dn(this)){var l=pn(this,{object:this.proxy_,type:Af,index:i,removedCount:r,added:s});if(!l)return Eo;r=l.removedCount,s=l.added}if(s=s.length===0?s:s.map(function(h){return o.enhancer_(h,void 0)}),this.legacyMode_||process.env.NODE_ENV!=="production"){var c=s.length-r;this.updateArrayLength_(a,c)}var u=this.spliceItemsIntoValues_(i,r,s);return(r!==0||s.length!==0)&&this.notifyArraySplice_(i,s,u),this.dehanceValues_(u)},e.spliceItemsIntoValues_=function(i,r,s){if(s.length<zy){var o;return(o=this.values_).splice.apply(o,[i,r].concat(s))}else{var a=this.values_.slice(i,i+r),l=this.values_.slice(i+r);this.values_.length+=s.length-r;for(var c=0;c<s.length;c++)this.values_[i+c]=s[c];for(var u=0;u<l.length;u++)this.values_[i+s.length+u]=l[u];return a}},e.notifyArrayChildUpdate_=function(i,r,s){var o=!this.owned_&&Ot(),a=Rn(this),l=a||o?{observableKind:"array",object:this.proxy_,type:Pn,debugObjectName:this.atom_.name_,index:i,newValue:r,oldValue:s}:null;process.env.NODE_ENV!=="production"&&o&&Jt(l),this.atom_.reportChanged(),a&&Cn(this,l),process.env.NODE_ENV!=="production"&&o&&Qt()},e.notifyArraySplice_=function(i,r,s){var o=!this.owned_&&Ot(),a=Rn(this),l=a||o?{observableKind:"array",object:this.proxy_,debugObjectName:this.atom_.name_,type:Af,index:i,removed:s,added:r,removedCount:s.length,addedCount:r.length}:null;process.env.NODE_ENV!=="production"&&o&&Jt(l),this.atom_.reportChanged(),a&&Cn(this,l),process.env.NODE_ENV!=="production"&&o&&Qt()},e.get_=function(i){if(this.legacyMode_&&i>=this.values_.length){console.warn(process.env.NODE_ENV!=="production"?"[mobx.array] Attempt to read an array index ("+i+") that is out of bounds ("+this.values_.length+"). Please check length first. Out of bound indices will not be tracked by MobX":"[mobx] Out of bounds read: "+i);return}return this.atom_.reportObserved(),this.dehanceValue_(this.values_[i])},e.set_=function(i,r){var s=this.values_;if(this.legacyMode_&&i>s.length&&ve(17,i,s.length),i<s.length){Hn(this.atom_);var o=s[i];if(dn(this)){var a=pn(this,{type:Pn,object:this.proxy_,index:i,newValue:r});if(!a)return;r=a.newValue}r=this.enhancer_(r,o);var l=r!==o;l&&(s[i]=r,this.notifyArrayChildUpdate_(i,r,o))}else{for(var c=new Array(i+1-s.length),u=0;u<c.length-1;u++)c[u]=void 0;c[c.length-1]=r,this.spliceWithArray_(s.length,0,c)}},n})();function Hy(n,e,t,i){return t===void 0&&(t=process.env.NODE_ENV!=="production"?"ObservableArray@"+wn():"ObservableArray"),i===void 0&&(i=!1),kh(),Zi(function(){var r=new Mc(t,e,i,!1);Wh(r.values_,Ue,r);var s=new Proxy(r.values_,Vy);return r.proxy_=s,n&&n.length&&r.spliceWithArray_(0,0,n),s})}var Bo={clear:function(){return this.splice(0)},replace:function(e){var t=this[Ue];return t.spliceWithArray_(0,t.values_.length,e)},toJSON:function(){return this.slice()},splice:function(e,t){for(var i=arguments.length,r=new Array(i>2?i-2:0),s=2;s<i;s++)r[s-2]=arguments[s];var o=this[Ue];switch(arguments.length){case 0:return[];case 1:return o.spliceWithArray_(e);case 2:return o.spliceWithArray_(e,t)}return o.spliceWithArray_(e,t,r)},spliceWithArray:function(e,t,i){return this[Ue].spliceWithArray_(e,t,i)},push:function(){for(var e=this[Ue],t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];return e.spliceWithArray_(e.values_.length,0,i),e.values_.length},pop:function(){return this.splice(Math.max(this[Ue].values_.length-1,0),1)[0]},shift:function(){return this.splice(0,1)[0]},unshift:function(){for(var e=this[Ue],t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];return e.spliceWithArray_(0,0,i),e.values_.length},reverse:function(){return he.trackingDerivation&&ve(37,"reverse"),this.replace(this.slice().reverse()),this},sort:function(){he.trackingDerivation&&ve(37,"sort");var e=this.slice();return e.sort.apply(e,arguments),this.replace(e),this},remove:function(e){var t=this[Ue],i=t.dehanceValues_(t.values_).indexOf(e);return i>-1?(this.splice(i,1),!0):!1}};lt("at",en),lt("concat",en),lt("flat",en),lt("includes",en),lt("indexOf",en),lt("join",en),lt("lastIndexOf",en),lt("slice",en),lt("toString",en),lt("toLocaleString",en),lt("toSorted",en),lt("toSpliced",en),lt("with",en),lt("every",Dn),lt("filter",Dn),lt("find",Dn),lt("findIndex",Dn),lt("findLast",Dn),lt("findLastIndex",Dn),lt("flatMap",Dn),lt("forEach",Dn),lt("map",Dn),lt("some",Dn),lt("toReversed",Dn),lt("reduce",Rf),lt("reduceRight",Rf);function lt(n,e){typeof Array.prototype[n]=="function"&&(Bo[n]=e(n))}function en(n){return function(){var e=this[Ue];e.atom_.reportObserved();var t=e.dehanceValues_(e.values_);return t[n].apply(t,arguments)}}function Dn(n){return function(e,t){var i=this,r=this[Ue];r.atom_.reportObserved();var s=r.dehanceValues_(r.values_);return s[n](function(o,a){return e.call(t,o,a,i)})}}function Rf(n){return function(){var e=this,t=this[Ue];t.atom_.reportObserved();var i=t.dehanceValues_(t.values_),r=arguments[0];return arguments[0]=function(s,o,a){return r(s,o,a,e)},i[n].apply(i,arguments)}}var ky=ki("ObservableArrayAdministration",Mc);function zo(n){return bo(n)&&ky(n[Ue])}var Gy={},xi="add",Vo="delete",Cf=(function(){function n(t,i,r){var s=this;i===void 0&&(i=Gi),r===void 0&&(r=process.env.NODE_ENV!=="production"?"ObservableMap@"+wn():"ObservableMap"),this.enhancer_=void 0,this.name_=void 0,this[Ue]=Gy,this.data_=void 0,this.hasMap_=void 0,this.keysAtom_=void 0,this.interceptors_=void 0,this.changeListeners_=void 0,this.dehancer=void 0,this.enhancer_=i,this.name_=r,At(Map)||ve(18),Zi(function(){s.keysAtom_=$h(process.env.NODE_ENV!=="production"?s.name_+".keys()":"ObservableMap.keys()"),s.data_=new Map,s.hasMap_=new Map,t&&s.merge(t)})}var e=n.prototype;return e.has_=function(i){return this.data_.has(i)},e.has=function(i){var r=this;if(!he.trackingDerivation)return this.has_(i);var s=this.hasMap_.get(i);if(!s){var o=s=new Xi(this.has_(i),Ao,process.env.NODE_ENV!=="production"?this.name_+"."+ic(i)+"?":"ObservableMap.key?",!1);this.hasMap_.set(i,o),Mf(o,function(){return r.hasMap_.delete(i)})}return s.get()},e.set=function(i,r){var s=this.has_(i);if(dn(this)){var o=pn(this,{type:s?Pn:xi,object:this,newValue:r,name:i});if(!o)return this;r=o.newValue}return s?this.updateValue_(i,r):this.addValue_(i,r),this},e.delete=function(i){var r=this;if(Hn(this.keysAtom_),dn(this)){var s=pn(this,{type:Vo,object:this,name:i});if(!s)return!1}if(this.has_(i)){var o=Ot(),a=Rn(this),l=a||o?{observableKind:"map",debugObjectName:this.name_,type:Vo,object:this,oldValue:this.data_.get(i).value_,name:i}:null;return process.env.NODE_ENV!=="production"&&o&&Jt(l),ti(function(){var c;r.keysAtom_.reportChanged(),(c=r.hasMap_.get(i))==null||c.setNewValue_(!1);var u=r.data_.get(i);u.setNewValue_(void 0),r.data_.delete(i)}),a&&Cn(this,l),process.env.NODE_ENV!=="production"&&o&&Qt(),!0}return!1},e.updateValue_=function(i,r){var s=this.data_.get(i);if(r=s.prepareNewValue_(r),r!==he.UNCHANGED){var o=Ot(),a=Rn(this),l=a||o?{observableKind:"map",debugObjectName:this.name_,type:Pn,object:this,oldValue:s.value_,name:i,newValue:r}:null;process.env.NODE_ENV!=="production"&&o&&Jt(l),s.setNewValue_(r),a&&Cn(this,l),process.env.NODE_ENV!=="production"&&o&&Qt()}},e.addValue_=function(i,r){var s=this;Hn(this.keysAtom_),ti(function(){var c,u=new Xi(r,s.enhancer_,process.env.NODE_ENV!=="production"?s.name_+"."+ic(i):"ObservableMap.key",!1);s.data_.set(i,u),r=u.value_,(c=s.hasMap_.get(i))==null||c.setNewValue_(!0),s.keysAtom_.reportChanged()});var o=Ot(),a=Rn(this),l=a||o?{observableKind:"map",debugObjectName:this.name_,type:xi,object:this,name:i,newValue:r}:null;process.env.NODE_ENV!=="production"&&o&&Jt(l),a&&Cn(this,l),process.env.NODE_ENV!=="production"&&o&&Qt()},e.get=function(i){return this.has(i)?this.dehanceValue_(this.data_.get(i).get()):this.dehanceValue_(void 0)},e.dehanceValue_=function(i){return this.dehancer!==void 0?this.dehancer(i):i},e.keys=function(){return this.keysAtom_.reportObserved(),this.data_.keys()},e.values=function(){var i=this,r=this.keys();return Pf({next:function(){var o=r.next(),a=o.done,l=o.value;return{done:a,value:a?void 0:i.get(l)}}})},e.entries=function(){var i=this,r=this.keys();return Pf({next:function(){var o=r.next(),a=o.done,l=o.value;return{done:a,value:a?void 0:[l,i.get(l)]}}})},e[Symbol.iterator]=function(){return this.entries()},e.forEach=function(i,r){for(var s=Lr(this),o;!(o=s()).done;){var a=o.value,l=a[0],c=a[1];i.call(r,c,l,this)}},e.merge=function(i){var r=this;return yi(i)&&(i=new Map(i)),ti(function(){$t(i)?hx(i).forEach(function(s){return r.set(s,i[s])}):Array.isArray(i)?i.forEach(function(s){var o=s[0],a=s[1];return r.set(o,a)}):Pr(i)?(ux(i)||ve(19,i),i.forEach(function(s,o){return r.set(o,s)})):i!=null&&ve(20,i)}),this},e.clear=function(){var i=this;ti(function(){cf(function(){for(var r=Lr(i.keys()),s;!(s=r()).done;){var o=s.value;i.delete(o)}})})},e.replace=function(i){var r=this;return ti(function(){for(var s=Wy(i),o=new Map,a=!1,l=Lr(r.data_.keys()),c;!(c=l()).done;){var u=c.value;if(!s.has(u)){var h=r.delete(u);if(h)a=!0;else{var d=r.data_.get(u);o.set(u,d)}}}for(var p=Lr(s.entries()),g;!(g=p()).done;){var y=g.value,m=y[0],f=y[1],w=r.data_.has(m);if(r.set(m,f),r.data_.has(m)){var T=r.data_.get(m);o.set(m,T),w||(a=!0)}}if(!a)if(r.data_.size!==o.size)r.keysAtom_.reportChanged();else for(var _=r.data_.keys(),S=o.keys(),b=_.next(),A=S.next();!b.done;){if(b.value!==A.value){r.keysAtom_.reportChanged();break}b=_.next(),A=S.next()}r.data_=o}),this},e.toString=function(){return"[object ObservableMap]"},e.toJSON=function(){return Array.from(this)},e.observe_=function(i,r){return process.env.NODE_ENV!=="production"&&r===!0&&ve("`observe` doesn't support fireImmediately=true in combination with maps."),gs(this,i)},e.intercept_=function(i){return _s(this,i)},Dr(n,[{key:"size",get:function(){return this.keysAtom_.reportObserved(),this.data_.size}},{key:Symbol.toStringTag,get:function(){return"Map"}}])})(),yi=ki("ObservableMap",Cf);function Pf(n){return n[Symbol.toStringTag]="MapIterator",wc(n)}function Wy(n){if(Pr(n)||yi(n))return n;if(Array.isArray(n))return new Map(n);if($t(n)){var e=new Map;for(var t in n)e.set(t,n[t]);return e}else return ve(21,n)}var Xy={},Df=(function(){function n(t,i,r){var s=this;i===void 0&&(i=Gi),r===void 0&&(r=process.env.NODE_ENV!=="production"?"ObservableSet@"+wn():"ObservableSet"),this.name_=void 0,this[Ue]=Xy,this.data_=new Set,this.atom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.dehancer=void 0,this.enhancer_=void 0,this.name_=r,At(Set)||ve(22),this.enhancer_=function(o,a){return i(o,a,r)},Zi(function(){s.atom_=$h(s.name_),t&&s.replace(t)})}var e=n.prototype;return e.dehanceValue_=function(i){return this.dehancer!==void 0?this.dehancer(i):i},e.clear=function(){var i=this;ti(function(){cf(function(){for(var r=Lr(i.data_.values()),s;!(s=r()).done;){var o=s.value;i.delete(o)}})})},e.forEach=function(i,r){for(var s=Lr(this),o;!(o=s()).done;){var a=o.value;i.call(r,a,a,this)}},e.add=function(i){var r=this;if(Hn(this.atom_),dn(this)){var s=pn(this,{type:xi,object:this,newValue:i});if(!s)return this;i=s.newValue}if(!this.has(i)){ti(function(){r.data_.add(r.enhancer_(i,void 0)),r.atom_.reportChanged()});var o=process.env.NODE_ENV!=="production"&&Ot(),a=Rn(this),l=a||o?{observableKind:"set",debugObjectName:this.name_,type:xi,object:this,newValue:i}:null;o&&process.env.NODE_ENV!=="production"&&Jt(l),a&&Cn(this,l),o&&process.env.NODE_ENV!=="production"&&Qt()}return this},e.delete=function(i){var r=this;if(dn(this)){var s=pn(this,{type:Vo,object:this,oldValue:i});if(!s)return!1}if(this.has(i)){var o=process.env.NODE_ENV!=="production"&&Ot(),a=Rn(this),l=a||o?{observableKind:"set",debugObjectName:this.name_,type:Vo,object:this,oldValue:i}:null;return o&&process.env.NODE_ENV!=="production"&&Jt(l),ti(function(){r.atom_.reportChanged(),r.data_.delete(i)}),a&&Cn(this,l),o&&process.env.NODE_ENV!=="production"&&Qt(),!0}return!1},e.has=function(i){return this.atom_.reportObserved(),this.data_.has(this.dehanceValue_(i))},e.entries=function(){var i=this.values();return Lf({next:function(){var s=i.next(),o=s.value,a=s.done;return a?{value:void 0,done:a}:{value:[o,o],done:a}}})},e.keys=function(){return this.values()},e.values=function(){this.atom_.reportObserved();var i=this,r=this.data_.values();return Lf({next:function(){var o=r.next(),a=o.value,l=o.done;return l?{value:void 0,done:l}:{value:i.dehanceValue_(a),done:l}}})},e.intersection=function(i){if(Jn(i)&&!kn(i))return i.intersection(this);var r=new Set(this);return r.intersection(i)},e.union=function(i){if(Jn(i)&&!kn(i))return i.union(this);var r=new Set(this);return r.union(i)},e.difference=function(i){return new Set(this).difference(i)},e.symmetricDifference=function(i){if(Jn(i)&&!kn(i))return i.symmetricDifference(this);var r=new Set(this);return r.symmetricDifference(i)},e.isSubsetOf=function(i){return new Set(this).isSubsetOf(i)},e.isSupersetOf=function(i){return new Set(this).isSupersetOf(i)},e.isDisjointFrom=function(i){if(Jn(i)&&!kn(i))return i.isDisjointFrom(this);var r=new Set(this);return r.isDisjointFrom(i)},e.replace=function(i){var r=this;return kn(i)&&(i=new Set(i)),ti(function(){Array.isArray(i)?(r.clear(),i.forEach(function(s){return r.add(s)})):Jn(i)?(r.clear(),i.forEach(function(s){return r.add(s)})):i!=null&&ve("Cannot initialize set from "+i)}),this},e.observe_=function(i,r){return process.env.NODE_ENV!=="production"&&r===!0&&ve("`observe` doesn't support fireImmediately=true in combination with sets."),gs(this,i)},e.intercept_=function(i){return _s(this,i)},e.toJSON=function(){return Array.from(this)},e.toString=function(){return"[object ObservableSet]"},e[Symbol.iterator]=function(){return this.values()},Dr(n,[{key:"size",get:function(){return this.atom_.reportObserved(),this.data_.size}},{key:Symbol.toStringTag,get:function(){return"Set"}}])})(),kn=ki("ObservableSet",Df);function Lf(n){return n[Symbol.toStringTag]="SetIterator",wc(n)}var Of=Object.create(null),If="remove",Ec=(function(){function n(t,i,r,s){i===void 0&&(i=new Map),s===void 0&&(s=Vx),this.target_=void 0,this.values_=void 0,this.name_=void 0,this.defaultAnnotation_=void 0,this.keysAtom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.proxy_=void 0,this.isPlainObject_=void 0,this.appliedAnnotations_=void 0,this.pendingKeys_=void 0,this.target_=t,this.values_=i,this.name_=r,this.defaultAnnotation_=s,this.keysAtom_=new gi(process.env.NODE_ENV!=="production"?this.name_+".keys":"ObservableObject.keys"),this.isPlainObject_=$t(this.target_),process.env.NODE_ENV!=="production"&&!jf(this.defaultAnnotation_)&&ve("defaultAnnotation must be valid annotation"),process.env.NODE_ENV!=="production"&&(this.appliedAnnotations_={})}var e=n.prototype;return e.getObservablePropValue_=function(i){return this.values_.get(i).get()},e.setObservablePropValue_=function(i,r){var s=this.values_.get(i);if(s instanceof cn)return s.set(r),!0;if(dn(this)){var o=pn(this,{type:Pn,object:this.proxy_||this.target_,name:i,newValue:r});if(!o)return null;r=o.newValue}if(r=s.prepareNewValue_(r),r!==he.UNCHANGED){var a=Rn(this),l=process.env.NODE_ENV!=="production"&&Ot(),c=a||l?{type:Pn,observableKind:"object",debugObjectName:this.name_,object:this.proxy_||this.target_,oldValue:s.value_,name:i,newValue:r}:null;process.env.NODE_ENV!=="production"&&l&&Jt(c),s.setNewValue_(r),a&&Cn(this,c),process.env.NODE_ENV!=="production"&&l&&Qt()}return!0},e.get_=function(i){return he.trackingDerivation&&!An(this.target_,i)&&this.has_(i),this.target_[i]},e.set_=function(i,r,s){return s===void 0&&(s=!1),An(this.target_,i)?this.values_.has(i)?this.setObservablePropValue_(i,r):s?Reflect.set(this.target_,i,r):(this.target_[i]=r,!0):this.extend_(i,{value:r,enumerable:!0,writable:!0,configurable:!0},this.defaultAnnotation_,s)},e.has_=function(i){if(!he.trackingDerivation)return i in this.target_;this.pendingKeys_||(this.pendingKeys_=new Map);var r=this.pendingKeys_.get(i);return r||(r=new Xi(i in this.target_,Ao,process.env.NODE_ENV!=="production"?this.name_+"."+ic(i)+"?":"ObservableObject.key?",!1),this.pendingKeys_.set(i,r)),r.get()},e.make_=function(i,r){if(r===!0&&(r=this.defaultAnnotation_),r!==!1){if(Ff(this,r,i),!(i in this.target_)){var s;if((s=this.target_[Qn])!=null&&s[i])return;ve(1,r.annotationType_,this.name_+"."+i.toString())}for(var o=this.target_;o&&o!==Mo;){var a=yo(o,i);if(a){var l=r.make_(this,i,a,o);if(l===0)return;if(l===1)break}o=Object.getPrototypeOf(o)}Uf(this,r,i)}},e.extend_=function(i,r,s,o){if(o===void 0&&(o=!1),s===!0&&(s=this.defaultAnnotation_),s===!1)return this.defineProperty_(i,r,o);Ff(this,s,i);var a=s.extend_(this,i,r,o);return a&&Uf(this,s,i),a},e.defineProperty_=function(i,r,s){s===void 0&&(s=!1),Hn(this.keysAtom_);try{hn();var o=this.delete_(i);if(!o)return o;if(dn(this)){var a=pn(this,{object:this.proxy_||this.target_,name:i,type:xi,newValue:r.value});if(!a)return null;var l=a.newValue;r.value!==l&&(r=_i({},r,{value:l}))}if(s){if(!Reflect.defineProperty(this.target_,i,r))return!1}else zn(this.target_,i,r);this.notifyPropertyAddition_(i,r.value)}finally{fn()}return!0},e.defineObservableProperty_=function(i,r,s,o){o===void 0&&(o=!1),Hn(this.keysAtom_);try{hn();var a=this.delete_(i);if(!a)return a;if(dn(this)){var l=pn(this,{object:this.proxy_||this.target_,name:i,type:xi,newValue:r});if(!l)return null;r=l.newValue}var c=Nf(i),u={configurable:he.safeDescriptors?this.isPlainObject_:!0,enumerable:!0,get:c.get,set:c.set};if(o){if(!Reflect.defineProperty(this.target_,i,u))return!1}else zn(this.target_,i,u);var h=new Xi(r,s,process.env.NODE_ENV!=="production"?this.name_+"."+i.toString():"ObservableObject.key",!1);this.values_.set(i,h),this.notifyPropertyAddition_(i,h.value_)}finally{fn()}return!0},e.defineComputedProperty_=function(i,r,s){s===void 0&&(s=!1),Hn(this.keysAtom_);try{hn();var o=this.delete_(i);if(!o)return o;if(dn(this)){var a=pn(this,{object:this.proxy_||this.target_,name:i,type:xi,newValue:void 0});if(!a)return null}r.name||(r.name=process.env.NODE_ENV!=="production"?this.name_+"."+i.toString():"ObservableObject.key"),r.context=this.proxy_||this.target_;var l=Nf(i),c={configurable:he.safeDescriptors?this.isPlainObject_:!0,enumerable:!1,get:l.get,set:l.set};if(s){if(!Reflect.defineProperty(this.target_,i,c))return!1}else zn(this.target_,i,c);this.values_.set(i,new cn(r)),this.notifyPropertyAddition_(i,void 0)}finally{fn()}return!0},e.delete_=function(i,r){if(r===void 0&&(r=!1),Hn(this.keysAtom_),!An(this.target_,i))return!0;if(dn(this)){var s=pn(this,{object:this.proxy_||this.target_,name:i,type:If});if(!s)return null}try{var o;hn();var a=Rn(this),l=process.env.NODE_ENV!=="production"&&Ot(),c=this.values_.get(i),u=void 0;if(!c&&(a||l)){var h;u=(h=yo(this.target_,i))==null?void 0:h.value}if(r){if(!Reflect.deleteProperty(this.target_,i))return!1}else delete this.target_[i];if(process.env.NODE_ENV!=="production"&&delete this.appliedAnnotations_[i],c&&(this.values_.delete(i),c instanceof Xi&&(u=c.value_),pf(c)),this.keysAtom_.reportChanged(),(o=this.pendingKeys_)==null||(o=o.get(i))==null||o.set(i in this.target_),a||l){var d={type:If,observableKind:"object",object:this.proxy_||this.target_,debugObjectName:this.name_,oldValue:u,name:i};process.env.NODE_ENV!=="production"&&l&&Jt(d),a&&Cn(this,d),process.env.NODE_ENV!=="production"&&l&&Qt()}}finally{fn()}return!0},e.observe_=function(i,r){return process.env.NODE_ENV!=="production"&&r===!0&&ve("`observe` doesn't support the fire immediately property for observable objects."),gs(this,i)},e.intercept_=function(i){return _s(this,i)},e.notifyPropertyAddition_=function(i,r){var s,o=Rn(this),a=process.env.NODE_ENV!=="production"&&Ot();if(o||a){var l=o||a?{type:xi,observableKind:"object",debugObjectName:this.name_,object:this.proxy_||this.target_,name:i,newValue:r}:null;process.env.NODE_ENV!=="production"&&a&&Jt(l),o&&Cn(this,l),process.env.NODE_ENV!=="production"&&a&&Qt()}(s=this.pendingKeys_)==null||(s=s.get(i))==null||s.set(!0),this.keysAtom_.reportChanged()},e.ownKeys_=function(){return this.keysAtom_.reportObserved(),ls(this.target_)},e.keys_=function(){return this.keysAtom_.reportObserved(),Object.keys(this.target_)},n})();function Nr(n,e){var t;if(process.env.NODE_ENV!=="production"&&e&&Ur(n)&&ve("Options can't be provided for already observable objects."),An(n,Ue))return process.env.NODE_ENV!=="production"&&!(Hf(n)instanceof Ec)&&ve("Cannot convert '"+Ho(n)+`' into observable object:
3894
+ The target is already observable of different type.
3895
+ Extending builtins is not supported.`),n;process.env.NODE_ENV!=="production"&&!Object.isExtensible(n)&&ve("Cannot make the designated object observable; it is not extensible");var i=(t=e?.name)!=null?t:process.env.NODE_ENV!=="production"?($t(n)?"ObservableObject":n.constructor.name)+"@"+wn():"ObservableObject",r=new Ec(n,new Map,String(i),Kx(e));return So(n,Ue,r),n}var jy=ki("ObservableObjectAdministration",Ec);function Nf(n){return Of[n]||(Of[n]={get:function(){return this[Ue].getObservablePropValue_(n)},set:function(t){return this[Ue].setObservablePropValue_(n,t)}})}function Ur(n){return bo(n)?jy(n[Ue]):!1}function Uf(n,e,t){var i;process.env.NODE_ENV!=="production"&&(n.appliedAnnotations_[t]=e),(i=n.target_[Qn])==null||delete i[t]}function Ff(n,e,t){if(process.env.NODE_ENV!=="production"&&!jf(e)&&ve("Cannot annotate '"+n.name_+"."+t.toString()+"': Invalid annotation."),process.env.NODE_ENV!=="production"&&!Ro(e)&&An(n.appliedAnnotations_,t)){var i=n.name_+"."+t.toString(),r=n.appliedAnnotations_[t].annotationType_,s=e.annotationType_;ve("Cannot apply '"+s+"' to '"+i+"':"+(`
3896
+ The field is already annotated with '`+r+"'.")+`
3897
+ Re-annotating fields is not allowed.
3898
+ Use 'override' annotation for methods overridden by subclass.`)}}var Yy=zf(0),qy=(function(){var n=!1,e={};return Object.defineProperty(e,"0",{set:function(){n=!0}}),Object.create(e)[0]=1,n===!1})(),bc=0,Bf=function(){};function $y(n,e){Object.setPrototypeOf?Object.setPrototypeOf(n.prototype,e):n.prototype.__proto__!==void 0?n.prototype.__proto__=e:n.prototype=e}$y(Bf,Array.prototype);var Sc=(function(n){function e(i,r,s,o){var a;return s===void 0&&(s=process.env.NODE_ENV!=="production"?"ObservableArray@"+wn():"ObservableArray"),o===void 0&&(o=!1),a=n.call(this)||this,Zi(function(){var l=new Mc(s,r,o,!0);l.proxy_=a,Wh(a,Ue,l),i&&i.length&&a.spliceWithArray(0,0,i),qy&&Object.defineProperty(a,"0",Yy)}),a}qh(e,n);var t=e.prototype;return t.concat=function(){this[Ue].atom_.reportObserved();for(var r=arguments.length,s=new Array(r),o=0;o<r;o++)s[o]=arguments[o];return Array.prototype.concat.apply(this.slice(),s.map(function(a){return zo(a)?a.slice():a}))},t[Symbol.iterator]=function(){var i=this,r=0;return wc({next:function(){return r<i.length?{value:i[r++],done:!1}:{done:!0,value:void 0}}})},Dr(e,[{key:"length",get:function(){return this[Ue].getArrayLength_()},set:function(r){this[Ue].setArrayLength_(r)}},{key:Symbol.toStringTag,get:function(){return"Array"}}])})(Bf);Object.entries(Bo).forEach(function(n){var e=n[0],t=n[1];e!=="concat"&&So(Sc.prototype,e,t)});function zf(n){return{enumerable:!1,configurable:!0,get:function(){return this[Ue].get_(n)},set:function(t){this[Ue].set_(n,t)}}}function Zy(n){zn(Sc.prototype,""+n,zf(n))}function Vf(n){if(n>bc){for(var e=bc;e<n+100;e++)Zy(e);bc=n}}Vf(1e3);function Ky(n,e,t){return new Sc(n,e,t)}function Fr(n,e){if(typeof n=="object"&&n!==null){if(zo(n))return e!==void 0&&ve(23),n[Ue].atom_;if(kn(n))return n.atom_;if(yi(n)){if(e===void 0)return n.keysAtom_;var t=n.data_.get(e)||n.hasMap_.get(e);return t||ve(25,e,Ho(n)),t}if(Ur(n)){if(!e)return ve(26);var i=n[Ue].values_.get(e);return i||ve(27,e,Ho(n)),i}if(sc(n)||Io(n)||Fo(n))return n}else if(At(n)&&Fo(n[Ue]))return n[Ue];ve(28)}function Hf(n,e){if(n||ve(29),sc(n)||Io(n)||Fo(n)||yi(n)||kn(n))return n;if(n[Ue])return n[Ue];ve(24,n)}function Ho(n,e){var t;if(e!==void 0)t=Fr(n,e);else{if(qi(n))return n.name;Ur(n)||yi(n)||kn(n)?t=Hf(n):t=Fr(n)}return t.name_}function Zi(n){var e=ji(),t=cc(!0);hn();try{return n()}finally{fn(),uc(t),ei(e)}}var kf=Mo.toString;function Gf(n,e,t){return t===void 0&&(t=-1),Tc(n,e,t)}function Tc(n,e,t,i,r){if(n===e)return n!==0||1/n===1/e;if(n==null||e==null)return!1;if(n!==n)return e!==e;var s=typeof n;if(s!=="function"&&s!=="object"&&typeof e!="object")return!1;var o=kf.call(n);if(o!==kf.call(e))return!1;switch(o){case"[object RegExp]":case"[object String]":return""+n==""+e;case"[object Number]":return+n!=+n?+e!=+e:+n==0?1/+n===1/e:+n==+e;case"[object Date]":case"[object Boolean]":return+n==+e;case"[object Symbol]":return typeof Symbol<"u"&&Symbol.valueOf.call(n)===Symbol.valueOf.call(e);case"[object Map]":case"[object Set]":t>=0&&t++;break}n=Wf(n),e=Wf(e);var a=o==="[object Array]";if(!a){if(typeof n!="object"||typeof e!="object")return!1;var l=n.constructor,c=e.constructor;if(l!==c&&!(At(l)&&l instanceof l&&At(c)&&c instanceof c)&&"constructor"in n&&"constructor"in e)return!1}if(t===0)return!1;t<0&&(t=-1),i=i||[],r=r||[];for(var u=i.length;u--;)if(i[u]===n)return r[u]===e;if(i.push(n),r.push(e),a){if(u=n.length,u!==e.length)return!1;for(;u--;)if(!Tc(n[u],e[u],t-1,i,r))return!1}else{var h=Object.keys(n),d=h.length;if(Object.keys(e).length!==d)return!1;for(var p=0;p<d;p++){var g=h[p];if(!(An(e,g)&&Tc(n[g],e[g],t-1,i,r)))return!1}}return i.pop(),r.pop(),!0}function Wf(n){return zo(n)?n.slice():Pr(n)||yi(n)||Jn(n)||kn(n)?Array.from(n.entries()):n}var Xf,Jy=((Xf=tc().Iterator)==null?void 0:Xf.prototype)||{};function wc(n){return n[Symbol.iterator]=Qy,Object.assign(Object.create(Jy),n)}function Qy(){return this}function jf(n){return n instanceof Object&&typeof n.annotationType_=="string"&&At(n.make_)&&At(n.extend_)}["Symbol","Map","Set"].forEach(function(n){var e=tc();typeof e[n]>"u"&&ve("MobX requires global '"+n+"' to be available or polyfilled")}),typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__=="object"&&__MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx({spy:gy,extras:{getDebugName:Ho},$mobx:Ue});var eM=Object.getOwnPropertyDescriptor,tM=(n,e,t,i)=>{for(var r=i>1?void 0:i?eM(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r};let Ac=class{_selectMode=ln.Mesh;_toolType=mi.Translate;_displayMode=Rr.Plane;_selectedObject=null;_selectedListeners=new Set;constructor(){By(this,{},{autoBind:!0})}getSelectMode(){return this._selectMode}getToolType(){return this._toolType}getDisplayMode(){return this._displayMode}setSelectMode(n){this._selectMode=n}setToolType(n){this._toolType=n}setDisplayMode(n){this._displayMode=n}getSelectedObject(){return this._selectedObject}setSelectedObject(n){if(this._selectedObject!==n){this._selectedObject=n;for(const e of this._selectedListeners)e(this._selectedObject)}}onSelectedObjectChange(n){return this._selectedListeners.add(n),()=>this._selectedListeners.delete(n)}};Ac=tM([zt()],Ac);let Yf=!1;const Dt=y0.createChildContainer();function nM(n){return Yf||(Dt.registerInstance("Canvas",n),Dt.registerSingleton("EventBus",_t.EventBus),Dt.registerSingleton("EditorRenderer",_t.EditorRenderer),Dt.registerSingleton("RendererApi",ec),Dt.registerSingleton("IDisplayHandler",Wl),Dt.registerSingleton("ISelectHandler",Yl),Dt.registerSingleton("ISelectHandler",ql),Dt.registerSingleton("ISelectHandler",Ql),Dt.registerSingleton("IToolHandler",Zl),Dt.registerSingleton("IToolHandler",Kl),Dt.registerSingleton("IToolHandler",Jl),Dt.registerSingleton("IDisplayManager",Vl),Dt.registerSingleton("ISelectManager",kl),Dt.registerSingleton("IToolManager",Gl),Dt.registerSingleton("EditorHub",_t.EditorHub),Dt.registerSingleton("IEditorStore",Ac),Yf=!0),Dt}function iM(n){return nM(n).resolve("EditorHub")}_t.EventTopics=Vi,_t.ObjLoader=D0,_t.PreviewRenderer=P0,_t.Renderer=Rl,_t.createAppHub=iM,Object.defineProperty(_t,Symbol.toStringTag,{value:"Module"})}));