ss-component-new 1.1.261 → 1.1.263

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 (88) hide show
  1. package/dist/{array-CGcjUVKX.cjs → array-BCYeTWHp.cjs} +1 -1
  2. package/dist/{array-BKq3BIQz.js → array-BiSkXjDh.js} +2 -2
  3. package/dist/{cloneDeep-B7uQBoFQ.cjs → cloneDeep-BShYbOkw.cjs} +1 -1
  4. package/dist/{cloneDeep-C2Kxf4cz.js → cloneDeep-CxhinJk5.js} +1 -1
  5. package/dist/{index-DSHdwrIv.js → index--CBmQToI.js} +4 -4
  6. package/dist/index-21rauG0g.cjs +1 -0
  7. package/dist/index-3fLiW589.cjs +1 -0
  8. package/dist/{index-B-UH_ubV.js → index-5G9gxVsG.js} +8 -8
  9. package/dist/{index-JlAZlJSa.js → index-6mqoLKfR.js} +6 -6
  10. package/dist/{index-BXTWkSfY.js → index-B0SEIfhd.js} +3 -3
  11. package/dist/{index-P8qnw1yi.js → index-B2bPpqmz.js} +5 -5
  12. package/dist/{index-CV8NL82B.js → index-B5fyktOS.js} +1 -1
  13. package/dist/index-B5vG0PaI.cjs +1 -0
  14. package/dist/{index-BEMqiaE4.cjs → index-B8d1EBwW.cjs} +1 -1
  15. package/dist/{index-B2U6bRXC.js → index-B96mvnY6.js} +1 -1
  16. package/dist/{index-i7I_BwC_.js → index-BEPkDcRB.js} +4 -4
  17. package/dist/{index-BSvAtDik.js → index-BEQcfNC8.js} +3264 -3260
  18. package/dist/{index-CUS5J9_e.js → index-BG7p7J6-.js} +3 -3
  19. package/dist/{index-XGNOqMia.cjs → index-BJEmWdGc.cjs} +1 -1
  20. package/dist/{index-BKkSFReI.cjs → index-BJWxGK8l.cjs} +1 -1
  21. package/dist/{index-C99sTbLR.cjs → index-BPGk6VZT.cjs} +1 -1
  22. package/dist/{index-BNRMWt2X.cjs → index-BRYyDz7j.cjs} +1 -1
  23. package/dist/{index-kzgPDfJF.cjs → index-BReBoqZM.cjs} +1 -1
  24. package/dist/{index-BqjnsqxM.cjs → index-BRgT-cwL.cjs} +1 -1
  25. package/dist/{index-CdbyfD9T.cjs → index-BTWHfvj_.cjs} +1 -1
  26. package/dist/{index-k1B4X854.js → index-BW_gJg6Y.js} +4 -4
  27. package/dist/index-BeYDJriQ.js +458 -0
  28. package/dist/{index-1FDUIkCX.cjs → index-BiIAlHzV.cjs} +1 -1
  29. package/dist/{index-CU_Jx-5J.cjs → index-Bl-nqQUb.cjs} +1 -1
  30. package/dist/{index-BPDeDTcT.js → index-BqqWyJ_i.js} +8 -8
  31. package/dist/{index-Dqq6ANsR.js → index-BxD91iWh.js} +1 -1
  32. package/dist/index-C3-tA5Oy.js +3520 -0
  33. package/dist/{index-CcWrPjiF.js → index-C8FwXAiK.js} +1 -1
  34. package/dist/{index-BTE2McnW.cjs → index-C9gBSiUj.cjs} +1 -1
  35. package/dist/{index-SuPnthkA.cjs → index-CNnhenkX.cjs} +1 -1
  36. package/dist/{index-CbAVZYKT.cjs → index-CPNiI7xc.cjs} +1 -1
  37. package/dist/{index-B5JYLkwE.js → index-CWpNIgx-.js} +5 -5
  38. package/dist/index-CYjQVlPG.cjs +1 -0
  39. package/dist/{index-CPLQkq0l.cjs → index-Cd2qjywt.cjs} +1 -1
  40. package/dist/index-ClyxHDAy.cjs +1 -0
  41. package/dist/{index-BpRK84YO.js → index-Cmf6TSRr.js} +9 -9
  42. package/dist/{index-BPc4Eac7.cjs → index-CvoVhrqh.cjs} +1 -1
  43. package/dist/{index-C4WiBNX7.cjs → index-CzuGT7Su.cjs} +1 -1
  44. package/dist/index-D0isXbYa.js +290 -0
  45. package/dist/{index-CtNApXqx.js → index-D9sisgye.js} +1 -1
  46. package/dist/{index-CRA36cu_.js → index-DJRZAkF4.js} +4 -4
  47. package/dist/{index-DBUg3cD4.js → index-DSPU33cy.js} +5 -5
  48. package/dist/{index-BuzU8y87.js → index-DdfwFwkR.js} +3 -3
  49. package/dist/{index-ChrvsNKe.cjs → index-DecqROTY.cjs} +1 -1
  50. package/dist/{index-BEUHy5vT.js → index-DhT3lFvD.js} +5 -5
  51. package/dist/{index-DJt9epxc.js → index-Duw1U19n.js} +3 -3
  52. package/dist/{index-DiqIaffC.js → index-DvydSDWz.js} +10 -10
  53. package/dist/{index-BSHYuItV.cjs → index-GDAKW2b9.cjs} +1 -1
  54. package/dist/{index-LztiiC8W.js → index-WOjw27kj.js} +38 -38
  55. package/dist/{index-DrgtDDgh.js → index-YBOakoO-.js} +1 -1
  56. package/dist/{index-BDeQhlHq.cjs → index-cPpFPrRC.cjs} +1 -1
  57. package/dist/{index-BePWixJ7.cjs → index-h9avu7we.cjs} +1 -1
  58. package/dist/{index-ChDUVY4O.cjs → index-jxXiBXta.cjs} +1 -1
  59. package/dist/{index-DqW6UiIO.cjs → index-kq_YOCp0.cjs} +32 -32
  60. package/dist/{index-D5iqPx4_.cjs → index-sYRfzwGi.cjs} +1 -1
  61. package/dist/{index.vue_vue_type_script_setup_true_lang-CsELnqsB.cjs → index.vue_vue_type_script_setup_true_lang-WZ_0N2ba.cjs} +1 -1
  62. package/dist/{index.vue_vue_type_script_setup_true_lang-GU5YecI_.js → index.vue_vue_type_script_setup_true_lang-dRZKrDpe.js} +1 -1
  63. package/dist/{index.vue_vue_type_style_index_0_scoped_11a5120d_lang-HXVPBHSR.js → index.vue_vue_type_style_index_0_scoped_11a5120d_lang-D6zTMeXs.js} +6 -6
  64. package/dist/{index.vue_vue_type_style_index_0_scoped_11a5120d_lang-CiQLJOHK.cjs → index.vue_vue_type_style_index_0_scoped_11a5120d_lang-DC0qx2mv.cjs} +1 -1
  65. package/dist/{index.vue_vue_type_style_index_0_scoped_4b7a2e5d_lang-Dhxd_sQH.cjs → index.vue_vue_type_style_index_0_scoped_4b7a2e5d_lang-B9TnTaRE.cjs} +1 -1
  66. package/dist/{index.vue_vue_type_style_index_0_scoped_4b7a2e5d_lang-BP1ltJdK.js → index.vue_vue_type_style_index_0_scoped_4b7a2e5d_lang-Bnu6O5Dx.js} +12 -12
  67. package/dist/{login-MRZ_aZ2l.cjs → login-B_Ta8W8C.cjs} +1 -1
  68. package/dist/{login-f0ZOWhgZ.js → login-D_UosrWe.js} +2 -2
  69. package/dist/{main-CD7tAcIb.js → main-CHSqRi2c.js} +7 -7
  70. package/dist/{main-CpGTA5Qv.cjs → main-DRtNsfjw.cjs} +1 -1
  71. package/dist/{menu-uQv0bEzE.js → menu-BjwI4sfO.js} +7 -2
  72. package/dist/{menu-PjSpUL7w.cjs → menu-CH06rBlw.cjs} +7 -7
  73. package/dist/{modelComp-BavIqTd8.js → modelComp-CiiFZm1t.js} +1 -1
  74. package/dist/{modelComp-qapurFEA.cjs → modelComp-LhGhARtD.cjs} +1 -1
  75. package/dist/ss-component.cjs +1 -1
  76. package/dist/ss-component.css +1 -1
  77. package/dist/ss-component.js +7 -7
  78. package/dist/ss-component3.cjs +1 -1
  79. package/dist/ss-component3.js +1 -1
  80. package/package.json +1 -1
  81. package/dist/index-BxNkT68g.js +0 -271
  82. package/dist/index-CW3K0wJl.cjs +0 -1
  83. package/dist/index-CaEGsvtY.cjs +0 -1
  84. package/dist/index-Clc0UQZs.cjs +0 -1
  85. package/dist/index-CrY9cebv.cjs +0 -1
  86. package/dist/index-DJXxlOVw.cjs +0 -1
  87. package/dist/index-DMxFp_J8.js +0 -301
  88. package/dist/index-Dz-F31F9.js +0 -3475
@@ -1,12 +1,12 @@
1
- "use strict";const V=require("vue"),cr=require("./index-D5iqPx4_.cjs"),Vu=require("./modelComp-qapurFEA.cjs"),Ei=require("./index-C99sTbLR.cjs"),Bn=require("./index-kzgPDfJF.cjs"),Rl=require("./_plugin-vue_export-helper-BHFhmbuH.cjs"),qe=require("./cloneDeep-B7uQBoFQ.cjs"),Et=require("./menu-PjSpUL7w.cjs"),Hu=require("./index-BKkSFReI.cjs");var Yh="__lodash_hash_undefined__";function Zh(s){return this.__data__.set(s,Yh),this}function $h(s){return this.__data__.has(s)}function Sa(s){var e=-1,t=s==null?0:s.length;for(this.__data__=new Ei.MapCache;++e<t;)this.add(s[e])}Sa.prototype.add=Sa.prototype.push=Zh;Sa.prototype.has=$h;function Jh(s,e){for(var t=-1,n=s==null?0:s.length;++t<n;)if(e(s[t],t,s))return!0;return!1}function Qh(s,e){return s.has(e)}var ed=1,td=2;function Gu(s,e,t,n,i,r){var a=t&ed,o=s.length,l=e.length;if(o!=l&&!(a&&l>o))return!1;var c=r.get(s),u=r.get(e);if(c&&u)return c==e&&u==s;var h=-1,d=!0,f=t&td?new Sa:void 0;for(r.set(s,e),r.set(e,s);++h<o;){var g=s[h],_=e[h];if(n)var m=a?n(_,g,h,e,s,r):n(g,_,h,s,e,r);if(m!==void 0){if(m)continue;d=!1;break}if(f){if(!Jh(e,function(p,S){if(!Qh(f,S)&&(g===p||i(g,p,t,n,r)))return f.push(S)})){d=!1;break}}else if(!(g===_||i(g,_,t,n,r))){d=!1;break}}return r.delete(s),r.delete(e),d}function nd(s){var e=-1,t=Array(s.size);return s.forEach(function(n,i){t[++e]=[i,n]}),t}function id(s){var e=-1,t=Array(s.size);return s.forEach(function(n){t[++e]=n}),t}var sd=1,rd=2,ad="[object Boolean]",od="[object Date]",ld="[object Error]",cd="[object Map]",ud="[object Number]",hd="[object RegExp]",dd="[object Set]",fd="[object String]",pd="[object Symbol]",md="[object ArrayBuffer]",gd="[object DataView]",ec=Ei.Symbol?Ei.Symbol.prototype:void 0,Ha=ec?ec.valueOf:void 0;function _d(s,e,t,n,i,r,a){switch(t){case gd:if(s.byteLength!=e.byteLength||s.byteOffset!=e.byteOffset)return!1;s=s.buffer,e=e.buffer;case md:return!(s.byteLength!=e.byteLength||!r(new qe.Uint8Array(s),new qe.Uint8Array(e)));case ad:case od:case ud:return Ei.eq(+s,+e);case ld:return s.name==e.name&&s.message==e.message;case hd:case fd:return s==e+"";case cd:var o=nd;case dd:var l=n&sd;if(o||(o=id),s.size!=e.size&&!l)return!1;var c=a.get(s);if(c)return c==e;n|=rd,a.set(s,e);var u=Gu(o(s),o(e),n,i,r,a);return a.delete(s),u;case pd:if(Ha)return Ha.call(s)==Ha.call(e)}return!1}var yd=1,xd=Object.prototype,vd=xd.hasOwnProperty;function Md(s,e,t,n,i,r){var a=t&yd,o=qe.getAllKeys(s),l=o.length,c=qe.getAllKeys(e),u=c.length;if(l!=u&&!a)return!1;for(var h=l;h--;){var d=o[h];if(!(a?d in e:vd.call(e,d)))return!1}var f=r.get(s),g=r.get(e);if(f&&g)return f==e&&g==s;var _=!0;r.set(s,e),r.set(e,s);for(var m=a;++h<l;){d=o[h];var p=s[d],S=e[d];if(n)var x=a?n(S,p,d,e,s,r):n(p,S,d,s,e,r);if(!(x===void 0?p===S||i(p,S,t,n,r):x)){_=!1;break}m||(m=d=="constructor")}if(_&&!m){var y=s.constructor,N=e.constructor;y!=N&&"constructor"in s&&"constructor"in e&&!(typeof y=="function"&&y instanceof y&&typeof N=="function"&&N instanceof N)&&(_=!1)}return r.delete(s),r.delete(e),_}var Sd=1,tc="[object Arguments]",nc="[object Array]",Ur="[object Object]",Td=Object.prototype,ic=Td.hasOwnProperty;function bd(s,e,t,n,i,r){var a=Ei.isArray(s),o=Ei.isArray(e),l=a?nc:qe.getTag(s),c=o?nc:qe.getTag(e);l=l==tc?Ur:l,c=c==tc?Ur:c;var u=l==Ur,h=c==Ur,d=l==c;if(d&&qe.isBuffer(s)){if(!qe.isBuffer(e))return!1;a=!0,u=!1}if(d&&!u)return r||(r=new qe.Stack),a||qe.isTypedArray(s)?Gu(s,e,t,n,i,r):_d(s,e,l,t,n,i,r);if(!(t&Sd)){var f=u&&ic.call(s,"__wrapped__"),g=h&&ic.call(e,"__wrapped__");if(f||g){var _=f?s.value():s,m=g?e.value():e;return r||(r=new qe.Stack),i(_,m,t,n,r)}}return d?(r||(r=new qe.Stack),Md(s,e,t,n,i,r)):!1}function Wu(s,e,t,n,i){return s===e?!0:s==null||e==null||!Ei.isObjectLike(s)&&!Ei.isObjectLike(e)?s!==s&&e!==e:bd(s,e,t,n,Wu,i)}function Ed(s,e){return Wu(s,e)}const Ad={__name:"index",props:{isVisible:{type:Boolean,default:!1},title:{type:String,default:""},width:{type:Number,default:200}},setup(s){const e=s,t=V.ref(null),n=V.ref(!1),i=V.ref(null);return V.watch(()=>e==null?void 0:e.isVisible,()=>{n.value=e==null?void 0:e.isVisible},{deep:!0,immediate:!0}),V.watch(()=>i.value,()=>{V.nextTick(()=>{var r,a;(a=(r=t.value)==null?void 0:r.updatePopper)==null||a.call(r)})},{deep:!0,immediate:!0}),(r,a)=>{const o=V.resolveComponent("el-popover");return V.openBlock(),V.createBlock(o,{visible:n.value,placement:"bottom",title:e==null?void 0:e.title,width:e==null?void 0:e.width,ref_key:"popOverRef",ref:t},{reference:V.withCtx(()=>[V.createElementVNode("div",null,[V.renderSlot(r.$slots,"reference",{ref_key:"referenceRef",ref:i})])]),default:V.withCtx(()=>[V.createElementVNode("div",null,[V.renderSlot(r.$slots,"content")])]),_:3},8,["visible","title","width"])}}},wd={class:"extra-button-content"},Rd={key:0,class:"extra-header"},Cd=["onClick"],Pd={class:"extra-button-filter"},Ld={class:"form-content-value"},Dd={__name:"header",props:{buttons:{type:Array,default:()=>[]},columns:{type:Array,default:()=>[]}},emits:["buttonClick","filter"],setup(s,{emit:e}){const t=e,n=s,i=V.ref(!1),r=V.ref([]),a=V.ref([{label:"取消"},{label:"确认"}]),o=u=>{t("buttonClick",u)},l=u=>{var h,d;r.value=(d=(h=Bn.getColumnChild(qe.cloneDeep(u)))==null?void 0:h.filter(f=>(f==null?void 0:f.label)!==""&&(f==null?void 0:f.label)!=="操作"))==null?void 0:d.map(f=>({label:(f==null?void 0:f.label)??"",value:"",name:(f==null?void 0:f.label)??"",isFormColHidden:f==null?void 0:f.isTableColHidden}))},c=u=>{(u==null?void 0:u.buttonName)==="确认"&&t("filter",u==null?void 0:u.content),i.value=!1};return V.onMounted(()=>{l(n.columns)}),V.watch(()=>n.columns,()=>{l(n.columns)},{deep:!0,immediate:!0}),(u,h)=>{var f;const d=V.resolveComponent("el-tooltip");return V.openBlock(),V.createElementBlock("div",wd,[n!=null&&n.buttons&&((f=n==null?void 0:n.buttons)==null?void 0:f.length)>0?(V.openBlock(),V.createElementBlock("div",Rd,[(V.openBlock(!0),V.createElementBlock(V.Fragment,null,V.renderList(n==null?void 0:n.buttons,(g,_)=>(V.openBlock(),V.createElementBlock("div",{class:"extra-contents",key:_},[V.createElementVNode("div",{class:"extra-content",style:V.normalizeStyle({background:(g==null?void 0:g.background)??"var(--ssComponent-primary-color)",color:"var(--system-bg)"}),onClick:m=>o(g==null?void 0:g.label)},V.toDisplayString(g==null?void 0:g.label),13,Cd)]))),128))])):V.createCommentVNode("",!0),V.createElementVNode("div",Pd,[V.createVNode(Ad,{title:"筛选数据",width:500,isVisible:i.value},{reference:V.withCtx(()=>[V.createVNode(d,{content:"筛选",placement:"top-start"},{default:V.withCtx(()=>[V.createElementVNode("div",{class:"button-style",onClick:h[0]||(h[0]=g=>i.value=!i.value)},[V.createVNode(V.unref(Ei.filter_default),{color:"var(--ssComponent-black)"})])]),_:1})]),content:V.withCtx(()=>[V.createElementVNode("div",Ld,[(V.openBlock(),V.createBlock(Bn.ssForm,{rowContents:r.value,buttonValue:a.value,isRowFlex:!0,isEnableWrap:!1,isButtonRow:!1,key:a.value,isStartJustify:!1,onOnButtonClick:c},null,8,["rowContents","buttonValue"]))])]),_:1},8,["isVisible"])])])}}},Id=Rl._export_sfc(Dd,[["__scopeId","data-v-e7197dc5"]]);/**
1
+ "use strict";const V=require("vue"),ur=require("./index-sYRfzwGi.cjs"),Vu=require("./modelComp-LhGhARtD.cjs"),Ai=require("./index-BPGk6VZT.cjs"),zn=require("./index-BReBoqZM.cjs"),Rl=require("./_plugin-vue_export-helper-BHFhmbuH.cjs"),Ke=require("./cloneDeep-BShYbOkw.cjs"),At=require("./menu-CH06rBlw.cjs"),Hu=require("./index-BJWxGK8l.cjs");var Yh="__lodash_hash_undefined__";function Zh(s){return this.__data__.set(s,Yh),this}function $h(s){return this.__data__.has(s)}function Ta(s){var e=-1,t=s==null?0:s.length;for(this.__data__=new Ai.MapCache;++e<t;)this.add(s[e])}Ta.prototype.add=Ta.prototype.push=Zh;Ta.prototype.has=$h;function Jh(s,e){for(var t=-1,n=s==null?0:s.length;++t<n;)if(e(s[t],t,s))return!0;return!1}function Qh(s,e){return s.has(e)}var ed=1,td=2;function Gu(s,e,t,n,i,r){var a=t&ed,o=s.length,l=e.length;if(o!=l&&!(a&&l>o))return!1;var c=r.get(s),u=r.get(e);if(c&&u)return c==e&&u==s;var h=-1,d=!0,f=t&td?new Ta:void 0;for(r.set(s,e),r.set(e,s);++h<o;){var g=s[h],_=e[h];if(n)var m=a?n(_,g,h,e,s,r):n(g,_,h,s,e,r);if(m!==void 0){if(m)continue;d=!1;break}if(f){if(!Jh(e,function(p,S){if(!Qh(f,S)&&(g===p||i(g,p,t,n,r)))return f.push(S)})){d=!1;break}}else if(!(g===_||i(g,_,t,n,r))){d=!1;break}}return r.delete(s),r.delete(e),d}function nd(s){var e=-1,t=Array(s.size);return s.forEach(function(n,i){t[++e]=[i,n]}),t}function id(s){var e=-1,t=Array(s.size);return s.forEach(function(n){t[++e]=n}),t}var sd=1,rd=2,ad="[object Boolean]",od="[object Date]",ld="[object Error]",cd="[object Map]",ud="[object Number]",hd="[object RegExp]",dd="[object Set]",fd="[object String]",pd="[object Symbol]",md="[object ArrayBuffer]",gd="[object DataView]",ec=Ai.Symbol?Ai.Symbol.prototype:void 0,Ha=ec?ec.valueOf:void 0;function _d(s,e,t,n,i,r,a){switch(t){case gd:if(s.byteLength!=e.byteLength||s.byteOffset!=e.byteOffset)return!1;s=s.buffer,e=e.buffer;case md:return!(s.byteLength!=e.byteLength||!r(new Ke.Uint8Array(s),new Ke.Uint8Array(e)));case ad:case od:case ud:return Ai.eq(+s,+e);case ld:return s.name==e.name&&s.message==e.message;case hd:case fd:return s==e+"";case cd:var o=nd;case dd:var l=n&sd;if(o||(o=id),s.size!=e.size&&!l)return!1;var c=a.get(s);if(c)return c==e;n|=rd,a.set(s,e);var u=Gu(o(s),o(e),n,i,r,a);return a.delete(s),u;case pd:if(Ha)return Ha.call(s)==Ha.call(e)}return!1}var yd=1,vd=Object.prototype,xd=vd.hasOwnProperty;function Md(s,e,t,n,i,r){var a=t&yd,o=Ke.getAllKeys(s),l=o.length,c=Ke.getAllKeys(e),u=c.length;if(l!=u&&!a)return!1;for(var h=l;h--;){var d=o[h];if(!(a?d in e:xd.call(e,d)))return!1}var f=r.get(s),g=r.get(e);if(f&&g)return f==e&&g==s;var _=!0;r.set(s,e),r.set(e,s);for(var m=a;++h<l;){d=o[h];var p=s[d],S=e[d];if(n)var v=a?n(S,p,d,e,s,r):n(p,S,d,s,e,r);if(!(v===void 0?p===S||i(p,S,t,n,r):v)){_=!1;break}m||(m=d=="constructor")}if(_&&!m){var y=s.constructor,N=e.constructor;y!=N&&"constructor"in s&&"constructor"in e&&!(typeof y=="function"&&y instanceof y&&typeof N=="function"&&N instanceof N)&&(_=!1)}return r.delete(s),r.delete(e),_}var Sd=1,tc="[object Arguments]",nc="[object Array]",Fr="[object Object]",Td=Object.prototype,ic=Td.hasOwnProperty;function bd(s,e,t,n,i,r){var a=Ai.isArray(s),o=Ai.isArray(e),l=a?nc:Ke.getTag(s),c=o?nc:Ke.getTag(e);l=l==tc?Fr:l,c=c==tc?Fr:c;var u=l==Fr,h=c==Fr,d=l==c;if(d&&Ke.isBuffer(s)){if(!Ke.isBuffer(e))return!1;a=!0,u=!1}if(d&&!u)return r||(r=new Ke.Stack),a||Ke.isTypedArray(s)?Gu(s,e,t,n,i,r):_d(s,e,l,t,n,i,r);if(!(t&Sd)){var f=u&&ic.call(s,"__wrapped__"),g=h&&ic.call(e,"__wrapped__");if(f||g){var _=f?s.value():s,m=g?e.value():e;return r||(r=new Ke.Stack),i(_,m,t,n,r)}}return d?(r||(r=new Ke.Stack),Md(s,e,t,n,i,r)):!1}function Wu(s,e,t,n,i){return s===e?!0:s==null||e==null||!Ai.isObjectLike(s)&&!Ai.isObjectLike(e)?s!==s&&e!==e:bd(s,e,t,n,Wu,i)}function Ed(s,e){return Wu(s,e)}const Ad={__name:"index",props:{isVisible:{type:Boolean,default:!1},title:{type:String,default:""},width:{type:Number,default:200}},setup(s){const e=s,t=V.ref(null),n=V.ref(!1),i=V.ref(null);return V.watch(()=>e==null?void 0:e.isVisible,()=>{n.value=e==null?void 0:e.isVisible},{deep:!0,immediate:!0}),V.watch(()=>i.value,()=>{V.nextTick(()=>{var r,a;(a=(r=t.value)==null?void 0:r.updatePopper)==null||a.call(r)})},{deep:!0,immediate:!0}),(r,a)=>{const o=V.resolveComponent("el-popover");return V.openBlock(),V.createBlock(o,{visible:n.value,placement:"bottom",title:e==null?void 0:e.title,width:e==null?void 0:e.width,ref_key:"popOverRef",ref:t},{reference:V.withCtx(()=>[V.createElementVNode("div",null,[V.renderSlot(r.$slots,"reference",{ref_key:"referenceRef",ref:i})])]),default:V.withCtx(()=>[V.createElementVNode("div",null,[V.renderSlot(r.$slots,"content")])]),_:3},8,["visible","title","width"])}}},wd={class:"extra-button-content"},Rd={key:0,class:"extra-header"},Cd=["onClick"],Pd={class:"extra-button-filter"},Ld={class:"form-content-value"},Dd={__name:"header",props:{buttons:{type:Array,default:()=>[]},columns:{type:Array,default:()=>[]}},emits:["buttonClick","filter"],setup(s,{emit:e}){const t=e,n=s,i=V.ref(!1),r=V.ref([]),a=V.ref([{label:"取消"},{label:"确认"}]),o=u=>{t("buttonClick",u)},l=u=>{var h,d;r.value=(d=(h=zn.getColumnChild(Ke.cloneDeep(u)))==null?void 0:h.filter(f=>(f==null?void 0:f.label)!==""&&(f==null?void 0:f.label)!=="操作"))==null?void 0:d.map(f=>({label:(f==null?void 0:f.label)??"",value:"",name:(f==null?void 0:f.label)??"",isFormColHidden:f==null?void 0:f.isTableColHidden}))},c=u=>{(u==null?void 0:u.buttonName)==="确认"&&t("filter",u==null?void 0:u.content),i.value=!1};return V.onMounted(()=>{l(n.columns)}),V.watch(()=>n.columns,()=>{l(n.columns)},{deep:!0,immediate:!0}),(u,h)=>{var f;const d=V.resolveComponent("el-tooltip");return V.openBlock(),V.createElementBlock("div",wd,[n!=null&&n.buttons&&((f=n==null?void 0:n.buttons)==null?void 0:f.length)>0?(V.openBlock(),V.createElementBlock("div",Rd,[(V.openBlock(!0),V.createElementBlock(V.Fragment,null,V.renderList(n==null?void 0:n.buttons,(g,_)=>(V.openBlock(),V.createElementBlock("div",{class:"extra-contents",key:_},[V.createElementVNode("div",{class:"extra-content",style:V.normalizeStyle({background:(g==null?void 0:g.background)??"var(--ssComponent-primary-color)",color:"var(--system-bg)"}),onClick:m=>o(g==null?void 0:g.label)},V.toDisplayString(g==null?void 0:g.label),13,Cd)]))),128))])):V.createCommentVNode("",!0),V.createElementVNode("div",Pd,[V.createVNode(Ad,{title:"筛选数据",width:500,isVisible:i.value},{reference:V.withCtx(()=>[V.createVNode(d,{content:"筛选",placement:"top-start"},{default:V.withCtx(()=>[V.createElementVNode("div",{class:"button-style",onClick:h[0]||(h[0]=g=>i.value=!i.value)},[V.createVNode(V.unref(Ai.filter_default),{color:"var(--ssComponent-black)"})])]),_:1})]),content:V.withCtx(()=>[V.createElementVNode("div",Ld,[(V.openBlock(),V.createBlock(zn.ssForm,{rowContents:r.value,buttonValue:a.value,isRowFlex:!0,isEnableWrap:!1,isButtonRow:!1,key:a.value,isStartJustify:!1,onOnButtonClick:c},null,8,["rowContents","buttonValue"]))])]),_:1},8,["isVisible"])])])}}},Id=Rl._export_sfc(Dd,[["__scopeId","data-v-e7197dc5"]]);/**
2
2
  * @license
3
3
  * Copyright 2010-2025 Three.js Authors
4
4
  * SPDX-License-Identifier: MIT
5
- */const Cl="177",Us={ROTATE:0,DOLLY:1,PAN:2},Ls={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Nd=0,sc=1,Ud=2,Xu=1,ju=2,xi=3,si=0,Ln=1,Yn=2,Hi=0,Fs=1,rc=2,ac=3,oc=4,Fd=5,ss=100,Od=101,kd=102,Bd=103,zd=104,Vd=200,Hd=201,Gd=202,Wd=203,No=204,Uo=205,Xd=206,jd=207,qd=208,Kd=209,Yd=210,Zd=211,$d=212,Jd=213,Qd=214,Fo=0,Oo=1,ko=2,zs=3,Bo=4,zo=5,Vo=6,Ho=7,Da=0,ef=1,tf=2,Gi=0,nf=1,sf=2,rf=3,af=4,of=5,lf=6,cf=7,lc="attached",uf="detached",qu=300,Vs=301,Hs=302,Ta=303,Go=304,Ia=306,Vn=1e3,Pn=1001,ba=1002,Sn=1003,Ku=1004,ar=1005,gn=1006,pa=1007,Jn=1008,ri=1009,Yu=1010,Zu=1011,fr=1012,Pl=1013,ls=1014,Qn=1015,wr=1016,Ll=1017,Dl=1018,pr=1020,$u=35902,Ju=1021,Qu=1022,Hn=1023,mr=1026,gr=1027,Il=1028,Nl=1029,eh=1030,Ul=1031,Fl=1033,ma=33776,ga=33777,_a=33778,ya=33779,Wo=35840,Xo=35841,jo=35842,qo=35843,Ko=36196,Yo=37492,Zo=37496,$o=37808,Jo=37809,Qo=37810,el=37811,tl=37812,nl=37813,il=37814,sl=37815,rl=37816,al=37817,ol=37818,ll=37819,cl=37820,ul=37821,xa=36492,hl=36494,dl=36495,th=36283,fl=36284,pl=36285,ml=36286,_r=2300,yr=2301,Ga=2302,cc=2400,uc=2401,hc=2402,hf=2500,df=0,nh=1,gl=2,ff=3200,pf=3201,Na=0,mf=1,zi="",_t="srgb",Tn="srgb-linear",Ea="linear",Ut="srgb",ms=7680,dc=519,gf=512,_f=513,yf=514,ih=515,xf=516,vf=517,Mf=518,Sf=519,_l=35044,fc="300 es",Si=2e3,Aa=2001;class ds{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 i=n[e];if(i!==void 0){const r=i.indexOf(t);r!==-1&&i.splice(r,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 i=n.slice(0);for(let r=0,a=i.length;r<a;r++)i[r].call(this,e);e.target=null}}}const pn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let pc=1234567;const ur=Math.PI/180,Gs=180/Math.PI;function ei(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(pn[s&255]+pn[s>>8&255]+pn[s>>16&255]+pn[s>>24&255]+"-"+pn[e&255]+pn[e>>8&255]+"-"+pn[e>>16&15|64]+pn[e>>24&255]+"-"+pn[t&63|128]+pn[t>>8&255]+"-"+pn[t>>16&255]+pn[t>>24&255]+pn[n&255]+pn[n>>8&255]+pn[n>>16&255]+pn[n>>24&255]).toLowerCase()}function yt(s,e,t){return Math.max(e,Math.min(t,s))}function Ol(s,e){return(s%e+e)%e}function Tf(s,e,t,n,i){return n+(s-e)*(i-n)/(t-e)}function bf(s,e,t){return s!==e?(t-s)/(e-s):0}function hr(s,e,t){return(1-t)*s+t*e}function Ef(s,e,t,n){return hr(s,e,1-Math.exp(-t*n))}function Af(s,e=1){return e-Math.abs(Ol(s,e*2)-e)}function wf(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function Rf(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function Cf(s,e){return s+Math.floor(Math.random()*(e-s+1))}function Pf(s,e){return s+Math.random()*(e-s)}function Lf(s){return s*(.5-Math.random())}function Df(s){s!==void 0&&(pc=s);let e=pc+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function If(s){return s*ur}function Nf(s){return s*Gs}function Uf(s){return(s&s-1)===0&&s!==0}function Ff(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function Of(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function kf(s,e,t,n,i){const r=Math.cos,a=Math.sin,o=r(t/2),l=a(t/2),c=r((e+n)/2),u=a((e+n)/2),h=r((e-n)/2),d=a((e-n)/2),f=r((n-e)/2),g=a((n-e)/2);switch(i){case"XYX":s.set(o*u,l*h,l*d,o*c);break;case"YZY":s.set(l*d,o*u,l*h,o*c);break;case"ZXZ":s.set(l*h,l*d,o*u,o*c);break;case"XZX":s.set(o*u,l*g,l*f,o*c);break;case"YXY":s.set(l*f,o*u,l*g,o*c);break;case"ZYZ":s.set(l*g,l*f,o*u,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Zn(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function It(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}const jt={DEG2RAD:ur,RAD2DEG:Gs,generateUUID:ei,clamp:yt,euclideanModulo:Ol,mapLinear:Tf,inverseLerp:bf,lerp:hr,damp:Ef,pingpong:Af,smoothstep:wf,smootherstep:Rf,randInt:Cf,randFloat:Pf,randFloatSpread:Lf,seededRandom:Df,degToRad:If,radToDeg:Nf,isPowerOfTwo:Uf,ceilPowerOfTwo:Ff,floorPowerOfTwo:Of,setQuaternionFromProperEuler:kf,normalize:It,denormalize:Zn};class ot{constructor(e=0,t=0){ot.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,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[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=yt(this.x,e.x,t.x),this.y=yt(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=yt(this.x,e,t),this.y=yt(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(yt(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(yt(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),i=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*i+e.x,this.y=r*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class tn{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,a,o){let l=n[i+0],c=n[i+1],u=n[i+2],h=n[i+3];const d=r[a+0],f=r[a+1],g=r[a+2],_=r[a+3];if(o===0){e[t+0]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h;return}if(o===1){e[t+0]=d,e[t+1]=f,e[t+2]=g,e[t+3]=_;return}if(h!==_||l!==d||c!==f||u!==g){let m=1-o;const p=l*d+c*f+u*g+h*_,S=p>=0?1:-1,x=1-p*p;if(x>Number.EPSILON){const N=Math.sqrt(x),P=Math.atan2(N,p*S);m=Math.sin(m*P)/N,o=Math.sin(o*P)/N}const y=o*S;if(l=l*m+d*y,c=c*m+f*y,u=u*m+g*y,h=h*m+_*y,m===1-o){const N=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=N,c*=N,u*=N,h*=N}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,r,a){const o=n[i],l=n[i+1],c=n[i+2],u=n[i+3],h=r[a],d=r[a+1],f=r[a+2],g=r[a+3];return e[t]=o*g+u*h+l*f-c*d,e[t+1]=l*g+u*d+c*h-o*f,e[t+2]=c*g+u*f+o*d-l*h,e[t+3]=u*g-o*h-l*d-c*f,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,i){return this._x=e,this._y=t,this._z=n,this._w=i,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,i=e._y,r=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(n/2),u=o(i/2),h=o(r/2),d=l(n/2),f=l(i/2),g=l(r/2);switch(a){case"XYZ":this._x=d*u*h+c*f*g,this._y=c*f*h-d*u*g,this._z=c*u*g+d*f*h,this._w=c*u*h-d*f*g;break;case"YXZ":this._x=d*u*h+c*f*g,this._y=c*f*h-d*u*g,this._z=c*u*g-d*f*h,this._w=c*u*h+d*f*g;break;case"ZXY":this._x=d*u*h-c*f*g,this._y=c*f*h+d*u*g,this._z=c*u*g+d*f*h,this._w=c*u*h-d*f*g;break;case"ZYX":this._x=d*u*h-c*f*g,this._y=c*f*h+d*u*g,this._z=c*u*g-d*f*h,this._w=c*u*h+d*f*g;break;case"YZX":this._x=d*u*h+c*f*g,this._y=c*f*h+d*u*g,this._z=c*u*g-d*f*h,this._w=c*u*h-d*f*g;break;case"XZY":this._x=d*u*h-c*f*g,this._y=c*f*h-d*u*g,this._z=c*u*g+d*f*h,this._w=c*u*h+d*f*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],a=t[1],o=t[5],l=t[9],c=t[2],u=t[6],h=t[10],d=n+o+h;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(u-l)*f,this._y=(r-c)*f,this._z=(a-i)*f}else if(n>o&&n>h){const f=2*Math.sqrt(1+n-o-h);this._w=(u-l)/f,this._x=.25*f,this._y=(i+a)/f,this._z=(r+c)/f}else if(o>h){const f=2*Math.sqrt(1+o-n-h);this._w=(r-c)/f,this._x=(i+a)/f,this._y=.25*f,this._z=(l+u)/f}else{const f=2*Math.sqrt(1+h-n-o);this._w=(a-i)/f,this._x=(r+c)/f,this._y=(l+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(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(yt(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(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,i=e._y,r=e._z,a=e._w,o=t._x,l=t._y,c=t._z,u=t._w;return this._x=n*u+a*o+i*c-r*l,this._y=i*u+a*l+r*o-n*c,this._z=r*u+a*c+n*l-i*o,this._w=a*u-n*o-i*l-r*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,i=this._y,r=this._z,a=this._w;let o=a*e._w+n*e._x+i*e._y+r*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=i,this._z=r,this;const l=1-o*o;if(l<=Number.EPSILON){const f=1-t;return this._w=f*a+t*this._w,this._x=f*n+t*this._x,this._y=f*i+t*this._y,this._z=f*r+t*this._z,this.normalize(),this}const c=Math.sqrt(l),u=Math.atan2(c,o),h=Math.sin((1-t)*u)/c,d=Math.sin(t*u)/c;return this._w=a*h+this._w*d,this._x=n*h+this._x*d,this._y=i*h+this._y*d,this._z=r*h+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(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class O{constructor(e=0,t=0,n=0){O.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(mc.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(mc.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*i-o*n),u=2*(o*t-r*i),h=2*(r*n-a*t);return this.x=t+l*c+a*h-o*u,this.y=n+l*u+o*c-r*h,this.z=i+l*h+r*u-a*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,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,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=yt(this.x,e.x,t.x),this.y=yt(this.y,e.y,t.y),this.z=yt(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=yt(this.x,e,t),this.y=yt(this.y,e,t),this.z=yt(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(yt(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,i=e.y,r=e.z,a=t.x,o=t.y,l=t.z;return this.x=i*l-r*o,this.y=r*a-n*l,this.z=n*o-i*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Wa.copy(this).projectOnVector(e),this.sub(Wa)}reflect(e){return this.sub(Wa.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(yt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}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 i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*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(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,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 Wa=new O,mc=new tn;class gt{constructor(e,t,n,i,r,a,o,l,c){gt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,r,a,o,l,c)}set(e,t,n,i,r,a,o,l,c){const u=this.elements;return u[0]=e,u[1]=i,u[2]=o,u[3]=t,u[4]=r,u[5]=l,u[6]=n,u[7]=a,u[8]=c,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,i=t.elements,r=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],u=n[4],h=n[7],d=n[2],f=n[5],g=n[8],_=i[0],m=i[3],p=i[6],S=i[1],x=i[4],y=i[7],N=i[2],P=i[5],L=i[8];return r[0]=a*_+o*S+l*N,r[3]=a*m+o*x+l*P,r[6]=a*p+o*y+l*L,r[1]=c*_+u*S+h*N,r[4]=c*m+u*x+h*P,r[7]=c*p+u*y+h*L,r[2]=d*_+f*S+g*N,r[5]=d*m+f*x+g*P,r[8]=d*p+f*y+g*L,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],i=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return t*a*u-t*o*c-n*r*u+n*o*l+i*r*c-i*a*l}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],h=u*a-o*c,d=o*l-u*r,f=c*r-a*l,g=t*h+n*d+i*f;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/g;return e[0]=h*_,e[1]=(i*c-u*n)*_,e[2]=(o*n-i*a)*_,e[3]=d*_,e[4]=(u*t-i*l)*_,e[5]=(i*r-o*t)*_,e[6]=f*_,e[7]=(n*l-c*t)*_,e[8]=(a*t-n*r)*_,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,i,r,a,o){const l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*a+c*o)+a+e,-i*c,i*l,-i*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Xa.makeScale(e,t)),this}rotate(e){return this.premultiply(Xa.makeRotation(-e)),this}translate(e,t){return this.premultiply(Xa.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 i=0;i<9;i++)if(t[i]!==n[i])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 Xa=new gt;function sh(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}function xr(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function Bf(){const s=xr("canvas");return s.style.display="block",s}const gc={};function Os(s){s in gc||(gc[s]=!0,console.warn(s))}function zf(s,e,t){return new Promise(function(n,i){function r(){switch(s.clientWaitSync(e,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:i();break;case s.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}function Vf(s){const e=s.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function Hf(s){const e=s.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}const _c=new gt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),yc=new gt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Gf(){const s={enabled:!0,workingColorSpace:Tn,spaces:{},convert:function(i,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===Ut&&(i.r=bi(i.r),i.g=bi(i.g),i.b=bi(i.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[r].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Ut&&(i.r=ks(i.r),i.g=ks(i.g),i.b=ks(i.b))),i},workingToColorSpace:function(i,r){return this.convert(i,this.workingColorSpace,r)},colorSpaceToWorking:function(i,r){return this.convert(i,r,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===zi?Ea:this.spaces[i].transfer},getLuminanceCoefficients:function(i,r=this.workingColorSpace){return i.fromArray(this.spaces[r].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,r,a){return i.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,r){return Os("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(i,r)},toWorkingColorSpace:function(i,r){return Os("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(i,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return s.define({[Tn]:{primaries:e,whitePoint:n,transfer:Ea,toXYZ:_c,fromXYZ:yc,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:_t},outputColorSpaceConfig:{drawingBufferColorSpace:_t}},[_t]:{primaries:e,whitePoint:n,transfer:Ut,toXYZ:_c,fromXYZ:yc,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:_t}}}),s}const pt=Gf();function bi(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function ks(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let gs;class Wf{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{gs===void 0&&(gs=xr("canvas")),gs.width=e.width,gs.height=e.height;const i=gs.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),n=gs}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=xr("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let a=0;a<r.length;a++)r[a]=bi(r[a]/255)*255;return n.putImageData(i,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(bi(t[n]/255)*255):t[n]=bi(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 Xf=0;class kl{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Xf++}),this.uuid=ei(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight):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:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?r.push(ja(i[a].image)):r.push(ja(i[a]))}else r=ja(i);n.url=r}return t||(e.images[this.uuid]=n),n}}function ja(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?Wf.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let jf=0;const qa=new O;class rn extends ds{constructor(e=rn.DEFAULT_IMAGE,t=rn.DEFAULT_MAPPING,n=Pn,i=Pn,r=gn,a=Jn,o=Hn,l=ri,c=rn.DEFAULT_ANISOTROPY,u=zi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:jf++}),this.uuid=ei(),this.name="",this.source=new kl(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new ot(0,0),this.repeat=new ot(1,1),this.center=new ot(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new gt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=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(qa).x}get height(){return this.source.getSize(qa).y}get depth(){return this.source.getSize(qa).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 i=this[t];if(i===void 0){console.warn(`THREE.Texture.setValues(): property '${t}' does not exist.`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.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!==qu)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Vn:e.x=e.x-Math.floor(e.x);break;case Pn:e.x=e.x<0?0:1;break;case ba: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 Vn:e.y=e.y-Math.floor(e.y);break;case Pn:e.y=e.y<0?0:1;break;case ba: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++}}rn.DEFAULT_IMAGE=null;rn.DEFAULT_MAPPING=qu;rn.DEFAULT_ANISOTROPY=1;class Tt{constructor(e=0,t=0,n=0,i=1){Tt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}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,i){return this.x=e,this.y=t,this.z=n,this.w=i,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,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*r,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,i,r;const l=e.elements,c=l[0],u=l[4],h=l[8],d=l[1],f=l[5],g=l[9],_=l[2],m=l[6],p=l[10];if(Math.abs(u-d)<.01&&Math.abs(h-_)<.01&&Math.abs(g-m)<.01){if(Math.abs(u+d)<.1&&Math.abs(h+_)<.1&&Math.abs(g+m)<.1&&Math.abs(c+f+p-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const x=(c+1)/2,y=(f+1)/2,N=(p+1)/2,P=(u+d)/4,L=(h+_)/4,U=(g+m)/4;return x>y&&x>N?x<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(x),i=P/n,r=L/n):y>N?y<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(y),n=P/i,r=U/i):N<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(N),n=L/r,i=U/r),this.set(n,i,r,t),this}let S=Math.sqrt((m-g)*(m-g)+(h-_)*(h-_)+(d-u)*(d-u));return Math.abs(S)<.001&&(S=1),this.x=(m-g)/S,this.y=(h-_)/S,this.z=(d-u)/S,this.w=Math.acos((c+f+p-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=yt(this.x,e.x,t.x),this.y=yt(this.y,e.y,t.y),this.z=yt(this.z,e.z,t.z),this.w=yt(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=yt(this.x,e,t),this.y=yt(this.y,e,t),this.z=yt(this.z,e,t),this.w=yt(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(yt(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 qf extends ds{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:gn,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 Tt(0,0,e,t),this.scissorTest=!1,this.viewport=new Tt(0,0,e,t);const i={width:e,height:t,depth:n.depth},r=new rn(i);this.textures=[];const a=n.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){const t={minFilter:gn,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 i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isArrayTexture=this.textures[i].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 i=Object.assign({},e.textures[t].image);this.textures[t].source=new kl(i)}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 cs extends qf{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class rh extends rn{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Sn,this.minFilter=Sn,this.wrapR=Pn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Kf extends rn{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Sn,this.minFilter=Sn,this.wrapR=Pn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ri{constructor(e=new O(1/0,1/0,1/0),t=new O(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Wn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Wn.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=Wn.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 r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Wn):Wn.fromBufferAttribute(r,a),Wn.applyMatrix4(e.matrixWorld),this.expandByPoint(Wn);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 i=e.children;for(let r=0,a=i.length;r<a;r++)this.expandByObject(i[r],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,Wn),Wn.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($s),Or.subVectors(this.max,$s),_s.subVectors(e.a,$s),ys.subVectors(e.b,$s),xs.subVectors(e.c,$s),Li.subVectors(ys,_s),Di.subVectors(xs,ys),Zi.subVectors(_s,xs);let t=[0,-Li.z,Li.y,0,-Di.z,Di.y,0,-Zi.z,Zi.y,Li.z,0,-Li.x,Di.z,0,-Di.x,Zi.z,0,-Zi.x,-Li.y,Li.x,0,-Di.y,Di.x,0,-Zi.y,Zi.x,0];return!Ka(t,_s,ys,xs,Or)||(t=[1,0,0,0,1,0,0,0,1],!Ka(t,_s,ys,xs,Or))?!1:(kr.crossVectors(Li,Di),t=[kr.x,kr.y,kr.z],Ka(t,_s,ys,xs,Or))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Wn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Wn).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:(fi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),fi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),fi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),fi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),fi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),fi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),fi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),fi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(fi),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 fi=[new O,new O,new O,new O,new O,new O,new O,new O],Wn=new O,Fr=new Ri,_s=new O,ys=new O,xs=new O,Li=new O,Di=new O,Zi=new O,$s=new O,Or=new O,kr=new O,$i=new O;function Ka(s,e,t,n,i){for(let r=0,a=s.length-3;r<=a;r+=3){$i.fromArray(s,r);const o=i.x*Math.abs($i.x)+i.y*Math.abs($i.y)+i.z*Math.abs($i.z),l=e.dot($i),c=t.dot($i),u=n.dot($i);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const Yf=new Ri,Js=new O,Ya=new O;class ai{constructor(e=new O,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):Yf.setFromPoints(e).getCenter(n);let i=0;for(let r=0,a=e.length;r<a;r++)i=Math.max(i,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),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;Js.subVectors(e,this.center);const t=Js.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(Js,i/n),this.radius+=i}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(Js.copy(e.center).add(Ya)),this.expandByPoint(Js.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 pi=new O,Za=new O,Br=new O,Ii=new O,$a=new O,zr=new O,Ja=new O;class Rr{constructor(e=new O,t=new O(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,pi)),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=pi.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(pi.copy(this.origin).addScaledVector(this.direction,t),pi.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Za.copy(e).add(t).multiplyScalar(.5),Br.copy(t).sub(e).normalize(),Ii.copy(this.origin).sub(Za);const r=e.distanceTo(t)*.5,a=-this.direction.dot(Br),o=Ii.dot(this.direction),l=-Ii.dot(Br),c=Ii.lengthSq(),u=Math.abs(1-a*a);let h,d,f,g;if(u>0)if(h=a*l-o,d=a*o-l,g=r*u,h>=0)if(d>=-g)if(d<=g){const _=1/u;h*=_,d*=_,f=h*(h+a*d+2*o)+d*(a*h+d+2*l)+c}else d=r,h=Math.max(0,-(a*d+o)),f=-h*h+d*(d+2*l)+c;else d=-r,h=Math.max(0,-(a*d+o)),f=-h*h+d*(d+2*l)+c;else d<=-g?(h=Math.max(0,-(-a*r+o)),d=h>0?-r:Math.min(Math.max(-r,-l),r),f=-h*h+d*(d+2*l)+c):d<=g?(h=0,d=Math.min(Math.max(-r,-l),r),f=d*(d+2*l)+c):(h=Math.max(0,-(a*r+o)),d=h>0?r:Math.min(Math.max(-r,-l),r),f=-h*h+d*(d+2*l)+c);else d=a>0?-r:r,h=Math.max(0,-(a*d+o)),f=-h*h+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(Za).addScaledVector(Br,d),f}intersectSphere(e,t){pi.subVectors(e.center,this.origin);const n=pi.dot(this.direction),i=pi.dot(pi)-n*n,r=e.radius*e.radius;if(i>r)return null;const a=Math.sqrt(r-i),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,a,o,l;const c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,i=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,i=(e.min.x-d.x)*c),u>=0?(r=(e.min.y-d.y)*u,a=(e.max.y-d.y)*u):(r=(e.max.y-d.y)*u,a=(e.min.y-d.y)*u),n>a||r>i||((r>n||isNaN(n))&&(n=r),(a<i||isNaN(i))&&(i=a),h>=0?(o=(e.min.z-d.z)*h,l=(e.max.z-d.z)*h):(o=(e.max.z-d.z)*h,l=(e.min.z-d.z)*h),n>l||o>i)||((o>n||n!==n)&&(n=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,pi)!==null}intersectTriangle(e,t,n,i,r){$a.subVectors(t,e),zr.subVectors(n,e),Ja.crossVectors($a,zr);let a=this.direction.dot(Ja),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Ii.subVectors(this.origin,e);const l=o*this.direction.dot(zr.crossVectors(Ii,zr));if(l<0)return null;const c=o*this.direction.dot($a.cross(Ii));if(c<0||l+c>a)return null;const u=-o*Ii.dot(Ja);return u<0?null:this.at(u/a,r)}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 Fe{constructor(e,t,n,i,r,a,o,l,c,u,h,d,f,g,_,m){Fe.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,i,r,a,o,l,c,u,h,d,f,g,_,m)}set(e,t,n,i,r,a,o,l,c,u,h,d,f,g,_,m){const p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=i,p[1]=r,p[5]=a,p[9]=o,p[13]=l,p[2]=c,p[6]=u,p[10]=h,p[14]=d,p[3]=f,p[7]=g,p[11]=_,p[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 Fe().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,i=1/vs.setFromMatrixColumn(e,0).length(),r=1/vs.setFromMatrixColumn(e,1).length(),a=1/vs.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,r=e.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(i),c=Math.sin(i),u=Math.cos(r),h=Math.sin(r);if(e.order==="XYZ"){const d=a*u,f=a*h,g=o*u,_=o*h;t[0]=l*u,t[4]=-l*h,t[8]=c,t[1]=f+g*c,t[5]=d-_*c,t[9]=-o*l,t[2]=_-d*c,t[6]=g+f*c,t[10]=a*l}else if(e.order==="YXZ"){const d=l*u,f=l*h,g=c*u,_=c*h;t[0]=d+_*o,t[4]=g*o-f,t[8]=a*c,t[1]=a*h,t[5]=a*u,t[9]=-o,t[2]=f*o-g,t[6]=_+d*o,t[10]=a*l}else if(e.order==="ZXY"){const d=l*u,f=l*h,g=c*u,_=c*h;t[0]=d-_*o,t[4]=-a*h,t[8]=g+f*o,t[1]=f+g*o,t[5]=a*u,t[9]=_-d*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const d=a*u,f=a*h,g=o*u,_=o*h;t[0]=l*u,t[4]=g*c-f,t[8]=d*c+_,t[1]=l*h,t[5]=_*c+d,t[9]=f*c-g,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const d=a*l,f=a*c,g=o*l,_=o*c;t[0]=l*u,t[4]=_-d*h,t[8]=g*h+f,t[1]=h,t[5]=a*u,t[9]=-o*u,t[2]=-c*u,t[6]=f*h+g,t[10]=d-_*h}else if(e.order==="XZY"){const d=a*l,f=a*c,g=o*l,_=o*c;t[0]=l*u,t[4]=-h,t[8]=c*u,t[1]=d*h+_,t[5]=a*u,t[9]=f*h-g,t[2]=g*h-f,t[6]=o*u,t[10]=_*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(Zf,e,$f)}lookAt(e,t,n){const i=this.elements;return In.subVectors(e,t),In.lengthSq()===0&&(In.z=1),In.normalize(),Ni.crossVectors(n,In),Ni.lengthSq()===0&&(Math.abs(n.z)===1?In.x+=1e-4:In.z+=1e-4,In.normalize(),Ni.crossVectors(n,In)),Ni.normalize(),Vr.crossVectors(In,Ni),i[0]=Ni.x,i[4]=Vr.x,i[8]=In.x,i[1]=Ni.y,i[5]=Vr.y,i[9]=In.y,i[2]=Ni.z,i[6]=Vr.z,i[10]=In.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],u=n[1],h=n[5],d=n[9],f=n[13],g=n[2],_=n[6],m=n[10],p=n[14],S=n[3],x=n[7],y=n[11],N=n[15],P=i[0],L=i[4],U=i[8],E=i[12],T=i[1],D=i[5],X=i[9],j=i[13],se=i[2],de=i[6],k=i[10],ae=i[14],G=i[3],pe=i[7],Me=i[11],le=i[15];return r[0]=a*P+o*T+l*se+c*G,r[4]=a*L+o*D+l*de+c*pe,r[8]=a*U+o*X+l*k+c*Me,r[12]=a*E+o*j+l*ae+c*le,r[1]=u*P+h*T+d*se+f*G,r[5]=u*L+h*D+d*de+f*pe,r[9]=u*U+h*X+d*k+f*Me,r[13]=u*E+h*j+d*ae+f*le,r[2]=g*P+_*T+m*se+p*G,r[6]=g*L+_*D+m*de+p*pe,r[10]=g*U+_*X+m*k+p*Me,r[14]=g*E+_*j+m*ae+p*le,r[3]=S*P+x*T+y*se+N*G,r[7]=S*L+x*D+y*de+N*pe,r[11]=S*U+x*X+y*k+N*Me,r[15]=S*E+x*j+y*ae+N*le,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],i=e[8],r=e[12],a=e[1],o=e[5],l=e[9],c=e[13],u=e[2],h=e[6],d=e[10],f=e[14],g=e[3],_=e[7],m=e[11],p=e[15];return g*(+r*l*h-i*c*h-r*o*d+n*c*d+i*o*f-n*l*f)+_*(+t*l*f-t*c*d+r*a*d-i*a*f+i*c*u-r*l*u)+m*(+t*c*h-t*o*f-r*a*h+n*a*f+r*o*u-n*c*u)+p*(-i*o*u-t*l*h+t*o*d+i*a*h-n*a*d+n*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,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],h=e[9],d=e[10],f=e[11],g=e[12],_=e[13],m=e[14],p=e[15],S=h*m*c-_*d*c+_*l*f-o*m*f-h*l*p+o*d*p,x=g*d*c-u*m*c-g*l*f+a*m*f+u*l*p-a*d*p,y=u*_*c-g*h*c+g*o*f-a*_*f-u*o*p+a*h*p,N=g*h*l-u*_*l-g*o*d+a*_*d+u*o*m-a*h*m,P=t*S+n*x+i*y+r*N;if(P===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const L=1/P;return e[0]=S*L,e[1]=(_*d*r-h*m*r-_*i*f+n*m*f+h*i*p-n*d*p)*L,e[2]=(o*m*r-_*l*r+_*i*c-n*m*c-o*i*p+n*l*p)*L,e[3]=(h*l*r-o*d*r-h*i*c+n*d*c+o*i*f-n*l*f)*L,e[4]=x*L,e[5]=(u*m*r-g*d*r+g*i*f-t*m*f-u*i*p+t*d*p)*L,e[6]=(g*l*r-a*m*r-g*i*c+t*m*c+a*i*p-t*l*p)*L,e[7]=(a*d*r-u*l*r+u*i*c-t*d*c-a*i*f+t*l*f)*L,e[8]=y*L,e[9]=(g*h*r-u*_*r-g*n*f+t*_*f+u*n*p-t*h*p)*L,e[10]=(a*_*r-g*o*r+g*n*c-t*_*c-a*n*p+t*o*p)*L,e[11]=(u*o*r-a*h*r-u*n*c+t*h*c+a*n*f-t*o*f)*L,e[12]=N*L,e[13]=(u*_*i-g*h*i+g*n*d-t*_*d-u*n*m+t*h*m)*L,e[14]=(g*o*i-a*_*i-g*n*l+t*_*l+a*n*m-t*o*m)*L,e[15]=(a*h*i-u*o*i+u*n*l-t*h*l-a*n*d+t*o*d)*L,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,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],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}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),i=Math.sin(t),r=1-n,a=e.x,o=e.y,l=e.z,c=r*a,u=r*o;return this.set(c*a+n,c*o-i*l,c*l+i*o,0,c*o+i*l,u*o+n,u*l-i*a,0,c*l-i*o,u*l+i*a,r*l*l+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,i,r,a){return this.set(1,n,r,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,a=t._y,o=t._z,l=t._w,c=r+r,u=a+a,h=o+o,d=r*c,f=r*u,g=r*h,_=a*u,m=a*h,p=o*h,S=l*c,x=l*u,y=l*h,N=n.x,P=n.y,L=n.z;return i[0]=(1-(_+p))*N,i[1]=(f+y)*N,i[2]=(g-x)*N,i[3]=0,i[4]=(f-y)*P,i[5]=(1-(d+p))*P,i[6]=(m+S)*P,i[7]=0,i[8]=(g+x)*L,i[9]=(m-S)*L,i[10]=(1-(d+_))*L,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let r=vs.set(i[0],i[1],i[2]).length();const a=vs.set(i[4],i[5],i[6]).length(),o=vs.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],Xn.copy(this);const c=1/r,u=1/a,h=1/o;return Xn.elements[0]*=c,Xn.elements[1]*=c,Xn.elements[2]*=c,Xn.elements[4]*=u,Xn.elements[5]*=u,Xn.elements[6]*=u,Xn.elements[8]*=h,Xn.elements[9]*=h,Xn.elements[10]*=h,t.setFromRotationMatrix(Xn),n.x=r,n.y=a,n.z=o,this}makePerspective(e,t,n,i,r,a,o=Si){const l=this.elements,c=2*r/(t-e),u=2*r/(n-i),h=(t+e)/(t-e),d=(n+i)/(n-i);let f,g;if(o===Si)f=-(a+r)/(a-r),g=-2*a*r/(a-r);else if(o===Aa)f=-a/(a-r),g=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=h,l[12]=0,l[1]=0,l[5]=u,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=f,l[14]=g,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,i,r,a,o=Si){const l=this.elements,c=1/(t-e),u=1/(n-i),h=1/(a-r),d=(t+e)*c,f=(n+i)*u;let g,_;if(o===Si)g=(a+r)*h,_=-2*h;else if(o===Aa)g=r*h,_=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-f,l[2]=0,l[6]=0,l[10]=_,l[14]=-g,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])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 vs=new O,Xn=new Fe,Zf=new O(0,0,0),$f=new O(1,1,1),Ni=new O,Vr=new O,In=new O,xc=new Fe,vc=new tn;class nn{constructor(e=0,t=0,n=0,i=nn.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}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,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,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 i=e.elements,r=i[0],a=i[4],o=i[8],l=i[1],c=i[5],u=i[9],h=i[2],d=i[6],f=i[10];switch(t){case"XYZ":this._y=Math.asin(yt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-yt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(yt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-yt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(yt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-yt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-u,f),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 xc.makeRotationFromQuaternion(e),this.setFromRotationMatrix(xc,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return vc.setFromEuler(this),this.setFromQuaternion(vc,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}}nn.DEFAULT_ORDER="XYZ";class ah{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 Jf=0;const Mc=new O,Ms=new tn,mi=new Fe,Hr=new O,Qs=new O,Qf=new O,ep=new tn,Sc=new O(1,0,0),Tc=new O(0,1,0),bc=new O(0,0,1),Ec={type:"added"},tp={type:"removed"},Ss={type:"childadded",child:null},Qa={type:"childremoved",child:null};class kt extends ds{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Jf++}),this.uuid=ei(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=kt.DEFAULT_UP.clone();const e=new O,t=new nn,n=new tn,i=new O(1,1,1);function r(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Fe},normalMatrix:{value:new gt}}),this.matrix=new Fe,this.matrixWorld=new Fe,this.matrixAutoUpdate=kt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=kt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new ah,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 Ms.setFromAxisAngle(e,t),this.quaternion.multiply(Ms),this}rotateOnWorldAxis(e,t){return Ms.setFromAxisAngle(e,t),this.quaternion.premultiply(Ms),this}rotateX(e){return this.rotateOnAxis(Sc,e)}rotateY(e){return this.rotateOnAxis(Tc,e)}rotateZ(e){return this.rotateOnAxis(bc,e)}translateOnAxis(e,t){return Mc.copy(e).applyQuaternion(this.quaternion),this.position.add(Mc.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Sc,e)}translateY(e){return this.translateOnAxis(Tc,e)}translateZ(e){return this.translateOnAxis(bc,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(mi.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Hr.copy(e):Hr.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),Qs.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?mi.lookAt(Qs,Hr,this.up):mi.lookAt(Hr,Qs,this.up),this.quaternion.setFromRotationMatrix(mi),i&&(mi.extractRotation(i.matrixWorld),Ms.setFromRotationMatrix(mi),this.quaternion.premultiply(Ms.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(Ec),Ss.child=e,this.dispatchEvent(Ss),Ss.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(tp),Qa.child=e,this.dispatchEvent(Qa),Qa.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),mi.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),mi.multiply(e.parent.matrixWorld)),e.applyMatrix4(mi),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Ec),Ss.child=e,this.dispatchEvent(Ss),Ss.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,i=this.children.length;n<i;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const i=this.children;for(let r=0,a=i.length;r<a;r++)i[r].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(Qs,e,Qf),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Qs,ep,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,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;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,i=t.length;n<i;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 i=this.children;for(let r=0,a=i.length;r<a;r++)i[r].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 i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c<u;c++){const h=l[c];r(e.shapes,h)}else r(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(r(e.materials,this.material[l]));i.material=o}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];i.animations.push(r(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),u=a(e.images),h=a(e.shapes),d=a(e.skeletons),f=a(e.animations),g=a(e.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),u.length>0&&(n.images=u),h.length>0&&(n.shapes=h),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),g.length>0&&(n.nodes=g)}return n.object=i,n;function a(o){const l=[];for(const c in o){const u=o[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 n=0;n<e.children.length;n++){const i=e.children[n];this.add(i.clone())}return this}}kt.DEFAULT_UP=new O(0,1,0);kt.DEFAULT_MATRIX_AUTO_UPDATE=!0;kt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const jn=new O,gi=new O,eo=new O,_i=new O,Ts=new O,bs=new O,Ac=new O,to=new O,no=new O,io=new O,so=new Tt,ro=new Tt,ao=new Tt;class $n{constructor(e=new O,t=new O,n=new O){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),jn.subVectors(e,t),i.cross(jn);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){jn.subVectors(i,t),gi.subVectors(n,t),eo.subVectors(e,t);const a=jn.dot(jn),o=jn.dot(gi),l=jn.dot(eo),c=gi.dot(gi),u=gi.dot(eo),h=a*c-o*o;if(h===0)return r.set(0,0,0),null;const d=1/h,f=(c*l-o*u)*d,g=(a*u-o*l)*d;return r.set(1-f-g,g,f)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,_i)===null?!1:_i.x>=0&&_i.y>=0&&_i.x+_i.y<=1}static getInterpolation(e,t,n,i,r,a,o,l){return this.getBarycoord(e,t,n,i,_i)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,_i.x),l.addScaledVector(a,_i.y),l.addScaledVector(o,_i.z),l)}static getInterpolatedAttribute(e,t,n,i,r,a){return so.setScalar(0),ro.setScalar(0),ao.setScalar(0),so.fromBufferAttribute(e,t),ro.fromBufferAttribute(e,n),ao.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(so,r.x),a.addScaledVector(ro,r.y),a.addScaledVector(ao,r.z),a}static isFrontFacing(e,t,n,i){return jn.subVectors(n,t),gi.subVectors(e,t),jn.cross(gi).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),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 jn.subVectors(this.c,this.b),gi.subVectors(this.a,this.b),jn.cross(gi).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return $n.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return $n.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return $n.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return $n.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return $n.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,r=this.c;let a,o;Ts.subVectors(i,n),bs.subVectors(r,n),to.subVectors(e,n);const l=Ts.dot(to),c=bs.dot(to);if(l<=0&&c<=0)return t.copy(n);no.subVectors(e,i);const u=Ts.dot(no),h=bs.dot(no);if(u>=0&&h<=u)return t.copy(i);const d=l*h-u*c;if(d<=0&&l>=0&&u<=0)return a=l/(l-u),t.copy(n).addScaledVector(Ts,a);io.subVectors(e,r);const f=Ts.dot(io),g=bs.dot(io);if(g>=0&&f<=g)return t.copy(r);const _=f*c-l*g;if(_<=0&&c>=0&&g<=0)return o=c/(c-g),t.copy(n).addScaledVector(bs,o);const m=u*g-f*h;if(m<=0&&h-u>=0&&f-g>=0)return Ac.subVectors(r,i),o=(h-u)/(h-u+(f-g)),t.copy(i).addScaledVector(Ac,o);const p=1/(m+_+d);return a=_*p,o=d*p,t.copy(n).addScaledVector(Ts,a).addScaledVector(bs,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const oh={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},Gr={h:0,s:0,l:0};function oo(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}class He{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 i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=_t){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,pt.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=pt.workingColorSpace){return this.r=e,this.g=t,this.b=n,pt.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=pt.workingColorSpace){if(e=Ol(e,1),t=yt(t,0,1),n=yt(n,0,1),t===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,a=2*n-r;this.r=oo(a,r,e+1/3),this.g=oo(a,r,e),this.b=oo(a,r,e-1/3)}return pt.colorSpaceToWorking(this,i),this}setStyle(e,t=_t){function n(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=i[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,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=_t){const n=oh[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=bi(e.r),this.g=bi(e.g),this.b=bi(e.b),this}copyLinearToSRGB(e){return this.r=ks(e.r),this.g=ks(e.g),this.b=ks(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=_t){return pt.workingToColorSpace(mn.copy(this),e),Math.round(yt(mn.r*255,0,255))*65536+Math.round(yt(mn.g*255,0,255))*256+Math.round(yt(mn.b*255,0,255))}getHexString(e=_t){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=pt.workingColorSpace){pt.workingToColorSpace(mn.copy(this),t);const n=mn.r,i=mn.g,r=mn.b,a=Math.max(n,i,r),o=Math.min(n,i,r);let l,c;const u=(o+a)/2;if(o===a)l=0,c=0;else{const h=a-o;switch(c=u<=.5?h/(a+o):h/(2-a-o),a){case n:l=(i-r)/h+(i<r?6:0);break;case i:l=(r-n)/h+2;break;case r:l=(n-i)/h+4;break}l/=6}return e.h=l,e.s=c,e.l=u,e}getRGB(e,t=pt.workingColorSpace){return pt.workingToColorSpace(mn.copy(this),t),e.r=mn.r,e.g=mn.g,e.b=mn.b,e}getStyle(e=_t){pt.workingToColorSpace(mn.copy(this),e);const t=mn.r,n=mn.g,i=mn.b;return e!==_t?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(Ui),this.setHSL(Ui.h+e,Ui.s+t,Ui.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(Ui),e.getHSL(Gr);const n=hr(Ui.h,Gr.h,t),i=hr(Ui.s,Gr.s,t),r=hr(Ui.l,Gr.l,t);return this.setHSL(n,i,r),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,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,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 mn=new He;He.NAMES=oh;let np=0;class Dn extends ds{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:np++}),this.uuid=ei(),this.name="",this.type="Material",this.blending=Fs,this.side=si,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=No,this.blendDst=Uo,this.blendEquation=ss,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new He(0,0,0),this.blendAlpha=0,this.depthFunc=zs,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=dc,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ms,this.stencilZFail=ms,this.stencilZPass=ms,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 i=this[t];if(i===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.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.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!==Fs&&(n.blending=this.blending),this.side!==si&&(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!==No&&(n.blendSrc=this.blendSrc),this.blendDst!==Uo&&(n.blendDst=this.blendDst),this.blendEquation!==ss&&(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!==zs&&(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!==dc&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ms&&(n.stencilFail=this.stencilFail),this.stencilZFail!==ms&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==ms&&(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 i(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(t){const r=i(e.textures),a=i(e.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const i=t.length;n=new Array(i);for(let r=0;r!==i;++r)n[r]=t[r].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 Ti extends Dn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new He(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 nn,this.combine=Da,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 $t=new O,Wr=new ot;let ip=0;class un{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:ip++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=_l,this.updateRanges=[],this.gpuType=Qn,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 i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];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++)Wr.fromBufferAttribute(this,t),Wr.applyMatrix3(e),this.setXY(t,Wr.x,Wr.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)$t.fromBufferAttribute(this,t),$t.applyMatrix3(e),this.setXYZ(t,$t.x,$t.y,$t.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)$t.fromBufferAttribute(this,t),$t.applyMatrix4(e),this.setXYZ(t,$t.x,$t.y,$t.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)$t.fromBufferAttribute(this,t),$t.applyNormalMatrix(e),this.setXYZ(t,$t.x,$t.y,$t.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)$t.fromBufferAttribute(this,t),$t.transformDirection(e),this.setXYZ(t,$t.x,$t.y,$t.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=Zn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=It(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Zn(t,this.array)),t}setX(e,t){return this.normalized&&(t=It(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Zn(t,this.array)),t}setY(e,t){return this.normalized&&(t=It(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=Zn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=It(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=Zn(t,this.array)),t}setW(e,t){return this.normalized&&(t=It(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=It(t,this.array),n=It(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=It(t,this.array),n=It(n,this.array),i=It(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e*=this.itemSize,this.normalized&&(t=It(t,this.array),n=It(n,this.array),i=It(i,this.array),r=It(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,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!==_l&&(e.usage=this.usage),e}}class Bl extends un{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class lh extends un{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class xt extends un{constructor(e,t,n){super(new Float32Array(e),t,n)}}let sp=0;const Fn=new Fe,lo=new kt,Es=new O,Nn=new Ri,er=new Ri,ln=new O;class Kt extends ds{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:sp++}),this.uuid=ei(),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(sh(e)?lh:Bl)(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 r=new gt().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Fn.makeRotationFromQuaternion(e),this.applyMatrix4(Fn),this}rotateX(e){return Fn.makeRotationX(e),this.applyMatrix4(Fn),this}rotateY(e){return Fn.makeRotationY(e),this.applyMatrix4(Fn),this}rotateZ(e){return Fn.makeRotationZ(e),this.applyMatrix4(Fn),this}translate(e,t,n){return Fn.makeTranslation(e,t,n),this.applyMatrix4(Fn),this}scale(e,t,n){return Fn.makeScale(e,t,n),this.applyMatrix4(Fn),this}lookAt(e){return lo.lookAt(e),lo.updateMatrix(),this.applyMatrix4(lo.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Es).negate(),this.translate(Es.x,Es.y,Es.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let i=0,r=e.length;i<r;i++){const a=e[i];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new xt(n,3))}else{const n=Math.min(e.length,t.count);for(let i=0;i<n;i++){const r=e[i];t.setXYZ(i,r.x,r.y,r.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 Ri);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new O(-1/0,-1/0,-1/0),new O(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){const r=t[n];Nn.setFromBufferAttribute(r),this.morphTargetsRelative?(ln.addVectors(this.boundingBox.min,Nn.min),this.boundingBox.expandByPoint(ln),ln.addVectors(this.boundingBox.max,Nn.max),this.boundingBox.expandByPoint(ln)):(this.boundingBox.expandByPoint(Nn.min),this.boundingBox.expandByPoint(Nn.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 ai);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new O,1/0);return}if(e){const n=this.boundingSphere.center;if(Nn.setFromBufferAttribute(e),t)for(let r=0,a=t.length;r<a;r++){const o=t[r];er.setFromBufferAttribute(o),this.morphTargetsRelative?(ln.addVectors(Nn.min,er.min),Nn.expandByPoint(ln),ln.addVectors(Nn.max,er.max),Nn.expandByPoint(ln)):(Nn.expandByPoint(er.min),Nn.expandByPoint(er.max))}Nn.getCenter(n);let i=0;for(let r=0,a=e.count;r<a;r++)ln.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(ln));if(t)for(let r=0,a=t.length;r<a;r++){const o=t[r],l=this.morphTargetsRelative;for(let c=0,u=o.count;c<u;c++)ln.fromBufferAttribute(o,c),l&&(Es.fromBufferAttribute(e,c),ln.add(Es)),i=Math.max(i,n.distanceToSquared(ln))}this.boundingSphere.radius=Math.sqrt(i),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,i=t.normal,r=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new un(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let U=0;U<n.count;U++)o[U]=new O,l[U]=new O;const c=new O,u=new O,h=new O,d=new ot,f=new ot,g=new ot,_=new O,m=new O;function p(U,E,T){c.fromBufferAttribute(n,U),u.fromBufferAttribute(n,E),h.fromBufferAttribute(n,T),d.fromBufferAttribute(r,U),f.fromBufferAttribute(r,E),g.fromBufferAttribute(r,T),u.sub(c),h.sub(c),f.sub(d),g.sub(d);const D=1/(f.x*g.y-g.x*f.y);isFinite(D)&&(_.copy(u).multiplyScalar(g.y).addScaledVector(h,-f.y).multiplyScalar(D),m.copy(h).multiplyScalar(f.x).addScaledVector(u,-g.x).multiplyScalar(D),o[U].add(_),o[E].add(_),o[T].add(_),l[U].add(m),l[E].add(m),l[T].add(m))}let S=this.groups;S.length===0&&(S=[{start:0,count:e.count}]);for(let U=0,E=S.length;U<E;++U){const T=S[U],D=T.start,X=T.count;for(let j=D,se=D+X;j<se;j+=3)p(e.getX(j+0),e.getX(j+1),e.getX(j+2))}const x=new O,y=new O,N=new O,P=new O;function L(U){N.fromBufferAttribute(i,U),P.copy(N);const E=o[U];x.copy(E),x.sub(N.multiplyScalar(N.dot(E))).normalize(),y.crossVectors(P,E);const D=y.dot(l[U])<0?-1:1;a.setXYZW(U,x.x,x.y,x.z,D)}for(let U=0,E=S.length;U<E;++U){const T=S[U],D=T.start,X=T.count;for(let j=D,se=D+X;j<se;j+=3)L(e.getX(j+0)),L(e.getX(j+1)),L(e.getX(j+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 un(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);const i=new O,r=new O,a=new O,o=new O,l=new O,c=new O,u=new O,h=new O;if(e)for(let d=0,f=e.count;d<f;d+=3){const g=e.getX(d+0),_=e.getX(d+1),m=e.getX(d+2);i.fromBufferAttribute(t,g),r.fromBufferAttribute(t,_),a.fromBufferAttribute(t,m),u.subVectors(a,r),h.subVectors(i,r),u.cross(h),o.fromBufferAttribute(n,g),l.fromBufferAttribute(n,_),c.fromBufferAttribute(n,m),o.add(u),l.add(u),c.add(u),n.setXYZ(g,o.x,o.y,o.z),n.setXYZ(_,l.x,l.y,l.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let d=0,f=t.count;d<f;d+=3)i.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,d+2),u.subVectors(a,r),h.subVectors(i,r),u.cross(h),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++)ln.fromBufferAttribute(e,t),ln.normalize(),e.setXYZ(t,ln.x,ln.y,ln.z)}toNonIndexed(){function e(o,l){const c=o.array,u=o.itemSize,h=o.normalized,d=new c.constructor(l.length*u);let f=0,g=0;for(let _=0,m=l.length;_<m;_++){o.isInterleavedBufferAttribute?f=l[_]*o.data.stride+o.offset:f=l[_]*u;for(let p=0;p<u;p++)d[g++]=c[f++]}return new un(d,u,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Kt,n=this.index.array,i=this.attributes;for(const o in i){const l=i[o],c=e(l,n);t.setAttribute(o,c)}const r=this.morphAttributes;for(const o in r){const l=[],c=r[o];for(let u=0,h=c.length;u<h;u++){const d=c[u],f=e(d,n);l.push(f)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];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 n=this.attributes;for(const l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let h=0,d=c.length;h<d;h++){const f=c[h];u.push(f.toJSON(e.data))}u.length>0&&(i[l]=u,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const i=e.attributes;for(const c in i){const u=i[c];this.setAttribute(c,u.clone(t))}const r=e.morphAttributes;for(const c in r){const u=[],h=r[c];for(let d=0,f=h.length;d<f;d++)u.push(h[d].clone(t));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,u=a.length;c<u;c++){const h=a[c];this.addGroup(h.start,h.count,h.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.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 wc=new Fe,Ji=new Rr,Xr=new ai,Rc=new O,jr=new O,qr=new O,Kr=new O,co=new O,Yr=new O,Cc=new O,Zr=new O;class sn extends kt{constructor(e=new Kt,t=new Ti){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 i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(r&&o){Yr.set(0,0,0);for(let l=0,c=r.length;l<c;l++){const u=o[l],h=r[l];u!==0&&(co.fromBufferAttribute(h,e),a?Yr.addScaledVector(co,u):Yr.addScaledVector(co.sub(t),u))}t.add(Yr)}return t}raycast(e,t){const n=this.geometry,i=this.material,r=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Xr.copy(n.boundingSphere),Xr.applyMatrix4(r),Ji.copy(e.ray).recast(e.near),!(Xr.containsPoint(Ji.origin)===!1&&(Ji.intersectSphere(Xr,Rc)===null||Ji.origin.distanceToSquared(Rc)>(e.far-e.near)**2))&&(wc.copy(r).invert(),Ji.copy(e.ray).applyMatrix4(wc),!(n.boundingBox!==null&&Ji.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Ji)))}_computeIntersections(e,t,n){let i;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,u=r.attributes.uv1,h=r.attributes.normal,d=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,_=d.length;g<_;g++){const m=d[g],p=a[m.materialIndex],S=Math.max(m.start,f.start),x=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let y=S,N=x;y<N;y+=3){const P=o.getX(y),L=o.getX(y+1),U=o.getX(y+2);i=$r(this,p,e,n,c,u,h,P,L,U),i&&(i.faceIndex=Math.floor(y/3),i.face.materialIndex=m.materialIndex,t.push(i))}}else{const g=Math.max(0,f.start),_=Math.min(o.count,f.start+f.count);for(let m=g,p=_;m<p;m+=3){const S=o.getX(m),x=o.getX(m+1),y=o.getX(m+2);i=$r(this,a,e,n,c,u,h,S,x,y),i&&(i.faceIndex=Math.floor(m/3),t.push(i))}}else if(l!==void 0)if(Array.isArray(a))for(let g=0,_=d.length;g<_;g++){const m=d[g],p=a[m.materialIndex],S=Math.max(m.start,f.start),x=Math.min(l.count,Math.min(m.start+m.count,f.start+f.count));for(let y=S,N=x;y<N;y+=3){const P=y,L=y+1,U=y+2;i=$r(this,p,e,n,c,u,h,P,L,U),i&&(i.faceIndex=Math.floor(y/3),i.face.materialIndex=m.materialIndex,t.push(i))}}else{const g=Math.max(0,f.start),_=Math.min(l.count,f.start+f.count);for(let m=g,p=_;m<p;m+=3){const S=m,x=m+1,y=m+2;i=$r(this,a,e,n,c,u,h,S,x,y),i&&(i.faceIndex=Math.floor(m/3),t.push(i))}}}}function rp(s,e,t,n,i,r,a,o){let l;if(e.side===Ln?l=n.intersectTriangle(a,r,i,!0,o):l=n.intersectTriangle(i,r,a,e.side===si,o),l===null)return null;Zr.copy(o),Zr.applyMatrix4(s.matrixWorld);const c=t.ray.origin.distanceTo(Zr);return c<t.near||c>t.far?null:{distance:c,point:Zr.clone(),object:s}}function $r(s,e,t,n,i,r,a,o,l,c){s.getVertexPosition(o,jr),s.getVertexPosition(l,qr),s.getVertexPosition(c,Kr);const u=rp(s,e,t,n,jr,qr,Kr,Cc);if(u){const h=new O;$n.getBarycoord(Cc,jr,qr,Kr,h),i&&(u.uv=$n.getInterpolatedAttribute(i,o,l,c,h,new ot)),r&&(u.uv1=$n.getInterpolatedAttribute(r,o,l,c,h,new ot)),a&&(u.normal=$n.getInterpolatedAttribute(a,o,l,c,h,new O),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));const d={a:o,b:l,c,normal:new O,materialIndex:0};$n.getNormal(jr,qr,Kr,d.normal),u.face=d,u.barycoord=h}return u}class Cr extends Kt{constructor(e=1,t=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};const o=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);const l=[],c=[],u=[],h=[];let d=0,f=0;g("z","y","x",-1,-1,n,t,e,a,r,0),g("z","y","x",1,-1,n,t,-e,a,r,1),g("x","z","y",1,1,e,n,t,i,a,2),g("x","z","y",1,-1,e,n,-t,i,a,3),g("x","y","z",1,-1,e,t,n,i,r,4),g("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(l),this.setAttribute("position",new xt(c,3)),this.setAttribute("normal",new xt(u,3)),this.setAttribute("uv",new xt(h,2));function g(_,m,p,S,x,y,N,P,L,U,E){const T=y/L,D=N/U,X=y/2,j=N/2,se=P/2,de=L+1,k=U+1;let ae=0,G=0;const pe=new O;for(let Me=0;Me<k;Me++){const le=Me*D-j;for(let we=0;we<de;we++){const be=we*T-X;pe[_]=be*S,pe[m]=le*x,pe[p]=se,c.push(pe.x,pe.y,pe.z),pe[_]=0,pe[m]=0,pe[p]=P>0?1:-1,u.push(pe.x,pe.y,pe.z),h.push(we/L),h.push(1-Me/U),ae+=1}}for(let Me=0;Me<U;Me++)for(let le=0;le<L;le++){const we=d+le+de*Me,be=d+le+de*(Me+1),W=d+(le+1)+de*(Me+1),$=d+(le+1)+de*Me;l.push(we,be,$),l.push(be,W,$),G+=6}o.addGroup(f,G,E),f+=G,d+=ae}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Cr(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Ws(s){const e={};for(const t in s){e[t]={};for(const n in s[t]){const i=s[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=i.clone():Array.isArray(i)?e[t][n]=i.slice():e[t][n]=i}}return e}function vn(s){const e={};for(let t=0;t<s.length;t++){const n=Ws(s[t]);for(const i in n)e[i]=n[i]}return e}function ap(s){const e=[];for(let t=0;t<s.length;t++)e.push(s[t].clone());return e}function ch(s){const e=s.getRenderTarget();return e===null?s.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:pt.workingColorSpace}const op={clone:Ws,merge:vn};var lp=`void main() {
5
+ */const Cl="177",Fs={ROTATE:0,DOLLY:1,PAN:2},Ds={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Nd=0,sc=1,Ud=2,Xu=1,ju=2,xi=3,ri=0,In=1,Zn=2,Hi=0,Os=1,rc=2,ac=3,oc=4,Fd=5,ss=100,Od=101,kd=102,Bd=103,zd=104,Vd=200,Hd=201,Gd=202,Wd=203,No=204,Uo=205,Xd=206,jd=207,qd=208,Kd=209,Yd=210,Zd=211,$d=212,Jd=213,Qd=214,Fo=0,Oo=1,ko=2,Vs=3,Bo=4,zo=5,Vo=6,Ho=7,Ia=0,ef=1,tf=2,Gi=0,nf=1,sf=2,rf=3,af=4,of=5,lf=6,cf=7,lc="attached",uf="detached",qu=300,Hs=301,Gs=302,ba=303,Go=304,Na=306,Hn=1e3,Dn=1001,Ea=1002,En=1003,Ku=1004,or=1005,yn=1006,ma=1007,Qn=1008,ai=1009,Yu=1010,Zu=1011,pr=1012,Pl=1013,ls=1014,ei=1015,Rr=1016,Ll=1017,Dl=1018,mr=1020,$u=35902,Ju=1021,Qu=1022,Gn=1023,gr=1026,_r=1027,Il=1028,Nl=1029,eh=1030,Ul=1031,Fl=1033,ga=33776,_a=33777,ya=33778,va=33779,Wo=35840,Xo=35841,jo=35842,qo=35843,Ko=36196,Yo=37492,Zo=37496,$o=37808,Jo=37809,Qo=37810,el=37811,tl=37812,nl=37813,il=37814,sl=37815,rl=37816,al=37817,ol=37818,ll=37819,cl=37820,ul=37821,xa=36492,hl=36494,dl=36495,th=36283,fl=36284,pl=36285,ml=36286,yr=2300,vr=2301,Ga=2302,cc=2400,uc=2401,hc=2402,hf=2500,df=0,nh=1,gl=2,ff=3200,pf=3201,Ua=0,mf=1,zi="",_t="srgb",An="srgb-linear",Aa="linear",Ut="srgb",gs=7680,dc=519,gf=512,_f=513,yf=514,ih=515,vf=516,xf=517,Mf=518,Sf=519,_l=35044,fc="300 es",Ti=2e3,wa=2001;class ds{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 i=n[e];if(i!==void 0){const r=i.indexOf(t);r!==-1&&i.splice(r,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 i=n.slice(0);for(let r=0,a=i.length;r<a;r++)i[r].call(this,e);e.target=null}}}const gn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let pc=1234567;const hr=Math.PI/180,Ws=180/Math.PI;function ti(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(gn[s&255]+gn[s>>8&255]+gn[s>>16&255]+gn[s>>24&255]+"-"+gn[e&255]+gn[e>>8&255]+"-"+gn[e>>16&15|64]+gn[e>>24&255]+"-"+gn[t&63|128]+gn[t>>8&255]+"-"+gn[t>>16&255]+gn[t>>24&255]+gn[n&255]+gn[n>>8&255]+gn[n>>16&255]+gn[n>>24&255]).toLowerCase()}function yt(s,e,t){return Math.max(e,Math.min(t,s))}function Ol(s,e){return(s%e+e)%e}function Tf(s,e,t,n,i){return n+(s-e)*(i-n)/(t-e)}function bf(s,e,t){return s!==e?(t-s)/(e-s):0}function dr(s,e,t){return(1-t)*s+t*e}function Ef(s,e,t,n){return dr(s,e,1-Math.exp(-t*n))}function Af(s,e=1){return e-Math.abs(Ol(s,e*2)-e)}function wf(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function Rf(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function Cf(s,e){return s+Math.floor(Math.random()*(e-s+1))}function Pf(s,e){return s+Math.random()*(e-s)}function Lf(s){return s*(.5-Math.random())}function Df(s){s!==void 0&&(pc=s);let e=pc+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function If(s){return s*hr}function Nf(s){return s*Ws}function Uf(s){return(s&s-1)===0&&s!==0}function Ff(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function Of(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function kf(s,e,t,n,i){const r=Math.cos,a=Math.sin,o=r(t/2),l=a(t/2),c=r((e+n)/2),u=a((e+n)/2),h=r((e-n)/2),d=a((e-n)/2),f=r((n-e)/2),g=a((n-e)/2);switch(i){case"XYX":s.set(o*u,l*h,l*d,o*c);break;case"YZY":s.set(l*d,o*u,l*h,o*c);break;case"ZXZ":s.set(l*h,l*d,o*u,o*c);break;case"XZX":s.set(o*u,l*g,l*f,o*c);break;case"YXY":s.set(l*f,o*u,l*g,o*c);break;case"ZYZ":s.set(l*g,l*f,o*u,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function $n(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function It(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}const Xt={DEG2RAD:hr,RAD2DEG:Ws,generateUUID:ti,clamp:yt,euclideanModulo:Ol,mapLinear:Tf,inverseLerp:bf,lerp:dr,damp:Ef,pingpong:Af,smoothstep:wf,smootherstep:Rf,randInt:Cf,randFloat:Pf,randFloatSpread:Lf,seededRandom:Df,degToRad:If,radToDeg:Nf,isPowerOfTwo:Uf,ceilPowerOfTwo:Ff,floorPowerOfTwo:Of,setQuaternionFromProperEuler:kf,normalize:It,denormalize:$n};class ct{constructor(e=0,t=0){ct.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,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[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=yt(this.x,e.x,t.x),this.y=yt(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=yt(this.x,e,t),this.y=yt(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(yt(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(yt(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),i=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*i+e.x,this.y=r*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class nn{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,a,o){let l=n[i+0],c=n[i+1],u=n[i+2],h=n[i+3];const d=r[a+0],f=r[a+1],g=r[a+2],_=r[a+3];if(o===0){e[t+0]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h;return}if(o===1){e[t+0]=d,e[t+1]=f,e[t+2]=g,e[t+3]=_;return}if(h!==_||l!==d||c!==f||u!==g){let m=1-o;const p=l*d+c*f+u*g+h*_,S=p>=0?1:-1,v=1-p*p;if(v>Number.EPSILON){const N=Math.sqrt(v),P=Math.atan2(N,p*S);m=Math.sin(m*P)/N,o=Math.sin(o*P)/N}const y=o*S;if(l=l*m+d*y,c=c*m+f*y,u=u*m+g*y,h=h*m+_*y,m===1-o){const N=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=N,c*=N,u*=N,h*=N}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,r,a){const o=n[i],l=n[i+1],c=n[i+2],u=n[i+3],h=r[a],d=r[a+1],f=r[a+2],g=r[a+3];return e[t]=o*g+u*h+l*f-c*d,e[t+1]=l*g+u*d+c*h-o*f,e[t+2]=c*g+u*f+o*d-l*h,e[t+3]=u*g-o*h-l*d-c*f,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,i){return this._x=e,this._y=t,this._z=n,this._w=i,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,i=e._y,r=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(n/2),u=o(i/2),h=o(r/2),d=l(n/2),f=l(i/2),g=l(r/2);switch(a){case"XYZ":this._x=d*u*h+c*f*g,this._y=c*f*h-d*u*g,this._z=c*u*g+d*f*h,this._w=c*u*h-d*f*g;break;case"YXZ":this._x=d*u*h+c*f*g,this._y=c*f*h-d*u*g,this._z=c*u*g-d*f*h,this._w=c*u*h+d*f*g;break;case"ZXY":this._x=d*u*h-c*f*g,this._y=c*f*h+d*u*g,this._z=c*u*g+d*f*h,this._w=c*u*h-d*f*g;break;case"ZYX":this._x=d*u*h-c*f*g,this._y=c*f*h+d*u*g,this._z=c*u*g-d*f*h,this._w=c*u*h+d*f*g;break;case"YZX":this._x=d*u*h+c*f*g,this._y=c*f*h+d*u*g,this._z=c*u*g-d*f*h,this._w=c*u*h-d*f*g;break;case"XZY":this._x=d*u*h-c*f*g,this._y=c*f*h-d*u*g,this._z=c*u*g+d*f*h,this._w=c*u*h+d*f*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],a=t[1],o=t[5],l=t[9],c=t[2],u=t[6],h=t[10],d=n+o+h;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(u-l)*f,this._y=(r-c)*f,this._z=(a-i)*f}else if(n>o&&n>h){const f=2*Math.sqrt(1+n-o-h);this._w=(u-l)/f,this._x=.25*f,this._y=(i+a)/f,this._z=(r+c)/f}else if(o>h){const f=2*Math.sqrt(1+o-n-h);this._w=(r-c)/f,this._x=(i+a)/f,this._y=.25*f,this._z=(l+u)/f}else{const f=2*Math.sqrt(1+h-n-o);this._w=(a-i)/f,this._x=(r+c)/f,this._y=(l+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(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(yt(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(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,i=e._y,r=e._z,a=e._w,o=t._x,l=t._y,c=t._z,u=t._w;return this._x=n*u+a*o+i*c-r*l,this._y=i*u+a*l+r*o-n*c,this._z=r*u+a*c+n*l-i*o,this._w=a*u-n*o-i*l-r*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,i=this._y,r=this._z,a=this._w;let o=a*e._w+n*e._x+i*e._y+r*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=i,this._z=r,this;const l=1-o*o;if(l<=Number.EPSILON){const f=1-t;return this._w=f*a+t*this._w,this._x=f*n+t*this._x,this._y=f*i+t*this._y,this._z=f*r+t*this._z,this.normalize(),this}const c=Math.sqrt(l),u=Math.atan2(c,o),h=Math.sin((1-t)*u)/c,d=Math.sin(t*u)/c;return this._w=a*h+this._w*d,this._x=n*h+this._x*d,this._y=i*h+this._y*d,this._z=r*h+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(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class O{constructor(e=0,t=0,n=0){O.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(mc.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(mc.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*i-o*n),u=2*(o*t-r*i),h=2*(r*n-a*t);return this.x=t+l*c+a*h-o*u,this.y=n+l*u+o*c-r*h,this.z=i+l*h+r*u-a*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,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,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=yt(this.x,e.x,t.x),this.y=yt(this.y,e.y,t.y),this.z=yt(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=yt(this.x,e,t),this.y=yt(this.y,e,t),this.z=yt(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(yt(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,i=e.y,r=e.z,a=t.x,o=t.y,l=t.z;return this.x=i*l-r*o,this.y=r*a-n*l,this.z=n*o-i*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Wa.copy(this).projectOnVector(e),this.sub(Wa)}reflect(e){return this.sub(Wa.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(yt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}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 i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*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(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,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 Wa=new O,mc=new nn;class gt{constructor(e,t,n,i,r,a,o,l,c){gt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,r,a,o,l,c)}set(e,t,n,i,r,a,o,l,c){const u=this.elements;return u[0]=e,u[1]=i,u[2]=o,u[3]=t,u[4]=r,u[5]=l,u[6]=n,u[7]=a,u[8]=c,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,i=t.elements,r=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],u=n[4],h=n[7],d=n[2],f=n[5],g=n[8],_=i[0],m=i[3],p=i[6],S=i[1],v=i[4],y=i[7],N=i[2],P=i[5],L=i[8];return r[0]=a*_+o*S+l*N,r[3]=a*m+o*v+l*P,r[6]=a*p+o*y+l*L,r[1]=c*_+u*S+h*N,r[4]=c*m+u*v+h*P,r[7]=c*p+u*y+h*L,r[2]=d*_+f*S+g*N,r[5]=d*m+f*v+g*P,r[8]=d*p+f*y+g*L,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],i=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return t*a*u-t*o*c-n*r*u+n*o*l+i*r*c-i*a*l}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],h=u*a-o*c,d=o*l-u*r,f=c*r-a*l,g=t*h+n*d+i*f;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/g;return e[0]=h*_,e[1]=(i*c-u*n)*_,e[2]=(o*n-i*a)*_,e[3]=d*_,e[4]=(u*t-i*l)*_,e[5]=(i*r-o*t)*_,e[6]=f*_,e[7]=(n*l-c*t)*_,e[8]=(a*t-n*r)*_,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,i,r,a,o){const l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*a+c*o)+a+e,-i*c,i*l,-i*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Xa.makeScale(e,t)),this}rotate(e){return this.premultiply(Xa.makeRotation(-e)),this}translate(e,t){return this.premultiply(Xa.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 i=0;i<9;i++)if(t[i]!==n[i])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 Xa=new gt;function sh(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}function xr(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function Bf(){const s=xr("canvas");return s.style.display="block",s}const gc={};function ks(s){s in gc||(gc[s]=!0,console.warn(s))}function zf(s,e,t){return new Promise(function(n,i){function r(){switch(s.clientWaitSync(e,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:i();break;case s.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}function Vf(s){const e=s.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function Hf(s){const e=s.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}const _c=new gt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),yc=new gt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Gf(){const s={enabled:!0,workingColorSpace:An,spaces:{},convert:function(i,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===Ut&&(i.r=Ei(i.r),i.g=Ei(i.g),i.b=Ei(i.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[r].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Ut&&(i.r=Bs(i.r),i.g=Bs(i.g),i.b=Bs(i.b))),i},workingToColorSpace:function(i,r){return this.convert(i,this.workingColorSpace,r)},colorSpaceToWorking:function(i,r){return this.convert(i,r,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===zi?Aa:this.spaces[i].transfer},getLuminanceCoefficients:function(i,r=this.workingColorSpace){return i.fromArray(this.spaces[r].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,r,a){return i.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,r){return ks("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(i,r)},toWorkingColorSpace:function(i,r){return ks("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(i,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return s.define({[An]:{primaries:e,whitePoint:n,transfer:Aa,toXYZ:_c,fromXYZ:yc,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:_t},outputColorSpaceConfig:{drawingBufferColorSpace:_t}},[_t]:{primaries:e,whitePoint:n,transfer:Ut,toXYZ:_c,fromXYZ:yc,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:_t}}}),s}const ft=Gf();function Ei(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function Bs(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let _s;class Wf{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{_s===void 0&&(_s=xr("canvas")),_s.width=e.width,_s.height=e.height;const i=_s.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),n=_s}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=xr("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let a=0;a<r.length;a++)r[a]=Ei(r[a]/255)*255;return n.putImageData(i,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(Ei(t[n]/255)*255):t[n]=Ei(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 Xf=0;class kl{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Xf++}),this.uuid=ti(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight):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:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?r.push(ja(i[a].image)):r.push(ja(i[a]))}else r=ja(i);n.url=r}return t||(e.images[this.uuid]=n),n}}function ja(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?Wf.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let jf=0;const qa=new O;class an extends ds{constructor(e=an.DEFAULT_IMAGE,t=an.DEFAULT_MAPPING,n=Dn,i=Dn,r=yn,a=Qn,o=Gn,l=ai,c=an.DEFAULT_ANISOTROPY,u=zi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:jf++}),this.uuid=ti(),this.name="",this.source=new kl(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new ct(0,0),this.repeat=new ct(1,1),this.center=new ct(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new gt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=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(qa).x}get height(){return this.source.getSize(qa).y}get depth(){return this.source.getSize(qa).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 i=this[t];if(i===void 0){console.warn(`THREE.Texture.setValues(): property '${t}' does not exist.`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.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!==qu)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Hn:e.x=e.x-Math.floor(e.x);break;case Dn:e.x=e.x<0?0:1;break;case Ea: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 Hn:e.y=e.y-Math.floor(e.y);break;case Dn:e.y=e.y<0?0:1;break;case Ea: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++}}an.DEFAULT_IMAGE=null;an.DEFAULT_MAPPING=qu;an.DEFAULT_ANISOTROPY=1;class Tt{constructor(e=0,t=0,n=0,i=1){Tt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}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,i){return this.x=e,this.y=t,this.z=n,this.w=i,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,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*r,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,i,r;const l=e.elements,c=l[0],u=l[4],h=l[8],d=l[1],f=l[5],g=l[9],_=l[2],m=l[6],p=l[10];if(Math.abs(u-d)<.01&&Math.abs(h-_)<.01&&Math.abs(g-m)<.01){if(Math.abs(u+d)<.1&&Math.abs(h+_)<.1&&Math.abs(g+m)<.1&&Math.abs(c+f+p-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const v=(c+1)/2,y=(f+1)/2,N=(p+1)/2,P=(u+d)/4,L=(h+_)/4,U=(g+m)/4;return v>y&&v>N?v<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(v),i=P/n,r=L/n):y>N?y<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(y),n=P/i,r=U/i):N<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(N),n=L/r,i=U/r),this.set(n,i,r,t),this}let S=Math.sqrt((m-g)*(m-g)+(h-_)*(h-_)+(d-u)*(d-u));return Math.abs(S)<.001&&(S=1),this.x=(m-g)/S,this.y=(h-_)/S,this.z=(d-u)/S,this.w=Math.acos((c+f+p-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=yt(this.x,e.x,t.x),this.y=yt(this.y,e.y,t.y),this.z=yt(this.z,e.z,t.z),this.w=yt(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=yt(this.x,e,t),this.y=yt(this.y,e,t),this.z=yt(this.z,e,t),this.w=yt(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(yt(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 qf extends ds{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:yn,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 Tt(0,0,e,t),this.scissorTest=!1,this.viewport=new Tt(0,0,e,t);const i={width:e,height:t,depth:n.depth},r=new an(i);this.textures=[];const a=n.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){const t={minFilter:yn,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 i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isArrayTexture=this.textures[i].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 i=Object.assign({},e.textures[t].image);this.textures[t].source=new kl(i)}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 cs extends qf{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class rh extends an{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=En,this.minFilter=En,this.wrapR=Dn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Kf extends an{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=En,this.minFilter=En,this.wrapR=Dn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ci{constructor(e=new O(1/0,1/0,1/0),t=new O(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Xn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Xn.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=Xn.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 r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Xn):Xn.fromBufferAttribute(r,a),Xn.applyMatrix4(e.matrixWorld),this.expandByPoint(Xn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Or.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Or.copy(n.boundingBox)),Or.applyMatrix4(e.matrixWorld),this.union(Or)}const i=e.children;for(let r=0,a=i.length;r<a;r++)this.expandByObject(i[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Xn),Xn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,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(Js),kr.subVectors(this.max,Js),ys.subVectors(e.a,Js),vs.subVectors(e.b,Js),xs.subVectors(e.c,Js),Li.subVectors(vs,ys),Di.subVectors(xs,vs),Zi.subVectors(ys,xs);let t=[0,-Li.z,Li.y,0,-Di.z,Di.y,0,-Zi.z,Zi.y,Li.z,0,-Li.x,Di.z,0,-Di.x,Zi.z,0,-Zi.x,-Li.y,Li.x,0,-Di.y,Di.x,0,-Zi.y,Zi.x,0];return!Ka(t,ys,vs,xs,kr)||(t=[1,0,0,0,1,0,0,0,1],!Ka(t,ys,vs,xs,kr))?!1:(Br.crossVectors(Li,Di),t=[Br.x,Br.y,Br.z],Ka(t,ys,vs,xs,kr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Xn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Xn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(pi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),pi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),pi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),pi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),pi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),pi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),pi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),pi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(pi),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 pi=[new O,new O,new O,new O,new O,new O,new O,new O],Xn=new O,Or=new Ci,ys=new O,vs=new O,xs=new O,Li=new O,Di=new O,Zi=new O,Js=new O,kr=new O,Br=new O,$i=new O;function Ka(s,e,t,n,i){for(let r=0,a=s.length-3;r<=a;r+=3){$i.fromArray(s,r);const o=i.x*Math.abs($i.x)+i.y*Math.abs($i.y)+i.z*Math.abs($i.z),l=e.dot($i),c=t.dot($i),u=n.dot($i);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const Yf=new Ci,Qs=new O,Ya=new O;class oi{constructor(e=new O,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):Yf.setFromPoints(e).getCenter(n);let i=0;for(let r=0,a=e.length;r<a;r++)i=Math.max(i,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),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;Qs.subVectors(e,this.center);const t=Qs.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(Qs,i/n),this.radius+=i}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(Qs.copy(e.center).add(Ya)),this.expandByPoint(Qs.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 mi=new O,Za=new O,zr=new O,Ii=new O,$a=new O,Vr=new O,Ja=new O;class Cr{constructor(e=new O,t=new O(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,mi)),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=mi.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(mi.copy(this.origin).addScaledVector(this.direction,t),mi.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Za.copy(e).add(t).multiplyScalar(.5),zr.copy(t).sub(e).normalize(),Ii.copy(this.origin).sub(Za);const r=e.distanceTo(t)*.5,a=-this.direction.dot(zr),o=Ii.dot(this.direction),l=-Ii.dot(zr),c=Ii.lengthSq(),u=Math.abs(1-a*a);let h,d,f,g;if(u>0)if(h=a*l-o,d=a*o-l,g=r*u,h>=0)if(d>=-g)if(d<=g){const _=1/u;h*=_,d*=_,f=h*(h+a*d+2*o)+d*(a*h+d+2*l)+c}else d=r,h=Math.max(0,-(a*d+o)),f=-h*h+d*(d+2*l)+c;else d=-r,h=Math.max(0,-(a*d+o)),f=-h*h+d*(d+2*l)+c;else d<=-g?(h=Math.max(0,-(-a*r+o)),d=h>0?-r:Math.min(Math.max(-r,-l),r),f=-h*h+d*(d+2*l)+c):d<=g?(h=0,d=Math.min(Math.max(-r,-l),r),f=d*(d+2*l)+c):(h=Math.max(0,-(a*r+o)),d=h>0?r:Math.min(Math.max(-r,-l),r),f=-h*h+d*(d+2*l)+c);else d=a>0?-r:r,h=Math.max(0,-(a*d+o)),f=-h*h+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(Za).addScaledVector(zr,d),f}intersectSphere(e,t){mi.subVectors(e.center,this.origin);const n=mi.dot(this.direction),i=mi.dot(mi)-n*n,r=e.radius*e.radius;if(i>r)return null;const a=Math.sqrt(r-i),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,a,o,l;const c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,i=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,i=(e.min.x-d.x)*c),u>=0?(r=(e.min.y-d.y)*u,a=(e.max.y-d.y)*u):(r=(e.max.y-d.y)*u,a=(e.min.y-d.y)*u),n>a||r>i||((r>n||isNaN(n))&&(n=r),(a<i||isNaN(i))&&(i=a),h>=0?(o=(e.min.z-d.z)*h,l=(e.max.z-d.z)*h):(o=(e.max.z-d.z)*h,l=(e.min.z-d.z)*h),n>l||o>i)||((o>n||n!==n)&&(n=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,mi)!==null}intersectTriangle(e,t,n,i,r){$a.subVectors(t,e),Vr.subVectors(n,e),Ja.crossVectors($a,Vr);let a=this.direction.dot(Ja),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Ii.subVectors(this.origin,e);const l=o*this.direction.dot(Vr.crossVectors(Ii,Vr));if(l<0)return null;const c=o*this.direction.dot($a.cross(Ii));if(c<0||l+c>a)return null;const u=-o*Ii.dot(Ja);return u<0?null:this.at(u/a,r)}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 Fe{constructor(e,t,n,i,r,a,o,l,c,u,h,d,f,g,_,m){Fe.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,i,r,a,o,l,c,u,h,d,f,g,_,m)}set(e,t,n,i,r,a,o,l,c,u,h,d,f,g,_,m){const p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=i,p[1]=r,p[5]=a,p[9]=o,p[13]=l,p[2]=c,p[6]=u,p[10]=h,p[14]=d,p[3]=f,p[7]=g,p[11]=_,p[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 Fe().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,i=1/Ms.setFromMatrixColumn(e,0).length(),r=1/Ms.setFromMatrixColumn(e,1).length(),a=1/Ms.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,r=e.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(i),c=Math.sin(i),u=Math.cos(r),h=Math.sin(r);if(e.order==="XYZ"){const d=a*u,f=a*h,g=o*u,_=o*h;t[0]=l*u,t[4]=-l*h,t[8]=c,t[1]=f+g*c,t[5]=d-_*c,t[9]=-o*l,t[2]=_-d*c,t[6]=g+f*c,t[10]=a*l}else if(e.order==="YXZ"){const d=l*u,f=l*h,g=c*u,_=c*h;t[0]=d+_*o,t[4]=g*o-f,t[8]=a*c,t[1]=a*h,t[5]=a*u,t[9]=-o,t[2]=f*o-g,t[6]=_+d*o,t[10]=a*l}else if(e.order==="ZXY"){const d=l*u,f=l*h,g=c*u,_=c*h;t[0]=d-_*o,t[4]=-a*h,t[8]=g+f*o,t[1]=f+g*o,t[5]=a*u,t[9]=_-d*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const d=a*u,f=a*h,g=o*u,_=o*h;t[0]=l*u,t[4]=g*c-f,t[8]=d*c+_,t[1]=l*h,t[5]=_*c+d,t[9]=f*c-g,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const d=a*l,f=a*c,g=o*l,_=o*c;t[0]=l*u,t[4]=_-d*h,t[8]=g*h+f,t[1]=h,t[5]=a*u,t[9]=-o*u,t[2]=-c*u,t[6]=f*h+g,t[10]=d-_*h}else if(e.order==="XZY"){const d=a*l,f=a*c,g=o*l,_=o*c;t[0]=l*u,t[4]=-h,t[8]=c*u,t[1]=d*h+_,t[5]=a*u,t[9]=f*h-g,t[2]=g*h-f,t[6]=o*u,t[10]=_*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(Zf,e,$f)}lookAt(e,t,n){const i=this.elements;return Un.subVectors(e,t),Un.lengthSq()===0&&(Un.z=1),Un.normalize(),Ni.crossVectors(n,Un),Ni.lengthSq()===0&&(Math.abs(n.z)===1?Un.x+=1e-4:Un.z+=1e-4,Un.normalize(),Ni.crossVectors(n,Un)),Ni.normalize(),Hr.crossVectors(Un,Ni),i[0]=Ni.x,i[4]=Hr.x,i[8]=Un.x,i[1]=Ni.y,i[5]=Hr.y,i[9]=Un.y,i[2]=Ni.z,i[6]=Hr.z,i[10]=Un.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],u=n[1],h=n[5],d=n[9],f=n[13],g=n[2],_=n[6],m=n[10],p=n[14],S=n[3],v=n[7],y=n[11],N=n[15],P=i[0],L=i[4],U=i[8],E=i[12],T=i[1],D=i[5],X=i[9],q=i[13],se=i[2],he=i[6],k=i[10],oe=i[14],G=i[3],fe=i[7],ve=i[11],le=i[15];return r[0]=a*P+o*T+l*se+c*G,r[4]=a*L+o*D+l*he+c*fe,r[8]=a*U+o*X+l*k+c*ve,r[12]=a*E+o*q+l*oe+c*le,r[1]=u*P+h*T+d*se+f*G,r[5]=u*L+h*D+d*he+f*fe,r[9]=u*U+h*X+d*k+f*ve,r[13]=u*E+h*q+d*oe+f*le,r[2]=g*P+_*T+m*se+p*G,r[6]=g*L+_*D+m*he+p*fe,r[10]=g*U+_*X+m*k+p*ve,r[14]=g*E+_*q+m*oe+p*le,r[3]=S*P+v*T+y*se+N*G,r[7]=S*L+v*D+y*he+N*fe,r[11]=S*U+v*X+y*k+N*ve,r[15]=S*E+v*q+y*oe+N*le,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],i=e[8],r=e[12],a=e[1],o=e[5],l=e[9],c=e[13],u=e[2],h=e[6],d=e[10],f=e[14],g=e[3],_=e[7],m=e[11],p=e[15];return g*(+r*l*h-i*c*h-r*o*d+n*c*d+i*o*f-n*l*f)+_*(+t*l*f-t*c*d+r*a*d-i*a*f+i*c*u-r*l*u)+m*(+t*c*h-t*o*f-r*a*h+n*a*f+r*o*u-n*c*u)+p*(-i*o*u-t*l*h+t*o*d+i*a*h-n*a*d+n*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,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],h=e[9],d=e[10],f=e[11],g=e[12],_=e[13],m=e[14],p=e[15],S=h*m*c-_*d*c+_*l*f-o*m*f-h*l*p+o*d*p,v=g*d*c-u*m*c-g*l*f+a*m*f+u*l*p-a*d*p,y=u*_*c-g*h*c+g*o*f-a*_*f-u*o*p+a*h*p,N=g*h*l-u*_*l-g*o*d+a*_*d+u*o*m-a*h*m,P=t*S+n*v+i*y+r*N;if(P===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const L=1/P;return e[0]=S*L,e[1]=(_*d*r-h*m*r-_*i*f+n*m*f+h*i*p-n*d*p)*L,e[2]=(o*m*r-_*l*r+_*i*c-n*m*c-o*i*p+n*l*p)*L,e[3]=(h*l*r-o*d*r-h*i*c+n*d*c+o*i*f-n*l*f)*L,e[4]=v*L,e[5]=(u*m*r-g*d*r+g*i*f-t*m*f-u*i*p+t*d*p)*L,e[6]=(g*l*r-a*m*r-g*i*c+t*m*c+a*i*p-t*l*p)*L,e[7]=(a*d*r-u*l*r+u*i*c-t*d*c-a*i*f+t*l*f)*L,e[8]=y*L,e[9]=(g*h*r-u*_*r-g*n*f+t*_*f+u*n*p-t*h*p)*L,e[10]=(a*_*r-g*o*r+g*n*c-t*_*c-a*n*p+t*o*p)*L,e[11]=(u*o*r-a*h*r-u*n*c+t*h*c+a*n*f-t*o*f)*L,e[12]=N*L,e[13]=(u*_*i-g*h*i+g*n*d-t*_*d-u*n*m+t*h*m)*L,e[14]=(g*o*i-a*_*i-g*n*l+t*_*l+a*n*m-t*o*m)*L,e[15]=(a*h*i-u*o*i+u*n*l-t*h*l-a*n*d+t*o*d)*L,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,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],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}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),i=Math.sin(t),r=1-n,a=e.x,o=e.y,l=e.z,c=r*a,u=r*o;return this.set(c*a+n,c*o-i*l,c*l+i*o,0,c*o+i*l,u*o+n,u*l-i*a,0,c*l-i*o,u*l+i*a,r*l*l+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,i,r,a){return this.set(1,n,r,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,a=t._y,o=t._z,l=t._w,c=r+r,u=a+a,h=o+o,d=r*c,f=r*u,g=r*h,_=a*u,m=a*h,p=o*h,S=l*c,v=l*u,y=l*h,N=n.x,P=n.y,L=n.z;return i[0]=(1-(_+p))*N,i[1]=(f+y)*N,i[2]=(g-v)*N,i[3]=0,i[4]=(f-y)*P,i[5]=(1-(d+p))*P,i[6]=(m+S)*P,i[7]=0,i[8]=(g+v)*L,i[9]=(m-S)*L,i[10]=(1-(d+_))*L,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let r=Ms.set(i[0],i[1],i[2]).length();const a=Ms.set(i[4],i[5],i[6]).length(),o=Ms.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],jn.copy(this);const c=1/r,u=1/a,h=1/o;return jn.elements[0]*=c,jn.elements[1]*=c,jn.elements[2]*=c,jn.elements[4]*=u,jn.elements[5]*=u,jn.elements[6]*=u,jn.elements[8]*=h,jn.elements[9]*=h,jn.elements[10]*=h,t.setFromRotationMatrix(jn),n.x=r,n.y=a,n.z=o,this}makePerspective(e,t,n,i,r,a,o=Ti){const l=this.elements,c=2*r/(t-e),u=2*r/(n-i),h=(t+e)/(t-e),d=(n+i)/(n-i);let f,g;if(o===Ti)f=-(a+r)/(a-r),g=-2*a*r/(a-r);else if(o===wa)f=-a/(a-r),g=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=h,l[12]=0,l[1]=0,l[5]=u,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=f,l[14]=g,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,i,r,a,o=Ti){const l=this.elements,c=1/(t-e),u=1/(n-i),h=1/(a-r),d=(t+e)*c,f=(n+i)*u;let g,_;if(o===Ti)g=(a+r)*h,_=-2*h;else if(o===wa)g=r*h,_=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-f,l[2]=0,l[6]=0,l[10]=_,l[14]=-g,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])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 Ms=new O,jn=new Fe,Zf=new O(0,0,0),$f=new O(1,1,1),Ni=new O,Hr=new O,Un=new O,vc=new Fe,xc=new nn;class sn{constructor(e=0,t=0,n=0,i=sn.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}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,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,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 i=e.elements,r=i[0],a=i[4],o=i[8],l=i[1],c=i[5],u=i[9],h=i[2],d=i[6],f=i[10];switch(t){case"XYZ":this._y=Math.asin(yt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-yt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(yt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-yt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(yt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-yt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-u,f),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 vc.makeRotationFromQuaternion(e),this.setFromRotationMatrix(vc,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return xc.setFromEuler(this),this.setFromQuaternion(xc,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}}sn.DEFAULT_ORDER="XYZ";class ah{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 Jf=0;const Mc=new O,Ss=new nn,gi=new Fe,Gr=new O,er=new O,Qf=new O,ep=new nn,Sc=new O(1,0,0),Tc=new O(0,1,0),bc=new O(0,0,1),Ec={type:"added"},tp={type:"removed"},Ts={type:"childadded",child:null},Qa={type:"childremoved",child:null};class kt extends ds{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Jf++}),this.uuid=ti(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=kt.DEFAULT_UP.clone();const e=new O,t=new sn,n=new nn,i=new O(1,1,1);function r(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Fe},normalMatrix:{value:new gt}}),this.matrix=new Fe,this.matrixWorld=new Fe,this.matrixAutoUpdate=kt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=kt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new ah,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 Ss.setFromAxisAngle(e,t),this.quaternion.multiply(Ss),this}rotateOnWorldAxis(e,t){return Ss.setFromAxisAngle(e,t),this.quaternion.premultiply(Ss),this}rotateX(e){return this.rotateOnAxis(Sc,e)}rotateY(e){return this.rotateOnAxis(Tc,e)}rotateZ(e){return this.rotateOnAxis(bc,e)}translateOnAxis(e,t){return Mc.copy(e).applyQuaternion(this.quaternion),this.position.add(Mc.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Sc,e)}translateY(e){return this.translateOnAxis(Tc,e)}translateZ(e){return this.translateOnAxis(bc,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(gi.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Gr.copy(e):Gr.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),er.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?gi.lookAt(er,Gr,this.up):gi.lookAt(Gr,er,this.up),this.quaternion.setFromRotationMatrix(gi),i&&(gi.extractRotation(i.matrixWorld),Ss.setFromRotationMatrix(gi),this.quaternion.premultiply(Ss.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(Ec),Ts.child=e,this.dispatchEvent(Ts),Ts.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(tp),Qa.child=e,this.dispatchEvent(Qa),Qa.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),gi.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),gi.multiply(e.parent.matrixWorld)),e.applyMatrix4(gi),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Ec),Ts.child=e,this.dispatchEvent(Ts),Ts.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,i=this.children.length;n<i;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const i=this.children;for(let r=0,a=i.length;r<a;r++)i[r].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(er,e,Qf),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(er,ep,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,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;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,i=t.length;n<i;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 i=this.children;for(let r=0,a=i.length;r<a;r++)i[r].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 i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c<u;c++){const h=l[c];r(e.shapes,h)}else r(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(r(e.materials,this.material[l]));i.material=o}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];i.animations.push(r(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),u=a(e.images),h=a(e.shapes),d=a(e.skeletons),f=a(e.animations),g=a(e.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),u.length>0&&(n.images=u),h.length>0&&(n.shapes=h),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),g.length>0&&(n.nodes=g)}return n.object=i,n;function a(o){const l=[];for(const c in o){const u=o[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 n=0;n<e.children.length;n++){const i=e.children[n];this.add(i.clone())}return this}}kt.DEFAULT_UP=new O(0,1,0);kt.DEFAULT_MATRIX_AUTO_UPDATE=!0;kt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const qn=new O,_i=new O,eo=new O,yi=new O,bs=new O,Es=new O,Ac=new O,to=new O,no=new O,io=new O,so=new Tt,ro=new Tt,ao=new Tt;class Jn{constructor(e=new O,t=new O,n=new O){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),qn.subVectors(e,t),i.cross(qn);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){qn.subVectors(i,t),_i.subVectors(n,t),eo.subVectors(e,t);const a=qn.dot(qn),o=qn.dot(_i),l=qn.dot(eo),c=_i.dot(_i),u=_i.dot(eo),h=a*c-o*o;if(h===0)return r.set(0,0,0),null;const d=1/h,f=(c*l-o*u)*d,g=(a*u-o*l)*d;return r.set(1-f-g,g,f)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,yi)===null?!1:yi.x>=0&&yi.y>=0&&yi.x+yi.y<=1}static getInterpolation(e,t,n,i,r,a,o,l){return this.getBarycoord(e,t,n,i,yi)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,yi.x),l.addScaledVector(a,yi.y),l.addScaledVector(o,yi.z),l)}static getInterpolatedAttribute(e,t,n,i,r,a){return so.setScalar(0),ro.setScalar(0),ao.setScalar(0),so.fromBufferAttribute(e,t),ro.fromBufferAttribute(e,n),ao.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(so,r.x),a.addScaledVector(ro,r.y),a.addScaledVector(ao,r.z),a}static isFrontFacing(e,t,n,i){return qn.subVectors(n,t),_i.subVectors(e,t),qn.cross(_i).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),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 qn.subVectors(this.c,this.b),_i.subVectors(this.a,this.b),qn.cross(_i).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Jn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Jn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return Jn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return Jn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Jn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,r=this.c;let a,o;bs.subVectors(i,n),Es.subVectors(r,n),to.subVectors(e,n);const l=bs.dot(to),c=Es.dot(to);if(l<=0&&c<=0)return t.copy(n);no.subVectors(e,i);const u=bs.dot(no),h=Es.dot(no);if(u>=0&&h<=u)return t.copy(i);const d=l*h-u*c;if(d<=0&&l>=0&&u<=0)return a=l/(l-u),t.copy(n).addScaledVector(bs,a);io.subVectors(e,r);const f=bs.dot(io),g=Es.dot(io);if(g>=0&&f<=g)return t.copy(r);const _=f*c-l*g;if(_<=0&&c>=0&&g<=0)return o=c/(c-g),t.copy(n).addScaledVector(Es,o);const m=u*g-f*h;if(m<=0&&h-u>=0&&f-g>=0)return Ac.subVectors(r,i),o=(h-u)/(h-u+(f-g)),t.copy(i).addScaledVector(Ac,o);const p=1/(m+_+d);return a=_*p,o=d*p,t.copy(n).addScaledVector(bs,a).addScaledVector(Es,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const oh={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},Wr={h:0,s:0,l:0};function oo(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}class Ge{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=_t){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,ft.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=ft.workingColorSpace){return this.r=e,this.g=t,this.b=n,ft.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=ft.workingColorSpace){if(e=Ol(e,1),t=yt(t,0,1),n=yt(n,0,1),t===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,a=2*n-r;this.r=oo(a,r,e+1/3),this.g=oo(a,r,e),this.b=oo(a,r,e-1/3)}return ft.colorSpaceToWorking(this,i),this}setStyle(e,t=_t){function n(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=i[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,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=_t){const n=oh[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=Ei(e.r),this.g=Ei(e.g),this.b=Ei(e.b),this}copyLinearToSRGB(e){return this.r=Bs(e.r),this.g=Bs(e.g),this.b=Bs(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=_t){return ft.workingToColorSpace(_n.copy(this),e),Math.round(yt(_n.r*255,0,255))*65536+Math.round(yt(_n.g*255,0,255))*256+Math.round(yt(_n.b*255,0,255))}getHexString(e=_t){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ft.workingColorSpace){ft.workingToColorSpace(_n.copy(this),t);const n=_n.r,i=_n.g,r=_n.b,a=Math.max(n,i,r),o=Math.min(n,i,r);let l,c;const u=(o+a)/2;if(o===a)l=0,c=0;else{const h=a-o;switch(c=u<=.5?h/(a+o):h/(2-a-o),a){case n:l=(i-r)/h+(i<r?6:0);break;case i:l=(r-n)/h+2;break;case r:l=(n-i)/h+4;break}l/=6}return e.h=l,e.s=c,e.l=u,e}getRGB(e,t=ft.workingColorSpace){return ft.workingToColorSpace(_n.copy(this),t),e.r=_n.r,e.g=_n.g,e.b=_n.b,e}getStyle(e=_t){ft.workingToColorSpace(_n.copy(this),e);const t=_n.r,n=_n.g,i=_n.b;return e!==_t?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(Ui),this.setHSL(Ui.h+e,Ui.s+t,Ui.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(Ui),e.getHSL(Wr);const n=dr(Ui.h,Wr.h,t),i=dr(Ui.s,Wr.s,t),r=dr(Ui.l,Wr.l,t);return this.setHSL(n,i,r),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,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,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 _n=new Ge;Ge.NAMES=oh;let np=0;class Nn extends ds{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:np++}),this.uuid=ti(),this.name="",this.type="Material",this.blending=Os,this.side=ri,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=No,this.blendDst=Uo,this.blendEquation=ss,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ge(0,0,0),this.blendAlpha=0,this.depthFunc=Vs,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=dc,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=gs,this.stencilZFail=gs,this.stencilZPass=gs,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 i=this[t];if(i===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.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.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!==Os&&(n.blending=this.blending),this.side!==ri&&(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!==No&&(n.blendSrc=this.blendSrc),this.blendDst!==Uo&&(n.blendDst=this.blendDst),this.blendEquation!==ss&&(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!==Vs&&(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!==dc&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==gs&&(n.stencilFail=this.stencilFail),this.stencilZFail!==gs&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==gs&&(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 i(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(t){const r=i(e.textures),a=i(e.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const i=t.length;n=new Array(i);for(let r=0;r!==i;++r)n[r]=t[r].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 bi extends Nn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ge(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new sn,this.combine=Ia,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 $t=new O,Xr=new ct;let ip=0;class hn{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:ip++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=_l,this.updateRanges=[],this.gpuType=ei,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 i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];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++)Xr.fromBufferAttribute(this,t),Xr.applyMatrix3(e),this.setXY(t,Xr.x,Xr.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)$t.fromBufferAttribute(this,t),$t.applyMatrix3(e),this.setXYZ(t,$t.x,$t.y,$t.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)$t.fromBufferAttribute(this,t),$t.applyMatrix4(e),this.setXYZ(t,$t.x,$t.y,$t.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)$t.fromBufferAttribute(this,t),$t.applyNormalMatrix(e),this.setXYZ(t,$t.x,$t.y,$t.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)$t.fromBufferAttribute(this,t),$t.transformDirection(e),this.setXYZ(t,$t.x,$t.y,$t.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=$n(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=It(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=$n(t,this.array)),t}setX(e,t){return this.normalized&&(t=It(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=$n(t,this.array)),t}setY(e,t){return this.normalized&&(t=It(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=$n(t,this.array)),t}setZ(e,t){return this.normalized&&(t=It(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=$n(t,this.array)),t}setW(e,t){return this.normalized&&(t=It(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=It(t,this.array),n=It(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=It(t,this.array),n=It(n,this.array),i=It(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e*=this.itemSize,this.normalized&&(t=It(t,this.array),n=It(n,this.array),i=It(i,this.array),r=It(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,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!==_l&&(e.usage=this.usage),e}}class Bl extends hn{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class lh extends hn{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class vt extends hn{constructor(e,t,n){super(new Float32Array(e),t,n)}}let sp=0;const On=new Fe,lo=new kt,As=new O,Fn=new Ci,tr=new Ci,cn=new O;class Kt extends ds{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:sp++}),this.uuid=ti(),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(sh(e)?lh:Bl)(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 r=new gt().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.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,n){return On.makeTranslation(e,t,n),this.applyMatrix4(On),this}scale(e,t,n){return On.makeScale(e,t,n),this.applyMatrix4(On),this}lookAt(e){return lo.lookAt(e),lo.updateMatrix(),this.applyMatrix4(lo.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(As).negate(),this.translate(As.x,As.y,As.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let i=0,r=e.length;i<r;i++){const a=e[i];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new vt(n,3))}else{const n=Math.min(e.length,t.count);for(let i=0;i<n;i++){const r=e[i];t.setXYZ(i,r.x,r.y,r.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 Ci);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new O(-1/0,-1/0,-1/0),new O(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){const r=t[n];Fn.setFromBufferAttribute(r),this.morphTargetsRelative?(cn.addVectors(this.boundingBox.min,Fn.min),this.boundingBox.expandByPoint(cn),cn.addVectors(this.boundingBox.max,Fn.max),this.boundingBox.expandByPoint(cn)):(this.boundingBox.expandByPoint(Fn.min),this.boundingBox.expandByPoint(Fn.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 oi);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new O,1/0);return}if(e){const n=this.boundingSphere.center;if(Fn.setFromBufferAttribute(e),t)for(let r=0,a=t.length;r<a;r++){const o=t[r];tr.setFromBufferAttribute(o),this.morphTargetsRelative?(cn.addVectors(Fn.min,tr.min),Fn.expandByPoint(cn),cn.addVectors(Fn.max,tr.max),Fn.expandByPoint(cn)):(Fn.expandByPoint(tr.min),Fn.expandByPoint(tr.max))}Fn.getCenter(n);let i=0;for(let r=0,a=e.count;r<a;r++)cn.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(cn));if(t)for(let r=0,a=t.length;r<a;r++){const o=t[r],l=this.morphTargetsRelative;for(let c=0,u=o.count;c<u;c++)cn.fromBufferAttribute(o,c),l&&(As.fromBufferAttribute(e,c),cn.add(As)),i=Math.max(i,n.distanceToSquared(cn))}this.boundingSphere.radius=Math.sqrt(i),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,i=t.normal,r=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new hn(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let U=0;U<n.count;U++)o[U]=new O,l[U]=new O;const c=new O,u=new O,h=new O,d=new ct,f=new ct,g=new ct,_=new O,m=new O;function p(U,E,T){c.fromBufferAttribute(n,U),u.fromBufferAttribute(n,E),h.fromBufferAttribute(n,T),d.fromBufferAttribute(r,U),f.fromBufferAttribute(r,E),g.fromBufferAttribute(r,T),u.sub(c),h.sub(c),f.sub(d),g.sub(d);const D=1/(f.x*g.y-g.x*f.y);isFinite(D)&&(_.copy(u).multiplyScalar(g.y).addScaledVector(h,-f.y).multiplyScalar(D),m.copy(h).multiplyScalar(f.x).addScaledVector(u,-g.x).multiplyScalar(D),o[U].add(_),o[E].add(_),o[T].add(_),l[U].add(m),l[E].add(m),l[T].add(m))}let S=this.groups;S.length===0&&(S=[{start:0,count:e.count}]);for(let U=0,E=S.length;U<E;++U){const T=S[U],D=T.start,X=T.count;for(let q=D,se=D+X;q<se;q+=3)p(e.getX(q+0),e.getX(q+1),e.getX(q+2))}const v=new O,y=new O,N=new O,P=new O;function L(U){N.fromBufferAttribute(i,U),P.copy(N);const E=o[U];v.copy(E),v.sub(N.multiplyScalar(N.dot(E))).normalize(),y.crossVectors(P,E);const D=y.dot(l[U])<0?-1:1;a.setXYZW(U,v.x,v.y,v.z,D)}for(let U=0,E=S.length;U<E;++U){const T=S[U],D=T.start,X=T.count;for(let q=D,se=D+X;q<se;q+=3)L(e.getX(q+0)),L(e.getX(q+1)),L(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 hn(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);const i=new O,r=new O,a=new O,o=new O,l=new O,c=new O,u=new O,h=new O;if(e)for(let d=0,f=e.count;d<f;d+=3){const g=e.getX(d+0),_=e.getX(d+1),m=e.getX(d+2);i.fromBufferAttribute(t,g),r.fromBufferAttribute(t,_),a.fromBufferAttribute(t,m),u.subVectors(a,r),h.subVectors(i,r),u.cross(h),o.fromBufferAttribute(n,g),l.fromBufferAttribute(n,_),c.fromBufferAttribute(n,m),o.add(u),l.add(u),c.add(u),n.setXYZ(g,o.x,o.y,o.z),n.setXYZ(_,l.x,l.y,l.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let d=0,f=t.count;d<f;d+=3)i.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,d+2),u.subVectors(a,r),h.subVectors(i,r),u.cross(h),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++)cn.fromBufferAttribute(e,t),cn.normalize(),e.setXYZ(t,cn.x,cn.y,cn.z)}toNonIndexed(){function e(o,l){const c=o.array,u=o.itemSize,h=o.normalized,d=new c.constructor(l.length*u);let f=0,g=0;for(let _=0,m=l.length;_<m;_++){o.isInterleavedBufferAttribute?f=l[_]*o.data.stride+o.offset:f=l[_]*u;for(let p=0;p<u;p++)d[g++]=c[f++]}return new hn(d,u,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Kt,n=this.index.array,i=this.attributes;for(const o in i){const l=i[o],c=e(l,n);t.setAttribute(o,c)}const r=this.morphAttributes;for(const o in r){const l=[],c=r[o];for(let u=0,h=c.length;u<h;u++){const d=c[u],f=e(d,n);l.push(f)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];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 n=this.attributes;for(const l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let h=0,d=c.length;h<d;h++){const f=c[h];u.push(f.toJSON(e.data))}u.length>0&&(i[l]=u,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const i=e.attributes;for(const c in i){const u=i[c];this.setAttribute(c,u.clone(t))}const r=e.morphAttributes;for(const c in r){const u=[],h=r[c];for(let d=0,f=h.length;d<f;d++)u.push(h[d].clone(t));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,u=a.length;c<u;c++){const h=a[c];this.addGroup(h.start,h.count,h.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.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 wc=new Fe,Ji=new Cr,jr=new oi,Rc=new O,qr=new O,Kr=new O,Yr=new O,co=new O,Zr=new O,Cc=new O,$r=new O;class rn extends kt{constructor(e=new Kt,t=new bi){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 i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(r&&o){Zr.set(0,0,0);for(let l=0,c=r.length;l<c;l++){const u=o[l],h=r[l];u!==0&&(co.fromBufferAttribute(h,e),a?Zr.addScaledVector(co,u):Zr.addScaledVector(co.sub(t),u))}t.add(Zr)}return t}raycast(e,t){const n=this.geometry,i=this.material,r=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),jr.copy(n.boundingSphere),jr.applyMatrix4(r),Ji.copy(e.ray).recast(e.near),!(jr.containsPoint(Ji.origin)===!1&&(Ji.intersectSphere(jr,Rc)===null||Ji.origin.distanceToSquared(Rc)>(e.far-e.near)**2))&&(wc.copy(r).invert(),Ji.copy(e.ray).applyMatrix4(wc),!(n.boundingBox!==null&&Ji.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Ji)))}_computeIntersections(e,t,n){let i;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,u=r.attributes.uv1,h=r.attributes.normal,d=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,_=d.length;g<_;g++){const m=d[g],p=a[m.materialIndex],S=Math.max(m.start,f.start),v=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let y=S,N=v;y<N;y+=3){const P=o.getX(y),L=o.getX(y+1),U=o.getX(y+2);i=Jr(this,p,e,n,c,u,h,P,L,U),i&&(i.faceIndex=Math.floor(y/3),i.face.materialIndex=m.materialIndex,t.push(i))}}else{const g=Math.max(0,f.start),_=Math.min(o.count,f.start+f.count);for(let m=g,p=_;m<p;m+=3){const S=o.getX(m),v=o.getX(m+1),y=o.getX(m+2);i=Jr(this,a,e,n,c,u,h,S,v,y),i&&(i.faceIndex=Math.floor(m/3),t.push(i))}}else if(l!==void 0)if(Array.isArray(a))for(let g=0,_=d.length;g<_;g++){const m=d[g],p=a[m.materialIndex],S=Math.max(m.start,f.start),v=Math.min(l.count,Math.min(m.start+m.count,f.start+f.count));for(let y=S,N=v;y<N;y+=3){const P=y,L=y+1,U=y+2;i=Jr(this,p,e,n,c,u,h,P,L,U),i&&(i.faceIndex=Math.floor(y/3),i.face.materialIndex=m.materialIndex,t.push(i))}}else{const g=Math.max(0,f.start),_=Math.min(l.count,f.start+f.count);for(let m=g,p=_;m<p;m+=3){const S=m,v=m+1,y=m+2;i=Jr(this,a,e,n,c,u,h,S,v,y),i&&(i.faceIndex=Math.floor(m/3),t.push(i))}}}}function rp(s,e,t,n,i,r,a,o){let l;if(e.side===In?l=n.intersectTriangle(a,r,i,!0,o):l=n.intersectTriangle(i,r,a,e.side===ri,o),l===null)return null;$r.copy(o),$r.applyMatrix4(s.matrixWorld);const c=t.ray.origin.distanceTo($r);return c<t.near||c>t.far?null:{distance:c,point:$r.clone(),object:s}}function Jr(s,e,t,n,i,r,a,o,l,c){s.getVertexPosition(o,qr),s.getVertexPosition(l,Kr),s.getVertexPosition(c,Yr);const u=rp(s,e,t,n,qr,Kr,Yr,Cc);if(u){const h=new O;Jn.getBarycoord(Cc,qr,Kr,Yr,h),i&&(u.uv=Jn.getInterpolatedAttribute(i,o,l,c,h,new ct)),r&&(u.uv1=Jn.getInterpolatedAttribute(r,o,l,c,h,new ct)),a&&(u.normal=Jn.getInterpolatedAttribute(a,o,l,c,h,new O),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));const d={a:o,b:l,c,normal:new O,materialIndex:0};Jn.getNormal(qr,Kr,Yr,d.normal),u.face=d,u.barycoord=h}return u}class Pr extends Kt{constructor(e=1,t=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};const o=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);const l=[],c=[],u=[],h=[];let d=0,f=0;g("z","y","x",-1,-1,n,t,e,a,r,0),g("z","y","x",1,-1,n,t,-e,a,r,1),g("x","z","y",1,1,e,n,t,i,a,2),g("x","z","y",1,-1,e,n,-t,i,a,3),g("x","y","z",1,-1,e,t,n,i,r,4),g("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(l),this.setAttribute("position",new vt(c,3)),this.setAttribute("normal",new vt(u,3)),this.setAttribute("uv",new vt(h,2));function g(_,m,p,S,v,y,N,P,L,U,E){const T=y/L,D=N/U,X=y/2,q=N/2,se=P/2,he=L+1,k=U+1;let oe=0,G=0;const fe=new O;for(let ve=0;ve<k;ve++){const le=ve*D-q;for(let we=0;we<he;we++){const Me=we*T-X;fe[_]=Me*S,fe[m]=le*v,fe[p]=se,c.push(fe.x,fe.y,fe.z),fe[_]=0,fe[m]=0,fe[p]=P>0?1:-1,u.push(fe.x,fe.y,fe.z),h.push(we/L),h.push(1-ve/U),oe+=1}}for(let ve=0;ve<U;ve++)for(let le=0;le<L;le++){const we=d+le+he*ve,Me=d+le+he*(ve+1),W=d+(le+1)+he*(ve+1),ee=d+(le+1)+he*ve;l.push(we,Me,ee),l.push(Me,W,ee),G+=6}o.addGroup(f,G,E),f+=G,d+=oe}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Pr(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Xs(s){const e={};for(const t in s){e[t]={};for(const n in s[t]){const i=s[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=i.clone():Array.isArray(i)?e[t][n]=i.slice():e[t][n]=i}}return e}function Tn(s){const e={};for(let t=0;t<s.length;t++){const n=Xs(s[t]);for(const i in n)e[i]=n[i]}return e}function ap(s){const e=[];for(let t=0;t<s.length;t++)e.push(s[t].clone());return e}function ch(s){const e=s.getRenderTarget();return e===null?s.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:ft.workingColorSpace}const op={clone:Xs,merge:Tn};var lp=`void main() {
6
6
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
7
7
  }`,cp=`void main() {
8
8
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
9
- }`;class Wi extends Dn{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=lp,this.fragmentShader=cp,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=Ws(e.uniforms),this.uniformsGroups=ap(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 i in this.uniforms){const a=this.uniforms[i].value;a&&a.isTexture?t.uniforms[i]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[i]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[i]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[i]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[i]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[i]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[i]={type:"m4",value:a.toArray()}:t.uniforms[i]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class uh extends kt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Fe,this.projectionMatrix=new Fe,this.projectionMatrixInverse=new Fe,this.coordinateSystem=Si}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 O,Pc=new ot,Lc=new ot;class cn extends uh{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,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=Gs*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(ur*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Gs*2*Math.atan(Math.tan(ur*.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){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),n.set(Fi.x,Fi.y).multiplyScalar(-e/Fi.z)}getViewSize(e,t){return this.getViewBounds(e,Pc,Lc),t.subVectors(Lc,Pc)}setViewOffset(e,t,n,i,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(ur*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*i/l,t-=a.offsetY*n/c,i*=a.width/l,n*=a.height/c}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem),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 As=-90,ws=1;class up extends kt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new cn(As,ws,e,t);i.layers=this.layers,this.add(i);const r=new cn(As,ws,e,t);r.layers=this.layers,this.add(r);const a=new cn(As,ws,e,t);a.layers=this.layers,this.add(a);const o=new cn(As,ws,e,t);o.layers=this.layers,this.add(o);const l=new cn(As,ws,e,t);l.layers=this.layers,this.add(l);const c=new cn(As,ws,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,r,a,o,l]=t;for(const c of t)this.remove(c);if(e===Si)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Aa)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,l,c,u]=this.children,h=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const _=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,i),e.render(t,r),e.setRenderTarget(n,1,i),e.render(t,a),e.setRenderTarget(n,2,i),e.render(t,o),e.setRenderTarget(n,3,i),e.render(t,l),e.setRenderTarget(n,4,i),e.render(t,c),n.texture.generateMipmaps=_,e.setRenderTarget(n,5,i),e.render(t,u),e.setRenderTarget(h,d,f),e.xr.enabled=g,n.texture.needsPMREMUpdate=!0}}class hh extends rn{constructor(e=[],t=Vs,n,i,r,a,o,l,c,u){super(e,t,n,i,r,a,o,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class hp extends cs{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new hh(i),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:`
9
+ }`;class Wi extends Nn{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=lp,this.fragmentShader=cp,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=Xs(e.uniforms),this.uniformsGroups=ap(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 i in this.uniforms){const a=this.uniforms[i].value;a&&a.isTexture?t.uniforms[i]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[i]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[i]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[i]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[i]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[i]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[i]={type:"m4",value:a.toArray()}:t.uniforms[i]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class uh extends kt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Fe,this.projectionMatrix=new Fe,this.projectionMatrixInverse=new Fe,this.coordinateSystem=Ti}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 O,Pc=new ct,Lc=new ct;class un extends uh{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,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=Ws*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(hr*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Ws*2*Math.atan(Math.tan(hr*.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){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),n.set(Fi.x,Fi.y).multiplyScalar(-e/Fi.z)}getViewSize(e,t){return this.getViewBounds(e,Pc,Lc),t.subVectors(Lc,Pc)}setViewOffset(e,t,n,i,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(hr*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*i/l,t-=a.offsetY*n/c,i*=a.width/l,n*=a.height/c}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem),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 ws=-90,Rs=1;class up extends kt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new un(ws,Rs,e,t);i.layers=this.layers,this.add(i);const r=new un(ws,Rs,e,t);r.layers=this.layers,this.add(r);const a=new un(ws,Rs,e,t);a.layers=this.layers,this.add(a);const o=new un(ws,Rs,e,t);o.layers=this.layers,this.add(o);const l=new un(ws,Rs,e,t);l.layers=this.layers,this.add(l);const c=new un(ws,Rs,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,r,a,o,l]=t;for(const c of t)this.remove(c);if(e===Ti)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===wa)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,l,c,u]=this.children,h=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const _=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,i),e.render(t,r),e.setRenderTarget(n,1,i),e.render(t,a),e.setRenderTarget(n,2,i),e.render(t,o),e.setRenderTarget(n,3,i),e.render(t,l),e.setRenderTarget(n,4,i),e.render(t,c),n.texture.generateMipmaps=_,e.setRenderTarget(n,5,i),e.render(t,u),e.setRenderTarget(h,d,f),e.xr.enabled=g,n.texture.needsPMREMUpdate=!0}}class hh extends an{constructor(e=[],t=Hs,n,i,r,a,o,l,c,u){super(e,t,n,i,r,a,o,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class hp extends cs{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new hh(i),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:`
10
10
 
11
11
  varying vec3 vWorldDirection;
12
12
 
@@ -41,11 +41,11 @@
41
41
  gl_FragColor = texture2D( tEquirect, sampleUV );
42
42
 
43
43
  }
44
- `},i=new Cr(5,5,5),r=new Wi({name:"CubemapFromEquirect",uniforms:Ws(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Ln,blending:Hi});r.uniforms.tEquirect.value=t;const a=new sn(i,r),o=t.minFilter;return t.minFilter===Jn&&(t.minFilter=gn),new up(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,i);e.setRenderTarget(r)}}class Gn extends kt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const dp={type:"move"};class uo{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Gn,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 Gn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new O,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new O),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Gn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new O,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new O),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const 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 i=null,r=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const _ of e.hand.values()){const m=t.getJointPose(_,n),p=this._getHandJoint(c,_);m!==null&&(p.matrix.fromArray(m.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=m.radius),p.visible=m!==null}const u=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],d=u.position.distanceTo(h.position),f=.02,g=.005;c.inputState.pinching&&d>f+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=f-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null&&(i=r),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(dp)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Gn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class dh extends kt{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 nn,this.environmentIntensity=1,this.environmentRotation=new nn,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}}class fp{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=_l,this.updateRanges=[],this.version=0,this.uuid=ei()}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.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ei()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ei()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const xn=new O;class zl{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)xn.fromBufferAttribute(this,t),xn.applyMatrix4(e),this.setXYZ(t,xn.x,xn.y,xn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)xn.fromBufferAttribute(this,t),xn.applyNormalMatrix(e),this.setXYZ(t,xn.x,xn.y,xn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)xn.fromBufferAttribute(this,t),xn.transformDirection(e),this.setXYZ(t,xn.x,xn.y,xn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=Zn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=It(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=It(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=It(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=It(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=It(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Zn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Zn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Zn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Zn(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=It(t,this.array),n=It(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=It(t,this.array),n=It(n,this.array),i=It(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=It(t,this.array),n=It(n,this.array),i=It(i,this.array),r=It(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new un(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new zl(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}const Dc=new O,Ic=new Tt,Nc=new Tt,pp=new O,Uc=new Fe,Jr=new O,ho=new ai,Fc=new Fe,fo=new Rr;class Vl extends sn{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=lc,this.bindMatrix=new Fe,this.bindMatrixInverse=new Fe,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Ri),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Jr),this.boundingBox.expandByPoint(Jr)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new ai),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Jr),this.boundingSphere.expandByPoint(Jr)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ho.copy(this.boundingSphere),ho.applyMatrix4(i),e.ray.intersectsSphere(ho)!==!1&&(Fc.copy(i).invert(),fo.copy(e.ray).applyMatrix4(Fc),!(this.boundingBox!==null&&fo.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,fo)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new Tt,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===lc?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===uf?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,i=this.geometry;Ic.fromBufferAttribute(i.attributes.skinIndex,e),Nc.fromBufferAttribute(i.attributes.skinWeight,e),Dc.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let r=0;r<4;r++){const a=Nc.getComponent(r);if(a!==0){const o=Ic.getComponent(r);Uc.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(pp.copy(Dc).applyMatrix4(Uc),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class vr extends kt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Hl extends rn{constructor(e=null,t=1,n=1,i,r,a,o,l,c=Sn,u=Sn,h,d){super(null,a,o,l,c,u,i,r,h,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Oc=new Fe,mp=new Fe;class Pr{constructor(e=[],t=[]){this.uuid=ei(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Fe)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new Fe;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,a=e.length;r<a;r++){const o=e[r]?e[r].matrixWorld:mp;Oc.multiplyMatrices(o,t[r]),Oc.toArray(n,r*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new Pr(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new Hl(t,e,e,Hn,Qn);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const r=e.bones[n];let a=t[r];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",r),a=new vr),this.bones.push(a),this.boneInverses.push(new Fe().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){const a=t[i];e.bones.push(a.uuid);const o=n[i];e.boneInverses.push(o.toArray())}return e}}class yl extends un{constructor(e,t,n,i=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Rs=new Fe,kc=new Fe,Qr=[],Bc=new Ri,gp=new Fe,tr=new sn,nr=new ai;class _p extends sn{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new yl(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,gp)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Ri),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Rs),Bc.copy(e.boundingBox).applyMatrix4(Rs),this.boundingBox.union(Bc)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new ai),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Rs),nr.copy(e.boundingSphere).applyMatrix4(Rs),this.boundingSphere.union(nr)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,a=e*r+1;for(let o=0;o<n.length;o++)n[o]=i[a+o]}raycast(e,t){const n=this.matrixWorld,i=this.count;if(tr.geometry=this.geometry,tr.material=this.material,tr.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),nr.copy(this.boundingSphere),nr.applyMatrix4(n),e.ray.intersectsSphere(nr)!==!1))for(let r=0;r<i;r++){this.getMatrixAt(r,Rs),kc.multiplyMatrices(n,Rs),tr.matrixWorld=kc,tr.raycast(e,Qr);for(let a=0,o=Qr.length;a<o;a++){const l=Qr[a];l.instanceId=r,l.object=this,t.push(l)}Qr.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new yl(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const n=t.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new Hl(new Float32Array(i*this.count),i,this.count,Il,Qn));const r=this.morphTexture.source.data.data;let a=0;for(let c=0;c<n.length;c++)a+=n[c];const o=this.geometry.morphTargetsRelative?1:1-a,l=i*e;r[l]=o,r.set(n,l+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const po=new O,yp=new O,xp=new gt;class Bi{constructor(e=new O(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=po.subVectors(n,t).cross(yp.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,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(po),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:t.copy(e.start).addScaledVector(n,r)}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||xp.getNormalMatrix(e),i=this.coplanarPoint(po).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),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 Qi=new ai,ea=new O;class Gl{constructor(e=new Bi,t=new Bi,n=new Bi,i=new Bi,r=new Bi,a=new Bi){this.planes=[e,t,n,i,r,a]}set(e,t,n,i,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Si){const n=this.planes,i=e.elements,r=i[0],a=i[1],o=i[2],l=i[3],c=i[4],u=i[5],h=i[6],d=i[7],f=i[8],g=i[9],_=i[10],m=i[11],p=i[12],S=i[13],x=i[14],y=i[15];if(n[0].setComponents(l-r,d-c,m-f,y-p).normalize(),n[1].setComponents(l+r,d+c,m+f,y+p).normalize(),n[2].setComponents(l+a,d+u,m+g,y+S).normalize(),n[3].setComponents(l-a,d-u,m-g,y-S).normalize(),n[4].setComponents(l-o,d-h,m-_,y-x).normalize(),t===Si)n[5].setComponents(l+o,d+h,m+_,y+x).normalize();else if(t===Aa)n[5].setComponents(o,h,_,x).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(),Qi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Qi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Qi)}intersectsSprite(e){return Qi.center.set(0,0,0),Qi.radius=.7071067811865476,Qi.applyMatrix4(e.matrixWorld),this.intersectsSphere(Qi)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(ea.x=i.normal.x>0?e.max.x:e.min.x,ea.y=i.normal.y>0?e.max.y:e.min.y,ea.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(ea)<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 ii extends Dn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new He(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 wa=new O,Ra=new O,zc=new Fe,ir=new Rr,ta=new ai,mo=new O,Vc=new O;class Lr extends kt{constructor(e=new Kt,t=new ii){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 i=1,r=t.count;i<r;i++)wa.fromBufferAttribute(t,i-1),Ra.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=wa.distanceTo(Ra);e.setAttribute("lineDistance",new xt(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),ta.copy(n.boundingSphere),ta.applyMatrix4(i),ta.radius+=r,e.ray.intersectsSphere(ta)===!1)return;zc.copy(i).invert(),ir.copy(e.ray).applyMatrix4(zc);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,u=n.index,d=n.attributes.position;if(u!==null){const f=Math.max(0,a.start),g=Math.min(u.count,a.start+a.count);for(let _=f,m=g-1;_<m;_+=c){const p=u.getX(_),S=u.getX(_+1),x=na(this,e,ir,l,p,S,_);x&&t.push(x)}if(this.isLineLoop){const _=u.getX(g-1),m=u.getX(f),p=na(this,e,ir,l,_,m,g-1);p&&t.push(p)}}else{const f=Math.max(0,a.start),g=Math.min(d.count,a.start+a.count);for(let _=f,m=g-1;_<m;_+=c){const p=na(this,e,ir,l,_,_+1,_);p&&t.push(p)}if(this.isLineLoop){const _=na(this,e,ir,l,g-1,f,g-1);_&&t.push(_)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function na(s,e,t,n,i,r,a){const o=s.geometry.attributes.position;if(wa.fromBufferAttribute(o,i),Ra.fromBufferAttribute(o,r),t.distanceSqToSegment(wa,Ra,mo,Vc)>n)return;mo.applyMatrix4(s.matrixWorld);const c=e.ray.origin.distanceTo(mo);if(!(c<e.near||c>e.far))return{distance:c,point:Vc.clone().applyMatrix4(s.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:s}}const Hc=new O,Gc=new O;class Xs extends Lr{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 i=0,r=t.count;i<r;i+=2)Hc.fromBufferAttribute(t,i),Gc.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+Hc.distanceTo(Gc);e.setAttribute("lineDistance",new xt(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class vp extends Lr{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Ds extends Dn{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new He(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const Wc=new Fe,xl=new Rr,ia=new ai,sa=new O;class va extends kt{constructor(e=new Kt,t=new Ds){super(),this.isPoints=!0,this.type="Points",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}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),ia.copy(n.boundingSphere),ia.applyMatrix4(i),ia.radius+=r,e.ray.intersectsSphere(ia)===!1)return;Wc.copy(i).invert(),xl.copy(e.ray).applyMatrix4(Wc);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=n.index,h=n.attributes.position;if(c!==null){const d=Math.max(0,a.start),f=Math.min(c.count,a.start+a.count);for(let g=d,_=f;g<_;g++){const m=c.getX(g);sa.fromBufferAttribute(h,m),Xc(sa,m,l,i,e,t,this)}}else{const d=Math.max(0,a.start),f=Math.min(h.count,a.start+a.count);for(let g=d,_=f;g<_;g++)sa.fromBufferAttribute(h,g),Xc(sa,g,l,i,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Xc(s,e,t,n,i,r,a){const o=xl.distanceSqToPoint(s);if(o<t){const l=new O;xl.closestPointToPoint(s,l),l.applyMatrix4(n);const c=i.ray.origin.distanceTo(l);if(c<i.near||c>i.far)return;r.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class fh extends rn{constructor(e,t,n=ls,i,r,a,o=Sn,l=Sn,c,u=mr,h=1){if(u!==mr&&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,i,r,a,o,l,u,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new kl(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 Mp{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){console.warn("THREE.Curve: .getPoint() not implemented.")}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),r=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),r+=n.distanceTo(i),t.push(r),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const n=this.getLengths();let i=0;const r=n.length;let a;t?a=t:a=e*n[r-1];let o=0,l=r-1,c;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),c=n[i]-a,c<0)o=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,n[i]===a)return i/(r-1);const u=n[i],d=n[i+1]-u,f=(a-u)/d;return(i+f)/(r-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);const a=this.getPoint(i),o=this.getPoint(r),l=t||(a.isVector2?new ot:new O);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){const n=new O,i=[],r=[],a=[],o=new O,l=new Fe;for(let f=0;f<=e;f++){const g=f/e;i[f]=this.getTangentAt(g,new O)}r[0]=new O,a[0]=new O;let c=Number.MAX_VALUE;const u=Math.abs(i[0].x),h=Math.abs(i[0].y),d=Math.abs(i[0].z);u<=c&&(c=u,n.set(1,0,0)),h<=c&&(c=h,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],o),a[0].crossVectors(i[0],r[0]);for(let f=1;f<=e;f++){if(r[f]=r[f-1].clone(),a[f]=a[f-1].clone(),o.crossVectors(i[f-1],i[f]),o.length()>Number.EPSILON){o.normalize();const g=Math.acos(yt(i[f-1].dot(i[f]),-1,1));r[f].applyMatrix4(l.makeRotationAxis(o,g))}a[f].crossVectors(i[f],r[f])}if(t===!0){let f=Math.acos(yt(r[0].dot(r[e]),-1,1));f/=e,i[0].dot(o.crossVectors(r[0],r[e]))>0&&(f=-f);for(let g=1;g<=e;g++)r[g].applyMatrix4(l.makeRotationAxis(i[g],f*g)),a[g].crossVectors(i[g],r[g])}return{tangents:i,normals:r,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}function Sp(s,e,t=2){const n=e&&e.length,i=n?e[0]*t:s.length;let r=ph(s,0,i,t,!0);const a=[];if(!r||r.next===r.prev)return a;let o,l,c;if(n&&(r=wp(s,e,r,t)),s.length>80*t){o=1/0,l=1/0;let u=-1/0,h=-1/0;for(let d=t;d<i;d+=t){const f=s[d],g=s[d+1];f<o&&(o=f),g<l&&(l=g),f>u&&(u=f),g>h&&(h=g)}c=Math.max(u-o,h-l),c=c!==0?32767/c:0}return Mr(r,a,t,o,l,c,0),a}function ph(s,e,t,n,i){let r;if(i===kp(s,e,t,n)>0)for(let a=e;a<t;a+=n)r=jc(a/n|0,s[a],s[a+1],r);else for(let a=t-n;a>=e;a-=n)r=jc(a/n|0,s[a],s[a+1],r);return r&&js(r,r.next)&&(Tr(r),r=r.next),r}function us(s,e){if(!s)return s;e||(e=s);let t=s,n;do if(n=!1,!t.steiner&&(js(t,t.next)||Xt(t.prev,t,t.next)===0)){if(Tr(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Mr(s,e,t,n,i,r,a){if(!s)return;!a&&r&&Dp(s,n,i,r);let o=s;for(;s.prev!==s.next;){const l=s.prev,c=s.next;if(r?bp(s,n,i,r):Tp(s)){e.push(l.i,s.i,c.i),Tr(s),s=c.next,o=c.next;continue}if(s=c,s===o){a?a===1?(s=Ep(us(s),e),Mr(s,e,t,n,i,r,2)):a===2&&Ap(s,e,t,n,i,r):Mr(us(s),e,t,n,i,r,1);break}}}function Tp(s){const e=s.prev,t=s,n=s.next;if(Xt(e,t,n)>=0)return!1;const i=e.x,r=t.x,a=n.x,o=e.y,l=t.y,c=n.y,u=Math.min(i,r,a),h=Math.min(o,l,c),d=Math.max(i,r,a),f=Math.max(o,l,c);let g=n.next;for(;g!==e;){if(g.x>=u&&g.x<=d&&g.y>=h&&g.y<=f&&or(i,o,r,l,a,c,g.x,g.y)&&Xt(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function bp(s,e,t,n){const i=s.prev,r=s,a=s.next;if(Xt(i,r,a)>=0)return!1;const o=i.x,l=r.x,c=a.x,u=i.y,h=r.y,d=a.y,f=Math.min(o,l,c),g=Math.min(u,h,d),_=Math.max(o,l,c),m=Math.max(u,h,d),p=vl(f,g,e,t,n),S=vl(_,m,e,t,n);let x=s.prevZ,y=s.nextZ;for(;x&&x.z>=p&&y&&y.z<=S;){if(x.x>=f&&x.x<=_&&x.y>=g&&x.y<=m&&x!==i&&x!==a&&or(o,u,l,h,c,d,x.x,x.y)&&Xt(x.prev,x,x.next)>=0||(x=x.prevZ,y.x>=f&&y.x<=_&&y.y>=g&&y.y<=m&&y!==i&&y!==a&&or(o,u,l,h,c,d,y.x,y.y)&&Xt(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;x&&x.z>=p;){if(x.x>=f&&x.x<=_&&x.y>=g&&x.y<=m&&x!==i&&x!==a&&or(o,u,l,h,c,d,x.x,x.y)&&Xt(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;y&&y.z<=S;){if(y.x>=f&&y.x<=_&&y.y>=g&&y.y<=m&&y!==i&&y!==a&&or(o,u,l,h,c,d,y.x,y.y)&&Xt(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function Ep(s,e){let t=s;do{const n=t.prev,i=t.next.next;!js(n,i)&&gh(n,t,t.next,i)&&Sr(n,i)&&Sr(i,n)&&(e.push(n.i,t.i,i.i),Tr(t),Tr(t.next),t=s=i),t=t.next}while(t!==s);return us(t)}function Ap(s,e,t,n,i,r){let a=s;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&Up(a,o)){let l=_h(a,o);a=us(a,a.next),l=us(l,l.next),Mr(a,e,t,n,i,r,0),Mr(l,e,t,n,i,r,0);return}o=o.next}a=a.next}while(a!==s)}function wp(s,e,t,n){const i=[];for(let r=0,a=e.length;r<a;r++){const o=e[r]*n,l=r<a-1?e[r+1]*n:s.length,c=ph(s,o,l,n,!1);c===c.next&&(c.steiner=!0),i.push(Np(c))}i.sort(Rp);for(let r=0;r<i.length;r++)t=Cp(i[r],t);return t}function Rp(s,e){let t=s.x-e.x;if(t===0&&(t=s.y-e.y,t===0)){const n=(s.next.y-s.y)/(s.next.x-s.x),i=(e.next.y-e.y)/(e.next.x-e.x);t=n-i}return t}function Cp(s,e){const t=Pp(s,e);if(!t)return e;const n=_h(t,s);return us(n,n.next),us(t,t.next)}function Pp(s,e){let t=e;const n=s.x,i=s.y;let r=-1/0,a;if(js(s,t))return t;do{if(js(s,t.next))return t.next;if(i<=t.y&&i>=t.next.y&&t.next.y!==t.y){const h=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(h<=n&&h>r&&(r=h,a=t.x<t.next.x?t:t.next,h===n))return a}t=t.next}while(t!==e);if(!a)return null;const o=a,l=a.x,c=a.y;let u=1/0;t=a;do{if(n>=t.x&&t.x>=l&&n!==t.x&&mh(i<c?n:r,i,l,c,i<c?r:n,i,t.x,t.y)){const h=Math.abs(i-t.y)/(n-t.x);Sr(t,s)&&(h<u||h===u&&(t.x>a.x||t.x===a.x&&Lp(a,t)))&&(a=t,u=h)}t=t.next}while(t!==o);return a}function Lp(s,e){return Xt(s.prev,s,e.prev)<0&&Xt(e.next,s,s.next)<0}function Dp(s,e,t,n){let i=s;do i.z===0&&(i.z=vl(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==s);i.prevZ.nextZ=null,i.prevZ=null,Ip(i)}function Ip(s){let e,t=1;do{let n=s,i;s=null;let r=null;for(e=0;n;){e++;let a=n,o=0;for(let c=0;c<t&&(o++,a=a.nextZ,!!a);c++);let l=t;for(;o>0||l>0&&a;)o!==0&&(l===0||!a||n.z<=a.z)?(i=n,n=n.nextZ,o--):(i=a,a=a.nextZ,l--),r?r.nextZ=i:s=i,i.prevZ=r,r=i;n=a}r.nextZ=null,t*=2}while(e>1);return s}function vl(s,e,t,n,i){return s=(s-t)*i|0,e=(e-n)*i|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,s|e<<1}function Np(s){let e=s,t=s;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==s);return t}function mh(s,e,t,n,i,r,a,o){return(i-a)*(e-o)>=(s-a)*(r-o)&&(s-a)*(n-o)>=(t-a)*(e-o)&&(t-a)*(r-o)>=(i-a)*(n-o)}function or(s,e,t,n,i,r,a,o){return!(s===a&&e===o)&&mh(s,e,t,n,i,r,a,o)}function Up(s,e){return s.next.i!==e.i&&s.prev.i!==e.i&&!Fp(s,e)&&(Sr(s,e)&&Sr(e,s)&&Op(s,e)&&(Xt(s.prev,s,e.prev)||Xt(s,e.prev,e))||js(s,e)&&Xt(s.prev,s,s.next)>0&&Xt(e.prev,e,e.next)>0)}function Xt(s,e,t){return(e.y-s.y)*(t.x-e.x)-(e.x-s.x)*(t.y-e.y)}function js(s,e){return s.x===e.x&&s.y===e.y}function gh(s,e,t,n){const i=aa(Xt(s,e,t)),r=aa(Xt(s,e,n)),a=aa(Xt(t,n,s)),o=aa(Xt(t,n,e));return!!(i!==r&&a!==o||i===0&&ra(s,t,e)||r===0&&ra(s,n,e)||a===0&&ra(t,s,n)||o===0&&ra(t,e,n))}function ra(s,e,t){return e.x<=Math.max(s.x,t.x)&&e.x>=Math.min(s.x,t.x)&&e.y<=Math.max(s.y,t.y)&&e.y>=Math.min(s.y,t.y)}function aa(s){return s>0?1:s<0?-1:0}function Fp(s,e){let t=s;do{if(t.i!==s.i&&t.next.i!==s.i&&t.i!==e.i&&t.next.i!==e.i&&gh(t,t.next,s,e))return!0;t=t.next}while(t!==s);return!1}function Sr(s,e){return Xt(s.prev,s,s.next)<0?Xt(s,e,s.next)>=0&&Xt(s,s.prev,e)>=0:Xt(s,e,s.prev)<0||Xt(s,s.next,e)<0}function Op(s,e){let t=s,n=!1;const i=(s.x+e.x)/2,r=(s.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&i<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==s);return n}function _h(s,e){const t=Ml(s.i,s.x,s.y),n=Ml(e.i,e.x,e.y),i=s.next,r=e.prev;return s.next=e,e.prev=s,t.next=i,i.prev=t,n.next=t,t.prev=n,r.next=n,n.prev=r,n}function jc(s,e,t,n){const i=Ml(s,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Tr(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function Ml(s,e,t){return{i:s,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function kp(s,e,t,n){let i=0;for(let r=e,a=t-n;r<t;r+=n)i+=(s[a]-s[r])*(s[r+1]+s[a+1]),a=r;return i}class Bp{static triangulate(e,t,n=2){return Sp(e,t,n)}}class Wl{static area(e){const t=e.length;let n=0;for(let i=t-1,r=0;r<t;i=r++)n+=e[i].x*e[r].y-e[r].x*e[i].y;return n*.5}static isClockWise(e){return Wl.area(e)<0}static triangulateShape(e,t){const n=[],i=[],r=[];qc(e),Kc(n,e);let a=e.length;t.forEach(qc);for(let l=0;l<t.length;l++)i.push(a),a+=t[l].length,Kc(n,t[l]);const o=Bp.triangulate(n,i);for(let l=0;l<o.length;l+=3)r.push(o.slice(l,l+3));return r}}function qc(s){const e=s.length;e>2&&s[e-1].equals(s[0])&&s.pop()}function Kc(s,e){for(let t=0;t<e.length;t++)s.push(e[t].x),s.push(e[t].y)}class Ua extends Kt{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const r=e/2,a=t/2,o=Math.floor(n),l=Math.floor(i),c=o+1,u=l+1,h=e/o,d=t/l,f=[],g=[],_=[],m=[];for(let p=0;p<u;p++){const S=p*d-a;for(let x=0;x<c;x++){const y=x*h-r;g.push(y,-S,0),_.push(0,0,1),m.push(x/o),m.push(1-p/l)}}for(let p=0;p<l;p++)for(let S=0;S<o;S++){const x=S+c*p,y=S+c*(p+1),N=S+1+c*(p+1),P=S+1+c*p;f.push(x,y,P),f.push(y,N,P)}this.setIndex(f),this.setAttribute("position",new xt(g,3)),this.setAttribute("normal",new xt(_,3)),this.setAttribute("uv",new xt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ua(e.width,e.height,e.widthSegments,e.heightSegments)}}class br extends Dn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new He(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 He(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Na,this.normalScale=new ot(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 nn,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 oi extends br{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new ot(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return yt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new He(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new He(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new He(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class as extends Dn{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new He(16777215),this.specular=new He(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new He(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Na,this.normalScale=new ot(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new nn,this.combine=Da,this.reflectivity=1,this.refractionRatio=.98,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.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,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.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.flatShading=e.flatShading,this.fog=e.fog,this}}class yh extends Dn{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new He(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new He(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Na,this.normalScale=new ot(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new nn,this.combine=Da,this.reflectivity=1,this.refractionRatio=.98,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.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.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.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.flatShading=e.flatShading,this.fog=e.fog,this}}class zp extends Dn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=ff,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 Vp extends Dn{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}}function oa(s,e){return!s||s.constructor===e?s:typeof e.BYTES_PER_ELEMENT=="number"?new e(s):Array.prototype.slice.call(s)}function Hp(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Gp(s){function e(i,r){return s[i]-s[r]}const t=s.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function Yc(s,e,t){const n=s.length,i=new s.constructor(n);for(let r=0,a=0;a!==n;++r){const o=t[r]*e;for(let l=0;l!==e;++l)i[a++]=s[o+l]}return i}function xh(s,e,t,n){let i=1,r=s[0];for(;r!==void 0&&r[n]===void 0;)r=s[i++];if(r===void 0)return;let a=r[n];if(a!==void 0)if(Array.isArray(a))do a=r[n],a!==void 0&&(e.push(r.time),t.push(...a)),r=s[i++];while(r!==void 0);else if(a.toArray!==void 0)do a=r[n],a!==void 0&&(e.push(r.time),a.toArray(t,t.length)),r=s[i++];while(r!==void 0);else do a=r[n],a!==void 0&&(e.push(r.time),t.push(a)),r=s[i++];while(r!==void 0)}class Dr{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let a;n:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=i,i=t[++n],e<i)break t}a=t.length;break n}if(!(e>=r)){const o=t[1];e<o&&(n=2,r=o);for(let l=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=r,r=t[--n-1],e>=r)break t}a=n,n=0;break n}break e}for(;n<a;){const o=n+a>>>1;e<t[o]?a=o:n=o+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let a=0;a!==i;++a)t[a]=n[r+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class Wp extends Dr{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:cc,endingEnd:cc}}intervalChanged_(e,t,n){const i=this.parameterPositions;let r=e-2,a=e+1,o=i[r],l=i[a];if(o===void 0)switch(this.getSettings_().endingStart){case uc:r=e,o=2*t-n;break;case hc:r=i.length-2,o=t+i[r]-i[r+1];break;default:r=e,o=n}if(l===void 0)switch(this.getSettings_().endingEnd){case uc:a=e,l=2*n-t;break;case hc:a=1,l=n+i[1]-i[0];break;default:a=e-1,l=t}const c=(n-t)*.5,u=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-n),this._offsetPrev=r*u,this._offsetNext=a*u}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,u=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,f=this._weightNext,g=(n-t)/(i-t),_=g*g,m=_*g,p=-d*m+2*d*_-d*g,S=(1+d)*m+(-1.5-2*d)*_+(-.5+d)*g+1,x=(-1-f)*m+(1.5+f)*_+.5*g,y=f*m-f*_;for(let N=0;N!==o;++N)r[N]=p*a[u+N]+S*a[c+N]+x*a[l+N]+y*a[h+N];return r}}class Xp extends Dr{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,u=(n-t)/(i-t),h=1-u;for(let d=0;d!==o;++d)r[d]=a[c+d]*h+a[l+d]*u;return r}}class jp extends Dr{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class ti{constructor(e,t,n,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=oa(t,this.TimeBufferType),this.values=oa(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:oa(e.times,Array),values:oa(e.values,Array)};const i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new jp(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Xp(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Wp(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case _r:t=this.InterpolantFactoryMethodDiscrete;break;case yr:t=this.InterpolantFactoryMethodLinear;break;case Ga:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return _r;case this.InterpolantFactoryMethodLinear:return yr;case this.InterpolantFactoryMethodSmooth:return Ga}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){const n=this.times,i=n.length;let r=0,a=i-1;for(;r!==i&&n[r]<e;)++r;for(;a!==-1&&n[a]>t;)--a;if(++a,r!==0||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);const o=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,r=n.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==r;o++){const l=n[o];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(i!==void 0&&Hp(i))for(let o=0,l=i.length;o!==l;++o){const c=i[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===Ga,r=e.length-1;let a=1;for(let o=1;o<r;++o){let l=!1;const c=e[o],u=e[o+1];if(c!==u&&(o!==1||c!==e[0]))if(i)l=!0;else{const h=o*n,d=h-n,f=h+n;for(let g=0;g!==n;++g){const _=t[h+g];if(_!==t[d+g]||_!==t[f+g]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];const h=o*n,d=a*n;for(let f=0;f!==n;++f)t[d+f]=t[h+f]}++a}}if(r>0){e[a]=e[r];for(let o=r*n,l=a*n,c=0;c!==n;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}ti.prototype.ValueTypeName="";ti.prototype.TimeBufferType=Float32Array;ti.prototype.ValueBufferType=Float32Array;ti.prototype.DefaultInterpolation=yr;class Ks extends ti{constructor(e,t,n){super(e,t,n)}}Ks.prototype.ValueTypeName="bool";Ks.prototype.ValueBufferType=Array;Ks.prototype.DefaultInterpolation=_r;Ks.prototype.InterpolantFactoryMethodLinear=void 0;Ks.prototype.InterpolantFactoryMethodSmooth=void 0;class vh extends ti{constructor(e,t,n,i){super(e,t,n,i)}}vh.prototype.ValueTypeName="color";class hs extends ti{constructor(e,t,n,i){super(e,t,n,i)}}hs.prototype.ValueTypeName="number";class qp extends Dr{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(n-t)/(i-t);let c=e*o;for(let u=c+o;c!==u;c+=4)tn.slerpFlat(r,0,a,c-o,a,c,l);return r}}class Ai extends ti{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new qp(this.times,this.values,this.getValueSize(),e)}}Ai.prototype.ValueTypeName="quaternion";Ai.prototype.InterpolantFactoryMethodSmooth=void 0;class Ys extends ti{constructor(e,t,n){super(e,t,n)}}Ys.prototype.ValueTypeName="string";Ys.prototype.ValueBufferType=Array;Ys.prototype.DefaultInterpolation=_r;Ys.prototype.InterpolantFactoryMethodLinear=void 0;Ys.prototype.InterpolantFactoryMethodSmooth=void 0;class wi extends ti{constructor(e,t,n,i){super(e,t,n,i)}}wi.prototype.ValueTypeName="vector";class Ca{constructor(e="",t=-1,n=[],i=hf){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=ei(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let a=0,o=n.length;a!==o;++a)t.push(Yp(n[a]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let r=0,a=n.length;r!==a;++r)t.push(ti.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const r=t.length,a=[];for(let o=0;o<r;o++){let l=[],c=[];l.push((o+r-1)%r,o,(o+1)%r),c.push(0,1,0);const u=Gp(l);l=Yc(l,1,u),c=Yc(c,1,u),!i&&l[0]===0&&(l.push(r),c.push(c[0])),a.push(new hs(".morphTargetInfluences["+t[o].name+"]",l,c).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const c=e[o],u=c.name.match(r);if(u&&u.length>1){const h=u[1];let d=i[h];d||(i[h]=d=[]),d.push(c)}}const a=[];for(const o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return a}static parseAnimation(e,t){if(console.warn("THREE.AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(h,d,f,g,_){if(f.length!==0){const m=[],p=[];xh(f,m,p,g),m.length!==0&&_.push(new h(d,m,p))}},i=[],r=e.name||"default",a=e.fps||30,o=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let h=0;h<c.length;h++){const d=c[h].keys;if(!(!d||d.length===0))if(d[0].morphTargets){const f={};let g;for(g=0;g<d.length;g++)if(d[g].morphTargets)for(let _=0;_<d[g].morphTargets.length;_++)f[d[g].morphTargets[_]]=-1;for(const _ in f){const m=[],p=[];for(let S=0;S!==d[g].morphTargets.length;++S){const x=d[g];m.push(x.time),p.push(x.morphTarget===_?1:0)}i.push(new hs(".morphTargetInfluence["+_+"]",m,p))}l=f.length*a}else{const f=".bones["+t[h].name+"]";n(wi,f+".position",d,"pos",i),n(Ai,f+".quaternion",d,"rot",i),n(wi,f+".scale",d,"scl",i)}}return i.length===0?null:new this(r,l,i,o)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,i=e.length;n!==i;++n){const r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function Kp(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return hs;case"vector":case"vector2":case"vector3":case"vector4":return wi;case"color":return vh;case"quaternion":return Ai;case"bool":case"boolean":return Ks;case"string":return Ys}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function Yp(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=Kp(s.type);if(s.times===void 0){const t=[],n=[];xh(s.keys,t,n,"value"),s.times=t,s.values=n}return e.parse!==void 0?e.parse(s):new e(s.name,s.times,s.values,s.interpolation)}const Vi={enabled:!1,files:{},add:function(s,e){this.enabled!==!1&&(this.files[s]=e)},get:function(s){if(this.enabled!==!1)return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}};class Zp{constructor(e,t,n){const i=this;let r=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(u){o++,r===!1&&i.onStart!==void 0&&i.onStart(u,a,o),r=!0},this.itemEnd=function(u){a++,i.onProgress!==void 0&&i.onProgress(u,a,o),a===o&&(r=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(u){i.onError!==void 0&&i.onError(u)},this.resolveURL=function(u){return l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,h){return c.push(u,h),this},this.removeHandler=function(u){const h=c.indexOf(u);return h!==-1&&c.splice(h,2),this},this.getHandler=function(u){for(let h=0,d=c.length;h<d;h+=2){const f=c[h],g=c[h+1];if(f.global&&(f.lastIndex=0),f.test(u))return g}return null}}}const $p=new Zp;class bn{constructor(e){this.manager=e!==void 0?e:$p,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}bn.DEFAULT_MATERIAL_NAME="__DEFAULT";const yi={};class Jp extends Error{constructor(e,t){super(e),this.response=t}}class Xi extends bn{constructor(e){super(e),this.mimeType="",this.responseType=""}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=Vi.get(e);if(r!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0),r;if(yi[e]!==void 0){yi[e].push({onLoad:t,onProgress:n,onError:i});return}yi[e]=[],yi[e].push({onLoad:t,onProgress:n,onError:i});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const u=yi[e],h=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),f=d?parseInt(d):0,g=f!==0;let _=0;const m=new ReadableStream({start(p){S();function S(){h.read().then(({done:x,value:y})=>{if(x)p.close();else{_+=y.byteLength;const N=new ProgressEvent("progress",{lengthComputable:g,loaded:_,total:f});for(let P=0,L=u.length;P<L;P++){const U=u[P];U.onProgress&&U.onProgress(N)}p.enqueue(y),S()}},x=>{p.error(x)})}}});return new Response(m)}else throw new Jp(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,o));case"json":return c.json();default:if(o==="")return c.text();{const h=/charset="?([^;"\s]*)"?/i.exec(o),d=h&&h[1]?h[1].toLowerCase():void 0,f=new TextDecoder(d);return c.arrayBuffer().then(g=>f.decode(g))}}}).then(c=>{Vi.add(e,c);const u=yi[e];delete yi[e];for(let h=0,d=u.length;h<d;h++){const f=u[h];f.onLoad&&f.onLoad(c)}}).catch(c=>{const u=yi[e];if(u===void 0)throw this.manager.itemError(e),c;delete yi[e];for(let h=0,d=u.length;h<d;h++){const f=u[h];f.onError&&f.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class Qp extends bn{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=Vi.get(e);if(a!==void 0)return r.manager.itemStart(e),setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0),a;const o=xr("img");function l(){u(),Vi.add(e,this),t&&t(this),r.manager.itemEnd(e)}function c(h){u(),i&&i(h),r.manager.itemError(e),r.manager.itemEnd(e)}function u(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),r.manager.itemStart(e),o.src=e,o}}class em extends bn{constructor(e){super(e)}load(e,t,n,i){const r=this,a=new Hl,o=new Xi(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(r.withCredentials),o.load(e,function(l){let c;try{c=r.parse(l)}catch(u){if(i!==void 0)i(u);else{console.error(u);return}}c.image!==void 0?a.image=c.image:c.data!==void 0&&(a.image.width=c.width,a.image.height=c.height,a.image.data=c.data),a.wrapS=c.wrapS!==void 0?c.wrapS:Pn,a.wrapT=c.wrapT!==void 0?c.wrapT:Pn,a.magFilter=c.magFilter!==void 0?c.magFilter:gn,a.minFilter=c.minFilter!==void 0?c.minFilter:gn,a.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0&&(a.colorSpace=c.colorSpace),c.flipY!==void 0&&(a.flipY=c.flipY),c.format!==void 0&&(a.format=c.format),c.type!==void 0&&(a.type=c.type),c.mipmaps!==void 0&&(a.mipmaps=c.mipmaps,a.minFilter=Jn),c.mipmapCount===1&&(a.minFilter=gn),c.generateMipmaps!==void 0&&(a.generateMipmaps=c.generateMipmaps),a.needsUpdate=!0,t&&t(a,c)},n,i),a}}class Xl extends bn{constructor(e){super(e)}load(e,t,n,i){const r=new rn,a=new Qp(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){r.image=o,r.needsUpdate=!0,t!==void 0&&t(r)},n,i),r}}class Fa extends kt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new He(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}}const go=new Fe,Zc=new O,$c=new O;class jl{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ot(512,512),this.mapType=ri,this.map=null,this.mapPass=null,this.matrix=new Fe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Gl,this._frameExtents=new ot(1,1),this._viewportCount=1,this._viewports=[new Tt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;Zc.setFromMatrixPosition(e.matrixWorld),t.position.copy(Zc),$c.setFromMatrixPosition(e.target.matrixWorld),t.lookAt($c),t.updateMatrixWorld(),go.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(go),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(go)}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 tm extends jl{constructor(){super(new cn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,n=Gs*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;(n!==t.fov||i!==t.aspect||r!==t.far)&&(t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class ql extends Fa{constructor(e,t,n=0,i=Math.PI/3,r=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(kt.DEFAULT_UP),this.updateMatrix(),this.target=new kt,this.distance=n,this.angle=i,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new tm}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const Jc=new Fe,sr=new O,_o=new O;class nm extends jl{constructor(){super(new cn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new ot(4,2),this._viewportCount=6,this._viewports=[new Tt(2,1,1,1),new Tt(0,1,1,1),new Tt(3,1,1,1),new Tt(1,1,1,1),new Tt(3,0,1,1),new Tt(1,0,1,1)],this._cubeDirections=[new O(1,0,0),new O(-1,0,0),new O(0,0,1),new O(0,0,-1),new O(0,1,0),new O(0,-1,0)],this._cubeUps=[new O(0,1,0),new O(0,1,0),new O(0,1,0),new O(0,1,0),new O(0,0,1),new O(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,r=e.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),sr.setFromMatrixPosition(e.matrixWorld),n.position.copy(sr),_o.copy(n.position),_o.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(_o),n.updateMatrixWorld(),i.makeTranslation(-sr.x,-sr.y,-sr.z),Jc.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Jc)}}class Pa extends Fa{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new nm}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class Oa extends uh{constructor(e=-1,t=1,n=1,i=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-e,a=n+e,o=i+t,l=i-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;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,this.near,this.far,this.coordinateSystem),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 im extends jl{constructor(){super(new Oa(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Er extends Fa{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(kt.DEFAULT_UP),this.updateMatrix(),this.target=new kt,this.shadow=new im}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class Kl extends Fa{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class os{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}const yo=new WeakMap;class sm extends bn{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=Vi.get(e);if(a!==void 0){if(r.manager.itemStart(e),a.then){a.then(c=>{if(yo.has(a)===!0)i&&i(yo.get(a)),r.manager.itemError(e),r.manager.itemEnd(e);else return t&&t(c),r.manager.itemEnd(e),c});return}return setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader;const l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(c){return Vi.add(e,c),t&&t(c),r.manager.itemEnd(e),c}).catch(function(c){i&&i(c),yo.set(l,c),Vi.remove(e),r.manager.itemError(e),r.manager.itemEnd(e)});Vi.add(e,l),r.manager.itemStart(e)}}class rm extends cn{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const Yl="\\[\\]\\.:\\/",am=new RegExp("["+Yl+"]","g"),Zl="[^"+Yl+"]",om="[^"+Yl.replace("\\.","")+"]",lm=/((?:WC+[\/:])*)/.source.replace("WC",Zl),cm=/(WCOD+)?/.source.replace("WCOD",om),um=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Zl),hm=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Zl),dm=new RegExp("^"+lm+cm+um+hm+"$"),fm=["material","materials","bones","map"];class pm{constructor(e,t,n){const i=n||At.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class At{constructor(e,t,n){this.path=t,this.parsedPath=n||At.parseTrackName(t),this.node=At.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new At.Composite(e,t,n):new At(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(am,"")}static parseTrackName(e){const t=dm.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const r=n.nodeName.substring(i+1);fm.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(r){for(let a=0;a<r.length;a++){const o=r[a];if(o.name===t||o.uuid===t)return o;const l=n(o.children);if(l)return l}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,i=t.propertyName;let r=t.propertyIndex;if(e||(e=At.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===c){c=u;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const a=e[i];if(a===void 0){const c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}At.Composite=pm;At.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};At.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};At.prototype.GetterByBindingType=[At.prototype._getValue_direct,At.prototype._getValue_array,At.prototype._getValue_arrayElement,At.prototype._getValue_toArray];At.prototype.SetterByBindingTypeAndVersioning=[[At.prototype._setValue_direct,At.prototype._setValue_direct_setNeedsUpdate,At.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[At.prototype._setValue_array,At.prototype._setValue_array_setNeedsUpdate,At.prototype._setValue_array_setMatrixWorldNeedsUpdate],[At.prototype._setValue_arrayElement,At.prototype._setValue_arrayElement_setNeedsUpdate,At.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[At.prototype._setValue_fromArray,At.prototype._setValue_fromArray_setNeedsUpdate,At.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Qc{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=yt(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(yt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class mm extends Xs{constructor(e=10,t=10,n=4473924,i=8947848){n=new He(n),i=new He(i);const r=t/2,a=e/t,o=e/2,l=[],c=[];for(let d=0,f=0,g=-o;d<=t;d++,g+=a){l.push(-o,0,g,o,0,g),l.push(g,0,-o,g,0,o);const _=d===r?n:i;_.toArray(c,f),f+=3,_.toArray(c,f),f+=3,_.toArray(c,f),f+=3,_.toArray(c,f),f+=3}const u=new Kt;u.setAttribute("position",new xt(l,3)),u.setAttribute("color",new xt(c,3));const h=new ii({vertexColors:!0,toneMapped:!1});super(u,h),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class gm extends Xs{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Kt;i.setAttribute("position",new xt(t,3)),i.setAttribute("color",new xt(n,3));const r=new ii({vertexColors:!0,toneMapped:!1});super(i,r),this.type="AxesHelper"}setColors(e,t,n){const i=new He,r=this.geometry.attributes.color.array;return i.set(e),i.toArray(r,0),i.toArray(r,3),i.set(t),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class _m extends ds{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 eu(s,e,t,n){const i=ym(n);switch(t){case Ju:return s*e;case Il:return s*e/i.components*i.byteLength;case Nl:return s*e/i.components*i.byteLength;case eh:return s*e*2/i.components*i.byteLength;case Ul:return s*e*2/i.components*i.byteLength;case Qu:return s*e*3/i.components*i.byteLength;case Hn:return s*e*4/i.components*i.byteLength;case Fl:return s*e*4/i.components*i.byteLength;case ma:case ga:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case _a:case ya:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Xo:case qo:return Math.max(s,16)*Math.max(e,8)/4;case Wo:case jo:return Math.max(s,8)*Math.max(e,8)/2;case Ko:case Yo:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case Zo:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case $o:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Jo:return Math.floor((s+4)/5)*Math.floor((e+3)/4)*16;case Qo:return Math.floor((s+4)/5)*Math.floor((e+4)/5)*16;case el:return Math.floor((s+5)/6)*Math.floor((e+4)/5)*16;case tl:return Math.floor((s+5)/6)*Math.floor((e+5)/6)*16;case nl:return Math.floor((s+7)/8)*Math.floor((e+4)/5)*16;case il:return Math.floor((s+7)/8)*Math.floor((e+5)/6)*16;case sl:return Math.floor((s+7)/8)*Math.floor((e+7)/8)*16;case rl:return Math.floor((s+9)/10)*Math.floor((e+4)/5)*16;case al:return Math.floor((s+9)/10)*Math.floor((e+5)/6)*16;case ol:return Math.floor((s+9)/10)*Math.floor((e+7)/8)*16;case ll:return Math.floor((s+9)/10)*Math.floor((e+9)/10)*16;case cl:return Math.floor((s+11)/12)*Math.floor((e+9)/10)*16;case ul:return Math.floor((s+11)/12)*Math.floor((e+11)/12)*16;case xa:case hl:case dl:return Math.ceil(s/4)*Math.ceil(e/4)*16;case th:case fl:return Math.ceil(s/4)*Math.ceil(e/4)*8;case pl:case ml:return Math.ceil(s/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function ym(s){switch(s){case ri:case Yu:return{byteLength:1,components:1};case fr:case Zu:case wr:return{byteLength:2,components:1};case Ll:case Dl:return{byteLength:2,components:4};case ls:case Pl:case Qn:return{byteLength:4,components:1};case $u:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${s}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Cl}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Cl);/**
44
+ `},i=new Pr(5,5,5),r=new Wi({name:"CubemapFromEquirect",uniforms:Xs(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:In,blending:Hi});r.uniforms.tEquirect.value=t;const a=new rn(i,r),o=t.minFilter;return t.minFilter===Qn&&(t.minFilter=yn),new up(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,i);e.setRenderTarget(r)}}class Wn extends kt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const dp={type:"move"};class uo{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Wn,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 Wn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new O,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new O),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Wn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new O,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new O),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const 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 i=null,r=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const _ of e.hand.values()){const m=t.getJointPose(_,n),p=this._getHandJoint(c,_);m!==null&&(p.matrix.fromArray(m.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=m.radius),p.visible=m!==null}const u=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],d=u.position.distanceTo(h.position),f=.02,g=.005;c.inputState.pinching&&d>f+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=f-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null&&(i=r),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(dp)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Wn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class dh extends kt{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 sn,this.environmentIntensity=1,this.environmentRotation=new sn,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}}class fp{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=_l,this.updateRanges=[],this.version=0,this.uuid=ti()}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.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ti()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ti()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Sn=new O;class zl{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Sn.fromBufferAttribute(this,t),Sn.applyMatrix4(e),this.setXYZ(t,Sn.x,Sn.y,Sn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Sn.fromBufferAttribute(this,t),Sn.applyNormalMatrix(e),this.setXYZ(t,Sn.x,Sn.y,Sn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Sn.fromBufferAttribute(this,t),Sn.transformDirection(e),this.setXYZ(t,Sn.x,Sn.y,Sn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=$n(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=It(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=It(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=It(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=It(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=It(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=$n(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=$n(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=$n(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=$n(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=It(t,this.array),n=It(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=It(t,this.array),n=It(n,this.array),i=It(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=It(t,this.array),n=It(n,this.array),i=It(i,this.array),r=It(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new hn(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new zl(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}const Dc=new O,Ic=new Tt,Nc=new Tt,pp=new O,Uc=new Fe,Qr=new O,ho=new oi,Fc=new Fe,fo=new Cr;class Vl extends rn{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=lc,this.bindMatrix=new Fe,this.bindMatrixInverse=new Fe,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Ci),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Qr),this.boundingBox.expandByPoint(Qr)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new oi),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Qr),this.boundingSphere.expandByPoint(Qr)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ho.copy(this.boundingSphere),ho.applyMatrix4(i),e.ray.intersectsSphere(ho)!==!1&&(Fc.copy(i).invert(),fo.copy(e.ray).applyMatrix4(Fc),!(this.boundingBox!==null&&fo.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,fo)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new Tt,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===lc?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===uf?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,i=this.geometry;Ic.fromBufferAttribute(i.attributes.skinIndex,e),Nc.fromBufferAttribute(i.attributes.skinWeight,e),Dc.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let r=0;r<4;r++){const a=Nc.getComponent(r);if(a!==0){const o=Ic.getComponent(r);Uc.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(pp.copy(Dc).applyMatrix4(Uc),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class Mr extends kt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Hl extends an{constructor(e=null,t=1,n=1,i,r,a,o,l,c=En,u=En,h,d){super(null,a,o,l,c,u,i,r,h,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Oc=new Fe,mp=new Fe;class Lr{constructor(e=[],t=[]){this.uuid=ti(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Fe)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new Fe;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,a=e.length;r<a;r++){const o=e[r]?e[r].matrixWorld:mp;Oc.multiplyMatrices(o,t[r]),Oc.toArray(n,r*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new Lr(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new Hl(t,e,e,Gn,ei);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const r=e.bones[n];let a=t[r];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",r),a=new Mr),this.bones.push(a),this.boneInverses.push(new Fe().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){const a=t[i];e.bones.push(a.uuid);const o=n[i];e.boneInverses.push(o.toArray())}return e}}class yl extends hn{constructor(e,t,n,i=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Cs=new Fe,kc=new Fe,ea=[],Bc=new Ci,gp=new Fe,nr=new rn,ir=new oi;class _p extends rn{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new yl(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,gp)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Ci),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Cs),Bc.copy(e.boundingBox).applyMatrix4(Cs),this.boundingBox.union(Bc)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new oi),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Cs),ir.copy(e.boundingSphere).applyMatrix4(Cs),this.boundingSphere.union(ir)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,a=e*r+1;for(let o=0;o<n.length;o++)n[o]=i[a+o]}raycast(e,t){const n=this.matrixWorld,i=this.count;if(nr.geometry=this.geometry,nr.material=this.material,nr.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ir.copy(this.boundingSphere),ir.applyMatrix4(n),e.ray.intersectsSphere(ir)!==!1))for(let r=0;r<i;r++){this.getMatrixAt(r,Cs),kc.multiplyMatrices(n,Cs),nr.matrixWorld=kc,nr.raycast(e,ea);for(let a=0,o=ea.length;a<o;a++){const l=ea[a];l.instanceId=r,l.object=this,t.push(l)}ea.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new yl(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const n=t.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new Hl(new Float32Array(i*this.count),i,this.count,Il,ei));const r=this.morphTexture.source.data.data;let a=0;for(let c=0;c<n.length;c++)a+=n[c];const o=this.geometry.morphTargetsRelative?1:1-a,l=i*e;r[l]=o,r.set(n,l+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const po=new O,yp=new O,vp=new gt;class Bi{constructor(e=new O(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=po.subVectors(n,t).cross(yp.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,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(po),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:t.copy(e.start).addScaledVector(n,r)}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||vp.getNormalMatrix(e),i=this.coplanarPoint(po).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),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 Qi=new oi,ta=new O;class Gl{constructor(e=new Bi,t=new Bi,n=new Bi,i=new Bi,r=new Bi,a=new Bi){this.planes=[e,t,n,i,r,a]}set(e,t,n,i,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Ti){const n=this.planes,i=e.elements,r=i[0],a=i[1],o=i[2],l=i[3],c=i[4],u=i[5],h=i[6],d=i[7],f=i[8],g=i[9],_=i[10],m=i[11],p=i[12],S=i[13],v=i[14],y=i[15];if(n[0].setComponents(l-r,d-c,m-f,y-p).normalize(),n[1].setComponents(l+r,d+c,m+f,y+p).normalize(),n[2].setComponents(l+a,d+u,m+g,y+S).normalize(),n[3].setComponents(l-a,d-u,m-g,y-S).normalize(),n[4].setComponents(l-o,d-h,m-_,y-v).normalize(),t===Ti)n[5].setComponents(l+o,d+h,m+_,y+v).normalize();else if(t===wa)n[5].setComponents(o,h,_,v).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(),Qi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Qi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Qi)}intersectsSprite(e){return Qi.center.set(0,0,0),Qi.radius=.7071067811865476,Qi.applyMatrix4(e.matrixWorld),this.intersectsSphere(Qi)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(ta.x=i.normal.x>0?e.max.x:e.min.x,ta.y=i.normal.y>0?e.max.y:e.min.y,ta.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(ta)<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 si extends Nn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ge(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Ra=new O,Ca=new O,zc=new Fe,sr=new Cr,na=new oi,mo=new O,Vc=new O;class Dr extends kt{constructor(e=new Kt,t=new si){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 i=1,r=t.count;i<r;i++)Ra.fromBufferAttribute(t,i-1),Ca.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=Ra.distanceTo(Ca);e.setAttribute("lineDistance",new vt(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),na.copy(n.boundingSphere),na.applyMatrix4(i),na.radius+=r,e.ray.intersectsSphere(na)===!1)return;zc.copy(i).invert(),sr.copy(e.ray).applyMatrix4(zc);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,u=n.index,d=n.attributes.position;if(u!==null){const f=Math.max(0,a.start),g=Math.min(u.count,a.start+a.count);for(let _=f,m=g-1;_<m;_+=c){const p=u.getX(_),S=u.getX(_+1),v=ia(this,e,sr,l,p,S,_);v&&t.push(v)}if(this.isLineLoop){const _=u.getX(g-1),m=u.getX(f),p=ia(this,e,sr,l,_,m,g-1);p&&t.push(p)}}else{const f=Math.max(0,a.start),g=Math.min(d.count,a.start+a.count);for(let _=f,m=g-1;_<m;_+=c){const p=ia(this,e,sr,l,_,_+1,_);p&&t.push(p)}if(this.isLineLoop){const _=ia(this,e,sr,l,g-1,f,g-1);_&&t.push(_)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function ia(s,e,t,n,i,r,a){const o=s.geometry.attributes.position;if(Ra.fromBufferAttribute(o,i),Ca.fromBufferAttribute(o,r),t.distanceSqToSegment(Ra,Ca,mo,Vc)>n)return;mo.applyMatrix4(s.matrixWorld);const c=e.ray.origin.distanceTo(mo);if(!(c<e.near||c>e.far))return{distance:c,point:Vc.clone().applyMatrix4(s.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:s}}const Hc=new O,Gc=new O;class js extends Dr{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 i=0,r=t.count;i<r;i+=2)Hc.fromBufferAttribute(t,i),Gc.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+Hc.distanceTo(Gc);e.setAttribute("lineDistance",new vt(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class xp extends Dr{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Is extends Nn{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ge(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const Wc=new Fe,vl=new Cr,sa=new oi,ra=new O;class Ma extends kt{constructor(e=new Kt,t=new Is){super(),this.isPoints=!0,this.type="Points",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}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),sa.copy(n.boundingSphere),sa.applyMatrix4(i),sa.radius+=r,e.ray.intersectsSphere(sa)===!1)return;Wc.copy(i).invert(),vl.copy(e.ray).applyMatrix4(Wc);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=n.index,h=n.attributes.position;if(c!==null){const d=Math.max(0,a.start),f=Math.min(c.count,a.start+a.count);for(let g=d,_=f;g<_;g++){const m=c.getX(g);ra.fromBufferAttribute(h,m),Xc(ra,m,l,i,e,t,this)}}else{const d=Math.max(0,a.start),f=Math.min(h.count,a.start+a.count);for(let g=d,_=f;g<_;g++)ra.fromBufferAttribute(h,g),Xc(ra,g,l,i,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Xc(s,e,t,n,i,r,a){const o=vl.distanceSqToPoint(s);if(o<t){const l=new O;vl.closestPointToPoint(s,l),l.applyMatrix4(n);const c=i.ray.origin.distanceTo(l);if(c<i.near||c>i.far)return;r.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class fh extends an{constructor(e,t,n=ls,i,r,a,o=En,l=En,c,u=gr,h=1){if(u!==gr&&u!==_r)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:e,height:t,depth:h};super(d,i,r,a,o,l,u,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new kl(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 Mp{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){console.warn("THREE.Curve: .getPoint() not implemented.")}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),r=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),r+=n.distanceTo(i),t.push(r),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const n=this.getLengths();let i=0;const r=n.length;let a;t?a=t:a=e*n[r-1];let o=0,l=r-1,c;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),c=n[i]-a,c<0)o=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,n[i]===a)return i/(r-1);const u=n[i],d=n[i+1]-u,f=(a-u)/d;return(i+f)/(r-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);const a=this.getPoint(i),o=this.getPoint(r),l=t||(a.isVector2?new ct:new O);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){const n=new O,i=[],r=[],a=[],o=new O,l=new Fe;for(let f=0;f<=e;f++){const g=f/e;i[f]=this.getTangentAt(g,new O)}r[0]=new O,a[0]=new O;let c=Number.MAX_VALUE;const u=Math.abs(i[0].x),h=Math.abs(i[0].y),d=Math.abs(i[0].z);u<=c&&(c=u,n.set(1,0,0)),h<=c&&(c=h,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],o),a[0].crossVectors(i[0],r[0]);for(let f=1;f<=e;f++){if(r[f]=r[f-1].clone(),a[f]=a[f-1].clone(),o.crossVectors(i[f-1],i[f]),o.length()>Number.EPSILON){o.normalize();const g=Math.acos(yt(i[f-1].dot(i[f]),-1,1));r[f].applyMatrix4(l.makeRotationAxis(o,g))}a[f].crossVectors(i[f],r[f])}if(t===!0){let f=Math.acos(yt(r[0].dot(r[e]),-1,1));f/=e,i[0].dot(o.crossVectors(r[0],r[e]))>0&&(f=-f);for(let g=1;g<=e;g++)r[g].applyMatrix4(l.makeRotationAxis(i[g],f*g)),a[g].crossVectors(i[g],r[g])}return{tangents:i,normals:r,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}function Sp(s,e,t=2){const n=e&&e.length,i=n?e[0]*t:s.length;let r=ph(s,0,i,t,!0);const a=[];if(!r||r.next===r.prev)return a;let o,l,c;if(n&&(r=wp(s,e,r,t)),s.length>80*t){o=1/0,l=1/0;let u=-1/0,h=-1/0;for(let d=t;d<i;d+=t){const f=s[d],g=s[d+1];f<o&&(o=f),g<l&&(l=g),f>u&&(u=f),g>h&&(h=g)}c=Math.max(u-o,h-l),c=c!==0?32767/c:0}return Sr(r,a,t,o,l,c,0),a}function ph(s,e,t,n,i){let r;if(i===kp(s,e,t,n)>0)for(let a=e;a<t;a+=n)r=jc(a/n|0,s[a],s[a+1],r);else for(let a=t-n;a>=e;a-=n)r=jc(a/n|0,s[a],s[a+1],r);return r&&qs(r,r.next)&&(br(r),r=r.next),r}function us(s,e){if(!s)return s;e||(e=s);let t=s,n;do if(n=!1,!t.steiner&&(qs(t,t.next)||Wt(t.prev,t,t.next)===0)){if(br(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Sr(s,e,t,n,i,r,a){if(!s)return;!a&&r&&Dp(s,n,i,r);let o=s;for(;s.prev!==s.next;){const l=s.prev,c=s.next;if(r?bp(s,n,i,r):Tp(s)){e.push(l.i,s.i,c.i),br(s),s=c.next,o=c.next;continue}if(s=c,s===o){a?a===1?(s=Ep(us(s),e),Sr(s,e,t,n,i,r,2)):a===2&&Ap(s,e,t,n,i,r):Sr(us(s),e,t,n,i,r,1);break}}}function Tp(s){const e=s.prev,t=s,n=s.next;if(Wt(e,t,n)>=0)return!1;const i=e.x,r=t.x,a=n.x,o=e.y,l=t.y,c=n.y,u=Math.min(i,r,a),h=Math.min(o,l,c),d=Math.max(i,r,a),f=Math.max(o,l,c);let g=n.next;for(;g!==e;){if(g.x>=u&&g.x<=d&&g.y>=h&&g.y<=f&&lr(i,o,r,l,a,c,g.x,g.y)&&Wt(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function bp(s,e,t,n){const i=s.prev,r=s,a=s.next;if(Wt(i,r,a)>=0)return!1;const o=i.x,l=r.x,c=a.x,u=i.y,h=r.y,d=a.y,f=Math.min(o,l,c),g=Math.min(u,h,d),_=Math.max(o,l,c),m=Math.max(u,h,d),p=xl(f,g,e,t,n),S=xl(_,m,e,t,n);let v=s.prevZ,y=s.nextZ;for(;v&&v.z>=p&&y&&y.z<=S;){if(v.x>=f&&v.x<=_&&v.y>=g&&v.y<=m&&v!==i&&v!==a&&lr(o,u,l,h,c,d,v.x,v.y)&&Wt(v.prev,v,v.next)>=0||(v=v.prevZ,y.x>=f&&y.x<=_&&y.y>=g&&y.y<=m&&y!==i&&y!==a&&lr(o,u,l,h,c,d,y.x,y.y)&&Wt(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;v&&v.z>=p;){if(v.x>=f&&v.x<=_&&v.y>=g&&v.y<=m&&v!==i&&v!==a&&lr(o,u,l,h,c,d,v.x,v.y)&&Wt(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;y&&y.z<=S;){if(y.x>=f&&y.x<=_&&y.y>=g&&y.y<=m&&y!==i&&y!==a&&lr(o,u,l,h,c,d,y.x,y.y)&&Wt(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function Ep(s,e){let t=s;do{const n=t.prev,i=t.next.next;!qs(n,i)&&gh(n,t,t.next,i)&&Tr(n,i)&&Tr(i,n)&&(e.push(n.i,t.i,i.i),br(t),br(t.next),t=s=i),t=t.next}while(t!==s);return us(t)}function Ap(s,e,t,n,i,r){let a=s;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&Up(a,o)){let l=_h(a,o);a=us(a,a.next),l=us(l,l.next),Sr(a,e,t,n,i,r,0),Sr(l,e,t,n,i,r,0);return}o=o.next}a=a.next}while(a!==s)}function wp(s,e,t,n){const i=[];for(let r=0,a=e.length;r<a;r++){const o=e[r]*n,l=r<a-1?e[r+1]*n:s.length,c=ph(s,o,l,n,!1);c===c.next&&(c.steiner=!0),i.push(Np(c))}i.sort(Rp);for(let r=0;r<i.length;r++)t=Cp(i[r],t);return t}function Rp(s,e){let t=s.x-e.x;if(t===0&&(t=s.y-e.y,t===0)){const n=(s.next.y-s.y)/(s.next.x-s.x),i=(e.next.y-e.y)/(e.next.x-e.x);t=n-i}return t}function Cp(s,e){const t=Pp(s,e);if(!t)return e;const n=_h(t,s);return us(n,n.next),us(t,t.next)}function Pp(s,e){let t=e;const n=s.x,i=s.y;let r=-1/0,a;if(qs(s,t))return t;do{if(qs(s,t.next))return t.next;if(i<=t.y&&i>=t.next.y&&t.next.y!==t.y){const h=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(h<=n&&h>r&&(r=h,a=t.x<t.next.x?t:t.next,h===n))return a}t=t.next}while(t!==e);if(!a)return null;const o=a,l=a.x,c=a.y;let u=1/0;t=a;do{if(n>=t.x&&t.x>=l&&n!==t.x&&mh(i<c?n:r,i,l,c,i<c?r:n,i,t.x,t.y)){const h=Math.abs(i-t.y)/(n-t.x);Tr(t,s)&&(h<u||h===u&&(t.x>a.x||t.x===a.x&&Lp(a,t)))&&(a=t,u=h)}t=t.next}while(t!==o);return a}function Lp(s,e){return Wt(s.prev,s,e.prev)<0&&Wt(e.next,s,s.next)<0}function Dp(s,e,t,n){let i=s;do i.z===0&&(i.z=xl(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==s);i.prevZ.nextZ=null,i.prevZ=null,Ip(i)}function Ip(s){let e,t=1;do{let n=s,i;s=null;let r=null;for(e=0;n;){e++;let a=n,o=0;for(let c=0;c<t&&(o++,a=a.nextZ,!!a);c++);let l=t;for(;o>0||l>0&&a;)o!==0&&(l===0||!a||n.z<=a.z)?(i=n,n=n.nextZ,o--):(i=a,a=a.nextZ,l--),r?r.nextZ=i:s=i,i.prevZ=r,r=i;n=a}r.nextZ=null,t*=2}while(e>1);return s}function xl(s,e,t,n,i){return s=(s-t)*i|0,e=(e-n)*i|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,s|e<<1}function Np(s){let e=s,t=s;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==s);return t}function mh(s,e,t,n,i,r,a,o){return(i-a)*(e-o)>=(s-a)*(r-o)&&(s-a)*(n-o)>=(t-a)*(e-o)&&(t-a)*(r-o)>=(i-a)*(n-o)}function lr(s,e,t,n,i,r,a,o){return!(s===a&&e===o)&&mh(s,e,t,n,i,r,a,o)}function Up(s,e){return s.next.i!==e.i&&s.prev.i!==e.i&&!Fp(s,e)&&(Tr(s,e)&&Tr(e,s)&&Op(s,e)&&(Wt(s.prev,s,e.prev)||Wt(s,e.prev,e))||qs(s,e)&&Wt(s.prev,s,s.next)>0&&Wt(e.prev,e,e.next)>0)}function Wt(s,e,t){return(e.y-s.y)*(t.x-e.x)-(e.x-s.x)*(t.y-e.y)}function qs(s,e){return s.x===e.x&&s.y===e.y}function gh(s,e,t,n){const i=oa(Wt(s,e,t)),r=oa(Wt(s,e,n)),a=oa(Wt(t,n,s)),o=oa(Wt(t,n,e));return!!(i!==r&&a!==o||i===0&&aa(s,t,e)||r===0&&aa(s,n,e)||a===0&&aa(t,s,n)||o===0&&aa(t,e,n))}function aa(s,e,t){return e.x<=Math.max(s.x,t.x)&&e.x>=Math.min(s.x,t.x)&&e.y<=Math.max(s.y,t.y)&&e.y>=Math.min(s.y,t.y)}function oa(s){return s>0?1:s<0?-1:0}function Fp(s,e){let t=s;do{if(t.i!==s.i&&t.next.i!==s.i&&t.i!==e.i&&t.next.i!==e.i&&gh(t,t.next,s,e))return!0;t=t.next}while(t!==s);return!1}function Tr(s,e){return Wt(s.prev,s,s.next)<0?Wt(s,e,s.next)>=0&&Wt(s,s.prev,e)>=0:Wt(s,e,s.prev)<0||Wt(s,s.next,e)<0}function Op(s,e){let t=s,n=!1;const i=(s.x+e.x)/2,r=(s.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&i<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==s);return n}function _h(s,e){const t=Ml(s.i,s.x,s.y),n=Ml(e.i,e.x,e.y),i=s.next,r=e.prev;return s.next=e,e.prev=s,t.next=i,i.prev=t,n.next=t,t.prev=n,r.next=n,n.prev=r,n}function jc(s,e,t,n){const i=Ml(s,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function br(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function Ml(s,e,t){return{i:s,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function kp(s,e,t,n){let i=0;for(let r=e,a=t-n;r<t;r+=n)i+=(s[a]-s[r])*(s[r+1]+s[a+1]),a=r;return i}class Bp{static triangulate(e,t,n=2){return Sp(e,t,n)}}class Wl{static area(e){const t=e.length;let n=0;for(let i=t-1,r=0;r<t;i=r++)n+=e[i].x*e[r].y-e[r].x*e[i].y;return n*.5}static isClockWise(e){return Wl.area(e)<0}static triangulateShape(e,t){const n=[],i=[],r=[];qc(e),Kc(n,e);let a=e.length;t.forEach(qc);for(let l=0;l<t.length;l++)i.push(a),a+=t[l].length,Kc(n,t[l]);const o=Bp.triangulate(n,i);for(let l=0;l<o.length;l+=3)r.push(o.slice(l,l+3));return r}}function qc(s){const e=s.length;e>2&&s[e-1].equals(s[0])&&s.pop()}function Kc(s,e){for(let t=0;t<e.length;t++)s.push(e[t].x),s.push(e[t].y)}class Fa extends Kt{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const r=e/2,a=t/2,o=Math.floor(n),l=Math.floor(i),c=o+1,u=l+1,h=e/o,d=t/l,f=[],g=[],_=[],m=[];for(let p=0;p<u;p++){const S=p*d-a;for(let v=0;v<c;v++){const y=v*h-r;g.push(y,-S,0),_.push(0,0,1),m.push(v/o),m.push(1-p/l)}}for(let p=0;p<l;p++)for(let S=0;S<o;S++){const v=S+c*p,y=S+c*(p+1),N=S+1+c*(p+1),P=S+1+c*p;f.push(v,y,P),f.push(y,N,P)}this.setIndex(f),this.setAttribute("position",new vt(g,3)),this.setAttribute("normal",new vt(_,3)),this.setAttribute("uv",new vt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Fa(e.width,e.height,e.widthSegments,e.heightSegments)}}class Er extends Nn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Ge(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ge(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ua,this.normalScale=new ct(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 sn,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 li extends Er{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new ct(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return yt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ge(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Ge(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ge(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class as extends Nn{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Ge(16777215),this.specular=new Ge(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ge(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ua,this.normalScale=new ct(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new sn,this.combine=Ia,this.reflectivity=1,this.refractionRatio=.98,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.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,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.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.flatShading=e.flatShading,this.fog=e.fog,this}}class yh extends Nn{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ge(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ge(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ua,this.normalScale=new ct(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new sn,this.combine=Ia,this.reflectivity=1,this.refractionRatio=.98,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.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.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.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.flatShading=e.flatShading,this.fog=e.fog,this}}class zp extends Nn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=ff,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 Vp extends Nn{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}}function la(s,e){return!s||s.constructor===e?s:typeof e.BYTES_PER_ELEMENT=="number"?new e(s):Array.prototype.slice.call(s)}function Hp(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Gp(s){function e(i,r){return s[i]-s[r]}const t=s.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function Yc(s,e,t){const n=s.length,i=new s.constructor(n);for(let r=0,a=0;a!==n;++r){const o=t[r]*e;for(let l=0;l!==e;++l)i[a++]=s[o+l]}return i}function vh(s,e,t,n){let i=1,r=s[0];for(;r!==void 0&&r[n]===void 0;)r=s[i++];if(r===void 0)return;let a=r[n];if(a!==void 0)if(Array.isArray(a))do a=r[n],a!==void 0&&(e.push(r.time),t.push(...a)),r=s[i++];while(r!==void 0);else if(a.toArray!==void 0)do a=r[n],a!==void 0&&(e.push(r.time),a.toArray(t,t.length)),r=s[i++];while(r!==void 0);else do a=r[n],a!==void 0&&(e.push(r.time),t.push(a)),r=s[i++];while(r!==void 0)}class Ir{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let a;n:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=i,i=t[++n],e<i)break t}a=t.length;break n}if(!(e>=r)){const o=t[1];e<o&&(n=2,r=o);for(let l=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=r,r=t[--n-1],e>=r)break t}a=n,n=0;break n}break e}for(;n<a;){const o=n+a>>>1;e<t[o]?a=o:n=o+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let a=0;a!==i;++a)t[a]=n[r+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class Wp extends Ir{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:cc,endingEnd:cc}}intervalChanged_(e,t,n){const i=this.parameterPositions;let r=e-2,a=e+1,o=i[r],l=i[a];if(o===void 0)switch(this.getSettings_().endingStart){case uc:r=e,o=2*t-n;break;case hc:r=i.length-2,o=t+i[r]-i[r+1];break;default:r=e,o=n}if(l===void 0)switch(this.getSettings_().endingEnd){case uc:a=e,l=2*n-t;break;case hc:a=1,l=n+i[1]-i[0];break;default:a=e-1,l=t}const c=(n-t)*.5,u=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-n),this._offsetPrev=r*u,this._offsetNext=a*u}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,u=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,f=this._weightNext,g=(n-t)/(i-t),_=g*g,m=_*g,p=-d*m+2*d*_-d*g,S=(1+d)*m+(-1.5-2*d)*_+(-.5+d)*g+1,v=(-1-f)*m+(1.5+f)*_+.5*g,y=f*m-f*_;for(let N=0;N!==o;++N)r[N]=p*a[u+N]+S*a[c+N]+v*a[l+N]+y*a[h+N];return r}}class Xp extends Ir{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,u=(n-t)/(i-t),h=1-u;for(let d=0;d!==o;++d)r[d]=a[c+d]*h+a[l+d]*u;return r}}class jp extends Ir{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class ni{constructor(e,t,n,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=la(t,this.TimeBufferType),this.values=la(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:la(e.times,Array),values:la(e.values,Array)};const i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new jp(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Xp(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Wp(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case yr:t=this.InterpolantFactoryMethodDiscrete;break;case vr:t=this.InterpolantFactoryMethodLinear;break;case Ga:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return yr;case this.InterpolantFactoryMethodLinear:return vr;case this.InterpolantFactoryMethodSmooth:return Ga}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){const n=this.times,i=n.length;let r=0,a=i-1;for(;r!==i&&n[r]<e;)++r;for(;a!==-1&&n[a]>t;)--a;if(++a,r!==0||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);const o=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,r=n.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==r;o++){const l=n[o];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(i!==void 0&&Hp(i))for(let o=0,l=i.length;o!==l;++o){const c=i[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===Ga,r=e.length-1;let a=1;for(let o=1;o<r;++o){let l=!1;const c=e[o],u=e[o+1];if(c!==u&&(o!==1||c!==e[0]))if(i)l=!0;else{const h=o*n,d=h-n,f=h+n;for(let g=0;g!==n;++g){const _=t[h+g];if(_!==t[d+g]||_!==t[f+g]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];const h=o*n,d=a*n;for(let f=0;f!==n;++f)t[d+f]=t[h+f]}++a}}if(r>0){e[a]=e[r];for(let o=r*n,l=a*n,c=0;c!==n;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}ni.prototype.ValueTypeName="";ni.prototype.TimeBufferType=Float32Array;ni.prototype.ValueBufferType=Float32Array;ni.prototype.DefaultInterpolation=vr;class Ys extends ni{constructor(e,t,n){super(e,t,n)}}Ys.prototype.ValueTypeName="bool";Ys.prototype.ValueBufferType=Array;Ys.prototype.DefaultInterpolation=yr;Ys.prototype.InterpolantFactoryMethodLinear=void 0;Ys.prototype.InterpolantFactoryMethodSmooth=void 0;class xh extends ni{constructor(e,t,n,i){super(e,t,n,i)}}xh.prototype.ValueTypeName="color";class hs extends ni{constructor(e,t,n,i){super(e,t,n,i)}}hs.prototype.ValueTypeName="number";class qp extends Ir{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(n-t)/(i-t);let c=e*o;for(let u=c+o;c!==u;c+=4)nn.slerpFlat(r,0,a,c-o,a,c,l);return r}}class wi extends ni{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new qp(this.times,this.values,this.getValueSize(),e)}}wi.prototype.ValueTypeName="quaternion";wi.prototype.InterpolantFactoryMethodSmooth=void 0;class Zs extends ni{constructor(e,t,n){super(e,t,n)}}Zs.prototype.ValueTypeName="string";Zs.prototype.ValueBufferType=Array;Zs.prototype.DefaultInterpolation=yr;Zs.prototype.InterpolantFactoryMethodLinear=void 0;Zs.prototype.InterpolantFactoryMethodSmooth=void 0;class Ri extends ni{constructor(e,t,n,i){super(e,t,n,i)}}Ri.prototype.ValueTypeName="vector";class Pa{constructor(e="",t=-1,n=[],i=hf){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=ti(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let a=0,o=n.length;a!==o;++a)t.push(Yp(n[a]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let r=0,a=n.length;r!==a;++r)t.push(ni.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const r=t.length,a=[];for(let o=0;o<r;o++){let l=[],c=[];l.push((o+r-1)%r,o,(o+1)%r),c.push(0,1,0);const u=Gp(l);l=Yc(l,1,u),c=Yc(c,1,u),!i&&l[0]===0&&(l.push(r),c.push(c[0])),a.push(new hs(".morphTargetInfluences["+t[o].name+"]",l,c).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const c=e[o],u=c.name.match(r);if(u&&u.length>1){const h=u[1];let d=i[h];d||(i[h]=d=[]),d.push(c)}}const a=[];for(const o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return a}static parseAnimation(e,t){if(console.warn("THREE.AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(h,d,f,g,_){if(f.length!==0){const m=[],p=[];vh(f,m,p,g),m.length!==0&&_.push(new h(d,m,p))}},i=[],r=e.name||"default",a=e.fps||30,o=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let h=0;h<c.length;h++){const d=c[h].keys;if(!(!d||d.length===0))if(d[0].morphTargets){const f={};let g;for(g=0;g<d.length;g++)if(d[g].morphTargets)for(let _=0;_<d[g].morphTargets.length;_++)f[d[g].morphTargets[_]]=-1;for(const _ in f){const m=[],p=[];for(let S=0;S!==d[g].morphTargets.length;++S){const v=d[g];m.push(v.time),p.push(v.morphTarget===_?1:0)}i.push(new hs(".morphTargetInfluence["+_+"]",m,p))}l=f.length*a}else{const f=".bones["+t[h].name+"]";n(Ri,f+".position",d,"pos",i),n(wi,f+".quaternion",d,"rot",i),n(Ri,f+".scale",d,"scl",i)}}return i.length===0?null:new this(r,l,i,o)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,i=e.length;n!==i;++n){const r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function Kp(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return hs;case"vector":case"vector2":case"vector3":case"vector4":return Ri;case"color":return xh;case"quaternion":return wi;case"bool":case"boolean":return Ys;case"string":return Zs}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function Yp(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=Kp(s.type);if(s.times===void 0){const t=[],n=[];vh(s.keys,t,n,"value"),s.times=t,s.values=n}return e.parse!==void 0?e.parse(s):new e(s.name,s.times,s.values,s.interpolation)}const Vi={enabled:!1,files:{},add:function(s,e){this.enabled!==!1&&(this.files[s]=e)},get:function(s){if(this.enabled!==!1)return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}};class Zp{constructor(e,t,n){const i=this;let r=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(u){o++,r===!1&&i.onStart!==void 0&&i.onStart(u,a,o),r=!0},this.itemEnd=function(u){a++,i.onProgress!==void 0&&i.onProgress(u,a,o),a===o&&(r=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(u){i.onError!==void 0&&i.onError(u)},this.resolveURL=function(u){return l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,h){return c.push(u,h),this},this.removeHandler=function(u){const h=c.indexOf(u);return h!==-1&&c.splice(h,2),this},this.getHandler=function(u){for(let h=0,d=c.length;h<d;h+=2){const f=c[h],g=c[h+1];if(f.global&&(f.lastIndex=0),f.test(u))return g}return null}}}const $p=new Zp;class wn{constructor(e){this.manager=e!==void 0?e:$p,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}wn.DEFAULT_MATERIAL_NAME="__DEFAULT";const vi={};class Jp extends Error{constructor(e,t){super(e),this.response=t}}class Xi extends wn{constructor(e){super(e),this.mimeType="",this.responseType=""}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=Vi.get(e);if(r!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0),r;if(vi[e]!==void 0){vi[e].push({onLoad:t,onProgress:n,onError:i});return}vi[e]=[],vi[e].push({onLoad:t,onProgress:n,onError:i});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const u=vi[e],h=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),f=d?parseInt(d):0,g=f!==0;let _=0;const m=new ReadableStream({start(p){S();function S(){h.read().then(({done:v,value:y})=>{if(v)p.close();else{_+=y.byteLength;const N=new ProgressEvent("progress",{lengthComputable:g,loaded:_,total:f});for(let P=0,L=u.length;P<L;P++){const U=u[P];U.onProgress&&U.onProgress(N)}p.enqueue(y),S()}},v=>{p.error(v)})}}});return new Response(m)}else throw new Jp(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,o));case"json":return c.json();default:if(o==="")return c.text();{const h=/charset="?([^;"\s]*)"?/i.exec(o),d=h&&h[1]?h[1].toLowerCase():void 0,f=new TextDecoder(d);return c.arrayBuffer().then(g=>f.decode(g))}}}).then(c=>{Vi.add(e,c);const u=vi[e];delete vi[e];for(let h=0,d=u.length;h<d;h++){const f=u[h];f.onLoad&&f.onLoad(c)}}).catch(c=>{const u=vi[e];if(u===void 0)throw this.manager.itemError(e),c;delete vi[e];for(let h=0,d=u.length;h<d;h++){const f=u[h];f.onError&&f.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class Qp extends wn{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=Vi.get(e);if(a!==void 0)return r.manager.itemStart(e),setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0),a;const o=xr("img");function l(){u(),Vi.add(e,this),t&&t(this),r.manager.itemEnd(e)}function c(h){u(),i&&i(h),r.manager.itemError(e),r.manager.itemEnd(e)}function u(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),r.manager.itemStart(e),o.src=e,o}}class em extends wn{constructor(e){super(e)}load(e,t,n,i){const r=this,a=new Hl,o=new Xi(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(r.withCredentials),o.load(e,function(l){let c;try{c=r.parse(l)}catch(u){if(i!==void 0)i(u);else{console.error(u);return}}c.image!==void 0?a.image=c.image:c.data!==void 0&&(a.image.width=c.width,a.image.height=c.height,a.image.data=c.data),a.wrapS=c.wrapS!==void 0?c.wrapS:Dn,a.wrapT=c.wrapT!==void 0?c.wrapT:Dn,a.magFilter=c.magFilter!==void 0?c.magFilter:yn,a.minFilter=c.minFilter!==void 0?c.minFilter:yn,a.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0&&(a.colorSpace=c.colorSpace),c.flipY!==void 0&&(a.flipY=c.flipY),c.format!==void 0&&(a.format=c.format),c.type!==void 0&&(a.type=c.type),c.mipmaps!==void 0&&(a.mipmaps=c.mipmaps,a.minFilter=Qn),c.mipmapCount===1&&(a.minFilter=yn),c.generateMipmaps!==void 0&&(a.generateMipmaps=c.generateMipmaps),a.needsUpdate=!0,t&&t(a,c)},n,i),a}}class Xl extends wn{constructor(e){super(e)}load(e,t,n,i){const r=new an,a=new Qp(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){r.image=o,r.needsUpdate=!0,t!==void 0&&t(r)},n,i),r}}class Oa extends kt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ge(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}const go=new Fe,Zc=new O,$c=new O;class jl{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ct(512,512),this.mapType=ai,this.map=null,this.mapPass=null,this.matrix=new Fe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Gl,this._frameExtents=new ct(1,1),this._viewportCount=1,this._viewports=[new Tt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;Zc.setFromMatrixPosition(e.matrixWorld),t.position.copy(Zc),$c.setFromMatrixPosition(e.target.matrixWorld),t.lookAt($c),t.updateMatrixWorld(),go.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(go),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(go)}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 tm extends jl{constructor(){super(new un(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,n=Ws*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;(n!==t.fov||i!==t.aspect||r!==t.far)&&(t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class ql extends Oa{constructor(e,t,n=0,i=Math.PI/3,r=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(kt.DEFAULT_UP),this.updateMatrix(),this.target=new kt,this.distance=n,this.angle=i,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new tm}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const Jc=new Fe,rr=new O,_o=new O;class nm extends jl{constructor(){super(new un(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new ct(4,2),this._viewportCount=6,this._viewports=[new Tt(2,1,1,1),new Tt(0,1,1,1),new Tt(3,1,1,1),new Tt(1,1,1,1),new Tt(3,0,1,1),new Tt(1,0,1,1)],this._cubeDirections=[new O(1,0,0),new O(-1,0,0),new O(0,0,1),new O(0,0,-1),new O(0,1,0),new O(0,-1,0)],this._cubeUps=[new O(0,1,0),new O(0,1,0),new O(0,1,0),new O(0,1,0),new O(0,0,1),new O(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,r=e.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),rr.setFromMatrixPosition(e.matrixWorld),n.position.copy(rr),_o.copy(n.position),_o.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(_o),n.updateMatrixWorld(),i.makeTranslation(-rr.x,-rr.y,-rr.z),Jc.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Jc)}}class La extends Oa{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new nm}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class ka extends uh{constructor(e=-1,t=1,n=1,i=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-e,a=n+e,o=i+t,l=i-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;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,this.near,this.far,this.coordinateSystem),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 im extends jl{constructor(){super(new ka(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Ar extends Oa{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(kt.DEFAULT_UP),this.updateMatrix(),this.target=new kt,this.shadow=new im}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class Kl extends Oa{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class os{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}const yo=new WeakMap;class sm extends wn{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=Vi.get(e);if(a!==void 0){if(r.manager.itemStart(e),a.then){a.then(c=>{if(yo.has(a)===!0)i&&i(yo.get(a)),r.manager.itemError(e),r.manager.itemEnd(e);else return t&&t(c),r.manager.itemEnd(e),c});return}return setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader;const l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(c){return Vi.add(e,c),t&&t(c),r.manager.itemEnd(e),c}).catch(function(c){i&&i(c),yo.set(l,c),Vi.remove(e),r.manager.itemError(e),r.manager.itemEnd(e)});Vi.add(e,l),r.manager.itemStart(e)}}class rm extends un{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const Yl="\\[\\]\\.:\\/",am=new RegExp("["+Yl+"]","g"),Zl="[^"+Yl+"]",om="[^"+Yl.replace("\\.","")+"]",lm=/((?:WC+[\/:])*)/.source.replace("WC",Zl),cm=/(WCOD+)?/.source.replace("WCOD",om),um=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Zl),hm=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Zl),dm=new RegExp("^"+lm+cm+um+hm+"$"),fm=["material","materials","bones","map"];class pm{constructor(e,t,n){const i=n||wt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class wt{constructor(e,t,n){this.path=t,this.parsedPath=n||wt.parseTrackName(t),this.node=wt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new wt.Composite(e,t,n):new wt(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(am,"")}static parseTrackName(e){const t=dm.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const r=n.nodeName.substring(i+1);fm.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(r){for(let a=0;a<r.length;a++){const o=r[a];if(o.name===t||o.uuid===t)return o;const l=n(o.children);if(l)return l}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,i=t.propertyName;let r=t.propertyIndex;if(e||(e=wt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===c){c=u;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const a=e[i];if(a===void 0){const c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}wt.Composite=pm;wt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};wt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};wt.prototype.GetterByBindingType=[wt.prototype._getValue_direct,wt.prototype._getValue_array,wt.prototype._getValue_arrayElement,wt.prototype._getValue_toArray];wt.prototype.SetterByBindingTypeAndVersioning=[[wt.prototype._setValue_direct,wt.prototype._setValue_direct_setNeedsUpdate,wt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[wt.prototype._setValue_array,wt.prototype._setValue_array_setNeedsUpdate,wt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[wt.prototype._setValue_arrayElement,wt.prototype._setValue_arrayElement_setNeedsUpdate,wt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[wt.prototype._setValue_fromArray,wt.prototype._setValue_fromArray_setNeedsUpdate,wt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Qc{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=yt(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(yt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class mm extends js{constructor(e=10,t=10,n=4473924,i=8947848){n=new Ge(n),i=new Ge(i);const r=t/2,a=e/t,o=e/2,l=[],c=[];for(let d=0,f=0,g=-o;d<=t;d++,g+=a){l.push(-o,0,g,o,0,g),l.push(g,0,-o,g,0,o);const _=d===r?n:i;_.toArray(c,f),f+=3,_.toArray(c,f),f+=3,_.toArray(c,f),f+=3,_.toArray(c,f),f+=3}const u=new Kt;u.setAttribute("position",new vt(l,3)),u.setAttribute("color",new vt(c,3));const h=new si({vertexColors:!0,toneMapped:!1});super(u,h),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class gm extends js{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Kt;i.setAttribute("position",new vt(t,3)),i.setAttribute("color",new vt(n,3));const r=new si({vertexColors:!0,toneMapped:!1});super(i,r),this.type="AxesHelper"}setColors(e,t,n){const i=new Ge,r=this.geometry.attributes.color.array;return i.set(e),i.toArray(r,0),i.toArray(r,3),i.set(t),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class _m extends ds{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 eu(s,e,t,n){const i=ym(n);switch(t){case Ju:return s*e;case Il:return s*e/i.components*i.byteLength;case Nl:return s*e/i.components*i.byteLength;case eh:return s*e*2/i.components*i.byteLength;case Ul:return s*e*2/i.components*i.byteLength;case Qu:return s*e*3/i.components*i.byteLength;case Gn:return s*e*4/i.components*i.byteLength;case Fl:return s*e*4/i.components*i.byteLength;case ga:case _a:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case ya:case va:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Xo:case qo:return Math.max(s,16)*Math.max(e,8)/4;case Wo:case jo:return Math.max(s,8)*Math.max(e,8)/2;case Ko:case Yo:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case Zo:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case $o:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Jo:return Math.floor((s+4)/5)*Math.floor((e+3)/4)*16;case Qo:return Math.floor((s+4)/5)*Math.floor((e+4)/5)*16;case el:return Math.floor((s+5)/6)*Math.floor((e+4)/5)*16;case tl:return Math.floor((s+5)/6)*Math.floor((e+5)/6)*16;case nl:return Math.floor((s+7)/8)*Math.floor((e+4)/5)*16;case il:return Math.floor((s+7)/8)*Math.floor((e+5)/6)*16;case sl:return Math.floor((s+7)/8)*Math.floor((e+7)/8)*16;case rl:return Math.floor((s+9)/10)*Math.floor((e+4)/5)*16;case al:return Math.floor((s+9)/10)*Math.floor((e+5)/6)*16;case ol:return Math.floor((s+9)/10)*Math.floor((e+7)/8)*16;case ll:return Math.floor((s+9)/10)*Math.floor((e+9)/10)*16;case cl:return Math.floor((s+11)/12)*Math.floor((e+9)/10)*16;case ul:return Math.floor((s+11)/12)*Math.floor((e+11)/12)*16;case xa:case hl:case dl:return Math.ceil(s/4)*Math.ceil(e/4)*16;case th:case fl:return Math.ceil(s/4)*Math.ceil(e/4)*8;case pl:case ml:return Math.ceil(s/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function ym(s){switch(s){case ai:case Yu:return{byteLength:1,components:1};case pr:case Zu:case Rr:return{byteLength:2,components:1};case Ll:case Dl:return{byteLength:2,components:4};case ls:case Pl:case ei:return{byteLength:4,components:1};case $u:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${s}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Cl}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Cl);/**
45
45
  * @license
46
46
  * Copyright 2010-2025 Three.js Authors
47
47
  * SPDX-License-Identifier: MIT
48
- */function Mh(){let s=null,e=!1,t=null,n=null;function i(r,a){t(r,a),n=s.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=s.requestAnimationFrame(i),e=!0)},stop:function(){s.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){s=r}}}function xm(s){const e=new WeakMap;function t(o,l){const c=o.array,u=o.usage,h=c.byteLength,d=s.createBuffer();s.bindBuffer(l,d),s.bufferData(l,c,u),o.onUploadCallback();let f;if(c instanceof Float32Array)f=s.FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?f=s.HALF_FLOAT:f=s.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=s.SHORT;else if(c instanceof Uint32Array)f=s.UNSIGNED_INT;else if(c instanceof Int32Array)f=s.INT;else if(c instanceof Int8Array)f=s.BYTE;else if(c instanceof Uint8Array)f=s.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:h}}function n(o,l,c){const u=l.array,h=l.updateRanges;if(s.bindBuffer(c,o),h.length===0)s.bufferSubData(c,0,u);else{h.sort((f,g)=>f.start-g.start);let d=0;for(let f=1;f<h.length;f++){const g=h[d],_=h[f];_.start<=g.start+g.count+1?g.count=Math.max(g.count,_.start+_.count-g.start):(++d,h[d]=_)}h.length=d+1;for(let f=0,g=h.length;f<g;f++){const _=h[f];s.bufferSubData(c,_.start*u.BYTES_PER_ELEMENT,u,_.start,_.count)}l.clearUpdateRanges()}l.onUploadCallback()}function i(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(s.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const u=e.get(o);(!u||u.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=e.get(o);if(c===void 0)e.set(o,t(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(c.buffer,o,l),c.version=o.version}}return{get:i,remove:r,update:a}}var vm=`#ifdef USE_ALPHAHASH
48
+ */function Mh(){let s=null,e=!1,t=null,n=null;function i(r,a){t(r,a),n=s.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=s.requestAnimationFrame(i),e=!0)},stop:function(){s.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){s=r}}}function vm(s){const e=new WeakMap;function t(o,l){const c=o.array,u=o.usage,h=c.byteLength,d=s.createBuffer();s.bindBuffer(l,d),s.bufferData(l,c,u),o.onUploadCallback();let f;if(c instanceof Float32Array)f=s.FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?f=s.HALF_FLOAT:f=s.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=s.SHORT;else if(c instanceof Uint32Array)f=s.UNSIGNED_INT;else if(c instanceof Int32Array)f=s.INT;else if(c instanceof Int8Array)f=s.BYTE;else if(c instanceof Uint8Array)f=s.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:h}}function n(o,l,c){const u=l.array,h=l.updateRanges;if(s.bindBuffer(c,o),h.length===0)s.bufferSubData(c,0,u);else{h.sort((f,g)=>f.start-g.start);let d=0;for(let f=1;f<h.length;f++){const g=h[d],_=h[f];_.start<=g.start+g.count+1?g.count=Math.max(g.count,_.start+_.count-g.start):(++d,h[d]=_)}h.length=d+1;for(let f=0,g=h.length;f<g;f++){const _=h[f];s.bufferSubData(c,_.start*u.BYTES_PER_ELEMENT,u,_.start,_.count)}l.clearUpdateRanges()}l.onUploadCallback()}function i(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(s.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const u=e.get(o);(!u||u.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=e.get(o);if(c===void 0)e.set(o,t(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(c.buffer,o,l),c.version=o.version}}return{get:i,remove:r,update:a}}var xm=`#ifdef USE_ALPHAHASH
49
49
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
50
50
  #endif`,Mm=`#ifdef USE_ALPHAHASH
51
51
  const float ALPHA_HASH_SCALE = 0.05;
@@ -1247,7 +1247,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
1247
1247
  #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1248
1248
  float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1249
1249
  return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1250
- }`,xg=`
1250
+ }`,vg=`
1251
1251
  vec3 geometryPosition = - vViewPosition;
1252
1252
  vec3 geometryNormal = normal;
1253
1253
  vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
@@ -1362,7 +1362,7 @@ IncidentLight directLight;
1362
1362
  #if defined( RE_IndirectSpecular )
1363
1363
  vec3 radiance = vec3( 0.0 );
1364
1364
  vec3 clearcoatRadiance = vec3( 0.0 );
1365
- #endif`,vg=`#if defined( RE_IndirectDiffuse )
1365
+ #endif`,xg=`#if defined( RE_IndirectDiffuse )
1366
1366
  #ifdef USE_LIGHTMAP
1367
1367
  vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1368
1368
  vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
@@ -2519,12 +2519,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,f_=`#ifdef USE_TRANSMISS
2519
2519
  worldPosition = instanceMatrix * worldPosition;
2520
2520
  #endif
2521
2521
  worldPosition = modelMatrix * worldPosition;
2522
- #endif`;const x_=`varying vec2 vUv;
2522
+ #endif`;const v_=`varying vec2 vUv;
2523
2523
  uniform mat3 uvTransform;
2524
2524
  void main() {
2525
2525
  vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2526
2526
  gl_Position = vec4( position.xy, 1.0, 1.0 );
2527
- }`,v_=`uniform sampler2D t2D;
2527
+ }`,x_=`uniform sampler2D t2D;
2528
2528
  uniform float backgroundIntensity;
2529
2529
  varying vec2 vUv;
2530
2530
  void main() {
@@ -3571,7 +3571,7 @@ void main() {
3571
3571
  #include <tonemapping_fragment>
3572
3572
  #include <colorspace_fragment>
3573
3573
  #include <fog_fragment>
3574
- }`,vt={alphahash_fragment:vm,alphahash_pars_fragment:Mm,alphamap_fragment:Sm,alphamap_pars_fragment:Tm,alphatest_fragment:bm,alphatest_pars_fragment:Em,aomap_fragment:Am,aomap_pars_fragment:wm,batching_pars_vertex:Rm,batching_vertex:Cm,begin_vertex:Pm,beginnormal_vertex:Lm,bsdfs:Dm,iridescence_fragment:Im,bumpmap_pars_fragment:Nm,clipping_planes_fragment:Um,clipping_planes_pars_fragment:Fm,clipping_planes_pars_vertex:Om,clipping_planes_vertex:km,color_fragment:Bm,color_pars_fragment:zm,color_pars_vertex:Vm,color_vertex:Hm,common:Gm,cube_uv_reflection_fragment:Wm,defaultnormal_vertex:Xm,displacementmap_pars_vertex:jm,displacementmap_vertex:qm,emissivemap_fragment:Km,emissivemap_pars_fragment:Ym,colorspace_fragment:Zm,colorspace_pars_fragment:$m,envmap_fragment:Jm,envmap_common_pars_fragment:Qm,envmap_pars_fragment:eg,envmap_pars_vertex:tg,envmap_physical_pars_fragment:dg,envmap_vertex:ng,fog_vertex:ig,fog_pars_vertex:sg,fog_fragment:rg,fog_pars_fragment:ag,gradientmap_pars_fragment:og,lightmap_pars_fragment:lg,lights_lambert_fragment:cg,lights_lambert_pars_fragment:ug,lights_pars_begin:hg,lights_toon_fragment:fg,lights_toon_pars_fragment:pg,lights_phong_fragment:mg,lights_phong_pars_fragment:gg,lights_physical_fragment:_g,lights_physical_pars_fragment:yg,lights_fragment_begin:xg,lights_fragment_maps:vg,lights_fragment_end:Mg,logdepthbuf_fragment:Sg,logdepthbuf_pars_fragment:Tg,logdepthbuf_pars_vertex:bg,logdepthbuf_vertex:Eg,map_fragment:Ag,map_pars_fragment:wg,map_particle_fragment:Rg,map_particle_pars_fragment:Cg,metalnessmap_fragment:Pg,metalnessmap_pars_fragment:Lg,morphinstance_vertex:Dg,morphcolor_vertex:Ig,morphnormal_vertex:Ng,morphtarget_pars_vertex:Ug,morphtarget_vertex:Fg,normal_fragment_begin:Og,normal_fragment_maps:kg,normal_pars_fragment:Bg,normal_pars_vertex:zg,normal_vertex:Vg,normalmap_pars_fragment:Hg,clearcoat_normal_fragment_begin:Gg,clearcoat_normal_fragment_maps:Wg,clearcoat_pars_fragment:Xg,iridescence_pars_fragment:jg,opaque_fragment:qg,packing:Kg,premultiplied_alpha_fragment:Yg,project_vertex:Zg,dithering_fragment:$g,dithering_pars_fragment:Jg,roughnessmap_fragment:Qg,roughnessmap_pars_fragment:e_,shadowmap_pars_fragment:t_,shadowmap_pars_vertex:n_,shadowmap_vertex:i_,shadowmask_pars_fragment:s_,skinbase_vertex:r_,skinning_pars_vertex:a_,skinning_vertex:o_,skinnormal_vertex:l_,specularmap_fragment:c_,specularmap_pars_fragment:u_,tonemapping_fragment:h_,tonemapping_pars_fragment:d_,transmission_fragment:f_,transmission_pars_fragment:p_,uv_pars_fragment:m_,uv_pars_vertex:g_,uv_vertex:__,worldpos_vertex:y_,background_vert:x_,background_frag:v_,backgroundCube_vert:M_,backgroundCube_frag:S_,cube_vert:T_,cube_frag:b_,depth_vert:E_,depth_frag:A_,distanceRGBA_vert:w_,distanceRGBA_frag:R_,equirect_vert:C_,equirect_frag:P_,linedashed_vert:L_,linedashed_frag:D_,meshbasic_vert:I_,meshbasic_frag:N_,meshlambert_vert:U_,meshlambert_frag:F_,meshmatcap_vert:O_,meshmatcap_frag:k_,meshnormal_vert:B_,meshnormal_frag:z_,meshphong_vert:V_,meshphong_frag:H_,meshphysical_vert:G_,meshphysical_frag:W_,meshtoon_vert:X_,meshtoon_frag:j_,points_vert:q_,points_frag:K_,shadow_vert:Y_,shadow_frag:Z_,sprite_vert:$_,sprite_frag:J_},Ie={common:{diffuse:{value:new He(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new gt},alphaMap:{value:null},alphaMapTransform:{value:new gt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new gt}},envmap:{envMap:{value:null},envMapRotation:{value:new gt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new gt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new gt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new gt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new gt},normalScale:{value:new ot(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new gt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new gt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new gt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new gt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new He(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 He(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new gt},alphaTest:{value:0},uvTransform:{value:new gt}},sprite:{diffuse:{value:new He(16777215)},opacity:{value:1},center:{value:new ot(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new gt},alphaMap:{value:null},alphaMapTransform:{value:new gt},alphaTest:{value:0}}},ni={basic:{uniforms:vn([Ie.common,Ie.specularmap,Ie.envmap,Ie.aomap,Ie.lightmap,Ie.fog]),vertexShader:vt.meshbasic_vert,fragmentShader:vt.meshbasic_frag},lambert:{uniforms:vn([Ie.common,Ie.specularmap,Ie.envmap,Ie.aomap,Ie.lightmap,Ie.emissivemap,Ie.bumpmap,Ie.normalmap,Ie.displacementmap,Ie.fog,Ie.lights,{emissive:{value:new He(0)}}]),vertexShader:vt.meshlambert_vert,fragmentShader:vt.meshlambert_frag},phong:{uniforms:vn([Ie.common,Ie.specularmap,Ie.envmap,Ie.aomap,Ie.lightmap,Ie.emissivemap,Ie.bumpmap,Ie.normalmap,Ie.displacementmap,Ie.fog,Ie.lights,{emissive:{value:new He(0)},specular:{value:new He(1118481)},shininess:{value:30}}]),vertexShader:vt.meshphong_vert,fragmentShader:vt.meshphong_frag},standard:{uniforms:vn([Ie.common,Ie.envmap,Ie.aomap,Ie.lightmap,Ie.emissivemap,Ie.bumpmap,Ie.normalmap,Ie.displacementmap,Ie.roughnessmap,Ie.metalnessmap,Ie.fog,Ie.lights,{emissive:{value:new He(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:vt.meshphysical_vert,fragmentShader:vt.meshphysical_frag},toon:{uniforms:vn([Ie.common,Ie.aomap,Ie.lightmap,Ie.emissivemap,Ie.bumpmap,Ie.normalmap,Ie.displacementmap,Ie.gradientmap,Ie.fog,Ie.lights,{emissive:{value:new He(0)}}]),vertexShader:vt.meshtoon_vert,fragmentShader:vt.meshtoon_frag},matcap:{uniforms:vn([Ie.common,Ie.bumpmap,Ie.normalmap,Ie.displacementmap,Ie.fog,{matcap:{value:null}}]),vertexShader:vt.meshmatcap_vert,fragmentShader:vt.meshmatcap_frag},points:{uniforms:vn([Ie.points,Ie.fog]),vertexShader:vt.points_vert,fragmentShader:vt.points_frag},dashed:{uniforms:vn([Ie.common,Ie.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:vt.linedashed_vert,fragmentShader:vt.linedashed_frag},depth:{uniforms:vn([Ie.common,Ie.displacementmap]),vertexShader:vt.depth_vert,fragmentShader:vt.depth_frag},normal:{uniforms:vn([Ie.common,Ie.bumpmap,Ie.normalmap,Ie.displacementmap,{opacity:{value:1}}]),vertexShader:vt.meshnormal_vert,fragmentShader:vt.meshnormal_frag},sprite:{uniforms:vn([Ie.sprite,Ie.fog]),vertexShader:vt.sprite_vert,fragmentShader:vt.sprite_frag},background:{uniforms:{uvTransform:{value:new gt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:vt.background_vert,fragmentShader:vt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new gt}},vertexShader:vt.backgroundCube_vert,fragmentShader:vt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:vt.cube_vert,fragmentShader:vt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:vt.equirect_vert,fragmentShader:vt.equirect_frag},distanceRGBA:{uniforms:vn([Ie.common,Ie.displacementmap,{referencePosition:{value:new O},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:vt.distanceRGBA_vert,fragmentShader:vt.distanceRGBA_frag},shadow:{uniforms:vn([Ie.lights,Ie.fog,{color:{value:new He(0)},opacity:{value:1}}]),vertexShader:vt.shadow_vert,fragmentShader:vt.shadow_frag}};ni.physical={uniforms:vn([ni.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new gt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new gt},clearcoatNormalScale:{value:new ot(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new gt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new gt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new gt},sheen:{value:0},sheenColor:{value:new He(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new gt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new gt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new gt},transmissionSamplerSize:{value:new ot},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new gt},attenuationDistance:{value:0},attenuationColor:{value:new He(0)},specularColor:{value:new He(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new gt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new gt},anisotropyVector:{value:new ot},anisotropyMap:{value:null},anisotropyMapTransform:{value:new gt}}]),vertexShader:vt.meshphysical_vert,fragmentShader:vt.meshphysical_frag};const la={r:0,b:0,g:0},es=new nn,Q_=new Fe;function e0(s,e,t,n,i,r,a){const o=new He(0);let l=r===!0?0:1,c,u,h=null,d=0,f=null;function g(x){let y=x.isScene===!0?x.background:null;return y&&y.isTexture&&(y=(x.backgroundBlurriness>0?t:e).get(y)),y}function _(x){let y=!1;const N=g(x);N===null?p(o,l):N&&N.isColor&&(p(N,1),y=!0);const P=s.xr.getEnvironmentBlendMode();P==="additive"?n.buffers.color.setClear(0,0,0,1,a):P==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(s.autoClear||y)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function m(x,y){const N=g(y);N&&(N.isCubeTexture||N.mapping===Ia)?(u===void 0&&(u=new sn(new Cr(1,1,1),new Wi({name:"BackgroundCubeMaterial",uniforms:Ws(ni.backgroundCube.uniforms),vertexShader:ni.backgroundCube.vertexShader,fragmentShader:ni.backgroundCube.fragmentShader,side:Ln,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(P,L,U){this.matrixWorld.copyPosition(U.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),es.copy(y.backgroundRotation),es.x*=-1,es.y*=-1,es.z*=-1,N.isCubeTexture&&N.isRenderTargetTexture===!1&&(es.y*=-1,es.z*=-1),u.material.uniforms.envMap.value=N,u.material.uniforms.flipEnvMap.value=N.isCubeTexture&&N.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=y.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(Q_.makeRotationFromEuler(es)),u.material.toneMapped=pt.getTransfer(N.colorSpace)!==Ut,(h!==N||d!==N.version||f!==s.toneMapping)&&(u.material.needsUpdate=!0,h=N,d=N.version,f=s.toneMapping),u.layers.enableAll(),x.unshift(u,u.geometry,u.material,0,0,null)):N&&N.isTexture&&(c===void 0&&(c=new sn(new Ua(2,2),new Wi({name:"BackgroundMaterial",uniforms:Ws(ni.background.uniforms),vertexShader:ni.background.vertexShader,fragmentShader:ni.background.fragmentShader,side:si,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=N,c.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,c.material.toneMapped=pt.getTransfer(N.colorSpace)!==Ut,N.matrixAutoUpdate===!0&&N.updateMatrix(),c.material.uniforms.uvTransform.value.copy(N.matrix),(h!==N||d!==N.version||f!==s.toneMapping)&&(c.material.needsUpdate=!0,h=N,d=N.version,f=s.toneMapping),c.layers.enableAll(),x.unshift(c,c.geometry,c.material,0,0,null))}function p(x,y){x.getRGB(la,ch(s)),n.buffers.color.setClear(la.r,la.g,la.b,y,a)}function S(){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 o},setClearColor:function(x,y=1){o.set(x),l=y,p(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(x){l=x,p(o,l)},render:_,addToRenderList:m,dispose:S}}function t0(s,e){const t=s.getParameter(s.MAX_VERTEX_ATTRIBS),n={},i=d(null);let r=i,a=!1;function o(T,D,X,j,se){let de=!1;const k=h(j,X,D);r!==k&&(r=k,c(r.object)),de=f(T,j,X,se),de&&g(T,j,X,se),se!==null&&e.update(se,s.ELEMENT_ARRAY_BUFFER),(de||a)&&(a=!1,y(T,D,X,j),se!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.get(se).buffer))}function l(){return s.createVertexArray()}function c(T){return s.bindVertexArray(T)}function u(T){return s.deleteVertexArray(T)}function h(T,D,X){const j=X.wireframe===!0;let se=n[T.id];se===void 0&&(se={},n[T.id]=se);let de=se[D.id];de===void 0&&(de={},se[D.id]=de);let k=de[j];return k===void 0&&(k=d(l()),de[j]=k),k}function d(T){const D=[],X=[],j=[];for(let se=0;se<t;se++)D[se]=0,X[se]=0,j[se]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:D,enabledAttributes:X,attributeDivisors:j,object:T,attributes:{},index:null}}function f(T,D,X,j){const se=r.attributes,de=D.attributes;let k=0;const ae=X.getAttributes();for(const G in ae)if(ae[G].location>=0){const Me=se[G];let le=de[G];if(le===void 0&&(G==="instanceMatrix"&&T.instanceMatrix&&(le=T.instanceMatrix),G==="instanceColor"&&T.instanceColor&&(le=T.instanceColor)),Me===void 0||Me.attribute!==le||le&&Me.data!==le.data)return!0;k++}return r.attributesNum!==k||r.index!==j}function g(T,D,X,j){const se={},de=D.attributes;let k=0;const ae=X.getAttributes();for(const G in ae)if(ae[G].location>=0){let Me=de[G];Me===void 0&&(G==="instanceMatrix"&&T.instanceMatrix&&(Me=T.instanceMatrix),G==="instanceColor"&&T.instanceColor&&(Me=T.instanceColor));const le={};le.attribute=Me,Me&&Me.data&&(le.data=Me.data),se[G]=le,k++}r.attributes=se,r.attributesNum=k,r.index=j}function _(){const T=r.newAttributes;for(let D=0,X=T.length;D<X;D++)T[D]=0}function m(T){p(T,0)}function p(T,D){const X=r.newAttributes,j=r.enabledAttributes,se=r.attributeDivisors;X[T]=1,j[T]===0&&(s.enableVertexAttribArray(T),j[T]=1),se[T]!==D&&(s.vertexAttribDivisor(T,D),se[T]=D)}function S(){const T=r.newAttributes,D=r.enabledAttributes;for(let X=0,j=D.length;X<j;X++)D[X]!==T[X]&&(s.disableVertexAttribArray(X),D[X]=0)}function x(T,D,X,j,se,de,k){k===!0?s.vertexAttribIPointer(T,D,X,se,de):s.vertexAttribPointer(T,D,X,j,se,de)}function y(T,D,X,j){_();const se=j.attributes,de=X.getAttributes(),k=D.defaultAttributeValues;for(const ae in de){const G=de[ae];if(G.location>=0){let pe=se[ae];if(pe===void 0&&(ae==="instanceMatrix"&&T.instanceMatrix&&(pe=T.instanceMatrix),ae==="instanceColor"&&T.instanceColor&&(pe=T.instanceColor)),pe!==void 0){const Me=pe.normalized,le=pe.itemSize,we=e.get(pe);if(we===void 0)continue;const be=we.buffer,W=we.type,$=we.bytesPerElement,re=W===s.INT||W===s.UNSIGNED_INT||pe.gpuType===Pl;if(pe.isInterleavedBufferAttribute){const oe=pe.data,Te=oe.stride,ne=pe.offset;if(oe.isInstancedInterleavedBuffer){for(let me=0;me<G.locationSize;me++)p(G.location+me,oe.meshPerAttribute);T.isInstancedMesh!==!0&&j._maxInstanceCount===void 0&&(j._maxInstanceCount=oe.meshPerAttribute*oe.count)}else for(let me=0;me<G.locationSize;me++)m(G.location+me);s.bindBuffer(s.ARRAY_BUFFER,be);for(let me=0;me<G.locationSize;me++)x(G.location+me,le/G.locationSize,W,Me,Te*$,(ne+le/G.locationSize*me)*$,re)}else{if(pe.isInstancedBufferAttribute){for(let oe=0;oe<G.locationSize;oe++)p(G.location+oe,pe.meshPerAttribute);T.isInstancedMesh!==!0&&j._maxInstanceCount===void 0&&(j._maxInstanceCount=pe.meshPerAttribute*pe.count)}else for(let oe=0;oe<G.locationSize;oe++)m(G.location+oe);s.bindBuffer(s.ARRAY_BUFFER,be);for(let oe=0;oe<G.locationSize;oe++)x(G.location+oe,le/G.locationSize,W,Me,le*$,le/G.locationSize*oe*$,re)}}else if(k!==void 0){const Me=k[ae];if(Me!==void 0)switch(Me.length){case 2:s.vertexAttrib2fv(G.location,Me);break;case 3:s.vertexAttrib3fv(G.location,Me);break;case 4:s.vertexAttrib4fv(G.location,Me);break;default:s.vertexAttrib1fv(G.location,Me)}}}}S()}function N(){U();for(const T in n){const D=n[T];for(const X in D){const j=D[X];for(const se in j)u(j[se].object),delete j[se];delete D[X]}delete n[T]}}function P(T){if(n[T.id]===void 0)return;const D=n[T.id];for(const X in D){const j=D[X];for(const se in j)u(j[se].object),delete j[se];delete D[X]}delete n[T.id]}function L(T){for(const D in n){const X=n[D];if(X[T.id]===void 0)continue;const j=X[T.id];for(const se in j)u(j[se].object),delete j[se];delete X[T.id]}}function U(){E(),a=!0,r!==i&&(r=i,c(r.object))}function E(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:U,resetDefaultState:E,dispose:N,releaseStatesOfGeometry:P,releaseStatesOfProgram:L,initAttributes:_,enableAttribute:m,disableUnusedAttributes:S}}function n0(s,e,t){let n;function i(c){n=c}function r(c,u){s.drawArrays(n,c,u),t.update(u,n,1)}function a(c,u,h){h!==0&&(s.drawArraysInstanced(n,c,u,h),t.update(u,n,h))}function o(c,u,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,u,0,h);let f=0;for(let g=0;g<h;g++)f+=u[g];t.update(f,n,1)}function l(c,u,h,d){if(h===0)return;const f=e.get("WEBGL_multi_draw");if(f===null)for(let g=0;g<c.length;g++)a(c[g],u[g],d[g]);else{f.multiDrawArraysInstancedWEBGL(n,c,0,u,0,d,0,h);let g=0;for(let _=0;_<h;_++)g+=u[_]*d[_];t.update(g,n,1)}}this.setMode=i,this.render=r,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function i0(s,e,t,n){let i;function r(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const L=e.get("EXT_texture_filter_anisotropic");i=s.getParameter(L.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function a(L){return!(L!==Hn&&n.convert(L)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(L){const U=L===wr&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(L!==ri&&n.convert(L)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE)&&L!==Qn&&!U)}function l(L){if(L==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";L="mediump"}return L==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.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.reverseDepthBuffer===!0&&e.has("EXT_clip_control"),f=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),g=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=s.getParameter(s.MAX_TEXTURE_SIZE),m=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),p=s.getParameter(s.MAX_VERTEX_ATTRIBS),S=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),x=s.getParameter(s.MAX_VARYING_VECTORS),y=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),N=g>0,P=s.getParameter(s.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:h,reverseDepthBuffer:d,maxTextures:f,maxVertexTextures:g,maxTextureSize:_,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:S,maxVaryings:x,maxFragmentUniforms:y,vertexTextures:N,maxSamples:P}}function s0(s){const e=this;let t=null,n=0,i=!1,r=!1;const a=new Bi,o=new gt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d){const f=h.length!==0||d||n!==0||i;return i=d,n=h.length,f},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(h,d){t=u(h,d,0)},this.setState=function(h,d,f){const g=h.clippingPlanes,_=h.clipIntersection,m=h.clipShadows,p=s.get(h);if(!i||g===null||g.length===0||r&&!m)r?u(null):c();else{const S=r?0:n,x=S*4;let y=p.clippingState||null;l.value=y,y=u(g,d,x,f);for(let N=0;N!==x;++N)y[N]=t[N];p.clippingState=y,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=S}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(h,d,f,g){const _=h!==null?h.length:0;let m=null;if(_!==0){if(m=l.value,g!==!0||m===null){const p=f+_*4,S=d.matrixWorldInverse;o.getNormalMatrix(S),(m===null||m.length<p)&&(m=new Float32Array(p));for(let x=0,y=f;x!==_;++x,y+=4)a.copy(h[x]).applyMatrix4(S,o),a.normal.toArray(m,y),m[y+3]=a.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=_,e.numIntersection=0,m}}function r0(s){let e=new WeakMap;function t(a,o){return o===Ta?a.mapping=Vs:o===Go&&(a.mapping=Hs),a}function n(a){if(a&&a.isTexture){const o=a.mapping;if(o===Ta||o===Go)if(e.has(a)){const l=e.get(a).texture;return t(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const c=new hp(l.height);return c.fromEquirectangularTexture(s,a),e.set(a,c),a.addEventListener("dispose",i),t(c.texture,a.mapping)}else return null}}return a}function i(a){const o=a.target;o.removeEventListener("dispose",i);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function r(){e=new WeakMap}return{get:n,dispose:r}}const Is=4,tu=[.125,.215,.35,.446,.526,.582],rs=20,xo=new Oa,nu=new He;let vo=null,Mo=0,So=0,To=!1;const is=(1+Math.sqrt(5))/2,Cs=1/is,iu=[new O(-is,Cs,0),new O(is,Cs,0),new O(-Cs,0,is),new O(Cs,0,is),new O(0,is,-Cs),new O(0,is,Cs),new O(-1,1,-1),new O(1,1,-1),new O(-1,1,1),new O(1,1,1)],a0=new O;class su{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,i=100,r={}){const{size:a=256,position:o=a0}=r;vo=this._renderer.getRenderTarget(),Mo=this._renderer.getActiveCubeFace(),So=this._renderer.getActiveMipmapLevel(),To=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,n,i,l,o),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=ou(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=au(),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(vo,Mo,So),this._renderer.xr.enabled=To,e.scissorTest=!1,ca(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Vs||e.mapping===Hs?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),vo=this._renderer.getRenderTarget(),Mo=this._renderer.getActiveCubeFace(),So=this._renderer.getActiveMipmapLevel(),To=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:gn,minFilter:gn,generateMipmaps:!1,type:wr,format:Hn,colorSpace:Tn,depthBuffer:!1},i=ru(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=ru(e,t,n);const{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=o0(r)),this._blurMaterial=l0(r,e,t)}return i}_compileMaterial(e){const t=new sn(this._lodPlanes[0],e);this._renderer.compile(t,xo)}_sceneToCubeUV(e,t,n,i,r){const l=new cn(90,1,t,n),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],h=this._renderer,d=h.autoClear,f=h.toneMapping;h.getClearColor(nu),h.toneMapping=Gi,h.autoClear=!1;const g=new Ti({name:"PMREM.Background",side:Ln,depthWrite:!1,depthTest:!1}),_=new sn(new Cr,g);let m=!1;const p=e.background;p?p.isColor&&(g.color.copy(p),e.background=null,m=!0):(g.color.copy(nu),m=!0);for(let S=0;S<6;S++){const x=S%3;x===0?(l.up.set(0,c[S],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x+u[S],r.y,r.z)):x===1?(l.up.set(0,0,c[S]),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y+u[S],r.z)):(l.up.set(0,c[S],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y,r.z+u[S]));const y=this._cubeSize;ca(i,x*y,S>2?y:0,y,y),h.setRenderTarget(i),m&&h.render(_,l),h.render(e,l)}_.geometry.dispose(),_.material.dispose(),h.toneMapping=f,h.autoClear=d,e.background=p}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===Vs||e.mapping===Hs;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=ou()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=au());const r=i?this._cubemapMaterial:this._equirectMaterial,a=new sn(this._lodPlanes[0],r),o=r.uniforms;o.envMap.value=e;const l=this._cubeSize;ca(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,xo)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const i=this._lodPlanes.length;for(let r=1;r<i;r++){const a=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),o=iu[(i-r-1)%iu.length];this._blur(e,r-1,r,a,o)}t.autoClear=n}_blur(e,t,n,i,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,i,"latitudinal",r),this._halfBlur(a,e,n,n,i,"longitudinal",r)}_halfBlur(e,t,n,i,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,h=new sn(this._lodPlanes[i],c),d=c.uniforms,f=this._sizeLods[n]-1,g=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*rs-1),_=r/g,m=isFinite(r)?1+Math.floor(u*_):rs;m>rs&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${rs}`);const p=[];let S=0;for(let L=0;L<rs;++L){const U=L/_,E=Math.exp(-U*U/2);p.push(E),L===0?S+=E:L<m&&(S+=2*E)}for(let L=0;L<p.length;L++)p[L]=p[L]/S;d.envMap.value=e.texture,d.samples.value=m,d.weights.value=p,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:x}=this;d.dTheta.value=g,d.mipInt.value=x-n;const y=this._sizeLods[i],N=3*y*(i>x-Is?i-x+Is:0),P=4*(this._cubeSize-y);ca(t,N,P,3*y,2*y),l.setRenderTarget(t),l.render(h,xo)}}function o0(s){const e=[],t=[],n=[];let i=s;const r=s-Is+1+tu.length;for(let a=0;a<r;a++){const o=Math.pow(2,i);t.push(o);let l=1/o;a>s-Is?l=tu[a-s+Is-1]:a===0&&(l=0),n.push(l);const c=1/(o-2),u=-c,h=1+c,d=[u,u,h,u,h,h,u,u,h,h,u,h],f=6,g=6,_=3,m=2,p=1,S=new Float32Array(_*g*f),x=new Float32Array(m*g*f),y=new Float32Array(p*g*f);for(let P=0;P<f;P++){const L=P%3*2/3-1,U=P>2?0:-1,E=[L,U,0,L+2/3,U,0,L+2/3,U+1,0,L,U,0,L+2/3,U+1,0,L,U+1,0];S.set(E,_*g*P),x.set(d,m*g*P);const T=[P,P,P,P,P,P];y.set(T,p*g*P)}const N=new Kt;N.setAttribute("position",new un(S,_)),N.setAttribute("uv",new un(x,m)),N.setAttribute("faceIndex",new un(y,p)),e.push(N),i>Is&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function ru(s,e,t){const n=new cs(s,e,t);return n.texture.mapping=Ia,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function ca(s,e,t,n,i){s.viewport.set(e,t,n,i),s.scissor.set(e,t,n,i)}function l0(s,e,t){const n=new Float32Array(rs),i=new O(0,1,0);return new Wi({name:"SphericalGaussianBlur",defines:{n:rs,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:$l(),fragmentShader:`
3574
+ }`,xt={alphahash_fragment:xm,alphahash_pars_fragment:Mm,alphamap_fragment:Sm,alphamap_pars_fragment:Tm,alphatest_fragment:bm,alphatest_pars_fragment:Em,aomap_fragment:Am,aomap_pars_fragment:wm,batching_pars_vertex:Rm,batching_vertex:Cm,begin_vertex:Pm,beginnormal_vertex:Lm,bsdfs:Dm,iridescence_fragment:Im,bumpmap_pars_fragment:Nm,clipping_planes_fragment:Um,clipping_planes_pars_fragment:Fm,clipping_planes_pars_vertex:Om,clipping_planes_vertex:km,color_fragment:Bm,color_pars_fragment:zm,color_pars_vertex:Vm,color_vertex:Hm,common:Gm,cube_uv_reflection_fragment:Wm,defaultnormal_vertex:Xm,displacementmap_pars_vertex:jm,displacementmap_vertex:qm,emissivemap_fragment:Km,emissivemap_pars_fragment:Ym,colorspace_fragment:Zm,colorspace_pars_fragment:$m,envmap_fragment:Jm,envmap_common_pars_fragment:Qm,envmap_pars_fragment:eg,envmap_pars_vertex:tg,envmap_physical_pars_fragment:dg,envmap_vertex:ng,fog_vertex:ig,fog_pars_vertex:sg,fog_fragment:rg,fog_pars_fragment:ag,gradientmap_pars_fragment:og,lightmap_pars_fragment:lg,lights_lambert_fragment:cg,lights_lambert_pars_fragment:ug,lights_pars_begin:hg,lights_toon_fragment:fg,lights_toon_pars_fragment:pg,lights_phong_fragment:mg,lights_phong_pars_fragment:gg,lights_physical_fragment:_g,lights_physical_pars_fragment:yg,lights_fragment_begin:vg,lights_fragment_maps:xg,lights_fragment_end:Mg,logdepthbuf_fragment:Sg,logdepthbuf_pars_fragment:Tg,logdepthbuf_pars_vertex:bg,logdepthbuf_vertex:Eg,map_fragment:Ag,map_pars_fragment:wg,map_particle_fragment:Rg,map_particle_pars_fragment:Cg,metalnessmap_fragment:Pg,metalnessmap_pars_fragment:Lg,morphinstance_vertex:Dg,morphcolor_vertex:Ig,morphnormal_vertex:Ng,morphtarget_pars_vertex:Ug,morphtarget_vertex:Fg,normal_fragment_begin:Og,normal_fragment_maps:kg,normal_pars_fragment:Bg,normal_pars_vertex:zg,normal_vertex:Vg,normalmap_pars_fragment:Hg,clearcoat_normal_fragment_begin:Gg,clearcoat_normal_fragment_maps:Wg,clearcoat_pars_fragment:Xg,iridescence_pars_fragment:jg,opaque_fragment:qg,packing:Kg,premultiplied_alpha_fragment:Yg,project_vertex:Zg,dithering_fragment:$g,dithering_pars_fragment:Jg,roughnessmap_fragment:Qg,roughnessmap_pars_fragment:e_,shadowmap_pars_fragment:t_,shadowmap_pars_vertex:n_,shadowmap_vertex:i_,shadowmask_pars_fragment:s_,skinbase_vertex:r_,skinning_pars_vertex:a_,skinning_vertex:o_,skinnormal_vertex:l_,specularmap_fragment:c_,specularmap_pars_fragment:u_,tonemapping_fragment:h_,tonemapping_pars_fragment:d_,transmission_fragment:f_,transmission_pars_fragment:p_,uv_pars_fragment:m_,uv_pars_vertex:g_,uv_vertex:__,worldpos_vertex:y_,background_vert:v_,background_frag:x_,backgroundCube_vert:M_,backgroundCube_frag:S_,cube_vert:T_,cube_frag:b_,depth_vert:E_,depth_frag:A_,distanceRGBA_vert:w_,distanceRGBA_frag:R_,equirect_vert:C_,equirect_frag:P_,linedashed_vert:L_,linedashed_frag:D_,meshbasic_vert:I_,meshbasic_frag:N_,meshlambert_vert:U_,meshlambert_frag:F_,meshmatcap_vert:O_,meshmatcap_frag:k_,meshnormal_vert:B_,meshnormal_frag:z_,meshphong_vert:V_,meshphong_frag:H_,meshphysical_vert:G_,meshphysical_frag:W_,meshtoon_vert:X_,meshtoon_frag:j_,points_vert:q_,points_frag:K_,shadow_vert:Y_,shadow_frag:Z_,sprite_vert:$_,sprite_frag:J_},Le={common:{diffuse:{value:new Ge(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new gt},alphaMap:{value:null},alphaMapTransform:{value:new gt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new gt}},envmap:{envMap:{value:null},envMapRotation:{value:new gt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new gt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new gt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new gt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new gt},normalScale:{value:new ct(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new gt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new gt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new gt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new gt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ge(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Ge(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new gt},alphaTest:{value:0},uvTransform:{value:new gt}},sprite:{diffuse:{value:new Ge(16777215)},opacity:{value:1},center:{value:new ct(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new gt},alphaMap:{value:null},alphaMapTransform:{value:new gt},alphaTest:{value:0}}},ii={basic:{uniforms:Tn([Le.common,Le.specularmap,Le.envmap,Le.aomap,Le.lightmap,Le.fog]),vertexShader:xt.meshbasic_vert,fragmentShader:xt.meshbasic_frag},lambert:{uniforms:Tn([Le.common,Le.specularmap,Le.envmap,Le.aomap,Le.lightmap,Le.emissivemap,Le.bumpmap,Le.normalmap,Le.displacementmap,Le.fog,Le.lights,{emissive:{value:new Ge(0)}}]),vertexShader:xt.meshlambert_vert,fragmentShader:xt.meshlambert_frag},phong:{uniforms:Tn([Le.common,Le.specularmap,Le.envmap,Le.aomap,Le.lightmap,Le.emissivemap,Le.bumpmap,Le.normalmap,Le.displacementmap,Le.fog,Le.lights,{emissive:{value:new Ge(0)},specular:{value:new Ge(1118481)},shininess:{value:30}}]),vertexShader:xt.meshphong_vert,fragmentShader:xt.meshphong_frag},standard:{uniforms:Tn([Le.common,Le.envmap,Le.aomap,Le.lightmap,Le.emissivemap,Le.bumpmap,Le.normalmap,Le.displacementmap,Le.roughnessmap,Le.metalnessmap,Le.fog,Le.lights,{emissive:{value:new Ge(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:xt.meshphysical_vert,fragmentShader:xt.meshphysical_frag},toon:{uniforms:Tn([Le.common,Le.aomap,Le.lightmap,Le.emissivemap,Le.bumpmap,Le.normalmap,Le.displacementmap,Le.gradientmap,Le.fog,Le.lights,{emissive:{value:new Ge(0)}}]),vertexShader:xt.meshtoon_vert,fragmentShader:xt.meshtoon_frag},matcap:{uniforms:Tn([Le.common,Le.bumpmap,Le.normalmap,Le.displacementmap,Le.fog,{matcap:{value:null}}]),vertexShader:xt.meshmatcap_vert,fragmentShader:xt.meshmatcap_frag},points:{uniforms:Tn([Le.points,Le.fog]),vertexShader:xt.points_vert,fragmentShader:xt.points_frag},dashed:{uniforms:Tn([Le.common,Le.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:xt.linedashed_vert,fragmentShader:xt.linedashed_frag},depth:{uniforms:Tn([Le.common,Le.displacementmap]),vertexShader:xt.depth_vert,fragmentShader:xt.depth_frag},normal:{uniforms:Tn([Le.common,Le.bumpmap,Le.normalmap,Le.displacementmap,{opacity:{value:1}}]),vertexShader:xt.meshnormal_vert,fragmentShader:xt.meshnormal_frag},sprite:{uniforms:Tn([Le.sprite,Le.fog]),vertexShader:xt.sprite_vert,fragmentShader:xt.sprite_frag},background:{uniforms:{uvTransform:{value:new gt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:xt.background_vert,fragmentShader:xt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new gt}},vertexShader:xt.backgroundCube_vert,fragmentShader:xt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:xt.cube_vert,fragmentShader:xt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:xt.equirect_vert,fragmentShader:xt.equirect_frag},distanceRGBA:{uniforms:Tn([Le.common,Le.displacementmap,{referencePosition:{value:new O},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:xt.distanceRGBA_vert,fragmentShader:xt.distanceRGBA_frag},shadow:{uniforms:Tn([Le.lights,Le.fog,{color:{value:new Ge(0)},opacity:{value:1}}]),vertexShader:xt.shadow_vert,fragmentShader:xt.shadow_frag}};ii.physical={uniforms:Tn([ii.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new gt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new gt},clearcoatNormalScale:{value:new ct(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new gt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new gt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new gt},sheen:{value:0},sheenColor:{value:new Ge(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new gt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new gt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new gt},transmissionSamplerSize:{value:new ct},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new gt},attenuationDistance:{value:0},attenuationColor:{value:new Ge(0)},specularColor:{value:new Ge(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new gt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new gt},anisotropyVector:{value:new ct},anisotropyMap:{value:null},anisotropyMapTransform:{value:new gt}}]),vertexShader:xt.meshphysical_vert,fragmentShader:xt.meshphysical_frag};const ca={r:0,b:0,g:0},es=new sn,Q_=new Fe;function e0(s,e,t,n,i,r,a){const o=new Ge(0);let l=r===!0?0:1,c,u,h=null,d=0,f=null;function g(v){let y=v.isScene===!0?v.background:null;return y&&y.isTexture&&(y=(v.backgroundBlurriness>0?t:e).get(y)),y}function _(v){let y=!1;const N=g(v);N===null?p(o,l):N&&N.isColor&&(p(N,1),y=!0);const P=s.xr.getEnvironmentBlendMode();P==="additive"?n.buffers.color.setClear(0,0,0,1,a):P==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(s.autoClear||y)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function m(v,y){const N=g(y);N&&(N.isCubeTexture||N.mapping===Na)?(u===void 0&&(u=new rn(new Pr(1,1,1),new Wi({name:"BackgroundCubeMaterial",uniforms:Xs(ii.backgroundCube.uniforms),vertexShader:ii.backgroundCube.vertexShader,fragmentShader:ii.backgroundCube.fragmentShader,side:In,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(P,L,U){this.matrixWorld.copyPosition(U.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),es.copy(y.backgroundRotation),es.x*=-1,es.y*=-1,es.z*=-1,N.isCubeTexture&&N.isRenderTargetTexture===!1&&(es.y*=-1,es.z*=-1),u.material.uniforms.envMap.value=N,u.material.uniforms.flipEnvMap.value=N.isCubeTexture&&N.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=y.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(Q_.makeRotationFromEuler(es)),u.material.toneMapped=ft.getTransfer(N.colorSpace)!==Ut,(h!==N||d!==N.version||f!==s.toneMapping)&&(u.material.needsUpdate=!0,h=N,d=N.version,f=s.toneMapping),u.layers.enableAll(),v.unshift(u,u.geometry,u.material,0,0,null)):N&&N.isTexture&&(c===void 0&&(c=new rn(new Fa(2,2),new Wi({name:"BackgroundMaterial",uniforms:Xs(ii.background.uniforms),vertexShader:ii.background.vertexShader,fragmentShader:ii.background.fragmentShader,side:ri,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=N,c.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,c.material.toneMapped=ft.getTransfer(N.colorSpace)!==Ut,N.matrixAutoUpdate===!0&&N.updateMatrix(),c.material.uniforms.uvTransform.value.copy(N.matrix),(h!==N||d!==N.version||f!==s.toneMapping)&&(c.material.needsUpdate=!0,h=N,d=N.version,f=s.toneMapping),c.layers.enableAll(),v.unshift(c,c.geometry,c.material,0,0,null))}function p(v,y){v.getRGB(ca,ch(s)),n.buffers.color.setClear(ca.r,ca.g,ca.b,y,a)}function S(){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 o},setClearColor:function(v,y=1){o.set(v),l=y,p(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(v){l=v,p(o,l)},render:_,addToRenderList:m,dispose:S}}function t0(s,e){const t=s.getParameter(s.MAX_VERTEX_ATTRIBS),n={},i=d(null);let r=i,a=!1;function o(T,D,X,q,se){let he=!1;const k=h(q,X,D);r!==k&&(r=k,c(r.object)),he=f(T,q,X,se),he&&g(T,q,X,se),se!==null&&e.update(se,s.ELEMENT_ARRAY_BUFFER),(he||a)&&(a=!1,y(T,D,X,q),se!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.get(se).buffer))}function l(){return s.createVertexArray()}function c(T){return s.bindVertexArray(T)}function u(T){return s.deleteVertexArray(T)}function h(T,D,X){const q=X.wireframe===!0;let se=n[T.id];se===void 0&&(se={},n[T.id]=se);let he=se[D.id];he===void 0&&(he={},se[D.id]=he);let k=he[q];return k===void 0&&(k=d(l()),he[q]=k),k}function d(T){const D=[],X=[],q=[];for(let se=0;se<t;se++)D[se]=0,X[se]=0,q[se]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:D,enabledAttributes:X,attributeDivisors:q,object:T,attributes:{},index:null}}function f(T,D,X,q){const se=r.attributes,he=D.attributes;let k=0;const oe=X.getAttributes();for(const G in oe)if(oe[G].location>=0){const ve=se[G];let le=he[G];if(le===void 0&&(G==="instanceMatrix"&&T.instanceMatrix&&(le=T.instanceMatrix),G==="instanceColor"&&T.instanceColor&&(le=T.instanceColor)),ve===void 0||ve.attribute!==le||le&&ve.data!==le.data)return!0;k++}return r.attributesNum!==k||r.index!==q}function g(T,D,X,q){const se={},he=D.attributes;let k=0;const oe=X.getAttributes();for(const G in oe)if(oe[G].location>=0){let ve=he[G];ve===void 0&&(G==="instanceMatrix"&&T.instanceMatrix&&(ve=T.instanceMatrix),G==="instanceColor"&&T.instanceColor&&(ve=T.instanceColor));const le={};le.attribute=ve,ve&&ve.data&&(le.data=ve.data),se[G]=le,k++}r.attributes=se,r.attributesNum=k,r.index=q}function _(){const T=r.newAttributes;for(let D=0,X=T.length;D<X;D++)T[D]=0}function m(T){p(T,0)}function p(T,D){const X=r.newAttributes,q=r.enabledAttributes,se=r.attributeDivisors;X[T]=1,q[T]===0&&(s.enableVertexAttribArray(T),q[T]=1),se[T]!==D&&(s.vertexAttribDivisor(T,D),se[T]=D)}function S(){const T=r.newAttributes,D=r.enabledAttributes;for(let X=0,q=D.length;X<q;X++)D[X]!==T[X]&&(s.disableVertexAttribArray(X),D[X]=0)}function v(T,D,X,q,se,he,k){k===!0?s.vertexAttribIPointer(T,D,X,se,he):s.vertexAttribPointer(T,D,X,q,se,he)}function y(T,D,X,q){_();const se=q.attributes,he=X.getAttributes(),k=D.defaultAttributeValues;for(const oe in he){const G=he[oe];if(G.location>=0){let fe=se[oe];if(fe===void 0&&(oe==="instanceMatrix"&&T.instanceMatrix&&(fe=T.instanceMatrix),oe==="instanceColor"&&T.instanceColor&&(fe=T.instanceColor)),fe!==void 0){const ve=fe.normalized,le=fe.itemSize,we=e.get(fe);if(we===void 0)continue;const Me=we.buffer,W=we.type,ee=we.bytesPerElement,ae=W===s.INT||W===s.UNSIGNED_INT||fe.gpuType===Pl;if(fe.isInterleavedBufferAttribute){const re=fe.data,Se=re.stride,ot=fe.offset;if(re.isInstancedInterleavedBuffer){for(let J=0;J<G.locationSize;J++)p(G.location+J,re.meshPerAttribute);T.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=re.meshPerAttribute*re.count)}else for(let J=0;J<G.locationSize;J++)m(G.location+J);s.bindBuffer(s.ARRAY_BUFFER,Me);for(let J=0;J<G.locationSize;J++)v(G.location+J,le/G.locationSize,W,ve,Se*ee,(ot+le/G.locationSize*J)*ee,ae)}else{if(fe.isInstancedBufferAttribute){for(let re=0;re<G.locationSize;re++)p(G.location+re,fe.meshPerAttribute);T.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=fe.meshPerAttribute*fe.count)}else for(let re=0;re<G.locationSize;re++)m(G.location+re);s.bindBuffer(s.ARRAY_BUFFER,Me);for(let re=0;re<G.locationSize;re++)v(G.location+re,le/G.locationSize,W,ve,le*ee,le/G.locationSize*re*ee,ae)}}else if(k!==void 0){const ve=k[oe];if(ve!==void 0)switch(ve.length){case 2:s.vertexAttrib2fv(G.location,ve);break;case 3:s.vertexAttrib3fv(G.location,ve);break;case 4:s.vertexAttrib4fv(G.location,ve);break;default:s.vertexAttrib1fv(G.location,ve)}}}}S()}function N(){U();for(const T in n){const D=n[T];for(const X in D){const q=D[X];for(const se in q)u(q[se].object),delete q[se];delete D[X]}delete n[T]}}function P(T){if(n[T.id]===void 0)return;const D=n[T.id];for(const X in D){const q=D[X];for(const se in q)u(q[se].object),delete q[se];delete D[X]}delete n[T.id]}function L(T){for(const D in n){const X=n[D];if(X[T.id]===void 0)continue;const q=X[T.id];for(const se in q)u(q[se].object),delete q[se];delete X[T.id]}}function U(){E(),a=!0,r!==i&&(r=i,c(r.object))}function E(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:U,resetDefaultState:E,dispose:N,releaseStatesOfGeometry:P,releaseStatesOfProgram:L,initAttributes:_,enableAttribute:m,disableUnusedAttributes:S}}function n0(s,e,t){let n;function i(c){n=c}function r(c,u){s.drawArrays(n,c,u),t.update(u,n,1)}function a(c,u,h){h!==0&&(s.drawArraysInstanced(n,c,u,h),t.update(u,n,h))}function o(c,u,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,u,0,h);let f=0;for(let g=0;g<h;g++)f+=u[g];t.update(f,n,1)}function l(c,u,h,d){if(h===0)return;const f=e.get("WEBGL_multi_draw");if(f===null)for(let g=0;g<c.length;g++)a(c[g],u[g],d[g]);else{f.multiDrawArraysInstancedWEBGL(n,c,0,u,0,d,0,h);let g=0;for(let _=0;_<h;_++)g+=u[_]*d[_];t.update(g,n,1)}}this.setMode=i,this.render=r,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function i0(s,e,t,n){let i;function r(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const L=e.get("EXT_texture_filter_anisotropic");i=s.getParameter(L.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function a(L){return!(L!==Gn&&n.convert(L)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(L){const U=L===Rr&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(L!==ai&&n.convert(L)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE)&&L!==ei&&!U)}function l(L){if(L==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";L="mediump"}return L==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.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.reverseDepthBuffer===!0&&e.has("EXT_clip_control"),f=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),g=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=s.getParameter(s.MAX_TEXTURE_SIZE),m=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),p=s.getParameter(s.MAX_VERTEX_ATTRIBS),S=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),v=s.getParameter(s.MAX_VARYING_VECTORS),y=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),N=g>0,P=s.getParameter(s.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:h,reverseDepthBuffer:d,maxTextures:f,maxVertexTextures:g,maxTextureSize:_,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:S,maxVaryings:v,maxFragmentUniforms:y,vertexTextures:N,maxSamples:P}}function s0(s){const e=this;let t=null,n=0,i=!1,r=!1;const a=new Bi,o=new gt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d){const f=h.length!==0||d||n!==0||i;return i=d,n=h.length,f},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(h,d){t=u(h,d,0)},this.setState=function(h,d,f){const g=h.clippingPlanes,_=h.clipIntersection,m=h.clipShadows,p=s.get(h);if(!i||g===null||g.length===0||r&&!m)r?u(null):c();else{const S=r?0:n,v=S*4;let y=p.clippingState||null;l.value=y,y=u(g,d,v,f);for(let N=0;N!==v;++N)y[N]=t[N];p.clippingState=y,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=S}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(h,d,f,g){const _=h!==null?h.length:0;let m=null;if(_!==0){if(m=l.value,g!==!0||m===null){const p=f+_*4,S=d.matrixWorldInverse;o.getNormalMatrix(S),(m===null||m.length<p)&&(m=new Float32Array(p));for(let v=0,y=f;v!==_;++v,y+=4)a.copy(h[v]).applyMatrix4(S,o),a.normal.toArray(m,y),m[y+3]=a.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=_,e.numIntersection=0,m}}function r0(s){let e=new WeakMap;function t(a,o){return o===ba?a.mapping=Hs:o===Go&&(a.mapping=Gs),a}function n(a){if(a&&a.isTexture){const o=a.mapping;if(o===ba||o===Go)if(e.has(a)){const l=e.get(a).texture;return t(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const c=new hp(l.height);return c.fromEquirectangularTexture(s,a),e.set(a,c),a.addEventListener("dispose",i),t(c.texture,a.mapping)}else return null}}return a}function i(a){const o=a.target;o.removeEventListener("dispose",i);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function r(){e=new WeakMap}return{get:n,dispose:r}}const Ns=4,tu=[.125,.215,.35,.446,.526,.582],rs=20,vo=new ka,nu=new Ge;let xo=null,Mo=0,So=0,To=!1;const is=(1+Math.sqrt(5))/2,Ps=1/is,iu=[new O(-is,Ps,0),new O(is,Ps,0),new O(-Ps,0,is),new O(Ps,0,is),new O(0,is,-Ps),new O(0,is,Ps),new O(-1,1,-1),new O(1,1,-1),new O(-1,1,1),new O(1,1,1)],a0=new O;class su{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,i=100,r={}){const{size:a=256,position:o=a0}=r;xo=this._renderer.getRenderTarget(),Mo=this._renderer.getActiveCubeFace(),So=this._renderer.getActiveMipmapLevel(),To=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,n,i,l,o),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=ou(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=au(),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(xo,Mo,So),this._renderer.xr.enabled=To,e.scissorTest=!1,ua(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Hs||e.mapping===Gs?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),xo=this._renderer.getRenderTarget(),Mo=this._renderer.getActiveCubeFace(),So=this._renderer.getActiveMipmapLevel(),To=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:yn,minFilter:yn,generateMipmaps:!1,type:Rr,format:Gn,colorSpace:An,depthBuffer:!1},i=ru(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=ru(e,t,n);const{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=o0(r)),this._blurMaterial=l0(r,e,t)}return i}_compileMaterial(e){const t=new rn(this._lodPlanes[0],e);this._renderer.compile(t,vo)}_sceneToCubeUV(e,t,n,i,r){const l=new un(90,1,t,n),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],h=this._renderer,d=h.autoClear,f=h.toneMapping;h.getClearColor(nu),h.toneMapping=Gi,h.autoClear=!1;const g=new bi({name:"PMREM.Background",side:In,depthWrite:!1,depthTest:!1}),_=new rn(new Pr,g);let m=!1;const p=e.background;p?p.isColor&&(g.color.copy(p),e.background=null,m=!0):(g.color.copy(nu),m=!0);for(let S=0;S<6;S++){const v=S%3;v===0?(l.up.set(0,c[S],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x+u[S],r.y,r.z)):v===1?(l.up.set(0,0,c[S]),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y+u[S],r.z)):(l.up.set(0,c[S],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y,r.z+u[S]));const y=this._cubeSize;ua(i,v*y,S>2?y:0,y,y),h.setRenderTarget(i),m&&h.render(_,l),h.render(e,l)}_.geometry.dispose(),_.material.dispose(),h.toneMapping=f,h.autoClear=d,e.background=p}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===Hs||e.mapping===Gs;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=ou()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=au());const r=i?this._cubemapMaterial:this._equirectMaterial,a=new rn(this._lodPlanes[0],r),o=r.uniforms;o.envMap.value=e;const l=this._cubeSize;ua(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,vo)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const i=this._lodPlanes.length;for(let r=1;r<i;r++){const a=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),o=iu[(i-r-1)%iu.length];this._blur(e,r-1,r,a,o)}t.autoClear=n}_blur(e,t,n,i,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,i,"latitudinal",r),this._halfBlur(a,e,n,n,i,"longitudinal",r)}_halfBlur(e,t,n,i,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,h=new rn(this._lodPlanes[i],c),d=c.uniforms,f=this._sizeLods[n]-1,g=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*rs-1),_=r/g,m=isFinite(r)?1+Math.floor(u*_):rs;m>rs&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${rs}`);const p=[];let S=0;for(let L=0;L<rs;++L){const U=L/_,E=Math.exp(-U*U/2);p.push(E),L===0?S+=E:L<m&&(S+=2*E)}for(let L=0;L<p.length;L++)p[L]=p[L]/S;d.envMap.value=e.texture,d.samples.value=m,d.weights.value=p,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:v}=this;d.dTheta.value=g,d.mipInt.value=v-n;const y=this._sizeLods[i],N=3*y*(i>v-Ns?i-v+Ns:0),P=4*(this._cubeSize-y);ua(t,N,P,3*y,2*y),l.setRenderTarget(t),l.render(h,vo)}}function o0(s){const e=[],t=[],n=[];let i=s;const r=s-Ns+1+tu.length;for(let a=0;a<r;a++){const o=Math.pow(2,i);t.push(o);let l=1/o;a>s-Ns?l=tu[a-s+Ns-1]:a===0&&(l=0),n.push(l);const c=1/(o-2),u=-c,h=1+c,d=[u,u,h,u,h,h,u,u,h,h,u,h],f=6,g=6,_=3,m=2,p=1,S=new Float32Array(_*g*f),v=new Float32Array(m*g*f),y=new Float32Array(p*g*f);for(let P=0;P<f;P++){const L=P%3*2/3-1,U=P>2?0:-1,E=[L,U,0,L+2/3,U,0,L+2/3,U+1,0,L,U,0,L+2/3,U+1,0,L,U+1,0];S.set(E,_*g*P),v.set(d,m*g*P);const T=[P,P,P,P,P,P];y.set(T,p*g*P)}const N=new Kt;N.setAttribute("position",new hn(S,_)),N.setAttribute("uv",new hn(v,m)),N.setAttribute("faceIndex",new hn(y,p)),e.push(N),i>Ns&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function ru(s,e,t){const n=new cs(s,e,t);return n.texture.mapping=Na,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function ua(s,e,t,n,i){s.viewport.set(e,t,n,i),s.scissor.set(e,t,n,i)}function l0(s,e,t){const n=new Float32Array(rs),i=new O(0,1,0);return new Wi({name:"SphericalGaussianBlur",defines:{n:rs,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:$l(),fragmentShader:`
3575
3575
 
3576
3576
  precision mediump float;
3577
3577
  precision mediump int;
@@ -3721,17 +3721,17 @@ void main() {
3721
3721
  gl_Position = vec4( position, 1.0 );
3722
3722
 
3723
3723
  }
3724
- `}function c0(s){let e=new WeakMap,t=null;function n(o){if(o&&o.isTexture){const l=o.mapping,c=l===Ta||l===Go,u=l===Vs||l===Hs;if(c||u){let h=e.get(o);const d=h!==void 0?h.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==d)return t===null&&(t=new su(s)),h=c?t.fromEquirectangular(o,h):t.fromCubemap(o,h),h.texture.pmremVersion=o.pmremVersion,e.set(o,h),h.texture;if(h!==void 0)return h.texture;{const f=o.image;return c&&f&&f.height>0||u&&f&&i(f)?(t===null&&(t=new su(s)),h=c?t.fromEquirectangular(o):t.fromCubemap(o),h.texture.pmremVersion=o.pmremVersion,e.set(o,h),o.addEventListener("dispose",r),h.texture):null}}}return o}function i(o){let l=0;const c=6;for(let u=0;u<c;u++)o[u]!==void 0&&l++;return l===c}function r(o){const l=o.target;l.removeEventListener("dispose",r);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:a}}function u0(s){const e={};function t(n){if(e[n]!==void 0)return e[n];let i;switch(n){case"WEBGL_depth_texture":i=s.getExtension("WEBGL_depth_texture")||s.getExtension("MOZ_WEBGL_depth_texture")||s.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=s.getExtension("EXT_texture_filter_anisotropic")||s.getExtension("MOZ_EXT_texture_filter_anisotropic")||s.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=s.getExtension("WEBGL_compressed_texture_s3tc")||s.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||s.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=s.getExtension("WEBGL_compressed_texture_pvrtc")||s.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=s.getExtension(n)}return e[n]=i,i}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 i=t(n);return i===null&&Os("THREE.WebGLRenderer: "+n+" extension not supported."),i}}}function h0(s,e,t,n){const i={},r=new WeakMap;function a(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",a),delete i[d.id];const f=r.get(d);f&&(e.remove(f),r.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function o(h,d){return i[d.id]===!0||(d.addEventListener("dispose",a),i[d.id]=!0,t.memory.geometries++),d}function l(h){const d=h.attributes;for(const f in d)e.update(d[f],s.ARRAY_BUFFER)}function c(h){const d=[],f=h.index,g=h.attributes.position;let _=0;if(f!==null){const S=f.array;_=f.version;for(let x=0,y=S.length;x<y;x+=3){const N=S[x+0],P=S[x+1],L=S[x+2];d.push(N,P,P,L,L,N)}}else if(g!==void 0){const S=g.array;_=g.version;for(let x=0,y=S.length/3-1;x<y;x+=3){const N=x+0,P=x+1,L=x+2;d.push(N,P,P,L,L,N)}}else return;const m=new(sh(d)?lh:Bl)(d,1);m.version=_;const p=r.get(h);p&&e.remove(p),r.set(h,m)}function u(h){const d=r.get(h);if(d){const f=h.index;f!==null&&d.version<f.version&&c(h)}else c(h);return r.get(h)}return{get:o,update:l,getWireframeAttribute:u}}function d0(s,e,t){let n;function i(d){n=d}let r,a;function o(d){r=d.type,a=d.bytesPerElement}function l(d,f){s.drawElements(n,f,r,d*a),t.update(f,n,1)}function c(d,f,g){g!==0&&(s.drawElementsInstanced(n,f,r,d*a,g),t.update(f,n,g))}function u(d,f,g){if(g===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,f,0,r,d,0,g);let m=0;for(let p=0;p<g;p++)m+=f[p];t.update(m,n,1)}function h(d,f,g,_){if(g===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let p=0;p<d.length;p++)c(d[p]/a,f[p],_[p]);else{m.multiDrawElementsInstancedWEBGL(n,f,0,r,d,0,_,0,g);let p=0;for(let S=0;S<g;S++)p+=f[S]*_[S];t.update(p,n,1)}}this.setMode=i,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u,this.renderMultiDrawInstances=h}function f0(s){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,a,o){switch(t.calls++,a){case s.TRIANGLES:t.triangles+=o*(r/3);break;case s.LINES:t.lines+=o*(r/2);break;case s.LINE_STRIP:t.lines+=o*(r-1);break;case s.LINE_LOOP:t.lines+=o*r;break;case s.POINTS:t.points+=o*r;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function i(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:i,update:n}}function p0(s,e,t){const n=new WeakMap,i=new Tt;function r(a,o,l){const c=a.morphTargetInfluences,u=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,h=u!==void 0?u.length:0;let d=n.get(o);if(d===void 0||d.count!==h){let E=function(){L.dispose(),n.delete(o),o.removeEventListener("dispose",E)};d!==void 0&&d.texture.dispose();const f=o.morphAttributes.position!==void 0,g=o.morphAttributes.normal!==void 0,_=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],p=o.morphAttributes.normal||[],S=o.morphAttributes.color||[];let x=0;f===!0&&(x=1),g===!0&&(x=2),_===!0&&(x=3);let y=o.attributes.position.count*x,N=1;y>e.maxTextureSize&&(N=Math.ceil(y/e.maxTextureSize),y=e.maxTextureSize);const P=new Float32Array(y*N*4*h),L=new rh(P,y,N,h);L.type=Qn,L.needsUpdate=!0;const U=x*4;for(let T=0;T<h;T++){const D=m[T],X=p[T],j=S[T],se=y*N*4*T;for(let de=0;de<D.count;de++){const k=de*U;f===!0&&(i.fromBufferAttribute(D,de),P[se+k+0]=i.x,P[se+k+1]=i.y,P[se+k+2]=i.z,P[se+k+3]=0),g===!0&&(i.fromBufferAttribute(X,de),P[se+k+4]=i.x,P[se+k+5]=i.y,P[se+k+6]=i.z,P[se+k+7]=0),_===!0&&(i.fromBufferAttribute(j,de),P[se+k+8]=i.x,P[se+k+9]=i.y,P[se+k+10]=i.z,P[se+k+11]=j.itemSize===4?i.w:1)}}d={count:h,texture:L,size:new ot(y,N)},n.set(o,d),o.addEventListener("dispose",E)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(s,"morphTexture",a.morphTexture,t);else{let f=0;for(let _=0;_<c.length;_++)f+=c[_];const g=o.morphTargetsRelative?1:1-f;l.getUniforms().setValue(s,"morphTargetBaseInfluence",g),l.getUniforms().setValue(s,"morphTargetInfluences",c)}l.getUniforms().setValue(s,"morphTargetsTexture",d.texture,t),l.getUniforms().setValue(s,"morphTargetsTextureSize",d.size)}return{update:r}}function m0(s,e,t,n){let i=new WeakMap;function r(l){const c=n.render.frame,u=l.geometry,h=e.get(l,u);if(i.get(h)!==c&&(e.update(h),i.set(h,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),i.get(l)!==c&&(t.update(l.instanceMatrix,s.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,s.ARRAY_BUFFER),i.set(l,c))),l.isSkinnedMesh){const d=l.skeleton;i.get(d)!==c&&(d.update(),i.set(d,c))}return h}function a(){i=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:r,dispose:a}}const Sh=new rn,lu=new fh(1,1),Th=new rh,bh=new Kf,Eh=new hh,cu=[],uu=[],hu=new Float32Array(16),du=new Float32Array(9),fu=new Float32Array(4);function Zs(s,e,t){const n=s[0];if(n<=0||n>0)return s;const i=e*t;let r=cu[i];if(r===void 0&&(r=new Float32Array(i),cu[i]=r),e!==0){n.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,s[a].toArray(r,o)}return r}function an(s,e){if(s.length!==e.length)return!1;for(let t=0,n=s.length;t<n;t++)if(s[t]!==e[t])return!1;return!0}function on(s,e){for(let t=0,n=e.length;t<n;t++)s[t]=e[t]}function ka(s,e){let t=uu[e];t===void 0&&(t=new Int32Array(e),uu[e]=t);for(let n=0;n!==e;++n)t[n]=s.allocateTextureUnit();return t}function g0(s,e){const t=this.cache;t[0]!==e&&(s.uniform1f(this.addr,e),t[0]=e)}function _0(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(an(t,e))return;s.uniform2fv(this.addr,e),on(t,e)}}function y0(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.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)&&(s.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(an(t,e))return;s.uniform3fv(this.addr,e),on(t,e)}}function x0(s,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)&&(s.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(an(t,e))return;s.uniform4fv(this.addr,e),on(t,e)}}function v0(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(an(t,e))return;s.uniformMatrix2fv(this.addr,!1,e),on(t,e)}else{if(an(t,n))return;fu.set(n),s.uniformMatrix2fv(this.addr,!1,fu),on(t,n)}}function M0(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(an(t,e))return;s.uniformMatrix3fv(this.addr,!1,e),on(t,e)}else{if(an(t,n))return;du.set(n),s.uniformMatrix3fv(this.addr,!1,du),on(t,n)}}function S0(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(an(t,e))return;s.uniformMatrix4fv(this.addr,!1,e),on(t,e)}else{if(an(t,n))return;hu.set(n),s.uniformMatrix4fv(this.addr,!1,hu),on(t,n)}}function T0(s,e){const t=this.cache;t[0]!==e&&(s.uniform1i(this.addr,e),t[0]=e)}function b0(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(an(t,e))return;s.uniform2iv(this.addr,e),on(t,e)}}function E0(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(an(t,e))return;s.uniform3iv(this.addr,e),on(t,e)}}function A0(s,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)&&(s.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(an(t,e))return;s.uniform4iv(this.addr,e),on(t,e)}}function w0(s,e){const t=this.cache;t[0]!==e&&(s.uniform1ui(this.addr,e),t[0]=e)}function R0(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(an(t,e))return;s.uniform2uiv(this.addr,e),on(t,e)}}function C0(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(an(t,e))return;s.uniform3uiv(this.addr,e),on(t,e)}}function P0(s,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)&&(s.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(an(t,e))return;s.uniform4uiv(this.addr,e),on(t,e)}}function L0(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i);let r;this.type===s.SAMPLER_2D_SHADOW?(lu.compareFunction=ih,r=lu):r=Sh,t.setTexture2D(e||r,i)}function D0(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture3D(e||bh,i)}function I0(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTextureCube(e||Eh,i)}function N0(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture2DArray(e||Th,i)}function U0(s){switch(s){case 5126:return g0;case 35664:return _0;case 35665:return y0;case 35666:return x0;case 35674:return v0;case 35675:return M0;case 35676:return S0;case 5124:case 35670:return T0;case 35667:case 35671:return b0;case 35668:case 35672:return E0;case 35669:case 35673:return A0;case 5125:return w0;case 36294:return R0;case 36295:return C0;case 36296:return P0;case 35678:case 36198:case 36298:case 36306:case 35682:return L0;case 35679:case 36299:case 36307:return D0;case 35680:case 36300:case 36308:case 36293:return I0;case 36289:case 36303:case 36311:case 36292:return N0}}function F0(s,e){s.uniform1fv(this.addr,e)}function O0(s,e){const t=Zs(e,this.size,2);s.uniform2fv(this.addr,t)}function k0(s,e){const t=Zs(e,this.size,3);s.uniform3fv(this.addr,t)}function B0(s,e){const t=Zs(e,this.size,4);s.uniform4fv(this.addr,t)}function z0(s,e){const t=Zs(e,this.size,4);s.uniformMatrix2fv(this.addr,!1,t)}function V0(s,e){const t=Zs(e,this.size,9);s.uniformMatrix3fv(this.addr,!1,t)}function H0(s,e){const t=Zs(e,this.size,16);s.uniformMatrix4fv(this.addr,!1,t)}function G0(s,e){s.uniform1iv(this.addr,e)}function W0(s,e){s.uniform2iv(this.addr,e)}function X0(s,e){s.uniform3iv(this.addr,e)}function j0(s,e){s.uniform4iv(this.addr,e)}function q0(s,e){s.uniform1uiv(this.addr,e)}function K0(s,e){s.uniform2uiv(this.addr,e)}function Y0(s,e){s.uniform3uiv(this.addr,e)}function Z0(s,e){s.uniform4uiv(this.addr,e)}function $0(s,e,t){const n=this.cache,i=e.length,r=ka(t,i);an(n,r)||(s.uniform1iv(this.addr,r),on(n,r));for(let a=0;a!==i;++a)t.setTexture2D(e[a]||Sh,r[a])}function J0(s,e,t){const n=this.cache,i=e.length,r=ka(t,i);an(n,r)||(s.uniform1iv(this.addr,r),on(n,r));for(let a=0;a!==i;++a)t.setTexture3D(e[a]||bh,r[a])}function Q0(s,e,t){const n=this.cache,i=e.length,r=ka(t,i);an(n,r)||(s.uniform1iv(this.addr,r),on(n,r));for(let a=0;a!==i;++a)t.setTextureCube(e[a]||Eh,r[a])}function ey(s,e,t){const n=this.cache,i=e.length,r=ka(t,i);an(n,r)||(s.uniform1iv(this.addr,r),on(n,r));for(let a=0;a!==i;++a)t.setTexture2DArray(e[a]||Th,r[a])}function ty(s){switch(s){case 5126:return F0;case 35664:return O0;case 35665:return k0;case 35666:return B0;case 35674:return z0;case 35675:return V0;case 35676:return H0;case 5124:case 35670:return G0;case 35667:case 35671:return W0;case 35668:case 35672:return X0;case 35669:case 35673:return j0;case 5125:return q0;case 36294:return K0;case 36295:return Y0;case 36296:return Z0;case 35678:case 36198:case 36298:case 36306:case 35682:return $0;case 35679:case 36299:case 36307:return J0;case 35680:case 36300:case 36308:case 36293:return Q0;case 36289:case 36303:case 36311:case 36292:return ey}}class ny{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=U0(t.type)}}class iy{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=ty(t.type)}}class sy{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const i=this.seq;for(let r=0,a=i.length;r!==a;++r){const o=i[r];o.setValue(e,t[o.id],n)}}}const bo=/(\w+)(\])?(\[|\.)?/g;function pu(s,e){s.seq.push(e),s.map[e.id]=e}function ry(s,e,t){const n=s.name,i=n.length;for(bo.lastIndex=0;;){const r=bo.exec(n),a=bo.lastIndex;let o=r[1];const l=r[2]==="]",c=r[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===i){pu(t,c===void 0?new ny(o,s,e):new iy(o,s,e));break}else{let h=t.map[o];h===void 0&&(h=new sy(o),pu(t,h)),t=h}}}class Ma{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){const r=e.getActiveUniform(t,i),a=e.getUniformLocation(t,r.name);ry(r,a,this)}}setValue(e,t,n,i){const r=this.map[t];r!==void 0&&r.setValue(e,n,i)}setOptional(e,t,n){const i=t[n];i!==void 0&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,a=t.length;r!==a;++r){const o=t[r],l=n[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,i)}}static seqWithValue(e,t){const n=[];for(let i=0,r=e.length;i!==r;++i){const a=e[i];a.id in t&&n.push(a)}return n}}function mu(s,e,t){const n=s.createShader(e);return s.shaderSource(n,t),s.compileShader(n),n}const ay=37297;let oy=0;function ly(s,e){const t=s.split(`
3724
+ `}function c0(s){let e=new WeakMap,t=null;function n(o){if(o&&o.isTexture){const l=o.mapping,c=l===ba||l===Go,u=l===Hs||l===Gs;if(c||u){let h=e.get(o);const d=h!==void 0?h.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==d)return t===null&&(t=new su(s)),h=c?t.fromEquirectangular(o,h):t.fromCubemap(o,h),h.texture.pmremVersion=o.pmremVersion,e.set(o,h),h.texture;if(h!==void 0)return h.texture;{const f=o.image;return c&&f&&f.height>0||u&&f&&i(f)?(t===null&&(t=new su(s)),h=c?t.fromEquirectangular(o):t.fromCubemap(o),h.texture.pmremVersion=o.pmremVersion,e.set(o,h),o.addEventListener("dispose",r),h.texture):null}}}return o}function i(o){let l=0;const c=6;for(let u=0;u<c;u++)o[u]!==void 0&&l++;return l===c}function r(o){const l=o.target;l.removeEventListener("dispose",r);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:a}}function u0(s){const e={};function t(n){if(e[n]!==void 0)return e[n];let i;switch(n){case"WEBGL_depth_texture":i=s.getExtension("WEBGL_depth_texture")||s.getExtension("MOZ_WEBGL_depth_texture")||s.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=s.getExtension("EXT_texture_filter_anisotropic")||s.getExtension("MOZ_EXT_texture_filter_anisotropic")||s.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=s.getExtension("WEBGL_compressed_texture_s3tc")||s.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||s.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=s.getExtension("WEBGL_compressed_texture_pvrtc")||s.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=s.getExtension(n)}return e[n]=i,i}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 i=t(n);return i===null&&ks("THREE.WebGLRenderer: "+n+" extension not supported."),i}}}function h0(s,e,t,n){const i={},r=new WeakMap;function a(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",a),delete i[d.id];const f=r.get(d);f&&(e.remove(f),r.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function o(h,d){return i[d.id]===!0||(d.addEventListener("dispose",a),i[d.id]=!0,t.memory.geometries++),d}function l(h){const d=h.attributes;for(const f in d)e.update(d[f],s.ARRAY_BUFFER)}function c(h){const d=[],f=h.index,g=h.attributes.position;let _=0;if(f!==null){const S=f.array;_=f.version;for(let v=0,y=S.length;v<y;v+=3){const N=S[v+0],P=S[v+1],L=S[v+2];d.push(N,P,P,L,L,N)}}else if(g!==void 0){const S=g.array;_=g.version;for(let v=0,y=S.length/3-1;v<y;v+=3){const N=v+0,P=v+1,L=v+2;d.push(N,P,P,L,L,N)}}else return;const m=new(sh(d)?lh:Bl)(d,1);m.version=_;const p=r.get(h);p&&e.remove(p),r.set(h,m)}function u(h){const d=r.get(h);if(d){const f=h.index;f!==null&&d.version<f.version&&c(h)}else c(h);return r.get(h)}return{get:o,update:l,getWireframeAttribute:u}}function d0(s,e,t){let n;function i(d){n=d}let r,a;function o(d){r=d.type,a=d.bytesPerElement}function l(d,f){s.drawElements(n,f,r,d*a),t.update(f,n,1)}function c(d,f,g){g!==0&&(s.drawElementsInstanced(n,f,r,d*a,g),t.update(f,n,g))}function u(d,f,g){if(g===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,f,0,r,d,0,g);let m=0;for(let p=0;p<g;p++)m+=f[p];t.update(m,n,1)}function h(d,f,g,_){if(g===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let p=0;p<d.length;p++)c(d[p]/a,f[p],_[p]);else{m.multiDrawElementsInstancedWEBGL(n,f,0,r,d,0,_,0,g);let p=0;for(let S=0;S<g;S++)p+=f[S]*_[S];t.update(p,n,1)}}this.setMode=i,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u,this.renderMultiDrawInstances=h}function f0(s){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,a,o){switch(t.calls++,a){case s.TRIANGLES:t.triangles+=o*(r/3);break;case s.LINES:t.lines+=o*(r/2);break;case s.LINE_STRIP:t.lines+=o*(r-1);break;case s.LINE_LOOP:t.lines+=o*r;break;case s.POINTS:t.points+=o*r;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function i(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:i,update:n}}function p0(s,e,t){const n=new WeakMap,i=new Tt;function r(a,o,l){const c=a.morphTargetInfluences,u=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,h=u!==void 0?u.length:0;let d=n.get(o);if(d===void 0||d.count!==h){let E=function(){L.dispose(),n.delete(o),o.removeEventListener("dispose",E)};d!==void 0&&d.texture.dispose();const f=o.morphAttributes.position!==void 0,g=o.morphAttributes.normal!==void 0,_=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],p=o.morphAttributes.normal||[],S=o.morphAttributes.color||[];let v=0;f===!0&&(v=1),g===!0&&(v=2),_===!0&&(v=3);let y=o.attributes.position.count*v,N=1;y>e.maxTextureSize&&(N=Math.ceil(y/e.maxTextureSize),y=e.maxTextureSize);const P=new Float32Array(y*N*4*h),L=new rh(P,y,N,h);L.type=ei,L.needsUpdate=!0;const U=v*4;for(let T=0;T<h;T++){const D=m[T],X=p[T],q=S[T],se=y*N*4*T;for(let he=0;he<D.count;he++){const k=he*U;f===!0&&(i.fromBufferAttribute(D,he),P[se+k+0]=i.x,P[se+k+1]=i.y,P[se+k+2]=i.z,P[se+k+3]=0),g===!0&&(i.fromBufferAttribute(X,he),P[se+k+4]=i.x,P[se+k+5]=i.y,P[se+k+6]=i.z,P[se+k+7]=0),_===!0&&(i.fromBufferAttribute(q,he),P[se+k+8]=i.x,P[se+k+9]=i.y,P[se+k+10]=i.z,P[se+k+11]=q.itemSize===4?i.w:1)}}d={count:h,texture:L,size:new ct(y,N)},n.set(o,d),o.addEventListener("dispose",E)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(s,"morphTexture",a.morphTexture,t);else{let f=0;for(let _=0;_<c.length;_++)f+=c[_];const g=o.morphTargetsRelative?1:1-f;l.getUniforms().setValue(s,"morphTargetBaseInfluence",g),l.getUniforms().setValue(s,"morphTargetInfluences",c)}l.getUniforms().setValue(s,"morphTargetsTexture",d.texture,t),l.getUniforms().setValue(s,"morphTargetsTextureSize",d.size)}return{update:r}}function m0(s,e,t,n){let i=new WeakMap;function r(l){const c=n.render.frame,u=l.geometry,h=e.get(l,u);if(i.get(h)!==c&&(e.update(h),i.set(h,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),i.get(l)!==c&&(t.update(l.instanceMatrix,s.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,s.ARRAY_BUFFER),i.set(l,c))),l.isSkinnedMesh){const d=l.skeleton;i.get(d)!==c&&(d.update(),i.set(d,c))}return h}function a(){i=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:r,dispose:a}}const Sh=new an,lu=new fh(1,1),Th=new rh,bh=new Kf,Eh=new hh,cu=[],uu=[],hu=new Float32Array(16),du=new Float32Array(9),fu=new Float32Array(4);function $s(s,e,t){const n=s[0];if(n<=0||n>0)return s;const i=e*t;let r=cu[i];if(r===void 0&&(r=new Float32Array(i),cu[i]=r),e!==0){n.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,s[a].toArray(r,o)}return r}function on(s,e){if(s.length!==e.length)return!1;for(let t=0,n=s.length;t<n;t++)if(s[t]!==e[t])return!1;return!0}function ln(s,e){for(let t=0,n=e.length;t<n;t++)s[t]=e[t]}function Ba(s,e){let t=uu[e];t===void 0&&(t=new Int32Array(e),uu[e]=t);for(let n=0;n!==e;++n)t[n]=s.allocateTextureUnit();return t}function g0(s,e){const t=this.cache;t[0]!==e&&(s.uniform1f(this.addr,e),t[0]=e)}function _0(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(on(t,e))return;s.uniform2fv(this.addr,e),ln(t,e)}}function y0(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.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)&&(s.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(on(t,e))return;s.uniform3fv(this.addr,e),ln(t,e)}}function v0(s,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)&&(s.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(on(t,e))return;s.uniform4fv(this.addr,e),ln(t,e)}}function x0(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(on(t,e))return;s.uniformMatrix2fv(this.addr,!1,e),ln(t,e)}else{if(on(t,n))return;fu.set(n),s.uniformMatrix2fv(this.addr,!1,fu),ln(t,n)}}function M0(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(on(t,e))return;s.uniformMatrix3fv(this.addr,!1,e),ln(t,e)}else{if(on(t,n))return;du.set(n),s.uniformMatrix3fv(this.addr,!1,du),ln(t,n)}}function S0(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(on(t,e))return;s.uniformMatrix4fv(this.addr,!1,e),ln(t,e)}else{if(on(t,n))return;hu.set(n),s.uniformMatrix4fv(this.addr,!1,hu),ln(t,n)}}function T0(s,e){const t=this.cache;t[0]!==e&&(s.uniform1i(this.addr,e),t[0]=e)}function b0(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(on(t,e))return;s.uniform2iv(this.addr,e),ln(t,e)}}function E0(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(on(t,e))return;s.uniform3iv(this.addr,e),ln(t,e)}}function A0(s,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)&&(s.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(on(t,e))return;s.uniform4iv(this.addr,e),ln(t,e)}}function w0(s,e){const t=this.cache;t[0]!==e&&(s.uniform1ui(this.addr,e),t[0]=e)}function R0(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(on(t,e))return;s.uniform2uiv(this.addr,e),ln(t,e)}}function C0(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(on(t,e))return;s.uniform3uiv(this.addr,e),ln(t,e)}}function P0(s,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)&&(s.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(on(t,e))return;s.uniform4uiv(this.addr,e),ln(t,e)}}function L0(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i);let r;this.type===s.SAMPLER_2D_SHADOW?(lu.compareFunction=ih,r=lu):r=Sh,t.setTexture2D(e||r,i)}function D0(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture3D(e||bh,i)}function I0(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTextureCube(e||Eh,i)}function N0(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture2DArray(e||Th,i)}function U0(s){switch(s){case 5126:return g0;case 35664:return _0;case 35665:return y0;case 35666:return v0;case 35674:return x0;case 35675:return M0;case 35676:return S0;case 5124:case 35670:return T0;case 35667:case 35671:return b0;case 35668:case 35672:return E0;case 35669:case 35673:return A0;case 5125:return w0;case 36294:return R0;case 36295:return C0;case 36296:return P0;case 35678:case 36198:case 36298:case 36306:case 35682:return L0;case 35679:case 36299:case 36307:return D0;case 35680:case 36300:case 36308:case 36293:return I0;case 36289:case 36303:case 36311:case 36292:return N0}}function F0(s,e){s.uniform1fv(this.addr,e)}function O0(s,e){const t=$s(e,this.size,2);s.uniform2fv(this.addr,t)}function k0(s,e){const t=$s(e,this.size,3);s.uniform3fv(this.addr,t)}function B0(s,e){const t=$s(e,this.size,4);s.uniform4fv(this.addr,t)}function z0(s,e){const t=$s(e,this.size,4);s.uniformMatrix2fv(this.addr,!1,t)}function V0(s,e){const t=$s(e,this.size,9);s.uniformMatrix3fv(this.addr,!1,t)}function H0(s,e){const t=$s(e,this.size,16);s.uniformMatrix4fv(this.addr,!1,t)}function G0(s,e){s.uniform1iv(this.addr,e)}function W0(s,e){s.uniform2iv(this.addr,e)}function X0(s,e){s.uniform3iv(this.addr,e)}function j0(s,e){s.uniform4iv(this.addr,e)}function q0(s,e){s.uniform1uiv(this.addr,e)}function K0(s,e){s.uniform2uiv(this.addr,e)}function Y0(s,e){s.uniform3uiv(this.addr,e)}function Z0(s,e){s.uniform4uiv(this.addr,e)}function $0(s,e,t){const n=this.cache,i=e.length,r=Ba(t,i);on(n,r)||(s.uniform1iv(this.addr,r),ln(n,r));for(let a=0;a!==i;++a)t.setTexture2D(e[a]||Sh,r[a])}function J0(s,e,t){const n=this.cache,i=e.length,r=Ba(t,i);on(n,r)||(s.uniform1iv(this.addr,r),ln(n,r));for(let a=0;a!==i;++a)t.setTexture3D(e[a]||bh,r[a])}function Q0(s,e,t){const n=this.cache,i=e.length,r=Ba(t,i);on(n,r)||(s.uniform1iv(this.addr,r),ln(n,r));for(let a=0;a!==i;++a)t.setTextureCube(e[a]||Eh,r[a])}function ey(s,e,t){const n=this.cache,i=e.length,r=Ba(t,i);on(n,r)||(s.uniform1iv(this.addr,r),ln(n,r));for(let a=0;a!==i;++a)t.setTexture2DArray(e[a]||Th,r[a])}function ty(s){switch(s){case 5126:return F0;case 35664:return O0;case 35665:return k0;case 35666:return B0;case 35674:return z0;case 35675:return V0;case 35676:return H0;case 5124:case 35670:return G0;case 35667:case 35671:return W0;case 35668:case 35672:return X0;case 35669:case 35673:return j0;case 5125:return q0;case 36294:return K0;case 36295:return Y0;case 36296:return Z0;case 35678:case 36198:case 36298:case 36306:case 35682:return $0;case 35679:case 36299:case 36307:return J0;case 35680:case 36300:case 36308:case 36293:return Q0;case 36289:case 36303:case 36311:case 36292:return ey}}class ny{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=U0(t.type)}}class iy{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=ty(t.type)}}class sy{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const i=this.seq;for(let r=0,a=i.length;r!==a;++r){const o=i[r];o.setValue(e,t[o.id],n)}}}const bo=/(\w+)(\])?(\[|\.)?/g;function pu(s,e){s.seq.push(e),s.map[e.id]=e}function ry(s,e,t){const n=s.name,i=n.length;for(bo.lastIndex=0;;){const r=bo.exec(n),a=bo.lastIndex;let o=r[1];const l=r[2]==="]",c=r[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===i){pu(t,c===void 0?new ny(o,s,e):new iy(o,s,e));break}else{let h=t.map[o];h===void 0&&(h=new sy(o),pu(t,h)),t=h}}}class Sa{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){const r=e.getActiveUniform(t,i),a=e.getUniformLocation(t,r.name);ry(r,a,this)}}setValue(e,t,n,i){const r=this.map[t];r!==void 0&&r.setValue(e,n,i)}setOptional(e,t,n){const i=t[n];i!==void 0&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,a=t.length;r!==a;++r){const o=t[r],l=n[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,i)}}static seqWithValue(e,t){const n=[];for(let i=0,r=e.length;i!==r;++i){const a=e[i];a.id in t&&n.push(a)}return n}}function mu(s,e,t){const n=s.createShader(e);return s.shaderSource(n,t),s.compileShader(n),n}const ay=37297;let oy=0;function ly(s,e){const t=s.split(`
3725
3725
  `),n=[],i=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=i;a<r;a++){const o=a+1;n.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return n.join(`
3726
- `)}const gu=new gt;function cy(s){pt._getMatrix(gu,pt.workingColorSpace,s);const e=`mat3( ${gu.elements.map(t=>t.toFixed(4))} )`;switch(pt.getTransfer(s)){case Ea:return[e,"LinearTransferOETF"];case Ut:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",s),[e,"LinearTransferOETF"]}}function _u(s,e,t){const n=s.getShaderParameter(e,s.COMPILE_STATUS),i=s.getShaderInfoLog(e).trim();if(n&&i==="")return"";const r=/ERROR: 0:(\d+)/.exec(i);if(r){const a=parseInt(r[1]);return t.toUpperCase()+`
3726
+ `)}const gu=new gt;function cy(s){ft._getMatrix(gu,ft.workingColorSpace,s);const e=`mat3( ${gu.elements.map(t=>t.toFixed(4))} )`;switch(ft.getTransfer(s)){case Aa:return[e,"LinearTransferOETF"];case Ut:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",s),[e,"LinearTransferOETF"]}}function _u(s,e,t){const n=s.getShaderParameter(e,s.COMPILE_STATUS),i=s.getShaderInfoLog(e).trim();if(n&&i==="")return"";const r=/ERROR: 0:(\d+)/.exec(i);if(r){const a=parseInt(r[1]);return t.toUpperCase()+`
3727
3727
 
3728
3728
  `+i+`
3729
3729
 
3730
3730
  `+ly(s.getShaderSource(e),a)}else return i}function uy(s,e){const t=cy(e);return[`vec4 ${s}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
3731
- `)}function hy(s,e){let t;switch(e){case nf:t="Linear";break;case sf:t="Reinhard";break;case rf:t="Cineon";break;case af:t="ACESFilmic";break;case lf:t="AgX";break;case cf:t="Neutral";break;case of:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+s+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const ua=new O;function dy(){pt.getLuminanceCoefficients(ua);const s=ua.x.toFixed(4),e=ua.y.toFixed(4),t=ua.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${s}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
3732
- `)}function fy(s){return[s.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",s.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(lr).join(`
3731
+ `)}function hy(s,e){let t;switch(e){case nf:t="Linear";break;case sf:t="Reinhard";break;case rf:t="Cineon";break;case af:t="ACESFilmic";break;case lf:t="AgX";break;case cf:t="Neutral";break;case of:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+s+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const ha=new O;function dy(){ft.getLuminanceCoefficients(ha);const s=ha.x.toFixed(4),e=ha.y.toFixed(4),t=ha.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${s}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
3732
+ `)}function fy(s){return[s.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",s.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(cr).join(`
3733
3733
  `)}function py(s){const e=[];for(const t in s){const n=s[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
3734
- `)}function my(s,e){const t={},n=s.getProgramParameter(e,s.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){const r=s.getActiveAttrib(e,i),a=r.name;let o=1;r.type===s.FLOAT_MAT2&&(o=2),r.type===s.FLOAT_MAT3&&(o=3),r.type===s.FLOAT_MAT4&&(o=4),t[a]={type:r.type,location:s.getAttribLocation(e,a),locationSize:o}}return t}function lr(s){return s!==""}function yu(s,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return s.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 xu(s,e){return s.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const gy=/^[ \t]*#include +<([\w\d./]+)>/gm;function Sl(s){return s.replace(gy,yy)}const _y=new Map;function yy(s,e){let t=vt[e];if(t===void 0){const n=_y.get(e);if(n!==void 0)t=vt[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 Sl(t)}const xy=/#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 vu(s){return s.replace(xy,vy)}function vy(s,e,t,n){let i="";for(let r=parseInt(e);r<parseInt(t);r++)i+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return i}function Mu(s){let e=`precision ${s.precision} float;
3734
+ `)}function my(s,e){const t={},n=s.getProgramParameter(e,s.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){const r=s.getActiveAttrib(e,i),a=r.name;let o=1;r.type===s.FLOAT_MAT2&&(o=2),r.type===s.FLOAT_MAT3&&(o=3),r.type===s.FLOAT_MAT4&&(o=4),t[a]={type:r.type,location:s.getAttribLocation(e,a),locationSize:o}}return t}function cr(s){return s!==""}function yu(s,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return s.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 vu(s,e){return s.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const gy=/^[ \t]*#include +<([\w\d./]+)>/gm;function Sl(s){return s.replace(gy,yy)}const _y=new Map;function yy(s,e){let t=xt[e];if(t===void 0){const n=_y.get(e);if(n!==void 0)t=xt[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 Sl(t)}const vy=/#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 xu(s){return s.replace(vy,xy)}function xy(s,e,t,n){let i="";for(let r=parseInt(e);r<parseInt(t);r++)i+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return i}function Mu(s){let e=`precision ${s.precision} float;
3735
3735
  precision ${s.precision} int;
3736
3736
  precision ${s.precision} sampler2D;
3737
3737
  precision ${s.precision} samplerCube;
@@ -3751,28 +3751,28 @@ void main() {
3751
3751
  `;return s.precision==="highp"?e+=`
3752
3752
  #define HIGH_PRECISION`:s.precision==="mediump"?e+=`
3753
3753
  #define MEDIUM_PRECISION`:s.precision==="lowp"&&(e+=`
3754
- #define LOW_PRECISION`),e}function My(s){let e="SHADOWMAP_TYPE_BASIC";return s.shadowMapType===Xu?e="SHADOWMAP_TYPE_PCF":s.shadowMapType===ju?e="SHADOWMAP_TYPE_PCF_SOFT":s.shadowMapType===xi&&(e="SHADOWMAP_TYPE_VSM"),e}function Sy(s){let e="ENVMAP_TYPE_CUBE";if(s.envMap)switch(s.envMapMode){case Vs:case Hs:e="ENVMAP_TYPE_CUBE";break;case Ia:e="ENVMAP_TYPE_CUBE_UV";break}return e}function Ty(s){let e="ENVMAP_MODE_REFLECTION";if(s.envMap)switch(s.envMapMode){case Hs:e="ENVMAP_MODE_REFRACTION";break}return e}function by(s){let e="ENVMAP_BLENDING_NONE";if(s.envMap)switch(s.combine){case Da:e="ENVMAP_BLENDING_MULTIPLY";break;case ef:e="ENVMAP_BLENDING_MIX";break;case tf:e="ENVMAP_BLENDING_ADD";break}return e}function Ey(s){const e=s.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),7*16)),texelHeight:n,maxMip:t}}function Ay(s,e,t,n){const i=s.getContext(),r=t.defines;let a=t.vertexShader,o=t.fragmentShader;const l=My(t),c=Sy(t),u=Ty(t),h=by(t),d=Ey(t),f=fy(t),g=py(r),_=i.createProgram();let m,p,S=t.glslVersion?"#version "+t.glslVersion+`
3755
- `:"";t.isRawShaderMaterial?(m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(lr).join(`
3754
+ #define LOW_PRECISION`),e}function My(s){let e="SHADOWMAP_TYPE_BASIC";return s.shadowMapType===Xu?e="SHADOWMAP_TYPE_PCF":s.shadowMapType===ju?e="SHADOWMAP_TYPE_PCF_SOFT":s.shadowMapType===xi&&(e="SHADOWMAP_TYPE_VSM"),e}function Sy(s){let e="ENVMAP_TYPE_CUBE";if(s.envMap)switch(s.envMapMode){case Hs:case Gs:e="ENVMAP_TYPE_CUBE";break;case Na:e="ENVMAP_TYPE_CUBE_UV";break}return e}function Ty(s){let e="ENVMAP_MODE_REFLECTION";if(s.envMap)switch(s.envMapMode){case Gs:e="ENVMAP_MODE_REFRACTION";break}return e}function by(s){let e="ENVMAP_BLENDING_NONE";if(s.envMap)switch(s.combine){case Ia:e="ENVMAP_BLENDING_MULTIPLY";break;case ef:e="ENVMAP_BLENDING_MIX";break;case tf:e="ENVMAP_BLENDING_ADD";break}return e}function Ey(s){const e=s.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),7*16)),texelHeight:n,maxMip:t}}function Ay(s,e,t,n){const i=s.getContext(),r=t.defines;let a=t.vertexShader,o=t.fragmentShader;const l=My(t),c=Sy(t),u=Ty(t),h=by(t),d=Ey(t),f=fy(t),g=py(r),_=i.createProgram();let m,p,S=t.glslVersion?"#version "+t.glslVersion+`
3755
+ `:"";t.isRawShaderMaterial?(m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(cr).join(`
3756
3756
  `),m.length>0&&(m+=`
3757
- `),p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(lr).join(`
3757
+ `),p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(cr).join(`
3758
3758
  `),p.length>0&&(p+=`
3759
3759
  `)):(m=[Mu(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_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","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",`
3760
- `].filter(lr).join(`
3761
- `),p=[Mu(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_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Gi?"#define TONE_MAPPING":"",t.toneMapping!==Gi?vt.tonemapping_pars_fragment:"",t.toneMapping!==Gi?hy("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",vt.colorspace_pars_fragment,uy("linearToOutputTexel",t.outputColorSpace),dy(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
3762
- `].filter(lr).join(`
3763
- `)),a=Sl(a),a=yu(a,t),a=xu(a,t),o=Sl(o),o=yu(o,t),o=xu(o,t),a=vu(a),o=vu(o),t.isRawShaderMaterial!==!0&&(S=`#version 300 es
3760
+ `].filter(cr).join(`
3761
+ `),p=[Mu(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_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Gi?"#define TONE_MAPPING":"",t.toneMapping!==Gi?xt.tonemapping_pars_fragment:"",t.toneMapping!==Gi?hy("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",xt.colorspace_pars_fragment,uy("linearToOutputTexel",t.outputColorSpace),dy(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
3762
+ `].filter(cr).join(`
3763
+ `)),a=Sl(a),a=yu(a,t),a=vu(a,t),o=Sl(o),o=yu(o,t),o=vu(o,t),a=xu(a),o=xu(o),t.isRawShaderMaterial!==!0&&(S=`#version 300 es
3764
3764
  `,m=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`
3765
3765
  `)+`
3766
3766
  `+m,p=["#define varying in",t.glslVersion===fc?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===fc?"":"#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(`
3767
3767
  `)+`
3768
- `+p);const x=S+m+a,y=S+p+o,N=mu(i,i.VERTEX_SHADER,x),P=mu(i,i.FRAGMENT_SHADER,y);i.attachShader(_,N),i.attachShader(_,P),t.index0AttributeName!==void 0?i.bindAttribLocation(_,0,t.index0AttributeName):t.morphTargets===!0&&i.bindAttribLocation(_,0,"position"),i.linkProgram(_);function L(D){if(s.debug.checkShaderErrors){const X=i.getProgramInfoLog(_).trim(),j=i.getShaderInfoLog(N).trim(),se=i.getShaderInfoLog(P).trim();let de=!0,k=!0;if(i.getProgramParameter(_,i.LINK_STATUS)===!1)if(de=!1,typeof s.debug.onShaderError=="function")s.debug.onShaderError(i,_,N,P);else{const ae=_u(i,N,"vertex"),G=_u(i,P,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(_,i.VALIDATE_STATUS)+`
3768
+ `+p);const v=S+m+a,y=S+p+o,N=mu(i,i.VERTEX_SHADER,v),P=mu(i,i.FRAGMENT_SHADER,y);i.attachShader(_,N),i.attachShader(_,P),t.index0AttributeName!==void 0?i.bindAttribLocation(_,0,t.index0AttributeName):t.morphTargets===!0&&i.bindAttribLocation(_,0,"position"),i.linkProgram(_);function L(D){if(s.debug.checkShaderErrors){const X=i.getProgramInfoLog(_).trim(),q=i.getShaderInfoLog(N).trim(),se=i.getShaderInfoLog(P).trim();let he=!0,k=!0;if(i.getProgramParameter(_,i.LINK_STATUS)===!1)if(he=!1,typeof s.debug.onShaderError=="function")s.debug.onShaderError(i,_,N,P);else{const oe=_u(i,N,"vertex"),G=_u(i,P,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(_,i.VALIDATE_STATUS)+`
3769
3769
 
3770
3770
  Material Name: `+D.name+`
3771
3771
  Material Type: `+D.type+`
3772
3772
 
3773
3773
  Program Info Log: `+X+`
3774
- `+ae+`
3775
- `+G)}else X!==""?console.warn("THREE.WebGLProgram: Program Info Log:",X):(j===""||se==="")&&(k=!1);k&&(D.diagnostics={runnable:de,programLog:X,vertexShader:{log:j,prefix:m},fragmentShader:{log:se,prefix:p}})}i.deleteShader(N),i.deleteShader(P),U=new Ma(i,_),E=my(i,_)}let U;this.getUniforms=function(){return U===void 0&&L(this),U};let E;this.getAttributes=function(){return E===void 0&&L(this),E};let T=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return T===!1&&(T=i.getProgramParameter(_,ay)),T},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=oy++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=N,this.fragmentShader=P,this}let wy=0;class Ry{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(i)===!1&&(a.add(i),i.usedTimes++),a.has(r)===!1&&(a.add(r),r.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 Cy(e),t.set(e,n)),n}}class Cy{constructor(e){this.id=wy++,this.code=e,this.usedTimes=0}}function Py(s,e,t,n,i,r,a){const o=new ah,l=new Ry,c=new Set,u=[],h=i.logarithmicDepthBuffer,d=i.vertexTextures;let f=i.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 _(E){return c.add(E),E===0?"uv":`uv${E}`}function m(E,T,D,X,j){const se=X.fog,de=j.geometry,k=E.isMeshStandardMaterial?X.environment:null,ae=(E.isMeshStandardMaterial?t:e).get(E.envMap||k),G=ae&&ae.mapping===Ia?ae.image.height:null,pe=g[E.type];E.precision!==null&&(f=i.getMaxPrecision(E.precision),f!==E.precision&&console.warn("THREE.WebGLProgram.getParameters:",E.precision,"not supported, using",f,"instead."));const Me=de.morphAttributes.position||de.morphAttributes.normal||de.morphAttributes.color,le=Me!==void 0?Me.length:0;let we=0;de.morphAttributes.position!==void 0&&(we=1),de.morphAttributes.normal!==void 0&&(we=2),de.morphAttributes.color!==void 0&&(we=3);let be,W,$,re;if(pe){const ft=ni[pe];be=ft.vertexShader,W=ft.fragmentShader}else be=E.vertexShader,W=E.fragmentShader,l.update(E),$=l.getVertexShaderID(E),re=l.getFragmentShaderID(E);const oe=s.getRenderTarget(),Te=s.state.buffers.depth.getReversed(),ne=j.isInstancedMesh===!0,me=j.isBatchedMesh===!0,Q=!!E.map,ee=!!E.matcap,te=!!ae,I=!!E.aoMap,ge=!!E.lightMap,Ne=!!E.bumpMap,dt=!!E.normalMap,ve=!!E.displacementMap,nt=!!E.emissiveMap,ke=!!E.metalnessMap,ht=!!E.roughnessMap,Nt=E.anisotropy>0,F=E.clearcoat>0,b=E.dispersion>0,q=E.iridescence>0,ue=E.sheen>0,fe=E.transmission>0,ie=Nt&&!!E.anisotropyMap,Ke=F&&!!E.clearcoatMap,Re=F&&!!E.clearcoatNormalMap,Ge=F&&!!E.clearcoatRoughnessMap,Ye=q&&!!E.iridescenceMap,_e=q&&!!E.iridescenceThicknessMap,Oe=ue&&!!E.sheenColorMap,it=ue&&!!E.sheenRoughnessMap,Qe=!!E.specularMap,Ee=!!E.specularColorMap,at=!!E.specularIntensityMap,B=fe&&!!E.transmissionMap,Pe=fe&&!!E.thicknessMap,ye=!!E.gradientMap,Be=!!E.alphaMap,Y=E.alphaTest>0,ce=!!E.alphaHash,Ce=!!E.extensions;let tt=Gi;E.toneMapped&&(oe===null||oe.isXRRenderTarget===!0)&&(tt=s.toneMapping);const Lt={shaderID:pe,shaderType:E.type,shaderName:E.name,vertexShader:be,fragmentShader:W,defines:E.defines,customVertexShaderID:$,customFragmentShaderID:re,isRawShaderMaterial:E.isRawShaderMaterial===!0,glslVersion:E.glslVersion,precision:f,batching:me,batchingColor:me&&j._colorsTexture!==null,instancing:ne,instancingColor:ne&&j.instanceColor!==null,instancingMorph:ne&&j.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:oe===null?s.outputColorSpace:oe.isXRRenderTarget===!0?oe.texture.colorSpace:Tn,alphaToCoverage:!!E.alphaToCoverage,map:Q,matcap:ee,envMap:te,envMapMode:te&&ae.mapping,envMapCubeUVHeight:G,aoMap:I,lightMap:ge,bumpMap:Ne,normalMap:dt,displacementMap:d&&ve,emissiveMap:nt,normalMapObjectSpace:dt&&E.normalMapType===mf,normalMapTangentSpace:dt&&E.normalMapType===Na,metalnessMap:ke,roughnessMap:ht,anisotropy:Nt,anisotropyMap:ie,clearcoat:F,clearcoatMap:Ke,clearcoatNormalMap:Re,clearcoatRoughnessMap:Ge,dispersion:b,iridescence:q,iridescenceMap:Ye,iridescenceThicknessMap:_e,sheen:ue,sheenColorMap:Oe,sheenRoughnessMap:it,specularMap:Qe,specularColorMap:Ee,specularIntensityMap:at,transmission:fe,transmissionMap:B,thicknessMap:Pe,gradientMap:ye,opaque:E.transparent===!1&&E.blending===Fs&&E.alphaToCoverage===!1,alphaMap:Be,alphaTest:Y,alphaHash:ce,combine:E.combine,mapUv:Q&&_(E.map.channel),aoMapUv:I&&_(E.aoMap.channel),lightMapUv:ge&&_(E.lightMap.channel),bumpMapUv:Ne&&_(E.bumpMap.channel),normalMapUv:dt&&_(E.normalMap.channel),displacementMapUv:ve&&_(E.displacementMap.channel),emissiveMapUv:nt&&_(E.emissiveMap.channel),metalnessMapUv:ke&&_(E.metalnessMap.channel),roughnessMapUv:ht&&_(E.roughnessMap.channel),anisotropyMapUv:ie&&_(E.anisotropyMap.channel),clearcoatMapUv:Ke&&_(E.clearcoatMap.channel),clearcoatNormalMapUv:Re&&_(E.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ge&&_(E.clearcoatRoughnessMap.channel),iridescenceMapUv:Ye&&_(E.iridescenceMap.channel),iridescenceThicknessMapUv:_e&&_(E.iridescenceThicknessMap.channel),sheenColorMapUv:Oe&&_(E.sheenColorMap.channel),sheenRoughnessMapUv:it&&_(E.sheenRoughnessMap.channel),specularMapUv:Qe&&_(E.specularMap.channel),specularColorMapUv:Ee&&_(E.specularColorMap.channel),specularIntensityMapUv:at&&_(E.specularIntensityMap.channel),transmissionMapUv:B&&_(E.transmissionMap.channel),thicknessMapUv:Pe&&_(E.thicknessMap.channel),alphaMapUv:Be&&_(E.alphaMap.channel),vertexTangents:!!de.attributes.tangent&&(dt||Nt),vertexColors:E.vertexColors,vertexAlphas:E.vertexColors===!0&&!!de.attributes.color&&de.attributes.color.itemSize===4,pointsUvs:j.isPoints===!0&&!!de.attributes.uv&&(Q||Be),fog:!!se,useFog:E.fog===!0,fogExp2:!!se&&se.isFogExp2,flatShading:E.flatShading===!0,sizeAttenuation:E.sizeAttenuation===!0,logarithmicDepthBuffer:h,reverseDepthBuffer:Te,skinning:j.isSkinnedMesh===!0,morphTargets:de.morphAttributes.position!==void 0,morphNormals:de.morphAttributes.normal!==void 0,morphColors:de.morphAttributes.color!==void 0,morphTargetsCount:le,morphTextureStride:we,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numSpotLightShadowsWithMaps:T.numSpotLightShadowsWithMaps,numLightProbes:T.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:E.dithering,shadowMapEnabled:s.shadowMap.enabled&&D.length>0,shadowMapType:s.shadowMap.type,toneMapping:tt,decodeVideoTexture:Q&&E.map.isVideoTexture===!0&&pt.getTransfer(E.map.colorSpace)===Ut,decodeVideoTextureEmissive:nt&&E.emissiveMap.isVideoTexture===!0&&pt.getTransfer(E.emissiveMap.colorSpace)===Ut,premultipliedAlpha:E.premultipliedAlpha,doubleSided:E.side===Yn,flipSided:E.side===Ln,useDepthPacking:E.depthPacking>=0,depthPacking:E.depthPacking||0,index0AttributeName:E.index0AttributeName,extensionClipCullDistance:Ce&&E.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ce&&E.extensions.multiDraw===!0||me)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:E.customProgramCacheKey()};return Lt.vertexUv1s=c.has(1),Lt.vertexUv2s=c.has(2),Lt.vertexUv3s=c.has(3),c.clear(),Lt}function p(E){const T=[];if(E.shaderID?T.push(E.shaderID):(T.push(E.customVertexShaderID),T.push(E.customFragmentShaderID)),E.defines!==void 0)for(const D in E.defines)T.push(D),T.push(E.defines[D]);return E.isRawShaderMaterial===!1&&(S(T,E),x(T,E),T.push(s.outputColorSpace)),T.push(E.customProgramCacheKey),T.join()}function S(E,T){E.push(T.precision),E.push(T.outputColorSpace),E.push(T.envMapMode),E.push(T.envMapCubeUVHeight),E.push(T.mapUv),E.push(T.alphaMapUv),E.push(T.lightMapUv),E.push(T.aoMapUv),E.push(T.bumpMapUv),E.push(T.normalMapUv),E.push(T.displacementMapUv),E.push(T.emissiveMapUv),E.push(T.metalnessMapUv),E.push(T.roughnessMapUv),E.push(T.anisotropyMapUv),E.push(T.clearcoatMapUv),E.push(T.clearcoatNormalMapUv),E.push(T.clearcoatRoughnessMapUv),E.push(T.iridescenceMapUv),E.push(T.iridescenceThicknessMapUv),E.push(T.sheenColorMapUv),E.push(T.sheenRoughnessMapUv),E.push(T.specularMapUv),E.push(T.specularColorMapUv),E.push(T.specularIntensityMapUv),E.push(T.transmissionMapUv),E.push(T.thicknessMapUv),E.push(T.combine),E.push(T.fogExp2),E.push(T.sizeAttenuation),E.push(T.morphTargetsCount),E.push(T.morphAttributeCount),E.push(T.numDirLights),E.push(T.numPointLights),E.push(T.numSpotLights),E.push(T.numSpotLightMaps),E.push(T.numHemiLights),E.push(T.numRectAreaLights),E.push(T.numDirLightShadows),E.push(T.numPointLightShadows),E.push(T.numSpotLightShadows),E.push(T.numSpotLightShadowsWithMaps),E.push(T.numLightProbes),E.push(T.shadowMapType),E.push(T.toneMapping),E.push(T.numClippingPlanes),E.push(T.numClipIntersection),E.push(T.depthPacking)}function x(E,T){o.disableAll(),T.supportsVertexTextures&&o.enable(0),T.instancing&&o.enable(1),T.instancingColor&&o.enable(2),T.instancingMorph&&o.enable(3),T.matcap&&o.enable(4),T.envMap&&o.enable(5),T.normalMapObjectSpace&&o.enable(6),T.normalMapTangentSpace&&o.enable(7),T.clearcoat&&o.enable(8),T.iridescence&&o.enable(9),T.alphaTest&&o.enable(10),T.vertexColors&&o.enable(11),T.vertexAlphas&&o.enable(12),T.vertexUv1s&&o.enable(13),T.vertexUv2s&&o.enable(14),T.vertexUv3s&&o.enable(15),T.vertexTangents&&o.enable(16),T.anisotropy&&o.enable(17),T.alphaHash&&o.enable(18),T.batching&&o.enable(19),T.dispersion&&o.enable(20),T.batchingColor&&o.enable(21),E.push(o.mask),o.disableAll(),T.fog&&o.enable(0),T.useFog&&o.enable(1),T.flatShading&&o.enable(2),T.logarithmicDepthBuffer&&o.enable(3),T.reverseDepthBuffer&&o.enable(4),T.skinning&&o.enable(5),T.morphTargets&&o.enable(6),T.morphNormals&&o.enable(7),T.morphColors&&o.enable(8),T.premultipliedAlpha&&o.enable(9),T.shadowMapEnabled&&o.enable(10),T.doubleSided&&o.enable(11),T.flipSided&&o.enable(12),T.useDepthPacking&&o.enable(13),T.dithering&&o.enable(14),T.transmission&&o.enable(15),T.sheen&&o.enable(16),T.opaque&&o.enable(17),T.pointsUvs&&o.enable(18),T.decodeVideoTexture&&o.enable(19),T.decodeVideoTextureEmissive&&o.enable(20),T.alphaToCoverage&&o.enable(21),E.push(o.mask)}function y(E){const T=g[E.type];let D;if(T){const X=ni[T];D=op.clone(X.uniforms)}else D=E.uniforms;return D}function N(E,T){let D;for(let X=0,j=u.length;X<j;X++){const se=u[X];if(se.cacheKey===T){D=se,++D.usedTimes;break}}return D===void 0&&(D=new Ay(s,T,E,r),u.push(D)),D}function P(E){if(--E.usedTimes===0){const T=u.indexOf(E);u[T]=u[u.length-1],u.pop(),E.destroy()}}function L(E){l.remove(E)}function U(){l.dispose()}return{getParameters:m,getProgramCacheKey:p,getUniforms:y,acquireProgram:N,releaseProgram:P,releaseShaderCache:L,programs:u,dispose:U}}function Ly(){let s=new WeakMap;function e(a){return s.has(a)}function t(a){let o=s.get(a);return o===void 0&&(o={},s.set(a,o)),o}function n(a){s.delete(a)}function i(a,o,l){s.get(a)[o]=l}function r(){s=new WeakMap}return{has:e,get:t,remove:n,update:i,dispose:r}}function Dy(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.material.id!==e.material.id?s.material.id-e.material.id:s.z!==e.z?s.z-e.z:s.id-e.id}function Su(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.z!==e.z?e.z-s.z:s.id-e.id}function Tu(){const s=[];let e=0;const t=[],n=[],i=[];function r(){e=0,t.length=0,n.length=0,i.length=0}function a(h,d,f,g,_,m){let p=s[e];return p===void 0?(p={id:h.id,object:h,geometry:d,material:f,groupOrder:g,renderOrder:h.renderOrder,z:_,group:m},s[e]=p):(p.id=h.id,p.object=h,p.geometry=d,p.material=f,p.groupOrder=g,p.renderOrder=h.renderOrder,p.z=_,p.group=m),e++,p}function o(h,d,f,g,_,m){const p=a(h,d,f,g,_,m);f.transmission>0?n.push(p):f.transparent===!0?i.push(p):t.push(p)}function l(h,d,f,g,_,m){const p=a(h,d,f,g,_,m);f.transmission>0?n.unshift(p):f.transparent===!0?i.unshift(p):t.unshift(p)}function c(h,d){t.length>1&&t.sort(h||Dy),n.length>1&&n.sort(d||Su),i.length>1&&i.sort(d||Su)}function u(){for(let h=e,d=s.length;h<d;h++){const f=s[h];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:t,transmissive:n,transparent:i,init:r,push:o,unshift:l,finish:u,sort:c}}function Iy(){let s=new WeakMap;function e(n,i){const r=s.get(n);let a;return r===void 0?(a=new Tu,s.set(n,[a])):i>=r.length?(a=new Tu,r.push(a)):a=r[i],a}function t(){s=new WeakMap}return{get:e,dispose:t}}function Ny(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new O,color:new He};break;case"SpotLight":t={position:new O,direction:new O,color:new He,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new O,color:new He,distance:0,decay:0};break;case"HemisphereLight":t={direction:new O,skyColor:new He,groundColor:new He};break;case"RectAreaLight":t={color:new He,position:new O,halfWidth:new O,halfHeight:new O};break}return s[e.id]=t,t}}}function Uy(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ot};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ot};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ot,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[e.id]=t,t}}}let Fy=0;function Oy(s,e){return(e.castShadow?2:0)-(s.castShadow?2:0)+(e.map?1:0)-(s.map?1:0)}function ky(s){const e=new Ny,t=Uy(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new O);const i=new O,r=new Fe,a=new Fe;function o(c){let u=0,h=0,d=0;for(let E=0;E<9;E++)n.probe[E].set(0,0,0);let f=0,g=0,_=0,m=0,p=0,S=0,x=0,y=0,N=0,P=0,L=0;c.sort(Oy);for(let E=0,T=c.length;E<T;E++){const D=c[E],X=D.color,j=D.intensity,se=D.distance,de=D.shadow&&D.shadow.map?D.shadow.map.texture:null;if(D.isAmbientLight)u+=X.r*j,h+=X.g*j,d+=X.b*j;else if(D.isLightProbe){for(let k=0;k<9;k++)n.probe[k].addScaledVector(D.sh.coefficients[k],j);L++}else if(D.isDirectionalLight){const k=e.get(D);if(k.color.copy(D.color).multiplyScalar(D.intensity),D.castShadow){const ae=D.shadow,G=t.get(D);G.shadowIntensity=ae.intensity,G.shadowBias=ae.bias,G.shadowNormalBias=ae.normalBias,G.shadowRadius=ae.radius,G.shadowMapSize=ae.mapSize,n.directionalShadow[f]=G,n.directionalShadowMap[f]=de,n.directionalShadowMatrix[f]=D.shadow.matrix,S++}n.directional[f]=k,f++}else if(D.isSpotLight){const k=e.get(D);k.position.setFromMatrixPosition(D.matrixWorld),k.color.copy(X).multiplyScalar(j),k.distance=se,k.coneCos=Math.cos(D.angle),k.penumbraCos=Math.cos(D.angle*(1-D.penumbra)),k.decay=D.decay,n.spot[_]=k;const ae=D.shadow;if(D.map&&(n.spotLightMap[N]=D.map,N++,ae.updateMatrices(D),D.castShadow&&P++),n.spotLightMatrix[_]=ae.matrix,D.castShadow){const G=t.get(D);G.shadowIntensity=ae.intensity,G.shadowBias=ae.bias,G.shadowNormalBias=ae.normalBias,G.shadowRadius=ae.radius,G.shadowMapSize=ae.mapSize,n.spotShadow[_]=G,n.spotShadowMap[_]=de,y++}_++}else if(D.isRectAreaLight){const k=e.get(D);k.color.copy(X).multiplyScalar(j),k.halfWidth.set(D.width*.5,0,0),k.halfHeight.set(0,D.height*.5,0),n.rectArea[m]=k,m++}else if(D.isPointLight){const k=e.get(D);if(k.color.copy(D.color).multiplyScalar(D.intensity),k.distance=D.distance,k.decay=D.decay,D.castShadow){const ae=D.shadow,G=t.get(D);G.shadowIntensity=ae.intensity,G.shadowBias=ae.bias,G.shadowNormalBias=ae.normalBias,G.shadowRadius=ae.radius,G.shadowMapSize=ae.mapSize,G.shadowCameraNear=ae.camera.near,G.shadowCameraFar=ae.camera.far,n.pointShadow[g]=G,n.pointShadowMap[g]=de,n.pointShadowMatrix[g]=D.shadow.matrix,x++}n.point[g]=k,g++}else if(D.isHemisphereLight){const k=e.get(D);k.skyColor.copy(D.color).multiplyScalar(j),k.groundColor.copy(D.groundColor).multiplyScalar(j),n.hemi[p]=k,p++}}m>0&&(s.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=Ie.LTC_FLOAT_1,n.rectAreaLTC2=Ie.LTC_FLOAT_2):(n.rectAreaLTC1=Ie.LTC_HALF_1,n.rectAreaLTC2=Ie.LTC_HALF_2)),n.ambient[0]=u,n.ambient[1]=h,n.ambient[2]=d;const U=n.hash;(U.directionalLength!==f||U.pointLength!==g||U.spotLength!==_||U.rectAreaLength!==m||U.hemiLength!==p||U.numDirectionalShadows!==S||U.numPointShadows!==x||U.numSpotShadows!==y||U.numSpotMaps!==N||U.numLightProbes!==L)&&(n.directional.length=f,n.spot.length=_,n.rectArea.length=m,n.point.length=g,n.hemi.length=p,n.directionalShadow.length=S,n.directionalShadowMap.length=S,n.pointShadow.length=x,n.pointShadowMap.length=x,n.spotShadow.length=y,n.spotShadowMap.length=y,n.directionalShadowMatrix.length=S,n.pointShadowMatrix.length=x,n.spotLightMatrix.length=y+N-P,n.spotLightMap.length=N,n.numSpotLightShadowsWithMaps=P,n.numLightProbes=L,U.directionalLength=f,U.pointLength=g,U.spotLength=_,U.rectAreaLength=m,U.hemiLength=p,U.numDirectionalShadows=S,U.numPointShadows=x,U.numSpotShadows=y,U.numSpotMaps=N,U.numLightProbes=L,n.version=Fy++)}function l(c,u){let h=0,d=0,f=0,g=0,_=0;const m=u.matrixWorldInverse;for(let p=0,S=c.length;p<S;p++){const x=c[p];if(x.isDirectionalLight){const y=n.directional[h];y.direction.setFromMatrixPosition(x.matrixWorld),i.setFromMatrixPosition(x.target.matrixWorld),y.direction.sub(i),y.direction.transformDirection(m),h++}else if(x.isSpotLight){const y=n.spot[f];y.position.setFromMatrixPosition(x.matrixWorld),y.position.applyMatrix4(m),y.direction.setFromMatrixPosition(x.matrixWorld),i.setFromMatrixPosition(x.target.matrixWorld),y.direction.sub(i),y.direction.transformDirection(m),f++}else if(x.isRectAreaLight){const y=n.rectArea[g];y.position.setFromMatrixPosition(x.matrixWorld),y.position.applyMatrix4(m),a.identity(),r.copy(x.matrixWorld),r.premultiply(m),a.extractRotation(r),y.halfWidth.set(x.width*.5,0,0),y.halfHeight.set(0,x.height*.5,0),y.halfWidth.applyMatrix4(a),y.halfHeight.applyMatrix4(a),g++}else if(x.isPointLight){const y=n.point[d];y.position.setFromMatrixPosition(x.matrixWorld),y.position.applyMatrix4(m),d++}else if(x.isHemisphereLight){const y=n.hemi[_];y.direction.setFromMatrixPosition(x.matrixWorld),y.direction.transformDirection(m),_++}}}return{setup:o,setupView:l,state:n}}function bu(s){const e=new ky(s),t=[],n=[];function i(u){c.camera=u,t.length=0,n.length=0}function r(u){t.push(u)}function a(u){n.push(u)}function o(){e.setup(t)}function l(u){e.setupView(t,u)}const c={lightsArray:t,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:c,setupLights:o,setupLightsView:l,pushLight:r,pushShadow:a}}function By(s){let e=new WeakMap;function t(i,r=0){const a=e.get(i);let o;return a===void 0?(o=new bu(s),e.set(i,[o])):r>=a.length?(o=new bu(s),a.push(o)):o=a[r],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const zy=`void main() {
3774
+ `+oe+`
3775
+ `+G)}else X!==""?console.warn("THREE.WebGLProgram: Program Info Log:",X):(q===""||se==="")&&(k=!1);k&&(D.diagnostics={runnable:he,programLog:X,vertexShader:{log:q,prefix:m},fragmentShader:{log:se,prefix:p}})}i.deleteShader(N),i.deleteShader(P),U=new Sa(i,_),E=my(i,_)}let U;this.getUniforms=function(){return U===void 0&&L(this),U};let E;this.getAttributes=function(){return E===void 0&&L(this),E};let T=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return T===!1&&(T=i.getProgramParameter(_,ay)),T},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=oy++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=N,this.fragmentShader=P,this}let wy=0;class Ry{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(i)===!1&&(a.add(i),i.usedTimes++),a.has(r)===!1&&(a.add(r),r.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 Cy(e),t.set(e,n)),n}}class Cy{constructor(e){this.id=wy++,this.code=e,this.usedTimes=0}}function Py(s,e,t,n,i,r,a){const o=new ah,l=new Ry,c=new Set,u=[],h=i.logarithmicDepthBuffer,d=i.vertexTextures;let f=i.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 _(E){return c.add(E),E===0?"uv":`uv${E}`}function m(E,T,D,X,q){const se=X.fog,he=q.geometry,k=E.isMeshStandardMaterial?X.environment:null,oe=(E.isMeshStandardMaterial?t:e).get(E.envMap||k),G=oe&&oe.mapping===Na?oe.image.height:null,fe=g[E.type];E.precision!==null&&(f=i.getMaxPrecision(E.precision),f!==E.precision&&console.warn("THREE.WebGLProgram.getParameters:",E.precision,"not supported, using",f,"instead."));const ve=he.morphAttributes.position||he.morphAttributes.normal||he.morphAttributes.color,le=ve!==void 0?ve.length:0;let we=0;he.morphAttributes.position!==void 0&&(we=1),he.morphAttributes.normal!==void 0&&(we=2),he.morphAttributes.color!==void 0&&(we=3);let Me,W,ee,ae;if(fe){const pt=ii[fe];Me=pt.vertexShader,W=pt.fragmentShader}else Me=E.vertexShader,W=E.fragmentShader,l.update(E),ee=l.getVertexShaderID(E),ae=l.getFragmentShaderID(E);const re=s.getRenderTarget(),Se=s.state.buffers.depth.getReversed(),ot=q.isInstancedMesh===!0,J=q.isBatchedMesh===!0,$=!!E.map,Z=!!E.matcap,ie=!!oe,I=!!E.aoMap,Te=!!E.lightMap,de=!!E.bumpMap,qe=!!E.normalMap,De=!!E.displacementMap,Oe=!!E.emissiveMap,Ie=!!E.metalnessMap,tt=!!E.roughnessMap,Nt=E.anisotropy>0,F=E.clearcoat>0,b=E.dispersion>0,K=E.iridescence>0,ce=E.sheen>0,pe=E.transmission>0,ne=Nt&&!!E.anisotropyMap,ze=F&&!!E.clearcoatMap,Ae=F&&!!E.clearcoatNormalMap,We=F&&!!E.clearcoatRoughnessMap,Ye=K&&!!E.iridescenceMap,me=K&&!!E.iridescenceThicknessMap,ke=ce&&!!E.sheenColorMap,st=ce&&!!E.sheenRoughnessMap,nt=!!E.specularMap,be=!!E.specularColorMap,lt=!!E.specularIntensityMap,B=pe&&!!E.transmissionMap,Re=pe&&!!E.thicknessMap,ge=!!E.gradientMap,Be=!!E.alphaMap,ye=E.alphaTest>0,j=!!E.alphaHash,Ce=!!E.extensions;let Ze=Gi;E.toneMapped&&(re===null||re.isXRRenderTarget===!0)&&(Ze=s.toneMapping);const bt={shaderID:fe,shaderType:E.type,shaderName:E.name,vertexShader:Me,fragmentShader:W,defines:E.defines,customVertexShaderID:ee,customFragmentShaderID:ae,isRawShaderMaterial:E.isRawShaderMaterial===!0,glslVersion:E.glslVersion,precision:f,batching:J,batchingColor:J&&q._colorsTexture!==null,instancing:ot,instancingColor:ot&&q.instanceColor!==null,instancingMorph:ot&&q.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:re===null?s.outputColorSpace:re.isXRRenderTarget===!0?re.texture.colorSpace:An,alphaToCoverage:!!E.alphaToCoverage,map:$,matcap:Z,envMap:ie,envMapMode:ie&&oe.mapping,envMapCubeUVHeight:G,aoMap:I,lightMap:Te,bumpMap:de,normalMap:qe,displacementMap:d&&De,emissiveMap:Oe,normalMapObjectSpace:qe&&E.normalMapType===mf,normalMapTangentSpace:qe&&E.normalMapType===Ua,metalnessMap:Ie,roughnessMap:tt,anisotropy:Nt,anisotropyMap:ne,clearcoat:F,clearcoatMap:ze,clearcoatNormalMap:Ae,clearcoatRoughnessMap:We,dispersion:b,iridescence:K,iridescenceMap:Ye,iridescenceThicknessMap:me,sheen:ce,sheenColorMap:ke,sheenRoughnessMap:st,specularMap:nt,specularColorMap:be,specularIntensityMap:lt,transmission:pe,transmissionMap:B,thicknessMap:Re,gradientMap:ge,opaque:E.transparent===!1&&E.blending===Os&&E.alphaToCoverage===!1,alphaMap:Be,alphaTest:ye,alphaHash:j,combine:E.combine,mapUv:$&&_(E.map.channel),aoMapUv:I&&_(E.aoMap.channel),lightMapUv:Te&&_(E.lightMap.channel),bumpMapUv:de&&_(E.bumpMap.channel),normalMapUv:qe&&_(E.normalMap.channel),displacementMapUv:De&&_(E.displacementMap.channel),emissiveMapUv:Oe&&_(E.emissiveMap.channel),metalnessMapUv:Ie&&_(E.metalnessMap.channel),roughnessMapUv:tt&&_(E.roughnessMap.channel),anisotropyMapUv:ne&&_(E.anisotropyMap.channel),clearcoatMapUv:ze&&_(E.clearcoatMap.channel),clearcoatNormalMapUv:Ae&&_(E.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:We&&_(E.clearcoatRoughnessMap.channel),iridescenceMapUv:Ye&&_(E.iridescenceMap.channel),iridescenceThicknessMapUv:me&&_(E.iridescenceThicknessMap.channel),sheenColorMapUv:ke&&_(E.sheenColorMap.channel),sheenRoughnessMapUv:st&&_(E.sheenRoughnessMap.channel),specularMapUv:nt&&_(E.specularMap.channel),specularColorMapUv:be&&_(E.specularColorMap.channel),specularIntensityMapUv:lt&&_(E.specularIntensityMap.channel),transmissionMapUv:B&&_(E.transmissionMap.channel),thicknessMapUv:Re&&_(E.thicknessMap.channel),alphaMapUv:Be&&_(E.alphaMap.channel),vertexTangents:!!he.attributes.tangent&&(qe||Nt),vertexColors:E.vertexColors,vertexAlphas:E.vertexColors===!0&&!!he.attributes.color&&he.attributes.color.itemSize===4,pointsUvs:q.isPoints===!0&&!!he.attributes.uv&&($||Be),fog:!!se,useFog:E.fog===!0,fogExp2:!!se&&se.isFogExp2,flatShading:E.flatShading===!0,sizeAttenuation:E.sizeAttenuation===!0,logarithmicDepthBuffer:h,reverseDepthBuffer:Se,skinning:q.isSkinnedMesh===!0,morphTargets:he.morphAttributes.position!==void 0,morphNormals:he.morphAttributes.normal!==void 0,morphColors:he.morphAttributes.color!==void 0,morphTargetsCount:le,morphTextureStride:we,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numSpotLightShadowsWithMaps:T.numSpotLightShadowsWithMaps,numLightProbes:T.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:E.dithering,shadowMapEnabled:s.shadowMap.enabled&&D.length>0,shadowMapType:s.shadowMap.type,toneMapping:Ze,decodeVideoTexture:$&&E.map.isVideoTexture===!0&&ft.getTransfer(E.map.colorSpace)===Ut,decodeVideoTextureEmissive:Oe&&E.emissiveMap.isVideoTexture===!0&&ft.getTransfer(E.emissiveMap.colorSpace)===Ut,premultipliedAlpha:E.premultipliedAlpha,doubleSided:E.side===Zn,flipSided:E.side===In,useDepthPacking:E.depthPacking>=0,depthPacking:E.depthPacking||0,index0AttributeName:E.index0AttributeName,extensionClipCullDistance:Ce&&E.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ce&&E.extensions.multiDraw===!0||J)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:E.customProgramCacheKey()};return bt.vertexUv1s=c.has(1),bt.vertexUv2s=c.has(2),bt.vertexUv3s=c.has(3),c.clear(),bt}function p(E){const T=[];if(E.shaderID?T.push(E.shaderID):(T.push(E.customVertexShaderID),T.push(E.customFragmentShaderID)),E.defines!==void 0)for(const D in E.defines)T.push(D),T.push(E.defines[D]);return E.isRawShaderMaterial===!1&&(S(T,E),v(T,E),T.push(s.outputColorSpace)),T.push(E.customProgramCacheKey),T.join()}function S(E,T){E.push(T.precision),E.push(T.outputColorSpace),E.push(T.envMapMode),E.push(T.envMapCubeUVHeight),E.push(T.mapUv),E.push(T.alphaMapUv),E.push(T.lightMapUv),E.push(T.aoMapUv),E.push(T.bumpMapUv),E.push(T.normalMapUv),E.push(T.displacementMapUv),E.push(T.emissiveMapUv),E.push(T.metalnessMapUv),E.push(T.roughnessMapUv),E.push(T.anisotropyMapUv),E.push(T.clearcoatMapUv),E.push(T.clearcoatNormalMapUv),E.push(T.clearcoatRoughnessMapUv),E.push(T.iridescenceMapUv),E.push(T.iridescenceThicknessMapUv),E.push(T.sheenColorMapUv),E.push(T.sheenRoughnessMapUv),E.push(T.specularMapUv),E.push(T.specularColorMapUv),E.push(T.specularIntensityMapUv),E.push(T.transmissionMapUv),E.push(T.thicknessMapUv),E.push(T.combine),E.push(T.fogExp2),E.push(T.sizeAttenuation),E.push(T.morphTargetsCount),E.push(T.morphAttributeCount),E.push(T.numDirLights),E.push(T.numPointLights),E.push(T.numSpotLights),E.push(T.numSpotLightMaps),E.push(T.numHemiLights),E.push(T.numRectAreaLights),E.push(T.numDirLightShadows),E.push(T.numPointLightShadows),E.push(T.numSpotLightShadows),E.push(T.numSpotLightShadowsWithMaps),E.push(T.numLightProbes),E.push(T.shadowMapType),E.push(T.toneMapping),E.push(T.numClippingPlanes),E.push(T.numClipIntersection),E.push(T.depthPacking)}function v(E,T){o.disableAll(),T.supportsVertexTextures&&o.enable(0),T.instancing&&o.enable(1),T.instancingColor&&o.enable(2),T.instancingMorph&&o.enable(3),T.matcap&&o.enable(4),T.envMap&&o.enable(5),T.normalMapObjectSpace&&o.enable(6),T.normalMapTangentSpace&&o.enable(7),T.clearcoat&&o.enable(8),T.iridescence&&o.enable(9),T.alphaTest&&o.enable(10),T.vertexColors&&o.enable(11),T.vertexAlphas&&o.enable(12),T.vertexUv1s&&o.enable(13),T.vertexUv2s&&o.enable(14),T.vertexUv3s&&o.enable(15),T.vertexTangents&&o.enable(16),T.anisotropy&&o.enable(17),T.alphaHash&&o.enable(18),T.batching&&o.enable(19),T.dispersion&&o.enable(20),T.batchingColor&&o.enable(21),E.push(o.mask),o.disableAll(),T.fog&&o.enable(0),T.useFog&&o.enable(1),T.flatShading&&o.enable(2),T.logarithmicDepthBuffer&&o.enable(3),T.reverseDepthBuffer&&o.enable(4),T.skinning&&o.enable(5),T.morphTargets&&o.enable(6),T.morphNormals&&o.enable(7),T.morphColors&&o.enable(8),T.premultipliedAlpha&&o.enable(9),T.shadowMapEnabled&&o.enable(10),T.doubleSided&&o.enable(11),T.flipSided&&o.enable(12),T.useDepthPacking&&o.enable(13),T.dithering&&o.enable(14),T.transmission&&o.enable(15),T.sheen&&o.enable(16),T.opaque&&o.enable(17),T.pointsUvs&&o.enable(18),T.decodeVideoTexture&&o.enable(19),T.decodeVideoTextureEmissive&&o.enable(20),T.alphaToCoverage&&o.enable(21),E.push(o.mask)}function y(E){const T=g[E.type];let D;if(T){const X=ii[T];D=op.clone(X.uniforms)}else D=E.uniforms;return D}function N(E,T){let D;for(let X=0,q=u.length;X<q;X++){const se=u[X];if(se.cacheKey===T){D=se,++D.usedTimes;break}}return D===void 0&&(D=new Ay(s,T,E,r),u.push(D)),D}function P(E){if(--E.usedTimes===0){const T=u.indexOf(E);u[T]=u[u.length-1],u.pop(),E.destroy()}}function L(E){l.remove(E)}function U(){l.dispose()}return{getParameters:m,getProgramCacheKey:p,getUniforms:y,acquireProgram:N,releaseProgram:P,releaseShaderCache:L,programs:u,dispose:U}}function Ly(){let s=new WeakMap;function e(a){return s.has(a)}function t(a){let o=s.get(a);return o===void 0&&(o={},s.set(a,o)),o}function n(a){s.delete(a)}function i(a,o,l){s.get(a)[o]=l}function r(){s=new WeakMap}return{has:e,get:t,remove:n,update:i,dispose:r}}function Dy(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.material.id!==e.material.id?s.material.id-e.material.id:s.z!==e.z?s.z-e.z:s.id-e.id}function Su(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.z!==e.z?e.z-s.z:s.id-e.id}function Tu(){const s=[];let e=0;const t=[],n=[],i=[];function r(){e=0,t.length=0,n.length=0,i.length=0}function a(h,d,f,g,_,m){let p=s[e];return p===void 0?(p={id:h.id,object:h,geometry:d,material:f,groupOrder:g,renderOrder:h.renderOrder,z:_,group:m},s[e]=p):(p.id=h.id,p.object=h,p.geometry=d,p.material=f,p.groupOrder=g,p.renderOrder=h.renderOrder,p.z=_,p.group=m),e++,p}function o(h,d,f,g,_,m){const p=a(h,d,f,g,_,m);f.transmission>0?n.push(p):f.transparent===!0?i.push(p):t.push(p)}function l(h,d,f,g,_,m){const p=a(h,d,f,g,_,m);f.transmission>0?n.unshift(p):f.transparent===!0?i.unshift(p):t.unshift(p)}function c(h,d){t.length>1&&t.sort(h||Dy),n.length>1&&n.sort(d||Su),i.length>1&&i.sort(d||Su)}function u(){for(let h=e,d=s.length;h<d;h++){const f=s[h];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:t,transmissive:n,transparent:i,init:r,push:o,unshift:l,finish:u,sort:c}}function Iy(){let s=new WeakMap;function e(n,i){const r=s.get(n);let a;return r===void 0?(a=new Tu,s.set(n,[a])):i>=r.length?(a=new Tu,r.push(a)):a=r[i],a}function t(){s=new WeakMap}return{get:e,dispose:t}}function Ny(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new O,color:new Ge};break;case"SpotLight":t={position:new O,direction:new O,color:new Ge,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new O,color:new Ge,distance:0,decay:0};break;case"HemisphereLight":t={direction:new O,skyColor:new Ge,groundColor:new Ge};break;case"RectAreaLight":t={color:new Ge,position:new O,halfWidth:new O,halfHeight:new O};break}return s[e.id]=t,t}}}function Uy(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ct};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ct};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ct,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[e.id]=t,t}}}let Fy=0;function Oy(s,e){return(e.castShadow?2:0)-(s.castShadow?2:0)+(e.map?1:0)-(s.map?1:0)}function ky(s){const e=new Ny,t=Uy(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new O);const i=new O,r=new Fe,a=new Fe;function o(c){let u=0,h=0,d=0;for(let E=0;E<9;E++)n.probe[E].set(0,0,0);let f=0,g=0,_=0,m=0,p=0,S=0,v=0,y=0,N=0,P=0,L=0;c.sort(Oy);for(let E=0,T=c.length;E<T;E++){const D=c[E],X=D.color,q=D.intensity,se=D.distance,he=D.shadow&&D.shadow.map?D.shadow.map.texture:null;if(D.isAmbientLight)u+=X.r*q,h+=X.g*q,d+=X.b*q;else if(D.isLightProbe){for(let k=0;k<9;k++)n.probe[k].addScaledVector(D.sh.coefficients[k],q);L++}else if(D.isDirectionalLight){const k=e.get(D);if(k.color.copy(D.color).multiplyScalar(D.intensity),D.castShadow){const oe=D.shadow,G=t.get(D);G.shadowIntensity=oe.intensity,G.shadowBias=oe.bias,G.shadowNormalBias=oe.normalBias,G.shadowRadius=oe.radius,G.shadowMapSize=oe.mapSize,n.directionalShadow[f]=G,n.directionalShadowMap[f]=he,n.directionalShadowMatrix[f]=D.shadow.matrix,S++}n.directional[f]=k,f++}else if(D.isSpotLight){const k=e.get(D);k.position.setFromMatrixPosition(D.matrixWorld),k.color.copy(X).multiplyScalar(q),k.distance=se,k.coneCos=Math.cos(D.angle),k.penumbraCos=Math.cos(D.angle*(1-D.penumbra)),k.decay=D.decay,n.spot[_]=k;const oe=D.shadow;if(D.map&&(n.spotLightMap[N]=D.map,N++,oe.updateMatrices(D),D.castShadow&&P++),n.spotLightMatrix[_]=oe.matrix,D.castShadow){const G=t.get(D);G.shadowIntensity=oe.intensity,G.shadowBias=oe.bias,G.shadowNormalBias=oe.normalBias,G.shadowRadius=oe.radius,G.shadowMapSize=oe.mapSize,n.spotShadow[_]=G,n.spotShadowMap[_]=he,y++}_++}else if(D.isRectAreaLight){const k=e.get(D);k.color.copy(X).multiplyScalar(q),k.halfWidth.set(D.width*.5,0,0),k.halfHeight.set(0,D.height*.5,0),n.rectArea[m]=k,m++}else if(D.isPointLight){const k=e.get(D);if(k.color.copy(D.color).multiplyScalar(D.intensity),k.distance=D.distance,k.decay=D.decay,D.castShadow){const oe=D.shadow,G=t.get(D);G.shadowIntensity=oe.intensity,G.shadowBias=oe.bias,G.shadowNormalBias=oe.normalBias,G.shadowRadius=oe.radius,G.shadowMapSize=oe.mapSize,G.shadowCameraNear=oe.camera.near,G.shadowCameraFar=oe.camera.far,n.pointShadow[g]=G,n.pointShadowMap[g]=he,n.pointShadowMatrix[g]=D.shadow.matrix,v++}n.point[g]=k,g++}else if(D.isHemisphereLight){const k=e.get(D);k.skyColor.copy(D.color).multiplyScalar(q),k.groundColor.copy(D.groundColor).multiplyScalar(q),n.hemi[p]=k,p++}}m>0&&(s.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=Le.LTC_FLOAT_1,n.rectAreaLTC2=Le.LTC_FLOAT_2):(n.rectAreaLTC1=Le.LTC_HALF_1,n.rectAreaLTC2=Le.LTC_HALF_2)),n.ambient[0]=u,n.ambient[1]=h,n.ambient[2]=d;const U=n.hash;(U.directionalLength!==f||U.pointLength!==g||U.spotLength!==_||U.rectAreaLength!==m||U.hemiLength!==p||U.numDirectionalShadows!==S||U.numPointShadows!==v||U.numSpotShadows!==y||U.numSpotMaps!==N||U.numLightProbes!==L)&&(n.directional.length=f,n.spot.length=_,n.rectArea.length=m,n.point.length=g,n.hemi.length=p,n.directionalShadow.length=S,n.directionalShadowMap.length=S,n.pointShadow.length=v,n.pointShadowMap.length=v,n.spotShadow.length=y,n.spotShadowMap.length=y,n.directionalShadowMatrix.length=S,n.pointShadowMatrix.length=v,n.spotLightMatrix.length=y+N-P,n.spotLightMap.length=N,n.numSpotLightShadowsWithMaps=P,n.numLightProbes=L,U.directionalLength=f,U.pointLength=g,U.spotLength=_,U.rectAreaLength=m,U.hemiLength=p,U.numDirectionalShadows=S,U.numPointShadows=v,U.numSpotShadows=y,U.numSpotMaps=N,U.numLightProbes=L,n.version=Fy++)}function l(c,u){let h=0,d=0,f=0,g=0,_=0;const m=u.matrixWorldInverse;for(let p=0,S=c.length;p<S;p++){const v=c[p];if(v.isDirectionalLight){const y=n.directional[h];y.direction.setFromMatrixPosition(v.matrixWorld),i.setFromMatrixPosition(v.target.matrixWorld),y.direction.sub(i),y.direction.transformDirection(m),h++}else if(v.isSpotLight){const y=n.spot[f];y.position.setFromMatrixPosition(v.matrixWorld),y.position.applyMatrix4(m),y.direction.setFromMatrixPosition(v.matrixWorld),i.setFromMatrixPosition(v.target.matrixWorld),y.direction.sub(i),y.direction.transformDirection(m),f++}else if(v.isRectAreaLight){const y=n.rectArea[g];y.position.setFromMatrixPosition(v.matrixWorld),y.position.applyMatrix4(m),a.identity(),r.copy(v.matrixWorld),r.premultiply(m),a.extractRotation(r),y.halfWidth.set(v.width*.5,0,0),y.halfHeight.set(0,v.height*.5,0),y.halfWidth.applyMatrix4(a),y.halfHeight.applyMatrix4(a),g++}else if(v.isPointLight){const y=n.point[d];y.position.setFromMatrixPosition(v.matrixWorld),y.position.applyMatrix4(m),d++}else if(v.isHemisphereLight){const y=n.hemi[_];y.direction.setFromMatrixPosition(v.matrixWorld),y.direction.transformDirection(m),_++}}}return{setup:o,setupView:l,state:n}}function bu(s){const e=new ky(s),t=[],n=[];function i(u){c.camera=u,t.length=0,n.length=0}function r(u){t.push(u)}function a(u){n.push(u)}function o(){e.setup(t)}function l(u){e.setupView(t,u)}const c={lightsArray:t,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:c,setupLights:o,setupLightsView:l,pushLight:r,pushShadow:a}}function By(s){let e=new WeakMap;function t(i,r=0){const a=e.get(i);let o;return a===void 0?(o=new bu(s),e.set(i,[o])):r>=a.length?(o=new bu(s),a.push(o)):o=a[r],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const zy=`void main() {
3776
3776
  gl_Position = vec4( position, 1.0 );
3777
3777
  }`,Vy=`uniform sampler2D shadow_pass;
3778
3778
  uniform vec2 resolution;
@@ -3800,7 +3800,7 @@ void main() {
3800
3800
  squared_mean = squared_mean / samples;
3801
3801
  float std_dev = sqrt( squared_mean - mean * mean );
3802
3802
  gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3803
- }`;function Hy(s,e,t){let n=new Gl;const i=new ot,r=new ot,a=new Tt,o=new zp({depthPacking:pf}),l=new Vp,c={},u=t.maxTextureSize,h={[si]:Ln,[Ln]:si,[Yn]:Yn},d=new Wi({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ot},radius:{value:4}},vertexShader:zy,fragmentShader:Vy}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const g=new Kt;g.setAttribute("position",new un(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new sn(g,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Xu;let p=this.type;this.render=function(P,L,U){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||P.length===0)return;const E=s.getRenderTarget(),T=s.getActiveCubeFace(),D=s.getActiveMipmapLevel(),X=s.state;X.setBlending(Hi),X.buffers.color.setClear(1,1,1,1),X.buffers.depth.setTest(!0),X.setScissorTest(!1);const j=p!==xi&&this.type===xi,se=p===xi&&this.type!==xi;for(let de=0,k=P.length;de<k;de++){const ae=P[de],G=ae.shadow;if(G===void 0){console.warn("THREE.WebGLShadowMap:",ae,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;i.copy(G.mapSize);const pe=G.getFrameExtents();if(i.multiply(pe),r.copy(G.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(r.x=Math.floor(u/pe.x),i.x=r.x*pe.x,G.mapSize.x=r.x),i.y>u&&(r.y=Math.floor(u/pe.y),i.y=r.y*pe.y,G.mapSize.y=r.y)),G.map===null||j===!0||se===!0){const le=this.type!==xi?{minFilter:Sn,magFilter:Sn}:{};G.map!==null&&G.map.dispose(),G.map=new cs(i.x,i.y,le),G.map.texture.name=ae.name+".shadowMap",G.camera.updateProjectionMatrix()}s.setRenderTarget(G.map),s.clear();const Me=G.getViewportCount();for(let le=0;le<Me;le++){const we=G.getViewport(le);a.set(r.x*we.x,r.y*we.y,r.x*we.z,r.y*we.w),X.viewport(a),G.updateMatrices(ae,le),n=G.getFrustum(),y(L,U,G.camera,ae,this.type)}G.isPointLightShadow!==!0&&this.type===xi&&S(G,U),G.needsUpdate=!1}p=this.type,m.needsUpdate=!1,s.setRenderTarget(E,T,D)};function S(P,L){const U=e.update(_);d.defines.VSM_SAMPLES!==P.blurSamples&&(d.defines.VSM_SAMPLES=P.blurSamples,f.defines.VSM_SAMPLES=P.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),P.mapPass===null&&(P.mapPass=new cs(i.x,i.y)),d.uniforms.shadow_pass.value=P.map.texture,d.uniforms.resolution.value=P.mapSize,d.uniforms.radius.value=P.radius,s.setRenderTarget(P.mapPass),s.clear(),s.renderBufferDirect(L,null,U,d,_,null),f.uniforms.shadow_pass.value=P.mapPass.texture,f.uniforms.resolution.value=P.mapSize,f.uniforms.radius.value=P.radius,s.setRenderTarget(P.map),s.clear(),s.renderBufferDirect(L,null,U,f,_,null)}function x(P,L,U,E){let T=null;const D=U.isPointLight===!0?P.customDistanceMaterial:P.customDepthMaterial;if(D!==void 0)T=D;else if(T=U.isPointLight===!0?l:o,s.localClippingEnabled&&L.clipShadows===!0&&Array.isArray(L.clippingPlanes)&&L.clippingPlanes.length!==0||L.displacementMap&&L.displacementScale!==0||L.alphaMap&&L.alphaTest>0||L.map&&L.alphaTest>0||L.alphaToCoverage===!0){const X=T.uuid,j=L.uuid;let se=c[X];se===void 0&&(se={},c[X]=se);let de=se[j];de===void 0&&(de=T.clone(),se[j]=de,L.addEventListener("dispose",N)),T=de}if(T.visible=L.visible,T.wireframe=L.wireframe,E===xi?T.side=L.shadowSide!==null?L.shadowSide:L.side:T.side=L.shadowSide!==null?L.shadowSide:h[L.side],T.alphaMap=L.alphaMap,T.alphaTest=L.alphaToCoverage===!0?.5:L.alphaTest,T.map=L.map,T.clipShadows=L.clipShadows,T.clippingPlanes=L.clippingPlanes,T.clipIntersection=L.clipIntersection,T.displacementMap=L.displacementMap,T.displacementScale=L.displacementScale,T.displacementBias=L.displacementBias,T.wireframeLinewidth=L.wireframeLinewidth,T.linewidth=L.linewidth,U.isPointLight===!0&&T.isMeshDistanceMaterial===!0){const X=s.properties.get(T);X.light=U}return T}function y(P,L,U,E,T){if(P.visible===!1)return;if(P.layers.test(L.layers)&&(P.isMesh||P.isLine||P.isPoints)&&(P.castShadow||P.receiveShadow&&T===xi)&&(!P.frustumCulled||n.intersectsObject(P))){P.modelViewMatrix.multiplyMatrices(U.matrixWorldInverse,P.matrixWorld);const j=e.update(P),se=P.material;if(Array.isArray(se)){const de=j.groups;for(let k=0,ae=de.length;k<ae;k++){const G=de[k],pe=se[G.materialIndex];if(pe&&pe.visible){const Me=x(P,pe,E,T);P.onBeforeShadow(s,P,L,U,j,Me,G),s.renderBufferDirect(U,null,j,Me,P,G),P.onAfterShadow(s,P,L,U,j,Me,G)}}}else if(se.visible){const de=x(P,se,E,T);P.onBeforeShadow(s,P,L,U,j,de,null),s.renderBufferDirect(U,null,j,de,P,null),P.onAfterShadow(s,P,L,U,j,de,null)}}const X=P.children;for(let j=0,se=X.length;j<se;j++)y(X[j],L,U,E,T)}function N(P){P.target.removeEventListener("dispose",N);for(const U in c){const E=c[U],T=P.target.uuid;T in E&&(E[T].dispose(),delete E[T])}}}const Gy={[Fo]:Oo,[ko]:Vo,[Bo]:Ho,[zs]:zo,[Oo]:Fo,[Vo]:ko,[Ho]:Bo,[zo]:zs};function Wy(s,e){function t(){let B=!1;const Pe=new Tt;let ye=null;const Be=new Tt(0,0,0,0);return{setMask:function(Y){ye!==Y&&!B&&(s.colorMask(Y,Y,Y,Y),ye=Y)},setLocked:function(Y){B=Y},setClear:function(Y,ce,Ce,tt,Lt){Lt===!0&&(Y*=tt,ce*=tt,Ce*=tt),Pe.set(Y,ce,Ce,tt),Be.equals(Pe)===!1&&(s.clearColor(Y,ce,Ce,tt),Be.copy(Pe))},reset:function(){B=!1,ye=null,Be.set(-1,0,0,0)}}}function n(){let B=!1,Pe=!1,ye=null,Be=null,Y=null;return{setReversed:function(ce){if(Pe!==ce){const Ce=e.get("EXT_clip_control");ce?Ce.clipControlEXT(Ce.LOWER_LEFT_EXT,Ce.ZERO_TO_ONE_EXT):Ce.clipControlEXT(Ce.LOWER_LEFT_EXT,Ce.NEGATIVE_ONE_TO_ONE_EXT),Pe=ce;const tt=Y;Y=null,this.setClear(tt)}},getReversed:function(){return Pe},setTest:function(ce){ce?oe(s.DEPTH_TEST):Te(s.DEPTH_TEST)},setMask:function(ce){ye!==ce&&!B&&(s.depthMask(ce),ye=ce)},setFunc:function(ce){if(Pe&&(ce=Gy[ce]),Be!==ce){switch(ce){case Fo:s.depthFunc(s.NEVER);break;case Oo:s.depthFunc(s.ALWAYS);break;case ko:s.depthFunc(s.LESS);break;case zs:s.depthFunc(s.LEQUAL);break;case Bo:s.depthFunc(s.EQUAL);break;case zo:s.depthFunc(s.GEQUAL);break;case Vo:s.depthFunc(s.GREATER);break;case Ho:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}Be=ce}},setLocked:function(ce){B=ce},setClear:function(ce){Y!==ce&&(Pe&&(ce=1-ce),s.clearDepth(ce),Y=ce)},reset:function(){B=!1,ye=null,Be=null,Y=null,Pe=!1}}}function i(){let B=!1,Pe=null,ye=null,Be=null,Y=null,ce=null,Ce=null,tt=null,Lt=null;return{setTest:function(ft){B||(ft?oe(s.STENCIL_TEST):Te(s.STENCIL_TEST))},setMask:function(ft){Pe!==ft&&!B&&(s.stencilMask(ft),Pe=ft)},setFunc:function(ft,We,Le){(ye!==ft||Be!==We||Y!==Le)&&(s.stencilFunc(ft,We,Le),ye=ft,Be=We,Y=Le)},setOp:function(ft,We,Le){(ce!==ft||Ce!==We||tt!==Le)&&(s.stencilOp(ft,We,Le),ce=ft,Ce=We,tt=Le)},setLocked:function(ft){B=ft},setClear:function(ft){Lt!==ft&&(s.clearStencil(ft),Lt=ft)},reset:function(){B=!1,Pe=null,ye=null,Be=null,Y=null,ce=null,Ce=null,tt=null,Lt=null}}}const r=new t,a=new n,o=new i,l=new WeakMap,c=new WeakMap;let u={},h={},d=new WeakMap,f=[],g=null,_=!1,m=null,p=null,S=null,x=null,y=null,N=null,P=null,L=new He(0,0,0),U=0,E=!1,T=null,D=null,X=null,j=null,se=null;const de=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let k=!1,ae=0;const G=s.getParameter(s.VERSION);G.indexOf("WebGL")!==-1?(ae=parseFloat(/^WebGL (\d)/.exec(G)[1]),k=ae>=1):G.indexOf("OpenGL ES")!==-1&&(ae=parseFloat(/^OpenGL ES (\d)/.exec(G)[1]),k=ae>=2);let pe=null,Me={};const le=s.getParameter(s.SCISSOR_BOX),we=s.getParameter(s.VIEWPORT),be=new Tt().fromArray(le),W=new Tt().fromArray(we);function $(B,Pe,ye,Be){const Y=new Uint8Array(4),ce=s.createTexture();s.bindTexture(B,ce),s.texParameteri(B,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(B,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let Ce=0;Ce<ye;Ce++)B===s.TEXTURE_3D||B===s.TEXTURE_2D_ARRAY?s.texImage3D(Pe,0,s.RGBA,1,1,Be,0,s.RGBA,s.UNSIGNED_BYTE,Y):s.texImage2D(Pe+Ce,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,Y);return ce}const re={};re[s.TEXTURE_2D]=$(s.TEXTURE_2D,s.TEXTURE_2D,1),re[s.TEXTURE_CUBE_MAP]=$(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),re[s.TEXTURE_2D_ARRAY]=$(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),re[s.TEXTURE_3D]=$(s.TEXTURE_3D,s.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),oe(s.DEPTH_TEST),a.setFunc(zs),Ne(!1),dt(sc),oe(s.CULL_FACE),I(Hi);function oe(B){u[B]!==!0&&(s.enable(B),u[B]=!0)}function Te(B){u[B]!==!1&&(s.disable(B),u[B]=!1)}function ne(B,Pe){return h[B]!==Pe?(s.bindFramebuffer(B,Pe),h[B]=Pe,B===s.DRAW_FRAMEBUFFER&&(h[s.FRAMEBUFFER]=Pe),B===s.FRAMEBUFFER&&(h[s.DRAW_FRAMEBUFFER]=Pe),!0):!1}function me(B,Pe){let ye=f,Be=!1;if(B){ye=d.get(Pe),ye===void 0&&(ye=[],d.set(Pe,ye));const Y=B.textures;if(ye.length!==Y.length||ye[0]!==s.COLOR_ATTACHMENT0){for(let ce=0,Ce=Y.length;ce<Ce;ce++)ye[ce]=s.COLOR_ATTACHMENT0+ce;ye.length=Y.length,Be=!0}}else ye[0]!==s.BACK&&(ye[0]=s.BACK,Be=!0);Be&&s.drawBuffers(ye)}function Q(B){return g!==B?(s.useProgram(B),g=B,!0):!1}const ee={[ss]:s.FUNC_ADD,[Od]:s.FUNC_SUBTRACT,[kd]:s.FUNC_REVERSE_SUBTRACT};ee[Bd]=s.MIN,ee[zd]=s.MAX;const te={[Vd]:s.ZERO,[Hd]:s.ONE,[Gd]:s.SRC_COLOR,[No]:s.SRC_ALPHA,[Yd]:s.SRC_ALPHA_SATURATE,[qd]:s.DST_COLOR,[Xd]:s.DST_ALPHA,[Wd]:s.ONE_MINUS_SRC_COLOR,[Uo]:s.ONE_MINUS_SRC_ALPHA,[Kd]:s.ONE_MINUS_DST_COLOR,[jd]:s.ONE_MINUS_DST_ALPHA,[Zd]:s.CONSTANT_COLOR,[$d]:s.ONE_MINUS_CONSTANT_COLOR,[Jd]:s.CONSTANT_ALPHA,[Qd]:s.ONE_MINUS_CONSTANT_ALPHA};function I(B,Pe,ye,Be,Y,ce,Ce,tt,Lt,ft){if(B===Hi){_===!0&&(Te(s.BLEND),_=!1);return}if(_===!1&&(oe(s.BLEND),_=!0),B!==Fd){if(B!==m||ft!==E){if((p!==ss||y!==ss)&&(s.blendEquation(s.FUNC_ADD),p=ss,y=ss),ft)switch(B){case Fs:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case rc:s.blendFunc(s.ONE,s.ONE);break;case ac:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case oc:s.blendFuncSeparate(s.ZERO,s.SRC_COLOR,s.ZERO,s.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",B);break}else switch(B){case Fs:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case rc:s.blendFunc(s.SRC_ALPHA,s.ONE);break;case ac:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case oc:s.blendFunc(s.ZERO,s.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",B);break}S=null,x=null,N=null,P=null,L.set(0,0,0),U=0,m=B,E=ft}return}Y=Y||Pe,ce=ce||ye,Ce=Ce||Be,(Pe!==p||Y!==y)&&(s.blendEquationSeparate(ee[Pe],ee[Y]),p=Pe,y=Y),(ye!==S||Be!==x||ce!==N||Ce!==P)&&(s.blendFuncSeparate(te[ye],te[Be],te[ce],te[Ce]),S=ye,x=Be,N=ce,P=Ce),(tt.equals(L)===!1||Lt!==U)&&(s.blendColor(tt.r,tt.g,tt.b,Lt),L.copy(tt),U=Lt),m=B,E=!1}function ge(B,Pe){B.side===Yn?Te(s.CULL_FACE):oe(s.CULL_FACE);let ye=B.side===Ln;Pe&&(ye=!ye),Ne(ye),B.blending===Fs&&B.transparent===!1?I(Hi):I(B.blending,B.blendEquation,B.blendSrc,B.blendDst,B.blendEquationAlpha,B.blendSrcAlpha,B.blendDstAlpha,B.blendColor,B.blendAlpha,B.premultipliedAlpha),a.setFunc(B.depthFunc),a.setTest(B.depthTest),a.setMask(B.depthWrite),r.setMask(B.colorWrite);const Be=B.stencilWrite;o.setTest(Be),Be&&(o.setMask(B.stencilWriteMask),o.setFunc(B.stencilFunc,B.stencilRef,B.stencilFuncMask),o.setOp(B.stencilFail,B.stencilZFail,B.stencilZPass)),nt(B.polygonOffset,B.polygonOffsetFactor,B.polygonOffsetUnits),B.alphaToCoverage===!0?oe(s.SAMPLE_ALPHA_TO_COVERAGE):Te(s.SAMPLE_ALPHA_TO_COVERAGE)}function Ne(B){T!==B&&(B?s.frontFace(s.CW):s.frontFace(s.CCW),T=B)}function dt(B){B!==Nd?(oe(s.CULL_FACE),B!==D&&(B===sc?s.cullFace(s.BACK):B===Ud?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):Te(s.CULL_FACE),D=B}function ve(B){B!==X&&(k&&s.lineWidth(B),X=B)}function nt(B,Pe,ye){B?(oe(s.POLYGON_OFFSET_FILL),(j!==Pe||se!==ye)&&(s.polygonOffset(Pe,ye),j=Pe,se=ye)):Te(s.POLYGON_OFFSET_FILL)}function ke(B){B?oe(s.SCISSOR_TEST):Te(s.SCISSOR_TEST)}function ht(B){B===void 0&&(B=s.TEXTURE0+de-1),pe!==B&&(s.activeTexture(B),pe=B)}function Nt(B,Pe,ye){ye===void 0&&(pe===null?ye=s.TEXTURE0+de-1:ye=pe);let Be=Me[ye];Be===void 0&&(Be={type:void 0,texture:void 0},Me[ye]=Be),(Be.type!==B||Be.texture!==Pe)&&(pe!==ye&&(s.activeTexture(ye),pe=ye),s.bindTexture(B,Pe||re[B]),Be.type=B,Be.texture=Pe)}function F(){const B=Me[pe];B!==void 0&&B.type!==void 0&&(s.bindTexture(B.type,null),B.type=void 0,B.texture=void 0)}function b(){try{s.compressedTexImage2D(...arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function q(){try{s.compressedTexImage3D(...arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function ue(){try{s.texSubImage2D(...arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function fe(){try{s.texSubImage3D(...arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function ie(){try{s.compressedTexSubImage2D(...arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function Ke(){try{s.compressedTexSubImage3D(...arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function Re(){try{s.texStorage2D(...arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function Ge(){try{s.texStorage3D(...arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function Ye(){try{s.texImage2D(...arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function _e(){try{s.texImage3D(...arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function Oe(B){be.equals(B)===!1&&(s.scissor(B.x,B.y,B.z,B.w),be.copy(B))}function it(B){W.equals(B)===!1&&(s.viewport(B.x,B.y,B.z,B.w),W.copy(B))}function Qe(B,Pe){let ye=c.get(Pe);ye===void 0&&(ye=new WeakMap,c.set(Pe,ye));let Be=ye.get(B);Be===void 0&&(Be=s.getUniformBlockIndex(Pe,B.name),ye.set(B,Be))}function Ee(B,Pe){const Be=c.get(Pe).get(B);l.get(Pe)!==Be&&(s.uniformBlockBinding(Pe,Be,B.__bindingPointIndex),l.set(Pe,Be))}function at(){s.disable(s.BLEND),s.disable(s.CULL_FACE),s.disable(s.DEPTH_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SCISSOR_TEST),s.disable(s.STENCIL_TEST),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),s.blendEquation(s.FUNC_ADD),s.blendFunc(s.ONE,s.ZERO),s.blendFuncSeparate(s.ONE,s.ZERO,s.ONE,s.ZERO),s.blendColor(0,0,0,0),s.colorMask(!0,!0,!0,!0),s.clearColor(0,0,0,0),s.depthMask(!0),s.depthFunc(s.LESS),a.setReversed(!1),s.clearDepth(1),s.stencilMask(4294967295),s.stencilFunc(s.ALWAYS,0,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),s.clearStencil(0),s.cullFace(s.BACK),s.frontFace(s.CCW),s.polygonOffset(0,0),s.activeTexture(s.TEXTURE0),s.bindFramebuffer(s.FRAMEBUFFER,null),s.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),s.bindFramebuffer(s.READ_FRAMEBUFFER,null),s.useProgram(null),s.lineWidth(1),s.scissor(0,0,s.canvas.width,s.canvas.height),s.viewport(0,0,s.canvas.width,s.canvas.height),u={},pe=null,Me={},h={},d=new WeakMap,f=[],g=null,_=!1,m=null,p=null,S=null,x=null,y=null,N=null,P=null,L=new He(0,0,0),U=0,E=!1,T=null,D=null,X=null,j=null,se=null,be.set(0,0,s.canvas.width,s.canvas.height),W.set(0,0,s.canvas.width,s.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:oe,disable:Te,bindFramebuffer:ne,drawBuffers:me,useProgram:Q,setBlending:I,setMaterial:ge,setFlipSided:Ne,setCullFace:dt,setLineWidth:ve,setPolygonOffset:nt,setScissorTest:ke,activeTexture:ht,bindTexture:Nt,unbindTexture:F,compressedTexImage2D:b,compressedTexImage3D:q,texImage2D:Ye,texImage3D:_e,updateUBOMapping:Qe,uniformBlockBinding:Ee,texStorage2D:Re,texStorage3D:Ge,texSubImage2D:ue,texSubImage3D:fe,compressedTexSubImage2D:ie,compressedTexSubImage3D:Ke,scissor:Oe,viewport:it,reset:at}}function Xy(s,e,t,n,i,r,a){const o=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 ot,u=new WeakMap;let h;const d=new WeakMap;let f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(F,b){return f?new OffscreenCanvas(F,b):xr("canvas")}function _(F,b,q){let ue=1;const fe=Nt(F);if((fe.width>q||fe.height>q)&&(ue=q/Math.max(fe.width,fe.height)),ue<1)if(typeof HTMLImageElement<"u"&&F instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&F instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&F instanceof ImageBitmap||typeof VideoFrame<"u"&&F instanceof VideoFrame){const ie=Math.floor(ue*fe.width),Ke=Math.floor(ue*fe.height);h===void 0&&(h=g(ie,Ke));const Re=b?g(ie,Ke):h;return Re.width=ie,Re.height=Ke,Re.getContext("2d").drawImage(F,0,0,ie,Ke),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+fe.width+"x"+fe.height+") to ("+ie+"x"+Ke+")."),Re}else return"data"in F&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+fe.width+"x"+fe.height+")."),F;return F}function m(F){return F.generateMipmaps}function p(F){s.generateMipmap(F)}function S(F){return F.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:F.isWebGL3DRenderTarget?s.TEXTURE_3D:F.isWebGLArrayRenderTarget||F.isCompressedArrayTexture?s.TEXTURE_2D_ARRAY:s.TEXTURE_2D}function x(F,b,q,ue,fe=!1){if(F!==null){if(s[F]!==void 0)return s[F];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+F+"'")}let ie=b;if(b===s.RED&&(q===s.FLOAT&&(ie=s.R32F),q===s.HALF_FLOAT&&(ie=s.R16F),q===s.UNSIGNED_BYTE&&(ie=s.R8)),b===s.RED_INTEGER&&(q===s.UNSIGNED_BYTE&&(ie=s.R8UI),q===s.UNSIGNED_SHORT&&(ie=s.R16UI),q===s.UNSIGNED_INT&&(ie=s.R32UI),q===s.BYTE&&(ie=s.R8I),q===s.SHORT&&(ie=s.R16I),q===s.INT&&(ie=s.R32I)),b===s.RG&&(q===s.FLOAT&&(ie=s.RG32F),q===s.HALF_FLOAT&&(ie=s.RG16F),q===s.UNSIGNED_BYTE&&(ie=s.RG8)),b===s.RG_INTEGER&&(q===s.UNSIGNED_BYTE&&(ie=s.RG8UI),q===s.UNSIGNED_SHORT&&(ie=s.RG16UI),q===s.UNSIGNED_INT&&(ie=s.RG32UI),q===s.BYTE&&(ie=s.RG8I),q===s.SHORT&&(ie=s.RG16I),q===s.INT&&(ie=s.RG32I)),b===s.RGB_INTEGER&&(q===s.UNSIGNED_BYTE&&(ie=s.RGB8UI),q===s.UNSIGNED_SHORT&&(ie=s.RGB16UI),q===s.UNSIGNED_INT&&(ie=s.RGB32UI),q===s.BYTE&&(ie=s.RGB8I),q===s.SHORT&&(ie=s.RGB16I),q===s.INT&&(ie=s.RGB32I)),b===s.RGBA_INTEGER&&(q===s.UNSIGNED_BYTE&&(ie=s.RGBA8UI),q===s.UNSIGNED_SHORT&&(ie=s.RGBA16UI),q===s.UNSIGNED_INT&&(ie=s.RGBA32UI),q===s.BYTE&&(ie=s.RGBA8I),q===s.SHORT&&(ie=s.RGBA16I),q===s.INT&&(ie=s.RGBA32I)),b===s.RGB&&q===s.UNSIGNED_INT_5_9_9_9_REV&&(ie=s.RGB9_E5),b===s.RGBA){const Ke=fe?Ea:pt.getTransfer(ue);q===s.FLOAT&&(ie=s.RGBA32F),q===s.HALF_FLOAT&&(ie=s.RGBA16F),q===s.UNSIGNED_BYTE&&(ie=Ke===Ut?s.SRGB8_ALPHA8:s.RGBA8),q===s.UNSIGNED_SHORT_4_4_4_4&&(ie=s.RGBA4),q===s.UNSIGNED_SHORT_5_5_5_1&&(ie=s.RGB5_A1)}return(ie===s.R16F||ie===s.R32F||ie===s.RG16F||ie===s.RG32F||ie===s.RGBA16F||ie===s.RGBA32F)&&e.get("EXT_color_buffer_float"),ie}function y(F,b){let q;return F?b===null||b===ls||b===pr?q=s.DEPTH24_STENCIL8:b===Qn?q=s.DEPTH32F_STENCIL8:b===fr&&(q=s.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):b===null||b===ls||b===pr?q=s.DEPTH_COMPONENT24:b===Qn?q=s.DEPTH_COMPONENT32F:b===fr&&(q=s.DEPTH_COMPONENT16),q}function N(F,b){return m(F)===!0||F.isFramebufferTexture&&F.minFilter!==Sn&&F.minFilter!==gn?Math.log2(Math.max(b.width,b.height))+1:F.mipmaps!==void 0&&F.mipmaps.length>0?F.mipmaps.length:F.isCompressedTexture&&Array.isArray(F.image)?b.mipmaps.length:1}function P(F){const b=F.target;b.removeEventListener("dispose",P),U(b),b.isVideoTexture&&u.delete(b)}function L(F){const b=F.target;b.removeEventListener("dispose",L),T(b)}function U(F){const b=n.get(F);if(b.__webglInit===void 0)return;const q=F.source,ue=d.get(q);if(ue){const fe=ue[b.__cacheKey];fe.usedTimes--,fe.usedTimes===0&&E(F),Object.keys(ue).length===0&&d.delete(q)}n.remove(F)}function E(F){const b=n.get(F);s.deleteTexture(b.__webglTexture);const q=F.source,ue=d.get(q);delete ue[b.__cacheKey],a.memory.textures--}function T(F){const b=n.get(F);if(F.depthTexture&&(F.depthTexture.dispose(),n.remove(F.depthTexture)),F.isWebGLCubeRenderTarget)for(let ue=0;ue<6;ue++){if(Array.isArray(b.__webglFramebuffer[ue]))for(let fe=0;fe<b.__webglFramebuffer[ue].length;fe++)s.deleteFramebuffer(b.__webglFramebuffer[ue][fe]);else s.deleteFramebuffer(b.__webglFramebuffer[ue]);b.__webglDepthbuffer&&s.deleteRenderbuffer(b.__webglDepthbuffer[ue])}else{if(Array.isArray(b.__webglFramebuffer))for(let ue=0;ue<b.__webglFramebuffer.length;ue++)s.deleteFramebuffer(b.__webglFramebuffer[ue]);else s.deleteFramebuffer(b.__webglFramebuffer);if(b.__webglDepthbuffer&&s.deleteRenderbuffer(b.__webglDepthbuffer),b.__webglMultisampledFramebuffer&&s.deleteFramebuffer(b.__webglMultisampledFramebuffer),b.__webglColorRenderbuffer)for(let ue=0;ue<b.__webglColorRenderbuffer.length;ue++)b.__webglColorRenderbuffer[ue]&&s.deleteRenderbuffer(b.__webglColorRenderbuffer[ue]);b.__webglDepthRenderbuffer&&s.deleteRenderbuffer(b.__webglDepthRenderbuffer)}const q=F.textures;for(let ue=0,fe=q.length;ue<fe;ue++){const ie=n.get(q[ue]);ie.__webglTexture&&(s.deleteTexture(ie.__webglTexture),a.memory.textures--),n.remove(q[ue])}n.remove(F)}let D=0;function X(){D=0}function j(){const F=D;return F>=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+F+" texture units while this GPU supports only "+i.maxTextures),D+=1,F}function se(F){const b=[];return b.push(F.wrapS),b.push(F.wrapT),b.push(F.wrapR||0),b.push(F.magFilter),b.push(F.minFilter),b.push(F.anisotropy),b.push(F.internalFormat),b.push(F.format),b.push(F.type),b.push(F.generateMipmaps),b.push(F.premultiplyAlpha),b.push(F.flipY),b.push(F.unpackAlignment),b.push(F.colorSpace),b.join()}function de(F,b){const q=n.get(F);if(F.isVideoTexture&&ke(F),F.isRenderTargetTexture===!1&&F.version>0&&q.__version!==F.version){const ue=F.image;if(ue===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ue.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{re(q,F,b);return}}t.bindTexture(s.TEXTURE_2D,q.__webglTexture,s.TEXTURE0+b)}function k(F,b){const q=n.get(F);if(F.version>0&&q.__version!==F.version){re(q,F,b);return}t.bindTexture(s.TEXTURE_2D_ARRAY,q.__webglTexture,s.TEXTURE0+b)}function ae(F,b){const q=n.get(F);if(F.version>0&&q.__version!==F.version){re(q,F,b);return}t.bindTexture(s.TEXTURE_3D,q.__webglTexture,s.TEXTURE0+b)}function G(F,b){const q=n.get(F);if(F.version>0&&q.__version!==F.version){oe(q,F,b);return}t.bindTexture(s.TEXTURE_CUBE_MAP,q.__webglTexture,s.TEXTURE0+b)}const pe={[Vn]:s.REPEAT,[Pn]:s.CLAMP_TO_EDGE,[ba]:s.MIRRORED_REPEAT},Me={[Sn]:s.NEAREST,[Ku]:s.NEAREST_MIPMAP_NEAREST,[ar]:s.NEAREST_MIPMAP_LINEAR,[gn]:s.LINEAR,[pa]:s.LINEAR_MIPMAP_NEAREST,[Jn]:s.LINEAR_MIPMAP_LINEAR},le={[gf]:s.NEVER,[Sf]:s.ALWAYS,[_f]:s.LESS,[ih]:s.LEQUAL,[yf]:s.EQUAL,[Mf]:s.GEQUAL,[xf]:s.GREATER,[vf]:s.NOTEQUAL};function we(F,b){if(b.type===Qn&&e.has("OES_texture_float_linear")===!1&&(b.magFilter===gn||b.magFilter===pa||b.magFilter===ar||b.magFilter===Jn||b.minFilter===gn||b.minFilter===pa||b.minFilter===ar||b.minFilter===Jn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(F,s.TEXTURE_WRAP_S,pe[b.wrapS]),s.texParameteri(F,s.TEXTURE_WRAP_T,pe[b.wrapT]),(F===s.TEXTURE_3D||F===s.TEXTURE_2D_ARRAY)&&s.texParameteri(F,s.TEXTURE_WRAP_R,pe[b.wrapR]),s.texParameteri(F,s.TEXTURE_MAG_FILTER,Me[b.magFilter]),s.texParameteri(F,s.TEXTURE_MIN_FILTER,Me[b.minFilter]),b.compareFunction&&(s.texParameteri(F,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(F,s.TEXTURE_COMPARE_FUNC,le[b.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(b.magFilter===Sn||b.minFilter!==ar&&b.minFilter!==Jn||b.type===Qn&&e.has("OES_texture_float_linear")===!1)return;if(b.anisotropy>1||n.get(b).__currentAnisotropy){const q=e.get("EXT_texture_filter_anisotropic");s.texParameterf(F,q.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(b.anisotropy,i.getMaxAnisotropy())),n.get(b).__currentAnisotropy=b.anisotropy}}}function be(F,b){let q=!1;F.__webglInit===void 0&&(F.__webglInit=!0,b.addEventListener("dispose",P));const ue=b.source;let fe=d.get(ue);fe===void 0&&(fe={},d.set(ue,fe));const ie=se(b);if(ie!==F.__cacheKey){fe[ie]===void 0&&(fe[ie]={texture:s.createTexture(),usedTimes:0},a.memory.textures++,q=!0),fe[ie].usedTimes++;const Ke=fe[F.__cacheKey];Ke!==void 0&&(fe[F.__cacheKey].usedTimes--,Ke.usedTimes===0&&E(b)),F.__cacheKey=ie,F.__webglTexture=fe[ie].texture}return q}function W(F,b,q){return Math.floor(Math.floor(F/q)/b)}function $(F,b,q,ue){const ie=F.updateRanges;if(ie.length===0)t.texSubImage2D(s.TEXTURE_2D,0,0,0,b.width,b.height,q,ue,b.data);else{ie.sort((_e,Oe)=>_e.start-Oe.start);let Ke=0;for(let _e=1;_e<ie.length;_e++){const Oe=ie[Ke],it=ie[_e],Qe=Oe.start+Oe.count,Ee=W(it.start,b.width,4),at=W(Oe.start,b.width,4);it.start<=Qe+1&&Ee===at&&W(it.start+it.count-1,b.width,4)===Ee?Oe.count=Math.max(Oe.count,it.start+it.count-Oe.start):(++Ke,ie[Ke]=it)}ie.length=Ke+1;const Re=s.getParameter(s.UNPACK_ROW_LENGTH),Ge=s.getParameter(s.UNPACK_SKIP_PIXELS),Ye=s.getParameter(s.UNPACK_SKIP_ROWS);s.pixelStorei(s.UNPACK_ROW_LENGTH,b.width);for(let _e=0,Oe=ie.length;_e<Oe;_e++){const it=ie[_e],Qe=Math.floor(it.start/4),Ee=Math.ceil(it.count/4),at=Qe%b.width,B=Math.floor(Qe/b.width),Pe=Ee,ye=1;s.pixelStorei(s.UNPACK_SKIP_PIXELS,at),s.pixelStorei(s.UNPACK_SKIP_ROWS,B),t.texSubImage2D(s.TEXTURE_2D,0,at,B,Pe,ye,q,ue,b.data)}F.clearUpdateRanges(),s.pixelStorei(s.UNPACK_ROW_LENGTH,Re),s.pixelStorei(s.UNPACK_SKIP_PIXELS,Ge),s.pixelStorei(s.UNPACK_SKIP_ROWS,Ye)}}function re(F,b,q){let ue=s.TEXTURE_2D;(b.isDataArrayTexture||b.isCompressedArrayTexture)&&(ue=s.TEXTURE_2D_ARRAY),b.isData3DTexture&&(ue=s.TEXTURE_3D);const fe=be(F,b),ie=b.source;t.bindTexture(ue,F.__webglTexture,s.TEXTURE0+q);const Ke=n.get(ie);if(ie.version!==Ke.__version||fe===!0){t.activeTexture(s.TEXTURE0+q);const Re=pt.getPrimaries(pt.workingColorSpace),Ge=b.colorSpace===zi?null:pt.getPrimaries(b.colorSpace),Ye=b.colorSpace===zi||Re===Ge?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,b.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,b.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,b.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ye);let _e=_(b.image,!1,i.maxTextureSize);_e=ht(b,_e);const Oe=r.convert(b.format,b.colorSpace),it=r.convert(b.type);let Qe=x(b.internalFormat,Oe,it,b.colorSpace,b.isVideoTexture);we(ue,b);let Ee;const at=b.mipmaps,B=b.isVideoTexture!==!0,Pe=Ke.__version===void 0||fe===!0,ye=ie.dataReady,Be=N(b,_e);if(b.isDepthTexture)Qe=y(b.format===gr,b.type),Pe&&(B?t.texStorage2D(s.TEXTURE_2D,1,Qe,_e.width,_e.height):t.texImage2D(s.TEXTURE_2D,0,Qe,_e.width,_e.height,0,Oe,it,null));else if(b.isDataTexture)if(at.length>0){B&&Pe&&t.texStorage2D(s.TEXTURE_2D,Be,Qe,at[0].width,at[0].height);for(let Y=0,ce=at.length;Y<ce;Y++)Ee=at[Y],B?ye&&t.texSubImage2D(s.TEXTURE_2D,Y,0,0,Ee.width,Ee.height,Oe,it,Ee.data):t.texImage2D(s.TEXTURE_2D,Y,Qe,Ee.width,Ee.height,0,Oe,it,Ee.data);b.generateMipmaps=!1}else B?(Pe&&t.texStorage2D(s.TEXTURE_2D,Be,Qe,_e.width,_e.height),ye&&$(b,_e,Oe,it)):t.texImage2D(s.TEXTURE_2D,0,Qe,_e.width,_e.height,0,Oe,it,_e.data);else if(b.isCompressedTexture)if(b.isCompressedArrayTexture){B&&Pe&&t.texStorage3D(s.TEXTURE_2D_ARRAY,Be,Qe,at[0].width,at[0].height,_e.depth);for(let Y=0,ce=at.length;Y<ce;Y++)if(Ee=at[Y],b.format!==Hn)if(Oe!==null)if(B){if(ye)if(b.layerUpdates.size>0){const Ce=eu(Ee.width,Ee.height,b.format,b.type);for(const tt of b.layerUpdates){const Lt=Ee.data.subarray(tt*Ce/Ee.data.BYTES_PER_ELEMENT,(tt+1)*Ce/Ee.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,Y,0,0,tt,Ee.width,Ee.height,1,Oe,Lt)}b.clearLayerUpdates()}else t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,Y,0,0,0,Ee.width,Ee.height,_e.depth,Oe,Ee.data)}else t.compressedTexImage3D(s.TEXTURE_2D_ARRAY,Y,Qe,Ee.width,Ee.height,_e.depth,0,Ee.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else B?ye&&t.texSubImage3D(s.TEXTURE_2D_ARRAY,Y,0,0,0,Ee.width,Ee.height,_e.depth,Oe,it,Ee.data):t.texImage3D(s.TEXTURE_2D_ARRAY,Y,Qe,Ee.width,Ee.height,_e.depth,0,Oe,it,Ee.data)}else{B&&Pe&&t.texStorage2D(s.TEXTURE_2D,Be,Qe,at[0].width,at[0].height);for(let Y=0,ce=at.length;Y<ce;Y++)Ee=at[Y],b.format!==Hn?Oe!==null?B?ye&&t.compressedTexSubImage2D(s.TEXTURE_2D,Y,0,0,Ee.width,Ee.height,Oe,Ee.data):t.compressedTexImage2D(s.TEXTURE_2D,Y,Qe,Ee.width,Ee.height,0,Ee.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):B?ye&&t.texSubImage2D(s.TEXTURE_2D,Y,0,0,Ee.width,Ee.height,Oe,it,Ee.data):t.texImage2D(s.TEXTURE_2D,Y,Qe,Ee.width,Ee.height,0,Oe,it,Ee.data)}else if(b.isDataArrayTexture)if(B){if(Pe&&t.texStorage3D(s.TEXTURE_2D_ARRAY,Be,Qe,_e.width,_e.height,_e.depth),ye)if(b.layerUpdates.size>0){const Y=eu(_e.width,_e.height,b.format,b.type);for(const ce of b.layerUpdates){const Ce=_e.data.subarray(ce*Y/_e.data.BYTES_PER_ELEMENT,(ce+1)*Y/_e.data.BYTES_PER_ELEMENT);t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,ce,_e.width,_e.height,1,Oe,it,Ce)}b.clearLayerUpdates()}else t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,_e.width,_e.height,_e.depth,Oe,it,_e.data)}else t.texImage3D(s.TEXTURE_2D_ARRAY,0,Qe,_e.width,_e.height,_e.depth,0,Oe,it,_e.data);else if(b.isData3DTexture)B?(Pe&&t.texStorage3D(s.TEXTURE_3D,Be,Qe,_e.width,_e.height,_e.depth),ye&&t.texSubImage3D(s.TEXTURE_3D,0,0,0,0,_e.width,_e.height,_e.depth,Oe,it,_e.data)):t.texImage3D(s.TEXTURE_3D,0,Qe,_e.width,_e.height,_e.depth,0,Oe,it,_e.data);else if(b.isFramebufferTexture){if(Pe)if(B)t.texStorage2D(s.TEXTURE_2D,Be,Qe,_e.width,_e.height);else{let Y=_e.width,ce=_e.height;for(let Ce=0;Ce<Be;Ce++)t.texImage2D(s.TEXTURE_2D,Ce,Qe,Y,ce,0,Oe,it,null),Y>>=1,ce>>=1}}else if(at.length>0){if(B&&Pe){const Y=Nt(at[0]);t.texStorage2D(s.TEXTURE_2D,Be,Qe,Y.width,Y.height)}for(let Y=0,ce=at.length;Y<ce;Y++)Ee=at[Y],B?ye&&t.texSubImage2D(s.TEXTURE_2D,Y,0,0,Oe,it,Ee):t.texImage2D(s.TEXTURE_2D,Y,Qe,Oe,it,Ee);b.generateMipmaps=!1}else if(B){if(Pe){const Y=Nt(_e);t.texStorage2D(s.TEXTURE_2D,Be,Qe,Y.width,Y.height)}ye&&t.texSubImage2D(s.TEXTURE_2D,0,0,0,Oe,it,_e)}else t.texImage2D(s.TEXTURE_2D,0,Qe,Oe,it,_e);m(b)&&p(ue),Ke.__version=ie.version,b.onUpdate&&b.onUpdate(b)}F.__version=b.version}function oe(F,b,q){if(b.image.length!==6)return;const ue=be(F,b),fe=b.source;t.bindTexture(s.TEXTURE_CUBE_MAP,F.__webglTexture,s.TEXTURE0+q);const ie=n.get(fe);if(fe.version!==ie.__version||ue===!0){t.activeTexture(s.TEXTURE0+q);const Ke=pt.getPrimaries(pt.workingColorSpace),Re=b.colorSpace===zi?null:pt.getPrimaries(b.colorSpace),Ge=b.colorSpace===zi||Ke===Re?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,b.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,b.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,b.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ge);const Ye=b.isCompressedTexture||b.image[0].isCompressedTexture,_e=b.image[0]&&b.image[0].isDataTexture,Oe=[];for(let ce=0;ce<6;ce++)!Ye&&!_e?Oe[ce]=_(b.image[ce],!0,i.maxCubemapSize):Oe[ce]=_e?b.image[ce].image:b.image[ce],Oe[ce]=ht(b,Oe[ce]);const it=Oe[0],Qe=r.convert(b.format,b.colorSpace),Ee=r.convert(b.type),at=x(b.internalFormat,Qe,Ee,b.colorSpace),B=b.isVideoTexture!==!0,Pe=ie.__version===void 0||ue===!0,ye=fe.dataReady;let Be=N(b,it);we(s.TEXTURE_CUBE_MAP,b);let Y;if(Ye){B&&Pe&&t.texStorage2D(s.TEXTURE_CUBE_MAP,Be,at,it.width,it.height);for(let ce=0;ce<6;ce++){Y=Oe[ce].mipmaps;for(let Ce=0;Ce<Y.length;Ce++){const tt=Y[Ce];b.format!==Hn?Qe!==null?B?ye&&t.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ce,0,0,tt.width,tt.height,Qe,tt.data):t.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ce,at,tt.width,tt.height,0,tt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):B?ye&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ce,0,0,tt.width,tt.height,Qe,Ee,tt.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ce,at,tt.width,tt.height,0,Qe,Ee,tt.data)}}}else{if(Y=b.mipmaps,B&&Pe){Y.length>0&&Be++;const ce=Nt(Oe[0]);t.texStorage2D(s.TEXTURE_CUBE_MAP,Be,at,ce.width,ce.height)}for(let ce=0;ce<6;ce++)if(_e){B?ye&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,0,0,Oe[ce].width,Oe[ce].height,Qe,Ee,Oe[ce].data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,at,Oe[ce].width,Oe[ce].height,0,Qe,Ee,Oe[ce].data);for(let Ce=0;Ce<Y.length;Ce++){const Lt=Y[Ce].image[ce].image;B?ye&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ce+1,0,0,Lt.width,Lt.height,Qe,Ee,Lt.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ce+1,at,Lt.width,Lt.height,0,Qe,Ee,Lt.data)}}else{B?ye&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,0,0,Qe,Ee,Oe[ce]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,at,Qe,Ee,Oe[ce]);for(let Ce=0;Ce<Y.length;Ce++){const tt=Y[Ce];B?ye&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ce+1,0,0,Qe,Ee,tt.image[ce]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ce+1,at,Qe,Ee,tt.image[ce])}}}m(b)&&p(s.TEXTURE_CUBE_MAP),ie.__version=fe.version,b.onUpdate&&b.onUpdate(b)}F.__version=b.version}function Te(F,b,q,ue,fe,ie){const Ke=r.convert(q.format,q.colorSpace),Re=r.convert(q.type),Ge=x(q.internalFormat,Ke,Re,q.colorSpace),Ye=n.get(b),_e=n.get(q);if(_e.__renderTarget=b,!Ye.__hasExternalTextures){const Oe=Math.max(1,b.width>>ie),it=Math.max(1,b.height>>ie);fe===s.TEXTURE_3D||fe===s.TEXTURE_2D_ARRAY?t.texImage3D(fe,ie,Ge,Oe,it,b.depth,0,Ke,Re,null):t.texImage2D(fe,ie,Ge,Oe,it,0,Ke,Re,null)}t.bindFramebuffer(s.FRAMEBUFFER,F),nt(b)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,ue,fe,_e.__webglTexture,0,ve(b)):(fe===s.TEXTURE_2D||fe>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&fe<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,ue,fe,_e.__webglTexture,ie),t.bindFramebuffer(s.FRAMEBUFFER,null)}function ne(F,b,q){if(s.bindRenderbuffer(s.RENDERBUFFER,F),b.depthBuffer){const ue=b.depthTexture,fe=ue&&ue.isDepthTexture?ue.type:null,ie=y(b.stencilBuffer,fe),Ke=b.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,Re=ve(b);nt(b)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Re,ie,b.width,b.height):q?s.renderbufferStorageMultisample(s.RENDERBUFFER,Re,ie,b.width,b.height):s.renderbufferStorage(s.RENDERBUFFER,ie,b.width,b.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,Ke,s.RENDERBUFFER,F)}else{const ue=b.textures;for(let fe=0;fe<ue.length;fe++){const ie=ue[fe],Ke=r.convert(ie.format,ie.colorSpace),Re=r.convert(ie.type),Ge=x(ie.internalFormat,Ke,Re,ie.colorSpace),Ye=ve(b);q&&nt(b)===!1?s.renderbufferStorageMultisample(s.RENDERBUFFER,Ye,Ge,b.width,b.height):nt(b)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Ye,Ge,b.width,b.height):s.renderbufferStorage(s.RENDERBUFFER,Ge,b.width,b.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function me(F,b){if(b&&b.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(s.FRAMEBUFFER,F),!(b.depthTexture&&b.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const ue=n.get(b.depthTexture);ue.__renderTarget=b,(!ue.__webglTexture||b.depthTexture.image.width!==b.width||b.depthTexture.image.height!==b.height)&&(b.depthTexture.image.width=b.width,b.depthTexture.image.height=b.height,b.depthTexture.needsUpdate=!0),de(b.depthTexture,0);const fe=ue.__webglTexture,ie=ve(b);if(b.depthTexture.format===mr)nt(b)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,fe,0,ie):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,fe,0);else if(b.depthTexture.format===gr)nt(b)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,fe,0,ie):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,fe,0);else throw new Error("Unknown depthTexture format")}function Q(F){const b=n.get(F),q=F.isWebGLCubeRenderTarget===!0;if(b.__boundDepthTexture!==F.depthTexture){const ue=F.depthTexture;if(b.__depthDisposeCallback&&b.__depthDisposeCallback(),ue){const fe=()=>{delete b.__boundDepthTexture,delete b.__depthDisposeCallback,ue.removeEventListener("dispose",fe)};ue.addEventListener("dispose",fe),b.__depthDisposeCallback=fe}b.__boundDepthTexture=ue}if(F.depthTexture&&!b.__autoAllocateDepthBuffer){if(q)throw new Error("target.depthTexture not supported in Cube render targets");const ue=F.texture.mipmaps;ue&&ue.length>0?me(b.__webglFramebuffer[0],F):me(b.__webglFramebuffer,F)}else if(q){b.__webglDepthbuffer=[];for(let ue=0;ue<6;ue++)if(t.bindFramebuffer(s.FRAMEBUFFER,b.__webglFramebuffer[ue]),b.__webglDepthbuffer[ue]===void 0)b.__webglDepthbuffer[ue]=s.createRenderbuffer(),ne(b.__webglDepthbuffer[ue],F,!1);else{const fe=F.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,ie=b.__webglDepthbuffer[ue];s.bindRenderbuffer(s.RENDERBUFFER,ie),s.framebufferRenderbuffer(s.FRAMEBUFFER,fe,s.RENDERBUFFER,ie)}}else{const ue=F.texture.mipmaps;if(ue&&ue.length>0?t.bindFramebuffer(s.FRAMEBUFFER,b.__webglFramebuffer[0]):t.bindFramebuffer(s.FRAMEBUFFER,b.__webglFramebuffer),b.__webglDepthbuffer===void 0)b.__webglDepthbuffer=s.createRenderbuffer(),ne(b.__webglDepthbuffer,F,!1);else{const fe=F.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,ie=b.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,ie),s.framebufferRenderbuffer(s.FRAMEBUFFER,fe,s.RENDERBUFFER,ie)}}t.bindFramebuffer(s.FRAMEBUFFER,null)}function ee(F,b,q){const ue=n.get(F);b!==void 0&&Te(ue.__webglFramebuffer,F,F.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),q!==void 0&&Q(F)}function te(F){const b=F.texture,q=n.get(F),ue=n.get(b);F.addEventListener("dispose",L);const fe=F.textures,ie=F.isWebGLCubeRenderTarget===!0,Ke=fe.length>1;if(Ke||(ue.__webglTexture===void 0&&(ue.__webglTexture=s.createTexture()),ue.__version=b.version,a.memory.textures++),ie){q.__webglFramebuffer=[];for(let Re=0;Re<6;Re++)if(b.mipmaps&&b.mipmaps.length>0){q.__webglFramebuffer[Re]=[];for(let Ge=0;Ge<b.mipmaps.length;Ge++)q.__webglFramebuffer[Re][Ge]=s.createFramebuffer()}else q.__webglFramebuffer[Re]=s.createFramebuffer()}else{if(b.mipmaps&&b.mipmaps.length>0){q.__webglFramebuffer=[];for(let Re=0;Re<b.mipmaps.length;Re++)q.__webglFramebuffer[Re]=s.createFramebuffer()}else q.__webglFramebuffer=s.createFramebuffer();if(Ke)for(let Re=0,Ge=fe.length;Re<Ge;Re++){const Ye=n.get(fe[Re]);Ye.__webglTexture===void 0&&(Ye.__webglTexture=s.createTexture(),a.memory.textures++)}if(F.samples>0&&nt(F)===!1){q.__webglMultisampledFramebuffer=s.createFramebuffer(),q.__webglColorRenderbuffer=[],t.bindFramebuffer(s.FRAMEBUFFER,q.__webglMultisampledFramebuffer);for(let Re=0;Re<fe.length;Re++){const Ge=fe[Re];q.__webglColorRenderbuffer[Re]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,q.__webglColorRenderbuffer[Re]);const Ye=r.convert(Ge.format,Ge.colorSpace),_e=r.convert(Ge.type),Oe=x(Ge.internalFormat,Ye,_e,Ge.colorSpace,F.isXRRenderTarget===!0),it=ve(F);s.renderbufferStorageMultisample(s.RENDERBUFFER,it,Oe,F.width,F.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+Re,s.RENDERBUFFER,q.__webglColorRenderbuffer[Re])}s.bindRenderbuffer(s.RENDERBUFFER,null),F.depthBuffer&&(q.__webglDepthRenderbuffer=s.createRenderbuffer(),ne(q.__webglDepthRenderbuffer,F,!0)),t.bindFramebuffer(s.FRAMEBUFFER,null)}}if(ie){t.bindTexture(s.TEXTURE_CUBE_MAP,ue.__webglTexture),we(s.TEXTURE_CUBE_MAP,b);for(let Re=0;Re<6;Re++)if(b.mipmaps&&b.mipmaps.length>0)for(let Ge=0;Ge<b.mipmaps.length;Ge++)Te(q.__webglFramebuffer[Re][Ge],F,b,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+Re,Ge);else Te(q.__webglFramebuffer[Re],F,b,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+Re,0);m(b)&&p(s.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Ke){for(let Re=0,Ge=fe.length;Re<Ge;Re++){const Ye=fe[Re],_e=n.get(Ye);t.bindTexture(s.TEXTURE_2D,_e.__webglTexture),we(s.TEXTURE_2D,Ye),Te(q.__webglFramebuffer,F,Ye,s.COLOR_ATTACHMENT0+Re,s.TEXTURE_2D,0),m(Ye)&&p(s.TEXTURE_2D)}t.unbindTexture()}else{let Re=s.TEXTURE_2D;if((F.isWebGL3DRenderTarget||F.isWebGLArrayRenderTarget)&&(Re=F.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(Re,ue.__webglTexture),we(Re,b),b.mipmaps&&b.mipmaps.length>0)for(let Ge=0;Ge<b.mipmaps.length;Ge++)Te(q.__webglFramebuffer[Ge],F,b,s.COLOR_ATTACHMENT0,Re,Ge);else Te(q.__webglFramebuffer,F,b,s.COLOR_ATTACHMENT0,Re,0);m(b)&&p(Re),t.unbindTexture()}F.depthBuffer&&Q(F)}function I(F){const b=F.textures;for(let q=0,ue=b.length;q<ue;q++){const fe=b[q];if(m(fe)){const ie=S(F),Ke=n.get(fe).__webglTexture;t.bindTexture(ie,Ke),p(ie),t.unbindTexture()}}}const ge=[],Ne=[];function dt(F){if(F.samples>0){if(nt(F)===!1){const b=F.textures,q=F.width,ue=F.height;let fe=s.COLOR_BUFFER_BIT;const ie=F.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,Ke=n.get(F),Re=b.length>1;if(Re)for(let Ye=0;Ye<b.length;Ye++)t.bindFramebuffer(s.FRAMEBUFFER,Ke.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+Ye,s.RENDERBUFFER,null),t.bindFramebuffer(s.FRAMEBUFFER,Ke.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+Ye,s.TEXTURE_2D,null,0);t.bindFramebuffer(s.READ_FRAMEBUFFER,Ke.__webglMultisampledFramebuffer);const Ge=F.texture.mipmaps;Ge&&Ge.length>0?t.bindFramebuffer(s.DRAW_FRAMEBUFFER,Ke.__webglFramebuffer[0]):t.bindFramebuffer(s.DRAW_FRAMEBUFFER,Ke.__webglFramebuffer);for(let Ye=0;Ye<b.length;Ye++){if(F.resolveDepthBuffer&&(F.depthBuffer&&(fe|=s.DEPTH_BUFFER_BIT),F.stencilBuffer&&F.resolveStencilBuffer&&(fe|=s.STENCIL_BUFFER_BIT)),Re){s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,Ke.__webglColorRenderbuffer[Ye]);const _e=n.get(b[Ye]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,_e,0)}s.blitFramebuffer(0,0,q,ue,0,0,q,ue,fe,s.NEAREST),l===!0&&(ge.length=0,Ne.length=0,ge.push(s.COLOR_ATTACHMENT0+Ye),F.depthBuffer&&F.resolveDepthBuffer===!1&&(ge.push(ie),Ne.push(ie),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,Ne)),s.invalidateFramebuffer(s.READ_FRAMEBUFFER,ge))}if(t.bindFramebuffer(s.READ_FRAMEBUFFER,null),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),Re)for(let Ye=0;Ye<b.length;Ye++){t.bindFramebuffer(s.FRAMEBUFFER,Ke.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+Ye,s.RENDERBUFFER,Ke.__webglColorRenderbuffer[Ye]);const _e=n.get(b[Ye]).__webglTexture;t.bindFramebuffer(s.FRAMEBUFFER,Ke.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+Ye,s.TEXTURE_2D,_e,0)}t.bindFramebuffer(s.DRAW_FRAMEBUFFER,Ke.__webglMultisampledFramebuffer)}else if(F.depthBuffer&&F.resolveDepthBuffer===!1&&l){const b=F.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[b])}}}function ve(F){return Math.min(i.maxSamples,F.samples)}function nt(F){const b=n.get(F);return F.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&b.__useRenderToTexture!==!1}function ke(F){const b=a.render.frame;u.get(F)!==b&&(u.set(F,b),F.update())}function ht(F,b){const q=F.colorSpace,ue=F.format,fe=F.type;return F.isCompressedTexture===!0||F.isVideoTexture===!0||q!==Tn&&q!==zi&&(pt.getTransfer(q)===Ut?(ue!==Hn||fe!==ri)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",q)),b}function Nt(F){return typeof HTMLImageElement<"u"&&F instanceof HTMLImageElement?(c.width=F.naturalWidth||F.width,c.height=F.naturalHeight||F.height):typeof VideoFrame<"u"&&F instanceof VideoFrame?(c.width=F.displayWidth,c.height=F.displayHeight):(c.width=F.width,c.height=F.height),c}this.allocateTextureUnit=j,this.resetTextureUnits=X,this.setTexture2D=de,this.setTexture2DArray=k,this.setTexture3D=ae,this.setTextureCube=G,this.rebindTextures=ee,this.setupRenderTarget=te,this.updateRenderTargetMipmap=I,this.updateMultisampleRenderTarget=dt,this.setupDepthRenderbuffer=Q,this.setupFrameBufferTexture=Te,this.useMultisampledRTT=nt}function jy(s,e){function t(n,i=zi){let r;const a=pt.getTransfer(i);if(n===ri)return s.UNSIGNED_BYTE;if(n===Ll)return s.UNSIGNED_SHORT_4_4_4_4;if(n===Dl)return s.UNSIGNED_SHORT_5_5_5_1;if(n===$u)return s.UNSIGNED_INT_5_9_9_9_REV;if(n===Yu)return s.BYTE;if(n===Zu)return s.SHORT;if(n===fr)return s.UNSIGNED_SHORT;if(n===Pl)return s.INT;if(n===ls)return s.UNSIGNED_INT;if(n===Qn)return s.FLOAT;if(n===wr)return s.HALF_FLOAT;if(n===Ju)return s.ALPHA;if(n===Qu)return s.RGB;if(n===Hn)return s.RGBA;if(n===mr)return s.DEPTH_COMPONENT;if(n===gr)return s.DEPTH_STENCIL;if(n===Il)return s.RED;if(n===Nl)return s.RED_INTEGER;if(n===eh)return s.RG;if(n===Ul)return s.RG_INTEGER;if(n===Fl)return s.RGBA_INTEGER;if(n===ma||n===ga||n===_a||n===ya)if(a===Ut)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===ma)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===ga)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===_a)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===ya)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===ma)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===ga)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===_a)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===ya)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Wo||n===Xo||n===jo||n===qo)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Wo)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Xo)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===jo)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===qo)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Ko||n===Yo||n===Zo)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Ko||n===Yo)return a===Ut?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Zo)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===$o||n===Jo||n===Qo||n===el||n===tl||n===nl||n===il||n===sl||n===rl||n===al||n===ol||n===ll||n===cl||n===ul)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===$o)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Jo)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Qo)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===el)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===tl)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===nl)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===il)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===sl)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===rl)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===al)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===ol)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===ll)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===cl)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===ul)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===xa||n===hl||n===dl)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===xa)return a===Ut?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===hl)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===dl)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===th||n===fl||n===pl||n===ml)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===xa)return r.COMPRESSED_RED_RGTC1_EXT;if(n===fl)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===pl)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===ml)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===pr?s.UNSIGNED_INT_24_8:s[n]!==void 0?s[n]:null}return{convert:t}}const qy=`
3803
+ }`;function Hy(s,e,t){let n=new Gl;const i=new ct,r=new ct,a=new Tt,o=new zp({depthPacking:pf}),l=new Vp,c={},u=t.maxTextureSize,h={[ri]:In,[In]:ri,[Zn]:Zn},d=new Wi({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ct},radius:{value:4}},vertexShader:zy,fragmentShader:Vy}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const g=new Kt;g.setAttribute("position",new hn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new rn(g,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Xu;let p=this.type;this.render=function(P,L,U){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||P.length===0)return;const E=s.getRenderTarget(),T=s.getActiveCubeFace(),D=s.getActiveMipmapLevel(),X=s.state;X.setBlending(Hi),X.buffers.color.setClear(1,1,1,1),X.buffers.depth.setTest(!0),X.setScissorTest(!1);const q=p!==xi&&this.type===xi,se=p===xi&&this.type!==xi;for(let he=0,k=P.length;he<k;he++){const oe=P[he],G=oe.shadow;if(G===void 0){console.warn("THREE.WebGLShadowMap:",oe,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;i.copy(G.mapSize);const fe=G.getFrameExtents();if(i.multiply(fe),r.copy(G.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(r.x=Math.floor(u/fe.x),i.x=r.x*fe.x,G.mapSize.x=r.x),i.y>u&&(r.y=Math.floor(u/fe.y),i.y=r.y*fe.y,G.mapSize.y=r.y)),G.map===null||q===!0||se===!0){const le=this.type!==xi?{minFilter:En,magFilter:En}:{};G.map!==null&&G.map.dispose(),G.map=new cs(i.x,i.y,le),G.map.texture.name=oe.name+".shadowMap",G.camera.updateProjectionMatrix()}s.setRenderTarget(G.map),s.clear();const ve=G.getViewportCount();for(let le=0;le<ve;le++){const we=G.getViewport(le);a.set(r.x*we.x,r.y*we.y,r.x*we.z,r.y*we.w),X.viewport(a),G.updateMatrices(oe,le),n=G.getFrustum(),y(L,U,G.camera,oe,this.type)}G.isPointLightShadow!==!0&&this.type===xi&&S(G,U),G.needsUpdate=!1}p=this.type,m.needsUpdate=!1,s.setRenderTarget(E,T,D)};function S(P,L){const U=e.update(_);d.defines.VSM_SAMPLES!==P.blurSamples&&(d.defines.VSM_SAMPLES=P.blurSamples,f.defines.VSM_SAMPLES=P.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),P.mapPass===null&&(P.mapPass=new cs(i.x,i.y)),d.uniforms.shadow_pass.value=P.map.texture,d.uniforms.resolution.value=P.mapSize,d.uniforms.radius.value=P.radius,s.setRenderTarget(P.mapPass),s.clear(),s.renderBufferDirect(L,null,U,d,_,null),f.uniforms.shadow_pass.value=P.mapPass.texture,f.uniforms.resolution.value=P.mapSize,f.uniforms.radius.value=P.radius,s.setRenderTarget(P.map),s.clear(),s.renderBufferDirect(L,null,U,f,_,null)}function v(P,L,U,E){let T=null;const D=U.isPointLight===!0?P.customDistanceMaterial:P.customDepthMaterial;if(D!==void 0)T=D;else if(T=U.isPointLight===!0?l:o,s.localClippingEnabled&&L.clipShadows===!0&&Array.isArray(L.clippingPlanes)&&L.clippingPlanes.length!==0||L.displacementMap&&L.displacementScale!==0||L.alphaMap&&L.alphaTest>0||L.map&&L.alphaTest>0||L.alphaToCoverage===!0){const X=T.uuid,q=L.uuid;let se=c[X];se===void 0&&(se={},c[X]=se);let he=se[q];he===void 0&&(he=T.clone(),se[q]=he,L.addEventListener("dispose",N)),T=he}if(T.visible=L.visible,T.wireframe=L.wireframe,E===xi?T.side=L.shadowSide!==null?L.shadowSide:L.side:T.side=L.shadowSide!==null?L.shadowSide:h[L.side],T.alphaMap=L.alphaMap,T.alphaTest=L.alphaToCoverage===!0?.5:L.alphaTest,T.map=L.map,T.clipShadows=L.clipShadows,T.clippingPlanes=L.clippingPlanes,T.clipIntersection=L.clipIntersection,T.displacementMap=L.displacementMap,T.displacementScale=L.displacementScale,T.displacementBias=L.displacementBias,T.wireframeLinewidth=L.wireframeLinewidth,T.linewidth=L.linewidth,U.isPointLight===!0&&T.isMeshDistanceMaterial===!0){const X=s.properties.get(T);X.light=U}return T}function y(P,L,U,E,T){if(P.visible===!1)return;if(P.layers.test(L.layers)&&(P.isMesh||P.isLine||P.isPoints)&&(P.castShadow||P.receiveShadow&&T===xi)&&(!P.frustumCulled||n.intersectsObject(P))){P.modelViewMatrix.multiplyMatrices(U.matrixWorldInverse,P.matrixWorld);const q=e.update(P),se=P.material;if(Array.isArray(se)){const he=q.groups;for(let k=0,oe=he.length;k<oe;k++){const G=he[k],fe=se[G.materialIndex];if(fe&&fe.visible){const ve=v(P,fe,E,T);P.onBeforeShadow(s,P,L,U,q,ve,G),s.renderBufferDirect(U,null,q,ve,P,G),P.onAfterShadow(s,P,L,U,q,ve,G)}}}else if(se.visible){const he=v(P,se,E,T);P.onBeforeShadow(s,P,L,U,q,he,null),s.renderBufferDirect(U,null,q,he,P,null),P.onAfterShadow(s,P,L,U,q,he,null)}}const X=P.children;for(let q=0,se=X.length;q<se;q++)y(X[q],L,U,E,T)}function N(P){P.target.removeEventListener("dispose",N);for(const U in c){const E=c[U],T=P.target.uuid;T in E&&(E[T].dispose(),delete E[T])}}}const Gy={[Fo]:Oo,[ko]:Vo,[Bo]:Ho,[Vs]:zo,[Oo]:Fo,[Vo]:ko,[Ho]:Bo,[zo]:Vs};function Wy(s,e){function t(){let B=!1;const Re=new Tt;let ge=null;const Be=new Tt(0,0,0,0);return{setMask:function(ye){ge!==ye&&!B&&(s.colorMask(ye,ye,ye,ye),ge=ye)},setLocked:function(ye){B=ye},setClear:function(ye,j,Ce,Ze,bt){bt===!0&&(ye*=Ze,j*=Ze,Ce*=Ze),Re.set(ye,j,Ce,Ze),Be.equals(Re)===!1&&(s.clearColor(ye,j,Ce,Ze),Be.copy(Re))},reset:function(){B=!1,ge=null,Be.set(-1,0,0,0)}}}function n(){let B=!1,Re=!1,ge=null,Be=null,ye=null;return{setReversed:function(j){if(Re!==j){const Ce=e.get("EXT_clip_control");j?Ce.clipControlEXT(Ce.LOWER_LEFT_EXT,Ce.ZERO_TO_ONE_EXT):Ce.clipControlEXT(Ce.LOWER_LEFT_EXT,Ce.NEGATIVE_ONE_TO_ONE_EXT),Re=j;const Ze=ye;ye=null,this.setClear(Ze)}},getReversed:function(){return Re},setTest:function(j){j?re(s.DEPTH_TEST):Se(s.DEPTH_TEST)},setMask:function(j){ge!==j&&!B&&(s.depthMask(j),ge=j)},setFunc:function(j){if(Re&&(j=Gy[j]),Be!==j){switch(j){case Fo:s.depthFunc(s.NEVER);break;case Oo:s.depthFunc(s.ALWAYS);break;case ko:s.depthFunc(s.LESS);break;case Vs:s.depthFunc(s.LEQUAL);break;case Bo:s.depthFunc(s.EQUAL);break;case zo:s.depthFunc(s.GEQUAL);break;case Vo:s.depthFunc(s.GREATER);break;case Ho:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}Be=j}},setLocked:function(j){B=j},setClear:function(j){ye!==j&&(Re&&(j=1-j),s.clearDepth(j),ye=j)},reset:function(){B=!1,ge=null,Be=null,ye=null,Re=!1}}}function i(){let B=!1,Re=null,ge=null,Be=null,ye=null,j=null,Ce=null,Ze=null,bt=null;return{setTest:function(pt){B||(pt?re(s.STENCIL_TEST):Se(s.STENCIL_TEST))},setMask:function(pt){Re!==pt&&!B&&(s.stencilMask(pt),Re=pt)},setFunc:function(pt,Jt,$e){(ge!==pt||Be!==Jt||ye!==$e)&&(s.stencilFunc(pt,Jt,$e),ge=pt,Be=Jt,ye=$e)},setOp:function(pt,Jt,$e){(j!==pt||Ce!==Jt||Ze!==$e)&&(s.stencilOp(pt,Jt,$e),j=pt,Ce=Jt,Ze=$e)},setLocked:function(pt){B=pt},setClear:function(pt){bt!==pt&&(s.clearStencil(pt),bt=pt)},reset:function(){B=!1,Re=null,ge=null,Be=null,ye=null,j=null,Ce=null,Ze=null,bt=null}}}const r=new t,a=new n,o=new i,l=new WeakMap,c=new WeakMap;let u={},h={},d=new WeakMap,f=[],g=null,_=!1,m=null,p=null,S=null,v=null,y=null,N=null,P=null,L=new Ge(0,0,0),U=0,E=!1,T=null,D=null,X=null,q=null,se=null;const he=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let k=!1,oe=0;const G=s.getParameter(s.VERSION);G.indexOf("WebGL")!==-1?(oe=parseFloat(/^WebGL (\d)/.exec(G)[1]),k=oe>=1):G.indexOf("OpenGL ES")!==-1&&(oe=parseFloat(/^OpenGL ES (\d)/.exec(G)[1]),k=oe>=2);let fe=null,ve={};const le=s.getParameter(s.SCISSOR_BOX),we=s.getParameter(s.VIEWPORT),Me=new Tt().fromArray(le),W=new Tt().fromArray(we);function ee(B,Re,ge,Be){const ye=new Uint8Array(4),j=s.createTexture();s.bindTexture(B,j),s.texParameteri(B,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(B,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let Ce=0;Ce<ge;Ce++)B===s.TEXTURE_3D||B===s.TEXTURE_2D_ARRAY?s.texImage3D(Re,0,s.RGBA,1,1,Be,0,s.RGBA,s.UNSIGNED_BYTE,ye):s.texImage2D(Re+Ce,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,ye);return j}const ae={};ae[s.TEXTURE_2D]=ee(s.TEXTURE_2D,s.TEXTURE_2D,1),ae[s.TEXTURE_CUBE_MAP]=ee(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),ae[s.TEXTURE_2D_ARRAY]=ee(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),ae[s.TEXTURE_3D]=ee(s.TEXTURE_3D,s.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),re(s.DEPTH_TEST),a.setFunc(Vs),de(!1),qe(sc),re(s.CULL_FACE),I(Hi);function re(B){u[B]!==!0&&(s.enable(B),u[B]=!0)}function Se(B){u[B]!==!1&&(s.disable(B),u[B]=!1)}function ot(B,Re){return h[B]!==Re?(s.bindFramebuffer(B,Re),h[B]=Re,B===s.DRAW_FRAMEBUFFER&&(h[s.FRAMEBUFFER]=Re),B===s.FRAMEBUFFER&&(h[s.DRAW_FRAMEBUFFER]=Re),!0):!1}function J(B,Re){let ge=f,Be=!1;if(B){ge=d.get(Re),ge===void 0&&(ge=[],d.set(Re,ge));const ye=B.textures;if(ge.length!==ye.length||ge[0]!==s.COLOR_ATTACHMENT0){for(let j=0,Ce=ye.length;j<Ce;j++)ge[j]=s.COLOR_ATTACHMENT0+j;ge.length=ye.length,Be=!0}}else ge[0]!==s.BACK&&(ge[0]=s.BACK,Be=!0);Be&&s.drawBuffers(ge)}function $(B){return g!==B?(s.useProgram(B),g=B,!0):!1}const Z={[ss]:s.FUNC_ADD,[Od]:s.FUNC_SUBTRACT,[kd]:s.FUNC_REVERSE_SUBTRACT};Z[Bd]=s.MIN,Z[zd]=s.MAX;const ie={[Vd]:s.ZERO,[Hd]:s.ONE,[Gd]:s.SRC_COLOR,[No]:s.SRC_ALPHA,[Yd]:s.SRC_ALPHA_SATURATE,[qd]:s.DST_COLOR,[Xd]:s.DST_ALPHA,[Wd]:s.ONE_MINUS_SRC_COLOR,[Uo]:s.ONE_MINUS_SRC_ALPHA,[Kd]:s.ONE_MINUS_DST_COLOR,[jd]:s.ONE_MINUS_DST_ALPHA,[Zd]:s.CONSTANT_COLOR,[$d]:s.ONE_MINUS_CONSTANT_COLOR,[Jd]:s.CONSTANT_ALPHA,[Qd]:s.ONE_MINUS_CONSTANT_ALPHA};function I(B,Re,ge,Be,ye,j,Ce,Ze,bt,pt){if(B===Hi){_===!0&&(Se(s.BLEND),_=!1);return}if(_===!1&&(re(s.BLEND),_=!0),B!==Fd){if(B!==m||pt!==E){if((p!==ss||y!==ss)&&(s.blendEquation(s.FUNC_ADD),p=ss,y=ss),pt)switch(B){case Os:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case rc:s.blendFunc(s.ONE,s.ONE);break;case ac:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case oc:s.blendFuncSeparate(s.ZERO,s.SRC_COLOR,s.ZERO,s.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",B);break}else switch(B){case Os:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case rc:s.blendFunc(s.SRC_ALPHA,s.ONE);break;case ac:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case oc:s.blendFunc(s.ZERO,s.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",B);break}S=null,v=null,N=null,P=null,L.set(0,0,0),U=0,m=B,E=pt}return}ye=ye||Re,j=j||ge,Ce=Ce||Be,(Re!==p||ye!==y)&&(s.blendEquationSeparate(Z[Re],Z[ye]),p=Re,y=ye),(ge!==S||Be!==v||j!==N||Ce!==P)&&(s.blendFuncSeparate(ie[ge],ie[Be],ie[j],ie[Ce]),S=ge,v=Be,N=j,P=Ce),(Ze.equals(L)===!1||bt!==U)&&(s.blendColor(Ze.r,Ze.g,Ze.b,bt),L.copy(Ze),U=bt),m=B,E=!1}function Te(B,Re){B.side===Zn?Se(s.CULL_FACE):re(s.CULL_FACE);let ge=B.side===In;Re&&(ge=!ge),de(ge),B.blending===Os&&B.transparent===!1?I(Hi):I(B.blending,B.blendEquation,B.blendSrc,B.blendDst,B.blendEquationAlpha,B.blendSrcAlpha,B.blendDstAlpha,B.blendColor,B.blendAlpha,B.premultipliedAlpha),a.setFunc(B.depthFunc),a.setTest(B.depthTest),a.setMask(B.depthWrite),r.setMask(B.colorWrite);const Be=B.stencilWrite;o.setTest(Be),Be&&(o.setMask(B.stencilWriteMask),o.setFunc(B.stencilFunc,B.stencilRef,B.stencilFuncMask),o.setOp(B.stencilFail,B.stencilZFail,B.stencilZPass)),Oe(B.polygonOffset,B.polygonOffsetFactor,B.polygonOffsetUnits),B.alphaToCoverage===!0?re(s.SAMPLE_ALPHA_TO_COVERAGE):Se(s.SAMPLE_ALPHA_TO_COVERAGE)}function de(B){T!==B&&(B?s.frontFace(s.CW):s.frontFace(s.CCW),T=B)}function qe(B){B!==Nd?(re(s.CULL_FACE),B!==D&&(B===sc?s.cullFace(s.BACK):B===Ud?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):Se(s.CULL_FACE),D=B}function De(B){B!==X&&(k&&s.lineWidth(B),X=B)}function Oe(B,Re,ge){B?(re(s.POLYGON_OFFSET_FILL),(q!==Re||se!==ge)&&(s.polygonOffset(Re,ge),q=Re,se=ge)):Se(s.POLYGON_OFFSET_FILL)}function Ie(B){B?re(s.SCISSOR_TEST):Se(s.SCISSOR_TEST)}function tt(B){B===void 0&&(B=s.TEXTURE0+he-1),fe!==B&&(s.activeTexture(B),fe=B)}function Nt(B,Re,ge){ge===void 0&&(fe===null?ge=s.TEXTURE0+he-1:ge=fe);let Be=ve[ge];Be===void 0&&(Be={type:void 0,texture:void 0},ve[ge]=Be),(Be.type!==B||Be.texture!==Re)&&(fe!==ge&&(s.activeTexture(ge),fe=ge),s.bindTexture(B,Re||ae[B]),Be.type=B,Be.texture=Re)}function F(){const B=ve[fe];B!==void 0&&B.type!==void 0&&(s.bindTexture(B.type,null),B.type=void 0,B.texture=void 0)}function b(){try{s.compressedTexImage2D(...arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function K(){try{s.compressedTexImage3D(...arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function ce(){try{s.texSubImage2D(...arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function pe(){try{s.texSubImage3D(...arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function ne(){try{s.compressedTexSubImage2D(...arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function ze(){try{s.compressedTexSubImage3D(...arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function Ae(){try{s.texStorage2D(...arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function We(){try{s.texStorage3D(...arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function Ye(){try{s.texImage2D(...arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function me(){try{s.texImage3D(...arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function ke(B){Me.equals(B)===!1&&(s.scissor(B.x,B.y,B.z,B.w),Me.copy(B))}function st(B){W.equals(B)===!1&&(s.viewport(B.x,B.y,B.z,B.w),W.copy(B))}function nt(B,Re){let ge=c.get(Re);ge===void 0&&(ge=new WeakMap,c.set(Re,ge));let Be=ge.get(B);Be===void 0&&(Be=s.getUniformBlockIndex(Re,B.name),ge.set(B,Be))}function be(B,Re){const Be=c.get(Re).get(B);l.get(Re)!==Be&&(s.uniformBlockBinding(Re,Be,B.__bindingPointIndex),l.set(Re,Be))}function lt(){s.disable(s.BLEND),s.disable(s.CULL_FACE),s.disable(s.DEPTH_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SCISSOR_TEST),s.disable(s.STENCIL_TEST),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),s.blendEquation(s.FUNC_ADD),s.blendFunc(s.ONE,s.ZERO),s.blendFuncSeparate(s.ONE,s.ZERO,s.ONE,s.ZERO),s.blendColor(0,0,0,0),s.colorMask(!0,!0,!0,!0),s.clearColor(0,0,0,0),s.depthMask(!0),s.depthFunc(s.LESS),a.setReversed(!1),s.clearDepth(1),s.stencilMask(4294967295),s.stencilFunc(s.ALWAYS,0,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),s.clearStencil(0),s.cullFace(s.BACK),s.frontFace(s.CCW),s.polygonOffset(0,0),s.activeTexture(s.TEXTURE0),s.bindFramebuffer(s.FRAMEBUFFER,null),s.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),s.bindFramebuffer(s.READ_FRAMEBUFFER,null),s.useProgram(null),s.lineWidth(1),s.scissor(0,0,s.canvas.width,s.canvas.height),s.viewport(0,0,s.canvas.width,s.canvas.height),u={},fe=null,ve={},h={},d=new WeakMap,f=[],g=null,_=!1,m=null,p=null,S=null,v=null,y=null,N=null,P=null,L=new Ge(0,0,0),U=0,E=!1,T=null,D=null,X=null,q=null,se=null,Me.set(0,0,s.canvas.width,s.canvas.height),W.set(0,0,s.canvas.width,s.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:re,disable:Se,bindFramebuffer:ot,drawBuffers:J,useProgram:$,setBlending:I,setMaterial:Te,setFlipSided:de,setCullFace:qe,setLineWidth:De,setPolygonOffset:Oe,setScissorTest:Ie,activeTexture:tt,bindTexture:Nt,unbindTexture:F,compressedTexImage2D:b,compressedTexImage3D:K,texImage2D:Ye,texImage3D:me,updateUBOMapping:nt,uniformBlockBinding:be,texStorage2D:Ae,texStorage3D:We,texSubImage2D:ce,texSubImage3D:pe,compressedTexSubImage2D:ne,compressedTexSubImage3D:ze,scissor:ke,viewport:st,reset:lt}}function Xy(s,e,t,n,i,r,a){const o=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 ct,u=new WeakMap;let h;const d=new WeakMap;let f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(F,b){return f?new OffscreenCanvas(F,b):xr("canvas")}function _(F,b,K){let ce=1;const pe=Nt(F);if((pe.width>K||pe.height>K)&&(ce=K/Math.max(pe.width,pe.height)),ce<1)if(typeof HTMLImageElement<"u"&&F instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&F instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&F instanceof ImageBitmap||typeof VideoFrame<"u"&&F instanceof VideoFrame){const ne=Math.floor(ce*pe.width),ze=Math.floor(ce*pe.height);h===void 0&&(h=g(ne,ze));const Ae=b?g(ne,ze):h;return Ae.width=ne,Ae.height=ze,Ae.getContext("2d").drawImage(F,0,0,ne,ze),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+pe.width+"x"+pe.height+") to ("+ne+"x"+ze+")."),Ae}else return"data"in F&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+pe.width+"x"+pe.height+")."),F;return F}function m(F){return F.generateMipmaps}function p(F){s.generateMipmap(F)}function S(F){return F.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:F.isWebGL3DRenderTarget?s.TEXTURE_3D:F.isWebGLArrayRenderTarget||F.isCompressedArrayTexture?s.TEXTURE_2D_ARRAY:s.TEXTURE_2D}function v(F,b,K,ce,pe=!1){if(F!==null){if(s[F]!==void 0)return s[F];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+F+"'")}let ne=b;if(b===s.RED&&(K===s.FLOAT&&(ne=s.R32F),K===s.HALF_FLOAT&&(ne=s.R16F),K===s.UNSIGNED_BYTE&&(ne=s.R8)),b===s.RED_INTEGER&&(K===s.UNSIGNED_BYTE&&(ne=s.R8UI),K===s.UNSIGNED_SHORT&&(ne=s.R16UI),K===s.UNSIGNED_INT&&(ne=s.R32UI),K===s.BYTE&&(ne=s.R8I),K===s.SHORT&&(ne=s.R16I),K===s.INT&&(ne=s.R32I)),b===s.RG&&(K===s.FLOAT&&(ne=s.RG32F),K===s.HALF_FLOAT&&(ne=s.RG16F),K===s.UNSIGNED_BYTE&&(ne=s.RG8)),b===s.RG_INTEGER&&(K===s.UNSIGNED_BYTE&&(ne=s.RG8UI),K===s.UNSIGNED_SHORT&&(ne=s.RG16UI),K===s.UNSIGNED_INT&&(ne=s.RG32UI),K===s.BYTE&&(ne=s.RG8I),K===s.SHORT&&(ne=s.RG16I),K===s.INT&&(ne=s.RG32I)),b===s.RGB_INTEGER&&(K===s.UNSIGNED_BYTE&&(ne=s.RGB8UI),K===s.UNSIGNED_SHORT&&(ne=s.RGB16UI),K===s.UNSIGNED_INT&&(ne=s.RGB32UI),K===s.BYTE&&(ne=s.RGB8I),K===s.SHORT&&(ne=s.RGB16I),K===s.INT&&(ne=s.RGB32I)),b===s.RGBA_INTEGER&&(K===s.UNSIGNED_BYTE&&(ne=s.RGBA8UI),K===s.UNSIGNED_SHORT&&(ne=s.RGBA16UI),K===s.UNSIGNED_INT&&(ne=s.RGBA32UI),K===s.BYTE&&(ne=s.RGBA8I),K===s.SHORT&&(ne=s.RGBA16I),K===s.INT&&(ne=s.RGBA32I)),b===s.RGB&&K===s.UNSIGNED_INT_5_9_9_9_REV&&(ne=s.RGB9_E5),b===s.RGBA){const ze=pe?Aa:ft.getTransfer(ce);K===s.FLOAT&&(ne=s.RGBA32F),K===s.HALF_FLOAT&&(ne=s.RGBA16F),K===s.UNSIGNED_BYTE&&(ne=ze===Ut?s.SRGB8_ALPHA8:s.RGBA8),K===s.UNSIGNED_SHORT_4_4_4_4&&(ne=s.RGBA4),K===s.UNSIGNED_SHORT_5_5_5_1&&(ne=s.RGB5_A1)}return(ne===s.R16F||ne===s.R32F||ne===s.RG16F||ne===s.RG32F||ne===s.RGBA16F||ne===s.RGBA32F)&&e.get("EXT_color_buffer_float"),ne}function y(F,b){let K;return F?b===null||b===ls||b===mr?K=s.DEPTH24_STENCIL8:b===ei?K=s.DEPTH32F_STENCIL8:b===pr&&(K=s.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):b===null||b===ls||b===mr?K=s.DEPTH_COMPONENT24:b===ei?K=s.DEPTH_COMPONENT32F:b===pr&&(K=s.DEPTH_COMPONENT16),K}function N(F,b){return m(F)===!0||F.isFramebufferTexture&&F.minFilter!==En&&F.minFilter!==yn?Math.log2(Math.max(b.width,b.height))+1:F.mipmaps!==void 0&&F.mipmaps.length>0?F.mipmaps.length:F.isCompressedTexture&&Array.isArray(F.image)?b.mipmaps.length:1}function P(F){const b=F.target;b.removeEventListener("dispose",P),U(b),b.isVideoTexture&&u.delete(b)}function L(F){const b=F.target;b.removeEventListener("dispose",L),T(b)}function U(F){const b=n.get(F);if(b.__webglInit===void 0)return;const K=F.source,ce=d.get(K);if(ce){const pe=ce[b.__cacheKey];pe.usedTimes--,pe.usedTimes===0&&E(F),Object.keys(ce).length===0&&d.delete(K)}n.remove(F)}function E(F){const b=n.get(F);s.deleteTexture(b.__webglTexture);const K=F.source,ce=d.get(K);delete ce[b.__cacheKey],a.memory.textures--}function T(F){const b=n.get(F);if(F.depthTexture&&(F.depthTexture.dispose(),n.remove(F.depthTexture)),F.isWebGLCubeRenderTarget)for(let ce=0;ce<6;ce++){if(Array.isArray(b.__webglFramebuffer[ce]))for(let pe=0;pe<b.__webglFramebuffer[ce].length;pe++)s.deleteFramebuffer(b.__webglFramebuffer[ce][pe]);else s.deleteFramebuffer(b.__webglFramebuffer[ce]);b.__webglDepthbuffer&&s.deleteRenderbuffer(b.__webglDepthbuffer[ce])}else{if(Array.isArray(b.__webglFramebuffer))for(let ce=0;ce<b.__webglFramebuffer.length;ce++)s.deleteFramebuffer(b.__webglFramebuffer[ce]);else s.deleteFramebuffer(b.__webglFramebuffer);if(b.__webglDepthbuffer&&s.deleteRenderbuffer(b.__webglDepthbuffer),b.__webglMultisampledFramebuffer&&s.deleteFramebuffer(b.__webglMultisampledFramebuffer),b.__webglColorRenderbuffer)for(let ce=0;ce<b.__webglColorRenderbuffer.length;ce++)b.__webglColorRenderbuffer[ce]&&s.deleteRenderbuffer(b.__webglColorRenderbuffer[ce]);b.__webglDepthRenderbuffer&&s.deleteRenderbuffer(b.__webglDepthRenderbuffer)}const K=F.textures;for(let ce=0,pe=K.length;ce<pe;ce++){const ne=n.get(K[ce]);ne.__webglTexture&&(s.deleteTexture(ne.__webglTexture),a.memory.textures--),n.remove(K[ce])}n.remove(F)}let D=0;function X(){D=0}function q(){const F=D;return F>=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+F+" texture units while this GPU supports only "+i.maxTextures),D+=1,F}function se(F){const b=[];return b.push(F.wrapS),b.push(F.wrapT),b.push(F.wrapR||0),b.push(F.magFilter),b.push(F.minFilter),b.push(F.anisotropy),b.push(F.internalFormat),b.push(F.format),b.push(F.type),b.push(F.generateMipmaps),b.push(F.premultiplyAlpha),b.push(F.flipY),b.push(F.unpackAlignment),b.push(F.colorSpace),b.join()}function he(F,b){const K=n.get(F);if(F.isVideoTexture&&Ie(F),F.isRenderTargetTexture===!1&&F.version>0&&K.__version!==F.version){const ce=F.image;if(ce===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ce.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ae(K,F,b);return}}t.bindTexture(s.TEXTURE_2D,K.__webglTexture,s.TEXTURE0+b)}function k(F,b){const K=n.get(F);if(F.version>0&&K.__version!==F.version){ae(K,F,b);return}t.bindTexture(s.TEXTURE_2D_ARRAY,K.__webglTexture,s.TEXTURE0+b)}function oe(F,b){const K=n.get(F);if(F.version>0&&K.__version!==F.version){ae(K,F,b);return}t.bindTexture(s.TEXTURE_3D,K.__webglTexture,s.TEXTURE0+b)}function G(F,b){const K=n.get(F);if(F.version>0&&K.__version!==F.version){re(K,F,b);return}t.bindTexture(s.TEXTURE_CUBE_MAP,K.__webglTexture,s.TEXTURE0+b)}const fe={[Hn]:s.REPEAT,[Dn]:s.CLAMP_TO_EDGE,[Ea]:s.MIRRORED_REPEAT},ve={[En]:s.NEAREST,[Ku]:s.NEAREST_MIPMAP_NEAREST,[or]:s.NEAREST_MIPMAP_LINEAR,[yn]:s.LINEAR,[ma]:s.LINEAR_MIPMAP_NEAREST,[Qn]:s.LINEAR_MIPMAP_LINEAR},le={[gf]:s.NEVER,[Sf]:s.ALWAYS,[_f]:s.LESS,[ih]:s.LEQUAL,[yf]:s.EQUAL,[Mf]:s.GEQUAL,[vf]:s.GREATER,[xf]:s.NOTEQUAL};function we(F,b){if(b.type===ei&&e.has("OES_texture_float_linear")===!1&&(b.magFilter===yn||b.magFilter===ma||b.magFilter===or||b.magFilter===Qn||b.minFilter===yn||b.minFilter===ma||b.minFilter===or||b.minFilter===Qn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(F,s.TEXTURE_WRAP_S,fe[b.wrapS]),s.texParameteri(F,s.TEXTURE_WRAP_T,fe[b.wrapT]),(F===s.TEXTURE_3D||F===s.TEXTURE_2D_ARRAY)&&s.texParameteri(F,s.TEXTURE_WRAP_R,fe[b.wrapR]),s.texParameteri(F,s.TEXTURE_MAG_FILTER,ve[b.magFilter]),s.texParameteri(F,s.TEXTURE_MIN_FILTER,ve[b.minFilter]),b.compareFunction&&(s.texParameteri(F,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(F,s.TEXTURE_COMPARE_FUNC,le[b.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(b.magFilter===En||b.minFilter!==or&&b.minFilter!==Qn||b.type===ei&&e.has("OES_texture_float_linear")===!1)return;if(b.anisotropy>1||n.get(b).__currentAnisotropy){const K=e.get("EXT_texture_filter_anisotropic");s.texParameterf(F,K.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(b.anisotropy,i.getMaxAnisotropy())),n.get(b).__currentAnisotropy=b.anisotropy}}}function Me(F,b){let K=!1;F.__webglInit===void 0&&(F.__webglInit=!0,b.addEventListener("dispose",P));const ce=b.source;let pe=d.get(ce);pe===void 0&&(pe={},d.set(ce,pe));const ne=se(b);if(ne!==F.__cacheKey){pe[ne]===void 0&&(pe[ne]={texture:s.createTexture(),usedTimes:0},a.memory.textures++,K=!0),pe[ne].usedTimes++;const ze=pe[F.__cacheKey];ze!==void 0&&(pe[F.__cacheKey].usedTimes--,ze.usedTimes===0&&E(b)),F.__cacheKey=ne,F.__webglTexture=pe[ne].texture}return K}function W(F,b,K){return Math.floor(Math.floor(F/K)/b)}function ee(F,b,K,ce){const ne=F.updateRanges;if(ne.length===0)t.texSubImage2D(s.TEXTURE_2D,0,0,0,b.width,b.height,K,ce,b.data);else{ne.sort((me,ke)=>me.start-ke.start);let ze=0;for(let me=1;me<ne.length;me++){const ke=ne[ze],st=ne[me],nt=ke.start+ke.count,be=W(st.start,b.width,4),lt=W(ke.start,b.width,4);st.start<=nt+1&&be===lt&&W(st.start+st.count-1,b.width,4)===be?ke.count=Math.max(ke.count,st.start+st.count-ke.start):(++ze,ne[ze]=st)}ne.length=ze+1;const Ae=s.getParameter(s.UNPACK_ROW_LENGTH),We=s.getParameter(s.UNPACK_SKIP_PIXELS),Ye=s.getParameter(s.UNPACK_SKIP_ROWS);s.pixelStorei(s.UNPACK_ROW_LENGTH,b.width);for(let me=0,ke=ne.length;me<ke;me++){const st=ne[me],nt=Math.floor(st.start/4),be=Math.ceil(st.count/4),lt=nt%b.width,B=Math.floor(nt/b.width),Re=be,ge=1;s.pixelStorei(s.UNPACK_SKIP_PIXELS,lt),s.pixelStorei(s.UNPACK_SKIP_ROWS,B),t.texSubImage2D(s.TEXTURE_2D,0,lt,B,Re,ge,K,ce,b.data)}F.clearUpdateRanges(),s.pixelStorei(s.UNPACK_ROW_LENGTH,Ae),s.pixelStorei(s.UNPACK_SKIP_PIXELS,We),s.pixelStorei(s.UNPACK_SKIP_ROWS,Ye)}}function ae(F,b,K){let ce=s.TEXTURE_2D;(b.isDataArrayTexture||b.isCompressedArrayTexture)&&(ce=s.TEXTURE_2D_ARRAY),b.isData3DTexture&&(ce=s.TEXTURE_3D);const pe=Me(F,b),ne=b.source;t.bindTexture(ce,F.__webglTexture,s.TEXTURE0+K);const ze=n.get(ne);if(ne.version!==ze.__version||pe===!0){t.activeTexture(s.TEXTURE0+K);const Ae=ft.getPrimaries(ft.workingColorSpace),We=b.colorSpace===zi?null:ft.getPrimaries(b.colorSpace),Ye=b.colorSpace===zi||Ae===We?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,b.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,b.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,b.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ye);let me=_(b.image,!1,i.maxTextureSize);me=tt(b,me);const ke=r.convert(b.format,b.colorSpace),st=r.convert(b.type);let nt=v(b.internalFormat,ke,st,b.colorSpace,b.isVideoTexture);we(ce,b);let be;const lt=b.mipmaps,B=b.isVideoTexture!==!0,Re=ze.__version===void 0||pe===!0,ge=ne.dataReady,Be=N(b,me);if(b.isDepthTexture)nt=y(b.format===_r,b.type),Re&&(B?t.texStorage2D(s.TEXTURE_2D,1,nt,me.width,me.height):t.texImage2D(s.TEXTURE_2D,0,nt,me.width,me.height,0,ke,st,null));else if(b.isDataTexture)if(lt.length>0){B&&Re&&t.texStorage2D(s.TEXTURE_2D,Be,nt,lt[0].width,lt[0].height);for(let ye=0,j=lt.length;ye<j;ye++)be=lt[ye],B?ge&&t.texSubImage2D(s.TEXTURE_2D,ye,0,0,be.width,be.height,ke,st,be.data):t.texImage2D(s.TEXTURE_2D,ye,nt,be.width,be.height,0,ke,st,be.data);b.generateMipmaps=!1}else B?(Re&&t.texStorage2D(s.TEXTURE_2D,Be,nt,me.width,me.height),ge&&ee(b,me,ke,st)):t.texImage2D(s.TEXTURE_2D,0,nt,me.width,me.height,0,ke,st,me.data);else if(b.isCompressedTexture)if(b.isCompressedArrayTexture){B&&Re&&t.texStorage3D(s.TEXTURE_2D_ARRAY,Be,nt,lt[0].width,lt[0].height,me.depth);for(let ye=0,j=lt.length;ye<j;ye++)if(be=lt[ye],b.format!==Gn)if(ke!==null)if(B){if(ge)if(b.layerUpdates.size>0){const Ce=eu(be.width,be.height,b.format,b.type);for(const Ze of b.layerUpdates){const bt=be.data.subarray(Ze*Ce/be.data.BYTES_PER_ELEMENT,(Ze+1)*Ce/be.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,ye,0,0,Ze,be.width,be.height,1,ke,bt)}b.clearLayerUpdates()}else t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,ye,0,0,0,be.width,be.height,me.depth,ke,be.data)}else t.compressedTexImage3D(s.TEXTURE_2D_ARRAY,ye,nt,be.width,be.height,me.depth,0,be.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else B?ge&&t.texSubImage3D(s.TEXTURE_2D_ARRAY,ye,0,0,0,be.width,be.height,me.depth,ke,st,be.data):t.texImage3D(s.TEXTURE_2D_ARRAY,ye,nt,be.width,be.height,me.depth,0,ke,st,be.data)}else{B&&Re&&t.texStorage2D(s.TEXTURE_2D,Be,nt,lt[0].width,lt[0].height);for(let ye=0,j=lt.length;ye<j;ye++)be=lt[ye],b.format!==Gn?ke!==null?B?ge&&t.compressedTexSubImage2D(s.TEXTURE_2D,ye,0,0,be.width,be.height,ke,be.data):t.compressedTexImage2D(s.TEXTURE_2D,ye,nt,be.width,be.height,0,be.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):B?ge&&t.texSubImage2D(s.TEXTURE_2D,ye,0,0,be.width,be.height,ke,st,be.data):t.texImage2D(s.TEXTURE_2D,ye,nt,be.width,be.height,0,ke,st,be.data)}else if(b.isDataArrayTexture)if(B){if(Re&&t.texStorage3D(s.TEXTURE_2D_ARRAY,Be,nt,me.width,me.height,me.depth),ge)if(b.layerUpdates.size>0){const ye=eu(me.width,me.height,b.format,b.type);for(const j of b.layerUpdates){const Ce=me.data.subarray(j*ye/me.data.BYTES_PER_ELEMENT,(j+1)*ye/me.data.BYTES_PER_ELEMENT);t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,j,me.width,me.height,1,ke,st,Ce)}b.clearLayerUpdates()}else t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,me.width,me.height,me.depth,ke,st,me.data)}else t.texImage3D(s.TEXTURE_2D_ARRAY,0,nt,me.width,me.height,me.depth,0,ke,st,me.data);else if(b.isData3DTexture)B?(Re&&t.texStorage3D(s.TEXTURE_3D,Be,nt,me.width,me.height,me.depth),ge&&t.texSubImage3D(s.TEXTURE_3D,0,0,0,0,me.width,me.height,me.depth,ke,st,me.data)):t.texImage3D(s.TEXTURE_3D,0,nt,me.width,me.height,me.depth,0,ke,st,me.data);else if(b.isFramebufferTexture){if(Re)if(B)t.texStorage2D(s.TEXTURE_2D,Be,nt,me.width,me.height);else{let ye=me.width,j=me.height;for(let Ce=0;Ce<Be;Ce++)t.texImage2D(s.TEXTURE_2D,Ce,nt,ye,j,0,ke,st,null),ye>>=1,j>>=1}}else if(lt.length>0){if(B&&Re){const ye=Nt(lt[0]);t.texStorage2D(s.TEXTURE_2D,Be,nt,ye.width,ye.height)}for(let ye=0,j=lt.length;ye<j;ye++)be=lt[ye],B?ge&&t.texSubImage2D(s.TEXTURE_2D,ye,0,0,ke,st,be):t.texImage2D(s.TEXTURE_2D,ye,nt,ke,st,be);b.generateMipmaps=!1}else if(B){if(Re){const ye=Nt(me);t.texStorage2D(s.TEXTURE_2D,Be,nt,ye.width,ye.height)}ge&&t.texSubImage2D(s.TEXTURE_2D,0,0,0,ke,st,me)}else t.texImage2D(s.TEXTURE_2D,0,nt,ke,st,me);m(b)&&p(ce),ze.__version=ne.version,b.onUpdate&&b.onUpdate(b)}F.__version=b.version}function re(F,b,K){if(b.image.length!==6)return;const ce=Me(F,b),pe=b.source;t.bindTexture(s.TEXTURE_CUBE_MAP,F.__webglTexture,s.TEXTURE0+K);const ne=n.get(pe);if(pe.version!==ne.__version||ce===!0){t.activeTexture(s.TEXTURE0+K);const ze=ft.getPrimaries(ft.workingColorSpace),Ae=b.colorSpace===zi?null:ft.getPrimaries(b.colorSpace),We=b.colorSpace===zi||ze===Ae?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,b.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,b.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,b.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,We);const Ye=b.isCompressedTexture||b.image[0].isCompressedTexture,me=b.image[0]&&b.image[0].isDataTexture,ke=[];for(let j=0;j<6;j++)!Ye&&!me?ke[j]=_(b.image[j],!0,i.maxCubemapSize):ke[j]=me?b.image[j].image:b.image[j],ke[j]=tt(b,ke[j]);const st=ke[0],nt=r.convert(b.format,b.colorSpace),be=r.convert(b.type),lt=v(b.internalFormat,nt,be,b.colorSpace),B=b.isVideoTexture!==!0,Re=ne.__version===void 0||ce===!0,ge=pe.dataReady;let Be=N(b,st);we(s.TEXTURE_CUBE_MAP,b);let ye;if(Ye){B&&Re&&t.texStorage2D(s.TEXTURE_CUBE_MAP,Be,lt,st.width,st.height);for(let j=0;j<6;j++){ye=ke[j].mipmaps;for(let Ce=0;Ce<ye.length;Ce++){const Ze=ye[Ce];b.format!==Gn?nt!==null?B?ge&&t.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+j,Ce,0,0,Ze.width,Ze.height,nt,Ze.data):t.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+j,Ce,lt,Ze.width,Ze.height,0,Ze.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):B?ge&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+j,Ce,0,0,Ze.width,Ze.height,nt,be,Ze.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+j,Ce,lt,Ze.width,Ze.height,0,nt,be,Ze.data)}}}else{if(ye=b.mipmaps,B&&Re){ye.length>0&&Be++;const j=Nt(ke[0]);t.texStorage2D(s.TEXTURE_CUBE_MAP,Be,lt,j.width,j.height)}for(let j=0;j<6;j++)if(me){B?ge&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,0,0,ke[j].width,ke[j].height,nt,be,ke[j].data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,lt,ke[j].width,ke[j].height,0,nt,be,ke[j].data);for(let Ce=0;Ce<ye.length;Ce++){const bt=ye[Ce].image[j].image;B?ge&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+j,Ce+1,0,0,bt.width,bt.height,nt,be,bt.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+j,Ce+1,lt,bt.width,bt.height,0,nt,be,bt.data)}}else{B?ge&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,0,0,nt,be,ke[j]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,lt,nt,be,ke[j]);for(let Ce=0;Ce<ye.length;Ce++){const Ze=ye[Ce];B?ge&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+j,Ce+1,0,0,nt,be,Ze.image[j]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+j,Ce+1,lt,nt,be,Ze.image[j])}}}m(b)&&p(s.TEXTURE_CUBE_MAP),ne.__version=pe.version,b.onUpdate&&b.onUpdate(b)}F.__version=b.version}function Se(F,b,K,ce,pe,ne){const ze=r.convert(K.format,K.colorSpace),Ae=r.convert(K.type),We=v(K.internalFormat,ze,Ae,K.colorSpace),Ye=n.get(b),me=n.get(K);if(me.__renderTarget=b,!Ye.__hasExternalTextures){const ke=Math.max(1,b.width>>ne),st=Math.max(1,b.height>>ne);pe===s.TEXTURE_3D||pe===s.TEXTURE_2D_ARRAY?t.texImage3D(pe,ne,We,ke,st,b.depth,0,ze,Ae,null):t.texImage2D(pe,ne,We,ke,st,0,ze,Ae,null)}t.bindFramebuffer(s.FRAMEBUFFER,F),Oe(b)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,ce,pe,me.__webglTexture,0,De(b)):(pe===s.TEXTURE_2D||pe>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&pe<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,ce,pe,me.__webglTexture,ne),t.bindFramebuffer(s.FRAMEBUFFER,null)}function ot(F,b,K){if(s.bindRenderbuffer(s.RENDERBUFFER,F),b.depthBuffer){const ce=b.depthTexture,pe=ce&&ce.isDepthTexture?ce.type:null,ne=y(b.stencilBuffer,pe),ze=b.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,Ae=De(b);Oe(b)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Ae,ne,b.width,b.height):K?s.renderbufferStorageMultisample(s.RENDERBUFFER,Ae,ne,b.width,b.height):s.renderbufferStorage(s.RENDERBUFFER,ne,b.width,b.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,ze,s.RENDERBUFFER,F)}else{const ce=b.textures;for(let pe=0;pe<ce.length;pe++){const ne=ce[pe],ze=r.convert(ne.format,ne.colorSpace),Ae=r.convert(ne.type),We=v(ne.internalFormat,ze,Ae,ne.colorSpace),Ye=De(b);K&&Oe(b)===!1?s.renderbufferStorageMultisample(s.RENDERBUFFER,Ye,We,b.width,b.height):Oe(b)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Ye,We,b.width,b.height):s.renderbufferStorage(s.RENDERBUFFER,We,b.width,b.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function J(F,b){if(b&&b.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(s.FRAMEBUFFER,F),!(b.depthTexture&&b.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const ce=n.get(b.depthTexture);ce.__renderTarget=b,(!ce.__webglTexture||b.depthTexture.image.width!==b.width||b.depthTexture.image.height!==b.height)&&(b.depthTexture.image.width=b.width,b.depthTexture.image.height=b.height,b.depthTexture.needsUpdate=!0),he(b.depthTexture,0);const pe=ce.__webglTexture,ne=De(b);if(b.depthTexture.format===gr)Oe(b)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,pe,0,ne):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,pe,0);else if(b.depthTexture.format===_r)Oe(b)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,pe,0,ne):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,pe,0);else throw new Error("Unknown depthTexture format")}function $(F){const b=n.get(F),K=F.isWebGLCubeRenderTarget===!0;if(b.__boundDepthTexture!==F.depthTexture){const ce=F.depthTexture;if(b.__depthDisposeCallback&&b.__depthDisposeCallback(),ce){const pe=()=>{delete b.__boundDepthTexture,delete b.__depthDisposeCallback,ce.removeEventListener("dispose",pe)};ce.addEventListener("dispose",pe),b.__depthDisposeCallback=pe}b.__boundDepthTexture=ce}if(F.depthTexture&&!b.__autoAllocateDepthBuffer){if(K)throw new Error("target.depthTexture not supported in Cube render targets");const ce=F.texture.mipmaps;ce&&ce.length>0?J(b.__webglFramebuffer[0],F):J(b.__webglFramebuffer,F)}else if(K){b.__webglDepthbuffer=[];for(let ce=0;ce<6;ce++)if(t.bindFramebuffer(s.FRAMEBUFFER,b.__webglFramebuffer[ce]),b.__webglDepthbuffer[ce]===void 0)b.__webglDepthbuffer[ce]=s.createRenderbuffer(),ot(b.__webglDepthbuffer[ce],F,!1);else{const pe=F.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,ne=b.__webglDepthbuffer[ce];s.bindRenderbuffer(s.RENDERBUFFER,ne),s.framebufferRenderbuffer(s.FRAMEBUFFER,pe,s.RENDERBUFFER,ne)}}else{const ce=F.texture.mipmaps;if(ce&&ce.length>0?t.bindFramebuffer(s.FRAMEBUFFER,b.__webglFramebuffer[0]):t.bindFramebuffer(s.FRAMEBUFFER,b.__webglFramebuffer),b.__webglDepthbuffer===void 0)b.__webglDepthbuffer=s.createRenderbuffer(),ot(b.__webglDepthbuffer,F,!1);else{const pe=F.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,ne=b.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,ne),s.framebufferRenderbuffer(s.FRAMEBUFFER,pe,s.RENDERBUFFER,ne)}}t.bindFramebuffer(s.FRAMEBUFFER,null)}function Z(F,b,K){const ce=n.get(F);b!==void 0&&Se(ce.__webglFramebuffer,F,F.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),K!==void 0&&$(F)}function ie(F){const b=F.texture,K=n.get(F),ce=n.get(b);F.addEventListener("dispose",L);const pe=F.textures,ne=F.isWebGLCubeRenderTarget===!0,ze=pe.length>1;if(ze||(ce.__webglTexture===void 0&&(ce.__webglTexture=s.createTexture()),ce.__version=b.version,a.memory.textures++),ne){K.__webglFramebuffer=[];for(let Ae=0;Ae<6;Ae++)if(b.mipmaps&&b.mipmaps.length>0){K.__webglFramebuffer[Ae]=[];for(let We=0;We<b.mipmaps.length;We++)K.__webglFramebuffer[Ae][We]=s.createFramebuffer()}else K.__webglFramebuffer[Ae]=s.createFramebuffer()}else{if(b.mipmaps&&b.mipmaps.length>0){K.__webglFramebuffer=[];for(let Ae=0;Ae<b.mipmaps.length;Ae++)K.__webglFramebuffer[Ae]=s.createFramebuffer()}else K.__webglFramebuffer=s.createFramebuffer();if(ze)for(let Ae=0,We=pe.length;Ae<We;Ae++){const Ye=n.get(pe[Ae]);Ye.__webglTexture===void 0&&(Ye.__webglTexture=s.createTexture(),a.memory.textures++)}if(F.samples>0&&Oe(F)===!1){K.__webglMultisampledFramebuffer=s.createFramebuffer(),K.__webglColorRenderbuffer=[],t.bindFramebuffer(s.FRAMEBUFFER,K.__webglMultisampledFramebuffer);for(let Ae=0;Ae<pe.length;Ae++){const We=pe[Ae];K.__webglColorRenderbuffer[Ae]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,K.__webglColorRenderbuffer[Ae]);const Ye=r.convert(We.format,We.colorSpace),me=r.convert(We.type),ke=v(We.internalFormat,Ye,me,We.colorSpace,F.isXRRenderTarget===!0),st=De(F);s.renderbufferStorageMultisample(s.RENDERBUFFER,st,ke,F.width,F.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+Ae,s.RENDERBUFFER,K.__webglColorRenderbuffer[Ae])}s.bindRenderbuffer(s.RENDERBUFFER,null),F.depthBuffer&&(K.__webglDepthRenderbuffer=s.createRenderbuffer(),ot(K.__webglDepthRenderbuffer,F,!0)),t.bindFramebuffer(s.FRAMEBUFFER,null)}}if(ne){t.bindTexture(s.TEXTURE_CUBE_MAP,ce.__webglTexture),we(s.TEXTURE_CUBE_MAP,b);for(let Ae=0;Ae<6;Ae++)if(b.mipmaps&&b.mipmaps.length>0)for(let We=0;We<b.mipmaps.length;We++)Se(K.__webglFramebuffer[Ae][We],F,b,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,We);else Se(K.__webglFramebuffer[Ae],F,b,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0);m(b)&&p(s.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ze){for(let Ae=0,We=pe.length;Ae<We;Ae++){const Ye=pe[Ae],me=n.get(Ye);t.bindTexture(s.TEXTURE_2D,me.__webglTexture),we(s.TEXTURE_2D,Ye),Se(K.__webglFramebuffer,F,Ye,s.COLOR_ATTACHMENT0+Ae,s.TEXTURE_2D,0),m(Ye)&&p(s.TEXTURE_2D)}t.unbindTexture()}else{let Ae=s.TEXTURE_2D;if((F.isWebGL3DRenderTarget||F.isWebGLArrayRenderTarget)&&(Ae=F.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(Ae,ce.__webglTexture),we(Ae,b),b.mipmaps&&b.mipmaps.length>0)for(let We=0;We<b.mipmaps.length;We++)Se(K.__webglFramebuffer[We],F,b,s.COLOR_ATTACHMENT0,Ae,We);else Se(K.__webglFramebuffer,F,b,s.COLOR_ATTACHMENT0,Ae,0);m(b)&&p(Ae),t.unbindTexture()}F.depthBuffer&&$(F)}function I(F){const b=F.textures;for(let K=0,ce=b.length;K<ce;K++){const pe=b[K];if(m(pe)){const ne=S(F),ze=n.get(pe).__webglTexture;t.bindTexture(ne,ze),p(ne),t.unbindTexture()}}}const Te=[],de=[];function qe(F){if(F.samples>0){if(Oe(F)===!1){const b=F.textures,K=F.width,ce=F.height;let pe=s.COLOR_BUFFER_BIT;const ne=F.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,ze=n.get(F),Ae=b.length>1;if(Ae)for(let Ye=0;Ye<b.length;Ye++)t.bindFramebuffer(s.FRAMEBUFFER,ze.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+Ye,s.RENDERBUFFER,null),t.bindFramebuffer(s.FRAMEBUFFER,ze.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+Ye,s.TEXTURE_2D,null,0);t.bindFramebuffer(s.READ_FRAMEBUFFER,ze.__webglMultisampledFramebuffer);const We=F.texture.mipmaps;We&&We.length>0?t.bindFramebuffer(s.DRAW_FRAMEBUFFER,ze.__webglFramebuffer[0]):t.bindFramebuffer(s.DRAW_FRAMEBUFFER,ze.__webglFramebuffer);for(let Ye=0;Ye<b.length;Ye++){if(F.resolveDepthBuffer&&(F.depthBuffer&&(pe|=s.DEPTH_BUFFER_BIT),F.stencilBuffer&&F.resolveStencilBuffer&&(pe|=s.STENCIL_BUFFER_BIT)),Ae){s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,ze.__webglColorRenderbuffer[Ye]);const me=n.get(b[Ye]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,me,0)}s.blitFramebuffer(0,0,K,ce,0,0,K,ce,pe,s.NEAREST),l===!0&&(Te.length=0,de.length=0,Te.push(s.COLOR_ATTACHMENT0+Ye),F.depthBuffer&&F.resolveDepthBuffer===!1&&(Te.push(ne),de.push(ne),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,de)),s.invalidateFramebuffer(s.READ_FRAMEBUFFER,Te))}if(t.bindFramebuffer(s.READ_FRAMEBUFFER,null),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),Ae)for(let Ye=0;Ye<b.length;Ye++){t.bindFramebuffer(s.FRAMEBUFFER,ze.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+Ye,s.RENDERBUFFER,ze.__webglColorRenderbuffer[Ye]);const me=n.get(b[Ye]).__webglTexture;t.bindFramebuffer(s.FRAMEBUFFER,ze.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+Ye,s.TEXTURE_2D,me,0)}t.bindFramebuffer(s.DRAW_FRAMEBUFFER,ze.__webglMultisampledFramebuffer)}else if(F.depthBuffer&&F.resolveDepthBuffer===!1&&l){const b=F.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[b])}}}function De(F){return Math.min(i.maxSamples,F.samples)}function Oe(F){const b=n.get(F);return F.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&b.__useRenderToTexture!==!1}function Ie(F){const b=a.render.frame;u.get(F)!==b&&(u.set(F,b),F.update())}function tt(F,b){const K=F.colorSpace,ce=F.format,pe=F.type;return F.isCompressedTexture===!0||F.isVideoTexture===!0||K!==An&&K!==zi&&(ft.getTransfer(K)===Ut?(ce!==Gn||pe!==ai)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",K)),b}function Nt(F){return typeof HTMLImageElement<"u"&&F instanceof HTMLImageElement?(c.width=F.naturalWidth||F.width,c.height=F.naturalHeight||F.height):typeof VideoFrame<"u"&&F instanceof VideoFrame?(c.width=F.displayWidth,c.height=F.displayHeight):(c.width=F.width,c.height=F.height),c}this.allocateTextureUnit=q,this.resetTextureUnits=X,this.setTexture2D=he,this.setTexture2DArray=k,this.setTexture3D=oe,this.setTextureCube=G,this.rebindTextures=Z,this.setupRenderTarget=ie,this.updateRenderTargetMipmap=I,this.updateMultisampleRenderTarget=qe,this.setupDepthRenderbuffer=$,this.setupFrameBufferTexture=Se,this.useMultisampledRTT=Oe}function jy(s,e){function t(n,i=zi){let r;const a=ft.getTransfer(i);if(n===ai)return s.UNSIGNED_BYTE;if(n===Ll)return s.UNSIGNED_SHORT_4_4_4_4;if(n===Dl)return s.UNSIGNED_SHORT_5_5_5_1;if(n===$u)return s.UNSIGNED_INT_5_9_9_9_REV;if(n===Yu)return s.BYTE;if(n===Zu)return s.SHORT;if(n===pr)return s.UNSIGNED_SHORT;if(n===Pl)return s.INT;if(n===ls)return s.UNSIGNED_INT;if(n===ei)return s.FLOAT;if(n===Rr)return s.HALF_FLOAT;if(n===Ju)return s.ALPHA;if(n===Qu)return s.RGB;if(n===Gn)return s.RGBA;if(n===gr)return s.DEPTH_COMPONENT;if(n===_r)return s.DEPTH_STENCIL;if(n===Il)return s.RED;if(n===Nl)return s.RED_INTEGER;if(n===eh)return s.RG;if(n===Ul)return s.RG_INTEGER;if(n===Fl)return s.RGBA_INTEGER;if(n===ga||n===_a||n===ya||n===va)if(a===Ut)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===ga)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===_a)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===ya)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===va)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===ga)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===_a)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===ya)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===va)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Wo||n===Xo||n===jo||n===qo)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Wo)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Xo)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===jo)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===qo)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Ko||n===Yo||n===Zo)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Ko||n===Yo)return a===Ut?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Zo)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===$o||n===Jo||n===Qo||n===el||n===tl||n===nl||n===il||n===sl||n===rl||n===al||n===ol||n===ll||n===cl||n===ul)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===$o)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Jo)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Qo)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===el)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===tl)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===nl)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===il)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===sl)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===rl)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===al)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===ol)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===ll)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===cl)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===ul)return a===Ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===xa||n===hl||n===dl)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===xa)return a===Ut?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===hl)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===dl)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===th||n===fl||n===pl||n===ml)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===xa)return r.COMPRESSED_RED_RGTC1_EXT;if(n===fl)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===pl)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===ml)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===mr?s.UNSIGNED_INT_24_8:s[n]!==void 0?s[n]:null}return{convert:t}}const qy=`
3804
3804
  void main() {
3805
3805
 
3806
3806
  gl_Position = vec4( position, 1.0 );
@@ -3824,16 +3824,16 @@ void main() {
3824
3824
 
3825
3825
  }
3826
3826
 
3827
- }`;class Yy{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){const i=new rn,r=e.properties.get(i);r.__webglTexture=t.texture,(t.depthNear!==n.depthNear||t.depthFar!==n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new Wi({vertexShader:qy,fragmentShader:Ky,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new sn(new Ua(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Zy extends ds{constructor(e,t){super();const n=this;let i=null,r=1,a=null,o="local-floor",l=1,c=null,u=null,h=null,d=null,f=null,g=null;const _=new Yy,m=t.getContextAttributes();let p=null,S=null;const x=[],y=[],N=new ot;let P=null;const L=new cn;L.viewport=new Tt;const U=new cn;U.viewport=new Tt;const E=[L,U],T=new rm;let D=null,X=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(W){let $=x[W];return $===void 0&&($=new uo,x[W]=$),$.getTargetRaySpace()},this.getControllerGrip=function(W){let $=x[W];return $===void 0&&($=new uo,x[W]=$),$.getGripSpace()},this.getHand=function(W){let $=x[W];return $===void 0&&($=new uo,x[W]=$),$.getHandSpace()};function j(W){const $=y.indexOf(W.inputSource);if($===-1)return;const re=x[$];re!==void 0&&(re.update(W.inputSource,W.frame,c||a),re.dispatchEvent({type:W.type,data:W.inputSource}))}function se(){i.removeEventListener("select",j),i.removeEventListener("selectstart",j),i.removeEventListener("selectend",j),i.removeEventListener("squeeze",j),i.removeEventListener("squeezestart",j),i.removeEventListener("squeezeend",j),i.removeEventListener("end",se),i.removeEventListener("inputsourceschange",de);for(let W=0;W<x.length;W++){const $=y[W];$!==null&&(y[W]=null,x[W].disconnect($))}D=null,X=null,_.reset(),e.setRenderTarget(p),f=null,d=null,h=null,i=null,S=null,be.stop(),n.isPresenting=!1,e.setPixelRatio(P),e.setSize(N.width,N.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(W){r=W,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(W){o=W,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(W){c=W},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return h},this.getFrame=function(){return g},this.getSession=function(){return i},this.setSession=async function(W){if(i=W,i!==null){if(p=e.getRenderTarget(),i.addEventListener("select",j),i.addEventListener("selectstart",j),i.addEventListener("selectend",j),i.addEventListener("squeeze",j),i.addEventListener("squeezestart",j),i.addEventListener("squeezeend",j),i.addEventListener("end",se),i.addEventListener("inputsourceschange",de),m.xrCompatible!==!0&&await t.makeXRCompatible(),P=e.getPixelRatio(),e.getSize(N),typeof XRWebGLBinding<"u"&&"createProjectionLayer"in XRWebGLBinding.prototype){let re=null,oe=null,Te=null;m.depth&&(Te=m.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,re=m.stencil?gr:mr,oe=m.stencil?pr:ls);const ne={colorFormat:t.RGBA8,depthFormat:Te,scaleFactor:r};h=new XRWebGLBinding(i,t),d=h.createProjectionLayer(ne),i.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),S=new cs(d.textureWidth,d.textureHeight,{format:Hn,type:ri,depthTexture:new fh(d.textureWidth,d.textureHeight,oe,void 0,void 0,void 0,void 0,void 0,void 0,re),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const re={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(i,t,re),i.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),S=new cs(f.framebufferWidth,f.framebufferHeight,{format:Hn,type:ri,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}S.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await i.requestReferenceSpace(o),be.setContext(i),be.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return _.getDepthTexture()};function de(W){for(let $=0;$<W.removed.length;$++){const re=W.removed[$],oe=y.indexOf(re);oe>=0&&(y[oe]=null,x[oe].disconnect(re))}for(let $=0;$<W.added.length;$++){const re=W.added[$];let oe=y.indexOf(re);if(oe===-1){for(let ne=0;ne<x.length;ne++)if(ne>=y.length){y.push(re),oe=ne;break}else if(y[ne]===null){y[ne]=re,oe=ne;break}if(oe===-1)break}const Te=x[oe];Te&&Te.connect(re)}}const k=new O,ae=new O;function G(W,$,re){k.setFromMatrixPosition($.matrixWorld),ae.setFromMatrixPosition(re.matrixWorld);const oe=k.distanceTo(ae),Te=$.projectionMatrix.elements,ne=re.projectionMatrix.elements,me=Te[14]/(Te[10]-1),Q=Te[14]/(Te[10]+1),ee=(Te[9]+1)/Te[5],te=(Te[9]-1)/Te[5],I=(Te[8]-1)/Te[0],ge=(ne[8]+1)/ne[0],Ne=me*I,dt=me*ge,ve=oe/(-I+ge),nt=ve*-I;if($.matrixWorld.decompose(W.position,W.quaternion,W.scale),W.translateX(nt),W.translateZ(ve),W.matrixWorld.compose(W.position,W.quaternion,W.scale),W.matrixWorldInverse.copy(W.matrixWorld).invert(),Te[10]===-1)W.projectionMatrix.copy($.projectionMatrix),W.projectionMatrixInverse.copy($.projectionMatrixInverse);else{const ke=me+ve,ht=Q+ve,Nt=Ne-nt,F=dt+(oe-nt),b=ee*Q/ht*ke,q=te*Q/ht*ke;W.projectionMatrix.makePerspective(Nt,F,b,q,ke,ht),W.projectionMatrixInverse.copy(W.projectionMatrix).invert()}}function pe(W,$){$===null?W.matrixWorld.copy(W.matrix):W.matrixWorld.multiplyMatrices($.matrixWorld,W.matrix),W.matrixWorldInverse.copy(W.matrixWorld).invert()}this.updateCamera=function(W){if(i===null)return;let $=W.near,re=W.far;_.texture!==null&&(_.depthNear>0&&($=_.depthNear),_.depthFar>0&&(re=_.depthFar)),T.near=U.near=L.near=$,T.far=U.far=L.far=re,(D!==T.near||X!==T.far)&&(i.updateRenderState({depthNear:T.near,depthFar:T.far}),D=T.near,X=T.far),L.layers.mask=W.layers.mask|2,U.layers.mask=W.layers.mask|4,T.layers.mask=L.layers.mask|U.layers.mask;const oe=W.parent,Te=T.cameras;pe(T,oe);for(let ne=0;ne<Te.length;ne++)pe(Te[ne],oe);Te.length===2?G(T,L,U):T.projectionMatrix.copy(L.projectionMatrix),Me(W,T,oe)};function Me(W,$,re){re===null?W.matrix.copy($.matrixWorld):(W.matrix.copy(re.matrixWorld),W.matrix.invert(),W.matrix.multiply($.matrixWorld)),W.matrix.decompose(W.position,W.quaternion,W.scale),W.updateMatrixWorld(!0),W.projectionMatrix.copy($.projectionMatrix),W.projectionMatrixInverse.copy($.projectionMatrixInverse),W.isPerspectiveCamera&&(W.fov=Gs*2*Math.atan(1/W.projectionMatrix.elements[5]),W.zoom=1)}this.getCamera=function(){return T},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function(W){l=W,d!==null&&(d.fixedFoveation=W),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=W)},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(T)};let le=null;function we(W,$){if(u=$.getViewerPose(c||a),g=$,u!==null){const re=u.views;f!==null&&(e.setRenderTargetFramebuffer(S,f.framebuffer),e.setRenderTarget(S));let oe=!1;re.length!==T.cameras.length&&(T.cameras.length=0,oe=!0);for(let me=0;me<re.length;me++){const Q=re[me];let ee=null;if(f!==null)ee=f.getViewport(Q);else{const I=h.getViewSubImage(d,Q);ee=I.viewport,me===0&&(e.setRenderTargetTextures(S,I.colorTexture,I.depthStencilTexture),e.setRenderTarget(S))}let te=E[me];te===void 0&&(te=new cn,te.layers.enable(me),te.viewport=new Tt,E[me]=te),te.matrix.fromArray(Q.transform.matrix),te.matrix.decompose(te.position,te.quaternion,te.scale),te.projectionMatrix.fromArray(Q.projectionMatrix),te.projectionMatrixInverse.copy(te.projectionMatrix).invert(),te.viewport.set(ee.x,ee.y,ee.width,ee.height),me===0&&(T.matrix.copy(te.matrix),T.matrix.decompose(T.position,T.quaternion,T.scale)),oe===!0&&T.cameras.push(te)}const Te=i.enabledFeatures;if(Te&&Te.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&h){const me=h.getDepthInformation(re[0]);me&&me.isValid&&me.texture&&_.init(e,me,i.renderState)}}for(let re=0;re<x.length;re++){const oe=y[re],Te=x[re];oe!==null&&Te!==void 0&&Te.update(oe,$,c||a)}le&&le(W,$),$.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:$}),g=null}const be=new Mh;be.setAnimationLoop(we),this.setAnimationLoop=function(W){le=W},this.dispose=function(){}}}const ts=new nn,$y=new Fe;function Jy(s,e){function t(m,p){m.matrixAutoUpdate===!0&&m.updateMatrix(),p.value.copy(m.matrix)}function n(m,p){p.color.getRGB(m.fogColor.value,ch(s)),p.isFog?(m.fogNear.value=p.near,m.fogFar.value=p.far):p.isFogExp2&&(m.fogDensity.value=p.density)}function i(m,p,S,x,y){p.isMeshBasicMaterial||p.isMeshLambertMaterial?r(m,p):p.isMeshToonMaterial?(r(m,p),h(m,p)):p.isMeshPhongMaterial?(r(m,p),u(m,p)):p.isMeshStandardMaterial?(r(m,p),d(m,p),p.isMeshPhysicalMaterial&&f(m,p,y)):p.isMeshMatcapMaterial?(r(m,p),g(m,p)):p.isMeshDepthMaterial?r(m,p):p.isMeshDistanceMaterial?(r(m,p),_(m,p)):p.isMeshNormalMaterial?r(m,p):p.isLineBasicMaterial?(a(m,p),p.isLineDashedMaterial&&o(m,p)):p.isPointsMaterial?l(m,p,S,x):p.isSpriteMaterial?c(m,p):p.isShadowMaterial?(m.color.value.copy(p.color),m.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function r(m,p){m.opacity.value=p.opacity,p.color&&m.diffuse.value.copy(p.color),p.emissive&&m.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.bumpMap&&(m.bumpMap.value=p.bumpMap,t(p.bumpMap,m.bumpMapTransform),m.bumpScale.value=p.bumpScale,p.side===Ln&&(m.bumpScale.value*=-1)),p.normalMap&&(m.normalMap.value=p.normalMap,t(p.normalMap,m.normalMapTransform),m.normalScale.value.copy(p.normalScale),p.side===Ln&&m.normalScale.value.negate()),p.displacementMap&&(m.displacementMap.value=p.displacementMap,t(p.displacementMap,m.displacementMapTransform),m.displacementScale.value=p.displacementScale,m.displacementBias.value=p.displacementBias),p.emissiveMap&&(m.emissiveMap.value=p.emissiveMap,t(p.emissiveMap,m.emissiveMapTransform)),p.specularMap&&(m.specularMap.value=p.specularMap,t(p.specularMap,m.specularMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest);const S=e.get(p),x=S.envMap,y=S.envMapRotation;x&&(m.envMap.value=x,ts.copy(y),ts.x*=-1,ts.y*=-1,ts.z*=-1,x.isCubeTexture&&x.isRenderTargetTexture===!1&&(ts.y*=-1,ts.z*=-1),m.envMapRotation.value.setFromMatrix4($y.makeRotationFromEuler(ts)),m.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio),p.lightMap&&(m.lightMap.value=p.lightMap,m.lightMapIntensity.value=p.lightMapIntensity,t(p.lightMap,m.lightMapTransform)),p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,m.aoMapTransform))}function a(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform))}function o(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}function l(m,p,S,x){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*S,m.scale.value=x*.5,p.map&&(m.map.value=p.map,t(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function c(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.rotation.value=p.rotation,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function u(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,1e-4)}function h(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function d(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,m.roughnessMapTransform)),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function f(m,p,S){m.ior.value=p.ior,p.sheen>0&&(m.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),m.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(m.sheenColorMap.value=p.sheenColorMap,t(p.sheenColorMap,m.sheenColorMapTransform)),p.sheenRoughnessMap&&(m.sheenRoughnessMap.value=p.sheenRoughnessMap,t(p.sheenRoughnessMap,m.sheenRoughnessMapTransform))),p.clearcoat>0&&(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(m.clearcoatMap.value=p.clearcoatMap,t(p.clearcoatMap,m.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,t(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(m.clearcoatNormalMap.value=p.clearcoatNormalMap,t(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===Ln&&m.clearcoatNormalScale.value.negate())),p.dispersion>0&&(m.dispersion.value=p.dispersion),p.iridescence>0&&(m.iridescence.value=p.iridescence,m.iridescenceIOR.value=p.iridescenceIOR,m.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(m.iridescenceMap.value=p.iridescenceMap,t(p.iridescenceMap,m.iridescenceMapTransform)),p.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,t(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),p.transmission>0&&(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=S.texture,m.transmissionSamplerSize.value.set(S.width,S.height),p.transmissionMap&&(m.transmissionMap.value=p.transmissionMap,t(p.transmissionMap,m.transmissionMapTransform)),m.thickness.value=p.thickness,p.thicknessMap&&(m.thicknessMap.value=p.thicknessMap,t(p.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=p.attenuationDistance,m.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(m.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(m.anisotropyMap.value=p.anisotropyMap,t(p.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap&&(m.specularColorMap.value=p.specularColorMap,t(p.specularColorMap,m.specularColorMapTransform)),p.specularIntensityMap&&(m.specularIntensityMap.value=p.specularIntensityMap,t(p.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,p){p.matcap&&(m.matcap.value=p.matcap)}function _(m,p){const S=e.get(p).light;m.referencePosition.value.setFromMatrixPosition(S.matrixWorld),m.nearDistance.value=S.shadow.camera.near,m.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function Qy(s,e,t,n){let i={},r={},a=[];const o=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function l(S,x){const y=x.program;n.uniformBlockBinding(S,y)}function c(S,x){let y=i[S.id];y===void 0&&(g(S),y=u(S),i[S.id]=y,S.addEventListener("dispose",m));const N=x.program;n.updateUBOMapping(S,N);const P=e.render.frame;r[S.id]!==P&&(d(S),r[S.id]=P)}function u(S){const x=h();S.__bindingPointIndex=x;const y=s.createBuffer(),N=S.__size,P=S.usage;return s.bindBuffer(s.UNIFORM_BUFFER,y),s.bufferData(s.UNIFORM_BUFFER,N,P),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,x,y),y}function h(){for(let S=0;S<o;S++)if(a.indexOf(S)===-1)return a.push(S),S;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(S){const x=i[S.id],y=S.uniforms,N=S.__cache;s.bindBuffer(s.UNIFORM_BUFFER,x);for(let P=0,L=y.length;P<L;P++){const U=Array.isArray(y[P])?y[P]:[y[P]];for(let E=0,T=U.length;E<T;E++){const D=U[E];if(f(D,P,E,N)===!0){const X=D.__offset,j=Array.isArray(D.value)?D.value:[D.value];let se=0;for(let de=0;de<j.length;de++){const k=j[de],ae=_(k);typeof k=="number"||typeof k=="boolean"?(D.__data[0]=k,s.bufferSubData(s.UNIFORM_BUFFER,X+se,D.__data)):k.isMatrix3?(D.__data[0]=k.elements[0],D.__data[1]=k.elements[1],D.__data[2]=k.elements[2],D.__data[3]=0,D.__data[4]=k.elements[3],D.__data[5]=k.elements[4],D.__data[6]=k.elements[5],D.__data[7]=0,D.__data[8]=k.elements[6],D.__data[9]=k.elements[7],D.__data[10]=k.elements[8],D.__data[11]=0):(k.toArray(D.__data,se),se+=ae.storage/Float32Array.BYTES_PER_ELEMENT)}s.bufferSubData(s.UNIFORM_BUFFER,X,D.__data)}}}s.bindBuffer(s.UNIFORM_BUFFER,null)}function f(S,x,y,N){const P=S.value,L=x+"_"+y;if(N[L]===void 0)return typeof P=="number"||typeof P=="boolean"?N[L]=P:N[L]=P.clone(),!0;{const U=N[L];if(typeof P=="number"||typeof P=="boolean"){if(U!==P)return N[L]=P,!0}else if(U.equals(P)===!1)return U.copy(P),!0}return!1}function g(S){const x=S.uniforms;let y=0;const N=16;for(let L=0,U=x.length;L<U;L++){const E=Array.isArray(x[L])?x[L]:[x[L]];for(let T=0,D=E.length;T<D;T++){const X=E[T],j=Array.isArray(X.value)?X.value:[X.value];for(let se=0,de=j.length;se<de;se++){const k=j[se],ae=_(k),G=y%N,pe=G%ae.boundary,Me=G+pe;y+=pe,Me!==0&&N-Me<ae.storage&&(y+=N-Me),X.__data=new Float32Array(ae.storage/Float32Array.BYTES_PER_ELEMENT),X.__offset=y,y+=ae.storage}}}const P=y%N;return P>0&&(y+=N-P),S.__size=y,S.__cache={},this}function _(S){const x={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(x.boundary=4,x.storage=4):S.isVector2?(x.boundary=8,x.storage=8):S.isVector3||S.isColor?(x.boundary=16,x.storage=12):S.isVector4?(x.boundary=16,x.storage=16):S.isMatrix3?(x.boundary=48,x.storage=48):S.isMatrix4?(x.boundary=64,x.storage=64):S.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",S),x}function m(S){const x=S.target;x.removeEventListener("dispose",m);const y=a.indexOf(x.__bindingPointIndex);a.splice(y,1),s.deleteBuffer(i[x.id]),delete i[x.id],delete r[x.id]}function p(){for(const S in i)s.deleteBuffer(i[S]);a=[],i={},r={}}return{bind:l,update:c,dispose:p}}class ex{constructor(e={}){const{canvas:t=Bf(),context:n=null,depth:i=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1,reverseDepthBuffer:d=!1}=e;this.isWebGLRenderer=!0;let f;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=n.getContextAttributes().alpha}else f=a;const g=new Uint32Array(4),_=new Int32Array(4);let m=null,p=null;const S=[],x=[];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=Gi,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const y=this;let N=!1;this._outputColorSpace=_t;let P=0,L=0,U=null,E=-1,T=null;const D=new Tt,X=new Tt;let j=null;const se=new He(0);let de=0,k=t.width,ae=t.height,G=1,pe=null,Me=null;const le=new Tt(0,0,k,ae),we=new Tt(0,0,k,ae);let be=!1;const W=new Gl;let $=!1,re=!1;const oe=new Fe,Te=new Fe,ne=new O,me=new Tt,Q={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ee=!1;function te(){return U===null?G:1}let I=n;function ge(w,z){return t.getContext(w,z)}try{const w={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Cl}`),t.addEventListener("webglcontextlost",Be,!1),t.addEventListener("webglcontextrestored",Y,!1),t.addEventListener("webglcontextcreationerror",ce,!1),I===null){const z="webgl2";if(I=ge(z,w),I===null)throw ge(z)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(w){throw console.error("THREE.WebGLRenderer: "+w.message),w}let Ne,dt,ve,nt,ke,ht,Nt,F,b,q,ue,fe,ie,Ke,Re,Ge,Ye,_e,Oe,it,Qe,Ee,at,B;function Pe(){Ne=new u0(I),Ne.init(),Ee=new jy(I,Ne),dt=new i0(I,Ne,e,Ee),ve=new Wy(I,Ne),dt.reverseDepthBuffer&&d&&ve.buffers.depth.setReversed(!0),nt=new f0(I),ke=new Ly,ht=new Xy(I,Ne,ve,ke,dt,Ee,nt),Nt=new r0(y),F=new c0(y),b=new xm(I),at=new t0(I,b),q=new h0(I,b,nt,at),ue=new m0(I,q,b,nt),Oe=new p0(I,dt,ht),Ge=new s0(ke),fe=new Py(y,Nt,F,Ne,dt,at,Ge),ie=new Jy(y,ke),Ke=new Iy,Re=new By(Ne),_e=new e0(y,Nt,F,ve,ue,f,l),Ye=new Hy(y,ue,dt),B=new Qy(I,nt,dt,ve),it=new n0(I,Ne,nt),Qe=new d0(I,Ne,nt),nt.programs=fe.programs,y.capabilities=dt,y.extensions=Ne,y.properties=ke,y.renderLists=Ke,y.shadowMap=Ye,y.state=ve,y.info=nt}Pe();const ye=new Zy(y,I);this.xr=ye,this.getContext=function(){return I},this.getContextAttributes=function(){return I.getContextAttributes()},this.forceContextLoss=function(){const w=Ne.get("WEBGL_lose_context");w&&w.loseContext()},this.forceContextRestore=function(){const w=Ne.get("WEBGL_lose_context");w&&w.restoreContext()},this.getPixelRatio=function(){return G},this.setPixelRatio=function(w){w!==void 0&&(G=w,this.setSize(k,ae,!1))},this.getSize=function(w){return w.set(k,ae)},this.setSize=function(w,z,K=!0){if(ye.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}k=w,ae=z,t.width=Math.floor(w*G),t.height=Math.floor(z*G),K===!0&&(t.style.width=w+"px",t.style.height=z+"px"),this.setViewport(0,0,w,z)},this.getDrawingBufferSize=function(w){return w.set(k*G,ae*G).floor()},this.setDrawingBufferSize=function(w,z,K){k=w,ae=z,G=K,t.width=Math.floor(w*K),t.height=Math.floor(z*K),this.setViewport(0,0,w,z)},this.getCurrentViewport=function(w){return w.copy(D)},this.getViewport=function(w){return w.copy(le)},this.setViewport=function(w,z,K,Z){w.isVector4?le.set(w.x,w.y,w.z,w.w):le.set(w,z,K,Z),ve.viewport(D.copy(le).multiplyScalar(G).round())},this.getScissor=function(w){return w.copy(we)},this.setScissor=function(w,z,K,Z){w.isVector4?we.set(w.x,w.y,w.z,w.w):we.set(w,z,K,Z),ve.scissor(X.copy(we).multiplyScalar(G).round())},this.getScissorTest=function(){return be},this.setScissorTest=function(w){ve.setScissorTest(be=w)},this.setOpaqueSort=function(w){pe=w},this.setTransparentSort=function(w){Me=w},this.getClearColor=function(w){return w.copy(_e.getClearColor())},this.setClearColor=function(){_e.setClearColor(...arguments)},this.getClearAlpha=function(){return _e.getClearAlpha()},this.setClearAlpha=function(){_e.setClearAlpha(...arguments)},this.clear=function(w=!0,z=!0,K=!0){let Z=0;if(w){let H=!1;if(U!==null){const Se=U.texture.format;H=Se===Fl||Se===Ul||Se===Nl}if(H){const Se=U.texture.type,De=Se===ri||Se===ls||Se===fr||Se===pr||Se===Ll||Se===Dl,Xe=_e.getClearColor(),ze=_e.getClearAlpha(),lt=Xe.r,ct=Xe.g,Je=Xe.b;De?(g[0]=lt,g[1]=ct,g[2]=Je,g[3]=ze,I.clearBufferuiv(I.COLOR,0,g)):(_[0]=lt,_[1]=ct,_[2]=Je,_[3]=ze,I.clearBufferiv(I.COLOR,0,_))}else Z|=I.COLOR_BUFFER_BIT}z&&(Z|=I.DEPTH_BUFFER_BIT),K&&(Z|=I.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),I.clear(Z)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Be,!1),t.removeEventListener("webglcontextrestored",Y,!1),t.removeEventListener("webglcontextcreationerror",ce,!1),_e.dispose(),Ke.dispose(),Re.dispose(),ke.dispose(),Nt.dispose(),F.dispose(),ue.dispose(),at.dispose(),B.dispose(),fe.dispose(),ye.dispose(),ye.removeEventListener("sessionstart",Yt),ye.removeEventListener("sessionend",Un),Vt.stop()};function Be(w){w.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),N=!0}function Y(){console.log("THREE.WebGLRenderer: Context Restored."),N=!1;const w=nt.autoReset,z=Ye.enabled,K=Ye.autoUpdate,Z=Ye.needsUpdate,H=Ye.type;Pe(),nt.autoReset=w,Ye.enabled=z,Ye.autoUpdate=K,Ye.needsUpdate=Z,Ye.type=H}function ce(w){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",w.statusMessage)}function Ce(w){const z=w.target;z.removeEventListener("dispose",Ce),tt(z)}function tt(w){Lt(w),ke.remove(w)}function Lt(w){const z=ke.get(w).programs;z!==void 0&&(z.forEach(function(K){fe.releaseProgram(K)}),w.isShaderMaterial&&fe.releaseShaderCache(w))}this.renderBufferDirect=function(w,z,K,Z,H,Se){z===null&&(z=Q);const De=H.isMesh&&H.matrixWorld.determinant()<0,Xe=Ki(w,z,K,Z,H);ve.setMaterial(Z,De);let ze=K.index,lt=1;if(Z.wireframe===!0){if(ze=q.getWireframeAttribute(K),ze===void 0)return;lt=2}const ct=K.drawRange,Je=K.attributes.position;let mt=ct.start*lt,Pt=(ct.start+ct.count)*lt;Se!==null&&(mt=Math.max(mt,Se.start*lt),Pt=Math.min(Pt,(Se.start+Se.count)*lt)),ze!==null?(mt=Math.max(mt,0),Pt=Math.min(Pt,ze.count)):Je!=null&&(mt=Math.max(mt,0),Pt=Math.min(Pt,Je.count));const Bt=Pt-mt;if(Bt<0||Bt===1/0)return;at.setup(H,Z,Xe,K,ze);let Gt,bt=it;if(ze!==null&&(Gt=b.get(ze),bt=Qe,bt.setIndex(Gt)),H.isMesh)Z.wireframe===!0?(ve.setLineWidth(Z.wireframeLinewidth*te()),bt.setMode(I.LINES)):bt.setMode(I.TRIANGLES);else if(H.isLine){let st=Z.linewidth;st===void 0&&(st=1),ve.setLineWidth(st*te()),H.isLineSegments?bt.setMode(I.LINES):H.isLineLoop?bt.setMode(I.LINE_LOOP):bt.setMode(I.LINE_STRIP)}else H.isPoints?bt.setMode(I.POINTS):H.isSprite&&bt.setMode(I.TRIANGLES);if(H.isBatchedMesh)if(H._multiDrawInstances!==null)Os("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),bt.renderMultiDrawInstances(H._multiDrawStarts,H._multiDrawCounts,H._multiDrawCount,H._multiDrawInstances);else if(Ne.get("WEBGL_multi_draw"))bt.renderMultiDraw(H._multiDrawStarts,H._multiDrawCounts,H._multiDrawCount);else{const st=H._multiDrawStarts,Jt=H._multiDrawCounts,wt=H._multiDrawCount,An=ze?b.get(ze).bytesPerElement:1,zt=ke.get(Z).currentProgram.getUniforms();for(let dn=0;dn<wt;dn++)zt.setValue(I,"_gl_DrawID",dn),bt.render(st[dn]/An,Jt[dn])}else if(H.isInstancedMesh)bt.renderInstances(mt,Bt,H.count);else if(K.isInstancedBufferGeometry){const st=K._maxInstanceCount!==void 0?K._maxInstanceCount:1/0,Jt=Math.min(K.instanceCount,st);bt.renderInstances(mt,Bt,Jt)}else bt.render(mt,Bt)};function ft(w,z,K){w.transparent===!0&&w.side===Yn&&w.forceSinglePass===!1?(w.side=Ln,w.needsUpdate=!0,ci(w,z,K),w.side=si,w.needsUpdate=!0,ci(w,z,K),w.side=Yn):ci(w,z,K)}this.compile=function(w,z,K=null){K===null&&(K=w),p=Re.get(K),p.init(z),x.push(p),K.traverseVisible(function(H){H.isLight&&H.layers.test(z.layers)&&(p.pushLight(H),H.castShadow&&p.pushShadow(H))}),w!==K&&w.traverseVisible(function(H){H.isLight&&H.layers.test(z.layers)&&(p.pushLight(H),H.castShadow&&p.pushShadow(H))}),p.setupLights();const Z=new Set;return w.traverse(function(H){if(!(H.isMesh||H.isPoints||H.isLine||H.isSprite))return;const Se=H.material;if(Se)if(Array.isArray(Se))for(let De=0;De<Se.length;De++){const Xe=Se[De];ft(Xe,K,H),Z.add(Xe)}else ft(Se,K,H),Z.add(Se)}),p=x.pop(),Z},this.compileAsync=function(w,z,K=null){const Z=this.compile(w,z,K);return new Promise(H=>{function Se(){if(Z.forEach(function(De){ke.get(De).currentProgram.isReady()&&Z.delete(De)}),Z.size===0){H(w);return}setTimeout(Se,10)}Ne.get("KHR_parallel_shader_compile")!==null?Se():setTimeout(Se,10)})};let We=null;function Le(w){We&&We(w)}function Yt(){Vt.stop()}function Un(){Vt.start()}const Vt=new Mh;Vt.setAnimationLoop(Le),typeof self<"u"&&Vt.setContext(self),this.setAnimationLoop=function(w){We=w,ye.setAnimationLoop(w),w===null?Vt.stop():Vt.start()},ye.addEventListener("sessionstart",Yt),ye.addEventListener("sessionend",Un),this.render=function(w,z){if(z!==void 0&&z.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(N===!0)return;if(w.matrixWorldAutoUpdate===!0&&w.updateMatrixWorld(),z.parent===null&&z.matrixWorldAutoUpdate===!0&&z.updateMatrixWorld(),ye.enabled===!0&&ye.isPresenting===!0&&(ye.cameraAutoUpdate===!0&&ye.updateCamera(z),z=ye.getCamera()),w.isScene===!0&&w.onBeforeRender(y,w,z,U),p=Re.get(w,x.length),p.init(z),x.push(p),Te.multiplyMatrices(z.projectionMatrix,z.matrixWorldInverse),W.setFromProjectionMatrix(Te),re=this.localClippingEnabled,$=Ge.init(this.clippingPlanes,re),m=Ke.get(w,S.length),m.init(),S.push(m),ye.enabled===!0&&ye.isPresenting===!0){const Se=y.xr.getDepthSensingMesh();Se!==null&&hn(Se,z,-1/0,y.sortObjects)}hn(w,z,0,y.sortObjects),m.finish(),y.sortObjects===!0&&m.sort(pe,Me),ee=ye.enabled===!1||ye.isPresenting===!1||ye.hasDepthSensing()===!1,ee&&_e.addToRenderList(m,w),this.info.render.frame++,$===!0&&Ge.beginShadows();const K=p.state.shadowsArray;Ye.render(K,w,z),$===!0&&Ge.endShadows(),this.info.autoReset===!0&&this.info.reset();const Z=m.opaque,H=m.transmissive;if(p.setupLights(),z.isArrayCamera){const Se=z.cameras;if(H.length>0)for(let De=0,Xe=Se.length;De<Xe;De++){const ze=Se[De];Ci(Z,H,w,ze)}ee&&_e.render(w);for(let De=0,Xe=Se.length;De<Xe;De++){const ze=Se[De];En(m,w,ze,ze.viewport)}}else H.length>0&&Ci(Z,H,w,z),ee&&_e.render(w),En(m,w,z);U!==null&&L===0&&(ht.updateMultisampleRenderTarget(U),ht.updateRenderTargetMipmap(U)),w.isScene===!0&&w.onAfterRender(y,w,z),at.resetDefaultState(),E=-1,T=null,x.pop(),x.length>0?(p=x[x.length-1],$===!0&&Ge.setGlobalState(y.clippingPlanes,p.state.camera)):p=null,S.pop(),S.length>0?m=S[S.length-1]:m=null};function hn(w,z,K,Z){if(w.visible===!1)return;if(w.layers.test(z.layers)){if(w.isGroup)K=w.renderOrder;else if(w.isLOD)w.autoUpdate===!0&&w.update(z);else if(w.isLight)p.pushLight(w),w.castShadow&&p.pushShadow(w);else if(w.isSprite){if(!w.frustumCulled||W.intersectsSprite(w)){Z&&me.setFromMatrixPosition(w.matrixWorld).applyMatrix4(Te);const De=ue.update(w),Xe=w.material;Xe.visible&&m.push(w,De,Xe,K,me.z,null)}}else if((w.isMesh||w.isLine||w.isPoints)&&(!w.frustumCulled||W.intersectsObject(w))){const De=ue.update(w),Xe=w.material;if(Z&&(w.boundingSphere!==void 0?(w.boundingSphere===null&&w.computeBoundingSphere(),me.copy(w.boundingSphere.center)):(De.boundingSphere===null&&De.computeBoundingSphere(),me.copy(De.boundingSphere.center)),me.applyMatrix4(w.matrixWorld).applyMatrix4(Te)),Array.isArray(Xe)){const ze=De.groups;for(let lt=0,ct=ze.length;lt<ct;lt++){const Je=ze[lt],mt=Xe[Je.materialIndex];mt&&mt.visible&&m.push(w,De,mt,K,me.z,Je)}}else Xe.visible&&m.push(w,De,Xe,K,me.z,null)}}const Se=w.children;for(let De=0,Xe=Se.length;De<Xe;De++)hn(Se[De],z,K,Z)}function En(w,z,K,Z){const H=w.opaque,Se=w.transmissive,De=w.transparent;p.setupLightsView(K),$===!0&&Ge.setGlobalState(y.clippingPlanes,K),Z&&ve.viewport(D.copy(Z)),H.length>0&&li(H,z,K),Se.length>0&&li(Se,z,K),De.length>0&&li(De,z,K),ve.buffers.depth.setTest(!0),ve.buffers.depth.setMask(!0),ve.buffers.color.setMask(!0),ve.setPolygonOffset(!1)}function Ci(w,z,K,Z){if((K.isScene===!0?K.overrideMaterial:null)!==null)return;p.state.transmissionRenderTarget[Z.id]===void 0&&(p.state.transmissionRenderTarget[Z.id]=new cs(1,1,{generateMipmaps:!0,type:Ne.has("EXT_color_buffer_half_float")||Ne.has("EXT_color_buffer_float")?wr:ri,minFilter:Jn,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:pt.workingColorSpace}));const Se=p.state.transmissionRenderTarget[Z.id],De=Z.viewport||D;Se.setSize(De.z*y.transmissionResolutionScale,De.w*y.transmissionResolutionScale);const Xe=y.getRenderTarget();y.setRenderTarget(Se),y.getClearColor(se),de=y.getClearAlpha(),de<1&&y.setClearColor(16777215,.5),y.clear(),ee&&_e.render(K);const ze=y.toneMapping;y.toneMapping=Gi;const lt=Z.viewport;if(Z.viewport!==void 0&&(Z.viewport=void 0),p.setupLightsView(Z),$===!0&&Ge.setGlobalState(y.clippingPlanes,Z),li(w,K,Z),ht.updateMultisampleRenderTarget(Se),ht.updateRenderTargetMipmap(Se),Ne.has("WEBGL_multisampled_render_to_texture")===!1){let ct=!1;for(let Je=0,mt=z.length;Je<mt;Je++){const Pt=z[Je],Bt=Pt.object,Gt=Pt.geometry,bt=Pt.material,st=Pt.group;if(bt.side===Yn&&Bt.layers.test(Z.layers)){const Jt=bt.side;bt.side=Ln,bt.needsUpdate=!0,Pi(Bt,K,Z,Gt,bt,st),bt.side=Jt,bt.needsUpdate=!0,ct=!0}}ct===!0&&(ht.updateMultisampleRenderTarget(Se),ht.updateRenderTargetMipmap(Se))}y.setRenderTarget(Xe),y.setClearColor(se,de),lt!==void 0&&(Z.viewport=lt),y.toneMapping=ze}function li(w,z,K){const Z=z.isScene===!0?z.overrideMaterial:null;for(let H=0,Se=w.length;H<Se;H++){const De=w[H],Xe=De.object,ze=De.geometry,lt=De.group;let ct=De.material;ct.allowOverride===!0&&Z!==null&&(ct=Z),Xe.layers.test(K.layers)&&Pi(Xe,z,K,ze,ct,lt)}}function Pi(w,z,K,Z,H,Se){w.onBeforeRender(y,z,K,Z,H,Se),w.modelViewMatrix.multiplyMatrices(K.matrixWorldInverse,w.matrixWorld),w.normalMatrix.getNormalMatrix(w.modelViewMatrix),H.onBeforeRender(y,z,K,Z,w,Se),H.transparent===!0&&H.side===Yn&&H.forceSinglePass===!1?(H.side=Ln,H.needsUpdate=!0,y.renderBufferDirect(K,z,Z,H,w,Se),H.side=si,H.needsUpdate=!0,y.renderBufferDirect(K,z,Z,H,w,Se),H.side=Yn):y.renderBufferDirect(K,z,Z,H,w,Se),w.onAfterRender(y,z,K,Z,H,Se)}function ci(w,z,K){z.isScene!==!0&&(z=Q);const Z=ke.get(w),H=p.state.lights,Se=p.state.shadowsArray,De=H.state.version,Xe=fe.getParameters(w,H.state,Se,z,K),ze=fe.getProgramCacheKey(Xe);let lt=Z.programs;Z.environment=w.isMeshStandardMaterial?z.environment:null,Z.fog=z.fog,Z.envMap=(w.isMeshStandardMaterial?F:Nt).get(w.envMap||Z.environment),Z.envMapRotation=Z.environment!==null&&w.envMap===null?z.environmentRotation:w.envMapRotation,lt===void 0&&(w.addEventListener("dispose",Ce),lt=new Map,Z.programs=lt);let ct=lt.get(ze);if(ct!==void 0){if(Z.currentProgram===ct&&Z.lightsStateVersion===De)return qi(w,Xe),ct}else Xe.uniforms=fe.getUniforms(w),w.onBeforeCompile(Xe,y),ct=fe.acquireProgram(Xe,ze),lt.set(ze,ct),Z.uniforms=Xe.uniforms;const Je=Z.uniforms;return(!w.isShaderMaterial&&!w.isRawShaderMaterial||w.clipping===!0)&&(Je.clippingPlanes=Ge.uniform),qi(w,Xe),Z.needsLights=ui(w),Z.lightsStateVersion=De,Z.needsLights&&(Je.ambientLightColor.value=H.state.ambient,Je.lightProbe.value=H.state.probe,Je.directionalLights.value=H.state.directional,Je.directionalLightShadows.value=H.state.directionalShadow,Je.spotLights.value=H.state.spot,Je.spotLightShadows.value=H.state.spotShadow,Je.rectAreaLights.value=H.state.rectArea,Je.ltc_1.value=H.state.rectAreaLTC1,Je.ltc_2.value=H.state.rectAreaLTC2,Je.pointLights.value=H.state.point,Je.pointLightShadows.value=H.state.pointShadow,Je.hemisphereLights.value=H.state.hemi,Je.directionalShadowMap.value=H.state.directionalShadowMap,Je.directionalShadowMatrix.value=H.state.directionalShadowMatrix,Je.spotShadowMap.value=H.state.spotShadowMap,Je.spotLightMatrix.value=H.state.spotLightMatrix,Je.spotLightMap.value=H.state.spotLightMap,Je.pointShadowMap.value=H.state.pointShadowMap,Je.pointShadowMatrix.value=H.state.pointShadowMatrix),Z.currentProgram=ct,Z.uniformsList=null,ct}function ji(w){if(w.uniformsList===null){const z=w.currentProgram.getUniforms();w.uniformsList=Ma.seqWithValue(z.seq,w.uniforms)}return w.uniformsList}function qi(w,z){const K=ke.get(w);K.outputColorSpace=z.outputColorSpace,K.batching=z.batching,K.batchingColor=z.batchingColor,K.instancing=z.instancing,K.instancingColor=z.instancingColor,K.instancingMorph=z.instancingMorph,K.skinning=z.skinning,K.morphTargets=z.morphTargets,K.morphNormals=z.morphNormals,K.morphColors=z.morphColors,K.morphTargetsCount=z.morphTargetsCount,K.numClippingPlanes=z.numClippingPlanes,K.numIntersection=z.numClipIntersection,K.vertexAlphas=z.vertexAlphas,K.vertexTangents=z.vertexTangents,K.toneMapping=z.toneMapping}function Ki(w,z,K,Z,H){z.isScene!==!0&&(z=Q),ht.resetTextureUnits();const Se=z.fog,De=Z.isMeshStandardMaterial?z.environment:null,Xe=U===null?y.outputColorSpace:U.isXRRenderTarget===!0?U.texture.colorSpace:Tn,ze=(Z.isMeshStandardMaterial?F:Nt).get(Z.envMap||De),lt=Z.vertexColors===!0&&!!K.attributes.color&&K.attributes.color.itemSize===4,ct=!!K.attributes.tangent&&(!!Z.normalMap||Z.anisotropy>0),Je=!!K.morphAttributes.position,mt=!!K.morphAttributes.normal,Pt=!!K.morphAttributes.color;let Bt=Gi;Z.toneMapped&&(U===null||U.isXRRenderTarget===!0)&&(Bt=y.toneMapping);const Gt=K.morphAttributes.position||K.morphAttributes.normal||K.morphAttributes.color,bt=Gt!==void 0?Gt.length:0,st=ke.get(Z),Jt=p.state.lights;if($===!0&&(re===!0||w!==T)){const Zt=w===T&&Z.id===E;Ge.setState(Z,w,Zt)}let wt=!1;Z.version===st.__version?(st.needsLights&&st.lightsStateVersion!==Jt.state.version||st.outputColorSpace!==Xe||H.isBatchedMesh&&st.batching===!1||!H.isBatchedMesh&&st.batching===!0||H.isBatchedMesh&&st.batchingColor===!0&&H.colorTexture===null||H.isBatchedMesh&&st.batchingColor===!1&&H.colorTexture!==null||H.isInstancedMesh&&st.instancing===!1||!H.isInstancedMesh&&st.instancing===!0||H.isSkinnedMesh&&st.skinning===!1||!H.isSkinnedMesh&&st.skinning===!0||H.isInstancedMesh&&st.instancingColor===!0&&H.instanceColor===null||H.isInstancedMesh&&st.instancingColor===!1&&H.instanceColor!==null||H.isInstancedMesh&&st.instancingMorph===!0&&H.morphTexture===null||H.isInstancedMesh&&st.instancingMorph===!1&&H.morphTexture!==null||st.envMap!==ze||Z.fog===!0&&st.fog!==Se||st.numClippingPlanes!==void 0&&(st.numClippingPlanes!==Ge.numPlanes||st.numIntersection!==Ge.numIntersection)||st.vertexAlphas!==lt||st.vertexTangents!==ct||st.morphTargets!==Je||st.morphNormals!==mt||st.morphColors!==Pt||st.toneMapping!==Bt||st.morphTargetsCount!==bt)&&(wt=!0):(wt=!0,st.__version=Z.version);let An=st.currentProgram;wt===!0&&(An=ci(Z,z,H));let zt=!1,dn=!1,Yi=!1;const Ot=An.getUniforms(),yn=st.uniforms;if(ve.useProgram(An.program)&&(zt=!0,dn=!0,Yi=!0),Z.id!==E&&(E=Z.id,dn=!0),zt||T!==w){ve.buffers.depth.getReversed()?(oe.copy(w.projectionMatrix),Vf(oe),Hf(oe),Ot.setValue(I,"projectionMatrix",oe)):Ot.setValue(I,"projectionMatrix",w.projectionMatrix),Ot.setValue(I,"viewMatrix",w.matrixWorldInverse);const Qt=Ot.map.cameraPosition;Qt!==void 0&&Qt.setValue(I,ne.setFromMatrixPosition(w.matrixWorld)),dt.logarithmicDepthBuffer&&Ot.setValue(I,"logDepthBufFC",2/(Math.log(w.far+1)/Math.LN2)),(Z.isMeshPhongMaterial||Z.isMeshToonMaterial||Z.isMeshLambertMaterial||Z.isMeshBasicMaterial||Z.isMeshStandardMaterial||Z.isShaderMaterial)&&Ot.setValue(I,"isOrthographic",w.isOrthographicCamera===!0),T!==w&&(T=w,dn=!0,Yi=!0)}if(H.isSkinnedMesh){Ot.setOptional(I,H,"bindMatrix"),Ot.setOptional(I,H,"bindMatrixInverse");const Zt=H.skeleton;Zt&&(Zt.boneTexture===null&&Zt.computeBoneTexture(),Ot.setValue(I,"boneTexture",Zt.boneTexture,ht))}H.isBatchedMesh&&(Ot.setOptional(I,H,"batchingTexture"),Ot.setValue(I,"batchingTexture",H._matricesTexture,ht),Ot.setOptional(I,H,"batchingIdTexture"),Ot.setValue(I,"batchingIdTexture",H._indirectTexture,ht),Ot.setOptional(I,H,"batchingColorTexture"),H._colorsTexture!==null&&Ot.setValue(I,"batchingColorTexture",H._colorsTexture,ht));const fn=K.morphAttributes;if((fn.position!==void 0||fn.normal!==void 0||fn.color!==void 0)&&Oe.update(H,K,An),(dn||st.receiveShadow!==H.receiveShadow)&&(st.receiveShadow=H.receiveShadow,Ot.setValue(I,"receiveShadow",H.receiveShadow)),Z.isMeshGouraudMaterial&&Z.envMap!==null&&(yn.envMap.value=ze,yn.flipEnvMap.value=ze.isCubeTexture&&ze.isRenderTargetTexture===!1?-1:1),Z.isMeshStandardMaterial&&Z.envMap===null&&z.environment!==null&&(yn.envMapIntensity.value=z.environmentIntensity),dn&&(Ot.setValue(I,"toneMappingExposure",y.toneMappingExposure),st.needsLights&&_n(yn,Yi),Se&&Z.fog===!0&&ie.refreshFogUniforms(yn,Se),ie.refreshMaterialUniforms(yn,Z,G,ae,p.state.transmissionRenderTarget[w.id]),Ma.upload(I,ji(st),yn,ht)),Z.isShaderMaterial&&Z.uniformsNeedUpdate===!0&&(Ma.upload(I,ji(st),yn,ht),Z.uniformsNeedUpdate=!1),Z.isSpriteMaterial&&Ot.setValue(I,"center",H.center),Ot.setValue(I,"modelViewMatrix",H.modelViewMatrix),Ot.setValue(I,"normalMatrix",H.normalMatrix),Ot.setValue(I,"modelMatrix",H.matrixWorld),Z.isShaderMaterial||Z.isRawShaderMaterial){const Zt=Z.uniformsGroups;for(let Qt=0,fs=Zt.length;Qt<fs;Qt++){const hi=Zt[Qt];B.update(hi,An),B.bind(hi,An)}}return An}function _n(w,z){w.ambientLightColor.needsUpdate=z,w.lightProbe.needsUpdate=z,w.directionalLights.needsUpdate=z,w.directionalLightShadows.needsUpdate=z,w.pointLights.needsUpdate=z,w.pointLightShadows.needsUpdate=z,w.spotLights.needsUpdate=z,w.spotLightShadows.needsUpdate=z,w.rectAreaLights.needsUpdate=z,w.hemisphereLights.needsUpdate=z}function ui(w){return w.isMeshLambertMaterial||w.isMeshToonMaterial||w.isMeshPhongMaterial||w.isMeshStandardMaterial||w.isShadowMaterial||w.isShaderMaterial&&w.lights===!0}this.getActiveCubeFace=function(){return P},this.getActiveMipmapLevel=function(){return L},this.getRenderTarget=function(){return U},this.setRenderTargetTextures=function(w,z,K){const Z=ke.get(w);Z.__autoAllocateDepthBuffer=w.resolveDepthBuffer===!1,Z.__autoAllocateDepthBuffer===!1&&(Z.__useRenderToTexture=!1),ke.get(w.texture).__webglTexture=z,ke.get(w.depthTexture).__webglTexture=Z.__autoAllocateDepthBuffer?void 0:K,Z.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(w,z){const K=ke.get(w);K.__webglFramebuffer=z,K.__useDefaultFramebuffer=z===void 0};const Ba=I.createFramebuffer();this.setRenderTarget=function(w,z=0,K=0){U=w,P=z,L=K;let Z=!0,H=null,Se=!1,De=!1;if(w){const ze=ke.get(w);if(ze.__useDefaultFramebuffer!==void 0)ve.bindFramebuffer(I.FRAMEBUFFER,null),Z=!1;else if(ze.__webglFramebuffer===void 0)ht.setupRenderTarget(w);else if(ze.__hasExternalTextures)ht.rebindTextures(w,ke.get(w.texture).__webglTexture,ke.get(w.depthTexture).__webglTexture);else if(w.depthBuffer){const Je=w.depthTexture;if(ze.__boundDepthTexture!==Je){if(Je!==null&&ke.has(Je)&&(w.width!==Je.image.width||w.height!==Je.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");ht.setupDepthRenderbuffer(w)}}const lt=w.texture;(lt.isData3DTexture||lt.isDataArrayTexture||lt.isCompressedArrayTexture)&&(De=!0);const ct=ke.get(w).__webglFramebuffer;w.isWebGLCubeRenderTarget?(Array.isArray(ct[z])?H=ct[z][K]:H=ct[z],Se=!0):w.samples>0&&ht.useMultisampledRTT(w)===!1?H=ke.get(w).__webglMultisampledFramebuffer:Array.isArray(ct)?H=ct[K]:H=ct,D.copy(w.viewport),X.copy(w.scissor),j=w.scissorTest}else D.copy(le).multiplyScalar(G).floor(),X.copy(we).multiplyScalar(G).floor(),j=be;if(K!==0&&(H=Ba),ve.bindFramebuffer(I.FRAMEBUFFER,H)&&Z&&ve.drawBuffers(w,H),ve.viewport(D),ve.scissor(X),ve.setScissorTest(j),Se){const ze=ke.get(w.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_CUBE_MAP_POSITIVE_X+z,ze.__webglTexture,K)}else if(De){const ze=ke.get(w.texture),lt=z;I.framebufferTextureLayer(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,ze.__webglTexture,K,lt)}else if(w!==null&&K!==0){const ze=ke.get(w.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,ze.__webglTexture,K)}E=-1},this.readRenderTargetPixels=function(w,z,K,Z,H,Se,De,Xe=0){if(!(w&&w.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ze=ke.get(w).__webglFramebuffer;if(w.isWebGLCubeRenderTarget&&De!==void 0&&(ze=ze[De]),ze){ve.bindFramebuffer(I.FRAMEBUFFER,ze);try{const lt=w.textures[Xe],ct=lt.format,Je=lt.type;if(!dt.textureFormatReadable(ct)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!dt.textureTypeReadable(Je)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}z>=0&&z<=w.width-Z&&K>=0&&K<=w.height-H&&(w.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+Xe),I.readPixels(z,K,Z,H,Ee.convert(ct),Ee.convert(Je),Se))}finally{const lt=U!==null?ke.get(U).__webglFramebuffer:null;ve.bindFramebuffer(I.FRAMEBUFFER,lt)}}},this.readRenderTargetPixelsAsync=async function(w,z,K,Z,H,Se,De,Xe=0){if(!(w&&w.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ze=ke.get(w).__webglFramebuffer;if(w.isWebGLCubeRenderTarget&&De!==void 0&&(ze=ze[De]),ze)if(z>=0&&z<=w.width-Z&&K>=0&&K<=w.height-H){ve.bindFramebuffer(I.FRAMEBUFFER,ze);const lt=w.textures[Xe],ct=lt.format,Je=lt.type;if(!dt.textureFormatReadable(ct))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!dt.textureTypeReadable(Je))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const mt=I.createBuffer();I.bindBuffer(I.PIXEL_PACK_BUFFER,mt),I.bufferData(I.PIXEL_PACK_BUFFER,Se.byteLength,I.STREAM_READ),w.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+Xe),I.readPixels(z,K,Z,H,Ee.convert(ct),Ee.convert(Je),0);const Pt=U!==null?ke.get(U).__webglFramebuffer:null;ve.bindFramebuffer(I.FRAMEBUFFER,Pt);const Bt=I.fenceSync(I.SYNC_GPU_COMMANDS_COMPLETE,0);return I.flush(),await zf(I,Bt,4),I.bindBuffer(I.PIXEL_PACK_BUFFER,mt),I.getBufferSubData(I.PIXEL_PACK_BUFFER,0,Se),I.deleteBuffer(mt),I.deleteSync(Bt),Se}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(w,z=null,K=0){const Z=Math.pow(2,-K),H=Math.floor(w.image.width*Z),Se=Math.floor(w.image.height*Z),De=z!==null?z.x:0,Xe=z!==null?z.y:0;ht.setTexture2D(w,0),I.copyTexSubImage2D(I.TEXTURE_2D,K,0,0,De,Xe,H,Se),ve.unbindTexture()};const za=I.createFramebuffer(),Va=I.createFramebuffer();this.copyTextureToTexture=function(w,z,K=null,Z=null,H=0,Se=null){Se===null&&(H!==0?(Os("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),Se=H,H=0):Se=0);let De,Xe,ze,lt,ct,Je,mt,Pt,Bt;const Gt=w.isCompressedTexture?w.mipmaps[Se]:w.image;if(K!==null)De=K.max.x-K.min.x,Xe=K.max.y-K.min.y,ze=K.isBox3?K.max.z-K.min.z:1,lt=K.min.x,ct=K.min.y,Je=K.isBox3?K.min.z:0;else{const fn=Math.pow(2,-H);De=Math.floor(Gt.width*fn),Xe=Math.floor(Gt.height*fn),w.isDataArrayTexture?ze=Gt.depth:w.isData3DTexture?ze=Math.floor(Gt.depth*fn):ze=1,lt=0,ct=0,Je=0}Z!==null?(mt=Z.x,Pt=Z.y,Bt=Z.z):(mt=0,Pt=0,Bt=0);const bt=Ee.convert(z.format),st=Ee.convert(z.type);let Jt;z.isData3DTexture?(ht.setTexture3D(z,0),Jt=I.TEXTURE_3D):z.isDataArrayTexture||z.isCompressedArrayTexture?(ht.setTexture2DArray(z,0),Jt=I.TEXTURE_2D_ARRAY):(ht.setTexture2D(z,0),Jt=I.TEXTURE_2D),I.pixelStorei(I.UNPACK_FLIP_Y_WEBGL,z.flipY),I.pixelStorei(I.UNPACK_PREMULTIPLY_ALPHA_WEBGL,z.premultiplyAlpha),I.pixelStorei(I.UNPACK_ALIGNMENT,z.unpackAlignment);const wt=I.getParameter(I.UNPACK_ROW_LENGTH),An=I.getParameter(I.UNPACK_IMAGE_HEIGHT),zt=I.getParameter(I.UNPACK_SKIP_PIXELS),dn=I.getParameter(I.UNPACK_SKIP_ROWS),Yi=I.getParameter(I.UNPACK_SKIP_IMAGES);I.pixelStorei(I.UNPACK_ROW_LENGTH,Gt.width),I.pixelStorei(I.UNPACK_IMAGE_HEIGHT,Gt.height),I.pixelStorei(I.UNPACK_SKIP_PIXELS,lt),I.pixelStorei(I.UNPACK_SKIP_ROWS,ct),I.pixelStorei(I.UNPACK_SKIP_IMAGES,Je);const Ot=w.isDataArrayTexture||w.isData3DTexture,yn=z.isDataArrayTexture||z.isData3DTexture;if(w.isDepthTexture){const fn=ke.get(w),Zt=ke.get(z),Qt=ke.get(fn.__renderTarget),fs=ke.get(Zt.__renderTarget);ve.bindFramebuffer(I.READ_FRAMEBUFFER,Qt.__webglFramebuffer),ve.bindFramebuffer(I.DRAW_FRAMEBUFFER,fs.__webglFramebuffer);for(let hi=0;hi<ze;hi++)Ot&&(I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,ke.get(w).__webglTexture,H,Je+hi),I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,ke.get(z).__webglTexture,Se,Bt+hi)),I.blitFramebuffer(lt,ct,De,Xe,mt,Pt,De,Xe,I.DEPTH_BUFFER_BIT,I.NEAREST);ve.bindFramebuffer(I.READ_FRAMEBUFFER,null),ve.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else if(H!==0||w.isRenderTargetTexture||ke.has(w)){const fn=ke.get(w),Zt=ke.get(z);ve.bindFramebuffer(I.READ_FRAMEBUFFER,za),ve.bindFramebuffer(I.DRAW_FRAMEBUFFER,Va);for(let Qt=0;Qt<ze;Qt++)Ot?I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,fn.__webglTexture,H,Je+Qt):I.framebufferTexture2D(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,fn.__webglTexture,H),yn?I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,Zt.__webglTexture,Se,Bt+Qt):I.framebufferTexture2D(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,Zt.__webglTexture,Se),H!==0?I.blitFramebuffer(lt,ct,De,Xe,mt,Pt,De,Xe,I.COLOR_BUFFER_BIT,I.NEAREST):yn?I.copyTexSubImage3D(Jt,Se,mt,Pt,Bt+Qt,lt,ct,De,Xe):I.copyTexSubImage2D(Jt,Se,mt,Pt,lt,ct,De,Xe);ve.bindFramebuffer(I.READ_FRAMEBUFFER,null),ve.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else yn?w.isDataTexture||w.isData3DTexture?I.texSubImage3D(Jt,Se,mt,Pt,Bt,De,Xe,ze,bt,st,Gt.data):z.isCompressedArrayTexture?I.compressedTexSubImage3D(Jt,Se,mt,Pt,Bt,De,Xe,ze,bt,Gt.data):I.texSubImage3D(Jt,Se,mt,Pt,Bt,De,Xe,ze,bt,st,Gt):w.isDataTexture?I.texSubImage2D(I.TEXTURE_2D,Se,mt,Pt,De,Xe,bt,st,Gt.data):w.isCompressedTexture?I.compressedTexSubImage2D(I.TEXTURE_2D,Se,mt,Pt,Gt.width,Gt.height,bt,Gt.data):I.texSubImage2D(I.TEXTURE_2D,Se,mt,Pt,De,Xe,bt,st,Gt);I.pixelStorei(I.UNPACK_ROW_LENGTH,wt),I.pixelStorei(I.UNPACK_IMAGE_HEIGHT,An),I.pixelStorei(I.UNPACK_SKIP_PIXELS,zt),I.pixelStorei(I.UNPACK_SKIP_ROWS,dn),I.pixelStorei(I.UNPACK_SKIP_IMAGES,Yi),Se===0&&z.generateMipmaps&&I.generateMipmap(Jt),ve.unbindTexture()},this.copyTextureToTexture3D=function(w,z,K=null,Z=null,H=0){return Os('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(w,z,K,Z,H)},this.initRenderTarget=function(w){ke.get(w).__webglFramebuffer===void 0&&ht.setupRenderTarget(w)},this.initTexture=function(w){w.isCubeTexture?ht.setTextureCube(w,0):w.isData3DTexture?ht.setTexture3D(w,0):w.isDataArrayTexture||w.isCompressedArrayTexture?ht.setTexture2DArray(w,0):ht.setTexture2D(w,0),ve.unbindTexture()},this.resetState=function(){P=0,L=0,U=null,ve.reset(),at.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Si}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=pt._getDrawingBufferColorSpace(e),t.unpackColorSpace=pt._getUnpackColorSpace()}}const tx=/^[og]\s*(.+)?/,nx=/^mtllib /,ix=/^usemtl /,sx=/^usemap /,Eu=/\s+/,Au=new O,Eo=new O,wu=new O,Ru=new O,On=new O,ha=new He;function rx(){const s={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(e,t){if(this.object&&this.object.fromDeclaration===!1){this.object.name=e,this.object.fromDeclaration=t!==!1;return}const n=this.object&&typeof this.object.currentMaterial=="function"?this.object.currentMaterial():void 0;if(this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0),this.object={name:e||"",fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(i,r){const a=this._finalize(!1);a&&(a.inherited||a.groupCount<=0)&&this.materials.splice(a.index,1);const o={index:this.materials.length,name:i||"",mtllib:Array.isArray(r)&&r.length>0?r[r.length-1]:"",smooth:a!==void 0?a.smooth:this.smooth,groupStart:a!==void 0?a.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(l){const c={index:typeof l=="number"?l:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return c.clone=this.clone.bind(c),c}};return this.materials.push(o),o},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(i){const r=this.currentMaterial();if(r&&r.groupEnd===-1&&(r.groupEnd=this.geometry.vertices.length/3,r.groupCount=r.groupEnd-r.groupStart,r.inherited=!1),i&&this.materials.length>1)for(let a=this.materials.length-1;a>=0;a--)this.materials[a].groupCount<=0&&this.materials.splice(a,1);return i&&this.materials.length===0&&this.materials.push({name:"",smooth:this.smooth}),r}},n&&n.name&&typeof n.clone=="function"){const i=n.clone(0);i.inherited=!0,this.object.materials.push(i)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0)},parseVertexIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseNormalIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseUVIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/2)*2},addVertex:function(e,t,n){const i=this.vertices,r=this.object.geometry.vertices;r.push(i[e+0],i[e+1],i[e+2]),r.push(i[t+0],i[t+1],i[t+2]),r.push(i[n+0],i[n+1],i[n+2])},addVertexPoint:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,n){const i=this.normals,r=this.object.geometry.normals;r.push(i[e+0],i[e+1],i[e+2]),r.push(i[t+0],i[t+1],i[t+2]),r.push(i[n+0],i[n+1],i[n+2])},addFaceNormal:function(e,t,n){const i=this.vertices,r=this.object.geometry.normals;Au.fromArray(i,e),Eo.fromArray(i,t),wu.fromArray(i,n),On.subVectors(wu,Eo),Ru.subVectors(Au,Eo),On.cross(Ru),On.normalize(),r.push(On.x,On.y,On.z),r.push(On.x,On.y,On.z),r.push(On.x,On.y,On.z)},addColor:function(e,t,n){const i=this.colors,r=this.object.geometry.colors;i[e]!==void 0&&r.push(i[e+0],i[e+1],i[e+2]),i[t]!==void 0&&r.push(i[t+0],i[t+1],i[t+2]),i[n]!==void 0&&r.push(i[n+0],i[n+1],i[n+2])},addUV:function(e,t,n){const i=this.uvs,r=this.object.geometry.uvs;r.push(i[e+0],i[e+1]),r.push(i[t+0],i[t+1]),r.push(i[n+0],i[n+1])},addDefaultUV:function(){const e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){const t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,n,i,r,a,o,l,c){const u=this.vertices.length;let h=this.parseVertexIndex(e,u),d=this.parseVertexIndex(t,u),f=this.parseVertexIndex(n,u);if(this.addVertex(h,d,f),this.addColor(h,d,f),o!==void 0&&o!==""){const g=this.normals.length;h=this.parseNormalIndex(o,g),d=this.parseNormalIndex(l,g),f=this.parseNormalIndex(c,g),this.addNormal(h,d,f)}else this.addFaceNormal(h,d,f);if(i!==void 0&&i!==""){const g=this.uvs.length;h=this.parseUVIndex(i,g),d=this.parseUVIndex(r,g),f=this.parseUVIndex(a,g),this.addUV(h,d,f),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type="Points";const t=this.vertices.length;for(let n=0,i=e.length;n<i;n++){const r=this.parseVertexIndex(e[n],t);this.addVertexPoint(r),this.addColor(r)}},addLineGeometry:function(e,t){this.object.geometry.type="Line";const n=this.vertices.length,i=this.uvs.length;for(let r=0,a=e.length;r<a;r++)this.addVertexLine(this.parseVertexIndex(e[r],n));for(let r=0,a=t.length;r<a;r++)this.addUVLine(this.parseUVIndex(t[r],i))}};return s.startObject("",!1),s}class ax extends bn{constructor(e){super(e),this.materials=null}load(e,t,n,i){const r=this,a=new Xi(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(r.parse(o))}catch(l){i?i(l):console.error(l),r.manager.itemError(e)}},n,i)}setMaterials(e){return this.materials=e,this}parse(e){const t=new rx;e.indexOf(`\r
3827
+ }`;class Yy{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){const i=new an,r=e.properties.get(i);r.__webglTexture=t.texture,(t.depthNear!==n.depthNear||t.depthFar!==n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new Wi({vertexShader:qy,fragmentShader:Ky,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new rn(new Fa(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Zy extends ds{constructor(e,t){super();const n=this;let i=null,r=1,a=null,o="local-floor",l=1,c=null,u=null,h=null,d=null,f=null,g=null;const _=new Yy,m=t.getContextAttributes();let p=null,S=null;const v=[],y=[],N=new ct;let P=null;const L=new un;L.viewport=new Tt;const U=new un;U.viewport=new Tt;const E=[L,U],T=new rm;let D=null,X=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(W){let ee=v[W];return ee===void 0&&(ee=new uo,v[W]=ee),ee.getTargetRaySpace()},this.getControllerGrip=function(W){let ee=v[W];return ee===void 0&&(ee=new uo,v[W]=ee),ee.getGripSpace()},this.getHand=function(W){let ee=v[W];return ee===void 0&&(ee=new uo,v[W]=ee),ee.getHandSpace()};function q(W){const ee=y.indexOf(W.inputSource);if(ee===-1)return;const ae=v[ee];ae!==void 0&&(ae.update(W.inputSource,W.frame,c||a),ae.dispatchEvent({type:W.type,data:W.inputSource}))}function se(){i.removeEventListener("select",q),i.removeEventListener("selectstart",q),i.removeEventListener("selectend",q),i.removeEventListener("squeeze",q),i.removeEventListener("squeezestart",q),i.removeEventListener("squeezeend",q),i.removeEventListener("end",se),i.removeEventListener("inputsourceschange",he);for(let W=0;W<v.length;W++){const ee=y[W];ee!==null&&(y[W]=null,v[W].disconnect(ee))}D=null,X=null,_.reset(),e.setRenderTarget(p),f=null,d=null,h=null,i=null,S=null,Me.stop(),n.isPresenting=!1,e.setPixelRatio(P),e.setSize(N.width,N.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(W){r=W,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(W){o=W,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(W){c=W},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return h},this.getFrame=function(){return g},this.getSession=function(){return i},this.setSession=async function(W){if(i=W,i!==null){if(p=e.getRenderTarget(),i.addEventListener("select",q),i.addEventListener("selectstart",q),i.addEventListener("selectend",q),i.addEventListener("squeeze",q),i.addEventListener("squeezestart",q),i.addEventListener("squeezeend",q),i.addEventListener("end",se),i.addEventListener("inputsourceschange",he),m.xrCompatible!==!0&&await t.makeXRCompatible(),P=e.getPixelRatio(),e.getSize(N),typeof XRWebGLBinding<"u"&&"createProjectionLayer"in XRWebGLBinding.prototype){let ae=null,re=null,Se=null;m.depth&&(Se=m.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ae=m.stencil?_r:gr,re=m.stencil?mr:ls);const ot={colorFormat:t.RGBA8,depthFormat:Se,scaleFactor:r};h=new XRWebGLBinding(i,t),d=h.createProjectionLayer(ot),i.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),S=new cs(d.textureWidth,d.textureHeight,{format:Gn,type:ai,depthTexture:new fh(d.textureWidth,d.textureHeight,re,void 0,void 0,void 0,void 0,void 0,void 0,ae),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const ae={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(i,t,ae),i.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),S=new cs(f.framebufferWidth,f.framebufferHeight,{format:Gn,type:ai,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}S.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await i.requestReferenceSpace(o),Me.setContext(i),Me.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return _.getDepthTexture()};function he(W){for(let ee=0;ee<W.removed.length;ee++){const ae=W.removed[ee],re=y.indexOf(ae);re>=0&&(y[re]=null,v[re].disconnect(ae))}for(let ee=0;ee<W.added.length;ee++){const ae=W.added[ee];let re=y.indexOf(ae);if(re===-1){for(let ot=0;ot<v.length;ot++)if(ot>=y.length){y.push(ae),re=ot;break}else if(y[ot]===null){y[ot]=ae,re=ot;break}if(re===-1)break}const Se=v[re];Se&&Se.connect(ae)}}const k=new O,oe=new O;function G(W,ee,ae){k.setFromMatrixPosition(ee.matrixWorld),oe.setFromMatrixPosition(ae.matrixWorld);const re=k.distanceTo(oe),Se=ee.projectionMatrix.elements,ot=ae.projectionMatrix.elements,J=Se[14]/(Se[10]-1),$=Se[14]/(Se[10]+1),Z=(Se[9]+1)/Se[5],ie=(Se[9]-1)/Se[5],I=(Se[8]-1)/Se[0],Te=(ot[8]+1)/ot[0],de=J*I,qe=J*Te,De=re/(-I+Te),Oe=De*-I;if(ee.matrixWorld.decompose(W.position,W.quaternion,W.scale),W.translateX(Oe),W.translateZ(De),W.matrixWorld.compose(W.position,W.quaternion,W.scale),W.matrixWorldInverse.copy(W.matrixWorld).invert(),Se[10]===-1)W.projectionMatrix.copy(ee.projectionMatrix),W.projectionMatrixInverse.copy(ee.projectionMatrixInverse);else{const Ie=J+De,tt=$+De,Nt=de-Oe,F=qe+(re-Oe),b=Z*$/tt*Ie,K=ie*$/tt*Ie;W.projectionMatrix.makePerspective(Nt,F,b,K,Ie,tt),W.projectionMatrixInverse.copy(W.projectionMatrix).invert()}}function fe(W,ee){ee===null?W.matrixWorld.copy(W.matrix):W.matrixWorld.multiplyMatrices(ee.matrixWorld,W.matrix),W.matrixWorldInverse.copy(W.matrixWorld).invert()}this.updateCamera=function(W){if(i===null)return;let ee=W.near,ae=W.far;_.texture!==null&&(_.depthNear>0&&(ee=_.depthNear),_.depthFar>0&&(ae=_.depthFar)),T.near=U.near=L.near=ee,T.far=U.far=L.far=ae,(D!==T.near||X!==T.far)&&(i.updateRenderState({depthNear:T.near,depthFar:T.far}),D=T.near,X=T.far),L.layers.mask=W.layers.mask|2,U.layers.mask=W.layers.mask|4,T.layers.mask=L.layers.mask|U.layers.mask;const re=W.parent,Se=T.cameras;fe(T,re);for(let ot=0;ot<Se.length;ot++)fe(Se[ot],re);Se.length===2?G(T,L,U):T.projectionMatrix.copy(L.projectionMatrix),ve(W,T,re)};function ve(W,ee,ae){ae===null?W.matrix.copy(ee.matrixWorld):(W.matrix.copy(ae.matrixWorld),W.matrix.invert(),W.matrix.multiply(ee.matrixWorld)),W.matrix.decompose(W.position,W.quaternion,W.scale),W.updateMatrixWorld(!0),W.projectionMatrix.copy(ee.projectionMatrix),W.projectionMatrixInverse.copy(ee.projectionMatrixInverse),W.isPerspectiveCamera&&(W.fov=Ws*2*Math.atan(1/W.projectionMatrix.elements[5]),W.zoom=1)}this.getCamera=function(){return T},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function(W){l=W,d!==null&&(d.fixedFoveation=W),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=W)},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(T)};let le=null;function we(W,ee){if(u=ee.getViewerPose(c||a),g=ee,u!==null){const ae=u.views;f!==null&&(e.setRenderTargetFramebuffer(S,f.framebuffer),e.setRenderTarget(S));let re=!1;ae.length!==T.cameras.length&&(T.cameras.length=0,re=!0);for(let J=0;J<ae.length;J++){const $=ae[J];let Z=null;if(f!==null)Z=f.getViewport($);else{const I=h.getViewSubImage(d,$);Z=I.viewport,J===0&&(e.setRenderTargetTextures(S,I.colorTexture,I.depthStencilTexture),e.setRenderTarget(S))}let ie=E[J];ie===void 0&&(ie=new un,ie.layers.enable(J),ie.viewport=new Tt,E[J]=ie),ie.matrix.fromArray($.transform.matrix),ie.matrix.decompose(ie.position,ie.quaternion,ie.scale),ie.projectionMatrix.fromArray($.projectionMatrix),ie.projectionMatrixInverse.copy(ie.projectionMatrix).invert(),ie.viewport.set(Z.x,Z.y,Z.width,Z.height),J===0&&(T.matrix.copy(ie.matrix),T.matrix.decompose(T.position,T.quaternion,T.scale)),re===!0&&T.cameras.push(ie)}const Se=i.enabledFeatures;if(Se&&Se.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&h){const J=h.getDepthInformation(ae[0]);J&&J.isValid&&J.texture&&_.init(e,J,i.renderState)}}for(let ae=0;ae<v.length;ae++){const re=y[ae],Se=v[ae];re!==null&&Se!==void 0&&Se.update(re,ee,c||a)}le&&le(W,ee),ee.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:ee}),g=null}const Me=new Mh;Me.setAnimationLoop(we),this.setAnimationLoop=function(W){le=W},this.dispose=function(){}}}const ts=new sn,$y=new Fe;function Jy(s,e){function t(m,p){m.matrixAutoUpdate===!0&&m.updateMatrix(),p.value.copy(m.matrix)}function n(m,p){p.color.getRGB(m.fogColor.value,ch(s)),p.isFog?(m.fogNear.value=p.near,m.fogFar.value=p.far):p.isFogExp2&&(m.fogDensity.value=p.density)}function i(m,p,S,v,y){p.isMeshBasicMaterial||p.isMeshLambertMaterial?r(m,p):p.isMeshToonMaterial?(r(m,p),h(m,p)):p.isMeshPhongMaterial?(r(m,p),u(m,p)):p.isMeshStandardMaterial?(r(m,p),d(m,p),p.isMeshPhysicalMaterial&&f(m,p,y)):p.isMeshMatcapMaterial?(r(m,p),g(m,p)):p.isMeshDepthMaterial?r(m,p):p.isMeshDistanceMaterial?(r(m,p),_(m,p)):p.isMeshNormalMaterial?r(m,p):p.isLineBasicMaterial?(a(m,p),p.isLineDashedMaterial&&o(m,p)):p.isPointsMaterial?l(m,p,S,v):p.isSpriteMaterial?c(m,p):p.isShadowMaterial?(m.color.value.copy(p.color),m.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function r(m,p){m.opacity.value=p.opacity,p.color&&m.diffuse.value.copy(p.color),p.emissive&&m.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.bumpMap&&(m.bumpMap.value=p.bumpMap,t(p.bumpMap,m.bumpMapTransform),m.bumpScale.value=p.bumpScale,p.side===In&&(m.bumpScale.value*=-1)),p.normalMap&&(m.normalMap.value=p.normalMap,t(p.normalMap,m.normalMapTransform),m.normalScale.value.copy(p.normalScale),p.side===In&&m.normalScale.value.negate()),p.displacementMap&&(m.displacementMap.value=p.displacementMap,t(p.displacementMap,m.displacementMapTransform),m.displacementScale.value=p.displacementScale,m.displacementBias.value=p.displacementBias),p.emissiveMap&&(m.emissiveMap.value=p.emissiveMap,t(p.emissiveMap,m.emissiveMapTransform)),p.specularMap&&(m.specularMap.value=p.specularMap,t(p.specularMap,m.specularMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest);const S=e.get(p),v=S.envMap,y=S.envMapRotation;v&&(m.envMap.value=v,ts.copy(y),ts.x*=-1,ts.y*=-1,ts.z*=-1,v.isCubeTexture&&v.isRenderTargetTexture===!1&&(ts.y*=-1,ts.z*=-1),m.envMapRotation.value.setFromMatrix4($y.makeRotationFromEuler(ts)),m.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio),p.lightMap&&(m.lightMap.value=p.lightMap,m.lightMapIntensity.value=p.lightMapIntensity,t(p.lightMap,m.lightMapTransform)),p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,m.aoMapTransform))}function a(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform))}function o(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}function l(m,p,S,v){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*S,m.scale.value=v*.5,p.map&&(m.map.value=p.map,t(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function c(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.rotation.value=p.rotation,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function u(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,1e-4)}function h(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function d(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,m.roughnessMapTransform)),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function f(m,p,S){m.ior.value=p.ior,p.sheen>0&&(m.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),m.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(m.sheenColorMap.value=p.sheenColorMap,t(p.sheenColorMap,m.sheenColorMapTransform)),p.sheenRoughnessMap&&(m.sheenRoughnessMap.value=p.sheenRoughnessMap,t(p.sheenRoughnessMap,m.sheenRoughnessMapTransform))),p.clearcoat>0&&(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(m.clearcoatMap.value=p.clearcoatMap,t(p.clearcoatMap,m.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,t(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(m.clearcoatNormalMap.value=p.clearcoatNormalMap,t(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===In&&m.clearcoatNormalScale.value.negate())),p.dispersion>0&&(m.dispersion.value=p.dispersion),p.iridescence>0&&(m.iridescence.value=p.iridescence,m.iridescenceIOR.value=p.iridescenceIOR,m.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(m.iridescenceMap.value=p.iridescenceMap,t(p.iridescenceMap,m.iridescenceMapTransform)),p.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,t(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),p.transmission>0&&(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=S.texture,m.transmissionSamplerSize.value.set(S.width,S.height),p.transmissionMap&&(m.transmissionMap.value=p.transmissionMap,t(p.transmissionMap,m.transmissionMapTransform)),m.thickness.value=p.thickness,p.thicknessMap&&(m.thicknessMap.value=p.thicknessMap,t(p.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=p.attenuationDistance,m.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(m.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(m.anisotropyMap.value=p.anisotropyMap,t(p.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap&&(m.specularColorMap.value=p.specularColorMap,t(p.specularColorMap,m.specularColorMapTransform)),p.specularIntensityMap&&(m.specularIntensityMap.value=p.specularIntensityMap,t(p.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,p){p.matcap&&(m.matcap.value=p.matcap)}function _(m,p){const S=e.get(p).light;m.referencePosition.value.setFromMatrixPosition(S.matrixWorld),m.nearDistance.value=S.shadow.camera.near,m.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function Qy(s,e,t,n){let i={},r={},a=[];const o=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function l(S,v){const y=v.program;n.uniformBlockBinding(S,y)}function c(S,v){let y=i[S.id];y===void 0&&(g(S),y=u(S),i[S.id]=y,S.addEventListener("dispose",m));const N=v.program;n.updateUBOMapping(S,N);const P=e.render.frame;r[S.id]!==P&&(d(S),r[S.id]=P)}function u(S){const v=h();S.__bindingPointIndex=v;const y=s.createBuffer(),N=S.__size,P=S.usage;return s.bindBuffer(s.UNIFORM_BUFFER,y),s.bufferData(s.UNIFORM_BUFFER,N,P),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,v,y),y}function h(){for(let S=0;S<o;S++)if(a.indexOf(S)===-1)return a.push(S),S;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(S){const v=i[S.id],y=S.uniforms,N=S.__cache;s.bindBuffer(s.UNIFORM_BUFFER,v);for(let P=0,L=y.length;P<L;P++){const U=Array.isArray(y[P])?y[P]:[y[P]];for(let E=0,T=U.length;E<T;E++){const D=U[E];if(f(D,P,E,N)===!0){const X=D.__offset,q=Array.isArray(D.value)?D.value:[D.value];let se=0;for(let he=0;he<q.length;he++){const k=q[he],oe=_(k);typeof k=="number"||typeof k=="boolean"?(D.__data[0]=k,s.bufferSubData(s.UNIFORM_BUFFER,X+se,D.__data)):k.isMatrix3?(D.__data[0]=k.elements[0],D.__data[1]=k.elements[1],D.__data[2]=k.elements[2],D.__data[3]=0,D.__data[4]=k.elements[3],D.__data[5]=k.elements[4],D.__data[6]=k.elements[5],D.__data[7]=0,D.__data[8]=k.elements[6],D.__data[9]=k.elements[7],D.__data[10]=k.elements[8],D.__data[11]=0):(k.toArray(D.__data,se),se+=oe.storage/Float32Array.BYTES_PER_ELEMENT)}s.bufferSubData(s.UNIFORM_BUFFER,X,D.__data)}}}s.bindBuffer(s.UNIFORM_BUFFER,null)}function f(S,v,y,N){const P=S.value,L=v+"_"+y;if(N[L]===void 0)return typeof P=="number"||typeof P=="boolean"?N[L]=P:N[L]=P.clone(),!0;{const U=N[L];if(typeof P=="number"||typeof P=="boolean"){if(U!==P)return N[L]=P,!0}else if(U.equals(P)===!1)return U.copy(P),!0}return!1}function g(S){const v=S.uniforms;let y=0;const N=16;for(let L=0,U=v.length;L<U;L++){const E=Array.isArray(v[L])?v[L]:[v[L]];for(let T=0,D=E.length;T<D;T++){const X=E[T],q=Array.isArray(X.value)?X.value:[X.value];for(let se=0,he=q.length;se<he;se++){const k=q[se],oe=_(k),G=y%N,fe=G%oe.boundary,ve=G+fe;y+=fe,ve!==0&&N-ve<oe.storage&&(y+=N-ve),X.__data=new Float32Array(oe.storage/Float32Array.BYTES_PER_ELEMENT),X.__offset=y,y+=oe.storage}}}const P=y%N;return P>0&&(y+=N-P),S.__size=y,S.__cache={},this}function _(S){const v={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(v.boundary=4,v.storage=4):S.isVector2?(v.boundary=8,v.storage=8):S.isVector3||S.isColor?(v.boundary=16,v.storage=12):S.isVector4?(v.boundary=16,v.storage=16):S.isMatrix3?(v.boundary=48,v.storage=48):S.isMatrix4?(v.boundary=64,v.storage=64):S.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",S),v}function m(S){const v=S.target;v.removeEventListener("dispose",m);const y=a.indexOf(v.__bindingPointIndex);a.splice(y,1),s.deleteBuffer(i[v.id]),delete i[v.id],delete r[v.id]}function p(){for(const S in i)s.deleteBuffer(i[S]);a=[],i={},r={}}return{bind:l,update:c,dispose:p}}class ev{constructor(e={}){const{canvas:t=Bf(),context:n=null,depth:i=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1,reverseDepthBuffer:d=!1}=e;this.isWebGLRenderer=!0;let f;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=n.getContextAttributes().alpha}else f=a;const g=new Uint32Array(4),_=new Int32Array(4);let m=null,p=null;const S=[],v=[];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=Gi,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const y=this;let N=!1;this._outputColorSpace=_t;let P=0,L=0,U=null,E=-1,T=null;const D=new Tt,X=new Tt;let q=null;const se=new Ge(0);let he=0,k=t.width,oe=t.height,G=1,fe=null,ve=null;const le=new Tt(0,0,k,oe),we=new Tt(0,0,k,oe);let Me=!1;const W=new Gl;let ee=!1,ae=!1;const re=new Fe,Se=new Fe,ot=new O,J=new Tt,$={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Z=!1;function ie(){return U===null?G:1}let I=n;function Te(w,z){return t.getContext(w,z)}try{const w={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Cl}`),t.addEventListener("webglcontextlost",Be,!1),t.addEventListener("webglcontextrestored",ye,!1),t.addEventListener("webglcontextcreationerror",j,!1),I===null){const z="webgl2";if(I=Te(z,w),I===null)throw Te(z)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(w){throw console.error("THREE.WebGLRenderer: "+w.message),w}let de,qe,De,Oe,Ie,tt,Nt,F,b,K,ce,pe,ne,ze,Ae,We,Ye,me,ke,st,nt,be,lt,B;function Re(){de=new u0(I),de.init(),be=new jy(I,de),qe=new i0(I,de,e,be),De=new Wy(I,de),qe.reverseDepthBuffer&&d&&De.buffers.depth.setReversed(!0),Oe=new f0(I),Ie=new Ly,tt=new Xy(I,de,De,Ie,qe,be,Oe),Nt=new r0(y),F=new c0(y),b=new vm(I),lt=new t0(I,b),K=new h0(I,b,Oe,lt),ce=new m0(I,K,b,Oe),ke=new p0(I,qe,tt),We=new s0(Ie),pe=new Py(y,Nt,F,de,qe,lt,We),ne=new Jy(y,Ie),ze=new Iy,Ae=new By(de),me=new e0(y,Nt,F,De,ce,f,l),Ye=new Hy(y,ce,qe),B=new Qy(I,Oe,qe,De),st=new n0(I,de,Oe),nt=new d0(I,de,Oe),Oe.programs=pe.programs,y.capabilities=qe,y.extensions=de,y.properties=Ie,y.renderLists=ze,y.shadowMap=Ye,y.state=De,y.info=Oe}Re();const ge=new Zy(y,I);this.xr=ge,this.getContext=function(){return I},this.getContextAttributes=function(){return I.getContextAttributes()},this.forceContextLoss=function(){const w=de.get("WEBGL_lose_context");w&&w.loseContext()},this.forceContextRestore=function(){const w=de.get("WEBGL_lose_context");w&&w.restoreContext()},this.getPixelRatio=function(){return G},this.setPixelRatio=function(w){w!==void 0&&(G=w,this.setSize(k,oe,!1))},this.getSize=function(w){return w.set(k,oe)},this.setSize=function(w,z,Y=!0){if(ge.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}k=w,oe=z,t.width=Math.floor(w*G),t.height=Math.floor(z*G),Y===!0&&(t.style.width=w+"px",t.style.height=z+"px"),this.setViewport(0,0,w,z)},this.getDrawingBufferSize=function(w){return w.set(k*G,oe*G).floor()},this.setDrawingBufferSize=function(w,z,Y){k=w,oe=z,G=Y,t.width=Math.floor(w*Y),t.height=Math.floor(z*Y),this.setViewport(0,0,w,z)},this.getCurrentViewport=function(w){return w.copy(D)},this.getViewport=function(w){return w.copy(le)},this.setViewport=function(w,z,Y,Q){w.isVector4?le.set(w.x,w.y,w.z,w.w):le.set(w,z,Y,Q),De.viewport(D.copy(le).multiplyScalar(G).round())},this.getScissor=function(w){return w.copy(we)},this.setScissor=function(w,z,Y,Q){w.isVector4?we.set(w.x,w.y,w.z,w.w):we.set(w,z,Y,Q),De.scissor(X.copy(we).multiplyScalar(G).round())},this.getScissorTest=function(){return Me},this.setScissorTest=function(w){De.setScissorTest(Me=w)},this.setOpaqueSort=function(w){fe=w},this.setTransparentSort=function(w){ve=w},this.getClearColor=function(w){return w.copy(me.getClearColor())},this.setClearColor=function(){me.setClearColor(...arguments)},this.getClearAlpha=function(){return me.getClearAlpha()},this.setClearAlpha=function(){me.setClearAlpha(...arguments)},this.clear=function(w=!0,z=!0,Y=!0){let Q=0;if(w){let H=!1;if(U!==null){const xe=U.texture.format;H=xe===Fl||xe===Ul||xe===Nl}if(H){const xe=U.texture.type,Pe=xe===ai||xe===ls||xe===pr||xe===mr||xe===Ll||xe===Dl,Xe=me.getClearColor(),Ve=me.getClearAlpha(),ut=Xe.r,ht=Xe.g,et=Xe.b;Pe?(g[0]=ut,g[1]=ht,g[2]=et,g[3]=Ve,I.clearBufferuiv(I.COLOR,0,g)):(_[0]=ut,_[1]=ht,_[2]=et,_[3]=Ve,I.clearBufferiv(I.COLOR,0,_))}else Q|=I.COLOR_BUFFER_BIT}z&&(Q|=I.DEPTH_BUFFER_BIT),Y&&(Q|=I.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),I.clear(Q)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Be,!1),t.removeEventListener("webglcontextrestored",ye,!1),t.removeEventListener("webglcontextcreationerror",j,!1),me.dispose(),ze.dispose(),Ae.dispose(),Ie.dispose(),Nt.dispose(),F.dispose(),ce.dispose(),lt.dispose(),B.dispose(),pe.dispose(),ge.dispose(),ge.removeEventListener("sessionstart",Ne),ge.removeEventListener("sessionend",Yt),dn.stop()};function Be(w){w.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),N=!0}function ye(){console.log("THREE.WebGLRenderer: Context Restored."),N=!1;const w=Oe.autoReset,z=Ye.enabled,Y=Ye.autoUpdate,Q=Ye.needsUpdate,H=Ye.type;Re(),Oe.autoReset=w,Ye.enabled=z,Ye.autoUpdate=Y,Ye.needsUpdate=Q,Ye.type=H}function j(w){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",w.statusMessage)}function Ce(w){const z=w.target;z.removeEventListener("dispose",Ce),Ze(z)}function Ze(w){bt(w),Ie.remove(w)}function bt(w){const z=Ie.get(w).programs;z!==void 0&&(z.forEach(function(Y){pe.releaseProgram(Y)}),w.isShaderMaterial&&pe.releaseShaderCache(w))}this.renderBufferDirect=function(w,z,Y,Q,H,xe){z===null&&(z=$);const Pe=H.isMesh&&H.matrixWorld.determinant()<0,Xe=fs(w,z,Y,Q,H);De.setMaterial(Q,Pe);let Ve=Y.index,ut=1;if(Q.wireframe===!0){if(Ve=K.getWireframeAttribute(Y),Ve===void 0)return;ut=2}const ht=Y.drawRange,et=Y.attributes.position;let mt=ht.start*ut,Lt=(ht.start+ht.count)*ut;xe!==null&&(mt=Math.max(mt,xe.start*ut),Lt=Math.min(Lt,(xe.start+xe.count)*ut)),Ve!==null?(mt=Math.max(mt,0),Lt=Math.min(Lt,Ve.count)):et!=null&&(mt=Math.max(mt,0),Lt=Math.min(Lt,et.count));const Bt=Lt-mt;if(Bt<0||Bt===1/0)return;lt.setup(H,Q,Xe,Y,Ve);let Ht,Et=st;if(Ve!==null&&(Ht=b.get(Ve),Et=nt,Et.setIndex(Ht)),H.isMesh)Q.wireframe===!0?(De.setLineWidth(Q.wireframeLinewidth*ie()),Et.setMode(I.LINES)):Et.setMode(I.TRIANGLES);else if(H.isLine){let rt=Q.linewidth;rt===void 0&&(rt=1),De.setLineWidth(rt*ie()),H.isLineSegments?Et.setMode(I.LINES):H.isLineLoop?Et.setMode(I.LINE_LOOP):Et.setMode(I.LINE_STRIP)}else H.isPoints?Et.setMode(I.POINTS):H.isSprite&&Et.setMode(I.TRIANGLES);if(H.isBatchedMesh)if(H._multiDrawInstances!==null)ks("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Et.renderMultiDrawInstances(H._multiDrawStarts,H._multiDrawCounts,H._multiDrawCount,H._multiDrawInstances);else if(de.get("WEBGL_multi_draw"))Et.renderMultiDraw(H._multiDrawStarts,H._multiDrawCounts,H._multiDrawCount);else{const rt=H._multiDrawStarts,Qt=H._multiDrawCounts,Rt=H._multiDrawCount,Rn=Ve?b.get(Ve).bytesPerElement:1,zt=Ie.get(Q).currentProgram.getUniforms();for(let fn=0;fn<Rt;fn++)zt.setValue(I,"_gl_DrawID",fn),Et.render(rt[fn]/Rn,Qt[fn])}else if(H.isInstancedMesh)Et.renderInstances(mt,Bt,H.count);else if(Y.isInstancedBufferGeometry){const rt=Y._maxInstanceCount!==void 0?Y._maxInstanceCount:1/0,Qt=Math.min(Y.instanceCount,rt);Et.renderInstances(mt,Bt,Qt)}else Et.render(mt,Bt)};function pt(w,z,Y){w.transparent===!0&&w.side===Zn&&w.forceSinglePass===!1?(w.side=In,w.needsUpdate=!0,ui(w,z,Y),w.side=ri,w.needsUpdate=!0,ui(w,z,Y),w.side=Zn):ui(w,z,Y)}this.compile=function(w,z,Y=null){Y===null&&(Y=w),p=Ae.get(Y),p.init(z),v.push(p),Y.traverseVisible(function(H){H.isLight&&H.layers.test(z.layers)&&(p.pushLight(H),H.castShadow&&p.pushShadow(H))}),w!==Y&&w.traverseVisible(function(H){H.isLight&&H.layers.test(z.layers)&&(p.pushLight(H),H.castShadow&&p.pushShadow(H))}),p.setupLights();const Q=new Set;return w.traverse(function(H){if(!(H.isMesh||H.isPoints||H.isLine||H.isSprite))return;const xe=H.material;if(xe)if(Array.isArray(xe))for(let Pe=0;Pe<xe.length;Pe++){const Xe=xe[Pe];pt(Xe,Y,H),Q.add(Xe)}else pt(xe,Y,H),Q.add(xe)}),p=v.pop(),Q},this.compileAsync=function(w,z,Y=null){const Q=this.compile(w,z,Y);return new Promise(H=>{function xe(){if(Q.forEach(function(Pe){Ie.get(Pe).currentProgram.isReady()&&Q.delete(Pe)}),Q.size===0){H(w);return}setTimeout(xe,10)}de.get("KHR_parallel_shader_compile")!==null?xe():setTimeout(xe,10)})};let Jt=null;function $e(w){Jt&&Jt(w)}function Ne(){dn.stop()}function Yt(){dn.start()}const dn=new Mh;dn.setAnimationLoop($e),typeof self<"u"&&dn.setContext(self),this.setAnimationLoop=function(w){Jt=w,ge.setAnimationLoop(w),w===null?dn.stop():dn.start()},ge.addEventListener("sessionstart",Ne),ge.addEventListener("sessionend",Yt),this.render=function(w,z){if(z!==void 0&&z.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(N===!0)return;if(w.matrixWorldAutoUpdate===!0&&w.updateMatrixWorld(),z.parent===null&&z.matrixWorldAutoUpdate===!0&&z.updateMatrixWorld(),ge.enabled===!0&&ge.isPresenting===!0&&(ge.cameraAutoUpdate===!0&&ge.updateCamera(z),z=ge.getCamera()),w.isScene===!0&&w.onBeforeRender(y,w,z,U),p=Ae.get(w,v.length),p.init(z),v.push(p),Se.multiplyMatrices(z.projectionMatrix,z.matrixWorldInverse),W.setFromProjectionMatrix(Se),ae=this.localClippingEnabled,ee=We.init(this.clippingPlanes,ae),m=ze.get(w,S.length),m.init(),S.push(m),ge.enabled===!0&&ge.isPresenting===!0){const xe=y.xr.getDepthSensingMesh();xe!==null&&jt(xe,z,-1/0,y.sortObjects)}jt(w,z,0,y.sortObjects),m.finish(),y.sortObjects===!0&&m.sort(fe,ve),Z=ge.enabled===!1||ge.isPresenting===!1||ge.hasDepthSensing()===!1,Z&&me.addToRenderList(m,w),this.info.render.frame++,ee===!0&&We.beginShadows();const Y=p.state.shadowsArray;Ye.render(Y,w,z),ee===!0&&We.endShadows(),this.info.autoReset===!0&&this.info.reset();const Q=m.opaque,H=m.transmissive;if(p.setupLights(),z.isArrayCamera){const xe=z.cameras;if(H.length>0)for(let Pe=0,Xe=xe.length;Pe<Xe;Pe++){const Ve=xe[Pe];vn(Q,H,w,Ve)}Z&&me.render(w);for(let Pe=0,Xe=xe.length;Pe<Xe;Pe++){const Ve=xe[Pe];pn(m,w,Ve,Ve.viewport)}}else H.length>0&&vn(Q,H,w,z),Z&&me.render(w),pn(m,w,z);U!==null&&L===0&&(tt.updateMultisampleRenderTarget(U),tt.updateRenderTargetMipmap(U)),w.isScene===!0&&w.onAfterRender(y,w,z),lt.resetDefaultState(),E=-1,T=null,v.pop(),v.length>0?(p=v[v.length-1],ee===!0&&We.setGlobalState(y.clippingPlanes,p.state.camera)):p=null,S.pop(),S.length>0?m=S[S.length-1]:m=null};function jt(w,z,Y,Q){if(w.visible===!1)return;if(w.layers.test(z.layers)){if(w.isGroup)Y=w.renderOrder;else if(w.isLOD)w.autoUpdate===!0&&w.update(z);else if(w.isLight)p.pushLight(w),w.castShadow&&p.pushShadow(w);else if(w.isSprite){if(!w.frustumCulled||W.intersectsSprite(w)){Q&&J.setFromMatrixPosition(w.matrixWorld).applyMatrix4(Se);const Pe=ce.update(w),Xe=w.material;Xe.visible&&m.push(w,Pe,Xe,Y,J.z,null)}}else if((w.isMesh||w.isLine||w.isPoints)&&(!w.frustumCulled||W.intersectsObject(w))){const Pe=ce.update(w),Xe=w.material;if(Q&&(w.boundingSphere!==void 0?(w.boundingSphere===null&&w.computeBoundingSphere(),J.copy(w.boundingSphere.center)):(Pe.boundingSphere===null&&Pe.computeBoundingSphere(),J.copy(Pe.boundingSphere.center)),J.applyMatrix4(w.matrixWorld).applyMatrix4(Se)),Array.isArray(Xe)){const Ve=Pe.groups;for(let ut=0,ht=Ve.length;ut<ht;ut++){const et=Ve[ut],mt=Xe[et.materialIndex];mt&&mt.visible&&m.push(w,Pe,mt,Y,J.z,et)}}else Xe.visible&&m.push(w,Pe,Xe,Y,J.z,null)}}const xe=w.children;for(let Pe=0,Xe=xe.length;Pe<Xe;Pe++)jt(xe[Pe],z,Y,Q)}function pn(w,z,Y,Q){const H=w.opaque,xe=w.transmissive,Pe=w.transparent;p.setupLightsView(Y),ee===!0&&We.setGlobalState(y.clippingPlanes,Y),Q&&De.viewport(D.copy(Q)),H.length>0&&ci(H,z,Y),xe.length>0&&ci(xe,z,Y),Pe.length>0&&ci(Pe,z,Y),De.buffers.depth.setTest(!0),De.buffers.depth.setMask(!0),De.buffers.color.setMask(!0),De.setPolygonOffset(!1)}function vn(w,z,Y,Q){if((Y.isScene===!0?Y.overrideMaterial:null)!==null)return;p.state.transmissionRenderTarget[Q.id]===void 0&&(p.state.transmissionRenderTarget[Q.id]=new cs(1,1,{generateMipmaps:!0,type:de.has("EXT_color_buffer_half_float")||de.has("EXT_color_buffer_float")?Rr:ai,minFilter:Qn,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:ft.workingColorSpace}));const xe=p.state.transmissionRenderTarget[Q.id],Pe=Q.viewport||D;xe.setSize(Pe.z*y.transmissionResolutionScale,Pe.w*y.transmissionResolutionScale);const Xe=y.getRenderTarget();y.setRenderTarget(xe),y.getClearColor(se),he=y.getClearAlpha(),he<1&&y.setClearColor(16777215,.5),y.clear(),Z&&me.render(Y);const Ve=y.toneMapping;y.toneMapping=Gi;const ut=Q.viewport;if(Q.viewport!==void 0&&(Q.viewport=void 0),p.setupLightsView(Q),ee===!0&&We.setGlobalState(y.clippingPlanes,Q),ci(w,Y,Q),tt.updateMultisampleRenderTarget(xe),tt.updateRenderTargetMipmap(xe),de.has("WEBGL_multisampled_render_to_texture")===!1){let ht=!1;for(let et=0,mt=z.length;et<mt;et++){const Lt=z[et],Bt=Lt.object,Ht=Lt.geometry,Et=Lt.material,rt=Lt.group;if(Et.side===Zn&&Bt.layers.test(Q.layers)){const Qt=Et.side;Et.side=In,Et.needsUpdate=!0,Pi(Bt,Y,Q,Ht,Et,rt),Et.side=Qt,Et.needsUpdate=!0,ht=!0}}ht===!0&&(tt.updateMultisampleRenderTarget(xe),tt.updateRenderTargetMipmap(xe))}y.setRenderTarget(Xe),y.setClearColor(se,he),ut!==void 0&&(Q.viewport=ut),y.toneMapping=Ve}function ci(w,z,Y){const Q=z.isScene===!0?z.overrideMaterial:null;for(let H=0,xe=w.length;H<xe;H++){const Pe=w[H],Xe=Pe.object,Ve=Pe.geometry,ut=Pe.group;let ht=Pe.material;ht.allowOverride===!0&&Q!==null&&(ht=Q),Xe.layers.test(Y.layers)&&Pi(Xe,z,Y,Ve,ht,ut)}}function Pi(w,z,Y,Q,H,xe){w.onBeforeRender(y,z,Y,Q,H,xe),w.modelViewMatrix.multiplyMatrices(Y.matrixWorldInverse,w.matrixWorld),w.normalMatrix.getNormalMatrix(w.modelViewMatrix),H.onBeforeRender(y,z,Y,Q,w,xe),H.transparent===!0&&H.side===Zn&&H.forceSinglePass===!1?(H.side=In,H.needsUpdate=!0,y.renderBufferDirect(Y,z,Q,H,w,xe),H.side=ri,H.needsUpdate=!0,y.renderBufferDirect(Y,z,Q,H,w,xe),H.side=Zn):y.renderBufferDirect(Y,z,Q,H,w,xe),w.onAfterRender(y,z,Y,Q,H,xe)}function ui(w,z,Y){z.isScene!==!0&&(z=$);const Q=Ie.get(w),H=p.state.lights,xe=p.state.shadowsArray,Pe=H.state.version,Xe=pe.getParameters(w,H.state,xe,z,Y),Ve=pe.getProgramCacheKey(Xe);let ut=Q.programs;Q.environment=w.isMeshStandardMaterial?z.environment:null,Q.fog=z.fog,Q.envMap=(w.isMeshStandardMaterial?F:Nt).get(w.envMap||Q.environment),Q.envMapRotation=Q.environment!==null&&w.envMap===null?z.environmentRotation:w.envMapRotation,ut===void 0&&(w.addEventListener("dispose",Ce),ut=new Map,Q.programs=ut);let ht=ut.get(Ve);if(ht!==void 0){if(Q.currentProgram===ht&&Q.lightsStateVersion===Pe)return qi(w,Xe),ht}else Xe.uniforms=pe.getUniforms(w),w.onBeforeCompile(Xe,y),ht=pe.acquireProgram(Xe,Ve),ut.set(Ve,ht),Q.uniforms=Xe.uniforms;const et=Q.uniforms;return(!w.isShaderMaterial&&!w.isRawShaderMaterial||w.clipping===!0)&&(et.clippingPlanes=We.uniform),qi(w,Xe),Q.needsLights=xn(w),Q.lightsStateVersion=Pe,Q.needsLights&&(et.ambientLightColor.value=H.state.ambient,et.lightProbe.value=H.state.probe,et.directionalLights.value=H.state.directional,et.directionalLightShadows.value=H.state.directionalShadow,et.spotLights.value=H.state.spot,et.spotLightShadows.value=H.state.spotShadow,et.rectAreaLights.value=H.state.rectArea,et.ltc_1.value=H.state.rectAreaLTC1,et.ltc_2.value=H.state.rectAreaLTC2,et.pointLights.value=H.state.point,et.pointLightShadows.value=H.state.pointShadow,et.hemisphereLights.value=H.state.hemi,et.directionalShadowMap.value=H.state.directionalShadowMap,et.directionalShadowMatrix.value=H.state.directionalShadowMatrix,et.spotShadowMap.value=H.state.spotShadowMap,et.spotLightMatrix.value=H.state.spotLightMatrix,et.spotLightMap.value=H.state.spotLightMap,et.pointShadowMap.value=H.state.pointShadowMap,et.pointShadowMatrix.value=H.state.pointShadowMatrix),Q.currentProgram=ht,Q.uniformsList=null,ht}function ji(w){if(w.uniformsList===null){const z=w.currentProgram.getUniforms();w.uniformsList=Sa.seqWithValue(z.seq,w.uniforms)}return w.uniformsList}function qi(w,z){const Y=Ie.get(w);Y.outputColorSpace=z.outputColorSpace,Y.batching=z.batching,Y.batchingColor=z.batchingColor,Y.instancing=z.instancing,Y.instancingColor=z.instancingColor,Y.instancingMorph=z.instancingMorph,Y.skinning=z.skinning,Y.morphTargets=z.morphTargets,Y.morphNormals=z.morphNormals,Y.morphColors=z.morphColors,Y.morphTargetsCount=z.morphTargetsCount,Y.numClippingPlanes=z.numClippingPlanes,Y.numIntersection=z.numClipIntersection,Y.vertexAlphas=z.vertexAlphas,Y.vertexTangents=z.vertexTangents,Y.toneMapping=z.toneMapping}function fs(w,z,Y,Q,H){z.isScene!==!0&&(z=$),tt.resetTextureUnits();const xe=z.fog,Pe=Q.isMeshStandardMaterial?z.environment:null,Xe=U===null?y.outputColorSpace:U.isXRRenderTarget===!0?U.texture.colorSpace:An,Ve=(Q.isMeshStandardMaterial?F:Nt).get(Q.envMap||Pe),ut=Q.vertexColors===!0&&!!Y.attributes.color&&Y.attributes.color.itemSize===4,ht=!!Y.attributes.tangent&&(!!Q.normalMap||Q.anisotropy>0),et=!!Y.morphAttributes.position,mt=!!Y.morphAttributes.normal,Lt=!!Y.morphAttributes.color;let Bt=Gi;Q.toneMapped&&(U===null||U.isXRRenderTarget===!0)&&(Bt=y.toneMapping);const Ht=Y.morphAttributes.position||Y.morphAttributes.normal||Y.morphAttributes.color,Et=Ht!==void 0?Ht.length:0,rt=Ie.get(Q),Qt=p.state.lights;if(ee===!0&&(ae===!0||w!==T)){const Zt=w===T&&Q.id===E;We.setState(Q,w,Zt)}let Rt=!1;Q.version===rt.__version?(rt.needsLights&&rt.lightsStateVersion!==Qt.state.version||rt.outputColorSpace!==Xe||H.isBatchedMesh&&rt.batching===!1||!H.isBatchedMesh&&rt.batching===!0||H.isBatchedMesh&&rt.batchingColor===!0&&H.colorTexture===null||H.isBatchedMesh&&rt.batchingColor===!1&&H.colorTexture!==null||H.isInstancedMesh&&rt.instancing===!1||!H.isInstancedMesh&&rt.instancing===!0||H.isSkinnedMesh&&rt.skinning===!1||!H.isSkinnedMesh&&rt.skinning===!0||H.isInstancedMesh&&rt.instancingColor===!0&&H.instanceColor===null||H.isInstancedMesh&&rt.instancingColor===!1&&H.instanceColor!==null||H.isInstancedMesh&&rt.instancingMorph===!0&&H.morphTexture===null||H.isInstancedMesh&&rt.instancingMorph===!1&&H.morphTexture!==null||rt.envMap!==Ve||Q.fog===!0&&rt.fog!==xe||rt.numClippingPlanes!==void 0&&(rt.numClippingPlanes!==We.numPlanes||rt.numIntersection!==We.numIntersection)||rt.vertexAlphas!==ut||rt.vertexTangents!==ht||rt.morphTargets!==et||rt.morphNormals!==mt||rt.morphColors!==Lt||rt.toneMapping!==Bt||rt.morphTargetsCount!==Et)&&(Rt=!0):(Rt=!0,rt.__version=Q.version);let Rn=rt.currentProgram;Rt===!0&&(Rn=ui(Q,z,H));let zt=!1,fn=!1,Yi=!1;const Ot=Rn.getUniforms(),Mn=rt.uniforms;if(De.useProgram(Rn.program)&&(zt=!0,fn=!0,Yi=!0),Q.id!==E&&(E=Q.id,fn=!0),zt||T!==w){De.buffers.depth.getReversed()?(re.copy(w.projectionMatrix),Vf(re),Hf(re),Ot.setValue(I,"projectionMatrix",re)):Ot.setValue(I,"projectionMatrix",w.projectionMatrix),Ot.setValue(I,"viewMatrix",w.matrixWorldInverse);const en=Ot.map.cameraPosition;en!==void 0&&en.setValue(I,ot.setFromMatrixPosition(w.matrixWorld)),qe.logarithmicDepthBuffer&&Ot.setValue(I,"logDepthBufFC",2/(Math.log(w.far+1)/Math.LN2)),(Q.isMeshPhongMaterial||Q.isMeshToonMaterial||Q.isMeshLambertMaterial||Q.isMeshBasicMaterial||Q.isMeshStandardMaterial||Q.isShaderMaterial)&&Ot.setValue(I,"isOrthographic",w.isOrthographicCamera===!0),T!==w&&(T=w,fn=!0,Yi=!0)}if(H.isSkinnedMesh){Ot.setOptional(I,H,"bindMatrix"),Ot.setOptional(I,H,"bindMatrixInverse");const Zt=H.skeleton;Zt&&(Zt.boneTexture===null&&Zt.computeBoneTexture(),Ot.setValue(I,"boneTexture",Zt.boneTexture,tt))}H.isBatchedMesh&&(Ot.setOptional(I,H,"batchingTexture"),Ot.setValue(I,"batchingTexture",H._matricesTexture,tt),Ot.setOptional(I,H,"batchingIdTexture"),Ot.setValue(I,"batchingIdTexture",H._indirectTexture,tt),Ot.setOptional(I,H,"batchingColorTexture"),H._colorsTexture!==null&&Ot.setValue(I,"batchingColorTexture",H._colorsTexture,tt));const mn=Y.morphAttributes;if((mn.position!==void 0||mn.normal!==void 0||mn.color!==void 0)&&ke.update(H,Y,Rn),(fn||rt.receiveShadow!==H.receiveShadow)&&(rt.receiveShadow=H.receiveShadow,Ot.setValue(I,"receiveShadow",H.receiveShadow)),Q.isMeshGouraudMaterial&&Q.envMap!==null&&(Mn.envMap.value=Ve,Mn.flipEnvMap.value=Ve.isCubeTexture&&Ve.isRenderTargetTexture===!1?-1:1),Q.isMeshStandardMaterial&&Q.envMap===null&&z.environment!==null&&(Mn.envMapIntensity.value=z.environmentIntensity),fn&&(Ot.setValue(I,"toneMappingExposure",y.toneMappingExposure),rt.needsLights&&Ki(Mn,Yi),xe&&Q.fog===!0&&ne.refreshFogUniforms(Mn,xe),ne.refreshMaterialUniforms(Mn,Q,G,oe,p.state.transmissionRenderTarget[w.id]),Sa.upload(I,ji(rt),Mn,tt)),Q.isShaderMaterial&&Q.uniformsNeedUpdate===!0&&(Sa.upload(I,ji(rt),Mn,tt),Q.uniformsNeedUpdate=!1),Q.isSpriteMaterial&&Ot.setValue(I,"center",H.center),Ot.setValue(I,"modelViewMatrix",H.modelViewMatrix),Ot.setValue(I,"normalMatrix",H.normalMatrix),Ot.setValue(I,"modelMatrix",H.matrixWorld),Q.isShaderMaterial||Q.isRawShaderMaterial){const Zt=Q.uniformsGroups;for(let en=0,ps=Zt.length;en<ps;en++){const di=Zt[en];B.update(di,Rn),B.bind(di,Rn)}}return Rn}function Ki(w,z){w.ambientLightColor.needsUpdate=z,w.lightProbe.needsUpdate=z,w.directionalLights.needsUpdate=z,w.directionalLightShadows.needsUpdate=z,w.pointLights.needsUpdate=z,w.pointLightShadows.needsUpdate=z,w.spotLights.needsUpdate=z,w.spotLightShadows.needsUpdate=z,w.rectAreaLights.needsUpdate=z,w.hemisphereLights.needsUpdate=z}function xn(w){return w.isMeshLambertMaterial||w.isMeshToonMaterial||w.isMeshPhongMaterial||w.isMeshStandardMaterial||w.isShadowMaterial||w.isShaderMaterial&&w.lights===!0}this.getActiveCubeFace=function(){return P},this.getActiveMipmapLevel=function(){return L},this.getRenderTarget=function(){return U},this.setRenderTargetTextures=function(w,z,Y){const Q=Ie.get(w);Q.__autoAllocateDepthBuffer=w.resolveDepthBuffer===!1,Q.__autoAllocateDepthBuffer===!1&&(Q.__useRenderToTexture=!1),Ie.get(w.texture).__webglTexture=z,Ie.get(w.depthTexture).__webglTexture=Q.__autoAllocateDepthBuffer?void 0:Y,Q.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(w,z){const Y=Ie.get(w);Y.__webglFramebuffer=z,Y.__useDefaultFramebuffer=z===void 0};const hi=I.createFramebuffer();this.setRenderTarget=function(w,z=0,Y=0){U=w,P=z,L=Y;let Q=!0,H=null,xe=!1,Pe=!1;if(w){const Ve=Ie.get(w);if(Ve.__useDefaultFramebuffer!==void 0)De.bindFramebuffer(I.FRAMEBUFFER,null),Q=!1;else if(Ve.__webglFramebuffer===void 0)tt.setupRenderTarget(w);else if(Ve.__hasExternalTextures)tt.rebindTextures(w,Ie.get(w.texture).__webglTexture,Ie.get(w.depthTexture).__webglTexture);else if(w.depthBuffer){const et=w.depthTexture;if(Ve.__boundDepthTexture!==et){if(et!==null&&Ie.has(et)&&(w.width!==et.image.width||w.height!==et.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");tt.setupDepthRenderbuffer(w)}}const ut=w.texture;(ut.isData3DTexture||ut.isDataArrayTexture||ut.isCompressedArrayTexture)&&(Pe=!0);const ht=Ie.get(w).__webglFramebuffer;w.isWebGLCubeRenderTarget?(Array.isArray(ht[z])?H=ht[z][Y]:H=ht[z],xe=!0):w.samples>0&&tt.useMultisampledRTT(w)===!1?H=Ie.get(w).__webglMultisampledFramebuffer:Array.isArray(ht)?H=ht[Y]:H=ht,D.copy(w.viewport),X.copy(w.scissor),q=w.scissorTest}else D.copy(le).multiplyScalar(G).floor(),X.copy(we).multiplyScalar(G).floor(),q=Me;if(Y!==0&&(H=hi),De.bindFramebuffer(I.FRAMEBUFFER,H)&&Q&&De.drawBuffers(w,H),De.viewport(D),De.scissor(X),De.setScissorTest(q),xe){const Ve=Ie.get(w.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_CUBE_MAP_POSITIVE_X+z,Ve.__webglTexture,Y)}else if(Pe){const Ve=Ie.get(w.texture),ut=z;I.framebufferTextureLayer(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,Ve.__webglTexture,Y,ut)}else if(w!==null&&Y!==0){const Ve=Ie.get(w.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,Ve.__webglTexture,Y)}E=-1},this.readRenderTargetPixels=function(w,z,Y,Q,H,xe,Pe,Xe=0){if(!(w&&w.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ve=Ie.get(w).__webglFramebuffer;if(w.isWebGLCubeRenderTarget&&Pe!==void 0&&(Ve=Ve[Pe]),Ve){De.bindFramebuffer(I.FRAMEBUFFER,Ve);try{const ut=w.textures[Xe],ht=ut.format,et=ut.type;if(!qe.textureFormatReadable(ht)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!qe.textureTypeReadable(et)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}z>=0&&z<=w.width-Q&&Y>=0&&Y<=w.height-H&&(w.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+Xe),I.readPixels(z,Y,Q,H,be.convert(ht),be.convert(et),xe))}finally{const ut=U!==null?Ie.get(U).__webglFramebuffer:null;De.bindFramebuffer(I.FRAMEBUFFER,ut)}}},this.readRenderTargetPixelsAsync=async function(w,z,Y,Q,H,xe,Pe,Xe=0){if(!(w&&w.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ve=Ie.get(w).__webglFramebuffer;if(w.isWebGLCubeRenderTarget&&Pe!==void 0&&(Ve=Ve[Pe]),Ve)if(z>=0&&z<=w.width-Q&&Y>=0&&Y<=w.height-H){De.bindFramebuffer(I.FRAMEBUFFER,Ve);const ut=w.textures[Xe],ht=ut.format,et=ut.type;if(!qe.textureFormatReadable(ht))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!qe.textureTypeReadable(et))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const mt=I.createBuffer();I.bindBuffer(I.PIXEL_PACK_BUFFER,mt),I.bufferData(I.PIXEL_PACK_BUFFER,xe.byteLength,I.STREAM_READ),w.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+Xe),I.readPixels(z,Y,Q,H,be.convert(ht),be.convert(et),0);const Lt=U!==null?Ie.get(U).__webglFramebuffer:null;De.bindFramebuffer(I.FRAMEBUFFER,Lt);const Bt=I.fenceSync(I.SYNC_GPU_COMMANDS_COMPLETE,0);return I.flush(),await zf(I,Bt,4),I.bindBuffer(I.PIXEL_PACK_BUFFER,mt),I.getBufferSubData(I.PIXEL_PACK_BUFFER,0,xe),I.deleteBuffer(mt),I.deleteSync(Bt),xe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(w,z=null,Y=0){const Q=Math.pow(2,-Y),H=Math.floor(w.image.width*Q),xe=Math.floor(w.image.height*Q),Pe=z!==null?z.x:0,Xe=z!==null?z.y:0;tt.setTexture2D(w,0),I.copyTexSubImage2D(I.TEXTURE_2D,Y,0,0,Pe,Xe,H,xe),De.unbindTexture()};const za=I.createFramebuffer(),Va=I.createFramebuffer();this.copyTextureToTexture=function(w,z,Y=null,Q=null,H=0,xe=null){xe===null&&(H!==0?(ks("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),xe=H,H=0):xe=0);let Pe,Xe,Ve,ut,ht,et,mt,Lt,Bt;const Ht=w.isCompressedTexture?w.mipmaps[xe]:w.image;if(Y!==null)Pe=Y.max.x-Y.min.x,Xe=Y.max.y-Y.min.y,Ve=Y.isBox3?Y.max.z-Y.min.z:1,ut=Y.min.x,ht=Y.min.y,et=Y.isBox3?Y.min.z:0;else{const mn=Math.pow(2,-H);Pe=Math.floor(Ht.width*mn),Xe=Math.floor(Ht.height*mn),w.isDataArrayTexture?Ve=Ht.depth:w.isData3DTexture?Ve=Math.floor(Ht.depth*mn):Ve=1,ut=0,ht=0,et=0}Q!==null?(mt=Q.x,Lt=Q.y,Bt=Q.z):(mt=0,Lt=0,Bt=0);const Et=be.convert(z.format),rt=be.convert(z.type);let Qt;z.isData3DTexture?(tt.setTexture3D(z,0),Qt=I.TEXTURE_3D):z.isDataArrayTexture||z.isCompressedArrayTexture?(tt.setTexture2DArray(z,0),Qt=I.TEXTURE_2D_ARRAY):(tt.setTexture2D(z,0),Qt=I.TEXTURE_2D),I.pixelStorei(I.UNPACK_FLIP_Y_WEBGL,z.flipY),I.pixelStorei(I.UNPACK_PREMULTIPLY_ALPHA_WEBGL,z.premultiplyAlpha),I.pixelStorei(I.UNPACK_ALIGNMENT,z.unpackAlignment);const Rt=I.getParameter(I.UNPACK_ROW_LENGTH),Rn=I.getParameter(I.UNPACK_IMAGE_HEIGHT),zt=I.getParameter(I.UNPACK_SKIP_PIXELS),fn=I.getParameter(I.UNPACK_SKIP_ROWS),Yi=I.getParameter(I.UNPACK_SKIP_IMAGES);I.pixelStorei(I.UNPACK_ROW_LENGTH,Ht.width),I.pixelStorei(I.UNPACK_IMAGE_HEIGHT,Ht.height),I.pixelStorei(I.UNPACK_SKIP_PIXELS,ut),I.pixelStorei(I.UNPACK_SKIP_ROWS,ht),I.pixelStorei(I.UNPACK_SKIP_IMAGES,et);const Ot=w.isDataArrayTexture||w.isData3DTexture,Mn=z.isDataArrayTexture||z.isData3DTexture;if(w.isDepthTexture){const mn=Ie.get(w),Zt=Ie.get(z),en=Ie.get(mn.__renderTarget),ps=Ie.get(Zt.__renderTarget);De.bindFramebuffer(I.READ_FRAMEBUFFER,en.__webglFramebuffer),De.bindFramebuffer(I.DRAW_FRAMEBUFFER,ps.__webglFramebuffer);for(let di=0;di<Ve;di++)Ot&&(I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,Ie.get(w).__webglTexture,H,et+di),I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,Ie.get(z).__webglTexture,xe,Bt+di)),I.blitFramebuffer(ut,ht,Pe,Xe,mt,Lt,Pe,Xe,I.DEPTH_BUFFER_BIT,I.NEAREST);De.bindFramebuffer(I.READ_FRAMEBUFFER,null),De.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else if(H!==0||w.isRenderTargetTexture||Ie.has(w)){const mn=Ie.get(w),Zt=Ie.get(z);De.bindFramebuffer(I.READ_FRAMEBUFFER,za),De.bindFramebuffer(I.DRAW_FRAMEBUFFER,Va);for(let en=0;en<Ve;en++)Ot?I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,mn.__webglTexture,H,et+en):I.framebufferTexture2D(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,mn.__webglTexture,H),Mn?I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,Zt.__webglTexture,xe,Bt+en):I.framebufferTexture2D(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,Zt.__webglTexture,xe),H!==0?I.blitFramebuffer(ut,ht,Pe,Xe,mt,Lt,Pe,Xe,I.COLOR_BUFFER_BIT,I.NEAREST):Mn?I.copyTexSubImage3D(Qt,xe,mt,Lt,Bt+en,ut,ht,Pe,Xe):I.copyTexSubImage2D(Qt,xe,mt,Lt,ut,ht,Pe,Xe);De.bindFramebuffer(I.READ_FRAMEBUFFER,null),De.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else Mn?w.isDataTexture||w.isData3DTexture?I.texSubImage3D(Qt,xe,mt,Lt,Bt,Pe,Xe,Ve,Et,rt,Ht.data):z.isCompressedArrayTexture?I.compressedTexSubImage3D(Qt,xe,mt,Lt,Bt,Pe,Xe,Ve,Et,Ht.data):I.texSubImage3D(Qt,xe,mt,Lt,Bt,Pe,Xe,Ve,Et,rt,Ht):w.isDataTexture?I.texSubImage2D(I.TEXTURE_2D,xe,mt,Lt,Pe,Xe,Et,rt,Ht.data):w.isCompressedTexture?I.compressedTexSubImage2D(I.TEXTURE_2D,xe,mt,Lt,Ht.width,Ht.height,Et,Ht.data):I.texSubImage2D(I.TEXTURE_2D,xe,mt,Lt,Pe,Xe,Et,rt,Ht);I.pixelStorei(I.UNPACK_ROW_LENGTH,Rt),I.pixelStorei(I.UNPACK_IMAGE_HEIGHT,Rn),I.pixelStorei(I.UNPACK_SKIP_PIXELS,zt),I.pixelStorei(I.UNPACK_SKIP_ROWS,fn),I.pixelStorei(I.UNPACK_SKIP_IMAGES,Yi),xe===0&&z.generateMipmaps&&I.generateMipmap(Qt),De.unbindTexture()},this.copyTextureToTexture3D=function(w,z,Y=null,Q=null,H=0){return ks('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(w,z,Y,Q,H)},this.initRenderTarget=function(w){Ie.get(w).__webglFramebuffer===void 0&&tt.setupRenderTarget(w)},this.initTexture=function(w){w.isCubeTexture?tt.setTextureCube(w,0):w.isData3DTexture?tt.setTexture3D(w,0):w.isDataArrayTexture||w.isCompressedArrayTexture?tt.setTexture2DArray(w,0):tt.setTexture2D(w,0),De.unbindTexture()},this.resetState=function(){P=0,L=0,U=null,De.reset(),lt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Ti}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=ft._getDrawingBufferColorSpace(e),t.unpackColorSpace=ft._getUnpackColorSpace()}}const tv=/^[og]\s*(.+)?/,nv=/^mtllib /,iv=/^usemtl /,sv=/^usemap /,Eu=/\s+/,Au=new O,Eo=new O,wu=new O,Ru=new O,kn=new O,da=new Ge;function rv(){const s={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(e,t){if(this.object&&this.object.fromDeclaration===!1){this.object.name=e,this.object.fromDeclaration=t!==!1;return}const n=this.object&&typeof this.object.currentMaterial=="function"?this.object.currentMaterial():void 0;if(this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0),this.object={name:e||"",fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(i,r){const a=this._finalize(!1);a&&(a.inherited||a.groupCount<=0)&&this.materials.splice(a.index,1);const o={index:this.materials.length,name:i||"",mtllib:Array.isArray(r)&&r.length>0?r[r.length-1]:"",smooth:a!==void 0?a.smooth:this.smooth,groupStart:a!==void 0?a.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(l){const c={index:typeof l=="number"?l:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return c.clone=this.clone.bind(c),c}};return this.materials.push(o),o},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(i){const r=this.currentMaterial();if(r&&r.groupEnd===-1&&(r.groupEnd=this.geometry.vertices.length/3,r.groupCount=r.groupEnd-r.groupStart,r.inherited=!1),i&&this.materials.length>1)for(let a=this.materials.length-1;a>=0;a--)this.materials[a].groupCount<=0&&this.materials.splice(a,1);return i&&this.materials.length===0&&this.materials.push({name:"",smooth:this.smooth}),r}},n&&n.name&&typeof n.clone=="function"){const i=n.clone(0);i.inherited=!0,this.object.materials.push(i)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0)},parseVertexIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseNormalIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseUVIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/2)*2},addVertex:function(e,t,n){const i=this.vertices,r=this.object.geometry.vertices;r.push(i[e+0],i[e+1],i[e+2]),r.push(i[t+0],i[t+1],i[t+2]),r.push(i[n+0],i[n+1],i[n+2])},addVertexPoint:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,n){const i=this.normals,r=this.object.geometry.normals;r.push(i[e+0],i[e+1],i[e+2]),r.push(i[t+0],i[t+1],i[t+2]),r.push(i[n+0],i[n+1],i[n+2])},addFaceNormal:function(e,t,n){const i=this.vertices,r=this.object.geometry.normals;Au.fromArray(i,e),Eo.fromArray(i,t),wu.fromArray(i,n),kn.subVectors(wu,Eo),Ru.subVectors(Au,Eo),kn.cross(Ru),kn.normalize(),r.push(kn.x,kn.y,kn.z),r.push(kn.x,kn.y,kn.z),r.push(kn.x,kn.y,kn.z)},addColor:function(e,t,n){const i=this.colors,r=this.object.geometry.colors;i[e]!==void 0&&r.push(i[e+0],i[e+1],i[e+2]),i[t]!==void 0&&r.push(i[t+0],i[t+1],i[t+2]),i[n]!==void 0&&r.push(i[n+0],i[n+1],i[n+2])},addUV:function(e,t,n){const i=this.uvs,r=this.object.geometry.uvs;r.push(i[e+0],i[e+1]),r.push(i[t+0],i[t+1]),r.push(i[n+0],i[n+1])},addDefaultUV:function(){const e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){const t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,n,i,r,a,o,l,c){const u=this.vertices.length;let h=this.parseVertexIndex(e,u),d=this.parseVertexIndex(t,u),f=this.parseVertexIndex(n,u);if(this.addVertex(h,d,f),this.addColor(h,d,f),o!==void 0&&o!==""){const g=this.normals.length;h=this.parseNormalIndex(o,g),d=this.parseNormalIndex(l,g),f=this.parseNormalIndex(c,g),this.addNormal(h,d,f)}else this.addFaceNormal(h,d,f);if(i!==void 0&&i!==""){const g=this.uvs.length;h=this.parseUVIndex(i,g),d=this.parseUVIndex(r,g),f=this.parseUVIndex(a,g),this.addUV(h,d,f),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type="Points";const t=this.vertices.length;for(let n=0,i=e.length;n<i;n++){const r=this.parseVertexIndex(e[n],t);this.addVertexPoint(r),this.addColor(r)}},addLineGeometry:function(e,t){this.object.geometry.type="Line";const n=this.vertices.length,i=this.uvs.length;for(let r=0,a=e.length;r<a;r++)this.addVertexLine(this.parseVertexIndex(e[r],n));for(let r=0,a=t.length;r<a;r++)this.addUVLine(this.parseUVIndex(t[r],i))}};return s.startObject("",!1),s}class av extends wn{constructor(e){super(e),this.materials=null}load(e,t,n,i){const r=this,a=new Xi(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(r.parse(o))}catch(l){i?i(l):console.error(l),r.manager.itemError(e)}},n,i)}setMaterials(e){return this.materials=e,this}parse(e){const t=new rv;e.indexOf(`\r
3828
3828
  `)!==-1&&(e=e.replace(/\r\n/g,`
3829
3829
  `)),e.indexOf(`\\
3830
3830
  `)!==-1&&(e=e.replace(/\\\n/g,""));const n=e.split(`
3831
- `);let i=[];for(let o=0,l=n.length;o<l;o++){const c=n[o].trimStart();if(c.length===0)continue;const u=c.charAt(0);if(u!=="#")if(u==="v"){const h=c.split(Eu);switch(h[0]){case"v":t.vertices.push(parseFloat(h[1]),parseFloat(h[2]),parseFloat(h[3])),h.length>=7?(ha.setRGB(parseFloat(h[4]),parseFloat(h[5]),parseFloat(h[6]),_t),t.colors.push(ha.r,ha.g,ha.b)):t.colors.push(void 0,void 0,void 0);break;case"vn":t.normals.push(parseFloat(h[1]),parseFloat(h[2]),parseFloat(h[3]));break;case"vt":t.uvs.push(parseFloat(h[1]),parseFloat(h[2]));break}}else if(u==="f"){const d=c.slice(1).trim().split(Eu),f=[];for(let _=0,m=d.length;_<m;_++){const p=d[_];if(p.length>0){const S=p.split("/");f.push(S)}}const g=f[0];for(let _=1,m=f.length-1;_<m;_++){const p=f[_],S=f[_+1];t.addFace(g[0],p[0],S[0],g[1],p[1],S[1],g[2],p[2],S[2])}}else if(u==="l"){const h=c.substring(1).trim().split(" ");let d=[];const f=[];if(c.indexOf("/")===-1)d=h;else for(let g=0,_=h.length;g<_;g++){const m=h[g].split("/");m[0]!==""&&d.push(m[0]),m[1]!==""&&f.push(m[1])}t.addLineGeometry(d,f)}else if(u==="p"){const d=c.slice(1).trim().split(" ");t.addPointGeometry(d)}else if((i=tx.exec(c))!==null){const h=(" "+i[0].slice(1).trim()).slice(1);t.startObject(h)}else if(ix.test(c))t.object.startMaterial(c.substring(7).trim(),t.materialLibraries);else if(nx.test(c))t.materialLibraries.push(c.substring(7).trim());else if(sx.test(c))console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.');else if(u==="s"){if(i=c.split(" "),i.length>1){const d=i[1].trim().toLowerCase();t.object.smooth=d!=="0"&&d!=="off"}else t.object.smooth=!0;const h=t.object.currentMaterial();h&&(h.smooth=t.object.smooth)}else{if(c==="\0")continue;console.warn('THREE.OBJLoader: Unexpected line: "'+c+'"')}}t.finalize();const r=new Gn;if(r.materialLibraries=[].concat(t.materialLibraries),!(t.objects.length===1&&t.objects[0].geometry.vertices.length===0)===!0)for(let o=0,l=t.objects.length;o<l;o++){const c=t.objects[o],u=c.geometry,h=c.materials,d=u.type==="Line",f=u.type==="Points";let g=!1;if(u.vertices.length===0)continue;const _=new Kt;_.setAttribute("position",new xt(u.vertices,3)),u.normals.length>0&&_.setAttribute("normal",new xt(u.normals,3)),u.colors.length>0&&(g=!0,_.setAttribute("color",new xt(u.colors,3))),u.hasUVIndices===!0&&_.setAttribute("uv",new xt(u.uvs,2));const m=[];for(let S=0,x=h.length;S<x;S++){const y=h[S],N=y.name+"_"+y.smooth+"_"+g;let P=t.materials[N];if(this.materials!==null){if(P=this.materials.create(y.name),d&&P&&!(P instanceof ii)){const L=new ii;Dn.prototype.copy.call(L,P),L.color.copy(P.color),P=L}else if(f&&P&&!(P instanceof Ds)){const L=new Ds({size:10,sizeAttenuation:!1});Dn.prototype.copy.call(L,P),L.color.copy(P.color),L.map=P.map,P=L}}P===void 0&&(d?P=new ii:f?P=new Ds({size:1,sizeAttenuation:!1}):P=new as,P.name=y.name,P.flatShading=!y.smooth,P.vertexColors=g,t.materials[N]=P),m.push(P)}let p;if(m.length>1){for(let S=0,x=h.length;S<x;S++){const y=h[S];_.addGroup(y.groupStart,y.groupCount,S)}d?p=new Xs(_,m):f?p=new va(_,m):p=new sn(_,m)}else d?p=new Xs(_,m[0]):f?p=new va(_,m[0]):p=new sn(_,m[0]);p.name=c.name,r.add(p)}else if(t.vertices.length>0){const o=new Ds({size:1,sizeAttenuation:!1}),l=new Kt;l.setAttribute("position",new xt(t.vertices,3)),t.colors.length>0&&t.colors[0]!==void 0&&(l.setAttribute("color",new xt(t.colors,3)),o.vertexColors=!0);const c=new va(l,o);r.add(c)}return r}}/*!
3831
+ `);let i=[];for(let o=0,l=n.length;o<l;o++){const c=n[o].trimStart();if(c.length===0)continue;const u=c.charAt(0);if(u!=="#")if(u==="v"){const h=c.split(Eu);switch(h[0]){case"v":t.vertices.push(parseFloat(h[1]),parseFloat(h[2]),parseFloat(h[3])),h.length>=7?(da.setRGB(parseFloat(h[4]),parseFloat(h[5]),parseFloat(h[6]),_t),t.colors.push(da.r,da.g,da.b)):t.colors.push(void 0,void 0,void 0);break;case"vn":t.normals.push(parseFloat(h[1]),parseFloat(h[2]),parseFloat(h[3]));break;case"vt":t.uvs.push(parseFloat(h[1]),parseFloat(h[2]));break}}else if(u==="f"){const d=c.slice(1).trim().split(Eu),f=[];for(let _=0,m=d.length;_<m;_++){const p=d[_];if(p.length>0){const S=p.split("/");f.push(S)}}const g=f[0];for(let _=1,m=f.length-1;_<m;_++){const p=f[_],S=f[_+1];t.addFace(g[0],p[0],S[0],g[1],p[1],S[1],g[2],p[2],S[2])}}else if(u==="l"){const h=c.substring(1).trim().split(" ");let d=[];const f=[];if(c.indexOf("/")===-1)d=h;else for(let g=0,_=h.length;g<_;g++){const m=h[g].split("/");m[0]!==""&&d.push(m[0]),m[1]!==""&&f.push(m[1])}t.addLineGeometry(d,f)}else if(u==="p"){const d=c.slice(1).trim().split(" ");t.addPointGeometry(d)}else if((i=tv.exec(c))!==null){const h=(" "+i[0].slice(1).trim()).slice(1);t.startObject(h)}else if(iv.test(c))t.object.startMaterial(c.substring(7).trim(),t.materialLibraries);else if(nv.test(c))t.materialLibraries.push(c.substring(7).trim());else if(sv.test(c))console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.');else if(u==="s"){if(i=c.split(" "),i.length>1){const d=i[1].trim().toLowerCase();t.object.smooth=d!=="0"&&d!=="off"}else t.object.smooth=!0;const h=t.object.currentMaterial();h&&(h.smooth=t.object.smooth)}else{if(c==="\0")continue;console.warn('THREE.OBJLoader: Unexpected line: "'+c+'"')}}t.finalize();const r=new Wn;if(r.materialLibraries=[].concat(t.materialLibraries),!(t.objects.length===1&&t.objects[0].geometry.vertices.length===0)===!0)for(let o=0,l=t.objects.length;o<l;o++){const c=t.objects[o],u=c.geometry,h=c.materials,d=u.type==="Line",f=u.type==="Points";let g=!1;if(u.vertices.length===0)continue;const _=new Kt;_.setAttribute("position",new vt(u.vertices,3)),u.normals.length>0&&_.setAttribute("normal",new vt(u.normals,3)),u.colors.length>0&&(g=!0,_.setAttribute("color",new vt(u.colors,3))),u.hasUVIndices===!0&&_.setAttribute("uv",new vt(u.uvs,2));const m=[];for(let S=0,v=h.length;S<v;S++){const y=h[S],N=y.name+"_"+y.smooth+"_"+g;let P=t.materials[N];if(this.materials!==null){if(P=this.materials.create(y.name),d&&P&&!(P instanceof si)){const L=new si;Nn.prototype.copy.call(L,P),L.color.copy(P.color),P=L}else if(f&&P&&!(P instanceof Is)){const L=new Is({size:10,sizeAttenuation:!1});Nn.prototype.copy.call(L,P),L.color.copy(P.color),L.map=P.map,P=L}}P===void 0&&(d?P=new si:f?P=new Is({size:1,sizeAttenuation:!1}):P=new as,P.name=y.name,P.flatShading=!y.smooth,P.vertexColors=g,t.materials[N]=P),m.push(P)}let p;if(m.length>1){for(let S=0,v=h.length;S<v;S++){const y=h[S];_.addGroup(y.groupStart,y.groupCount,S)}d?p=new js(_,m):f?p=new Ma(_,m):p=new rn(_,m)}else d?p=new js(_,m[0]):f?p=new Ma(_,m[0]):p=new rn(_,m[0]);p.name=c.name,r.add(p)}else if(t.vertices.length>0){const o=new Is({size:1,sizeAttenuation:!1}),l=new Kt;l.setAttribute("position",new vt(t.vertices,3)),t.colors.length>0&&t.colors[0]!==void 0&&(l.setAttribute("color",new vt(t.colors,3)),o.vertexColors=!0);const c=new Ma(l,o);r.add(c)}return r}}/*!
3832
3832
  fflate - fast JavaScript compression/decompression
3833
3833
  <https://101arrowz.github.io/fflate>
3834
3834
  Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
3835
3835
  version 0.8.2
3836
- */var zn=Uint8Array,Ns=Uint16Array,ox=Int32Array,Ah=new zn([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),wh=new zn([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),lx=new zn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Rh=function(s,e){for(var t=new Ns(31),n=0;n<31;++n)t[n]=e+=1<<s[n-1];for(var i=new ox(t[30]),n=1;n<30;++n)for(var r=t[n];r<t[n+1];++r)i[r]=r-t[n]<<5|n;return{b:t,r:i}},Ch=Rh(Ah,2),Ph=Ch.b,cx=Ch.r;Ph[28]=258,cx[258]=28;var ux=Rh(wh,0),hx=ux.b,Tl=new Ns(32768);for(var Ht=0;Ht<32768;++Ht){var Oi=(Ht&43690)>>1|(Ht&21845)<<1;Oi=(Oi&52428)>>2|(Oi&13107)<<2,Oi=(Oi&61680)>>4|(Oi&3855)<<4,Tl[Ht]=((Oi&65280)>>8|(Oi&255)<<8)>>1}var dr=function(s,e,t){for(var n=s.length,i=0,r=new Ns(e);i<n;++i)s[i]&&++r[s[i]-1];var a=new Ns(e);for(i=1;i<e;++i)a[i]=a[i-1]+r[i-1]<<1;var o;if(t){o=new Ns(1<<e);var l=15-e;for(i=0;i<n;++i)if(s[i])for(var c=i<<4|s[i],u=e-s[i],h=a[s[i]-1]++<<u,d=h|(1<<u)-1;h<=d;++h)o[Tl[h]>>l]=c}else for(o=new Ns(n),i=0;i<n;++i)s[i]&&(o[i]=Tl[a[s[i]-1]++]>>15-s[i]);return o},Ir=new zn(288);for(var Ht=0;Ht<144;++Ht)Ir[Ht]=8;for(var Ht=144;Ht<256;++Ht)Ir[Ht]=9;for(var Ht=256;Ht<280;++Ht)Ir[Ht]=7;for(var Ht=280;Ht<288;++Ht)Ir[Ht]=8;var Lh=new zn(32);for(var Ht=0;Ht<32;++Ht)Lh[Ht]=5;var dx=dr(Ir,9,1),fx=dr(Lh,5,1),Ao=function(s){for(var e=s[0],t=1;t<s.length;++t)s[t]>e&&(e=s[t]);return e},qn=function(s,e,t){var n=e/8|0;return(s[n]|s[n+1]<<8)>>(e&7)&t},wo=function(s,e){var t=e/8|0;return(s[t]|s[t+1]<<8|s[t+2]<<16)>>(e&7)},px=function(s){return(s+7)/8|0},mx=function(s,e,t){return(t==null||t>s.length)&&(t=s.length),new zn(s.subarray(e,t))},gx=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Kn=function(s,e,t){var n=new Error(e||gx[s]);if(n.code=s,Error.captureStackTrace&&Error.captureStackTrace(n,Kn),!t)throw n;return n},_x=function(s,e,t,n){var i=s.length,r=0;if(!i||e.f&&!e.l)return t||new zn(0);var a=!t,o=a||e.i!=2,l=e.i;a&&(t=new zn(i*3));var c=function(Q){var ee=t.length;if(Q>ee){var te=new zn(Math.max(ee*2,Q));te.set(t),t=te}},u=e.f||0,h=e.p||0,d=e.b||0,f=e.l,g=e.d,_=e.m,m=e.n,p=i*8;do{if(!f){u=qn(s,h,1);var S=qn(s,h+1,3);if(h+=3,S)if(S==1)f=dx,g=fx,_=9,m=5;else if(S==2){var P=qn(s,h,31)+257,L=qn(s,h+10,15)+4,U=P+qn(s,h+5,31)+1;h+=14;for(var E=new zn(U),T=new zn(19),D=0;D<L;++D)T[lx[D]]=qn(s,h+D*3,7);h+=L*3;for(var X=Ao(T),j=(1<<X)-1,se=dr(T,X,1),D=0;D<U;){var de=se[qn(s,h,j)];h+=de&15;var x=de>>4;if(x<16)E[D++]=x;else{var k=0,ae=0;for(x==16?(ae=3+qn(s,h,3),h+=2,k=E[D-1]):x==17?(ae=3+qn(s,h,7),h+=3):x==18&&(ae=11+qn(s,h,127),h+=7);ae--;)E[D++]=k}}var G=E.subarray(0,P),pe=E.subarray(P);_=Ao(G),m=Ao(pe),f=dr(G,_,1),g=dr(pe,m,1)}else Kn(1);else{var x=px(h)+4,y=s[x-4]|s[x-3]<<8,N=x+y;if(N>i){l&&Kn(0);break}o&&c(d+y),t.set(s.subarray(x,N),d),e.b=d+=y,e.p=h=N*8,e.f=u;continue}if(h>p){l&&Kn(0);break}}o&&c(d+131072);for(var Me=(1<<_)-1,le=(1<<m)-1,we=h;;we=h){var k=f[wo(s,h)&Me],be=k>>4;if(h+=k&15,h>p){l&&Kn(0);break}if(k||Kn(2),be<256)t[d++]=be;else if(be==256){we=h,f=null;break}else{var W=be-254;if(be>264){var D=be-257,$=Ah[D];W=qn(s,h,(1<<$)-1)+Ph[D],h+=$}var re=g[wo(s,h)&le],oe=re>>4;re||Kn(3),h+=re&15;var pe=hx[oe];if(oe>3){var $=wh[oe];pe+=wo(s,h)&(1<<$)-1,h+=$}if(h>p){l&&Kn(0);break}o&&c(d+131072);var Te=d+W;if(d<pe){var ne=r-pe,me=Math.min(pe,Te);for(ne+d<0&&Kn(3);d<me;++d)t[d]=n[ne+d]}for(;d<Te;++d)t[d]=t[d-pe]}}e.l=f,e.p=we,e.b=d,e.f=u,f&&(u=1,e.m=_,e.d=g,e.n=m)}while(!u);return d!=t.length&&a?mx(t,0,d):t.subarray(0,d)},yx=new zn(0),xx=function(s,e){return((s[0]&15)!=8||s[0]>>4>7||(s[0]<<8|s[1])%31)&&Kn(6,"invalid zlib data"),(s[1]>>5&1)==1&&Kn(6,"invalid zlib data: "+(s[1]&32?"need":"unexpected")+" dictionary"),(s[1]>>3&4)+2};function vx(s,e){return _x(s.subarray(xx(s),-4),{i:2},e,e)}var Mx=typeof TextDecoder<"u"&&new TextDecoder,Sx=0;try{Mx.decode(yx,{stream:!0}),Sx=1}catch{}function Dh(s,e,t){const n=t.length-s-1;if(e>=t[n])return n-1;if(e<=t[s])return s;let i=s,r=n,a=Math.floor((i+r)/2);for(;e<t[a]||e>=t[a+1];)e<t[a]?r=a:i=a,a=Math.floor((i+r)/2);return a}function Tx(s,e,t,n){const i=[],r=[],a=[];i[0]=1;for(let o=1;o<=t;++o){r[o]=e-n[s+1-o],a[o]=n[s+o]-e;let l=0;for(let c=0;c<o;++c){const u=a[c+1],h=r[o-c],d=i[c]/(u+h);i[c]=l+u*d,l=h*d}i[o]=l}return i}function bx(s,e,t,n){const i=Dh(s,n,e),r=Tx(i,n,s,e),a=new Tt(0,0,0,0);for(let o=0;o<=s;++o){const l=t[i-s+o],c=r[o],u=l.w*c;a.x+=l.x*u,a.y+=l.y*u,a.z+=l.z*u,a.w+=l.w*c}return a}function Ex(s,e,t,n,i){const r=[];for(let h=0;h<=t;++h)r[h]=0;const a=[];for(let h=0;h<=n;++h)a[h]=r.slice(0);const o=[];for(let h=0;h<=t;++h)o[h]=r.slice(0);o[0][0]=1;const l=r.slice(0),c=r.slice(0);for(let h=1;h<=t;++h){l[h]=e-i[s+1-h],c[h]=i[s+h]-e;let d=0;for(let f=0;f<h;++f){const g=c[f+1],_=l[h-f];o[h][f]=g+_;const m=o[f][h-1]/o[h][f];o[f][h]=d+g*m,d=_*m}o[h][h]=d}for(let h=0;h<=t;++h)a[0][h]=o[h][t];for(let h=0;h<=t;++h){let d=0,f=1;const g=[];for(let _=0;_<=t;++_)g[_]=r.slice(0);g[0][0]=1;for(let _=1;_<=n;++_){let m=0;const p=h-_,S=t-_;h>=_&&(g[f][0]=g[d][0]/o[S+1][p],m=g[f][0]*o[p][S]);const x=p>=-1?1:-p,y=h-1<=S?_-1:t-h;for(let P=x;P<=y;++P)g[f][P]=(g[d][P]-g[d][P-1])/o[S+1][p+P],m+=g[f][P]*o[p+P][S];h<=S&&(g[f][_]=-g[d][_-1]/o[S+1][h],m+=g[f][_]*o[h][S]),a[_][h]=m;const N=d;d=f,f=N}}let u=t;for(let h=1;h<=n;++h){for(let d=0;d<=t;++d)a[h][d]*=u;u*=t-h}return a}function Ax(s,e,t,n,i){const r=i<s?i:s,a=[],o=Dh(s,n,e),l=Ex(o,n,s,r,e),c=[];for(let u=0;u<t.length;++u){const h=t[u].clone(),d=h.w;h.x*=d,h.y*=d,h.z*=d,c[u]=h}for(let u=0;u<=r;++u){const h=c[o-s].clone().multiplyScalar(l[u][0]);for(let d=1;d<=s;++d)h.add(c[o-s+d].clone().multiplyScalar(l[u][d]));a[u]=h}for(let u=r+1;u<=i+1;++u)a[u]=new Tt(0,0,0);return a}function wx(s,e){let t=1;for(let i=2;i<=s;++i)t*=i;let n=1;for(let i=2;i<=e;++i)n*=i;for(let i=2;i<=s-e;++i)n*=i;return t/n}function Rx(s){const e=s.length,t=[],n=[];for(let r=0;r<e;++r){const a=s[r];t[r]=new O(a.x,a.y,a.z),n[r]=a.w}const i=[];for(let r=0;r<e;++r){const a=t[r].clone();for(let o=1;o<=r;++o)a.sub(i[r-o].clone().multiplyScalar(wx(r,o)*n[o]));i[r]=a.divideScalar(n[0])}return i}function Cx(s,e,t,n,i){const r=Ax(s,e,t,n,i);return Rx(r)}class Px extends Mp{constructor(e,t,n,i,r){super();const a=t?t.length-1:0,o=n?n.length:0;this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=i||0,this.endKnot=r||a;for(let l=0;l<o;++l){const c=n[l];this.controlPoints[l]=new Tt(c.x,c.y,c.z,c.w)}}getPoint(e,t=new O){const n=t,i=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),r=bx(this.degree,this.knots,this.controlPoints,i);return r.w!==1&&r.divideScalar(r.w),n.set(r.x,r.y,r.z)}getTangent(e,t=new O){const n=t,i=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),r=Cx(this.degree,this.knots,this.controlPoints,i,1);return n.copy(r[1]).normalize(),n}toJSON(){const e=super.toJSON();return e.degree=this.degree,e.knots=[...this.knots],e.controlPoints=this.controlPoints.map(t=>t.toArray()),e.startKnot=this.startKnot,e.endKnot=this.endKnot,e}fromJSON(e){return super.fromJSON(e),this.degree=e.degree,this.knots=[...e.knots],this.controlPoints=e.controlPoints.map(t=>new Tt(t[0],t[1],t[2],t[3])),this.startKnot=e.startKnot,this.endKnot=e.endKnot,this}}let Mt,qt,Mn;class Lx extends bn{constructor(e){super(e)}load(e,t,n,i){const r=this,a=r.path===""?os.extractUrlBase(e):r.path,o=new Xi(this.manager);o.setPath(r.path),o.setResponseType("arraybuffer"),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,function(l){try{t(r.parse(l,a))}catch(c){i?i(c):console.error(c),r.manager.itemError(e)}},n,i)}parse(e,t){if(Ox(e))Mt=new Fx().parse(e);else{const i=Uh(e);if(!kx(i))throw new Error("THREE.FBXLoader: Unknown format.");if(Pu(i)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+Pu(i));Mt=new Ux().parse(i)}const n=new Xl(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new Dx(n,this.manager).parse(Mt)}}class Dx{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){qt=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),i=this.parseDeformers(),r=new Ix().parse(i);return this.parseScene(i,r,n),Mn}parseConnections(){const e=new Map;return"Connections"in Mt&&Mt.Connections.connections.forEach(function(n){const i=n[0],r=n[1],a=n[2];e.has(i)||e.set(i,{parents:[],children:[]});const o={ID:r,relationship:a};e.get(i).parents.push(o),e.has(r)||e.set(r,{parents:[],children:[]});const l={ID:i,relationship:a};e.get(r).children.push(l)}),e}parseImages(){const e={},t={};if("Video"in Mt.Objects){const n=Mt.Objects.Video;for(const i in n){const r=n[i],a=parseInt(i);if(e[a]=r.RelativeFilename||r.Filename,"Content"in r){const o=r.Content instanceof ArrayBuffer&&r.Content.byteLength>0,l=typeof r.Content=="string"&&r.Content!=="";if(o||l){const c=this.parseImage(n[i]);t[r.RelativeFilename||r.Filename]=c}}}}for(const n in e){const i=e[n];t[i]!==void 0?e[n]=t[i]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,i=n.slice(n.lastIndexOf(".")+1).toLowerCase();let r;switch(i){case"bmp":r="image/bmp";break;case"jpg":case"jpeg":r="image/jpeg";break;case"png":r="image/png";break;case"tif":r="image/tiff";break;case"tga":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",n),r="image/tga";break;case"webp":r="image/webp";break;default:console.warn('FBXLoader: Image type "'+i+'" is not supported.');return}if(typeof t=="string")return"data:"+r+";base64,"+t;{const a=new Uint8Array(t);return window.URL.createObjectURL(new Blob([a],{type:r}))}}parseTextures(e){const t=new Map;if("Texture"in Mt.Objects){const n=Mt.Objects.Texture;for(const i in n){const r=this.parseTexture(n[i],e);t.set(parseInt(i),r)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const i=e.WrapModeU,r=e.WrapModeV,a=i!==void 0?i.value:0,o=r!==void 0?r.value:0;if(n.wrapS=a===0?Vn:Pn,n.wrapT=o===0?Vn:Pn,"Scaling"in e){const l=e.Scaling.value;n.repeat.x=l[0],n.repeat.y=l[1]}if("Translation"in e){const l=e.Translation.value;n.offset.x=l[0],n.offset.y=l[1]}return n}loadTexture(e,t){const n=e.FileName.split(".").pop().toLowerCase();let i=this.manager.getHandler(`.${n}`);i===null&&(i=this.textureLoader);const r=i.path;r||i.setPath(this.textureLoader.path);const a=qt.get(e.id).children;let o;if(a!==void 0&&a.length>0&&t[a[0].ID]!==void 0&&(o=t[a[0].ID],(o.indexOf("blob:")===0||o.indexOf("data:")===0)&&i.setPath(void 0)),o===void 0)return console.warn("FBXLoader: Undefined filename, creating placeholder texture."),new rn;const l=i.load(o);return i.setPath(r),l}parseMaterials(e){const t=new Map;if("Material"in Mt.Objects){const n=Mt.Objects.Material;for(const i in n){const r=this.parseMaterial(n[i],e);r!==null&&t.set(parseInt(i),r)}}return t}parseMaterial(e,t){const n=e.id,i=e.attrName;let r=e.ShadingModel;if(typeof r=="object"&&(r=r.value),!qt.has(n))return null;const a=this.parseParameters(e,t,n);let o;switch(r.toLowerCase()){case"phong":o=new as;break;case"lambert":o=new yh;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',r),o=new as;break}return o.setValues(a),o.name=i,o}parseParameters(e,t,n){const i={};e.BumpFactor&&(i.bumpScale=e.BumpFactor.value),e.Diffuse?i.color=pt.colorSpaceToWorking(new He().fromArray(e.Diffuse.value),_t):e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(i.color=pt.colorSpaceToWorking(new He().fromArray(e.DiffuseColor.value),_t)),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=pt.colorSpaceToWorking(new He().fromArray(e.Emissive.value),_t):e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(i.emissive=pt.colorSpaceToWorking(new He().fromArray(e.EmissiveColor.value),_t)),e.EmissiveFactor&&(i.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),i.opacity=1-(e.TransparencyFactor?parseFloat(e.TransparencyFactor.value):0),(i.opacity===1||i.opacity===0)&&(i.opacity=e.Opacity?parseFloat(e.Opacity.value):null,i.opacity===null&&(i.opacity=1-(e.TransparentColor?parseFloat(e.TransparentColor.value[0]):0))),i.opacity<1&&(i.transparent=!0),e.ReflectionFactor&&(i.reflectivity=e.ReflectionFactor.value),e.Shininess&&(i.shininess=e.Shininess.value),e.Specular?i.specular=pt.colorSpaceToWorking(new He().fromArray(e.Specular.value),_t):e.SpecularColor&&e.SpecularColor.type==="Color"&&(i.specular=pt.colorSpaceToWorking(new He().fromArray(e.SpecularColor.value),_t));const r=this;return qt.get(n).children.forEach(function(a){const o=a.relationship;switch(o){case"Bump":i.bumpMap=r.getTexture(t,a.ID);break;case"Maya|TEX_ao_map":i.aoMap=r.getTexture(t,a.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":i.map=r.getTexture(t,a.ID),i.map!==void 0&&(i.map.colorSpace=_t);break;case"DisplacementColor":i.displacementMap=r.getTexture(t,a.ID);break;case"EmissiveColor":i.emissiveMap=r.getTexture(t,a.ID),i.emissiveMap!==void 0&&(i.emissiveMap.colorSpace=_t);break;case"NormalMap":case"Maya|TEX_normal_map":i.normalMap=r.getTexture(t,a.ID);break;case"ReflectionColor":i.envMap=r.getTexture(t,a.ID),i.envMap!==void 0&&(i.envMap.mapping=Ta,i.envMap.colorSpace=_t);break;case"SpecularColor":i.specularMap=r.getTexture(t,a.ID),i.specularMap!==void 0&&(i.specularMap.colorSpace=_t);break;case"TransparentColor":case"TransparencyFactor":i.alphaMap=r.getTexture(t,a.ID),i.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",o);break}}),i}getTexture(e,t){return"LayeredTexture"in Mt.Objects&&t in Mt.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=qt.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in Mt.Objects){const n=Mt.Objects.Deformer;for(const i in n){const r=n[i],a=qt.get(parseInt(i));if(r.attrType==="Skin"){const o=this.parseSkeleton(a,n);o.ID=i,a.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),o.geometryID=a.parents[0].ID,e[i]=o}else if(r.attrType==="BlendShape"){const o={id:i};o.rawTargets=this.parseMorphTargets(a,n),o.id=i,a.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[i]=o}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach(function(i){const r=t[i.ID];if(r.attrType!=="Cluster")return;const a={ID:i.ID,indices:[],weights:[],transformLink:new Fe().fromArray(r.TransformLink.a)};"Indexes"in r&&(a.indices=r.Indexes.a,a.weights=r.Weights.a),n.push(a)}),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let i=0;i<e.children.length;i++){const r=e.children[i],a=t[r.ID],o={name:a.attrName,initialWeight:a.DeformPercent,id:a.id,fullWeights:a.FullWeights.a};if(a.attrType!=="BlendShapeChannel")return;o.geoID=qt.get(parseInt(r.ID)).children.filter(function(l){return l.relationship===void 0})[0].ID,n.push(o)}return n}parseScene(e,t,n){Mn=new Gn;const i=this.parseModels(e.skeletons,t,n),r=Mt.Objects.Model,a=this;i.forEach(function(l){const c=r[l.ID];a.setLookAtProperties(l,c),qt.get(l.ID).parents.forEach(function(h){const d=i.get(h.ID);d!==void 0&&d.add(l)}),l.parent===null&&Mn.add(l)}),this.bindSkeleton(e.skeletons,t,i),this.addGlobalSceneSettings(),Mn.traverse(function(l){if(l.userData.transformData){l.parent&&(l.userData.transformData.parentMatrix=l.parent.matrix,l.userData.transformData.parentMatrixWorld=l.parent.matrixWorld);const c=Nh(l.userData.transformData);l.applyMatrix4(c),l.updateWorldMatrix()}});const o=new Nx().parse();Mn.children.length===1&&Mn.children[0].isGroup&&(Mn.children[0].animations=o,Mn=Mn.children[0]),Mn.animations=o}parseModels(e,t,n){const i=new Map,r=Mt.Objects.Model;for(const a in r){const o=parseInt(a),l=r[a],c=qt.get(o);let u=this.buildSkeleton(c,e,o,l.attrName);if(!u){switch(l.attrType){case"Camera":u=this.createCamera(c);break;case"Light":u=this.createLight(c);break;case"Mesh":u=this.createMesh(c,t,n);break;case"NurbsCurve":u=this.createCurve(c,t);break;case"LimbNode":case"Root":u=new vr;break;case"Null":default:u=new Gn;break}u.name=l.attrName?At.sanitizeNodeName(l.attrName):"",u.userData.originalName=l.attrName,u.ID=o}this.getTransformData(u,l),i.set(o,u)}return i}buildSkeleton(e,t,n,i){let r=null;return e.parents.forEach(function(a){for(const o in t){const l=t[o];l.rawBones.forEach(function(c,u){if(c.ID===a.ID){const h=r;r=new vr,r.matrixWorld.copy(c.transformLink),r.name=i?At.sanitizeNodeName(i):"",r.userData.originalName=i,r.ID=n,l.bones[u]=r,h!==null&&r.add(h)}})}}),r}createCamera(e){let t,n;if(e.children.forEach(function(i){const r=Mt.Objects.NodeAttribute[i.ID];r!==void 0&&(n=r)}),n===void 0)t=new kt;else{let i=0;n.CameraProjectionType!==void 0&&n.CameraProjectionType.value===1&&(i=1);let r=1;n.NearPlane!==void 0&&(r=n.NearPlane.value/1e3);let a=1e3;n.FarPlane!==void 0&&(a=n.FarPlane.value/1e3);let o=window.innerWidth,l=window.innerHeight;n.AspectWidth!==void 0&&n.AspectHeight!==void 0&&(o=n.AspectWidth.value,l=n.AspectHeight.value);const c=o/l;let u=45;n.FieldOfView!==void 0&&(u=n.FieldOfView.value);const h=n.FocalLength?n.FocalLength.value:null;switch(i){case 0:t=new cn(u,c,r,a),h!==null&&t.setFocalLength(h);break;case 1:console.warn("THREE.FBXLoader: Orthographic cameras not supported yet."),t=new kt;break;default:console.warn("THREE.FBXLoader: Unknown camera type "+i+"."),t=new kt;break}}return t}createLight(e){let t,n;if(e.children.forEach(function(i){const r=Mt.Objects.NodeAttribute[i.ID];r!==void 0&&(n=r)}),n===void 0)t=new kt;else{let i;n.LightType===void 0?i=0:i=n.LightType.value;let r=16777215;n.Color!==void 0&&(r=pt.colorSpaceToWorking(new He().fromArray(n.Color.value),_t));let a=n.Intensity===void 0?1:n.Intensity.value/100;n.CastLightOnObject!==void 0&&n.CastLightOnObject.value===0&&(a=0);let o=0;n.FarAttenuationEnd!==void 0&&(n.EnableFarAttenuation!==void 0&&n.EnableFarAttenuation.value===0?o=0:o=n.FarAttenuationEnd.value);const l=1;switch(i){case 0:t=new Pa(r,a,o,l);break;case 1:t=new Er(r,a);break;case 2:let c=Math.PI/3;n.InnerAngle!==void 0&&(c=jt.degToRad(n.InnerAngle.value));let u=0;n.OuterAngle!==void 0&&(u=jt.degToRad(n.OuterAngle.value),u=Math.max(u,1)),t=new ql(r,a,o,c,u,l);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new Pa(r,a);break}n.CastShadows!==void 0&&n.CastShadows.value===1&&(t.castShadow=!0)}return t}createMesh(e,t,n){let i,r=null,a=null;const o=[];if(e.children.forEach(function(l){t.has(l.ID)&&(r=t.get(l.ID)),n.has(l.ID)&&o.push(n.get(l.ID))}),o.length>1?a=o:o.length>0?a=o[0]:(a=new as({name:bn.DEFAULT_MATERIAL_NAME,color:13421772}),o.push(a)),"color"in r.attributes&&o.forEach(function(l){l.vertexColors=!0}),r.groups.length>0){let l=!1;for(let c=0,u=r.groups.length;c<u;c++){const h=r.groups[c];(h.materialIndex<0||h.materialIndex>=o.length)&&(h.materialIndex=o.length,l=!0)}if(l){const c=new as;o.push(c)}}return r.FBX_Deformer?(i=new Vl(r,a),i.normalizeSkinWeights()):i=new sn(r,a),i}createCurve(e,t){const n=e.children.reduce(function(r,a){return t.has(a.ID)&&(r=t.get(a.ID)),r},null),i=new ii({name:bn.DEFAULT_MATERIAL_NAME,color:3342591,linewidth:1});return new Lr(n,i)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),"RotationOrder"in t?n.eulerOrder=Ar(t.RotationOrder.value):n.eulerOrder=Ar(0),"Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){"LookAtProperty"in t&&qt.get(e.ID).children.forEach(function(i){if(i.relationship==="LookAtProperty"){const r=Mt.Objects.Model[i.ID];if("Lcl_Translation"in r){const a=r.Lcl_Translation.value;e.target!==void 0?(e.target.position.fromArray(a),Mn.add(e.target)):e.lookAt(new O().fromArray(a))}}})}bindSkeleton(e,t,n){const i=this.parsePoseNodes();for(const r in e){const a=e[r];qt.get(parseInt(a.ID)).parents.forEach(function(l){if(t.has(l.ID)){const c=l.ID;qt.get(c).parents.forEach(function(h){n.has(h.ID)&&n.get(h.ID).bind(new Pr(a.bones),i[h.ID])})}})}}parsePoseNodes(){const e={};if("Pose"in Mt.Objects){const t=Mt.Objects.Pose;for(const n in t)if(t[n].attrType==="BindPose"&&t[n].NbPoseNodes>0){const i=t[n].PoseNode;Array.isArray(i)?i.forEach(function(r){e[r.Node]=new Fe().fromArray(r.Matrix.a)}):e[i.Node]=new Fe().fromArray(i.Matrix.a)}}return e}addGlobalSceneSettings(){if("GlobalSettings"in Mt){if("AmbientColor"in Mt.GlobalSettings){const e=Mt.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],i=e[2];if(t!==0||n!==0||i!==0){const r=new He().setRGB(t,n,i,_t);Mn.add(new Kl(r,1))}}"UnitScaleFactor"in Mt.GlobalSettings&&(Mn.userData.unitScaleFactor=Mt.GlobalSettings.UnitScaleFactor.value)}}}class Ix{constructor(){this.negativeMaterialIndices=!1}parse(e){const t=new Map;if("Geometry"in Mt.Objects){const n=Mt.Objects.Geometry;for(const i in n){const r=qt.get(parseInt(i)),a=this.parseGeometry(r,n[i],e);t.set(parseInt(i),a)}}return this.negativeMaterialIndices===!0&&console.warn("THREE.FBXLoader: The FBX file contains invalid (negative) material indices. The asset might not render as expected."),t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const i=n.skeletons,r=[],a=e.parents.map(function(h){return Mt.Objects.Model[h.ID]});if(a.length===0)return;const o=e.children.reduce(function(h,d){return i[d.ID]!==void 0&&(h=i[d.ID]),h},null);e.children.forEach(function(h){n.morphTargets[h.ID]!==void 0&&r.push(n.morphTargets[h.ID])});const l=a[0],c={};"RotationOrder"in l&&(c.eulerOrder=Ar(l.RotationOrder.value)),"InheritType"in l&&(c.inheritType=parseInt(l.InheritType.value)),"GeometricTranslation"in l&&(c.translation=l.GeometricTranslation.value),"GeometricRotation"in l&&(c.rotation=l.GeometricRotation.value),"GeometricScaling"in l&&(c.scale=l.GeometricScaling.value);const u=Nh(c);return this.genGeometry(t,o,r,u)}genGeometry(e,t,n,i){const r=new Kt;e.attrName&&(r.name=e.attrName);const a=this.parseGeoNode(e,t),o=this.genBuffers(a),l=new xt(o.vertex,3);if(l.applyMatrix4(i),r.setAttribute("position",l),o.colors.length>0&&r.setAttribute("color",new xt(o.colors,3)),t&&(r.setAttribute("skinIndex",new Bl(o.weightsIndices,4)),r.setAttribute("skinWeight",new xt(o.vertexWeights,4)),r.FBX_Deformer=t),o.normal.length>0){const c=new gt().getNormalMatrix(i),u=new xt(o.normal,3);u.applyNormalMatrix(c),r.setAttribute("normal",u)}if(o.uvs.forEach(function(c,u){const h=u===0?"uv":`uv${u}`;r.setAttribute(h,new xt(o.uvs[u],2))}),a.material&&a.material.mappingType!=="AllSame"){let c=o.materialIndex[0],u=0;if(o.materialIndex.forEach(function(h,d){h!==c&&(r.addGroup(u,d-u,c),c=h,u=d)}),r.groups.length>0){const h=r.groups[r.groups.length-1],d=h.start+h.count;d!==o.materialIndex.length&&r.addGroup(d,o.materialIndex.length-d,c)}r.groups.length===0&&r.addGroup(0,o.materialIndex.length,o.materialIndex[0])}return this.addMorphTargets(r,e,n,i),r}parseGeoNode(e,t){const n={};if(n.vertexPositions=e.Vertices!==void 0?e.Vertices.a:[],n.vertexIndices=e.PolygonVertexIndex!==void 0?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let i=0;for(;e.LayerElementUV[i];)e.LayerElementUV[i].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[i])),i++}return n.weightTable={},t!==null&&(n.skeleton=t,t.rawBones.forEach(function(i,r){i.indices.forEach(function(a,o){n.weightTable[a]===void 0&&(n.weightTable[a]=[]),n.weightTable[a].push({id:r,weight:i.weights[o]})})})),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,i=0,r=!1,a=[],o=[],l=[],c=[],u=[],h=[];const d=this;return e.vertexIndices.forEach(function(f,g){let _,m=!1;f<0&&(f=f^-1,m=!0);let p=[],S=[];if(a.push(f*3,f*3+1,f*3+2),e.color){const x=da(g,n,f,e.color);l.push(x[0],x[1],x[2])}if(e.skeleton){if(e.weightTable[f]!==void 0&&e.weightTable[f].forEach(function(x){S.push(x.weight),p.push(x.id)}),S.length>4){r||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),r=!0);const x=[0,0,0,0],y=[0,0,0,0];S.forEach(function(N,P){let L=N,U=p[P];y.forEach(function(E,T,D){if(L>E){D[T]=L,L=E;const X=x[T];x[T]=U,U=X}})}),p=x,S=y}for(;S.length<4;)S.push(0),p.push(0);for(let x=0;x<4;++x)u.push(S[x]),h.push(p[x])}if(e.normal){const x=da(g,n,f,e.normal);o.push(x[0],x[1],x[2])}e.material&&e.material.mappingType!=="AllSame"&&(_=da(g,n,f,e.material)[0],_<0&&(d.negativeMaterialIndices=!0,_=0)),e.uv&&e.uv.forEach(function(x,y){const N=da(g,n,f,x);c[y]===void 0&&(c[y]=[]),c[y].push(N[0]),c[y].push(N[1])}),i++,m&&(d.genFace(t,e,a,_,o,l,c,u,h,i),n++,i=0,a=[],o=[],l=[],c=[],u=[],h=[])}),t}getNormalNewell(e){const t=new O(0,0,0);for(let n=0;n<e.length;n++){const i=e[n],r=e[(n+1)%e.length];t.x+=(i.y-r.y)*(i.z+r.z),t.y+=(i.z-r.z)*(i.x+r.x),t.z+=(i.x-r.x)*(i.y+r.y)}return t.normalize(),t}getNormalTangentAndBitangent(e){const t=this.getNormalNewell(e),i=(Math.abs(t.z)>.5?new O(0,1,0):new O(0,0,1)).cross(t).normalize(),r=t.clone().cross(i).normalize();return{normal:t,tangent:i,bitangent:r}}flattenVertex(e,t,n){return new ot(e.dot(t),e.dot(n))}genFace(e,t,n,i,r,a,o,l,c,u){let h;if(u>3){const d=[],f=t.baseVertexPositions||t.vertexPositions;for(let p=0;p<n.length;p+=3)d.push(new O(f[n[p]],f[n[p+1]],f[n[p+2]]));const{tangent:g,bitangent:_}=this.getNormalTangentAndBitangent(d),m=[];for(const p of d)m.push(this.flattenVertex(p,g,_));h=Wl.triangulateShape(m,[])}else h=[[0,1,2]];for(const[d,f,g]of h)e.vertex.push(t.vertexPositions[n[d*3]]),e.vertex.push(t.vertexPositions[n[d*3+1]]),e.vertex.push(t.vertexPositions[n[d*3+2]]),e.vertex.push(t.vertexPositions[n[f*3]]),e.vertex.push(t.vertexPositions[n[f*3+1]]),e.vertex.push(t.vertexPositions[n[f*3+2]]),e.vertex.push(t.vertexPositions[n[g*3]]),e.vertex.push(t.vertexPositions[n[g*3+1]]),e.vertex.push(t.vertexPositions[n[g*3+2]]),t.skeleton&&(e.vertexWeights.push(l[d*4]),e.vertexWeights.push(l[d*4+1]),e.vertexWeights.push(l[d*4+2]),e.vertexWeights.push(l[d*4+3]),e.vertexWeights.push(l[f*4]),e.vertexWeights.push(l[f*4+1]),e.vertexWeights.push(l[f*4+2]),e.vertexWeights.push(l[f*4+3]),e.vertexWeights.push(l[g*4]),e.vertexWeights.push(l[g*4+1]),e.vertexWeights.push(l[g*4+2]),e.vertexWeights.push(l[g*4+3]),e.weightsIndices.push(c[d*4]),e.weightsIndices.push(c[d*4+1]),e.weightsIndices.push(c[d*4+2]),e.weightsIndices.push(c[d*4+3]),e.weightsIndices.push(c[f*4]),e.weightsIndices.push(c[f*4+1]),e.weightsIndices.push(c[f*4+2]),e.weightsIndices.push(c[f*4+3]),e.weightsIndices.push(c[g*4]),e.weightsIndices.push(c[g*4+1]),e.weightsIndices.push(c[g*4+2]),e.weightsIndices.push(c[g*4+3])),t.color&&(e.colors.push(a[d*3]),e.colors.push(a[d*3+1]),e.colors.push(a[d*3+2]),e.colors.push(a[f*3]),e.colors.push(a[f*3+1]),e.colors.push(a[f*3+2]),e.colors.push(a[g*3]),e.colors.push(a[g*3+1]),e.colors.push(a[g*3+2])),t.material&&t.material.mappingType!=="AllSame"&&(e.materialIndex.push(i),e.materialIndex.push(i),e.materialIndex.push(i)),t.normal&&(e.normal.push(r[d*3]),e.normal.push(r[d*3+1]),e.normal.push(r[d*3+2]),e.normal.push(r[f*3]),e.normal.push(r[f*3+1]),e.normal.push(r[f*3+2]),e.normal.push(r[g*3]),e.normal.push(r[g*3+1]),e.normal.push(r[g*3+2])),t.uv&&t.uv.forEach(function(_,m){e.uvs[m]===void 0&&(e.uvs[m]=[]),e.uvs[m].push(o[m][d*2]),e.uvs[m].push(o[m][d*2+1]),e.uvs[m].push(o[m][f*2]),e.uvs[m].push(o[m][f*2+1]),e.uvs[m].push(o[m][g*2]),e.uvs[m].push(o[m][g*2+1])})}addMorphTargets(e,t,n,i){if(n.length===0)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const r=this;n.forEach(function(a){a.rawTargets.forEach(function(o){const l=Mt.Objects.Geometry[o.geoID];l!==void 0&&r.genMorphGeometry(e,t,l,i,o.name)})})}genMorphGeometry(e,t,n,i,r){const a=t.Vertices!==void 0?t.Vertices.a:[],o=t.PolygonVertexIndex!==void 0?t.PolygonVertexIndex.a:[],l=n.Vertices!==void 0?n.Vertices.a:[],c=n.Indexes!==void 0?n.Indexes.a:[],u=e.attributes.position.count*3,h=new Float32Array(u);for(let _=0;_<c.length;_++){const m=c[_]*3;h[m]=l[_*3],h[m+1]=l[_*3+1],h[m+2]=l[_*3+2]}const d={vertexIndices:o,vertexPositions:h,baseVertexPositions:a},f=this.genBuffers(d),g=new xt(f.vertex,3);g.name=r||n.attrName,g.applyMatrix4(i),e.morphAttributes.position.push(g)}parseNormals(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.Normals.a;let r=[];return n==="IndexToDirect"&&("NormalIndex"in e?r=e.NormalIndex.a:"NormalsIndex"in e&&(r=e.NormalsIndex.a)),{dataSize:3,buffer:i,indices:r,mappingType:t,referenceType:n}}parseUVs(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.UV.a;let r=[];return n==="IndexToDirect"&&(r=e.UVIndex.a),{dataSize:2,buffer:i,indices:r,mappingType:t,referenceType:n}}parseVertexColors(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.Colors.a;let r=[];n==="IndexToDirect"&&(r=e.ColorIndex.a);for(let a=0,o=new He;a<i.length;a+=4)o.fromArray(i,a),pt.colorSpaceToWorking(o,_t),o.toArray(i,a);return{dataSize:4,buffer:i,indices:r,mappingType:t,referenceType:n}}parseMaterialIndices(e){const t=e.MappingInformationType,n=e.ReferenceInformationType;if(t==="NoMappingInformation")return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const i=e.Materials.a,r=[];for(let a=0;a<i.length;++a)r.push(a);return{dataSize:1,buffer:i,indices:r,mappingType:t,referenceType:n}}parseNurbsGeometry(e){const t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new Kt;const n=t-1,i=e.KnotVector.a,r=[],a=e.Points.a;for(let h=0,d=a.length;h<d;h+=4)r.push(new Tt().fromArray(a,h));let o,l;if(e.Form==="Closed")r.push(r[0]);else if(e.Form==="Periodic"){o=n,l=i.length-1-o;for(let h=0;h<n;++h)r.push(r[h])}const u=new Px(n,i,r,o,l).getPoints(r.length*12);return new Kt().setFromPoints(u)}}class Nx{parse(){const e=[],t=this.parseClips();if(t!==void 0)for(const n in t){const i=t[n],r=this.addClip(i);e.push(r)}return e}parseClips(){if(Mt.Objects.AnimationCurve===void 0)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=Mt.Objects.AnimationCurveNode,t=new Map;for(const n in e){const i=e[n];if(i.attrName.match(/S|R|T|DeformPercent/)!==null){const r={id:i.id,attr:i.attrName,curves:{}};t.set(r.id,r)}}return t}parseAnimationCurves(e){const t=Mt.Objects.AnimationCurve;for(const n in t){const i={id:t[n].id,times:t[n].KeyTime.a.map(Bx),values:t[n].KeyValueFloat.a},r=qt.get(i.id);if(r!==void 0){const a=r.parents[0].ID,o=r.parents[0].relationship;o.match(/X/)?e.get(a).curves.x=i:o.match(/Y/)?e.get(a).curves.y=i:o.match(/Z/)?e.get(a).curves.z=i:o.match(/DeformPercent/)&&e.has(a)&&(e.get(a).curves.morph=i)}}}parseAnimationLayers(e){const t=Mt.Objects.AnimationLayer,n=new Map;for(const i in t){const r=[],a=qt.get(parseInt(i));a!==void 0&&(a.children.forEach(function(l,c){if(e.has(l.ID)){const u=e.get(l.ID);if(u.curves.x!==void 0||u.curves.y!==void 0||u.curves.z!==void 0){if(r[c]===void 0){const h=qt.get(l.ID).parents.filter(function(d){return d.relationship!==void 0})[0].ID;if(h!==void 0){const d=Mt.Objects.Model[h.toString()];if(d===void 0){console.warn("THREE.FBXLoader: Encountered a unused curve.",l);return}const f={modelName:d.attrName?At.sanitizeNodeName(d.attrName):"",ID:d.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};Mn.traverse(function(g){g.ID===d.id&&(f.transform=g.matrix,g.userData.transformData&&(f.eulerOrder=g.userData.transformData.eulerOrder))}),f.transform||(f.transform=new Fe),"PreRotation"in d&&(f.preRotation=d.PreRotation.value),"PostRotation"in d&&(f.postRotation=d.PostRotation.value),r[c]=f}}r[c]&&(r[c][u.attr]=u)}else if(u.curves.morph!==void 0){if(r[c]===void 0){const h=qt.get(l.ID).parents.filter(function(p){return p.relationship!==void 0})[0].ID,d=qt.get(h).parents[0].ID,f=qt.get(d).parents[0].ID,g=qt.get(f).parents[0].ID,_=Mt.Objects.Model[g],m={modelName:_.attrName?At.sanitizeNodeName(_.attrName):"",morphName:Mt.Objects.Deformer[h].attrName};r[c]=m}r[c][u.attr]=u}}}),n.set(parseInt(i),r))}return n}parseAnimStacks(e){const t=Mt.Objects.AnimationStack,n={};for(const i in t){const r=qt.get(parseInt(i)).children;r.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const a=e.get(r[0].ID);n[i]={name:t[i].attrName,layer:a}}return n}addClip(e){let t=[];const n=this;return e.layer.forEach(function(i){t=t.concat(n.generateTracks(i))}),new Ca(e.name,-1,t)}generateTracks(e){const t=[];let n=new O,i=new O;if(e.transform&&e.transform.decompose(n,new tn,i),n=n.toArray(),i=i.toArray(),e.T!==void 0&&Object.keys(e.T.curves).length>0){const r=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");r!==void 0&&t.push(r)}if(e.R!==void 0&&Object.keys(e.R.curves).length>0){const r=this.generateRotationTrack(e.modelName,e.R.curves,e.preRotation,e.postRotation,e.eulerOrder);r!==void 0&&t.push(r)}if(e.S!==void 0&&Object.keys(e.S.curves).length>0){const r=this.generateVectorTrack(e.modelName,e.S.curves,i,"scale");r!==void 0&&t.push(r)}if(e.DeformPercent!==void 0){const r=this.generateMorphTrack(e);r!==void 0&&t.push(r)}return t}generateVectorTrack(e,t,n,i){const r=this.getTimesForAllAxes(t),a=this.getKeyframeTrackValues(r,t,n);return new wi(e+"."+i,r,a)}generateRotationTrack(e,t,n,i,r){let a,o;if(t.x!==void 0&&t.y!==void 0&&t.z!==void 0){const d=this.interpolateRotations(t.x,t.y,t.z,r);a=d[0],o=d[1]}const l=Ar(0);n!==void 0&&(n=n.map(jt.degToRad),n.push(l),n=new nn().fromArray(n),n=new tn().setFromEuler(n)),i!==void 0&&(i=i.map(jt.degToRad),i.push(l),i=new nn().fromArray(i),i=new tn().setFromEuler(i).invert());const c=new tn,u=new nn,h=[];if(!o||!a)return new Ai(e+".quaternion",[0],[0]);for(let d=0;d<o.length;d+=3)u.set(o[d],o[d+1],o[d+2],r),c.setFromEuler(u),n!==void 0&&c.premultiply(n),i!==void 0&&c.multiply(i),d>2&&new tn().fromArray(h,(d-3)/3*4).dot(c)<0&&c.set(-c.x,-c.y,-c.z,-c.w),c.toArray(h,d/3*4);return new Ai(e+".quaternion",a,h)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map(function(r){return r/100}),i=Mn.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new hs(e.modelName+".morphTargetInfluences["+i+"]",t.times,n)}getTimesForAllAxes(e){let t=[];if(e.x!==void 0&&(t=t.concat(e.x.times)),e.y!==void 0&&(t=t.concat(e.y.times)),e.z!==void 0&&(t=t.concat(e.z.times)),t=t.sort(function(n,i){return n-i}),t.length>1){let n=1,i=t[0];for(let r=1;r<t.length;r++){const a=t[r];a!==i&&(t[n]=a,i=a,n++)}t=t.slice(0,n)}return t}getKeyframeTrackValues(e,t,n){const i=n,r=[];let a=-1,o=-1,l=-1;return e.forEach(function(c){if(t.x&&(a=t.x.times.indexOf(c)),t.y&&(o=t.y.times.indexOf(c)),t.z&&(l=t.z.times.indexOf(c)),a!==-1){const u=t.x.values[a];r.push(u),i[0]=u}else r.push(i[0]);if(o!==-1){const u=t.y.values[o];r.push(u),i[1]=u}else r.push(i[1]);if(l!==-1){const u=t.z.values[l];r.push(u),i[2]=u}else r.push(i[2])}),r}interpolateRotations(e,t,n,i){const r=[],a=[];r.push(e.times[0]),a.push(jt.degToRad(e.values[0])),a.push(jt.degToRad(t.values[0])),a.push(jt.degToRad(n.values[0]));for(let o=1;o<e.values.length;o++){const l=[e.values[o-1],t.values[o-1],n.values[o-1]];if(isNaN(l[0])||isNaN(l[1])||isNaN(l[2]))continue;const c=l.map(jt.degToRad),u=[e.values[o],t.values[o],n.values[o]];if(isNaN(u[0])||isNaN(u[1])||isNaN(u[2]))continue;const h=u.map(jt.degToRad),d=[u[0]-l[0],u[1]-l[1],u[2]-l[2]],f=[Math.abs(d[0]),Math.abs(d[1]),Math.abs(d[2])];if(f[0]>=180||f[1]>=180||f[2]>=180){const _=Math.max(...f)/180,m=new nn(...c,i),p=new nn(...h,i),S=new tn().setFromEuler(m),x=new tn().setFromEuler(p);S.dot(x)&&x.set(-x.x,-x.y,-x.z,-x.w);const y=e.times[o-1],N=e.times[o]-y,P=new tn,L=new nn;for(let U=0;U<1;U+=1/_)P.copy(S.clone().slerp(x.clone(),U)),r.push(y+U*N),L.setFromQuaternion(P,i),a.push(L.x),a.push(L.y),a.push(L.z)}else r.push(e.times[o]),a.push(jt.degToRad(e.values[o])),a.push(jt.degToRad(t.values[o])),a.push(jt.degToRad(n.values[o]))}return[r,a]}}class Ux{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new Ih,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,n=e.split(/[\r\n]+/);return n.forEach(function(i,r){const a=i.match(/^[\s\t]*;/),o=i.match(/^[\s\t]*$/);if(a||o)return;const l=i.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),c=i.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),u=i.match("^\\t{"+(t.currentIndent-1)+"}}");l?t.parseNodeBegin(i,l):c?t.parseNodeProperty(i,c,n[++r]):u?t.popStack():i.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(i)}),this.allNodes}parseNodeBegin(e,t){const n=t[1].trim().replace(/^"/,"").replace(/"$/,""),i=t[2].split(",").map(function(l){return l.trim().replace(/^"/,"").replace(/"$/,"")}),r={name:n},a=this.parseNodeAttr(i),o=this.getCurrentNode();this.currentIndent===0?this.allNodes.add(n,r):n in o?(n==="PoseNode"?o.PoseNode.push(r):o[n].id!==void 0&&(o[n]={},o[n][o[n].id]=o[n]),a.id!==""&&(o[n][a.id]=r)):typeof a.id=="number"?(o[n]={},o[n][a.id]=r):n!=="Properties70"&&(n==="PoseNode"?o[n]=[r]:o[n]=r),typeof a.id=="number"&&(r.id=a.id),a.name!==""&&(r.attrName=a.name),a.type!==""&&(r.attrType=a.type),this.pushStack(r)}parseNodeAttr(e){let t=e[0];e[0]!==""&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",i="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),i=e[2]),{id:t,name:n,type:i}}parseNodeProperty(e,t,n){let i=t[1].replace(/^"/,"").replace(/"$/,"").trim(),r=t[2].replace(/^"/,"").replace(/"$/,"").trim();i==="Content"&&r===","&&(r=n.replace(/"/g,"").replace(/,$/,"").trim());const a=this.getCurrentNode();if(a.name==="Properties70"){this.parseNodeSpecialProperty(e,i,r);return}if(i==="C"){const l=r.split(",").slice(1),c=parseInt(l[0]),u=parseInt(l[1]);let h=r.split(",").slice(3);h=h.map(function(d){return d.trim().replace(/^"/,"")}),i="connections",r=[c,u],Vx(r,h),a[i]===void 0&&(a[i]=[])}i==="Node"&&(a.id=r),i in a&&Array.isArray(a[i])?a[i].push(r):i!=="a"?a[i]=r:a.a=r,this.setCurrentProp(a,i),i==="a"&&r.slice(-1)!==","&&(a.a=Co(r))}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=Co(t.a))}parseNodeSpecialProperty(e,t,n){const i=n.split('",').map(function(u){return u.trim().replace(/^\"/,"").replace(/\s/,"_")}),r=i[0],a=i[1],o=i[2],l=i[3];let c=i[4];switch(a){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":c=parseFloat(c);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":c=Co(c);break}this.getPrevNode()[r]={type:a,type2:o,flag:l,value:c},this.setCurrentProp(this.getPrevNode(),r)}}class Fx{parse(e){const t=new Cu(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const i=new Ih;for(;!this.endOfContent(t);){const r=this.parseNode(t,n);r!==null&&i.add(r.name,r)}return i}endOfContent(e){return e.size()%16===0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},i=t>=7500?e.getUint64():e.getUint32(),r=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const a=e.getUint8(),o=e.getString(a);if(i===0)return null;const l=[];for(let d=0;d<r;d++)l.push(this.parseProperty(e));const c=l.length>0?l[0]:"",u=l.length>1?l[1]:"",h=l.length>2?l[2]:"";for(n.singleProperty=r===1&&e.getOffset()===i;i>e.getOffset();){const d=this.parseNode(e,t);d!==null&&this.parseSubNode(o,n,d)}return n.propertyList=l,typeof c=="number"&&(n.id=c),u!==""&&(n.attrName=u),h!==""&&(n.attrType=h),o!==""&&(n.name=o),n}parseSubNode(e,t,n){if(n.singleProperty===!0){const i=n.propertyList[0];Array.isArray(i)?(t[n.name]=n,n.a=i):t[n.name]=i}else if(e==="Connections"&&n.name==="C"){const i=[];n.propertyList.forEach(function(r,a){a!==0&&i.push(r)}),t.connections===void 0&&(t.connections=[]),t.connections.push(i)}else if(n.name==="Properties70")Object.keys(n).forEach(function(r){t[r]=n[r]});else if(e==="Properties70"&&n.name==="P"){let i=n.propertyList[0],r=n.propertyList[1];const a=n.propertyList[2],o=n.propertyList[3];let l;i.indexOf("Lcl ")===0&&(i=i.replace("Lcl ","Lcl_")),r.indexOf("Lcl ")===0&&(r=r.replace("Lcl ","Lcl_")),r==="Color"||r==="ColorRGB"||r==="Vector"||r==="Vector3D"||r.indexOf("Lcl_")===0?l=[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:l=n.propertyList[4],t[i]={type:r,type2:a,flag:o,value:l}}else t[n.name]===void 0?typeof n.id=="number"?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:n.name==="PoseNode"?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):t[n.name][n.id]===void 0&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const i=e.getUint32(),r=e.getUint32(),a=e.getUint32();if(r===0)switch(t){case"b":case"c":return e.getBooleanArray(i);case"d":return e.getFloat64Array(i);case"f":return e.getFloat32Array(i);case"i":return e.getInt32Array(i);case"l":return e.getInt64Array(i)}const o=vx(new Uint8Array(e.getArrayBuffer(a))),l=new Cu(o.buffer);switch(t){case"b":case"c":return l.getBooleanArray(i);case"d":return l.getFloat64Array(i);case"f":return l.getFloat32Array(i);case"i":return l.getInt32Array(i);case"l":return l.getInt64Array(i)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class Cu{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=t!==void 0?t:!0,this._textDecoder=new TextDecoder}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(e){const t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){const e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t&2147483648?(t=~t&4294967295,e=~e&4294967295,e===4294967295&&(t=t+1&4294967295),e=e+1&4294967295,-(t*4294967296+e)):t*4294967296+e}getInt64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t*4294967296+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){const t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){const t=this.offset;let n=new Uint8Array(this.dv.buffer,t,e);this.skip(e);const i=n.indexOf(0);return i>=0&&(n=new Uint8Array(this.dv.buffer,t,i)),this._textDecoder.decode(n)}}class Ih{add(e,t){this[e]=t}}function Ox(s){const e="Kaydara FBX Binary \0";return s.byteLength>=e.length&&e===Uh(s,0,e.length)}function kx(s){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let t=0;function n(i){const r=s[i-1];return s=s.slice(t+i),t++,r}for(let i=0;i<e.length;++i)if(n(1)===e[i])return!1;return!0}function Pu(s){const e=/FBXVersion: (\d+)/,t=s.match(e);if(t)return parseInt(t[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function Bx(s){return s/46186158e3}const zx=[];function da(s,e,t,n){let i;switch(n.mappingType){case"ByPolygonVertex":i=s;break;case"ByPolygon":i=e;break;case"ByVertice":i=t;break;case"AllSame":i=n.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+n.mappingType)}n.referenceType==="IndexToDirect"&&(i=n.indices[i]);const r=i*n.dataSize,a=r+n.dataSize;return Hx(zx,n.buffer,r,a)}const Ro=new nn,Ps=new O;function Nh(s){const e=new Fe,t=new Fe,n=new Fe,i=new Fe,r=new Fe,a=new Fe,o=new Fe,l=new Fe,c=new Fe,u=new Fe,h=new Fe,d=new Fe,f=s.inheritType?s.inheritType:0;s.translation&&e.setPosition(Ps.fromArray(s.translation));const g=Ar(0);if(s.preRotation){const D=s.preRotation.map(jt.degToRad);D.push(g),t.makeRotationFromEuler(Ro.fromArray(D))}if(s.rotation){const D=s.rotation.map(jt.degToRad);D.push(s.eulerOrder||g),n.makeRotationFromEuler(Ro.fromArray(D))}if(s.postRotation){const D=s.postRotation.map(jt.degToRad);D.push(g),i.makeRotationFromEuler(Ro.fromArray(D)),i.invert()}s.scale&&r.scale(Ps.fromArray(s.scale)),s.scalingOffset&&o.setPosition(Ps.fromArray(s.scalingOffset)),s.scalingPivot&&a.setPosition(Ps.fromArray(s.scalingPivot)),s.rotationOffset&&l.setPosition(Ps.fromArray(s.rotationOffset)),s.rotationPivot&&c.setPosition(Ps.fromArray(s.rotationPivot)),s.parentMatrixWorld&&(h.copy(s.parentMatrix),u.copy(s.parentMatrixWorld));const _=t.clone().multiply(n).multiply(i),m=new Fe;m.extractRotation(u);const p=new Fe;p.copyPosition(u);const S=p.clone().invert().multiply(u),x=m.clone().invert().multiply(S),y=r,N=new Fe;if(f===0)N.copy(m).multiply(_).multiply(x).multiply(y);else if(f===1)N.copy(m).multiply(x).multiply(_).multiply(y);else{const X=new Fe().scale(new O().setFromMatrixScale(h)).clone().invert(),j=x.clone().multiply(X);N.copy(m).multiply(_).multiply(j).multiply(y)}const P=c.clone().invert(),L=a.clone().invert();let U=e.clone().multiply(l).multiply(c).multiply(t).multiply(n).multiply(i).multiply(P).multiply(o).multiply(a).multiply(r).multiply(L);const E=new Fe().copyPosition(U),T=u.clone().multiply(E);return d.copyPosition(T),U=d.clone().multiply(N),U.premultiply(u.invert()),U}function Ar(s){s=s||0;const e=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return s===6?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),e[0]):e[s]}function Co(s){return s.split(",").map(function(t){return parseFloat(t)})}function Uh(s,e,t){return e===void 0&&(e=0),t===void 0&&(t=s.byteLength),new TextDecoder().decode(new Uint8Array(s,e,t))}function Vx(s,e){for(let t=0,n=s.length,i=e.length;t<i;t++,n++)s[n]=e[t]}function Hx(s,e,t,n){for(let i=t,r=0;i<n;i++,r++)s[r]=e[i];return s}function Lu(s,e){if(e===df)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),s;if(e===gl||e===nh){let t=s.getIndex();if(t===null){const a=[],o=s.getAttribute("position");if(o!==void 0){for(let l=0;l<o.count;l++)a.push(l);s.setIndex(a),t=s.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),s}const n=t.count-2,i=[];if(e===gl)for(let a=1;a<=n;a++)i.push(t.getX(0)),i.push(t.getX(a)),i.push(t.getX(a+1));else for(let a=0;a<n;a++)a%2===0?(i.push(t.getX(a)),i.push(t.getX(a+1)),i.push(t.getX(a+2))):(i.push(t.getX(a+2)),i.push(t.getX(a+1)),i.push(t.getX(a)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=s.clone();return r.setIndex(i),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),s}class Gx extends bn{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Kx(t)}),this.register(function(t){return new Yx(t)}),this.register(function(t){return new sv(t)}),this.register(function(t){return new rv(t)}),this.register(function(t){return new av(t)}),this.register(function(t){return new $x(t)}),this.register(function(t){return new Jx(t)}),this.register(function(t){return new Qx(t)}),this.register(function(t){return new ev(t)}),this.register(function(t){return new qx(t)}),this.register(function(t){return new tv(t)}),this.register(function(t){return new Zx(t)}),this.register(function(t){return new iv(t)}),this.register(function(t){return new nv(t)}),this.register(function(t){return new Xx(t)}),this.register(function(t){return new ov(t)}),this.register(function(t){return new lv(t)})}load(e,t,n,i){const r=this;let a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){const c=os.extractUrlBase(e);a=os.resolveURL(c,this.path)}else a=os.extractUrlBase(e);this.manager.itemStart(e);const o=function(c){i?i(c):console.error(c),r.manager.itemError(e),r.manager.itemEnd(e)},l=new Xi(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{r.parse(c,a,function(u){t(u),r.manager.itemEnd(e)},o)}catch(u){o(u)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let r;const a={},o={},l=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===Fh){try{a[St.KHR_BINARY_GLTF]=new cv(e)}catch(h){i&&i(h);return}r=JSON.parse(a[St.KHR_BINARY_GLTF].content)}else r=JSON.parse(l.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new Sv(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){const h=this.pluginCallbacks[u](c);h.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),o[h.name]=h,a[h.name]=!0}if(r.extensionsUsed)for(let u=0;u<r.extensionsUsed.length;++u){const h=r.extensionsUsed[u],d=r.extensionsRequired||[];switch(h){case St.KHR_MATERIALS_UNLIT:a[h]=new jx;break;case St.KHR_DRACO_MESH_COMPRESSION:a[h]=new uv(r,this.dracoLoader);break;case St.KHR_TEXTURE_TRANSFORM:a[h]=new hv;break;case St.KHR_MESH_QUANTIZATION:a[h]=new dv;break;default:d.indexOf(h)>=0&&o[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}c.setExtensions(a),c.setPlugins(o),c.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function Wx(){let s={};return{get:function(e){return s[e]},add:function(e,t){s[e]=t},remove:function(e){delete s[e]},removeAll:function(){s={}}}}const St={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Xx{constructor(e){this.parser=e,this.name=St.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const r=t.json,l=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let c;const u=new He(16777215);l.color!==void 0&&u.setRGB(l.color[0],l.color[1],l.color[2],Tn);const h=l.range!==void 0?l.range:0;switch(l.type){case"directional":c=new Er(u),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new Pa(u),c.distance=h;break;case"spot":c=new ql(u),c.distance=h,l.spot=l.spot||{},l.spot.innerConeAngle=l.spot.innerConeAngle!==void 0?l.spot.innerConeAngle:0,l.spot.outerConeAngle=l.spot.outerConeAngle!==void 0?l.spot.outerConeAngle:Math.PI/4,c.angle=l.spot.outerConeAngle,c.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return c.position.set(0,0,0),Mi(c,l),l.intensity!==void 0&&(c.intensity=l.intensity),c.name=t.createUniqueName(l.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],o=(r.extensions&&r.extensions[this.name]||{}).light;return o===void 0?null:this._loadLight(o).then(function(l){return n._getNodeRef(t.cache,o,l)})}}class jx{constructor(){this.name=St.KHR_MATERIALS_UNLIT}getMaterialType(){return Ti}extendParams(e,t,n){const i=[];e.color=new He(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const a=r.baseColorFactor;e.color.setRGB(a[0],a[1],a[2],Tn),e.opacity=a[3]}r.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",r.baseColorTexture,_t))}return Promise.all(i)}}class qx{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=i.extensions[this.name].emissiveStrength;return r!==void 0&&(t.emissiveIntensity=r),Promise.resolve()}}class Kx{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:oi}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],a=i.extensions[this.name];if(a.clearcoatFactor!==void 0&&(t.clearcoat=a.clearcoatFactor),a.clearcoatTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatMap",a.clearcoatTexture)),a.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=a.clearcoatRoughnessFactor),a.clearcoatRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatRoughnessMap",a.clearcoatRoughnessTexture)),a.clearcoatNormalTexture!==void 0&&(r.push(n.assignTexture(t,"clearcoatNormalMap",a.clearcoatNormalTexture)),a.clearcoatNormalTexture.scale!==void 0)){const o=a.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new ot(o,o)}return Promise.all(r)}}class Yx{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:oi}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=i.extensions[this.name];return t.dispersion=r.dispersion!==void 0?r.dispersion:0,Promise.resolve()}}class Zx{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:oi}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],a=i.extensions[this.name];return a.iridescenceFactor!==void 0&&(t.iridescence=a.iridescenceFactor),a.iridescenceTexture!==void 0&&r.push(n.assignTexture(t,"iridescenceMap",a.iridescenceTexture)),a.iridescenceIor!==void 0&&(t.iridescenceIOR=a.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),a.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=a.iridescenceThicknessMinimum),a.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=a.iridescenceThicknessMaximum),a.iridescenceThicknessTexture!==void 0&&r.push(n.assignTexture(t,"iridescenceThicknessMap",a.iridescenceThicknessTexture)),Promise.all(r)}}class $x{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:oi}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new He(0,0,0),t.sheenRoughness=0,t.sheen=1;const a=i.extensions[this.name];if(a.sheenColorFactor!==void 0){const o=a.sheenColorFactor;t.sheenColor.setRGB(o[0],o[1],o[2],Tn)}return a.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=a.sheenRoughnessFactor),a.sheenColorTexture!==void 0&&r.push(n.assignTexture(t,"sheenColorMap",a.sheenColorTexture,_t)),a.sheenRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"sheenRoughnessMap",a.sheenRoughnessTexture)),Promise.all(r)}}class Jx{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:oi}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],a=i.extensions[this.name];return a.transmissionFactor!==void 0&&(t.transmission=a.transmissionFactor),a.transmissionTexture!==void 0&&r.push(n.assignTexture(t,"transmissionMap",a.transmissionTexture)),Promise.all(r)}}class Qx{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:oi}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],a=i.extensions[this.name];t.thickness=a.thicknessFactor!==void 0?a.thicknessFactor:0,a.thicknessTexture!==void 0&&r.push(n.assignTexture(t,"thicknessMap",a.thicknessTexture)),t.attenuationDistance=a.attenuationDistance||1/0;const o=a.attenuationColor||[1,1,1];return t.attenuationColor=new He().setRGB(o[0],o[1],o[2],Tn),Promise.all(r)}}class ev{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:oi}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=i.extensions[this.name];return t.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}}class tv{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:oi}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],a=i.extensions[this.name];t.specularIntensity=a.specularFactor!==void 0?a.specularFactor:1,a.specularTexture!==void 0&&r.push(n.assignTexture(t,"specularIntensityMap",a.specularTexture));const o=a.specularColorFactor||[1,1,1];return t.specularColor=new He().setRGB(o[0],o[1],o[2],Tn),a.specularColorTexture!==void 0&&r.push(n.assignTexture(t,"specularColorMap",a.specularColorTexture,_t)),Promise.all(r)}}class nv{constructor(e){this.parser=e,this.name=St.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:oi}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],a=i.extensions[this.name];return t.bumpScale=a.bumpFactor!==void 0?a.bumpFactor:1,a.bumpTexture!==void 0&&r.push(n.assignTexture(t,"bumpMap",a.bumpTexture)),Promise.all(r)}}class iv{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:oi}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],a=i.extensions[this.name];return a.anisotropyStrength!==void 0&&(t.anisotropy=a.anisotropyStrength),a.anisotropyRotation!==void 0&&(t.anisotropyRotation=a.anisotropyRotation),a.anisotropyTexture!==void 0&&r.push(n.assignTexture(t,"anisotropyMap",a.anisotropyTexture)),Promise.all(r)}}class sv{constructor(e){this.parser=e,this.name=St.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const r=i.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,a)}}class rv{constructor(e){this.parser=e,this.name=St.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.extensions[t],o=i.images[a.source];let l=n.textureLoader;if(o.uri){const c=n.options.manager.getHandler(o.uri);c!==null&&(l=c)}return n.loadTextureImage(e,a.source,l)}}class av{constructor(e){this.parser=e,this.name=St.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.extensions[t],o=i.images[a.source];let l=n.textureLoader;if(o.uri){const c=n.options.manager.getHandler(o.uri);c!==null&&(l=c)}return n.loadTextureImage(e,a.source,l)}}class ov{constructor(e){this.name=St.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(o){const l=i.byteOffset||0,c=i.byteLength||0,u=i.count,h=i.byteStride,d=new Uint8Array(o,l,c);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(u,h,d,i.mode,i.filter).then(function(f){return f.buffer}):a.ready.then(function(){const f=new ArrayBuffer(u*h);return a.decodeGltfBuffer(new Uint8Array(f),u,h,d,i.mode,i.filter),f})})}else return null}}class lv{constructor(e){this.name=St.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=t.meshes[n.mesh];for(const c of i.primitives)if(c.mode!==kn.TRIANGLES&&c.mode!==kn.TRIANGLE_STRIP&&c.mode!==kn.TRIANGLE_FAN&&c.mode!==void 0)return null;const a=n.extensions[this.name].attributes,o=[],l={};for(const c in a)o.push(this.parser.getDependency("accessor",a[c]).then(u=>(l[c]=u,l[c])));return o.length<1?null:(o.push(this.parser.createNodeMesh(e)),Promise.all(o).then(c=>{const u=c.pop(),h=u.isGroup?u.children:[u],d=c[0].count,f=[];for(const g of h){const _=new Fe,m=new O,p=new tn,S=new O(1,1,1),x=new _p(g.geometry,g.material,d);for(let y=0;y<d;y++)l.TRANSLATION&&m.fromBufferAttribute(l.TRANSLATION,y),l.ROTATION&&p.fromBufferAttribute(l.ROTATION,y),l.SCALE&&S.fromBufferAttribute(l.SCALE,y),x.setMatrixAt(y,_.compose(m,p,S));for(const y in l)if(y==="_COLOR_0"){const N=l[y];x.instanceColor=new yl(N.array,N.itemSize,N.normalized)}else y!=="TRANSLATION"&&y!=="ROTATION"&&y!=="SCALE"&&g.geometry.setAttribute(y,l[y]);kt.prototype.copy.call(x,g),this.parser.assignFinalMaterial(x),f.push(x)}return u.isGroup?(u.clear(),u.add(...f),u):f[0]}))}}const Fh="glTF",rr=12,Du={JSON:1313821514,BIN:5130562};class cv{constructor(e){this.name=St.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,rr),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Fh)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-rr,r=new DataView(e,rr);let a=0;for(;a<i;){const o=r.getUint32(a,!0);a+=4;const l=r.getUint32(a,!0);if(a+=4,l===Du.JSON){const c=new Uint8Array(e,rr+a,o);this.content=n.decode(c)}else if(l===Du.BIN){const c=rr+a;this.body=e.slice(c,c+o)}a+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class uv{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=St.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},l={},c={};for(const u in a){const h=bl[u]||u.toLowerCase();o[h]=a[u]}for(const u in e.attributes){const h=bl[u]||u.toLowerCase();if(a[u]!==void 0){const d=n.accessors[e.attributes[u]],f=Bs[d.componentType];c[h]=f.name,l[h]=d.normalized===!0}}return t.getDependency("bufferView",r).then(function(u){return new Promise(function(h,d){i.decodeDracoFile(u,function(f){for(const g in f.attributes){const _=f.attributes[g],m=l[g];m!==void 0&&(_.normalized=m)}h(f)},o,c,Tn,d)})})}}class hv{constructor(){this.name=St.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class dv{constructor(){this.name=St.KHR_MESH_QUANTIZATION}}class Oh extends Dr{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let a=0;a!==i;a++)t[a]=n[r+a];return t}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=o*2,c=o*3,u=i-t,h=(n-t)/u,d=h*h,f=d*h,g=e*c,_=g-c,m=-2*f+3*d,p=f-d,S=1-m,x=p-d+h;for(let y=0;y!==o;y++){const N=a[_+y+o],P=a[_+y+l]*u,L=a[g+y+o],U=a[g+y]*u;r[y]=S*N+x*P+m*L+p*U}return r}}const fv=new tn;class pv extends Oh{interpolate_(e,t,n,i){const r=super.interpolate_(e,t,n,i);return fv.fromArray(r).normalize().toArray(r),r}}const kn={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Bs={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Iu={9728:Sn,9729:gn,9984:Ku,9985:pa,9986:ar,9987:Jn},Nu={33071:Pn,33648:ba,10497:Vn},Po={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},bl={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},ki={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},mv={CUBICSPLINE:void 0,LINEAR:yr,STEP:_r},Lo={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function gv(s){return s.DefaultMaterial===void 0&&(s.DefaultMaterial=new br({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:si})),s.DefaultMaterial}function ns(s,e,t){for(const n in t.extensions)s[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function Mi(s,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(s.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function _v(s,e,t){let n=!1,i=!1,r=!1;for(let c=0,u=e.length;c<u;c++){const h=e[c];if(h.POSITION!==void 0&&(n=!0),h.NORMAL!==void 0&&(i=!0),h.COLOR_0!==void 0&&(r=!0),n&&i&&r)break}if(!n&&!i&&!r)return Promise.resolve(s);const a=[],o=[],l=[];for(let c=0,u=e.length;c<u;c++){const h=e[c];if(n){const d=h.POSITION!==void 0?t.getDependency("accessor",h.POSITION):s.attributes.position;a.push(d)}if(i){const d=h.NORMAL!==void 0?t.getDependency("accessor",h.NORMAL):s.attributes.normal;o.push(d)}if(r){const d=h.COLOR_0!==void 0?t.getDependency("accessor",h.COLOR_0):s.attributes.color;l.push(d)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l)]).then(function(c){const u=c[0],h=c[1],d=c[2];return n&&(s.morphAttributes.position=u),i&&(s.morphAttributes.normal=h),r&&(s.morphAttributes.color=d),s.morphTargetsRelative=!0,s})}function yv(s,e){if(s.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)s.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(s.morphTargetInfluences.length===t.length){s.morphTargetDictionary={};for(let n=0,i=t.length;n<i;n++)s.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function xv(s){let e;const t=s.extensions&&s.extensions[St.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Do(t.attributes):e=s.indices+":"+Do(s.attributes)+":"+s.mode,s.targets!==void 0)for(let n=0,i=s.targets.length;n<i;n++)e+=":"+Do(s.targets[n]);return e}function Do(s){let e="";const t=Object.keys(s).sort();for(let n=0,i=t.length;n<i;n++)e+=t[n]+":"+s[t[n]]+";";return e}function El(s){switch(s){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function vv(s){return s.search(/\.jpe?g($|\?)/i)>0||s.search(/^data\:image\/jpeg/)===0?"image/jpeg":s.search(/\.webp($|\?)/i)>0||s.search(/^data\:image\/webp/)===0?"image/webp":s.search(/\.ktx2($|\?)/i)>0||s.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const Mv=new Fe;class Sv{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Wx,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,a=-1;if(typeof navigator<"u"){const o=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(o)===!0;const l=o.match(/Version\/(\d+)/);i=n&&l?parseInt(l[1],10):-1,r=o.indexOf("Firefox")>-1,a=r?o.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&i<17||r&&a<98?this.textureLoader=new Xl(this.options.manager):this.textureLoader=new sm(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Xi(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(a){return a._markDefs&&a._markDefs()}),Promise.all(this._invokeAll(function(a){return a.beforeRoot&&a.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(a){const o={scene:a[0][i.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:i.asset,parser:n,userData:{}};return ns(r,o,i),Mi(o,i),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(o)})).then(function(){for(const l of o.scenes)l.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){const a=t[i].joints;for(let o=0,l=a.length;o<l;o++)e[a[o]].isBone=!0}for(let i=0,r=e.length;i<r;i++){const a=e[i];a.mesh!==void 0&&(this._addNodeRef(this.meshCache,a.mesh),a.skin!==void 0&&(n[a.mesh].isSkinnedMesh=!0)),a.camera!==void 0&&this._addNodeRef(this.cameraCache,a.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),r=(a,o)=>{const l=this.associations.get(a);l!=null&&this.associations.set(o,l);for(const[c,u]of a.children.entries())r(u,o.children[c])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const r=e(t[i]);r&&n.push(r)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw new Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,a){return n.getDependency(e,a)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[St.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(r,a){n.load(os.resolveURL(t.uri,i.path),r,void 0,function(){a(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const i=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const a=Po[i.type],o=Bs[i.componentType],l=i.normalized===!0,c=new o(i.count*a);return Promise.resolve(new un(c,a,l))}const r=[];return i.bufferView!==void 0?r.push(this.getDependency("bufferView",i.bufferView)):r.push(null),i.sparse!==void 0&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then(function(a){const o=a[0],l=Po[i.type],c=Bs[i.componentType],u=c.BYTES_PER_ELEMENT,h=u*l,d=i.byteOffset||0,f=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,g=i.normalized===!0;let _,m;if(f&&f!==h){const p=Math.floor(d/f),S="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count;let x=t.cache.get(S);x||(_=new c(o,p*f,i.count*f/u),x=new fp(_,f/u),t.cache.add(S,x)),m=new zl(x,l,d%f/u,g)}else o===null?_=new c(i.count*l):_=new c(o,d,i.count*l),m=new un(_,l,g);if(i.sparse!==void 0){const p=Po.SCALAR,S=Bs[i.sparse.indices.componentType],x=i.sparse.indices.byteOffset||0,y=i.sparse.values.byteOffset||0,N=new S(a[1],x,i.sparse.count*p),P=new c(a[2],y,i.sparse.count*l);o!==null&&(m=new un(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let L=0,U=N.length;L<U;L++){const E=N[L];if(m.setX(E,P[L*l]),l>=2&&m.setY(E,P[L*l+1]),l>=3&&m.setZ(E,P[L*l+2]),l>=4&&m.setW(E,P[L*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=g}return m})}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,a=t.images[r];let o=this.textureLoader;if(a.uri){const l=n.manager.getHandler(a.uri);l!==null&&(o=l)}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,n){const i=this,r=this.json,a=r.textures[e],o=r.images[t],l=(o.uri||o.bufferView)+":"+a.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,n).then(function(u){u.flipY=!1,u.name=a.name||o.name||"",u.name===""&&typeof o.uri=="string"&&o.uri.startsWith("data:image/")===!1&&(u.name=o.uri);const d=(r.samplers||{})[a.sampler]||{};return u.magFilter=Iu[d.magFilter]||gn,u.minFilter=Iu[d.minFilter]||Jn,u.wrapS=Nu[d.wrapS]||Vn,u.wrapT=Nu[d.wrapT]||Vn,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==Sn&&u.minFilter!==gn,i.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());const a=i.images[e],o=self.URL||self.webkitURL;let l=a.uri||"",c=!1;if(a.bufferView!==void 0)l=n.getDependency("bufferView",a.bufferView).then(function(h){c=!0;const d=new Blob([h],{type:a.mimeType});return l=o.createObjectURL(d),l});else if(a.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(l).then(function(h){return new Promise(function(d,f){let g=d;t.isImageBitmapLoader===!0&&(g=function(_){const m=new rn(_);m.needsUpdate=!0,d(m)}),t.load(os.resolveURL(h,r.path),g,void 0,f)})}).then(function(h){return c===!0&&o.revokeObjectURL(l),Mi(h,a),h.userData.mimeType=a.mimeType||vv(a.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),h});return this.sourceCache[e]=u,u}assignTexture(e,t,n,i){const r=this;return this.getDependency("texture",n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),r.extensions[St.KHR_TEXTURE_TRANSFORM]){const o=n.extensions!==void 0?n.extensions[St.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const l=r.associations.get(a);a=r.extensions[St.KHR_TEXTURE_TRANSFORM].extendTexture(a,o),r.associations.set(a,l)}}return i!==void 0&&(a.colorSpace=i),e[t]=a,a})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){const o="PointsMaterial:"+n.uuid;let l=this.cache.get(o);l||(l=new Ds,Dn.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(o,l)),n=l}else if(e.isLine){const o="LineBasicMaterial:"+n.uuid;let l=this.cache.get(o);l||(l=new ii,Dn.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(o,l)),n=l}if(i||r||a){let o="ClonedMaterial:"+n.uuid+":";i&&(o+="derivative-tangents:"),r&&(o+="vertex-colors:"),a&&(o+="flat-shading:");let l=this.cache.get(o);l||(l=n.clone(),r&&(l.vertexColors=!0),a&&(l.flatShading=!0),i&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(o,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return br}loadMaterial(e){const t=this,n=this.json,i=this.extensions,r=n.materials[e];let a;const o={},l=r.extensions||{},c=[];if(l[St.KHR_MATERIALS_UNLIT]){const h=i[St.KHR_MATERIALS_UNLIT];a=h.getMaterialType(),c.push(h.extendParams(o,r,t))}else{const h=r.pbrMetallicRoughness||{};if(o.color=new He(1,1,1),o.opacity=1,Array.isArray(h.baseColorFactor)){const d=h.baseColorFactor;o.color.setRGB(d[0],d[1],d[2],Tn),o.opacity=d[3]}h.baseColorTexture!==void 0&&c.push(t.assignTexture(o,"map",h.baseColorTexture,_t)),o.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,o.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,"metalnessMap",h.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",h.metallicRoughnessTexture))),a=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,o)})))}r.doubleSided===!0&&(o.side=Yn);const u=r.alphaMode||Lo.OPAQUE;if(u===Lo.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,u===Lo.MASK&&(o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&a!==Ti&&(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new ot(1,1),r.normalTexture.scale!==void 0)){const h=r.normalTexture.scale;o.normalScale.set(h,h)}if(r.occlusionTexture!==void 0&&a!==Ti&&(c.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&a!==Ti){const h=r.emissiveFactor;o.emissive=new He().setRGB(h[0],h[1],h[2],Tn)}return r.emissiveTexture!==void 0&&a!==Ti&&c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,_t)),Promise.all(c).then(function(){const h=new a(o);return r.name&&(h.name=r.name),Mi(h,r),t.associations.set(h,{materials:e}),r.extensions&&ns(i,h,r),h})}createUniqueName(e){const t=At.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function r(o){return n[St.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(l){return Uu(l,o,t)})}const a=[];for(let o=0,l=e.length;o<l;o++){const c=e[o],u=xv(c),h=i[u];if(h)a.push(h.promise);else{let d;c.extensions&&c.extensions[St.KHR_DRACO_MESH_COMPRESSION]?d=r(c):d=Uu(new Kt,c,t),i[u]={primitive:c,promise:d},a.push(d)}}return Promise.all(a)}loadMesh(e){const t=this,n=this.json,i=this.extensions,r=n.meshes[e],a=r.primitives,o=[];for(let l=0,c=a.length;l<c;l++){const u=a[l].material===void 0?gv(this.cache):this.getDependency("material",a[l].material);o.push(u)}return o.push(t.loadGeometries(a)),Promise.all(o).then(function(l){const c=l.slice(0,l.length-1),u=l[l.length-1],h=[];for(let f=0,g=u.length;f<g;f++){const _=u[f],m=a[f];let p;const S=c[f];if(m.mode===kn.TRIANGLES||m.mode===kn.TRIANGLE_STRIP||m.mode===kn.TRIANGLE_FAN||m.mode===void 0)p=r.isSkinnedMesh===!0?new Vl(_,S):new sn(_,S),p.isSkinnedMesh===!0&&p.normalizeSkinWeights(),m.mode===kn.TRIANGLE_STRIP?p.geometry=Lu(p.geometry,nh):m.mode===kn.TRIANGLE_FAN&&(p.geometry=Lu(p.geometry,gl));else if(m.mode===kn.LINES)p=new Xs(_,S);else if(m.mode===kn.LINE_STRIP)p=new Lr(_,S);else if(m.mode===kn.LINE_LOOP)p=new vp(_,S);else if(m.mode===kn.POINTS)p=new va(_,S);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(p.geometry.morphAttributes).length>0&&yv(p,r),p.name=t.createUniqueName(r.name||"mesh_"+e),Mi(p,r),m.extensions&&ns(i,p,m),t.assignFinalMaterial(p),h.push(p)}for(let f=0,g=h.length;f<g;f++)t.associations.set(h[f],{meshes:e,primitives:f});if(h.length===1)return r.extensions&&ns(i,h[0],r),h[0];const d=new Gn;r.extensions&&ns(i,d,r),t.associations.set(d,{meshes:e});for(let f=0,g=h.length;f<g;f++)d.add(h[f]);return d})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new cn(jt.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new Oa(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Mi(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(i){const r=i.pop(),a=i,o=[],l=[];for(let c=0,u=a.length;c<u;c++){const h=a[c];if(h){o.push(h);const d=new Fe;r!==null&&d.fromArray(r.array,c*16),l.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new Pr(o,l)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,a=[],o=[],l=[],c=[],u=[];for(let h=0,d=i.channels.length;h<d;h++){const f=i.channels[h],g=i.samplers[f.sampler],_=f.target,m=_.node,p=i.parameters!==void 0?i.parameters[g.input]:g.input,S=i.parameters!==void 0?i.parameters[g.output]:g.output;_.node!==void 0&&(a.push(this.getDependency("node",m)),o.push(this.getDependency("accessor",p)),l.push(this.getDependency("accessor",S)),c.push(g),u.push(_))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l),Promise.all(c),Promise.all(u)]).then(function(h){const d=h[0],f=h[1],g=h[2],_=h[3],m=h[4],p=[];for(let S=0,x=d.length;S<x;S++){const y=d[S],N=f[S],P=g[S],L=_[S],U=m[S];if(y===void 0)continue;y.updateMatrix&&y.updateMatrix();const E=n._createAnimationTracks(y,N,P,L,U);if(E)for(let T=0;T<E.length;T++)p.push(E[T])}return new Ca(r,void 0,p)})}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(r){const a=n._getNodeRef(n.meshCache,i.mesh,r);return i.weights!==void 0&&a.traverse(function(o){if(o.isMesh)for(let l=0,c=i.weights.length;l<c;l++)o.morphTargetInfluences[l]=i.weights[l]}),a})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),a=[],o=i.children||[];for(let c=0,u=o.length;c<u;c++)a.push(n.getDependency("node",o[c]));const l=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(a),l]).then(function(c){const u=c[0],h=c[1],d=c[2];d!==null&&u.traverse(function(f){f.isSkinnedMesh&&f.bind(d,Mv)});for(let f=0,g=h.length;f<g;f++)u.add(h[f]);return u})}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],a=r.name?i.createUniqueName(r.name):"",o=[],l=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&o.push(l),r.camera!==void 0&&o.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)})),i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){o.push(c)}),this.nodeCache[e]=Promise.all(o).then(function(c){let u;if(r.isBone===!0?u=new vr:c.length>1?u=new Gn:c.length===1?u=c[0]:u=new kt,u!==c[0])for(let h=0,d=c.length;h<d;h++)u.add(c[h]);if(r.name&&(u.userData.name=r.name,u.name=a),Mi(u,r),r.extensions&&ns(n,u,r),r.matrix!==void 0){const h=new Fe;h.fromArray(r.matrix),u.applyMatrix4(h)}else r.translation!==void 0&&u.position.fromArray(r.translation),r.rotation!==void 0&&u.quaternion.fromArray(r.rotation),r.scale!==void 0&&u.scale.fromArray(r.scale);if(!i.associations.has(u))i.associations.set(u,{});else if(r.mesh!==void 0&&i.meshCache.refs[r.mesh]>1){const h=i.associations.get(u);i.associations.set(u,{...h})}return i.associations.get(u).nodes=e,u}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,r=new Gn;n.name&&(r.name=i.createUniqueName(n.name)),Mi(r,n),n.extensions&&ns(t,r,n);const a=n.nodes||[],o=[];for(let l=0,c=a.length;l<c;l++)o.push(i.getDependency("node",a[l]));return Promise.all(o).then(function(l){for(let u=0,h=l.length;u<h;u++)r.add(l[u]);const c=u=>{const h=new Map;for(const[d,f]of i.associations)(d instanceof Dn||d instanceof rn)&&h.set(d,f);return u.traverse(d=>{const f=i.associations.get(d);f!=null&&h.set(d,f)}),h};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){const a=[],o=e.name?e.name:e.uuid,l=[];ki[r.path]===ki.weights?e.traverse(function(d){d.morphTargetInfluences&&l.push(d.name?d.name:d.uuid)}):l.push(o);let c;switch(ki[r.path]){case ki.weights:c=hs;break;case ki.rotation:c=Ai;break;case ki.translation:case ki.scale:c=wi;break;default:switch(n.itemSize){case 1:c=hs;break;case 2:case 3:default:c=wi;break}break}const u=i.interpolation!==void 0?mv[i.interpolation]:yr,h=this._getArrayFromAccessor(n);for(let d=0,f=l.length;d<f;d++){const g=new c(l[d]+"."+ki[r.path],t.array,h,u);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),a.push(g)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=El(t.constructor),i=new Float32Array(t.length);for(let r=0,a=t.length;r<a;r++)i[r]=t[r]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const i=this instanceof Ai?pv:Oh;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Tv(s,e,t){const n=e.attributes,i=new Ri;if(n.POSITION!==void 0){const o=t.json.accessors[n.POSITION],l=o.min,c=o.max;if(l!==void 0&&c!==void 0){if(i.set(new O(l[0],l[1],l[2]),new O(c[0],c[1],c[2])),o.normalized){const u=El(Bs[o.componentType]);i.min.multiplyScalar(u),i.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const o=new O,l=new O;for(let c=0,u=r.length;c<u;c++){const h=r[c];if(h.POSITION!==void 0){const d=t.json.accessors[h.POSITION],f=d.min,g=d.max;if(f!==void 0&&g!==void 0){if(l.setX(Math.max(Math.abs(f[0]),Math.abs(g[0]))),l.setY(Math.max(Math.abs(f[1]),Math.abs(g[1]))),l.setZ(Math.max(Math.abs(f[2]),Math.abs(g[2]))),d.normalized){const _=El(Bs[d.componentType]);l.multiplyScalar(_)}o.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(o)}s.boundingBox=i;const a=new ai;i.getCenter(a.center),a.radius=i.min.distanceTo(i.max)/2,s.boundingSphere=a}function Uu(s,e,t){const n=e.attributes,i=[];function r(a,o){return t.getDependency("accessor",a).then(function(l){s.setAttribute(o,l)})}for(const a in n){const o=bl[a]||a.toLowerCase();o in s.attributes||i.push(r(n[a],o))}if(e.indices!==void 0&&!s.index){const a=t.getDependency("accessor",e.indices).then(function(o){s.setIndex(o)});i.push(a)}return pt.workingColorSpace!==Tn&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${pt.workingColorSpace}" not supported.`),Mi(s,e),Tv(s,e,t),Promise.all(i).then(function(){return e.targets!==void 0?_v(s,e.targets,t):s})}class Fu extends em{constructor(e){super(e)}parse(e){function t(k){switch(k.image_type){case d:case _:if(k.colormap_length>256||k.colormap_size!==24||k.colormap_type!==1)throw new Error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case f:case g:case m:case p:if(k.colormap_type)throw new Error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case h:throw new Error("THREE.TGALoader: No data.");default:throw new Error("THREE.TGALoader: Invalid type "+k.image_type)}if(k.width<=0||k.height<=0)throw new Error("THREE.TGALoader: Invalid image size.");if(k.pixel_size!==8&&k.pixel_size!==16&&k.pixel_size!==24&&k.pixel_size!==32)throw new Error("THREE.TGALoader: Invalid pixel size "+k.pixel_size)}function n(k,ae,G,pe,Me){let le,we;const be=G.pixel_size>>3,W=G.width*G.height*be;if(ae&&(we=Me.subarray(pe,pe+=G.colormap_length*(G.colormap_size>>3))),k){le=new Uint8Array(W);let $,re,oe,Te=0;const ne=new Uint8Array(be);for(;Te<W;)if($=Me[pe++],re=($&127)+1,$&128){for(oe=0;oe<be;++oe)ne[oe]=Me[pe++];for(oe=0;oe<re;++oe)le.set(ne,Te+oe*be);Te+=be*re}else{for(re*=be,oe=0;oe<re;++oe)le[Te+oe]=Me[pe++];Te+=re}}else le=Me.subarray(pe,pe+=ae?G.width*G.height:W);return{pixel_data:le,palettes:we}}function i(k,ae,G,pe,Me,le,we,be,W){const $=W;let re,oe=0,Te,ne;const me=T.width;for(ne=ae;ne!==pe;ne+=G)for(Te=Me;Te!==we;Te+=le,oe++)re=be[oe],k[(Te+me*ne)*4+3]=255,k[(Te+me*ne)*4+2]=$[re*3+0],k[(Te+me*ne)*4+1]=$[re*3+1],k[(Te+me*ne)*4+0]=$[re*3+2];return k}function r(k,ae,G,pe,Me,le,we,be){let W,$=0,re,oe;const Te=T.width;for(oe=ae;oe!==pe;oe+=G)for(re=Me;re!==we;re+=le,$+=2)W=be[$+0]+(be[$+1]<<8),k[(re+Te*oe)*4+0]=(W&31744)>>7,k[(re+Te*oe)*4+1]=(W&992)>>2,k[(re+Te*oe)*4+2]=(W&31)<<3,k[(re+Te*oe)*4+3]=W&32768?0:255;return k}function a(k,ae,G,pe,Me,le,we,be){let W=0,$,re;const oe=T.width;for(re=ae;re!==pe;re+=G)for($=Me;$!==we;$+=le,W+=3)k[($+oe*re)*4+3]=255,k[($+oe*re)*4+2]=be[W+0],k[($+oe*re)*4+1]=be[W+1],k[($+oe*re)*4+0]=be[W+2];return k}function o(k,ae,G,pe,Me,le,we,be){let W=0,$,re;const oe=T.width;for(re=ae;re!==pe;re+=G)for($=Me;$!==we;$+=le,W+=4)k[($+oe*re)*4+2]=be[W+0],k[($+oe*re)*4+1]=be[W+1],k[($+oe*re)*4+0]=be[W+2],k[($+oe*re)*4+3]=be[W+3];return k}function l(k,ae,G,pe,Me,le,we,be){let W,$=0,re,oe;const Te=T.width;for(oe=ae;oe!==pe;oe+=G)for(re=Me;re!==we;re+=le,$++)W=be[$],k[(re+Te*oe)*4+0]=W,k[(re+Te*oe)*4+1]=W,k[(re+Te*oe)*4+2]=W,k[(re+Te*oe)*4+3]=255;return k}function c(k,ae,G,pe,Me,le,we,be){let W=0,$,re;const oe=T.width;for(re=ae;re!==pe;re+=G)for($=Me;$!==we;$+=le,W+=2)k[($+oe*re)*4+0]=be[W+0],k[($+oe*re)*4+1]=be[W+0],k[($+oe*re)*4+2]=be[W+0],k[($+oe*re)*4+3]=be[W+1];return k}function u(k,ae,G,pe,Me){let le,we,be,W,$,re;switch((T.flags&S)>>x){default:case P:le=0,be=1,$=ae,we=0,W=1,re=G;break;case y:le=0,be=1,$=ae,we=G-1,W=-1,re=-1;break;case L:le=ae-1,be=-1,$=-1,we=0,W=1,re=G;break;case N:le=ae-1,be=-1,$=-1,we=G-1,W=-1,re=-1;break}if(j)switch(T.pixel_size){case 8:l(k,we,W,re,le,be,$,pe);break;case 16:c(k,we,W,re,le,be,$,pe);break;default:throw new Error("THREE.TGALoader: Format not supported.")}else switch(T.pixel_size){case 8:i(k,we,W,re,le,be,$,pe,Me);break;case 16:r(k,we,W,re,le,be,$,pe);break;case 24:a(k,we,W,re,le,be,$,pe);break;case 32:o(k,we,W,re,le,be,$,pe);break;default:throw new Error("THREE.TGALoader: Format not supported.")}return k}const h=0,d=1,f=2,g=3,_=9,m=10,p=11,S=48,x=4,y=0,N=1,P=2,L=3;if(e.length<19)throw new Error("THREE.TGALoader: Not enough data to contain header.");let U=0;const E=new Uint8Array(e),T={id_length:E[U++],colormap_type:E[U++],image_type:E[U++],colormap_index:E[U++]|E[U++]<<8,colormap_length:E[U++]|E[U++]<<8,colormap_size:E[U++],origin:[E[U++]|E[U++]<<8,E[U++]|E[U++]<<8],width:E[U++]|E[U++]<<8,height:E[U++]|E[U++]<<8,pixel_size:E[U++],flags:E[U++]};if(t(T),T.id_length+U>e.length)throw new Error("THREE.TGALoader: No data.");U+=T.id_length;let D=!1,X=!1,j=!1;switch(T.image_type){case _:D=!0,X=!0;break;case d:X=!0;break;case m:D=!0;break;case f:break;case p:D=!0,j=!0;break;case g:j=!0;break}const se=new Uint8Array(T.width*T.height*4),de=n(D,X,T,U,E);return u(se,T.width,T.height,de.pixel_data,de.palettes),{data:se,width:T.width,height:T.height,flipY:!0,generateMipmaps:!0,minFilter:Jn}}}class bv extends bn{load(e,t,n,i){const r=this,a=r.path===""?os.extractUrlBase(e):r.path,o=new Xi(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,function(l){try{t(r.parse(l,a))}catch(c){i?i(c):console.error(c),r.manager.itemError(e)}},n,i)}parse(e,t){function n(M,v){const R=[],A=M.childNodes;for(let C=0,J=A.length;C<J;C++){const he=A[C];he.nodeName===v&&R.push(he)}return R}function i(M){if(M.length===0)return[];const v=M.trim().split(/\s+/),R=new Array(v.length);for(let A=0,C=v.length;A<C;A++)R[A]=v[A];return R}function r(M){if(M.length===0)return[];const v=M.trim().split(/\s+/),R=new Array(v.length);for(let A=0,C=v.length;A<C;A++)R[A]=parseFloat(v[A]);return R}function a(M){if(M.length===0)return[];const v=M.trim().split(/\s+/),R=new Array(v.length);for(let A=0,C=v.length;A<C;A++)R[A]=parseInt(v[A]);return R}function o(M){return M.substring(1)}function l(){return"three_default_"+hi++}function c(M){return Object.keys(M).length===0}function u(M){return{unit:h(n(M,"unit")[0]),upAxis:d(n(M,"up_axis")[0])}}function h(M){return M!==void 0&&M.hasAttribute("meter")===!0?parseFloat(M.getAttribute("meter")):1}function d(M){return M!==void 0?M.textContent:"Y_UP"}function f(M,v,R,A){const C=n(M,v)[0];if(C!==void 0){const J=n(C,R);for(let he=0;he<J.length;he++)A(J[he])}}function g(M,v){for(const R in M){const A=M[R];A.build=v(M[R])}}function _(M,v){return M.build!==void 0||(M.build=v(M)),M.build}function m(M){const v={sources:{},samplers:{},channels:{}};let R=!1;for(let A=0,C=M.childNodes.length;A<C;A++){const J=M.childNodes[A];if(J.nodeType!==1)continue;let he;switch(J.nodeName){case"source":he=J.getAttribute("id"),v.sources[he]=ye(J);break;case"sampler":he=J.getAttribute("id"),v.samplers[he]=p(J);break;case"channel":he=J.getAttribute("target"),v.channels[he]=S(J);break;case"animation":m(J),R=!0;break;default:console.log(J)}}R===!1&&(ut.animations[M.getAttribute("id")||jt.generateUUID()]=v)}function p(M){const v={inputs:{}};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"input":const J=o(C.getAttribute("source")),he=C.getAttribute("semantic");v.inputs[he]=J;break}}return v}function S(M){const v={};let A=M.getAttribute("target").split("/");const C=A.shift();let J=A.shift();const he=J.indexOf("(")!==-1,Ve=J.indexOf(".")!==-1;if(Ve)A=J.split("."),J=A.shift(),v.member=A.shift();else if(he){const Ae=J.split("(");J=Ae.shift();for(let Ue=0;Ue<Ae.length;Ue++)Ae[Ue]=parseInt(Ae[Ue].replace(/\)/,""));v.indices=Ae}return v.id=C,v.sid=J,v.arraySyntax=he,v.memberSyntax=Ve,v.sampler=o(M.getAttribute("source")),v}function x(M){const v=[],R=M.channels,A=M.samplers,C=M.sources;for(const J in R)if(R.hasOwnProperty(J)){const he=R[J],Ve=A[he.sampler],Ae=Ve.inputs.INPUT,Ue=Ve.inputs.OUTPUT,$e=C[Ae],xe=C[Ue],Ze=N(he,$e,xe);T(Ze,v)}return v}function y(M){return _(ut.animations[M],x)}function N(M,v,R){const A=ut.nodes[M.id],C=mt(A.id),J=A.transforms[M.sid],he=A.matrix.clone().transpose();let Ve,Ae,Ue,$e,xe,Ze;const je={};switch(J){case"matrix":for(Ue=0,$e=v.array.length;Ue<$e;Ue++)if(Ve=v.array[Ue],Ae=Ue*R.stride,je[Ve]===void 0&&(je[Ve]={}),M.arraySyntax===!0){const Wt=R.array[Ae],Dt=M.indices[0]+4*M.indices[1];je[Ve][Dt]=Wt}else for(xe=0,Ze=R.stride;xe<Ze;xe++)je[Ve][xe]=R.array[Ae+xe];break;case"translate":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',J);break;case"rotate":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',J);break;case"scale":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',J);break}const rt=P(je,he);return{name:C.uuid,keyframes:rt}}function P(M,v){const R=[];for(const C in M)R.push({time:parseFloat(C),value:M[C]});R.sort(A);for(let C=0;C<16;C++)D(R,C,v.elements[C]);return R;function A(C,J){return C.time-J.time}}const L=new O,U=new O,E=new tn;function T(M,v){const R=M.keyframes,A=M.name,C=[],J=[],he=[],Ve=[];for(let Ae=0,Ue=R.length;Ae<Ue;Ae++){const $e=R[Ae],xe=$e.time,Ze=$e.value;z.fromArray(Ze).transpose(),z.decompose(L,E,U),C.push(xe),J.push(L.x,L.y,L.z),he.push(E.x,E.y,E.z,E.w),Ve.push(U.x,U.y,U.z)}return J.length>0&&v.push(new wi(A+".position",C,J)),he.length>0&&v.push(new Ai(A+".quaternion",C,he)),Ve.length>0&&v.push(new wi(A+".scale",C,Ve)),v}function D(M,v,R){let A,C=!0,J,he;for(J=0,he=M.length;J<he;J++)A=M[J],A.value[v]===void 0?A.value[v]=null:C=!1;if(C===!0)for(J=0,he=M.length;J<he;J++)A=M[J],A.value[v]=R;else X(M,v)}function X(M,v){let R,A;for(let C=0,J=M.length;C<J;C++){const he=M[C];if(he.value[v]===null){if(R=j(M,C,v),A=se(M,C,v),R===null){he.value[v]=A.value[v];continue}if(A===null){he.value[v]=R.value[v];continue}de(he,R,A,v)}}}function j(M,v,R){for(;v>=0;){const A=M[v];if(A.value[R]!==null)return A;v--}return null}function se(M,v,R){for(;v<M.length;){const A=M[v];if(A.value[R]!==null)return A;v++}return null}function de(M,v,R,A){if(R.time-v.time===0){M.value[A]=v.value[A];return}M.value[A]=(M.time-v.time)*(R.value[A]-v.value[A])/(R.time-v.time)+v.value[A]}function k(M){const v={name:M.getAttribute("id")||"default",start:parseFloat(M.getAttribute("start")||0),end:parseFloat(M.getAttribute("end")||0),animations:[]};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"instance_animation":v.animations.push(o(C.getAttribute("url")));break}}ut.clips[M.getAttribute("id")]=v}function ae(M){const v=[],R=M.name,A=M.end-M.start||-1,C=M.animations;for(let J=0,he=C.length;J<he;J++){const Ve=y(C[J]);for(let Ae=0,Ue=Ve.length;Ae<Ue;Ae++)v.push(Ve[Ae])}return new Ca(R,A,v)}function G(M){return _(ut.clips[M],ae)}function pe(M){const v={};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"skin":v.id=o(C.getAttribute("source")),v.skin=Me(C);break;case"morph":v.id=o(C.getAttribute("source")),console.warn("THREE.ColladaLoader: Morph target animation not supported yet.");break}}ut.controllers[M.getAttribute("id")]=v}function Me(M){const v={sources:{}};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"bind_shape_matrix":v.bindShapeMatrix=r(C.textContent);break;case"source":const J=C.getAttribute("id");v.sources[J]=ye(C);break;case"joints":v.joints=le(C);break;case"vertex_weights":v.vertexWeights=we(C);break}}return v}function le(M){const v={inputs:{}};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"input":const J=C.getAttribute("semantic"),he=o(C.getAttribute("source"));v.inputs[J]=he;break}}return v}function we(M){const v={inputs:{}};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"input":const J=C.getAttribute("semantic"),he=o(C.getAttribute("source")),Ve=parseInt(C.getAttribute("offset"));v.inputs[J]={id:he,offset:Ve};break;case"vcount":v.vcount=a(C.textContent);break;case"v":v.v=a(C.textContent);break}}return v}function be(M){const v={id:M.id},R=ut.geometries[v.id];return M.skin!==void 0&&(v.skin=W(M.skin),R.sources.skinIndices=v.skin.indices,R.sources.skinWeights=v.skin.weights),v}function W(M){const R={joints:[],indices:{array:[],stride:4},weights:{array:[],stride:4}},A=M.sources,C=M.vertexWeights,J=C.vcount,he=C.v,Ve=C.inputs.JOINT.offset,Ae=C.inputs.WEIGHT.offset,Ue=M.sources[M.joints.inputs.JOINT],$e=M.sources[M.joints.inputs.INV_BIND_MATRIX],xe=A[C.inputs.WEIGHT.id].array;let Ze=0,je,rt,et;for(je=0,et=J.length;je<et;je++){const Dt=J[je],Rt=[];for(rt=0;rt<Dt;rt++){const Ct=he[Ze+Ve],di=he[Ze+Ae],wn=xe[di];Rt.push({index:Ct,weight:wn}),Ze+=2}for(Rt.sort(Wt),rt=0;rt<4;rt++){const Ct=Rt[rt];Ct!==void 0?(R.indices.array.push(Ct.index),R.weights.array.push(Ct.weight)):(R.indices.array.push(0),R.weights.array.push(0))}}for(M.bindShapeMatrix?R.bindMatrix=new Fe().fromArray(M.bindShapeMatrix).transpose():R.bindMatrix=new Fe().identity(),je=0,et=Ue.array.length;je<et;je++){const Dt=Ue.array[je],Rt=new Fe().fromArray($e.array,je*$e.stride).transpose();R.joints.push({name:Dt,boneInverse:Rt})}return R;function Wt(Dt,Rt){return Rt.weight-Dt.weight}}function $(M){return _(ut.controllers[M],be)}function re(M){const v={init_from:n(M,"init_from")[0].textContent};ut.images[M.getAttribute("id")]=v}function oe(M){return M.build!==void 0?M.build:M.init_from}function Te(M){const v=ut.images[M];return v!==void 0?_(v,oe):(console.warn("THREE.ColladaLoader: Couldn't find image with ID:",M),null)}function ne(M){const v={};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"profile_COMMON":v.profile=me(C);break}}ut.effects[M.getAttribute("id")]=v}function me(M){const v={surfaces:{},samplers:{}};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"newparam":Q(C,v);break;case"technique":v.technique=I(C);break;case"extra":v.extra=ke(C);break}}return v}function Q(M,v){const R=M.getAttribute("sid");for(let A=0,C=M.childNodes.length;A<C;A++){const J=M.childNodes[A];if(J.nodeType===1)switch(J.nodeName){case"surface":v.surfaces[R]=ee(J);break;case"sampler2D":v.samplers[R]=te(J);break}}}function ee(M){const v={};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"init_from":v.init_from=C.textContent;break}}return v}function te(M){const v={};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"source":v.source=C.textContent;break}}return v}function I(M){const v={};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"constant":case"lambert":case"blinn":case"phong":v.type=C.nodeName,v.parameters=ge(C);break;case"extra":v.extra=ke(C);break}}return v}function ge(M){const v={};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"emission":case"diffuse":case"specular":case"bump":case"ambient":case"shininess":case"transparency":v[C.nodeName]=Ne(C);break;case"transparent":v[C.nodeName]={opaque:C.hasAttribute("opaque")?C.getAttribute("opaque"):"A_ONE",data:Ne(C)};break}}return v}function Ne(M){const v={};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"color":v[C.nodeName]=r(C.textContent);break;case"float":v[C.nodeName]=parseFloat(C.textContent);break;case"texture":v[C.nodeName]={id:C.getAttribute("texture"),extra:dt(C)};break}}return v}function dt(M){const v={technique:{}};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"extra":ve(C,v);break}}return v}function ve(M,v){for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"technique":nt(C,v);break}}}function nt(M,v){for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"repeatU":case"repeatV":case"offsetU":case"offsetV":v.technique[C.nodeName]=parseFloat(C.textContent);break;case"wrapU":case"wrapV":C.textContent.toUpperCase()==="TRUE"?v.technique[C.nodeName]=1:C.textContent.toUpperCase()==="FALSE"?v.technique[C.nodeName]=0:v.technique[C.nodeName]=parseInt(C.textContent);break;case"bump":v[C.nodeName]=Nt(C);break}}}function ke(M){const v={};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"technique":v.technique=ht(C);break}}return v}function ht(M){const v={};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"double_sided":v[C.nodeName]=parseInt(C.textContent);break;case"bump":v[C.nodeName]=Nt(C);break}}return v}function Nt(M){const v={};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"texture":v[C.nodeName]={id:C.getAttribute("texture"),texcoord:C.getAttribute("texcoord"),extra:dt(C)};break}}return v}function F(M){return M}function b(M){return _(ut.effects[M],F)}function q(M){const v={name:M.getAttribute("name")};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"instance_effect":v.url=o(C.getAttribute("url"));break}}ut.materials[M.getAttribute("id")]=v}function ue(M){let v,R=M.slice((M.lastIndexOf(".")-1>>>0)+2);switch(R=R.toLowerCase(),R){case"tga":v=fn;break;default:v=yn}return v}function fe(M){const v=b(M.url),R=v.profile.technique;let A;switch(R.type){case"phong":case"blinn":A=new as;break;case"lambert":A=new yh;break;default:A=new Ti;break}A.name=M.name||"";function C(Ae,Ue=null){const $e=v.profile.samplers[Ae.id];let xe=null;if($e!==void 0){const Ze=v.profile.surfaces[$e.source];xe=Te(Ze.init_from)}else console.warn("THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530)."),xe=Te(Ae.id);if(xe!==null){const Ze=ue(xe);if(Ze!==void 0){const je=Ze.load(xe),rt=Ae.extra;if(rt!==void 0&&rt.technique!==void 0&&c(rt.technique)===!1){const et=rt.technique;je.wrapS=et.wrapU?Vn:Pn,je.wrapT=et.wrapV?Vn:Pn,je.offset.set(et.offsetU||0,et.offsetV||0),je.repeat.set(et.repeatU||1,et.repeatV||1)}else je.wrapS=Vn,je.wrapT=Vn;return Ue!==null&&(je.colorSpace=Ue),je}else return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",xe),null}else return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",Ae.id),null}const J=R.parameters;for(const Ae in J){const Ue=J[Ae];switch(Ae){case"diffuse":Ue.color&&A.color.fromArray(Ue.color),Ue.texture&&(A.map=C(Ue.texture,_t));break;case"specular":Ue.color&&A.specular&&A.specular.fromArray(Ue.color),Ue.texture&&(A.specularMap=C(Ue.texture));break;case"bump":Ue.texture&&(A.normalMap=C(Ue.texture));break;case"ambient":Ue.texture&&(A.lightMap=C(Ue.texture,_t));break;case"shininess":Ue.float&&A.shininess&&(A.shininess=Ue.float);break;case"emission":Ue.color&&A.emissive&&A.emissive.fromArray(Ue.color),Ue.texture&&(A.emissiveMap=C(Ue.texture,_t));break}}pt.colorSpaceToWorking(A.color,_t),A.specular&&pt.colorSpaceToWorking(A.specular,_t),A.emissive&&pt.colorSpaceToWorking(A.emissive,_t);let he=J.transparent,Ve=J.transparency;if(Ve===void 0&&he&&(Ve={float:1}),he===void 0&&Ve&&(he={opaque:"A_ONE",data:{color:[1,1,1,1]}}),he&&Ve)if(he.data.texture)A.transparent=!0;else{const Ae=he.data.color;switch(he.opaque){case"A_ONE":A.opacity=Ae[3]*Ve.float;break;case"RGB_ZERO":A.opacity=1-Ae[0]*Ve.float;break;case"A_ZERO":A.opacity=1-Ae[3]*Ve.float;break;case"RGB_ONE":A.opacity=Ae[0]*Ve.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',he.opaque)}A.opacity<1&&(A.transparent=!0)}if(R.extra!==void 0&&R.extra.technique!==void 0){const Ae=R.extra.technique;for(const Ue in Ae){const $e=Ae[Ue];switch(Ue){case"double_sided":A.side=$e===1?Yn:si;break;case"bump":A.normalMap=C($e.texture),A.normalScale=new ot(1,1);break}}}return A}function ie(M){return _(ut.materials[M],fe)}function Ke(M){const v={name:M.getAttribute("name")};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"optics":v.optics=Re(C);break}}ut.cameras[M.getAttribute("id")]=v}function Re(M){for(let v=0;v<M.childNodes.length;v++){const R=M.childNodes[v];switch(R.nodeName){case"technique_common":return Ge(R)}}return{}}function Ge(M){const v={};for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];switch(A.nodeName){case"perspective":case"orthographic":v.technique=A.nodeName,v.parameters=Ye(A);break}}return v}function Ye(M){const v={};for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];switch(A.nodeName){case"xfov":case"yfov":case"xmag":case"ymag":case"znear":case"zfar":case"aspect_ratio":v[A.nodeName]=parseFloat(A.textContent);break}}return v}function _e(M){let v;switch(M.optics.technique){case"perspective":v=new cn(M.optics.parameters.yfov,M.optics.parameters.aspect_ratio,M.optics.parameters.znear,M.optics.parameters.zfar);break;case"orthographic":let R=M.optics.parameters.ymag,A=M.optics.parameters.xmag;const C=M.optics.parameters.aspect_ratio;A=A===void 0?R*C:A,R=R===void 0?A/C:R,A*=.5,R*=.5,v=new Oa(-A,A,R,-R,M.optics.parameters.znear,M.optics.parameters.zfar);break;default:v=new cn;break}return v.name=M.name||"",v}function Oe(M){const v=ut.cameras[M];return v!==void 0?_(v,_e):(console.warn("THREE.ColladaLoader: Couldn't find camera with ID:",M),null)}function it(M){let v={};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"technique_common":v=Qe(C);break}}ut.lights[M.getAttribute("id")]=v}function Qe(M){const v={};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"directional":case"point":case"spot":case"ambient":v.technique=C.nodeName,v.parameters=Ee(C)}}return v}function Ee(M){const v={};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"color":const J=r(C.textContent);v.color=new He().fromArray(J),pt.colorSpaceToWorking(v.color,_t);break;case"falloff_angle":v.falloffAngle=parseFloat(C.textContent);break;case"quadratic_attenuation":const he=parseFloat(C.textContent);v.distance=he?Math.sqrt(1/he):0;break}}return v}function at(M){let v;switch(M.technique){case"directional":v=new Er;break;case"point":v=new Pa;break;case"spot":v=new ql;break;case"ambient":v=new Kl;break}return M.parameters.color&&v.color.copy(M.parameters.color),M.parameters.distance&&(v.distance=M.parameters.distance),v}function B(M){const v=ut.lights[M];return v!==void 0?_(v,at):(console.warn("THREE.ColladaLoader: Couldn't find light with ID:",M),null)}function Pe(M){const v={name:M.getAttribute("name"),sources:{},vertices:{},primitives:[]},R=n(M,"mesh")[0];if(R!==void 0){for(let A=0;A<R.childNodes.length;A++){const C=R.childNodes[A];if(C.nodeType!==1)continue;const J=C.getAttribute("id");switch(C.nodeName){case"source":v.sources[J]=ye(C);break;case"vertices":v.vertices=Be(C);break;case"polygons":console.warn("THREE.ColladaLoader: Unsupported primitive type: ",C.nodeName);break;case"lines":case"linestrips":case"polylist":case"triangles":v.primitives.push(Y(C));break;default:console.log(C)}}ut.geometries[M.getAttribute("id")]=v}}function ye(M){const v={array:[],stride:3};for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];if(A.nodeType===1)switch(A.nodeName){case"float_array":v.array=r(A.textContent);break;case"Name_array":v.array=i(A.textContent);break;case"technique_common":const C=n(A,"accessor")[0];C!==void 0&&(v.stride=parseInt(C.getAttribute("stride")));break}}return v}function Be(M){const v={};for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];A.nodeType===1&&(v[A.getAttribute("semantic")]=o(A.getAttribute("source")))}return v}function Y(M){const v={type:M.nodeName,material:M.getAttribute("material"),count:parseInt(M.getAttribute("count")),inputs:{},stride:0,hasUV:!1};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"input":const J=o(C.getAttribute("source")),he=C.getAttribute("semantic"),Ve=parseInt(C.getAttribute("offset")),Ae=parseInt(C.getAttribute("set")),Ue=Ae>0?he+Ae:he;v.inputs[Ue]={id:J,offset:Ve},v.stride=Math.max(v.stride,Ve+1),he==="TEXCOORD"&&(v.hasUV=!0);break;case"vcount":v.vcount=a(C.textContent);break;case"p":v.p=a(C.textContent);break}}return v}function ce(M){const v={};for(let R=0;R<M.length;R++){const A=M[R];v[A.type]===void 0&&(v[A.type]=[]),v[A.type].push(A)}return v}function Ce(M){let v=0;for(let R=0,A=M.length;R<A;R++)M[R].hasUV===!0&&v++;v>0&&v<M.length&&(M.uvsNeedsFix=!0)}function tt(M){const v={},R=M.sources,A=M.vertices,C=M.primitives;if(C.length===0)return{};const J=ce(C);for(const he in J){const Ve=J[he];Ce(Ve),v[he]=Lt(Ve,R,A)}return v}function Lt(M,v,R){const A={},C={array:[],stride:0},J={array:[],stride:0},he={array:[],stride:0},Ve={array:[],stride:0},Ae={array:[],stride:0},Ue={array:[],stride:4},$e={array:[],stride:4},xe=new Kt,Ze=[];let je=0;for(let rt=0;rt<M.length;rt++){const et=M[rt],Wt=et.inputs;let Dt=0;switch(et.type){case"lines":case"linestrips":Dt=et.count*2;break;case"triangles":Dt=et.count*3;break;case"polylist":for(let Rt=0;Rt<et.count;Rt++){const Ct=et.vcount[Rt];switch(Ct){case 3:Dt+=3;break;case 4:Dt+=6;break;default:Dt+=(Ct-2)*3;break}}break;default:console.warn("THREE.ColladaLoader: Unknown primitive type:",et.type)}xe.addGroup(je,Dt,rt),je+=Dt,et.material&&Ze.push(et.material);for(const Rt in Wt){const Ct=Wt[Rt];switch(Rt){case"VERTEX":for(const di in R){const wn=R[di];switch(di){case"POSITION":const ps=C.array.length;if(ft(et,v[wn],Ct.offset,C.array),C.stride=v[wn].stride,v.skinWeights&&v.skinIndices&&(ft(et,v.skinIndices,Ct.offset,Ue.array),ft(et,v.skinWeights,Ct.offset,$e.array)),et.hasUV===!1&&M.uvsNeedsFix===!0){const Kh=(C.array.length-ps)/C.stride;for(let Ql=0;Ql<Kh;Ql++)he.array.push(0,0)}break;case"NORMAL":ft(et,v[wn],Ct.offset,J.array),J.stride=v[wn].stride;break;case"COLOR":ft(et,v[wn],Ct.offset,Ae.array),Ae.stride=v[wn].stride;break;case"TEXCOORD":ft(et,v[wn],Ct.offset,he.array),he.stride=v[wn].stride;break;case"TEXCOORD1":ft(et,v[wn],Ct.offset,Ve.array),he.stride=v[wn].stride;break;default:console.warn('THREE.ColladaLoader: Semantic "%s" not handled in geometry build process.',di)}}break;case"NORMAL":ft(et,v[Ct.id],Ct.offset,J.array),J.stride=v[Ct.id].stride;break;case"COLOR":ft(et,v[Ct.id],Ct.offset,Ae.array,!0),Ae.stride=v[Ct.id].stride;break;case"TEXCOORD":ft(et,v[Ct.id],Ct.offset,he.array),he.stride=v[Ct.id].stride;break;case"TEXCOORD1":ft(et,v[Ct.id],Ct.offset,Ve.array),Ve.stride=v[Ct.id].stride;break}}}return C.array.length>0&&xe.setAttribute("position",new xt(C.array,C.stride)),J.array.length>0&&xe.setAttribute("normal",new xt(J.array,J.stride)),Ae.array.length>0&&xe.setAttribute("color",new xt(Ae.array,Ae.stride)),he.array.length>0&&xe.setAttribute("uv",new xt(he.array,he.stride)),Ve.array.length>0&&xe.setAttribute("uv1",new xt(Ve.array,Ve.stride)),Ue.array.length>0&&xe.setAttribute("skinIndex",new xt(Ue.array,Ue.stride)),$e.array.length>0&&xe.setAttribute("skinWeight",new xt($e.array,$e.stride)),A.data=xe,A.type=M[0].type,A.materialKeys=Ze,A}function ft(M,v,R,A,C=!1){const J=M.p,he=M.stride,Ve=M.vcount;function Ae(xe){let Ze=J[xe+R]*$e;const je=Ze+$e;for(;Ze<je;Ze++)A.push(Ue[Ze]);if(C){const rt=A.length-$e-1;Zt.setRGB(A[rt+0],A[rt+1],A[rt+2],_t),A[rt+0]=Zt.r,A[rt+1]=Zt.g,A[rt+2]=Zt.b}}const Ue=v.array,$e=v.stride;if(M.vcount!==void 0){let xe=0;for(let Ze=0,je=Ve.length;Ze<je;Ze++){const rt=Ve[Ze];if(rt===4){const et=xe+he*0,Wt=xe+he*1,Dt=xe+he*2,Rt=xe+he*3;Ae(et),Ae(Wt),Ae(Rt),Ae(Wt),Ae(Dt),Ae(Rt)}else if(rt===3){const et=xe+he*0,Wt=xe+he*1,Dt=xe+he*2;Ae(et),Ae(Wt),Ae(Dt)}else if(rt>4)for(let et=1,Wt=rt-2;et<=Wt;et++){const Dt=xe+he*0,Rt=xe+he*et,Ct=xe+he*(et+1);Ae(Dt),Ae(Rt),Ae(Ct)}xe+=he*rt}}else for(let xe=0,Ze=J.length;xe<Ze;xe+=he)Ae(xe)}function We(M){return _(ut.geometries[M],tt)}function Le(M){const v={name:M.getAttribute("name")||"",joints:{},links:[]};for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];if(A.nodeType===1)switch(A.nodeName){case"technique_common":Vt(A,v);break}}ut.kinematicsModels[M.getAttribute("id")]=v}function Yt(M){return M.build!==void 0?M.build:M}function Un(M){return _(ut.kinematicsModels[M],Yt)}function Vt(M,v){for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];if(A.nodeType===1)switch(A.nodeName){case"joint":v.joints[A.getAttribute("sid")]=hn(A);break;case"link":v.links.push(Ci(A));break}}}function hn(M){let v;for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];if(A.nodeType===1)switch(A.nodeName){case"prismatic":case"revolute":v=En(A);break}}return v}function En(M){const v={sid:M.getAttribute("sid"),name:M.getAttribute("name")||"",axis:new O,limits:{min:0,max:0},type:M.nodeName,static:!1,zeroPosition:0,middlePosition:0};for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];if(A.nodeType===1)switch(A.nodeName){case"axis":const C=r(A.textContent);v.axis.fromArray(C);break;case"limits":const J=A.getElementsByTagName("max")[0],he=A.getElementsByTagName("min")[0];v.limits.max=parseFloat(J.textContent),v.limits.min=parseFloat(he.textContent);break}}return v.limits.min>=v.limits.max&&(v.static=!0),v.middlePosition=(v.limits.min+v.limits.max)/2,v}function Ci(M){const v={sid:M.getAttribute("sid"),name:M.getAttribute("name")||"",attachments:[],transforms:[]};for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];if(A.nodeType===1)switch(A.nodeName){case"attachment_full":v.attachments.push(li(A));break;case"matrix":case"translate":case"rotate":v.transforms.push(Pi(A));break}}return v}function li(M){const v={joint:M.getAttribute("joint").split("/").pop(),transforms:[],links:[]};for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];if(A.nodeType===1)switch(A.nodeName){case"link":v.links.push(Ci(A));break;case"matrix":case"translate":case"rotate":v.transforms.push(Pi(A));break}}return v}function Pi(M){const v={type:M.nodeName},R=r(M.textContent);switch(v.type){case"matrix":v.obj=new Fe,v.obj.fromArray(R).transpose();break;case"translate":v.obj=new O,v.obj.fromArray(R);break;case"rotate":v.obj=new O,v.obj.fromArray(R),v.angle=jt.degToRad(R[3]);break}return v}function ci(M){const v={name:M.getAttribute("name")||"",rigidBodies:{}};for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];if(A.nodeType===1)switch(A.nodeName){case"rigid_body":v.rigidBodies[A.getAttribute("name")]={},ji(A,v.rigidBodies[A.getAttribute("name")]);break}}ut.physicsModels[M.getAttribute("id")]=v}function ji(M,v){for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];if(A.nodeType===1)switch(A.nodeName){case"technique_common":qi(A,v);break}}}function qi(M,v){for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];if(A.nodeType===1)switch(A.nodeName){case"inertia":v.inertia=r(A.textContent);break;case"mass":v.mass=r(A.textContent)[0];break}}}function Ki(M){const v={bindJointAxis:[]};for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];if(A.nodeType===1)switch(A.nodeName){case"bind_joint_axis":v.bindJointAxis.push(_n(A));break}}ut.kinematicsScenes[o(M.getAttribute("url"))]=v}function _n(M){const v={target:M.getAttribute("target").split("/").pop()};for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];if(A.nodeType===1)switch(A.nodeName){case"axis":const C=A.getElementsByTagName("param")[0];v.axis=C.textContent;const J=v.axis.split("inst_").pop().split("axis")[0];v.jointIndex=J.substring(0,J.length-1);break}}return v}function ui(M){return M.build!==void 0?M.build:M}function Ba(M){return _(ut.kinematicsScenes[M],ui)}function za(){const M=Object.keys(ut.kinematicsModels)[0],v=Object.keys(ut.kinematicsScenes)[0],R=Object.keys(ut.visualScenes)[0];if(M===void 0||v===void 0)return;const A=Un(M),C=Ba(v),J=bt(R),he=C.bindJointAxis,Ve={};for(let $e=0,xe=he.length;$e<xe;$e++){const Ze=he[$e],je=zt.querySelector('[sid="'+Ze.target+'"]');if(je){const rt=je.parentElement;Ae(Ze.jointIndex,rt)}}function Ae($e,xe){const Ze=xe.getAttribute("name"),je=A.joints[$e];J.traverse(function(rt){rt.name===Ze&&(Ve[$e]={object:rt,transforms:Va(xe),joint:je,position:je.zeroPosition})})}const Ue=new Fe;fs={joints:A&&A.joints,getJointValue:function($e){const xe=Ve[$e];if(xe)return xe.position;console.warn("THREE.ColladaLoader: Joint "+$e+" doesn't exist.")},setJointValue:function($e,xe){const Ze=Ve[$e];if(Ze){const je=Ze.joint;if(xe>je.limits.max||xe<je.limits.min)console.warn("THREE.ColladaLoader: Joint "+$e+" value "+xe+" outside of limits (min: "+je.limits.min+", max: "+je.limits.max+").");else if(je.static)console.warn("THREE.ColladaLoader: Joint "+$e+" is static.");else{const rt=Ze.object,et=je.axis,Wt=Ze.transforms;z.identity();for(let Dt=0;Dt<Wt.length;Dt++){const Rt=Wt[Dt];if(Rt.sid&&Rt.sid.indexOf($e)!==-1)switch(je.type){case"revolute":z.multiply(Ue.makeRotationAxis(et,jt.degToRad(xe)));break;case"prismatic":z.multiply(Ue.makeTranslation(et.x*xe,et.y*xe,et.z*xe));break;default:console.warn("THREE.ColladaLoader: Unknown joint type: "+je.type);break}else switch(Rt.type){case"matrix":z.multiply(Rt.obj);break;case"translate":z.multiply(Ue.makeTranslation(Rt.obj.x,Rt.obj.y,Rt.obj.z));break;case"scale":z.scale(Rt.obj);break;case"rotate":z.multiply(Ue.makeRotationAxis(Rt.obj,Rt.angle));break}}rt.matrix.copy(z),rt.matrix.decompose(rt.position,rt.quaternion,rt.scale),Ve[$e].position=xe}}else console.log("THREE.ColladaLoader: "+$e+" does not exist.")}}}function Va(M){const v=[],R=zt.querySelector('[id="'+M.id+'"]');for(let A=0;A<R.childNodes.length;A++){const C=R.childNodes[A];if(C.nodeType!==1)continue;let J,he;switch(C.nodeName){case"matrix":J=r(C.textContent);const Ve=new Fe().fromArray(J).transpose();v.push({sid:C.getAttribute("sid"),type:C.nodeName,obj:Ve});break;case"translate":case"scale":J=r(C.textContent),he=new O().fromArray(J),v.push({sid:C.getAttribute("sid"),type:C.nodeName,obj:he});break;case"rotate":J=r(C.textContent),he=new O().fromArray(J);const Ae=jt.degToRad(J[3]);v.push({sid:C.getAttribute("sid"),type:C.nodeName,obj:he,angle:Ae});break}}return v}function w(M){const v=M.getElementsByTagName("node");for(let R=0;R<v.length;R++){const A=v[R];A.hasAttribute("id")===!1&&A.setAttribute("id",l())}}const z=new Fe,K=new O;function Z(M){const v={name:M.getAttribute("name")||"",type:M.getAttribute("type"),id:M.getAttribute("id"),sid:M.getAttribute("sid"),matrix:new Fe,nodes:[],instanceCameras:[],instanceControllers:[],instanceLights:[],instanceGeometries:[],instanceNodes:[],transforms:{}};for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];if(A.nodeType!==1)continue;let C;switch(A.nodeName){case"node":v.nodes.push(A.getAttribute("id")),Z(A);break;case"instance_camera":v.instanceCameras.push(o(A.getAttribute("url")));break;case"instance_controller":v.instanceControllers.push(H(A));break;case"instance_light":v.instanceLights.push(o(A.getAttribute("url")));break;case"instance_geometry":v.instanceGeometries.push(H(A));break;case"instance_node":v.instanceNodes.push(o(A.getAttribute("url")));break;case"matrix":C=r(A.textContent),v.matrix.multiply(z.fromArray(C).transpose()),v.transforms[A.getAttribute("sid")]=A.nodeName;break;case"translate":C=r(A.textContent),K.fromArray(C),v.matrix.multiply(z.makeTranslation(K.x,K.y,K.z)),v.transforms[A.getAttribute("sid")]=A.nodeName;break;case"rotate":C=r(A.textContent);const J=jt.degToRad(C[3]);v.matrix.multiply(z.makeRotationAxis(K.fromArray(C),J)),v.transforms[A.getAttribute("sid")]=A.nodeName;break;case"scale":C=r(A.textContent),v.matrix.scale(K.fromArray(C)),v.transforms[A.getAttribute("sid")]=A.nodeName;break;case"extra":break;default:console.log(A)}}return Je(v.id)?console.warn("THREE.ColladaLoader: There is already a node with ID %s. Exclude current node from further processing.",v.id):ut.nodes[v.id]=v,v}function H(M){const v={id:o(M.getAttribute("url")),materials:{},skeletons:[]};for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];switch(A.nodeName){case"bind_material":const C=A.getElementsByTagName("instance_material");for(let J=0;J<C.length;J++){const he=C[J],Ve=he.getAttribute("symbol"),Ae=he.getAttribute("target");v.materials[Ve]=o(Ae)}break;case"skeleton":v.skeletons.push(o(A.textContent));break}}return v}function Se(M,v){const R=[],A=[];let C,J,he;for(C=0;C<M.length;C++){const Ue=M[C];let $e;if(Je(Ue))$e=mt(Ue),De($e,v,R);else if(Gt(Ue)){const Ze=ut.visualScenes[Ue].children;for(let je=0;je<Ze.length;je++){const rt=Ze[je];if(rt.type==="JOINT"){const et=mt(rt.id);De(et,v,R)}}}else console.error("THREE.ColladaLoader: Unable to find root bone of skeleton with ID:",Ue)}for(C=0;C<v.length;C++)for(J=0;J<R.length;J++)if(he=R[J],he.bone.name===v[C].name){A[C]=he,he.processed=!0;break}for(C=0;C<R.length;C++)he=R[C],he.processed===!1&&(A.push(he),he.processed=!0);const Ve=[],Ae=[];for(C=0;C<A.length;C++)he=A[C],Ve.push(he.bone),Ae.push(he.boneInverse);return new Pr(Ve,Ae)}function De(M,v,R){M.traverse(function(A){if(A.isBone===!0){let C;for(let J=0;J<v.length;J++){const he=v[J];if(he.name===A.name){C=he.boneInverse;break}}C===void 0&&(C=new Fe),R.push({bone:A,boneInverse:C,processed:!1})}})}function Xe(M){const v=[],R=M.matrix,A=M.nodes,C=M.type,J=M.instanceCameras,he=M.instanceControllers,Ve=M.instanceLights,Ae=M.instanceGeometries,Ue=M.instanceNodes;for(let xe=0,Ze=A.length;xe<Ze;xe++)v.push(mt(A[xe]));for(let xe=0,Ze=J.length;xe<Ze;xe++){const je=Oe(J[xe]);je!==null&&v.push(je.clone())}for(let xe=0,Ze=he.length;xe<Ze;xe++){const je=he[xe],rt=$(je.id),et=We(rt.id),Wt=ct(et,je.materials),Dt=je.skeletons,Rt=rt.skin.joints,Ct=Se(Dt,Rt);for(let di=0,wn=Wt.length;di<wn;di++){const ps=Wt[di];ps.isSkinnedMesh&&(ps.bind(Ct,rt.skin.bindMatrix),ps.normalizeSkinWeights()),v.push(ps)}}for(let xe=0,Ze=Ve.length;xe<Ze;xe++){const je=B(Ve[xe]);je!==null&&v.push(je.clone())}for(let xe=0,Ze=Ae.length;xe<Ze;xe++){const je=Ae[xe],rt=We(je.id),et=ct(rt,je.materials);for(let Wt=0,Dt=et.length;Wt<Dt;Wt++)v.push(et[Wt])}for(let xe=0,Ze=Ue.length;xe<Ze;xe++)v.push(mt(Ue[xe]).clone());let $e;if(A.length===0&&v.length===1)$e=v[0];else{$e=C==="JOINT"?new vr:new Gn;for(let xe=0;xe<v.length;xe++)$e.add(v[xe])}return $e.name=C==="JOINT"?M.sid:M.name,$e.matrix.copy(R),$e.matrix.decompose($e.position,$e.quaternion,$e.scale),$e}const ze=new Ti({name:bn.DEFAULT_MATERIAL_NAME,color:16711935});function lt(M,v){const R=[];for(let A=0,C=M.length;A<C;A++){const J=v[M[A]];J===void 0?(console.warn("THREE.ColladaLoader: Material with key %s not found. Apply fallback material.",M[A]),R.push(ze)):R.push(ie(J))}return R}function ct(M,v){const R=[];for(const A in M){const C=M[A],J=lt(C.materialKeys,v);if(J.length===0&&(A==="lines"||A==="linestrips"?J.push(new ii):J.push(new as)),A==="lines"||A==="linestrips")for(let Ue=0,$e=J.length;Ue<$e;Ue++){const xe=J[Ue];if(xe.isMeshPhongMaterial===!0||xe.isMeshLambertMaterial===!0){const Ze=new ii;Ze.color.copy(xe.color),Ze.opacity=xe.opacity,Ze.transparent=xe.transparent,J[Ue]=Ze}}const he=C.data.attributes.skinIndex!==void 0,Ve=J.length===1?J[0]:J;let Ae;switch(A){case"lines":Ae=new Xs(C.data,Ve);break;case"linestrips":Ae=new Lr(C.data,Ve);break;case"triangles":case"polylist":he?Ae=new Vl(C.data,Ve):Ae=new sn(C.data,Ve);break}R.push(Ae)}return R}function Je(M){return ut.nodes[M]!==void 0}function mt(M){return _(ut.nodes[M],Xe)}function Pt(M){const v={name:M.getAttribute("name"),children:[]};w(M);const R=n(M,"node");for(let A=0;A<R.length;A++)v.children.push(Z(R[A]));ut.visualScenes[M.getAttribute("id")]=v}function Bt(M){const v=new Gn;v.name=M.name;const R=M.children;for(let A=0;A<R.length;A++){const C=R[A];v.add(mt(C.id))}return v}function Gt(M){return ut.visualScenes[M]!==void 0}function bt(M){return _(ut.visualScenes[M],Bt)}function st(M){const v=n(M,"instance_visual_scene")[0];return bt(o(v.getAttribute("url")))}function Jt(){const M=ut.clips;if(c(M)===!0){if(c(ut.animations)===!1){const v=[];for(const R in ut.animations){const A=y(R);for(let C=0,J=A.length;C<J;C++)v.push(A[C])}Qt.push(new Ca("default",-1,v))}}else for(const v in M)Qt.push(G(v))}function wt(M){let v="";const R=[M];for(;R.length;){const A=R.shift();A.nodeType===Node.TEXT_NODE?v+=A.textContent:(v+=`
3837
- `,R.push(...A.childNodes))}return v.trim()}if(e.length===0)return{scene:new dh};const An=new DOMParser().parseFromString(e,"application/xml"),zt=n(An,"COLLADA")[0],dn=An.getElementsByTagName("parsererror")[0];if(dn!==void 0){const M=n(dn,"div")[0];let v;return M?v=M.textContent:v=wt(dn),console.error(`THREE.ColladaLoader: Failed to parse collada file.
3838
- `,v),null}const Yi=zt.getAttribute("version");console.debug("THREE.ColladaLoader: File version",Yi);const Ot=u(n(zt,"asset")[0]),yn=new Xl(this.manager);yn.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);let fn;Fu&&(fn=new Fu(this.manager),fn.setPath(this.resourcePath||t));const Zt=new He,Qt=[];let fs={},hi=0;const ut={animations:{},clips:{},controllers:{},images:{},effects:{},materials:{},cameras:{},lights:{},geometries:{},nodes:{},visualScenes:{},kinematicsModels:{},physicsModels:{},kinematicsScenes:{}};f(zt,"library_animations","animation",m),f(zt,"library_animation_clips","animation_clip",k),f(zt,"library_controllers","controller",pe),f(zt,"library_images","image",re),f(zt,"library_effects","effect",ne),f(zt,"library_materials","material",q),f(zt,"library_cameras","camera",Ke),f(zt,"library_lights","light",it),f(zt,"library_geometries","geometry",Pe),f(zt,"library_nodes","node",Z),f(zt,"library_visual_scenes","visual_scene",Pt),f(zt,"library_kinematics_models","kinematics_model",Le),f(zt,"library_physics_models","physics_model",ci),f(zt,"scene","instance_kinematics_scene",Ki),g(ut.animations,x),g(ut.clips,ae),g(ut.controllers,be),g(ut.images,oe),g(ut.effects,F),g(ut.materials,fe),g(ut.cameras,_e),g(ut.lights,at),g(ut.geometries,tt),g(ut.visualScenes,Bt),Jt(),za();const Nr=st(n(zt,"scene")[0]);return Nr.animations=Qt,Ot.upAxis==="Z_UP"&&(console.warn("THREE.ColladaLoader: You are loading an asset with a Z-UP coordinate system. The loader just rotates the asset to transform it into Y-UP. The vertex data are not converted, see #24289."),Nr.rotation.set(-Math.PI/2,0,0)),Nr.scale.multiplyScalar(Ot.unit),{get animations(){return console.warn("THREE.ColladaLoader: Please access animations over scene.animations now."),Qt},kinematics:fs,library:ut,scene:Nr}}}const Rn=new He;class Ev extends bn{constructor(e){super(e),this.propertyNameMapping={},this.customPropertyMapping={}}load(e,t,n,i){const r=this,a=new Xi(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(r.parse(o))}catch(l){i?i(l):console.error(l),r.manager.itemError(e)}},n,i)}setPropertyNameMapping(e){this.propertyNameMapping=e}setCustomPropertyNameMapping(e){this.customPropertyMapping=e}parse(e){function t(m,p=0){const S=/^ply([\s\S]*)end_header(\r\n|\r|\n)/;let x="";const y=S.exec(m);y!==null&&(x=y[1]);const N={comments:[],elements:[],headerLength:p,objInfo:""},P=x.split(/\r\n|\r|\n/);let L;function U(E,T){const D={type:E[0]};return D.type==="list"?(D.name=E[3],D.countType=E[1],D.itemType=E[2]):D.name=E[1],D.name in T&&(D.name=T[D.name]),D}for(let E=0;E<P.length;E++){let T=P[E];if(T=T.trim(),T==="")continue;const D=T.split(/\s+/),X=D.shift();switch(T=D.join(" "),X){case"format":N.format=D[0],N.version=D[1];break;case"comment":N.comments.push(T);break;case"element":L!==void 0&&N.elements.push(L),L={},L.name=D[0],L.count=parseInt(D[1]),L.properties=[];break;case"property":L.properties.push(U(D,_.propertyNameMapping));break;case"obj_info":N.objInfo=T;break;default:console.log("unhandled",X,D)}}return L!==void 0&&N.elements.push(L),N}function n(m,p){switch(p){case"char":case"uchar":case"short":case"ushort":case"int":case"uint":case"int8":case"uint8":case"int16":case"uint16":case"int32":case"uint32":return parseInt(m);case"float":case"double":case"float32":case"float64":return parseFloat(m)}}function i(m,p){const S={};for(let x=0;x<m.length;x++){if(p.empty())return null;if(m[x].type==="list"){const y=[],N=n(p.next(),m[x].countType);for(let P=0;P<N;P++){if(p.empty())return null;y.push(n(p.next(),m[x].itemType))}S[m[x].name]=y}else S[m[x].name]=n(p.next(),m[x].type)}return S}function r(){const m={indices:[],vertices:[],normals:[],uvs:[],faceVertexUvs:[],colors:[],faceVertexColors:[]};for(const p of Object.keys(_.customPropertyMapping))m[p]=[];return m}function a(m){const p=m.map(x=>x.name);function S(x){for(let y=0,N=x.length;y<N;y++){const P=x[y];if(p.includes(P))return P}return null}return{attrX:S(["x","px","posx"])||"x",attrY:S(["y","py","posy"])||"y",attrZ:S(["z","pz","posz"])||"z",attrNX:S(["nx","normalx"]),attrNY:S(["ny","normaly"]),attrNZ:S(["nz","normalz"]),attrS:S(["s","u","texture_u","tx"]),attrT:S(["t","v","texture_v","ty"]),attrR:S(["red","diffuse_red","r","diffuse_r"]),attrG:S(["green","diffuse_green","g","diffuse_g"]),attrB:S(["blue","diffuse_blue","b","diffuse_b"])}}function o(m,p){const S=r(),x=/end_header\s+(\S[\s\S]*\S|\S)\s*$/;let y,N;(N=x.exec(m))!==null?y=N[1].split(/\s+/):y=[];const P=new Av(y);e:for(let L=0;L<p.elements.length;L++){const U=p.elements[L],E=a(U.properties);for(let T=0;T<U.count;T++){const D=i(U.properties,P);if(!D)break e;c(S,U.name,D,E)}}return l(S)}function l(m){let p=new Kt;m.indices.length>0&&p.setIndex(m.indices),p.setAttribute("position",new xt(m.vertices,3)),m.normals.length>0&&p.setAttribute("normal",new xt(m.normals,3)),m.uvs.length>0&&p.setAttribute("uv",new xt(m.uvs,2)),m.colors.length>0&&p.setAttribute("color",new xt(m.colors,3)),(m.faceVertexUvs.length>0||m.faceVertexColors.length>0)&&(p=p.toNonIndexed(),m.faceVertexUvs.length>0&&p.setAttribute("uv",new xt(m.faceVertexUvs,2)),m.faceVertexColors.length>0&&p.setAttribute("color",new xt(m.faceVertexColors,3)));for(const S of Object.keys(_.customPropertyMapping))m[S].length>0&&p.setAttribute(S,new xt(m[S],_.customPropertyMapping[S].length));return p.computeBoundingSphere(),p}function c(m,p,S,x){if(p==="vertex"){m.vertices.push(S[x.attrX],S[x.attrY],S[x.attrZ]),x.attrNX!==null&&x.attrNY!==null&&x.attrNZ!==null&&m.normals.push(S[x.attrNX],S[x.attrNY],S[x.attrNZ]),x.attrS!==null&&x.attrT!==null&&m.uvs.push(S[x.attrS],S[x.attrT]),x.attrR!==null&&x.attrG!==null&&x.attrB!==null&&(Rn.setRGB(S[x.attrR]/255,S[x.attrG]/255,S[x.attrB]/255,_t),m.colors.push(Rn.r,Rn.g,Rn.b));for(const y of Object.keys(_.customPropertyMapping))for(const N of _.customPropertyMapping[y])m[y].push(S[N])}else if(p==="face"){const y=S.vertex_indices||S.vertex_index,N=S.texcoord;y.length===3?(m.indices.push(y[0],y[1],y[2]),N&&N.length===6&&(m.faceVertexUvs.push(N[0],N[1]),m.faceVertexUvs.push(N[2],N[3]),m.faceVertexUvs.push(N[4],N[5]))):y.length===4&&(m.indices.push(y[0],y[1],y[3]),m.indices.push(y[1],y[2],y[3])),x.attrR!==null&&x.attrG!==null&&x.attrB!==null&&(Rn.setRGB(S[x.attrR]/255,S[x.attrG]/255,S[x.attrB]/255,_t),m.faceVertexColors.push(Rn.r,Rn.g,Rn.b),m.faceVertexColors.push(Rn.r,Rn.g,Rn.b),m.faceVertexColors.push(Rn.r,Rn.g,Rn.b))}}function u(m,p){const S={};let x=0;for(let y=0;y<p.length;y++){const N=p[y],P=N.valueReader;if(N.type==="list"){const L=[],U=N.countReader.read(m+x);x+=N.countReader.size;for(let E=0;E<U;E++)L.push(P.read(m+x)),x+=P.size;S[N.name]=L}else S[N.name]=P.read(m+x),x+=P.size}return[S,x]}function h(m,p,S){function x(y,N,P){switch(N){case"int8":case"char":return{read:L=>y.getInt8(L),size:1};case"uint8":case"uchar":return{read:L=>y.getUint8(L),size:1};case"int16":case"short":return{read:L=>y.getInt16(L,P),size:2};case"uint16":case"ushort":return{read:L=>y.getUint16(L,P),size:2};case"int32":case"int":return{read:L=>y.getInt32(L,P),size:4};case"uint32":case"uint":return{read:L=>y.getUint32(L,P),size:4};case"float32":case"float":return{read:L=>y.getFloat32(L,P),size:4};case"float64":case"double":return{read:L=>y.getFloat64(L,P),size:8}}}for(let y=0,N=m.length;y<N;y++){const P=m[y];P.type==="list"?(P.countReader=x(p,P.countType,S),P.valueReader=x(p,P.itemType,S)):P.valueReader=x(p,P.type,S)}}function d(m,p){const S=r(),x=p.format==="binary_little_endian",y=new DataView(m,p.headerLength);let N,P=0;for(let L=0;L<p.elements.length;L++){const U=p.elements[L],E=U.properties,T=a(E);h(E,y,x);for(let D=0;D<U.count;D++){N=u(P,E),P+=N[1];const X=N[0];c(S,U.name,X,T)}}return l(S)}function f(m){let p=0,S=!0,x="";const y=[],N=new TextDecoder().decode(m.subarray(0,5)),P=/^ply\r\n/.test(N);do{const L=String.fromCharCode(m[p++]);L!==`
3839
- `&&L!=="\r"?x+=L:(x==="end_header"&&(S=!1),x!==""&&(y.push(x),x=""))}while(S&&p<m.length);return P===!0&&p++,{headerText:y.join("\r")+"\r",headerLength:p}}let g;const _=this;if(e instanceof ArrayBuffer){const m=new Uint8Array(e),{headerText:p,headerLength:S}=f(m),x=t(p,S);if(x.format==="ascii"){const y=new TextDecoder().decode(m);g=o(y,x)}else g=d(e,x)}else g=o(e,t(e));return g}}class Av{constructor(e){this.arr=e,this.i=0}empty(){return this.i>=this.arr.length}next(){return this.arr[this.i++]}}class wv extends bn{constructor(e){super(e)}load(e,t,n,i){const r=this,a=new Xi(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(r.parse(o))}catch(l){i?i(l):console.error(l),r.manager.itemError(e)}},n,i)}parse(e){function t(c){const u=new DataView(c),h=32/8*3+32/8*3*3+16/8,d=u.getUint32(80,!0);if(80+32/8+d*h===u.byteLength)return!0;const g=[115,111,108,105,100];for(let _=0;_<5;_++)if(n(g,u,_))return!1;return!0}function n(c,u,h){for(let d=0,f=c.length;d<f;d++)if(c[d]!==u.getUint8(h+d))return!1;return!0}function i(c){const u=new DataView(c),h=u.getUint32(80,!0);let d,f,g,_=!1,m,p,S,x,y;for(let D=0;D<70;D++)u.getUint32(D,!1)==1129270351&&u.getUint8(D+4)==82&&u.getUint8(D+5)==61&&(_=!0,m=new Float32Array(h*3*3),p=u.getUint8(D+6)/255,S=u.getUint8(D+7)/255,x=u.getUint8(D+8)/255,y=u.getUint8(D+9)/255);const N=84,P=12*4+2,L=new Kt,U=new Float32Array(h*3*3),E=new Float32Array(h*3*3),T=new He;for(let D=0;D<h;D++){const X=N+D*P,j=u.getFloat32(X,!0),se=u.getFloat32(X+4,!0),de=u.getFloat32(X+8,!0);if(_){const k=u.getUint16(X+48,!0);(k&32768)===0?(d=(k&31)/31,f=(k>>5&31)/31,g=(k>>10&31)/31):(d=p,f=S,g=x)}for(let k=1;k<=3;k++){const ae=X+k*12,G=D*3*3+(k-1)*3;U[G]=u.getFloat32(ae,!0),U[G+1]=u.getFloat32(ae+4,!0),U[G+2]=u.getFloat32(ae+8,!0),E[G]=j,E[G+1]=se,E[G+2]=de,_&&(T.setRGB(d,f,g,_t),m[G]=T.r,m[G+1]=T.g,m[G+2]=T.b)}}return L.setAttribute("position",new un(U,3)),L.setAttribute("normal",new un(E,3)),_&&(L.setAttribute("color",new un(m,3)),L.hasColors=!0,L.alpha=y),L}function r(c){const u=new Kt,h=/solid([\s\S]*?)endsolid/g,d=/facet([\s\S]*?)endfacet/g,f=/solid\s(.+)/;let g=0;const _=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,m=new RegExp("vertex"+_+_+_,"g"),p=new RegExp("normal"+_+_+_,"g"),S=[],x=[],y=[],N=new O;let P,L=0,U=0,E=0;for(;(P=h.exec(c))!==null;){U=E;const T=P[0],D=(P=f.exec(T))!==null?P[1]:"";for(y.push(D);(P=d.exec(T))!==null;){let se=0,de=0;const k=P[0];for(;(P=p.exec(k))!==null;)N.x=parseFloat(P[1]),N.y=parseFloat(P[2]),N.z=parseFloat(P[3]),de++;for(;(P=m.exec(k))!==null;)S.push(parseFloat(P[1]),parseFloat(P[2]),parseFloat(P[3])),x.push(N.x,N.y,N.z),se++,E++;de!==1&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+g),se!==3&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+g),g++}const X=U,j=E-U;u.userData.groupNames=y,u.addGroup(X,j,L),L++}return u.setAttribute("position",new xt(S,3)),u.setAttribute("normal",new xt(x,3)),u}function a(c){return typeof c!="string"?new TextDecoder().decode(c):c}function o(c){if(typeof c=="string"){const u=new Uint8Array(c.length);for(let h=0;h<c.length;h++)u[h]=c.charCodeAt(h)&255;return u.buffer||u}else return c}const l=o(e);return t(l)?i(l):r(a(e))}}const Ou={type:"change"},Jl={type:"start"},kh={type:"end"},fa=new Rr,ku=new Bi,Rv=Math.cos(70*jt.DEG2RAD),en=new O,Cn=2*Math.PI,Ft={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Io=1e-6;class Cv extends _m{constructor(e,t=null){super(e,t),this.state=Ft.NONE,this.target=new O,this.cursor=new O,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Us.ROTATE,MIDDLE:Us.DOLLY,RIGHT:Us.PAN},this.touches={ONE:Ls.ROTATE,TWO:Ls.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new O,this._lastQuaternion=new tn,this._lastTargetPosition=new O,this._quat=new tn().setFromUnitVectors(e.up,new O(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Qc,this._sphericalDelta=new Qc,this._scale=1,this._panOffset=new O,this._rotateStart=new ot,this._rotateEnd=new ot,this._rotateDelta=new ot,this._panStart=new ot,this._panEnd=new ot,this._panDelta=new ot,this._dollyStart=new ot,this._dollyEnd=new ot,this._dollyDelta=new ot,this._dollyDirection=new O,this._mouse=new ot,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Lv.bind(this),this._onPointerDown=Pv.bind(this),this._onPointerUp=Dv.bind(this),this._onContextMenu=Bv.bind(this),this._onMouseWheel=Uv.bind(this),this._onKeyDown=Fv.bind(this),this._onTouchStart=Ov.bind(this),this._onTouchMove=kv.bind(this),this._onMouseDown=Iv.bind(this),this._onMouseMove=Nv.bind(this),this._interceptControlDown=zv.bind(this),this._interceptControlUp=Vv.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(Ou),this.update(),this.state=Ft.NONE}update(e=null){const t=this.object.position;en.copy(t).sub(this.target),en.applyQuaternion(this._quat),this._spherical.setFromVector3(en),this.autoRotate&&this.state===Ft.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,i=this.maxAzimuthAngle;isFinite(n)&&isFinite(i)&&(n<-Math.PI?n+=Cn:n>Math.PI&&(n-=Cn),i<-Math.PI?i+=Cn:i>Math.PI&&(i-=Cn),n<=i?this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(en.setFromSpherical(this._spherical),en.applyQuaternion(this._quatInverse),t.copy(this.target).add(en),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=en.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const o=new O(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new O(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=en.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(fa.origin.copy(this.object.position),fa.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(fa.direction))<Rv?this.object.lookAt(this.target):(ku.setFromNormalAndCoplanarPoint(this.object.up,this.target),fa.intersectPlane(ku,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>Io||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Io||this._lastTargetPosition.distanceToSquared(this.target)>Io?(this.dispatchEvent(Ou),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Cn/60*this.autoRotateSpeed*e:Cn/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){en.setFromMatrixColumn(t,0),en.multiplyScalar(-e),this._panOffset.add(en)}_panUp(e,t){this.screenSpacePanning===!0?en.setFromMatrixColumn(t,1):(en.setFromMatrixColumn(t,0),en.crossVectors(this.object.up,en)),en.multiplyScalar(e),this._panOffset.add(en)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;en.copy(i).sub(this.target);let r=en.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/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(),i=e-n.left,r=t-n.top,a=n.width,o=n.height;this._mouse.x=i/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(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(Cn*this._rotateDelta.x/t.clientHeight),this._rotateUp(Cn*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(Cn*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(-Cn*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(Cn*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(-Cn*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),i=.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_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),i=.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_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),i=.5*(e.pageX+n.x),r=.5*(e.pageY+n.y);this._rotateEnd.set(i,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Cn*this._rotateDelta.x/t.clientHeight),this._rotateUp(Cn*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),i=.5*(e.pageY+t.y);this._panEnd.set(n,i)}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,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new ot,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 Pv(s){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(s.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(s)&&(this._addPointer(s),s.pointerType==="touch"?this._onTouchStart(s):this._onMouseDown(s)))}function Lv(s){this.enabled!==!1&&(s.pointerType==="touch"?this._onTouchMove(s):this._onMouseMove(s))}function Dv(s){switch(this._removePointer(s),this._pointers.length){case 0:this.domElement.releasePointerCapture(s.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(kh),this.state=Ft.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 Iv(s){let e;switch(s.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 Us.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(s),this.state=Ft.DOLLY;break;case Us.ROTATE:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=Ft.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=Ft.ROTATE}break;case Us.PAN:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=Ft.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=Ft.PAN}break;default:this.state=Ft.NONE}this.state!==Ft.NONE&&this.dispatchEvent(Jl)}function Nv(s){switch(this.state){case Ft.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(s);break;case Ft.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(s);break;case Ft.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(s);break}}function Uv(s){this.enabled===!1||this.enableZoom===!1||this.state!==Ft.NONE||(s.preventDefault(),this.dispatchEvent(Jl),this._handleMouseWheel(this._customWheelEvent(s)),this.dispatchEvent(kh))}function Fv(s){this.enabled!==!1&&this._handleKeyDown(s)}function Ov(s){switch(this._trackPointer(s),this._pointers.length){case 1:switch(this.touches.ONE){case Ls.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(s),this.state=Ft.TOUCH_ROTATE;break;case Ls.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(s),this.state=Ft.TOUCH_PAN;break;default:this.state=Ft.NONE}break;case 2:switch(this.touches.TWO){case Ls.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(s),this.state=Ft.TOUCH_DOLLY_PAN;break;case Ls.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(s),this.state=Ft.TOUCH_DOLLY_ROTATE;break;default:this.state=Ft.NONE}break;default:this.state=Ft.NONE}this.state!==Ft.NONE&&this.dispatchEvent(Jl)}function kv(s){switch(this._trackPointer(s),this.state){case Ft.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(s),this.update();break;case Ft.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(s),this.update();break;case Ft.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(s),this.update();break;case Ft.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(s),this.update();break;default:this.state=Ft.NONE}}function Bv(s){this.enabled!==!1&&s.preventDefault()}function zv(s){s.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Vv(s){s.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const Hv=Et.defineStore("threeJSComp",{state:()=>({scene:null,camera:null,renderer:null,controls:null,uploadedModels:[],loadedModels:[],selectedModels:[],showAxes:!0,showModelList:!1,isInitialized:!1,loadingQueue:[],isProcessingQueue:!1,axesHelper:null}),getters:{getAllLoadedModels:s=>s.uploadedModels.filter(e=>e.status==="loaded"),getSelectedModelsData:s=>s.selectedModels.map(e=>s.uploadedModels[e]).filter(Boolean)},actions:{forceRender(){this.renderer&&this.scene&&this.camera},setScene(s){this.scene=s},setCamera(s){this.camera=s},setRenderer(s){this.renderer=s},setControls(s){this.controls=s},setAxesHelper(s){this.axesHelper=s},setIsInitialized(s){this.isInitialized=s},addUploadedModel(s){s.id||(s.id=Date.now()+Math.random()),this.uploadedModels.push(s)},findModelIndexById(s){return this.uploadedModels.findIndex(e=>e.id===s)},getModelById(s){return this.uploadedModels.find(e=>e.id===s)},updateModelStatus(s,e){const t=this.getModelById(s);t&&(t.status=e)},updateModelObject(s,e){const t=this.getModelById(s);t&&(t.model=e,t.status="loaded",this.loadedModels.find(n=>n.id===s)||this.loadedModels.push(t))},removeUploadedModel(s){if(s<0||s>=this.uploadedModels.length)return console.error("无效的模型索引:",s),!1;const e=this.uploadedModels[s];e.model&&this.scene&&(this.scene.remove(e.model),this.disposeModel(e.model)),this.uploadedModels.splice(s,1);const t=this.loadedModels.findIndex(n=>n.id===e.id);return t!==-1&&this.loadedModels.splice(t,1),this.updateSelectedIndicesAfterRemoval(s),!0},removeModelById(s){const e=this.findModelIndexById(s);return e!==-1?this.removeUploadedModel(e):!1},removeSelectedModels(){if(this.selectedModels.length===0)return;[...this.selectedModels].sort((e,t)=>t-e).forEach(e=>{this.removeUploadedModel(e)}),this.selectedModels=[],this.forceRender()},updateSelectedIndicesAfterRemoval(s){this.selectedModels=this.selectedModels.filter(e=>e!==s).map(e=>e>s?e-1:e)},toggleModelVisibility(s){const e=this.uploadedModels[s];e&&e.model&&(e.visible=!e.visible,e.model.visible=e.visible,this.forceRender())},clearAllModels(){if(!this.scene){console.error("场景未初始化,无法清空模型");return}this.uploadedModels.forEach(s=>{s.model&&s.status==="loaded"&&(this.scene.remove(s.model),this.disposeModel(s.model))}),this.uploadedModels=[],this.loadedModels=[],this.selectedModels=[],this.forceRender()},disposeModel(s){if(s){if(s.children)for(let e=s.children.length-1;e>=0;e--)this.disposeModel(s.children[e]);if(s.geometry&&s.geometry.dispose(),s.material){const e=s.material;Array.isArray(e)?e.forEach(t=>{this.disposeMaterial(t)}):this.disposeMaterial(e)}}},disposeMaterial(s){s&&(Object.keys(s).forEach(e=>{const t=s[e];t&&typeof t=="object"&&t.isTexture&&t.dispose()}),s.dispose())},setSelectedModels(s){this.selectedModels=s.filter(e=>e>=0&&e<this.uploadedModels.length)},selectAllModels(){this.selectedModels=this.uploadedModels.map((s,e)=>e)},deselectAllModels(){this.selectedModels=[]},setShowAxes(s){this.showAxes=s},setShowModelList(s){this.showModelList=s},setLoadingQueue(s){this.loadingQueue=s},addToLoadingQueue(s){this.loadingQueue.push(s)},setIsProcessingQueue(s){this.isProcessingQueue=s},async addModelFromUrl(s){try{const e=await Hu.downloadAvatarApi({url:s});if(e.status!=200)throw new Error(`下载失败: ${e.status}`);return await e.data}catch(e){throw console.error("addModelFromUrl失败:",e),e}},resetCamera(){this.camera&&this.controls&&(this.camera.position.set(10,10,10),this.camera.lookAt(0,0,0),this.controls.reset())},toggleAxes(){this.showAxes=!this.showAxes,this.scene&&this.axesHelper&&(this.axesHelper.visible=this.showAxes)}}}),Gv={class:"content-show"},Wv={key:0,class:"upload-overlay"},Xv={key:1,class:"floating-model-panel"},jv={class:"panel-actions"},qv=["disabled"],Kv={class:"model-list"},Yv={key:0,class:"empty-state"},Zv={class:"model-checkbox"},$v=["value"],Jv={class:"model-info"},Qv=["title"],eM={class:"model-meta"},tM={class:"model-type"},nM={class:"model-size"},iM={class:"model-actions"},sM=["onClick","title"],rM={width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor"},aM={key:0,d:"M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"},oM={key:1,d:"M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7zM2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3 2 4.27zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2zm4.31-.78l3.15 3.15.02-.16c0-1.66-1.34-3-3-3l-.17.01z"},lM=["onClick","disabled"],cM={key:2,class:"error-message"},uM={__name:"threeModel",props:{isShow:Boolean},setup(s,{expose:e}){const t=s,n=V.ref(null);V.ref(null),V.ref(""),V.ref(!1);const i=V.ref(""),r=V.ref(!1),a=Vu.useModelComp(cr.pinia),{nodeDev:o}=Et.storeToRefs(a),l=Hv(),{uploadedModels:c,selectedModels:u,showAxes:h,showModelList:d,isInitialized:f}=Et.storeToRefs(l);V.computed(()=>l.getAllLoadedModels);let g,_,m,p,S=null;const x={".obj":"OBJ",".fbx":"FBX",".gltf":"GLTF",".glb":"GLB",".dae":"Collada",".3ds":"3DS",".ply":"PLY",".stl":"STL",".step":"STEP",".stp":"STEP",".iges":"IGES",".igs":"IGES"},y=Q=>{const ee="."+Q.split(".").pop().toLowerCase();return x[ee]||"未知"},N=Q=>({pending:"待加载",loading:"加载中",loaded:"已加载",error:"失败"})[Q]||"未知",P=Q=>{if(Q===0)return"0 B";const ee=1024,te=["B","KB","MB","GB"],I=Math.floor(Math.log(Q)/Math.log(ee));return parseFloat((Q/Math.pow(ee,I)).toFixed(2))+" "+te[I]},L=()=>{if(!(f.value||!n.value))try{g=new dh,g.background=new He(15790320),l.setScene(g),_=new cn(45,n.value.clientWidth/n.value.clientHeight,.1,1e5),_.position.set(10,10,10),_.lookAt(0,0,0),l.setCamera(_),m=new ex({antialias:!0}),m.setSize(n.value.clientWidth,n.value.clientHeight),m.setPixelRatio(window.devicePixelRatio),m.shadowMap.enabled=!0,m.shadowMap.type=ju,n.value.appendChild(m.domElement),l.setRenderer(m),p=new Cv(_,m.domElement),p.enableDamping=!0,p.dampingFactor=.05,p.enableZoom=!0,p.enablePan=!0,l.setControls(p),U(),E(),T(),D(),l.setIsInitialized(!0)}catch(Q){console.error("Three.js场景初始化失败:",Q)}},U=()=>{const Q=new Kl(16777215,.6);g.add(Q);const ee=new Er(16777215,.8);ee.position.set(10,10,5),ee.castShadow=!0,ee.shadow.mapSize.width=2048,ee.shadow.mapSize.height=2048,g.add(ee);const te=new Er(16777215,.3);te.position.set(-10,5,-5),g.add(te)},E=()=>{S=new gm(5),g.add(S),l.setAxesHelper(S)},T=()=>{const Q=new mm(1e3,1e3,8947848,13421772);g.add(Q)},D=()=>{const Q=()=>{requestAnimationFrame(Q),p&&p.update(),m&&g&&_&&m.render(g,_)};Q()},X=async Q=>{if(Q.status==="pending"){l.updateModelStatus(Q.id,"loading");try{const ee=URL.createObjectURL(Q.file),te=await j(Q.file,ee);if(te)te.userData.modelId=Q.id,te.userData.fileName=Q.file.name,g.add(te),l.updateModelObject(Q.id,te);else throw new Error("模型加载返回空对象");URL.revokeObjectURL(ee)}catch(ee){console.error(`模型 ${Q.file.name} 加载失败:`,ee),l.updateModelStatus(Q.id,"error")}}},j=(Q,ee)=>new Promise((te,I)=>{const ge="."+Q.name.split(".").pop().toLowerCase();switch(ge){case".obj":se(ee,te,I);break;case".fbx":de(ee,te,I);break;case".gltf":case".glb":k(ee,te,I);break;case".dae":ae(ee,te,I);break;case".ply":G(ee,te,I);break;case".stl":pe(ee,te,I);break;default:I(new Error(`不支持的文件格式: ${ge}`))}}),se=(Q,ee,te)=>{new ax().load(Q,ee,void 0,te)},de=(Q,ee,te)=>{new Lx().load(Q,ee,void 0,te)},k=(Q,ee,te)=>{new Gx().load(Q,ge=>{ee(ge.scene)},void 0,te)},ae=(Q,ee,te)=>{new bv().load(Q,ge=>{ee(ge.scene)},void 0,te)},G=(Q,ee,te)=>{new Ev().load(Q,ge=>{const Ne=new br({color:8947848}),dt=new sn(ge,Ne);ee(dt)},void 0,te)},pe=(Q,ee,te)=>{new wv().load(Q,ge=>{const Ne=new br({color:8947848}),dt=new sn(ge,Ne);ee(dt)},void 0,te)},Me=()=>{l.setShowModelList(!d.value)},le=Q=>{l.toggleModelVisibility(Q)},we=()=>{l.selectAllModels()},be=()=>{l.deselectAllModels()},W=()=>{l.removeSelectedModels()},$=Q=>{l.removeUploadedModel(Q)?Et.ElMessage.success("模型删除成功"):Et.ElMessage.error("模型删除失败")},re=()=>{l.clearAllModels(),l.resetCamera()},oe=()=>{_&&m&&n.value&&(_.aspect=n.value.clientWidth/n.value.clientHeight,_.updateProjectionMatrix(),m.setSize(n.value.clientWidth,n.value.clientHeight))};V.onMounted(async()=>{window.addEventListener("resize",oe),L()}),V.watch(()=>t==null?void 0:t.isShow,Q=>{Q&&!f.value&&setTimeout(()=>{L()},100)},{immediate:!0});const Te=async(Q,ee={})=>{if(!Q||!(Q instanceof File||Q instanceof Blob))throw new Error("参数必须是File或Blob对象");const te=Q.name||ee.fileName||"unknown.obj",I="."+te.split(".").pop().toLowerCase();if(!x[I])throw new Error(`不支持的文件格式: ${I}`);f.value||(L(),await new Promise(Ne=>setTimeout(Ne,100)));const ge={file:Q,name:te,size:Q.size,type:y(te),status:"pending",model:null,visible:!0,id:Date.now()+Math.random()};l.addUploadedModel(ge);try{return await X(ge),{success:!0,modelId:ge.id,fileName:te}}catch(Ne){throw console.error(`外部模型 ${te} 加载失败:`,Ne),l.removeModelById(ge.id),Ne}},ne=async Q=>{try{const ee=await Hu.downloadAvatarApi({url:Q});if(ee.status!=200)throw new Error(`下载失败: ${ee.status}`);return await ee.data}catch(ee){throw console.error("addModelFromUrl失败:",ee),ee}};return e({addModelFromStream:Te,addModelFromUrl:async Q=>{try{const ee=await ne(Q),te=Q.split("/").pop()||"model.obj",I=new File([ee],te,{type:ee.type});return await Te(I,{autoFit:!0}),ee}catch(ee){throw console.error("从URL加载模型失败:",ee),ee}},clearAllModels:re}),V.onBeforeUnmount(()=>{window.removeEventListener("resize",oe),m&&(m.dispose(),m=null),p&&(p.dispose(),p=null),re(),l.setIsInitialized(!1),l.setScene(null),l.setCamera(null),l.setRenderer(null),l.setControls(null),l.setAxesHelper(null)}),(Q,ee)=>(V.openBlock(),V.createElementBlock("div",Gv,[r.value?(V.openBlock(),V.createElementBlock("div",Wv,ee[2]||(ee[2]=[V.createElementVNode("div",{class:"upload-spinner"},[V.createElementVNode("div",{class:"spinner"}),V.createElementVNode("p",{class:"upload-text"},"正在上传模型...")],-1)]))):V.createCommentVNode("",!0),V.unref(d)?(V.openBlock(),V.createElementBlock("div",Xv,[V.createElementVNode("div",{class:"panel-header"},[ee[4]||(ee[4]=V.createElementVNode("span",{class:"panel-title"},"模型列表",-1)),V.createElementVNode("button",{onClick:Me,class:"close-btn"},ee[3]||(ee[3]=[V.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor"},[V.createElementVNode("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})],-1)]))]),V.createElementVNode("div",jv,[V.createElementVNode("button",{onClick:we,class:"action-btn"},"全选"),V.createElementVNode("button",{onClick:be,class:"action-btn"},"取消"),V.createElementVNode("button",{onClick:W,class:"action-btn danger",disabled:V.unref(u).length===0}," 删除 ("+V.toDisplayString(V.unref(u).length)+") ",9,qv)]),V.createElementVNode("div",Kv,[V.unref(c).length===0?(V.openBlock(),V.createElementBlock("div",Yv,ee[5]||(ee[5]=[V.createElementVNode("p",null,"暂无模型",-1)]))):V.createCommentVNode("",!0),(V.openBlock(!0),V.createElementBlock(V.Fragment,null,V.renderList(V.unref(c),(te,I)=>(V.openBlock(),V.createElementBlock("div",{key:te.id,class:V.normalizeClass(["model-item",{selected:V.unref(u).includes(I)}])},[V.createElementVNode("div",Zv,[V.withDirectives(V.createElementVNode("input",{type:"checkbox","onUpdate:modelValue":ee[0]||(ee[0]=ge=>V.isRef(u)?u.value=ge:null),value:I},null,8,$v),[[V.vModelCheckbox,V.unref(u)]])]),V.createElementVNode("div",Jv,[V.createElementVNode("div",{class:"model-name",title:te.file.name},V.toDisplayString(te.file.name),9,Qv),V.createElementVNode("div",eM,[V.createElementVNode("span",tM,V.toDisplayString(y(te.file.name)),1),V.createElementVNode("span",nM,V.toDisplayString(P(te.file.size)),1),V.createElementVNode("span",{class:V.normalizeClass(["model-status",te.status])},V.toDisplayString(N(te.status)),3)])]),V.createElementVNode("div",iM,[te.status==="loaded"?(V.openBlock(),V.createElementBlock("button",{key:0,onClick:ge=>le(I),class:"action-icon",title:te.visible?"隐藏模型":"显示模型"},[(V.openBlock(),V.createElementBlock("svg",rM,[te.visible?(V.openBlock(),V.createElementBlock("path",aM)):(V.openBlock(),V.createElementBlock("path",oM))]))],8,sM)):V.createCommentVNode("",!0),V.createElementVNode("button",{onClick:ge=>$(I),class:"action-icon danger",disabled:te.status==="loading",title:"删除模型"},ee[6]||(ee[6]=[V.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor"},[V.createElementVNode("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"})],-1)]),8,lM)])],2))),128))])])):V.createCommentVNode("",!0),V.createElementVNode("div",{ref_key:"container",ref:n,class:"three-container"},null,512),i.value?(V.openBlock(),V.createElementBlock("div",cM,[V.createElementVNode("span",null,V.toDisplayString(i.value),1),V.createElementVNode("button",{onClick:ee[1]||(ee[1]=te=>i.value=""),class:"btn-close"},"×")])):V.createCommentVNode("",!0)]))}},Bh=Rl._export_sfc(uM,[["__scopeId","data-v-4aaec5a9"]]),zh=Et.defineStore("formToTableComp",{state:()=>({selectArray:[],selectString:""}),actions:{setSelectArray(s){this.selectArray=s},setSelectString(s){this.selectString=s}}}),Vh=Et.defineStore("unit",{state:()=>({selectIndex:"",selectMenu:"",selectTitle:[]}),actions:{setSelectIndex(s){this.selectIndex=s},setSelectMenu(s){this.selectMenu=s},setSelectTitle(s){this.selectTitle=s}}}),Hh=(s,e)=>{let t=s,n=e;return Array.isArray(t)&&(t=t==null?void 0:t.map((i,r)=>{if(Array.isArray(i)){let a={};return i=i==null?void 0:i.forEach((o,l)=>{var c;(c=n==null?void 0:n[l])!=null&&c.prop?a[n[l].prop]=o:Array.isArray(o)&&(a.children=Hh(o,n))}),Object.assign(a,{id:r})}else return i})),t},Gh=(s,e,t)=>{let n=s,i=e;return n=n==null?void 0:n.map((r,a)=>{var o,l;return!Array.isArray(r)||!((o=i==null?void 0:i[a])!=null&&o.label)&&!t||(r.unshift(((l=i==null?void 0:i[a])==null?void 0:l.label)??""),r.some(c=>Array.isArray(c))&&(r=r==null?void 0:r.map(c=>{var u;return Array.isArray(c)&&(c=Gh(c,(u=i==null?void 0:i[a])==null?void 0:u.children,t)),c}))),r}),n},hM=(s,e,t)=>{if(e==="")return s==null?void 0:s.filter(n=>(n==null?void 0:n.id)!==t);{const n=e.split("-");return dM(s,n,t)}},dM=(s,e,t)=>{let n=s,i=e;return(i==null?void 0:i.length)===0?n=n==null?void 0:n.filter(r=>r.id!==t):n=n==null?void 0:n.map(r=>(r.id.toString()===(i==null?void 0:i[0])&&(i==null||i.shift(),r=Wh(r,i,t)),r)),n},Wh=(s,e,t)=>{var r,a;let n=s,i=e;return(i==null?void 0:i.length)===0?n.children=(r=n.children)==null?void 0:r.filter(o=>o.id!==t):n.children=(a=n.children)==null?void 0:a.map(o=>(o.id.toString()===(i==null?void 0:i[0])&&(i==null||i.shift(),o=Wh(o,i,t)),o)),n},fM=(s,e,t)=>{if(e==="")return t;{const n=e.split("-");return pM(s,n,t)}},pM=(s,e,t)=>{let n=s,i=e;return(i==null?void 0:i.length)===0?n=t:n=n==null?void 0:n.map(r=>(r.id.toString()===(i==null?void 0:i[0])&&(i==null||i.shift(),r=Xh(r,i,t)),r)),n},Xh=(s,e,t)=>{var r;let n=s,i=e;return(i==null?void 0:i.length)===0?n.children=t:n.children=(r=n.children)==null?void 0:r.map(a=>(a.id.toString()===(i==null?void 0:i[0])&&(i==null||i.shift(),a=Xh(a,i,t)),a)),n},jh=(s,e)=>s==null?void 0:s.map(n=>{var i,r,a,o,l,c;if(Array.isArray(n)?n=n:n=[n],(i=n==null?void 0:n.filter(u=>!(u!=null&&u.id)))!=null&&i.every(u=>typeof u!="object"||u===null))return n;if((r=n==null?void 0:n.filter(u=>!(u!=null&&u.id)))!=null&&r.some(u=>Array.isArray(u)))return n;{let u=[];if(u.push(n==null?void 0:n.find(h=>h==null?void 0:h.id)),Array.isArray(e==null?void 0:e[0])){const h=(a=n==null?void 0:n.filter(d=>!(d!=null&&d.id)))==null?void 0:a[0];(o=Bn.getColumnChild(qe.cloneDeep(e==null?void 0:e[0])))==null||o.forEach(d=>{u.push(h==null?void 0:h[(d==null?void 0:d.prop)??(d==null?void 0:d.label)??d])})}else{const h=(l=n==null?void 0:n.filter(d=>!(d!=null&&d.id)))==null?void 0:l[0];(c=Bn.getColumnChild(qe.cloneDeep(e)))==null||c.forEach(d=>{u.push(h==null?void 0:h[(d==null?void 0:d.prop)??(d==null?void 0:d.label)??d])})}return u}}),mM=s=>{try{return JSON.parse(s),!0}catch{return!1}},Bu=(s,e)=>Ed(s,e),qs=s=>{let e=[];function t(i){Array.isArray(i)&&(i==null||i.forEach(r=>{Array.isArray(r)||(r=[r]),r==null||r.forEach(a=>{!(a!=null&&a.children)||a.children.length===0?e.push(a.label):n(a.children)})}))}function n(i){i==null||i.forEach(r=>{!(r!=null&&r.children)||r.children.length===0?e.push(r.label):n(r.children)})}return t(s),e},gM=(s,e,t)=>{var i;let n=(i=qe.cloneDeep(s))==null?void 0:i.map(r=>(r=r.filter(a=>!(a!=null&&a.id)),r));return n=n==null?void 0:n.map(r=>{var a;return r=(a=r.map((o,l)=>{let c={};if(t!=null&&t.find(u=>u===e[l]))return c[e[l]]=o,c}))==null?void 0:a.filter(o=>o),r}),n},_M=(s,e)=>{var a,o;const t=qe.cloneDeep(s),n=(a=t==null?void 0:t.find(l=>(l==null?void 0:l.key)==="header"))==null?void 0:a.contents,i=(o=t==null?void 0:t.find(l=>(l==null?void 0:l.key)==="tableContents"))==null?void 0:o.contents;return gM(i,qs(n).slice(0,qs(n).length-1),e)},vi=s=>{var i,r,a,o;const e=s;let t=[];e.compData=(i=e.compData)==null?void 0:i.filter(l=>(l==null?void 0:l.key)!=="tableContents"&&(l==null?void 0:l.key)!=="tableIndex");const n=(a=(r=qe.cloneDeep(e.compData))==null?void 0:r.find(l=>(l==null?void 0:l.key)==="tableIndexColumn"))==null?void 0:a.contents;return(o=qe.cloneDeep(e.compData))==null||o.forEach(l=>{if((l==null?void 0:l.key)!=="tableIndexColumn"&&(l==null?void 0:l.key)!=="header")t.push(l);else if((l==null?void 0:l.key)==="header"){let c=l.contents;n&&(c!=null&&c.every(u=>Array.isArray(u))?c==null||c[0].unshift({label:n}):c.unshift({label:n})),t.push({key:"header",contents:c})}}),e.compData=t,e},Al=s=>{var r,a,o,l,c;const e=(r=s.compData)==null?void 0:r.filter(u=>(u==null?void 0:u.key)==="tableContents"||(u==null?void 0:u.key)==="tableIndex"),t=(o=(a=e==null?void 0:e.find(u=>(u==null?void 0:u.key)==="tableIndex"))==null?void 0:a.contents)==null?void 0:o.map(u=>u.label),n=(l=e==null?void 0:e.find(u=>(u==null?void 0:u.key)==="tableContents"))==null?void 0:l.contents;let i=[];return(t==null?void 0:t.length)>0&&(n!=null&&n.every(u=>Array.isArray(u)))?i=t==null?void 0:t.map((u,h)=>n[h]?[u,...n[h]]:[u]):Array.isArray(n==null?void 0:n[0])&&((c=n==null?void 0:n[0])!=null&&c.every(u=>Array.isArray(u)))?i=n==null?void 0:n[0]:Array.isArray(n==null?void 0:n[0])?i=n:i.push(n),i},yM=s=>{const e=[];function t(n){!n||n.length===0||(e.push(n==null?void 0:n.map(i=>({label:i.label}))),n==null||n.forEach(i=>{i!=null&&i.children&&(i==null?void 0:i.children.length)>0&&t(i==null?void 0:i.children)}))}return t(s),e},xM=s=>{const e=[];function t(n,i=[]){!n||n.length===0||(e.push({key:i==null?void 0:i.filter(r=>!Array.isArray(r)),value:n}),n==null||n.forEach(r=>{r!=null&&r.some(a=>Array.isArray(a))&&t(r.find(a=>Array.isArray(a)),r)}))}return t(s),e},vM=s=>{const e=[];function t(n){!n||n.length===0||(e.push(n==null?void 0:n.map(i=>i==null?void 0:i.filter(r=>!Array.isArray(r)))),n==null||n.forEach(i=>{i!=null&&i.some(r=>Array.isArray(r))&&t(i.find(r=>Array.isArray(r)))}))}return t(s),e},MM=s=>{const e=[];function t(n){var i;!n||n.length===0||(n!=null&&n.every(r=>!Array.isArray(r))?e.push(n):(e.push((i=n==null?void 0:n.map(r=>r==null?void 0:r.filter(a=>!Array.isArray(a))))==null?void 0:i[0]),n==null||n.forEach(r=>{r!=null&&r.some(a=>Array.isArray(a))&&t(r.find(a=>Array.isArray(a)))})))}return t(s),e},SM=(s,e)=>{let t;function n(i,r,a=1){var l;if(!i||i.length===0)return;const o=(l=qe.cloneDeep(r))==null?void 0:l.map(c=>c==null?void 0:c.filter(u=>!Array.isArray(u)));return o!=null&&o.find(c=>Bu(c,i==null?void 0:i.key))?(r==null||r.forEach(c=>{!n(i,c.find(h=>Array.isArray(h)))&&Bu(c.filter(h=>!Array.isArray(h)),i==null?void 0:i.key)&&(t={type:a,contents:c.filter(h=>!Array.isArray(h))})}),!0):!1}return n(s,e,0),t},zu=(s,e)=>{function t(n,i){return!n||n.length===0||n==null?void 0:n.map((a,o)=>{var c,u;let l=a;return l.unshift((c=i==null?void 0:i[o])==null?void 0:c.label),l.some(h=>Array.isArray(h))&&(l[l.length-1]=t(l.find(h=>Array.isArray(h)),(u=i==null?void 0:i[o])==null?void 0:u.children)),l})}return t(s,e)},wl=s=>{var t,n,i,r,a,o,l,c,u,h,d,f,g,_,m,p,S,x,y,N,P,L,U,E,T;const e=s;if((s==null?void 0:s.comp)==="Table"){if((i=(n=(t=s.compData)==null?void 0:t.find(D=>(D==null?void 0:D.key)==="tableIndex"))==null?void 0:n.contents)!=null&&i.every(D=>!(D!=null&&D.children))||!((r=s.compData)!=null&&r.find(D=>(D==null?void 0:D.key)==="tableIndex")))return((l=(o=(a=e.compData)==null?void 0:a.find(D=>(D==null?void 0:D.key)==="tableContents"))==null?void 0:o.contents)==null?void 0:l.length)===1&&((d=(h=(u=(c=e.compData)==null?void 0:c.find(D=>(D==null?void 0:D.key)==="tableContents"))==null?void 0:u.contents)==null?void 0:h[0])!=null&&d.every(D=>Array.isArray(D)))?(e.compData=(f=e.compData)==null?void 0:f.map(D=>{var X;return(D==null?void 0:D.key)==="tableContents"&&(D.contents=(X=D.contents)==null?void 0:X[0]),D}),[e]):[e];{let D=[];const X=e.compData,j=(g=qe.cloneDeep(X))==null?void 0:g.find(le=>(le==null?void 0:le.key)==="tableIndexColumn"),se=(_=qe.cloneDeep(X))==null?void 0:_.find(le=>(le==null?void 0:le.key)==="extraButton"),de=(m=qe.cloneDeep(X))==null?void 0:m.find(le=>(le==null?void 0:le.key)==="rowButton"),k=MM((S=(p=qe.cloneDeep(X))==null?void 0:p.find(le=>(le==null?void 0:le.key)==="header"))==null?void 0:S.contents),ae=(x=qe.cloneDeep(X))==null?void 0:x.find(le=>(le==null?void 0:le.key)==="tableIndex"),G=vM((N=(y=qe.cloneDeep(X))==null?void 0:y.find(le=>(le==null?void 0:le.key)==="tableContents"))==null?void 0:N.contents),pe=zu((L=(P=qe.cloneDeep(X))==null?void 0:P.find(le=>(le==null?void 0:le.key)==="tableContents"))==null?void 0:L.contents,ae==null?void 0:ae.contents),Me=xM(zu((E=(U=qe.cloneDeep(X))==null?void 0:U.find(le=>(le==null?void 0:le.key)==="tableContents"))==null?void 0:E.contents,ae==null?void 0:ae.contents));if(ae)return(T=yM(ae.contents))==null||T.forEach((le,we)=>{var W;let be=[];be.push({key:"tableIndex",contents:le}),be.push(j),be.push(se),be.push(de),be.push({key:"tableContents",contents:G[we]}),be.push({key:"header",contents:k!=null&&k[we]?[k==null?void 0:k[we]]:[k==null?void 0:k[0]]}),D.push({comp:"Table",compData:be,name:"",parentTableContents:((W=SM(Me[we],pe))==null?void 0:W.contents)??""})}),D}}else return[e]},La=(s,e)=>{let t={};return Array.isArray(s)?s==null||s.forEach((n,i)=>{t[e[i]]=n}):[s].forEach((n,i)=>{t[e[i]]=n}),t},TM=async s=>{let e=[];s==null||s.forEach(t=>{var n;(n=t.compData)==null||n.forEach(i=>{var r;(r=i.contents)==null||r.forEach(a=>{var o;Array.isArray(a)?a==null||a.forEach(l=>{var c;(c=wl(qe.cloneDeep(l)))==null||c.forEach(async u=>{var h,d,f,g,_;if(l.comp==="Table"){const m=await Et.createInsofDataApi({key:{systemKey:sessionStorage.getItem("systemKey"),pageKey:t.name,type:"structure",version:1,parentTable:(u==null?void 0:u.parentTableContents)??""},value:{pageData:{comp:(h=vi(qe.cloneDeep(u)))==null?void 0:h.comp,compData:(d=vi(qe.cloneDeep(u)))==null?void 0:d.compData,name:(f=vi(qe.cloneDeep(u)))==null?void 0:f.name}}}),p=m.data.result,S=await((g=Al(qe.cloneDeep(u)))==null?void 0:g.map(async x=>{var L,U,E,T,D;let y;x.length!==0&&(y=await Et.createInsofDataApi({key:{systemKey:sessionStorage.getItem("systemKey"),pageKey:t.name,type:"data",tableId:p},value:{tableData:La(x,(T=qs((E=(U=(L=vi(qe.cloneDeep(u)))==null?void 0:L.compData)==null?void 0:U.find(X=>(X==null?void 0:X.key)==="header"))==null?void 0:E.contents))==null?void 0:T.filter(X=>X!=="操作"))}}));const P=await((D=(await Et.getInsofDataApi({key:{systemKey:sessionStorage.getItem("systemKey"),pageKey:t.name,type:"structure",parentTable:x}})).data.result)==null?void 0:D.map(async X=>await Et.updateInsofDataApi({id:X.id,key:{systemKey:X.key.systemKey,pageKey:X.key.pageKey,type:X.key.type,version:X.key.version,parentTable:y.data.result}})));return e.push(P),y}));e.push(m),e.push(S)}else if((u==null?void 0:u.key)==="extraButton"){if(((_=Object.values(u==null?void 0:u.value))==null?void 0:_.length)!==0){const m=await Et.createInsofDataApi({key:{systemKey:sessionStorage.getItem("systemKey"),pageKey:t.name,type:"structureMethod",version:1},value:{pageData:u.value}});e.push(m)}}else{const m=await Et.createInsofDataApi({key:{systemKey:sessionStorage.getItem("systemKey"),pageKey:t.name,type:"structure",version:1,parentTable:(u==null?void 0:u.parentTableContents)??""},value:{pageData:u}});e.push(m)}})}):(o=wl(qe.cloneDeep(a)))==null||o.forEach(async l=>{var c,u,h,d,f;if(a.comp==="Table"){const g=await Et.createInsofDataApi({key:{systemKey:sessionStorage.getItem("systemKey"),pageKey:t.name,type:"structure",version:1,parentTable:(l==null?void 0:l.parentTableContents)??""},value:{pageData:{comp:(c=vi(qe.cloneDeep(l)))==null?void 0:c.comp,compData:(u=vi(qe.cloneDeep(l)))==null?void 0:u.compData,name:(h=vi(qe.cloneDeep(l)))==null?void 0:h.name}}}),_=g.data.result,m=await((d=Al(qe.cloneDeep(l)))==null?void 0:d.map(async p=>{var N,P,L,U,E;let S;(p==null?void 0:p.length)!==0&&(S=await Et.createInsofDataApi({key:{systemKey:sessionStorage.getItem("systemKey"),pageKey:t.name,type:"data",tableId:_},value:{tableData:La(p,(U=qs((L=(P=(N=vi(qe.cloneDeep(l)))==null?void 0:N.compData)==null?void 0:P.find(T=>(T==null?void 0:T.key)==="header"))==null?void 0:L.contents))==null?void 0:U.filter(T=>T!=="操作"))}}));const y=await((E=(await Et.getInsofDataApi({key:{parentTable:p,systemKey:sessionStorage.getItem("systemKey"),pageKey:t.name,type:"structure"}})).data.result)==null?void 0:E.map(async T=>await Et.updateInsofDataApi({id:T.id,key:{systemKey:T.key.systemKey,pageKey:T.key.pageKey,type:T.key.type,version:T.key.version,parentTable:T.key.parentTable===""?"":S.data.result}})));return e.push(y),S}));e.push(g),e.push(m)}else if((l==null?void 0:l.key)==="extraButton"){if(((f=Object.values(l==null?void 0:l.value))==null?void 0:f.length)!==0){const g=await Et.createInsofDataApi({key:{systemKey:sessionStorage.getItem("systemKey"),pageKey:t.name,type:"structureMethod",version:1},value:{pageData:l.value}});e.push(g)}}else{const g=await Et.createInsofDataApi({key:{systemKey:sessionStorage.getItem("systemKey"),pageKey:t.name,type:"structure",version:1,parentTable:(l==null?void 0:l.parentTableContents)??""},value:{pageData:l}});e.push(g)}})})})}),await Promise.all(e)},bM=Et.useMenuState(cr.pinia),EM=s=>{var t;const e=Array.isArray(s)?s==null?void 0:s[0]:{};return(t=e==null?void 0:e.contents)==null?void 0:t.map(n=>({...n[0],...n[1]}))},qh=async(s,e,t="",n)=>{var h,d,f,g,_,m;const i=await Et.getInsofDataApi({key:{pageKey:s,systemKey:e,parentTable:t}}),r=await Et.getInsofDataApi({key:{pageKey:s,systemKey:e,type:"structureMethod"}}),a=(h=i.data.result)==null?void 0:h.map(p=>p.id),o=a==null?void 0:a.map(p=>Et.getInsofDataApi({key:{pageKey:s,systemKey:e,tableId:p}})),l=await Promise.all(o),c=[];l==null||l.forEach(p=>{var y,N,P,L;const S=(y=p.data.result)==null?void 0:y.map(U=>{const E=Array.isArray(U.value.tableData)?U.value.tableData:[U.value.tableData];return E.unshift({id:U.id}),E}),x=(L=(P=(N=p.data.result)==null?void 0:N[0])==null?void 0:P.key)==null?void 0:L.tableId;c.push({key:x,contents:S})});const u=[];return(d=i.data.result)==null||d.forEach(p=>{var y,N,P,L;const S=p.value.pageData,x=(y=qe.cloneDeep(S.compData))==null?void 0:y.filter(U=>(U==null?void 0:U.key)!=="tableContents");if(x&&(x!=null&&x.find(U=>(U==null?void 0:U.key)==="header"))&&x.push({key:"tableContents",contents:n==="/系统管理/用户管理"?EM(c):jh((N=c==null?void 0:c.find(U=>(U==null?void 0:U.key)===p.id))==null?void 0:N.contents,(P=x==null?void 0:x.find(U=>(U==null?void 0:U.key)==="header"))==null?void 0:P.contents)}),S.compData=x,S.id=p.id,((L=p.key)==null?void 0:L.type)!=="method")u.push(S);else{let U;U={name:"",compData:[S],comp:"calculator"},u.push(U)}}),((g=(f=r.data.result)==null?void 0:f.map(p=>p.value.pageData))==null?void 0:g.filter(p=>Object.values(p).length>0).length)>0&&u.push({comp:"methodButton",name:"",compData:(m=(_=r.data.result)==null?void 0:_.map(p=>p.value.pageData))==null?void 0:m.filter(p=>Object.values(p).length>0)}),u},AM=async s=>{await Et.deleteInsofDataApi({id:s})},wM=async(s,e,t,n,i,r)=>{var a;await Et.createInsofDataApi({key:{type:s,pageKey:e,tableId:t,systemKey:n},value:{tableData:La(i,(a=qs(r))==null?void 0:a.filter(o=>o!=="操作"))}})},RM=async(s,e,t,n,i,r,a)=>{var o;await Et.updateInsofDataApi({key:{type:s,pageKey:e,tableId:t,systemKey:i},value:{tableData:La(r,(o=qs(a))==null?void 0:o.filter(l=>l!=="操作"))},id:n})},CM=async(s,e)=>{await Et.updateInsofDataApi({value:{pageData:e},id:s})},PM=async(s,e)=>await Et.getInsofDataApi({key:s,valueLikes:e}),LM=async()=>{var s,e,t,n,i,r,a,o,l;try{const c=await Et.getInsofDataApi({key:{systemKey:sessionStorage.getItem("systemKey"),layer:"superAdmin"}});((s=c==null?void 0:c.data)==null?void 0:s.code)===200&&(bM.setPlatform(((i=(n=(t=(e=c==null?void 0:c.data)==null?void 0:e.result)==null?void 0:t[0])==null?void 0:n.key)==null?void 0:i.type)==="制造系统"?"client":"browser"),(l=(o=(a=(r=c==null?void 0:c.data)==null?void 0:r.result)==null?void 0:a[0])==null?void 0:o.key)==null||l.type)}catch(c){return Promise.reject(c)}},DM={class:"table-content"},IM=["onClick"],NM={class:"form-content"},UM={key:0,class:"dialog-footer"},FM={__name:"index",props:{itemData:{type:Array,default:()=>[]},childItemData:{type:Array,default:()=>[]},index:Number,changedContent:{type:Object,default:()=>{}}},emits:["change","contentChange","onButtonClick","contentClick","pageChange"],setup(s,{emit:e}){const t=s,n=e,i=V.ref([]),r=Et.useMenuState(),{activeMenuPath:a}=Et.storeToRefs(r),o=Vu.useModelComp(cr.pinia),{extraContents:l}=Et.storeToRefs(o),c=V.ref([]),u=V.ref(!1),h=V.ref("");V.ref();const d=V.ref(!0),f=V.ref(0),g=V.ref(!1),_=V.ref(""),m=V.ref(!1),p=V.ref({label:"查看三维模型"}),S=V.ref([]),x=V.ref([]),y=V.ref(!1),N=V.ref([]),P=V.ref([]),L=V.ref(),U=V.ref(),E=zh(cr.pinia),T=V.ref(),D=Vh(cr.pinia),{selectIndex:X,selectMenu:j,selectTitle:se}=Et.storeToRefs(D),{selectString:de}=Et.storeToRefs(E),k=V.ref(720),ae=()=>{m.value=!1},G=(ne,me)=>{if(Object.values(me).length!==0)return Object.values(me).find(Q=>{var ee,te;return((ee=Q==null?void 0:Q.toString())==null?void 0:ee.includes(".obj"))||((te=Q==null?void 0:Q.toString())==null?void 0:te.includes(".stl"))})?[...ne,p.value]:ne},pe=ne=>{var te;de.value===""?ne==null||ne[0]:(ne==null?void 0:ne.find(I=>(I==null?void 0:I.selectLabel)==="("+de.value+")"))??(ne==null||ne.find(I=>!(I!=null&&I.selectLabel)));let me=ne;(te=i.value)!=null&&te.find(I=>I.prop==="index");let Q=L.value;const ee=[];return me==null||me.forEach((I,ge)=>{var dt;let Ne={};if(Array.isArray(I)){let ve=[];I==null||I.filter(nt=>!(nt!=null&&nt.id)).forEach((nt,ke)=>{var ht,Nt,F,b,q;if((ht=Q==null?void 0:Q[ke])!=null&&ht.prop&&!Array.isArray(nt)){let ue={};ue[Q[ke].column]=nt,l!=null&&l.value&&((Nt=l==null?void 0:l.value)==null?void 0:Nt.length)>0&&((F=l==null?void 0:l.value)!=null&&F.find(fe=>JSON.stringify(fe==null?void 0:fe[0])===JSON.stringify(ue)))&&(ve=(b=l==null?void 0:l.value)==null?void 0:b.find(fe=>JSON.stringify(fe==null?void 0:fe[0])===JSON.stringify(ue))),ve&&ve.length>0?Ne[Q[ke].prop]=ve!=null&&ve.find(fe=>{var ie;return((ie=Object.keys(fe))==null?void 0:ie[0])===Q[ke].column})?(q=ve==null?void 0:ve.find(fe=>{var ie;return((ie=Object.keys(fe))==null?void 0:ie[0])===Q[ke].column}))==null?void 0:q[Q[ke].column]:nt:Ne[Q[ke].prop]=nt}})}else Ne=I;Array.isArray(I)&&I.some(ve=>ve==null?void 0:ve.id)?ee.push(Object.assign(Ne,{id:(dt=I==null?void 0:I.find(ve=>ve.id))==null?void 0:dt.id})):Ne.id?ee.push(Ne):ee.push(Object.assign(Ne,{id:ge}))}),ee},Me=async ne=>{var te,I,ge,Ne,dt;let me={};for(let ve in ne)ne[ve]!==""&&(me["tableData."+ve]=ne[ve]);const Q=await PM({type:"data",tableId:t==null?void 0:t.index,systemKey:sessionStorage.getItem("systemKey"),pageKey:a.value},me),ee=(ge=(I=(te=qe.cloneDeep(Q))==null?void 0:te.data)==null?void 0:I.result)==null?void 0:ge.map(ve=>{var ke;let nt=[];return nt.push({id:ve.id}),nt.push((ke=ve==null?void 0:ve.value)==null?void 0:ke.tableData),nt});c.value=pe(jh(ee,(dt=(Ne=qe.cloneDeep(i.value))==null?void 0:Ne.map(ve=>ve.label))==null?void 0:dt.filter(ve=>ve!=="操作")))},le=async ne=>{var Q,ee,te,I,ge,Ne,dt;let me=await qh(a.value,sessionStorage.getItem("systemKey"),ne.id);if(me=me==null?void 0:me.filter(ve=>ve.comp!=="methodButton"),me&&me.length>0){const ve=!Array.isArray(se.value)&&((Q=se.value)==null?void 0:Q.key)!=="main"?[]:se.value;ve.push({key:j.value===""?(ee=ne==null?void 0:ne.id)==null?void 0:ee.toString():j.value+"-"+((te=ne==null?void 0:ne.id)==null?void 0:te.toString()),value:ne[(I=Object.keys(ne))==null?void 0:I.filter(nt=>nt!=="index"&&nt!=="id")[0]]}),D.setSelectMenu(j.value===""?(ge=ne==null?void 0:ne.id)==null?void 0:ge.toString():j.value+"-"+((Ne=ne==null?void 0:ne.id)==null?void 0:Ne.toString())),D.setSelectTitle(ve),D.setSelectIndex((dt=ne==null?void 0:ne.id)==null?void 0:dt.toString()),n("pageChange",me)}},we=ne=>{var me;(me=qe.cloneDeep(t.itemData))==null||me.map(Q=>((Q==null?void 0:Q.key)==="tableContents"&&(Q.contents=ne),Q))},be=(ne,me,Q)=>{n("contentClick",ne,me,Q,{id:t==null?void 0:t.index})};V.watch(()=>t.changedContent,()=>{var Q,ee;if(!t.changedContent)return;let ne=(Q=c.value)==null?void 0:Q.map(te=>{var I;return te.id===((I=t.changedContent)==null?void 0:I.id)&&(te={...t.changedContent,id:t.changedContent.newId?t.changedContent.newId:t.changedContent.id},delete te.newId),te});const me=(ee=t.itemData)==null?void 0:ee.map(te=>((te==null?void 0:te.key)==="tableContents"&&(te.contents=ne),te));c.value=ne,n("contentChange",{contents:me,index:t.index}),n("change",{content:ne,index:t==null?void 0:t.index,buttonName:"",id:t==null?void 0:t.index})},{deep:!0,immediate:!0});const W=(ne,me)=>{var Q;if(h.value="",y.value=!0,d.value=!0,n("onButtonClick",ne,me),ne==="删除"){c.value=(Q=qe.cloneDeep(c.value))==null?void 0:Q.filter(te=>(te==null?void 0:te.id)!==(me==null?void 0:me.id));const ee=hM(T.value,j.value,me==null?void 0:me.id);we(ee),n("change",{content:c.value,singleContent:me,index:t==null?void 0:t.index,type:"delete",buttonName:ne,column:i.value})}else ne==="新增"?(_.value="新增",re(""),m.value=!0):ne==="编辑"?(_.value="编辑",re(me),m.value=!0):ne==="查看"?(_.value="查看",re(me),y.value=!1,d.value=!1,m.value=!0):ne==="查看三维模型"&&(u.value=!0)},$=()=>{u.value=!1},re=ne=>{var ee,te,I;const me=[];let Q=[];for(let ge in ne)Array.isArray(ne==null?void 0:ne[ge])&&Q.push(ge);(te=Bn.getColumnChild((ee=qe.cloneDeep(i.value))==null?void 0:ee.filter(ge=>(ge==null?void 0:ge.label)!=="操作")))==null||te.forEach((ge,Ne)=>{Q.find(dt=>dt===(ge==null?void 0:ge.prop))||me.push({label:(ge==null?void 0:ge.label)??"",name:(ge==null?void 0:ge.prop)??"t"+Ne,type:!(ge!=null&&ge.formType)||(ge==null?void 0:ge.formType)===""?"Input":ge==null?void 0:ge.formType,value:(ne==null?void 0:ne[ge==null?void 0:ge.prop])??"",id:(ge==null?void 0:ge.id)??Ne,contents:(ge==null?void 0:ge.options)??[],width:1,isFormColHidden:ge==null?void 0:ge.isFormColHidden})}),ne===""||!ne||(h.value=ne==null?void 0:ne.id),P.value=S.value&&((I=S.value)==null?void 0:I.length)>0?S.value:me};V.onMounted(()=>{});const oe=()=>{let ne,me=qe.cloneDeep(c.value);h.value===""?(f.value++,me.push(Object.assign(U.value,{id:f.value})),ne=Object.assign(U.value,{id:f.value})):me=me==null?void 0:me.map(ee=>((ee==null?void 0:ee.id)===h.value&&(ee=Object.assign(ee,U.value),ne=ee),ee)),c.value=me;const Q=fM(T.value,j.value,me);we(Q),m.value=!1,n("change",{content:Q,singleContent:ne,index:t==null?void 0:t.index,buttonName:_.value,column:i.value})},Te=ne=>{U.value=ne};return V.watch(()=>[t.itemData,de.value,X.value,j.value,l==null?void 0:l.value],()=>{var dt,ve,nt,ke,ht,Nt,F,b,q,ue,fe,ie,Ke,Re,Ge,Ye,_e,Oe,it,Qe,Ee,at,B,Pe,ye,Be;const ne=(dt=qe.cloneDeep(t.itemData))==null?void 0:dt.filter(Y=>(Y==null?void 0:Y.key)==="header");(ve=qe.cloneDeep(t.itemData))==null||ve.filter(Y=>(Y==null?void 0:Y.key)==="tableIndexColumn")[0];const me=(nt=qe.cloneDeep(t.itemData))==null?void 0:nt.find(Y=>(Y==null?void 0:Y.key)==="page"),Q=(ke=qe.cloneDeep(t.itemData))==null?void 0:ke.find(Y=>(Y==null?void 0:Y.key)==="rowButton"),ee=(ht=qe.cloneDeep(t.itemData))==null?void 0:ht.find(Y=>(Y==null?void 0:Y.key)==="extraButton"),te=(Nt=qe.cloneDeep(t.itemData))==null?void 0:Nt.filter(Y=>(Y==null?void 0:Y.key)==="tableContents"),I=(F=qe.cloneDeep(t.itemData))==null?void 0:F.filter(Y=>(Y==null?void 0:Y.key)==="tableIndex");S.value=(ue=(q=(b=qe.cloneDeep(t.itemData))==null?void 0:b.filter(Y=>(Y==null?void 0:Y.key)==="tableToForm"))==null?void 0:q[0])==null?void 0:ue.contents,g.value=(me==null?void 0:me.contents)??!1;let ge=[];de.value===""?ge=ne==null?void 0:ne[0]:ge=(ne==null?void 0:ne.find(Y=>(Y==null?void 0:Y.selectLabel)==="("+de.value+")"))??(ne==null?void 0:ne.find(Y=>!(Y!=null&&Y.selectLabel)));let Ne=[];if(de.value===""?Ne=I==null?void 0:I[0]:Ne=(I==null?void 0:I.find(Y=>(Y==null?void 0:Y.selectLabel)==="("+de.value+")"))??(I==null?void 0:I.find(Y=>!(Y!=null&&Y.selectLabel))),((fe=ge==null?void 0:ge.contents)==null?void 0:fe.length)>0){let Y=[];if(ge!=null&&ge.contents.some(We=>Array.isArray(We)&&(We==null?void 0:We.find(Le=>Le.children))))j.value===""?Y=(Ke=(ie=Bn.getGradeColumns(qe.cloneDeep(ge==null?void 0:ge.contents)))==null?void 0:ie[0])==null?void 0:Ke.filter(We=>!Array.isArray(We)):(j.value.split("-"),Y=(Re=Bn.getGradeColumns(qe.cloneDeep(ge==null?void 0:ge.contents)))==null?void 0:Re[0]);else{const We=ge!=null&&ge.contents.some(Le=>Array.isArray(Le))?(Ge=ge==null?void 0:ge.contents)==null?void 0:Ge[0]:ge==null?void 0:ge.contents;We==null||We.forEach((Le,Yt)=>{Y.push({label:(Le==null?void 0:Le.label)??"",prop:(Le==null?void 0:Le.label)==="操作"?"operate":(Le==null?void 0:Le.prop)??"a"+Yt,width:(Le==null?void 0:Le.label)==="操作"?"200":Le!=null&&Le.width?parseInt(Le.width):"",fixed:(Le==null?void 0:Le.fixed)??void 0,sortable:(Le==null?void 0:Le.sortable)??!1,align:(Le==null?void 0:Le.align)??"center",showOverflowTooltip:(Le==null?void 0:Le.showOverflowTooltip)??!0,isNotDrag:(Le==null?void 0:Le.isNotDrag)??!1,isEditCol:(Le==null?void 0:Le.isEditCol)??!1,isOperate:(Le==null?void 0:Le.isOperate)??!1,id:(Le==null?void 0:Le.id)??Yt,type:(Le==null?void 0:Le.label)==="操作"?"operate":void 0,formType:(Le==null?void 0:Le.formType)??"",isTableColHidden:Le==null?void 0:Le.isTableColHidden,isFormColHidden:Le==null?void 0:Le.isFormColHidden,options:(Le==null?void 0:Le.options)??[]})})}i.value=Y;let ce=(_e=(Ye=Bn.getAllLeafNodes(qe.cloneDeep(i.value)))==null?void 0:Ye.filter(We=>(We==null?void 0:We.type)!=="operate"))==null?void 0:_e.map((We,Le)=>({prop:(We==null?void 0:We.prop)??"a"+Le,column:We.label}));L.value=ce;let Ce=[];de.value===""?Ce=te==null?void 0:te[0]:Ce=(te==null?void 0:te.find(We=>(We==null?void 0:We.selectLabel)==="("+de.value+")"))??(te==null?void 0:te.find(We=>!(We!=null&&We.selectLabel)));let tt=Array.isArray((Oe=Ce==null?void 0:Ce.contents)==null?void 0:Oe[0])&&((it=Ce==null?void 0:Ce.contents)!=null&&it[0].every(We=>Array.isArray(We)))?(Qe=qe.cloneDeep(Ce==null?void 0:Ce.contents))==null?void 0:Qe[0]:qe.cloneDeep(Ce==null?void 0:Ce.contents);Ne!=null&&Ne.contents&&((Ee=Ne==null?void 0:Ne.contents)==null?void 0:Ee.length)!==0&&(tt=(at=qe.cloneDeep(tt))==null?void 0:at.map((We,Le)=>{if(!Array.isArray(We)){let Yt={};for(let Un in We)Un!=="id"&&Un!=="index"&&(Yt[Un]=We[Un]);We=Object.values(Yt)}return We}));const Lt=!!((B=i.value)!=null&&B.find(We=>We.prop==="index"));tt=Gh(qe.cloneDeep(tt),Ne==null?void 0:Ne.contents,Lt);const ft=[];tt==null||tt.forEach((We,Le)=>{var Un;let Yt={};if(Array.isArray(We)){let Vt=[];We==null||We.filter(hn=>!(hn!=null&&hn.id)).forEach((hn,En)=>{var Ci,li,Pi,ci,ji,qi;if((Ci=ce==null?void 0:ce[En])!=null&&Ci.prop&&!Array.isArray(hn)){let Ki={};Ki[ce[En].column]=hn,l!=null&&l.value&&((li=l==null?void 0:l.value)==null?void 0:li.length)>0&&((Pi=l==null?void 0:l.value)!=null&&Pi.find(_n=>JSON.stringify(_n==null?void 0:_n[0])===JSON.stringify(Ki)))&&(Vt=(ci=l==null?void 0:l.value)==null?void 0:ci.find(_n=>JSON.stringify(_n==null?void 0:_n[0])===JSON.stringify(Ki))),Vt&&Vt.length>0?Yt[ce[En].prop]=Vt!=null&&Vt.find(_n=>{var ui;return((ui=Object.keys(_n))==null?void 0:ui[0])===ce[En].column})?(ji=Vt==null?void 0:Vt.find(_n=>{var ui;return((ui=Object.keys(_n))==null?void 0:ui[0])===ce[En].column}))==null?void 0:ji[ce[En].column]:hn:Yt[ce[En].prop]=hn}else Array.isArray(hn)&&((qi=ce[En])!=null&&qi.prop?Yt[ce[En].prop]=hn:Yt.children=Hh(hn,ce))})}else Yt=We;Array.isArray(We)&&We.some(Vt=>Vt==null?void 0:Vt.id)?ft.push(Object.assign(Yt,{id:(Un=We==null?void 0:We.find(Vt=>Vt.id))==null?void 0:Un.id})):Yt.id?ft.push(Yt):ft.push(Object.assign(Yt,{id:Le}))}),c.value=ft}else i.value=[],c.value=[];((Pe=Q==null?void 0:Q.contents)==null?void 0:Pe.length)>0?x.value=Q==null?void 0:Q.contents:x.value=[],((ye=ee==null?void 0:ee.contents)==null?void 0:ye.length)>0?N.value=ee==null?void 0:ee.contents:N.value=[],f.value=((Be=c==null?void 0:c.value)==null?void 0:Be.length)??0,T.value=c.value},{deep:!0,immediate:!0}),(ne,me)=>{var Q;return V.openBlock(),V.createElementBlock("div",DM,[(V.openBlock(),V.createBlock(Bn.ssTable,{columns:i.value,key:i.value,tableData:c.value,isShowPagination:g.value,isShowEdit:!1,isShowDelete:!1,onDbClickRow:le,extraButton:N.value,onButtonClick:me[1]||(me[1]=ee=>W(ee,"")),onContentClick:be},V.createSlots({headerButton:V.withCtx(ee=>[V.createVNode(Id,{buttons:ee.buttons,onButtonClick:me[0]||(me[0]=te=>W(te,"")),columns:i.value,onFilter:Me},null,8,["buttons","columns"])]),_:2},[((Q=x.value)==null?void 0:Q.length)>0?{name:"actions",fn:V.withCtx(({item:ee})=>[(V.openBlock(!0),V.createElementBlock(V.Fragment,null,V.renderList(G(x.value,ee),(te,I)=>(V.openBlock(),V.createElementBlock("div",{key:I},[V.createElementVNode("div",{style:V.normalizeStyle({color:te==null?void 0:te.textColor}),class:"extra-button-label",onClick:ge=>W(te==null?void 0:te.label,ee)},V.toDisplayString(te==null?void 0:te.label),13,IM)]))),128))]),key:"0"}:void 0]),1032,["columns","tableData","isShowPagination","extraButton"])),V.createVNode(Bn.ssDialog,{title:_.value,visible:m.value,width:k.value,onBeforeDestroy:ae},{default:V.withCtx(()=>[V.createElementVNode("div",NM,[V.createVNode(Bn.ssForm,{rowContents:P.value,isEnableWrap:!1,onChange:Te,isEdit:d.value},null,8,["rowContents","isEdit"])])]),footer:V.withCtx(()=>[y.value?(V.openBlock(),V.createElementBlock("div",UM,[V.createElementVNode("div",{onClick:me[2]||(me[2]=ee=>m.value=!1),class:"cancel-button"},V.toDisplayString("取消")),V.createElementVNode("div",{class:"ok-button",onClick:oe},V.toDisplayString("确认"))])):V.createCommentVNode("",!0)]),_:1},8,["title","visible","width"]),V.createVNode(Bn.ssDialog,{visible:u.value,fullScreen:"",onBeforeDestroy:$},{default:V.withCtx(()=>[V.createVNode(Bh,{isShow:u.value},null,8,["isShow"])]),_:1},8,["visible"])])}}},OM=Rl._export_sfc(FM,[["__scopeId","data-v-3458b8f1"]]);exports.IsJson=mM;exports.addTableContents=wM;exports.conStructContents=TM;exports.deleteTableContents=AM;exports.fixFormContents=CM;exports.fixTableContents=RM;exports.getItemData=qh;exports.loadingSystemType=LM;exports.methodTableToContent=_M;exports.ssTable=OM;exports.tableEveryContents=wl;exports.tableToContents=Al;exports.tableToStruct=vi;exports.threeModel=Bh;exports.useFormToTableComp=zh;exports.useUnit=Vh;
3836
+ */var Vn=Uint8Array,Us=Uint16Array,ov=Int32Array,Ah=new Vn([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),wh=new Vn([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),lv=new Vn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Rh=function(s,e){for(var t=new Us(31),n=0;n<31;++n)t[n]=e+=1<<s[n-1];for(var i=new ov(t[30]),n=1;n<30;++n)for(var r=t[n];r<t[n+1];++r)i[r]=r-t[n]<<5|n;return{b:t,r:i}},Ch=Rh(Ah,2),Ph=Ch.b,cv=Ch.r;Ph[28]=258,cv[258]=28;var uv=Rh(wh,0),hv=uv.b,Tl=new Us(32768);for(var Vt=0;Vt<32768;++Vt){var Oi=(Vt&43690)>>1|(Vt&21845)<<1;Oi=(Oi&52428)>>2|(Oi&13107)<<2,Oi=(Oi&61680)>>4|(Oi&3855)<<4,Tl[Vt]=((Oi&65280)>>8|(Oi&255)<<8)>>1}var fr=function(s,e,t){for(var n=s.length,i=0,r=new Us(e);i<n;++i)s[i]&&++r[s[i]-1];var a=new Us(e);for(i=1;i<e;++i)a[i]=a[i-1]+r[i-1]<<1;var o;if(t){o=new Us(1<<e);var l=15-e;for(i=0;i<n;++i)if(s[i])for(var c=i<<4|s[i],u=e-s[i],h=a[s[i]-1]++<<u,d=h|(1<<u)-1;h<=d;++h)o[Tl[h]>>l]=c}else for(o=new Us(n),i=0;i<n;++i)s[i]&&(o[i]=Tl[a[s[i]-1]++]>>15-s[i]);return o},Nr=new Vn(288);for(var Vt=0;Vt<144;++Vt)Nr[Vt]=8;for(var Vt=144;Vt<256;++Vt)Nr[Vt]=9;for(var Vt=256;Vt<280;++Vt)Nr[Vt]=7;for(var Vt=280;Vt<288;++Vt)Nr[Vt]=8;var Lh=new Vn(32);for(var Vt=0;Vt<32;++Vt)Lh[Vt]=5;var dv=fr(Nr,9,1),fv=fr(Lh,5,1),Ao=function(s){for(var e=s[0],t=1;t<s.length;++t)s[t]>e&&(e=s[t]);return e},Kn=function(s,e,t){var n=e/8|0;return(s[n]|s[n+1]<<8)>>(e&7)&t},wo=function(s,e){var t=e/8|0;return(s[t]|s[t+1]<<8|s[t+2]<<16)>>(e&7)},pv=function(s){return(s+7)/8|0},mv=function(s,e,t){return(t==null||t>s.length)&&(t=s.length),new Vn(s.subarray(e,t))},gv=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Yn=function(s,e,t){var n=new Error(e||gv[s]);if(n.code=s,Error.captureStackTrace&&Error.captureStackTrace(n,Yn),!t)throw n;return n},_v=function(s,e,t,n){var i=s.length,r=0;if(!i||e.f&&!e.l)return t||new Vn(0);var a=!t,o=a||e.i!=2,l=e.i;a&&(t=new Vn(i*3));var c=function($){var Z=t.length;if($>Z){var ie=new Vn(Math.max(Z*2,$));ie.set(t),t=ie}},u=e.f||0,h=e.p||0,d=e.b||0,f=e.l,g=e.d,_=e.m,m=e.n,p=i*8;do{if(!f){u=Kn(s,h,1);var S=Kn(s,h+1,3);if(h+=3,S)if(S==1)f=dv,g=fv,_=9,m=5;else if(S==2){var P=Kn(s,h,31)+257,L=Kn(s,h+10,15)+4,U=P+Kn(s,h+5,31)+1;h+=14;for(var E=new Vn(U),T=new Vn(19),D=0;D<L;++D)T[lv[D]]=Kn(s,h+D*3,7);h+=L*3;for(var X=Ao(T),q=(1<<X)-1,se=fr(T,X,1),D=0;D<U;){var he=se[Kn(s,h,q)];h+=he&15;var v=he>>4;if(v<16)E[D++]=v;else{var k=0,oe=0;for(v==16?(oe=3+Kn(s,h,3),h+=2,k=E[D-1]):v==17?(oe=3+Kn(s,h,7),h+=3):v==18&&(oe=11+Kn(s,h,127),h+=7);oe--;)E[D++]=k}}var G=E.subarray(0,P),fe=E.subarray(P);_=Ao(G),m=Ao(fe),f=fr(G,_,1),g=fr(fe,m,1)}else Yn(1);else{var v=pv(h)+4,y=s[v-4]|s[v-3]<<8,N=v+y;if(N>i){l&&Yn(0);break}o&&c(d+y),t.set(s.subarray(v,N),d),e.b=d+=y,e.p=h=N*8,e.f=u;continue}if(h>p){l&&Yn(0);break}}o&&c(d+131072);for(var ve=(1<<_)-1,le=(1<<m)-1,we=h;;we=h){var k=f[wo(s,h)&ve],Me=k>>4;if(h+=k&15,h>p){l&&Yn(0);break}if(k||Yn(2),Me<256)t[d++]=Me;else if(Me==256){we=h,f=null;break}else{var W=Me-254;if(Me>264){var D=Me-257,ee=Ah[D];W=Kn(s,h,(1<<ee)-1)+Ph[D],h+=ee}var ae=g[wo(s,h)&le],re=ae>>4;ae||Yn(3),h+=ae&15;var fe=hv[re];if(re>3){var ee=wh[re];fe+=wo(s,h)&(1<<ee)-1,h+=ee}if(h>p){l&&Yn(0);break}o&&c(d+131072);var Se=d+W;if(d<fe){var ot=r-fe,J=Math.min(fe,Se);for(ot+d<0&&Yn(3);d<J;++d)t[d]=n[ot+d]}for(;d<Se;++d)t[d]=t[d-fe]}}e.l=f,e.p=we,e.b=d,e.f=u,f&&(u=1,e.m=_,e.d=g,e.n=m)}while(!u);return d!=t.length&&a?mv(t,0,d):t.subarray(0,d)},yv=new Vn(0),vv=function(s,e){return((s[0]&15)!=8||s[0]>>4>7||(s[0]<<8|s[1])%31)&&Yn(6,"invalid zlib data"),(s[1]>>5&1)==1&&Yn(6,"invalid zlib data: "+(s[1]&32?"need":"unexpected")+" dictionary"),(s[1]>>3&4)+2};function xv(s,e){return _v(s.subarray(vv(s),-4),{i:2},e,e)}var Mv=typeof TextDecoder<"u"&&new TextDecoder,Sv=0;try{Mv.decode(yv,{stream:!0}),Sv=1}catch{}function Dh(s,e,t){const n=t.length-s-1;if(e>=t[n])return n-1;if(e<=t[s])return s;let i=s,r=n,a=Math.floor((i+r)/2);for(;e<t[a]||e>=t[a+1];)e<t[a]?r=a:i=a,a=Math.floor((i+r)/2);return a}function Tv(s,e,t,n){const i=[],r=[],a=[];i[0]=1;for(let o=1;o<=t;++o){r[o]=e-n[s+1-o],a[o]=n[s+o]-e;let l=0;for(let c=0;c<o;++c){const u=a[c+1],h=r[o-c],d=i[c]/(u+h);i[c]=l+u*d,l=h*d}i[o]=l}return i}function bv(s,e,t,n){const i=Dh(s,n,e),r=Tv(i,n,s,e),a=new Tt(0,0,0,0);for(let o=0;o<=s;++o){const l=t[i-s+o],c=r[o],u=l.w*c;a.x+=l.x*u,a.y+=l.y*u,a.z+=l.z*u,a.w+=l.w*c}return a}function Ev(s,e,t,n,i){const r=[];for(let h=0;h<=t;++h)r[h]=0;const a=[];for(let h=0;h<=n;++h)a[h]=r.slice(0);const o=[];for(let h=0;h<=t;++h)o[h]=r.slice(0);o[0][0]=1;const l=r.slice(0),c=r.slice(0);for(let h=1;h<=t;++h){l[h]=e-i[s+1-h],c[h]=i[s+h]-e;let d=0;for(let f=0;f<h;++f){const g=c[f+1],_=l[h-f];o[h][f]=g+_;const m=o[f][h-1]/o[h][f];o[f][h]=d+g*m,d=_*m}o[h][h]=d}for(let h=0;h<=t;++h)a[0][h]=o[h][t];for(let h=0;h<=t;++h){let d=0,f=1;const g=[];for(let _=0;_<=t;++_)g[_]=r.slice(0);g[0][0]=1;for(let _=1;_<=n;++_){let m=0;const p=h-_,S=t-_;h>=_&&(g[f][0]=g[d][0]/o[S+1][p],m=g[f][0]*o[p][S]);const v=p>=-1?1:-p,y=h-1<=S?_-1:t-h;for(let P=v;P<=y;++P)g[f][P]=(g[d][P]-g[d][P-1])/o[S+1][p+P],m+=g[f][P]*o[p+P][S];h<=S&&(g[f][_]=-g[d][_-1]/o[S+1][h],m+=g[f][_]*o[h][S]),a[_][h]=m;const N=d;d=f,f=N}}let u=t;for(let h=1;h<=n;++h){for(let d=0;d<=t;++d)a[h][d]*=u;u*=t-h}return a}function Av(s,e,t,n,i){const r=i<s?i:s,a=[],o=Dh(s,n,e),l=Ev(o,n,s,r,e),c=[];for(let u=0;u<t.length;++u){const h=t[u].clone(),d=h.w;h.x*=d,h.y*=d,h.z*=d,c[u]=h}for(let u=0;u<=r;++u){const h=c[o-s].clone().multiplyScalar(l[u][0]);for(let d=1;d<=s;++d)h.add(c[o-s+d].clone().multiplyScalar(l[u][d]));a[u]=h}for(let u=r+1;u<=i+1;++u)a[u]=new Tt(0,0,0);return a}function wv(s,e){let t=1;for(let i=2;i<=s;++i)t*=i;let n=1;for(let i=2;i<=e;++i)n*=i;for(let i=2;i<=s-e;++i)n*=i;return t/n}function Rv(s){const e=s.length,t=[],n=[];for(let r=0;r<e;++r){const a=s[r];t[r]=new O(a.x,a.y,a.z),n[r]=a.w}const i=[];for(let r=0;r<e;++r){const a=t[r].clone();for(let o=1;o<=r;++o)a.sub(i[r-o].clone().multiplyScalar(wv(r,o)*n[o]));i[r]=a.divideScalar(n[0])}return i}function Cv(s,e,t,n,i){const r=Av(s,e,t,n,i);return Rv(r)}class Pv extends Mp{constructor(e,t,n,i,r){super();const a=t?t.length-1:0,o=n?n.length:0;this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=i||0,this.endKnot=r||a;for(let l=0;l<o;++l){const c=n[l];this.controlPoints[l]=new Tt(c.x,c.y,c.z,c.w)}}getPoint(e,t=new O){const n=t,i=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),r=bv(this.degree,this.knots,this.controlPoints,i);return r.w!==1&&r.divideScalar(r.w),n.set(r.x,r.y,r.z)}getTangent(e,t=new O){const n=t,i=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),r=Cv(this.degree,this.knots,this.controlPoints,i,1);return n.copy(r[1]).normalize(),n}toJSON(){const e=super.toJSON();return e.degree=this.degree,e.knots=[...this.knots],e.controlPoints=this.controlPoints.map(t=>t.toArray()),e.startKnot=this.startKnot,e.endKnot=this.endKnot,e}fromJSON(e){return super.fromJSON(e),this.degree=e.degree,this.knots=[...e.knots],this.controlPoints=e.controlPoints.map(t=>new Tt(t[0],t[1],t[2],t[3])),this.startKnot=e.startKnot,this.endKnot=e.endKnot,this}}let Mt,qt,bn;class Lv extends wn{constructor(e){super(e)}load(e,t,n,i){const r=this,a=r.path===""?os.extractUrlBase(e):r.path,o=new Xi(this.manager);o.setPath(r.path),o.setResponseType("arraybuffer"),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,function(l){try{t(r.parse(l,a))}catch(c){i?i(c):console.error(c),r.manager.itemError(e)}},n,i)}parse(e,t){if(Ov(e))Mt=new Fv().parse(e);else{const i=Uh(e);if(!kv(i))throw new Error("THREE.FBXLoader: Unknown format.");if(Pu(i)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+Pu(i));Mt=new Uv().parse(i)}const n=new Xl(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new Dv(n,this.manager).parse(Mt)}}class Dv{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){qt=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),i=this.parseDeformers(),r=new Iv().parse(i);return this.parseScene(i,r,n),bn}parseConnections(){const e=new Map;return"Connections"in Mt&&Mt.Connections.connections.forEach(function(n){const i=n[0],r=n[1],a=n[2];e.has(i)||e.set(i,{parents:[],children:[]});const o={ID:r,relationship:a};e.get(i).parents.push(o),e.has(r)||e.set(r,{parents:[],children:[]});const l={ID:i,relationship:a};e.get(r).children.push(l)}),e}parseImages(){const e={},t={};if("Video"in Mt.Objects){const n=Mt.Objects.Video;for(const i in n){const r=n[i],a=parseInt(i);if(e[a]=r.RelativeFilename||r.Filename,"Content"in r){const o=r.Content instanceof ArrayBuffer&&r.Content.byteLength>0,l=typeof r.Content=="string"&&r.Content!=="";if(o||l){const c=this.parseImage(n[i]);t[r.RelativeFilename||r.Filename]=c}}}}for(const n in e){const i=e[n];t[i]!==void 0?e[n]=t[i]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,i=n.slice(n.lastIndexOf(".")+1).toLowerCase();let r;switch(i){case"bmp":r="image/bmp";break;case"jpg":case"jpeg":r="image/jpeg";break;case"png":r="image/png";break;case"tif":r="image/tiff";break;case"tga":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",n),r="image/tga";break;case"webp":r="image/webp";break;default:console.warn('FBXLoader: Image type "'+i+'" is not supported.');return}if(typeof t=="string")return"data:"+r+";base64,"+t;{const a=new Uint8Array(t);return window.URL.createObjectURL(new Blob([a],{type:r}))}}parseTextures(e){const t=new Map;if("Texture"in Mt.Objects){const n=Mt.Objects.Texture;for(const i in n){const r=this.parseTexture(n[i],e);t.set(parseInt(i),r)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const i=e.WrapModeU,r=e.WrapModeV,a=i!==void 0?i.value:0,o=r!==void 0?r.value:0;if(n.wrapS=a===0?Hn:Dn,n.wrapT=o===0?Hn:Dn,"Scaling"in e){const l=e.Scaling.value;n.repeat.x=l[0],n.repeat.y=l[1]}if("Translation"in e){const l=e.Translation.value;n.offset.x=l[0],n.offset.y=l[1]}return n}loadTexture(e,t){const n=e.FileName.split(".").pop().toLowerCase();let i=this.manager.getHandler(`.${n}`);i===null&&(i=this.textureLoader);const r=i.path;r||i.setPath(this.textureLoader.path);const a=qt.get(e.id).children;let o;if(a!==void 0&&a.length>0&&t[a[0].ID]!==void 0&&(o=t[a[0].ID],(o.indexOf("blob:")===0||o.indexOf("data:")===0)&&i.setPath(void 0)),o===void 0)return console.warn("FBXLoader: Undefined filename, creating placeholder texture."),new an;const l=i.load(o);return i.setPath(r),l}parseMaterials(e){const t=new Map;if("Material"in Mt.Objects){const n=Mt.Objects.Material;for(const i in n){const r=this.parseMaterial(n[i],e);r!==null&&t.set(parseInt(i),r)}}return t}parseMaterial(e,t){const n=e.id,i=e.attrName;let r=e.ShadingModel;if(typeof r=="object"&&(r=r.value),!qt.has(n))return null;const a=this.parseParameters(e,t,n);let o;switch(r.toLowerCase()){case"phong":o=new as;break;case"lambert":o=new yh;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',r),o=new as;break}return o.setValues(a),o.name=i,o}parseParameters(e,t,n){const i={};e.BumpFactor&&(i.bumpScale=e.BumpFactor.value),e.Diffuse?i.color=ft.colorSpaceToWorking(new Ge().fromArray(e.Diffuse.value),_t):e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(i.color=ft.colorSpaceToWorking(new Ge().fromArray(e.DiffuseColor.value),_t)),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=ft.colorSpaceToWorking(new Ge().fromArray(e.Emissive.value),_t):e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(i.emissive=ft.colorSpaceToWorking(new Ge().fromArray(e.EmissiveColor.value),_t)),e.EmissiveFactor&&(i.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),i.opacity=1-(e.TransparencyFactor?parseFloat(e.TransparencyFactor.value):0),(i.opacity===1||i.opacity===0)&&(i.opacity=e.Opacity?parseFloat(e.Opacity.value):null,i.opacity===null&&(i.opacity=1-(e.TransparentColor?parseFloat(e.TransparentColor.value[0]):0))),i.opacity<1&&(i.transparent=!0),e.ReflectionFactor&&(i.reflectivity=e.ReflectionFactor.value),e.Shininess&&(i.shininess=e.Shininess.value),e.Specular?i.specular=ft.colorSpaceToWorking(new Ge().fromArray(e.Specular.value),_t):e.SpecularColor&&e.SpecularColor.type==="Color"&&(i.specular=ft.colorSpaceToWorking(new Ge().fromArray(e.SpecularColor.value),_t));const r=this;return qt.get(n).children.forEach(function(a){const o=a.relationship;switch(o){case"Bump":i.bumpMap=r.getTexture(t,a.ID);break;case"Maya|TEX_ao_map":i.aoMap=r.getTexture(t,a.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":i.map=r.getTexture(t,a.ID),i.map!==void 0&&(i.map.colorSpace=_t);break;case"DisplacementColor":i.displacementMap=r.getTexture(t,a.ID);break;case"EmissiveColor":i.emissiveMap=r.getTexture(t,a.ID),i.emissiveMap!==void 0&&(i.emissiveMap.colorSpace=_t);break;case"NormalMap":case"Maya|TEX_normal_map":i.normalMap=r.getTexture(t,a.ID);break;case"ReflectionColor":i.envMap=r.getTexture(t,a.ID),i.envMap!==void 0&&(i.envMap.mapping=ba,i.envMap.colorSpace=_t);break;case"SpecularColor":i.specularMap=r.getTexture(t,a.ID),i.specularMap!==void 0&&(i.specularMap.colorSpace=_t);break;case"TransparentColor":case"TransparencyFactor":i.alphaMap=r.getTexture(t,a.ID),i.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",o);break}}),i}getTexture(e,t){return"LayeredTexture"in Mt.Objects&&t in Mt.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=qt.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in Mt.Objects){const n=Mt.Objects.Deformer;for(const i in n){const r=n[i],a=qt.get(parseInt(i));if(r.attrType==="Skin"){const o=this.parseSkeleton(a,n);o.ID=i,a.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),o.geometryID=a.parents[0].ID,e[i]=o}else if(r.attrType==="BlendShape"){const o={id:i};o.rawTargets=this.parseMorphTargets(a,n),o.id=i,a.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[i]=o}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach(function(i){const r=t[i.ID];if(r.attrType!=="Cluster")return;const a={ID:i.ID,indices:[],weights:[],transformLink:new Fe().fromArray(r.TransformLink.a)};"Indexes"in r&&(a.indices=r.Indexes.a,a.weights=r.Weights.a),n.push(a)}),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let i=0;i<e.children.length;i++){const r=e.children[i],a=t[r.ID],o={name:a.attrName,initialWeight:a.DeformPercent,id:a.id,fullWeights:a.FullWeights.a};if(a.attrType!=="BlendShapeChannel")return;o.geoID=qt.get(parseInt(r.ID)).children.filter(function(l){return l.relationship===void 0})[0].ID,n.push(o)}return n}parseScene(e,t,n){bn=new Wn;const i=this.parseModels(e.skeletons,t,n),r=Mt.Objects.Model,a=this;i.forEach(function(l){const c=r[l.ID];a.setLookAtProperties(l,c),qt.get(l.ID).parents.forEach(function(h){const d=i.get(h.ID);d!==void 0&&d.add(l)}),l.parent===null&&bn.add(l)}),this.bindSkeleton(e.skeletons,t,i),this.addGlobalSceneSettings(),bn.traverse(function(l){if(l.userData.transformData){l.parent&&(l.userData.transformData.parentMatrix=l.parent.matrix,l.userData.transformData.parentMatrixWorld=l.parent.matrixWorld);const c=Nh(l.userData.transformData);l.applyMatrix4(c),l.updateWorldMatrix()}});const o=new Nv().parse();bn.children.length===1&&bn.children[0].isGroup&&(bn.children[0].animations=o,bn=bn.children[0]),bn.animations=o}parseModels(e,t,n){const i=new Map,r=Mt.Objects.Model;for(const a in r){const o=parseInt(a),l=r[a],c=qt.get(o);let u=this.buildSkeleton(c,e,o,l.attrName);if(!u){switch(l.attrType){case"Camera":u=this.createCamera(c);break;case"Light":u=this.createLight(c);break;case"Mesh":u=this.createMesh(c,t,n);break;case"NurbsCurve":u=this.createCurve(c,t);break;case"LimbNode":case"Root":u=new Mr;break;case"Null":default:u=new Wn;break}u.name=l.attrName?wt.sanitizeNodeName(l.attrName):"",u.userData.originalName=l.attrName,u.ID=o}this.getTransformData(u,l),i.set(o,u)}return i}buildSkeleton(e,t,n,i){let r=null;return e.parents.forEach(function(a){for(const o in t){const l=t[o];l.rawBones.forEach(function(c,u){if(c.ID===a.ID){const h=r;r=new Mr,r.matrixWorld.copy(c.transformLink),r.name=i?wt.sanitizeNodeName(i):"",r.userData.originalName=i,r.ID=n,l.bones[u]=r,h!==null&&r.add(h)}})}}),r}createCamera(e){let t,n;if(e.children.forEach(function(i){const r=Mt.Objects.NodeAttribute[i.ID];r!==void 0&&(n=r)}),n===void 0)t=new kt;else{let i=0;n.CameraProjectionType!==void 0&&n.CameraProjectionType.value===1&&(i=1);let r=1;n.NearPlane!==void 0&&(r=n.NearPlane.value/1e3);let a=1e3;n.FarPlane!==void 0&&(a=n.FarPlane.value/1e3);let o=window.innerWidth,l=window.innerHeight;n.AspectWidth!==void 0&&n.AspectHeight!==void 0&&(o=n.AspectWidth.value,l=n.AspectHeight.value);const c=o/l;let u=45;n.FieldOfView!==void 0&&(u=n.FieldOfView.value);const h=n.FocalLength?n.FocalLength.value:null;switch(i){case 0:t=new un(u,c,r,a),h!==null&&t.setFocalLength(h);break;case 1:console.warn("THREE.FBXLoader: Orthographic cameras not supported yet."),t=new kt;break;default:console.warn("THREE.FBXLoader: Unknown camera type "+i+"."),t=new kt;break}}return t}createLight(e){let t,n;if(e.children.forEach(function(i){const r=Mt.Objects.NodeAttribute[i.ID];r!==void 0&&(n=r)}),n===void 0)t=new kt;else{let i;n.LightType===void 0?i=0:i=n.LightType.value;let r=16777215;n.Color!==void 0&&(r=ft.colorSpaceToWorking(new Ge().fromArray(n.Color.value),_t));let a=n.Intensity===void 0?1:n.Intensity.value/100;n.CastLightOnObject!==void 0&&n.CastLightOnObject.value===0&&(a=0);let o=0;n.FarAttenuationEnd!==void 0&&(n.EnableFarAttenuation!==void 0&&n.EnableFarAttenuation.value===0?o=0:o=n.FarAttenuationEnd.value);const l=1;switch(i){case 0:t=new La(r,a,o,l);break;case 1:t=new Ar(r,a);break;case 2:let c=Math.PI/3;n.InnerAngle!==void 0&&(c=Xt.degToRad(n.InnerAngle.value));let u=0;n.OuterAngle!==void 0&&(u=Xt.degToRad(n.OuterAngle.value),u=Math.max(u,1)),t=new ql(r,a,o,c,u,l);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new La(r,a);break}n.CastShadows!==void 0&&n.CastShadows.value===1&&(t.castShadow=!0)}return t}createMesh(e,t,n){let i,r=null,a=null;const o=[];if(e.children.forEach(function(l){t.has(l.ID)&&(r=t.get(l.ID)),n.has(l.ID)&&o.push(n.get(l.ID))}),o.length>1?a=o:o.length>0?a=o[0]:(a=new as({name:wn.DEFAULT_MATERIAL_NAME,color:13421772}),o.push(a)),"color"in r.attributes&&o.forEach(function(l){l.vertexColors=!0}),r.groups.length>0){let l=!1;for(let c=0,u=r.groups.length;c<u;c++){const h=r.groups[c];(h.materialIndex<0||h.materialIndex>=o.length)&&(h.materialIndex=o.length,l=!0)}if(l){const c=new as;o.push(c)}}return r.FBX_Deformer?(i=new Vl(r,a),i.normalizeSkinWeights()):i=new rn(r,a),i}createCurve(e,t){const n=e.children.reduce(function(r,a){return t.has(a.ID)&&(r=t.get(a.ID)),r},null),i=new si({name:wn.DEFAULT_MATERIAL_NAME,color:3342591,linewidth:1});return new Dr(n,i)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),"RotationOrder"in t?n.eulerOrder=wr(t.RotationOrder.value):n.eulerOrder=wr(0),"Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){"LookAtProperty"in t&&qt.get(e.ID).children.forEach(function(i){if(i.relationship==="LookAtProperty"){const r=Mt.Objects.Model[i.ID];if("Lcl_Translation"in r){const a=r.Lcl_Translation.value;e.target!==void 0?(e.target.position.fromArray(a),bn.add(e.target)):e.lookAt(new O().fromArray(a))}}})}bindSkeleton(e,t,n){const i=this.parsePoseNodes();for(const r in e){const a=e[r];qt.get(parseInt(a.ID)).parents.forEach(function(l){if(t.has(l.ID)){const c=l.ID;qt.get(c).parents.forEach(function(h){n.has(h.ID)&&n.get(h.ID).bind(new Lr(a.bones),i[h.ID])})}})}}parsePoseNodes(){const e={};if("Pose"in Mt.Objects){const t=Mt.Objects.Pose;for(const n in t)if(t[n].attrType==="BindPose"&&t[n].NbPoseNodes>0){const i=t[n].PoseNode;Array.isArray(i)?i.forEach(function(r){e[r.Node]=new Fe().fromArray(r.Matrix.a)}):e[i.Node]=new Fe().fromArray(i.Matrix.a)}}return e}addGlobalSceneSettings(){if("GlobalSettings"in Mt){if("AmbientColor"in Mt.GlobalSettings){const e=Mt.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],i=e[2];if(t!==0||n!==0||i!==0){const r=new Ge().setRGB(t,n,i,_t);bn.add(new Kl(r,1))}}"UnitScaleFactor"in Mt.GlobalSettings&&(bn.userData.unitScaleFactor=Mt.GlobalSettings.UnitScaleFactor.value)}}}class Iv{constructor(){this.negativeMaterialIndices=!1}parse(e){const t=new Map;if("Geometry"in Mt.Objects){const n=Mt.Objects.Geometry;for(const i in n){const r=qt.get(parseInt(i)),a=this.parseGeometry(r,n[i],e);t.set(parseInt(i),a)}}return this.negativeMaterialIndices===!0&&console.warn("THREE.FBXLoader: The FBX file contains invalid (negative) material indices. The asset might not render as expected."),t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const i=n.skeletons,r=[],a=e.parents.map(function(h){return Mt.Objects.Model[h.ID]});if(a.length===0)return;const o=e.children.reduce(function(h,d){return i[d.ID]!==void 0&&(h=i[d.ID]),h},null);e.children.forEach(function(h){n.morphTargets[h.ID]!==void 0&&r.push(n.morphTargets[h.ID])});const l=a[0],c={};"RotationOrder"in l&&(c.eulerOrder=wr(l.RotationOrder.value)),"InheritType"in l&&(c.inheritType=parseInt(l.InheritType.value)),"GeometricTranslation"in l&&(c.translation=l.GeometricTranslation.value),"GeometricRotation"in l&&(c.rotation=l.GeometricRotation.value),"GeometricScaling"in l&&(c.scale=l.GeometricScaling.value);const u=Nh(c);return this.genGeometry(t,o,r,u)}genGeometry(e,t,n,i){const r=new Kt;e.attrName&&(r.name=e.attrName);const a=this.parseGeoNode(e,t),o=this.genBuffers(a),l=new vt(o.vertex,3);if(l.applyMatrix4(i),r.setAttribute("position",l),o.colors.length>0&&r.setAttribute("color",new vt(o.colors,3)),t&&(r.setAttribute("skinIndex",new Bl(o.weightsIndices,4)),r.setAttribute("skinWeight",new vt(o.vertexWeights,4)),r.FBX_Deformer=t),o.normal.length>0){const c=new gt().getNormalMatrix(i),u=new vt(o.normal,3);u.applyNormalMatrix(c),r.setAttribute("normal",u)}if(o.uvs.forEach(function(c,u){const h=u===0?"uv":`uv${u}`;r.setAttribute(h,new vt(o.uvs[u],2))}),a.material&&a.material.mappingType!=="AllSame"){let c=o.materialIndex[0],u=0;if(o.materialIndex.forEach(function(h,d){h!==c&&(r.addGroup(u,d-u,c),c=h,u=d)}),r.groups.length>0){const h=r.groups[r.groups.length-1],d=h.start+h.count;d!==o.materialIndex.length&&r.addGroup(d,o.materialIndex.length-d,c)}r.groups.length===0&&r.addGroup(0,o.materialIndex.length,o.materialIndex[0])}return this.addMorphTargets(r,e,n,i),r}parseGeoNode(e,t){const n={};if(n.vertexPositions=e.Vertices!==void 0?e.Vertices.a:[],n.vertexIndices=e.PolygonVertexIndex!==void 0?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let i=0;for(;e.LayerElementUV[i];)e.LayerElementUV[i].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[i])),i++}return n.weightTable={},t!==null&&(n.skeleton=t,t.rawBones.forEach(function(i,r){i.indices.forEach(function(a,o){n.weightTable[a]===void 0&&(n.weightTable[a]=[]),n.weightTable[a].push({id:r,weight:i.weights[o]})})})),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,i=0,r=!1,a=[],o=[],l=[],c=[],u=[],h=[];const d=this;return e.vertexIndices.forEach(function(f,g){let _,m=!1;f<0&&(f=f^-1,m=!0);let p=[],S=[];if(a.push(f*3,f*3+1,f*3+2),e.color){const v=fa(g,n,f,e.color);l.push(v[0],v[1],v[2])}if(e.skeleton){if(e.weightTable[f]!==void 0&&e.weightTable[f].forEach(function(v){S.push(v.weight),p.push(v.id)}),S.length>4){r||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),r=!0);const v=[0,0,0,0],y=[0,0,0,0];S.forEach(function(N,P){let L=N,U=p[P];y.forEach(function(E,T,D){if(L>E){D[T]=L,L=E;const X=v[T];v[T]=U,U=X}})}),p=v,S=y}for(;S.length<4;)S.push(0),p.push(0);for(let v=0;v<4;++v)u.push(S[v]),h.push(p[v])}if(e.normal){const v=fa(g,n,f,e.normal);o.push(v[0],v[1],v[2])}e.material&&e.material.mappingType!=="AllSame"&&(_=fa(g,n,f,e.material)[0],_<0&&(d.negativeMaterialIndices=!0,_=0)),e.uv&&e.uv.forEach(function(v,y){const N=fa(g,n,f,v);c[y]===void 0&&(c[y]=[]),c[y].push(N[0]),c[y].push(N[1])}),i++,m&&(d.genFace(t,e,a,_,o,l,c,u,h,i),n++,i=0,a=[],o=[],l=[],c=[],u=[],h=[])}),t}getNormalNewell(e){const t=new O(0,0,0);for(let n=0;n<e.length;n++){const i=e[n],r=e[(n+1)%e.length];t.x+=(i.y-r.y)*(i.z+r.z),t.y+=(i.z-r.z)*(i.x+r.x),t.z+=(i.x-r.x)*(i.y+r.y)}return t.normalize(),t}getNormalTangentAndBitangent(e){const t=this.getNormalNewell(e),i=(Math.abs(t.z)>.5?new O(0,1,0):new O(0,0,1)).cross(t).normalize(),r=t.clone().cross(i).normalize();return{normal:t,tangent:i,bitangent:r}}flattenVertex(e,t,n){return new ct(e.dot(t),e.dot(n))}genFace(e,t,n,i,r,a,o,l,c,u){let h;if(u>3){const d=[],f=t.baseVertexPositions||t.vertexPositions;for(let p=0;p<n.length;p+=3)d.push(new O(f[n[p]],f[n[p+1]],f[n[p+2]]));const{tangent:g,bitangent:_}=this.getNormalTangentAndBitangent(d),m=[];for(const p of d)m.push(this.flattenVertex(p,g,_));h=Wl.triangulateShape(m,[])}else h=[[0,1,2]];for(const[d,f,g]of h)e.vertex.push(t.vertexPositions[n[d*3]]),e.vertex.push(t.vertexPositions[n[d*3+1]]),e.vertex.push(t.vertexPositions[n[d*3+2]]),e.vertex.push(t.vertexPositions[n[f*3]]),e.vertex.push(t.vertexPositions[n[f*3+1]]),e.vertex.push(t.vertexPositions[n[f*3+2]]),e.vertex.push(t.vertexPositions[n[g*3]]),e.vertex.push(t.vertexPositions[n[g*3+1]]),e.vertex.push(t.vertexPositions[n[g*3+2]]),t.skeleton&&(e.vertexWeights.push(l[d*4]),e.vertexWeights.push(l[d*4+1]),e.vertexWeights.push(l[d*4+2]),e.vertexWeights.push(l[d*4+3]),e.vertexWeights.push(l[f*4]),e.vertexWeights.push(l[f*4+1]),e.vertexWeights.push(l[f*4+2]),e.vertexWeights.push(l[f*4+3]),e.vertexWeights.push(l[g*4]),e.vertexWeights.push(l[g*4+1]),e.vertexWeights.push(l[g*4+2]),e.vertexWeights.push(l[g*4+3]),e.weightsIndices.push(c[d*4]),e.weightsIndices.push(c[d*4+1]),e.weightsIndices.push(c[d*4+2]),e.weightsIndices.push(c[d*4+3]),e.weightsIndices.push(c[f*4]),e.weightsIndices.push(c[f*4+1]),e.weightsIndices.push(c[f*4+2]),e.weightsIndices.push(c[f*4+3]),e.weightsIndices.push(c[g*4]),e.weightsIndices.push(c[g*4+1]),e.weightsIndices.push(c[g*4+2]),e.weightsIndices.push(c[g*4+3])),t.color&&(e.colors.push(a[d*3]),e.colors.push(a[d*3+1]),e.colors.push(a[d*3+2]),e.colors.push(a[f*3]),e.colors.push(a[f*3+1]),e.colors.push(a[f*3+2]),e.colors.push(a[g*3]),e.colors.push(a[g*3+1]),e.colors.push(a[g*3+2])),t.material&&t.material.mappingType!=="AllSame"&&(e.materialIndex.push(i),e.materialIndex.push(i),e.materialIndex.push(i)),t.normal&&(e.normal.push(r[d*3]),e.normal.push(r[d*3+1]),e.normal.push(r[d*3+2]),e.normal.push(r[f*3]),e.normal.push(r[f*3+1]),e.normal.push(r[f*3+2]),e.normal.push(r[g*3]),e.normal.push(r[g*3+1]),e.normal.push(r[g*3+2])),t.uv&&t.uv.forEach(function(_,m){e.uvs[m]===void 0&&(e.uvs[m]=[]),e.uvs[m].push(o[m][d*2]),e.uvs[m].push(o[m][d*2+1]),e.uvs[m].push(o[m][f*2]),e.uvs[m].push(o[m][f*2+1]),e.uvs[m].push(o[m][g*2]),e.uvs[m].push(o[m][g*2+1])})}addMorphTargets(e,t,n,i){if(n.length===0)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const r=this;n.forEach(function(a){a.rawTargets.forEach(function(o){const l=Mt.Objects.Geometry[o.geoID];l!==void 0&&r.genMorphGeometry(e,t,l,i,o.name)})})}genMorphGeometry(e,t,n,i,r){const a=t.Vertices!==void 0?t.Vertices.a:[],o=t.PolygonVertexIndex!==void 0?t.PolygonVertexIndex.a:[],l=n.Vertices!==void 0?n.Vertices.a:[],c=n.Indexes!==void 0?n.Indexes.a:[],u=e.attributes.position.count*3,h=new Float32Array(u);for(let _=0;_<c.length;_++){const m=c[_]*3;h[m]=l[_*3],h[m+1]=l[_*3+1],h[m+2]=l[_*3+2]}const d={vertexIndices:o,vertexPositions:h,baseVertexPositions:a},f=this.genBuffers(d),g=new vt(f.vertex,3);g.name=r||n.attrName,g.applyMatrix4(i),e.morphAttributes.position.push(g)}parseNormals(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.Normals.a;let r=[];return n==="IndexToDirect"&&("NormalIndex"in e?r=e.NormalIndex.a:"NormalsIndex"in e&&(r=e.NormalsIndex.a)),{dataSize:3,buffer:i,indices:r,mappingType:t,referenceType:n}}parseUVs(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.UV.a;let r=[];return n==="IndexToDirect"&&(r=e.UVIndex.a),{dataSize:2,buffer:i,indices:r,mappingType:t,referenceType:n}}parseVertexColors(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.Colors.a;let r=[];n==="IndexToDirect"&&(r=e.ColorIndex.a);for(let a=0,o=new Ge;a<i.length;a+=4)o.fromArray(i,a),ft.colorSpaceToWorking(o,_t),o.toArray(i,a);return{dataSize:4,buffer:i,indices:r,mappingType:t,referenceType:n}}parseMaterialIndices(e){const t=e.MappingInformationType,n=e.ReferenceInformationType;if(t==="NoMappingInformation")return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const i=e.Materials.a,r=[];for(let a=0;a<i.length;++a)r.push(a);return{dataSize:1,buffer:i,indices:r,mappingType:t,referenceType:n}}parseNurbsGeometry(e){const t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new Kt;const n=t-1,i=e.KnotVector.a,r=[],a=e.Points.a;for(let h=0,d=a.length;h<d;h+=4)r.push(new Tt().fromArray(a,h));let o,l;if(e.Form==="Closed")r.push(r[0]);else if(e.Form==="Periodic"){o=n,l=i.length-1-o;for(let h=0;h<n;++h)r.push(r[h])}const u=new Pv(n,i,r,o,l).getPoints(r.length*12);return new Kt().setFromPoints(u)}}class Nv{parse(){const e=[],t=this.parseClips();if(t!==void 0)for(const n in t){const i=t[n],r=this.addClip(i);e.push(r)}return e}parseClips(){if(Mt.Objects.AnimationCurve===void 0)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=Mt.Objects.AnimationCurveNode,t=new Map;for(const n in e){const i=e[n];if(i.attrName.match(/S|R|T|DeformPercent/)!==null){const r={id:i.id,attr:i.attrName,curves:{}};t.set(r.id,r)}}return t}parseAnimationCurves(e){const t=Mt.Objects.AnimationCurve;for(const n in t){const i={id:t[n].id,times:t[n].KeyTime.a.map(Bv),values:t[n].KeyValueFloat.a},r=qt.get(i.id);if(r!==void 0){const a=r.parents[0].ID,o=r.parents[0].relationship;o.match(/X/)?e.get(a).curves.x=i:o.match(/Y/)?e.get(a).curves.y=i:o.match(/Z/)?e.get(a).curves.z=i:o.match(/DeformPercent/)&&e.has(a)&&(e.get(a).curves.morph=i)}}}parseAnimationLayers(e){const t=Mt.Objects.AnimationLayer,n=new Map;for(const i in t){const r=[],a=qt.get(parseInt(i));a!==void 0&&(a.children.forEach(function(l,c){if(e.has(l.ID)){const u=e.get(l.ID);if(u.curves.x!==void 0||u.curves.y!==void 0||u.curves.z!==void 0){if(r[c]===void 0){const h=qt.get(l.ID).parents.filter(function(d){return d.relationship!==void 0})[0].ID;if(h!==void 0){const d=Mt.Objects.Model[h.toString()];if(d===void 0){console.warn("THREE.FBXLoader: Encountered a unused curve.",l);return}const f={modelName:d.attrName?wt.sanitizeNodeName(d.attrName):"",ID:d.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};bn.traverse(function(g){g.ID===d.id&&(f.transform=g.matrix,g.userData.transformData&&(f.eulerOrder=g.userData.transformData.eulerOrder))}),f.transform||(f.transform=new Fe),"PreRotation"in d&&(f.preRotation=d.PreRotation.value),"PostRotation"in d&&(f.postRotation=d.PostRotation.value),r[c]=f}}r[c]&&(r[c][u.attr]=u)}else if(u.curves.morph!==void 0){if(r[c]===void 0){const h=qt.get(l.ID).parents.filter(function(p){return p.relationship!==void 0})[0].ID,d=qt.get(h).parents[0].ID,f=qt.get(d).parents[0].ID,g=qt.get(f).parents[0].ID,_=Mt.Objects.Model[g],m={modelName:_.attrName?wt.sanitizeNodeName(_.attrName):"",morphName:Mt.Objects.Deformer[h].attrName};r[c]=m}r[c][u.attr]=u}}}),n.set(parseInt(i),r))}return n}parseAnimStacks(e){const t=Mt.Objects.AnimationStack,n={};for(const i in t){const r=qt.get(parseInt(i)).children;r.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const a=e.get(r[0].ID);n[i]={name:t[i].attrName,layer:a}}return n}addClip(e){let t=[];const n=this;return e.layer.forEach(function(i){t=t.concat(n.generateTracks(i))}),new Pa(e.name,-1,t)}generateTracks(e){const t=[];let n=new O,i=new O;if(e.transform&&e.transform.decompose(n,new nn,i),n=n.toArray(),i=i.toArray(),e.T!==void 0&&Object.keys(e.T.curves).length>0){const r=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");r!==void 0&&t.push(r)}if(e.R!==void 0&&Object.keys(e.R.curves).length>0){const r=this.generateRotationTrack(e.modelName,e.R.curves,e.preRotation,e.postRotation,e.eulerOrder);r!==void 0&&t.push(r)}if(e.S!==void 0&&Object.keys(e.S.curves).length>0){const r=this.generateVectorTrack(e.modelName,e.S.curves,i,"scale");r!==void 0&&t.push(r)}if(e.DeformPercent!==void 0){const r=this.generateMorphTrack(e);r!==void 0&&t.push(r)}return t}generateVectorTrack(e,t,n,i){const r=this.getTimesForAllAxes(t),a=this.getKeyframeTrackValues(r,t,n);return new Ri(e+"."+i,r,a)}generateRotationTrack(e,t,n,i,r){let a,o;if(t.x!==void 0&&t.y!==void 0&&t.z!==void 0){const d=this.interpolateRotations(t.x,t.y,t.z,r);a=d[0],o=d[1]}const l=wr(0);n!==void 0&&(n=n.map(Xt.degToRad),n.push(l),n=new sn().fromArray(n),n=new nn().setFromEuler(n)),i!==void 0&&(i=i.map(Xt.degToRad),i.push(l),i=new sn().fromArray(i),i=new nn().setFromEuler(i).invert());const c=new nn,u=new sn,h=[];if(!o||!a)return new wi(e+".quaternion",[0],[0]);for(let d=0;d<o.length;d+=3)u.set(o[d],o[d+1],o[d+2],r),c.setFromEuler(u),n!==void 0&&c.premultiply(n),i!==void 0&&c.multiply(i),d>2&&new nn().fromArray(h,(d-3)/3*4).dot(c)<0&&c.set(-c.x,-c.y,-c.z,-c.w),c.toArray(h,d/3*4);return new wi(e+".quaternion",a,h)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map(function(r){return r/100}),i=bn.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new hs(e.modelName+".morphTargetInfluences["+i+"]",t.times,n)}getTimesForAllAxes(e){let t=[];if(e.x!==void 0&&(t=t.concat(e.x.times)),e.y!==void 0&&(t=t.concat(e.y.times)),e.z!==void 0&&(t=t.concat(e.z.times)),t=t.sort(function(n,i){return n-i}),t.length>1){let n=1,i=t[0];for(let r=1;r<t.length;r++){const a=t[r];a!==i&&(t[n]=a,i=a,n++)}t=t.slice(0,n)}return t}getKeyframeTrackValues(e,t,n){const i=n,r=[];let a=-1,o=-1,l=-1;return e.forEach(function(c){if(t.x&&(a=t.x.times.indexOf(c)),t.y&&(o=t.y.times.indexOf(c)),t.z&&(l=t.z.times.indexOf(c)),a!==-1){const u=t.x.values[a];r.push(u),i[0]=u}else r.push(i[0]);if(o!==-1){const u=t.y.values[o];r.push(u),i[1]=u}else r.push(i[1]);if(l!==-1){const u=t.z.values[l];r.push(u),i[2]=u}else r.push(i[2])}),r}interpolateRotations(e,t,n,i){const r=[],a=[];r.push(e.times[0]),a.push(Xt.degToRad(e.values[0])),a.push(Xt.degToRad(t.values[0])),a.push(Xt.degToRad(n.values[0]));for(let o=1;o<e.values.length;o++){const l=[e.values[o-1],t.values[o-1],n.values[o-1]];if(isNaN(l[0])||isNaN(l[1])||isNaN(l[2]))continue;const c=l.map(Xt.degToRad),u=[e.values[o],t.values[o],n.values[o]];if(isNaN(u[0])||isNaN(u[1])||isNaN(u[2]))continue;const h=u.map(Xt.degToRad),d=[u[0]-l[0],u[1]-l[1],u[2]-l[2]],f=[Math.abs(d[0]),Math.abs(d[1]),Math.abs(d[2])];if(f[0]>=180||f[1]>=180||f[2]>=180){const _=Math.max(...f)/180,m=new sn(...c,i),p=new sn(...h,i),S=new nn().setFromEuler(m),v=new nn().setFromEuler(p);S.dot(v)&&v.set(-v.x,-v.y,-v.z,-v.w);const y=e.times[o-1],N=e.times[o]-y,P=new nn,L=new sn;for(let U=0;U<1;U+=1/_)P.copy(S.clone().slerp(v.clone(),U)),r.push(y+U*N),L.setFromQuaternion(P,i),a.push(L.x),a.push(L.y),a.push(L.z)}else r.push(e.times[o]),a.push(Xt.degToRad(e.values[o])),a.push(Xt.degToRad(t.values[o])),a.push(Xt.degToRad(n.values[o]))}return[r,a]}}class Uv{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new Ih,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,n=e.split(/[\r\n]+/);return n.forEach(function(i,r){const a=i.match(/^[\s\t]*;/),o=i.match(/^[\s\t]*$/);if(a||o)return;const l=i.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),c=i.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),u=i.match("^\\t{"+(t.currentIndent-1)+"}}");l?t.parseNodeBegin(i,l):c?t.parseNodeProperty(i,c,n[++r]):u?t.popStack():i.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(i)}),this.allNodes}parseNodeBegin(e,t){const n=t[1].trim().replace(/^"/,"").replace(/"$/,""),i=t[2].split(",").map(function(l){return l.trim().replace(/^"/,"").replace(/"$/,"")}),r={name:n},a=this.parseNodeAttr(i),o=this.getCurrentNode();this.currentIndent===0?this.allNodes.add(n,r):n in o?(n==="PoseNode"?o.PoseNode.push(r):o[n].id!==void 0&&(o[n]={},o[n][o[n].id]=o[n]),a.id!==""&&(o[n][a.id]=r)):typeof a.id=="number"?(o[n]={},o[n][a.id]=r):n!=="Properties70"&&(n==="PoseNode"?o[n]=[r]:o[n]=r),typeof a.id=="number"&&(r.id=a.id),a.name!==""&&(r.attrName=a.name),a.type!==""&&(r.attrType=a.type),this.pushStack(r)}parseNodeAttr(e){let t=e[0];e[0]!==""&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",i="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),i=e[2]),{id:t,name:n,type:i}}parseNodeProperty(e,t,n){let i=t[1].replace(/^"/,"").replace(/"$/,"").trim(),r=t[2].replace(/^"/,"").replace(/"$/,"").trim();i==="Content"&&r===","&&(r=n.replace(/"/g,"").replace(/,$/,"").trim());const a=this.getCurrentNode();if(a.name==="Properties70"){this.parseNodeSpecialProperty(e,i,r);return}if(i==="C"){const l=r.split(",").slice(1),c=parseInt(l[0]),u=parseInt(l[1]);let h=r.split(",").slice(3);h=h.map(function(d){return d.trim().replace(/^"/,"")}),i="connections",r=[c,u],Vv(r,h),a[i]===void 0&&(a[i]=[])}i==="Node"&&(a.id=r),i in a&&Array.isArray(a[i])?a[i].push(r):i!=="a"?a[i]=r:a.a=r,this.setCurrentProp(a,i),i==="a"&&r.slice(-1)!==","&&(a.a=Co(r))}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=Co(t.a))}parseNodeSpecialProperty(e,t,n){const i=n.split('",').map(function(u){return u.trim().replace(/^\"/,"").replace(/\s/,"_")}),r=i[0],a=i[1],o=i[2],l=i[3];let c=i[4];switch(a){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":c=parseFloat(c);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":c=Co(c);break}this.getPrevNode()[r]={type:a,type2:o,flag:l,value:c},this.setCurrentProp(this.getPrevNode(),r)}}class Fv{parse(e){const t=new Cu(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const i=new Ih;for(;!this.endOfContent(t);){const r=this.parseNode(t,n);r!==null&&i.add(r.name,r)}return i}endOfContent(e){return e.size()%16===0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},i=t>=7500?e.getUint64():e.getUint32(),r=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const a=e.getUint8(),o=e.getString(a);if(i===0)return null;const l=[];for(let d=0;d<r;d++)l.push(this.parseProperty(e));const c=l.length>0?l[0]:"",u=l.length>1?l[1]:"",h=l.length>2?l[2]:"";for(n.singleProperty=r===1&&e.getOffset()===i;i>e.getOffset();){const d=this.parseNode(e,t);d!==null&&this.parseSubNode(o,n,d)}return n.propertyList=l,typeof c=="number"&&(n.id=c),u!==""&&(n.attrName=u),h!==""&&(n.attrType=h),o!==""&&(n.name=o),n}parseSubNode(e,t,n){if(n.singleProperty===!0){const i=n.propertyList[0];Array.isArray(i)?(t[n.name]=n,n.a=i):t[n.name]=i}else if(e==="Connections"&&n.name==="C"){const i=[];n.propertyList.forEach(function(r,a){a!==0&&i.push(r)}),t.connections===void 0&&(t.connections=[]),t.connections.push(i)}else if(n.name==="Properties70")Object.keys(n).forEach(function(r){t[r]=n[r]});else if(e==="Properties70"&&n.name==="P"){let i=n.propertyList[0],r=n.propertyList[1];const a=n.propertyList[2],o=n.propertyList[3];let l;i.indexOf("Lcl ")===0&&(i=i.replace("Lcl ","Lcl_")),r.indexOf("Lcl ")===0&&(r=r.replace("Lcl ","Lcl_")),r==="Color"||r==="ColorRGB"||r==="Vector"||r==="Vector3D"||r.indexOf("Lcl_")===0?l=[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:l=n.propertyList[4],t[i]={type:r,type2:a,flag:o,value:l}}else t[n.name]===void 0?typeof n.id=="number"?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:n.name==="PoseNode"?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):t[n.name][n.id]===void 0&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const i=e.getUint32(),r=e.getUint32(),a=e.getUint32();if(r===0)switch(t){case"b":case"c":return e.getBooleanArray(i);case"d":return e.getFloat64Array(i);case"f":return e.getFloat32Array(i);case"i":return e.getInt32Array(i);case"l":return e.getInt64Array(i)}const o=xv(new Uint8Array(e.getArrayBuffer(a))),l=new Cu(o.buffer);switch(t){case"b":case"c":return l.getBooleanArray(i);case"d":return l.getFloat64Array(i);case"f":return l.getFloat32Array(i);case"i":return l.getInt32Array(i);case"l":return l.getInt64Array(i)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class Cu{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=t!==void 0?t:!0,this._textDecoder=new TextDecoder}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(e){const t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){const e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t&2147483648?(t=~t&4294967295,e=~e&4294967295,e===4294967295&&(t=t+1&4294967295),e=e+1&4294967295,-(t*4294967296+e)):t*4294967296+e}getInt64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t*4294967296+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){const t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){const t=this.offset;let n=new Uint8Array(this.dv.buffer,t,e);this.skip(e);const i=n.indexOf(0);return i>=0&&(n=new Uint8Array(this.dv.buffer,t,i)),this._textDecoder.decode(n)}}class Ih{add(e,t){this[e]=t}}function Ov(s){const e="Kaydara FBX Binary \0";return s.byteLength>=e.length&&e===Uh(s,0,e.length)}function kv(s){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let t=0;function n(i){const r=s[i-1];return s=s.slice(t+i),t++,r}for(let i=0;i<e.length;++i)if(n(1)===e[i])return!1;return!0}function Pu(s){const e=/FBXVersion: (\d+)/,t=s.match(e);if(t)return parseInt(t[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function Bv(s){return s/46186158e3}const zv=[];function fa(s,e,t,n){let i;switch(n.mappingType){case"ByPolygonVertex":i=s;break;case"ByPolygon":i=e;break;case"ByVertice":i=t;break;case"AllSame":i=n.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+n.mappingType)}n.referenceType==="IndexToDirect"&&(i=n.indices[i]);const r=i*n.dataSize,a=r+n.dataSize;return Hv(zv,n.buffer,r,a)}const Ro=new sn,Ls=new O;function Nh(s){const e=new Fe,t=new Fe,n=new Fe,i=new Fe,r=new Fe,a=new Fe,o=new Fe,l=new Fe,c=new Fe,u=new Fe,h=new Fe,d=new Fe,f=s.inheritType?s.inheritType:0;s.translation&&e.setPosition(Ls.fromArray(s.translation));const g=wr(0);if(s.preRotation){const D=s.preRotation.map(Xt.degToRad);D.push(g),t.makeRotationFromEuler(Ro.fromArray(D))}if(s.rotation){const D=s.rotation.map(Xt.degToRad);D.push(s.eulerOrder||g),n.makeRotationFromEuler(Ro.fromArray(D))}if(s.postRotation){const D=s.postRotation.map(Xt.degToRad);D.push(g),i.makeRotationFromEuler(Ro.fromArray(D)),i.invert()}s.scale&&r.scale(Ls.fromArray(s.scale)),s.scalingOffset&&o.setPosition(Ls.fromArray(s.scalingOffset)),s.scalingPivot&&a.setPosition(Ls.fromArray(s.scalingPivot)),s.rotationOffset&&l.setPosition(Ls.fromArray(s.rotationOffset)),s.rotationPivot&&c.setPosition(Ls.fromArray(s.rotationPivot)),s.parentMatrixWorld&&(h.copy(s.parentMatrix),u.copy(s.parentMatrixWorld));const _=t.clone().multiply(n).multiply(i),m=new Fe;m.extractRotation(u);const p=new Fe;p.copyPosition(u);const S=p.clone().invert().multiply(u),v=m.clone().invert().multiply(S),y=r,N=new Fe;if(f===0)N.copy(m).multiply(_).multiply(v).multiply(y);else if(f===1)N.copy(m).multiply(v).multiply(_).multiply(y);else{const X=new Fe().scale(new O().setFromMatrixScale(h)).clone().invert(),q=v.clone().multiply(X);N.copy(m).multiply(_).multiply(q).multiply(y)}const P=c.clone().invert(),L=a.clone().invert();let U=e.clone().multiply(l).multiply(c).multiply(t).multiply(n).multiply(i).multiply(P).multiply(o).multiply(a).multiply(r).multiply(L);const E=new Fe().copyPosition(U),T=u.clone().multiply(E);return d.copyPosition(T),U=d.clone().multiply(N),U.premultiply(u.invert()),U}function wr(s){s=s||0;const e=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return s===6?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),e[0]):e[s]}function Co(s){return s.split(",").map(function(t){return parseFloat(t)})}function Uh(s,e,t){return e===void 0&&(e=0),t===void 0&&(t=s.byteLength),new TextDecoder().decode(new Uint8Array(s,e,t))}function Vv(s,e){for(let t=0,n=s.length,i=e.length;t<i;t++,n++)s[n]=e[t]}function Hv(s,e,t,n){for(let i=t,r=0;i<n;i++,r++)s[r]=e[i];return s}function Lu(s,e){if(e===df)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),s;if(e===gl||e===nh){let t=s.getIndex();if(t===null){const a=[],o=s.getAttribute("position");if(o!==void 0){for(let l=0;l<o.count;l++)a.push(l);s.setIndex(a),t=s.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),s}const n=t.count-2,i=[];if(e===gl)for(let a=1;a<=n;a++)i.push(t.getX(0)),i.push(t.getX(a)),i.push(t.getX(a+1));else for(let a=0;a<n;a++)a%2===0?(i.push(t.getX(a)),i.push(t.getX(a+1)),i.push(t.getX(a+2))):(i.push(t.getX(a+2)),i.push(t.getX(a+1)),i.push(t.getX(a)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=s.clone();return r.setIndex(i),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),s}class Gv extends wn{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Kv(t)}),this.register(function(t){return new Yv(t)}),this.register(function(t){return new sx(t)}),this.register(function(t){return new rx(t)}),this.register(function(t){return new ax(t)}),this.register(function(t){return new $v(t)}),this.register(function(t){return new Jv(t)}),this.register(function(t){return new Qv(t)}),this.register(function(t){return new ex(t)}),this.register(function(t){return new qv(t)}),this.register(function(t){return new tx(t)}),this.register(function(t){return new Zv(t)}),this.register(function(t){return new ix(t)}),this.register(function(t){return new nx(t)}),this.register(function(t){return new Xv(t)}),this.register(function(t){return new ox(t)}),this.register(function(t){return new lx(t)})}load(e,t,n,i){const r=this;let a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){const c=os.extractUrlBase(e);a=os.resolveURL(c,this.path)}else a=os.extractUrlBase(e);this.manager.itemStart(e);const o=function(c){i?i(c):console.error(c),r.manager.itemError(e),r.manager.itemEnd(e)},l=new Xi(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{r.parse(c,a,function(u){t(u),r.manager.itemEnd(e)},o)}catch(u){o(u)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let r;const a={},o={},l=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===Fh){try{a[St.KHR_BINARY_GLTF]=new cx(e)}catch(h){i&&i(h);return}r=JSON.parse(a[St.KHR_BINARY_GLTF].content)}else r=JSON.parse(l.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new Sx(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){const h=this.pluginCallbacks[u](c);h.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),o[h.name]=h,a[h.name]=!0}if(r.extensionsUsed)for(let u=0;u<r.extensionsUsed.length;++u){const h=r.extensionsUsed[u],d=r.extensionsRequired||[];switch(h){case St.KHR_MATERIALS_UNLIT:a[h]=new jv;break;case St.KHR_DRACO_MESH_COMPRESSION:a[h]=new ux(r,this.dracoLoader);break;case St.KHR_TEXTURE_TRANSFORM:a[h]=new hx;break;case St.KHR_MESH_QUANTIZATION:a[h]=new dx;break;default:d.indexOf(h)>=0&&o[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}c.setExtensions(a),c.setPlugins(o),c.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function Wv(){let s={};return{get:function(e){return s[e]},add:function(e,t){s[e]=t},remove:function(e){delete s[e]},removeAll:function(){s={}}}}const St={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Xv{constructor(e){this.parser=e,this.name=St.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const r=t.json,l=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let c;const u=new Ge(16777215);l.color!==void 0&&u.setRGB(l.color[0],l.color[1],l.color[2],An);const h=l.range!==void 0?l.range:0;switch(l.type){case"directional":c=new Ar(u),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new La(u),c.distance=h;break;case"spot":c=new ql(u),c.distance=h,l.spot=l.spot||{},l.spot.innerConeAngle=l.spot.innerConeAngle!==void 0?l.spot.innerConeAngle:0,l.spot.outerConeAngle=l.spot.outerConeAngle!==void 0?l.spot.outerConeAngle:Math.PI/4,c.angle=l.spot.outerConeAngle,c.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return c.position.set(0,0,0),Si(c,l),l.intensity!==void 0&&(c.intensity=l.intensity),c.name=t.createUniqueName(l.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],o=(r.extensions&&r.extensions[this.name]||{}).light;return o===void 0?null:this._loadLight(o).then(function(l){return n._getNodeRef(t.cache,o,l)})}}class jv{constructor(){this.name=St.KHR_MATERIALS_UNLIT}getMaterialType(){return bi}extendParams(e,t,n){const i=[];e.color=new Ge(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const a=r.baseColorFactor;e.color.setRGB(a[0],a[1],a[2],An),e.opacity=a[3]}r.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",r.baseColorTexture,_t))}return Promise.all(i)}}class qv{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=i.extensions[this.name].emissiveStrength;return r!==void 0&&(t.emissiveIntensity=r),Promise.resolve()}}class Kv{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:li}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],a=i.extensions[this.name];if(a.clearcoatFactor!==void 0&&(t.clearcoat=a.clearcoatFactor),a.clearcoatTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatMap",a.clearcoatTexture)),a.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=a.clearcoatRoughnessFactor),a.clearcoatRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatRoughnessMap",a.clearcoatRoughnessTexture)),a.clearcoatNormalTexture!==void 0&&(r.push(n.assignTexture(t,"clearcoatNormalMap",a.clearcoatNormalTexture)),a.clearcoatNormalTexture.scale!==void 0)){const o=a.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new ct(o,o)}return Promise.all(r)}}class Yv{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:li}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=i.extensions[this.name];return t.dispersion=r.dispersion!==void 0?r.dispersion:0,Promise.resolve()}}class Zv{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:li}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],a=i.extensions[this.name];return a.iridescenceFactor!==void 0&&(t.iridescence=a.iridescenceFactor),a.iridescenceTexture!==void 0&&r.push(n.assignTexture(t,"iridescenceMap",a.iridescenceTexture)),a.iridescenceIor!==void 0&&(t.iridescenceIOR=a.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),a.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=a.iridescenceThicknessMinimum),a.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=a.iridescenceThicknessMaximum),a.iridescenceThicknessTexture!==void 0&&r.push(n.assignTexture(t,"iridescenceThicknessMap",a.iridescenceThicknessTexture)),Promise.all(r)}}class $v{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:li}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new Ge(0,0,0),t.sheenRoughness=0,t.sheen=1;const a=i.extensions[this.name];if(a.sheenColorFactor!==void 0){const o=a.sheenColorFactor;t.sheenColor.setRGB(o[0],o[1],o[2],An)}return a.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=a.sheenRoughnessFactor),a.sheenColorTexture!==void 0&&r.push(n.assignTexture(t,"sheenColorMap",a.sheenColorTexture,_t)),a.sheenRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"sheenRoughnessMap",a.sheenRoughnessTexture)),Promise.all(r)}}class Jv{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:li}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],a=i.extensions[this.name];return a.transmissionFactor!==void 0&&(t.transmission=a.transmissionFactor),a.transmissionTexture!==void 0&&r.push(n.assignTexture(t,"transmissionMap",a.transmissionTexture)),Promise.all(r)}}class Qv{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:li}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],a=i.extensions[this.name];t.thickness=a.thicknessFactor!==void 0?a.thicknessFactor:0,a.thicknessTexture!==void 0&&r.push(n.assignTexture(t,"thicknessMap",a.thicknessTexture)),t.attenuationDistance=a.attenuationDistance||1/0;const o=a.attenuationColor||[1,1,1];return t.attenuationColor=new Ge().setRGB(o[0],o[1],o[2],An),Promise.all(r)}}class ex{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:li}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=i.extensions[this.name];return t.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}}class tx{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:li}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],a=i.extensions[this.name];t.specularIntensity=a.specularFactor!==void 0?a.specularFactor:1,a.specularTexture!==void 0&&r.push(n.assignTexture(t,"specularIntensityMap",a.specularTexture));const o=a.specularColorFactor||[1,1,1];return t.specularColor=new Ge().setRGB(o[0],o[1],o[2],An),a.specularColorTexture!==void 0&&r.push(n.assignTexture(t,"specularColorMap",a.specularColorTexture,_t)),Promise.all(r)}}class nx{constructor(e){this.parser=e,this.name=St.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:li}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],a=i.extensions[this.name];return t.bumpScale=a.bumpFactor!==void 0?a.bumpFactor:1,a.bumpTexture!==void 0&&r.push(n.assignTexture(t,"bumpMap",a.bumpTexture)),Promise.all(r)}}class ix{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:li}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],a=i.extensions[this.name];return a.anisotropyStrength!==void 0&&(t.anisotropy=a.anisotropyStrength),a.anisotropyRotation!==void 0&&(t.anisotropyRotation=a.anisotropyRotation),a.anisotropyTexture!==void 0&&r.push(n.assignTexture(t,"anisotropyMap",a.anisotropyTexture)),Promise.all(r)}}class sx{constructor(e){this.parser=e,this.name=St.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const r=i.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,a)}}class rx{constructor(e){this.parser=e,this.name=St.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.extensions[t],o=i.images[a.source];let l=n.textureLoader;if(o.uri){const c=n.options.manager.getHandler(o.uri);c!==null&&(l=c)}return n.loadTextureImage(e,a.source,l)}}class ax{constructor(e){this.parser=e,this.name=St.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.extensions[t],o=i.images[a.source];let l=n.textureLoader;if(o.uri){const c=n.options.manager.getHandler(o.uri);c!==null&&(l=c)}return n.loadTextureImage(e,a.source,l)}}class ox{constructor(e){this.name=St.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(o){const l=i.byteOffset||0,c=i.byteLength||0,u=i.count,h=i.byteStride,d=new Uint8Array(o,l,c);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(u,h,d,i.mode,i.filter).then(function(f){return f.buffer}):a.ready.then(function(){const f=new ArrayBuffer(u*h);return a.decodeGltfBuffer(new Uint8Array(f),u,h,d,i.mode,i.filter),f})})}else return null}}class lx{constructor(e){this.name=St.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=t.meshes[n.mesh];for(const c of i.primitives)if(c.mode!==Bn.TRIANGLES&&c.mode!==Bn.TRIANGLE_STRIP&&c.mode!==Bn.TRIANGLE_FAN&&c.mode!==void 0)return null;const a=n.extensions[this.name].attributes,o=[],l={};for(const c in a)o.push(this.parser.getDependency("accessor",a[c]).then(u=>(l[c]=u,l[c])));return o.length<1?null:(o.push(this.parser.createNodeMesh(e)),Promise.all(o).then(c=>{const u=c.pop(),h=u.isGroup?u.children:[u],d=c[0].count,f=[];for(const g of h){const _=new Fe,m=new O,p=new nn,S=new O(1,1,1),v=new _p(g.geometry,g.material,d);for(let y=0;y<d;y++)l.TRANSLATION&&m.fromBufferAttribute(l.TRANSLATION,y),l.ROTATION&&p.fromBufferAttribute(l.ROTATION,y),l.SCALE&&S.fromBufferAttribute(l.SCALE,y),v.setMatrixAt(y,_.compose(m,p,S));for(const y in l)if(y==="_COLOR_0"){const N=l[y];v.instanceColor=new yl(N.array,N.itemSize,N.normalized)}else y!=="TRANSLATION"&&y!=="ROTATION"&&y!=="SCALE"&&g.geometry.setAttribute(y,l[y]);kt.prototype.copy.call(v,g),this.parser.assignFinalMaterial(v),f.push(v)}return u.isGroup?(u.clear(),u.add(...f),u):f[0]}))}}const Fh="glTF",ar=12,Du={JSON:1313821514,BIN:5130562};class cx{constructor(e){this.name=St.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,ar),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Fh)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-ar,r=new DataView(e,ar);let a=0;for(;a<i;){const o=r.getUint32(a,!0);a+=4;const l=r.getUint32(a,!0);if(a+=4,l===Du.JSON){const c=new Uint8Array(e,ar+a,o);this.content=n.decode(c)}else if(l===Du.BIN){const c=ar+a;this.body=e.slice(c,c+o)}a+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class ux{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=St.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},l={},c={};for(const u in a){const h=bl[u]||u.toLowerCase();o[h]=a[u]}for(const u in e.attributes){const h=bl[u]||u.toLowerCase();if(a[u]!==void 0){const d=n.accessors[e.attributes[u]],f=zs[d.componentType];c[h]=f.name,l[h]=d.normalized===!0}}return t.getDependency("bufferView",r).then(function(u){return new Promise(function(h,d){i.decodeDracoFile(u,function(f){for(const g in f.attributes){const _=f.attributes[g],m=l[g];m!==void 0&&(_.normalized=m)}h(f)},o,c,An,d)})})}}class hx{constructor(){this.name=St.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class dx{constructor(){this.name=St.KHR_MESH_QUANTIZATION}}class Oh extends Ir{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let a=0;a!==i;a++)t[a]=n[r+a];return t}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=o*2,c=o*3,u=i-t,h=(n-t)/u,d=h*h,f=d*h,g=e*c,_=g-c,m=-2*f+3*d,p=f-d,S=1-m,v=p-d+h;for(let y=0;y!==o;y++){const N=a[_+y+o],P=a[_+y+l]*u,L=a[g+y+o],U=a[g+y]*u;r[y]=S*N+v*P+m*L+p*U}return r}}const fx=new nn;class px extends Oh{interpolate_(e,t,n,i){const r=super.interpolate_(e,t,n,i);return fx.fromArray(r).normalize().toArray(r),r}}const Bn={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},zs={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Iu={9728:En,9729:yn,9984:Ku,9985:ma,9986:or,9987:Qn},Nu={33071:Dn,33648:Ea,10497:Hn},Po={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},bl={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},ki={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},mx={CUBICSPLINE:void 0,LINEAR:vr,STEP:yr},Lo={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function gx(s){return s.DefaultMaterial===void 0&&(s.DefaultMaterial=new Er({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:ri})),s.DefaultMaterial}function ns(s,e,t){for(const n in t.extensions)s[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function Si(s,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(s.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function _x(s,e,t){let n=!1,i=!1,r=!1;for(let c=0,u=e.length;c<u;c++){const h=e[c];if(h.POSITION!==void 0&&(n=!0),h.NORMAL!==void 0&&(i=!0),h.COLOR_0!==void 0&&(r=!0),n&&i&&r)break}if(!n&&!i&&!r)return Promise.resolve(s);const a=[],o=[],l=[];for(let c=0,u=e.length;c<u;c++){const h=e[c];if(n){const d=h.POSITION!==void 0?t.getDependency("accessor",h.POSITION):s.attributes.position;a.push(d)}if(i){const d=h.NORMAL!==void 0?t.getDependency("accessor",h.NORMAL):s.attributes.normal;o.push(d)}if(r){const d=h.COLOR_0!==void 0?t.getDependency("accessor",h.COLOR_0):s.attributes.color;l.push(d)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l)]).then(function(c){const u=c[0],h=c[1],d=c[2];return n&&(s.morphAttributes.position=u),i&&(s.morphAttributes.normal=h),r&&(s.morphAttributes.color=d),s.morphTargetsRelative=!0,s})}function yx(s,e){if(s.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)s.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(s.morphTargetInfluences.length===t.length){s.morphTargetDictionary={};for(let n=0,i=t.length;n<i;n++)s.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function vx(s){let e;const t=s.extensions&&s.extensions[St.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Do(t.attributes):e=s.indices+":"+Do(s.attributes)+":"+s.mode,s.targets!==void 0)for(let n=0,i=s.targets.length;n<i;n++)e+=":"+Do(s.targets[n]);return e}function Do(s){let e="";const t=Object.keys(s).sort();for(let n=0,i=t.length;n<i;n++)e+=t[n]+":"+s[t[n]]+";";return e}function El(s){switch(s){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function xx(s){return s.search(/\.jpe?g($|\?)/i)>0||s.search(/^data\:image\/jpeg/)===0?"image/jpeg":s.search(/\.webp($|\?)/i)>0||s.search(/^data\:image\/webp/)===0?"image/webp":s.search(/\.ktx2($|\?)/i)>0||s.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const Mx=new Fe;class Sx{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Wv,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,a=-1;if(typeof navigator<"u"){const o=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(o)===!0;const l=o.match(/Version\/(\d+)/);i=n&&l?parseInt(l[1],10):-1,r=o.indexOf("Firefox")>-1,a=r?o.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&i<17||r&&a<98?this.textureLoader=new Xl(this.options.manager):this.textureLoader=new sm(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Xi(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(a){return a._markDefs&&a._markDefs()}),Promise.all(this._invokeAll(function(a){return a.beforeRoot&&a.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(a){const o={scene:a[0][i.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:i.asset,parser:n,userData:{}};return ns(r,o,i),Si(o,i),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(o)})).then(function(){for(const l of o.scenes)l.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){const a=t[i].joints;for(let o=0,l=a.length;o<l;o++)e[a[o]].isBone=!0}for(let i=0,r=e.length;i<r;i++){const a=e[i];a.mesh!==void 0&&(this._addNodeRef(this.meshCache,a.mesh),a.skin!==void 0&&(n[a.mesh].isSkinnedMesh=!0)),a.camera!==void 0&&this._addNodeRef(this.cameraCache,a.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),r=(a,o)=>{const l=this.associations.get(a);l!=null&&this.associations.set(o,l);for(const[c,u]of a.children.entries())r(u,o.children[c])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const r=e(t[i]);r&&n.push(r)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw new Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,a){return n.getDependency(e,a)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[St.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(r,a){n.load(os.resolveURL(t.uri,i.path),r,void 0,function(){a(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const i=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const a=Po[i.type],o=zs[i.componentType],l=i.normalized===!0,c=new o(i.count*a);return Promise.resolve(new hn(c,a,l))}const r=[];return i.bufferView!==void 0?r.push(this.getDependency("bufferView",i.bufferView)):r.push(null),i.sparse!==void 0&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then(function(a){const o=a[0],l=Po[i.type],c=zs[i.componentType],u=c.BYTES_PER_ELEMENT,h=u*l,d=i.byteOffset||0,f=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,g=i.normalized===!0;let _,m;if(f&&f!==h){const p=Math.floor(d/f),S="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count;let v=t.cache.get(S);v||(_=new c(o,p*f,i.count*f/u),v=new fp(_,f/u),t.cache.add(S,v)),m=new zl(v,l,d%f/u,g)}else o===null?_=new c(i.count*l):_=new c(o,d,i.count*l),m=new hn(_,l,g);if(i.sparse!==void 0){const p=Po.SCALAR,S=zs[i.sparse.indices.componentType],v=i.sparse.indices.byteOffset||0,y=i.sparse.values.byteOffset||0,N=new S(a[1],v,i.sparse.count*p),P=new c(a[2],y,i.sparse.count*l);o!==null&&(m=new hn(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let L=0,U=N.length;L<U;L++){const E=N[L];if(m.setX(E,P[L*l]),l>=2&&m.setY(E,P[L*l+1]),l>=3&&m.setZ(E,P[L*l+2]),l>=4&&m.setW(E,P[L*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=g}return m})}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,a=t.images[r];let o=this.textureLoader;if(a.uri){const l=n.manager.getHandler(a.uri);l!==null&&(o=l)}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,n){const i=this,r=this.json,a=r.textures[e],o=r.images[t],l=(o.uri||o.bufferView)+":"+a.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,n).then(function(u){u.flipY=!1,u.name=a.name||o.name||"",u.name===""&&typeof o.uri=="string"&&o.uri.startsWith("data:image/")===!1&&(u.name=o.uri);const d=(r.samplers||{})[a.sampler]||{};return u.magFilter=Iu[d.magFilter]||yn,u.minFilter=Iu[d.minFilter]||Qn,u.wrapS=Nu[d.wrapS]||Hn,u.wrapT=Nu[d.wrapT]||Hn,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==En&&u.minFilter!==yn,i.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());const a=i.images[e],o=self.URL||self.webkitURL;let l=a.uri||"",c=!1;if(a.bufferView!==void 0)l=n.getDependency("bufferView",a.bufferView).then(function(h){c=!0;const d=new Blob([h],{type:a.mimeType});return l=o.createObjectURL(d),l});else if(a.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(l).then(function(h){return new Promise(function(d,f){let g=d;t.isImageBitmapLoader===!0&&(g=function(_){const m=new an(_);m.needsUpdate=!0,d(m)}),t.load(os.resolveURL(h,r.path),g,void 0,f)})}).then(function(h){return c===!0&&o.revokeObjectURL(l),Si(h,a),h.userData.mimeType=a.mimeType||xx(a.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),h});return this.sourceCache[e]=u,u}assignTexture(e,t,n,i){const r=this;return this.getDependency("texture",n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),r.extensions[St.KHR_TEXTURE_TRANSFORM]){const o=n.extensions!==void 0?n.extensions[St.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const l=r.associations.get(a);a=r.extensions[St.KHR_TEXTURE_TRANSFORM].extendTexture(a,o),r.associations.set(a,l)}}return i!==void 0&&(a.colorSpace=i),e[t]=a,a})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){const o="PointsMaterial:"+n.uuid;let l=this.cache.get(o);l||(l=new Is,Nn.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(o,l)),n=l}else if(e.isLine){const o="LineBasicMaterial:"+n.uuid;let l=this.cache.get(o);l||(l=new si,Nn.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(o,l)),n=l}if(i||r||a){let o="ClonedMaterial:"+n.uuid+":";i&&(o+="derivative-tangents:"),r&&(o+="vertex-colors:"),a&&(o+="flat-shading:");let l=this.cache.get(o);l||(l=n.clone(),r&&(l.vertexColors=!0),a&&(l.flatShading=!0),i&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(o,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return Er}loadMaterial(e){const t=this,n=this.json,i=this.extensions,r=n.materials[e];let a;const o={},l=r.extensions||{},c=[];if(l[St.KHR_MATERIALS_UNLIT]){const h=i[St.KHR_MATERIALS_UNLIT];a=h.getMaterialType(),c.push(h.extendParams(o,r,t))}else{const h=r.pbrMetallicRoughness||{};if(o.color=new Ge(1,1,1),o.opacity=1,Array.isArray(h.baseColorFactor)){const d=h.baseColorFactor;o.color.setRGB(d[0],d[1],d[2],An),o.opacity=d[3]}h.baseColorTexture!==void 0&&c.push(t.assignTexture(o,"map",h.baseColorTexture,_t)),o.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,o.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,"metalnessMap",h.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",h.metallicRoughnessTexture))),a=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,o)})))}r.doubleSided===!0&&(o.side=Zn);const u=r.alphaMode||Lo.OPAQUE;if(u===Lo.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,u===Lo.MASK&&(o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&a!==bi&&(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new ct(1,1),r.normalTexture.scale!==void 0)){const h=r.normalTexture.scale;o.normalScale.set(h,h)}if(r.occlusionTexture!==void 0&&a!==bi&&(c.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&a!==bi){const h=r.emissiveFactor;o.emissive=new Ge().setRGB(h[0],h[1],h[2],An)}return r.emissiveTexture!==void 0&&a!==bi&&c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,_t)),Promise.all(c).then(function(){const h=new a(o);return r.name&&(h.name=r.name),Si(h,r),t.associations.set(h,{materials:e}),r.extensions&&ns(i,h,r),h})}createUniqueName(e){const t=wt.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function r(o){return n[St.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(l){return Uu(l,o,t)})}const a=[];for(let o=0,l=e.length;o<l;o++){const c=e[o],u=vx(c),h=i[u];if(h)a.push(h.promise);else{let d;c.extensions&&c.extensions[St.KHR_DRACO_MESH_COMPRESSION]?d=r(c):d=Uu(new Kt,c,t),i[u]={primitive:c,promise:d},a.push(d)}}return Promise.all(a)}loadMesh(e){const t=this,n=this.json,i=this.extensions,r=n.meshes[e],a=r.primitives,o=[];for(let l=0,c=a.length;l<c;l++){const u=a[l].material===void 0?gx(this.cache):this.getDependency("material",a[l].material);o.push(u)}return o.push(t.loadGeometries(a)),Promise.all(o).then(function(l){const c=l.slice(0,l.length-1),u=l[l.length-1],h=[];for(let f=0,g=u.length;f<g;f++){const _=u[f],m=a[f];let p;const S=c[f];if(m.mode===Bn.TRIANGLES||m.mode===Bn.TRIANGLE_STRIP||m.mode===Bn.TRIANGLE_FAN||m.mode===void 0)p=r.isSkinnedMesh===!0?new Vl(_,S):new rn(_,S),p.isSkinnedMesh===!0&&p.normalizeSkinWeights(),m.mode===Bn.TRIANGLE_STRIP?p.geometry=Lu(p.geometry,nh):m.mode===Bn.TRIANGLE_FAN&&(p.geometry=Lu(p.geometry,gl));else if(m.mode===Bn.LINES)p=new js(_,S);else if(m.mode===Bn.LINE_STRIP)p=new Dr(_,S);else if(m.mode===Bn.LINE_LOOP)p=new xp(_,S);else if(m.mode===Bn.POINTS)p=new Ma(_,S);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(p.geometry.morphAttributes).length>0&&yx(p,r),p.name=t.createUniqueName(r.name||"mesh_"+e),Si(p,r),m.extensions&&ns(i,p,m),t.assignFinalMaterial(p),h.push(p)}for(let f=0,g=h.length;f<g;f++)t.associations.set(h[f],{meshes:e,primitives:f});if(h.length===1)return r.extensions&&ns(i,h[0],r),h[0];const d=new Wn;r.extensions&&ns(i,d,r),t.associations.set(d,{meshes:e});for(let f=0,g=h.length;f<g;f++)d.add(h[f]);return d})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new un(Xt.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new ka(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Si(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(i){const r=i.pop(),a=i,o=[],l=[];for(let c=0,u=a.length;c<u;c++){const h=a[c];if(h){o.push(h);const d=new Fe;r!==null&&d.fromArray(r.array,c*16),l.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new Lr(o,l)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,a=[],o=[],l=[],c=[],u=[];for(let h=0,d=i.channels.length;h<d;h++){const f=i.channels[h],g=i.samplers[f.sampler],_=f.target,m=_.node,p=i.parameters!==void 0?i.parameters[g.input]:g.input,S=i.parameters!==void 0?i.parameters[g.output]:g.output;_.node!==void 0&&(a.push(this.getDependency("node",m)),o.push(this.getDependency("accessor",p)),l.push(this.getDependency("accessor",S)),c.push(g),u.push(_))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l),Promise.all(c),Promise.all(u)]).then(function(h){const d=h[0],f=h[1],g=h[2],_=h[3],m=h[4],p=[];for(let S=0,v=d.length;S<v;S++){const y=d[S],N=f[S],P=g[S],L=_[S],U=m[S];if(y===void 0)continue;y.updateMatrix&&y.updateMatrix();const E=n._createAnimationTracks(y,N,P,L,U);if(E)for(let T=0;T<E.length;T++)p.push(E[T])}return new Pa(r,void 0,p)})}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(r){const a=n._getNodeRef(n.meshCache,i.mesh,r);return i.weights!==void 0&&a.traverse(function(o){if(o.isMesh)for(let l=0,c=i.weights.length;l<c;l++)o.morphTargetInfluences[l]=i.weights[l]}),a})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),a=[],o=i.children||[];for(let c=0,u=o.length;c<u;c++)a.push(n.getDependency("node",o[c]));const l=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(a),l]).then(function(c){const u=c[0],h=c[1],d=c[2];d!==null&&u.traverse(function(f){f.isSkinnedMesh&&f.bind(d,Mx)});for(let f=0,g=h.length;f<g;f++)u.add(h[f]);return u})}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],a=r.name?i.createUniqueName(r.name):"",o=[],l=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&o.push(l),r.camera!==void 0&&o.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)})),i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){o.push(c)}),this.nodeCache[e]=Promise.all(o).then(function(c){let u;if(r.isBone===!0?u=new Mr:c.length>1?u=new Wn:c.length===1?u=c[0]:u=new kt,u!==c[0])for(let h=0,d=c.length;h<d;h++)u.add(c[h]);if(r.name&&(u.userData.name=r.name,u.name=a),Si(u,r),r.extensions&&ns(n,u,r),r.matrix!==void 0){const h=new Fe;h.fromArray(r.matrix),u.applyMatrix4(h)}else r.translation!==void 0&&u.position.fromArray(r.translation),r.rotation!==void 0&&u.quaternion.fromArray(r.rotation),r.scale!==void 0&&u.scale.fromArray(r.scale);if(!i.associations.has(u))i.associations.set(u,{});else if(r.mesh!==void 0&&i.meshCache.refs[r.mesh]>1){const h=i.associations.get(u);i.associations.set(u,{...h})}return i.associations.get(u).nodes=e,u}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,r=new Wn;n.name&&(r.name=i.createUniqueName(n.name)),Si(r,n),n.extensions&&ns(t,r,n);const a=n.nodes||[],o=[];for(let l=0,c=a.length;l<c;l++)o.push(i.getDependency("node",a[l]));return Promise.all(o).then(function(l){for(let u=0,h=l.length;u<h;u++)r.add(l[u]);const c=u=>{const h=new Map;for(const[d,f]of i.associations)(d instanceof Nn||d instanceof an)&&h.set(d,f);return u.traverse(d=>{const f=i.associations.get(d);f!=null&&h.set(d,f)}),h};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){const a=[],o=e.name?e.name:e.uuid,l=[];ki[r.path]===ki.weights?e.traverse(function(d){d.morphTargetInfluences&&l.push(d.name?d.name:d.uuid)}):l.push(o);let c;switch(ki[r.path]){case ki.weights:c=hs;break;case ki.rotation:c=wi;break;case ki.translation:case ki.scale:c=Ri;break;default:switch(n.itemSize){case 1:c=hs;break;case 2:case 3:default:c=Ri;break}break}const u=i.interpolation!==void 0?mx[i.interpolation]:vr,h=this._getArrayFromAccessor(n);for(let d=0,f=l.length;d<f;d++){const g=new c(l[d]+"."+ki[r.path],t.array,h,u);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),a.push(g)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=El(t.constructor),i=new Float32Array(t.length);for(let r=0,a=t.length;r<a;r++)i[r]=t[r]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const i=this instanceof wi?px:Oh;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Tx(s,e,t){const n=e.attributes,i=new Ci;if(n.POSITION!==void 0){const o=t.json.accessors[n.POSITION],l=o.min,c=o.max;if(l!==void 0&&c!==void 0){if(i.set(new O(l[0],l[1],l[2]),new O(c[0],c[1],c[2])),o.normalized){const u=El(zs[o.componentType]);i.min.multiplyScalar(u),i.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const o=new O,l=new O;for(let c=0,u=r.length;c<u;c++){const h=r[c];if(h.POSITION!==void 0){const d=t.json.accessors[h.POSITION],f=d.min,g=d.max;if(f!==void 0&&g!==void 0){if(l.setX(Math.max(Math.abs(f[0]),Math.abs(g[0]))),l.setY(Math.max(Math.abs(f[1]),Math.abs(g[1]))),l.setZ(Math.max(Math.abs(f[2]),Math.abs(g[2]))),d.normalized){const _=El(zs[d.componentType]);l.multiplyScalar(_)}o.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(o)}s.boundingBox=i;const a=new oi;i.getCenter(a.center),a.radius=i.min.distanceTo(i.max)/2,s.boundingSphere=a}function Uu(s,e,t){const n=e.attributes,i=[];function r(a,o){return t.getDependency("accessor",a).then(function(l){s.setAttribute(o,l)})}for(const a in n){const o=bl[a]||a.toLowerCase();o in s.attributes||i.push(r(n[a],o))}if(e.indices!==void 0&&!s.index){const a=t.getDependency("accessor",e.indices).then(function(o){s.setIndex(o)});i.push(a)}return ft.workingColorSpace!==An&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${ft.workingColorSpace}" not supported.`),Si(s,e),Tx(s,e,t),Promise.all(i).then(function(){return e.targets!==void 0?_x(s,e.targets,t):s})}class Fu extends em{constructor(e){super(e)}parse(e){function t(k){switch(k.image_type){case d:case _:if(k.colormap_length>256||k.colormap_size!==24||k.colormap_type!==1)throw new Error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case f:case g:case m:case p:if(k.colormap_type)throw new Error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case h:throw new Error("THREE.TGALoader: No data.");default:throw new Error("THREE.TGALoader: Invalid type "+k.image_type)}if(k.width<=0||k.height<=0)throw new Error("THREE.TGALoader: Invalid image size.");if(k.pixel_size!==8&&k.pixel_size!==16&&k.pixel_size!==24&&k.pixel_size!==32)throw new Error("THREE.TGALoader: Invalid pixel size "+k.pixel_size)}function n(k,oe,G,fe,ve){let le,we;const Me=G.pixel_size>>3,W=G.width*G.height*Me;if(oe&&(we=ve.subarray(fe,fe+=G.colormap_length*(G.colormap_size>>3))),k){le=new Uint8Array(W);let ee,ae,re,Se=0;const ot=new Uint8Array(Me);for(;Se<W;)if(ee=ve[fe++],ae=(ee&127)+1,ee&128){for(re=0;re<Me;++re)ot[re]=ve[fe++];for(re=0;re<ae;++re)le.set(ot,Se+re*Me);Se+=Me*ae}else{for(ae*=Me,re=0;re<ae;++re)le[Se+re]=ve[fe++];Se+=ae}}else le=ve.subarray(fe,fe+=oe?G.width*G.height:W);return{pixel_data:le,palettes:we}}function i(k,oe,G,fe,ve,le,we,Me,W){const ee=W;let ae,re=0,Se,ot;const J=T.width;for(ot=oe;ot!==fe;ot+=G)for(Se=ve;Se!==we;Se+=le,re++)ae=Me[re],k[(Se+J*ot)*4+3]=255,k[(Se+J*ot)*4+2]=ee[ae*3+0],k[(Se+J*ot)*4+1]=ee[ae*3+1],k[(Se+J*ot)*4+0]=ee[ae*3+2];return k}function r(k,oe,G,fe,ve,le,we,Me){let W,ee=0,ae,re;const Se=T.width;for(re=oe;re!==fe;re+=G)for(ae=ve;ae!==we;ae+=le,ee+=2)W=Me[ee+0]+(Me[ee+1]<<8),k[(ae+Se*re)*4+0]=(W&31744)>>7,k[(ae+Se*re)*4+1]=(W&992)>>2,k[(ae+Se*re)*4+2]=(W&31)<<3,k[(ae+Se*re)*4+3]=W&32768?0:255;return k}function a(k,oe,G,fe,ve,le,we,Me){let W=0,ee,ae;const re=T.width;for(ae=oe;ae!==fe;ae+=G)for(ee=ve;ee!==we;ee+=le,W+=3)k[(ee+re*ae)*4+3]=255,k[(ee+re*ae)*4+2]=Me[W+0],k[(ee+re*ae)*4+1]=Me[W+1],k[(ee+re*ae)*4+0]=Me[W+2];return k}function o(k,oe,G,fe,ve,le,we,Me){let W=0,ee,ae;const re=T.width;for(ae=oe;ae!==fe;ae+=G)for(ee=ve;ee!==we;ee+=le,W+=4)k[(ee+re*ae)*4+2]=Me[W+0],k[(ee+re*ae)*4+1]=Me[W+1],k[(ee+re*ae)*4+0]=Me[W+2],k[(ee+re*ae)*4+3]=Me[W+3];return k}function l(k,oe,G,fe,ve,le,we,Me){let W,ee=0,ae,re;const Se=T.width;for(re=oe;re!==fe;re+=G)for(ae=ve;ae!==we;ae+=le,ee++)W=Me[ee],k[(ae+Se*re)*4+0]=W,k[(ae+Se*re)*4+1]=W,k[(ae+Se*re)*4+2]=W,k[(ae+Se*re)*4+3]=255;return k}function c(k,oe,G,fe,ve,le,we,Me){let W=0,ee,ae;const re=T.width;for(ae=oe;ae!==fe;ae+=G)for(ee=ve;ee!==we;ee+=le,W+=2)k[(ee+re*ae)*4+0]=Me[W+0],k[(ee+re*ae)*4+1]=Me[W+0],k[(ee+re*ae)*4+2]=Me[W+0],k[(ee+re*ae)*4+3]=Me[W+1];return k}function u(k,oe,G,fe,ve){let le,we,Me,W,ee,ae;switch((T.flags&S)>>v){default:case P:le=0,Me=1,ee=oe,we=0,W=1,ae=G;break;case y:le=0,Me=1,ee=oe,we=G-1,W=-1,ae=-1;break;case L:le=oe-1,Me=-1,ee=-1,we=0,W=1,ae=G;break;case N:le=oe-1,Me=-1,ee=-1,we=G-1,W=-1,ae=-1;break}if(q)switch(T.pixel_size){case 8:l(k,we,W,ae,le,Me,ee,fe);break;case 16:c(k,we,W,ae,le,Me,ee,fe);break;default:throw new Error("THREE.TGALoader: Format not supported.")}else switch(T.pixel_size){case 8:i(k,we,W,ae,le,Me,ee,fe,ve);break;case 16:r(k,we,W,ae,le,Me,ee,fe);break;case 24:a(k,we,W,ae,le,Me,ee,fe);break;case 32:o(k,we,W,ae,le,Me,ee,fe);break;default:throw new Error("THREE.TGALoader: Format not supported.")}return k}const h=0,d=1,f=2,g=3,_=9,m=10,p=11,S=48,v=4,y=0,N=1,P=2,L=3;if(e.length<19)throw new Error("THREE.TGALoader: Not enough data to contain header.");let U=0;const E=new Uint8Array(e),T={id_length:E[U++],colormap_type:E[U++],image_type:E[U++],colormap_index:E[U++]|E[U++]<<8,colormap_length:E[U++]|E[U++]<<8,colormap_size:E[U++],origin:[E[U++]|E[U++]<<8,E[U++]|E[U++]<<8],width:E[U++]|E[U++]<<8,height:E[U++]|E[U++]<<8,pixel_size:E[U++],flags:E[U++]};if(t(T),T.id_length+U>e.length)throw new Error("THREE.TGALoader: No data.");U+=T.id_length;let D=!1,X=!1,q=!1;switch(T.image_type){case _:D=!0,X=!0;break;case d:X=!0;break;case m:D=!0;break;case f:break;case p:D=!0,q=!0;break;case g:q=!0;break}const se=new Uint8Array(T.width*T.height*4),he=n(D,X,T,U,E);return u(se,T.width,T.height,he.pixel_data,he.palettes),{data:se,width:T.width,height:T.height,flipY:!0,generateMipmaps:!0,minFilter:Qn}}}class bx extends wn{load(e,t,n,i){const r=this,a=r.path===""?os.extractUrlBase(e):r.path,o=new Xi(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,function(l){try{t(r.parse(l,a))}catch(c){i?i(c):console.error(c),r.manager.itemError(e)}},n,i)}parse(e,t){function n(M,x){const R=[],A=M.childNodes;for(let C=0,te=A.length;C<te;C++){const ue=A[C];ue.nodeName===x&&R.push(ue)}return R}function i(M){if(M.length===0)return[];const x=M.trim().split(/\s+/),R=new Array(x.length);for(let A=0,C=x.length;A<C;A++)R[A]=x[A];return R}function r(M){if(M.length===0)return[];const x=M.trim().split(/\s+/),R=new Array(x.length);for(let A=0,C=x.length;A<C;A++)R[A]=parseFloat(x[A]);return R}function a(M){if(M.length===0)return[];const x=M.trim().split(/\s+/),R=new Array(x.length);for(let A=0,C=x.length;A<C;A++)R[A]=parseInt(x[A]);return R}function o(M){return M.substring(1)}function l(){return"three_default_"+di++}function c(M){return Object.keys(M).length===0}function u(M){return{unit:h(n(M,"unit")[0]),upAxis:d(n(M,"up_axis")[0])}}function h(M){return M!==void 0&&M.hasAttribute("meter")===!0?parseFloat(M.getAttribute("meter")):1}function d(M){return M!==void 0?M.textContent:"Y_UP"}function f(M,x,R,A){const C=n(M,x)[0];if(C!==void 0){const te=n(C,R);for(let ue=0;ue<te.length;ue++)A(te[ue])}}function g(M,x){for(const R in M){const A=M[R];A.build=x(M[R])}}function _(M,x){return M.build!==void 0||(M.build=x(M)),M.build}function m(M){const x={sources:{},samplers:{},channels:{}};let R=!1;for(let A=0,C=M.childNodes.length;A<C;A++){const te=M.childNodes[A];if(te.nodeType!==1)continue;let ue;switch(te.nodeName){case"source":ue=te.getAttribute("id"),x.sources[ue]=ge(te);break;case"sampler":ue=te.getAttribute("id"),x.samplers[ue]=p(te);break;case"channel":ue=te.getAttribute("target"),x.channels[ue]=S(te);break;case"animation":m(te),R=!0;break;default:console.log(te)}}R===!1&&(dt.animations[M.getAttribute("id")||Xt.generateUUID()]=x)}function p(M){const x={inputs:{}};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"input":const te=o(C.getAttribute("source")),ue=C.getAttribute("semantic");x.inputs[ue]=te;break}}return x}function S(M){const x={};let A=M.getAttribute("target").split("/");const C=A.shift();let te=A.shift();const ue=te.indexOf("(")!==-1,He=te.indexOf(".")!==-1;if(He)A=te.split("."),te=A.shift(),x.member=A.shift();else if(ue){const Ee=te.split("(");te=Ee.shift();for(let Ue=0;Ue<Ee.length;Ue++)Ee[Ue]=parseInt(Ee[Ue].replace(/\)/,""));x.indices=Ee}return x.id=C,x.sid=te,x.arraySyntax=ue,x.memberSyntax=He,x.sampler=o(M.getAttribute("source")),x}function v(M){const x=[],R=M.channels,A=M.samplers,C=M.sources;for(const te in R)if(R.hasOwnProperty(te)){const ue=R[te],He=A[ue.sampler],Ee=He.inputs.INPUT,Ue=He.inputs.OUTPUT,Qe=C[Ee],_e=C[Ue],Je=N(ue,Qe,_e);T(Je,x)}return x}function y(M){return _(dt.animations[M],v)}function N(M,x,R){const A=dt.nodes[M.id],C=mt(A.id),te=A.transforms[M.sid],ue=A.matrix.clone().transpose();let He,Ee,Ue,Qe,_e,Je;const je={};switch(te){case"matrix":for(Ue=0,Qe=x.array.length;Ue<Qe;Ue++)if(He=x.array[Ue],Ee=Ue*R.stride,je[He]===void 0&&(je[He]={}),M.arraySyntax===!0){const Gt=R.array[Ee],Dt=M.indices[0]+4*M.indices[1];je[He][Dt]=Gt}else for(_e=0,Je=R.stride;_e<Je;_e++)je[He][_e]=R.array[Ee+_e];break;case"translate":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',te);break;case"rotate":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',te);break;case"scale":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',te);break}const at=P(je,ue);return{name:C.uuid,keyframes:at}}function P(M,x){const R=[];for(const C in M)R.push({time:parseFloat(C),value:M[C]});R.sort(A);for(let C=0;C<16;C++)D(R,C,x.elements[C]);return R;function A(C,te){return C.time-te.time}}const L=new O,U=new O,E=new nn;function T(M,x){const R=M.keyframes,A=M.name,C=[],te=[],ue=[],He=[];for(let Ee=0,Ue=R.length;Ee<Ue;Ee++){const Qe=R[Ee],_e=Qe.time,Je=Qe.value;z.fromArray(Je).transpose(),z.decompose(L,E,U),C.push(_e),te.push(L.x,L.y,L.z),ue.push(E.x,E.y,E.z,E.w),He.push(U.x,U.y,U.z)}return te.length>0&&x.push(new Ri(A+".position",C,te)),ue.length>0&&x.push(new wi(A+".quaternion",C,ue)),He.length>0&&x.push(new Ri(A+".scale",C,He)),x}function D(M,x,R){let A,C=!0,te,ue;for(te=0,ue=M.length;te<ue;te++)A=M[te],A.value[x]===void 0?A.value[x]=null:C=!1;if(C===!0)for(te=0,ue=M.length;te<ue;te++)A=M[te],A.value[x]=R;else X(M,x)}function X(M,x){let R,A;for(let C=0,te=M.length;C<te;C++){const ue=M[C];if(ue.value[x]===null){if(R=q(M,C,x),A=se(M,C,x),R===null){ue.value[x]=A.value[x];continue}if(A===null){ue.value[x]=R.value[x];continue}he(ue,R,A,x)}}}function q(M,x,R){for(;x>=0;){const A=M[x];if(A.value[R]!==null)return A;x--}return null}function se(M,x,R){for(;x<M.length;){const A=M[x];if(A.value[R]!==null)return A;x++}return null}function he(M,x,R,A){if(R.time-x.time===0){M.value[A]=x.value[A];return}M.value[A]=(M.time-x.time)*(R.value[A]-x.value[A])/(R.time-x.time)+x.value[A]}function k(M){const x={name:M.getAttribute("id")||"default",start:parseFloat(M.getAttribute("start")||0),end:parseFloat(M.getAttribute("end")||0),animations:[]};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"instance_animation":x.animations.push(o(C.getAttribute("url")));break}}dt.clips[M.getAttribute("id")]=x}function oe(M){const x=[],R=M.name,A=M.end-M.start||-1,C=M.animations;for(let te=0,ue=C.length;te<ue;te++){const He=y(C[te]);for(let Ee=0,Ue=He.length;Ee<Ue;Ee++)x.push(He[Ee])}return new Pa(R,A,x)}function G(M){return _(dt.clips[M],oe)}function fe(M){const x={};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"skin":x.id=o(C.getAttribute("source")),x.skin=ve(C);break;case"morph":x.id=o(C.getAttribute("source")),console.warn("THREE.ColladaLoader: Morph target animation not supported yet.");break}}dt.controllers[M.getAttribute("id")]=x}function ve(M){const x={sources:{}};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"bind_shape_matrix":x.bindShapeMatrix=r(C.textContent);break;case"source":const te=C.getAttribute("id");x.sources[te]=ge(C);break;case"joints":x.joints=le(C);break;case"vertex_weights":x.vertexWeights=we(C);break}}return x}function le(M){const x={inputs:{}};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"input":const te=C.getAttribute("semantic"),ue=o(C.getAttribute("source"));x.inputs[te]=ue;break}}return x}function we(M){const x={inputs:{}};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"input":const te=C.getAttribute("semantic"),ue=o(C.getAttribute("source")),He=parseInt(C.getAttribute("offset"));x.inputs[te]={id:ue,offset:He};break;case"vcount":x.vcount=a(C.textContent);break;case"v":x.v=a(C.textContent);break}}return x}function Me(M){const x={id:M.id},R=dt.geometries[x.id];return M.skin!==void 0&&(x.skin=W(M.skin),R.sources.skinIndices=x.skin.indices,R.sources.skinWeights=x.skin.weights),x}function W(M){const R={joints:[],indices:{array:[],stride:4},weights:{array:[],stride:4}},A=M.sources,C=M.vertexWeights,te=C.vcount,ue=C.v,He=C.inputs.JOINT.offset,Ee=C.inputs.WEIGHT.offset,Ue=M.sources[M.joints.inputs.JOINT],Qe=M.sources[M.joints.inputs.INV_BIND_MATRIX],_e=A[C.inputs.WEIGHT.id].array;let Je=0,je,at,it;for(je=0,it=te.length;je<it;je++){const Dt=te[je],Ct=[];for(at=0;at<Dt;at++){const Pt=ue[Je+He],fi=ue[Je+Ee],Cn=_e[fi];Ct.push({index:Pt,weight:Cn}),Je+=2}for(Ct.sort(Gt),at=0;at<4;at++){const Pt=Ct[at];Pt!==void 0?(R.indices.array.push(Pt.index),R.weights.array.push(Pt.weight)):(R.indices.array.push(0),R.weights.array.push(0))}}for(M.bindShapeMatrix?R.bindMatrix=new Fe().fromArray(M.bindShapeMatrix).transpose():R.bindMatrix=new Fe().identity(),je=0,it=Ue.array.length;je<it;je++){const Dt=Ue.array[je],Ct=new Fe().fromArray(Qe.array,je*Qe.stride).transpose();R.joints.push({name:Dt,boneInverse:Ct})}return R;function Gt(Dt,Ct){return Ct.weight-Dt.weight}}function ee(M){return _(dt.controllers[M],Me)}function ae(M){const x={init_from:n(M,"init_from")[0].textContent};dt.images[M.getAttribute("id")]=x}function re(M){return M.build!==void 0?M.build:M.init_from}function Se(M){const x=dt.images[M];return x!==void 0?_(x,re):(console.warn("THREE.ColladaLoader: Couldn't find image with ID:",M),null)}function ot(M){const x={};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"profile_COMMON":x.profile=J(C);break}}dt.effects[M.getAttribute("id")]=x}function J(M){const x={surfaces:{},samplers:{}};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"newparam":$(C,x);break;case"technique":x.technique=I(C);break;case"extra":x.extra=Ie(C);break}}return x}function $(M,x){const R=M.getAttribute("sid");for(let A=0,C=M.childNodes.length;A<C;A++){const te=M.childNodes[A];if(te.nodeType===1)switch(te.nodeName){case"surface":x.surfaces[R]=Z(te);break;case"sampler2D":x.samplers[R]=ie(te);break}}}function Z(M){const x={};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"init_from":x.init_from=C.textContent;break}}return x}function ie(M){const x={};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"source":x.source=C.textContent;break}}return x}function I(M){const x={};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"constant":case"lambert":case"blinn":case"phong":x.type=C.nodeName,x.parameters=Te(C);break;case"extra":x.extra=Ie(C);break}}return x}function Te(M){const x={};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"emission":case"diffuse":case"specular":case"bump":case"ambient":case"shininess":case"transparency":x[C.nodeName]=de(C);break;case"transparent":x[C.nodeName]={opaque:C.hasAttribute("opaque")?C.getAttribute("opaque"):"A_ONE",data:de(C)};break}}return x}function de(M){const x={};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"color":x[C.nodeName]=r(C.textContent);break;case"float":x[C.nodeName]=parseFloat(C.textContent);break;case"texture":x[C.nodeName]={id:C.getAttribute("texture"),extra:qe(C)};break}}return x}function qe(M){const x={technique:{}};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"extra":De(C,x);break}}return x}function De(M,x){for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"technique":Oe(C,x);break}}}function Oe(M,x){for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"repeatU":case"repeatV":case"offsetU":case"offsetV":x.technique[C.nodeName]=parseFloat(C.textContent);break;case"wrapU":case"wrapV":C.textContent.toUpperCase()==="TRUE"?x.technique[C.nodeName]=1:C.textContent.toUpperCase()==="FALSE"?x.technique[C.nodeName]=0:x.technique[C.nodeName]=parseInt(C.textContent);break;case"bump":x[C.nodeName]=Nt(C);break}}}function Ie(M){const x={};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"technique":x.technique=tt(C);break}}return x}function tt(M){const x={};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"double_sided":x[C.nodeName]=parseInt(C.textContent);break;case"bump":x[C.nodeName]=Nt(C);break}}return x}function Nt(M){const x={};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"texture":x[C.nodeName]={id:C.getAttribute("texture"),texcoord:C.getAttribute("texcoord"),extra:qe(C)};break}}return x}function F(M){return M}function b(M){return _(dt.effects[M],F)}function K(M){const x={name:M.getAttribute("name")};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"instance_effect":x.url=o(C.getAttribute("url"));break}}dt.materials[M.getAttribute("id")]=x}function ce(M){let x,R=M.slice((M.lastIndexOf(".")-1>>>0)+2);switch(R=R.toLowerCase(),R){case"tga":x=mn;break;default:x=Mn}return x}function pe(M){const x=b(M.url),R=x.profile.technique;let A;switch(R.type){case"phong":case"blinn":A=new as;break;case"lambert":A=new yh;break;default:A=new bi;break}A.name=M.name||"";function C(Ee,Ue=null){const Qe=x.profile.samplers[Ee.id];let _e=null;if(Qe!==void 0){const Je=x.profile.surfaces[Qe.source];_e=Se(Je.init_from)}else console.warn("THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530)."),_e=Se(Ee.id);if(_e!==null){const Je=ce(_e);if(Je!==void 0){const je=Je.load(_e),at=Ee.extra;if(at!==void 0&&at.technique!==void 0&&c(at.technique)===!1){const it=at.technique;je.wrapS=it.wrapU?Hn:Dn,je.wrapT=it.wrapV?Hn:Dn,je.offset.set(it.offsetU||0,it.offsetV||0),je.repeat.set(it.repeatU||1,it.repeatV||1)}else je.wrapS=Hn,je.wrapT=Hn;return Ue!==null&&(je.colorSpace=Ue),je}else return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",_e),null}else return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",Ee.id),null}const te=R.parameters;for(const Ee in te){const Ue=te[Ee];switch(Ee){case"diffuse":Ue.color&&A.color.fromArray(Ue.color),Ue.texture&&(A.map=C(Ue.texture,_t));break;case"specular":Ue.color&&A.specular&&A.specular.fromArray(Ue.color),Ue.texture&&(A.specularMap=C(Ue.texture));break;case"bump":Ue.texture&&(A.normalMap=C(Ue.texture));break;case"ambient":Ue.texture&&(A.lightMap=C(Ue.texture,_t));break;case"shininess":Ue.float&&A.shininess&&(A.shininess=Ue.float);break;case"emission":Ue.color&&A.emissive&&A.emissive.fromArray(Ue.color),Ue.texture&&(A.emissiveMap=C(Ue.texture,_t));break}}ft.colorSpaceToWorking(A.color,_t),A.specular&&ft.colorSpaceToWorking(A.specular,_t),A.emissive&&ft.colorSpaceToWorking(A.emissive,_t);let ue=te.transparent,He=te.transparency;if(He===void 0&&ue&&(He={float:1}),ue===void 0&&He&&(ue={opaque:"A_ONE",data:{color:[1,1,1,1]}}),ue&&He)if(ue.data.texture)A.transparent=!0;else{const Ee=ue.data.color;switch(ue.opaque){case"A_ONE":A.opacity=Ee[3]*He.float;break;case"RGB_ZERO":A.opacity=1-Ee[0]*He.float;break;case"A_ZERO":A.opacity=1-Ee[3]*He.float;break;case"RGB_ONE":A.opacity=Ee[0]*He.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',ue.opaque)}A.opacity<1&&(A.transparent=!0)}if(R.extra!==void 0&&R.extra.technique!==void 0){const Ee=R.extra.technique;for(const Ue in Ee){const Qe=Ee[Ue];switch(Ue){case"double_sided":A.side=Qe===1?Zn:ri;break;case"bump":A.normalMap=C(Qe.texture),A.normalScale=new ct(1,1);break}}}return A}function ne(M){return _(dt.materials[M],pe)}function ze(M){const x={name:M.getAttribute("name")};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"optics":x.optics=Ae(C);break}}dt.cameras[M.getAttribute("id")]=x}function Ae(M){for(let x=0;x<M.childNodes.length;x++){const R=M.childNodes[x];switch(R.nodeName){case"technique_common":return We(R)}}return{}}function We(M){const x={};for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];switch(A.nodeName){case"perspective":case"orthographic":x.technique=A.nodeName,x.parameters=Ye(A);break}}return x}function Ye(M){const x={};for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];switch(A.nodeName){case"xfov":case"yfov":case"xmag":case"ymag":case"znear":case"zfar":case"aspect_ratio":x[A.nodeName]=parseFloat(A.textContent);break}}return x}function me(M){let x;switch(M.optics.technique){case"perspective":x=new un(M.optics.parameters.yfov,M.optics.parameters.aspect_ratio,M.optics.parameters.znear,M.optics.parameters.zfar);break;case"orthographic":let R=M.optics.parameters.ymag,A=M.optics.parameters.xmag;const C=M.optics.parameters.aspect_ratio;A=A===void 0?R*C:A,R=R===void 0?A/C:R,A*=.5,R*=.5,x=new ka(-A,A,R,-R,M.optics.parameters.znear,M.optics.parameters.zfar);break;default:x=new un;break}return x.name=M.name||"",x}function ke(M){const x=dt.cameras[M];return x!==void 0?_(x,me):(console.warn("THREE.ColladaLoader: Couldn't find camera with ID:",M),null)}function st(M){let x={};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"technique_common":x=nt(C);break}}dt.lights[M.getAttribute("id")]=x}function nt(M){const x={};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"directional":case"point":case"spot":case"ambient":x.technique=C.nodeName,x.parameters=be(C)}}return x}function be(M){const x={};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"color":const te=r(C.textContent);x.color=new Ge().fromArray(te),ft.colorSpaceToWorking(x.color,_t);break;case"falloff_angle":x.falloffAngle=parseFloat(C.textContent);break;case"quadratic_attenuation":const ue=parseFloat(C.textContent);x.distance=ue?Math.sqrt(1/ue):0;break}}return x}function lt(M){let x;switch(M.technique){case"directional":x=new Ar;break;case"point":x=new La;break;case"spot":x=new ql;break;case"ambient":x=new Kl;break}return M.parameters.color&&x.color.copy(M.parameters.color),M.parameters.distance&&(x.distance=M.parameters.distance),x}function B(M){const x=dt.lights[M];return x!==void 0?_(x,lt):(console.warn("THREE.ColladaLoader: Couldn't find light with ID:",M),null)}function Re(M){const x={name:M.getAttribute("name"),sources:{},vertices:{},primitives:[]},R=n(M,"mesh")[0];if(R!==void 0){for(let A=0;A<R.childNodes.length;A++){const C=R.childNodes[A];if(C.nodeType!==1)continue;const te=C.getAttribute("id");switch(C.nodeName){case"source":x.sources[te]=ge(C);break;case"vertices":x.vertices=Be(C);break;case"polygons":console.warn("THREE.ColladaLoader: Unsupported primitive type: ",C.nodeName);break;case"lines":case"linestrips":case"polylist":case"triangles":x.primitives.push(ye(C));break;default:console.log(C)}}dt.geometries[M.getAttribute("id")]=x}}function ge(M){const x={array:[],stride:3};for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];if(A.nodeType===1)switch(A.nodeName){case"float_array":x.array=r(A.textContent);break;case"Name_array":x.array=i(A.textContent);break;case"technique_common":const C=n(A,"accessor")[0];C!==void 0&&(x.stride=parseInt(C.getAttribute("stride")));break}}return x}function Be(M){const x={};for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];A.nodeType===1&&(x[A.getAttribute("semantic")]=o(A.getAttribute("source")))}return x}function ye(M){const x={type:M.nodeName,material:M.getAttribute("material"),count:parseInt(M.getAttribute("count")),inputs:{},stride:0,hasUV:!1};for(let R=0,A=M.childNodes.length;R<A;R++){const C=M.childNodes[R];if(C.nodeType===1)switch(C.nodeName){case"input":const te=o(C.getAttribute("source")),ue=C.getAttribute("semantic"),He=parseInt(C.getAttribute("offset")),Ee=parseInt(C.getAttribute("set")),Ue=Ee>0?ue+Ee:ue;x.inputs[Ue]={id:te,offset:He},x.stride=Math.max(x.stride,He+1),ue==="TEXCOORD"&&(x.hasUV=!0);break;case"vcount":x.vcount=a(C.textContent);break;case"p":x.p=a(C.textContent);break}}return x}function j(M){const x={};for(let R=0;R<M.length;R++){const A=M[R];x[A.type]===void 0&&(x[A.type]=[]),x[A.type].push(A)}return x}function Ce(M){let x=0;for(let R=0,A=M.length;R<A;R++)M[R].hasUV===!0&&x++;x>0&&x<M.length&&(M.uvsNeedsFix=!0)}function Ze(M){const x={},R=M.sources,A=M.vertices,C=M.primitives;if(C.length===0)return{};const te=j(C);for(const ue in te){const He=te[ue];Ce(He),x[ue]=bt(He,R,A)}return x}function bt(M,x,R){const A={},C={array:[],stride:0},te={array:[],stride:0},ue={array:[],stride:0},He={array:[],stride:0},Ee={array:[],stride:0},Ue={array:[],stride:4},Qe={array:[],stride:4},_e=new Kt,Je=[];let je=0;for(let at=0;at<M.length;at++){const it=M[at],Gt=it.inputs;let Dt=0;switch(it.type){case"lines":case"linestrips":Dt=it.count*2;break;case"triangles":Dt=it.count*3;break;case"polylist":for(let Ct=0;Ct<it.count;Ct++){const Pt=it.vcount[Ct];switch(Pt){case 3:Dt+=3;break;case 4:Dt+=6;break;default:Dt+=(Pt-2)*3;break}}break;default:console.warn("THREE.ColladaLoader: Unknown primitive type:",it.type)}_e.addGroup(je,Dt,at),je+=Dt,it.material&&Je.push(it.material);for(const Ct in Gt){const Pt=Gt[Ct];switch(Ct){case"VERTEX":for(const fi in R){const Cn=R[fi];switch(fi){case"POSITION":const ms=C.array.length;if(pt(it,x[Cn],Pt.offset,C.array),C.stride=x[Cn].stride,x.skinWeights&&x.skinIndices&&(pt(it,x.skinIndices,Pt.offset,Ue.array),pt(it,x.skinWeights,Pt.offset,Qe.array)),it.hasUV===!1&&M.uvsNeedsFix===!0){const Kh=(C.array.length-ms)/C.stride;for(let Ql=0;Ql<Kh;Ql++)ue.array.push(0,0)}break;case"NORMAL":pt(it,x[Cn],Pt.offset,te.array),te.stride=x[Cn].stride;break;case"COLOR":pt(it,x[Cn],Pt.offset,Ee.array),Ee.stride=x[Cn].stride;break;case"TEXCOORD":pt(it,x[Cn],Pt.offset,ue.array),ue.stride=x[Cn].stride;break;case"TEXCOORD1":pt(it,x[Cn],Pt.offset,He.array),ue.stride=x[Cn].stride;break;default:console.warn('THREE.ColladaLoader: Semantic "%s" not handled in geometry build process.',fi)}}break;case"NORMAL":pt(it,x[Pt.id],Pt.offset,te.array),te.stride=x[Pt.id].stride;break;case"COLOR":pt(it,x[Pt.id],Pt.offset,Ee.array,!0),Ee.stride=x[Pt.id].stride;break;case"TEXCOORD":pt(it,x[Pt.id],Pt.offset,ue.array),ue.stride=x[Pt.id].stride;break;case"TEXCOORD1":pt(it,x[Pt.id],Pt.offset,He.array),He.stride=x[Pt.id].stride;break}}}return C.array.length>0&&_e.setAttribute("position",new vt(C.array,C.stride)),te.array.length>0&&_e.setAttribute("normal",new vt(te.array,te.stride)),Ee.array.length>0&&_e.setAttribute("color",new vt(Ee.array,Ee.stride)),ue.array.length>0&&_e.setAttribute("uv",new vt(ue.array,ue.stride)),He.array.length>0&&_e.setAttribute("uv1",new vt(He.array,He.stride)),Ue.array.length>0&&_e.setAttribute("skinIndex",new vt(Ue.array,Ue.stride)),Qe.array.length>0&&_e.setAttribute("skinWeight",new vt(Qe.array,Qe.stride)),A.data=_e,A.type=M[0].type,A.materialKeys=Je,A}function pt(M,x,R,A,C=!1){const te=M.p,ue=M.stride,He=M.vcount;function Ee(_e){let Je=te[_e+R]*Qe;const je=Je+Qe;for(;Je<je;Je++)A.push(Ue[Je]);if(C){const at=A.length-Qe-1;Zt.setRGB(A[at+0],A[at+1],A[at+2],_t),A[at+0]=Zt.r,A[at+1]=Zt.g,A[at+2]=Zt.b}}const Ue=x.array,Qe=x.stride;if(M.vcount!==void 0){let _e=0;for(let Je=0,je=He.length;Je<je;Je++){const at=He[Je];if(at===4){const it=_e+ue*0,Gt=_e+ue*1,Dt=_e+ue*2,Ct=_e+ue*3;Ee(it),Ee(Gt),Ee(Ct),Ee(Gt),Ee(Dt),Ee(Ct)}else if(at===3){const it=_e+ue*0,Gt=_e+ue*1,Dt=_e+ue*2;Ee(it),Ee(Gt),Ee(Dt)}else if(at>4)for(let it=1,Gt=at-2;it<=Gt;it++){const Dt=_e+ue*0,Ct=_e+ue*it,Pt=_e+ue*(it+1);Ee(Dt),Ee(Ct),Ee(Pt)}_e+=ue*at}}else for(let _e=0,Je=te.length;_e<Je;_e+=ue)Ee(_e)}function Jt(M){return _(dt.geometries[M],Ze)}function $e(M){const x={name:M.getAttribute("name")||"",joints:{},links:[]};for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];if(A.nodeType===1)switch(A.nodeName){case"technique_common":dn(A,x);break}}dt.kinematicsModels[M.getAttribute("id")]=x}function Ne(M){return M.build!==void 0?M.build:M}function Yt(M){return _(dt.kinematicsModels[M],Ne)}function dn(M,x){for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];if(A.nodeType===1)switch(A.nodeName){case"joint":x.joints[A.getAttribute("sid")]=jt(A);break;case"link":x.links.push(vn(A));break}}}function jt(M){let x;for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];if(A.nodeType===1)switch(A.nodeName){case"prismatic":case"revolute":x=pn(A);break}}return x}function pn(M){const x={sid:M.getAttribute("sid"),name:M.getAttribute("name")||"",axis:new O,limits:{min:0,max:0},type:M.nodeName,static:!1,zeroPosition:0,middlePosition:0};for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];if(A.nodeType===1)switch(A.nodeName){case"axis":const C=r(A.textContent);x.axis.fromArray(C);break;case"limits":const te=A.getElementsByTagName("max")[0],ue=A.getElementsByTagName("min")[0];x.limits.max=parseFloat(te.textContent),x.limits.min=parseFloat(ue.textContent);break}}return x.limits.min>=x.limits.max&&(x.static=!0),x.middlePosition=(x.limits.min+x.limits.max)/2,x}function vn(M){const x={sid:M.getAttribute("sid"),name:M.getAttribute("name")||"",attachments:[],transforms:[]};for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];if(A.nodeType===1)switch(A.nodeName){case"attachment_full":x.attachments.push(ci(A));break;case"matrix":case"translate":case"rotate":x.transforms.push(Pi(A));break}}return x}function ci(M){const x={joint:M.getAttribute("joint").split("/").pop(),transforms:[],links:[]};for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];if(A.nodeType===1)switch(A.nodeName){case"link":x.links.push(vn(A));break;case"matrix":case"translate":case"rotate":x.transforms.push(Pi(A));break}}return x}function Pi(M){const x={type:M.nodeName},R=r(M.textContent);switch(x.type){case"matrix":x.obj=new Fe,x.obj.fromArray(R).transpose();break;case"translate":x.obj=new O,x.obj.fromArray(R);break;case"rotate":x.obj=new O,x.obj.fromArray(R),x.angle=Xt.degToRad(R[3]);break}return x}function ui(M){const x={name:M.getAttribute("name")||"",rigidBodies:{}};for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];if(A.nodeType===1)switch(A.nodeName){case"rigid_body":x.rigidBodies[A.getAttribute("name")]={},ji(A,x.rigidBodies[A.getAttribute("name")]);break}}dt.physicsModels[M.getAttribute("id")]=x}function ji(M,x){for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];if(A.nodeType===1)switch(A.nodeName){case"technique_common":qi(A,x);break}}}function qi(M,x){for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];if(A.nodeType===1)switch(A.nodeName){case"inertia":x.inertia=r(A.textContent);break;case"mass":x.mass=r(A.textContent)[0];break}}}function fs(M){const x={bindJointAxis:[]};for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];if(A.nodeType===1)switch(A.nodeName){case"bind_joint_axis":x.bindJointAxis.push(Ki(A));break}}dt.kinematicsScenes[o(M.getAttribute("url"))]=x}function Ki(M){const x={target:M.getAttribute("target").split("/").pop()};for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];if(A.nodeType===1)switch(A.nodeName){case"axis":const C=A.getElementsByTagName("param")[0];x.axis=C.textContent;const te=x.axis.split("inst_").pop().split("axis")[0];x.jointIndex=te.substring(0,te.length-1);break}}return x}function xn(M){return M.build!==void 0?M.build:M}function hi(M){return _(dt.kinematicsScenes[M],xn)}function za(){const M=Object.keys(dt.kinematicsModels)[0],x=Object.keys(dt.kinematicsScenes)[0],R=Object.keys(dt.visualScenes)[0];if(M===void 0||x===void 0)return;const A=Yt(M),C=hi(x),te=Et(R),ue=C.bindJointAxis,He={};for(let Qe=0,_e=ue.length;Qe<_e;Qe++){const Je=ue[Qe],je=zt.querySelector('[sid="'+Je.target+'"]');if(je){const at=je.parentElement;Ee(Je.jointIndex,at)}}function Ee(Qe,_e){const Je=_e.getAttribute("name"),je=A.joints[Qe];te.traverse(function(at){at.name===Je&&(He[Qe]={object:at,transforms:Va(_e),joint:je,position:je.zeroPosition})})}const Ue=new Fe;ps={joints:A&&A.joints,getJointValue:function(Qe){const _e=He[Qe];if(_e)return _e.position;console.warn("THREE.ColladaLoader: Joint "+Qe+" doesn't exist.")},setJointValue:function(Qe,_e){const Je=He[Qe];if(Je){const je=Je.joint;if(_e>je.limits.max||_e<je.limits.min)console.warn("THREE.ColladaLoader: Joint "+Qe+" value "+_e+" outside of limits (min: "+je.limits.min+", max: "+je.limits.max+").");else if(je.static)console.warn("THREE.ColladaLoader: Joint "+Qe+" is static.");else{const at=Je.object,it=je.axis,Gt=Je.transforms;z.identity();for(let Dt=0;Dt<Gt.length;Dt++){const Ct=Gt[Dt];if(Ct.sid&&Ct.sid.indexOf(Qe)!==-1)switch(je.type){case"revolute":z.multiply(Ue.makeRotationAxis(it,Xt.degToRad(_e)));break;case"prismatic":z.multiply(Ue.makeTranslation(it.x*_e,it.y*_e,it.z*_e));break;default:console.warn("THREE.ColladaLoader: Unknown joint type: "+je.type);break}else switch(Ct.type){case"matrix":z.multiply(Ct.obj);break;case"translate":z.multiply(Ue.makeTranslation(Ct.obj.x,Ct.obj.y,Ct.obj.z));break;case"scale":z.scale(Ct.obj);break;case"rotate":z.multiply(Ue.makeRotationAxis(Ct.obj,Ct.angle));break}}at.matrix.copy(z),at.matrix.decompose(at.position,at.quaternion,at.scale),He[Qe].position=_e}}else console.log("THREE.ColladaLoader: "+Qe+" does not exist.")}}}function Va(M){const x=[],R=zt.querySelector('[id="'+M.id+'"]');for(let A=0;A<R.childNodes.length;A++){const C=R.childNodes[A];if(C.nodeType!==1)continue;let te,ue;switch(C.nodeName){case"matrix":te=r(C.textContent);const He=new Fe().fromArray(te).transpose();x.push({sid:C.getAttribute("sid"),type:C.nodeName,obj:He});break;case"translate":case"scale":te=r(C.textContent),ue=new O().fromArray(te),x.push({sid:C.getAttribute("sid"),type:C.nodeName,obj:ue});break;case"rotate":te=r(C.textContent),ue=new O().fromArray(te);const Ee=Xt.degToRad(te[3]);x.push({sid:C.getAttribute("sid"),type:C.nodeName,obj:ue,angle:Ee});break}}return x}function w(M){const x=M.getElementsByTagName("node");for(let R=0;R<x.length;R++){const A=x[R];A.hasAttribute("id")===!1&&A.setAttribute("id",l())}}const z=new Fe,Y=new O;function Q(M){const x={name:M.getAttribute("name")||"",type:M.getAttribute("type"),id:M.getAttribute("id"),sid:M.getAttribute("sid"),matrix:new Fe,nodes:[],instanceCameras:[],instanceControllers:[],instanceLights:[],instanceGeometries:[],instanceNodes:[],transforms:{}};for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];if(A.nodeType!==1)continue;let C;switch(A.nodeName){case"node":x.nodes.push(A.getAttribute("id")),Q(A);break;case"instance_camera":x.instanceCameras.push(o(A.getAttribute("url")));break;case"instance_controller":x.instanceControllers.push(H(A));break;case"instance_light":x.instanceLights.push(o(A.getAttribute("url")));break;case"instance_geometry":x.instanceGeometries.push(H(A));break;case"instance_node":x.instanceNodes.push(o(A.getAttribute("url")));break;case"matrix":C=r(A.textContent),x.matrix.multiply(z.fromArray(C).transpose()),x.transforms[A.getAttribute("sid")]=A.nodeName;break;case"translate":C=r(A.textContent),Y.fromArray(C),x.matrix.multiply(z.makeTranslation(Y.x,Y.y,Y.z)),x.transforms[A.getAttribute("sid")]=A.nodeName;break;case"rotate":C=r(A.textContent);const te=Xt.degToRad(C[3]);x.matrix.multiply(z.makeRotationAxis(Y.fromArray(C),te)),x.transforms[A.getAttribute("sid")]=A.nodeName;break;case"scale":C=r(A.textContent),x.matrix.scale(Y.fromArray(C)),x.transforms[A.getAttribute("sid")]=A.nodeName;break;case"extra":break;default:console.log(A)}}return et(x.id)?console.warn("THREE.ColladaLoader: There is already a node with ID %s. Exclude current node from further processing.",x.id):dt.nodes[x.id]=x,x}function H(M){const x={id:o(M.getAttribute("url")),materials:{},skeletons:[]};for(let R=0;R<M.childNodes.length;R++){const A=M.childNodes[R];switch(A.nodeName){case"bind_material":const C=A.getElementsByTagName("instance_material");for(let te=0;te<C.length;te++){const ue=C[te],He=ue.getAttribute("symbol"),Ee=ue.getAttribute("target");x.materials[He]=o(Ee)}break;case"skeleton":x.skeletons.push(o(A.textContent));break}}return x}function xe(M,x){const R=[],A=[];let C,te,ue;for(C=0;C<M.length;C++){const Ue=M[C];let Qe;if(et(Ue))Qe=mt(Ue),Pe(Qe,x,R);else if(Ht(Ue)){const Je=dt.visualScenes[Ue].children;for(let je=0;je<Je.length;je++){const at=Je[je];if(at.type==="JOINT"){const it=mt(at.id);Pe(it,x,R)}}}else console.error("THREE.ColladaLoader: Unable to find root bone of skeleton with ID:",Ue)}for(C=0;C<x.length;C++)for(te=0;te<R.length;te++)if(ue=R[te],ue.bone.name===x[C].name){A[C]=ue,ue.processed=!0;break}for(C=0;C<R.length;C++)ue=R[C],ue.processed===!1&&(A.push(ue),ue.processed=!0);const He=[],Ee=[];for(C=0;C<A.length;C++)ue=A[C],He.push(ue.bone),Ee.push(ue.boneInverse);return new Lr(He,Ee)}function Pe(M,x,R){M.traverse(function(A){if(A.isBone===!0){let C;for(let te=0;te<x.length;te++){const ue=x[te];if(ue.name===A.name){C=ue.boneInverse;break}}C===void 0&&(C=new Fe),R.push({bone:A,boneInverse:C,processed:!1})}})}function Xe(M){const x=[],R=M.matrix,A=M.nodes,C=M.type,te=M.instanceCameras,ue=M.instanceControllers,He=M.instanceLights,Ee=M.instanceGeometries,Ue=M.instanceNodes;for(let _e=0,Je=A.length;_e<Je;_e++)x.push(mt(A[_e]));for(let _e=0,Je=te.length;_e<Je;_e++){const je=ke(te[_e]);je!==null&&x.push(je.clone())}for(let _e=0,Je=ue.length;_e<Je;_e++){const je=ue[_e],at=ee(je.id),it=Jt(at.id),Gt=ht(it,je.materials),Dt=je.skeletons,Ct=at.skin.joints,Pt=xe(Dt,Ct);for(let fi=0,Cn=Gt.length;fi<Cn;fi++){const ms=Gt[fi];ms.isSkinnedMesh&&(ms.bind(Pt,at.skin.bindMatrix),ms.normalizeSkinWeights()),x.push(ms)}}for(let _e=0,Je=He.length;_e<Je;_e++){const je=B(He[_e]);je!==null&&x.push(je.clone())}for(let _e=0,Je=Ee.length;_e<Je;_e++){const je=Ee[_e],at=Jt(je.id),it=ht(at,je.materials);for(let Gt=0,Dt=it.length;Gt<Dt;Gt++)x.push(it[Gt])}for(let _e=0,Je=Ue.length;_e<Je;_e++)x.push(mt(Ue[_e]).clone());let Qe;if(A.length===0&&x.length===1)Qe=x[0];else{Qe=C==="JOINT"?new Mr:new Wn;for(let _e=0;_e<x.length;_e++)Qe.add(x[_e])}return Qe.name=C==="JOINT"?M.sid:M.name,Qe.matrix.copy(R),Qe.matrix.decompose(Qe.position,Qe.quaternion,Qe.scale),Qe}const Ve=new bi({name:wn.DEFAULT_MATERIAL_NAME,color:16711935});function ut(M,x){const R=[];for(let A=0,C=M.length;A<C;A++){const te=x[M[A]];te===void 0?(console.warn("THREE.ColladaLoader: Material with key %s not found. Apply fallback material.",M[A]),R.push(Ve)):R.push(ne(te))}return R}function ht(M,x){const R=[];for(const A in M){const C=M[A],te=ut(C.materialKeys,x);if(te.length===0&&(A==="lines"||A==="linestrips"?te.push(new si):te.push(new as)),A==="lines"||A==="linestrips")for(let Ue=0,Qe=te.length;Ue<Qe;Ue++){const _e=te[Ue];if(_e.isMeshPhongMaterial===!0||_e.isMeshLambertMaterial===!0){const Je=new si;Je.color.copy(_e.color),Je.opacity=_e.opacity,Je.transparent=_e.transparent,te[Ue]=Je}}const ue=C.data.attributes.skinIndex!==void 0,He=te.length===1?te[0]:te;let Ee;switch(A){case"lines":Ee=new js(C.data,He);break;case"linestrips":Ee=new Dr(C.data,He);break;case"triangles":case"polylist":ue?Ee=new Vl(C.data,He):Ee=new rn(C.data,He);break}R.push(Ee)}return R}function et(M){return dt.nodes[M]!==void 0}function mt(M){return _(dt.nodes[M],Xe)}function Lt(M){const x={name:M.getAttribute("name"),children:[]};w(M);const R=n(M,"node");for(let A=0;A<R.length;A++)x.children.push(Q(R[A]));dt.visualScenes[M.getAttribute("id")]=x}function Bt(M){const x=new Wn;x.name=M.name;const R=M.children;for(let A=0;A<R.length;A++){const C=R[A];x.add(mt(C.id))}return x}function Ht(M){return dt.visualScenes[M]!==void 0}function Et(M){return _(dt.visualScenes[M],Bt)}function rt(M){const x=n(M,"instance_visual_scene")[0];return Et(o(x.getAttribute("url")))}function Qt(){const M=dt.clips;if(c(M)===!0){if(c(dt.animations)===!1){const x=[];for(const R in dt.animations){const A=y(R);for(let C=0,te=A.length;C<te;C++)x.push(A[C])}en.push(new Pa("default",-1,x))}}else for(const x in M)en.push(G(x))}function Rt(M){let x="";const R=[M];for(;R.length;){const A=R.shift();A.nodeType===Node.TEXT_NODE?x+=A.textContent:(x+=`
3837
+ `,R.push(...A.childNodes))}return x.trim()}if(e.length===0)return{scene:new dh};const Rn=new DOMParser().parseFromString(e,"application/xml"),zt=n(Rn,"COLLADA")[0],fn=Rn.getElementsByTagName("parsererror")[0];if(fn!==void 0){const M=n(fn,"div")[0];let x;return M?x=M.textContent:x=Rt(fn),console.error(`THREE.ColladaLoader: Failed to parse collada file.
3838
+ `,x),null}const Yi=zt.getAttribute("version");console.debug("THREE.ColladaLoader: File version",Yi);const Ot=u(n(zt,"asset")[0]),Mn=new Xl(this.manager);Mn.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);let mn;Fu&&(mn=new Fu(this.manager),mn.setPath(this.resourcePath||t));const Zt=new Ge,en=[];let ps={},di=0;const dt={animations:{},clips:{},controllers:{},images:{},effects:{},materials:{},cameras:{},lights:{},geometries:{},nodes:{},visualScenes:{},kinematicsModels:{},physicsModels:{},kinematicsScenes:{}};f(zt,"library_animations","animation",m),f(zt,"library_animation_clips","animation_clip",k),f(zt,"library_controllers","controller",fe),f(zt,"library_images","image",ae),f(zt,"library_effects","effect",ot),f(zt,"library_materials","material",K),f(zt,"library_cameras","camera",ze),f(zt,"library_lights","light",st),f(zt,"library_geometries","geometry",Re),f(zt,"library_nodes","node",Q),f(zt,"library_visual_scenes","visual_scene",Lt),f(zt,"library_kinematics_models","kinematics_model",$e),f(zt,"library_physics_models","physics_model",ui),f(zt,"scene","instance_kinematics_scene",fs),g(dt.animations,v),g(dt.clips,oe),g(dt.controllers,Me),g(dt.images,re),g(dt.effects,F),g(dt.materials,pe),g(dt.cameras,me),g(dt.lights,lt),g(dt.geometries,Ze),g(dt.visualScenes,Bt),Qt(),za();const Ur=rt(n(zt,"scene")[0]);return Ur.animations=en,Ot.upAxis==="Z_UP"&&(console.warn("THREE.ColladaLoader: You are loading an asset with a Z-UP coordinate system. The loader just rotates the asset to transform it into Y-UP. The vertex data are not converted, see #24289."),Ur.rotation.set(-Math.PI/2,0,0)),Ur.scale.multiplyScalar(Ot.unit),{get animations(){return console.warn("THREE.ColladaLoader: Please access animations over scene.animations now."),en},kinematics:ps,library:dt,scene:Ur}}}const Pn=new Ge;class Ex extends wn{constructor(e){super(e),this.propertyNameMapping={},this.customPropertyMapping={}}load(e,t,n,i){const r=this,a=new Xi(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(r.parse(o))}catch(l){i?i(l):console.error(l),r.manager.itemError(e)}},n,i)}setPropertyNameMapping(e){this.propertyNameMapping=e}setCustomPropertyNameMapping(e){this.customPropertyMapping=e}parse(e){function t(m,p=0){const S=/^ply([\s\S]*)end_header(\r\n|\r|\n)/;let v="";const y=S.exec(m);y!==null&&(v=y[1]);const N={comments:[],elements:[],headerLength:p,objInfo:""},P=v.split(/\r\n|\r|\n/);let L;function U(E,T){const D={type:E[0]};return D.type==="list"?(D.name=E[3],D.countType=E[1],D.itemType=E[2]):D.name=E[1],D.name in T&&(D.name=T[D.name]),D}for(let E=0;E<P.length;E++){let T=P[E];if(T=T.trim(),T==="")continue;const D=T.split(/\s+/),X=D.shift();switch(T=D.join(" "),X){case"format":N.format=D[0],N.version=D[1];break;case"comment":N.comments.push(T);break;case"element":L!==void 0&&N.elements.push(L),L={},L.name=D[0],L.count=parseInt(D[1]),L.properties=[];break;case"property":L.properties.push(U(D,_.propertyNameMapping));break;case"obj_info":N.objInfo=T;break;default:console.log("unhandled",X,D)}}return L!==void 0&&N.elements.push(L),N}function n(m,p){switch(p){case"char":case"uchar":case"short":case"ushort":case"int":case"uint":case"int8":case"uint8":case"int16":case"uint16":case"int32":case"uint32":return parseInt(m);case"float":case"double":case"float32":case"float64":return parseFloat(m)}}function i(m,p){const S={};for(let v=0;v<m.length;v++){if(p.empty())return null;if(m[v].type==="list"){const y=[],N=n(p.next(),m[v].countType);for(let P=0;P<N;P++){if(p.empty())return null;y.push(n(p.next(),m[v].itemType))}S[m[v].name]=y}else S[m[v].name]=n(p.next(),m[v].type)}return S}function r(){const m={indices:[],vertices:[],normals:[],uvs:[],faceVertexUvs:[],colors:[],faceVertexColors:[]};for(const p of Object.keys(_.customPropertyMapping))m[p]=[];return m}function a(m){const p=m.map(v=>v.name);function S(v){for(let y=0,N=v.length;y<N;y++){const P=v[y];if(p.includes(P))return P}return null}return{attrX:S(["x","px","posx"])||"x",attrY:S(["y","py","posy"])||"y",attrZ:S(["z","pz","posz"])||"z",attrNX:S(["nx","normalx"]),attrNY:S(["ny","normaly"]),attrNZ:S(["nz","normalz"]),attrS:S(["s","u","texture_u","tx"]),attrT:S(["t","v","texture_v","ty"]),attrR:S(["red","diffuse_red","r","diffuse_r"]),attrG:S(["green","diffuse_green","g","diffuse_g"]),attrB:S(["blue","diffuse_blue","b","diffuse_b"])}}function o(m,p){const S=r(),v=/end_header\s+(\S[\s\S]*\S|\S)\s*$/;let y,N;(N=v.exec(m))!==null?y=N[1].split(/\s+/):y=[];const P=new Ax(y);e:for(let L=0;L<p.elements.length;L++){const U=p.elements[L],E=a(U.properties);for(let T=0;T<U.count;T++){const D=i(U.properties,P);if(!D)break e;c(S,U.name,D,E)}}return l(S)}function l(m){let p=new Kt;m.indices.length>0&&p.setIndex(m.indices),p.setAttribute("position",new vt(m.vertices,3)),m.normals.length>0&&p.setAttribute("normal",new vt(m.normals,3)),m.uvs.length>0&&p.setAttribute("uv",new vt(m.uvs,2)),m.colors.length>0&&p.setAttribute("color",new vt(m.colors,3)),(m.faceVertexUvs.length>0||m.faceVertexColors.length>0)&&(p=p.toNonIndexed(),m.faceVertexUvs.length>0&&p.setAttribute("uv",new vt(m.faceVertexUvs,2)),m.faceVertexColors.length>0&&p.setAttribute("color",new vt(m.faceVertexColors,3)));for(const S of Object.keys(_.customPropertyMapping))m[S].length>0&&p.setAttribute(S,new vt(m[S],_.customPropertyMapping[S].length));return p.computeBoundingSphere(),p}function c(m,p,S,v){if(p==="vertex"){m.vertices.push(S[v.attrX],S[v.attrY],S[v.attrZ]),v.attrNX!==null&&v.attrNY!==null&&v.attrNZ!==null&&m.normals.push(S[v.attrNX],S[v.attrNY],S[v.attrNZ]),v.attrS!==null&&v.attrT!==null&&m.uvs.push(S[v.attrS],S[v.attrT]),v.attrR!==null&&v.attrG!==null&&v.attrB!==null&&(Pn.setRGB(S[v.attrR]/255,S[v.attrG]/255,S[v.attrB]/255,_t),m.colors.push(Pn.r,Pn.g,Pn.b));for(const y of Object.keys(_.customPropertyMapping))for(const N of _.customPropertyMapping[y])m[y].push(S[N])}else if(p==="face"){const y=S.vertex_indices||S.vertex_index,N=S.texcoord;y.length===3?(m.indices.push(y[0],y[1],y[2]),N&&N.length===6&&(m.faceVertexUvs.push(N[0],N[1]),m.faceVertexUvs.push(N[2],N[3]),m.faceVertexUvs.push(N[4],N[5]))):y.length===4&&(m.indices.push(y[0],y[1],y[3]),m.indices.push(y[1],y[2],y[3])),v.attrR!==null&&v.attrG!==null&&v.attrB!==null&&(Pn.setRGB(S[v.attrR]/255,S[v.attrG]/255,S[v.attrB]/255,_t),m.faceVertexColors.push(Pn.r,Pn.g,Pn.b),m.faceVertexColors.push(Pn.r,Pn.g,Pn.b),m.faceVertexColors.push(Pn.r,Pn.g,Pn.b))}}function u(m,p){const S={};let v=0;for(let y=0;y<p.length;y++){const N=p[y],P=N.valueReader;if(N.type==="list"){const L=[],U=N.countReader.read(m+v);v+=N.countReader.size;for(let E=0;E<U;E++)L.push(P.read(m+v)),v+=P.size;S[N.name]=L}else S[N.name]=P.read(m+v),v+=P.size}return[S,v]}function h(m,p,S){function v(y,N,P){switch(N){case"int8":case"char":return{read:L=>y.getInt8(L),size:1};case"uint8":case"uchar":return{read:L=>y.getUint8(L),size:1};case"int16":case"short":return{read:L=>y.getInt16(L,P),size:2};case"uint16":case"ushort":return{read:L=>y.getUint16(L,P),size:2};case"int32":case"int":return{read:L=>y.getInt32(L,P),size:4};case"uint32":case"uint":return{read:L=>y.getUint32(L,P),size:4};case"float32":case"float":return{read:L=>y.getFloat32(L,P),size:4};case"float64":case"double":return{read:L=>y.getFloat64(L,P),size:8}}}for(let y=0,N=m.length;y<N;y++){const P=m[y];P.type==="list"?(P.countReader=v(p,P.countType,S),P.valueReader=v(p,P.itemType,S)):P.valueReader=v(p,P.type,S)}}function d(m,p){const S=r(),v=p.format==="binary_little_endian",y=new DataView(m,p.headerLength);let N,P=0;for(let L=0;L<p.elements.length;L++){const U=p.elements[L],E=U.properties,T=a(E);h(E,y,v);for(let D=0;D<U.count;D++){N=u(P,E),P+=N[1];const X=N[0];c(S,U.name,X,T)}}return l(S)}function f(m){let p=0,S=!0,v="";const y=[],N=new TextDecoder().decode(m.subarray(0,5)),P=/^ply\r\n/.test(N);do{const L=String.fromCharCode(m[p++]);L!==`
3839
+ `&&L!=="\r"?v+=L:(v==="end_header"&&(S=!1),v!==""&&(y.push(v),v=""))}while(S&&p<m.length);return P===!0&&p++,{headerText:y.join("\r")+"\r",headerLength:p}}let g;const _=this;if(e instanceof ArrayBuffer){const m=new Uint8Array(e),{headerText:p,headerLength:S}=f(m),v=t(p,S);if(v.format==="ascii"){const y=new TextDecoder().decode(m);g=o(y,v)}else g=d(e,v)}else g=o(e,t(e));return g}}class Ax{constructor(e){this.arr=e,this.i=0}empty(){return this.i>=this.arr.length}next(){return this.arr[this.i++]}}class wx extends wn{constructor(e){super(e)}load(e,t,n,i){const r=this,a=new Xi(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(r.parse(o))}catch(l){i?i(l):console.error(l),r.manager.itemError(e)}},n,i)}parse(e){function t(c){const u=new DataView(c),h=32/8*3+32/8*3*3+16/8,d=u.getUint32(80,!0);if(80+32/8+d*h===u.byteLength)return!0;const g=[115,111,108,105,100];for(let _=0;_<5;_++)if(n(g,u,_))return!1;return!0}function n(c,u,h){for(let d=0,f=c.length;d<f;d++)if(c[d]!==u.getUint8(h+d))return!1;return!0}function i(c){const u=new DataView(c),h=u.getUint32(80,!0);let d,f,g,_=!1,m,p,S,v,y;for(let D=0;D<70;D++)u.getUint32(D,!1)==1129270351&&u.getUint8(D+4)==82&&u.getUint8(D+5)==61&&(_=!0,m=new Float32Array(h*3*3),p=u.getUint8(D+6)/255,S=u.getUint8(D+7)/255,v=u.getUint8(D+8)/255,y=u.getUint8(D+9)/255);const N=84,P=12*4+2,L=new Kt,U=new Float32Array(h*3*3),E=new Float32Array(h*3*3),T=new Ge;for(let D=0;D<h;D++){const X=N+D*P,q=u.getFloat32(X,!0),se=u.getFloat32(X+4,!0),he=u.getFloat32(X+8,!0);if(_){const k=u.getUint16(X+48,!0);(k&32768)===0?(d=(k&31)/31,f=(k>>5&31)/31,g=(k>>10&31)/31):(d=p,f=S,g=v)}for(let k=1;k<=3;k++){const oe=X+k*12,G=D*3*3+(k-1)*3;U[G]=u.getFloat32(oe,!0),U[G+1]=u.getFloat32(oe+4,!0),U[G+2]=u.getFloat32(oe+8,!0),E[G]=q,E[G+1]=se,E[G+2]=he,_&&(T.setRGB(d,f,g,_t),m[G]=T.r,m[G+1]=T.g,m[G+2]=T.b)}}return L.setAttribute("position",new hn(U,3)),L.setAttribute("normal",new hn(E,3)),_&&(L.setAttribute("color",new hn(m,3)),L.hasColors=!0,L.alpha=y),L}function r(c){const u=new Kt,h=/solid([\s\S]*?)endsolid/g,d=/facet([\s\S]*?)endfacet/g,f=/solid\s(.+)/;let g=0;const _=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,m=new RegExp("vertex"+_+_+_,"g"),p=new RegExp("normal"+_+_+_,"g"),S=[],v=[],y=[],N=new O;let P,L=0,U=0,E=0;for(;(P=h.exec(c))!==null;){U=E;const T=P[0],D=(P=f.exec(T))!==null?P[1]:"";for(y.push(D);(P=d.exec(T))!==null;){let se=0,he=0;const k=P[0];for(;(P=p.exec(k))!==null;)N.x=parseFloat(P[1]),N.y=parseFloat(P[2]),N.z=parseFloat(P[3]),he++;for(;(P=m.exec(k))!==null;)S.push(parseFloat(P[1]),parseFloat(P[2]),parseFloat(P[3])),v.push(N.x,N.y,N.z),se++,E++;he!==1&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+g),se!==3&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+g),g++}const X=U,q=E-U;u.userData.groupNames=y,u.addGroup(X,q,L),L++}return u.setAttribute("position",new vt(S,3)),u.setAttribute("normal",new vt(v,3)),u}function a(c){return typeof c!="string"?new TextDecoder().decode(c):c}function o(c){if(typeof c=="string"){const u=new Uint8Array(c.length);for(let h=0;h<c.length;h++)u[h]=c.charCodeAt(h)&255;return u.buffer||u}else return c}const l=o(e);return t(l)?i(l):r(a(e))}}const Ou={type:"change"},Jl={type:"start"},kh={type:"end"},pa=new Cr,ku=new Bi,Rx=Math.cos(70*Xt.DEG2RAD),tn=new O,Ln=2*Math.PI,Ft={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Io=1e-6;class Cx extends _m{constructor(e,t=null){super(e,t),this.state=Ft.NONE,this.target=new O,this.cursor=new O,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Fs.ROTATE,MIDDLE:Fs.DOLLY,RIGHT:Fs.PAN},this.touches={ONE:Ds.ROTATE,TWO:Ds.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new O,this._lastQuaternion=new nn,this._lastTargetPosition=new O,this._quat=new nn().setFromUnitVectors(e.up,new O(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Qc,this._sphericalDelta=new Qc,this._scale=1,this._panOffset=new O,this._rotateStart=new ct,this._rotateEnd=new ct,this._rotateDelta=new ct,this._panStart=new ct,this._panEnd=new ct,this._panDelta=new ct,this._dollyStart=new ct,this._dollyEnd=new ct,this._dollyDelta=new ct,this._dollyDirection=new O,this._mouse=new ct,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Lx.bind(this),this._onPointerDown=Px.bind(this),this._onPointerUp=Dx.bind(this),this._onContextMenu=Bx.bind(this),this._onMouseWheel=Ux.bind(this),this._onKeyDown=Fx.bind(this),this._onTouchStart=Ox.bind(this),this._onTouchMove=kx.bind(this),this._onMouseDown=Ix.bind(this),this._onMouseMove=Nx.bind(this),this._interceptControlDown=zx.bind(this),this._interceptControlUp=Vx.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(Ou),this.update(),this.state=Ft.NONE}update(e=null){const t=this.object.position;tn.copy(t).sub(this.target),tn.applyQuaternion(this._quat),this._spherical.setFromVector3(tn),this.autoRotate&&this.state===Ft.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,i=this.maxAzimuthAngle;isFinite(n)&&isFinite(i)&&(n<-Math.PI?n+=Ln:n>Math.PI&&(n-=Ln),i<-Math.PI?i+=Ln:i>Math.PI&&(i-=Ln),n<=i?this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(tn.setFromSpherical(this._spherical),tn.applyQuaternion(this._quatInverse),t.copy(this.target).add(tn),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=tn.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const o=new O(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new O(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=tn.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(pa.origin.copy(this.object.position),pa.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(pa.direction))<Rx?this.object.lookAt(this.target):(ku.setFromNormalAndCoplanarPoint(this.object.up,this.target),pa.intersectPlane(ku,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>Io||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Io||this._lastTargetPosition.distanceToSquared(this.target)>Io?(this.dispatchEvent(Ou),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Ln/60*this.autoRotateSpeed*e:Ln/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){tn.setFromMatrixColumn(t,0),tn.multiplyScalar(-e),this._panOffset.add(tn)}_panUp(e,t){this.screenSpacePanning===!0?tn.setFromMatrixColumn(t,1):(tn.setFromMatrixColumn(t,0),tn.crossVectors(this.object.up,tn)),tn.multiplyScalar(e),this._panOffset.add(tn)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;tn.copy(i).sub(this.target);let r=tn.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/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(),i=e-n.left,r=t-n.top,a=n.width,o=n.height;this._mouse.x=i/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(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(Ln*this._rotateDelta.x/t.clientHeight),this._rotateUp(Ln*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(Ln*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(-Ln*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(Ln*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(-Ln*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),i=.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_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),i=.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_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),i=.5*(e.pageX+n.x),r=.5*(e.pageY+n.y);this._rotateEnd.set(i,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Ln*this._rotateDelta.x/t.clientHeight),this._rotateUp(Ln*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),i=.5*(e.pageY+t.y);this._panEnd.set(n,i)}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,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new ct,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 Px(s){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(s.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(s)&&(this._addPointer(s),s.pointerType==="touch"?this._onTouchStart(s):this._onMouseDown(s)))}function Lx(s){this.enabled!==!1&&(s.pointerType==="touch"?this._onTouchMove(s):this._onMouseMove(s))}function Dx(s){switch(this._removePointer(s),this._pointers.length){case 0:this.domElement.releasePointerCapture(s.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(kh),this.state=Ft.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 Ix(s){let e;switch(s.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 Fs.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(s),this.state=Ft.DOLLY;break;case Fs.ROTATE:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=Ft.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=Ft.ROTATE}break;case Fs.PAN:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=Ft.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=Ft.PAN}break;default:this.state=Ft.NONE}this.state!==Ft.NONE&&this.dispatchEvent(Jl)}function Nx(s){switch(this.state){case Ft.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(s);break;case Ft.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(s);break;case Ft.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(s);break}}function Ux(s){this.enabled===!1||this.enableZoom===!1||this.state!==Ft.NONE||(s.preventDefault(),this.dispatchEvent(Jl),this._handleMouseWheel(this._customWheelEvent(s)),this.dispatchEvent(kh))}function Fx(s){this.enabled!==!1&&this._handleKeyDown(s)}function Ox(s){switch(this._trackPointer(s),this._pointers.length){case 1:switch(this.touches.ONE){case Ds.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(s),this.state=Ft.TOUCH_ROTATE;break;case Ds.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(s),this.state=Ft.TOUCH_PAN;break;default:this.state=Ft.NONE}break;case 2:switch(this.touches.TWO){case Ds.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(s),this.state=Ft.TOUCH_DOLLY_PAN;break;case Ds.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(s),this.state=Ft.TOUCH_DOLLY_ROTATE;break;default:this.state=Ft.NONE}break;default:this.state=Ft.NONE}this.state!==Ft.NONE&&this.dispatchEvent(Jl)}function kx(s){switch(this._trackPointer(s),this.state){case Ft.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(s),this.update();break;case Ft.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(s),this.update();break;case Ft.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(s),this.update();break;case Ft.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(s),this.update();break;default:this.state=Ft.NONE}}function Bx(s){this.enabled!==!1&&s.preventDefault()}function zx(s){s.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Vx(s){s.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const Hx=At.defineStore("threeJSComp",{state:()=>({scene:null,camera:null,renderer:null,controls:null,uploadedModels:[],loadedModels:[],selectedModels:[],showAxes:!0,showModelList:!1,isInitialized:!1,loadingQueue:[],isProcessingQueue:!1,axesHelper:null}),getters:{getAllLoadedModels:s=>s.uploadedModels.filter(e=>e.status==="loaded"),getSelectedModelsData:s=>s.selectedModels.map(e=>s.uploadedModels[e]).filter(Boolean)},actions:{forceRender(){this.renderer&&this.scene&&this.camera},setScene(s){this.scene=s},setCamera(s){this.camera=s},setRenderer(s){this.renderer=s},setControls(s){this.controls=s},setAxesHelper(s){this.axesHelper=s},setIsInitialized(s){this.isInitialized=s},addUploadedModel(s){s.id||(s.id=Date.now()+Math.random()),this.uploadedModels.push(s)},findModelIndexById(s){return this.uploadedModels.findIndex(e=>e.id===s)},getModelById(s){return this.uploadedModels.find(e=>e.id===s)},updateModelStatus(s,e){const t=this.getModelById(s);t&&(t.status=e)},updateModelObject(s,e){const t=this.getModelById(s);t&&(t.model=e,t.status="loaded",this.loadedModels.find(n=>n.id===s)||this.loadedModels.push(t))},removeUploadedModel(s){if(s<0||s>=this.uploadedModels.length)return console.error("无效的模型索引:",s),!1;const e=this.uploadedModels[s];e.model&&this.scene&&(this.scene.remove(e.model),this.disposeModel(e.model)),this.uploadedModels.splice(s,1);const t=this.loadedModels.findIndex(n=>n.id===e.id);return t!==-1&&this.loadedModels.splice(t,1),this.updateSelectedIndicesAfterRemoval(s),!0},removeModelById(s){const e=this.findModelIndexById(s);return e!==-1?this.removeUploadedModel(e):!1},removeSelectedModels(){if(this.selectedModels.length===0)return;[...this.selectedModels].sort((e,t)=>t-e).forEach(e=>{this.removeUploadedModel(e)}),this.selectedModels=[],this.forceRender()},updateSelectedIndicesAfterRemoval(s){this.selectedModels=this.selectedModels.filter(e=>e!==s).map(e=>e>s?e-1:e)},toggleModelVisibility(s){const e=this.uploadedModels[s];e&&e.model&&(e.visible=!e.visible,e.model.visible=e.visible,this.forceRender())},clearAllModels(){if(!this.scene){console.error("场景未初始化,无法清空模型");return}this.uploadedModels.forEach(s=>{s.model&&s.status==="loaded"&&(this.scene.remove(s.model),this.disposeModel(s.model))}),this.uploadedModels=[],this.loadedModels=[],this.selectedModels=[],this.forceRender()},disposeModel(s){if(s){if(s.children)for(let e=s.children.length-1;e>=0;e--)this.disposeModel(s.children[e]);if(s.geometry&&s.geometry.dispose(),s.material){const e=s.material;Array.isArray(e)?e.forEach(t=>{this.disposeMaterial(t)}):this.disposeMaterial(e)}}},disposeMaterial(s){s&&(Object.keys(s).forEach(e=>{const t=s[e];t&&typeof t=="object"&&t.isTexture&&t.dispose()}),s.dispose())},setSelectedModels(s){this.selectedModels=s.filter(e=>e>=0&&e<this.uploadedModels.length)},selectAllModels(){this.selectedModels=this.uploadedModels.map((s,e)=>e)},deselectAllModels(){this.selectedModels=[]},setShowAxes(s){this.showAxes=s},setShowModelList(s){this.showModelList=s},setLoadingQueue(s){this.loadingQueue=s},addToLoadingQueue(s){this.loadingQueue.push(s)},setIsProcessingQueue(s){this.isProcessingQueue=s},async addModelFromUrl(s){try{const e=await Hu.downloadAvatarApi({url:s});if(e.status!=200)throw new Error(`下载失败: ${e.status}`);return await e.data}catch(e){throw console.error("addModelFromUrl失败:",e),e}},resetCamera(){this.camera&&this.controls&&(this.camera.position.set(10,10,10),this.camera.lookAt(0,0,0),this.controls.reset())},toggleAxes(){this.showAxes=!this.showAxes,this.scene&&this.axesHelper&&(this.axesHelper.visible=this.showAxes)}}}),Gx={class:"content-show"},Wx={key:0,class:"upload-overlay"},Xx={key:1,class:"floating-model-panel"},jx={class:"panel-actions"},qx=["disabled"],Kx={class:"model-list"},Yx={key:0,class:"empty-state"},Zx={class:"model-checkbox"},$x=["value"],Jx={class:"model-info"},Qx=["title"],eM={class:"model-meta"},tM={class:"model-type"},nM={class:"model-size"},iM={class:"model-actions"},sM=["onClick","title"],rM={width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor"},aM={key:0,d:"M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"},oM={key:1,d:"M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7zM2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3 2 4.27zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2zm4.31-.78l3.15 3.15.02-.16c0-1.66-1.34-3-3-3l-.17.01z"},lM=["onClick","disabled"],cM={key:2,class:"error-message"},uM={__name:"threeModel",props:{isShow:Boolean},setup(s,{expose:e}){const t=s,n=V.ref(null);V.ref(null),V.ref(""),V.ref(!1);const i=V.ref(""),r=V.ref(!1),a=Vu.useModelComp(ur.pinia),{nodeDev:o}=At.storeToRefs(a),l=Hx(),{uploadedModels:c,selectedModels:u,showAxes:h,showModelList:d,isInitialized:f}=At.storeToRefs(l);V.computed(()=>l.getAllLoadedModels);let g,_,m,p,S=null;const v={".obj":"OBJ",".fbx":"FBX",".gltf":"GLTF",".glb":"GLB",".dae":"Collada",".3ds":"3DS",".ply":"PLY",".stl":"STL",".step":"STEP",".stp":"STEP",".iges":"IGES",".igs":"IGES"},y=$=>{const Z="."+$.split(".").pop().toLowerCase();return v[Z]||"未知"},N=$=>({pending:"待加载",loading:"加载中",loaded:"已加载",error:"失败"})[$]||"未知",P=$=>{if($===0)return"0 B";const Z=1024,ie=["B","KB","MB","GB"],I=Math.floor(Math.log($)/Math.log(Z));return parseFloat(($/Math.pow(Z,I)).toFixed(2))+" "+ie[I]},L=()=>{if(!(f.value||!n.value))try{g=new dh,g.background=new Ge(15790320),l.setScene(g),_=new un(45,n.value.clientWidth/n.value.clientHeight,.1,1e5),_.position.set(10,10,10),_.lookAt(0,0,0),l.setCamera(_),m=new ev({antialias:!0}),m.setSize(n.value.clientWidth,n.value.clientHeight),m.setPixelRatio(window.devicePixelRatio),m.shadowMap.enabled=!0,m.shadowMap.type=ju,n.value.appendChild(m.domElement),l.setRenderer(m),p=new Cx(_,m.domElement),p.enableDamping=!0,p.dampingFactor=.05,p.enableZoom=!0,p.enablePan=!0,l.setControls(p),U(),E(),T(),D(),l.setIsInitialized(!0)}catch($){console.error("Three.js场景初始化失败:",$)}},U=()=>{const $=new Kl(16777215,.6);g.add($);const Z=new Ar(16777215,.8);Z.position.set(10,10,5),Z.castShadow=!0,Z.shadow.mapSize.width=2048,Z.shadow.mapSize.height=2048,g.add(Z);const ie=new Ar(16777215,.3);ie.position.set(-10,5,-5),g.add(ie)},E=()=>{S=new gm(5),g.add(S),l.setAxesHelper(S)},T=()=>{const $=new mm(1e3,1e3,8947848,13421772);g.add($)},D=()=>{const $=()=>{requestAnimationFrame($),p&&p.update(),m&&g&&_&&m.render(g,_)};$()},X=async $=>{if($.status==="pending"){l.updateModelStatus($.id,"loading");try{const Z=URL.createObjectURL($.file),ie=await q($.file,Z);if(ie)ie.userData.modelId=$.id,ie.userData.fileName=$.file.name,g.add(ie),l.updateModelObject($.id,ie);else throw new Error("模型加载返回空对象");URL.revokeObjectURL(Z)}catch(Z){console.error(`模型 ${$.file.name} 加载失败:`,Z),l.updateModelStatus($.id,"error")}}},q=($,Z)=>new Promise((ie,I)=>{const Te="."+$.name.split(".").pop().toLowerCase();switch(Te){case".obj":se(Z,ie,I);break;case".fbx":he(Z,ie,I);break;case".gltf":case".glb":k(Z,ie,I);break;case".dae":oe(Z,ie,I);break;case".ply":G(Z,ie,I);break;case".stl":fe(Z,ie,I);break;default:I(new Error(`不支持的文件格式: ${Te}`))}}),se=($,Z,ie)=>{new av().load($,Z,void 0,ie)},he=($,Z,ie)=>{new Lv().load($,Z,void 0,ie)},k=($,Z,ie)=>{new Gv().load($,Te=>{Z(Te.scene)},void 0,ie)},oe=($,Z,ie)=>{new bx().load($,Te=>{Z(Te.scene)},void 0,ie)},G=($,Z,ie)=>{new Ex().load($,Te=>{const de=new Er({color:8947848}),qe=new rn(Te,de);Z(qe)},void 0,ie)},fe=($,Z,ie)=>{new wx().load($,Te=>{const de=new Er({color:8947848}),qe=new rn(Te,de);Z(qe)},void 0,ie)},ve=()=>{l.setShowModelList(!d.value)},le=$=>{l.toggleModelVisibility($)},we=()=>{l.selectAllModels()},Me=()=>{l.deselectAllModels()},W=()=>{l.removeSelectedModels()},ee=$=>{l.removeUploadedModel($)?At.ElMessage.success("模型删除成功"):At.ElMessage.error("模型删除失败")},ae=()=>{l.clearAllModels(),l.resetCamera()},re=()=>{_&&m&&n.value&&(_.aspect=n.value.clientWidth/n.value.clientHeight,_.updateProjectionMatrix(),m.setSize(n.value.clientWidth,n.value.clientHeight))};V.onMounted(async()=>{window.addEventListener("resize",re),L()}),V.watch(()=>t==null?void 0:t.isShow,$=>{$&&!f.value&&setTimeout(()=>{L()},100)},{immediate:!0});const Se=async($,Z={})=>{if(!$||!($ instanceof File||$ instanceof Blob))throw new Error("参数必须是File或Blob对象");const ie=$.name||Z.fileName||"unknown.obj",I="."+ie.split(".").pop().toLowerCase();if(!v[I])throw new Error(`不支持的文件格式: ${I}`);f.value||(L(),await new Promise(de=>setTimeout(de,100)));const Te={file:$,name:ie,size:$.size,type:y(ie),status:"pending",model:null,visible:!0,id:Date.now()+Math.random()};l.addUploadedModel(Te);try{return await X(Te),{success:!0,modelId:Te.id,fileName:ie}}catch(de){throw console.error(`外部模型 ${ie} 加载失败:`,de),l.removeModelById(Te.id),de}},ot=async $=>{try{const Z=await Hu.downloadAvatarApi({url:$});if(Z.status!=200)throw new Error(`下载失败: ${Z.status}`);return await Z.data}catch(Z){throw console.error("addModelFromUrl失败:",Z),Z}};return e({addModelFromStream:Se,addModelFromUrl:async $=>{try{const Z=await ot($),ie=$.split("/").pop()||"model.obj",I=new File([Z],ie,{type:Z.type});return await Se(I,{autoFit:!0}),Z}catch(Z){throw console.error("从URL加载模型失败:",Z),Z}},clearAllModels:ae}),V.onBeforeUnmount(()=>{window.removeEventListener("resize",re),m&&(m.dispose(),m=null),p&&(p.dispose(),p=null),ae(),l.setIsInitialized(!1),l.setScene(null),l.setCamera(null),l.setRenderer(null),l.setControls(null),l.setAxesHelper(null)}),($,Z)=>(V.openBlock(),V.createElementBlock("div",Gx,[r.value?(V.openBlock(),V.createElementBlock("div",Wx,Z[2]||(Z[2]=[V.createElementVNode("div",{class:"upload-spinner"},[V.createElementVNode("div",{class:"spinner"}),V.createElementVNode("p",{class:"upload-text"},"正在上传模型...")],-1)]))):V.createCommentVNode("",!0),V.unref(d)?(V.openBlock(),V.createElementBlock("div",Xx,[V.createElementVNode("div",{class:"panel-header"},[Z[4]||(Z[4]=V.createElementVNode("span",{class:"panel-title"},"模型列表",-1)),V.createElementVNode("button",{onClick:ve,class:"close-btn"},Z[3]||(Z[3]=[V.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor"},[V.createElementVNode("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})],-1)]))]),V.createElementVNode("div",jx,[V.createElementVNode("button",{onClick:we,class:"action-btn"},"全选"),V.createElementVNode("button",{onClick:Me,class:"action-btn"},"取消"),V.createElementVNode("button",{onClick:W,class:"action-btn danger",disabled:V.unref(u).length===0}," 删除 ("+V.toDisplayString(V.unref(u).length)+") ",9,qx)]),V.createElementVNode("div",Kx,[V.unref(c).length===0?(V.openBlock(),V.createElementBlock("div",Yx,Z[5]||(Z[5]=[V.createElementVNode("p",null,"暂无模型",-1)]))):V.createCommentVNode("",!0),(V.openBlock(!0),V.createElementBlock(V.Fragment,null,V.renderList(V.unref(c),(ie,I)=>(V.openBlock(),V.createElementBlock("div",{key:ie.id,class:V.normalizeClass(["model-item",{selected:V.unref(u).includes(I)}])},[V.createElementVNode("div",Zx,[V.withDirectives(V.createElementVNode("input",{type:"checkbox","onUpdate:modelValue":Z[0]||(Z[0]=Te=>V.isRef(u)?u.value=Te:null),value:I},null,8,$x),[[V.vModelCheckbox,V.unref(u)]])]),V.createElementVNode("div",Jx,[V.createElementVNode("div",{class:"model-name",title:ie.file.name},V.toDisplayString(ie.file.name),9,Qx),V.createElementVNode("div",eM,[V.createElementVNode("span",tM,V.toDisplayString(y(ie.file.name)),1),V.createElementVNode("span",nM,V.toDisplayString(P(ie.file.size)),1),V.createElementVNode("span",{class:V.normalizeClass(["model-status",ie.status])},V.toDisplayString(N(ie.status)),3)])]),V.createElementVNode("div",iM,[ie.status==="loaded"?(V.openBlock(),V.createElementBlock("button",{key:0,onClick:Te=>le(I),class:"action-icon",title:ie.visible?"隐藏模型":"显示模型"},[(V.openBlock(),V.createElementBlock("svg",rM,[ie.visible?(V.openBlock(),V.createElementBlock("path",aM)):(V.openBlock(),V.createElementBlock("path",oM))]))],8,sM)):V.createCommentVNode("",!0),V.createElementVNode("button",{onClick:Te=>ee(I),class:"action-icon danger",disabled:ie.status==="loading",title:"删除模型"},Z[6]||(Z[6]=[V.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor"},[V.createElementVNode("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"})],-1)]),8,lM)])],2))),128))])])):V.createCommentVNode("",!0),V.createElementVNode("div",{ref_key:"container",ref:n,class:"three-container"},null,512),i.value?(V.openBlock(),V.createElementBlock("div",cM,[V.createElementVNode("span",null,V.toDisplayString(i.value),1),V.createElementVNode("button",{onClick:Z[1]||(Z[1]=ie=>i.value=""),class:"btn-close"},"×")])):V.createCommentVNode("",!0)]))}},Bh=Rl._export_sfc(uM,[["__scopeId","data-v-4aaec5a9"]]),zh=At.defineStore("formToTableComp",{state:()=>({selectArray:[],selectString:""}),actions:{setSelectArray(s){this.selectArray=s},setSelectString(s){this.selectString=s}}}),Vh=At.defineStore("unit",{state:()=>({selectIndex:"",selectMenu:"",selectTitle:[]}),actions:{setSelectIndex(s){this.selectIndex=s},setSelectMenu(s){this.selectMenu=s},setSelectTitle(s){this.selectTitle=s}}}),Hh=(s,e)=>{let t=s,n=e;return Array.isArray(t)&&(t=t==null?void 0:t.map((i,r)=>{if(Array.isArray(i)){let a={};return i=i==null?void 0:i.forEach((o,l)=>{var c;(c=n==null?void 0:n[l])!=null&&c.prop?a[n[l].prop]=o:Array.isArray(o)&&(a.children=Hh(o,n))}),Object.assign(a,{id:r})}else return i})),t},Gh=(s,e,t)=>{let n=s,i=e;return n=n==null?void 0:n.map((r,a)=>{var o,l;return!Array.isArray(r)||!((o=i==null?void 0:i[a])!=null&&o.label)&&!t||(r.unshift(((l=i==null?void 0:i[a])==null?void 0:l.label)??""),r.some(c=>Array.isArray(c))&&(r=r==null?void 0:r.map(c=>{var u;return Array.isArray(c)&&(c=Gh(c,(u=i==null?void 0:i[a])==null?void 0:u.children,t)),c}))),r}),n},hM=(s,e,t)=>{if(e==="")return s==null?void 0:s.filter(n=>(n==null?void 0:n.id)!==t);{const n=e.split("-");return dM(s,n,t)}},dM=(s,e,t)=>{let n=s,i=e;return(i==null?void 0:i.length)===0?n=n==null?void 0:n.filter(r=>r.id!==t):n=n==null?void 0:n.map(r=>(r.id.toString()===(i==null?void 0:i[0])&&(i==null||i.shift(),r=Wh(r,i,t)),r)),n},Wh=(s,e,t)=>{var r,a;let n=s,i=e;return(i==null?void 0:i.length)===0?n.children=(r=n.children)==null?void 0:r.filter(o=>o.id!==t):n.children=(a=n.children)==null?void 0:a.map(o=>(o.id.toString()===(i==null?void 0:i[0])&&(i==null||i.shift(),o=Wh(o,i,t)),o)),n},fM=(s,e,t)=>{if(e==="")return t;{const n=e.split("-");return pM(s,n,t)}},pM=(s,e,t)=>{let n=s,i=e;return(i==null?void 0:i.length)===0?n=t:n=n==null?void 0:n.map(r=>(r.id.toString()===(i==null?void 0:i[0])&&(i==null||i.shift(),r=Xh(r,i,t)),r)),n},Xh=(s,e,t)=>{var r;let n=s,i=e;return(i==null?void 0:i.length)===0?n.children=t:n.children=(r=n.children)==null?void 0:r.map(a=>(a.id.toString()===(i==null?void 0:i[0])&&(i==null||i.shift(),a=Xh(a,i,t)),a)),n},jh=(s,e)=>s==null?void 0:s.map(n=>{var i,r,a,o,l,c;if(Array.isArray(n)?n=n:n=[n],(i=n==null?void 0:n.filter(u=>!(u!=null&&u.id)))!=null&&i.every(u=>typeof u!="object"||u===null))return n;if((r=n==null?void 0:n.filter(u=>!(u!=null&&u.id)))!=null&&r.some(u=>Array.isArray(u)))return n;{let u=[];if(u.push(n==null?void 0:n.find(h=>h==null?void 0:h.id)),Array.isArray(e==null?void 0:e[0])){const h=(a=n==null?void 0:n.filter(d=>!(d!=null&&d.id)))==null?void 0:a[0];(o=zn.getColumnChild(Ke.cloneDeep(e==null?void 0:e[0])))==null||o.forEach(d=>{u.push(h==null?void 0:h[(d==null?void 0:d.prop)??(d==null?void 0:d.label)??d])})}else{const h=(l=n==null?void 0:n.filter(d=>!(d!=null&&d.id)))==null?void 0:l[0];(c=zn.getColumnChild(Ke.cloneDeep(e)))==null||c.forEach(d=>{u.push(h==null?void 0:h[(d==null?void 0:d.prop)??(d==null?void 0:d.label)??d])})}return u}}),mM=s=>{try{return JSON.parse(s),!0}catch{return!1}},Bu=(s,e)=>Ed(s,e),Ks=s=>{let e=[];function t(i){Array.isArray(i)&&(i==null||i.forEach(r=>{Array.isArray(r)||(r=[r]),r==null||r.forEach(a=>{!(a!=null&&a.children)||a.children.length===0?e.push(a.label):n(a.children)})}))}function n(i){i==null||i.forEach(r=>{!(r!=null&&r.children)||r.children.length===0?e.push(r.label):n(r.children)})}return t(s),e},gM=(s,e,t)=>{var i;let n=(i=Ke.cloneDeep(s))==null?void 0:i.map(r=>(r=r.filter(a=>!(a!=null&&a.id)),r));return n=n==null?void 0:n.map(r=>{var a;return r=(a=r.map((o,l)=>{let c={};if(t!=null&&t.find(u=>u===e[l]))return c[e[l]]=o,c}))==null?void 0:a.filter(o=>o),r}),n},_M=(s,e)=>{var a,o;const t=Ke.cloneDeep(s),n=(a=t==null?void 0:t.find(l=>(l==null?void 0:l.key)==="header"))==null?void 0:a.contents,i=(o=t==null?void 0:t.find(l=>(l==null?void 0:l.key)==="tableContents"))==null?void 0:o.contents;return gM(i,Ks(n).slice(0,Ks(n).length-1),e)},Mi=s=>{var i,r,a,o;const e=s;let t=[];e.compData=(i=e.compData)==null?void 0:i.filter(l=>(l==null?void 0:l.key)!=="tableContents"&&(l==null?void 0:l.key)!=="tableIndex");const n=(a=(r=Ke.cloneDeep(e.compData))==null?void 0:r.find(l=>(l==null?void 0:l.key)==="tableIndexColumn"))==null?void 0:a.contents;return(o=Ke.cloneDeep(e.compData))==null||o.forEach(l=>{if((l==null?void 0:l.key)!=="tableIndexColumn"&&(l==null?void 0:l.key)!=="header")t.push(l);else if((l==null?void 0:l.key)==="header"){let c=l.contents;n&&(c!=null&&c.every(u=>Array.isArray(u))?c==null||c[0].unshift({label:n}):c.unshift({label:n})),t.push({key:"header",contents:c})}}),e.compData=t,e},Al=s=>{var r,a,o,l,c;const e=(r=s.compData)==null?void 0:r.filter(u=>(u==null?void 0:u.key)==="tableContents"||(u==null?void 0:u.key)==="tableIndex"),t=(o=(a=e==null?void 0:e.find(u=>(u==null?void 0:u.key)==="tableIndex"))==null?void 0:a.contents)==null?void 0:o.map(u=>u.label),n=(l=e==null?void 0:e.find(u=>(u==null?void 0:u.key)==="tableContents"))==null?void 0:l.contents;let i=[];return(t==null?void 0:t.length)>0&&(n!=null&&n.every(u=>Array.isArray(u)))?i=t==null?void 0:t.map((u,h)=>n[h]?[u,...n[h]]:[u]):Array.isArray(n==null?void 0:n[0])&&((c=n==null?void 0:n[0])!=null&&c.every(u=>Array.isArray(u)))?i=n==null?void 0:n[0]:Array.isArray(n==null?void 0:n[0])?i=n:i.push(n),i},yM=s=>{const e=[];function t(n){!n||n.length===0||(e.push(n==null?void 0:n.map(i=>({label:i.label}))),n==null||n.forEach(i=>{i!=null&&i.children&&(i==null?void 0:i.children.length)>0&&t(i==null?void 0:i.children)}))}return t(s),e},vM=s=>{const e=[];function t(n,i=[]){!n||n.length===0||(e.push({key:i==null?void 0:i.filter(r=>!Array.isArray(r)),value:n}),n==null||n.forEach(r=>{r!=null&&r.some(a=>Array.isArray(a))&&t(r.find(a=>Array.isArray(a)),r)}))}return t(s),e},xM=s=>{const e=[];function t(n){!n||n.length===0||(e.push(n==null?void 0:n.map(i=>i==null?void 0:i.filter(r=>!Array.isArray(r)))),n==null||n.forEach(i=>{i!=null&&i.some(r=>Array.isArray(r))&&t(i.find(r=>Array.isArray(r)))}))}return t(s),e},MM=s=>{const e=[];function t(n){var i;!n||n.length===0||(n!=null&&n.every(r=>!Array.isArray(r))?e.push(n):(e.push((i=n==null?void 0:n.map(r=>r==null?void 0:r.filter(a=>!Array.isArray(a))))==null?void 0:i[0]),n==null||n.forEach(r=>{r!=null&&r.some(a=>Array.isArray(a))&&t(r.find(a=>Array.isArray(a)))})))}return t(s),e},SM=(s,e)=>{let t;function n(i,r,a=1){var l;if(!i||i.length===0)return;const o=(l=Ke.cloneDeep(r))==null?void 0:l.map(c=>c==null?void 0:c.filter(u=>!Array.isArray(u)));return o!=null&&o.find(c=>Bu(c,i==null?void 0:i.key))?(r==null||r.forEach(c=>{!n(i,c.find(h=>Array.isArray(h)))&&Bu(c.filter(h=>!Array.isArray(h)),i==null?void 0:i.key)&&(t={type:a,contents:c.filter(h=>!Array.isArray(h))})}),!0):!1}return n(s,e,0),t},zu=(s,e)=>{function t(n,i){return!n||n.length===0||n==null?void 0:n.map((a,o)=>{var c,u;let l=a;return l.unshift((c=i==null?void 0:i[o])==null?void 0:c.label),l.some(h=>Array.isArray(h))&&(l[l.length-1]=t(l.find(h=>Array.isArray(h)),(u=i==null?void 0:i[o])==null?void 0:u.children)),l})}return t(s,e)},wl=s=>{var t,n,i,r,a,o,l,c,u,h,d,f,g,_,m,p,S,v,y,N,P,L,U,E,T;const e=s;if((s==null?void 0:s.comp)==="Table"){if((i=(n=(t=s.compData)==null?void 0:t.find(D=>(D==null?void 0:D.key)==="tableIndex"))==null?void 0:n.contents)!=null&&i.every(D=>!(D!=null&&D.children))||!((r=s.compData)!=null&&r.find(D=>(D==null?void 0:D.key)==="tableIndex")))return((l=(o=(a=e.compData)==null?void 0:a.find(D=>(D==null?void 0:D.key)==="tableContents"))==null?void 0:o.contents)==null?void 0:l.length)===1&&((d=(h=(u=(c=e.compData)==null?void 0:c.find(D=>(D==null?void 0:D.key)==="tableContents"))==null?void 0:u.contents)==null?void 0:h[0])!=null&&d.every(D=>Array.isArray(D)))?(e.compData=(f=e.compData)==null?void 0:f.map(D=>{var X;return(D==null?void 0:D.key)==="tableContents"&&(D.contents=(X=D.contents)==null?void 0:X[0]),D}),[e]):[e];{let D=[];const X=e.compData,q=(g=Ke.cloneDeep(X))==null?void 0:g.find(le=>(le==null?void 0:le.key)==="tableIndexColumn"),se=(_=Ke.cloneDeep(X))==null?void 0:_.find(le=>(le==null?void 0:le.key)==="extraButton"),he=(m=Ke.cloneDeep(X))==null?void 0:m.find(le=>(le==null?void 0:le.key)==="rowButton"),k=MM((S=(p=Ke.cloneDeep(X))==null?void 0:p.find(le=>(le==null?void 0:le.key)==="header"))==null?void 0:S.contents),oe=(v=Ke.cloneDeep(X))==null?void 0:v.find(le=>(le==null?void 0:le.key)==="tableIndex"),G=xM((N=(y=Ke.cloneDeep(X))==null?void 0:y.find(le=>(le==null?void 0:le.key)==="tableContents"))==null?void 0:N.contents),fe=zu((L=(P=Ke.cloneDeep(X))==null?void 0:P.find(le=>(le==null?void 0:le.key)==="tableContents"))==null?void 0:L.contents,oe==null?void 0:oe.contents),ve=vM(zu((E=(U=Ke.cloneDeep(X))==null?void 0:U.find(le=>(le==null?void 0:le.key)==="tableContents"))==null?void 0:E.contents,oe==null?void 0:oe.contents));if(oe)return(T=yM(oe.contents))==null||T.forEach((le,we)=>{var W;let Me=[];Me.push({key:"tableIndex",contents:le}),Me.push(q),Me.push(se),Me.push(he),Me.push({key:"tableContents",contents:G[we]}),Me.push({key:"header",contents:k!=null&&k[we]?[k==null?void 0:k[we]]:[k==null?void 0:k[0]]}),D.push({comp:"Table",compData:Me,name:"",parentTableContents:((W=SM(ve[we],fe))==null?void 0:W.contents)??""})}),D}}else return[e]},Da=(s,e)=>{let t={};return Array.isArray(s)?s==null||s.forEach((n,i)=>{t[e[i]]=n}):[s].forEach((n,i)=>{t[e[i]]=n}),t},TM=async s=>{let e=[];s==null||s.forEach(t=>{var n;(n=t.compData)==null||n.forEach(i=>{var r;(r=i.contents)==null||r.forEach(a=>{var o;Array.isArray(a)?a==null||a.forEach(l=>{var c;(c=wl(Ke.cloneDeep(l)))==null||c.forEach(async u=>{var h,d,f,g,_;if(l.comp==="Table"){const m=await At.createInsofDataApi({key:{systemKey:sessionStorage.getItem("systemKey"),pageKey:t.name,type:"structure",version:1,parentTable:(u==null?void 0:u.parentTableContents)??""},value:{pageData:{comp:(h=Mi(Ke.cloneDeep(u)))==null?void 0:h.comp,compData:(d=Mi(Ke.cloneDeep(u)))==null?void 0:d.compData,name:(f=Mi(Ke.cloneDeep(u)))==null?void 0:f.name}}}),p=m.data.result,S=await((g=Al(Ke.cloneDeep(u)))==null?void 0:g.map(async v=>{var L,U,E,T,D;let y;v.length!==0&&(y=await At.createInsofDataApi({key:{systemKey:sessionStorage.getItem("systemKey"),pageKey:t.name,type:"data",tableId:p},value:{tableData:Da(v,(T=Ks((E=(U=(L=Mi(Ke.cloneDeep(u)))==null?void 0:L.compData)==null?void 0:U.find(X=>(X==null?void 0:X.key)==="header"))==null?void 0:E.contents))==null?void 0:T.filter(X=>X!=="操作"))}}));const P=await((D=(await At.getInsofDataApi({key:{systemKey:sessionStorage.getItem("systemKey"),pageKey:t.name,type:"structure",parentTable:v}})).data.result)==null?void 0:D.map(async X=>await At.updateInsofDataApi({id:X.id,key:{systemKey:X.key.systemKey,pageKey:X.key.pageKey,type:X.key.type,version:X.key.version,parentTable:y.data.result}})));return e.push(P),y}));e.push(m),e.push(S)}else if((u==null?void 0:u.key)==="extraButton"){if(((_=Object.values(u==null?void 0:u.value))==null?void 0:_.length)!==0){const m=await At.createInsofDataApi({key:{systemKey:sessionStorage.getItem("systemKey"),pageKey:t.name,type:"structureMethod",version:1},value:{pageData:u.value}});e.push(m)}}else{const m=await At.createInsofDataApi({key:{systemKey:sessionStorage.getItem("systemKey"),pageKey:t.name,type:"structure",version:1,parentTable:(u==null?void 0:u.parentTableContents)??""},value:{pageData:u}});e.push(m)}})}):(o=wl(Ke.cloneDeep(a)))==null||o.forEach(async l=>{var c,u,h,d,f;if(a.comp==="Table"){const g=await At.createInsofDataApi({key:{systemKey:sessionStorage.getItem("systemKey"),pageKey:t.name,type:"structure",version:1,parentTable:(l==null?void 0:l.parentTableContents)??""},value:{pageData:{comp:(c=Mi(Ke.cloneDeep(l)))==null?void 0:c.comp,compData:(u=Mi(Ke.cloneDeep(l)))==null?void 0:u.compData,name:(h=Mi(Ke.cloneDeep(l)))==null?void 0:h.name}}}),_=g.data.result,m=await((d=Al(Ke.cloneDeep(l)))==null?void 0:d.map(async p=>{var N,P,L,U,E;let S;(p==null?void 0:p.length)!==0&&(S=await At.createInsofDataApi({key:{systemKey:sessionStorage.getItem("systemKey"),pageKey:t.name,type:"data",tableId:_},value:{tableData:Da(p,(U=Ks((L=(P=(N=Mi(Ke.cloneDeep(l)))==null?void 0:N.compData)==null?void 0:P.find(T=>(T==null?void 0:T.key)==="header"))==null?void 0:L.contents))==null?void 0:U.filter(T=>T!=="操作"))}}));const y=await((E=(await At.getInsofDataApi({key:{parentTable:p,systemKey:sessionStorage.getItem("systemKey"),pageKey:t.name,type:"structure"}})).data.result)==null?void 0:E.map(async T=>await At.updateInsofDataApi({id:T.id,key:{systemKey:T.key.systemKey,pageKey:T.key.pageKey,type:T.key.type,version:T.key.version,parentTable:T.key.parentTable===""?"":S.data.result}})));return e.push(y),S}));e.push(g),e.push(m)}else if((l==null?void 0:l.key)==="extraButton"){if(((f=Object.values(l==null?void 0:l.value))==null?void 0:f.length)!==0){const g=await At.createInsofDataApi({key:{systemKey:sessionStorage.getItem("systemKey"),pageKey:t.name,type:"structureMethod",version:1},value:{pageData:l.value}});e.push(g)}}else{const g=await At.createInsofDataApi({key:{systemKey:sessionStorage.getItem("systemKey"),pageKey:t.name,type:"structure",version:1,parentTable:(l==null?void 0:l.parentTableContents)??""},value:{pageData:l}});e.push(g)}})})})}),await Promise.all(e)},bM=At.useMenuState(ur.pinia),EM=s=>{var t;const e=Array.isArray(s)?s==null?void 0:s[0]:{};return(t=e==null?void 0:e.contents)==null?void 0:t.map(n=>({...n[0],...n[1]}))},qh=async(s,e,t="",n)=>{var h,d,f,g,_,m;const i=await At.getInsofDataApi({key:{pageKey:s,systemKey:e,parentTable:t}}),r=await At.getInsofDataApi({key:{pageKey:s,systemKey:e,type:"structureMethod"}}),a=(h=i.data.result)==null?void 0:h.map(p=>p.id),o=a==null?void 0:a.map(p=>At.getInsofDataApi({key:{pageKey:s,systemKey:e,tableId:p}})),l=await Promise.all(o),c=[];l==null||l.forEach(p=>{var y,N,P,L;const S=(y=p.data.result)==null?void 0:y.map(U=>{const E=Array.isArray(U.value.tableData)?U.value.tableData:[U.value.tableData];return E.unshift({id:U.id}),E}),v=(L=(P=(N=p.data.result)==null?void 0:N[0])==null?void 0:P.key)==null?void 0:L.tableId;c.push({key:v,contents:S})});const u=[];return(d=i.data.result)==null||d.forEach(p=>{var y,N,P,L;const S=p.value.pageData,v=(y=Ke.cloneDeep(S.compData))==null?void 0:y.filter(U=>(U==null?void 0:U.key)!=="tableContents");if(v&&(v!=null&&v.find(U=>(U==null?void 0:U.key)==="header"))&&v.push({key:"tableContents",contents:n==="/系统管理/用户管理"?EM(c):jh((N=c==null?void 0:c.find(U=>(U==null?void 0:U.key)===p.id))==null?void 0:N.contents,(P=v==null?void 0:v.find(U=>(U==null?void 0:U.key)==="header"))==null?void 0:P.contents)}),S.compData=v,S.id=p.id,((L=p.key)==null?void 0:L.type)!=="method")u.push(S);else{let U;U={name:"",compData:[S],comp:"calculator"},u.push(U)}}),((g=(f=r.data.result)==null?void 0:f.map(p=>p.value.pageData))==null?void 0:g.filter(p=>Object.values(p).length>0).length)>0&&u.push({comp:"methodButton",name:"",compData:(m=(_=r.data.result)==null?void 0:_.map(p=>p.value.pageData))==null?void 0:m.filter(p=>Object.values(p).length>0)}),u},AM=async s=>{await At.deleteInsofDataApi({id:s})},wM=async(s,e,t,n,i,r)=>{var a;await At.createInsofDataApi({key:{type:s,pageKey:e,tableId:t,systemKey:n},value:{tableData:Da(i,(a=Ks(r))==null?void 0:a.filter(o=>o!=="操作"))}})},RM=async(s,e,t,n,i,r,a)=>{var o;await At.updateInsofDataApi({key:{type:s,pageKey:e,tableId:t,systemKey:i},value:{tableData:Da(r,(o=Ks(a))==null?void 0:o.filter(l=>l!=="操作"))},id:n})},CM=async(s,e)=>{await At.updateInsofDataApi({value:{pageData:e},id:s})},PM=async(s,e)=>await At.getInsofDataApi({key:s,valueLikes:e}),LM=async()=>{var s,e,t,n,i,r,a,o,l;try{const c=await At.getInsofDataApi({key:{systemKey:sessionStorage.getItem("systemKey"),layer:"superAdmin"}});((s=c==null?void 0:c.data)==null?void 0:s.code)===200&&(bM.setPlatform(((i=(n=(t=(e=c==null?void 0:c.data)==null?void 0:e.result)==null?void 0:t[0])==null?void 0:n.key)==null?void 0:i.type)==="制造系统"?"client":"browser"),(l=(o=(a=(r=c==null?void 0:c.data)==null?void 0:r.result)==null?void 0:a[0])==null?void 0:o.key)==null||l.type)}catch(c){return Promise.reject(c)}},DM={class:"table-content"},IM=["onClick"],NM={class:"form-content"},UM={key:0,class:"dialog-footer"},FM={__name:"index",props:{itemData:{type:Array,default:()=>[]},childItemData:{type:Array,default:()=>[]},index:Number,changedContent:{type:Object,default:()=>{}}},emits:["change","contentChange","onButtonClick","contentClick","pageChange"],setup(s,{emit:e}){const t=s,n=e,i=V.ref([]),r=At.useMenuState(),{activeMenuPath:a}=At.storeToRefs(r),o=Vu.useModelComp(ur.pinia),{extraContents:l}=At.storeToRefs(o),c=V.ref([]),u=V.ref(!1),h=V.ref("");V.ref();const d=V.ref(!0),f=V.ref(0),g=V.ref(!1),_=V.ref(""),m=V.ref(!1),p=V.ref({label:"查看三维模型"}),S=V.ref([]),v=V.ref([]),y=V.ref(!1),N=V.ref([]),P=V.ref([]),L=V.ref(),U=V.ref(),E=zh(ur.pinia),T=V.ref(),D=Vh(ur.pinia),{selectIndex:X,selectMenu:q,selectTitle:se}=At.storeToRefs(D),{selectString:he}=At.storeToRefs(E),k=V.ref(720),oe=()=>{m.value=!1},G=J=>{n("clickTrigger",J)},fe=(J,$)=>{if(Object.values($).length!==0)return Object.values($).find(Z=>{var ie,I;return((ie=Z==null?void 0:Z.toString())==null?void 0:ie.includes(".obj"))||((I=Z==null?void 0:Z.toString())==null?void 0:I.includes(".stl"))})?[...J,p.value]:J},ve=J=>{var I;he.value===""?J==null||J[0]:(J==null?void 0:J.find(Te=>(Te==null?void 0:Te.selectLabel)==="("+he.value+")"))??(J==null||J.find(Te=>!(Te!=null&&Te.selectLabel)));let $=J;(I=i.value)!=null&&I.find(Te=>Te.prop==="index");let Z=L.value;const ie=[];return $==null||$.forEach((Te,de)=>{var De;let qe={};if(Array.isArray(Te)){let Oe=[];Te==null||Te.filter(Ie=>!(Ie!=null&&Ie.id)).forEach((Ie,tt)=>{var Nt,F,b,K,ce;if((Nt=Z==null?void 0:Z[tt])!=null&&Nt.prop&&!Array.isArray(Ie)){let pe={};pe[Z[tt].column]=Ie,l!=null&&l.value&&((F=l==null?void 0:l.value)==null?void 0:F.length)>0&&((b=l==null?void 0:l.value)!=null&&b.find(ne=>JSON.stringify(ne==null?void 0:ne[0])===JSON.stringify(pe)))&&(Oe=(K=l==null?void 0:l.value)==null?void 0:K.find(ne=>JSON.stringify(ne==null?void 0:ne[0])===JSON.stringify(pe))),Oe&&Oe.length>0?qe[Z[tt].prop]=Oe!=null&&Oe.find(ne=>{var ze;return((ze=Object.keys(ne))==null?void 0:ze[0])===Z[tt].column})?(ce=Oe==null?void 0:Oe.find(ne=>{var ze;return((ze=Object.keys(ne))==null?void 0:ze[0])===Z[tt].column}))==null?void 0:ce[Z[tt].column]:Ie:qe[Z[tt].prop]=Ie}})}else qe=Te;Array.isArray(Te)&&Te.some(Oe=>Oe==null?void 0:Oe.id)?ie.push(Object.assign(qe,{id:(De=Te==null?void 0:Te.find(Oe=>Oe.id))==null?void 0:De.id})):qe.id?ie.push(qe):ie.push(Object.assign(qe,{id:de}))}),ie},le=async J=>{var I,Te,de,qe,De;let $={};for(let Oe in J)J[Oe]!==""&&($["tableData."+Oe]=J[Oe]);const Z=await PM({type:"data",tableId:t==null?void 0:t.index,systemKey:sessionStorage.getItem("systemKey"),pageKey:a.value},$),ie=(de=(Te=(I=Ke.cloneDeep(Z))==null?void 0:I.data)==null?void 0:Te.result)==null?void 0:de.map(Oe=>{var tt;let Ie=[];return Ie.push({id:Oe.id}),Ie.push((tt=Oe==null?void 0:Oe.value)==null?void 0:tt.tableData),Ie});c.value=ve(jh(ie,(De=(qe=Ke.cloneDeep(i.value))==null?void 0:qe.map(Oe=>Oe.label))==null?void 0:De.filter(Oe=>Oe!=="操作")))},we=async J=>{var Z,ie,I,Te,de,qe,De;let $=await qh(a.value,sessionStorage.getItem("systemKey"),J.id);if($=$==null?void 0:$.filter(Oe=>Oe.comp!=="methodButton"),$&&$.length>0){const Oe=!Array.isArray(se.value)&&((Z=se.value)==null?void 0:Z.key)!=="main"?[]:se.value;Oe.push({key:q.value===""?(ie=J==null?void 0:J.id)==null?void 0:ie.toString():q.value+"-"+((I=J==null?void 0:J.id)==null?void 0:I.toString()),value:J[(Te=Object.keys(J))==null?void 0:Te.filter(Ie=>Ie!=="index"&&Ie!=="id")[0]]}),D.setSelectMenu(q.value===""?(de=J==null?void 0:J.id)==null?void 0:de.toString():q.value+"-"+((qe=J==null?void 0:J.id)==null?void 0:qe.toString())),D.setSelectTitle(Oe),D.setSelectIndex((De=J==null?void 0:J.id)==null?void 0:De.toString()),n("pageChange",$)}},Me=J=>{var $;($=Ke.cloneDeep(t.itemData))==null||$.map(Z=>((Z==null?void 0:Z.key)==="tableContents"&&(Z.contents=J),Z))},W=(J,$,Z)=>{n("contentClick",J,$,Z,{id:t==null?void 0:t.index})};V.watch(()=>t.changedContent,()=>{var Z,ie;if(!t.changedContent)return;let J=(Z=c.value)==null?void 0:Z.map(I=>{var Te;return I.id===((Te=t.changedContent)==null?void 0:Te.id)&&(I={...t.changedContent,id:t.changedContent.newId?t.changedContent.newId:t.changedContent.id},delete I.newId),I});const $=(ie=t.itemData)==null?void 0:ie.map(I=>((I==null?void 0:I.key)==="tableContents"&&(I.contents=J),I));c.value=J,n("contentChange",{contents:$,index:t.index}),n("change",{content:J,index:t==null?void 0:t.index,buttonName:"",id:t==null?void 0:t.index})},{deep:!0,immediate:!0});const ee=(J,$)=>{var Z;if(h.value="",y.value=!0,d.value=!0,n("onButtonClick",J,$),console.log(666,J),J==="删除"){c.value=(Z=Ke.cloneDeep(c.value))==null?void 0:Z.filter(I=>(I==null?void 0:I.id)!==($==null?void 0:$.id));const ie=hM(T.value,q.value,$==null?void 0:$.id);Me(ie),n("change",{content:c.value,singleContent:$,index:t==null?void 0:t.index,type:"delete",buttonName:J,column:i.value})}else J==="新增"?(_.value="新增",re(""),m.value=!0):J==="编辑"?(_.value="编辑",re($),m.value=!0):J==="查看"?(_.value="查看",re($),y.value=!1,d.value=!1,m.value=!0):J==="查看三维模型"&&(u.value=!0)},ae=()=>{u.value=!1},re=J=>{var ie,I,Te;const $=[];let Z=[];for(let de in J)Array.isArray(J==null?void 0:J[de])&&Z.push(de);(I=zn.getColumnChild((ie=Ke.cloneDeep(i.value))==null?void 0:ie.filter(de=>(de==null?void 0:de.label)!=="操作")))==null||I.forEach((de,qe)=>{Z.find(De=>De===(de==null?void 0:de.prop))||$.push({label:(de==null?void 0:de.label)??"",name:(de==null?void 0:de.prop)??"t"+qe,type:!(de!=null&&de.formType)||(de==null?void 0:de.formType)===""?"Input":de==null?void 0:de.formType,value:(J==null?void 0:J[de==null?void 0:de.prop])??(de==null?void 0:de.value)??"",id:(de==null?void 0:de.id)??qe,contents:(de==null?void 0:de.options)??[],width:1,isFormColHidden:de==null?void 0:de.isFormColHidden})}),J===""||!J||(h.value=J==null?void 0:J.id),P.value=S.value&&((Te=S.value)==null?void 0:Te.length)>0?S.value:$};V.onMounted(()=>{});const Se=()=>{let J,$=Ke.cloneDeep(c.value);h.value===""?(f.value++,$.push(Object.assign(U.value,{id:f.value})),J=Object.assign(U.value,{id:f.value})):$=$==null?void 0:$.map(ie=>((ie==null?void 0:ie.id)===h.value&&(ie=Object.assign(ie,U.value),J=ie),ie)),c.value=$;const Z=fM(T.value,q.value,$);Me(Z),m.value=!1,n("change",{content:Z,singleContent:J,index:t==null?void 0:t.index,buttonName:_.value,column:i.value})},ot=J=>{U.value=J,n("onFormChange",J)};return V.watch(()=>[t.itemData,he.value,X.value,q.value,l==null?void 0:l.value],()=>{var De,Oe,Ie,tt,Nt,F,b,K,ce,pe,ne,ze,Ae,We,Ye,me,ke,st,nt,be,lt,B,Re,ge,Be,ye;const J=(De=Ke.cloneDeep(t.itemData))==null?void 0:De.filter(j=>(j==null?void 0:j.key)==="header");(Oe=Ke.cloneDeep(t.itemData))==null||Oe.filter(j=>(j==null?void 0:j.key)==="tableIndexColumn")[0];const $=(Ie=Ke.cloneDeep(t.itemData))==null?void 0:Ie.find(j=>(j==null?void 0:j.key)==="page"),Z=(tt=Ke.cloneDeep(t.itemData))==null?void 0:tt.find(j=>(j==null?void 0:j.key)==="rowButton"),ie=(Nt=Ke.cloneDeep(t.itemData))==null?void 0:Nt.find(j=>(j==null?void 0:j.key)==="extraButton"),I=(F=Ke.cloneDeep(t.itemData))==null?void 0:F.filter(j=>(j==null?void 0:j.key)==="tableContents"),Te=(b=Ke.cloneDeep(t.itemData))==null?void 0:b.filter(j=>(j==null?void 0:j.key)==="tableIndex");S.value=(pe=(ce=(K=Ke.cloneDeep(t.itemData))==null?void 0:K.filter(j=>(j==null?void 0:j.key)==="tableToForm"))==null?void 0:ce[0])==null?void 0:pe.contents,g.value=($==null?void 0:$.contents)??!1;let de=[];he.value===""?de=J==null?void 0:J[0]:de=(J==null?void 0:J.find(j=>(j==null?void 0:j.selectLabel)==="("+he.value+")"))??(J==null?void 0:J.find(j=>!(j!=null&&j.selectLabel)));let qe=[];if(he.value===""?qe=Te==null?void 0:Te[0]:qe=(Te==null?void 0:Te.find(j=>(j==null?void 0:j.selectLabel)==="("+he.value+")"))??(Te==null?void 0:Te.find(j=>!(j!=null&&j.selectLabel))),((ne=de==null?void 0:de.contents)==null?void 0:ne.length)>0){let j=[];if(de!=null&&de.contents.some($e=>Array.isArray($e)&&($e==null?void 0:$e.find(Ne=>Ne.children))))q.value===""?j=(Ae=(ze=zn.getGradeColumns(Ke.cloneDeep(de==null?void 0:de.contents)))==null?void 0:ze[0])==null?void 0:Ae.filter($e=>!Array.isArray($e)):(q.value.split("-"),j=(We=zn.getGradeColumns(Ke.cloneDeep(de==null?void 0:de.contents)))==null?void 0:We[0]);else{const $e=de!=null&&de.contents.some(Ne=>Array.isArray(Ne))?(Ye=de==null?void 0:de.contents)==null?void 0:Ye[0]:de==null?void 0:de.contents;$e==null||$e.forEach((Ne,Yt)=>{j.push({label:(Ne==null?void 0:Ne.label)??"",prop:(Ne==null?void 0:Ne.label)==="操作"?"operate":(Ne==null?void 0:Ne.prop)??"a"+Yt,width:(Ne==null?void 0:Ne.label)==="操作"?"200":Ne!=null&&Ne.width?parseInt(Ne.width):"",fixed:(Ne==null?void 0:Ne.fixed)??void 0,sortable:(Ne==null?void 0:Ne.sortable)??!1,align:(Ne==null?void 0:Ne.align)??"center",showOverflowTooltip:(Ne==null?void 0:Ne.showOverflowTooltip)??!0,isNotDrag:(Ne==null?void 0:Ne.isNotDrag)??!1,isEditCol:(Ne==null?void 0:Ne.isEditCol)??!1,isOperate:(Ne==null?void 0:Ne.isOperate)??!1,id:(Ne==null?void 0:Ne.id)??Yt,type:(Ne==null?void 0:Ne.label)==="操作"?"operate":void 0,formType:(Ne==null?void 0:Ne.formType)??"",isTableColHidden:Ne==null?void 0:Ne.isTableColHidden,isFormColHidden:Ne==null?void 0:Ne.isFormColHidden,options:(Ne==null?void 0:Ne.options)??[],value:(Ne==null?void 0:Ne.value)??""})})}i.value=j;let Ce=(ke=(me=zn.getAllLeafNodes(Ke.cloneDeep(i.value)))==null?void 0:me.filter($e=>($e==null?void 0:$e.type)!=="operate"))==null?void 0:ke.map(($e,Ne)=>({prop:($e==null?void 0:$e.prop)??"a"+Ne,column:$e.label}));L.value=Ce;let Ze=[];he.value===""?Ze=I==null?void 0:I[0]:Ze=(I==null?void 0:I.find($e=>($e==null?void 0:$e.selectLabel)==="("+he.value+")"))??(I==null?void 0:I.find($e=>!($e!=null&&$e.selectLabel)));let bt=Array.isArray((st=Ze==null?void 0:Ze.contents)==null?void 0:st[0])&&((nt=Ze==null?void 0:Ze.contents)!=null&&nt[0].every($e=>Array.isArray($e)))?(be=Ke.cloneDeep(Ze==null?void 0:Ze.contents))==null?void 0:be[0]:Ke.cloneDeep(Ze==null?void 0:Ze.contents);qe!=null&&qe.contents&&((lt=qe==null?void 0:qe.contents)==null?void 0:lt.length)!==0&&(bt=(B=Ke.cloneDeep(bt))==null?void 0:B.map(($e,Ne)=>{if(!Array.isArray($e)){let Yt={};for(let dn in $e)dn!=="id"&&dn!=="index"&&(Yt[dn]=$e[dn]);$e=Object.values(Yt)}return $e}));const pt=!!((Re=i.value)!=null&&Re.find($e=>$e.prop==="index"));bt=Gh(Ke.cloneDeep(bt),qe==null?void 0:qe.contents,pt);const Jt=[];bt==null||bt.forEach(($e,Ne)=>{var dn;let Yt={};if(Array.isArray($e)){let jt=[];$e==null||$e.filter(pn=>!(pn!=null&&pn.id)).forEach((pn,vn)=>{var ci,Pi,ui,ji,qi,fs;if((ci=Ce==null?void 0:Ce[vn])!=null&&ci.prop&&!Array.isArray(pn)){let Ki={};Ki[Ce[vn].column]=pn,l!=null&&l.value&&((Pi=l==null?void 0:l.value)==null?void 0:Pi.length)>0&&((ui=l==null?void 0:l.value)!=null&&ui.find(xn=>JSON.stringify(xn==null?void 0:xn[0])===JSON.stringify(Ki)))&&(jt=(ji=l==null?void 0:l.value)==null?void 0:ji.find(xn=>JSON.stringify(xn==null?void 0:xn[0])===JSON.stringify(Ki))),jt&&jt.length>0?Yt[Ce[vn].prop]=jt!=null&&jt.find(xn=>{var hi;return((hi=Object.keys(xn))==null?void 0:hi[0])===Ce[vn].column})?(qi=jt==null?void 0:jt.find(xn=>{var hi;return((hi=Object.keys(xn))==null?void 0:hi[0])===Ce[vn].column}))==null?void 0:qi[Ce[vn].column]:pn:Yt[Ce[vn].prop]=pn}else Array.isArray(pn)&&((fs=Ce[vn])!=null&&fs.prop?Yt[Ce[vn].prop]=pn:Yt.children=Hh(pn,Ce))})}else Yt=$e;Array.isArray($e)&&$e.some(jt=>jt==null?void 0:jt.id)?Jt.push(Object.assign(Yt,{id:(dn=$e==null?void 0:$e.find(jt=>jt.id))==null?void 0:dn.id})):Yt.id?Jt.push(Yt):Jt.push(Object.assign(Yt,{id:Ne}))}),c.value=Jt}else i.value=[],c.value=[];((ge=Z==null?void 0:Z.contents)==null?void 0:ge.length)>0?v.value=Z==null?void 0:Z.contents:v.value=[],((Be=ie==null?void 0:ie.contents)==null?void 0:Be.length)>0?N.value=ie==null?void 0:ie.contents:N.value=[],f.value=((ye=c==null?void 0:c.value)==null?void 0:ye.length)??0,T.value=c.value},{deep:!0,immediate:!0}),(J,$)=>{var Z;return V.openBlock(),V.createElementBlock("div",DM,[(V.openBlock(),V.createBlock(zn.ssTable,{columns:i.value,key:i.value,tableData:c.value,isShowPagination:g.value,isShowEdit:!1,isShowDelete:!1,onDbClickRow:we,extraButton:N.value,onButtonClick:$[1]||($[1]=ie=>ee(ie,"")),onContentClick:W},V.createSlots({headerButton:V.withCtx(ie=>[V.createVNode(Id,{buttons:ie.buttons,onButtonClick:$[0]||($[0]=I=>ee(I,"")),columns:i.value,onFilter:le},null,8,["buttons","columns"])]),_:2},[((Z=v.value)==null?void 0:Z.length)>0?{name:"actions",fn:V.withCtx(({item:ie})=>[(V.openBlock(!0),V.createElementBlock(V.Fragment,null,V.renderList(fe(v.value,ie),(I,Te)=>(V.openBlock(),V.createElementBlock("div",{key:Te},[V.createElementVNode("div",{style:V.normalizeStyle({color:I==null?void 0:I.textColor}),class:"extra-button-label",onClick:de=>ee(I==null?void 0:I.label,ie)},V.toDisplayString(I==null?void 0:I.label),13,IM)]))),128))]),key:"0"}:void 0]),1032,["columns","tableData","isShowPagination","extraButton"])),V.createVNode(zn.ssDialog,{title:_.value,visible:m.value,width:k.value,onBeforeDestroy:oe},{default:V.withCtx(()=>[V.createElementVNode("div",NM,[V.createVNode(zn.ssForm,{rowContents:P.value,isEnableWrap:!1,onChange:ot,onClickTrigger:G,isEdit:d.value},null,8,["rowContents","isEdit"])])]),footer:V.withCtx(()=>[y.value?(V.openBlock(),V.createElementBlock("div",UM,[V.createElementVNode("div",{onClick:$[2]||($[2]=ie=>m.value=!1),class:"cancel-button"},V.toDisplayString("取消")),V.createElementVNode("div",{class:"ok-button",onClick:Se},V.toDisplayString("确认"))])):V.createCommentVNode("",!0)]),_:1},8,["title","visible","width"]),V.createVNode(zn.ssDialog,{visible:u.value,fullScreen:"",onBeforeDestroy:ae},{default:V.withCtx(()=>[V.createVNode(Bh,{isShow:u.value},null,8,["isShow"])]),_:1},8,["visible"])])}}},OM=Rl._export_sfc(FM,[["__scopeId","data-v-83a7967a"]]);exports.IsJson=mM;exports.addTableContents=wM;exports.conStructContents=TM;exports.deleteTableContents=AM;exports.fixFormContents=CM;exports.fixTableContents=RM;exports.getItemData=qh;exports.loadingSystemType=LM;exports.methodTableToContent=_M;exports.ssTable=OM;exports.tableEveryContents=wl;exports.tableToContents=Al;exports.tableToStruct=Mi;exports.threeModel=Bh;exports.useFormToTableComp=zh;exports.useUnit=Vh;