ss-component-new 1.1.263 → 1.1.264
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{array-BCYeTWHp.cjs → array-D3xioWc3.cjs} +1 -1
- package/dist/{array-BiSkXjDh.js → array-De6v-7c8.js} +2 -2
- package/dist/{cloneDeep-CxhinJk5.js → cloneDeep-B2ByQP-n.js} +1 -1
- package/dist/{cloneDeep-BShYbOkw.cjs → cloneDeep-fJrTDzM4.cjs} +1 -1
- package/dist/{index-DvydSDWz.js → index--0pthhoG.js} +33 -33
- package/dist/{index-B8d1EBwW.cjs → index-08aCULjy.cjs} +1 -1
- package/dist/{index-BRgT-cwL.cjs → index-0TcXp8mH.cjs} +1 -1
- package/dist/index-B4jC_LC5.cjs +1 -0
- package/dist/{index-Cd2qjywt.cjs → index-B6yeLC4B.cjs} +1 -1
- package/dist/{index-BJEmWdGc.cjs → index-BCLA1nYG.cjs} +1 -1
- package/dist/{index-CWpNIgx-.js → index-BDIP3GvE.js} +5 -5
- package/dist/{index-6mqoLKfR.js → index-BLC8ydIr.js} +6 -6
- package/dist/{index-BEQcfNC8.js → index-BRdg4IiT.js} +503 -496
- package/dist/{index-GDAKW2b9.cjs → index-BRkdObg7.cjs} +1 -1
- package/dist/{index-DecqROTY.cjs → index-BRkvuCrS.cjs} +1 -1
- package/dist/index-BYUhFGra.cjs +1 -0
- package/dist/{index-C9gBSiUj.cjs → index-BjJJGDlr.cjs} +1 -1
- package/dist/{index-BxD91iWh.js → index-BwYoB3zY.js} +1 -1
- package/dist/{index-D9sisgye.js → index-ByD0b4gQ.js} +1 -1
- package/dist/{index-kq_YOCp0.cjs → index-BzfDFTVJ.cjs} +7 -7
- package/dist/{index-BqqWyJ_i.js → index-C4k05bGp.js} +8 -8
- package/dist/{index-jxXiBXta.cjs → index-C7u1PeVA.cjs} +1 -1
- package/dist/{index-B0SEIfhd.js → index-CACJUJNK.js} +3 -3
- package/dist/{index-Duw1U19n.js → index-CAMfVOTJ.js} +3 -3
- package/dist/{index-D0isXbYa.js → index-CCxjdgET.js} +13 -14
- package/dist/{index-BJWxGK8l.cjs → index-CGmFed4r.cjs} +1 -1
- package/dist/{index-Bl-nqQUb.cjs → index-CINFGcYo.cjs} +1 -1
- package/dist/{index-DdfwFwkR.js → index-CKwpRhPM.js} +3 -3
- package/dist/{index-B2bPpqmz.js → index-CMMc21DE.js} +5 -5
- package/dist/{index-B96mvnY6.js → index-CUmxELcB.js} +1 -1
- package/dist/{index--CBmQToI.js → index-CZ2mVLUS.js} +4 -4
- package/dist/{index-BRYyDz7j.cjs → index-Ca-dN5Cs.cjs} +1 -1
- package/dist/{index-BeYDJriQ.js → index-CiPPPWoz.js} +110 -111
- package/dist/index-ClFJDxkW.js +704 -0
- package/dist/{index-YBOakoO-.js → index-CmiwbsGe.js} +1 -1
- package/dist/{index-h9avu7we.cjs → index-CophBMbH.cjs} +1 -1
- package/dist/{index-cPpFPrRC.cjs → index-Ctjc6Jcq.cjs} +1 -1
- package/dist/{index-CzuGT7Su.cjs → index-CvvmJuAB.cjs} +1 -1
- package/dist/{index-C8FwXAiK.js → index-CwB7I565.js} +1 -1
- package/dist/{index-BW_gJg6Y.js → index-DCGzAKWd.js} +4 -4
- package/dist/{index-CNnhenkX.cjs → index-DDPAMlSG.cjs} +1 -1
- package/dist/index-DEv2DOlH.cjs +1 -0
- package/dist/{index-DhT3lFvD.js → index-DMCUh24w.js} +5 -5
- package/dist/{index-BiIAlHzV.cjs → index-DSxBLvAT.cjs} +1 -1
- package/dist/{index-DSPU33cy.js → index-DXd7EQps.js} +5 -5
- package/dist/index-Dcpfhw1L.cjs +1 -0
- package/dist/{index-5G9gxVsG.js → index-DfKXP07X.js} +13 -8
- package/dist/{index-BG7p7J6-.js → index-Dn9ZzQw9.js} +3 -3
- package/dist/{index-CvoVhrqh.cjs → index-DymcJtj4.cjs} +1 -1
- package/dist/{index-CPNiI7xc.cjs → index-ERfBi-RP.cjs} +1 -1
- package/dist/{index-DJRZAkF4.js → index-EmmO21uK.js} +4 -4
- package/dist/{index-BEPkDcRB.js → index-GG9AAJSa.js} +4 -4
- package/dist/index-GtWRkXjP.js +133 -0
- package/dist/{index-B5fyktOS.js → index-Pzfiy_pl.js} +1 -1
- package/dist/index-SYAZCe_x.js +3579 -0
- package/dist/{index-sYRfzwGi.cjs → index-_rARCgTs.cjs} +1 -1
- package/dist/index-cj-WHGF0.cjs +1 -0
- package/dist/{index-BTWHfvj_.cjs → index-hRwcFNhM.cjs} +1 -1
- package/dist/{index-Cmf6TSRr.js → index-qofx0IRr.js} +9 -9
- package/dist/index-sFDoFhGY.cjs +1 -0
- package/dist/{index-BPGk6VZT.cjs → index-sVlKvvQZ.cjs} +1 -1
- package/dist/{index-BReBoqZM.cjs → index-u6rAowW4.cjs} +1 -1
- package/dist/{index.vue_vue_type_script_setup_true_lang-dRZKrDpe.js → index.vue_vue_type_script_setup_true_lang-CwRRfUhq.js} +1 -1
- package/dist/{index.vue_vue_type_script_setup_true_lang-WZ_0N2ba.cjs → index.vue_vue_type_script_setup_true_lang-HIAfOHHq.cjs} +1 -1
- package/dist/{index.vue_vue_type_style_index_0_scoped_11a5120d_lang-DC0qx2mv.cjs → index.vue_vue_type_style_index_0_scoped_11a5120d_lang-Be6r7R3U.cjs} +1 -1
- package/dist/{index.vue_vue_type_style_index_0_scoped_11a5120d_lang-D6zTMeXs.js → index.vue_vue_type_style_index_0_scoped_11a5120d_lang-dyax8Dv5.js} +6 -6
- package/dist/{index.vue_vue_type_style_index_0_scoped_4b7a2e5d_lang-Bnu6O5Dx.js → index.vue_vue_type_style_index_0_scoped_4b7a2e5d_lang-DUY9SJBE.js} +12 -12
- package/dist/{index.vue_vue_type_style_index_0_scoped_4b7a2e5d_lang-B9TnTaRE.cjs → index.vue_vue_type_style_index_0_scoped_4b7a2e5d_lang-DYSNP688.cjs} +1 -1
- package/dist/{login-B_Ta8W8C.cjs → login-Wrj9nSOa.cjs} +1 -1
- package/dist/{login-D_UosrWe.js → login-o8x8Nxaf.js} +2 -2
- package/dist/{main-CHSqRi2c.js → main-DWoD0Vdp.js} +7 -7
- package/dist/{main-DRtNsfjw.cjs → main-rSkhpXGR.cjs} +1 -1
- package/dist/{menu-BjwI4sfO.js → menu-CFLAcuA-.js} +33 -24
- package/dist/{menu-CH06rBlw.cjs → menu-cQfDaGL1.cjs} +4 -4
- package/dist/{modelComp-LhGhARtD.cjs → modelComp-4oAkv2ok.cjs} +1 -1
- package/dist/{modelComp-CiiFZm1t.js → modelComp-B7C56fRv.js} +1 -1
- package/dist/ss-component.cjs +1 -1
- package/dist/ss-component.css +1 -1
- package/dist/ss-component.js +7 -7
- package/dist/ss-component3.cjs +1 -1
- package/dist/ss-component3.js +1 -1
- package/package.json +1 -1
- package/dist/index-21rauG0g.cjs +0 -1
- package/dist/index-3fLiW589.cjs +0 -1
- package/dist/index-B5vG0PaI.cjs +0 -1
- package/dist/index-C3-tA5Oy.js +0 -3520
- package/dist/index-CYjQVlPG.cjs +0 -1
- package/dist/index-ClyxHDAy.cjs +0 -1
- package/dist/index-WOjw27kj.js +0 -683
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const z=require("vue"),ur=require("./index-_rARCgTs.cjs"),Vu=require("./modelComp-4oAkv2ok.cjs"),Ai=require("./index-sVlKvvQZ.cjs"),zn=require("./index-u6rAowW4.cjs"),Rl=require("./_plugin-vue_export-helper-BHFhmbuH.cjs"),Ke=require("./cloneDeep-fJrTDzM4.cjs"),At=require("./menu-cQfDaGL1.cjs"),Hu=require("./index-CGmFed4r.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=z.ref(null),n=z.ref(!1),i=z.ref(null);return z.watch(()=>e==null?void 0:e.isVisible,()=>{n.value=e==null?void 0:e.isVisible},{deep:!0,immediate:!0}),z.watch(()=>i.value,()=>{z.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=z.resolveComponent("el-popover");return z.openBlock(),z.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:z.withCtx(()=>[z.createElementVNode("div",null,[z.renderSlot(r.$slots,"reference",{ref_key:"referenceRef",ref:i})])]),default:z.withCtx(()=>[z.createElementVNode("div",null,[z.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=z.ref(!1),r=z.ref([]),a=z.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 z.onMounted(()=>{l(n.columns)}),z.watch(()=>n.columns,()=>{l(n.columns)},{deep:!0,immediate:!0}),(u,h)=>{var f;const d=z.resolveComponent("el-tooltip");return z.openBlock(),z.createElementBlock("div",wd,[n!=null&&n.buttons&&((f=n==null?void 0:n.buttons)==null?void 0:f.length)>0?(z.openBlock(),z.createElementBlock("div",Rd,[(z.openBlock(!0),z.createElementBlock(z.Fragment,null,z.renderList(n==null?void 0:n.buttons,(g,_)=>(z.openBlock(),z.createElementBlock("div",{class:"extra-contents",key:_},[z.createElementVNode("div",{class:"extra-content",style:z.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)},z.toDisplayString(g==null?void 0:g.label),13,Cd)]))),128))])):z.createCommentVNode("",!0),z.createElementVNode("div",Pd,[z.createVNode(Ad,{title:"筛选数据",width:500,isVisible:i.value},{reference:z.withCtx(()=>[z.createVNode(d,{content:"筛选",placement:"top-start"},{default:z.withCtx(()=>[z.createElementVNode("div",{class:"button-style",onClick:h[0]||(h[0]=g=>i.value=!i.value)},[z.createVNode(z.unref(Ai.filter_default),{color:"var(--ssComponent-black)"})])]),_:1})]),content:z.withCtx(()=>[z.createElementVNode("div",Ld,[(z.openBlock(),z.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
|
|
@@ -3571,7 +3571,7 @@ void main() {
|
|
|
3571
3571
|
#include <tonemapping_fragment>
|
|
3572
3572
|
#include <colorspace_fragment>
|
|
3573
3573
|
#include <fog_fragment>
|
|
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:`
|
|
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 Y=0;Y<G.locationSize;Y++)p(G.location+Y,re.meshPerAttribute);T.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=re.meshPerAttribute*re.count)}else for(let Y=0;Y<G.locationSize;Y++)m(G.location+Y);s.bindBuffer(s.ARRAY_BUFFER,Me);for(let Y=0;Y<G.locationSize;Y++)v(G.location+Y,le/G.locationSize,W,ve,Se*ee,(ot+le/G.locationSize*Y)*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;
|
|
@@ -3772,7 +3772,7 @@ Material Type: `+D.type+`
|
|
|
3772
3772
|
|
|
3773
3773
|
Program Info Log: `+X+`
|
|
3774
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() {
|
|
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,Y=q.isBatchedMesh===!0,J=!!E.map,$=!!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:Y,batchingColor:Y&&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:J,matcap:$,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:J&&_(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&&(J||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:J&&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||Y)&&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 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=`
|
|
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 Y(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 J(B){return g!==B?(s.useProgram(B),g=B,!0):!1}const $={[ss]:s.FUNC_ADD,[Od]:s.FUNC_SUBTRACT,[kd]:s.FUNC_REVERSE_SUBTRACT};$[Bd]=s.MIN,$[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($[Re],$[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:Y,useProgram:J,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 Y(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 J(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?Y(b.__webglFramebuffer[0],F):Y(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 $(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&&J(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&&J(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=$,this.setupRenderTarget=ie,this.updateRenderTargetMipmap=I,this.updateMultisampleRenderTarget=qe,this.setupDepthRenderbuffer=J,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,7 +3824,7 @@ 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 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
|
|
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,Y=Se[14]/(Se[10]-1),J=Se[14]/(Se[10]+1),$=(Se[9]+1)/Se[5],ie=(Se[9]-1)/Se[5],I=(Se[8]-1)/Se[0],Te=(ot[8]+1)/ot[0],de=Y*I,qe=Y*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=Y+De,tt=J+De,Nt=de-Oe,F=qe+(re-Oe),b=$*J/tt*Ie,K=ie*J/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 Y=0;Y<ae.length;Y++){const J=ae[Y];let $=null;if(f!==null)$=f.getViewport(J);else{const I=h.getViewSubImage(d,J);$=I.viewport,Y===0&&(e.setRenderTargetTextures(S,I.colorTexture,I.depthStencilTexture),e.setRenderTarget(S))}let ie=E[Y];ie===void 0&&(ie=new un,ie.layers.enable(Y),ie.viewport=new Tt,E[Y]=ie),ie.matrix.fromArray(J.transform.matrix),ie.matrix.decompose(ie.position,ie.quaternion,ie.scale),ie.projectionMatrix.fromArray(J.projectionMatrix),ie.projectionMatrixInverse.copy(ie.projectionMatrix).invert(),ie.viewport.set($.x,$.y,$.width,$.height),Y===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 Y=h.getDepthInformation(ae[0]);Y&&Y.isValid&&Y.texture&&_.init(e,Y,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,Y=new Tt,J={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let $=!1;function ie(){return U===null?G:1}let I=n;function Te(w,V){return t.getContext(w,V)}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 V="webgl2";if(I=Te(V,w),I===null)throw Te(V)?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,V,Z=!0){if(ge.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}k=w,oe=V,t.width=Math.floor(w*G),t.height=Math.floor(V*G),Z===!0&&(t.style.width=w+"px",t.style.height=V+"px"),this.setViewport(0,0,w,V)},this.getDrawingBufferSize=function(w){return w.set(k*G,oe*G).floor()},this.setDrawingBufferSize=function(w,V,Z){k=w,oe=V,G=Z,t.width=Math.floor(w*Z),t.height=Math.floor(V*Z),this.setViewport(0,0,w,V)},this.getCurrentViewport=function(w){return w.copy(D)},this.getViewport=function(w){return w.copy(le)},this.setViewport=function(w,V,Z,Q){w.isVector4?le.set(w.x,w.y,w.z,w.w):le.set(w,V,Z,Q),De.viewport(D.copy(le).multiplyScalar(G).round())},this.getScissor=function(w){return w.copy(we)},this.setScissor=function(w,V,Z,Q){w.isVector4?we.set(w.x,w.y,w.z,w.w):we.set(w,V,Z,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,V=!0,Z=!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}V&&(Q|=I.DEPTH_BUFFER_BIT),Z&&(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,V=Ye.enabled,Z=Ye.autoUpdate,Q=Ye.needsUpdate,H=Ye.type;Re(),Oe.autoReset=w,Ye.enabled=V,Ye.autoUpdate=Z,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 V=w.target;V.removeEventListener("dispose",Ce),Ze(V)}function Ze(w){bt(w),Ie.remove(w)}function bt(w){const V=Ie.get(w).programs;V!==void 0&&(V.forEach(function(Z){pe.releaseProgram(Z)}),w.isShaderMaterial&&pe.releaseShaderCache(w))}this.renderBufferDirect=function(w,V,Z,Q,H,xe){V===null&&(V=J);const Pe=H.isMesh&&H.matrixWorld.determinant()<0,Xe=fs(w,V,Z,Q,H);De.setMaterial(Q,Pe);let Ve=Z.index,ut=1;if(Q.wireframe===!0){if(Ve=K.getWireframeAttribute(Z),Ve===void 0)return;ut=2}const ht=Z.drawRange,et=Z.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,Z,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(Z.isInstancedBufferGeometry){const rt=Z._maxInstanceCount!==void 0?Z._maxInstanceCount:1/0,Qt=Math.min(Z.instanceCount,rt);Et.renderInstances(mt,Bt,Qt)}else Et.render(mt,Bt)};function pt(w,V,Z){w.transparent===!0&&w.side===Zn&&w.forceSinglePass===!1?(w.side=In,w.needsUpdate=!0,ui(w,V,Z),w.side=ri,w.needsUpdate=!0,ui(w,V,Z),w.side=Zn):ui(w,V,Z)}this.compile=function(w,V,Z=null){Z===null&&(Z=w),p=Ae.get(Z),p.init(V),v.push(p),Z.traverseVisible(function(H){H.isLight&&H.layers.test(V.layers)&&(p.pushLight(H),H.castShadow&&p.pushShadow(H))}),w!==Z&&w.traverseVisible(function(H){H.isLight&&H.layers.test(V.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,Z,H),Q.add(Xe)}else pt(xe,Z,H),Q.add(xe)}),p=v.pop(),Q},this.compileAsync=function(w,V,Z=null){const Q=this.compile(w,V,Z);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,V){if(V!==void 0&&V.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(),V.parent===null&&V.matrixWorldAutoUpdate===!0&&V.updateMatrixWorld(),ge.enabled===!0&&ge.isPresenting===!0&&(ge.cameraAutoUpdate===!0&&ge.updateCamera(V),V=ge.getCamera()),w.isScene===!0&&w.onBeforeRender(y,w,V,U),p=Ae.get(w,v.length),p.init(V),v.push(p),Se.multiplyMatrices(V.projectionMatrix,V.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,V,-1/0,y.sortObjects)}jt(w,V,0,y.sortObjects),m.finish(),y.sortObjects===!0&&m.sort(fe,ve),$=ge.enabled===!1||ge.isPresenting===!1||ge.hasDepthSensing()===!1,$&&me.addToRenderList(m,w),this.info.render.frame++,ee===!0&&We.beginShadows();const Z=p.state.shadowsArray;Ye.render(Z,w,V),ee===!0&&We.endShadows(),this.info.autoReset===!0&&this.info.reset();const Q=m.opaque,H=m.transmissive;if(p.setupLights(),V.isArrayCamera){const xe=V.cameras;if(H.length>0)for(let Pe=0,Xe=xe.length;Pe<Xe;Pe++){const Ve=xe[Pe];vn(Q,H,w,Ve)}$&&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,V),$&&me.render(w),pn(m,w,V);U!==null&&L===0&&(tt.updateMultisampleRenderTarget(U),tt.updateRenderTargetMipmap(U)),w.isScene===!0&&w.onAfterRender(y,w,V),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,V,Z,Q){if(w.visible===!1)return;if(w.layers.test(V.layers)){if(w.isGroup)Z=w.renderOrder;else if(w.isLOD)w.autoUpdate===!0&&w.update(V);else if(w.isLight)p.pushLight(w),w.castShadow&&p.pushShadow(w);else if(w.isSprite){if(!w.frustumCulled||W.intersectsSprite(w)){Q&&Y.setFromMatrixPosition(w.matrixWorld).applyMatrix4(Se);const Pe=ce.update(w),Xe=w.material;Xe.visible&&m.push(w,Pe,Xe,Z,Y.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(),Y.copy(w.boundingSphere.center)):(Pe.boundingSphere===null&&Pe.computeBoundingSphere(),Y.copy(Pe.boundingSphere.center)),Y.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,Z,Y.z,et)}}else Xe.visible&&m.push(w,Pe,Xe,Z,Y.z,null)}}const xe=w.children;for(let Pe=0,Xe=xe.length;Pe<Xe;Pe++)jt(xe[Pe],V,Z,Q)}function pn(w,V,Z,Q){const H=w.opaque,xe=w.transmissive,Pe=w.transparent;p.setupLightsView(Z),ee===!0&&We.setGlobalState(y.clippingPlanes,Z),Q&&De.viewport(D.copy(Q)),H.length>0&&ci(H,V,Z),xe.length>0&&ci(xe,V,Z),Pe.length>0&&ci(Pe,V,Z),De.buffers.depth.setTest(!0),De.buffers.depth.setMask(!0),De.buffers.color.setMask(!0),De.setPolygonOffset(!1)}function vn(w,V,Z,Q){if((Z.isScene===!0?Z.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(),$&&me.render(Z);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,Z,Q),tt.updateMultisampleRenderTarget(xe),tt.updateRenderTargetMipmap(xe),de.has("WEBGL_multisampled_render_to_texture")===!1){let ht=!1;for(let et=0,mt=V.length;et<mt;et++){const Lt=V[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,Z,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,V,Z){const Q=V.isScene===!0?V.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(Z.layers)&&Pi(Xe,V,Z,Ve,ht,ut)}}function Pi(w,V,Z,Q,H,xe){w.onBeforeRender(y,V,Z,Q,H,xe),w.modelViewMatrix.multiplyMatrices(Z.matrixWorldInverse,w.matrixWorld),w.normalMatrix.getNormalMatrix(w.modelViewMatrix),H.onBeforeRender(y,V,Z,Q,w,xe),H.transparent===!0&&H.side===Zn&&H.forceSinglePass===!1?(H.side=In,H.needsUpdate=!0,y.renderBufferDirect(Z,V,Q,H,w,xe),H.side=ri,H.needsUpdate=!0,y.renderBufferDirect(Z,V,Q,H,w,xe),H.side=Zn):y.renderBufferDirect(Z,V,Q,H,w,xe),w.onAfterRender(y,V,Z,Q,H,xe)}function ui(w,V,Z){V.isScene!==!0&&(V=J);const Q=Ie.get(w),H=p.state.lights,xe=p.state.shadowsArray,Pe=H.state.version,Xe=pe.getParameters(w,H.state,xe,V,Z),Ve=pe.getProgramCacheKey(Xe);let ut=Q.programs;Q.environment=w.isMeshStandardMaterial?V.environment:null,Q.fog=V.fog,Q.envMap=(w.isMeshStandardMaterial?F:Nt).get(w.envMap||Q.environment),Q.envMapRotation=Q.environment!==null&&w.envMap===null?V.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 V=w.currentProgram.getUniforms();w.uniformsList=Sa.seqWithValue(V.seq,w.uniforms)}return w.uniformsList}function qi(w,V){const Z=Ie.get(w);Z.outputColorSpace=V.outputColorSpace,Z.batching=V.batching,Z.batchingColor=V.batchingColor,Z.instancing=V.instancing,Z.instancingColor=V.instancingColor,Z.instancingMorph=V.instancingMorph,Z.skinning=V.skinning,Z.morphTargets=V.morphTargets,Z.morphNormals=V.morphNormals,Z.morphColors=V.morphColors,Z.morphTargetsCount=V.morphTargetsCount,Z.numClippingPlanes=V.numClippingPlanes,Z.numIntersection=V.numClipIntersection,Z.vertexAlphas=V.vertexAlphas,Z.vertexTangents=V.vertexTangents,Z.toneMapping=V.toneMapping}function fs(w,V,Z,Q,H){V.isScene!==!0&&(V=J),tt.resetTextureUnits();const xe=V.fog,Pe=Q.isMeshStandardMaterial?V.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&&!!Z.attributes.color&&Z.attributes.color.itemSize===4,ht=!!Z.attributes.tangent&&(!!Q.normalMap||Q.anisotropy>0),et=!!Z.morphAttributes.position,mt=!!Z.morphAttributes.normal,Lt=!!Z.morphAttributes.color;let Bt=Gi;Q.toneMapped&&(U===null||U.isXRRenderTarget===!0)&&(Bt=y.toneMapping);const Ht=Z.morphAttributes.position||Z.morphAttributes.normal||Z.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,V,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=Z.morphAttributes;if((mn.position!==void 0||mn.normal!==void 0||mn.color!==void 0)&&ke.update(H,Z,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&&V.environment!==null&&(Mn.envMapIntensity.value=V.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,V){w.ambientLightColor.needsUpdate=V,w.lightProbe.needsUpdate=V,w.directionalLights.needsUpdate=V,w.directionalLightShadows.needsUpdate=V,w.pointLights.needsUpdate=V,w.pointLightShadows.needsUpdate=V,w.spotLights.needsUpdate=V,w.spotLightShadows.needsUpdate=V,w.rectAreaLights.needsUpdate=V,w.hemisphereLights.needsUpdate=V}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,V,Z){const Q=Ie.get(w);Q.__autoAllocateDepthBuffer=w.resolveDepthBuffer===!1,Q.__autoAllocateDepthBuffer===!1&&(Q.__useRenderToTexture=!1),Ie.get(w.texture).__webglTexture=V,Ie.get(w.depthTexture).__webglTexture=Q.__autoAllocateDepthBuffer?void 0:Z,Q.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(w,V){const Z=Ie.get(w);Z.__webglFramebuffer=V,Z.__useDefaultFramebuffer=V===void 0};const hi=I.createFramebuffer();this.setRenderTarget=function(w,V=0,Z=0){U=w,P=V,L=Z;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[V])?H=ht[V][Z]:H=ht[V],xe=!0):w.samples>0&&tt.useMultisampledRTT(w)===!1?H=Ie.get(w).__webglMultisampledFramebuffer:Array.isArray(ht)?H=ht[Z]: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(Z!==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+V,Ve.__webglTexture,Z)}else if(Pe){const Ve=Ie.get(w.texture),ut=V;I.framebufferTextureLayer(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,Ve.__webglTexture,Z,ut)}else if(w!==null&&Z!==0){const Ve=Ie.get(w.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,Ve.__webglTexture,Z)}E=-1},this.readRenderTargetPixels=function(w,V,Z,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}V>=0&&V<=w.width-Q&&Z>=0&&Z<=w.height-H&&(w.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+Xe),I.readPixels(V,Z,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,V,Z,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(V>=0&&V<=w.width-Q&&Z>=0&&Z<=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(V,Z,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,V=null,Z=0){const Q=Math.pow(2,-Z),H=Math.floor(w.image.width*Q),xe=Math.floor(w.image.height*Q),Pe=V!==null?V.x:0,Xe=V!==null?V.y:0;tt.setTexture2D(w,0),I.copyTexSubImage2D(I.TEXTURE_2D,Z,0,0,Pe,Xe,H,xe),De.unbindTexture()};const za=I.createFramebuffer(),Va=I.createFramebuffer();this.copyTextureToTexture=function(w,V,Z=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(Z!==null)Pe=Z.max.x-Z.min.x,Xe=Z.max.y-Z.min.y,Ve=Z.isBox3?Z.max.z-Z.min.z:1,ut=Z.min.x,ht=Z.min.y,et=Z.isBox3?Z.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(V.format),rt=be.convert(V.type);let Qt;V.isData3DTexture?(tt.setTexture3D(V,0),Qt=I.TEXTURE_3D):V.isDataArrayTexture||V.isCompressedArrayTexture?(tt.setTexture2DArray(V,0),Qt=I.TEXTURE_2D_ARRAY):(tt.setTexture2D(V,0),Qt=I.TEXTURE_2D),I.pixelStorei(I.UNPACK_FLIP_Y_WEBGL,V.flipY),I.pixelStorei(I.UNPACK_PREMULTIPLY_ALPHA_WEBGL,V.premultiplyAlpha),I.pixelStorei(I.UNPACK_ALIGNMENT,V.unpackAlignment);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=V.isDataArrayTexture||V.isData3DTexture;if(w.isDepthTexture){const mn=Ie.get(w),Zt=Ie.get(V),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(V).__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(V);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):V.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&&V.generateMipmaps&&I.generateMipmap(Qt),De.unbindTexture()},this.copyTextureToTexture3D=function(w,V,Z=null,Q=null,H=0){return ks('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(w,V,Z,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(`
|
|
@@ -3833,7 +3833,7 @@ 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 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+=`
|
|
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(J){var $=t.length;if(J>$){var ie=new Vn(Math.max($*2,J));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,Y=Math.min(fe,Se);for(ot+d<0&&Yn(3);d<Y;++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 Y=T.width;for(ot=oe;ot!==fe;ot+=G)for(Se=ve;Se!==we;Se+=le,re++)ae=Me[re],k[(Se+Y*ot)*4+3]=255,k[(Se+Y*ot)*4+2]=ee[ae*3+0],k[(Se+Y*ot)*4+1]=ee[ae*3+1],k[(Se+Y*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;V.fromArray(Je).transpose(),V.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=Y(C);break}}dt.effects[M.getAttribute("id")]=x}function Y(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":J(C,x);break;case"technique":x.technique=I(C);break;case"extra":x.extra=Ie(C);break}}return x}function J(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]=$(te);break;case"sampler2D":x.samplers[R]=ie(te);break}}}function $(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;V.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":V.multiply(Ue.makeRotationAxis(it,Xt.degToRad(_e)));break;case"prismatic":V.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":V.multiply(Ct.obj);break;case"translate":V.multiply(Ue.makeTranslation(Ct.obj.x,Ct.obj.y,Ct.obj.z));break;case"scale":V.scale(Ct.obj);break;case"rotate":V.multiply(Ue.makeRotationAxis(Ct.obj,Ct.angle));break}}at.matrix.copy(V),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 V=new Fe,Z=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(V.fromArray(C).transpose()),x.transforms[A.getAttribute("sid")]=A.nodeName;break;case"translate":C=r(A.textContent),Z.fromArray(C),x.matrix.multiply(V.makeTranslation(Z.x,Z.y,Z.z)),x.transforms[A.getAttribute("sid")]=A.nodeName;break;case"rotate":C=r(A.textContent);const te=Xt.degToRad(C[3]);x.matrix.multiply(V.makeRotationAxis(Z.fromArray(C),te)),x.transforms[A.getAttribute("sid")]=A.nodeName;break;case"scale":C=r(A.textContent),x.matrix.scale(Z.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
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
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;
|
|
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=z.ref(null);z.ref(null),z.ref(""),z.ref(!1);const i=z.ref(""),r=z.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);z.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=J=>{const $="."+J.split(".").pop().toLowerCase();return v[$]||"未知"},N=J=>({pending:"待加载",loading:"加载中",loaded:"已加载",error:"失败"})[J]||"未知",P=J=>{if(J===0)return"0 B";const $=1024,ie=["B","KB","MB","GB"],I=Math.floor(Math.log(J)/Math.log($));return parseFloat((J/Math.pow($,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(J){console.error("Three.js场景初始化失败:",J)}},U=()=>{const J=new Kl(16777215,.6);g.add(J);const $=new Ar(16777215,.8);$.position.set(10,10,5),$.castShadow=!0,$.shadow.mapSize.width=2048,$.shadow.mapSize.height=2048,g.add($);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 J=new mm(1e3,1e3,8947848,13421772);g.add(J)},D=()=>{const J=()=>{requestAnimationFrame(J),p&&p.update(),m&&g&&_&&m.render(g,_)};J()},X=async J=>{if(J.status==="pending"){l.updateModelStatus(J.id,"loading");try{const $=URL.createObjectURL(J.file),ie=await q(J.file,$);if(ie)ie.userData.modelId=J.id,ie.userData.fileName=J.file.name,g.add(ie),l.updateModelObject(J.id,ie);else throw new Error("模型加载返回空对象");URL.revokeObjectURL($)}catch($){console.error(`模型 ${J.file.name} 加载失败:`,$),l.updateModelStatus(J.id,"error")}}},q=(J,$)=>new Promise((ie,I)=>{const Te="."+J.name.split(".").pop().toLowerCase();switch(Te){case".obj":se($,ie,I);break;case".fbx":he($,ie,I);break;case".gltf":case".glb":k($,ie,I);break;case".dae":oe($,ie,I);break;case".ply":G($,ie,I);break;case".stl":fe($,ie,I);break;default:I(new Error(`不支持的文件格式: ${Te}`))}}),se=(J,$,ie)=>{new av().load(J,$,void 0,ie)},he=(J,$,ie)=>{new Lv().load(J,$,void 0,ie)},k=(J,$,ie)=>{new Gv().load(J,Te=>{$(Te.scene)},void 0,ie)},oe=(J,$,ie)=>{new bx().load(J,Te=>{$(Te.scene)},void 0,ie)},G=(J,$,ie)=>{new Ex().load(J,Te=>{const de=new Er({color:8947848}),qe=new rn(Te,de);$(qe)},void 0,ie)},fe=(J,$,ie)=>{new wx().load(J,Te=>{const de=new Er({color:8947848}),qe=new rn(Te,de);$(qe)},void 0,ie)},ve=()=>{l.setShowModelList(!d.value)},le=J=>{l.toggleModelVisibility(J)},we=()=>{l.selectAllModels()},Me=()=>{l.deselectAllModels()},W=()=>{l.removeSelectedModels()},ee=J=>{l.removeUploadedModel(J)?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))};z.onMounted(async()=>{window.addEventListener("resize",re),L()}),z.watch(()=>t==null?void 0:t.isShow,J=>{J&&!f.value&&setTimeout(()=>{L()},100)},{immediate:!0});const Se=async(J,$={})=>{if(!J||!(J instanceof File||J instanceof Blob))throw new Error("参数必须是File或Blob对象");const ie=J.name||$.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:J,name:ie,size:J.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 J=>{try{const $=await Hu.downloadAvatarApi({url:J});if($.status!=200)throw new Error(`下载失败: ${$.status}`);return await $.data}catch($){throw console.error("addModelFromUrl失败:",$),$}};return e({addModelFromStream:Se,addModelFromUrl:async J=>{try{const $=await ot(J),ie=J.split("/").pop()||"model.obj",I=new File([$],ie,{type:$.type});return await Se(I,{autoFit:!0}),$}catch($){throw console.error("从URL加载模型失败:",$),$}},clearAllModels:ae}),z.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)}),(J,$)=>(z.openBlock(),z.createElementBlock("div",Gx,[r.value?(z.openBlock(),z.createElementBlock("div",Wx,$[2]||($[2]=[z.createElementVNode("div",{class:"upload-spinner"},[z.createElementVNode("div",{class:"spinner"}),z.createElementVNode("p",{class:"upload-text"},"正在上传模型...")],-1)]))):z.createCommentVNode("",!0),z.unref(d)?(z.openBlock(),z.createElementBlock("div",Xx,[z.createElementVNode("div",{class:"panel-header"},[$[4]||($[4]=z.createElementVNode("span",{class:"panel-title"},"模型列表",-1)),z.createElementVNode("button",{onClick:ve,class:"close-btn"},$[3]||($[3]=[z.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor"},[z.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)]))]),z.createElementVNode("div",jx,[z.createElementVNode("button",{onClick:we,class:"action-btn"},"全选"),z.createElementVNode("button",{onClick:Me,class:"action-btn"},"取消"),z.createElementVNode("button",{onClick:W,class:"action-btn danger",disabled:z.unref(u).length===0}," 删除 ("+z.toDisplayString(z.unref(u).length)+") ",9,qx)]),z.createElementVNode("div",Kx,[z.unref(c).length===0?(z.openBlock(),z.createElementBlock("div",Yx,$[5]||($[5]=[z.createElementVNode("p",null,"暂无模型",-1)]))):z.createCommentVNode("",!0),(z.openBlock(!0),z.createElementBlock(z.Fragment,null,z.renderList(z.unref(c),(ie,I)=>(z.openBlock(),z.createElementBlock("div",{key:ie.id,class:z.normalizeClass(["model-item",{selected:z.unref(u).includes(I)}])},[z.createElementVNode("div",Zx,[z.withDirectives(z.createElementVNode("input",{type:"checkbox","onUpdate:modelValue":$[0]||($[0]=Te=>z.isRef(u)?u.value=Te:null),value:I},null,8,$x),[[z.vModelCheckbox,z.unref(u)]])]),z.createElementVNode("div",Jx,[z.createElementVNode("div",{class:"model-name",title:ie.file.name},z.toDisplayString(ie.file.name),9,Qx),z.createElementVNode("div",eM,[z.createElementVNode("span",tM,z.toDisplayString(y(ie.file.name)),1),z.createElementVNode("span",nM,z.toDisplayString(P(ie.file.size)),1),z.createElementVNode("span",{class:z.normalizeClass(["model-status",ie.status])},z.toDisplayString(N(ie.status)),3)])]),z.createElementVNode("div",iM,[ie.status==="loaded"?(z.openBlock(),z.createElementBlock("button",{key:0,onClick:Te=>le(I),class:"action-icon",title:ie.visible?"隐藏模型":"显示模型"},[(z.openBlock(),z.createElementBlock("svg",rM,[ie.visible?(z.openBlock(),z.createElementBlock("path",aM)):(z.openBlock(),z.createElementBlock("path",oM))]))],8,sM)):z.createCommentVNode("",!0),z.createElementVNode("button",{onClick:Te=>ee(I),class:"action-icon danger",disabled:ie.status==="loading",title:"删除模型"},$[6]||($[6]=[z.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor"},[z.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))])])):z.createCommentVNode("",!0),z.createElementVNode("div",{ref_key:"container",ref:n,class:"three-container"},null,512),i.value?(z.openBlock(),z.createElementBlock("div",cM,[z.createElementVNode("span",null,z.toDisplayString(i.value),1),z.createElementVNode("button",{onClick:$[1]||($[1]=ie=>i.value=""),class:"btn-close"},"×")])):z.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:{operatingForm:{type:Object,default:()=>{}},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=z.ref([]),r=At.useMenuState(),{activeMenuPath:a}=At.storeToRefs(r),o=Vu.useModelComp(ur.pinia),{extraContents:l}=At.storeToRefs(o),c=z.ref([]),u=z.ref(!1),h=z.ref("");z.ref();const d=z.ref(!0),f=z.ref(0),g=z.ref(!1),_=z.ref(""),m=z.ref(!1),p=z.ref({label:"查看三维模型"}),S=z.ref([]),v=z.ref([]),y=z.ref(!1),N=z.ref([]),P=z.ref([]),L=z.ref(),U=z.ref(),E=zh(ur.pinia),T=z.ref(),D=Vh(ur.pinia),{selectIndex:X,selectMenu:q,selectTitle:se}=At.storeToRefs(D),{selectString:he}=At.storeToRefs(E),k=z.ref(720),oe=()=>{m.value=!1},G=Y=>{n("clickTrigger",Y)},fe=(Y,J)=>{if(Object.values(J).length!==0)return Object.values(J).find($=>{var ie,I;return((ie=$==null?void 0:$.toString())==null?void 0:ie.includes(".obj"))||((I=$==null?void 0:$.toString())==null?void 0:I.includes(".stl"))})?[...Y,p.value]:Y},ve=Y=>{var I;he.value===""?Y==null||Y[0]:(Y==null?void 0:Y.find(Te=>(Te==null?void 0:Te.selectLabel)==="("+he.value+")"))??(Y==null||Y.find(Te=>!(Te!=null&&Te.selectLabel)));let J=Y;(I=i.value)!=null&&I.find(Te=>Te.prop==="index");let $=L.value;const ie=[];return J==null||J.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=$==null?void 0:$[tt])!=null&&Nt.prop&&!Array.isArray(Ie)){let pe={};pe[$[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[$[tt].prop]=Oe!=null&&Oe.find(ne=>{var ze;return((ze=Object.keys(ne))==null?void 0:ze[0])===$[tt].column})?(ce=Oe==null?void 0:Oe.find(ne=>{var ze;return((ze=Object.keys(ne))==null?void 0:ze[0])===$[tt].column}))==null?void 0:ce[$[tt].column]:Ie:qe[$[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 Y=>{var I,Te,de,qe,De;let J={};for(let Oe in Y)Y[Oe]!==""&&(J["tableData."+Oe]=Y[Oe]);const $=await PM({type:"data",tableId:t==null?void 0:t.index,systemKey:sessionStorage.getItem("systemKey"),pageKey:a.value},J),ie=(de=(Te=(I=Ke.cloneDeep($))==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 Y=>{var $,ie,I,Te,de,qe,De;let J=await qh(a.value,sessionStorage.getItem("systemKey"),Y.id);if(J=J==null?void 0:J.filter(Oe=>Oe.comp!=="methodButton"),J&&J.length>0){const Oe=!Array.isArray(se.value)&&(($=se.value)==null?void 0:$.key)!=="main"?[]:se.value;Oe.push({key:q.value===""?(ie=Y==null?void 0:Y.id)==null?void 0:ie.toString():q.value+"-"+((I=Y==null?void 0:Y.id)==null?void 0:I.toString()),value:Y[(Te=Object.keys(Y))==null?void 0:Te.filter(Ie=>Ie!=="index"&&Ie!=="id")[0]]}),D.setSelectMenu(q.value===""?(de=Y==null?void 0:Y.id)==null?void 0:de.toString():q.value+"-"+((qe=Y==null?void 0:Y.id)==null?void 0:qe.toString())),D.setSelectTitle(Oe),D.setSelectIndex((De=Y==null?void 0:Y.id)==null?void 0:De.toString()),n("pageChange",J)}},Me=Y=>{var J;(J=Ke.cloneDeep(t.itemData))==null||J.map($=>(($==null?void 0:$.key)==="tableContents"&&($.contents=Y),$))},W=(Y,J,$)=>{n("contentClick",Y,J,$,{id:t==null?void 0:t.index})};z.watch(()=>t.changedContent,()=>{var $,ie;if(!t.changedContent)return;let Y=($=c.value)==null?void 0:$.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 J=(ie=t.itemData)==null?void 0:ie.map(I=>((I==null?void 0:I.key)==="tableContents"&&(I.contents=Y),I));c.value=Y,n("contentChange",{contents:J,index:t.index}),n("change",{content:Y,index:t==null?void 0:t.index,buttonName:"",id:t==null?void 0:t.index})},{deep:!0,immediate:!0});const ee=(Y,J)=>{var $;if(h.value="",y.value=!0,d.value=!0,n("onButtonClick",Y,J),Y==="删除"){c.value=($=Ke.cloneDeep(c.value))==null?void 0:$.filter(I=>(I==null?void 0:I.id)!==(J==null?void 0:J.id));const ie=hM(T.value,q.value,J==null?void 0:J.id);Me(ie),n("change",{content:c.value,singleContent:J,index:t==null?void 0:t.index,type:"delete",buttonName:Y,column:i.value})}else Y==="新增"?(_.value="新增",re(""),m.value=!0):Y==="编辑"?(_.value="编辑",re(J),m.value=!0):Y==="查看"?(_.value="查看",re(J),y.value=!1,d.value=!1,m.value=!0):Y==="查看三维模型"&&(u.value=!0)},ae=()=>{u.value=!1},re=Y=>{var ie,I,Te;const J=[];let $=[];for(let de in Y)Array.isArray(Y==null?void 0:Y[de])&&$.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)=>{$.find(De=>De===(de==null?void 0:de.prop))||J.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:(Y==null?void 0:Y[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})}),Y===""||!Y||(h.value=Y==null?void 0:Y.id),P.value=S.value&&((Te=S.value)==null?void 0:Te.length)>0?S.value:J};z.onMounted(()=>{});const Se=()=>{let Y,J=Ke.cloneDeep(c.value);h.value===""?(f.value++,J.push(Object.assign(U.value,{id:f.value})),Y=Object.assign(U.value,{id:f.value})):J=J==null?void 0:J.map(ie=>((ie==null?void 0:ie.id)===h.value&&(ie=Object.assign(ie,U.value),Y=ie),ie)),c.value=J;const $=fM(T.value,q.value,J);Me($),m.value=!1,n("change",{content:$,singleContent:Y,index:t==null?void 0:t.index,buttonName:_.value,column:i.value})},ot=Y=>{U.value=Y,n("onFormChange",Y)};return z.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 Y=(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 J=(Ie=Ke.cloneDeep(t.itemData))==null?void 0:Ie.find(j=>(j==null?void 0:j.key)==="page"),$=(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=(J==null?void 0:J.contents)??!1;let de=[];he.value===""?de=Y==null?void 0:Y[0]:de=(Y==null?void 0:Y.find(j=>(j==null?void 0:j.selectLabel)==="("+he.value+")"))??(Y==null?void 0:Y.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=$==null?void 0:$.contents)==null?void 0:ge.length)>0?v.value=$==null?void 0:$.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}),z.watch(()=>t==null?void 0:t.operatingForm,Y=>{Y!=null&&Y.form&&(re(Y==null?void 0:Y.form),_.value=Y==null?void 0:Y.dialogTitle,y.value=!0,m.value=!0)},{immediate:!0,deep:!0}),(Y,J)=>{var $;return z.openBlock(),z.createElementBlock("div",DM,[(z.openBlock(),z.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:J[1]||(J[1]=ie=>ee(ie,"")),onContentClick:W},z.createSlots({headerButton:z.withCtx(ie=>[z.createVNode(Id,{buttons:ie.buttons,onButtonClick:J[0]||(J[0]=I=>ee(I,"")),columns:i.value,onFilter:le},null,8,["buttons","columns"])]),_:2},[(($=v.value)==null?void 0:$.length)>0?{name:"actions",fn:z.withCtx(({item:ie})=>[(z.openBlock(!0),z.createElementBlock(z.Fragment,null,z.renderList(fe(v.value,ie),(I,Te)=>(z.openBlock(),z.createElementBlock("div",{key:Te},[z.createElementVNode("div",{style:z.normalizeStyle({color:I==null?void 0:I.textColor}),class:"extra-button-label",onClick:de=>ee(I==null?void 0:I.label,ie)},z.toDisplayString(I==null?void 0:I.label),13,IM)]))),128))]),key:"0"}:void 0]),1032,["columns","tableData","isShowPagination","extraButton"])),z.createVNode(zn.ssDialog,{title:_.value,visible:m.value,width:k.value,onBeforeDestroy:oe},{default:z.withCtx(()=>[z.createElementVNode("div",NM,[z.createVNode(zn.ssForm,{rowContents:P.value,isEnableWrap:!1,onChange:ot,onClickTrigger:G,isEdit:d.value},null,8,["rowContents","isEdit"])])]),footer:z.withCtx(()=>[y.value?(z.openBlock(),z.createElementBlock("div",UM,[z.createElementVNode("div",{onClick:J[2]||(J[2]=ie=>m.value=!1),class:"cancel-button"},z.toDisplayString("取消")),z.createElementVNode("div",{class:"ok-button",onClick:Se},z.toDisplayString("确认"))])):z.createCommentVNode("",!0)]),_:1},8,["title","visible","width"]),z.createVNode(zn.ssDialog,{visible:u.value,fullScreen:"",onBeforeDestroy:ae},{default:z.withCtx(()=>[z.createVNode(Bh,{isShow:u.value},null,8,["isShow"])]),_:1},8,["visible"])])}}},OM=Rl._export_sfc(FM,[["__scopeId","data-v-8259afc8"]]);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;
|